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;
1191 return (
int)
GETPOST($paramname,
'int', $method,
null,
null, 0);
1223function GETPOSTDATE($prefix, $hourTime =
'', $gm =
'auto', $saverestore =
'')
1226 if ($hourTime ===
'getpost' || $hourTime ===
'getpostend') {
1227 $hour = (GETPOSTISSET($prefix .
'hour') &&
GETPOSTINT($prefix .
'hour') >= 0) ?
GETPOSTINT($prefix .
'hour') : ($hourTime ===
'getpostend' ? 23 : 0);
1228 $minute = (GETPOSTISSET($prefix .
'min') &&
GETPOSTINT($prefix .
'min') >= 0) ?
GETPOSTINT($prefix .
'min') : ($hourTime ===
'getpostend' ? 59 : 0);
1229 $second = (GETPOSTISSET($prefix .
'sec') &&
GETPOSTINT($prefix .
'sec') >= 0) ?
GETPOSTINT($prefix .
'sec') : ($hourTime ===
'getpostend' ? 59 : 0);
1230 } elseif (preg_match(
'/^(\d\d):(\d\d):(\d\d)$/', $hourTime, $m)) {
1231 $hour = intval($m[1]);
1232 $minute = intval($m[2]);
1233 $second = intval($m[3]);
1234 } elseif ($hourTime ===
'end') {
1239 $hour = $minute = $second = 0;
1244 && !GETPOSTISSET($prefix .
'day')
1245 && !GETPOSTISSET($prefix .
'month')
1246 && !GETPOSTISSET($prefix .
'year')
1247 && isset($_SESSION[
'DOLDATE_' . $saverestore .
'_day'])
1248 && isset($_SESSION[
'DOLDATE_' . $saverestore .
'_month'])
1249 && isset($_SESSION[
'DOLDATE_' . $saverestore .
'_year'])
1251 $day = $_SESSION[
'DOLDATE_'.$saverestore.
'_day'];
1252 $month = $_SESSION[
'DOLDATE_'.$saverestore.
'_month'];
1253 $year = $_SESSION[
'DOLDATE_'.$saverestore.
'_year'];
1261 $hour = (int) min($hour, 23);
1262 $minute = (int) min($minute, 59);
1263 $second = (int) min($second, 59);
1266 $_SESSION[
'DOLDATE_'.$saverestore.
'_day'] = $day;
1267 $_SESSION[
'DOLDATE_'.$saverestore.
'_month'] = $month;
1268 $_SESSION[
'DOLDATE_'.$saverestore.
'_year'] = $year;
1272 return dol_mktime($hour, $minute, $second, $month, $day, $year, $gm);
1286function checkVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1288 return sanitizeVal($out, $check, $filter, $options);
1300function sanitizeVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1304 if ($out ===
null) {
1312 if (!is_numeric($out)) {
1317 if (is_array($out)) {
1318 $out = implode(
',', $out);
1320 if (preg_match(
'/[^0-9,-]+/i', $out)) {
1325 $out = filter_var($out, FILTER_SANITIZE_STRING);
1328 $out = filter_var($out, FILTER_SANITIZE_EMAIL);
1332 $out = preg_replace(
'/[^:\/\[\]a-z0-9@\$\'\*\~\.\-_,;\?\!=%&+#]+/i',
'', $out);
1336 if (!is_array($out)) {
1338 if (preg_match(
'/[^a-z]+/i', $out)) {
1344 if (!is_array($out)) {
1346 if (preg_match(
'/[^a-z0-9_\-\.]+/i', $out)) {
1352 if (!is_array($out)) {
1354 if (preg_match(
'/[^a-z0-9_\-\.@]+/i', $out)) {
1360 if (!is_array($out)) {
1362 if (preg_match(
'/[^a-z0-9_\-\.,]+/i', $out)) {
1369 if (!is_array($out)) {
1372 $oldstringtoclean = $out;
1376 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1383 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1384 }
while ($oldstringtoclean != $out);
1388 case 'alphawithlgt':
1389 if (!is_array($out)) {
1392 $oldstringtoclean = $out;
1396 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1403 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1404 }
while ($oldstringtoclean != $out);
1410 case 'restricthtmlnolink':
1411 case 'restricthtml':
1412 case 'restricthtmlallowclass':
1413 case 'restricthtmlallowiframe':
1414 case 'restricthtmlallowlinkscript':
1415 case 'restricthtmlallowunvalid':
1420 if (empty($filter)) {
1421 return 'BadParameterForGETPOST - Param 3 of sanitizeVal()';
1423 if (is_null($options)) {
1426 $out = filter_var($out, $filter, $options);
1430 dol_syslog(
"Error, you call sanitizeVal() with a bad value for the check type. Data will be sanitized with alphanohtml.", LOG_ERR);
1431 $out =
GETPOST($out,
'alphanohtml');
1446function dolSetCookie(
string $cookiename,
string $cookievalue,
int $expire = -1)
1448 global $dolibarr_main_force_https;
1450 if ($expire == -1) {
1451 $expire = (time() + (86400 * 354));
1454 if (PHP_VERSION_ID < 70300) {
1455 setcookie($cookiename, empty($cookievalue) ?
'' : $cookievalue, empty($cookievalue) ? 0 : $expire,
'/',
'', !(empty($dolibarr_main_force_https) &&
isHTTPS() === false), true);
1458 $cookieparams = array(
1459 'expires' => empty($cookievalue) ? 0 : $expire,
1462 'secure' => !(empty($dolibarr_main_force_https) &&
isHTTPS() === false),
1466 setcookie($cookiename, empty($cookievalue) ?
'' : $cookievalue, $cookieparams);
1468 if (empty($cookievalue)) {
1469 unset($_COOKIE[$cookiename]);
1473if (!function_exists(
'dol_getprefix')) {
1484 function dol_getprefix($mode =
'')
1487 if ($mode ==
'email') {
1493 } elseif (isset($_SERVER[
"SERVER_NAME"])) {
1494 return $_SERVER[
"SERVER_NAME"];
1499 if (!empty(
$conf->file->instance_unique_id)) {
1500 return sha1(
'dolibarr'.
$conf->file->instance_unique_id);
1504 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1508 global $dolibarr_main_instance_unique_id, $dolibarr_main_cookie_cryptkey;
1509 $tmp_instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ?
'' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
1512 if (!empty($tmp_instance_unique_id)) {
1513 return sha1(
'dolibarr'.$tmp_instance_unique_id);
1517 if (isset($_SERVER[
"SERVER_NAME"]) && isset($_SERVER[
"DOCUMENT_ROOT"])) {
1518 return sha1($_SERVER[
"SERVER_NAME"].$_SERVER[
"DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1520 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1537 global
$conf, $langs, $user, $mysoc;
1541 if (!file_exists($fullpath)) {
1542 dol_syslog(
'functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_WARNING);
1545 if (!empty($classname) && !class_exists($classname)) {
1546 return include $fullpath;
1548 return include_once $fullpath;
1566function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
1570 $path = preg_replace(
'/^\//',
'', $path);
1573 $res = DOL_DOCUMENT_ROOT.
'/'.$path;
1574 if (is_array(
$conf->file->dol_document_root)) {
1575 foreach (
$conf->file->dol_document_root as $key => $dirroot) {
1576 if ($key ==
'main') {
1580 if (@file_exists($dirroot.
'/'.$path)) {
1581 $res = $dirroot.
'/'.$path;
1586 if ($returnemptyifnotfound) {
1588 if ($returnemptyifnotfound == 1 || !file_exists($res)) {
1600 $res = DOL_URL_ROOT.
'/'.$path;
1603 $res = DOL_MAIN_URL_ROOT.
'/'.$path;
1606 $res = DOL_URL_ROOT.
'/'.$path;
1609 foreach (
$conf->file->dol_document_root as $key => $dirroot) {
1610 if ($key ==
'main') {
1615 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$conf->file->dol_main_url_root));
1616 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1619 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
'/'.$path;
1624 preg_match(
'/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);
1625 if (!empty($regs[1])) {
1628 if (@file_exists($dirroot.
'/'.$regs[1])) {
1630 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : DOL_URL_ROOT).
$conf->file->dol_url_root[$key].
'/'.$path;
1631 } elseif ($type == 2) {
1632 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : DOL_MAIN_URL_ROOT).
$conf->file->dol_url_root[$key].
'/'.$path;
1633 } elseif ($type == 3) {
1637 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$conf->file->dol_main_url_root));
1638 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1641 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
$conf->file->dol_url_root[$key].
'/'.$path;
1665 if (empty($properties)) {
1666 return get_object_vars($obj);
1669 $existingProperties = [];
1670 $realProperties = get_object_vars($obj);
1673 foreach ($properties as $property) {
1674 if (array_key_exists($property, $realProperties)) {
1676 $existingProperties[$property] = $obj->{$property};
1677 } elseif (property_exists($obj, $property)) {
1679 $existingProperties[$property] = $obj->{$property};
1683 return $existingProperties;
1712 $myclone = unserialize(serialize(
$object));
1714 if (!empty($tmpsavdb)) {
1717 } elseif ($native == 2) {
1720 $tmparray = get_object_vars(
$object);
1722 if (is_array($tmparray)) {
1723 foreach ($tmparray as $propertykey => $propertyval) {
1724 if (is_scalar($propertyval) || is_array($propertyval)) {
1725 $myclone->$propertykey = $propertyval;
1745function dol_size($size, $type =
'')
1748 if (empty(
$conf->dol_optimize_smallscreen)) {
1751 if ($type ==
'width' && $size > 250) {
1777 $filesystem_forbidden_chars = array(
'<',
'>',
'/',
'\\',
'?',
'*',
'|',
'"',
':',
'°',
'$',
';',
'`');
1778 if ($includequotes) {
1779 $filesystem_forbidden_chars[] =
"'";
1782 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1783 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1784 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1785 $tmp = str_replace(
'..',
'', $tmp);
1786 $tmp = preg_replace(
'/\s{2,}/',
' ', $tmp);
1808 $filesystem_forbidden_chars = array(
'<',
'>',
'?',
'*',
'|',
'"',
'°',
'$',
';',
'`');
1815 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1816 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1817 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1818 $tmp = str_replace(
'..',
'', $tmp);
1819 $tmp = preg_replace(
'/\s{2,}/',
' ', $tmp);
1835 $stringtoclean = preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $stringtoclean);
1837 $stringtoclean = preg_replace(
'/<!--[^>]*-->/',
'', $stringtoclean);
1839 $stringtoclean = str_replace(
'\\',
'/', $stringtoclean);
1843 $stringtoclean = str_replace(array(
':',
';',
'@'),
'', $stringtoclean);
1847 $oldstringtoclean = $stringtoclean;
1850 $stringtoclean = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $stringtoclean);
1851 }
while ($oldstringtoclean != $stringtoclean);
1855 $stringtoclean = preg_replace(array(
'/^[a-z]*\/\/+/i'),
'', $stringtoclean);
1858 return $stringtoclean;
1870 $oldstringtoclean = $stringtoclean;
1871 $stringtoclean = str_ireplace(array(
'"',
':',
'[',
']',
"\n",
"\r",
'\\',
'\/'),
'', $stringtoclean);
1872 }
while ($oldstringtoclean != $stringtoclean);
1874 return $stringtoclean;
1887 return preg_replace(
'/[^\w]+/',
'', $str);
1901 if (is_null($str)) {
1906 if (extension_loaded(
'intl') &&
getDolGlobalString(
'MAIN_UNACCENT_USE_TRANSLITERATOR')) {
1907 $transliterator = Transliterator::createFromRules(
':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', Transliterator::FORWARD);
1908 return $transliterator->transliterate($str);
1911 $string = rawurlencode($str);
1912 $replacements = array(
1913 '%C3%80' =>
'A',
'%C3%81' =>
'A',
'%C3%82' =>
'A',
'%C3%83' =>
'A',
'%C3%84' =>
'A',
'%C3%85' =>
'A',
1915 '%C3%88' =>
'E',
'%C3%89' =>
'E',
'%C3%8A' =>
'E',
'%C3%8B' =>
'E',
1916 '%C3%8C' =>
'I',
'%C3%8D' =>
'I',
'%C3%8E' =>
'I',
'%C3%8F' =>
'I',
1918 '%C3%92' =>
'O',
'%C3%93' =>
'O',
'%C3%94' =>
'O',
'%C3%95' =>
'O',
'%C3%96' =>
'O',
1920 '%C3%99' =>
'U',
'%C3%9A' =>
'U',
'%C3%9B' =>
'U',
'%C3%9C' =>
'U',
1921 '%C3%9D' =>
'Y',
'%C5%B8' =>
'y',
1922 '%C3%A0' =>
'a',
'%C3%A1' =>
'a',
'%C3%A2' =>
'a',
'%C3%A3' =>
'a',
'%C3%A4' =>
'a',
'%C3%A5' =>
'a',
1924 '%C3%A8' =>
'e',
'%C3%A9' =>
'e',
'%C3%AA' =>
'e',
'%C3%AB' =>
'e',
1925 '%C3%AC' =>
'i',
'%C3%AD' =>
'i',
'%C3%AE' =>
'i',
'%C3%AF' =>
'i',
1927 '%C3%B2' =>
'o',
'%C3%B3' =>
'o',
'%C3%B4' =>
'o',
'%C3%B5' =>
'o',
'%C3%B6' =>
'o',
1929 '%C3%B9' =>
'u',
'%C3%BA' =>
'u',
'%C3%BB' =>
'u',
'%C3%BC' =>
'u',
1930 '%C3%BD' =>
'y',
'%C3%BF' =>
'y'
1932 $string = strtr($string, $replacements);
1933 return rawurldecode($string);
1938 "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
1939 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
1940 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
1941 \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
1942 \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
1943 \xF9\xFA\xFB\xFC\xFD\xFF",
1951 $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"));
1969function dol_string_nospecial($str, $newstr =
'_', $badcharstoreplace =
'', $badcharstoremove =
'', $keepspaces = 0)
1971 $forbidden_chars_to_replace = array(
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
",",
";",
"=",
'°',
'$',
';');
1972 if (empty($keepspaces)) {
1973 $forbidden_chars_to_replace[] =
" ";
1975 $forbidden_chars_to_remove = array();
1978 if (is_array($badcharstoreplace)) {
1979 $forbidden_chars_to_replace = $badcharstoreplace;
1981 if (is_array($badcharstoremove)) {
1982 $forbidden_chars_to_remove = $badcharstoremove;
1986 return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove,
"", $str));
2005 if ($removetabcrlf) {
2006 return preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $str);
2008 return preg_replace(
'/[\x00-\x08\x11-\x12\x14-\x1F\x7F]/u',
'', $str);
2023 if (function_exists(
'iconv')) {
2024 $slug = iconv(
'UTF-8',
'ASCII//TRANSLIT//IGNORE', $slug);
2028 $slug = strtolower($slug);
2031 $slug = preg_replace(
'/[^a-z0-9]+/',
'-', $slug);
2034 $slug = trim($slug,
'-');
2047function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0)
2049 if (is_null($stringtoescape)) {
2054 $substitjs = array(
"'" =>
"\\'",
"\r" =>
'\\r');
2056 if (empty($noescapebackslashn)) {
2057 $substitjs[
"\n"] =
'\\n';
2058 $substitjs[
'\\'] =
'\\\\';
2061 $substitjs[
"'"] =
"\\'";
2062 $substitjs[
'"'] =
"\\'";
2063 } elseif ($mode == 1) {
2064 $substitjs[
"'"] =
"\\'";
2065 } elseif ($mode == 2) {
2066 $substitjs[
'"'] =
'\\"';
2067 } elseif ($mode == 3) {
2068 $substitjs[
"'"] =
"\\'";
2069 $substitjs[
'"'] =
"\\\"";
2071 return strtr((
string) $stringtoescape, $substitjs);
2085 return rawurlencode($stringtoescape);
2096 return str_replace(
'"',
'\"', $stringtoescape);
2108 if (is_null($stringtoescape)) {
2112 if ($stringforquotes == 2) {
2113 return str_replace(
'"',
"'", $stringtoescape);
2114 } elseif ($stringforquotes == 1) {
2120 $stringtoescape = str_replace(
'\\',
'', $stringtoescape);
2121 return str_replace(
"'",
"\'", str_replace(
'"',
"'", $stringtoescape));
2124 return 'Bad parameter for stringforquotes in dol_escape_php';
2135 return preg_replace(
'/[^a-z0-9_]/i',
'', $stringtoescape);
2146 return $stringtoescape;
2210 $allowedtags = array(
'br',
'b',
'font',
'hr',
'span');
2211 if (!empty($allowothertags) && is_array($allowothertags)) {
2212 $allowedtags = array_merge($allowedtags, $allowothertags);
2216 if ($escapeonlyhtmltags) {
2217 return dol_escape_htmltag(
dol_string_onlythesehtmltags($s, 1, 0, 0, 0, $allowedtags), 1, -1,
'', 1, 1);
2219 return dol_escape_htmltag(
dol_string_onlythesehtmltags(
dol_htmlentitiesbr($s), 1, 0, 0, 0, $allowedtags), 1, -1,
'', 0, 1);
2235 $escapeonlyhtmltags = 1;
2236 return dol_escape_htmltag(
dol_string_onlythesehtmltags($s, 1, 1, 1, 0, array()), 0, 0,
'', $escapeonlyhtmltags, 1);
2261 return htmlspecialchars($s, ENT_HTML5,
'UTF-8');
2281function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags =
'', $escapeonlyhtmltags = 0, $cleanalsojavascript = 0)
2283 if ($noescapetags ==
'common') {
2284 $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';
2286 $noescapetags .=
',header,footer,nav,section,menu,menuitem';
2288 if ($cleanalsojavascript) {
2293 if ($escapeonlyhtmltags) {
2294 $tmp = htmlspecialchars_decode((
string) $stringtoescape, ENT_COMPAT);
2301 $tmp = (string) $stringtoescape;
2304 $tmp = str_ireplace(
'<',
'__DONOTDECODELT', $tmp);
2305 $tmp = str_ireplace(
'>',
'__DONOTDECODEGT', $tmp);
2306 $tmp = str_ireplace(
'&',
'__DONOTDECODEAMP', $tmp);
2307 $tmp = str_ireplace(
'"',
'__DONOTDECODEQUOT', $tmp);
2308 $tmp = str_ireplace(
'&apos',
'__DONOTDECODEAPOS', $tmp);
2309 $tmp = str_ireplace(
''',
'__DONOTDECODE39', $tmp);
2311 $tmp = html_entity_decode((
string) $tmp, ENT_COMPAT,
'UTF-8');
2314 $tmp = str_ireplace(
'__DONOTDECODELT',
'<', $tmp);
2315 $tmp = str_ireplace(
'__DONOTDECODEGT',
'>', $tmp);
2316 $tmp = str_ireplace(
'__DONOTDECODEAMP',
'&', $tmp);
2317 $tmp = str_ireplace(
'__DONOTDECODEQUOT',
'"', $tmp);
2318 $tmp = str_ireplace(
'__DONOTDECODEAPOS',
'&apos', $tmp);
2319 $tmp = str_ireplace(
'__DONOTDECODE39',
''', $tmp);
2321 $tmp = str_ireplace(
''',
'__SIMPLEQUOTE__', $tmp);
2324 $tmp = strtr($tmp, array(
"<b>" =>
'',
'</b>' =>
'',
'<strong>' =>
'',
'</strong>' =>
''));
2327 $tmp = strtr($tmp, array(
"\r" =>
'\\r',
"\n" =>
'\\n'));
2328 } elseif ($keepn == -1) {
2329 $tmp = strtr($tmp, array(
"\r" =>
'',
"\n" =>
''));
2332 if ($escapeonlyhtmltags) {
2333 $tmp = htmlspecialchars($tmp, ENT_COMPAT,
'UTF-8');
2337 $tmparrayoftags = array();
2338 if ($noescapetags) {
2339 $tmparrayoftags = explode(
',', $noescapetags);
2342 if (count($tmparrayoftags)) {
2347 $tmp = str_ireplace(array(
'__DOUBLEQUOTE',
'__BEGINTAGTOREPLACE',
'__ENDTAGTOREPLACE',
'__BEGINENDTAGTOREPLACE'),
'', $tmp);
2349 foreach ($tmparrayoftags as $tagtoreplace) {
2351 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'>/',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2352 $tmp = str_ireplace(
'</'.$tagtoreplace.
'>',
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2353 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
' \/>/',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2359 if (preg_match(
'/<'.preg_quote($tagtoreplace,
'/').
'(\s+)([^>]+)>/', $tmp, $reg)) {
2361 $tmpattributes = str_ireplace(array(
'[',
']'),
'_', $reg[2]);
2362 $tmpattributes = str_ireplace(
'"',
'__DOUBLEQUOTE__', $tmpattributes);
2363 $tmpattributes = preg_replace(
'/[^a-z0-9_%,\/\?\;\s=&\.\-@:\.#\+]/i',
'', $tmpattributes);
2365 $tmp = str_replace(
'<'.$tagtoreplace.$reg[1].$reg[2].
'>',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'['.$tmpattributes.
']__', $tmp);
2368 $diff = strcmp($tmpold, $tmp);
2372 $tmp = str_ireplace(
'&',
'__ANDNOSEMICOLON__', $tmp);
2373 $tmp = str_ireplace(
'"',
'__DOUBLEQUOTENOSEMICOLON__', $tmp);
2374 $tmp = str_ireplace(
'<',
'__LESSTHAN__', $tmp);
2375 $tmp = str_ireplace(
'>',
'__GREATERTHAN__', $tmp);
2379 $result = htmlentities($tmp, ENT_COMPAT,
'UTF-8');
2383 if (count($tmparrayoftags)) {
2385 foreach ($tmparrayoftags as $tagtoreplace) {
2386 $result = str_ireplace(
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
'>', $result);
2387 $result = preg_replace(
'/__BEGINTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1>', $result);
2388 $result = str_ireplace(
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__',
'</'.$tagtoreplace.
'>', $result);
2389 $result = str_ireplace(
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
' />', $result);
2390 $result = preg_replace(
'/__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1 />', $result);
2393 $result = str_ireplace(
'__DOUBLEQUOTE__',
'"', $result);
2395 $result = str_ireplace(
'__ANDNOSEMICOLON__',
'&', $result);
2396 $result = str_ireplace(
'__DOUBLEQUOTENOSEMICOLON__',
'"', $result);
2397 $result = str_ireplace(
'__LESSTHAN__',
'<', $result);
2398 $result = str_ireplace(
'__GREATERTHAN__',
'>', $result);
2401 $result = str_ireplace(
'__SIMPLEQUOTE__',
''', $result);
2418 if (function_exists(
'mb_strtolower')) {
2419 return mb_strtolower($string, $encoding);
2421 return strtolower($string);
2435 if (function_exists(
'mb_strtoupper')) {
2436 return mb_strtoupper($string, $encoding);
2438 return strtoupper($string);
2452 if (function_exists(
'mb_substr')) {
2453 return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1,
null, $encoding);
2455 return ucfirst($string);
2469 if (function_exists(
'mb_convert_case')) {
2470 return mb_convert_case($string, MB_CASE_TITLE, $encoding);
2472 return ucwords($string);
2484 $backtrace = debug_backtrace();
2486 if (count($backtrace) >= 1) {
2488 if (count($backtrace) == 1) {
2491 $trace = $backtrace[$pos];
2492 if (isset($trace[
'file'], $trace[
'line'])) {
2493 $msg =
" From {$trace['file']}:{$trace['line']}.";
2521function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
'', $restricttologhandler =
'', $logcontext =
null)
2523 global
$conf, $user, $debugbar;
2526 if (!isModEnabled(
'syslog')) {
2531 if (defined(
'USEEXTERNALSERVER') && !defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
2532 global $website, $websitekey;
2533 if (is_object($website) && !empty($website->ref)) {
2534 $suffixinfilename .=
'_website_'.$website->ref;
2535 } elseif (!empty($websitekey)) {
2536 $suffixinfilename .=
'_website_'.$websitekey;
2541 if (defined(
'USESUFFIXINLOG')) {
2542 $suffixinfilename .= constant(
'USESUFFIXINLOG');
2546 foreach (
$conf->loghandlers as $loghandlerinstance) {
2547 $loghandlerinstance->setIdent($ident);
2551 if (!empty($message)) {
2554 $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');
2556 if (!array_key_exists($level, $logLevels)) {
2557 dol_syslog(
'Error Bad Log Level '.$level, LOG_ERR);
2565 $message = preg_replace(
'/password=\'[^\']*\'/',
'password=\'hidden\'', $message);
2569 if ((!empty($_REQUEST[
'logtohtml']) &&
getDolGlobalString(
'MAIN_ENABLE_LOG_TO_HTML'))
2570 || (is_object($user) && $user->hasRight(
'debugbar',
'read') && is_object($debugbar))) {
2571 $ospid = sprintf(
"%7s",
dol_trunc((
string) getmypid(), 7,
'right',
'UTF-8', 1));
2572 $osuser =
" ".sprintf(
"%6s",
dol_trunc(function_exists(
'posix_getuid') ? posix_getuid() :
'', 6,
'right',
'UTF-8', 1));
2574 $conf->logbuffer[] =
dol_print_date(time(),
"%Y-%m-%d %H:%M:%S").
" ".sprintf(
"%-7s", $logLevels[$level]).
" ".$ospid.
" ".$osuser.
" ".$message;
2580 print
"\n\n<!-- Log start\n";
2582 print
"Log end -->\n";
2586 'message' => $message,
2587 'script' => (isset($_SERVER[
'PHP_SELF']) ? basename($_SERVER[
'PHP_SELF'],
'.php') :
''),
2589 'user' => ((is_object($user) && $user->id) ? $user->login :
''),
2591 'osuser' => function_exists(
'posix_getuid') ? (string) posix_getuid() :
'',
2592 'ospid' => (string) getmypid()
2597 if (!empty($remoteip)) {
2598 $data[
'ip'] = $remoteip;
2602 if (!empty($_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
2603 $tmpips = explode(
',', $_SERVER[
'HTTP_X_FORWARDED_FOR']);
2607 foreach ($tmpips as $tmpip) {
2608 $tmpip = trim($tmpip);
2609 if (strtolower($tmpip) == strtolower($remoteip)) {
2612 if (empty($data[
'ip'])) {
2613 $data[
'ip'] = $tmpip;
2616 $data[
'ip'] .= (($j == 1) ?
' [via ' :
',').$tmpip;
2619 if (!$foundremoteip) {
2621 $data[
'ip'] .= (($j == 1) ?
' [via ' :
',').$remoteip;
2623 $data[
'ip'] .= (($j > 0) ?
']' :
'');
2624 } elseif (!empty($_SERVER[
'HTTP_CLIENT_IP'])) {
2625 $tmpips = explode(
',', $_SERVER[
'HTTP_CLIENT_IP']);
2629 foreach ($tmpips as $tmpip) {
2630 $tmpip = trim($tmpip);
2631 if (strtolower($tmpip) == strtolower($remoteip)) {
2634 if (empty($data[
'ip'])) {
2635 $data[
'ip'] = $tmpip;
2638 $data[
'ip'] .= (($j == 1) ?
' [via ' :
',').$tmpip;
2641 if (!$foundremoteip) {
2643 $data[
'ip'] .= (($j == 1) ?
' [via ' :
',').$remoteip;
2645 $data[
'ip'] .= (($j > 0) ?
']' :
'');
2647 } elseif (!empty($_SERVER[
'SERVER_ADDR'])) {
2649 $data[
'ip'] = (string) $_SERVER[
'SERVER_ADDR'];
2650 } elseif (!empty($_SERVER[
'COMPUTERNAME'])) {
2652 $data[
'ip'] = (string) $_SERVER[
'COMPUTERNAME'];
2654 $data[
'ip'] =
'???';
2657 if (!empty($_SERVER[
'USERNAME'])) {
2659 $data[
'osuser'] = (string) $_SERVER[
'USERNAME'];
2660 } elseif (!empty($_SERVER[
'LOGNAME'])) {
2662 $data[
'osuser'] = (string) $_SERVER[
'LOGNAME'];
2666 foreach (
$conf->loghandlers as $loghandlerinstance) {
2667 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
2670 $loghandlerinstance->export($data, $suffixinfilename);
2676 foreach (
$conf->loghandlers as $loghandlerinstance) {
2677 $loghandlerinstance->setIdent($ident);
2697 $form =
new Form($db);
2699 $templatenameforexport = $website->name_template;
2700 if (empty($templatenameforexport)) {
2701 $templatenameforexport =
'website_'.$website->ref;
2705 $out .=
'<input type="button" class="cursorpointer button bordertransp" id="open-dialog-' . $name .
'" value="'.dol_escape_htmltag($buttonstring).
'"/>';
2708 $out .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">';
2709 $out .=
'jQuery(document).ready(function () {';
2710 $out .=
' jQuery("#open-dialog-' . $name .
'").click(function () {';
2711 $out .=
' var dialogHtml = \'';
2713 $dialogcontent =
' <div id="custom-dialog-' . $name .
'">';
2714 $dialogcontent .=
' <div style="margin-top: 20px;">';
2715 $dialogcontent .=
' <label for="export-site-' . $name .
'"><strong>'.$langs->trans(
"ExportSiteLabel").
'...</label><br>';
2716 $dialogcontent .=
' <button class="button smallpaddingimp" id="export-site-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"DownloadZip")) .
'</button>';
2717 $dialogcontent .=
' </div>';
2718 $dialogcontent .=
' <br>';
2719 $dialogcontent .=
' <div style="margin-top: 20px;">';
2720 $dialogcontent .=
' <strong>'.$langs->trans(
"ExportSiteGitLabel").
' '.$form->textwithpicto(
'', $langs->trans(
"SourceFiles"), 1,
'help',
'', 0, 3,
'').
'</strong><br>';
2721 $dialogcontent .=
' <form action="'.dol_escape_htmltag($overwriteGitUrl).
'" method="POST">';
2722 $dialogcontent .=
' <input type="hidden" name="action" value="overwritesite">';
2723 $dialogcontent .=
' <input type="hidden" name="token" value="'.newToken().
'">';
2724 $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>';
2725 $dialogcontent .=
' <button type="submit" class="button smallpaddingimp" id="overwrite-git-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"ExportIntoGIT")) .
'</button>';
2726 $dialogcontent .=
' </form>';
2727 $dialogcontent .=
' </div>';
2728 $dialogcontent .=
' </div>';
2735 // Add the content of the dialog to the body of the page
2736 $out .= ' var $dialog = jQuery(
"#custom-dialog-' . $name . '");
';
2737 $out .= ' if ($dialog.length > 0) {
2740 jQuery(
"body").append(dialogHtml);
';
2742 // Configuration of popup
2743 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog({
';
2744 $out .= ' autoOpen:
false,
';
2745 $out .= ' modal:
true,
';
2746 $out .= ' height: 290,
';
2747 $out .= ' width:
"40%",
';
2748 $out .= ' title:
"' . dol_escape_js($label) . '",
';
2751 // Simulate a click on the original "submit" input to export the site.
2752 $out .= ' jQuery(
"#export-site-' . $name . '").click(
function () {
';
2753 $out .= ' console.log(
"Clic on exportsite.");
';
2754 $out .= ' var target = jQuery(
"input[name=\'' . dol_escape_js($exportSiteName) . '\']");
';
2755 $out .= ' console.log(
"element founded:", target.length > 0);
';
2756 $out .= ' if (target.length > 0) { target.click(); }
';
2757 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"close");
';
2761 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"open");
';
2762 $out .= ' return false;
';
2765 $out .= '</script>
';
2787function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '
', $morecss = 'classlink
button bordertransp
', $jsonopen = '', $jsonclose = '', $accesskey = '')
2791 if (strpos($url, '?
') > 0) {
2792 $url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2794 $url .= '?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2799 //print '<input
type=
"submit" class=
"button bordertransp"'.$disabled.' value=
"'.dol_escape_htmltag($langs->trans("MediaFiles
")).'" name=
"file_manager">
';
2800 $out .= '<!-- a link
for button to open url into a dialog popup -->
';
2801 $out .= '<a
'.($accesskey ? ' accesskey=
"'.$accesskey.'"' : '').' class=
"cursorpointer reposition button_'.$name.($morecss ? ' '.$morecss : '').'"'.$disabled.' title=
"'.dol_escape_htmltag($label).'"';
2802 if (empty($conf->use_javascript_ajax)) {
2803 $out .= ' href=
"'.DOL_URL_ROOT.$url.'" target=
"_blank"';
2804 } elseif ($jsonopen) {
2805 $out .= ' href=
"#" onclick=
"'.$jsonopen.'"';
2807 $out .= ' href=
"#"';
2809 $out .= '>
'.$buttonstring.'</a>
';
2811 if (!empty($conf->use_javascript_ajax)) {
2812 // Add code to open url using the popup.
2813 $out .= '<!-- code to open popup and variables to retrieve returned variables -->
';
2814 $out .= '<div
id=
"idfordialog'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for dialog
' : '').'</div>
';
2816 $out .= '<!-- Add js code to open dialog popup on dialog -->
';
2817 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript">
2818 jQuery(document).ready(
function () {
2819 jQuery(
".button_'.$name.'").click(
function () {
2820 console.log(\
'Open popup with jQuery(...).dialog() on URL '.
dol_escape_js(DOL_URL_ROOT.$url).
'\');
2821 var $tmpdialog = $(\
'#idfordialog'.$name.
'\');
2822 $tmpdialog.html(\
'<iframe class="iframedialog" id="iframedialog'.$name.
'" style="border: 0px;" src="'.DOL_URL_ROOT.$url.
'" width="100%" height="98%"></iframe>\');
2826 height: (window.innerHeight - 150),
2829 open: function (event, ui) {
2830 console.log(
"open popup name='.$name.'");
2832 close:
function (event, ui) {
2833 console.log(
"Popup is closed, run jsonclose = '.$jsonclose.'");
2834 '.(empty($jsonclose) ? '' : $jsonclose.';
').'
2838 $tmpdialog.dialog(\
'open\');
2863function dol_fiche_head($links = array(), $active =
'0', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
2865 print
dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow, $moretabssuffix);
2885function dol_get_fiche_head($links = array(), $active =
'', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'', $dragdropfile = 0, $morecssdiv =
'')
2887 global
$conf, $langs, $hookmanager;
2891 if (!empty(
$conf->dol_optimize_smallscreen)) {
2895 $out =
"\n".
'<!-- dol_fiche_head - dol_get_fiche_head -->';
2897 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2898 $out .=
'<div class="tabs'.($picto ?
'' :
' nopaddingleft').
'" data-role="controlgroup" data-type="horizontal">'.
"\n";
2902 if ($morehtmlright) {
2903 $out .=
'<div class="inline-block floatright tabsElem">'.$morehtmlright.
'</div>';
2910 if (is_array($links) && !empty($links)) {
2911 $keys = array_keys($links);
2913 $maxkey = max($keys);
2919 if (empty($limittoshow)) {
2922 if (!empty(
$conf->dol_optimize_smallscreen)) {
2930 for ($i = 0; $i <= $maxkey; $i++) {
2931 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2933 if ($i >= $limittoshow) {
2939 for ($i = 0; $i <= $maxkey; $i++) {
2940 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2946 if ($i < $limittoshow || $isactive) {
2948 $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])).
' -->';
2950 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2951 if (!empty($links[$i][0])) {
2952 $out .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2954 $out .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2956 } elseif (!empty($links[$i][1])) {
2958 $out .=
'<div class="tab tab'.($isactive ?
'active' :
'unactive').
'" style="margin: 0 !important">';
2960 if (!empty($links[$i][0])) {
2961 $titletoshow = preg_replace(
'/<.*$/',
'', $links[$i][1]);
2962 $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).
'">';
2965 if ($displaytab == 0 && $picto) {
2966 $out .=
img_picto($title, $picto,
'', $pictoisfullpath, 0, 0,
'',
'imgTabTitle paddingright marginrightonlyshort');
2969 $out .= $links[$i][1];
2970 if (!empty($links[$i][0])) {
2971 $out .=
'</a>'.
"\n";
2973 $out .= empty($links[$i][4]) ?
'' : $links[$i][4];
2982 $outmore .=
'<div class="popuptabset wordwrap">';
2984 $outmore_content =
'';
2986 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2987 if (!empty($links[$i][0])) {
2988 $outmore_content .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2990 $outmore_content .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2992 } elseif (!empty($links[$i][1])) {
2993 $outmore_content .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="wordwrap inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
2994 $outmore_content .= preg_replace(
'/([a-z])\|([a-z])/i',
'\\1 | \\2', $links[$i][1]);
2995 $outmore_content .=
'</a>'.
"\n";
2997 if ($outmore_content !==
'') {
2998 $outmore .=
'<div class="popuptab wordwrap" style="display:inherit;">' . $outmore_content .
'</div>';
3004 $displaytab = $i + 1;
3007 $outmore .=
'</div>';
3011 $left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
3012 $right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
3013 $widthofpopup = 240;
3015 $tabsname = $moretabssuffix;
3016 if (empty($tabsname)) {
3017 $tabsname = str_replace(
"@",
"", $picto);
3019 $out .=
'<div id="moretabs'.$tabsname.
'" class="inline-block tabsElem valignmiddle">';
3021 $out .=
'<div class="tab valignmiddle"><a href="#" class="tab moretab inline-block tabunactive valignmiddle"><span class="hideonsmartphone">'.$langs->trans(
"More").
'</span>... ('.$nbintab.
')</a></div>';
3023 $out .=
'<div id="moretabsList'.$tabsname.
'" style="width: '.$widthofpopup.
'px; position: absolute; '.$left.
': -999em; text-align: '.$left.
'; margin:0px; padding:2px; z-index:10;">';
3026 $out .=
'<div></div>';
3029 $out .=
'<script nonce="'.getNonce().
'">';
3030 $out .=
"$('#moretabs".$tabsname.
"').mouseenter( function() {
3031 var x = this.offsetLeft, y = this.offsetTop;
3032 console.log('mouseenter ".$left.
" x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
3033 if ((window.innerWidth - x) < ".($widthofpopup + 10).
") {
3034 $('#moretabsList".$tabsname.
"').css('".$right.
"','8px');
3036 $('#moretabsList".$tabsname.
"').css('".$left.
"','auto');
3039 $out .=
"$('#moretabs".$tabsname.
"').mouseleave( function() { console.log('mouseleave ".$left.
"'); $('#moretabsList".$tabsname.
"').css('".$left.
"','-999em');});";
3040 $out .=
"</script>";
3043 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
3047 if (!$notab || $notab == -1 || $notab == -2 || $notab == -3 || $notab == -4) {
3048 $out .=
"\n".
'<div id="dragDropAreaTabBar" class="tabBar'.($notab == -1 ?
'' : ($notab == -2 ?
' tabBarNoTop' : ((($notab == -3 || $notab == -4) ?
' noborderbottom' :
'').($notab == -4 ?
'' :
' tabBarWithBottom'))));
3049 $out .= ($morecssdiv ?
' '.$morecssdiv :
'');
3052 if (!empty($dragdropfile)) {
3053 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
3056 $parameters = array(
'tabname' => $active,
'out' => $out);
3057 $reshook = $hookmanager->executeHooks(
'printTabsHead', $parameters);
3059 $out = $hookmanager->resPrint;
3085 if (!$notab || $notab == -1) {
3086 return "\n</div>\n";
3111function dol_banner_tab(
$object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $onlybanner = 0, $morehtmlright =
'')
3113 global
$conf, $form, $user, $langs, $hookmanager, $action;
3117 $maxvisiblephotos = 1;
3121 $showbarcode = !isModEnabled(
'barcode') ? 0 : (empty(
$object->barcode) ? 0 : 1);
3122 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
3125 $modulepart =
'unknown';
3127 if (in_array(
$object->element, [
'societe',
'contact',
'product',
'ticket',
'bom'])) {
3128 $modulepart =
$object->element;
3129 } elseif (
$object->element ==
'member') {
3130 $modulepart =
'memberphoto';
3131 } elseif (
$object->element ==
'user') {
3132 $modulepart =
'userphoto';
3135 if (class_exists(
"Imagick")) {
3136 if (
$object->element ==
'expensereport' ||
$object->element ==
'propal' ||
$object->element ==
'commande' ||
$object->element ==
'facture' ||
$object->element ==
'supplier_proposal') {
3137 $modulepart =
$object->element;
3138 } elseif (
$object->element ==
'fichinter' ||
$object->element ==
'intervention') {
3139 $modulepart =
'ficheinter';
3140 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
3141 $modulepart =
'contract';
3142 } elseif (
$object->element ==
'order_supplier') {
3143 $modulepart =
'supplier_order';
3144 } elseif (
$object->element ==
'invoice_supplier') {
3145 $modulepart =
'supplier_invoice';
3149 if (
$object->element ==
'product') {
3151 '@phan-var-force Product $object';
3153 $cssclass =
'photowithmargin photoref';
3154 $showimage =
$object->is_photo_available(
$conf->product->multidir_output[$entity]);
3156 if (
$conf->browser->layout ==
'phone') {
3157 $maxvisiblephotos = 1;
3160 $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>';
3164 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
3166 $nophoto =
'/public/theme/common/nophoto.png';
3167 $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>';
3170 } elseif (
$object->element ==
'category') {
3172 '@phan-var-force Categorie $object';
3174 $cssclass =
'photowithmargin photoref';
3175 $showimage =
$object->isAnyPhotoAvailable(
$conf->categorie->multidir_output[$entity]);
3177 if (
$conf->browser->layout ==
'phone') {
3178 $maxvisiblephotos = 1;
3181 $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>';
3185 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
3187 $nophoto =
'/public/theme/common/nophoto.png';
3188 $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>';
3191 } elseif (
$object->element ==
'bom') {
3193 '@phan-var-force Bom $object';
3195 $cssclass =
'photowithmargin photoref';
3196 $showimage =
$object->is_photo_available(
$conf->bom->multidir_output[$entity]);
3198 if (
$conf->browser->layout ==
'phone') {
3199 $maxvisiblephotos = 1;
3202 $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>';
3206 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
3208 $nophoto =
'/public/theme/common/nophoto.png';
3209 $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>';
3212 } elseif (
$object->element ==
'ticket') {
3214 $cssclass =
'photoref';
3216 '@phan-var-force Ticket $object';
3217 $showimage =
$object->is_photo_available(
$conf->ticket->multidir_output[$entity].
'/'.
$object->ref);
3219 if (
$conf->browser->layout ==
'phone') {
3220 $maxvisiblephotos = 1;
3224 $showphoto =
$object->show_photos(
'ticket',
$conf->ticket->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0);
3226 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$showphoto.
'</div>';
3234 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
3236 $nophoto =
img_picto(
'No photo',
'object_ticket');
3237 $morehtmlleft .=
'<!-- No photo to show -->';
3238 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
3239 $morehtmlleft .= $nophoto;
3240 $morehtmlleft .=
'</div></div>';
3245 if ($modulepart !=
'unknown' || method_exists(
$object,
'getDataToShowPhoto')) {
3248 if (in_array($modulepart, array(
'propal',
'commande',
'facture',
'ficheinter',
'contract',
'supplier_order',
'supplier_proposal',
'supplier_invoice',
'expensereport')) && class_exists(
"Imagick")) {
3250 $dir_output = (empty(
$conf->$modulepart->multidir_output[$entity]) ?
$conf->$modulepart->dir_output :
$conf->$modulepart->multidir_output[$entity]).
"/";
3251 if (in_array($modulepart, array(
'invoice_supplier',
'supplier_invoice'))) {
3253 $subdir .= ((!empty($subdir) && !preg_match(
'/\/$/', $subdir)) ?
'/' :
'').$objectref;
3257 if (empty($subdir)) {
3258 $subdir =
'errorgettingsubdirofobject';
3261 $filepath = $dir_output.$subdir.
"/";
3263 $filepdf = $filepath.$objectref.
".pdf";
3264 $relativepath = $subdir.
'/'.$objectref.
'.pdf';
3267 $fileimage = $filepdf.
'_preview.png';
3268 $relativepathimage = $relativepath.
'_preview.png';
3270 $pdfexists = file_exists($filepdf);
3275 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
3277 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
3286 if ($pdfexists && !$error) {
3287 $heightforphotref = 80;
3288 if (!empty(
$conf->dol_optimize_smallscreen)) {
3289 $heightforphotref = 60;
3292 if (file_exists($fileimage)) {
3293 $phototoshow =
'<div class="photoref">';
3294 $phototoshow .=
'<img height="'.$heightforphotref.
'" class="photo photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
3295 $phototoshow .=
'</div>';
3298 } elseif (!$phototoshow) {
3299 $phototoshow .= $form->showphoto($modulepart,
$object, 0, 0, 0,
'photowithmargin photoref',
'small', 1, 0);
3303 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
3304 $morehtmlleft .= $phototoshow;
3305 $morehtmlleft .=
'</div>';
3309 if (empty($phototoshow)) {
3310 if (
$object->element ==
'action') {
3312 $cssclass =
'photorefcenter';
3313 $nophoto =
img_picto(
'No photo',
'title_agenda');
3316 $cssclass =
'photorefcenter';
3318 $prefix =
'object_';
3322 if (strpos($picto,
'fontawesome_') !==
false) {
3325 $nophoto =
img_picto(
'No photo', $prefix.$picto);
3327 $morehtmlleft .=
'<!-- No photo to show -->';
3328 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
3329 $morehtmlleft .= $nophoto;
3330 $morehtmlleft .=
'</div></div>';
3337 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode(
$object, 100,
'photoref valignmiddle').
'</div>';
3340 if (
$object->element ==
'societe') {
3341 if (!empty(
$conf->use_javascript_ajax) && $user->hasRight(
'societe',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3344 $morehtmlstatus .=
$object->getLibStatut(6);
3346 } elseif (
$object->element ==
'product') {
3348 if (!empty(
$conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3349 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
3351 $morehtmlstatus .=
'<span class="statusrefsell">'.$object->getLibStatut(6, 0).
'</span>';
3353 $morehtmlstatus .=
' ';
3355 if (!empty(
$conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3356 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
3358 $morehtmlstatus .=
'<span class="statusrefbuy">'.$object->getLibStatut(6, 1).
'</span>';
3360 } elseif (in_array(
$object->element, array(
'salary'))) {
3361 '@phan-var-force Salary $object';
3363 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3366 $morehtmlstatus .= $tmptxt;
3367 } elseif (in_array(
$object->element, array(
'facture',
'invoice',
'invoice_supplier'))) {
3368 '@phan-var-force Facture|FactureFournisseur|CommonInvoice $object';
3369 $totalallpayments =
$object->getSommePaiement(0);
3370 $totalallpayments +=
$object->getSumCreditNotesUsed(0);
3371 $totalallpayments +=
$object->getSumDepositsUsed(0);
3372 $tmptxt =
$object->getLibStatut(6, $totalallpayments);
3373 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3374 $tmptxt =
$object->getLibStatut(5, $totalallpayments);
3376 $morehtmlstatus .= $tmptxt;
3377 } elseif (in_array(
$object->element, array(
'chargesociales',
'loan',
'tva'))) {
3378 '@phan-var-force ChargeSociales|Loan|Tva $object';
3380 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3383 $morehtmlstatus .= $tmptxt;
3384 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
3386 $morehtmlstatus .=
$object->getLibStatut(5);
3388 $morehtmlstatus .=
$object->getLibStatut(4);
3390 } elseif (
$object->element ==
'facturerec') {
3391 '@phan-var-force FactureRec $object';
3392 if (
$object->frequency == 0) {
3393 $morehtmlstatus .=
$object->getLibStatut(2);
3395 $morehtmlstatus .=
$object->getLibStatut(5);
3397 } elseif (
$object->element ==
'project_task') {
3398 $tmptxt =
$object->getLibStatut(4);
3399 $morehtmlstatus .= $tmptxt;
3400 } elseif (method_exists(
$object,
'getLibStatut')) {
3401 $tmptxt =
$object->getLibStatut(6);
3402 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3403 $tmptxt =
$object->getLibStatut(5);
3405 $morehtmlstatus .= $tmptxt;
3409 if (isModEnabled(
'accounting') && in_array(
$object->element, array(
'bank',
'paiementcharge',
'facture',
'invoice',
'invoice_supplier',
'expensereport',
'payment_various'))) {
3411 if (method_exists(
$object,
'getVentilExportCompta')) {
3412 $accounted =
$object->getVentilExportCompta(1);
3413 $langs->load(
"accountancy");
3414 $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>';
3419 if (!empty(
$object->name_alias)) {
3420 '@phan-var-force Societe $object';
3421 $morehtmlref .=
'<div class="refidno opacitymedium">'.dol_escape_htmltag(
$object->name_alias).
'</div>';
3425 if (in_array(
$object->element, array(
'product',
'bank_account',
'project_task'))) {
3427 $morehtmlref .=
'<div class="refidno opacitymedium">'.$object->label.
'</div>';
3431 if (method_exists(
$object,
'getBannerAddress') && !in_array(
$object->element, array(
'product',
'bookmark',
'ecm_directories',
'ecm_files'))) {
3434 $morehtmlref .=
'<div class="refidno refaddress">';
3435 $morehtmlref .= $moreaddress;
3436 $morehtmlref .=
'</div>';
3440 $morehtmlref .=
'<div style="clear: both;"></div>';
3441 $morehtmlref .=
'<div class="refidno opacitymedium">';
3442 $morehtmlref .= $langs->trans(
"TechnicalID").
': '.((int)
$object->id);
3443 $morehtmlref .=
'</div>';
3446 $parameters = array(
'morehtmlref' => &$morehtmlref,
'moreparam' => &$moreparam,
'morehtmlleft' => &$morehtmlleft,
'morehtmlstatus' => &$morehtmlstatus,
'morehtmlright' => &$morehtmlright);
3447 $reshook = $hookmanager->executeHooks(
'formDolBanner', $parameters,
$object, $action);
3450 } elseif (empty($reshook)) {
3451 $morehtmlref .= $hookmanager->resPrint;
3452 } elseif ($reshook > 0) {
3453 $morehtmlref = $hookmanager->resPrint;
3461 print
'<div class="'.($onlybanner ?
'arearefnobottom ' :
'arearef ').
'heightref valignmiddle centpercent">';
3462 print $form->showrefnav(
$object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
3464 print
'<div class="underrefbanner clearboth"></div>';
3476function fieldLabel($langkey, $fieldkey, $fieldrequired = 0)
3480 if ($fieldrequired) {
3481 $ret .=
'<span class="fieldrequired">';
3483 $ret .=
'<label for="'.$fieldkey.
'">';
3484 $ret .= $langs->trans($langkey);
3486 if ($fieldrequired) {
3507 global $langs, $hookmanager;
3510 $countriesusingstate = array(
'AU',
'CA',
'US',
'IN',
'GB',
'ES',
'UK',
'TR',
'CN');
3515 $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)));
3518 if (isset(
$object->country_code) && in_array(
$object->country_code, array(
'AU',
'CA',
'US',
'CN')) ||
getDolGlobalString(
'MAIN_FORCE_STATE_INTO_ADDRESS')) {
3520 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3521 $ret .= (($ret && $town) ? $sep :
'').$town;
3524 $ret .= ($ret ? ($town ?
", " : $sep) :
'').
$object->state;
3527 $ret .= ($ret ? (($town ||
$object->state) ?
", " : $sep) :
'').
$object->zip;
3529 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'GB',
'UK'))) {
3531 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3532 $ret .= ($ret ? $sep :
'').$town;
3534 $ret .= ($ret ?
", " :
'').
$object->state;
3537 $ret .= ($ret ? $sep :
'').
$object->zip;
3539 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'ES',
'TR'))) {
3541 $ret .= ($ret ? $sep :
'').
$object->zip;
3542 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3543 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3545 $ret .= $sep.$object->state;
3547 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'JP'))) {
3550 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3552 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'IT'))) {
3554 $ret .= ($ret ? $sep :
'').
$object->zip;
3555 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3556 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3557 $ret .= (empty(
$object->state_code) ?
'' : (
' '.$object->state_code));
3560 $town = (($extralangcode && !empty(
$object->array_languages[
'address'][$extralangcode])) ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3561 $ret .= !empty(
$object->zip) ? (($ret ? $sep :
'').
$object->zip) :
'';
3562 $ret .= ($town ? ((
$object->zip ?
' ' : ($ret ? $sep :
'')).$town) :
'');
3563 if (!empty(
$object->state) && in_array(
$object->country_code, $countriesusingstate)) {
3564 $ret .= ($ret ?
", " :
'').
$object->state;
3568 if (!is_object($outputlangs)) {
3569 $outputlangs = $langs;
3572 $langs->load(
"dict");
3573 $ret .= (empty(
$object->country_code) ?
'' : ($ret ? $sep :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$object->country_code)));
3576 $parameters = array(
'withcountry' => $withcountry,
'sep' => $sep,
'outputlangs' => $outputlangs,
'mode' => $mode,
'extralangcode' => $extralangcode);
3577 $reshook = $hookmanager->executeHooks(
'formatAddress', $parameters,
$object);
3581 $ret .= $hookmanager->resPrint;
3598function dol_strftime($fmt, $ts =
false, $is_gmt =
false)
3600 if ((abs($ts) <= 0x7FFFFFFF)) {
3603 return 'Error date outside supported range';
3628function dol_print_date($time, $format =
'', $tzoutput =
'auto', $outputlangs =
null, $encodetooutput =
false)
3630 global
$conf, $langs;
3637 if ($tzoutput ===
'auto') {
3638 $tzoutput = (empty(
$conf) ?
'tzserver' : (isset(
$conf->tzuserinputkey) ?
$conf->tzuserinputkey :
'tzserver'));
3643 $offsettz = $offsetdst = 0;
3646 if (is_string($tzoutput)) {
3647 if ($tzoutput ==
'tzserver') {
3649 $offsettzstring = @date_default_timezone_get();
3654 } elseif ($tzoutput ==
'tzuser' || $tzoutput ==
'tzuserrel') {
3656 $offsettzstring = (empty($_SESSION[
'dol_tz_string']) ?
'UTC' : $_SESSION[
'dol_tz_string']);
3658 if (class_exists(
'DateTimeZone')) {
3659 $user_date_tz =
new DateTimeZone($offsettzstring);
3660 $user_dt =
new DateTime();
3661 $user_dt->setTimezone($user_date_tz);
3662 $user_dt->setTimestamp($tzoutput ==
'tzuser' ?
dol_now() : (int) $time);
3663 $offsettz = $user_dt->getOffset();
3665 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3666 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3671 if (!is_object($outputlangs)) {
3672 $outputlangs = $langs;
3675 $format =
'daytextshort';
3680 $reduceformat = (!empty(
$conf->dol_optimize_smallscreen) && in_array($format, array(
'day',
'dayhour',
'dayhoursec'))) ? 1 : 0;
3681 $format = preg_replace(
'/inputnoreduce/',
'', $format);
3682 $formatwithoutreduce = preg_replace(
'/reduceformat/',
'', $format);
3683 if ($formatwithoutreduce != $format) {
3684 $format = $formatwithoutreduce;
3690 if ($format ==
'day') {
3691 $format = ($outputlangs->trans(
"FormatDateShort") !=
"FormatDateShort" ? $outputlangs->trans(
"FormatDateShort") :
$conf->format_date_short);
3692 } elseif ($format ==
'hour') {
3693 $format = ($outputlangs->trans(
"FormatHourShort") !=
"FormatHourShort" ? $outputlangs->trans(
"FormatHourShort") :
$conf->format_hour_short);
3694 } elseif ($format ==
'hourduration') {
3695 $format = ($outputlangs->trans(
"FormatHourShortDuration") !=
"FormatHourShortDuration" ? $outputlangs->trans(
"FormatHourShortDuration") :
$conf->format_hour_short_duration);
3696 } elseif ($format ==
'daytext') {
3697 $format = ($outputlangs->trans(
"FormatDateText") !=
"FormatDateText" ? $outputlangs->trans(
"FormatDateText") :
$conf->format_date_text);
3698 } elseif ($format ==
'daytextshort') {
3699 $format = ($outputlangs->trans(
"FormatDateTextShort") !=
"FormatDateTextShort" ? $outputlangs->trans(
"FormatDateTextShort") :
$conf->format_date_text_short);
3700 } elseif ($format ==
'dayhour') {
3701 $format = ($outputlangs->trans(
"FormatDateHourShort") !=
"FormatDateHourShort" ? $outputlangs->trans(
"FormatDateHourShort") :
$conf->format_date_hour_short);
3702 } elseif ($format ==
'dayhoursec') {
3703 $format = ($outputlangs->trans(
"FormatDateHourSecShort") !=
"FormatDateHourSecShort" ? $outputlangs->trans(
"FormatDateHourSecShort") :
$conf->format_date_hour_sec_short);
3704 } elseif ($format ==
'dayhourtext') {
3705 $format = ($outputlangs->trans(
"FormatDateHourText") !=
"FormatDateHourText" ? $outputlangs->trans(
"FormatDateHourText") :
$conf->format_date_hour_text);
3706 } elseif ($format ==
'dayhourtextshort') {
3707 $format = ($outputlangs->trans(
"FormatDateHourTextShort") !=
"FormatDateHourTextShort" ? $outputlangs->trans(
"FormatDateHourTextShort") :
$conf->format_date_hour_text_short);
3708 } elseif ($format ==
'dayhourlog') {
3710 $format =
'%Y%m%d%H%M%S';
3711 } elseif ($format ==
'dayhourlogsmall') {
3713 $format =
'%y%m%d%H%M';
3714 } elseif ($format ==
'dayhourldap') {
3715 $format =
'%Y%m%d%H%M%SZ';
3716 } elseif ($format ==
'dayhourxcard') {
3717 $format =
'%Y%m%dT%H%M%SZ';
3718 } elseif ($format ==
'dayxcard') {
3720 } elseif ($format ==
'dayrfc') {
3721 $format =
'%Y-%m-%d';
3722 } elseif ($format ==
'dayhourrfc') {
3723 $format =
'%Y-%m-%dT%H:%M:%SZ';
3724 } elseif ($format ==
'standard') {
3725 $format =
'%Y-%m-%d %H:%M:%S';
3728 if ($reduceformat) {
3729 $format = str_replace(
'%Y',
'%y', $format);
3730 $format = str_replace(
'yyyy',
'yy', $format);
3734 if (preg_match(
'/%b/i', $format)) {
3736 $format = str_replace(
'%b',
'__b__', $format);
3737 $format = str_replace(
'%B',
'__B__', $format);
3739 if (preg_match(
'/%a/i', $format)) {
3741 $format = str_replace(
'%a',
'__a__', $format);
3742 $format = str_replace(
'%A',
'__A__', $format);
3747 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)) {
3748 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"]));
3750 } elseif (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', (
string) $time, $reg)) {
3752 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);
3755 $syear = (!empty($reg[1]) ? $reg[1] :
'');
3756 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
3757 $sday = (!empty($reg[3]) ? $reg[3] :
'');
3758 $shour = (!empty($reg[4]) ? $reg[4] :
'');
3759 $smin = (!empty($reg[5]) ? $reg[5] :
'');
3760 $ssec = (!empty($reg[6]) ? $reg[6] :
'');
3762 $time =
dol_mktime((
int) $shour, (
int) $smin, (
int) $ssec, (
int) $smonth, (
int) $sday, (
int) $syear,
true);
3765 $tzo =
new DateTimeZone(
'UTC');
3767 $tzo =
new DateTimeZone(date_default_timezone_get());
3769 $dtts =
new DateTime();
3770 $dtts->setTimestamp($time);
3771 $dtts->setTimezone($tzo);
3772 $newformat = str_replace(
3773 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3774 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3777 $ret = $dtts->format($newformat);
3779 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3780 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3785 if ($time < 100000000000) {
3786 $timetouse = $time + $offsettz + $offsetdst;
3789 $tzo =
new DateTimeZone(
'UTC');
3791 $tzo =
new DateTimeZone(date_default_timezone_get());
3793 $dtts =
new DateTime();
3794 $dtts->setTimestamp($timetouse);
3795 $dtts->setTimezone($tzo);
3796 $newformat = str_replace(
3797 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'%w',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3798 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'w',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3801 $ret = $dtts->format($newformat);
3803 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3804 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3809 $ret =
'Bad value '.$time.
' for date';
3813 if (preg_match(
'/__b__/i', $format)) {
3814 $timetouse = $time + $offsettz + $offsetdst;
3817 $tzo =
new DateTimeZone(
'UTC');
3819 $tzo =
new DateTimeZone(date_default_timezone_get());
3821 $dtts =
new DateTime();
3822 $dtts->setTimestamp($timetouse);
3823 $dtts->setTimezone($tzo);
3824 $month = (int) $dtts->format(
"m");
3825 $month = sprintf(
"%02d", $month);
3826 if ($encodetooutput) {
3827 $monthtext = $outputlangs->transnoentities(
'Month'.$month);
3828 $monthtextshort = $outputlangs->transnoentities(
'MonthShort'.$month);
3830 $monthtext = $outputlangs->transnoentitiesnoconv(
'Month'.$month);
3831 $monthtextshort = $outputlangs->transnoentitiesnoconv(
'MonthShort'.$month);
3834 $ret = str_replace(
'__b__', $monthtextshort, $ret);
3835 $ret = str_replace(
'__B__', $monthtext, $ret);
3839 if (preg_match(
'/__a__/i', $format)) {
3841 $timetouse = $time + $offsettz + $offsetdst;
3844 $tzo =
new DateTimeZone(
'UTC');
3846 $tzo =
new DateTimeZone(date_default_timezone_get());
3848 $dtts =
new DateTime();
3849 $dtts->setTimestamp($timetouse);
3850 $dtts->setTimezone($tzo);
3851 $w = $dtts->format(
"w");
3852 $dayweek = $outputlangs->transnoentitiesnoconv(
'Day'.$w);
3854 $ret = str_replace(
'__A__', $dayweek, $ret);
3855 $ret = str_replace(
'__a__',
dol_substr($dayweek, 0, 3), $ret);
3882function dol_getdate($timestamp, $fast =
false, $forcetimezone =
'')
3884 if ($timestamp ===
'') {
3888 $datetimeobj =
new DateTime();
3889 $datetimeobj->setTimestamp($timestamp);
3890 if ($forcetimezone) {
3891 $datetimeobj->setTimezone(
new DateTimeZone($forcetimezone ==
'gmt' ?
'UTC' : $forcetimezone));
3894 'year' => ((
int) date_format($datetimeobj,
'Y')),
3895 'mon' => ((
int) date_format($datetimeobj,
'm')),
3896 'mday' => ((
int) date_format($datetimeobj,
'd')),
3897 'wday' => ((
int) date_format($datetimeobj,
'w')),
3898 'yday' => ((
int) date_format($datetimeobj,
'z')),
3899 'hours' => ((
int) date_format($datetimeobj,
'H')),
3900 'minutes' => ((
int) date_format($datetimeobj,
'i')),
3901 'seconds' => ((
int) date_format($datetimeobj,
's')),
3929function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm =
'auto', $check = 1)
3934 if ($gm ===
'auto') {
3935 $gm = (empty(
$conf) ?
'tzserver' :
$conf->tzuserinputkey);
3940 if ($hour == -1 || empty($hour)) {
3943 if ($minute == -1 || empty($minute)) {
3946 if ($second == -1 || empty($second)) {
3952 if (!$month || !$day) {
3961 if ($hour < 0 || $hour > 24) {
3964 if ($minute < 0 || $minute > 60) {
3967 if ($second < 0 || $second > 60) {
3972 if (empty($gm) || ($gm ===
'server' || $gm ===
'tzserver')) {
3973 $default_timezone = @date_default_timezone_get();
3974 $localtz =
new DateTimeZone($default_timezone);
3975 } elseif ($gm ===
'user' || $gm ===
'tzuser' || $gm ===
'tzuserrel') {
3977 $default_timezone = (empty($_SESSION[
"dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION[
"dol_tz_string"]);
3979 $localtz =
new DateTimeZone($default_timezone);
3981 dol_syslog(
"Warning dol_tz_string contains an invalid value ".json_encode($_SESSION[
"dol_tz_string"] ??
null), LOG_WARNING);
3982 $default_timezone = @date_default_timezone_get();
3984 } elseif (strrpos($gm,
"tz,") !==
false) {
3985 $timezone = str_replace(
"tz,",
"", $gm);
3987 $localtz =
new DateTimeZone($timezone);
3989 dol_syslog(
"Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
3993 if (empty($localtz)) {
3994 $localtz =
new DateTimeZone(
'UTC');
3998 $dt =
new DateTime(
'now', $localtz);
3999 $dt->setDate((
int) $year, (
int) $month, (
int) $day);
4000 $dt->setTime((
int) $hour, (
int) $minute, (
int) $second);
4001 $date = $dt->getTimestamp();
4017function dol_now($mode =
'auto')
4021 if ($mode ===
'auto') {
4025 if ($mode ==
'gmt') {
4027 } elseif ($mode ==
'tzserver') {
4028 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
4030 $ret = (int) (
dol_now(
'gmt') + ($tzsecond * 3600));
4036 } elseif ($mode ==
'tzuser' || $mode ==
'tzuserrel') {
4039 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
4040 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
4041 $ret = (int) (
dol_now(
'gmt') + ($offsettz + $offsetdst));
4058 global
$conf, $langs;
4061 if (!empty(
$conf->dol_optimize_smallscreen)) {
4066 if (empty($shortvalue) || $size < ($level * 10)) {
4068 $textunitshort = $langs->trans(
"b");
4069 $textunitlong = $langs->trans(
"Bytes");
4071 $ret = round($size / $level, 0);
4072 $textunitshort = $langs->trans(
"Kb");
4073 $textunitlong = $langs->trans(
"KiloBytes");
4076 if (empty($shortunit)) {
4077 $ret .=
' '.$textunitlong;
4079 $ret .=
' '.$textunitshort;
4095function dol_print_url($url, $target =
'_blank', $max = 32, $withpicto = 0, $morecss =
'')
4103 $linkstart =
'<a href="';
4104 if (!preg_match(
'/^http/i', $url)) {
4105 $linkstart .=
'http://';
4110 $linkstart .=
' target="'.$target.
'"';
4112 $linkstart .=
' title="'.$langs->trans(
"URL").
': '.$url.
'"';
4116 if (!preg_match(
'/^http/i', $url)) {
4123 if ($morecss ==
'float') {
4124 return '<div class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe',
'class="paddingrightonly"') :
'').$link.
'</div>';
4126 return $linkstart.
'<span class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto(
'',
'globe',
'class="paddingrightonly"') :
'').$link.
'</span>'.$linkend;
4143function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0, $morecss =
'paddingrightonly')
4145 global $user, $langs, $hookmanager;
4156 if (empty($email)) {
4160 if ($addlink == 1) {
4161 $newemail =
'<a class="'.($morecss ? $morecss :
'').
'" style="text-overflow: ellipsis;" href="';
4162 if (!preg_match(
'/^mailto:/i', $email)) {
4163 $newemail .=
'mailto:';
4165 $newemail .= $email;
4166 $newemail .=
'" target="_blank">';
4168 $newemail .= ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'');
4173 $newemail .= $email;
4175 $newemail .=
'</a>';
4177 $langs->load(
"errors");
4178 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email),
'',
'paddingrightonly');
4181 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
4183 $linktoaddaction =
'';
4185 $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>';
4187 if ($linktoaddaction) {
4188 $newemail =
'<div>'.$newemail.
' '.$linktoaddaction.
'</div>';
4191 } elseif ($addlink ===
'thirdparty') {
4192 $tmpnewemail =
'<a class="'.($morecss ? $morecss :
'').
'" style="text-overflow: ellipsis;" href="'.DOL_URL_ROOT.
'/societe/card.php?socid='.$socid.
'&action=presend&mode=init#formmailbeforetitle">';
4193 $tmpnewemail .= ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'');
4194 if ($withpicto == 1) {
4195 $tmpnewemail .= $newemail;
4197 $tmpnewemail .=
'</a>';
4199 $newemail = $tmpnewemail;
4201 $newemail = ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'').$newemail;
4204 $langs->load(
"errors");
4205 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
4215 $parameters = array(
'cid' => $cid,
'socid' => $socid,
'addlink' => $addlink,
'picto' => $withpicto);
4217 $reshook = $hookmanager->executeHooks(
'printEmail', $parameters, $email);
4221 $rep .= $hookmanager->resPrint;
4236 $socialnetworks = array();
4238 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
4239 $cachekey =
'socialnetworks_' .
$conf->entity;
4241 if (!is_null($dataretrieved)) {
4242 $socialnetworks = $dataretrieved;
4244 $sql =
"SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX.
"c_socialnetworks";
4245 $sql .=
" WHERE entity=".$conf->entity;
4246 $resql = $db->query($sql);
4248 while ($obj = $db->fetch_object($resql)) {
4249 $socialnetworks[$obj->code] = array(
4250 'rowid' => $obj->rowid,
4251 'label' => $obj->label,
4253 'icon' => $obj->icon,
4254 'active' => $obj->active,
4260 return $socialnetworks;
4275 global $hookmanager, $langs, $user;
4279 if (empty($value)) {
4283 if (!empty($type)) {
4284 $htmllink =
'<div class="divsocialnetwork inline-block valignmiddle">';
4286 $htmllink .=
'<span class="fab pictofixedwidth ' . ($dictsocialnetworks[$type][
'icon'] ? $dictsocialnetworks[$type][
'icon'] :
'fa-link') .
'"></span>';
4287 if ($type ==
'skype') {
4289 $htmllink .=
' <a href="skype:';
4291 $htmllink .=
'?call" alt="' . $langs->trans(
"Call") .
' ' . $value .
'" title="' .
dol_escape_htmltag($langs->trans(
"Call") .
' ' . $value) .
'">';
4292 $htmllink .=
'<img src="' . DOL_URL_ROOT .
'/theme/common/skype_callbutton.png" border="0">';
4293 $htmllink .=
'</a><a href="skype:';
4295 $htmllink .=
'?chat" alt="' . $langs->trans(
"Chat") .
' ' . $value .
'" title="' .
dol_escape_htmltag($langs->trans(
"Chat") .
' ' . $value) .
'">';
4296 $htmllink .=
'<img class="paddingleft" src="' . DOL_URL_ROOT .
'/theme/common/skype_chatbutton.png" border="0">';
4297 $htmllink .=
'</a>';
4298 if (($contactid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
4299 $addlink =
'AC_SKYPE';
4302 $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>';
4304 $htmllink .= ($link ?
' ' . $link :
'');
4307 if (!empty($dictsocialnetworks[$type][
'url'])) {
4308 $tmpvirginurl = preg_replace(
'/\/?{socialid}/',
'', $dictsocialnetworks[$type][
'url']);
4309 if ($tmpvirginurl) {
4310 $value = preg_replace(
'/^www\.' . preg_quote($tmpvirginurl,
'/') .
'\/?/',
'', $value);
4311 $value = preg_replace(
'/^' . preg_quote($tmpvirginurl,
'/') .
'\/?/',
'', $value);
4313 $tmpvirginurl3 = preg_replace(
'/^https:\/\//i',
'https://www.', $tmpvirginurl);
4314 if ($tmpvirginurl3) {
4315 $value = preg_replace(
'/^www\.' . preg_quote($tmpvirginurl3,
'/') .
'\/?/',
'', $value);
4316 $value = preg_replace(
'/^' . preg_quote($tmpvirginurl3,
'/') .
'\/?/',
'', $value);
4319 $tmpvirginurl2 = preg_replace(
'/^https?:\/\//i',
'', $tmpvirginurl);
4320 if ($tmpvirginurl2) {
4321 $value = preg_replace(
'/^www\.' . preg_quote($tmpvirginurl2,
'/') .
'\/?/',
'', $value);
4322 $value = preg_replace(
'/^' . preg_quote($tmpvirginurl2,
'/') .
'\/?/',
'', $value);
4325 if (preg_match(
'/^https?:\/\//i', $value)) {
4328 $link = str_replace(
'{socialid}', $value, $dictsocialnetworks[$type][
'url']);
4330 $valuetoshow = $value;
4331 $valuetoshow = preg_replace(
'/https:\/\/www\.(twitter|x|linkedin)\.com\/?/',
'', $valuetoshow);
4332 if (preg_match(
'/^https?:\/\//i', $link)) {
4341 $htmllink .=
'</div>';
4343 $langs->load(
"errors");
4344 $htmllink .=
img_warning($langs->trans(
"ErrorBadSocialNetworkValue", $value));
4348 $parameters = array(
4350 'cid' => $contactid,
4353 'dictsocialnetworks' => $dictsocialnetworks,
4356 $reshook = $hookmanager->executeHooks(
'printSocialNetworks', $parameters);
4360 $htmllink .= $hookmanager->resPrint;
4375function dol_print_profids($profID, $profIDtype, $countrycode =
'', $addcpButton = 1)
4379 if (empty($profID) || empty($profIDtype)) {
4382 if (empty($countrycode)) {
4383 $countrycode = $mysoc->country_code;
4385 $newProfID = $profID;
4386 $id = substr($profIDtype, -1);
4388 if (strtoupper($countrycode) ==
'FR') {
4394 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3);
4398 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3).
' '.substr($newProfID, 9, 5);
4402 $newProfID = substr($newProfID, 0, 2).
'.'.substr($newProfID, 2, 3);
4404 if ($profIDtype ===
'VAT' &&
dol_strlen($newProfID) == 13) {
4406 $newProfID = substr($newProfID, 0, 4).
' '.substr($newProfID, 4, 3).
' '.substr($newProfID, 7, 3).
' '.substr($newProfID, 10, 3);
4409 if (!empty($addcpButton)) {
4432function dol_print_phone($phone, $countrycode =
'', $cid = 0, $socid = 0, $addlink =
'', $separ =
" ", $withpicto =
'', $titlealt =
'', $adddivfloat = 0, $morecss =
'paddingright')
4434 global
$conf, $user, $langs, $mysoc, $hookmanager;
4437 $phone = is_null($phone) ?
'' : preg_replace(
"/[\s.-]/",
"", trim($phone));
4438 if (empty($phone)) {
4444 if (empty($countrycode) && is_object($mysoc)) {
4445 $countrycode = $mysoc->country_code;
4449 if (!empty(
$conf->dol_optimize_smallscreen) && $separ !=
'hidenum') {
4454 $newphonewa = $phone;
4455 if (strtoupper($countrycode) ==
"FR") {
4458 $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);
4460 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
4462 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
4464 $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);
4466 $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);
4468 $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);
4470 } elseif (strtoupper($countrycode) ==
"CA") {
4472 $newphone = ($separ !=
'' ?
'(' :
'').substr($newphone, 0, 3).($separ !=
'' ?
')' :
'').$separ.substr($newphone, 3, 3).($separ !=
'' ?
'-' :
'').substr($newphone, 6, 4);
4474 } elseif (strtoupper($countrycode) ==
"PT") {
4476 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4478 } elseif (strtoupper($countrycode) ==
"SR") {
4480 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
4482 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
4484 } elseif (strtoupper($countrycode) ==
"DE") {
4486 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
4488 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
4490 } elseif (strtoupper($countrycode) ==
"ES") {
4492 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4494 } elseif (strtoupper($countrycode) ==
"BF") {
4496 $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);
4498 } elseif (strtoupper($countrycode) ==
"RO") {
4500 $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);
4502 } elseif (strtoupper($countrycode) ==
"TR") {
4504 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4506 } elseif (strtoupper($countrycode) ==
"US") {
4508 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4510 } elseif (strtoupper($countrycode) ==
"MX") {
4512 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4514 $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);
4516 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4518 } elseif (strtoupper($countrycode) ==
"ML") {
4520 $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);
4522 } elseif (strtoupper($countrycode) ==
"TH") {
4524 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4526 $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);
4528 } elseif (strtoupper($countrycode) ==
"MU") {
4531 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
4533 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4535 } elseif (strtoupper($countrycode) ==
"ZA") {
4537 $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);
4539 } elseif (strtoupper($countrycode) ==
"SY") {
4541 $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);
4543 $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);
4545 } elseif (strtoupper($countrycode) ==
"AE") {
4547 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4549 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4551 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
4553 } elseif (strtoupper($countrycode) ==
"DZ") {
4555 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4557 } elseif (strtoupper($countrycode) ==
"BE") {
4559 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4561 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4563 } elseif (strtoupper($countrycode) ==
"PF") {
4565 $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);
4567 } elseif (strtoupper($countrycode) ==
"CO") {
4569 $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);
4571 } elseif (strtoupper($countrycode) ==
"JO") {
4573 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 1).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
4575 } elseif (strtoupper($countrycode) ==
"JM") {
4577 $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4579 } elseif (strtoupper($countrycode) ==
"MG") {
4581 $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);
4583 } elseif (strtoupper($countrycode) ==
"GB") {
4585 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4587 } elseif (strtoupper($countrycode) ==
"CH") {
4589 $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);
4591 $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);
4593 } elseif (strtoupper($countrycode) ==
"TN") {
4595 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4597 } elseif (strtoupper($countrycode) ==
"GF") {
4599 $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);
4601 } elseif (strtoupper($countrycode) ==
"GP") {
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) ==
"MQ") {
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) ==
"IT") {
4611 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4613 $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);
4615 } elseif (strtoupper($countrycode) ==
"AU") {
4619 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
4621 } elseif (strtoupper($countrycode) ==
"LU") {
4624 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
4626 $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);
4628 $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);
4630 $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);
4632 } elseif (strtoupper($countrycode) ==
"PE") {
4635 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4);
4637 $newphonewa =
'+51'.$newphone;
4638 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 10, 3);
4640 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 8, 4);
4642 $newphonewa = $newphone;
4643 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 10, 3).$separ.substr($newphone, 14, 3);
4645 } elseif (strtoupper($countrycode) ==
"IN") {
4647 if ($withpicto ==
'phone') {
4648 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 4).$separ.substr($newphone, 9, 4);
4650 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 5).$separ.substr($newphone, 8, 5);
4655 $newphoneastart = $newphoneaend =
'';
4656 if (!empty($addlink)) {
4657 if ($addlink ==
'tel' ||
$conf->browser->layout ==
'phone' || (isModEnabled(
'clicktodial') &&
getDolGlobalString(
'CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS'))) {
4658 $newphoneastart =
'<a href="tel:'.urlencode($phone).
'">';
4659 $newphoneaend .=
'</a>';
4660 } elseif (isModEnabled(
'clicktodial') && $addlink ==
'AC_TEL') {
4661 if (empty($user->clicktodial_loaded)) {
4662 $user->fetch_clicktodial();
4666 $urlmask =
getDolGlobalString(
'CLICKTODIAL_URL',
'ErrorClickToDialModuleNotConfigured');
4667 if (!empty($user->clicktodial_url)) {
4668 $urlmask = $user->clicktodial_url;
4671 $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) :
'');
4672 $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) :
'');
4673 $clicktodial_password = (!empty($user->clicktodial_password) ? urlencode($user->clicktodial_password) :
'');
4675 $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
4677 $substitarray = array(
'__PHONEFROM__' => $clicktodial_poste,
4678 '__PHONETO__' => urlencode($phone),
4679 '__LOGIN__' => $clicktodial_login,
4680 '__PASS__' => $clicktodial_password);
4684 $newphoneastart =
'<a href="'.$url.
'" class="cssforclicktodial">';
4685 $newphoneaend =
'</a>';
4688 $newphoneastart =
'<a href="'.$url.
'"';
4690 $newphoneastart .=
' target="_blank" rel="noopener noreferrer"';
4692 $newphoneastart .=
'>';
4693 $newphoneaend .=
'</a>';
4698 if (isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
4700 $addlinktoagenda =
'';
4701 if ($addlink ==
'AC_FAX') {
4705 $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>';
4707 if ($addlinktoagenda) {
4708 $newphone =
'<span>'.$newphone.
' '.$addlinktoagenda.
'</span>';
4713 if (
getDolGlobalString(
'CONTACT_PHONEMOBILE_SHOW_LINK_TO_WHATSAPP') && $withpicto ==
'mobile') {
4715 $newphone .=
' <a href="https://wa.me/'.$newphonewa.
'" target="_blank"';
4716 $newphone .=
'><span class="paddingright fab fa-whatsapp" style="color:#25D366;" title="WhatsApp"></span></a>';
4719 if (empty($titlealt)) {
4720 $titlealt = ($withpicto ==
'fax' ? $langs->trans(
"Fax") : $langs->trans(
"Phone"));
4725 $parameters = array(
'countrycode' => $countrycode,
'cid' => $cid,
'socid' => $socid,
'titlealt' => $titlealt,
'picto' => $withpicto);
4726 $reshook = $hookmanager->executeHooks(
'printPhone', $parameters, $phone);
4727 $rep .= $hookmanager->resPrint;
4729 if (empty($reshook)) {
4732 if ($withpicto ==
'fax') {
4733 $picto =
'phoning_fax';
4734 } elseif ($withpicto ==
'phone') {
4736 } elseif ($withpicto ==
'mobile') {
4737 $picto =
'phoning_mobile';
4742 if ($adddivfloat == 1) {
4743 $rep .=
'<div class="nospan float'.($morecss ?
' '.$morecss :
'').
'">';
4744 } elseif (empty($adddivfloat)) {
4745 $rep .=
'<span'.($morecss ?
' class="'.$morecss.
'"' :
'').
'>';
4748 $rep .= $newphoneastart;
4749 $rep .= ($withpicto ?
img_picto($titlealt,
'object_'.$picto.
'.png') :
'');
4750 if ($separ !=
'hidenum') {
4751 $rep .= ($withpicto ?
' ' :
'').$newphone;
4753 $rep .= $newphoneaend;
4755 if ($adddivfloat == 1) {
4757 } elseif (empty($adddivfloat)) {
4778 if (!isset(
$conf->cache[
'resolveips'])) {
4779 $conf->cache[
'resolveips'] = array();
4785 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/common/flags/'.$countrycode.
'.png')) {
4789 $ret .=
'('.$countrycode.
')';
4797 if (in_array($mode, [0, 2])) {
4800 if (!array_key_exists($ip,
$conf->cache[
'resolveips'])) {
4801 $domain = gethostbyaddr($ip);
4802 $conf->cache[
'resolveips'][$ip] = $domain;
4804 $domain =
$conf->cache[
'resolveips'][$ip];
4832 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
4839 if (empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) || preg_match(
'/[^0-9\.\:,\[\]\s]/', $_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
4840 if (empty($_SERVER[
'HTTP_CLIENT_IP']) || preg_match(
'/[^0-9\.\:,\[\]\s]/', $_SERVER[
'HTTP_CLIENT_IP'])) {
4841 if (empty($_SERVER[
"HTTP_CF_CONNECTING_IP"])) {
4842 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
4844 $ip = $_SERVER[
"HTTP_CF_CONNECTING_IP"];
4847 $ip = preg_replace(
'/,.*$/',
'', $_SERVER[
'HTTP_CLIENT_IP']);
4850 $ip = preg_replace(
'/,.*$/',
'', $_SERVER[
'HTTP_X_FORWARDED_FOR']);
4866 if (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on') {
4868 } 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') {
4884 if (isModEnabled(
'geoipmaxmind')) {
4890 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4891 $geoip =
new DolGeoIP(
'country', $datafile);
4893 $countrycode = $geoip->getCountryCodeFromIP($ip);
4900 return $countrycode;
4912 global
$conf, $langs, $user;
4916 if (isModEnabled(
'geoipmaxmind')) {
4921 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4922 $geoip =
new DolGeoIP(
'country', $datafile);
4923 $countrycode = $geoip->getCountryCodeFromIP($ip);
4924 $ret = $countrycode;
4943 global $hookmanager;
4949 $parameters = array(
'element' => $element,
'id' =>
$id);
4950 $reshook = $hookmanager->executeHooks(
'printAddress', $parameters, $address);
4951 $out .= $hookmanager->resPrint;
4953 if (empty($reshook)) {
4954 if (empty($charfornl)) {
4955 $out .= nl2br((
string) $address);
4957 $out .= preg_replace(
'/[\r\n]+/', $charfornl, (
string) $address);
4961 $showgmap = $showomap = 0;
4962 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS')) {
4965 if ($element ==
'contact' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_CONTACTS')) {
4968 if ($element ==
'member' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_MEMBERS')) {
4971 if ($element ==
'user' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_USERS')) {
4974 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS')) {
4977 if ($element ==
'contact' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_CONTACTS')) {
4980 if ($element ==
'member' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_MEMBERS')) {
4983 if ($element ==
'user' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_USERS')) {
4988 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4991 $url =
dol_buildpath(
'/openstreetmap/maps.php?mode='.$element.
'&id='.
$id, 1);
4992 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
5014function isValidEmail($address, $acceptsupervisorkey = 0, $acceptuserkey = 0)
5016 if ($acceptsupervisorkey && $address ==
'__SUPERVISOREMAIL__') {
5019 if ($acceptuserkey && $address ==
'__USER_EMAIL__') {
5022 if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
5040 if (function_exists(
'idn_to_ascii') && function_exists(
'checkdnsrr')) {
5041 if (!checkdnsrr(idn_to_ascii($domain),
'MX')) {
5044 if (function_exists(
'getmxrr')) {
5047 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
5048 if (count($mxhosts) > 1) {
5051 if (count($mxhosts) == 1 && !in_array((
string) $mxhosts[0], array(
'',
'.'))) {
5088 $tmparray = explode(
' ', $s);
5089 foreach ($tmparray as $tmps) {
5104function dol_strlen($string, $stringencoding =
'UTF-8')
5106 if (is_null($string)) {
5110 if (function_exists(
'mb_strlen')) {
5111 return mb_strlen($string, $stringencoding);
5113 return strlen($string);
5127function dol_substr($string, $start, $length =
null, $stringencoding =
'', $trunconbytes = 0)
5131 if (empty($stringencoding)) {
5132 $stringencoding = (empty($langs) ?
'UTF-8' : $langs->charset_output);
5136 if (empty($trunconbytes)) {
5137 if (function_exists(
'mb_substr')) {
5138 $ret = mb_substr($string, $start, $length, $stringencoding);
5140 $ret = substr($string, $start, $length);
5143 if (function_exists(
'mb_strcut')) {
5144 $ret = mb_strcut($string, $start, $length, $stringencoding);
5146 $ret = substr($string, $start, $length);
5166function dol_trunc($string, $size = 40, $trunc =
'right', $stringencoding =
'UTF-8', $nodot = 0, $display = 0)
5174 if (empty($stringencoding)) {
5175 $stringencoding =
'UTF-8';
5178 if (!empty(
$conf->dol_optimize_smallscreen) &&
$conf->dol_optimize_smallscreen == 1 && $display == 1) {
5179 $size = round($size / 3);
5183 if ($trunc ==
'right') {
5185 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
5187 return dol_substr($newstring, 0, $size, $stringencoding).($nodot ?
'' :
'…');
5192 } elseif ($trunc ==
'middle') {
5194 if (
dol_strlen($newstring, $stringencoding) > 2 &&
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
5195 $size1 = (int) round($size / 2);
5196 $size2 = (int) round($size / 2);
5197 return dol_substr($newstring, 0, $size1, $stringencoding).
'…'.
dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
5201 } elseif ($trunc ==
'left') {
5203 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
5205 return '…'.dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
5209 } elseif ($trunc ==
'wrap') {
5211 if (
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
5217 return 'BadParam3CallingDolTrunc';
5231 $type2picto = array(
5232 'varchar' =>
'font',
5235 'int' =>
'sort-numeric-down',
5236 'double' =>
'sort-numeric-down',
5237 'price' =>
'currency',
5238 'pricecy' =>
'multicurrency',
5239 'password' =>
'key',
5240 'boolean' =>
'check-square',
5241 'date' =>
'calendar',
5242 'datetime' =>
'calendar',
5243 'duration' =>
'hourglass',
5249 'sellist' =>
'list',
5250 'stars' =>
'fontawesome_star_fas',
5251 'radio' =>
'check-circle',
5252 'checkbox' =>
'list',
5253 'chkbxlst' =>
'list',
5255 'icon' =>
"question",
5256 'point' =>
"country",
5257 'multipts' =>
'country',
5258 'linestrg' =>
"country",
5259 'polygon' =>
"country",
5260 'separate' =>
'minus'
5263 if (!empty($type2picto[$key])) {
5264 return img_picto(
'', $type2picto[$key],
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
5267 return img_picto(
'',
'generic',
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
5293function img_picto($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0, $alt =
'', $morecss =
'', $marginleftonlyshort = 2, $allowothertags = array())
5298 $url = DOL_URL_ROOT;
5299 $theme = isset(
$conf->theme) ?
$conf->theme :
null;
5300 $path =
'theme/'.$theme;
5301 if (empty($picto)) {
5306 if ($pictoisfullpath) {
5308 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
5311 $fullpathpicto = $picto;
5313 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5314 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5315 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5320 $pictowithouttext = preg_replace(
'/(\.png|\.gif|\.svg)$/',
'', $picto);
5321 $pictowithouttext = str_replace(
'object_',
'', $pictowithouttext);
5322 $pictowithouttext = str_replace(
'_nocolor',
'', $pictowithouttext);
5325 $pictoconvertkey = array(
'facture' =>
'bill',
'shipping' =>
'shipment',
'fichinter' =>
'intervention',
'agenda' =>
'calendar',
'invoice_supplier' =>
'supplier_invoice',
'order_supplier' =>
'supplier_order');
5326 if (in_array($pictowithouttext, array_keys($pictoconvertkey))) {
5327 $pictowithouttext = $pictoconvertkey[$pictowithouttext];
5330 if (strpos($pictowithouttext,
'fontawesome_') === 0 || strpos($pictowithouttext,
'fa-') === 0) {
5332 $pictowithouttext = str_replace(
'fontawesome_',
'', $pictowithouttext);
5333 $pictowithouttext = str_replace(
'fa-',
'', $pictowithouttext);
5336 if ($pictowithouttext ==
'file-o') {
5337 $pictowithouttext =
'file';
5340 $pictowithouttextarray = explode(
'_', $pictowithouttext);
5341 $marginleftonlyshort = 0;
5343 if (!empty($pictowithouttextarray[1])) {
5345 $fakey =
'fa-'.$pictowithouttextarray[0];
5346 $faprefix = empty($pictowithouttextarray[1]) ?
'fas' : $pictowithouttextarray[1];
5347 $facolor = empty($pictowithouttextarray[2]) ?
'' : $pictowithouttextarray[2];
5348 $fasize = empty($pictowithouttextarray[3]) ?
'' : $pictowithouttextarray[3];
5350 $fakey =
'fa-'.$pictowithouttext;
5360 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5361 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5362 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5364 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
5365 $morestyle = $reg[1];
5366 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
5368 $moreatt = trim($moreatt);
5370 $enabledisablehtml =
'<span class="'.$faprefix.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
5371 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
5372 $enabledisablehtml .=
'</span>';
5374 return $enabledisablehtml;
5378 $fakey = $pictowithouttext;
5382 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'))) {
5385 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'))) {
5391 if ($pictowithouttext ==
'off') {
5392 $fakey =
'fa-square';
5394 } elseif ($pictowithouttext ==
'on') {
5395 $fakey =
'fa-check-square';
5397 } elseif ($pictowithouttext ==
'listlight') {
5398 $fakey =
'fa-download';
5399 $marginleftonlyshort = 1;
5400 } elseif ($pictowithouttext ==
'printer') {
5401 $fakey =
'fa-print';
5403 } elseif ($pictowithouttext ==
'note') {
5404 $fakey =
'fa-sticky-note';
5405 $marginleftonlyshort = 1;
5406 } elseif (in_array($pictowithouttext, array(
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'))) {
5407 $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');
5408 $fakey =
'fa-'.$convertarray[$pictowithouttext];
5409 if (preg_match(
'/selected/', $pictowithouttext)) {
5412 $marginleftonlyshort = 1;
5413 } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) {
5414 $fakey =
'fa-'.$arrayconvpictotofa[$pictowithouttext];
5416 $fakey =
'fa-'.$pictowithouttext;
5419 if (in_array($pictowithouttext, array(
'dollyrevert',
'member',
'members',
'contract',
'group',
'resource',
'shipment',
'reception'))) {
5420 $morecss .=
' em092';
5422 if (in_array($pictowithouttext, array(
'conferenceorbooth',
'collab',
'eventorganization',
'holiday',
'info',
'info_black',
'project',
'workstation'))) {
5423 $morecss .=
' em088';
5425 if (in_array($pictowithouttext, array(
'asset',
'intervention',
'payment',
'loan',
'partnership',
'stock',
'technic'))) {
5426 $morecss .=
' em080';
5430 $arrayconvpictotomarginleftonly = array(
5431 'bank',
'check',
'delete',
'generic',
'grip',
'grip_title',
'jabber',
5432 'grip_title',
'grip',
'listlight',
'note',
'on',
'off',
'playdisabled',
'printer',
'resize',
'sign-out',
'stats',
'switch_on',
'switch_on_grey',
'switch_on_red',
'switch_off',
5433 'uparrow',
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'
5435 if (!array_key_exists($pictowithouttext, $arrayconvpictotomarginleftonly)) {
5436 $marginleftonlyshort = 0;
5440 $arrayconvpictotomorcess = array(
5441 'action' =>
'infobox-action',
'account' =>
'infobox-bank_account',
'accounting_account' =>
'infobox-bank_account',
'accountline' =>
'infobox-bank_account',
'accountancy' =>
'infobox-bank_account',
'asset' =>
'infobox-bank_account',
5442 'bank_account' =>
'infobox-bank_account',
5443 'bill' =>
'infobox-commande',
'billa' =>
'infobox-commande',
'billr' =>
'infobox-commande',
'billd' =>
'infobox-commande',
5444 'bookcal' =>
'infobox-action',
5445 'margin' =>
'infobox-bank_account',
'conferenceorbooth' =>
'infobox-project',
5446 'cash-register' =>
'infobox-bank_account',
'contract' =>
'infobox-contrat',
'check' =>
'font-status4',
'collab' =>
'infobox-action',
'conversation' =>
'infobox-contrat',
5447 'donation' =>
'infobox-commande',
'dolly' =>
'infobox-commande',
'dollyrevert' =>
'flip infobox-order_supplier',
5448 'ecm' =>
'infobox-action',
'eventorganization' =>
'infobox-project',
5449 'hrm' =>
'infobox-adherent',
'group' =>
'infobox-adherent',
'intervention' =>
'infobox-contrat',
5450 'incoterm' =>
'infobox-supplier_proposal',
5451 'currency' =>
'infobox-bank_account',
'multicurrency' =>
'infobox-bank_account',
5452 'members' =>
'infobox-adherent',
'member' =>
'infobox-adherent',
'money-bill-alt' =>
'infobox-bank_account',
5453 'order' =>
'infobox-commande',
5454 'user' =>
'infobox-adherent',
'users' =>
'infobox-adherent',
5455 'error' =>
'pictoerror',
'warning' =>
'pictowarning',
'switch_on' =>
'font-status4',
'switch_on_warning' =>
'font-status4 warning',
'switch_on_red' =>
'font-status8',
5456 'holiday' =>
'infobox-holiday',
'info' =>
'opacityhigh',
'info_black' =>
'font-status1',
'invoice' =>
'infobox-commande',
5457 'knowledgemanagement' =>
'infobox-contrat rotate90',
'loan' =>
'infobox-bank_account',
5458 'payment' =>
'infobox-bank_account',
'payment_vat' =>
'infobox-bank_account',
'poll' =>
'infobox-adherent',
'pos' =>
'infobox-bank_account',
'project' =>
'infobox-project',
'projecttask' =>
'infobox-project',
5459 'propal' =>
'infobox-propal',
'proposal' =>
'infobox-propal',
'private' =>
'infobox-project',
5460 'reception' =>
'flip infobox-order_supplier',
'recruitmentjobposition' =>
'infobox-adherent',
'recruitmentcandidature' =>
'infobox-adherent',
5461 'resource' =>
'infobox-action',
5462 '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',
5463 'supplier' =>
'infobox-order_supplier',
'supplier_order' =>
'infobox-order_supplier',
'supplier_proposal' =>
'infobox-supplier_proposal',
5464 'ticket' =>
'infobox-contrat',
'title_accountancy' =>
'infobox-bank_account',
'title_hrm' =>
'infobox-holiday',
'expensereport' =>
'infobox-expensereport',
'trip' =>
'infobox-expensereport',
'title_agenda' =>
'infobox-action',
5465 'vat' =>
'infobox-bank_account',
5467 'list-alt' =>
'imgforviewmode',
'calendar' =>
'imgforviewmode',
'calendarweek' =>
'imgforviewmode',
'calendarmonth' =>
'imgforviewmode',
'calendarday' =>
'imgforviewmode',
'calendarperuser' =>
'imgforviewmode',
'calendarpertype' =>
'imgforviewmode'
5469 if (!empty($arrayconvpictotomorcess[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5470 $morecss .= ($morecss ?
' ' :
'').$arrayconvpictotomorcess[$pictowithouttext];
5474 $arrayconvpictotocolor = array(
5475 'address' =>
'#6c6aa8',
'building' =>
'#6c6aa8',
'bom' =>
'#a69944',
5476 'clone' =>
'#999',
'cog' =>
'#999',
'companies' =>
'#6c6aa8',
'company' =>
'#6c6aa8',
'contact' =>
'#6c6aa8',
'cron' =>
'#555',
5477 'dynamicprice' =>
'#a69944',
5478 'edit' =>
'#444',
'note' =>
'#999',
'error' =>
'',
'help' =>
'#bbb',
'listlight' =>
'#999',
'language' =>
'#555',
5480 'lock' =>
'#ddd',
'lot' =>
'#a69944',
5481 'map-marker-alt' =>
'#aaa',
'mrp' =>
'#a69944',
'product' =>
'#a69944',
'service' =>
'#a69944',
'inventory' =>
'#a69944',
'stock' =>
'#a69944',
'movement' =>
'#a69944',
5482 'other' =>
'#ddd',
'world' =>
'#986c6a',
5483 'partnership' =>
'#6c6aa8',
'playdisabled' =>
'#ccc',
'printer' =>
'#444',
'projectpub' =>
'#986c6a',
'resize' =>
'#444',
'rss' =>
'#cba',
5485 'search-plus' =>
'#808080',
'security' =>
'#999',
'square' =>
'#888',
'stop-circle' =>
'#888',
'stats' =>
'#444',
'switch_off' =>
'#999',
5486 'technic' =>
'#999',
'tick' =>
'#282',
'timespent' =>
'#555',
5487 'uncheck' =>
'#800',
'uparrow' =>
'#555',
'user-cog' =>
'#999',
'country' =>
'#aaa',
'globe-americas' =>
'#aaa',
'region' =>
'#aaa',
'state' =>
'#aaa',
5488 'website' =>
'#304',
'workstation' =>
'#a69944'
5490 if (isset($arrayconvpictotocolor[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5491 $facolor = $arrayconvpictotocolor[$pictowithouttext];
5498 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5499 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5500 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5502 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
5503 $morestyle = $reg[1];
5504 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
5506 $moreatt = trim($moreatt);
5508 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
5509 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
5510 $enabledisablehtml .=
'</span>';
5512 return $enabledisablehtml;
5519 } elseif (!empty(
$conf->modules_parts[
'theme']) && array_key_exists($theme,
$conf->modules_parts[
'theme'])) {
5520 $path = $theme.
'/theme/'.$theme;
5525 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
5531 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
5536 foreach (
$conf->file->dol_document_root as $type => $dirroot) {
5537 if ($type ==
'main') {
5541 if (file_exists($dirroot.
'/'.$path.
'/img/'.$picto)) {
5542 $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type];
5548 $fullpathpicto = $url.
'/'.$path.
'/img/'.$picto;
5552 return $fullpathpicto;
5556 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 :
'').
'"').
'>';
5567 '1downarrow',
'1uparrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected',
5568 'accountancy',
'accounting_account',
'account',
'accountline',
'action',
'add',
'address',
'ai',
'angle-double-down',
'angle-double-up',
'asset',
5569 'back',
'bank_account',
'barcode',
'bank',
'bell',
'bill',
'billa',
'billr',
'billd',
'birthday-cake',
'bom',
'bookcal',
'bookmark',
'briefcase-medical',
'bug',
'building',
5570 'card',
'calendarlist',
'calendar',
'calendarmonth',
'calendarweek',
'calendarday',
'calendarperuser',
'calendarpertype',
'hourglass',
5571 'cash-register',
'category',
'chart',
'check',
'clock',
'clone',
'close_title',
'code',
'cog',
'collab',
'company',
'contact',
'country',
'contract',
'conversation',
'cron',
'cross',
'cubes',
5572 'check-circle',
'check-square',
'circle',
'stop-circle',
'currency',
'multicurrency',
5573 'chevron-left',
'chevron-right',
'chevron-down',
'chevron-up',
5574 'chevron-double-left',
'chevron-double-right',
'chevron-double-down',
'chevron-double-top',
5575 'commercial',
'companies',
5576 'delete',
'dolly',
'dollyrevert',
'donation',
'download',
'dynamicprice',
5577 'edit',
'ellipsis-h',
'email',
'entity',
'envelope',
'eraser',
'establishment',
'expensereport',
'external-link-alt',
'external-link-square-alt',
'eye',
5578 'filter',
'file',
'file-o',
'file-code',
'file-export',
'file-import',
'file-upload',
'autofill',
'folder',
'folder-open',
'folder-plus',
'font',
5579 'generate',
'generic',
'globe',
'globe-americas',
'graph',
'grip',
'grip_title',
'group',
5580 'hands-helping',
'help',
'holiday',
5581 'id-card',
'images',
'incoterm',
'info',
'info_black',
'intervention',
'inventory',
'intracommreport',
'jobprofile',
5582 'key',
'knowledgemanagement',
5583 'label',
'language',
'layout',
'line',
'link',
'list',
'list-alt',
'listlight',
'loan',
'lock',
'lot',
'long-arrow-alt-right',
5584 'margin',
'map-marker-alt',
'member',
'meeting',
'minus',
'money-bill-alt',
'movement',
'mrp',
'note',
'next',
5585 'off',
'on',
'order',
5586 'paragraph',
'play',
'pdf',
'phone',
'phoning',
'phoning_mobile',
'phoning_fax',
'playdisabled',
'previous',
'poll',
'pos',
'printer',
'product',
'propal',
'proposal',
'puce',
5587 'resize',
'search',
'service',
'stats',
'stock',
5588 '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',
5589 'discord',
'facebook',
'flickr',
'instagram',
'linkedin',
'github',
'google',
'jabber',
'meetup',
'microsoft',
'skype',
'slack',
'twitter',
'pinterest',
'reddit',
'snapchat',
'tumblr',
'youtube',
'viadeo',
'google-plus-g',
'whatsapp',
5590 'generic',
'home',
'hrm',
'members',
'products',
'invoicing',
5591 'partnership',
'payment',
'payment_vat',
'pencil-ruler',
'pictoconfirm',
'preview',
'project',
'projectpub',
'projecttask',
'question',
'refresh',
'region',
5592 'salary',
'shipment',
'state',
'supplier_invoice',
'supplier_invoicea',
'supplier_invoicer',
'supplier_invoiced',
5593 'technic',
'ticket',
5595 'recent',
'reception',
'recruitmentcandidature',
'recruitmentjobposition',
'replacement',
'resource',
'recurring',
'rss',
5596 'search-plus',
'shapes',
'skill',
'square',
'sort-numeric-down',
'status',
'stop-circle',
'store',
'supplier',
'supplier_proposal',
'supplier_order',
'supplier_invoice',
5597 'terminal',
'tick',
'timespent',
'title_setup',
'title_accountancy',
'title_bank',
'title_hrm',
'title_agenda',
'trip',
5598 'uncheck',
'undo',
'url',
'user-cog',
'user-injured',
'user-md',
'upload',
'vat',
'website',
'workstation',
'webhook',
'world',
'private',
5599 'conferenceorbooth',
'eventorganization',
5600 'stamp',
'signature',
5617 $arrayconvpictotofa = array(
5618 'account' =>
'university',
'accounting_account' =>
'clipboard-list',
'accountline' =>
'receipt',
'accountancy' =>
'search-dollar',
'action' =>
'calendar-alt',
'add' =>
'plus-circle',
'address' =>
'address-book',
'ai' =>
'magic',
5619 'asset' =>
'money-check-alt',
'autofill' =>
'fill',
5620 'back' =>
'arrow-left',
'bank_account' =>
'university',
5621 'bill' =>
'file-invoice-dollar',
'billa' =>
'file-excel',
'billr' =>
'file-invoice-dollar',
'billd' =>
'file-medical',
5622 'bookcal' =>
'calendar-check',
5623 'supplier_invoice' =>
'file-invoice-dollar',
'supplier_invoicea' =>
'file-excel',
'supplier_invoicer' =>
'file-invoice-dollar',
'supplier_invoiced' =>
'file-medical',
5625 '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',
5626 'chevron-double-left' =>
'angle-double-left',
'chevron-double-right' =>
'angle-double-right',
'chevron-double-down' =>
'angle-double-down',
'chevron-double-top' =>
'angle-double-up',
5627 'donation' =>
'file-alt',
'dynamicprice' =>
'hand-holding-usd',
5628 'setup' =>
'cog',
'companies' =>
'building',
'products' =>
'cube',
'commercial' =>
'suitcase',
'invoicing' =>
'coins',
5629 'accounting' =>
'search-dollar',
'category' =>
'tag',
'dollyrevert' =>
'dolly',
5630 'file-o' =>
'file',
'generate' =>
'plus-square',
'hrm' =>
'user-tie',
'incoterm' =>
'truck-loading',
5631 'margin' =>
'calculator',
'members' =>
'user-friends',
'ticket' =>
'ticket-alt',
'globe' =>
'external-link-alt',
'lot' =>
'barcode',
5632 'email' =>
'at',
'establishment' =>
'building',
'edit' =>
'pencil-alt',
'entity' =>
'globe',
5633 'graph' =>
'chart-line',
'grip_title' =>
'arrows-alt',
'grip' =>
'arrows-alt',
'help' =>
'question-circle',
5634 'generic' =>
'file',
'holiday' =>
'umbrella-beach',
5635 'info' =>
'info-circle',
'info_black' =>
'info-circle',
'inventory' =>
'boxes',
'intracommreport' =>
'globe-europe',
'jobprofile' =>
'cogs',
5636 'knowledgemanagement' =>
'ticket-alt',
'label' =>
'layer-group',
'layout' =>
'columns',
'line' =>
'bars',
'loan' =>
'money-bill-alt',
5637 'member' =>
'user-alt',
'meeting' =>
'chalkboard-teacher',
'mrp' =>
'cubes',
'next' =>
'arrow-alt-circle-right',
5638 'trip' =>
'wallet',
'expensereport' =>
'wallet',
'group' =>
'users',
'movement' =>
'people-carry',
5639 'sign-out' =>
'sign-out-alt',
5640 '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',
5641 'bank' =>
'university',
'close_title' =>
'times',
'delete' =>
'trash',
'filter' =>
'filter',
5642 'list-alt' =>
'list-alt',
'calendarlist' =>
'bars',
'calendar' =>
'calendar-alt',
'calendarmonth' =>
'calendar-alt',
'calendarweek' =>
'calendar-week',
'calendarday' =>
'calendar-day',
'calendarperuser' =>
'table',
'calendarpertype' =>
'table',
5643 'intervention' =>
'ambulance',
'invoice' =>
'file-invoice-dollar',
'order' =>
'file-invoice',
5644 'error' =>
'exclamation-triangle',
'warning' =>
'exclamation-triangle',
5645 'other' =>
'square',
5646 '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',
5647 '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',
5648 'recent' =>
'check-square',
'reception' =>
'dolly',
'recruitmentjobposition' =>
'id-card-alt',
'recruitmentcandidature' =>
'id-badge',
5649 'resize' =>
'crop',
'supplier_order' =>
'dol-order_supplier',
'supplier_proposal' =>
'file-signature',
5650 'refresh' =>
'redo',
'region' =>
'map-marked',
'replacement' =>
'exchange-alt',
'resource' =>
'laptop-house',
'recurring' =>
'history',
5651 'service' =>
'concierge-bell',
5652 'skill' =>
'shapes',
'state' =>
'map-marked-alt',
'security' =>
'key',
'salary' =>
'wallet',
'shipment' =>
'dolly',
'stock' =>
'box-open',
'stats' =>
'chart-bar',
'split' =>
'code-branch',
5653 'status' =>
'stop-circle',
5654 'stripe' =>
'stripe-s',
'supplier' =>
'building',
5655 'technic' =>
'cogs',
'tick' =>
'check',
'timespent' =>
'clock',
'title_setup' =>
'tools',
'title_accountancy' =>
'money-check-alt',
'title_bank' =>
'university',
'title_hrm' =>
'umbrella-beach',
5656 'title_agenda' =>
'calendar-alt',
5657 'uncheck' =>
'times',
'uparrow' =>
'share',
'url' =>
'external-link-alt',
'vat' =>
'money-check-alt',
'vcard' =>
'arrow-alt-circle-down',
5658 'jabber' =>
'comment',
5659 'website' =>
'globe-americas',
'workstation' =>
'pallet',
'webhook' =>
'bullseye',
'world' =>
'globe',
'private' =>
'user-lock',
5660 'conferenceorbooth' =>
'chalkboard-teacher',
'eventorganization' =>
'project-diagram',
5661 'webportal' =>
'door-open'
5664 if (
$conf->currency ==
'EUR') {
5665 $arrayconvpictotofa[
'currency'] =
'euro-sign';
5666 $arrayconvpictotofa[
'multicurrency'] =
'dollar-sign';
5668 $arrayconvpictotofa[
'currency'] =
'dollar-sign';
5669 $arrayconvpictotofa[
'multicurrency'] =
'euro-sign';
5672 return $arrayconvpictotofa;
5690function img_object($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0, $allowothertags = array())
5692 if (strpos($picto,
'^') === 0) {
5693 return img_picto($titlealt, str_replace(
'^',
'', $picto), $moreatt, $pictoisfullpath, $srconly, $notitle,
'',
'', 2, $allowothertags);
5695 return img_picto($titlealt,
'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle,
'',
'', 2, $allowothertags);
5710function img_weather($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $morecss =
'')
5714 if (is_numeric($picto)) {
5717 return '<i class="fa fa-weather-level'.$picto.
'"></i>';
5718 } elseif (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5722 $path = DOL_URL_ROOT.
'/theme/'.
$conf->theme.
'/img/weather/'.$picto;
5724 return img_picto($titlealt, $path, $moreatt, 1, 0, 0,
'', $morecss);
5738function img_picto_common($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $notitle = 0)
5742 if (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5746 if ($pictoisfullpath) {
5749 $path = DOL_URL_ROOT.
'/theme/common/'.$picto;
5752 $themepath = DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/img/'.$picto;
5754 if (file_exists($themepath)) {
5760 return img_picto($titlealt, $path, $moreatt, 1, 0, $notitle);
5776function img_action($titlealt, $numaction, $picto =
'', $moreatt =
'')
5780 if (empty($titlealt) || $titlealt ==
'default') {
5781 if ($numaction ==
'-1' || $numaction ==
'ST_NO') {
5783 $titlealt = $langs->transnoentitiesnoconv(
'ChangeDoNotContact');
5784 } elseif ($numaction ==
'0' || $numaction ==
'ST_NEVER') {
5786 $titlealt = $langs->transnoentitiesnoconv(
'ChangeNeverContacted');
5787 } elseif ($numaction ==
'1' || $numaction ==
'ST_TODO') {
5789 $titlealt = $langs->transnoentitiesnoconv(
'ChangeToContact');
5790 } elseif ($numaction ==
'2' || $numaction ==
'ST_PEND') {
5792 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactInProcess');
5793 } elseif ($numaction ==
'3' || $numaction ==
'ST_DONE') {
5795 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactDone');
5797 $titlealt = $langs->transnoentitiesnoconv(
'ChangeStatus '.$numaction);
5801 if (!is_numeric($numaction)) {
5805 return img_picto($titlealt, (empty($picto) ?
'stcomm'.$numaction.
'.png' : $picto), $moreatt);
5815function img_pdf($titlealt =
'default', $size = 3)
5819 if ($titlealt ==
'default') {
5820 $titlealt = $langs->trans(
'Show');
5823 return img_picto($titlealt,
'pdf'.$size.
'.png');
5833function img_edit_add($titlealt =
'default', $other =
'')
5837 if ($titlealt ==
'default') {
5838 $titlealt = $langs->trans(
'Add');
5841 return img_picto($titlealt,
'edit_add.png', $other);
5854 if ($titlealt ==
'default') {
5855 $titlealt = $langs->trans(
'Remove');
5858 return img_picto($titlealt,
'edit_remove.png', $other);
5869function img_edit($titlealt =
'default', $float = 0, $other =
'')
5873 if ($titlealt ==
'default') {
5874 $titlealt = $langs->trans(
'Modify');
5877 return img_picto($titlealt,
'edit.png', ($float ?
'style="float: '.($langs->tab_translate[
"DIRECTION"] ==
'rtl' ?
'left' :
'right').
'"' :
"").($other ?
' '.$other :
''));
5888function img_view($titlealt =
'default', $float = 0, $other =
'class="valignmiddle"')
5892 if ($titlealt ==
'default') {
5893 $titlealt = $langs->trans(
'View');
5896 $moreatt = ($float ?
'style="float: right" ' :
'').$other;
5898 return img_picto($titlealt,
'eye', $moreatt);
5909function img_delete($titlealt =
'default', $other =
'class="pictodelete"', $morecss =
'')
5913 if ($titlealt ==
'default') {
5914 $titlealt = $langs->trans(
'Delete');
5917 return img_picto($titlealt,
'delete.png', $other, 0, 0, 0,
'', $morecss);
5927function img_printer($titlealt =
"default", $other =
'')
5930 if ($titlealt ==
"default") {
5931 $titlealt = $langs->trans(
"Print");
5933 return img_picto($titlealt,
'printer.png', $other);
5943function img_split($titlealt =
'default', $other =
'class="pictosplit"')
5947 if ($titlealt ==
'default') {
5948 $titlealt = $langs->trans(
'Split');
5951 return img_picto($titlealt,
'split.png', $other);
5961function img_help($usehelpcursor = 1, $usealttitle = 1)
5966 if (is_string($usealttitle)) {
5969 $usealttitle = $langs->trans(
'Info');
5973 return img_picto($usealttitle,
'info.png',
'style="vertical-align: middle;'.($usehelpcursor == 1 ?
' cursor: help' : ($usehelpcursor == 2 ?
' cursor: pointer' :
'')).
'"');
5982function img_info($titlealt =
'default')
5986 if ($titlealt ==
'default') {
5987 $titlealt = $langs->trans(
'Informations');
5990 return img_picto($titlealt,
'info.png',
'style="vertical-align: middle;"');
6001function img_warning($titlealt =
'default', $moreatt =
'', $morecss =
'pictowarning')
6005 if ($titlealt ==
'default') {
6006 $titlealt = $langs->trans(
'Warning');
6010 return img_picto($titlealt,
'warning.png',
'class="'.$morecss.
'"'.($moreatt ? ($moreatt ==
'1' ?
' style="float: right"' :
' '.$moreatt) :
''));
6019function img_error($titlealt =
'default')
6023 if ($titlealt ==
'default') {
6024 $titlealt = $langs->trans(
'Error');
6027 return img_picto($titlealt,
'error.png');
6037function img_next($titlealt =
'default', $moreatt =
'')
6041 if ($titlealt ==
'default') {
6042 $titlealt = $langs->trans(
'Next');
6046 return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
6056function img_previous($titlealt =
'default', $moreatt =
'')
6060 if ($titlealt ==
'default') {
6061 $titlealt = $langs->trans(
'Previous');
6065 return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
6076function img_down($titlealt =
'default', $selected = 0, $moreclass =
'')
6080 if ($titlealt ==
'default') {
6081 $titlealt = $langs->trans(
'Down');
6084 return img_picto($titlealt, ($selected ?
'1downarrow_selected.png' :
'1downarrow.png'),
'class="imgdown'.($moreclass ?
" ".$moreclass :
"").
'"');
6095function img_up($titlealt =
'default', $selected = 0, $moreclass =
'')
6099 if ($titlealt ==
'default') {
6100 $titlealt = $langs->trans(
'Up');
6103 return img_picto($titlealt, ($selected ?
'1uparrow_selected.png' :
'1uparrow.png'),
'class="imgup'.($moreclass ?
" ".$moreclass :
"").
'"');
6114function img_left($titlealt =
'default', $selected = 0, $moreatt =
'')
6118 if ($titlealt ==
'default') {
6119 $titlealt = $langs->trans(
'Left');
6122 return img_picto($titlealt, ($selected ?
'1leftarrow_selected.png' :
'1leftarrow.png'), $moreatt);
6133function img_right($titlealt =
'default', $selected = 0, $moreatt =
'')
6137 if ($titlealt ==
'default') {
6138 $titlealt = $langs->trans(
'Right');
6141 return img_picto($titlealt, ($selected ?
'1rightarrow_selected.png' :
'1rightarrow.png'), $moreatt);
6151function img_allow($allow, $titlealt =
'default')
6155 if ($titlealt ==
'default') {
6156 $titlealt = $langs->trans(
'Active');
6160 return img_picto($titlealt,
'tick.png');
6175 if (is_null($morecss)) {
6179 if ($brand ==
'visa' || $brand ==
'Visa') {
6181 } elseif ($brand ==
'mastercard' || $brand ==
'MasterCard') {
6182 $brand =
'cc-mastercard';
6183 } elseif ($brand ==
'amex' || $brand ==
'American Express') {
6185 } elseif ($brand ==
'discover' || $brand ==
'Discover') {
6186 $brand =
'cc-discover';
6187 } elseif ($brand ==
'jcb' || $brand ==
'JCB') {
6189 } elseif ($brand ==
'diners' || $brand ==
'Diners club') {
6190 $brand =
'cc-diners-club';
6191 } elseif (!in_array($brand, array(
'cc-visa',
'cc-mastercard',
'cc-amex',
'cc-discover',
'cc-jcb',
'cc-diners-club'))) {
6192 $brand =
'credit-card';
6195 return '<span class="fa fa-'.$brand.
' fa-fw'.($morecss ?
' '.$morecss :
'').
'"></span>';
6206function img_mime($file, $titlealt =
'', $morecss =
'')
6208 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
6214 if (empty($titlealt)) {
6215 $titlealt =
'Mime type: '.$mimetype;
6219 return '<i class="fa fa-'.$mimefa.
' '.(preg_match(
'/pictofixedwidth/', $morecss) ?
'' :
'paddingright ').($morecss ?
' '.$morecss :
'').
'"'.($titlealt ?
' title="'.
dolPrintHTMLForAttribute($titlealt).
'"' :
'').
'></i>';
6230function img_search($titlealt =
'default', $other =
'')
6234 if ($titlealt ==
'default') {
6235 $titlealt = $langs->trans(
'Search');
6238 $img =
img_picto($titlealt,
'search.png', $other, 0, 1);
6240 $input =
'<input type="image" class="liste_titre" name="button_search" src="'.$img.
'" ';
6241 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
6257 if ($titlealt ==
'default') {
6258 $titlealt = $langs->trans(
'Search');
6261 $img =
img_picto($titlealt,
'searchclear.png', $other, 0, 1);
6263 $input =
'<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.
'" ';
6264 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
6281function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin =
'1', $morecss =
'hideonsmartphone', $textfordropdown =
'', $picto =
'')
6283 global
$conf, $langs;
6285 if ($infoonimgalt) {
6286 $result =
img_picto($text,
'info',
'class="'.($morecss ?
' '.$morecss :
'').
'"');
6288 if (empty(
$conf->use_javascript_ajax)) {
6289 $textfordropdown =
'';
6292 $class = (empty($admin) ?
'undefined' : ($admin ==
'1' ?
'info' : $admin));
6293 $fa =
'info-circle';
6294 if ($picto ==
'warning') {
6295 $fa =
'exclamation-triangle';
6297 $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> ';
6299 $result .= ($nodiv ?
'' :
'</div>');
6301 if ($textfordropdown) {
6302 $tmpresult =
'<span class="'.$class.
'text opacitymedium cursorpointer">'.$langs->trans($textfordropdown).
' '.
img_picto($langs->trans($textfordropdown),
'1downarrow').
'</span>';
6303 $tmpresult .=
'<script nonce="'.getNonce().
'" type="text/javascript">
6304 jQuery(document).ready(function() {
6305 jQuery(".'.$class.
'text").click(function() {
6306 console.log("toggle text");
6307 jQuery(".'.$class.
'").toggle();
6312 $result = $tmpresult.$result;
6333 global
$conf, $langs, $user, $argv;
6334 global $dolibarr_main_prod;
6341 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
6343 $langs->load(
"main");
6347 $langs->loadLangs(array(
'main',
'errors'));
6349 if ($_SERVER[
'DOCUMENT_ROOT']) {
6350 $out .= $langs->trans(
"DolibarrHasDetectedError").
".<br>\n";
6352 $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";
6354 $out .= $langs->trans(
"InformationToHelpDiagnose").
":<br>\n";
6356 $out .=
"<b>".$langs->trans(
"Date").
":</b> ".
dol_print_date(time(),
'dayhourlog').
"<br>\n";
6357 $out .=
"<b>".$langs->trans(
"Dolibarr").
":</b> ".DOL_VERSION.
" - https://www.dolibarr.org<br>\n";
6358 if (isset(
$conf->global->MAIN_FEATURES_LEVEL)) {
6359 $out .=
"<b>".$langs->trans(
"LevelOfFeature").
":</b> ".
getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
"<br>\n";
6361 if ($user instanceof
User) {
6362 $out .=
"<b>".$langs->trans(
"Login").
":</b> ".$user->login.
"<br>\n";
6364 if (function_exists(
"phpversion")) {
6365 $out .=
"<b>".$langs->trans(
"PHP").
":</b> ".phpversion().
"<br>\n";
6367 $out .=
"<b>".$langs->trans(
"Server").
":</b> ".(isset($_SERVER[
"SERVER_SOFTWARE"]) ?
dol_htmlentities($_SERVER[
"SERVER_SOFTWARE"], ENT_COMPAT) :
'').
"<br>\n";
6368 if (function_exists(
"php_uname")) {
6369 $out .=
"<b>".$langs->trans(
"OS").
":</b> ".php_uname().
"<br>\n";
6371 $out .=
"<b>".$langs->trans(
"UserAgent").
":</b> ".(isset($_SERVER[
"HTTP_USER_AGENT"]) ?
dol_htmlentities($_SERVER[
"HTTP_USER_AGENT"], ENT_COMPAT) :
'').
"<br>\n";
6373 $out .=
"<b>" . $langs->trans(
"RequestedUrl") .
":</b> " . (isset($_SERVER[
"REQUEST_URI"]) ?
dol_htmlentities($_SERVER[
"REQUEST_URI"], ENT_COMPAT) :
'') .
"<br>\n";
6374 $out .=
"<b>" . $langs->trans(
"Referer") .
":</b> " . (isset($_SERVER[
"HTTP_REFERER"]) ?
dol_htmlentities($_SERVER[
"HTTP_REFERER"], ENT_COMPAT) :
'') .
"<br>\n";
6375 $out .=
"<b>" . $langs->trans(
"MenuManager") .
":</b> " . (isset(
$conf->standard_menu) ?
dol_htmlentities(
$conf->standard_menu, ENT_COMPAT) :
'') .
"<br>\n";
6377 $syslog .=
"url=" . (isset($_SERVER[
"REQUEST_URI"]) ?
dol_escape_htmltag($_SERVER[
"REQUEST_URI"]) :
'');
6378 $syslog .=
", query_string=" . (isset($_SERVER[
"QUERY_STRING"]) ?
dol_escape_htmltag($_SERVER[
"QUERY_STRING"]) :
'');
6380 $out .=
'> '.$langs->transnoentities(
"ErrorInternalErrorDetected").
":\n".$argv[0].
"\n";
6381 $syslog .=
"pid=".dol_getmypid();
6384 if (!empty(
$conf->modules)) {
6385 $out .=
"<b>".$langs->trans(
"Modules").
":</b> ".implode(
', ',
$conf->modules).
"<br>\n";
6388 if (is_object($db)) {
6389 if ($_SERVER[
'DOCUMENT_ROOT']) {
6390 $out .=
"<b>".$langs->trans(
"DatabaseTypeManager").
":</b> ".$db->type.
"<br>\n";
6391 $lastqueryerror = $db->lastqueryerror();
6393 $lastqueryerror =
"SQL error string is not a valid UTF8 string. We can't show it.";
6395 $out .=
"<b>".$langs->trans(
"RequestLastAccessInError").
":</b> ".($lastqueryerror ?
dol_escape_htmltag($lastqueryerror) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6396 $out .=
"<b>".$langs->trans(
"ReturnCodeLastAccessInError").
":</b> ".($db->lasterrno() ?
dol_escape_htmltag($db->lasterrno()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6397 $out .=
"<b>".$langs->trans(
"InformationLastAccessInError").
":</b> ".($db->lasterror() ?
dol_escape_htmltag($db->lasterror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6401 $out .=
'> '.$langs->transnoentities(
"DatabaseTypeManager").
":\n".$db->type.
"\n";
6402 $out .=
'> '.$langs->transnoentities(
"RequestLastAccessInError").
":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6403 $out .=
'> '.$langs->transnoentities(
"ReturnCodeLastAccessInError").
":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6404 $out .=
'> '.$langs->transnoentities(
"InformationLastAccessInError").
":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6406 $syslog .=
", sql=".$db->lastquery();
6407 $syslog .=
", db_error=".$db->lasterror();
6410 if ($error || $errors) {
6412 if (is_array($error) && is_array($errors)) {
6413 $errors = array_merge($error, $errors);
6414 } elseif (is_array($error)) {
6416 } elseif (is_array($errors) && !empty($error)) {
6417 $errors = array_merge(array($error), $errors);
6418 } elseif (!empty($error)) {
6419 $errors = array_merge(array($error), array($errors));
6422 $langs->load(
"errors");
6424 foreach ($errors as $msg) {
6428 if ($_SERVER[
'DOCUMENT_ROOT']) {
6431 $out .=
'> '.$langs->transnoentities(
"Message").
":\n".$msg.
"\n";
6433 $syslog .=
", msg=".$msg;
6436 if (empty($dolibarr_main_prod) && $_SERVER[
'DOCUMENT_ROOT'] && function_exists(
'xdebug_print_function_stack') && function_exists(
'xdebug_call_file')) {
6437 xdebug_print_function_stack();
6438 $out .=
'<b>XDebug information:</b>'.
"<br>\n";
6439 $out .=
'File: '.xdebug_call_file().
"<br>\n";
6440 $out .=
'Line: '.xdebug_call_line().
"<br>\n";
6441 $out .=
'Function: '.xdebug_call_function().
"<br>\n";
6446 if (!headers_sent()) {
6447 if (function_exists(
'top_httphead')) {
6451 http_response_code(202);
6454 if (empty($dolibarr_main_prod)) {
6457 if (empty($langs->defaultlang)) {
6458 $langs->setDefaultLang();
6460 $langs->loadLangs(array(
"main",
"errors"));
6462 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";
6463 print $langs->trans(
"DolibarrHasDetectedError").
'. ';
6464 print $langs->trans(
"YouCanSetOptionDolibarrMainProdToZero");
6465 if (!defined(
"MAIN_CORE_ERROR")) {
6466 define(
"MAIN_CORE_ERROR", 1);
6483function dol_print_error_email($prefixcode, $errormessage =
'', $errormessages = array(), $morecss =
'error', $email =
'')
6487 if (empty($email)) {
6491 $langs->load(
"errors");
6494 print
'<br><div class="center login_main_message"><div class="'.$morecss.
'">';
6495 print $langs->trans(
"ErrorContactEMail", $email, $prefixcode.
'-'.
dol_print_date($now,
'%Y%m%d%H%M%S'));
6496 if ($errormessage) {
6497 print
'<br><br>'.$errormessage;
6499 if (is_array($errormessages) && count($errormessages)) {
6500 foreach ($errormessages as $mesgtoshow) {
6501 print
'<br><br>'.$mesgtoshow;
6504 print
'</div></div>';
6523function print_liste_field_titre($name, $file =
"", $field =
"", $begin =
"", $param =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $tooltip =
"", $forcenowrapcolumntitle = 0)
6525 print
getTitleFieldOfList($name, 0, $file, $field, $begin, $param, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip, $forcenowrapcolumntitle);
6546function getTitleFieldOfList($name, $thead = 0, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $disablesortlink = 0, $tooltip =
'', $forcenowrapcolumntitle = 0)
6548 global $langs, $form;
6551 if ($moreattrib ==
'class="right"') {
6552 $prefix .=
'right ';
6555 $sortorder = strtoupper((
string) $sortorder);
6564 $tmpsortfield = explode(
',', (
string) $sortfield);
6565 $sortfield1 = trim($tmpsortfield[0]);
6566 $tmpfield = explode(
',', $field);
6567 $field1 = trim($tmpfield[0]);
6569 if (!
getDolGlobalString(
'MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE') && empty($forcenowrapcolumntitle)) {
6570 $prefix =
'wrapcolumntitle '.$prefix;
6576 $liste_titre =
'liste_titre';
6577 if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace(
"/^[^\.]+\./",
"", $field1))) {
6578 $liste_titre =
'liste_titre_sel';
6581 $tagstart =
'<'.$tag.
' class="'.$prefix.$liste_titre.
'" '.$moreattrib;
6586 if (empty($thead) && $field && empty($disablesortlink)) {
6587 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6588 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6589 $options = preg_replace(
'/&+/i',
'&', $options);
6590 if (!preg_match(
'/^&/', $options)) {
6591 $options =
'&'.$options;
6594 $sortordertouseinlink =
'';
6595 if ($field1 != $sortfield1) {
6596 if (preg_match(
'/^DESC/i', $sortorder)) {
6597 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6599 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6602 if (preg_match(
'/^ASC/i', $sortorder)) {
6603 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6605 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6608 $sortordertouseinlink = preg_replace(
'/,$/',
'', $sortordertouseinlink);
6609 $out .=
'<a class="reposition" href="'.$file.
'?sortfield='.urlencode($field).
'&sortorder='.urlencode($sortordertouseinlink).
'&begin='.urlencode($begin).$options.
'"';
6615 if (strpos($tooltip,
':') !==
false) {
6616 $tmptooltip = explode(
':', $tooltip);
6618 $tmptooltip = array($tooltip);
6620 $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]));
6622 $out .= $langs->trans((
string) $name);
6625 if (empty($thead) && $field && empty($disablesortlink)) {
6629 if (empty($thead) && $field) {
6630 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6631 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6632 $options = preg_replace(
'/&+/i',
'&', $options);
6633 if (!preg_match(
'/^&/', $options)) {
6634 $options =
'&'.$options;
6637 if (!$sortorder || ($field1 != $sortfield1)) {
6640 if (preg_match(
'/^DESC/', $sortorder)) {
6641 $sortimg .=
'<span class="nowrap">'.img_up(
"Z-A", 0,
'paddingright').
'</span>';
6643 if (preg_match(
'/^ASC/', $sortorder)) {
6644 $sortimg .=
'<span class="nowrap">'.img_down(
"A-Z", 0,
'paddingright').
'</span>';
6649 $tagend =
'</'.$tag.
'>';
6651 $out = $tagstart.$sortimg.$out.$tagend;
6666 dol_syslog(__FUNCTION__.
" is deprecated", LOG_WARNING);
6668 print
'<div class="titre">'.$title.
'</div>';
6682function print_fiche_titre($title, $mesg =
'', $picto =
'generic', $pictoisfullpath = 0,
$id =
'')
6700function load_fiche_titre($title, $morehtmlright =
'', $picto =
'generic', $pictoisfullpath = 0,
$id =
'', $morecssontable =
'', $morehtmlcenter =
'')
6704 if ($picto ==
'setup') {
6709 $return .=
'<table '.($id ?
'id="'.$id.
'" ' :
'').
'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ?
' '.$morecssontable :
'').
'">';
6710 $return .=
'<tr class="toptitle">';
6712 $return .=
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).
'</td>';
6714 $return .=
'<td class="nobordernopadding valignmiddle col-title">';
6715 $return .=
'<div class="titre inline-block">';
6716 $return .=
'<span class="inline-block valignmiddle">'.$title.
'</span>';
6717 $return .=
'</div>';
6720 $return .=
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
6723 $return .=
'<td class="nobordernopadding titre_right wordbreakimp right valignmiddle col-right">'.$morehtmlright.
'</td>';
6725 $return .=
'</tr></table>'.
"\n";
6753function 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 =
'')
6755 global
$conf, $langs;
6758 $savtotalnboflines = $totalnboflines;
6759 if (is_numeric($totalnboflines)) {
6760 $totalnboflines = abs($totalnboflines);
6765 $tmparray = preg_split(
'/<br>/i', $title, 2);
6766 if (!empty($tmparray[1])) {
6767 $title = $tmparray[0];
6768 $subtitle = $tmparray[1];
6771 $page = (int) $page;
6773 if ($picto ==
'setup') {
6774 $picto =
'title_setup.png';
6776 if ((
$conf->browser->name ==
'ie') && $picto ==
'generic') {
6777 $picto =
'title.gif';
6780 $limit =
$conf->liste_limit;
6783 if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
6791 print
"<!-- Begin print_barre_liste -->\n";
6792 print
'<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ?
' '.$morecss :
'').
'">';
6793 print
'<tr class="toptitle">';
6797 if ($picto && $title) {
6798 print
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">';
6799 print
img_picto(
'', $picto,
'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath);
6803 print
'<td class="nobordernopadding valignmiddle col-title">';
6804 print
'<div class="titre inline-block">';
6805 print
'<span class="inline-block valignmiddle print-barre-liste">'.$title.
'</span>';
6806 if (!empty($title) && $savtotalnboflines >= 0 && (
string) $savtotalnboflines !=
'' && $totalnboflines > 0) {
6807 print
'<span class="opacitymedium colorblack marginleftonly totalnboflines valignmiddle" title="'.$langs->trans(
"NbRecordQualified").
'">('.$totalnboflines.
')</span>';
6810 if (!empty($subtitle)) {
6811 print
'<br><div class="subtitle inline-block hideonsmartphone">'.$subtitle.
'</div>';
6816 if ($morehtmlcenter && empty(
$conf->dol_optimize_smallscreen)) {
6817 print
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
6821 print
'<td class="nobordernopadding valignmiddle right col-right">';
6822 print
'<input type="hidden" name="pageplusoneold" value="'.((int) $page + 1).
'">';
6824 $options .=
"&sortfield=".urlencode($sortfield);
6827 $options .=
"&sortorder=".urlencode($sortorder);
6831 if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
6832 if ($totalnboflines) {
6834 $maxnbofpage = (empty(
$conf->dol_optimize_smallscreen) ? 4 : 0);
6837 $nbpages = ceil($totalnboflines / $limit);
6841 $cpt = ($page - $maxnbofpage);
6847 if (empty($pagenavastextinput)) {
6848 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page=0'.$options.
'">1</a></li>';
6850 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
6851 } elseif ($cpt == 2) {
6852 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page=1'.$options.
'">2</a></li>';
6858 if ($pagenavastextinput) {
6859 if ($cpt == $page) {
6860 $pagelist .=
'<li class="pagination pageplusone valignmiddle"><input type="text" class="'.($totalnboflines > 100 ?
'width40' :
'width25').
' center pageplusone heightofcombo" name="pageplusone" value="'.($page + 1).
'"></li>';
6864 if ($cpt == $page) {
6865 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
'</span></li>';
6867 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.$cpt.$options.
'">'.($cpt + 1).
'</a></li>';
6871 }
while ($cpt < $nbpages && $cpt <= ($page + $maxnbofpage));
6873 if (empty($pagenavastextinput)) {
6874 if ($cpt < $nbpages) {
6875 if ($cpt < $nbpages - 2) {
6876 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
6877 } elseif ($cpt == $nbpages - 2) {
6878 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.($nbpages - 2).$options.
'">'.($nbpages - 1).
'</a></li>';
6880 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
6884 $pagelist .=
'<li class="pagination paginationlastpage"><a class="reposition" href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
6887 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
"</li>";
6891 if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
6892 print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $selectlimitsuffix, $morehtmlrightbeforearrow, $hidenavigation);
6896 if ($pagenavastextinput) {
6903 print
'</table>'.
"\n";
6906 if ($morehtmlcenter && !empty(
$conf->dol_optimize_smallscreen)) {
6907 print
'<div class="nobordernopadding marginbottomonly center valignmiddle col-center centpercent">'.$morehtmlcenter.
'</div>';
6910 print
"<!-- End title -->\n\n";
6929function print_fleche_navigation($page, $file, $options =
'', $nextpage = 0, $betweenarrows =
'', $afterarrows =
'', $limit = -1, $totalnboflines = 0, $selectlimitsuffix =
'', $beforearrows =
'', $hidenavigation = 0)
6931 global
$conf, $langs;
6933 print
'<div class="pagination"><ul>';
6934 if ($beforearrows) {
6935 print
'<li class="paginationbeforearrows">';
6936 print $beforearrows;
6940 if (empty($hidenavigation)) {
6941 if ((
int) $limit > 0 && (empty($selectlimitsuffix) || !is_numeric($selectlimitsuffix))) {
6942 $pagesizechoices =
'10:10,15:15,20:20,25:25,50:50,100:100,250:250,500:500,1000:1000';
6943 $pagesizechoices .=
',5000:5000';
6953 print
'<li class="pagination">';
6954 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.
'">';
6955 print
'<datalist id="limitlist">';
6957 print
'<li class="paginationcombolimit valignmiddle">';
6958 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")).
'">';
6960 $tmpchoice = explode(
',', $pagesizechoices);
6961 $tmpkey = $limit.
':'.$limit;
6962 if (!in_array($tmpkey, $tmpchoice)) {
6963 $tmpchoice[$tmpkey] = $tmpkey;
6965 $tmpkey =
$conf->liste_limit.
':'.
$conf->liste_limit;
6966 if (!in_array($tmpkey, $tmpchoice)) {
6967 $tmpchoice[$tmpkey] = $tmpkey;
6969 asort($tmpchoice, SORT_NUMERIC);
6970 foreach ($tmpchoice as $val) {
6972 $tmp = explode(
':', $val);
6975 if ($key !=
'' && $val !=
'') {
6976 if ((
int) $key == (
int) $limit) {
6977 $selected =
' selected="selected"';
6979 print
'<option name="'.$key.
'"'.$selected.
'>'.
dol_escape_htmltag($val).
'</option>'.
"\n";
6983 print
'</datalist>';
6986 print
ajax_combobox(
"limit".(is_numeric($selectlimitsuffix) ?
'' : $selectlimitsuffix), array(), 0, 0,
'resolve',
'-1',
'limit');
6990 if (
$conf->use_javascript_ajax) {
6991 print
'<!-- JS CODE TO ENABLE select limit to launch submit of page -->
6993 jQuery(document).ready(function () {
6994 jQuery(".selectlimit").change(function() {
6995 console.log("We change limit so we submit the form");
6996 $(this).parents(\'form:first\').submit();
7005 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>';
7007 if ($betweenarrows) {
7008 print
'<!--<div class="betweenarrows nowraponall inline-block">-->';
7009 print $betweenarrows;
7010 print
'<!--</div>-->';
7012 if ($nextpage > 0) {
7013 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>';
7016 print
'<li class="paginationafterarrows">';
7021 print
'</ul></div>'.
"\n";
7036function vatrate($rate, $addpercent =
false, $info_bits = 0, $usestarfornpr = 0, $html = 0)
7040 if (preg_match(
'/%/', $rate)) {
7041 $rate = str_replace(
'%',
'', $rate);
7045 if (preg_match(
'/\((.*)\)/', $rate, $reg)) {
7046 $morelabel =
' ('.$reg[1].
')';
7047 $rate = preg_replace(
'/\s*'.preg_quote($morelabel,
'/').
'/',
'', $rate);
7048 $morelabel =
' '.($html ?
'<span class="opacitymedium">' :
'').
'('.$reg[1].
')'.($html ?
'</span>' :
'');
7050 if (preg_match(
'/\*/', $rate)) {
7051 $rate = str_replace(
'*',
'', $rate);
7056 if (!preg_match(
'/\//', $rate)) {
7057 $ret =
price($rate, 0,
'', 0, 0).($addpercent ?
'%' :
'');
7060 $ret = $rate.($addpercent ?
'%' :
'');
7062 if (($info_bits & 1) && $usestarfornpr >= 0) {
7085function price($amount, $form = 0, $outlangs =
'', $trunc = 1, $rounding = -1, $forcerounding = -1, $currency_code =
'')
7087 global $langs,
$conf;
7090 if (empty($amount)) {
7093 $amount = (is_numeric($amount) ? $amount : 0);
7094 if ($rounding == -1) {
7097 $nbdecimal = $rounding;
7099 if ($outlangs ===
'none') {
7109 if (!($outlangs instanceof
Translate)) {
7113 if ($outlangs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
7114 $dec = $outlangs->transnoentitiesnoconv(
"SeparatorDecimal");
7116 if ($outlangs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
7117 $thousand = $outlangs->transnoentitiesnoconv(
"SeparatorThousand");
7119 if ($thousand ==
'None') {
7121 } elseif ($thousand ==
'Space') {
7128 $amount = str_replace(
',',
'.', $amount);
7130 $data = explode(
'.', $amount);
7131 $decpart = isset($data[1]) ? $data[1] :
'';
7132 $decpart = preg_replace(
'/0+$/i',
'', $decpart);
7142 $nbdecimalmaxshown = (int) str_replace(
'...',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN'));
7143 if ($trunc && $nbdecimal > $nbdecimalmaxshown) {
7144 $nbdecimal = $nbdecimalmaxshown;
7152 if ((
string) $forcerounding !=
'-1' && (string) $forcerounding !=
'') {
7153 if ($forcerounding ===
'MU') {
7155 } elseif ($forcerounding ===
'MT') {
7157 } elseif ($forcerounding >= 0) {
7158 $nbdecimal = (int) $forcerounding;
7163 $output = number_format((
float) $amount, $nbdecimal, $dec, $thousand);
7165 $cursymbolbefore = $cursymbolafter =
'';
7166 if ($currency_code && is_object($outlangs)) {
7167 if ($currency_code ==
'auto') {
7168 $currency_code =
$conf->currency;
7171 $listofcurrenciesbefore = array(
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD',
'CRC',
'ZAR');
7172 $listoflanguagesbefore = array(
'nl_NL');
7173 if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) {
7174 $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
7176 $tmpcur = $outlangs->getCurrencySymbol($currency_code);
7177 $cursymbolafter .= ($tmpcur == $currency_code ?
' '.$tmpcur : $tmpcur);
7180 $output = $cursymbolbefore.$output.$end.($cursymbolafter ?
' ' :
'').$cursymbolafter;
7182 $output = preg_replace(
'/\s/',
' ', $output);
7183 $output = preg_replace(
'/\'/',
''', $output);
7213function price2num($amount, $rounding =
'', $option = 0)
7215 global $langs,
$conf;
7218 if (is_null($amount)) {
7227 if (is_null($langs)) {
7231 if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
7232 $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
7234 if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
7235 $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
7238 if ($thousand ==
'None') {
7240 } elseif ($thousand ==
'Space') {
7248 if (!is_numeric($amount)) {
7249 $amount = preg_replace(
'/[a-zA-Z\/\\\*\(\)<>\_]/',
'', $amount);
7252 if ($option == 2 && $thousand ==
'.' && preg_match(
'/\.(\d\d\d)$/', (
string) $amount)) {
7253 $amount = str_replace($thousand,
'', $amount);
7259 if (is_numeric($amount)) {
7261 $temps = sprintf(
"%10.10F", $amount - intval($amount));
7262 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
7264 $amount = number_format($amount, $nbofdec, $dec, $thousand);
7270 if ($thousand !=
',' && $thousand !=
'.') {
7283 if (preg_match(
'/^(?<int>[^,]*,|[^.]*\.)(?<dec>[^.,]*)$/u', $amount, $matches)) {
7284 $intPart = $matches[
'int'];
7285 $decPart = $matches[
'dec'];
7288 $intPart = str_replace([
'.',
','],
'', $intPart);
7291 $amount = $intPart . $dec . $decPart;
7295 $amount = str_replace(
' ',
'', $amount);
7296 $amount = str_replace($thousand,
'', $amount);
7297 $amount = str_replace($dec,
'.', $amount);
7299 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
7305 $nbofdectoround =
'';
7306 if ($rounding ==
'MU') {
7308 } elseif ($rounding ==
'MT') {
7310 } elseif ($rounding ==
'MS') {
7311 $nbofdectoround = isset(
$conf->global->MAIN_MAX_DECIMALS_STOCK) ?
getDolGlobalInt(
'MAIN_MAX_DECIMALS_STOCK') : 5;
7312 } elseif ($rounding ==
'CU') {
7314 } elseif ($rounding ==
'CT') {
7316 } elseif (is_numeric($rounding)) {
7317 $nbofdectoround = (int) $rounding;
7322 $amount = round(is_string($amount) ? (
float) $amount : $amount, $nbofdectoround);
7324 return 'ErrorBadParameterProvidedToFunction';
7330 if (is_numeric($amount)) {
7332 $temps = sprintf(
"%10.10F", $amount - intval($amount));
7333 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
7335 $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand);
7341 if ($thousand !=
',' && $thousand !=
'.') {
7342 $amount = str_replace(
',',
'.', $amount);
7345 $amount = str_replace(
' ',
'', $amount);
7346 $amount = str_replace($thousand,
'', $amount);
7347 $amount = str_replace($dec,
'.', $amount);
7349 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
7367function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput =
'no', $use_short_label = 0)
7369 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
7371 if (($forceunitoutput ==
'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
7372 $dimension *= 1000000;
7374 } elseif (($forceunitoutput ==
'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) {
7377 } elseif (($forceunitoutput ==
'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) {
7378 $dimension /= 1000000;
7380 } elseif (($forceunitoutput ==
'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) {
7397 $ret =
price($dimension, 0, $outputlangs, 0, 0, $round);
7399 $ret .=
' '.measuringUnitString(0, $type, $unit, $use_short_label, $outputlangs);
7417function get_localtax($vatrate, $local, $thirdparty_buyer =
null, $thirdparty_seller =
null, $vatnpr = 0)
7419 global $db,
$conf, $mysoc;
7421 if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) {
7422 $thirdparty_seller = $mysoc;
7425 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);
7427 $vatratecleaned = $vatrate;
7429 if (preg_match(
'/^(.*)\s*\((.*)\)$/', (
string) $vatrate, $reg)) {
7430 $vatratecleaned = trim($reg[1]);
7431 $vatratecode = $reg[2];
7440 if ($mysoc->country_code ==
'ES') {
7442 if (!$mysoc->localtax1_assuj || (
string) $vatratecleaned ==
"0") {
7445 if ($thirdparty_seller->id == $mysoc->id) {
7446 if (!$thirdparty_buyer->localtax1_assuj) {
7450 if (!$thirdparty_seller->localtax1_assuj) {
7458 if (!$mysoc->localtax2_assuj) {
7461 if ($thirdparty_seller->id == $mysoc->id) {
7462 if (!$thirdparty_buyer->localtax2_assuj) {
7466 if (!$thirdparty_seller->localtax2_assuj) {
7472 if ($local == 1 && !$thirdparty_seller->localtax1_assuj) {
7475 if ($local == 2 && !$thirdparty_seller->localtax2_assuj) {
7481 if (in_array($mysoc->country_code, array(
'ES'))) {
7482 $conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY = 1;
7488 if ($thirdparty_seller != $mysoc) {
7490 return $thirdparty_seller->localtax1_value;
7499 if ($thirdparty_seller != $mysoc) {
7502 return $thirdparty_seller->localtax2_value;
7505 if (in_array($mysoc->country_code, array(
'ES'))) {
7506 return $thirdparty_buyer->localtax2_value;
7515 $sql =
"SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
7516 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7517 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdparty_seller->country_code).
"'";
7518 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7519 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7520 if (!empty($vatratecode)) {
7521 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
7523 $sql .=
" AND t.recuperableonly = '".$db->escape((
string) $vatnpr).
"'";
7526 $resql = $db->query($sql);
7529 $obj = $db->fetch_object($resql);
7532 return $obj->localtax1;
7533 } elseif ($local == 2) {
7534 return $obj->localtax2;
7555 $valors = explode(
":", $tax);
7557 if (count($valors) > 1) {
7574 $sql =
" SELECT t.localtax".$local.
" as localtax";
7575 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t INNER JOIN ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid = t.fk_pays";
7576 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.active = 1 AND t.entity IN (".
getEntity(
'c_tva').
") AND t.taux = (";
7577 $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";
7578 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.entity IN (".
getEntity(
'c_tva').
") AND tt.active = 1)";
7579 $sql .=
" AND t.localtax".$local.
"_type <> '0'";
7580 $sql .=
" ORDER BY t.rowid DESC";
7582 $resql = $db->query($sql);
7584 $obj = $db->fetch_object($resql);
7586 return $obj->localtax;
7607function getTaxesFromId($vatrate, $buyer =
null, $seller =
null, $firstparamisid = 1)
7611 dol_syslog(
"getTaxesFromId vat id or rate = ".$vatrate);
7614 $sql =
"SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy,";
7615 $sql .=
" t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
7616 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
7617 if ($firstparamisid) {
7618 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
7620 $vatratecleaned = $vatrate;
7623 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
7624 $vatratecleaned = $reg[1];
7625 $vatratecode = $reg[2];
7628 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
7631 $sql .=
" WHERE t.fk_pays = c.rowid";
7633 $sql .=
" AND c.code = '".$db->escape($buyer->country_code).
"'";
7635 $sql .=
" AND c.code = '".$db->escape($seller->country_code).
"'";
7637 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7638 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7640 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
7644 $resql = $db->query($sql);
7646 $obj = $db->fetch_object($resql);
7649 'rowid' => $obj->rowid,
7650 'code' => $obj->code,
7651 'rate' => $obj->rate,
7652 'localtax1' => $obj->localtax1,
7653 'localtax1_type' => $obj->localtax1_type,
7654 'localtax2' => $obj->localtax2,
7655 'localtax2_type' => $obj->localtax2_type,
7657 'accountancy_code_sell' => $obj->accountancy_code_sell,
7658 'accountancy_code_buy' => $obj->accountancy_code_buy
7690 dol_syslog(
"getLocalTaxesFromRate vatrate=".$vatrate.
" local=".$local);
7693 $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";
7694 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
7695 if ($firstparamisid) {
7696 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
7698 $vatratecleaned = $vatrate;
7701 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
7702 $vatratecleaned = $reg[1];
7703 $vatratecode = $reg[2];
7706 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
7707 if (!empty($mysoc) && $mysoc->country_code ==
'ES') {
7708 $countrycodetouse = ((empty($buyer) || empty($buyer->country_code)) ? $mysoc->country_code : $buyer->country_code);
7709 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
7711 $countrycodetouse = ((empty($seller) || empty($seller->country_code)) ? $mysoc->country_code : $seller->country_code);
7712 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
7714 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7716 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
7720 $resql = $db->query($sql);
7722 $obj = $db->fetch_object($resql);
7725 $vateratestring = $obj->rate.($obj->code ?
' ('.$obj->code.
')' :
'');
7728 return array($obj->localtax1_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
7729 } elseif ($local == 2) {
7730 return array($obj->localtax2_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
7732 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);
7754 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
7762 $product->fetch($idprod);
7764 if (($mysoc->country_code == $thirdpartytouse->country_code)
7765 || (in_array($mysoc->country_code, array(
'FR',
'MC')) && in_array($thirdpartytouse->country_code, array(
'FR',
'MC')))
7766 || (in_array($mysoc->country_code, array(
'MQ',
'GP')) && in_array($thirdpartytouse->country_code, array(
'MQ',
'GP')))
7769 if ($idprodfournprice > 0) {
7770 $result = $product->get_buyprice($idprodfournprice, 0, 0,
'');
7772 $ret = $product->vatrate_supplier;
7773 if ($product->default_vat_code_supplier) {
7774 $ret .=
' ('.$product->default_vat_code_supplier.
')';
7780 $ret = $product->tva_tx;
7781 if ($product->default_vat_code) {
7782 $ret .=
' ('.$product->default_vat_code.
')';
7795 $sql =
"SELECT t.taux as vat_rate, t.code as default_vat_code";
7796 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7797 $sql .=
" WHERE t.active = 1 AND t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdpartytouse->country_code).
"'";
7798 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7799 $sql .=
" ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC";
7800 $sql .= $db->plimit(1);
7802 $resql = $db->query($sql);
7804 $obj = $db->fetch_object($resql);
7806 $ret = $obj->vat_rate;
7807 if ($obj->default_vat_code) {
7808 $ret .=
' ('.$obj->default_vat_code.
')';
7832 dol_syslog(
"get_product_vat_for_country: ret=".$ret);
7849 if (!class_exists(
'Product')) {
7850 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
7859 $result = $product->fetch($idprod);
7861 if ($mysoc->country_code == $thirdpartytouse->country_code) {
7875 $sql =
"SELECT taux as vat_rate, localtax1, localtax2";
7876 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7877 $sql .=
" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdpartytouse->country_code).
"'";
7878 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7879 $sql .=
" ORDER BY t.taux DESC, t.recuperableonly ASC";
7880 $sql .= $db->plimit(1);
7882 $resql = $db->query($sql);
7884 $obj = $db->fetch_object($resql);
7887 $ret = $obj->localtax1;
7888 } elseif ($local == 2) {
7889 $ret = $obj->localtax2;
7897 dol_syslog(
"get_product_localtax_for_country: ret=".$ret);
7922 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
7925 $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;
7927 if (empty($thirdparty_seller->country_code)) {
7928 $thirdparty_seller->country_code = $mysoc->country_code;
7930 $seller_country_code = $thirdparty_seller->country_code;
7931 $seller_in_cee =
isInEEC($thirdparty_seller);
7933 if (empty($thirdparty_buyer->country_code)) {
7934 $thirdparty_buyer->country_code = $mysoc->country_code;
7936 $buyer_country_code = $thirdparty_buyer->country_code;
7937 $buyer_in_cee =
isInEEC($thirdparty_buyer);
7939 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'));
7944 if ($seller_in_cee && $buyer_in_cee) {
7945 $isacompany = $thirdparty_buyer->isACompany();
7946 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
7947 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
7961 if (!$seller_use_vat) {
7967 if (!empty($thirdparty_buyer->state_id)) {
7968 $sql =
"SELECT d.rowid, t.taux as vat_default_rate, t.code as vat_default_code ";
7969 $sql .=
" FROM ".$db->prefix().
"c_tva as t";
7970 $sql .=
" INNER JOIN ".$db->prefix().
"c_departements as d ON t.fk_department_buyer = d.rowid";
7971 $sql .=
" WHERE d.rowid = ".((int) $thirdparty_buyer->state_id);
7972 $sql .=
" ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC";
7974 $res = $db->query($sql);
7976 if ($db->num_rows($res)) {
7977 $obj = $db->fetch_object($res);
7978 return $obj->vat_default_rate.
' ('.$obj->vat_default_code.
')';
7985 if (($seller_country_code == $buyer_country_code)
7986 || (in_array($seller_country_code, array(
'FR',
'MC')) && in_array($buyer_country_code, array(
'FR',
'MC')))
7987 || (in_array($seller_country_code, array(
'MQ',
'GP')) && in_array($buyer_country_code, array(
'MQ',
'GP')))
7992 if ($seller_country_code ==
'IN' &&
getDolGlobalString(
'MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA')) {
7996 if (preg_match(
'/C+S-(\d+)/', $tmpvat, $reg) && $thirdparty_seller->state_id != $thirdparty_buyer->state_id) {
7998 $tmpvat = str_replace(
"C+S",
"I", $tmpvat);
7999 } elseif (preg_match(
'/I-(\d+)/', $tmpvat, $reg) && $thirdparty_seller->state_id == $thirdparty_buyer->state_id) {
8001 $tmpvat = str_replace(
"I",
"C+S", $tmpvat);
8013 if (($seller_in_cee && $buyer_in_cee)) {
8014 $isacompany = $thirdparty_buyer->isACompany();
8015 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
8016 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
8033 if (
getDolGlobalString(
'MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC') && empty($buyer_in_cee)) {
8034 $isacompany = $thirdparty_buyer->isACompany();
8062 if ($idprodfournprice > 0) {
8063 if (!class_exists(
'ProductFournisseur')) {
8064 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
8067 $prodprice->fetch_product_fournisseur_price($idprodfournprice);
8068 return $prodprice->fourn_tva_npr;
8069 } elseif ($idprod > 0) {
8070 if (!class_exists(
'Product')) {
8071 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
8074 $prod->fetch($idprod);
8075 return $prod->tva_npr;
8098 if (!is_object($thirdparty_seller)) {
8101 if (!is_object($thirdparty_buyer)) {
8105 if (empty($thirdparty_seller->country_code)) {
8106 $thirdparty_seller->country_code = $mysoc->country_code;
8108 $seller_country_code = $thirdparty_seller->country_code;
8111 if (empty($thirdparty_buyer->country_code)) {
8112 $thirdparty_buyer->country_code = $mysoc->country_code;
8114 $buyer_country_code = $thirdparty_buyer->country_code;
8118 if ($mysoc->country_code ==
'ES') {
8119 if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) {
8124 if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) {
8127 if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj ==
'localtax1off') {
8131 } elseif ($local == 2) {
8133 if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) {
8136 if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj ==
'localtax2off') {
8141 if ($seller_country_code == $buyer_country_code) {
8156function yn($yesno, $format = 1, $color = 0)
8160 $result =
'unknown';
8162 if ($yesno == 1 || (isset($yesno) && (strtolower($yesno) ==
'yes' || strtolower($yesno) ==
'true'))) {
8163 $result = $langs->trans(
'yes');
8164 if ($format == 1 || $format == 3) {
8165 $result = $langs->trans(
"Yes");
8168 $result =
'<input type="checkbox" value="1" checked disabled>';
8171 $result =
'<input type="checkbox" value="1" checked disabled> '.$result;
8173 if ($format == 4 || !is_numeric($format)) {
8174 $result =
img_picto(is_numeric($format) ?
'' : $format,
'check');
8178 } elseif ($yesno == 0 || strtolower($yesno) ==
'no' || strtolower($yesno) ==
'false') {
8179 $result = $langs->trans(
"no");
8180 if ($format == 1 || $format == 3) {
8181 $result = $langs->trans(
"No");
8184 $result =
'<input type="checkbox" value="0" disabled>';
8187 $result =
'<input type="checkbox" value="0" disabled> '.$result;
8189 if ($format == 4 || !is_numeric($format)) {
8190 $result =
img_picto(is_numeric($format) ?
'' : $format,
'uncheck');
8196 $classname =
'error';
8200 return '<span class="'.$classname.
'">'.$result.
'</span>';
8223function get_exdir($num, $level, $alpha, $withoutslash,
$object, $modulepart =
'')
8225 if (empty($modulepart) && is_object(
$object)) {
8226 if (!empty(
$object->module)) {
8227 $modulepart =
$object->module;
8228 } elseif (!empty(
$object->element)) {
8229 $modulepart =
$object->element;
8236 $arrayforoldpath = array(
'cheque' => 2,
'category' => 2,
'holiday' => 2,
'supplier_invoice' => 2,
'invoice_supplier' => 2,
'mailing' => 2,
'supplier_payment' => 2);
8238 $arrayforoldpath[
'product'] = 2;
8241 if (empty($level) && array_key_exists($modulepart, $arrayforoldpath)) {
8242 $level = $arrayforoldpath[$modulepart];
8244 if (!empty($level) && array_key_exists($modulepart, $arrayforoldpath)) {
8246 if (empty($num) && is_object(
$object)) {
8249 if (empty($alpha)) {
8250 $num = preg_replace(
'/([^0-9])/i',
'', $num);
8252 $num = preg_replace(
'/^.*\-/i',
'', $num);
8254 $num = substr(
"000".$num, -$level);
8256 $path = substr($num, 0, 1);
8259 $path = substr($num, 1, 1).
'/'.substr($num, 0, 1);
8262 $path = substr($num, 2, 1).
'/'.substr($num, 1, 1).
'/'.substr($num, 0, 1);
8268 if (in_array($modulepart, array(
'societe',
'thirdparty')) &&
$object instanceOf
Societe) {
8276 if (empty($withoutslash) && !empty($path)) {
8291function dol_mkdir($dir, $dataroot =
'', $newmask =
'')
8293 dol_syslog(
"functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
8298 if (@is_dir($dir_osencoded)) {
8306 if (!empty($dataroot)) {
8308 $dir = str_replace($dataroot.
'/',
'', $dir);
8309 $ccdir = $dataroot.
'/';
8312 $cdir = explode(
"/", $dir);
8313 $num = count($cdir);
8314 for ($i = 0; $i < $num; $i++) {
8316 $ccdir .=
'/'.$cdir[$i];
8318 $ccdir .= $cdir[$i];
8321 if (preg_match(
"/^.:$/", $ccdir, $regs)) {
8329 if (!@is_dir($ccdir_osencoded)) {
8330 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' is not found (does not exists or is outside open_basedir PHP setting).", LOG_DEBUG);
8333 $dirmaskdec = octdec((
string) $newmask);
8334 if (empty($newmask)) {
8337 $dirmaskdec |= octdec(
'0111');
8338 if (!@mkdir($ccdir_osencoded, $dirmaskdec)) {
8340 dol_syslog(
"functions.lib::dol_mkdir: Fails to create directory '".$ccdir.
"' (no permission to write into parent or directory already exists).", LOG_WARNING);
8343 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' created", LOG_DEBUG);
8352 return ($nberr ? -$nberr : $nbcreated);
8363function dolChmod($filepath, $newmask =
'')
8365 if (!empty($newmask)) {
8366 @chmod($filepath, octdec($newmask));
8380 return '<span class="fieldrequired">*</span>';
8400function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
'UTF-8', $strip_tags = 0, $removedoublespaces = 1)
8402 if (is_null($stringtoclean)) {
8406 if ($removelinefeed == 2) {
8407 $stringtoclean = preg_replace(
'/<br[^>]*>(\n|\r)+/ims',
'<br>', $stringtoclean);
8409 $temp = preg_replace(
'/<br[^>]*>/i',
"\n", $stringtoclean);
8414 $temp = str_replace(
'< ',
'__ltspace__', $temp);
8415 $temp = str_replace(
'<:',
'__lttwopoints__', $temp);
8418 $temp = strip_tags($temp);
8421 $pattern =
"/<[^<>]+>/";
8428 $tempbis = str_replace(
'<>',
'', $temp);
8429 $tempbis = preg_replace($pattern,
'', $tempbis);
8431 }
while ($tempbis != $temp);
8436 $temp = preg_replace(
'/<+([a-z]+)/i',
'\1', $temp);
8442 if ($removelinefeed == 1) {
8443 $temp = str_replace(array(
"\r\n",
"\r",
"\n"),
" ", $temp);
8447 if ($removedoublespaces) {
8448 while (strpos($temp,
" ")) {
8449 $temp = str_replace(
" ",
" ", $temp);
8453 $temp = str_replace(
'__ltspace__',
'< ', $temp);
8454 $temp = str_replace(
'__lttwopoints__',
'<:', $temp);
8478function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $removeclassattribute = 1, $cleanalsojavascript = 0, $allowiframe = 0, $allowed_tags = array(), $allowlink = 0, $allowscript = 0, $allowstyle = 0, $allowphp = 0)
8480 if (empty($allowed_tags)) {
8481 $allowed_tags = array(
8482 "html",
"head",
"meta",
"body",
"article",
"a",
"abbr",
"b",
"blockquote",
"br",
"cite",
"div",
"dl",
"dd",
"dt",
"em",
"font",
"img",
"ins",
"hr",
"i",
"li",
8483 "ol",
"p",
"q",
"s",
"span",
"strike",
"strong",
"title",
"table",
"tr",
"th",
"td",
"u",
"ul",
"sup",
"sub",
"blockquote",
"pre",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
8484 "header",
"footer",
"nav",
"section",
"menu",
"menuitem"
8487 $allowed_tags[] =
"comment";
8489 if (!in_array(
'iframe', $allowed_tags)) {
8490 $allowed_tags[] =
"iframe";
8494 if (!in_array(
'link', $allowed_tags)) {
8495 $allowed_tags[] =
"link";
8499 if (!in_array(
'script', $allowed_tags)) {
8500 $allowed_tags[] =
"script";
8504 if (!in_array(
'style', $allowed_tags)) {
8505 $allowed_tags[] =
"style";
8509 $allowed_tags_string = implode(
"><", $allowed_tags);
8510 $allowed_tags_string =
'<'.$allowed_tags_string.
'>';
8512 $stringtoclean = str_replace(
'<!DOCTYPE html>',
'__!DOCTYPE_HTML__', $stringtoclean);
8517 $stringtoclean = preg_replace(
'/<!--([^>]*)-->/',
'<comment>\1</comment>', $stringtoclean);
8520 $allowed_tags[] =
"commentphp";
8521 $stringtoclean = preg_replace(
'/^<\?php([^"]+)\?>$/i',
'<commentphp>\1__</commentphp>', $stringtoclean);
8522 $stringtoclean = preg_replace(
'/"<\?php([^"]+)\?>"/i',
'"<commentphp>\1</commentphp>"', $stringtoclean);
8525 $stringtoclean = preg_replace(
'/:/i',
':', $stringtoclean);
8526 $stringtoclean = preg_replace(
'/:|�+58|:/i',
'', $stringtoclean);
8529 $temp = strip_tags($stringtoclean, $allowed_tags_string);
8531 if ($cleanalsosomestyles) {
8532 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/i',
'', $temp);
8534 if ($removeclassattribute) {
8535 $temp = preg_replace(
'/(<[^>]+)\s+class=((["\']).*?\\3|\\w*)/i',
'\\1', $temp);
8540 if ($cleanalsojavascript) {
8541 $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);
8544 $temp = str_replace(
'__!DOCTYPE_HTML__',
'<!DOCTYPE html>', $temp);
8547 $temp = preg_replace(
'/<commentphp>(.*)<\/commentphp>/',
'<?php\1?>', $temp);
8550 $temp = preg_replace(
'/<comment>([^>]*)<\/comment>/',
'<!--\1-->', $temp);
8571 if (is_null($allowed_attributes)) {
8572 $allowed_attributes = array(
8573 "allow",
"allowfullscreen",
"alt",
"async",
"class",
"contenteditable",
"crossorigin",
"data-html",
"frameborder",
"height",
"href",
"id",
"name",
"property",
"rel",
"src",
"style",
"target",
"title",
"type",
"width",
8575 "header",
"footer",
"nav",
"section",
"menu",
"menuitem"
8579 if (!in_array(
"content", $allowed_attributes)) {
8580 $allowed_attributes[] =
"content";
8582 if (!in_array(
"http-equiv", $allowed_attributes)) {
8583 $allowed_attributes[] =
"http-equiv";
8586 if (class_exists(
'DOMDocument') && !empty($stringtoclean)) {
8588 $stringtoclean =
'<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>'.$stringtoclean.
'</body></html>';
8591 $dom =
new DOMDocument(
'',
'UTF-8');
8593 $savwarning = error_reporting();
8594 error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);
8595 $dom->loadHTML($stringtoclean, LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOXMLDECL);
8596 error_reporting($savwarning);
8598 if ($dom instanceof DOMDocument) {
8599 for ($els = $dom->getElementsByTagname(
'*'), $i = $els->length - 1; $i >= 0; $i--) {
8600 $el = $els->item($i);
8601 if (!$el instanceof DOMElement) {
8604 $attrs = $el->attributes;
8605 for ($ii = $attrs->length - 1; $ii >= 0; $ii--) {
8607 if (!empty($attrs->item($ii)->name)) {
8608 if (! in_array($attrs->item($ii)->name, $allowed_attributes)) {
8610 $els->item($i)->removeAttribute($attrs->item($ii)->name);
8611 } elseif (in_array($attrs->item($ii)->name, array(
'style'))) {
8613 $valuetoclean = $attrs->item($ii)->value;
8615 if (isset($valuetoclean)) {
8617 $oldvaluetoclean = $valuetoclean;
8618 $valuetoclean = preg_replace(
'/\/\*.*\*\//m',
'', $valuetoclean);
8619 $valuetoclean = preg_replace(
'/position\s*:\s*[a-z]+/mi',
'', $valuetoclean);
8620 if ($els->item($i)->tagName ==
'a') {
8621 $valuetoclean = preg_replace(
'/display\s*:/mi',
'', $valuetoclean);
8622 $valuetoclean = preg_replace(
'/z-index\s*:/mi',
'', $valuetoclean);
8623 $valuetoclean = preg_replace(
'/\s+(top|left|right|bottom)\s*:/mi',
'', $valuetoclean);
8627 $valuetoclean = preg_replace(
'/(logout|passwordforgotten)\.php/mi',
'', $valuetoclean);
8628 $valuetoclean = preg_replace(
'/action=/mi',
'', $valuetoclean);
8629 }
while ($oldvaluetoclean != $valuetoclean);
8632 $attrs->item($ii)->value = $valuetoclean;
8639 $dom->encoding =
'UTF-8';
8641 $return = $dom->saveHTML();
8645 $return = preg_replace(
'/^'.preg_quote(
'<html><head><',
'/').
'[^<>]*'.preg_quote(
'></head><body>',
'/').
'/',
'', $return);
8646 $return = preg_replace(
'/'.preg_quote(
'</body></html>',
'/').
'$/',
'', trim($return));
8648 return trim($return);
8650 return $stringtoclean;
8667 $temp = $stringtoclean;
8668 foreach ($disallowed_tags as $tagtoremove) {
8669 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'>/',
'', $temp);
8670 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'\s+[^>]*>/',
'', $temp);
8673 if ($cleanalsosomestyles) {
8674 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/',
'', $temp);
8692 if ($nboflines == 1) {
8694 $firstline = preg_replace(
'/<br[^>]*>.*$/s',
'', $text);
8695 $firstline = preg_replace(
'/<div[^>]*>.*$/s',
'', $firstline);
8698 $firstline = preg_replace(
'/[\n\r].*/',
'', $text);
8703 return $firstline.(isset($firstline) && isset($text) && (strlen($firstline) != strlen($text)) ?
'...' :
'');
8707 $text = preg_replace(
'/\n/',
'', $text);
8709 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8711 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8714 $text = strtr($text, $repTable);
8715 if ($charset ==
'UTF-8') {
8716 $pattern =
'/(<br[^>]*>)/Uu';
8719 $pattern =
'/(<br[^>]*>)/U';
8721 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
8726 $lastaddediscontent = 1;
8727 while ($countline < $nboflines && isset($a[$i])) {
8728 if (preg_match(
'/<br[^>]*>/', $a[$i])) {
8729 if (array_key_exists($i + 1, $a) && !empty($a[$i + 1])) {
8730 $firstline .= ($ishtml ?
"<br>\n" :
"\n");
8732 if (!$lastaddediscontent) {
8735 $lastaddediscontent = 0;
8738 $firstline .= $a[$i];
8739 $lastaddediscontent = 1;
8745 $adddots = (isset($a[$i]) && (!preg_match(
'/<br[^>]*>/', $a[$i]) || (array_key_exists($i + 1, $a) && !empty($a[$i + 1]))));
8747 $ret = $firstline.($adddots ?
'...' :
'');
8765function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml =
false)
8767 if (is_null($stringtoencode)) {
8772 return nl2br($stringtoencode, $forxml);
8774 $ret = preg_replace(
'/(\r\n|\r|\n)/i', ($forxml ?
'<br />' :
'<br>'), $stringtoencode);
8788function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check =
'restricthtml')
8790 if (empty($nouseofiframesandbox) &&
getDolGlobalString(
'MAIN_SECURITY_USE_SANDBOX_FOR_HTMLWITHNOJS')) {
8795 return $stringtoencode;
8797 $out = $stringtoencode;
8801 $oldstringtoclean = $out;
8809 if (!empty($out) &&
getDolGlobalString(
'MAIN_RESTRICTHTML_ONLY_VALID_HTML') && $check !=
'restricthtmlallowunvalid') {
8811 libxml_use_internal_errors(
false);
8812 if (LIBXML_VERSION < 20900) {
8816 libxml_disable_entity_loader(
true);
8819 $dom =
new DOMDocument();
8827 $out =
'<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body><div class="tricktoremove">'.$out.
'</div></body></html>';
8831 $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>';
8835 $dom->loadHTML($out, LIBXML_HTML_NODEFDTD | LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOERROR | LIBXML_NOXMLDECL);
8837 $dom->encoding =
'UTF-8';
8839 $out = trim($dom->saveHTML());
8843 $out = preg_replace(
'/^'.preg_quote(
'<html><head><',
'/').
'[^<>]+'.preg_quote(
'></head><body><div class="tricktoremove">',
'/').
'/',
'', $out);
8844 $out = preg_replace(
'/'.preg_quote(
'</div></body></html>',
'/').
'$/',
'', trim($out));
8850 $out = str_replace(
'<br>',
'', $out);
8855 $out =
'InvalidHTMLStringCantBeCleaned '.$e->getMessage();
8862 if (!empty($out) &&
getDolGlobalString(
'MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY') && !in_array($check, array(
'restricthtmlallowunvalid',
'restricthtmlallowlinkscript')) && $outishtml) {
8868 if (extension_loaded(
'tidy') && class_exists(
"tidy")) {
8875 'quote-marks' =>
false,
8876 'doctype' =>
'strict',
8877 'show-body-only' =>
true,
8878 "indent-attributes" =>
false,
8879 "vertical-space" =>
false,
8882 'preserve-entities' =>
true
8892 $out = $tidy->repairString($out, $config,
'utf8');
8901 $out =
'InvalidHTMLStringCantBeCleaned '.$e->getMessage();
8906 $out = preg_replace(
'/[\x{200B}-\x{200D}\x{FEFF}]/u',
' ', $out);
8909 $out = preg_replace(
'/&(tab|newline);/i',
' ', $out);
8913 $out = preg_replace(
'/'/i',
''', $out);
8918 if (function_exists(
'realCharForNumericEntities')) {
8919 $out = preg_replace_callback(
8920 '/&#(x?[0-9][0-9a-f]+;?)/i',
8925 static function ($m) {
8933 $out = preg_replace(
'/&#x?[0-9]+/i',
'', $out);
8936 if ($check ==
'restricthtmlallowlinkscript') {
8938 } elseif ($check ==
'restricthtmlallowclass' || $check ==
'restricthtmlallowunvalid') {
8940 } elseif ($check ==
'restricthtmlallowiframe') {
8953 $out = preg_replace(
'/'/i',
"'", $out);
8957 $out = preg_replace(
'/on(mouse|drag|key|load|touch|pointer|select|transition)[a-z]*\s*=/i',
'', $out);
8958 $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);
8959 $out = preg_replace(
'/on(dblclick|drop|durationchange|emptied|end|ended|error|focus(in|out)?|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i',
'', $out);
8960 $out = preg_replace(
'/on(lostpointercapture|offline|online|pagehide|pageshow)[a-z]*\s*=/i',
'', $out);
8961 $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);
8962 $out = preg_replace(
'/on(timeupdate|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i',
'', $out);
8964 $out = preg_replace(
'/on(repeat|begin|finish|beforeinput)[a-z]*\s*=/i',
'', $out);
8965 }
while ($oldstringtoclean != $out);
8972 $tmpout = preg_replace(
'/<img src="data:/mi',
'<__IMG_SRC_DATA__ src="data:', $out);
8973 preg_match_all(
'/(<img|url\(|<link)/i', $tmpout, $reg);
8974 $nblinks = count($reg[0]);
8975 if ($nblinks >
getDolGlobalInt(
"MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 1000)) {
8976 $out =
'ErrorTooManyLinksIntoHTMLString';
8979 if (
getDolGlobalInt(
'MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 2 || $check ==
'restricthtmlnolink') {
8981 $out =
'ErrorHTMLLinksNotAllowed';
8983 } elseif (
getDolGlobalInt(
'MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 1) {
8986 $pattern =
'/src=["\']?(http[^"\']+)|url\(["\']?(http[^\)]+)/';
8989 if (preg_match_all($pattern, $out, $matches)) {
8991 $urls = $matches[1];
8994 foreach ($urls as $url) {
8996 echo
"Found url = ".$url .
"\n";
8999 $out =
'ErrorHTMLExternalLinksNotAllowed';
9028function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom =
'UTF-8', $removelasteolbr = 1)
9030 if (is_null($stringtoencode)) {
9034 $newstring = $stringtoencode;
9036 $newstring = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
'<br>', $newstring);
9037 if ($removelasteolbr) {
9038 $newstring = preg_replace(
'/<br>$/i',
'', $newstring);
9040 $newstring = preg_replace(
'/[\x{200B}-\x{200D}\x{FEFF}]/u',
' ', $newstring);
9041 $newstring = strtr($newstring, array(
'&' =>
'__PROTECTand__',
'<' =>
'__PROTECTlt__',
'>' =>
'__PROTECTgt__',
'"' =>
'__PROTECTdquot__'));
9043 $newstring = strtr($newstring, array(
'__PROTECTand__' =>
'&',
'__PROTECTlt__' =>
'<',
'__PROTECTgt__' =>
'>',
'__PROTECTdquot__' =>
'"'));
9045 if ($removelasteolbr) {
9046 $newstring = preg_replace(
'/(\r\n|\r|\n)$/i',
'', $newstring);
9065 $ret = preg_replace(
'/'.
"\r\n".
'<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"<br>", $ret);
9066 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\r\n".
'/i',
"\r\n", $ret);
9067 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\n".
'/i',
"\n", $ret);
9068 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"\n", $ret);
9080 $ret = preg_replace(
'/ $/i',
"", $stringtodecode);
9081 $ret = preg_replace(
'/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'.
"\n".
'|'.
"\r".
')+$/i',
"", $ret);
9097 if ($keepsomeentities) {
9098 $newstring = strtr($newstring, array(
'&' =>
'__andamp__',
'<' =>
'__andlt__',
'>' =>
'__andgt__',
'"' =>
'__dquot__'));
9100 $newstring = html_entity_decode((
string) $newstring, (
int) $b, (
string)
$c);
9101 if ($keepsomeentities) {
9102 $newstring = strtr($newstring, array(
'__andamp__' =>
'&',
'__andlt__' =>
'<',
'__andgt__' =>
'>',
'__dquot__' =>
'"'));
9118function dol_htmlentities($string, $flags = ENT_QUOTES | ENT_SUBSTITUTE, $encoding =
'UTF-8', $double_encode =
false)
9120 return htmlentities($string, $flags, $encoding, $double_encode);
9139 for ($scursor = 0; $scursor < $len; $scursor++) {
9140 $ordchar = ord($s[$scursor]);
9142 if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) {
9145 } elseif ($ordchar > 126 && $ordchar < 160) {
9149 $out .= $s[$scursor];
9171 $arraystring = explode(
"\n", $s);
9172 $nb = count($arraystring);
9189 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
9191 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
9194 $text = strtr($text, $repTable);
9195 if ($charset ==
'UTF-8') {
9196 $pattern =
'/(<br[^>]*>)/Uu';
9199 $pattern =
'/(<br[^>]*>)/U';
9201 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
9203 $nblines = (int) floor((count($a) + 1) / 2);
9206 foreach ($a as $line) {
9209 $line_dec = html_entity_decode($line);
9211 $line_dec = wordwrap($line_dec, $maxlinesize,
'\n',
true);
9212 $nblines += substr_count($line_dec,
'\n');
9232 if (is_null($msg)) {
9237 if (preg_match(
'/<(html|link|script)/i', $msg)) {
9239 } elseif (preg_match(
'/<body/i', $msg)) {
9241 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
9243 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
9245 } elseif (preg_match(
'/<br/i', $msg)) {
9251 $msg = preg_replace(
'/https?:\/\/[^"\'\s]+/i',
'', $msg);
9252 if (preg_match(
'/<(html|link|script|body)/i', $msg)) {
9254 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
9256 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
9258 } elseif (preg_match(
'/<(br|hr)\/>/i', $msg)) {
9260 } elseif (preg_match(
'/<(br|hr|div|font|li|p|span|strong|table)>/i', $msg)) {
9262 } elseif (preg_match(
'/<(br|hr|div|font|li|p|span|strong|table)\s+[^<>\/]*\/?>/i', $msg)) {
9264 } elseif (preg_match(
'/<img\s+[^<>]*src[^<>]*>/i', $msg)) {
9266 } elseif (preg_match(
'/<a\s+[^<>]*href[^<>]*>/i', $msg)) {
9268 } elseif (preg_match(
'/<h[0-9]>/i', $msg)) {
9270 } elseif (preg_match(
'/&[A-Z0-9]{1,6};/i', $msg)) {
9273 } elseif (preg_match(
'/&#[0-9]{2,3};/i', $msg)) {
9275 } elseif (preg_match(
'/&#x[a-f0-9][a-f0-9];/i', $msg)) {
9297function dol_concatdesc($text1, $text2, $forxml =
false, $invert =
false)
9299 if (!empty($invert)) {
9307 $ret .= (!empty($text1) && !empty($text2)) ? ((
dol_textishtml($text1) ||
dol_textishtml($text2)) ? ($forxml ?
"<br >\n" :
"<br>\n") :
"\n") :
"";
9327function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude =
null,
$object =
null, $include =
null)
9329 global $db,
$conf, $mysoc, $user, $extrafields;
9331 $substitutionarray = array();
9333 if ((empty($exclude) || !in_array(
'user', $exclude)) && (empty($include) || in_array(
'user', $include)) && $user instanceof
User) {
9337 $emailsendersignature = $user->signature;
9338 $usersignature = $user->signature;
9339 $substitutionarray = array_merge($substitutionarray, array(
9340 '__SENDEREMAIL_SIGNATURE__' => (
string) ((!
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? ($onlykey == 2 ?
dol_trunc(
'SignatureFromTheSelectedSenderProfile', 30) : $emailsendersignature) :
''),
9344 if (is_object($user) && ($user instanceof
User)) {
9345 $substitutionarray = array_merge($substitutionarray, array(
9346 '__USER_ID__' => (
string) $user->id,
9347 '__USER_LOGIN__' => (
string) $user->login,
9348 '__USER_EMAIL__' => (
string) $user->email,
9349 '__USER_PHONE__' => (
string)
dol_print_phone($user->office_phone,
'', 0, 0,
'',
" ",
'',
'', -1),
9350 '__USER_PHONEPRO__' => (
string)
dol_print_phone($user->user_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
9351 '__USER_PHONEMOBILE__' => (
string)
dol_print_phone($user->personal_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
9352 '__USER_FAX__' => (
string) $user->office_fax,
9353 '__USER_LASTNAME__' => (
string) $user->lastname,
9354 '__USER_FIRSTNAME__' => (
string) $user->firstname,
9355 '__USER_FULLNAME__' => (
string) $user->getFullName($outputlangs),
9356 '__USER_SUPERVISOR_ID__' => (
string) ($user->fk_user ? $user->fk_user :
'0'),
9357 '__USER_JOB__' => (string) $user->job,
9359 '__USER_VCARD_URL__' => (string) $user->getOnlineVirtualCardUrl(
'',
'external')
9363 if ((empty($exclude) || !in_array(
'mycompany', $exclude)) && is_object($mysoc) && (empty($include) || in_array(
'mycompany', $include))) {
9364 $substitutionarray = array_merge($substitutionarray, array(
9365 '__MYCOMPANY_NAME__' => $mysoc->name,
9366 '__MYCOMPANY_EMAIL__' => $mysoc->email,
9367 '__MYCOMPANY_URL__' => $mysoc->url,
9368 '__MYCOMPANY_PHONE__' =>
dol_print_phone($mysoc->phone,
'', 0, 0,
'',
" ",
'',
'', -1),
9369 '__MYCOMPANY_PHONEMOBILE__' =>
dol_print_phone($mysoc->phone_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
9370 '__MYCOMPANY_FAX__' =>
dol_print_phone($mysoc->fax,
'', 0, 0,
'',
" ",
'',
'', -1),
9371 '__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
9372 '__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
9373 '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
9374 '__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
9375 '__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
9376 '__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
9377 '__MYCOMPANY_PROFID7__' => $mysoc->idprof7,
9378 '__MYCOMPANY_PROFID8__' => $mysoc->idprof8,
9379 '__MYCOMPANY_PROFID9__' => $mysoc->idprof9,
9380 '__MYCOMPANY_PROFID10__' => $mysoc->idprof10,
9381 '__MYCOMPANY_CAPITAL__' => $mysoc->capital,
9382 '__MYCOMPANY_FULLADDRESS__' => (method_exists($mysoc,
'getFullAddress') ? $mysoc->getFullAddress(1,
', ') :
''),
9383 '__MYCOMPANY_ADDRESS__' => $mysoc->
address,
9384 '__MYCOMPANY_ZIP__' => $mysoc->zip,
9385 '__MYCOMPANY_TOWN__' => $mysoc->town,
9386 '__MYCOMPANY_STATE__' => $mysoc->state,
9387 '__MYCOMPANY_COUNTRY__' => $mysoc->country,
9388 '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id,
9389 '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code,
9390 '__MYCOMPANY_CURRENCY_CODE__' =>
$conf->currency
9394 if (($onlykey || is_object(
$object)) && (empty($exclude) || !in_array(
'object', $exclude)) && (empty($include) || in_array(
'object', $include))) {
9396 $substitutionarray[
'__ID__'] =
'__ID__';
9397 $substitutionarray[
'__REF__'] =
'__REF__';
9398 $substitutionarray[
'__NEWREF__'] =
'__NEWREF__';
9399 $substitutionarray[
'__LABEL__'] =
'__LABEL__';
9400 $substitutionarray[
'__REF_CLIENT__'] =
'__REF_CLIENT__';
9401 $substitutionarray[
'__REF_SUPPLIER__'] =
'__REF_SUPPLIER__';
9402 $substitutionarray[
'__NOTE_PUBLIC__'] =
'__NOTE_PUBLIC__';
9403 $substitutionarray[
'__NOTE_PRIVATE__'] =
'__NOTE_PRIVATE__';
9404 $substitutionarray[
'__EXTRAFIELD_XXX__'] =
'__EXTRAFIELD_XXX__';
9406 if (isModEnabled(
"societe")) {
9407 $substitutionarray[
'__THIRDPARTY_ID__'] =
'__THIRDPARTY_ID__';
9408 $substitutionarray[
'__THIRDPARTY_NAME__'] =
'__THIRDPARTY_NAME__';
9409 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
'__THIRDPARTY_NAME_ALIAS__';
9410 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
'__THIRDPARTY_CODE_CLIENT__';
9411 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
'__THIRDPARTY_CODE_FOURNISSEUR__';
9412 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
'__THIRDPARTY_EMAIL__';
9414 $substitutionarray[
'__THIRDPARTY_URL__'] =
'__THIRDPARTY_URL__';
9416 $substitutionarray[
'__THIRDPARTY_PHONE__'] =
'__THIRDPARTY_PHONE__';
9417 $substitutionarray[
'__THIRDPARTY_FAX__'] =
'__THIRDPARTY_FAX__';
9418 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
'__THIRDPARTY_ADDRESS__';
9419 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
'__THIRDPARTY_ZIP__';
9420 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
'__THIRDPARTY_TOWN__';
9421 $substitutionarray[
'__THIRDPARTY_STATE__'] =
'__THIRDPARTY_STATE__';
9422 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
'__THIRDPARTY_IDPROF1__';
9423 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
'__THIRDPARTY_IDPROF2__';
9424 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
'__THIRDPARTY_IDPROF3__';
9425 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
'__THIRDPARTY_IDPROF4__';
9426 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
'__THIRDPARTY_IDPROF5__';
9427 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
'__THIRDPARTY_IDPROF6__';
9428 $substitutionarray[
'__THIRDPARTY_IDPROF7__'] =
'__THIRDPARTY_IDPROF7__';
9429 $substitutionarray[
'__THIRDPARTY_IDPROF8__'] =
'__THIRDPARTY_IDPROF8__';
9430 $substitutionarray[
'__THIRDPARTY_IDPROF9__'] =
'__THIRDPARTY_IDPROF9__';
9431 $substitutionarray[
'__THIRDPARTY_IDPROF10__'] =
'__THIRDPARTY_IDPROF10__';
9432 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
'__THIRDPARTY_TVAINTRA__';
9433 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] =
'__THIRDPARTY_NOTE_PUBLIC__';
9434 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] =
'__THIRDPARTY_NOTE_PRIVATE__';
9436 if (isModEnabled(
'member') && (!is_object(
$object) ||
$object->element ==
'adherent') && (empty($exclude) || !in_array(
'member', $exclude)) && (empty($include) || in_array(
'member', $include))) {
9437 $substitutionarray[
'__MEMBER_ID__'] =
'__MEMBER_ID__';
9438 $substitutionarray[
'__MEMBER_TITLE__'] =
'__MEMBER_TITLE__';
9439 $substitutionarray[
'__MEMBER_FIRSTNAME__'] =
'__MEMBER_FIRSTNAME__';
9440 $substitutionarray[
'__MEMBER_LASTNAME__'] =
'__MEMBER_LASTNAME__';
9441 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'Login and pass of the external user account';
9446 if (isModEnabled(
'ticket') && (!is_object(
$object) ||
$object->element ==
'ticket') && (empty($exclude) || !in_array(
'ticket', $exclude)) && (empty($include) || in_array(
'ticket', $include))) {
9447 $substitutionarray[
'__TICKET_TRACKID__'] =
'__TICKET_TRACKID__';
9448 $substitutionarray[
'__TICKET_SUBJECT__'] =
'__TICKET_SUBJECT__';
9449 $substitutionarray[
'__TICKET_TYPE__'] =
'__TICKET_TYPE__';
9450 $substitutionarray[
'__TICKET_SEVERITY__'] =
'__TICKET_SEVERITY__';
9451 $substitutionarray[
'__TICKET_CATEGORY__'] =
'__TICKET_CATEGORY__';
9452 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
'__TICKET_ANALYTIC_CODE__';
9453 $substitutionarray[
'__TICKET_MESSAGE__'] =
'__TICKET_MESSAGE__';
9454 $substitutionarray[
'__TICKET_PROGRESSION__'] =
'__TICKET_PROGRESSION__';
9455 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
'__TICKET_USER_ASSIGN__';
9458 if (isModEnabled(
'recruitment') && (!is_object(
$object) ||
$object->element ==
'recruitmentcandidature') && (empty($exclude) || !in_array(
'recruitment', $exclude)) && (empty($include) || in_array(
'recruitment', $include))) {
9459 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
'__CANDIDATE_FULLNAME__';
9460 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] =
'__CANDIDATE_FIRSTNAME__';
9461 $substitutionarray[
'__CANDIDATE_LASTNAME__'] =
'__CANDIDATE_LASTNAME__';
9463 if (isModEnabled(
'project') && (empty($exclude) || !in_array(
'project', $exclude)) && (empty($include) || in_array(
'project', $include))) {
9464 $substitutionarray[
'__PROJECT_ID__'] =
'__PROJECT_ID__';
9465 $substitutionarray[
'__PROJECT_REF__'] =
'__PROJECT_REF__';
9466 $substitutionarray[
'__PROJECT_NAME__'] =
'__PROJECT_NAME__';
9470 if (isModEnabled(
'contract') && (!is_object(
$object) ||
$object->element ==
'contract') && (empty($exclude) || !in_array(
'contract', $exclude)) && (empty($include) || in_array(
'contract', $include))) {
9471 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
'Highest date planned for a service start';
9472 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
'Highest date and hour planned for service start';
9473 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
'Lowest data for planned expiration of service';
9474 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
'Lowest date and hour for planned expiration of service';
9476 if (isModEnabled(
"propal") && (!is_object(
$object) ||
$object->element ==
'propal') && (empty($exclude) || !in_array(
'propal', $exclude)) && (empty($include) || in_array(
'propal', $include))) {
9477 $substitutionarray[
'__ONLINE_SIGN_URL__'] =
'ToOfferALinkForOnlineSignature';
9479 if (isModEnabled(
"intervention") && (!is_object(
$object) ||
$object->element ==
'fichinter') && (empty($exclude) || !in_array(
'intervention', $exclude)) && (empty($include) || in_array(
'intervention', $include))) {
9480 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] =
'ToOfferALinkForOnlineSignature';
9482 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'UrlToPayOnlineIfApplicable';
9483 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'TextAndUrlToPayOnlineIfApplicable';
9484 $substitutionarray[
'__SECUREKEYPAYMENT__'] =
'Security key (if key is not unique per record)';
9485 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
'Security key for payment on a member subscription (one key per member)';
9486 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
'Security key for payment on an order';
9487 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
'Security key for payment on an invoice';
9488 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
'Security key for payment on a service of a contract';
9490 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'Direct download url of a proposal';
9491 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'Direct download url of an order';
9492 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'Direct download url of an invoice';
9493 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'Direct download url of a contract';
9494 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'Direct download url of a supplier proposal';
9496 if (isModEnabled(
"shipping") && (!is_object(
$object) ||
$object->element ==
'shipping')) {
9497 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
'Shipping tracking number';
9498 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
'Shipping tracking url';
9499 $substitutionarray[
'__SHIPPINGMETHOD__'] =
'Shipping method';
9501 if (isModEnabled(
"reception") && (!is_object(
$object) ||
$object->element ==
'reception')) {
9502 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
'Shipping tracking number of shipment';
9503 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
'Shipping tracking url';
9506 '@phan-var-force Adherent|Delivery $object';
9508 $substitutionarray[
'__ID__'] =
$object->id;
9509 $substitutionarray[
'__REF__'] =
$object->ref;
9510 $substitutionarray[
'__NEWREF__'] =
$object->newref;
9512 $substitutionarray[
'__REF_CLIENT__'] = (isset(
$object->ref_client) ?
$object->ref_client : (isset(
$object->ref_customer) ?
$object->ref_customer :
null));
9513 $substitutionarray[
'__REF_SUPPLIER__'] = (isset(
$object->ref_supplier) ?
$object->ref_supplier :
null);
9514 $substitutionarray[
'__NOTE_PUBLIC__'] = (isset(
$object->note_public) ?
$object->note_public :
null);
9515 $substitutionarray[
'__NOTE_PRIVATE__'] = (isset(
$object->note_private) ?
$object->note_private :
null);
9517 $substitutionarray[
'__DATE_CREATION__'] = (isset(
$object->date_creation) ?
dol_print_date(
$object->date_creation,
'day',
false, $outputlangs) :
'');
9518 $substitutionarray[
'__DATE_MODIFICATION__'] = (isset(
$object->date_modification) ?
dol_print_date(
$object->date_modification,
'day',
false, $outputlangs) :
'');
9519 $substitutionarray[
'__DATE_VALIDATION__'] = (isset(
$object->date_validation) ?
dol_print_date(
$object->date_validation,
'day',
false, $outputlangs) :
'');
9522 $date_delivery =
null;
9523 if (property_exists(
$object,
'date_delivery')) {
9524 $date_delivery =
$object->date_delivery;
9525 } elseif (property_exists(
$object,
'delivery_date')) {
9526 $date_delivery =
$object->delivery_date;
9528 $substitutionarray[
'__DATE_DELIVERY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
'day',
false, $outputlangs) :
'');
9529 $substitutionarray[
'__DATE_DELIVERY_DAY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%d") :
'');
9530 $substitutionarray[
'__DATE_DELIVERY_DAY_TEXT__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%A") :
'');
9531 $substitutionarray[
'__DATE_DELIVERY_MON__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%m") :
'');
9532 $substitutionarray[
'__DATE_DELIVERY_MON_TEXT__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%b") :
'');
9533 $substitutionarray[
'__DATE_DELIVERY_YEAR__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%Y") :
'');
9534 $substitutionarray[
'__DATE_DELIVERY_HH__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%H") :
'');
9535 $substitutionarray[
'__DATE_DELIVERY_MM__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%M") :
'');
9536 $substitutionarray[
'__DATE_DELIVERY_SS__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%S") :
'');
9539 $substitutionarray[
'__REFCLIENT__'] = (isset(
$object->ref_client) ?
$object->ref_client : (isset(
$object->ref_customer) ?
$object->ref_customer :
null));
9540 $substitutionarray[
'__REFSUPPLIER__'] = (isset(
$object->ref_supplier) ?
$object->ref_supplier :
null);
9542 $substitutionarray[
'__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
'day',
false, $outputlangs) :
'');
9543 $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 :
'')) :
'');
9547 '@phan-var-force Adherent $object';
9551 $substitutionarray[
'__MEMBER_ID__'] = (isset(
$object->id) ?
$object->id :
'');
9552 if (method_exists(
$object,
'getCivilityLabel')) {
9553 $substitutionarray[
'__MEMBER_TITLE__'] =
$object->getCivilityLabel();
9555 $substitutionarray[
'__MEMBER_FIRSTNAME__'] = (isset(
$object->firstname) ?
$object->firstname :
'');
9556 $substitutionarray[
'__MEMBER_LASTNAME__'] = (isset(
$object->lastname) ?
$object->lastname :
'');
9557 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'';
9558 if (method_exists(
$object,
'getFullName')) {
9559 $substitutionarray[
'__MEMBER_FULLNAME__'] =
$object->getFullName($outputlangs);
9561 $substitutionarray[
'__MEMBER_COMPANY__'] = (isset(
$object->societe) ?
$object->societe :
'');
9562 $substitutionarray[
'__MEMBER_ADDRESS__'] = (isset(
$object->address) ?
$object->address :
'');
9563 $substitutionarray[
'__MEMBER_ZIP__'] = (isset(
$object->zip) ?
$object->zip :
'');
9564 $substitutionarray[
'__MEMBER_TOWN__'] = (isset(
$object->town) ?
$object->town :
'');
9565 $substitutionarray[
'__MEMBER_STATE__'] = (isset(
$object->state) ?
$object->state :
'');
9566 $substitutionarray[
'__MEMBER_COUNTRY__'] = (isset(
$object->country) ?
$object->country :
'');
9567 $substitutionarray[
'__MEMBER_EMAIL__'] = (isset(
$object->email) ?
$object->email :
'');
9568 $substitutionarray[
'__MEMBER_BIRTH__'] = (isset($birthday) ? $birthday :
'');
9569 $substitutionarray[
'__MEMBER_PHOTO__'] = (isset(
$object->photo) ?
$object->photo :
'');
9570 $substitutionarray[
'__MEMBER_LOGIN__'] = (isset(
$object->login) ?
$object->login :
'');
9571 $substitutionarray[
'__MEMBER_PASSWORD__'] = (isset(
$object->pass) ?
$object->pass :
'');
9575 $substitutionarray[
'__MEMBER_TYPE__'] = (isset(
$object->type) ?
$object->type :
'');
9576 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE__'] =
dol_print_date(
$object->first_subscription_date,
'day');
9578 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_RFC__'] =
dol_print_date(
$object->first_subscription_date,
'dayrfc');
9579 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = (isset(
$object->first_subscription_date_start) ?
dol_print_date(
$object->first_subscription_date_start,
'day') :
'');
9580 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START_RFC__'] = (isset(
$object->first_subscription_date_start) ?
dol_print_date(
$object->first_subscription_date_start,
'dayrfc') :
'');
9581 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = (isset(
$object->first_subscription_date_end) ?
dol_print_date(
$object->first_subscription_date_end,
'day') :
'');
9582 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END_RFC__'] = (isset(
$object->first_subscription_date_end) ?
dol_print_date(
$object->first_subscription_date_end,
'dayrfc') :
'');
9583 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE__'] =
dol_print_date(
$object->last_subscription_date,
'day');
9584 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_RFC__'] =
dol_print_date(
$object->last_subscription_date,
'dayrfc');
9585 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] =
dol_print_date(
$object->last_subscription_date_start,
'day');
9586 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START_RFC__'] =
dol_print_date(
$object->last_subscription_date_start,
'dayrfc');
9587 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] =
dol_print_date(
$object->last_subscription_date_end,
'day');
9588 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END_RFC__'] =
dol_print_date(
$object->last_subscription_date_end,
'dayrfc');
9593 '@phan-var-force Societe $object';
9594 $substitutionarray[
'__THIRDPARTY_ID__'] =
$object->id ??
'';
9595 $substitutionarray[
'__THIRDPARTY_NAME__'] =
$object->name ??
'';
9596 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
$object->name_alias ??
'';
9597 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
$object->code_client ??
'';
9598 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
$object->code_fournisseur ??
'';
9599 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
$object->email ??
'';
9600 $substitutionarray[
'__THIRDPARTY_EMAIL_URLENCODED__'] = urlencode(
$object->email ??
'');
9601 $substitutionarray[
'__THIRDPARTY_URL__'] =
$object->url ??
'';
9602 $substitutionarray[
'__THIRDPARTY_URL_URLENCODED__'] = urlencode(
$object->url ??
'');
9605 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
$object->address ??
'';
9606 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
$object->zip ??
'';
9607 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
$object->town ??
'';
9608 $substitutionarray[
'__THIRDPARTY_STATE__'] =
$object->state ??
'';
9609 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (
$object->country_id > 0 ?:
'');
9610 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] =
$object->country_code ??
'';
9611 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
$object->idprof1 ??
'';
9612 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
$object->idprof2 ??
'';
9613 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
$object->idprof3 ??
'';
9614 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
$object->idprof4 ??
'';
9615 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
$object->idprof5 ??
'';
9616 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
$object->idprof6 ??
'';
9617 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
$object->tva_intra ??
'';
9620 } elseif (is_object(
$object) && is_object(
$object->thirdparty)) {
9621 $substitutionarray[
'__THIRDPARTY_ID__'] =
$object->thirdparty->id ??
'';
9622 $substitutionarray[
'__THIRDPARTY_NAME__'] =
$object->thirdparty->name ??
'';
9623 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
$object->thirdparty->name_alias ??
'';
9624 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
$object->thirdparty->code_client ??
'';
9625 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
$object->thirdparty->code_fournisseur ??
'';
9626 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
$object->thirdparty->email ??
'';
9627 $substitutionarray[
'__THIRDPARTY_EMAIL_URLENCODED__'] = urlencode(
$object->thirdparty->email ??
'');
9630 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
$object->thirdparty->address ??
'';
9631 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
$object->thirdparty->zip ??
'';
9632 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
$object->thirdparty->town ??
'';
9633 $substitutionarray[
'__THIRDPARTY_STATE__'] =
$object->thirdparty->state ??
'';
9634 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (
$object->thirdparty->country_id > 0 ?:
'');
9635 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] =
$object->thirdparty->country_code ??
'';
9636 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
$object->thirdparty->idprof1 ??
'';
9637 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
$object->thirdparty->idprof2 ??
'';
9638 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
$object->thirdparty->idprof3 ??
'';
9639 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
$object->thirdparty->idprof4 ??
'';
9640 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
$object->thirdparty->idprof5 ??
'';
9641 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
$object->thirdparty->idprof6 ??
'';
9642 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
$object->thirdparty->tva_intra ??
'';
9647 if (is_object(
$object) &&
$object->element ==
'recruitmentcandidature') {
9648 '@phan-var-force RecruitmentCandidature $object';
9650 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
$object->getFullName($outputlangs);
9651 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] = isset(
$object->firstname) ?
$object->firstname :
'';
9652 $substitutionarray[
'__CANDIDATE_LASTNAME__'] = isset(
$object->lastname) ?
$object->lastname :
'';
9654 if (is_object(
$object) &&
$object->element ==
'conferenceorboothattendee') {
9655 '@phan-var-force ConferenceOrBoothAttendee $object';
9657 $substitutionarray[
'__ATTENDEE_FULLNAME__'] =
$object->getFullName($outputlangs);
9658 $substitutionarray[
'__ATTENDEE_FIRSTNAME__'] = isset(
$object->firstname) ?
$object->firstname :
'';
9659 $substitutionarray[
'__ATTENDEE_LASTNAME__'] = isset(
$object->lastname) ?
$object->lastname :
'';
9663 '@phan-var-force Project $object';
9665 $substitutionarray[
'__PROJECT_ID__'] =
$object->id;
9666 $substitutionarray[
'__PROJECT_REF__'] =
$object->ref;
9667 $substitutionarray[
'__PROJECT_NAME__'] =
$object->title;
9668 } elseif (is_object(
$object)) {
9670 if (!empty(
$object->project)) {
9672 } elseif (!empty(
$object->projet)) {
9675 if (!is_null($project) && is_object($project)) {
9676 $substitutionarray[
'__PROJECT_ID__'] = $project->id;
9677 $substitutionarray[
'__PROJECT_REF__'] = $project->ref;
9678 $substitutionarray[
'__PROJECT_NAME__'] = $project->title;
9683 $project_id =
$object->fk_project;
9684 } elseif (!empty(
$object->fk_projet) &&
$object->fk_projet > 0) {
9685 $project_id =
$object->fk_project;
9687 if ($project_id > 0) {
9689 $substitutionarray[
'__PROJECT_ID__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9690 $substitutionarray[
'__PROJECT_REF__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9691 $substitutionarray[
'__PROJECT_NAME__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9697 '@phan-var-force Facture $object';
9699 $substitutionarray[
'__INVOICE_SITUATION_NUMBER__'] = isset(
$object->situation_counter) ?
$object->situation_counter :
'';
9702 '@phan-var-force Expedition $object';
9704 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
$object->tracking_number;
9705 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
$object->tracking_url;
9706 $substitutionarray[
'__SHIPPINGMETHOD__'] =
$object->shipping_method;
9709 '@phan-var-force Reception $object';
9711 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
$object->tracking_number;
9712 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
$object->tracking_url;
9716 '@phan-var-force Contrat $object';
9718 $dateplannedstart =
'';
9719 $datenextexpiration =
'';
9720 foreach (
$object->lines as $line) {
9721 if ($line->date_start > $dateplannedstart) {
9722 $dateplannedstart = $line->date_start;
9724 if ($line->statut == 4 && $line->date_end && (!$datenextexpiration || $line->date_end < $datenextexpiration)) {
9725 $datenextexpiration = $line->date_end;
9728 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
dol_print_date($dateplannedstart,
'day');
9729 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE_RFC__'] =
dol_print_date($dateplannedstart,
'dayrfc');
9730 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
dol_print_date($dateplannedstart,
'standard');
9732 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
dol_print_date($datenextexpiration,
'day');
9733 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE_RFC__'] =
dol_print_date($datenextexpiration,
'dayrfc');
9734 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
dol_print_date($datenextexpiration,
'standard');
9738 '@phan-var-force Ticket $object';
9740 $substitutionarray[
'__TICKET_TRACKID__'] =
$object->track_id;
9741 $substitutionarray[
'__TICKET_SUBJECT__'] =
$object->subject;
9742 $substitutionarray[
'__TICKET_TYPE__'] =
$object->type_code;
9743 $substitutionarray[
'__TICKET_SEVERITY__'] =
$object->severity_code;
9744 $substitutionarray[
'__TICKET_CATEGORY__'] =
$object->category_code;
9745 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
$object->category_code;
9746 $substitutionarray[
'__TICKET_MESSAGE__'] =
$object->message;
9747 $substitutionarray[
'__TICKET_PROGRESSION__'] =
$object->progress;
9748 $userstat =
new User($db);
9749 if (
$object->fk_user_assign > 0) {
9750 $userstat->fetch(
$object->fk_user_assign);
9751 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
9754 if (
$object->fk_user_create > 0) {
9755 $userstat->fetch(
$object->fk_user_create);
9756 $substitutionarray[
'__USER_CREATE__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
9762 if (!is_object($extrafields)) {
9765 $extrafields->fetch_name_optionals_label(
$object->table_element,
true);
9767 if (
$object->fetch_optionals() > 0) {
9768 if (is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label']) > 0) {
9769 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $label) {
9770 if ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'date') {
9771 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'day');
9772 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'day',
'tzserver', $outputlangs);
9773 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'dayrfc');
9774 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'datetime') {
9775 $datetime =
$object->array_options[
'options_'.$key];
9776 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
9777 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
9778 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_DAY_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'day',
'tzserver', $outputlangs) :
'');
9779 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
9780 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'phone') {
9781 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_phone(
$object->array_options[
'options_'.$key]);
9782 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'price') {
9783 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
$object->array_options[
'options_'.$key];
9784 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATED__'] =
price(
$object->array_options[
'options_'.$key]);
9785 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATTED__'] =
price(
$object->array_options[
'options_'.$key]);
9786 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separator') {
9787 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = !empty(
$object->array_options[
'options_'.$key]) ?
$object->array_options[
'options_'.$key] :
'';
9795 if (empty($substitutionarray[
'__REF__'])) {
9799 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
9800 $outputlangs->loadLangs(array(
'paypal',
'other'));
9803 $typeforonlinepayment =
'free';
9805 $typeforonlinepayment =
'order';
9808 $typeforonlinepayment =
'invoice';
9811 $typeforonlinepayment =
'member';
9812 if (!empty(
$object->last_subscription_amount)) {
9813 $amounttouse =
$object->last_subscription_amount;
9817 $typeforonlinepayment =
'contract';
9820 $typeforonlinepayment =
'ficheinter';
9823 $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray[
'__REF__'], $amounttouse);
9828 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ? str_replace(
'\n',
"\n", $outputlangs->trans(
"PredefinedMailContentLink", $paymenturl)) :
'');
9829 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] = $paymenturl;
9833 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
9838 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
$object->getLastMainDocLink(
$object->element);
9840 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'';
9843 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
$object->getLastMainDocLink(
$object->element);
9845 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'';
9848 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
$object->getLastMainDocLink(
$object->element);
9850 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'';
9853 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
$object->getLastMainDocLink(
$object->element);
9855 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'';
9858 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] =
$object->getLastMainDocLink(
$object->element);
9860 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] =
'';
9863 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
$object->getLastMainDocLink(
$object->element);
9865 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'';
9869 '@phan-var-force Propal $object';
9871 $substitutionarray[
'__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/comm/propal/card.php?id=".
$object->id;
9872 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9873 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'proposal',
$object->ref, 1,
$object);
9876 '@phan-var-force Commande $object';
9878 $substitutionarray[
'__URL_ORDER__'] = DOL_MAIN_URL_ROOT.
"/commande/card.php?id=".
$object->id;
9881 '@phan-var-force Facture $object';
9883 $substitutionarray[
'__URL_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/compta/facture/card.php?id=".
$object->id;
9886 '@phan-var-force Contrat $object';
9888 $substitutionarray[
'__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT.
"/contrat/card.php?id=".
$object->id;
9889 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9890 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'contract',
$object->ref, 1,
$object);
9893 '@phan-var-force Fichinter $object';
9895 $substitutionarray[
'__URL_FICHINTER__'] = DOL_MAIN_URL_ROOT.
"/fichinter/card.php?id=".
$object->id;
9896 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9897 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0,
'fichinter',
$object->ref, 1,
$object);
9899 if (is_object(
$object) &&
$object->element ==
'supplier_proposal') {
9900 '@phan-var-force SupplierProposal $object';
9902 $substitutionarray[
'__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/supplier_proposal/card.php?id=".
$object->id;
9904 if (is_object(
$object) &&
$object->element ==
'invoice_supplier') {
9905 '@phan-var-force FactureFournisseur $object';
9907 $substitutionarray[
'__URL_SUPPLIER_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/fourn/facture/card.php?id=".
$object->id;
9910 '@phan-var-force Expedition $object';
9912 $substitutionarray[
'__URL_SHIPMENT__'] = DOL_MAIN_URL_ROOT.
"/expedition/card.php?id=".
$object->id;
9917 '@phan-var-force ActionComm $object';
9919 $substitutionarray[
'__EVENT_LABEL__'] =
$object->label;
9920 $substitutionarray[
'__EVENT_TYPE__'] = $outputlangs->trans(
"Action".
$object->type_code);
9922 $substitutionarray[
'__EVENT_TIME__'] =
dol_print_date(
$object->datep,
'hour',
'auto', $outputlangs);
9926 if ((empty($exclude) || !in_array(
'objectamount', $exclude)) && (empty($include) || in_array(
'objectamount', $include))) {
9927 '@phan-var-force Facture|FactureRec $object';
9929 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functionsnumtoword.lib.php';
9932 $substitutionarray[
'__DATE_DUE_YMD__'] = is_object(
$object) ? (isset(
$object->date_lim_reglement) ?
dol_print_date(
$object->date_lim_reglement,
'day',
false, $outputlangs) : null) :
'';
9934 $substitutionarray[
'__DATE_DUE_YMD_TEXT__'] = is_object(
$object) ? (isset(
$object->date_lim_reglement) ?
dol_print_date(
$object->date_lim_reglement,
'daytext',
false, $outputlangs) : null) :
'';
9936 $already_payed_all = 0;
9941 $substitutionarray[
'__AMOUNT_EXCL_TAX__'] = is_object(
$object) ?
$object->total_ht :
'';
9945 $substitutionarray[
'__AMOUNT__'] = is_object(
$object) ?
$object->total_ttc :
'';
9949 $substitutionarray[
'__AMOUNT_REMAIN__'] = is_object(
$object) ?
price2num(
$object->total_ttc - $already_payed_all,
'MT') :
'';
9951 $substitutionarray[
'__AMOUNT_VAT__'] = is_object(
$object) ? (isset(
$object->total_vat) ?
$object->total_vat :
$object->total_tva) :
'';
9955 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
9956 $substitutionarray[
'__AMOUNT_TAX2__'] = is_object(
$object) ?
$object->total_localtax1 :
'';
9958 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
9959 $substitutionarray[
'__AMOUNT_TAX3__'] = is_object(
$object) ?
$object->total_localtax2 :
'';
9963 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATTED__'] = is_object(
$object) ? (
$object->total_ht ?
price(
$object->total_ht, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null) :
'';
9964 $substitutionarray[
'__AMOUNT_FORMATTED__'] = is_object(
$object) ? (
$object->total_ttc ?
price(
$object->total_ttc, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null) :
'';
9965 $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) :
'';
9966 $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)) :
'';
9967 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
9968 $substitutionarray[
'__AMOUNT_TAX2_FORMATTED__'] = is_object(
$object) ? (
$object->total_localtax1 ?
price(
$object->total_localtax1, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null) :
'';
9970 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
9971 $substitutionarray[
'__AMOUNT_TAX3_FORMATTED__'] = is_object(
$object) ? (
$object->total_localtax2 ?
price(
$object->total_localtax2, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null) :
'';
9974 if ($onlykey != 2) {
9975 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATED__'] = $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATTED__'];
9976 $substitutionarray[
'__AMOUNT_FORMATED__'] = $substitutionarray[
'__AMOUNT_FORMATTED__'];
9977 $substitutionarray[
'__AMOUNT_REMAIN_FORMATED__'] = $substitutionarray[
'__AMOUNT_REMAIN_FORMATTED__'];
9978 $substitutionarray[
'__AMOUNT_VAT_FORMATED__'] = $substitutionarray[
'__AMOUNT_VAT_FORMATTED__'];
9979 if ($mysoc instanceof
Societe && $mysoc->useLocalTax(1)) {
9980 $substitutionarray[
'__AMOUNT_TAX2_FORMATED__'] = $substitutionarray[
'__AMOUNT_TAX2_FORMATTED__'];
9982 if ($mysoc instanceof
Societe && $mysoc->useLocalTax(2)) {
9983 $substitutionarray[
'__AMOUNT_TAX3_FORMATED__'] = $substitutionarray[
'__AMOUNT_TAX3_FORMATTED__'];
9987 $substitutionarray[
'__AMOUNT_MULTICURRENCY__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
$object->multicurrency_total_ttc :
'';
9988 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXT__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
dol_convertToWord(
$object->multicurrency_total_ttc, $outputlangs,
'',
true) :
'';
9989 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXTCURRENCY__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
dol_convertToWord(
$object->multicurrency_total_ttc, $outputlangs,
$object->multicurrency_code,
true) :
'';
9990 $substitutionarray[
'__MULTICURRENCY_CODE__'] = (is_object(
$object) && isset(
$object->multicurrency_code)) ?
$object->multicurrency_code :
'';
9994 if ($onlykey != 2) {
9995 $substitutionarray[
'__TOTAL_TTC__'] = is_object(
$object) ?
$object->total_ttc :
'';
9996 $substitutionarray[
'__TOTAL_HT__'] = is_object(
$object) ?
$object->total_ht :
'';
10002 if ((empty($exclude) || !in_array(
'date', $exclude)) && (empty($include) || in_array(
'date', $include))) {
10003 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
10013 $daytext = $outputlangs->trans(
'Day'.$tmp[
'wday']);
10015 $substitutionarray = array_merge($substitutionarray, array(
10016 '__NOW_TMS__' => (
string) $now,
10017 '__NOW_TMS_YMD__' =>
dol_print_date($now,
'day',
'auto', $outputlangs),
10018 '__DAY__' => (
string) $tmp[
'mday'],
10019 '__DAY_TEXT__' => $daytext,
10020 '__DAY_TEXT_SHORT__' =>
dol_trunc($daytext, 3,
'right',
'UTF-8', 1),
10021 '__DAY_TEXT_MIN__' =>
dol_trunc($daytext, 1,
'right',
'UTF-8', 1),
10022 '__MONTH__' => (
string) $tmp[
'mon'],
10023 '__MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp[
'mon'])),
10024 '__MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp[
'mon'])),
10025 '__MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp[
'mon'])),
10026 '__YEAR__' => (
string) $tmp[
'year'],
10027 '__YEAR_PREVIOUS_MONTH__' => (
string) $tmp3[
'year'],
10028 '__YEAR_NEXT_MONTH__' => (
string) $tmp5[
'year'],
10029 '__PREVIOUS_DAY__' => (
string) $tmp2[
'day'],
10030 '__PREVIOUS_MONTH__' => (
string) $tmp3[
'month'],
10031 '__PREVIOUS_MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp3[
'month'])),
10032 '__PREVIOUS_MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp3[
'month'])),
10033 '__PREVIOUS_MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp3[
'month'])),
10034 '__PREVIOUS_YEAR__' => (
string) ($tmp[
'year'] - 1),
10035 '__NEXT_DAY__' => (
string) $tmp4[
'day'],
10036 '__NEXT_MONTH__' => (
string) $tmp5[
'month'],
10037 '__NEXT_MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp5[
'month'])),
10038 '__NEXT_MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp5[
'month'])),
10039 '__NEXT_MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp5[
'month'])),
10040 '__NEXT_YEAR__' => (
string) ($tmp[
'year'] + 1),
10044 if (isModEnabled(
'multicompany')) {
10045 $substitutionarray = array_merge($substitutionarray, array(
'__ENTITY_ID__' =>
$conf->entity));
10047 if ((empty($exclude) || !in_array(
'system', $exclude)) && (empty($include) || in_array(
'user', $include))) {
10048 $substitutionarray[
'__DOL_MAIN_URL_ROOT__'] = DOL_MAIN_URL_ROOT;
10049 $substitutionarray[
'__(AnyTranslationKey)__'] = $outputlangs->trans(
'TranslationOfKey');
10050 $substitutionarray[
'__(AnyTranslationKey|langfile)__'] = $outputlangs->trans(
'TranslationOfKey').
' (load also language file before)';
10051 $substitutionarray[
'__[AnyConstantKey]__'] = $outputlangs->trans(
'ValueOfConstantKey');
10056 return $substitutionarray;
10075function make_substitutions($text, $substitutionarray, $outputlangs =
null, $converttextinhtmlifnecessary = 0)
10077 global
$conf, $db, $langs;
10079 if (!is_array($substitutionarray)) {
10080 return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
10083 if (empty($outputlangs)) {
10084 $outputlangs = $langs;
10094 if (is_object($outputlangs)) {
10096 while (preg_match(
'/__\(([^\)]+)\)__/', $text, $reg)) {
10098 $tmp = explode(
'|', $reg[1]);
10099 if (!empty($tmp[1])) {
10100 $outputlangs->load($tmp[1]);
10103 $value = $outputlangs->transnoentitiesnoconv($reg[1]);
10105 if (empty($converttextinhtmlifnecessary)) {
10107 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
10109 if (! $msgishtml) {
10113 if ($valueishtml) {
10121 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $value, $text);
10129 while (preg_match(
'/__\[([^\]]+)\]__/', $text, $reg)) {
10130 $keyfound = $reg[1];
10132 $value =
'*****forbidden*****';
10134 $value = empty(
$conf->global->$keyfound) ?
'' :
$conf->global->$keyfound;
10137 if (empty($converttextinhtmlifnecessary)) {
10139 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
10141 if (! $msgishtml) {
10144 if ($valueishtml) {
10152 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $value, $text);
10157 foreach ($substitutionarray as $key => $value) {
10158 if (!isset($value)) {
10162 if (($key ==
'__USER_SIGNATURE__' || $key ==
'__SENDEREMAIL_SIGNATURE__') && (
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN'))) {
10166 if (empty($converttextinhtmlifnecessary)) {
10167 $text = str_replace((
string) $key, (
string) $value, $text);
10169 if (! $msgishtml) {
10172 if ($valueishtml) {
10179 $text = str_replace((
string) $key, (
string) $value, $text);
10195 $memory_object_list = array();
10196 foreach ($substitutionarray as $key => $value) {
10197 $lazy_load_arr = array();
10198 if (preg_match(
'/(__[A-Z\_]+__)@lazyload$/', $key, $lazy_load_arr)) {
10199 if (isset($lazy_load_arr[1]) && !empty($lazy_load_arr[1])) {
10200 $key_to_substitute = $lazy_load_arr[1];
10201 if (preg_match(
'/' . preg_quote($key_to_substitute,
'/') .
'/', $text)) {
10202 $param_arr = explode(
':', (
string) $value);
10204 if (count($param_arr) == 4) {
10205 $path = $param_arr[0];
10206 $class = $param_arr[1];
10207 $method = $param_arr[2];
10208 $id = (int) $param_arr[3];
10211 if (!isset($memory_object_list[$class])) {
10213 require_once DOL_DOCUMENT_ROOT . $path;
10214 if (class_exists($class)) {
10215 $memory_object_list[$class] = array(
10223 if (isset($memory_object_list[$class]) && isset($memory_object_list[$class][
'list'])) {
10224 if (method_exists($class, $method)) {
10225 if (!isset($memory_object_list[$class][
'list'][
$id])) {
10226 $tmpobj =
new $class($db);
10228 $valuetouseforsubstitution = $tmpobj->$method(
$id, $key_to_substitute);
10229 $memory_object_list[$class][
'list'][
$id] = $tmpobj;
10232 $tmpobj = $memory_object_list[$class][
'list'][
$id];
10234 $valuetouseforsubstitution = $tmpobj->$method(
$id, $key_to_substitute,
true);
10237 $text = str_replace((
string) $key_to_substitute, (
string) $valuetouseforsubstitution, $text);
10263 global
$conf, $user;
10265 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
10270 $dirsubstitutions = array_merge(array(), (array)
$conf->modules_parts[
'substitutions']);
10272 foreach ($dirsubstitutions as $reldir) {
10280 $substitfiles =
dol_dir_list($dir,
'files', 0,
'functions_');
10281 foreach ($substitfiles as $substitfile) {
10283 if (preg_match(
'/functions_(.*)\.lib\.php/i', $substitfile[
'name'], $reg)) {
10286 dol_syslog(
"Library ".$substitfile[
'name'].
" found into ".$dir);
10288 require_once $dir.$substitfile[
'name'];
10290 $function_name = $module.
"_".$callfunc;
10291 if (function_exists($function_name)) {
10292 $function_name($substitutionarray, $outputlangs,
$object, $parameters);
10300 foreach ($substitutionarray as $key => $value) {
10301 $tags .=
'{'.$key.
'} => '.$value.
"\n";
10303 $substitutionarray = array_merge($substitutionarray, array(
'__ALL_TAGS__' => $tags));
10316function print_date_range($date_start, $date_end, $format =
'', $outputlangs =
null)
10318 print
get_date_range($date_start, $date_end, $format, $outputlangs);
10331function get_date_range($date_start, $date_end, $format =
'', $outputlangs =
null, $withparenthesis = 1)
10337 if (!is_object($outputlangs)) {
10338 $outputlangs = $langs;
10341 if ($date_start && $date_end) {
10342 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFromTo',
dol_print_date($date_start, $format,
false, $outputlangs),
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
10344 if ($date_start && !$date_end) {
10345 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($date_start, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
10347 if (!$date_start && $date_end) {
10348 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
10368 if ($nameorder < 0) {
10371 if ($nameorder == 1) {
10372 $ret .= $firstname;
10373 if ($firstname && $lastname) {
10377 } elseif ($nameorder == 2 || $nameorder == 3) {
10378 $ret .= $firstname;
10379 if (empty($ret) && $nameorder == 3) {
10384 if (empty($ret) && $nameorder == 5) {
10385 $ret .= $firstname;
10387 if ($nameorder == 0) {
10388 if ($firstname && $lastname) {
10391 $ret .= $firstname;
10410function setEventMessage($mesgs, $style =
'mesgs', $noduplicate = 0, $attop = 0)
10413 if (!is_array($mesgs)) {
10414 $mesgs = trim((
string) $mesgs);
10417 if (!empty($noduplicate) && isset($_SESSION[
'dol_events'][$style]) && in_array($mesgs, $_SESSION[
'dol_events'][$style])) {
10421 array_unshift($_SESSION[
'dol_events'][$style], $mesgs);
10423 $_SESSION[
'dol_events'][$style][] = $mesgs;
10428 foreach ($mesgs as $mesg) {
10429 $mesg = trim((
string) $mesg);
10431 if (!empty($noduplicate) && isset($_SESSION[
'dol_events'][$style]) && in_array($mesg, $_SESSION[
'dol_events'][$style])) {
10435 array_unshift($_SESSION[
'dol_events'][$style], $mesgs);
10437 $_SESSION[
'dol_events'][$style][] = $mesg;
10457function setEventMessages($mesg, $mesgs, $style =
'mesgs', $messagekey =
'', $noduplicate = 0, $attop = 0)
10459 if (empty($mesg) && empty($mesgs)) {
10467 if (empty($messagekey) || empty($_COOKIE[
"DOLUSER_HIDEMESSAGE".$messagekey])) {
10468 if (!in_array((
string) $style, array(
'mesgs',
'warnings',
'errors'))) {
10469 dol_print_error(
null,
'Bad parameter style='.$style.
' for setEventMessages');
10471 if (empty($mesgs)) {
10474 if (!empty($mesg) && !in_array($mesg, $mesgs)) {
10495 if (isset($_SESSION[
'dol_events'][
'mesgs'])) {
10496 if (empty($disabledoutputofmessages)) {
10499 unset($_SESSION[
'dol_events'][
'mesgs']);
10502 if (isset($_SESSION[
'dol_events'][
'errors'])) {
10503 if (empty($disabledoutputofmessages)) {
10506 unset($_SESSION[
'dol_events'][
'errors']);
10510 if (isset($_SESSION[
'dol_events'][
'warnings'])) {
10511 if (empty($disabledoutputofmessages)) {
10514 unset($_SESSION[
'dol_events'][
'warnings']);
10532function get_htmloutput_mesg($mesgstring =
'', $mesgarray = [], $style =
'ok', $keepembedded = 0)
10534 global
$conf, $langs;
10539 $divstart = $divend =
'';
10542 if ((empty(
$conf->use_javascript_ajax) ||
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') || $keepembedded) && !preg_match(
'/<div class=".*">/i', $out)) {
10543 $divstart =
'<div class="'.$style.
' clearboth">';
10544 $divend =
'</div>';
10547 if ((is_array($mesgarray) && count($mesgarray)) || $mesgstring) {
10548 $langs->load(
"errors");
10550 if (is_array($mesgarray) && count($mesgarray)) {
10551 foreach ($mesgarray as $message) {
10553 $out .= $langs->trans($message);
10554 if ($ret < count($mesgarray)) {
10561 $out .= $langs->trans($mesgstring);
10567 if (!empty(
$conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') && empty($keepembedded)) {
10568 $return =
'<script nonce="'.getNonce().
'">
10569 $(document).ready(function() {
10570 /* jnotify(message, preset of message type, keepmessage) */
10571 $.jnotify("'.
dol_escape_js($out).
'", "'.($style ==
"ok" ? 3000 : $style).
'", '.($style ==
"ok" ?
"false" :
"true").
',{ remove: function (){} } );
10611function dol_htmloutput_mesg($mesgstring =
'', $mesgarray = array(), $style =
'ok', $keepembedded = 0)
10613 if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) {
10619 if (is_array($mesgarray)) {
10620 foreach ($mesgarray as $val) {
10621 if ($val && preg_match(
'/class="error"/i', $val)) {
10625 if ($val && preg_match(
'/class="warning"/i', $val)) {
10630 } elseif ($mesgstring && preg_match(
'/class="error"/i', $mesgstring)) {
10632 } elseif ($mesgstring && preg_match(
'/class="warning"/i', $mesgstring)) {
10635 if ($style ==
'error') {
10638 if ($style ==
'warning') {
10642 if ($iserror || $iswarning) {
10644 $mesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $mesgstring);
10645 $mesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $mesgstring);
10646 $mesgstring = preg_replace(
'/<\/div>/',
'', $mesgstring);
10648 if (is_array($mesgarray)) {
10649 $newmesgarray = array();
10650 foreach ($mesgarray as $val) {
10651 if (is_string($val)) {
10652 $tmpmesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $val);
10653 $tmpmesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $tmpmesgstring);
10654 $tmpmesgstring = preg_replace(
'/<\/div>/',
'', $tmpmesgstring);
10655 $newmesgarray[] = $tmpmesgstring;
10657 dol_syslog(
"Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING);
10660 $mesgarray = $newmesgarray;
10662 print
get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ?
'error' :
'warning'), $keepembedded);
10704function dol_sort_array(&$array, $index, $order =
'asc', $natsort = 0, $case_sensitive = 0, $keepindex = 0)
10707 $order = strtolower($order);
10709 if (is_array($array)) {
10710 $sizearray = count($array);
10711 if ($sizearray > 0) {
10713 foreach (array_keys($array) as $key) {
10714 if (is_object($array[$key])) {
10715 $temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index;
10718 $temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index];
10720 if ($natsort == -1) {
10721 $temp[$key] =
'___'.$temp[$key];
10725 if (empty($natsort) || $natsort == -1) {
10726 if ($order ==
'asc') {
10732 if ($case_sensitive) {
10735 natcasesort($temp);
10737 if ($order !=
'asc') {
10738 $temp = array_reverse($temp,
true);
10744 foreach (array_keys($temp) as $key) {
10745 (is_numeric($key) && empty($keepindex)) ? $sorted[] = $array[$key] : $sorted[$key] = $array[$key];
10764 $str = (string) $str;
10767 $strLength = strlen($str);
10768 for ($i = 0; $i < $strLength; $i++) {
10769 if (ord($str[$i]) < 0x80) {
10771 } elseif ((ord($str[$i]) & 0xE0) == 0xC0) {
10773 } elseif ((ord($str[$i]) & 0xF0) == 0xE0) {
10775 } elseif ((ord($str[$i]) & 0xF8) == 0xF0) {
10777 } elseif ((ord($str[$i]) & 0xFC) == 0xF8) {
10779 } elseif ((ord($str[$i]) & 0xFE) == 0xFC) {
10784 for ($j = 0; $j < $n; $j++) {
10785 if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) {
10806 return preg_match(
'//u', $str) ? true :
false;
10818 if (function_exists(
'mb_check_encoding')) {
10820 if (!mb_check_encoding($str,
'ASCII')) {
10824 if (preg_match(
'/[^\x00-\x7f]/', $str)) {
10842 $tmp = ini_get(
"unicode.filesystem_encoding");
10843 if (empty($tmp) && !empty($_SERVER[
"WINDIR"])) {
10844 $tmp =
'iso-8859-1';
10853 if ($tmp ==
'iso-8859-1') {
10854 return mb_convert_encoding($str,
'ISO-8859-1',
'UTF-8');
10875function dol_getIdFromCode($db, $key, $tablename, $fieldkey =
'code', $fieldid =
'id', $entityfilter = 0, $filters =
'', $useCache =
true)
10885 if ($useCache && isset(
$conf->cache[
'codeid'][$tablename][$key][$fieldid])) {
10886 return $conf->cache[
'codeid'][$tablename][$key][$fieldid];
10889 dol_syslog(
'dol_getIdFromCode (value for field '.$fieldid.
' from key '.$key.
' not found into cache)', LOG_DEBUG);
10891 $sql =
"SELECT ".$fieldid.
" as valuetoget";
10892 $sql .=
" FROM ".MAIN_DB_PREFIX.$tablename;
10893 if ($fieldkey ==
'id' || $fieldkey ==
'rowid') {
10894 $sql .=
" WHERE ".$fieldkey.
" = ".((int) $key);
10896 $sql .=
" WHERE ".$fieldkey.
" = '".$db->escape($key).
"'";
10898 if (!empty($entityfilter)) {
10899 $sql .=
" AND entity IN (".getEntity($tablename).
")";
10905 $resql = $db->query($sql);
10907 $obj = $db->fetch_object($resql);
10910 $valuetoget = $obj->valuetoget;
10911 $conf->cache[
'codeid'][$tablename][$key][$fieldid] = $valuetoget;
10913 $conf->cache[
'codeid'][$tablename][$key][$fieldid] =
'';
10917 return $valuetoget;
10934 if ($matchrule == 1) {
10935 if ($var ==
'mainmenu') {
10937 return (preg_match(
'/^'.$regextext.
'/', $mainmenu));
10938 } elseif ($var ==
'leftmenu') {
10940 return (preg_match(
'/^'.$regextext.
'/', $leftmenu));
10942 return 'This variable is not accessible with dol_eval';
10945 return 'This value for matchrule is not implemented';
10959function verifCond($strToEvaluate, $onlysimplestring =
'1')
10963 if (isset($strToEvaluate) && $strToEvaluate !==
'') {
10966 $rep =
dol_eval($strToEvaluate, 1, 1, $onlysimplestring);
10967 $rights = (bool) $rep && (!is_string($rep) || strpos($rep,
'Bad string syntax to evaluate') ===
false);
10987function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring =
'1')
10989 if ($returnvalue != 1) {
10990 dol_syslog(
"Use of dol_eval with parameter returnvalue = 0 is now forbidden. Please fix this", LOG_ERR);
11013 $db, $langs, $user, $website, $websitepage,
11014 $action, $mainmenu, $leftmenu,
11023 defined(
'T_COALESCE_EQUAL') || define(
'T_COALESCE_EQUAL', PHP_INT_MAX);
11024 defined(
'T_FN') || define(
'T_FN', PHP_INT_MAX);
11027 defined(
'T_ATTRIBUTE') || define(
'T_ATTRIBUTE', PHP_INT_MAX);
11028 defined(
'T_MATCH') || define(
'T_MATCH', PHP_INT_MAX);
11029 defined(
'T_NAME_FULLY_QUALIFIED') || define(
'T_NAME_FULLY_QUALIFIED', PHP_INT_MAX);
11030 defined(
'T_NAME_QUALIFIED') || define(
'T_NAME_QUALIFIED', PHP_INT_MAX);
11031 defined(
'T_NAME_RELATIVE') || define(
'T_NAME_RELATIVE', PHP_INT_MAX);
11034 defined(
'T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG') || define(
'T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG', PHP_INT_MAX);
11035 defined(
'T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG') || define(
'T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG', PHP_INT_MAX);
11036 defined(
'T_ENUM') || define(
'T_ENUM', PHP_INT_MAX);
11037 defined(
'T_READONLY') || define(
'T_READONLY', PHP_INT_MAX);
11040 defined(
'T_PRIVATE_SET') || define(
'T_PRIVATE_SET', PHP_INT_MAX);
11041 defined(
'T_PROTECTED_SET') || define(
'T_PROTECTED_SET', PHP_INT_MAX);
11042 defined(
'T_PUBLIC_SET') || define(
'T_PUBLIC_SET', PHP_INT_MAX);
11044 $prohibited_token_ids = [
11050 'T_ABSTRACT',
'T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG',
'T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG',
'T_ATTRIBUTE',
11055 'T_CALLABLE',
'T_CATCH',
'T_CLASS',
'T_CLOSE_TAG',
'T_CONST',
11058 'T_DECLARE',
'T_DIR',
11061 'T_ECHO',
'T_ENDDECLARE',
'T_ENUM',
'T_EVAL',
'T_EXIT',
'T_EXTENDS',
11063 'T_FILE',
'T_FINAL',
'T_FINALLY',
'T_FN',
'T_FUNCTION',
'T_FUNC_C',
11064 'T_GLOBAL',
'T_GOTO',
11068 'T_IMPLEMENTS',
'T_INCLUDE',
'T_INCLUDE_ONCE',
'T_INSTEADOF',
'T_INTERFACE',
11078 'T_OPEN_TAG',
'T_OPEN_TAG_WITH_ECHO',
11080 'T_PRINT',
'T_PRIVATE',
'T_PROTECTED',
'T_PUBLIC',
11082 'T_READONLY',
'T_REQUIRE',
'T_REQUIRE_ONCE',
'T_RETURN',
11086 'T_THROW',
'T_TRAIT',
'T_TRAIT_C',
'T_TRY',
11087 'T_UNSET',
'T_UNSET_CAST',
'T_USE',
11100 $prohibited_variables = [
11101 '$_COOKIE',
'$_ENV',
'$_FILES',
'$GLOBALS',
'$_GET',
'$_POST',
'$_REQUEST',
'$_SERVER',
'$_SESSION',
11104 $prohibited_functions = [
11107 'override_function',
'session_id',
'session_create_id',
'session_regenerate_id',
11108 'call_user_func',
'call_user_func_array',
11109 'exec',
'passthru',
'shell_exec',
'system',
'proc_open',
'popen',
11110 'dol_eval',
'dol_eval_new',
'dol_eval_standard',
'dol_contctdesc',
'executeCLI',
'verifCond',
'GETPOST',
11111 'create_function',
'assert',
'mb_ereg_replace',
'mb_eregi_replace',
11112 'dol_compress_dir',
'dol_decode',
'dol_delete_file',
'dol_delete_dir',
'dol_delete_dir_recursive',
'dol_copy',
'archiveOrBackupFile',
11113 'fopen',
'file_put_contents',
'fputs',
'fputscsv',
'fwrite',
'fpassthru',
'mkdir',
'rmdir',
'symlink',
'touch',
'unlink',
'umask',
11114 'invoke',
'invokeArgs',
11115 'filter_input',
'filter_input_array',
'GETPOST',
11118 $prohibited_token_arrangements = [
11120 ' T_VARIABLE ( ',
' " ( ',
' \' ( ',
' T_CONSTANT_ENCAPSED_STRING ( ',
' ) ( ',
11123 $tokens = token_get_all(
"<?php return {$s};", TOKEN_PARSE);
11125 $tokens_arrangement =
' ';
11127 for ($i = 2,
$c = count($tokens) - 1; $i <
$c; ++$i) {
11128 if (is_array($tokens[$i])) {
11129 $token_id = $tokens[$i][0];
11130 $token_value = $tokens[$i][1];
11131 $token_name = token_name($tokens[$i][0]);
11133 $token_id = $tokens[$i];
11134 $token_value = $tokens[$i];
11135 $token_name = $tokens[$i];
11139 if (T_WHITESPACE === $token_id) {
11144 $tokens_arrangement .=
"{$token_name} ";
11147 if (T_VARIABLE === $token_id
11148 && in_array($token_value, $prohibited_variables,
true)
11150 return "« {$token_value} » is prohibited in « {$s} »";
11154 if (T_STRING === $token_id
11155 && in_array($token_value, $prohibited_functions,
true)
11157 return "« {$token_value} » is prohibited in « {$s} »";
11162 $maxi = count($prohibited_token_ids);
11163 for ($i = 0; $i < $maxi; ++$i) {
11164 if (
false !== strpos($tokens_arrangement,
" {$prohibited_token_ids[$i]} ")) {
11165 return "« {$prohibited_token_ids[$i]} » is prohibited in « {$s} »";
11170 $maxi = count($prohibited_token_arrangements);
11171 for ($i = 0; $i < $maxi; ++$i) {
11172 if (
false !== strpos($tokens_arrangement, $prohibited_token_arrangements[$i])) {
11173 return "« {$prohibited_token_arrangements[$i]} » is prohibited in « {$s} »";
11179 return @eval(
"return {$s};") ??
'';
11180 }
catch (Throwable $ex) {
11181 return "Exception during evaluation: ".$s.
" - ".$ex->getMessage();
11199function dol_eval_standard($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring =
'1')
11203 global $db, $langs, $user, $website, $websitepage;
11204 global $action, $mainmenu, $leftmenu;
11206 global $objectoffield;
11212 $isObBufferActive =
false;
11213 if (!in_array($onlysimplestring, array(
'0',
'1',
'2'))) {
11214 return "Bad call of dol_eval. Parameter onlysimplestring must be '0' (deprecated), '1' or '2'";
11216 if (!is_scalar($s)) {
11217 return "Bad call of dol_eval. First parameter must be a string, found ".var_export($s,
true);
11222 if ($onlysimplestring ==
'1' || $onlysimplestring ==
'2') {
11228 $specialcharsallowed =
'^$_+-.*>&|=!?():"\',/@';
11229 if ($onlysimplestring ==
'2') {
11230 $specialcharsallowed .=
'<[]';
11233 $specialcharsallowed .=
getDolGlobalString(
'MAIN_ALLOW_UNSECURED_SPECIAL_CHARS_IN_DOL_EVAL');
11235 if (preg_match(
'/[^a-z0-9\s'.preg_quote($specialcharsallowed,
'/').
']/i', $s)) {
11236 if ($returnvalue) {
11237 return 'Bad string syntax to evaluate (found chars that are not chars for a simple one line clean eval string): '.$s;
11239 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for a simple one line clean eval string): '.$s, LOG_WARNING);
11245 $tmps = str_replace(
' ? ',
'__XXX__', $s);
11246 if (strpos($tmps,
'?') !==
false) {
11247 if ($returnvalue) {
11248 return 'Bad string syntax to evaluate (The char ? can be used only with a space before and after): '.$s;
11250 dol_syslog(
'Bad string syntax to evaluate (The char ? can be used only with a space before and after): '.$s, LOG_WARNING);
11256 if (preg_match(
'/<=?[^\s]/', $s)) {
11257 if ($returnvalue) {
11258 return 'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found a < or <= without space before and after): '.$s;
11260 dol_syslog(
'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found a < or <= without space before and after): '.$s, LOG_WARNING);
11266 if (preg_match(
'/\$[\w]*\s*\(/', $s)) {
11267 if ($returnvalue) {
11268 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;
11270 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);
11279 while ($scheck && $savescheck != $scheck) {
11280 $savescheck = $scheck;
11281 $scheck = preg_replace(
'/->[a-zA-Z0-9_]+\(/',
'->__METHOD__', $scheck);
11282 $scheck = preg_replace(
'/::[a-zA-Z0-9_]+\(/',
'->__METHOD__', $scheck);
11283 $scheck = preg_replace(
'/^\(+/',
'__PARENTHESIS__ ', $scheck);
11284 $scheck = preg_replace(
'/\&\&\s+\(/',
'__ANDPARENTHESIS__ ', $scheck);
11285 $scheck = preg_replace(
'/\|\|\s+\(/',
'__ORPARENTHESIS__ ', $scheck);
11286 $scheck = preg_replace(
'/^!?[a-zA-Z0-9_]+\(/',
'__FUNCTION__', $scheck);
11287 $scheck = preg_replace(
'/\s!?[a-zA-Z0-9_]+\(/',
'__FUNCTION__', $scheck);
11288 $scheck = preg_replace(
'/^!\(/',
'__NOTANDPARENTHESIS__', $scheck);
11289 $scheck = preg_replace(
'/\s!\(/',
' __NOTANDPARENTHESIS__', $scheck);
11290 $scheck = preg_replace(
'/(\^|\')\(/',
'__REGEXSTART__', $scheck);
11295 if (strpos($scheck,
'(') !==
false) {
11296 if ($returnvalue) {
11297 return 'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found call of a function or method without using the direct name of the function): '.$s;
11299 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);
11308 if ($s ===
'Array') {
11309 if ($returnvalue) {
11310 return 'Bad string syntax to evaluate (value is Array): '.var_export($s,
true);
11312 dol_syslog(
'Bad string syntax to evaluate (value is Array): '.var_export($s,
true), LOG_WARNING);
11317 if (!
getDolGlobalString(
'MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL') && strpos($s,
'::') !==
false) {
11318 if ($returnvalue) {
11319 return 'Bad string syntax to evaluate (double : char is forbidden without setting MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL): '.$s;
11321 dol_syslog(
'Bad string syntax to evaluate (double : char is forbidden without setting MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL): '.$s, LOG_WARNING);
11326 if (strpos($s,
'`') !==
false) {
11327 if ($returnvalue) {
11328 return 'Bad string syntax to evaluate (backtick char is forbidden): '.$s;
11330 dol_syslog(
'Bad string syntax to evaluate (backtick char is forbidden): '.$s, LOG_WARNING);
11337 if (preg_match(
'/[^0-9]+\.[^0-9]+/', $s)) {
11338 if ($returnvalue) {
11339 return 'Bad string syntax to evaluate (dot char is forbidden): '.$s;
11341 dol_syslog(
'Bad string syntax to evaluate (dot char is forbidden): '.$s, LOG_WARNING);
11348 $forbiddenphpstrings = array(
'$$',
'$_',
'}[',
')(');
11349 $forbiddenphpstrings = array_merge($forbiddenphpstrings, array(
'_ENV',
'_SESSION',
'_COOKIE',
'_GET',
'_GLOBAL',
'_POST',
'_REQUEST',
'ReflectionFunction'));
11354 $forbiddenphpfunctions = array();
11355 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"override_function",
"session_id",
"session_create_id",
"session_regenerate_id"));
11356 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"get_defined_functions",
"get_defined_vars",
"get_defined_constants",
"get_declared_classes"));
11357 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"function",
"call_user_func",
"call_user_func_array"));
11359 $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"));
11360 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"usort",
"uasort",
"uksort",
"preg_replace_callback",
"preg_replace_callback_array",
"header_register_callback"));
11361 $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"));
11362 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"spl_autoload_register",
"spl_autoload_unregister",
"iterator_apply",
"session_set_save_handler"));
11363 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"forward_static_call",
"forward_static_call_array",
"register_postsend_function"));
11365 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"ob_start"));
11367 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"require",
"include",
"require_once",
"include_once"));
11368 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"exec",
"passthru",
"shell_exec",
"system",
"proc_open",
"popen"));
11369 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_eval",
"dol_eval_new",
"dol_eval_standard",
"dol_concatdesc",
"executeCLI",
"verifCond",
"GETPOST",
"dolEncrypt",
"dolDecrypt"));
11370 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"eval",
"create_function",
"assert",
"mb_ereg_replace"));
11371 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"readline_completion_function",
"readline_callback_handler_install"));
11372 $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"));
11373 $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"));
11374 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"require",
"include"));
11377 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"base64".
"_".
"decode",
"rawurl".
"decode",
"url".
"decode",
"str".
"_rot13",
"hex".
"2bin"));
11378 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_concatdesc"));
11381 $forbiddenphpmethods = array(
'invoke',
'invokeArgs');
11383 $forbiddenphpregex =
'global\s*\$';
11384 $forbiddenphpregex .=
'|';
11385 $forbiddenphpregex .=
'\b('.implode(
'|', $forbiddenphpfunctions).
')\b';
11387 $forbiddenphpmethodsregex =
'->('.implode(
'|', $forbiddenphpmethods).
')';
11390 $oldstringtoclean = $s;
11391 $s = str_ireplace($forbiddenphpstrings,
'__forbiddenstring__', $s);
11392 $s = preg_replace(
'/'.$forbiddenphpregex.
'/i',
'__forbiddenstring__', $s);
11393 $s = preg_replace(
'/'.$forbiddenphpmethodsregex.
'/i',
'__forbiddenstring__', $s);
11395 }
while ($oldstringtoclean != $s);
11398 if (strpos($s,
'__forbiddenstring__') !==
false) {
11399 dol_syslog(
'Bad string syntax to evaluate: '.$s, LOG_WARNING);
11400 if ($returnvalue) {
11401 return 'Bad string syntax to evaluate: '.$s;
11403 dol_syslog(
'Bad string syntax to evaluate: '.$s);
11409 if ($returnvalue) {
11411 $isObBufferActive =
true;
11412 $tmps = $hideerrors ? @eval(
'return ' . $s .
';') : eval(
'return ' . $s .
';');
11413 $tmpo = ob_get_clean();
11414 $isObBufferActive =
false;
11416 print
'Bad string syntax to evaluate. Some data were output when it should not when evaluating: ' . $s;
11420 dol_syslog(
'Do not use anymore dol_eval with param returnvalue=0', LOG_WARNING);
11428 }
catch (Error $e) {
11429 if ($isObBufferActive) {
11431 $tmpo = ob_get_clean();
11432 $isObBufferActive =
false;
11434 $error =
'dol_eval try/catch error : ';
11435 $error .= $e->getMessage();
11437 if ($returnvalue) {
11438 return 'Exception during evaluation: '.$s;
11454 return (trim($element) !=
'');
11467 if (empty($codelang)) {
11471 if ($codelang ==
'auto') {
11472 return '<span class="fa fa-language"></span>';
11475 $langtocountryflag = array(
11477 'ca_ES' =>
'catalonia',
11481 'sw_SW' =>
'unknown',
11491 if (isset($langtocountryflag[$codelang])) {
11492 $flagImage = $langtocountryflag[$codelang];
11494 $tmparray = explode(
'_', $codelang);
11495 $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
11500 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
11501 $morecss = $reg[1];
11506 return '<span class="flag-sprite '.strtolower($flagImage).($morecss ?
' '.$morecss :
'').
'"'.($moreatt ?
' '.$moreatt :
'').(!$notitlealt ?
' title="'.$codelang.
'"' :
'').
'></span>';
11520 if (empty($countrycode)) {
11524 if (strtoupper($countrycode) ==
'MQ') {
11527 if (strtoupper($countrycode) ==
'SE') {
11530 if (strtoupper($countrycode) ==
'CH') {
11531 if ($mysoc->country_code ==
'FR') {
11534 if ($mysoc->country_code ==
'DE') {
11537 if ($mysoc->country_code ==
'IT') {
11719 $buildprimarykeytotest = strtolower($countrycode).
'-'.strtoupper($countrycode);
11720 if (in_array($buildprimarykeytotest, $locales)) {
11721 return strtolower($countrycode).
'_'.strtoupper($countrycode);
11724 if (function_exists(
'locale_get_primary_language') && function_exists(
'locale_get_region')) {
11725 foreach ($locales as $locale) {
11726 $locale_language = locale_get_primary_language($locale);
11727 $locale_region = locale_get_region($locale);
11728 if (strtoupper($countrycode) == $locale_region) {
11730 return strtolower($locale_language).
'_'.strtoupper($locale_region);
11734 dol_syslog(
"Warning Extension php-intl is not available", LOG_WARNING);
11772 global $hookmanager, $db;
11774 if (isset(
$conf->modules_parts[
'tabs'][$type]) && is_array(
$conf->modules_parts[
'tabs'][$type])) {
11775 foreach (
$conf->modules_parts[
'tabs'][$type] as $value) {
11776 $values = explode(
':', $value);
11779 if ($mode ==
'add' && !preg_match(
'/^\-/', $values[1])) {
11784 $posstart = strpos($str,
'(');
11785 if ($posstart > 0) {
11786 $posend = strpos($str,
')');
11787 if ($posstart > 0) {
11788 $res1 = substr($str, $posstart + 1, $posend - $posstart - 1);
11789 if (is_numeric($res1)) {
11790 $postab = (int) $res1;
11791 $values[1] =
'+' . substr($str, $posend + 1);
11795 if (count($values) == 6) {
11799 if ($values[0] != $type) {
11805 if ($filterorigmodule) {
11806 if (strpos($values[3],
'@')) {
11807 if ($filterorigmodule !=
'external') {
11811 if ($filterorigmodule !=
'core') {
11816 $langs->load($values[3]);
11818 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
11820 $substitutionarray = array();
11825 $labeltemp = explode(
',', $values[2]);
11826 $label = $langs->trans($labeltemp[0]);
11828 if (!empty($labeltemp[1]) && is_object(
$object) && !empty(
$object->id)) {
11830 $classtoload = $labeltemp[1];
11831 if (class_exists($classtoload)) {
11832 $obj =
new $classtoload($db);
11833 $function = $labeltemp[3];
11834 if ($obj && $function && method_exists($obj, $function)) {
11836 $nbrec = $obj->$function(
$object->id, $obj);
11837 if (!empty($nbrec)) {
11838 $label .=
'<span class="badge marginleftonlyshort">'.$nbrec.
'</span>';
11846 $newtab[1] = $label;
11847 $newtab[2] = str_replace(
'+',
'', $values[1]);
11852 } elseif (count($values) == 5) {
11853 dol_syslog(
'Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
11855 if ($values[0] != $type) {
11859 if ($filterorigmodule) {
11860 if (strpos($values[3],
'@')) {
11861 if ($filterorigmodule !=
'external') {
11865 if ($filterorigmodule !=
'core') {
11870 $langs->load($values[3]);
11872 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
11873 $substitutionarray = array();
11877 $label = $langs->trans($values[2]);
11881 $newtab[1] = $label;
11882 $newtab[2] = str_replace(
'+',
'', $values[1]);
11886 $head = array_merge(array_slice($head, 0, $postab), array($newtab), array_slice($head, $postab));
11887 } elseif ($mode ==
'remove' && preg_match(
'/^\-/', $values[1])) {
11888 if ($values[0] != $type) {
11891 $tabname = str_replace(
'-',
'', $values[1]);
11892 foreach ($head as $key => $val) {
11893 $condition = (!empty($values[3]) ?
verifCond($values[3],
'2') : 1);
11895 if ($head[$key][2] == $tabname && $condition) {
11896 unset($head[$key]);
11905 if (!empty($hookmanager)) {
11906 $parameters = array(
'object' =>
$object,
'mode' => $mode,
'head' => &$head,
'filterorigmodule' => $filterorigmodule);
11908 $reshook = $hookmanager->executeHooks(
'completeTabsHead', $parameters,
$object);
11909 if ($reshook > 0) {
11910 $head = $hookmanager->resArray;
11912 $head = array_merge($head, $hookmanager->resArray);
11931 global
$conf, $hookmanager, $user, $langs;
11934 global $micro_start_time;
11936 if ($zone ==
'private') {
11937 print
"\n".
'<!-- Common footer for private page -->'.
"\n";
11939 print
"\n".
'<!-- Common footer for public page -->'.
"\n";
11943 print
"\n<!-- A div to store page_y POST parameter -->\n";
11944 print
'<div id="page_y" style="display: none;">'.(GETPOST(
'page_y') ?
GETPOST(
'page_y') :
'').
'</div>'.
"\n";
11946 $parameters = array();
11947 $reshook = $hookmanager->executeHooks(
'printCommonFooter', $parameters);
11948 if (empty($reshook)) {
11954 if (!empty(
$conf->use_javascript_ajax)) {
11955 print
"\n<!-- A script section to add menuhider handler on backoffice, manage focus and mandatory fields, tuning info, ... -->\n";
11956 print
'<script>'.
"\n";
11957 print
'jQuery(document).ready(function() {'.
"\n";
11959 if ($zone ==
'private' && empty(
$conf->dol_use_jmobile)) {
11961 print
'/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'.
"\n";
11962 print
'jQuery("li.menuhider").click(function(event) {';
11963 print
' if (!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'.
"\n";
11964 print
' console.log("We click on .menuhider");'.
"\n";
11965 print
' $("body").toggleClass("sidebar-collapse")'.
"\n";
11970 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"])))) {
11971 print
'/* JS CODE TO ENABLE to manage focus and mandatory form fields */'.
"\n";
11972 $relativepathstring = $_SERVER[
"PHP_SELF"];
11974 if (constant(
'DOL_URL_ROOT')) {
11975 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
11977 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
11978 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
11981 if (!empty($user->default_values[$relativepathstring][
'focus'])) {
11982 foreach ($user->default_values[$relativepathstring][
'focus'] as $defkey => $defval) {
11984 if ($defkey !=
'_noquery_') {
11985 $tmpqueryarraytohave = explode(
'&', $defkey);
11987 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
11988 $tmpquerytohaveparam = explode(
'=', $tmpquerytohave);
11990 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] !=
GETPOST($tmpquerytohaveparam[0]))) {
11994 if (!$foundintru) {
12003 print
'console.log("set the focus by executing jQuery(...).focus();")'.
"\n";
12004 foreach ($defval as $paramkey => $paramval) {
12006 print
'jQuery("input[name=\''.$paramkey.
'\']
").focus();'."\n
";
12007 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").focus();'."\n
"; // TODO KO with ckeditor
12008 print 'jQuery("select[
name=\
''.$paramkey.
'\']
").focus();'."\n
"; // Not really useful, but we keep it in case of.
12013 if (!empty($user->default_values[$relativepathstring]['mandatory'])) {
12014 foreach ($user->default_values[$relativepathstring]['mandatory'] as $defkey => $defval) {
12016 if ($defkey != '_noquery_') {
12017 $tmpqueryarraytohave = explode('&', $defkey);
12019 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
12020 $tmpquerytohaveparam = explode('=', $tmpquerytohave);
12021 //print "console.log(
'".$tmpquerytohaveparam[0]." ".$tmpquerytohaveparam[1]." ".GETPOST($tmpquerytohaveparam[0])."');
";
12022 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] != GETPOST($tmpquerytohaveparam[0]))) {
12026 if (!$foundintru) {
12029 //var_dump($defkey.'-'.$qualified);
12035 print 'console.log("set the js code to manage fields that are
set as mandatory
");'."\n
";
12037 foreach ($defval as $paramkey => $paramval) {
12038 // Solution 1: Add handler on submit to check if mandatory fields are empty
12039 print 'var form = $(\'[name="'.dol_escape_js($paramkey).'"]\').closest("form
");'."\n
";
12040 print "form.on(
'submit',
function(event) {
12041 var submitter = \$(
this).find(
':submit:focus').get(0);
12042 var buttonName = submitter ? \$(submitter).attr(
'name') :
'save';
12044 if (buttonName ==
'cancel') {
12045 console.log(
'We click on cancel button so we accept submit with no need to check mandatory fields');
12049 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');
12051 var tmpvalue = jQuery(
'[name=\"".dol_escape_js($paramkey)."\"]').val();
12052 let tmptypefield = jQuery(
'[name=\"".dol_escape_js($paramkey)."\"]').prop(
'nodeName').toLowerCase();
12054 if (tmptypefield ==
'textarea') {
12056 var tmpeditor = CKEDITOR.instances[
'".dol_escape_js($paramkey)."'];
12058 tmpvalue = tmpeditor.getData();
12059 console.log(
'For textarea tmpvalue is '+tmpvalue);
12063 let tmpvalueisempty =
false;
12064 if (tmpvalue ===
null || tmpvalue === undefined || tmpvalue ===
'' || tmpvalue === -1) {
12065 tmpvalueisempty =
true;
12067 if (tmpvalue ===
'0' && (tmptypefield ==
'select' || tmptypefield ==
'input')) {
12068 tmpvalueisempty =
true;
12070 if (tmpvalueisempty && buttonName !==
'cancel') {
12071 console.log(
'field has type '+tmptypefield+
' and is empty, we cancel the submit');
12072 event.preventDefault();
12073 event.stopPropagation();
12075 alert(
'".dol_escape_js($langs->transnoentitiesnoconv("ErrorFieldRequired", $paramkey).' (
'.$langs->transnoentitiesnoconv("CustomMandatoryFieldRule").')
')."');
12079 console.log(
'field has type '+tmptypefield+
' and is defined to '+tmpvalue);
12084 // Solution 2: Add property 'required' on input
12085 // so browser will check value and try to focus on it when submitting the form.
12086 //print 'setTimeout(function() {'; // If we want to wait that ckeditor beuatifier has finished its job.
12087 //print 'jQuery("input[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
12088 //print 'jQuery("textarea[
id=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
12089 //print 'jQuery("select[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";*/
12090 //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
";
12091 //print 'jQuery("select[
name=\
''.$paramkey.
'\'] option[value=\
'-1\']").prop(\'value\', \'\');'.
"\n";
12097 print
'jQuery(\':input[name="' .
dol_escape_js($paramkey) .
'"]\').closest("tr").find("td:first").addClass("fieldrequired");'.
"\n";
12101 print
'jQuery("input[name=\'cancel\']").click(function() {
12102 console.log("We click on cancel button so removed all required attribute");
12103 jQuery("input, textarea, select").each(function(){this.removeAttribute(\'required\');});
12113 if (!empty($_SERVER[
'MAIN_SHOW_TUNING_INFO']) ||
getDolGlobalString(
'MAIN_SHOW_TUNING_INFO')) {
12115 print
"/* JS CODE TO ENABLE to add memory info */\n";
12116 print
'window.console && console.log("';
12121 if (!empty($micro_start_time)) {
12122 $micro_end_time = microtime(
true);
12123 print
' - Build time: '.ceil(1000 * ($micro_end_time - $micro_start_time)).
' ms';
12126 if (function_exists(
"memory_get_usage")) {
12127 print
' - Mem: '.memory_get_usage();
12129 if (function_exists(
"memory_get_peak_usage")) {
12130 print
' - Real mem peak: '.memory_get_peak_usage(
true);
12132 if (function_exists(
"zend_loader_file_encoded")) {
12133 print
' - Zend encoded file: '.(zend_loader_file_encoded() ?
'yes' :
'no');
12138 print
"\n".
'</script>'.
"\n";
12144 foreach ($tmptagarray as $tmptag) {
12146 print
"<!-- JS CODE TO ENABLE for google analtics tag -->\n";
12148 <!-- Global site tag (gtag.js) - Google Analytics -->
12149 <script nonce="'.getNonce().
'" async src="https://www.googletagmanager.com/gtag/js?id='.trim($tmptag).
'"></script>
12151 window.dataLayer = window.dataLayer || [];
12152 function gtag(){dataLayer.push(arguments);}
12153 gtag(\'js\', new Date());
12155 gtag(\'config\', \''.trim($tmptag).
'\');
12162 // Add Xdebug coverage of code
12163 if (defined('XDEBUGCOVERAGE
')) {
12164 print_r(xdebug_get_code_coverage());
12167 // Add DebugBar data
12168 if ($user->hasRight('debugbar
', 'read
') && $debugbar instanceof DebugBar\DebugBar) {
12169 if (isset($debugbar['time
'])) {
12170 // @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
12171 $debugbar['time
']->stopMeasure('pageaftermaster
');
12173 print '<!-- Output debugbar data -->
'."\n";
12174 $renderer = $debugbar->getJavascriptRenderer();
12175 print $renderer->render();
12176 } elseif (count($conf->logbuffer)) { // If there is some logs in buffer to show
12178 print "<!-- Start of log output\n";
12179 //print '<div
class=
"hidden">
'."\n";
12180 foreach ($conf->logbuffer as $logline) {
12181 print $logline."<br>\n";
12183 //print '</div>
'."\n";
12184 print "End of log output -->\n";
12198function dolExplodeIntoArray($string, $delimiter = ';
', $kv = '=
')
12200 if (is_null($string)) {
12204 if (preg_match('/^\[.*\]$/sm
', $delimiter) || preg_match('/^\(.*\)$/sm
', $delimiter)) {
12205 // This is a regex string
12206 $newdelimiter = $delimiter;
12208 // This is a simple string
12209 // @phan-suppress-next-line PhanPluginSuspiciousParamPositionInternal
12210 $newdelimiter = preg_quote($delimiter, '/
');
12213 if ($a = preg_split('/
'.$newdelimiter.'/
', $string)) {
12215 foreach ($a as $s) { // each part
12217 if ($pos = strpos($s, $kv)) { // key/value delimiter
12218 $ka[trim(substr($s, 0, $pos))] = trim(substr($s, $pos + strlen($kv)));
12219 } else { // key delimiter not found
12237function dolExplodeKeepIfQuotes($input)
12239 // Use regexp to capture words and section in quotes
12240 $matches = array();
12241 preg_match_all('/
"([^"]*)
"|\'([^\']*)\'|(\S+)/', $input, $matches);
12243 // Merge result and delete empty values
12245 $result = array_map(
12252 static function ($a, $b, $c) {
12268 return array_values(array_filter(
12276 static function ($val) {
12277 return $val !== '';
12289function dol_set_focus($selector)
12291 print "\n
".'<!-- Set focus onto a specific field -->'."\n
";
12292 print '<script nonce="'.getNonce().'">jQuery(document).ready(function() { console.log("Force focus by
dol_set_focus"); jQuery("'.dol_escape_js($selector).'").focus(); });</script>'."\n
";
12303function dol_getmypid()
12305 if (!function_exists('getmypid')) {
12306 return mt_rand(99900000, 99965535);
12308 return getmypid(); // May be a number on 64 bits (depending on OS)
12333function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
12335 global $db, $langs;
12337 $value = trim($value);
12340 $value = preg_replace('/\*/', '%', $value); // Replace * with %
12343 $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
12346 $value = preg_replace('/\s*\|\s*/', '|', $value);
12348 // Split criteria on ' ' but not if we are inside quotes.
12349 // For mode 3, the split is done later on the , only and not on the ' '.
12350 if ($mode != -3 && $mode != 3) {
12351 $crits = dolExplodeKeepIfQuotes($value);
12353 $crits = array($value);
12357 if (!is_array($fields)) {
12358 $fields = array($fields);
12360 $i1 = 0; // count the nb of "and
" criteria added (all fields / criteria)
12361 foreach ($crits as $crit) { // Loop on each AND criteria
12362 $crit = trim($crit);
12363 $i2 = 0; // count the nb of valid criteria added for this this first criteria
12366 foreach ($fields as $field) {
12368 $tmpcrits = explode('|', $crit);
12369 $i3 = 0; // count the nb of valid criteria added for this current field
12370 foreach ($tmpcrits as $tmpcrit) {
12371 if ($tmpcrit !== '0' && empty($tmpcrit)) {
12374 $tmpcrit = trim($tmpcrit);
12376 $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '');
12379 $newcrit = preg_replace('/([!<>=]+)/', '', $tmpcrit);
12382 preg_match('/([!<>=]+)/', $tmpcrit, $reg);
12383 if (!empty($reg[1])) {
12384 $operator = $reg[1];
12386 if ($newcrit != '') {
12387 $numnewcrit = price2num($newcrit);
12388 if (is_numeric($numnewcrit)) {
12389 $newres .= $db->sanitize($field).' '.$operator.' '.((float) $numnewcrit); // should be a numeric
12391 $newres .= '1 = 2'; // force false, we received a corrupted data
12393 $i3++; // a criteria was added to string
12396 $i2++; // a criteria for 1 more field was added to string
12397 } elseif ($mode == 2 || $mode == -2) {
12398 $crit = preg_replace('/[^\-0-9,]/', '', $crit); // ID are always integer
12399 $newres .= ($i2 > 0 ? ' OR ' : '').$db->sanitize($field)." ".($mode == -2 ? 'NOT ' : '');
12400 $newres .= $crit ? "IN (
".$db->sanitize($db->escape($crit)).")
" : "IN (0)
";
12402 $newres .= ' OR '.$db->sanitize($field).' IS NULL';
12404 $i2++; // a criteria for 1 more field was added to string
12405 } elseif ($mode == 3 || $mode == -3) {
12406 $tmparray = explode(',', $crit);
12407 if (count($tmparray)) {
12409 foreach ($tmparray as $val) {
12412 $listofcodes .= ($listofcodes ? ',' : '');
12413 $listofcodes .= "'".$db->escape($val)."'";
12416 $newres .= ($i2 > 0 ? ' OR ' : '').$db->sanitize($field)." ".($mode == -3 ? 'NOT ' : '')."IN (
".$db->sanitize($listofcodes, 1, 0, 1).")
";
12417 $i2++; // a criteria for 1 more field was added to string
12420 $newres .= ' OR '.$db->sanitize($field).' IS NULL';
12422 } elseif ($mode == 4) {
12423 $tmparray = explode(',', $crit);
12424 if (count($tmparray)) {
12426 foreach ($tmparray as $val) {
12429 $newres .= ($i2 > 0 ? " OR (
" : "(
").$db->sanitize($field)." LIKE
'".$db->escape($val).",%'";
12430 $newres .= ' OR '.$db->sanitize($field)." =
'".$db->escape($val)."'";
12431 $newres .= ' OR '.$db->sanitize($field)." LIKE
'%,".$db->escape($val)."'";
12432 $newres .= ' OR '.$db->sanitize($field)." LIKE
'%,".$db->escape($val).",%'";
12434 $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)
12438 } else { // $mode=0
12439 $tmpcrits = explode('|', $crit);
12440 $i3 = 0; // count the nb of valid criteria added for the current couple criteria/field
12441 foreach ($tmpcrits as $tmpcrit) { // loop on each OR criteria
12442 if ($tmpcrit !== '0' && empty($tmpcrit)) {
12445 $tmpcrit = trim($tmpcrit);
12447 if ($tmpcrit == '^$' || strpos($crit, '!') === 0) { // If we search empty, we must combined different OR fields with AND
12448 $newres .= (($i2 > 0 || $i3 > 0) ? ' AND ' : '');
12450 $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '');
12453 if (preg_match('/\.(id|rowid)$/', $field)) { // Special case for rowid that is sometimes a ref so used as a search field
12454 $newres .= $db->sanitize($field)." =
".(is_numeric($tmpcrit) ? ((float) $tmpcrit) : '0');
12456 $tmpcrit2 = $tmpcrit;
12461 if (preg_match('/^!/', $tmpcrit)) {
12462 $tmps .= $db->sanitize($field)." NOT LIKE
"; // ! as exclude character
12463 $tmpcrit2 = preg_replace('/^!/', '', $tmpcrit2);
12465 $tmps .= $db->sanitize($field)." LIKE
";
12469 if (preg_match('/^[\^\$]/
', $tmpcrit)) {
12471 $tmpcrit2 = preg_replace('/^[\^\$]/
', '', $tmpcrit2);
12473 if (preg_match('/[\^\$]$/
', $tmpcrit)) {
12475 $tmpcrit2 = preg_replace('/[\^\$]$/
', '', $tmpcrit2);
12478 if ($tmpcrit2 == '' || preg_match('/^!/
', $tmpcrit)) {
12482 $newres .= $tmpbefore;
12483 $newres .= $db->escape($tmpcrit2);
12484 $newres .= $tmpafter;
12486 if ($tmpcrit2 == '' || preg_match('/^!/', $tmpcrit)) {
12487 $newres .= " OR
".$field." IS NULL)
";
12494 $i2++; // a criteria for 1 more field was added to string
12498 $res = $res.($res ? ' AND ' : '').($i2 > 1 ? '(' : '').$newres.($i2 > 1 ? ')' : '');
12502 $res = ($nofirstand ? "" : " AND
")."(
".$res.")
";
12513function showDirectDownloadLink($object)
12518 $url = $object->getLastMainDocLink($object->element);
12520 $out .= img_picto($langs->trans("PublicDownloadLinkDesc
"), 'globe').' <span class="opacitymedium
">'.$langs->trans("DirectDownloadLink
").'</span><br>';
12522 $out .= '<div class="urllink
"><input type="text
" id="directdownloadlink
" class="quatrevingtpercent
" value="'.$url.'"></div>';
12523 $out .= ajax_autoselect("directdownloadlink
", '');
12525 $out .= '<div class="urllink
">'.$langs->trans("FileNotShared
").'</div>';
12539function getImageFileNameForSize($file, $extName, $extImgTarget = '')
12541 $dirName = dirname($file);
12542 if ($dirName == '.') {
12546 if (!in_array($extName, array('', '_small', '_mini'))) {
12547 return 'Bad parameter extName';
12550 $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp|\.webp)$/i', '', $file); // We remove image extension, whatever is its case
12551 $fileName = basename($fileName);
12553 if (empty($extImgTarget)) {
12554 $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : '');
12556 if (empty($extImgTarget)) {
12557 $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '');
12559 if (empty($extImgTarget)) {
12560 $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : '');
12562 if (empty($extImgTarget)) {
12563 $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : '');
12565 if (empty($extImgTarget)) {
12566 $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : '');
12568 if (empty($extImgTarget)) {
12569 $extImgTarget = (preg_match('/\.webp$/i', $file) ? '.webp' : '');
12572 if (!$extImgTarget) {
12578 $subdir = 'thumbs/';
12581 return ($dirName ? $dirName.'/' : '').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb
12594function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param = '')
12596 global $conf, $langs;
12598 if (empty($conf->use_javascript_ajax)) {
12602 $isAllowedForPreview = dolIsAllowedForPreview($relativepath);
12604 if ($alldata == 1) {
12605 if ($isAllowedForPreview) {
12606 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));
12612 // old behavior, return a string
12613 if ($isAllowedForPreview) {
12614 $tmpurl = DOL_URL_ROOT.'/document.php?modulepart='.urlencode($modulepart).'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : '');
12615 $title = $langs->transnoentities("Preview
");
12616 //$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().
12617 //$tmpurl = 'file='.urlencode("'-alert(document.domain)-'_small.jpg
"); // An example of tmpurl that should be blocked by the dol_escape_uri()
12619 // 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,
12620 // 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.
12621 // Using the dol_escape_uri guarantee that we encode for URI so decode retrieve original expected value.
12622 return 'javascript:'.dol_escape_uri('document_preview(\''.dol_escape_js($tmpurl).'\', \''.dol_escape_js(dol_mimetype($relativepath)).'\', \''.dol_escape_js($title).'\')');
12634function getLabelSpecialCode($idcode)
12638 $arrayspecialines = array(1 => 'Transport', 2 => 'EcoTax', 3 => 'Option');
12639 if ($idcode > 10) {
12640 return 'Module ID '.$idcode;
12642 if (!empty($arrayspecialines[$idcode])) {
12643 return $langs->trans($arrayspecialines[$idcode]);
12656function ajax_autoselect($htmlname, $addlink = '', $textonlink = 'Link')
12659 $out = '<script nonce="
'.getNonce().'">
12660 jQuery(document).ready(function () {
12661 jQuery("'.((strpos($htmlname, '.
') === 0 ? '' : '#
').$htmlname).'").click(function() { jQuery(this).select(); } );
12665 if ($textonlink === 'image') {
12666 $out .= ' <a href="'.$addlink.'" target="_blank
" rel="noopener noreferrer
">'.img_picto('', 'globe').'</a>';
12668 $out .= ' <a href="'.$addlink.'" target="_blank
" rel="noopener noreferrer
">'.$langs->trans("Link").'</a>';
12681function dolIsAllowedForPreview($file)
12683 // Check .noexe extension in filename
12684 if (preg_match('/\.noexe$/i', $file)) {
12688 // Check mime types
12689 $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'webp');
12690 if (getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES')) {
12691 $mime_preview[] = 'svg+xml';
12693 //$mime_preview[]='vnd.oasis.opendocument.presentation';
12694 //$mime_preview[]='archive';
12695 $num_mime = array_search(dol_mimetype($file, '', 1), $mime_preview);
12696 if ($num_mime !== false) {
12700 // By default, not allowed for preview
12714function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0)
12717 $imgmime = 'other.png';
12718 $famime = 'file-o';
12721 $tmpfile = preg_replace('/\.noexe$/', '', $file);
12723 // Plain text files
12724 if (preg_match('/\.txt$/i', $tmpfile)) {
12725 $mime = 'text/plain';
12726 $imgmime = 'text.png';
12727 $famime = 'file-alt';
12728 } elseif (preg_match('/\.rtx$/i', $tmpfile)) {
12729 $mime = 'text/richtext';
12730 $imgmime = 'text.png';
12731 $famime = 'file-alt';
12732 } elseif (preg_match('/\.csv$/i', $tmpfile)) {
12733 $mime = 'text/csv';
12734 $imgmime = 'text.png';
12735 $famime = 'file-csv';
12736 } elseif (preg_match('/\.tsv$/i', $tmpfile)) {
12737 $mime = 'text/tab-separated-values';
12738 $imgmime = 'text.png';
12739 $famime = 'file-alt';
12740 } elseif (preg_match('/\.(cf|conf|log)$/i', $tmpfile)) {
12741 $mime = 'text/plain';
12742 $imgmime = 'text.png';
12743 $famime = 'file-alt';
12744 } elseif (preg_match('/\.ini$/i', $tmpfile)) {
12745 $mime = 'text/plain';
12746 $imgmime = 'text.png';
12748 $famime = 'file-alt';
12749 } elseif (preg_match('/\.md$/i', $tmpfile)) {
12750 $mime = 'text/plain';
12751 $imgmime = 'text.png';
12753 $famime = 'file-alt';
12754 } elseif (preg_match('/\.css$/i', $tmpfile)) {
12755 $mime = 'text/css';
12756 $imgmime = 'css.png';
12758 $famime = 'file-alt';
12759 } elseif (preg_match('/\.lang$/i', $tmpfile)) {
12760 $mime = 'text/plain';
12761 $imgmime = 'text.png';
12763 $famime = 'file-alt';
12764 } elseif (preg_match('/\.(crt|cer|key|pub)$/i', $tmpfile)) { // Certificate files
12765 $mime = 'text/plain';
12766 $imgmime = 'text.png';
12767 $famime = 'file-alt';
12768 } elseif (preg_match('/\.(html|htm|shtml)$/i', $tmpfile)) { // XML based (HTML/XML/XAML)
12769 $mime = 'text/html';
12770 $imgmime = 'html.png';
12772 $famime = 'file-alt';
12773 } elseif (preg_match('/\.(xml|xhtml)$/i', $tmpfile)) {
12774 $mime = 'text/xml';
12775 $imgmime = 'other.png';
12777 $famime = 'file-alt';
12778 } elseif (preg_match('/\.xaml$/i', $tmpfile)) {
12779 $mime = 'text/xml';
12780 $imgmime = 'other.png';
12782 $famime = 'file-alt';
12783 } elseif (preg_match('/\.bas$/i', $tmpfile)) { // Languages
12784 $mime = 'text/plain';
12785 $imgmime = 'text.png';
12787 $famime = 'file-code';
12788 } elseif (preg_match('/\.(c)$/i', $tmpfile)) {
12789 $mime = 'text/plain';
12790 $imgmime = 'text.png';
12792 $famime = 'file-code';
12793 } elseif (preg_match('/\.(cpp)$/i', $tmpfile)) {
12794 $mime = 'text/plain';
12795 $imgmime = 'text.png';
12797 $famime = 'file-code';
12798 } elseif (preg_match('/\.cs$/i', $tmpfile)) {
12799 $mime = 'text/plain';
12800 $imgmime = 'text.png';
12802 $famime = 'file-code';
12803 } elseif (preg_match('/\.(h)$/i', $tmpfile)) {
12804 $mime = 'text/plain';
12805 $imgmime = 'text.png';
12807 $famime = 'file-code';
12808 } elseif (preg_match('/\.(java|jsp)$/i', $tmpfile)) {
12809 $mime = 'text/plain';
12810 $imgmime = 'text.png';
12812 $famime = 'file-code';
12813 } elseif (preg_match('/\.php([0-9]{1})?$/i', $tmpfile)) {
12814 $mime = 'text/plain';
12815 $imgmime = 'php.png';
12817 $famime = 'file-code';
12818 } elseif (preg_match('/\.phtml$/i', $tmpfile)) {
12819 $mime = 'text/plain';
12820 $imgmime = 'php.png';
12822 $famime = 'file-code';
12823 } elseif (preg_match('/\.(pl|pm)$/i', $tmpfile)) {
12824 $mime = 'text/plain';
12825 $imgmime = 'pl.png';
12827 $famime = 'file-code';
12828 } elseif (preg_match('/\.sql$/i', $tmpfile)) {
12829 $mime = 'text/plain';
12830 $imgmime = 'text.png';
12832 $famime = 'file-code';
12833 } elseif (preg_match('/\.js$/i', $tmpfile)) {
12834 $mime = 'text/x-javascript';
12835 $imgmime = 'jscript.png';
12837 $famime = 'file-code';
12838 } elseif (preg_match('/\.odp$/i', $tmpfile)) { // Open office
12839 $mime = 'application/vnd.oasis.opendocument.presentation';
12840 $imgmime = 'ooffice.png';
12841 $famime = 'file-powerpoint';
12842 } elseif (preg_match('/\.ods$/i', $tmpfile)) {
12843 $mime = 'application/vnd.oasis.opendocument.spreadsheet';
12844 $imgmime = 'ooffice.png';
12845 $famime = 'file-excel';
12846 } elseif (preg_match('/\.odt$/i', $tmpfile)) {
12847 $mime = 'application/vnd.oasis.opendocument.text';
12848 $imgmime = 'ooffice.png';
12849 $famime = 'file-word';
12850 } elseif (preg_match('/\.mdb$/i', $tmpfile)) { // MS Office
12851 $mime = 'application/msaccess';
12852 $imgmime = 'mdb.png';
12854 } elseif (preg_match('/\.doc[xm]?$/i', $tmpfile)) {
12855 $mime = 'application/msword';
12856 $imgmime = 'doc.png';
12857 $famime = 'file-word';
12858 } elseif (preg_match('/\.dot[xm]?$/i', $tmpfile)) {
12859 $mime = 'application/msword';
12860 $imgmime = 'doc.png';
12861 $famime = 'file-word';
12862 } elseif (preg_match('/\.xlt(x)?$/i', $tmpfile)) {
12863 $mime = 'application/vnd.ms-excel';
12864 $imgmime = 'xls.png';
12865 $famime = 'file-excel';
12866 } elseif (preg_match('/\.xla(m)?$/i', $tmpfile)) {
12867 $mime = 'application/vnd.ms-excel';
12868 $imgmime = 'xls.png';
12869 $famime = 'file-excel';
12870 } elseif (preg_match('/\.xls$/i', $tmpfile)) {
12871 $mime = 'application/vnd.ms-excel';
12872 $imgmime = 'xls.png';
12873 $famime = 'file-excel';
12874 } elseif (preg_match('/\.xls[bmx]$/i', $tmpfile)) {
12875 $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
12876 $imgmime = 'xls.png';
12877 $famime = 'file-excel';
12878 } elseif (preg_match('/\.pps[mx]?$/i', $tmpfile)) {
12879 $mime = 'application/vnd.ms-powerpoint';
12880 $imgmime = 'ppt.png';
12881 $famime = 'file-powerpoint';
12882 } elseif (preg_match('/\.ppt[mx]?$/i', $tmpfile)) {
12883 $mime = 'application/x-mspowerpoint';
12884 $imgmime = 'ppt.png';
12885 $famime = 'file-powerpoint';
12886 } elseif (preg_match('/\.pdf$/i', $tmpfile)) { // Other
12887 $mime = 'application/pdf';
12888 $imgmime = 'pdf.png';
12889 $famime = 'file-pdf';
12890 } elseif (preg_match('/\.bat$/i', $tmpfile)) { // Scripts
12891 $mime = 'text/x-bat';
12892 $imgmime = 'script.png';
12894 $famime = 'file-code';
12895 } elseif (preg_match('/\.sh$/i', $tmpfile)) {
12896 $mime = 'text/x-sh';
12897 $imgmime = 'script.png';
12899 $famime = 'file-code';
12900 } elseif (preg_match('/\.ksh$/i', $tmpfile)) {
12901 $mime = 'text/x-ksh';
12902 $imgmime = 'script.png';
12904 $famime = 'file-code';
12905 } elseif (preg_match('/\.bash$/i', $tmpfile)) {
12906 $mime = 'text/x-bash';
12907 $imgmime = 'script.png';
12909 $famime = 'file-code';
12910 } elseif (preg_match('/\.ico$/i', $tmpfile)) { // Images
12911 $mime = 'image/x-icon';
12912 $imgmime = 'image.png';
12913 $famime = 'file-image';
12914 } elseif (preg_match('/\.(jpg|jpeg)$/i', $tmpfile)) {
12915 $mime = 'image/jpeg';
12916 $imgmime = 'image.png';
12917 $famime = 'file-image';
12918 } elseif (preg_match('/\.png$/i', $tmpfile)) {
12919 $mime = 'image/png';
12920 $imgmime = 'image.png';
12921 $famime = 'file-image';
12922 } elseif (preg_match('/\.gif$/i', $tmpfile)) {
12923 $mime = 'image/gif';
12924 $imgmime = 'image.png';
12925 $famime = 'file-image';
12926 } elseif (preg_match('/\.bmp$/i', $tmpfile)) {
12927 $mime = 'image/bmp';
12928 $imgmime = 'image.png';
12929 $famime = 'file-image';
12930 } elseif (preg_match('/\.(tif|tiff)$/i', $tmpfile)) {
12931 $mime = 'image/tiff';
12932 $imgmime = 'image.png';
12933 $famime = 'file-image';
12934 } elseif (preg_match('/\.svg$/i', $tmpfile)) {
12935 $mime = 'image/svg+xml';
12936 $imgmime = 'image.png';
12937 $famime = 'file-image';
12938 } elseif (preg_match('/\.webp$/i', $tmpfile)) {
12939 $mime = 'image/webp';
12940 $imgmime = 'image.png';
12941 $famime = 'file-image';
12942 } elseif (preg_match('/\.vcs$/i', $tmpfile)) { // Calendar
12943 $mime = 'text/calendar';
12944 $imgmime = 'other.png';
12945 $famime = 'file-alt';
12946 } elseif (preg_match('/\.ics$/i', $tmpfile)) {
12947 $mime = 'text/calendar';
12948 $imgmime = 'other.png';
12949 $famime = 'file-alt';
12950 } elseif (preg_match('/\.torrent$/i', $tmpfile)) { // Other
12951 $mime = 'application/x-bittorrent';
12952 $imgmime = 'other.png';
12953 $famime = 'file-o';
12954 } elseif (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i', $tmpfile)) { // Audio
12956 $imgmime = 'audio.png';
12957 $famime = 'file-audio';
12958 } elseif (preg_match('/\.mp4$/i', $tmpfile)) { // Video
12959 $mime = 'video/mp4';
12960 $imgmime = 'video.png';
12961 $famime = 'file-video';
12962 } elseif (preg_match('/\.ogv$/i', $tmpfile)) {
12963 $mime = 'video/ogg';
12964 $imgmime = 'video.png';
12965 $famime = 'file-video';
12966 } elseif (preg_match('/\.webm$/i', $tmpfile)) {
12967 $mime = 'video/webm';
12968 $imgmime = 'video.png';
12969 $famime = 'file-video';
12970 } elseif (preg_match('/\.avi$/i', $tmpfile)) {
12971 $mime = 'video/x-msvideo';
12972 $imgmime = 'video.png';
12973 $famime = 'file-video';
12974 } elseif (preg_match('/\.divx$/i', $tmpfile)) {
12975 $mime = 'video/divx';
12976 $imgmime = 'video.png';
12977 $famime = 'file-video';
12978 } elseif (preg_match('/\.xvid$/i', $tmpfile)) {
12979 $mime = 'video/xvid';
12980 $imgmime = 'video.png';
12981 $famime = 'file-video';
12982 } elseif (preg_match('/\.(wmv|mpg|mpeg)$/i', $tmpfile)) {
12984 $imgmime = 'video.png';
12985 $famime = 'file-video';
12986 } elseif (preg_match('/\.(zip|rar|gz|tgz|xz|z|cab|bz2|7z|tar|lzh|zst)$/i', $tmpfile)) { // Archive
12987 // application/xxx where zzz is zip, ...
12989 $imgmime = 'archive.png';
12990 $famime = 'file-archive';
12991 } elseif (preg_match('/\.(exe|com)$/i', $tmpfile)) { // Exe
12992 $mime = 'application/octet-stream';
12993 $imgmime = 'other.png';
12994 $famime = 'file-o';
12995 } elseif (preg_match('/\.(dll|lib|o|so|a)$/i', $tmpfile)) { // Lib
12997 $imgmime = 'library.png';
12998 $famime = 'file-o';
12999 } elseif (preg_match('/\.err$/i', $tmpfile)) { // phpcs:ignore
13001 $imgmime = 'error.png';
13002 $famime = 'file-alt';
13005 if ($famime == 'file-o') {
13006 // file-o seems to not work in fontawesome 5
13010 // Return mimetype string
13011 switch ((int) $mode) {
13013 $tmp = explode('/', $mime);
13014 return (!empty($tmp[1]) ? $tmp[1] : $tmp[0]);
13036function getDictionaryValue($tablename, $field, $id, $checkentity = false, $rowidfield = 'rowid')
13040 $tablename = preg_replace('/^'.preg_quote(MAIN_DB_PREFIX, '/').'/', '', $tablename); // Clean name of table for backward compatibility.
13042 $dictvalues = (isset($conf->cache['dictvalues_'.$tablename]) ? $conf->cache['dictvalues_'.$tablename] : null);
13044 if (is_null($dictvalues)) {
13045 $dictvalues = array();
13047 $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
13048 if ($checkentity) {
13049 $sql .= ' AND entity IN (0,'.getEntity($tablename).')';
13052 $resql = $db->query($sql);
13054 while ($obj = $db->fetch_object($resql)) {
13055 $dictvalues[$obj->$rowidfield] = $obj; // $obj is stdClass
13058 dol_print_error($db);
13061 $conf->cache['dictvalues_'.$tablename] = $dictvalues;
13064 if (!empty($dictvalues[$id])) {
13066 $tmp = $dictvalues[$id];
13067 return (property_exists($tmp, $field) ? $tmp->$field : '');
13080function colorIsLight($stringcolor)
13082 $stringcolor = str_replace('#', '', $stringcolor);
13084 if (!empty($stringcolor)) {
13086 $tmp = explode(',', $stringcolor);
13087 if (count($tmp) > 1) { // This is a comma RGB ('255','255','255')
13092 $hexr = $stringcolor[0].$stringcolor[1];
13093 $hexg = $stringcolor[2].$stringcolor[3];
13094 $hexb = $stringcolor[4].$stringcolor[5];
13095 $r = hexdec($hexr);
13096 $g = hexdec($hexg);
13097 $b = hexdec($hexb);
13099 $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm
13100 if ($bright > 0.6) {
13115function isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal)
13119 //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms'];
13120 //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal);
13121 if (empty($menuentry['enabled'])) {
13122 return 0; // Entry disabled by condition
13124 if ($type_user && array_key_exists('module', $menuentry) && $menuentry['module']) {
13125 $tmploops = explode('|', $menuentry['module']);
13127 foreach ($tmploops as $tmploop) {
13128 if (in_array($tmploop, $listofmodulesforexternal)) {
13134 return 0; // Entry is for menus all excluded to external users
13137 if (!$menuentry['perms'] && $type_user) {
13138 return 0; // No permissions and user is external
13140 if (!$menuentry['perms'] && getDolGlobalString('MAIN_MENU_HIDE_UNAUTHORIZED')) {
13141 return 0; // No permissions and option to hide when not allowed, even for internal user, is on
13143 if (!$menuentry['perms']) {
13144 return 2; // No permissions and user is external
13156function roundUpToNextMultiple($n, $x = 5)
13158 $result = (ceil($n) % $x === 0) ? ceil($n) : (round(($n + $x / 2) / $x) * $x);
13159 return (int) $result;
13173function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '', $params = array())
13175 $csstouse = 'badge';
13176 $csstouse .= (!empty($mode) ? ' badge-'.$mode : '');
13177 $csstouse .= (!empty($type) ? ' badge-'.$type : '');
13178 $csstouse .= (empty($params['css']) ? '' : ' '.$params['css']);
13181 'class' => $csstouse
13184 if (empty($html)) {
13188 if (!empty($url)) {
13189 $attr['href'] = $url;
13192 if ($mode === 'dot') {
13193 $attr['class'] .= ' classfortooltip';
13194 $attr['title'] = $html;
13195 $attr['aria-label'] = $label;
13200 if (!empty($params['attr']) && is_array($params['attr'])) {
13201 foreach ($params['attr'] as $key => $value) {
13202 if ($key == 'class') {
13203 $attr['class'] .= ' '.$value;
13204 } elseif ($key == 'classOverride') {
13205 $attr['class'] = $value;
13207 $attr[$key] = $value;
13214 // escape all attribute
13215 $attr = array_map('dolPrintHTMLForAttribute', $attr);
13217 $TCompiledAttr = array();
13218 foreach ($attr as $key => $value) {
13219 $TCompiledAttr[] = $key.'="
'.$value.'"';
13222 $compiledAttributes = !empty($TCompiledAttr) ? implode(' ', $TCompiledAttr) : '';
13224 $tag = !empty($url) ? 'a' : 'span';
13226 return '<'.$tag.' '.$compiledAttributes.'>'.$html.'</'.$tag.'>';
13242function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $statusType = 'status0', $displayMode = 0, $url = '', $params = array())
13247 $dolGetBadgeParams = array();
13249 if (!empty($params['badgeParams'])) {
13250 $dolGetBadgeParams = $params['badgeParams'];
13253 // TODO : add a hook
13254 if ($displayMode == 0) {
13255 $return = !empty($html) ? $html : (empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort));
13256 } elseif ($displayMode == 1) {
13257 $return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
13258 } elseif (getDolGlobalString('MAIN_STATUS_USES_IMAGES')) {
13259 // Use status with images (for backward compatibility)
13261 $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ? '<span class="hideonsmartphone
">' : '').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ? '</span>' : '');
13262 $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>' : '');
13264 // For small screen, we always use the short label instead of long label.
13265 if (!empty($conf->dol_optimize_smallscreen)) {
13266 if ($displayMode == 0) {
13268 } elseif ($displayMode == 4) {
13270 } elseif ($displayMode == 6) {
13275 // For backward compatibility. Image's filename are still in French, so we use this array to convert
13276 $statusImg = array(
13277 'status0' => 'statut0',
13278 'status1' => 'statut1',
13279 'status2' => 'statut2',
13280 'status3' => 'statut3',
13281 'status4' => 'statut4',
13282 'status5' => 'statut5',
13283 'status6' => 'statut6',
13284 'status7' => 'statut7',
13285 'status8' => 'statut8',
13286 'status9' => 'statut9'
13289 if (!empty($statusImg[$statusType])) {
13290 $htmlImg = img_picto($statusLabel, $statusImg[$statusType]);
13292 $htmlImg = img_picto($statusLabel, $statusType);
13295 if ($displayMode === 2) {
13296 $return = $htmlImg.' '.$htmlLabelShort;
13297 } elseif ($displayMode === 3) {
13298 $return = $htmlImg;
13299 } elseif ($displayMode === 4) {
13300 $return = $htmlImg.' '.$htmlLabel;
13301 } elseif ($displayMode === 5) {
13302 $return = $htmlLabelShort.' '.$htmlImg;
13303 } else { // $displayMode >= 6
13304 $return = $htmlLabel.' '.$htmlImg;
13306 } elseif (!getDolGlobalString('MAIN_STATUS_USES_IMAGES') && !empty($displayMode)) {
13308 $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
13310 $dolGetBadgeParams['attr']['class'] = 'badge-status';
13311 if (empty($dolGetBadgeParams['attr']['title'])) {
13312 $dolGetBadgeParams['attr']['title'] = empty($params['tooltip']) ? $statusLabel : ($params['tooltip'] != 'no' ? $params['tooltip'] : '');
13313 } else { // If a title was forced from $params['badgeParams']['attr']['title'], we set the class to get it as a tooltip.
13314 $dolGetBadgeParams['attr']['class'] .= ' classfortooltip';
13315 // And if we use tooltip, we can output title in HTML @phan-suppress-next-line PhanTypeInvalidDimOffset
13316 $dolGetBadgeParams['attr']['title'] = dol_htmlentitiesbr((string) $dolGetBadgeParams['attr']['title'], 1);
13319 if ($displayMode == 3) {
13320 $return = dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), '', $statusType, 'dot', $url, $dolGetBadgeParams);
13321 } elseif ($displayMode === 5) {
13322 $return = dolGetBadge($statusLabelShort, $html, $statusType, '', $url, $dolGetBadgeParams);
13324 $return = dolGetBadge(((empty($conf->dol_optimize_smallscreen) && $displayMode != 2) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), $html, $statusType, '', $url, $dolGetBadgeParams);
13367function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = '', $id = '', $userRight = 1, $params = array())
13369 global $hookmanager, $action, $object, $langs;
13371 // If $url is an array, we must build a dropdown button or recursively iterate over each value
13372 if (is_array($url)) {
13373 // Loop on $url array to remove entries of disabled modules
13374 foreach ($url as $key => $subbutton) {
13375 if (isset($subbutton['enabled']) && empty($subbutton['enabled'])) {
13382 if (array_key_exists('areDropdownButtons', $params) && $params["areDropdownButtons
"] === false) { // @phan-suppress-current-line PhanTypeInvalidDimOffset
13383 foreach ($url as $button) {
13384 if (!empty($button['lang'])) {
13385 $langs->load($button['lang']);
13387 $label = $langs->trans($button['label']);
13388 $text = $button['text'] ?? '';
13389 $actionType = $button['actionType'] ?? '';
13390 $tmpUrl = DOL_URL_ROOT.$button['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage']));
13391 $id = $button['id'] ?? '';
13392 $userRight = $button['perm'] ?? 1;
13393 $button['params'] = $button['params'] ?? []; // @phan-suppress-current-line PhanPluginDuplicateExpressionAssignmentOperation
13395 $out .= dolGetButtonAction($label, $text, $actionType, $tmpUrl, $id, $userRight, $button['params']);
13400 if (count($url) > 1) {
13401 $out .= '<div class="dropdown
inline-block dropdown-holder
">';
13402 $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>';
13403 $out .= '<div class="dropdown-content
">';
13404 foreach ($url as $subbutton) {
13405 if (!empty($subbutton['lang'])) {
13406 $langs->load($subbutton['lang']);
13409 if (!empty($subbutton['urlraw'])) {
13410 $tmpurl = $subbutton['urlraw']; // Use raw url, no url completion, use only what developer send
13412 $tmpurl = !empty($subbutton['urlroot']) ? $subbutton['urlroot'] : $subbutton['url'];
13413 $tmpurl = dolCompletUrlForDropdownButton($tmpurl, $params, empty($subbutton['urlroot']));
13416 $subbuttonparam = array();
13417 if (!empty($subbutton['attr'])) {
13418 $subbuttonparam['attr'] = $subbutton['attr'];
13420 $subbuttonparam['isDropDown'] = (empty($params['isDropDown']) ? ($subbutton['isDropDown'] ?? false) : $params['isDropDown']);
13422 $out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, $subbutton['id'] ?? '', $subbutton['perm'], $subbuttonparam);
13427 foreach ($url as $subbutton) { // Should loop on 1 record only
13428 if (!empty($subbutton['lang'])) {
13429 $langs->load($subbutton['lang']);
13432 if (!empty($subbutton['urlraw'])) {
13433 $tmpurl = $subbutton['urlraw']; // Use raw url, no url completion, use only what developer send
13435 $tmpurl = !empty($subbutton['urlroot']) ? $subbutton['urlroot'] : $subbutton['url'];
13436 $tmpurl = dolCompletUrlForDropdownButton($tmpurl, $params, empty($subbutton['urlroot']));
13439 $out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm'], $params);
13446 // Here, $url is a simple link
13448 if (!empty($params['isDropdown']) || !empty($params['isDropDown'])) { // Use the dropdown-item style (not for action button)
13449 $class = "dropdown-item
";
13451 $class = 'butAction';
13452 if ($actionType == 'danger' || $actionType == 'delete') {
13453 $class = 'butActionDelete';
13454 if (!empty($url) && strpos($url, 'token=') === false) {
13455 $url .= '&token='.newToken();
13461 'href' => empty($url) ? '' : $url,
13465 if (empty($text)) {
13467 $attr['title'] = ''; // if html not set, leave label on title is redundant
13469 $attr['title'] = $label;
13470 $attr['aria-label'] = $label;
13473 if (empty($userRight) || $userRight < 0) {
13474 $attr['class'] = 'butActionRefused';
13475 $attr['href'] = '';
13476 $attr['title'] = (($label && $text && $label != $text) ? $label : '');
13477 $attr['title'] = ($attr['title'] ? $attr['title'] . (empty($userRight) ? '<br>' : '') : '').(empty($userRight) ? $langs->trans('NotEnoughPermissions') : '');
13485 if (!empty($params['attr']) && is_array($params['attr'])) {
13486 foreach ($params['attr'] as $key => $value) {
13487 if ($key == 'class') {
13488 $attr['class'] .= ' '.$value;
13489 } elseif ($key == 'classOverride') {
13490 $attr['class'] = $value;
13492 $attr[$key] = $value;
13497 // automatic add tooltip when title is detected
13498 if (!empty($attr['title']) && !empty($attr['class']) && strpos($attr['class'], 'classfortooltip') === false) {
13499 $attr['class'] .= ' classfortooltip';
13502 // Js Confirm button
13503 if ($userRight && !empty($params['confirm'])) {
13504 if (!is_array($params['confirm'])) {
13505 $params['confirm'] = array();
13508 if (empty($params['confirm']['url'])) {
13509 $params['confirm']['url'] = $url . (strpos($url, '?') > 0 ? '&' : '?') . 'confirm=yes';
13512 // for js disabled compatibility set $url as call to confirm action and $params['confirm']['url'] to confirmed action
13513 $attr['data-confirm-url'] = $params['confirm']['url'];
13514 $attr['data-confirm-title'] = !empty($params['confirm']['title']) ? $params['confirm']['title'] : $langs->trans('ConfirmBtnCommonTitle', $label);
13515 $attr['data-confirm-content'] = !empty($params['confirm']['content']) ? $params['confirm']['content'] : $langs->trans('ConfirmBtnCommonContent', $label);
13516 $attr['data-confirm-content'] = preg_replace("/\r|\n/
", "", $attr['data-confirm-content']);
13517 $attr['data-confirm-action-btn-label'] = !empty($params['confirm']['action-btn-label']) ? $params['confirm']['action-btn-label'] : $langs->trans('Confirm');
13518 $attr['data-confirm-cancel-btn-label'] = !empty($params['confirm']['cancel-btn-label']) ? $params['confirm']['cancel-btn-label'] : $langs->trans('CloseDialog');
13519 $attr['data-confirm-modal'] = !empty($params['confirm']['modal']) ? $params['confirm']['modal'] : true;
13521 $attr['class'] .= ' butActionConfirm';
13524 if (isset($attr['href']) && empty($attr['href'])) {
13525 unset($attr['href']);
13528 $TCompiledAttr = array();
13529 foreach ($attr as $key => $value) {
13530 if (!empty($params['use_unsecured_unescapedattr']) && is_array($params['use_unsecured_unescapedattr']) && in_array($key, $params['use_unsecured_unescapedattr'])) {
13532 $value = dol_htmlentities($value, ENT_QUOTES | ENT_SUBSTITUTE);
13533 } elseif ($key == 'href') {
13534 $value = dolPrintHTMLForAttributeUrl($value);
13536 $value = dolPrintHTMLForAttribute($value);
13539 $TCompiledAttr[] = $key.'="'.$value.'"'; // $value has been escaped by the dolPrintHTMLForAttribute... just before
13542 $compiledAttributes = empty($TCompiledAttr) ? '' : implode(' ', $TCompiledAttr);
13544 $tag = !empty($attr['href']) ? 'a' : 'span';
13547 $parameters = array(
13548 'TCompiledAttr' => $TCompiledAttr, // array
13549 'compiledAttributes' => $compiledAttributes, // string
13554 'actionType' => $actionType,
13557 'userRight' => $userRight,
13558 'params' => $params
13561 $reshook = $hookmanager->executeHooks('dolGetButtonAction', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
13562 if ($reshook < 0) {
13563 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
13566 if (empty($reshook)) {
13567 if (dol_textishtml($text)) { // If content already HTML encoded
13568 return '<' . $tag . ' ' . $compiledAttributes . '><span class="textbutton
">' . $text . '</span></' . $tag . '>';
13570 return '<' . $tag . ' ' . $compiledAttributes . '><span class="textbutton
">' . dol_escape_htmltag($text) . '</span></' . $tag . '>';
13573 return $hookmanager->resPrint;
13586function dolCompletUrlForDropdownButton(string $url, array $params, bool $addDolUrlRoot = true)
13592 $parsedUrl = parse_url($url);
13593 if ((isset($parsedUrl['scheme']) && in_array($parsedUrl['scheme'], ['javascript', 'mailto', 'tel'])) || strpos($url, '#') === 0) {
13597 if (!empty($parsedUrl['query'])) {
13598 // Use parse_str() function to parse the string passed via URL
13599 parse_str($parsedUrl['query'], $urlQuery);
13600 if (!isset($urlQuery['backtopage']) && isset($params['backtopage'])) {
13601 $url .= '&backtopage='.urlencode($params['backtopage']);
13605 if (!isset($parsedUrl['scheme']) && $addDolUrlRoot) {
13606 $url = DOL_URL_ROOT.$url;
13619function dolGetButtonTitleSeparator($moreClass = "
")
13621 return '<span class="button-title-separator
'.$moreClass.'" ></span>';
13630function getFieldErrorIcon($fieldValidationErrorMsg)
13633 if (!empty($fieldValidationErrorMsg)) {
13634 $out .= '<span class="field-error-icon classfortooltip
" title="'.dol_escape_htmltag($fieldValidationErrorMsg, 1).'" role="alert
" >'; // role alert is used for accessibility
13635 $out .= '<span class="fa fa-exclamation-circle
" aria-hidden="true" ></span>'; // For accessibility icon is separated and aria-hidden
13654function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $url = '', $id = '', $status = 1, $params = array())
13656 global $langs, $user;
13658 // Actually this conf is used in css too for external module compatibility and smooth transition to this function
13659 if (getDolGlobalString('MAIN_BUTTON_HIDE_UNAUTHORIZED') && (!$user->admin) && $status <= 0) {
13662 // Fix old picto fa-th-list to use fa-grid-vertical instead
13663 if ($iconClass == 'fa fa-th-list imgforviewmode') {
13664 $iconClass = ' fa fa-grip-horizontal imgforviewmode';
13667 $class = 'btnTitle';
13668 if (in_array($iconClass, array('fa fa-plus-circle', 'fa fa-plus-circle size15x', 'fa fa-comment-dots', 'fa fa-paper-plane'))) {
13669 $class .= ' btnTitlePlus';
13671 $useclassfortooltip = 1;
13673 if (!empty($params['morecss'])) {
13674 $class .= ' '.$params['morecss'];
13679 'href' => empty($url) ? '' : $url
13682 if (!empty($helpText)) {
13683 $attr['title'] = $helpText;
13684 } elseif ($label) { // empty($attr['title']) &&
13685 $attr['title'] = $label;
13686 $useclassfortooltip = 0;
13689 if ($status == 2) {
13690 $attr['class'] .= ' btnTitleSelected';
13691 } elseif ($status <= 0) {
13692 $attr['class'] .= ' refused';
13694 $attr['href'] = '';
13696 if ($status == -1) { // disable
13697 $attr['title'] = $langs->transnoentitiesnoconv("FeatureDisabled
");
13698 } elseif ($status == 0) { // Not enough permissions
13699 $attr['title'] = $langs->transnoentitiesnoconv("NotEnoughPermissions
");
13703 if (!empty($attr['title']) && $useclassfortooltip) {
13704 $attr['class'] .= ' classfortooltip';
13712 if (!empty($params['attr']) && is_array($params['attr'])) {
13713 foreach ($params['attr'] as $key => $value) {
13714 if ($key == 'class') {
13715 $attr['class'] .= ' '.$value;
13716 } elseif ($key == 'classOverride') {
13717 $attr['class'] = $value;
13719 $attr[$key] = $value;
13724 if (isset($attr['href']) && empty($attr['href'])) {
13725 unset($attr['href']);
13728 // TODO : add a hook
13730 // Generate attributes with escapement
13731 $TCompiledAttr = array();
13732 foreach ($attr as $key => $value) {
13733 $TCompiledAttr[] = $key.'="'.dol_escape_htmltag($value).'"'; // Do not use dolPrintHTMLForAttribute() here, we must accept "javascript:
string"
13736 $compiledAttributes = (empty($TCompiledAttr) ? '' : implode(' ', $TCompiledAttr));
13738 $tag = (empty($attr['href']) ? 'span' : 'a');
13740 $button = '<'.$tag.' '.$compiledAttributes.'>';
13741 $button .= '<span class="'.$iconClass.' valignmiddle btnTitle-icon
"></span>';
13742 if (!empty($params['forcenohideoftext'])) {
13743 $button .= '<span class="valignmiddle text-plus-circle btnTitle-label
'.(empty($params['forcenohideoftext
']) ? ' hideonsmartphone
' : '').'">'.$label.'</span>';
13745 $button .= '</'.$tag.'>';
13759function getElementProperties($elementType)
13761 global $conf, $db, $hookmanager;
13765 //$element_type='facture';
13767 $classfile = $classname = $classpath = $subdir = $dir_output = $dir_temp = $parent_element = '';
13769 // Parse element/subelement
13770 $module = $elementType;
13771 $element = $elementType;
13772 $subelement = $elementType;
13773 $table_element = $elementType;
13775 // If we ask a resource form external module (instead of default path)
13776 if (preg_match('/^([^@]+)@([^@]+)$/i', $elementType, $regs)) { // 'myobject@mymodule'
13777 $element = $subelement = $regs[1];
13778 $module = $regs[2];
13781 // If we ask a resource for a string with an element and a subelement
13782 // Example 'project_task'
13783 if (preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) { // 'myobject_mysubobject' with myobject=mymodule
13784 $module = $element = $regs[1];
13785 $subelement = $regs[2];
13788 // Object lines will use parent classpath and module ref
13789 if (substr($elementType, -3) == 'det') {
13790 $module = preg_replace('/det$/', '', $element);
13791 $subelement = preg_replace('/det$/', '', $subelement);
13792 $classpath = $module.'/class';
13793 $classfile = $module;
13794 $classname = preg_replace('/det$/', 'Line', $element);
13795 if (in_array($module, array('expedition', 'propale', 'facture', 'contrat', 'fichinter', 'commandefournisseur'))) {
13796 $classname = preg_replace('/det$/', 'Ligne', $element);
13799 // For compatibility and to work with non standard path
13800 if ($elementType == "action
" || $elementType == "actioncomm
") {
13801 $classpath = 'comm/action/class';
13802 $subelement = 'Actioncomm';
13803 $module = 'agenda';
13804 $table_element = 'actioncomm';
13805 } elseif ($elementType == 'cronjob') {
13806 $classpath = 'cron/class';
13808 $table_element = 'cron';
13809 } elseif ($elementType == 'adherent_type') {
13810 $classpath = 'adherents/class';
13811 $classfile = 'adherent_type';
13812 $module = 'adherent';
13813 $subelement = 'adherent_type';
13814 $classname = 'AdherentType';
13815 $table_element = 'adherent_type';
13816 } elseif ($elementType == 'bank_account') {
13817 $classpath = 'compta/bank/class';
13818 $module = 'bank'; // We need $conf->bank->dir_output and not $conf->banque->dir_output
13819 $classfile = 'account';
13820 $classname = 'Account';
13821 } elseif ($elementType == 'bank_line') {
13822 $classpath = 'compta/bank/class';
13823 $module = 'bank'; // We need $conf->bank->dir_output and not $conf->banque->dir_output
13824 $classfile = 'account';
13825 $classname = 'AccountLine';
13826 } elseif ($elementType == 'category') {
13827 $classpath = 'categories/class';
13828 $module = 'categorie';
13829 $subelement = 'categorie';
13830 $table_element = 'categorie';
13831 } elseif ($elementType == 'contact') {
13832 $classpath = 'contact/class';
13833 $classfile = 'contact';
13834 $module = 'societe';
13835 $subelement = 'contact';
13836 $table_element = 'socpeople';
13837 } elseif ($elementType == 'inventory') {
13838 $module = 'product';
13839 $classpath = 'product/inventory/class';
13840 } elseif ($elementType == 'inventoryline') {
13841 $module = 'product';
13842 $classpath = 'product/inventory/class';
13843 $table_element = 'inventorydet';
13844 $parent_element = 'inventory';
13845 } elseif ($elementType == 'stock' || $elementType == 'entrepot' || $elementType == 'warehouse') {
13847 $classpath = 'product/stock/class';
13848 $classfile = 'entrepot';
13849 $classname = 'Entrepot';
13850 $table_element = 'entrepot';
13851 } elseif ($elementType == 'project') {
13852 $classpath = 'projet/class';
13853 $module = 'projet';
13854 $table_element = 'projet';
13855 } elseif ($elementType == 'project_task') {
13856 $classpath = 'projet/class';
13857 $module = 'projet';
13858 $subelement = 'task';
13859 $table_element = 'projet_task';
13860 } elseif ($elementType == 'facture' || $elementType == 'invoice') {
13861 $classpath = 'compta/facture/class';
13862 $module = 'facture';
13863 $subelement = 'facture';
13864 $table_element = 'facture';
13865 } elseif ($elementType == 'facturedet') {
13866 $classpath = 'compta/facture/class';
13867 $classfile = 'facture';
13868 $classname = 'FactureLigne';
13869 $module = 'facture';
13870 $table_element = 'facturedet';
13871 $parent_element = 'facture';
13872 } elseif ($elementType == 'facturerec') {
13873 $classpath = 'compta/facture/class';
13874 $classfile = 'facture-rec';
13875 $module = 'facture';
13876 $classname = 'FactureRec';
13877 } elseif ($elementType == 'commande' || $elementType == 'order') {
13878 $classpath = 'commande/class';
13879 $module = 'commande';
13880 $subelement = 'commande';
13881 $table_element = 'commande';
13882 } elseif ($elementType == 'commandedet') {
13883 $classpath = 'commande/class';
13884 $classfile = 'commande';
13885 $classname = 'OrderLine';
13886 $module = 'commande';
13887 $table_element = 'commandedet';
13888 $parent_element = 'commande';
13889 } elseif ($elementType == 'propal') {
13890 $classpath = 'comm/propal/class';
13891 $table_element = 'propal';
13892 } elseif ($elementType == 'propaldet') {
13893 $classpath = 'comm/propal/class';
13894 $classfile = 'propal';
13895 $subelement = 'propaleligne';
13896 $module = 'propal';
13897 $table_element = 'propaldet';
13898 $parent_element = 'propal';
13899 } elseif ($elementType == 'shipping') {
13900 $classpath = 'expedition/class';
13901 $classfile = 'expedition';
13902 $classname = 'Expedition';
13903 $module = 'expedition';
13904 $table_element = 'expedition';
13905 } elseif ($elementType == 'expeditiondet' || $elementType == 'shippingdet') {
13906 $classpath = 'expedition/class';
13907 $classfile = 'expedition';
13908 $classname = 'ExpeditionLigne';
13909 $module = 'expedition';
13910 $table_element = 'expeditiondet';
13911 $parent_element = 'expedition';
13912 } elseif ($elementType == 'delivery_note') {
13913 $classpath = 'delivery/class';
13914 $subelement = 'delivery';
13915 $module = 'expedition';
13916 } elseif ($elementType == 'delivery') {
13917 $classpath = 'delivery/class';
13918 $subelement = 'delivery';
13919 $module = 'expedition';
13920 } elseif ($elementType == 'deliverydet') {
13922 } elseif ($elementType == 'supplier_proposal') {
13923 $classpath = 'supplier_proposal/class';
13924 $module = 'supplier_proposal';
13925 $element = 'supplierproposal';
13926 $classfile = 'supplier_proposal';
13927 $subelement = 'supplierproposal';
13928 } elseif ($elementType == 'supplier_proposaldet') {
13929 $classpath = 'supplier_proposal/class';
13930 $module = 'supplier_proposal';
13931 $classfile = 'supplier_proposal';
13932 $classname = 'SupplierProposalLine';
13933 $table_element = 'supplier_proposaldet';
13934 $parent_element = 'supplier_proposal';
13935 } elseif ($elementType == 'contract') {
13936 $classpath = 'contrat/class';
13937 $module = 'contrat';
13938 $subelement = 'contrat';
13939 $table_element = 'contract';
13940 } elseif ($elementType == 'contratdet') {
13941 $classpath = 'contrat/class';
13942 $module = 'contrat';
13943 $table_element = 'contratdet';
13944 $parent_element = 'contrat';
13945 } elseif ($elementType == 'mailing') {
13946 $classpath = 'comm/mailing/class';
13947 $module = 'mailing';
13948 $classfile = 'mailing';
13949 $classname = 'Mailing';
13951 } elseif ($elementType == 'member' || $elementType == 'adherent') {
13952 $classpath = 'adherents/class';
13953 $module = 'adherent';
13954 $subelement = 'adherent';
13955 $table_element = 'adherent';
13956 } elseif ($elementType == 'subscription') {
13957 $classpath = 'adherents/class';
13958 $classfile = 'subscription';
13959 $module = 'adherent';
13960 $subelement = 'subscription';
13961 $classname = 'Subscription';
13962 $table_element = 'subscription';
13963 } elseif ($elementType == 'usergroup') {
13964 $classpath = 'user/class';
13966 } elseif ($elementType == 'mo') {
13967 $classpath = 'mrp/class';
13972 $table_element = 'mrp_mo';
13973 } elseif ($elementType == 'mrp_production') {
13974 $classpath = 'mrp/class';
13976 $classname = 'MoLine';
13979 $table_element = 'mrp_production';
13980 $parent_element = 'mo';
13981 } elseif ($elementType == 'cabinetmed_cons') {
13982 $classpath = 'cabinetmed/class';
13983 $module = 'cabinetmed';
13984 $subelement = 'cabinetmedcons';
13985 $table_element = 'cabinetmedcons';
13986 } elseif ($elementType == 'fichinter') {
13987 $classpath = 'fichinter/class';
13988 $module = 'ficheinter';
13989 $subelement = 'fichinter';
13990 $table_element = 'fichinter';
13991 } elseif ($elementType == 'dolresource' || $elementType == 'resource') {
13992 $classpath = 'resource/class';
13993 $module = 'resource';
13994 $subelement = 'dolresource';
13995 $table_element = 'resource';
13996 } elseif ($elementType == 'opensurvey_sondage') {
13997 $classpath = 'opensurvey/class';
13998 $module = 'opensurvey';
13999 $subelement = 'opensurveysondage';
14000 } elseif ($elementType == 'order_supplier' || $elementType == 'supplier_order' ||$elementType == 'commande_fournisseur' || $elementType == 'commandefournisseur') {
14001 $classpath = 'fourn/class';
14002 $module = 'fournisseur';
14003 $classfile = 'fournisseur.commande';
14004 $element = 'order_supplier';
14006 $classname = 'CommandeFournisseur';
14007 $table_element = 'commande_fournisseur';
14008 } elseif ($elementType == 'commande_fournisseurdet') {
14009 $classpath = 'fourn/class';
14010 $module = 'fournisseur';
14011 $classfile = 'fournisseur.commande';
14012 $element = 'commande_fournisseurdet';
14014 $classname = 'CommandeFournisseurLigne';
14015 $table_element = 'commande_fournisseurdet';
14016 $parent_element = 'commande_fournisseur';
14017 } elseif ($elementType == 'invoice_supplier' || $elementType == 'supplier_invoice' || $elementType == 'facture_fourn') {
14018 $classpath = 'fourn/class';
14019 $module = 'fournisseur';
14020 $classfile = 'fournisseur.facture';
14021 $element = 'invoice_supplier';
14023 $classname = 'FactureFournisseur';
14024 $table_element = 'facture_fourn';
14025 } elseif ($elementType == 'facture_fourn_det') {
14026 $classpath = 'fourn/class';
14027 $module = 'fournisseur';
14028 $classfile = 'fournisseur.facture';
14029 $element = 'facture_fourn_det';
14031 $classname = 'SupplierInvoiceLine';
14032 $table_element = 'facture_fourn_det';
14033 $parent_element = 'invoice_supplier';
14034 } elseif ($elementType == "service
") {
14035 $classpath = 'product/class';
14036 $subelement = 'product';
14037 $table_element = 'product';
14038 } elseif ($elementType == 'salary') {
14039 $classpath = 'salaries/class';
14040 $module = 'salaries';
14041 } elseif ($elementType == 'payment_salary') {
14042 $classpath = 'salaries/class';
14043 $classfile = 'paymentsalary';
14044 $classname = 'PaymentSalary';
14045 $module = 'salaries';
14046 } elseif ($elementType == 'productlot') {
14047 $module = 'productbatch';
14048 $classpath = 'product/stock/class';
14049 $classfile = 'productlot';
14050 $classname = 'Productlot';
14051 $element = 'productlot';
14053 $table_element = 'product_lot';
14054 } elseif ($elementType == 'societeaccount') {
14055 $classpath = 'societe/class';
14056 $classfile = 'societeaccount';
14057 $classname = 'SocieteAccount';
14058 $module = 'societe';
14059 } elseif ($elementType == 'websitepage' || $elementType == 'website_page') {
14060 $classpath = 'website/class';
14061 $classfile = 'websitepage';
14062 $classname = 'Websitepage';
14063 $module = 'website';
14064 $subelement = 'websitepage';
14065 $table_element = 'website_page';
14066 } elseif ($elementType == 'fiscalyear') {
14067 $classpath = 'core/class';
14068 $module = 'accounting';
14069 $subelement = 'fiscalyear';
14070 } elseif ($elementType == 'chargesociales') {
14071 $classpath = 'compta/sociales/class';
14073 $table_element = 'chargesociales';
14074 } elseif ($elementType == 'tva') {
14075 $classpath = 'compta/tva/class';
14078 $table_element = 'tva';
14079 } elseif ($elementType == 'emailsenderprofile') {
14081 $classpath = 'core/class';
14082 $classfile = 'emailsenderprofile';
14083 $classname = 'EmailSenderProfile';
14084 $table_element = 'c_email_senderprofile';
14086 } elseif ($elementType == 'conferenceorboothattendee') {
14087 $classpath = 'eventorganization/class';
14088 $classfile = 'conferenceorboothattendee';
14089 $classname = 'ConferenceOrBoothAttendee';
14090 $module = 'eventorganization';
14091 } elseif ($elementType == 'conferenceorbooth') {
14092 $classpath = 'eventorganization/class';
14093 $classfile = 'conferenceorbooth';
14094 $classname = 'ConferenceOrBooth';
14095 $module = 'eventorganization';
14096 } elseif ($elementType == 'ccountry') {
14098 $classpath = 'core/class';
14099 $classfile = 'ccountry';
14100 $classname = 'Ccountry';
14101 $table_element = 'c_country';
14103 } elseif ($elementType == 'ecmfiles') {
14105 $classpath = 'ecm/class';
14106 $classfile = 'ecmfiles';
14107 $classname = 'Ecmfiles';
14108 $table_element = 'ecmfiles';
14110 } elseif ($elementType == 'knowledgerecord' || $elementType == 'knowledgemanagement') {
14111 $module = 'knowledgemanagement';
14112 $classpath = 'knowledgemanagement/class';
14113 $classfile = 'knowledgerecord';
14114 $classname = 'KnowledgeRecord';
14115 $table_element = 'knowledgemanagement_knowledgerecord';
14117 } elseif ($elementType == 'customer') {
14118 $module = 'societe';
14119 $classpath = 'societe/class';
14120 $classfile = 'client';
14121 $classname = 'Client';
14122 $table_element = 'societe';
14124 } elseif ($elementType == 'fournisseur' || $elementType == 'supplier') {
14125 $module = 'societe';
14126 $classpath = 'fourn/class';
14127 $classfile = 'fournisseur';
14128 $classname = 'Fournisseur';
14129 $table_element = 'societe';
14134 if (empty($classfile)) {
14135 $classfile = strtolower($subelement);
14137 if (empty($classname)) {
14138 $classname = ucfirst($subelement);
14140 if (empty($classpath)) {
14141 $classpath = $module.'/class';
14144 //print 'getElementProperties subdir='.$subdir;
14147 if ($module && isset($conf->$module)) { // The generic case
14148 if (!empty($conf->$module->multidir_output[$conf->entity])) {
14149 $dir_output = $conf->$module->multidir_output[$conf->entity];
14150 } elseif (!empty($conf->$module->output[$conf->entity])) {
14151 $dir_output = $conf->$module->output[$conf->entity];
14152 } elseif (!empty($conf->$module->dir_output)) {
14153 $dir_output = $conf->$module->dir_output;
14155 if (!empty($conf->$module->multidir_temp[$conf->entity])) {
14156 $dir_temp = $conf->$module->multidir_temp[$conf->entity];
14157 } elseif (!empty($conf->$module->temp[$conf->entity])) {
14158 $dir_temp = $conf->$module->temp[$conf->entity];
14159 } elseif (!empty($conf->$module->dir_temp)) {
14160 $dir_temp = $conf->$module->dir_temp;
14164 // Overwrite value for special cases
14165 if ($element == 'order_supplier' && isModEnabled('fournisseur')) {
14166 $dir_output = $conf->fournisseur->commande->dir_output;
14167 $dir_temp = $conf->fournisseur->commande->dir_temp;
14168 } elseif ($element == 'invoice_supplier' && isModEnabled('fournisseur')) {
14169 $dir_output = $conf->fournisseur->facture->dir_output;
14170 $dir_temp = $conf->fournisseur->facture->dir_temp;
14172 $dir_output .= $subdir;
14173 $dir_temp .= $subdir;
14175 $elementProperties = array(
14176 'module' => $module,
14177 'element' => $element,
14178 'table_element' => $table_element,
14179 'subelement' => $subelement,
14180 'classpath' => $classpath,
14181 'classfile' => $classfile,
14182 'classname' => $classname,
14183 'dir_output' => $dir_output,
14184 'dir_temp' => $dir_temp,
14185 'parent_element' => $parent_element,
14190 if (!is_object($hookmanager)) {
14191 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
14192 $hookmanager = new HookManager($db);
14194 $hookmanager->initHooks(array('elementproperties'));
14198 $parameters = array(
14199 'elementType' => $elementType,
14200 'elementProperties' => $elementProperties
14203 $reshook = $hookmanager->executeHooks('getElementProperties', $parameters);
14206 $elementProperties = $hookmanager->resArray;
14207 } elseif (!empty($hookmanager->resArray) && is_array($hookmanager->resArray)) { // resArray is always an array but for sécurity against misconfigured external modules
14208 $elementProperties = array_replace($elementProperties, $hookmanager->resArray);
14211 // context of elementproperties doesn't need to exist out of this function so delete it to avoid elementproperties context is equal to all
14212 if (($key = array_search('elementproperties', $hookmanager->contextarray)) !== false) {
14213 unset($hookmanager->contextarray[$key]);
14216 return $elementProperties;
14231function fetchObjectByElement($element_id, $element_type, $element_ref = '', $useCache = 0, $maxCacheByType = 10)
14237 $element_prop = getElementProperties($element_type);
14239 if ($element_prop['module'] == 'product' || $element_prop['module'] == 'service') {
14240 // For example, for an extrafield 'product' (shared for both product and service) that is a link to an object,
14241 // this is called with $element_type = 'product' when we need element properties of a service, we must return a product. If we create the
14242 // extrafield for a service, it is not supported and not found when editing the product/service card. So we must keep 'product' for extrafields
14243 // of service and we will return properties of a product.
14244 $ismodenabled = (isModEnabled('product') || isModEnabled('service'));
14245 } elseif ($element_prop['module'] == 'societeaccount') {
14246 $ismodenabled = isModEnabled('website') || isModEnabled('webportal');
14248 $ismodenabled = isModEnabled($element_prop['module']);
14250 //var_dump('element_type='.$element_type);
14251 //var_dump($element_prop);
14252 //var_dump($element_prop['module'].' '.$ismodenabled);
14253 if (is_array($element_prop) && (empty($element_prop['module']) || $ismodenabled)) {
14254 if ($useCache === 1 && $element_id > 0
14255 && !empty($conf->cache['fetchObjectByElement'][$element_type])
14256 && !empty($conf->cache['fetchObjectByElement'][$element_type][$element_id])
14257 && is_object($conf->cache['fetchObjectByElement'][$element_type][$element_id])
14259 return $conf->cache['fetchObjectByElement'][$element_type][$element_id];
14262 dol_include_once('/'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php');
14264 if (class_exists($element_prop['classname'])) {
14265 $className = $element_prop['classname'];
14266 $objecttmp = new $className($db);
14267 '@phan-var-force CommonObject $objecttmp';
14269 if ($element_id > 0 || !empty($element_ref)) {
14270 $ret = $objecttmp->fetch($element_id, $element_ref);
14272 if (empty($objecttmp->module)) {
14273 $objecttmp->module = $element_prop['module'];
14276 if ($useCache > 0) {
14277 if (!isset($conf->cache['fetchObjectByElement'][$element_type])) {
14278 $conf->cache['fetchObjectByElement'][$element_type] = [];
14281 // Manage cache limit
14282 if (! empty($conf->cache['fetchObjectByElement'][$element_type]) && is_array($conf->cache['fetchObjectByElement'][$element_type]) && count($conf->cache['fetchObjectByElement'][$element_type]) >= $maxCacheByType) {
14283 array_shift($conf->cache['fetchObjectByElement'][$element_type]);
14286 $conf->cache['fetchObjectByElement'][$element_type][$element_id] = $objecttmp;
14292 return $objecttmp; // returned an object without fetch
14295 dol_syslog($element_prop['classname'].' doesn\'t exists in /'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php');
14308function getExecutableContent()
14310 $arrayofregexextension = array(
14311 'htm', 'html', 'shtml', 'js', 'phar', 'php', 'php3', 'php4', 'php5', 'phtml', 'pht', 'pl', 'py', 'cgi', 'ksh', 'sh', 'shtml',
14312 'bash', 'bat', 'cmd', 'wpk', 'exe', 'dmg', 'appimage'
14315 return $arrayofregexextension;
14324function isAFileWithExecutableContent($filename)
14326 $arrayofregexextension = getExecutableContent();
14328 foreach ($arrayofregexextension as $fileextension) {
14329 if (preg_match('/\.'.preg_quote($fileextension, '/').'$/i', $filename)) {
14346 return empty($_SESSION['newtoken']) ? '' : $_SESSION['newtoken'];
14356function currentToken()
14358 return isset($_SESSION['token']) ? $_SESSION['token'] : '';
14370 if (empty($conf->cache['nonce'])) {
14371 $conf->cache['nonce'] = dolGetRandomBytes(8);
14374 return $conf->cache['nonce'];
14391function startSimpleTable($header, $link = "
", $arguments = "", $emptyColumns = 0, $number = -1, $pictofulllist = '')
14395 print '<div class="div-
table-responsive-no-min
">';
14396 print '<table class="noborder centpercent
">';
14397 print '<tr class="liste_titre
">';
14399 print ($emptyColumns < 1) ? '<th>' : '<th colspan="'.($emptyColumns + 1).'">';
14401 print '<span class="valignmiddle
">'.$langs->trans($header).'</span>';
14403 if (!empty($link)) {
14404 if (!empty($arguments)) {
14405 print '<a href="'.DOL_URL_ROOT.'/
'.$link.'?
'.$arguments.'">';
14407 print '<a href="'.DOL_URL_ROOT.'/
'.$link.'">';
14411 if ($number > -1) {
14412 print '<span class="badge marginleftonlyshort
">'.$number.'</span>';
14413 } elseif (!empty($link)) {
14414 print '<span class="badge marginleftonlyshort
">...</span>';
14417 if (!empty($link)) {
14423 if ($number < 0 && !empty($link)) {
14424 print '<th class="right
">';
14439function finishSimpleTable($addLineBreak = false)
14444 if ($addLineBreak) {
14460function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord = "None
", $extraRightColumn = false)
14465 print '<tr class="oddeven
">';
14466 print '<td colspan="'.$tableColumnCount.'"><span class="opacitymedium
">'.$langs->trans($noneWord).'</span></td>';
14471 if ($nbofloop === 0) {
14472 // don't show a summary line
14476 /* Case already handled above, commented to satisfy phpstan.
14478 $colspan = $tableColumnCount;
14481 if ($num > $nbofloop) {
14482 $colspan = $tableColumnCount;
14484 $colspan = $tableColumnCount - 1;
14487 if ($extraRightColumn) {
14491 print '<tr class="liste_total
">';
14493 if ($nbofloop > 0 && $num > $nbofloop) {
14494 print '<td colspan="'.$colspan.'" class="right
">'.$langs->trans("XMoreLines
", ($num - $nbofloop)).'</td>';
14496 print '<td colspan="'.$colspan.'" class="right
"> '.$langs->trans("Total
").'</td>';
14497 print '<td class="right centpercent
">'.price($total).'</td>';
14500 if ($extraRightColumn) {
14515function readfileLowMemory($fullpath_original_file_osencoded, $method = -1)
14517 if ($method == -1) {
14519 if (getDolGlobalString('MAIN_FORCE_READFILE_WITH_FREAD')) {
14522 if (getDolGlobalString('MAIN_FORCE_READFILE_WITH_STREAM_COPY')) {
14527 // Be sure we don't have output buffering enabled to have readfile working correctly
14528 while (ob_get_level()) {
14533 if ($method == 0) {
14534 readfile($fullpath_original_file_osencoded);
14535 } elseif ($method == 1) {
14537 $handle = fopen($fullpath_original_file_osencoded, "rb
");
14538 while (!feof($handle)) {
14539 print fread($handle, 8192);
14542 } elseif ($method == 2) {
14544 $handle1 = fopen($fullpath_original_file_osencoded, "rb
");
14545 $handle2 = fopen("php:
14546 stream_copy_to_stream($handle1, $handle2);
14567 $result =
'<span class="clipboardCP'.($showonlyonhover ?
' clipboardCPShowOnHover' :
'').
'">';
14568 if ($texttoshow ===
'none') {
14569 $result .=
'<'.$tag.
' class="clipboardCPValue hidewithsize">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'>';
14570 $result .=
'<span class="clipboardCPValueToPrint"></span>';
14571 } elseif ($texttoshow) {
14572 $result .=
'<'.$tag.
' class="clipboardCPValue hidewithsize">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'>';
14573 $result .=
'<span class="clipboardCPValueToPrint">'.dol_escape_htmltag($texttoshow, 1, 1).
'</span>';
14575 $result .=
'<'.$tag.
' class="clipboardCPValue">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'>';
14577 $result .=
'<span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft pictomodule" title="'.dolPrintHTML($langs->trans(
"ClickToCopyToClipboard")).
'"></span>';
14578 $result .=
img_picto(
'',
'tick',
'class="clipboardCPTick hidden paddingleft pictomodule"');
14579 $result .=
'<span class="clipboardCPText"></span>';
14580 $result .=
'</span>';
14594 $result = json_decode($stringtodecode);
14595 if ($result ===
null) {
14596 $result = unserialize($stringtodecode);
14623 if (is_null($filter) || !is_string($filter) || $filter ===
'') {
14626 if (!preg_match(
'/^\(.*\)$/', $filter)) {
14627 $filter =
'(' . $filter .
')';
14630 $regexstring =
'\(([a-zA-Z0-9_\.]+:[<>!=insotlke]+:[^\(\)]+)\)';
14631 $firstandlastparenthesis = 0;
14633 if (!
dolCheckFilters($filter, $errorstr, $firstandlastparenthesis)) {
14637 return 'Filter syntax error - '.$errorstr;
14642 $t = preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeDummyCriteriaCallback', $filter);
14643 $t = str_ireplace(array(
'and',
'or',
' '),
'', $t);
14646 if (preg_match(
'/[^\(\)]/', $t)) {
14647 $tmperrorstr =
'Bad syntax of the search string';
14648 $errorstr =
'Bad syntax of the search string: '.$filter;
14652 dol_syslog(
"forgeSQLFromUniversalSearchCriteria Filter error - ".$errorstr, LOG_WARNING);
14653 return 'Filter error - '.$tmperrorstr;
14657 $ret = ($noand ?
"" :
" AND ").($nopar ?
"" :
'(').preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeSQLCriteriaCallback', $filter).($nopar ?
"" :
')');
14659 if (is_object($db)) {
14660 $ret = str_replace(
'__NOW__',
"'".$db->idate(
dol_now()).
"'", $ret);
14662 if (is_object($user)) {
14663 $ret = str_replace(
'__USER_ID__', (
string) $user->id, $ret);
14678 $arrayofandtags = array();
14682 $parenthesislevel = 0;
14687 if ($parenthesislevel >= 1) {
14688 $sqlfilters = preg_replace(
'/^\(/',
'', preg_replace(
'/\)$/',
'', $sqlfilters));
14693 $countparenthesis = 0;
14694 while ($i < $nbofchars) {
14697 if ($char ==
'(') {
14698 $countparenthesis++;
14699 } elseif ($char ==
')') {
14700 $countparenthesis--;
14703 if ($countparenthesis == 0) {
14704 $char2 =
dol_substr($sqlfilters, $i + 1, 1);
14705 $char3 =
dol_substr($sqlfilters, $i + 2, 1);
14706 if ($char ==
'A' && $char2 ==
'N' && $char3 ==
'D') {
14709 if (!preg_match(
'/^\(.*\)$/', $s)) {
14712 $arrayofandtags[] = $s;
14725 if (!preg_match(
'/^\(.*\)$/', $s)) {
14728 $arrayofandtags[] = $s;
14731 return $arrayofandtags;
14743function dolCheckFilters($sqlfilters, &$error =
'', &$parenthesislevel = 0)
14747 $tmp = $sqlfilters;
14751 $parenthesislevel = 0;
14759 if ($char ==
'(') {
14760 if ($i == $parenthesislevel && $parenthesislevel == $counter) {
14762 $parenthesislevel++;
14765 } elseif ($char ==
')') {
14766 $nbcharremaining = ($nb - $i - 1);
14767 if ($nbcharremaining >= $counter) {
14768 $parenthesislevel = min($parenthesislevel, $counter - 1);
14770 if ($parenthesislevel > $counter && $nbcharremaining >= $counter) {
14771 $parenthesislevel = $counter;
14776 if ($counter < 0) {
14777 $error =
"Wrong balance of parenthesis in sqlfilters=".$sqlfilters;
14778 $parenthesislevel = 0;
14786 if ($counter > 0) {
14787 $error =
"Wrong balance of parenthesis in sqlfilters=".$sqlfilters;
14788 $parenthesislevel = 0;
14806 if (empty($matches[1])) {
14809 $tmp = explode(
':', $matches[1]);
14810 if (count($tmp) < 3) {
14830 if (empty($matches[1])) {
14833 $tmp = explode(
':', $matches[1], 3);
14834 if (count($tmp) < 3) {
14838 $operand = preg_replace(
'/[^a-z0-9\._]/i',
'', trim($tmp[0]));
14840 $operator = strtoupper(preg_replace(
'/[^a-z<>!=]/i',
'', trim($tmp[1])));
14843 'NOTLIKE' =>
'NOT LIKE',
14844 'ISNOT' =>
'IS NOT',
14845 'NOTIN' =>
'NOT IN',
14849 if (array_key_exists($operator, $realOperator)) {
14850 $operator = $realOperator[$operator];
14853 $tmpescaped = $tmp[2];
14859 if ($operator ==
'IN' || $operator ==
'NOT IN') {
14861 $tmpescaped2 =
'(';
14863 $tmpelemarray = explode(
',', $tmpescaped);
14864 foreach ($tmpelemarray as $tmpkey => $tmpelem) {
14866 $tmpelem = trim($tmpelem);
14867 if (preg_match(
'/^\'(.*)\'$/', $tmpelem, $reg)) {
14868 $tmpelemarray[$tmpkey] =
"'".$db->escape($db->sanitize($reg[1], 2, 1, 1, 1)).
"'";
14869 } elseif (ctype_digit((
string) $tmpelem)) {
14870 $tmpelemarray[$tmpkey] = (int) $tmpelem;
14871 } elseif (is_numeric((
string) $tmpelem)) {
14872 $tmpelemarray[$tmpkey] = (float) $tmpelem;
14873 } elseif (!
getDolGlobalString(
"MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER")) {
14874 $tmpelemarray[$tmpkey] = preg_replace(
'/[^a-z0-9_<>=!\s]/i',
'', $tmpelem);
14876 $tmpelemarray[$tmpkey] = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpelem);
14879 $tmpescaped2 .= implode(
',', $tmpelemarray);
14880 $tmpescaped2 .=
')';
14882 $tmpescaped = $tmpescaped2;
14883 } elseif ($operator ==
'LIKE' || $operator ==
'NOT LIKE') {
14884 if (preg_match(
'/^\'([^\']*)\'$/', $tmpescaped, $regbis)) {
14885 $tmpescaped = $regbis[1];
14888 $tmpescaped =
"'".$db->escape($tmpescaped).
"'";
14889 } elseif (preg_match(
'/^\'(.*)\'$/', $tmpescaped, $regbis)) {
14892 $tmpescaped =
"'".$db->escape($regbis[1]).
"'";
14894 if (strtoupper($tmpescaped) ==
'NULL') {
14895 $tmpescaped =
'NULL';
14896 } elseif (ctype_digit((
string) $tmpescaped)) {
14897 $tmpescaped = (int) $tmpescaped;
14898 } elseif (is_numeric((
string) $tmpescaped)) {
14899 $tmpescaped = (float) $tmpescaped;
14901 $tmpescaped = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpescaped);
14905 return '('.$db->escape($operand).
' '.strtoupper($operator).
' '.$tmpescaped.
')';
14922 $out =
'<!-- timeline icon -->'.
"\n";
14923 $iconClass =
'fa fa-comments';
14928 if ($histo[$key][
'percent'] == -1) {
14929 $colorClass =
'timeline-icon-not-applicble';
14930 $pictoTitle = $langs->trans(
'StatusNotApplicable');
14931 } elseif ($histo[$key][
'percent'] == 0) {
14932 $colorClass =
'timeline-icon-todo';
14933 $pictoTitle = $langs->trans(
'StatusActionToDo').
' (0%)';
14934 } elseif ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100) {
14935 $colorClass =
'timeline-icon-in-progress';
14936 $pictoTitle = $langs->trans(
'StatusActionInProcess').
' ('.$histo[$key][
'percent'].
'%)';
14937 } elseif ($histo[$key][
'percent'] >= 100) {
14938 $colorClass =
'timeline-icon-done';
14939 $pictoTitle = $langs->trans(
'StatusActionDone').
' (100%)';
14942 if ($actionstatic->code ==
'AC_TICKET_CREATE') {
14943 $iconClass =
'fa fa-ticket';
14944 } elseif ($actionstatic->code ==
'AC_TICKET_MODIFY') {
14945 $iconClass =
'fa fa-pencilxxx';
14946 } elseif (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
14947 $iconClass =
'fa fa-comments';
14948 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
14949 $iconClass =
'fa fa-mask';
14951 if ($actionstatic->type_picto) {
14952 $img_picto =
img_picto(
'', $actionstatic->type_picto);
14954 if ($actionstatic->type_code ==
'AC_RDV') {
14955 $iconClass =
'fa fa-handshake';
14956 } elseif ($actionstatic->type_code ==
'AC_TEL') {
14957 $iconClass =
'fa fa-phone';
14958 } elseif ($actionstatic->type_code ==
'AC_FAX') {
14959 $iconClass =
'fa fa-fax';
14960 } elseif ($actionstatic->type_code ==
'AC_EMAIL') {
14961 $iconClass =
'fa fa-envelope';
14962 } elseif ($actionstatic->type_code ==
'AC_INT') {
14963 $iconClass =
'fa fa-shipping-fast';
14964 } elseif ($actionstatic->type_code ==
'AC_OTH_AUTO') {
14965 $iconClass =
'fa fa-robot';
14966 } elseif (!preg_match(
'/_AUTO/', $actionstatic->type_code)) {
14967 $iconClass =
'fa fa-robot';
14972 $out .=
'<i class="'.$iconClass.
' '.$colorClass.
'" title="'.$pictoTitle.
'">'.$img_picto.
'</i>'.
"\n";
14986 $documents = array();
14988 $sql =
'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.filepath, ecm.filename, ecm.agenda_id';
14989 $sql .=
' FROM '.MAIN_DB_PREFIX.
'ecm_files ecm';
14990 $sql .=
" WHERE ecm.filepath = 'agenda/".((int)
$object->id).
"'";
14992 $sql.=
' OR ecm.agenda_id = '.(int)
$object->id;
14993 $sql .=
' ORDER BY ecm.position ASC';
14995 $resql = $db->query($sql);
14997 if ($db->num_rows($resql)) {
14998 while ($obj = $db->fetch_object($resql)) {
14999 $documents[$obj->id] = $obj;
15025function show_actions_messaging(
$conf, $langs, $db, $filterobj, $objcon =
null, $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC')
15027 global $user,
$conf;
15030 global $param, $massactionbutton;
15032 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
15035 if (!is_object($filterobj) && !is_object($objcon)) {
15040 '@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';
15045 $sortfield_list = explode(
',', $sortfield);
15046 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
15047 $sortfield_new_list = array();
15048 foreach ($sortfield_list as $sortfield_value) {
15049 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
15051 $sortfield_new = implode(
',', $sortfield_new_list);
15056 if (isModEnabled(
'agenda')) {
15058 if (is_object($objcon) && $objcon->id > 0) {
15059 $sql =
"SELECT DISTINCT a.id, a.label as label,";
15061 $sql =
"SELECT a.id, a.label as label,";
15063 $sql .=
" a.datep as dp,";
15064 $sql .=
" a.note as message,";
15065 $sql .=
" a.datep2 as dp2,";
15066 $sql .=
" a.percent as percent, 'action' as type,";
15067 $sql .=
" a.fk_element, a.elementtype,";
15068 $sql .=
" a.fk_contact,";
15069 $sql .=
" a.email_from as msg_from,";
15070 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
15071 $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";
15072 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
15073 $sql .=
", sp.lastname, sp.firstname";
15074 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
15075 $sql .=
", m.lastname, m.firstname";
15076 } elseif (is_object($filterobj) && in_array(get_class($filterobj), array(
'Commande',
'CommandeFournisseur',
'Product',
'Ticket',
'BOM',
'Contrat',
'Facture',
'FactureFournisseur'))) {
15079 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
15080 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
15081 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
15083 $force_filter_contact = $filterobj instanceof
User;
15085 if (is_object($objcon) && $objcon->id > 0) {
15086 $force_filter_contact =
true;
15087 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as r ON a.id = r.fk_actioncomm";
15088 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id);
15091 if ((is_object($filterobj) && get_class($filterobj) ==
'Societe') || (is_object($filterobj) && get_class($filterobj) ==
'Contact')) {
15092 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
15093 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
15094 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
15095 $sql .=
" ON er.resource_type = 'dolresource'";
15096 $sql .=
" AND er.element_id = a.id";
15097 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
15098 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
15099 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
15100 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
15101 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
15102 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
15103 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
15104 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
15105 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
15106 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
15107 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
15108 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
15109 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
15110 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Facture') {
15111 $sql .=
", ".MAIN_DB_PREFIX.
"facture as o";
15112 } elseif (is_object($filterobj) && get_class($filterobj) ==
'FactureFournisseur') {
15113 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as o";
15116 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
15117 if (!$force_filter_contact) {
15118 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
15119 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
15120 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
15121 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
15122 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
15123 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
15124 if ($filterobj->id) {
15125 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
15127 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Commande') {
15128 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order'";
15129 if ($filterobj->id) {
15130 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
15132 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
15133 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
15134 if ($filterobj->id) {
15135 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
15137 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
15138 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
15139 if ($filterobj->id) {
15140 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
15142 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
15143 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
15144 if ($filterobj->id) {
15145 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
15147 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
15148 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
15149 if ($filterobj->id) {
15150 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
15152 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
15153 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
15154 if ($filterobj->id) {
15155 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
15157 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contact' && $filterobj->id) {
15158 $sql .=
" AND a.fk_contact = sp.rowid";
15159 if ($filterobj->id) {
15160 $sql .=
" AND a.fk_contact = ".((int) $filterobj->id);
15162 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Facture') {
15163 $sql .=
" AND a.fk_element = o.rowid";
15164 if ($filterobj->id) {
15165 $sql .=
" AND a.fk_element = ".((int) $filterobj->id).
" AND a.elementtype = 'invoice'";
15167 } elseif (is_object($filterobj) && get_class($filterobj) ==
'FactureFournisseur') {
15168 $sql .=
" AND a.fk_element = o.rowid";
15169 if ($filterobj->id) {
15170 $sql .=
" AND a.fk_element = ".((int) $filterobj->id).
" AND a.elementtype = 'invoice_supplier'";
15174 $sql .=
" AND u.rowid = ". ((int) $filterobj->id);
15178 if (!empty($actioncode) && $actioncode !=
'-1') {
15180 if ($actioncode ==
'AC_NON_AUTO') {
15181 $sql .=
" AND c.type != 'systemauto'";
15182 } elseif ($actioncode ==
'AC_ALL_AUTO') {
15183 $sql .=
" AND c.type = 'systemauto'";
15185 if ($actioncode ==
'AC_OTH') {
15186 $sql .=
" AND c.type != 'systemauto'";
15187 } elseif ($actioncode ==
'AC_OTH_AUTO') {
15188 $sql .=
" AND c.type = 'systemauto'";
15192 if ($actioncode ==
'AC_NON_AUTO') {
15193 $sql .=
" AND c.type != 'systemauto'";
15194 } elseif ($actioncode ==
'AC_ALL_AUTO') {
15195 $sql .=
" AND c.type = 'systemauto'";
15197 $sql .=
" AND c.code = '".$db->escape($actioncode).
"'";
15201 if ($donetodo ==
'todo') {
15202 $sql .=
" AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now).
"'))";
15203 } elseif ($donetodo ==
'done') {
15204 $sql .=
" AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now).
"'))";
15206 if (is_array($filters) && $filters[
'search_agenda_label']) {
15207 $sql .=
natural_search(
'a.label', $filters[
'search_agenda_label']);
15212 if (isModEnabled(
'mailing') && !empty($objcon->email)
15213 && (empty($actioncode) || $actioncode ==
'AC_OTH_AUTO' || $actioncode ==
'AC_EMAILING')) {
15214 $langs->load(
"mails");
15216 $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";
15217 $sql2 .=
", null as fk_element, '' as elementtype, null as contact_id";
15218 $sql2 .=
", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
15219 $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";
15220 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
15221 $sql2 .=
", '' as lastname, '' as firstname";
15222 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
15223 $sql2 .=
", '' as lastname, '' as firstname";
15224 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
15225 $sql2 .=
", '' as ref";
15226 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
15227 $sql2 .=
", '' as ref";
15228 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
15229 $sql2 .=
", '' as ref";
15231 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"user as u";
15232 $sql2 .=
" WHERE mc.email = '".$db->escape($objcon->email).
"'";
15233 $sql2 .=
" AND mc.statut = 1";
15234 $sql2 .=
" AND u.rowid = m.fk_user_valid";
15235 $sql2 .=
" AND mc.fk_mailing=m.rowid";
15238 if ($sql || $sql2) {
15239 if (!empty($sql) && !empty($sql2)) {
15240 $sql = $sql.
" UNION ".$sql2;
15241 } elseif (empty($sql) && !empty($sql2)) {
15250 $sql .= $db->order($sortfield_new, $sortorder);
15252 $sql .= $db->plimit($limit + 1, $offset);
15255 dol_syslog(
"function.lib::show_actions_messaging", LOG_DEBUG);
15256 $resql = $db->query($sql);
15259 $num = $db->num_rows($resql);
15261 $imaxinloop = ($limit ? min($num, $limit) : $num);
15262 while ($i < $imaxinloop) {
15263 $obj = $db->fetch_object($resql);
15265 if ($obj->type ==
'action') {
15267 $contactaction->id = $obj->id;
15268 $result = $contactaction->fetchResources();
15271 setEventMessage(
"actions.lib::show_actions_messaging Error fetch resource",
'errors');
15277 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->dp > $now)) {
15278 $tododone =
'todo';
15281 $histo[$numaction] = array(
15282 'type' => $obj->type,
15283 'tododone' => $tododone,
15285 'datestart' => $db->jdate($obj->dp),
15286 'dateend' => $db->jdate($obj->dp2),
15287 'note' => $obj->label,
15289 'percent' => $obj->percent,
15291 'userid' => $obj->user_id,
15292 'login' => $obj->user_login,
15293 'userfirstname' => $obj->user_firstname,
15294 'userlastname' => $obj->user_lastname,
15295 'userphoto' => $obj->user_photo,
15296 'msg_from' => $obj->msg_from,
15298 'contact_id' => $obj->fk_contact,
15299 'socpeopleassigned' => $contactaction->socpeopleassigned,
15300 'lastname' => (empty($obj->lastname) ?
'' : $obj->lastname),
15301 'firstname' => (empty($obj->firstname) ?
'' : $obj->firstname),
15302 'fk_element' => $obj->fk_element,
15303 'elementtype' => $obj->elementtype,
15305 'acode' => $obj->acode,
15306 'alabel' => $obj->alabel,
15307 'libelle' => $obj->alabel,
15308 'apicto' => $obj->apicto
15311 $histo[$numaction] = array(
15312 'type' => $obj->type,
15313 'tododone' =>
'done',
15315 'datestart' => $db->jdate($obj->dp),
15316 'dateend' => $db->jdate($obj->dp2),
15317 'note' => $obj->label,
15319 'percent' => $obj->percent,
15320 'acode' => $obj->acode,
15322 'userid' => $obj->user_id,
15323 'login' => $obj->user_login,
15324 'userfirstname' => $obj->user_firstname,
15325 'userlastname' => $obj->user_lastname,
15326 'userphoto' => $obj->user_photo
15341 if (!isModEnabled(
'agenda')) {
15342 $langs->loadLangs(array(
"admin",
"errors"));
15343 $out =
info_admin($langs->trans(
"WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv(
"Module2400Name")), 0, 0,
'warning');
15346 if (isModEnabled(
'agenda') || (isModEnabled(
'mailing') && !empty($objcon->email))) {
15347 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
15349 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
15350 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
15351 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
15352 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
15357 $userstatic =
new User($db);
15358 $contactstatic =
new Contact($db);
15359 $userGetNomUrlCache = array();
15360 $contactGetNomUrlCache = array();
15362 $out .=
'<div class="filters-container" >';
15363 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
15364 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
15366 if ($objcon && get_class($objcon) ==
'Contact' &&
15367 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
15368 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
15370 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
15372 if (($filterobj && get_class($filterobj) ==
'Societe')) {
15373 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
15375 $out .=
'<input type="hidden" name="userid" value="'.$filterobj->id.
'" />';
15380 $out .=
'<div class="div-table-responsive-no-min">';
15381 $out .=
'<table class="noborder borderbottom centpercent">';
15383 $out .=
'<tr class="liste_titre">';
15387 $out .=
'<th class="liste_titre width50 middle">';
15388 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
15389 $out .= $searchpicto;
15394 $out .=
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep',
'', $param,
'', $sortfield, $sortorder,
'nowraponall nopaddingleftimp ').
"\n";
15396 $out .=
'<th class="liste_titre hideonsmartphone"><strong class="hideonsmartphone">'.$langs->trans(
"Search").
' : </strong></th>';
15398 $out .=
'<th class="liste_titre"></th>';
15401 $out .=
'<th class="liste_titre">';
15402 $out .=
'<span class="fas fa-square inline-block fawidth30 hideonsmartphone" style="color: #ddd;" title="'.$langs->trans(
"ActionType").
'"></span>';
15403 $out .= $formactions->select_type_actions($actioncode,
"actioncode",
'',
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? -1 : 1, 0, 0, 1,
'selecttype minwidth100', $langs->trans(
"Type"));
15406 $out .=
'<th class="liste_titre maxwidth100onsmartphone">';
15407 $out .=
'<input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'" placeholder="'.$langs->trans(
"Label").
'">';
15412 $out .=
'<th class="liste_titre width50 middle">';
15413 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
15414 $out .= $searchpicto;
15420 $out .=
'</table>';
15427 $out .=
'<ul class="timeline">';
15431 if ($filterobj instanceof
Societe) {
15432 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
15434 if ($filterobj instanceof
User) {
15435 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
15437 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
15438 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
15439 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
15441 if ($filterobj instanceof
Societe) {
15444 if ($filterobj instanceof
User) {
15450 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
15452 $arraylist = $caction->liste_array(1,
'code',
'', (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 1 : 0),
'', 1);
15454 $actualCycleDate =
false;
15457 foreach ($histo as $key => $value) {
15458 $actionstatic->fetch($histo[$key][
'id']);
15460 $actionstatic->type_picto = $histo[$key][
'apicto'];
15461 $actionstatic->type_code = $histo[$key][
'acode'];
15463 $labeltype = $actionstatic->type_code;
15464 if (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labeltype])) {
15465 $labeltype =
'AC_OTH';
15467 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
15468 $labeltype = $langs->trans(
"Message");
15470 if (!empty($arraylist[$labeltype])) {
15471 $labeltype = $arraylist[$labeltype];
15473 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
15474 $labeltype .=
' - '.$arraylist[$actionstatic->code];
15478 $url = DOL_URL_ROOT.
'/comm/action/card.php?id='.$histo[$key][
'id'];
15480 $tmpa =
dol_getdate($histo[$key][
'datestart'],
false);
15482 if (isset($tmpa[
'year']) && isset($tmpa[
'yday']) && $actualCycleDate !== $tmpa[
'year'].
'-'.$tmpa[
'yday']) {
15483 $actualCycleDate = $tmpa[
'year'].
'-'.$tmpa[
'yday'];
15484 $out .=
'<!-- timeline time label -->';
15485 $out .=
'<li class="time-label">';
15486 $out .=
'<span class="timeline-badge-date">';
15487 $out .=
dol_print_date($histo[$key][
'datestart'],
'daytext',
'tzuserrel', $langs);
15490 $out .=
'<!-- /.timeline-label -->';
15494 $out .=
'<!-- timeline item -->'.
"\n";
15495 $out .=
'<li class="timeline-code-'.(!empty($actionstatic->code) ? strtolower($actionstatic->code) :
"none").
'">';
15498 $typeicon = $actionstatic->getTypePicto(
'pictofixedwidth timeline-icon-not-applicble', $labeltype);
15503 $out .=
'<div class="timeline-item">'.
"\n";
15505 $out .=
'<span class="time timeline-header-action2">';
15507 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
15508 $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").
' ';
15509 $out .= $histo[$key][
'id'];
15512 $out .= $actionstatic->getNomUrl(1, -1,
'valignmiddle').
' ';
15515 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
15516 (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
15517 $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).
'">';
15519 $out .=
img_picto($langs->trans(
"Modify"),
'edit',
'class="edita"');
15526 $out .=
'<span class="time"><i class="fa fa-clock-o valignmiddle"></i> <span class="valignmiddle">';
15527 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
15528 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
15529 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
15530 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
15531 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
15532 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
15534 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
15538 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
15541 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
15544 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
15547 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
15553 $out .=
"</span></span>\n";
15555 $out .=
'<span class="time">';
15556 $out .= $actionstatic->getLibStatut(2);
15560 $out .=
'<h3 class="timeline-header">';
15563 $out .=
'<div class="messaging-author inline-block tdoverflowmax150 valignmiddle marginrightonly">';
15564 if ($histo[$key][
'userid'] > 0) {
15565 if (!isset($userGetNomUrlCache[$histo[$key][
'userid']])) {
15566 $userstatic->fetch($histo[$key][
'userid']);
15567 $userGetNomUrlCache[$histo[$key][
'userid']] = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
15569 $out .= $userGetNomUrlCache[$histo[$key][
'userid']];
15570 } elseif (!empty($histo[$key][
'msg_from']) && $actionstatic->code ==
'TICKET_MSG') {
15571 if (!isset($contactGetNomUrlCache[$histo[$key][
'msg_from']])) {
15572 if ($contactstatic->fetch(0,
null,
'', $histo[$key][
'msg_from']) > 0) {
15573 $contactGetNomUrlCache[$histo[$key][
'msg_from']] = $contactstatic->getNomUrl(-1,
'', 16);
15575 $contactGetNomUrlCache[$histo[$key][
'msg_from']] = $histo[$key][
'msg_from'];
15578 $out .= $contactGetNomUrlCache[$histo[$key][
'msg_from']];
15583 $out .=
' <div class="messaging-title inline-block">';
15585 if (empty(
$conf->dol_optimize_smallscreen) && $actionstatic->type_code !=
'AC_OTH_AUTO') {
15586 $out .= $labeltype.
' - ';
15591 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
15592 $out .= $langs->trans(
'TicketNewMessage').
' <em>('.$langs->trans(
'Private').
')</em>';
15593 } elseif (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
15594 $out .= $langs->trans(
'TicketNewMessage');
15595 } elseif (isset($histo[$key][
'type'])) {
15596 if ($histo[$key][
'type'] ==
'action') {
15597 $transcode = $langs->transnoentitiesnoconv(
"Action".$histo[$key][
'acode']);
15598 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode : $histo[$key][
'alabel']);
15599 $libelle = $histo[$key][
'note'];
15600 $actionstatic->id = $histo[$key][
'id'];
15601 if ($libelle != $labeltype) {
15604 } elseif ($histo[$key][
'type'] ==
'mailing') {
15605 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
15606 $transcode = $langs->transnoentitiesnoconv(
"Action".$histo[$key][
'acode']);
15607 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
15610 $libelle .= $histo[$key][
'note'];
15614 $out = preg_replace(
'/ - $/',
'', $out);
15616 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
15617 if (isset(
$conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']]) && isset(
$conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
15618 $link =
$conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
15620 if (!isset(
$conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']])) {
15621 $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']] = array();
15623 $link =
dolGetElementUrl($histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
15624 $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
15627 $out .=
' - '.$link;
15636 if (!empty($histo[$key][
'message'] && $histo[$key][
'message'] != $libelle)
15637 && $actionstatic->code !=
'AC_TICKET_CREATE'
15638 && $actionstatic->code !=
'AC_TICKET_MODIFY'
15640 $out .=
'<div class="timeline-body wordbreak small">';
15641 $truncateLines =
getDolGlobalInt(
'MAIN_TRUNCATE_TIMELINE_MESSAGE', 3);
15643 if ($truncateLines > 0 && strlen($histo[$key][
'message']) > strlen($truncatedText)) {
15644 $out .=
'<div class="readmore-block --closed" >';
15645 $out .=
' <div class="readmore-block__excerpt">';
15647 $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>';
15649 $out .=
' <div class="readmore-block__full-text" >';
15651 $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>';
15665 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
15667 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $Tab) {
15668 if (empty(
$conf->cache[
'contact'][$cid])) {
15670 $contact->fetch($cid);
15671 $conf->cache[
'contact'][$cid] = $contact;
15673 $contact =
$conf->cache[
'contact'][$cid];
15677 $contactList .= !empty($contactList) ?
', ' :
'';
15678 $contactList .= $contact->getNomUrl(1);
15679 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
15680 if (!empty($contact->phone_pro)) {
15681 $contactList .=
'('.dol_print_phone($contact->phone_pro).
')';
15687 $footer .= $langs->trans(
'ActionOnContact').
' : '.$contactList;
15688 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
15689 if (empty(
$conf->cache[
'contact'][$histo[$key][
'contact_id']])) {
15691 $result = $contact->fetch($histo[$key][
'contact_id']);
15692 $conf->cache[
'contact'][$histo[$key][
'contact_id']] = $contact;
15694 $contact =
$conf->cache[
'contact'][$histo[$key][
'contact_id']];
15695 $result = ($contact instanceof
Contact) ? $contact->id : 0;
15699 $footer .= $contact->getNomUrl(1);
15700 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
15701 if (!empty($contact->phone_pro)) {
15702 $footer .=
'('.dol_print_phone($contact->phone_pro).
')';
15709 if (!empty($documents)) {
15710 $footer .=
'<div class="timeline-documents-container">';
15711 foreach ($documents as $doc) {
15712 $footer .=
'<span id="document_'.$doc->id.
'" class="timeline-documents" ';
15713 $footer .=
' data-id="'.$doc->id.
'" ';
15714 $footer .=
' data-path="'.$doc->filepath.
'"';
15715 $footer .=
' data-filename="'.dol_escape_htmltag($doc->filename).
'" ';
15718 $filePath = DOL_DATA_ROOT.
'/'.$doc->filepath.
'/'.$doc->filename;
15720 if (empty($doc->agenda_id)) {
15721 $dir_ref = $actionstatic->id;
15722 $modulepart =
'actions';
15724 $split_dir = explode(
'/', $doc->filepath);
15725 $modulepart = array_shift($split_dir);
15726 $dir_ref = implode(
'/', $split_dir);
15729 $file = $dir_ref.
'/'.$doc->filename;
15730 $thumb = $dir_ref.
'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename,
'.')).
'_mini'.substr($doc->filename, strrpos($doc->filename,
'.'));
15731 $doclink =
dol_buildpath(
'document.php', 1).
'?modulepart='.$modulepart.
'&attachment=0&file='.urlencode($file).
'&entity='.
$conf->entity;
15732 $viewlink =
dol_buildpath(
'viewimage.php', 1).
'?modulepart='.$modulepart.
'&file='.urlencode($thumb).
'&entity='.
$conf->entity;
15736 $mimeAttr =
' mime="'.$mime.
'" ';
15738 if (in_array($mime, array(
'image/png',
'image/jpeg',
'application/pdf'))) {
15739 $class .=
' documentpreview';
15742 $footer .=
'<a href="'.$doclink.
'" class="btn-link '.$class.
'" target="_blank" rel="noopener noreferrer" '.$mimeAttr.
' >';
15743 $footer .=
img_mime($filePath).
' '.$doc->filename;
15746 $footer .=
'</span>';
15748 $footer .=
'</div>';
15751 if (!empty($footer)) {
15752 $out .=
'<div class="timeline-footer">'.$footer.
'</div>';
15755 $out .=
'</div>'.
"\n";
15758 $out .=
'<!-- END timeline item -->';
15765 jQuery(document).ready(function () {
15766 $(document).on("click", "[data-read-more-action]", function(e){
15767 console.log("We click on data-read-more-action");
15768 let readMoreBloc = $(this).closest(".readmore-block");
15769 if(readMoreBloc.length > 0){
15770 e.preventDefault();
15771 if($(this).attr("data-read-more-action") == "close"){
15772 readMoreBloc.addClass("--closed").removeClass("--open");
15773 $("html, body").animate({
15774 scrollTop: readMoreBloc.offset().top - 200
15777 readMoreBloc.addClass("--open").removeClass("--closed");
15785 if (empty($histo)) {
15786 $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
15809function buildParamDate($prefix, $timestamp =
null, $hourTime =
'', $gm =
'auto')
15811 if ($timestamp ===
null) {
15812 $timestamp =
GETPOSTDATE($prefix, $hourTime, $gm);
15819 if ($hourTime ===
'getpost' || ($timestamp !==
null &&
dol_print_date($timestamp,
'%H:%M:%S') !==
'00:00:00')) {
15820 $TParam = array_merge($TParam, array(
15827 return '&' . http_build_query($TParam);
15848function recordNotFound($message =
'', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params =
null)
15850 global
$conf, $db, $langs, $hookmanager;
15853 if (!is_object($langs)) {
15854 include_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
15856 $langs->setDefaultLang();
15859 $langs->load(
"errors");
15861 if ($printheader) {
15862 if (function_exists(
"llxHeader")) {
15864 } elseif (function_exists(
"llxHeaderVierge")) {
15869 print
'<div class="error">';
15870 if (empty($message)) {
15871 print $langs->trans(
"ErrorRecordNotFound");
15873 print $langs->trans($message);
15878 if (empty($showonlymessage)) {
15879 if (empty($hookmanager)) {
15880 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
15883 $hookmanager->initHooks(array(
'main'));
15886 $parameters = array(
'message' => $message,
'params' => $params);
15887 $reshook = $hookmanager->executeHooks(
'getErrorRecordNotFound', $parameters,
$object, $action);
15888 print $hookmanager->resPrint;
15891 if ($printfooter && function_exists(
"llxFooter")) {
15893 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.