46include_once DOL_DOCUMENT_ROOT.
'/core/lib/json.lib.php';
49if (!function_exists(
'utf8_encode')) {
56 function utf8_encode($elements)
58 return mb_convert_encoding($elements,
'UTF-8',
'ISO-8859-1');
62if (!function_exists(
'utf8_decode')) {
69 function utf8_decode($elements)
71 return mb_convert_encoding($elements,
'ISO-8859-1',
'UTF-8');
74if (!function_exists(
'str_starts_with')) {
82 function str_starts_with($haystack, $needle)
84 return (
string) $needle !==
'' && strncmp($haystack, $needle, strlen($needle)) === 0;
87if (!function_exists(
'str_ends_with')) {
95 function str_ends_with($haystack, $needle)
97 return $needle !==
'' && substr($haystack, -strlen($needle)) === (string) $needle;
100if (!function_exists(
'str_contains')) {
108 function str_contains($haystack, $needle)
110 return $needle !==
'' && mb_strpos($haystack, $needle) !==
false;
127 if (!is_object($object) && empty($module)) {
130 if (empty($module) && !empty($object->element)) {
131 $module = $object->element;
134 if ($module ==
'fichinter') {
135 $module =
'ficheinter';
137 if (isset($conf->$module) && property_exists($conf->$module,
'multidir_output')) {
138 return $conf->$module->multidir_output[(empty($object->entity) ? $conf->entity : $object->entity)];
140 return 'error-diroutput-not-defined-for-this-object='.$module;
154 return (
string) (isset($conf->global->$key) ? $conf->global->$key : $default);
168 return (
int) (isset($conf->global->$key) ? $conf->global->$key : $default);
181 if (empty($tmpuser)) {
186 return (
string) (empty($tmpuser->conf->$key) ? $default : $tmpuser->conf->$key);
199 if (empty($tmpuser)) {
204 return (
int) (empty($tmpuser->conf->$key) ? $default : $tmpuser->conf->$key);
213function isModEnabled($module)
220 'category' =>
'categorie',
221 'contract' =>
'contrat',
222 'project' =>
'projet',
223 'delivery_note' =>
'expedition'
226 $arrayconv[
'supplier_order'] =
'fournisseur';
227 $arrayconv[
'supplier_invoice'] =
'fournisseur';
229 if (!empty($arrayconv[$module])) {
230 $module = $arrayconv[$module];
233 return !empty($conf->modules[$module]);
250 require_once DOL_DOCUMENT_ROOT.
"/core/db/".$type.
'.class.php';
252 $class =
'DoliDB'.ucfirst($type);
253 $dolidb =
new $class($type, $host, $user, $pass, $name, $port);
274function getEntity($element, $shared = 1, $currentobject =
null)
276 global $conf, $mc, $hookmanager, $object, $action, $db;
278 if (!is_object($hookmanager)) {
279 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
286 $element =
'project';
289 $element =
'contract';
291 case 'order_supplier':
292 $element =
'supplier_order';
294 case 'invoice_supplier':
295 $element =
'supplier_invoice';
299 if (is_object($mc)) {
300 $out = $mc->getEntity($element, $shared, $currentobject);
303 $addzero = array(
'user',
'usergroup',
'cronjob',
'c_email_templates',
'email_template',
'default_values',
'overwrite_trans');
304 if (in_array($element, $addzero)) {
307 $out .= ((int) $conf->entity);
312 'element' => $element,
315 'currentobject' => $currentobject,
318 $reshook = $hookmanager->executeHooks(
'hookGetEntity', $parameters, $currentobject, $action);
320 if (is_numeric($reshook)) {
321 if ($reshook == 0 && !empty($hookmanager->resPrint)) {
322 $out .=
','.$hookmanager->resPrint;
323 } elseif ($reshook == 1) {
324 $out = $hookmanager->resPrint;
341 if (is_object($mc) && method_exists($mc,
'setEntity')) {
342 return $mc->setEntity($currentobject);
344 return ((is_object($currentobject) && $currentobject->id > 0 && $currentobject->entity > 0) ? $currentobject->entity : $conf->entity);
356 return preg_match(
'/(_pass|password|_pw|_key|securekey|serverkey|secret\d?|p12key|exportkey|_PW_[a-z]+|token)$/i', $keyname);
368 for ($r =
""; $n >= 0; $n = intval($n / 26) - 1) {
369 $r = chr($n % 26 + 0x41) . $r;
393 include_once DOL_DOCUMENT_ROOT.
'/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php';
400 $user_agent = substr($user_agent, 0, 512);
402 $detectmobile =
new Mobile_Detect(
null, $user_agent);
403 $tablet = $detectmobile->isTablet();
405 if ($detectmobile->isMobile()) {
409 if ($detectmobile->is(
'AndroidOS')) {
410 $os = $phone =
'android';
411 } elseif ($detectmobile->is(
'BlackBerryOS')) {
412 $os = $phone =
'blackberry';
413 } elseif ($detectmobile->is(
'iOS')) {
416 } elseif ($detectmobile->is(
'PalmOS')) {
417 $os = $phone =
'palm';
418 } elseif ($detectmobile->is(
'SymbianOS')) {
420 } elseif ($detectmobile->is(
'webOS')) {
422 } elseif ($detectmobile->is(
'MaemoOS')) {
424 } elseif ($detectmobile->is(
'WindowsMobileOS') || $detectmobile->is(
'WindowsPhoneOS')) {
430 if (preg_match(
'/linux/i', $user_agent)) {
432 } elseif (preg_match(
'/macintosh/i', $user_agent)) {
434 } elseif (preg_match(
'/windows/i', $user_agent)) {
440 if (preg_match(
'/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
442 $version = empty($reg[2]) ?
'' : $reg[2];
443 } elseif (preg_match(
'/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
445 $version = empty($reg[2]) ?
'' : $reg[2];
446 } elseif (preg_match(
'/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) {
448 $version = empty($reg[2]) ?
'' : $reg[2];
449 } elseif (preg_match(
'/chrome/i', $user_agent, $reg)) {
452 } elseif (preg_match(
'/iceweasel/i', $user_agent)) {
454 } elseif (preg_match(
'/epiphany/i', $user_agent)) {
456 } elseif (preg_match(
'/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
458 $version = empty($reg[2]) ?
'' : $reg[2];
459 } elseif (preg_match(
'/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
462 $version = empty($reg[2]) ?
'' : $reg[2];
463 } elseif (preg_match(
'/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
465 $version = end($reg);
466 } elseif (preg_match(
'/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
469 $version = end($reg);
470 } elseif (preg_match(
'/l[iy]n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) {
473 $version = empty($reg[3]) ?
'' : $reg[3];
485 'browsername' => $name,
486 'browserversion' => $version,
488 'browserua' => $user_agent,
503 $disconnectdone =
false;
505 if (is_object($db) && !empty($db->connected)) {
506 $depth = $db->transaction_opened;
507 $disconnectdone = $db->close();
509 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));
521function GETPOSTISSET($paramname)
525 $relativepathstring = $_SERVER[
"PHP_SELF"];
527 if (constant(
'DOL_URL_ROOT')) {
528 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
530 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
531 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
537 if (!empty($_GET[
'restore_lastsearch_values'])) {
538 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
539 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
540 if (is_array($tmp)) {
541 foreach ($tmp as $key => $val) {
542 if ($key == $paramname) {
550 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
552 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
554 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
556 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
560 $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname]));
577 if (empty($method)) {
578 $val = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
579 } elseif ($method == 1) {
580 $val = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
581 } elseif ($method == 2) {
582 $val = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
583 } elseif ($method == 3) {
584 $val = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
586 $val =
'BadFirstParameterForGETPOST';
589 return is_array($val);
621function GETPOST($paramname, $check =
'alphanohtml', $method = 0, $filter =
null, $options =
null, $noreplace = 0)
623 global $mysoc, $user, $conf;
625 if (empty($paramname)) {
626 return 'BadFirstParameterForGETPOST';
629 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);
634 if (empty($method)) {
635 $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
636 } elseif ($method == 1) {
637 $out = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
638 } elseif ($method == 2) {
639 $out = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
640 } elseif ($method == 3) {
641 $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
643 return 'BadThirdParameterForGETPOST';
646 if (empty($method) || $method == 3 || $method == 4) {
647 $relativepathstring = (empty($_SERVER[
"PHP_SELF"]) ?
'' : $_SERVER[
"PHP_SELF"]);
649 if (constant(
'DOL_URL_ROOT')) {
650 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
652 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
653 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
659 if (!empty($_GET[
'restore_lastsearch_values'])) {
660 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
661 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
662 if (is_array($tmp)) {
663 foreach ($tmp as $key => $val) {
664 if ($key == $paramname) {
672 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
673 $out = $_SESSION[
'lastsearch_contextpage_'.$relativepathstring];
674 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
675 $out = $_SESSION[
'lastsearch_limit_'.$relativepathstring];
676 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
677 $out = $_SESSION[
'lastsearch_page_'.$relativepathstring];
678 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
679 $out = $_SESSION[
'lastsearch_mode_'.$relativepathstring];
681 } elseif (!isset($_GET[
'sortfield'])) {
684 if (!empty($_GET[
'action']) && $_GET[
'action'] ==
'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
687 if (is_object($object) && isset($object->fields[$paramname][
'default'])) {
688 $out = $object->fields[$paramname][
'default'];
692 if (!empty($_GET[
'action']) && (preg_match(
'/^create/', $_GET[
'action']) || preg_match(
'/^presend/', $_GET[
'action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
694 if (!empty($user->default_values)) {
695 if (isset($user->default_values[$relativepathstring][
'createform'])) {
696 foreach ($user->default_values[$relativepathstring][
'createform'] as $defkey => $defval) {
698 if ($defkey !=
'_noquery_') {
699 $tmpqueryarraytohave = explode(
'&', $defkey);
702 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
703 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
716 if (isset($user->default_values[$relativepathstring][
'createform'][$defkey][$paramname])) {
717 $out = $user->default_values[$relativepathstring][
'createform'][$defkey][$paramname];
724 } elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
726 if (!empty($user->default_values)) {
729 if ($paramname ==
'sortfield' || $paramname ==
'sortorder') {
731 if (isset($user->default_values[$relativepathstring][
'sortorder'])) {
733 foreach ($user->default_values[$relativepathstring][
'sortorder'] as $defkey => $defval) {
735 if ($defkey !=
'_noquery_') {
736 $tmpqueryarraytohave = explode(
'&', $defkey);
739 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
740 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
753 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
754 foreach ($user->default_values[$relativepathstring][
'sortorder'][$defkey] as $key => $val) {
758 if ($paramname ==
'sortfield') {
761 if ($paramname ==
'sortorder') {
769 } elseif (isset($user->default_values[$relativepathstring][
'filters'])) {
770 foreach ($user->default_values[$relativepathstring][
'filters'] as $defkey => $defval) {
771 if (!empty($_GET[
'disabledefaultvalues'])) {
775 if ($defkey !=
'_noquery_') {
776 $tmpqueryarraytohave = explode(
'&', $defkey);
779 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
780 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
792 if ($qualified && isset($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname])) {
794 if (isset($_POST[
'sall']) || isset($_POST[
'search_all']) || isset($_GET[
'sall']) || isset($_GET[
'search_all'])) {
797 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
798 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
801 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
802 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
817 if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
821 while (preg_match(
'/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) {
825 if ($reg[1] ==
'DAY') {
827 $newout = $tmp[
'mday'];
828 } elseif ($reg[1] ==
'MONTH') {
830 $newout = $tmp[
'mon'];
831 } elseif ($reg[1] ==
'YEAR') {
833 $newout = $tmp[
'year'];
834 } elseif ($reg[1] ==
'PREVIOUS_DAY') {
837 $newout = $tmp2[
'day'];
838 } elseif ($reg[1] ==
'PREVIOUS_MONTH') {
841 $newout = $tmp2[
'month'];
842 } elseif ($reg[1] ==
'PREVIOUS_YEAR') {
844 $newout = ($tmp[
'year'] - 1);
845 } elseif ($reg[1] ==
'NEXT_DAY') {
848 $newout = $tmp2[
'day'];
849 } elseif ($reg[1] ==
'NEXT_MONTH') {
852 $newout = $tmp2[
'month'];
853 } elseif ($reg[1] ==
'NEXT_YEAR') {
855 $newout = ($tmp[
'year'] + 1);
856 } elseif ($reg[1] ==
'MYCOMPANY_COUNTRY_ID' || $reg[1] ==
'MYCOUNTRY_ID' || $reg[1] ==
'MYCOUNTRYID') {
857 $newout = $mysoc->country_id;
858 } elseif ($reg[1] ==
'USER_ID' || $reg[1] ==
'USERID') {
860 } elseif ($reg[1] ==
'USER_SUPERVISOR_ID' || $reg[1] ==
'SUPERVISOR_ID' || $reg[1] ==
'SUPERVISORID') {
861 $newout = $user->fk_user;
862 } elseif ($reg[1] ==
'ENTITY_ID' || $reg[1] ==
'ENTITYID') {
863 $newout = $conf->entity;
868 $out = preg_replace(
'/__'.preg_quote($reg[1],
'/').
'__/', $newout, $out);
873 if (preg_match(
'/^array/', $check)) {
874 if (!is_array($out) || empty($out)) {
877 $tmparray = explode(
':', $check);
878 if (!empty($tmparray[1])) {
879 $tmpcheck = $tmparray[1];
881 $tmpcheck =
'alphanohtml';
883 foreach ($out as $outkey => $outval) {
884 $out[$outkey] =
sanitizeVal($outval, $tmpcheck, $filter, $options);
890 if (strpos($paramname,
'search_') === 0) {
891 $out = preg_replace(
'/([<>])([-+]?\d)/',
'\1 \2', $out);
894 $out =
sanitizeVal($out, $check, $filter, $options);
899 if ($paramname ==
'backtopage' || $paramname ==
'backtolist' || $paramname ==
'backtourl') {
900 $out = str_replace(
'\\',
'/', $out);
901 $out = str_replace(array(
':',
';',
'@',
"\t",
' '),
'', $out);
903 $oldstringtoclean = $out;
904 $out = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $out);
905 $out = preg_replace(array(
'/^[^\?]*%/'),
'', $out);
906 $out = preg_replace(array(
'/^[a-z]*\/\s*\/+/i'),
'', $out);
907 }
while ($oldstringtoclean != $out);
912 if (empty($method) || $method == 3 || $method == 4) {
913 if (preg_match(
'/^search_/', $paramname) || in_array($paramname, array(
'sortorder',
'sortfield'))) {
920 if ($out !=
'' && isset($user)) {
921 $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out;
940 return (
int)
GETPOST($paramname,
'int', $method,
null,
null, 0);
954function checkVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
956 return sanitizeVal($out, $check, $filter, $options);
968function sanitizeVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
976 if (!is_numeric($out)) {
981 if (is_array($out)) {
982 $out = implode(
',', $out);
984 if (preg_match(
'/[^0-9,-]+/i', $out)) {
989 $out = filter_var($out, FILTER_SANITIZE_STRING);
992 $out = filter_var($out, FILTER_SANITIZE_EMAIL);
995 if (!is_array($out)) {
997 if (preg_match(
'/[^a-z]+/i', $out)) {
1003 if (!is_array($out)) {
1005 if (preg_match(
'/[^a-z0-9_\-\.]+/i', $out)) {
1011 if (!is_array($out)) {
1013 if (preg_match(
'/[^a-z0-9_\-\.@]+/i', $out)) {
1019 if (!is_array($out)) {
1021 if (preg_match(
'/[^a-z0-9_\-\.,]+/i', $out)) {
1028 if (!is_array($out)) {
1031 $oldstringtoclean = $out;
1038 $out = str_ireplace(array(
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'\',
'\',
'/',
'../',
'..\\'),
'', $out);
1039 }
while ($oldstringtoclean != $out);
1043 case 'alphawithlgt':
1044 if (!is_array($out)) {
1047 $oldstringtoclean = $out;
1053 $out = str_ireplace(array(
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'\',
'\',
'/',
'../',
'..\\'),
'', $out);
1054 }
while ($oldstringtoclean != $out);
1060 case 'restricthtmlnolink':
1061 case 'restricthtml':
1062 case 'restricthtmlallowclass':
1063 case 'restricthtmlallowunvalid':
1068 if (empty($filter)) {
1069 return 'BadParameterForGETPOST - Param 3 of sanitizeVal()';
1074 $out = filter_var($out, $filter, $options);
1078 dol_syslog(
"Error, you call sanitizeVal() with a bad value for the check type. Data can't be sanitized.", LOG_ERR);
1086if (!function_exists(
'dol_getprefix')) {
1096 function dol_getprefix($mode =
'')
1099 if ($mode ==
'email') {
1104 return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
1105 } elseif (isset($_SERVER[
"SERVER_NAME"])) {
1106 return $_SERVER[
"SERVER_NAME"];
1111 if (!empty($conf->file->instance_unique_id)) {
1112 return sha1(
'dolibarr'.$conf->file->instance_unique_id);
1116 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1120 global $dolibarr_main_instance_unique_id, $dolibarr_main_cookie_cryptkey;
1121 $tmp_instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ?
'' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
1124 if (!empty($tmp_instance_unique_id)) {
1125 return sha1(
'dolibarr'.$tmp_instance_unique_id);
1129 if (isset($_SERVER[
"SERVER_NAME"]) && isset($_SERVER[
"DOCUMENT_ROOT"])) {
1130 return sha1($_SERVER[
"SERVER_NAME"].$_SERVER[
"DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1132 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1149 global $conf, $langs, $user, $mysoc;
1153 if (!file_exists($fullpath)) {
1154 dol_syslog(
'functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_WARNING);
1158 if (!empty($classname) && !class_exists($classname)) {
1159 return include $fullpath;
1161 return include_once $fullpath;
1180 $path = preg_replace(
'/^\//',
'', $path);
1183 $res = DOL_DOCUMENT_ROOT.
'/'.$path;
1184 if (is_array($conf->file->dol_document_root)) {
1185 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1186 if ($key ==
'main') {
1190 if (@file_exists($dirroot.
'/'.$path)) {
1191 $res = $dirroot.
'/'.$path;
1196 if ($returnemptyifnotfound) {
1198 if ($returnemptyifnotfound == 1 || !file_exists($res)) {
1210 $res = DOL_URL_ROOT.
'/'.$path;
1213 $res = DOL_MAIN_URL_ROOT.
'/'.$path;
1216 $res = DOL_URL_ROOT.
'/'.$path;
1219 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1220 if ($key ==
'main') {
1225 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($conf->file->dol_main_url_root));
1226 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1229 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
'/'.$path;
1234 preg_match(
'/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);
1235 if (!empty($regs[1])) {
1238 if (@file_exists($dirroot.
'/'.$regs[1])) {
1240 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1243 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1249 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($conf->file->dol_main_url_root));
1250 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1253 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).$conf->file->dol_url_root[$key].
'/'.$path;
1280 if (isset($object->db) && isset($object->db->db) && is_object($object->db->db) && get_class($object->db->db) ==
'PgSql\Connection') {
1281 $tmpsavdb = $object->db;
1285 $myclone = unserialize(serialize($object));
1287 if (!empty($tmpsavdb)) {
1288 $object->db = $tmpsavdb;
1290 } elseif ($native == 2) {
1293 $tmparray = get_object_vars($object);
1295 if (is_array($tmparray)) {
1296 foreach ($tmparray as $propertykey => $propertyval) {
1297 if (is_scalar($propertyval) || is_array($propertyval)) {
1298 $myclone->$propertykey = $propertyval;
1303 $myclone = clone $object;
1321 if (empty($conf->dol_optimize_smallscreen)) {
1324 if ($type ==
'width' && $size > 250) {
1349 $filesystem_forbidden_chars = array(
'<',
'>',
'/',
'\\',
'?',
'*',
'|',
'"',
':',
'°',
'$',
';',
'`');
1351 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1352 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1353 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1354 $tmp = str_replace(
'..',
'', $tmp);
1374 $filesystem_forbidden_chars = array(
'<',
'>',
'?',
'*',
'|',
'"',
'°',
'$',
';',
'`');
1376 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1377 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1378 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1379 $tmp = str_replace(
'..',
'', $tmp);
1394 $stringtoclean = preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $stringtoclean);
1396 $stringtoclean = preg_replace(
'/<!--[^>]*-->/',
'', $stringtoclean);
1398 $stringtoclean = str_replace(
'\\',
'/', $stringtoclean);
1402 $stringtoclean = str_replace(array(
':',
';',
'@'),
'', $stringtoclean);
1406 $oldstringtoclean = $stringtoclean;
1409 $stringtoclean = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $stringtoclean);
1410 }
while ($oldstringtoclean != $stringtoclean);
1414 $stringtoclean = preg_replace(array(
'/^[a-z]*\/\/+/i'),
'', $stringtoclean);
1417 return $stringtoclean;
1429 $oldstringtoclean = $stringtoclean;
1430 $stringtoclean = str_ireplace(array(
'"',
':',
'[',
']',
"\n",
"\r",
'\\',
'\/'),
'', $stringtoclean);
1431 }
while ($oldstringtoclean != $stringtoclean);
1433 return $stringtoclean;
1448 if (is_null($str)) {
1453 if (extension_loaded(
'intl') &&
getDolGlobalString(
'MAIN_UNACCENT_USE_TRANSLITERATOR')) {
1454 $transliterator = Transliterator::createFromRules(
':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', Transliterator::FORWARD);
1455 return $transliterator->transliterate($str);
1458 $string = rawurlencode($str);
1459 $replacements = array(
1460 '%C3%80' =>
'A',
'%C3%81' =>
'A',
'%C3%82' =>
'A',
'%C3%83' =>
'A',
'%C3%84' =>
'A',
'%C3%85' =>
'A',
1462 '%C3%88' =>
'E',
'%C3%89' =>
'E',
'%C3%8A' =>
'E',
'%C3%8B' =>
'E',
1463 '%C3%8C' =>
'I',
'%C3%8D' =>
'I',
'%C3%8E' =>
'I',
'%C3%8F' =>
'I',
1465 '%C3%92' =>
'O',
'%C3%93' =>
'O',
'%C3%94' =>
'O',
'%C3%95' =>
'O',
'%C3%96' =>
'O',
1467 '%C3%99' =>
'U',
'%C3%9A' =>
'U',
'%C3%9B' =>
'U',
'%C3%9C' =>
'U',
1468 '%C3%9D' =>
'Y',
'%C5%B8' =>
'y',
1469 '%C3%A0' =>
'a',
'%C3%A1' =>
'a',
'%C3%A2' =>
'a',
'%C3%A3' =>
'a',
'%C3%A4' =>
'a',
'%C3%A5' =>
'a',
1471 '%C3%A8' =>
'e',
'%C3%A9' =>
'e',
'%C3%AA' =>
'e',
'%C3%AB' =>
'e',
1472 '%C3%AC' =>
'i',
'%C3%AD' =>
'i',
'%C3%AE' =>
'i',
'%C3%AF' =>
'i',
1474 '%C3%B2' =>
'o',
'%C3%B3' =>
'o',
'%C3%B4' =>
'o',
'%C3%B5' =>
'o',
'%C3%B6' =>
'o',
1476 '%C3%B9' =>
'u',
'%C3%BA' =>
'u',
'%C3%BB' =>
'u',
'%C3%BC' =>
'u',
1477 '%C3%BD' =>
'y',
'%C3%BF' =>
'y'
1479 $string = strtr($string, $replacements);
1480 return rawurldecode($string);
1485 "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
1486 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
1487 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
1488 \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
1489 \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
1490 \xF9\xFA\xFB\xFC\xFD\xFF",
1498 $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"));
1516function dol_string_nospecial($str, $newstr =
'_', $badcharstoreplace =
'', $badcharstoremove =
'', $keepspaces = 0)
1518 $forbidden_chars_to_replace = array(
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
",",
";",
"=",
'°',
'$',
';');
1519 if (empty($keepspaces)) {
1520 $forbidden_chars_to_replace[] =
" ";
1522 $forbidden_chars_to_remove = array();
1525 if (is_array($badcharstoreplace)) {
1526 $forbidden_chars_to_replace = $badcharstoreplace;
1528 if (is_array($badcharstoremove)) {
1529 $forbidden_chars_to_remove = $badcharstoremove;
1532 return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove,
"", $str));
1551 if ($removetabcrlf) {
1552 return preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $str);
1554 return preg_replace(
'/[\x00-\x08\x11-\x12\x14-\x1F\x7F]/u',
'', $str);
1568 if (is_null($stringtoescape)) {
1573 $substitjs = array(
"'"=>
"\\'",
"\r"=>
'\\r');
1575 if (empty($noescapebackslashn)) {
1576 $substitjs[
"\n"] =
'\\n';
1577 $substitjs[
'\\'] =
'\\\\';
1580 $substitjs[
"'"] =
"\\'";
1581 $substitjs[
'"'] =
"\\'";
1582 } elseif ($mode == 1) {
1583 $substitjs[
"'"] =
"\\'";
1584 } elseif ($mode == 2) {
1585 $substitjs[
'"'] =
'\\"';
1586 } elseif ($mode == 3) {
1587 $substitjs[
"'"] =
"\\'";
1588 $substitjs[
'"'] =
"\\\"";
1590 return strtr($stringtoescape, $substitjs);
1601 return str_replace(
'"',
'\"', $stringtoescape);
1613 if (is_null($stringtoescape)) {
1617 if ($stringforquotes == 2) {
1618 return str_replace(
'"',
"'", $stringtoescape);
1620 if ($stringforquotes == 1) {
1621 return str_replace(
"'",
"\'", str_replace(
'"',
"'", $stringtoescape));
1624 return 'Bad parameter for stringforquotes in dol_escape_php';
1635 return preg_replace(
'/[^a-z0-9_]/i',
'', $stringtoescape);
1646 return $stringtoescape;
1684 return dol_escape_htmltag(
dol_string_onlythesehtmltags(
dol_htmlentitiesbr($s), 1, 0, 0, 0, array(
'br',
'b',
'font',
'span')), 1, -1,
'', 0, 1);
1708 return htmlspecialchars($s, ENT_COMPAT,
'UTF-8');
1728function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags =
'', $escapeonlyhtmltags = 0, $cleanalsojavascript = 0)
1730 if ($noescapetags ==
'common') {
1731 $noescapetags =
'html,body,a,b,em,hr,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody,h1,h2,h3,h4,h5,h6,h7,h8,h9';
1733 $noescapetags .=
',header,footer,nav,section,menu,menuitem';
1735 if ($cleanalsojavascript) {
1740 if ($escapeonlyhtmltags) {
1741 $tmp = htmlspecialchars_decode((
string) $stringtoescape, ENT_COMPAT);
1743 $tmp = html_entity_decode((
string) $stringtoescape, ENT_COMPAT,
'UTF-8');
1746 $tmp = strtr($tmp, array(
"<b>"=>
'',
'</b>'=>
'',
'<strong>'=>
'',
'</strong>'=>
''));
1749 $tmp = strtr($tmp, array(
"\r"=>
'\\r',
"\n"=>
'\\n'));
1750 } elseif ($keepn == -1) {
1751 $tmp = strtr($tmp, array(
"\r"=>
'',
"\n"=>
''));
1754 if ($escapeonlyhtmltags) {
1755 return htmlspecialchars($tmp, ENT_COMPAT,
'UTF-8');
1758 $tmparrayoftags = array();
1759 if ($noescapetags) {
1760 $tmparrayoftags = explode(
',', $noescapetags);
1762 if (count($tmparrayoftags)) {
1764 foreach ($tmparrayoftags as $tagtoreplace) {
1765 $tmp = str_ireplace(
'<'.$tagtoreplace.
'>',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1766 $tmp = str_ireplace(
'</'.$tagtoreplace.
'>',
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1767 $tmp = str_ireplace(
'<'.$tagtoreplace.
' />',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1771 $result = htmlentities($tmp, ENT_COMPAT,
'UTF-8');
1773 if (count($tmparrayoftags)) {
1774 foreach ($tmparrayoftags as $tagtoreplace) {
1775 $result = str_ireplace(
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
'>', $result);
1776 $result = str_ireplace(
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__',
'</'.$tagtoreplace.
'>', $result);
1777 $result = str_ireplace(
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
' />', $result);
1794 if (function_exists(
'mb_strtolower')) {
1795 return mb_strtolower($string, $encoding);
1797 return strtolower($string);
1811 if (function_exists(
'mb_strtoupper')) {
1812 return mb_strtoupper($string, $encoding);
1814 return strtoupper($string);
1828 if (function_exists(
'mb_substr')) {
1829 return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1,
null, $encoding);
1831 return ucfirst($string);
1845 if (function_exists(
'mb_convert_case')) {
1846 return mb_convert_case($string, MB_CASE_TITLE, $encoding);
1848 return ucwords($string);
1873function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
'', $restricttologhandler =
'', $logcontext =
null)
1875 global $conf, $user, $debugbar;
1878 if (!isModEnabled(
'syslog')) {
1883 if (defined(
'USEEXTERNALSERVER') && !defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
1884 global $website, $websitekey;
1885 if (is_object($website) && !empty($website->ref)) {
1886 $suffixinfilename .=
'_website_'.$website->ref;
1887 } elseif (!empty($websitekey)) {
1888 $suffixinfilename .=
'_website_'.$websitekey;
1893 if (defined(
'USESUFFIXINLOG')) {
1894 $suffixinfilename .= constant(
'USESUFFIXINLOG');
1898 foreach ($conf->loghandlers as $loghandlerinstance) {
1899 $loghandlerinstance->setIdent($ident);
1903 if (!empty($message)) {
1905 $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');
1907 if (!array_key_exists($level, $logLevels)) {
1908 dol_syslog(
'Error Bad Log Level '.$level, LOG_ERR);
1909 $level = $logLevels[LOG_ERR];
1916 $message = preg_replace(
'/password=\'[^\']*\'/',
'password=\'hidden\'', $message);
1920 if ((!empty($_REQUEST[
'logtohtml']) &&
getDolGlobalString(
'MAIN_ENABLE_LOG_TO_HTML'))
1921 || (is_object($user) && $user->hasRight(
'debugbar',
'read') && is_object($debugbar))) {
1922 $conf->logbuffer[] =
dol_print_date(time(),
"%Y-%m-%d %H:%M:%S").
" ".$logLevels[$level].
" ".$message;
1928 print
"\n\n<!-- Log start\n";
1930 print
"Log end -->\n";
1934 'message' => $message,
1935 'script' => (isset($_SERVER[
'PHP_SELF']) ? basename($_SERVER[
'PHP_SELF'],
'.php') :
false),
1937 'user' => ((is_object($user) && $user->id) ? $user->login :
false),
1942 if (!empty($remoteip)) {
1943 $data[
'ip'] = $remoteip;
1945 if (!empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) && $_SERVER[
'HTTP_X_FORWARDED_FOR'] != $remoteip) {
1946 $data[
'ip'] = $_SERVER[
'HTTP_X_FORWARDED_FOR'].
' -> '.$data[
'ip'];
1947 } elseif (!empty($_SERVER[
'HTTP_CLIENT_IP']) && $_SERVER[
'HTTP_CLIENT_IP'] != $remoteip) {
1948 $data[
'ip'] = $_SERVER[
'HTTP_CLIENT_IP'].
' -> '.$data[
'ip'];
1950 } elseif (!empty($_SERVER[
'SERVER_ADDR'])) {
1952 $data[
'ip'] = $_SERVER[
'SERVER_ADDR'];
1953 } elseif (!empty($_SERVER[
'COMPUTERNAME'])) {
1955 $data[
'ip'] = $_SERVER[
'COMPUTERNAME'].(empty($_SERVER[
'USERNAME']) ?
'' :
'@'.$_SERVER[
'USERNAME']);
1956 } elseif (!empty($_SERVER[
'LOGNAME'])) {
1958 $data[
'ip'] =
'???@'.$_SERVER[
'LOGNAME'];
1962 foreach ($conf->loghandlers as $loghandlerinstance) {
1963 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
1966 $loghandlerinstance->export($data, $suffixinfilename);
1972 foreach ($conf->loghandlers as $loghandlerinstance) {
1973 $loghandlerinstance->setIdent($ident);
1994function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled =
'', $morecss =
'classlink button bordertransp', $jsonopen =
'', $backtopagejsfields =
'', $accesskey =
'')
1998 if (strpos($url,
'?') > 0) {
1999 $url .=
'&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name);
2001 $url .=
'?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name);
2006 $backtopagejsfieldsid =
'';
2007 $backtopagejsfieldslabel =
'';
2008 if ($backtopagejsfields) {
2009 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
2010 if (empty($tmpbacktopagejsfields[1])) {
2011 $backtopagejsfields = $name.
":".$backtopagejsfields;
2012 $tmp2backtopagejsfields = explode(
',', $tmpbacktopagejsfields[0]);
2014 $tmp2backtopagejsfields = explode(
',', $tmpbacktopagejsfields[1]);
2016 $backtopagejsfieldsid = empty($tmp2backtopagejsfields[0]) ?
'' : $tmp2backtopagejsfields[0];
2017 $backtopagejsfieldslabel = empty($tmp2backtopagejsfields[1]) ?
'' : $tmp2backtopagejsfields[1];
2018 $url .=
'&backtopagejsfields='.urlencode($backtopagejsfields);
2022 $out .=
'<!-- a link for button to open url into a dialog popup with backtopagejsfields = '.$backtopagejsfields.
' -->';
2023 $out .=
'<a '.($accesskey ?
' accesskey="'.$accesskey.
'"' :
'').
' class="cursorpointer reposition button_'.$name.($morecss ?
' '.$morecss :
'').
'"'.$disabled.
' title="'.
dol_escape_htmltag($label).
'"';
2024 if (empty($conf->use_javascript_ajax)) {
2025 $out .=
' href="'.DOL_URL_ROOT.$url.
'" target="_blank"';
2026 } elseif ($jsonopen) {
2027 $out .=
' href="#" onclick="'.$jsonopen.
'"';
2029 $out .=
' href="#"';
2031 $out .=
'>'.$buttonstring.
'</a>';
2033 if (!empty($conf->use_javascript_ajax)) {
2035 $out .=
'<!-- code to open popup and variables to retreive returned variables -->';
2036 $out .=
'<div id="idfordialog'.$name.
'" class="hidden">div for dialog</div>';
2037 $out .=
'<div id="varforreturndialogid'.$name.
'" class="hidden">div for returned id</div>';
2038 $out .=
'<div id="varforreturndialoglabel'.$name.
'" class="hidden">div for returned label</div>';
2039 $out .=
'<!-- Add js code to open dialog popup on dialog -->';
2040 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">
2041 jQuery(document).ready(function () {
2042 jQuery(".button_'.$name.
'").click(function () {
2043 console.log(\'Open popup with jQuery(...).dialog() on URL '.
dol_escape_js(DOL_URL_ROOT.$url).
'\');
2044 var $tmpdialog = $(\
'#idfordialog'.$name.
'\');
2045 $tmpdialog.html(\
'<iframe class="iframedialog" id="iframedialog'.$name.
'" style="border: 0px;" src="'.DOL_URL_ROOT.$url.
'" width="100%" height="98%"></iframe>\');
2049 height: (window.innerHeight - 150),
2052 open:
function (event, ui) {
2053 console.log(
"open popup name='.$name.', backtopagejsfields='.$backtopagejsfields.'");
2055 close:
function (event, ui) {
2056 var returnedid = jQuery(
"#varforreturndialogid'.$name.'").text();
2057 var returnedlabel = jQuery(
"#varforreturndialoglabel'.$name.'").text();
2058 console.log(
"popup has been closed. returnedid (js var defined into parent page)="+returnedid+
" returnedlabel="+returnedlabel);
2059 if (returnedid !=
"" && returnedid !=
"div for returned id") {
2060 jQuery(
"#'.(empty($backtopagejsfieldsid) ? "none
" : $backtopagejsfieldsid).'").val(returnedid);
2062 if (returnedlabel !=
"" && returnedlabel !=
"div for returned label") {
2063 jQuery(
"#'.(empty($backtopagejsfieldslabel) ? "none
" : $backtopagejsfieldslabel).'").val(returnedlabel);
2068 $tmpdialog.dialog(\
'open\');
2093function dol_fiche_head($links = array(), $active =
'0', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
2095 print
dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow, $moretabssuffix);
2114function dol_get_fiche_head($links = array(), $active =
'', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'', $dragdropfile = 0)
2116 global $conf, $langs, $hookmanager;
2120 if (!empty($conf->dol_optimize_smallscreen)) {
2124 $out =
"\n".
'<!-- dol_fiche_head - dol_get_fiche_head -->';
2126 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2127 $out .=
'<div class="tabs'.($picto ?
'' :
' nopaddingleft').
'" data-role="controlgroup" data-type="horizontal">'.
"\n";
2131 if ($morehtmlright) {
2132 $out .=
'<div class="inline-block floatright tabsElem">'.$morehtmlright.
'</div>';
2136 if (!empty($title) && $showtitle && !
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER')) {
2138 $out .=
'<a class="tabTitle">';
2140 $noprefix = $pictoisfullpath;
2141 if (strpos($picto,
'fontawesome_') !==
false) {
2144 $out .=
img_picto($title, ($noprefix ?
'' :
'object_').$picto,
'', $pictoisfullpath, 0, 0,
'',
'imgTabTitle').
' ';
2146 $out .=
'<span class="tabTitleText">'.dol_escape_htmltag(
dol_trunc($title, $limittitle)).
'</span>';
2154 if (is_array($links) && !empty($links)) {
2155 $keys = array_keys($links);
2157 $maxkey = max($keys);
2163 if (empty($limittoshow)) {
2164 $limittoshow = (!
getDolGlobalString(
'MAIN_MAXTABS_IN_CARD') ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD);
2166 if (!empty($conf->dol_optimize_smallscreen)) {
2174 for ($i = 0; $i <= $maxkey; $i++) {
2175 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2177 if ($i >= $limittoshow) {
2183 for ($i = 0; $i <= $maxkey; $i++) {
2184 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2190 if ($i < $limittoshow || $isactive) {
2192 $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])).
' -->';
2194 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2195 if (!empty($links[$i][0])) {
2196 $out .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2198 $out .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2200 } elseif (!empty($links[$i][1])) {
2202 $out .=
'<div class="tab tab'.($isactive ?
'active' :
'unactive').
'" style="margin: 0 !important">';
2203 if (!empty($links[$i][0])) {
2204 $titletoshow = preg_replace(
'/<.*$/',
'', $links[$i][1]);
2205 $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).
'">';
2207 $out .= $links[$i][1];
2208 if (!empty($links[$i][0])) {
2209 $out .=
'</a>'.
"\n";
2211 $out .= empty($links[$i][4]) ?
'' : $links[$i][4];
2220 $outmore .=
'<div class="popuptabset wordwrap">';
2222 $outmore .=
'<div class="popuptab wordwrap" style="display:inherit;">';
2223 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2224 if (!empty($links[$i][0])) {
2225 $outmore .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2227 $outmore .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2229 } elseif (!empty($links[$i][1])) {
2230 $outmore .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="wordwrap inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
2231 $outmore .= preg_replace(
'/([a-z])\|([a-z])/i',
'\\1 | \\2', $links[$i][1]);
2232 $outmore .=
'</a>'.
"\n";
2234 $outmore .=
'</div>';
2241 $outmore .=
'</div>';
2245 $left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
2246 $right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
2247 $widthofpopup = 200;
2249 $tabsname = $moretabssuffix;
2250 if (empty($tabsname)) {
2251 $tabsname = str_replace(
"@",
"", $picto);
2253 $out .=
'<div id="moretabs'.$tabsname.
'" class="inline-block tabsElem valignmiddle">';
2254 $out .=
'<div class="tab valignmiddle"><a href="#" class="tab moretab inline-block tabunactive valignmiddle"><span class="hideonsmartphone">'.$langs->trans(
"More").
'</span>... ('.$nbintab.
')</a></div>';
2255 $out .=
'<div id="moretabsList'.$tabsname.
'" style="width: '.$widthofpopup.
'px; position: absolute; '.$left.
': -999em; text-align: '.$left.
'; margin:0px; padding:2px; z-index:10;">';
2258 $out .=
'<div></div>';
2261 $out .=
'<script nonce="'.getNonce().
'">';
2262 $out .=
"$('#moretabs".$tabsname.
"').mouseenter( function() {
2263 var x = this.offsetLeft, y = this.offsetTop;
2264 console.log('mouseenter ".$left.
" x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
2265 if ((window.innerWidth - x) < ".($widthofpopup + 10).
") {
2266 $('#moretabsList".$tabsname.
"').css('".$right.
"','8px');
2268 $('#moretabsList".$tabsname.
"').css('".$left.
"','auto');
2271 $out .=
"$('#moretabs".$tabsname.
"').mouseleave( function() { console.log('mouseleave ".$left.
"'); $('#moretabsList".$tabsname.
"').css('".$left.
"','-999em');});";
2272 $out .=
"</script>";
2275 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2279 if (!$notab || $notab == -1 || $notab == -2 || $notab == -3) {
2280 $out .=
"\n".
'<div id="dragDropAreaTabBar" class="tabBar'.($notab == -1 ?
'' : ($notab == -2 ?
' tabBarNoTop' : (($notab == -3 ?
' noborderbottom' :
'').
' tabBarWithBottom'))).
'">'.
"\n";
2282 if (!empty($dragdropfile)) {
2283 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2286 $parameters = array(
'tabname' => $active,
'out' => $out);
2287 $reshook = $hookmanager->executeHooks(
'printTabsHead', $parameters);
2289 $out = $hookmanager->resPrint;
2315 if (!$notab || $notab == -1) {
2316 return "\n</div>\n";
2341function dol_banner_tab($object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $onlybanner = 0, $morehtmlright =
'')
2343 global $conf, $form, $user, $langs, $hookmanager, $action;
2347 $maxvisiblephotos = 1;
2349 $entity = (empty($object->entity) ? $conf->entity : $object->entity);
2350 $showbarcode = empty($conf->barcode->enabled) ? 0 : (empty($object->barcode) ? 0 : 1);
2351 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2354 $modulepart =
'unknown';
2356 if ($object->element ==
'societe' || $object->element ==
'contact' || $object->element ==
'product' || $object->element ==
'ticket') {
2357 $modulepart = $object->element;
2358 } elseif ($object->element ==
'member') {
2359 $modulepart =
'memberphoto';
2360 } elseif ($object->element ==
'user') {
2361 $modulepart =
'userphoto';
2364 if (class_exists(
"Imagick")) {
2365 if ($object->element ==
'expensereport' || $object->element ==
'propal' || $object->element ==
'commande' || $object->element ==
'facture' || $object->element ==
'supplier_proposal') {
2366 $modulepart = $object->element;
2367 } elseif ($object->element ==
'fichinter') {
2368 $modulepart =
'ficheinter';
2369 } elseif ($object->element ==
'contrat') {
2370 $modulepart =
'contract';
2371 } elseif ($object->element ==
'order_supplier') {
2372 $modulepart =
'supplier_order';
2373 } elseif ($object->element ==
'invoice_supplier') {
2374 $modulepart =
'supplier_invoice';
2378 if ($object->element ==
'product') {
2380 $cssclass =
'photowithmargin photoref';
2381 $showimage = $object->is_photo_available($conf->product->multidir_output[$entity]);
2382 $maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5);
2383 if ($conf->browser->layout ==
'phone') {
2384 $maxvisiblephotos = 1;
2387 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos(
'product', $conf->product->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, 0, $width, 0,
'').
'</div>';
2391 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2393 $nophoto =
'/public/theme/common/nophoto.png';
2394 $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>';
2397 } elseif ($object->element ==
'ticket') {
2399 $cssclass =
'photoref';
2400 $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity].
'/'.$object->ref);
2401 $maxvisiblephotos = (isset($conf->global->TICKET_MAX_VISIBLE_PHOTO) ? $conf->global->TICKET_MAX_VISIBLE_PHOTO : 2);
2402 if ($conf->browser->layout ==
'phone') {
2403 $maxvisiblephotos = 1;
2407 $showphoto = $object->show_photos(
'ticket', $conf->ticket->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0);
2408 if ($object->nbphoto > 0) {
2409 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$showphoto.
'</div>';
2417 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2419 $nophoto =
img_picto(
'No photo',
'object_ticket');
2420 $morehtmlleft .=
'<!-- No photo to show -->';
2421 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2422 $morehtmlleft .= $nophoto;
2423 $morehtmlleft .=
'</div></div>';
2428 if ($modulepart !=
'unknown') {
2431 if (in_array($modulepart, array(
'propal',
'commande',
'facture',
'ficheinter',
'contract',
'supplier_order',
'supplier_proposal',
'supplier_invoice',
'expensereport')) && class_exists(
"Imagick")) {
2433 $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]).
"/";
2434 if (in_array($modulepart, array(
'invoice_supplier',
'supplier_invoice'))) {
2435 $subdir =
get_exdir($object->id, 2, 0, 1, $object, $modulepart);
2436 $subdir .= ((!empty($subdir) && !preg_match(
'/\/$/', $subdir)) ?
'/' :
'').$objectref;
2438 $subdir =
get_exdir($object->id, 0, 0, 1, $object, $modulepart);
2440 if (empty($subdir)) {
2441 $subdir =
'errorgettingsubdirofobject';
2444 $filepath = $dir_output.$subdir.
"/";
2446 $filepdf = $filepath.$objectref.
".pdf";
2447 $relativepath = $subdir.
'/'.$objectref.
'.pdf';
2450 $fileimage = $filepdf.
'_preview.png';
2451 $relativepathimage = $relativepath.
'_preview.png';
2453 $pdfexists = file_exists($filepdf);
2458 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2460 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2469 if ($pdfexists && !$error) {
2470 $heightforphotref = 80;
2471 if (!empty($conf->dol_optimize_smallscreen)) {
2472 $heightforphotref = 60;
2475 if (file_exists($fileimage)) {
2476 $phototoshow =
'<div class="photoref">';
2477 $phototoshow .=
'<img height="'.$heightforphotref.
'" class="photo photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2478 $phototoshow .=
'</div>';
2481 } elseif (!$phototoshow) {
2482 $phototoshow .= $form->showphoto($modulepart, $object, 0, 0, 0,
'photowithmargin photoref',
'small', 1, 0, $maxvisiblephotos);
2486 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
2487 $morehtmlleft .= $phototoshow;
2488 $morehtmlleft .=
'</div>';
2492 if (empty($phototoshow)) {
2493 if ($object->element ==
'action') {
2495 $cssclass =
'photorefcenter';
2496 $nophoto =
img_picto(
'No photo',
'title_agenda');
2499 $cssclass =
'photorefcenter';
2500 $picto = $object->picto;
2501 $prefix =
'object_';
2502 if ($object->element ==
'project' && !$object->public) {
2505 if (strpos($picto,
'fontawesome_') !==
false) {
2508 $nophoto =
img_picto(
'No photo', $prefix.$picto);
2510 $morehtmlleft .=
'<!-- No photo to show -->';
2511 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2512 $morehtmlleft .= $nophoto;
2513 $morehtmlleft .=
'</div></div>';
2520 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object, 100,
'photoref valignmiddle').
'</div>';
2523 if ($object->element ==
'societe') {
2524 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'societe',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
2525 $morehtmlstatus .=
ajax_object_onoff($object,
'status',
'status',
'InActivity',
'ActivityCeased');
2527 $morehtmlstatus .= $object->getLibStatut(6);
2529 } elseif ($object->element ==
'product') {
2531 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
2532 $morehtmlstatus .=
ajax_object_onoff($object,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
2534 $morehtmlstatus .=
'<span class="statusrefsell">'.$object->getLibStatut(6, 0).
'</span>';
2536 $morehtmlstatus .=
' ';
2538 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
2539 $morehtmlstatus .=
ajax_object_onoff($object,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
2541 $morehtmlstatus .=
'<span class="statusrefbuy">'.$object->getLibStatut(6, 1).
'</span>';
2543 } elseif (in_array($object->element, array(
'salary'))) {
2544 $tmptxt = $object->getLibStatut(6, $object->alreadypaid);
2545 if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
2546 $tmptxt = $object->getLibStatut(5, $object->alreadypaid);
2548 $morehtmlstatus .= $tmptxt;
2549 } elseif (in_array($object->element, array(
'facture',
'invoice',
'invoice_supplier'))) {
2550 $totalallpayments = $object->getSommePaiement(0);
2551 $totalallpayments += $object->getSumCreditNotesUsed(0);
2552 $totalallpayments += $object->getSumDepositsUsed(0);
2553 $tmptxt = $object->getLibStatut(6, $totalallpayments);
2554 if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
2555 $tmptxt = $object->getLibStatut(5, $totalallpayments);
2557 $morehtmlstatus .= $tmptxt;
2558 } elseif (in_array($object->element, array(
'chargesociales',
'loan',
'tva'))) {
2559 $tmptxt = $object->getLibStatut(6, $object->totalpaid);
2560 if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
2561 $tmptxt = $object->getLibStatut(5, $object->totalpaid);
2563 $morehtmlstatus .= $tmptxt;
2564 } elseif ($object->element ==
'contrat' || $object->element ==
'contract') {
2565 if ($object->statut == 0) {
2566 $morehtmlstatus .= $object->getLibStatut(5);
2568 $morehtmlstatus .= $object->getLibStatut(4);
2570 } elseif ($object->element ==
'facturerec') {
2571 if ($object->frequency == 0) {
2572 $morehtmlstatus .= $object->getLibStatut(2);
2574 $morehtmlstatus .= $object->getLibStatut(5);
2576 } elseif ($object->element ==
'project_task') {
2577 $object->fk_statut = 1;
2578 if ($object->progress > 0) {
2579 $object->fk_statut = 2;
2581 if ($object->progress >= 100) {
2582 $object->fk_statut = 3;
2584 $tmptxt = $object->getLibStatut(5);
2585 $morehtmlstatus .= $tmptxt;
2586 } elseif (method_exists($object,
'getLibStatut')) {
2587 $tmptxt = $object->getLibStatut(6);
2588 if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
2589 $tmptxt = $object->getLibStatut(5);
2591 $morehtmlstatus .= $tmptxt;
2595 if (isModEnabled(
'accounting') && in_array($object->element, array(
'bank',
'paiementcharge',
'facture',
'invoice',
'invoice_supplier',
'expensereport',
'payment_various'))) {
2597 if (method_exists($object,
'getVentilExportCompta')) {
2598 $accounted = $object->getVentilExportCompta();
2599 $langs->load(
"accountancy");
2600 $morehtmlstatus .=
'</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? $langs->trans(
"Accounted") : $langs->trans(
"NotYetAccounted")).
'</span>';
2605 if (!empty($object->name_alias)) {
2606 $morehtmlref .=
'<div class="refidno opacitymedium">'.dol_escape_htmltag($object->name_alias).
'</div>';
2610 if (in_array($object->element, array(
'product',
'bank_account',
'project_task'))) {
2611 if (!empty($object->label)) {
2612 $morehtmlref .=
'<div class="refidno opacitymedium">'.$object->label.
'</div>';
2617 if (method_exists($object,
'getBannerAddress') && !in_array($object->element, array(
'product',
'bookmark',
'ecm_directories',
'ecm_files'))) {
2618 $moreaddress = $object->getBannerAddress(
'refaddress', $object);
2620 $morehtmlref .=
'<div class="refidno refaddress">';
2621 $morehtmlref .= $moreaddress;
2622 $morehtmlref .=
'</div>';
2625 if (
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') && (
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') ==
'1' || preg_match(
'/'.preg_quote($object->element,
'/').
'/i', $conf->global->MAIN_SHOW_TECHNICAL_ID)) && !empty($object->id)) {
2626 $morehtmlref .=
'<div style="clear: both;"></div>';
2627 $morehtmlref .=
'<div class="refidno opacitymedium">';
2628 $morehtmlref .= $langs->trans(
"TechnicalID").
': '.((int) $object->id);
2629 $morehtmlref .=
'</div>';
2632 $parameters=array(
'morehtmlref'=>$morehtmlref);
2633 $reshook = $hookmanager->executeHooks(
'formDolBanner', $parameters, $object, $action);
2636 } elseif (empty($reshook)) {
2637 $morehtmlref .= $hookmanager->resPrint;
2638 } elseif ($reshook > 0) {
2639 $morehtmlref = $hookmanager->resPrint;
2642 print
'<div class="'.($onlybanner ?
'arearefnobottom ' :
'arearef ').
'heightref valignmiddle centpercent">';
2643 print $form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
2645 print
'<div class="underrefbanner clearboth"></div>';
2661 if ($fieldrequired) {
2662 $ret .=
'<span class="fieldrequired">';
2664 $ret .=
'<label for="'.$fieldkey.
'">';
2665 $ret .= $langs->trans($langkey);
2667 if ($fieldrequired) {
2683 $ret =
' '.$bc[$var];
2685 $ret = preg_replace(
'/class=\"/',
'class="'.$moreclass.
' ', $ret);
2703function dol_format_address($object, $withcountry = 0, $sep =
"\n", $outputlangs =
'', $mode = 0, $extralangcode =
'')
2705 global $conf, $langs, $hookmanager;
2708 $countriesusingstate = array(
'AU',
'CA',
'US',
'IN',
'GB',
'ES',
'UK',
'TR',
'CN');
2713 $ret .= ($extralangcode ? $object->array_languages[
'address'][$extralangcode] : (empty($object->address) ?
'' : preg_replace(
'/(\r\n|\r|\n)+/', $sep, $object->address)));
2716 if (isset($object->country_code) && in_array($object->country_code, array(
'AU',
'CA',
'US',
'CN')) ||
getDolGlobalString(
'MAIN_FORCE_STATE_INTO_ADDRESS')) {
2718 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2719 $ret .= (($ret && $town) ? $sep :
'').$town;
2721 if (!empty($object->state)) {
2722 $ret .= ($ret ? ($town ?
", " : $sep) :
'').$object->state;
2724 if (!empty($object->zip)) {
2725 $ret .= ($ret ? (($town || $object->state) ?
", " : $sep) :
'').$object->zip;
2727 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'GB',
'UK'))) {
2729 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2730 $ret .= ($ret ? $sep :
'').$town;
2731 if (!empty($object->state)) {
2732 $ret .= ($ret ?
", " :
'').$object->state;
2734 if (!empty($object->zip)) {
2735 $ret .= ($ret ? $sep :
'').$object->zip;
2737 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'ES',
'TR'))) {
2739 $ret .= ($ret ? $sep :
'').$object->zip;
2740 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2741 $ret .= ($town ? (($object->zip ?
' ' :
'').$town) :
'');
2742 if (!empty($object->state)) {
2743 $ret .= $sep.$object->state;
2745 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'JP'))) {
2748 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2749 $ret .= ($ret ? $sep :
'').($object->state ? $object->state.
', ' :
'').$town.($object->zip ?
' ' :
'').$object->zip;
2750 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'IT'))) {
2752 $ret .= ($ret ? $sep :
'').$object->zip;
2753 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2754 $ret .= ($town ? (($object->zip ?
' ' :
'').$town) :
'');
2755 $ret .= (empty($object->state_code) ?
'' : (
' '.$object->state_code));
2758 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2759 $ret .= !empty($object->zip) ? (($ret ? $sep :
'').$object->zip) :
'';
2760 $ret .= ($town ? (($object->zip ?
' ' : ($ret ? $sep :
'')).$town) :
'');
2761 if (!empty($object->state) && in_array($object->country_code, $countriesusingstate)) {
2762 $ret .= ($ret ?
", " :
'').$object->state;
2766 if (!is_object($outputlangs)) {
2767 $outputlangs = $langs;
2770 $langs->load(
"dict");
2771 $ret .= (empty($object->country_code) ?
'' : ($ret ? $sep :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$object->country_code)));
2774 $parameters = array(
'withcountry' => $withcountry,
'sep' => $sep,
'outputlangs' => $outputlangs,
'mode' => $mode,
'extralangcode' => $extralangcode);
2775 $reshook = $hookmanager->executeHooks(
'formatAddress', $parameters, $object);
2779 $ret .= $hookmanager->resPrint;
2797 if ((abs($ts) <= 0x7FFFFFFF)) {
2798 return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts);
2800 return 'Error date into a not supported range';
2825function dol_print_date($time, $format =
'', $tzoutput =
'auto', $outputlangs =
'', $encodetooutput =
false)
2827 global $conf, $langs;
2834 if ($tzoutput ===
'auto') {
2835 $tzoutput = (empty($conf) ?
'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey :
'tzserver'));
2840 $offsettz = $offsetdst = 0;
2843 if (is_string($tzoutput)) {
2844 if ($tzoutput ==
'tzserver') {
2846 $offsettzstring = @date_default_timezone_get();
2849 } elseif ($tzoutput ==
'tzuser' || $tzoutput ==
'tzuserrel') {
2851 $offsettzstring = (empty($_SESSION[
'dol_tz_string']) ?
'UTC' : $_SESSION[
'dol_tz_string']);
2853 if (class_exists(
'DateTimeZone')) {
2854 $user_date_tz =
new DateTimeZone($offsettzstring);
2855 $user_dt =
new DateTime();
2856 $user_dt->setTimezone($user_date_tz);
2857 $user_dt->setTimestamp($tzoutput ==
'tzuser' ?
dol_now() : (int) $time);
2858 $offsettz = $user_dt->getOffset();
2860 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
2861 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
2866 if (!is_object($outputlangs)) {
2867 $outputlangs = $langs;
2870 $format =
'daytextshort';
2875 $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array(
'day',
'dayhour',
'dayhoursec'))) ? 1 : 0;
2876 $format = preg_replace(
'/inputnoreduce/',
'', $format);
2877 $formatwithoutreduce = preg_replace(
'/reduceformat/',
'', $format);
2878 if ($formatwithoutreduce != $format) {
2879 $format = $formatwithoutreduce;
2885 if ($format ==
'day') {
2886 $format = ($outputlangs->trans(
"FormatDateShort") !=
"FormatDateShort" ? $outputlangs->trans(
"FormatDateShort") : $conf->format_date_short);
2887 } elseif ($format ==
'hour') {
2888 $format = ($outputlangs->trans(
"FormatHourShort") !=
"FormatHourShort" ? $outputlangs->trans(
"FormatHourShort") : $conf->format_hour_short);
2889 } elseif ($format ==
'hourduration') {
2890 $format = ($outputlangs->trans(
"FormatHourShortDuration") !=
"FormatHourShortDuration" ? $outputlangs->trans(
"FormatHourShortDuration") : $conf->format_hour_short_duration);
2891 } elseif ($format ==
'daytext') {
2892 $format = ($outputlangs->trans(
"FormatDateText") !=
"FormatDateText" ? $outputlangs->trans(
"FormatDateText") : $conf->format_date_text);
2893 } elseif ($format ==
'daytextshort') {
2894 $format = ($outputlangs->trans(
"FormatDateTextShort") !=
"FormatDateTextShort" ? $outputlangs->trans(
"FormatDateTextShort") : $conf->format_date_text_short);
2895 } elseif ($format ==
'dayhour') {
2896 $format = ($outputlangs->trans(
"FormatDateHourShort") !=
"FormatDateHourShort" ? $outputlangs->trans(
"FormatDateHourShort") : $conf->format_date_hour_short);
2897 } elseif ($format ==
'dayhoursec') {
2898 $format = ($outputlangs->trans(
"FormatDateHourSecShort") !=
"FormatDateHourSecShort" ? $outputlangs->trans(
"FormatDateHourSecShort") : $conf->format_date_hour_sec_short);
2899 } elseif ($format ==
'dayhourtext') {
2900 $format = ($outputlangs->trans(
"FormatDateHourText") !=
"FormatDateHourText" ? $outputlangs->trans(
"FormatDateHourText") : $conf->format_date_hour_text);
2901 } elseif ($format ==
'dayhourtextshort') {
2902 $format = ($outputlangs->trans(
"FormatDateHourTextShort") !=
"FormatDateHourTextShort" ? $outputlangs->trans(
"FormatDateHourTextShort") : $conf->format_date_hour_text_short);
2903 } elseif ($format ==
'dayhourlog') {
2905 $format =
'%Y%m%d%H%M%S';
2906 } elseif ($format ==
'dayhourlogsmall') {
2908 $format =
'%y%m%d%H%M';
2909 } elseif ($format ==
'dayhourldap') {
2910 $format =
'%Y%m%d%H%M%SZ';
2911 } elseif ($format ==
'dayhourxcard') {
2912 $format =
'%Y%m%dT%H%M%SZ';
2913 } elseif ($format ==
'dayxcard') {
2915 } elseif ($format ==
'dayrfc') {
2916 $format =
'%Y-%m-%d';
2917 } elseif ($format ==
'dayhourrfc') {
2918 $format =
'%Y-%m-%dT%H:%M:%SZ';
2919 } elseif ($format ==
'standard') {
2920 $format =
'%Y-%m-%d %H:%M:%S';
2923 if ($reduceformat) {
2924 $format = str_replace(
'%Y',
'%y', $format);
2925 $format = str_replace(
'yyyy',
'yy', $format);
2929 if (preg_match(
'/%b/i', $format)) {
2931 $format = str_replace(
'%b',
'__b__', $format);
2932 $format = str_replace(
'%B',
'__B__', $format);
2934 if (preg_match(
'/%a/i', $format)) {
2936 $format = str_replace(
'%a',
'__a__', $format);
2937 $format = str_replace(
'%A',
'__A__', $format);
2942 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', $time, $reg)) {
2943 dol_print_error(
'',
"Functions.lib::dol_print_date function called with a bad value from page ".(empty($_SERVER[
"PHP_SELF"]) ?
'unknown' : $_SERVER[
"PHP_SELF"]));
2945 } elseif (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)) {
2947 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);
2950 $syear = (!empty($reg[1]) ? $reg[1] :
'');
2951 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
2952 $sday = (!empty($reg[3]) ? $reg[3] :
'');
2953 $shour = (!empty($reg[4]) ? $reg[4] :
'');
2954 $smin = (!empty($reg[5]) ? $reg[5] :
'');
2955 $ssec = (!empty($reg[6]) ? $reg[6] :
'');
2957 $time =
dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear,
true);
2960 $tzo =
new DateTimeZone(
'UTC');
2962 $tzo =
new DateTimeZone(date_default_timezone_get());
2964 $dtts =
new DateTime();
2965 $dtts->setTimestamp($time);
2966 $dtts->setTimezone($tzo);
2967 $newformat = str_replace(
2968 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2969 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2972 $ret = $dtts->format($newformat);
2974 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2975 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2980 if ($time < 100000000000) {
2981 $timetouse = $time + $offsettz + $offsetdst;
2984 $tzo =
new DateTimeZone(
'UTC');
2986 $tzo =
new DateTimeZone(date_default_timezone_get());
2988 $dtts =
new DateTime();
2989 $dtts->setTimestamp($timetouse);
2990 $dtts->setTimezone($tzo);
2991 $newformat = str_replace(
2992 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'%w',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2993 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'w',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2996 $ret = $dtts->format($newformat);
2998 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2999 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3004 $ret =
'Bad value '.$time.
' for date';
3008 if (preg_match(
'/__b__/i', $format)) {
3009 $timetouse = $time + $offsettz + $offsetdst;
3012 $tzo =
new DateTimeZone(
'UTC');
3014 $tzo =
new DateTimeZone(date_default_timezone_get());
3016 $dtts =
new DateTime();
3017 $dtts->setTimestamp($timetouse);
3018 $dtts->setTimezone($tzo);
3019 $month = $dtts->format(
"m");
3020 $month = sprintf(
"%02d", $month);
3021 if ($encodetooutput) {
3022 $monthtext = $outputlangs->transnoentities(
'Month'.$month);
3023 $monthtextshort = $outputlangs->transnoentities(
'MonthShort'.$month);
3025 $monthtext = $outputlangs->transnoentitiesnoconv(
'Month'.$month);
3026 $monthtextshort = $outputlangs->transnoentitiesnoconv(
'MonthShort'.$month);
3029 $ret = str_replace(
'__b__', $monthtextshort, $ret);
3030 $ret = str_replace(
'__B__', $monthtext, $ret);
3034 if (preg_match(
'/__a__/i', $format)) {
3036 $timetouse = $time + $offsettz + $offsetdst;
3039 $tzo =
new DateTimeZone(
'UTC');
3041 $tzo =
new DateTimeZone(date_default_timezone_get());
3043 $dtts =
new DateTime();
3044 $dtts->setTimestamp($timetouse);
3045 $dtts->setTimezone($tzo);
3046 $w = $dtts->format(
"w");
3047 $dayweek = $outputlangs->transnoentitiesnoconv(
'Day'.$w);
3049 $ret = str_replace(
'__A__', $dayweek, $ret);
3050 $ret = str_replace(
'__a__',
dol_substr($dayweek, 0, 3), $ret);
3079 if ($timestamp ===
'') {
3083 $datetimeobj =
new DateTime();
3084 $datetimeobj->setTimestamp($timestamp);
3085 if ($forcetimezone) {
3086 $datetimeobj->setTimezone(
new DateTimeZone($forcetimezone ==
'gmt' ?
'UTC' : $forcetimezone));
3089 'year'=>((
int) date_format($datetimeobj,
'Y')),
3090 'mon'=>((
int) date_format($datetimeobj,
'm')),
3091 'mday'=>((
int) date_format($datetimeobj,
'd')),
3092 'wday'=>((
int) date_format($datetimeobj,
'w')),
3093 'yday'=>((
int) date_format($datetimeobj,
'z')),
3094 'hours'=>((
int) date_format($datetimeobj,
'H')),
3095 'minutes'=>((
int) date_format($datetimeobj,
'i')),
3096 'seconds'=>((
int) date_format($datetimeobj,
's')),
3124function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm =
'auto', $check = 1)
3129 if ($gm ===
'auto') {
3130 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
3135 if ($hour == -1 || empty($hour)) {
3138 if ($minute == -1 || empty($minute)) {
3141 if ($second == -1 || empty($second)) {
3147 if (!$month || !$day) {
3156 if ($hour < 0 || $hour > 24) {
3159 if ($minute < 0 || $minute > 60) {
3162 if ($second < 0 || $second > 60) {
3167 if (empty($gm) || ($gm ===
'server' || $gm ===
'tzserver')) {
3168 $default_timezone = @date_default_timezone_get();
3169 $localtz =
new DateTimeZone($default_timezone);
3170 } elseif ($gm ===
'user' || $gm ===
'tzuser' || $gm ===
'tzuserrel') {
3172 $default_timezone = (empty($_SESSION[
"dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION[
"dol_tz_string"]);
3174 $localtz =
new DateTimeZone($default_timezone);
3176 dol_syslog(
"Warning dol_tz_string contains an invalid value ".$_SESSION[
"dol_tz_string"], LOG_WARNING);
3177 $default_timezone = @date_default_timezone_get();
3179 } elseif (strrpos($gm,
"tz,") !==
false) {
3180 $timezone = str_replace(
"tz,",
"", $gm);
3182 $localtz =
new DateTimeZone($timezone);
3184 dol_syslog(
"Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
3188 if (empty($localtz)) {
3189 $localtz =
new DateTimeZone(
'UTC');
3193 $dt =
new DateTime(
'now', $localtz);
3194 $dt->setDate((
int) $year, (
int) $month, (
int) $day);
3195 $dt->setTime((
int) $hour, (
int) $minute, (
int) $second);
3196 $date = $dt->getTimestamp();
3216 if ($mode ===
'auto') {
3220 if ($mode ==
'gmt') {
3222 } elseif ($mode ==
'tzserver') {
3223 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
3225 $ret = (int) (
dol_now(
'gmt') + ($tzsecond * 3600));
3231 } elseif ($mode ==
'tzuser' || $mode ==
'tzuserrel') {
3234 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3235 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3236 $ret = (int) (
dol_now(
'gmt') + ($offsettz + $offsetdst));
3253 global $conf, $langs;
3256 if (!empty($conf->dol_optimize_smallscreen)) {
3261 if (empty($shortvalue) || $size < ($level * 10)) {
3263 $textunitshort = $langs->trans(
"b");
3264 $textunitlong = $langs->trans(
"Bytes");
3266 $ret = round($size / $level, 0);
3267 $textunitshort = $langs->trans(
"Kb");
3268 $textunitlong = $langs->trans(
"KiloBytes");
3271 if (empty($shortunit)) {
3272 $ret .=
' '.$textunitlong;
3274 $ret .=
' '.$textunitshort;
3290function dol_print_url($url, $target =
'_blank', $max = 32, $withpicto = 0, $morecss =
'')
3298 $linkstart =
'<a href="';
3299 if (!preg_match(
'/^http/i', $url)) {
3300 $linkstart .=
'http://';
3305 $linkstart .=
' target="'.$target.
'"';
3307 $linkstart .=
' title="'.$langs->trans(
"URL").
': '.$url.
'"';
3311 if (!preg_match(
'/^http/i', $url)) {
3318 if ($morecss ==
'float') {
3319 return '<div class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe',
'class="paddingrightonly"') :
'').$link.
'</div>';
3321 return $linkstart.
'<span class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto(
'',
'globe',
'class="paddingrightonly"') :
'').$link.
'</span>'.$linkend;
3337function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0)
3339 global $user, $langs, $hookmanager;
3350 if (empty($email)) {
3354 if (!empty($addlink)) {
3355 $newemail =
'<a class="paddingrightonly" style="text-overflow: ellipsis;" href="';
3356 if (!preg_match(
'/^mailto:/i', $email)) {
3357 $newemail .=
'mailto:';
3359 $newemail .= $email;
3362 $newemail .= ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'');
3365 $newemail .=
'</a>';
3367 $langs->load(
"errors");
3368 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email),
'',
'paddingrightonly');
3371 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
3373 $linktoaddaction =
'';
3375 $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>';
3377 if ($linktoaddaction) {
3378 $newemail =
'<div>'.$newemail.
' '.$linktoaddaction.
'</div>';
3382 $newemail = ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'').$newemail;
3385 $langs->load(
"errors");
3386 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
3396 $parameters = array(
'cid' => $cid,
'socid' => $socid,
'addlink' => $addlink,
'picto' => $withpicto);
3398 $reshook = $hookmanager->executeHooks(
'printEmail', $parameters, $email);
3402 $rep .= $hookmanager->resPrint;
3417 $socialnetworks = array();
3419 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
3420 $cachekey =
'socialnetworks_' . $conf->entity;
3422 if (!is_null($dataretrieved)) {
3423 $socialnetworks = $dataretrieved;
3425 $sql =
"SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX.
"c_socialnetworks";
3426 $sql .=
" WHERE entity=".$conf->entity;
3427 $resql = $db->query($sql);
3429 while ($obj = $db->fetch_object($resql)) {
3430 $socialnetworks[$obj->code] = array(
3431 'rowid' => $obj->rowid,
3432 'label' => $obj->label,
3434 'icon' => $obj->icon,
3435 'active' => $obj->active,
3442 return $socialnetworks;
3457 global $conf, $user, $langs;
3461 if (empty($value)) {
3465 if (!empty($type)) {
3466 $htmllink =
'<div class="divsocialnetwork inline-block valignmiddle">';
3468 $htmllink .=
'<span class="fab pictofixedwidth '.($dictsocialnetworks[$type][
'icon'] ? $dictsocialnetworks[$type][
'icon'] :
'fa-link').
'"></span>';
3469 if ($type ==
'skype') {
3471 $htmllink .=
' <a href="skype:';
3473 $htmllink .=
'?call" alt="'.$langs->trans(
"Call").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Call").
' '.$value).
'">';
3474 $htmllink .=
'<img src="'.DOL_URL_ROOT.
'/theme/common/skype_callbutton.png" border="0">';
3475 $htmllink .=
'</a><a href="skype:';
3477 $htmllink .=
'?chat" alt="'.$langs->trans(
"Chat").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Chat").
' '.$value).
'">';
3478 $htmllink .=
'<img class="paddingleft" src="'.DOL_URL_ROOT.
'/theme/common/skype_chatbutton.png" border="0">';
3479 $htmllink .=
'</a>';
3480 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
3481 $addlink =
'AC_SKYPE';
3484 $link =
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&backtopage=1&actioncode='.$addlink.
'&contactid='.$cid.
'&socid='.$socid.
'">'.
img_object($langs->trans(
"AddAction"),
"calendar").
'</a>';
3486 $htmllink .= ($link ?
' '.$link :
'');
3489 $networkconstname =
'MAIN_INFO_SOCIETE_'.strtoupper($type).
'_URL';
3492 if (preg_match(
'/^https?:\/\//i', $link)) {
3493 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3495 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3497 } elseif (!empty($dictsocialnetworks[$type][
'url'])) {
3498 $tmpvirginurl = preg_replace(
'/\/?{socialid}/',
'', $dictsocialnetworks[$type][
'url']);
3499 if ($tmpvirginurl) {
3500 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3501 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3503 $tmpvirginurl3 = preg_replace(
'/^https:\/\//i',
'https://www.', $tmpvirginurl);
3504 if ($tmpvirginurl3) {
3505 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3506 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3509 $tmpvirginurl2 = preg_replace(
'/^https?:\/\//i',
'', $tmpvirginurl);
3510 if ($tmpvirginurl2) {
3511 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3512 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3515 $link = str_replace(
'{socialid}', $value, $dictsocialnetworks[$type][
'url']);
3516 if (preg_match(
'/^https?:\/\//i', $link)) {
3517 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3519 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3525 $htmllink .=
'</div>';
3527 $langs->load(
"errors");
3528 $htmllink .=
img_warning($langs->trans(
"ErrorBadSocialNetworkValue", $value));
3546 if (empty($profID) || empty($profIDtype)) {
3549 if (empty($countrycode)) {
3550 $countrycode = $mysoc->country_code;
3552 $newProfID = $profID;
3553 $id = substr($profIDtype, -1);
3555 if (strtoupper($countrycode) ==
'FR') {
3559 if ($id == 1 &&
dol_strlen($newProfID) == 9) {
3561 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3);
3563 if ($id == 2 &&
dol_strlen($newProfID) == 14) {
3565 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3).
' '.substr($newProfID, 9, 5);
3567 if ($id == 3 &&
dol_strlen($newProfID) == 5) {
3569 $newProfID = substr($newProfID, 0, 2).
'.'.substr($newProfID, 2, 3);
3571 if ($profIDtype ===
'VAT' &&
dol_strlen($newProfID) == 13) {
3573 $newProfID = substr($newProfID, 0, 4).
' '.substr($newProfID, 4, 3).
' '.substr($newProfID, 7, 3).
' '.substr($newProfID, 10, 3);
3576 if (!empty($addcpButton)) {
3598function dol_print_phone($phone, $countrycode =
'', $cid = 0, $socid = 0, $addlink =
'', $separ =
" ", $withpicto =
'', $titlealt =
'', $adddivfloat = 0)
3600 global $conf, $user, $langs, $mysoc, $hookmanager;
3603 $phone = is_null($phone) ?
'' : preg_replace(
"/[\s.-]/",
"", trim($phone));
3604 if (empty($phone)) {
3608 $separ = $conf->global->MAIN_PHONE_SEPAR;
3610 if (empty($countrycode) && is_object($mysoc)) {
3611 $countrycode = $mysoc->country_code;
3615 if ($conf->dol_optimize_smallscreen) {
3620 if (strtoupper($countrycode) ==
"FR") {
3623 $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);
3625 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
3627 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
3629 $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);
3631 $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);
3633 $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);
3635 } elseif (strtoupper($countrycode) ==
"CA") {
3637 $newphone = ($separ !=
'' ?
'(' :
'').substr($newphone, 0, 3).($separ !=
'' ?
')' :
'').$separ.substr($newphone, 3, 3).($separ !=
'' ?
'-' :
'').substr($newphone, 6, 4);
3639 } elseif (strtoupper($countrycode) ==
"PT") {
3641 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3643 } elseif (strtoupper($countrycode) ==
"SR") {
3645 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
3647 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
3649 } elseif (strtoupper($countrycode) ==
"DE") {
3651 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
3653 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
3655 } elseif (strtoupper($countrycode) ==
"ES") {
3657 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3659 } elseif (strtoupper($countrycode) ==
"BF") {
3661 $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);
3663 } elseif (strtoupper($countrycode) ==
"RO") {
3665 $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);
3667 } elseif (strtoupper($countrycode) ==
"TR") {
3669 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
3671 } elseif (strtoupper($countrycode) ==
"US") {
3673 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
3675 } elseif (strtoupper($countrycode) ==
"MX") {
3677 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
3679 $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);
3681 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
3683 } elseif (strtoupper($countrycode) ==
"ML") {
3685 $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);
3687 } elseif (strtoupper($countrycode) ==
"TH") {
3689 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
3691 $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);
3693 } elseif (strtoupper($countrycode) ==
"MU") {
3696 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
3698 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
3700 } elseif (strtoupper($countrycode) ==
"ZA") {
3702 $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);
3704 } elseif (strtoupper($countrycode) ==
"SY") {
3706 $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);
3708 $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);
3710 } elseif (strtoupper($countrycode) ==
"AE") {
3712 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
3714 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3716 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
3718 } elseif (strtoupper($countrycode) ==
"DZ") {
3720 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3722 } elseif (strtoupper($countrycode) ==
"BE") {
3724 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
3726 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3728 } elseif (strtoupper($countrycode) ==
"PF") {
3730 $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);
3732 } elseif (strtoupper($countrycode) ==
"CO") {
3734 $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);
3736 } elseif (strtoupper($countrycode) ==
"JO") {
3738 $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);
3740 } elseif (strtoupper($countrycode) ==
"JM") {
3742 $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
3744 } elseif (strtoupper($countrycode) ==
"MG") {
3746 $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);
3748 } elseif (strtoupper($countrycode) ==
"GB") {
3750 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3752 } elseif (strtoupper($countrycode) ==
"CH") {
3754 $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);
3756 $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);
3758 } elseif (strtoupper($countrycode) ==
"TN") {
3760 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3762 } elseif (strtoupper($countrycode) ==
"GF") {
3764 $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);
3766 } elseif (strtoupper($countrycode) ==
"GP") {
3768 $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);
3770 } elseif (strtoupper($countrycode) ==
"MQ") {
3772 $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);
3774 } elseif (strtoupper($countrycode) ==
"IT") {
3776 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3778 $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);
3780 } elseif (strtoupper($countrycode) ==
"AU") {
3784 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
3786 } elseif (strtoupper($countrycode) ==
"LU") {
3789 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
3791 $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);
3793 $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);
3795 $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);
3799 $newphoneastart = $newphoneaend =
'';
3800 if (!empty($addlink)) {
3801 if ($addlink ==
'tel' || $conf->browser->layout ==
'phone' || (isModEnabled(
'clicktodial') &&
getDolGlobalString(
'CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS'))) {
3802 $newphoneastart =
'<a href="tel:'.$phone.
'">';
3803 $newphoneaend .=
'</a>';
3804 } elseif (isModEnabled(
'clicktodial') && $addlink ==
'AC_TEL') {
3805 if (empty($user->clicktodial_loaded)) {
3806 $user->fetch_clicktodial();
3810 $urlmask =
getDolGlobalString(
'CLICKTODIAL_URL',
'ErrorClickToDialModuleNotConfigured');
3811 if (!empty($user->clicktodial_url)) {
3812 $urlmask = $user->clicktodial_url;
3815 $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) :
'');
3816 $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) :
'');
3817 $clicktodial_password = (!empty($user->clicktodial_password) ? urlencode($user->clicktodial_password) :
'');
3819 $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
3821 $substitarray = array(
'__PHONEFROM__'=>$clicktodial_poste,
3822 '__PHONETO__'=>urlencode($phone),
3823 '__LOGIN__'=>$clicktodial_login,
3824 '__PASS__'=>$clicktodial_password);
3828 $newphoneastart =
'<a href="'.$url.
'" class="cssforclicktodial">';
3829 $newphoneaend =
'</a>';
3832 $newphoneastart =
'<a href="'.$url.
'"';
3834 $newphoneastart .=
' target="_blank" rel="noopener noreferrer"';
3836 $newphoneastart .=
'>';
3837 $newphoneaend .=
'</a>';
3842 if (isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
3844 $addlinktoagenda =
'';
3845 if ($addlink ==
'AC_FAX') {
3849 $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>';
3851 if ($addlinktoagenda) {
3852 $newphone =
'<span>'.$newphone.
' '.$addlinktoagenda.
'</span>';
3857 if (empty($titlealt)) {
3858 $titlealt = ($withpicto ==
'fax' ? $langs->trans(
"Fax") : $langs->trans(
"Phone"));
3863 $parameters = array(
'countrycode' => $countrycode,
'cid' => $cid,
'socid' => $socid,
'titlealt' => $titlealt,
'picto' => $withpicto);
3864 $reshook = $hookmanager->executeHooks(
'printPhone', $parameters, $phone);
3865 $rep .= $hookmanager->resPrint;
3867 if (empty($reshook)) {
3870 if ($withpicto ==
'fax') {
3871 $picto =
'phoning_fax';
3872 } elseif ($withpicto ==
'phone') {
3874 } elseif ($withpicto ==
'mobile') {
3875 $picto =
'phoning_mobile';
3880 if ($adddivfloat == 1) {
3881 $rep .=
'<div class="nospan float" style="margin-right: 10px">';
3882 } elseif (empty($adddivfloat)) {
3883 $rep .=
'<span style="margin-right: 10px;">';
3886 $rep .= $newphoneastart;
3887 $rep .= ($withpicto ?
img_picto($titlealt,
'object_'.$picto.
'.png') :
'');
3888 if ($separ !=
'hidenum') {
3889 $rep .= ($withpicto ?
' ' :
'').$newphone;
3891 $rep .= $newphoneaend;
3893 if ($adddivfloat == 1) {
3895 } elseif (empty($adddivfloat)) {
3923 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/common/flags/'.$countrycode.
'.png')) {
3924 $ret .=
' '.img_picto($countrycode.
' '.$langs->trans(
"AccordingToGeoIPDatabase"), DOL_URL_ROOT.
'/theme/common/flags/'.$countrycode.
'.png',
'', 1);
3926 $ret .=
' ('.$countrycode.
')';
3946 if (empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
3947 if (empty($_SERVER[
'HTTP_CLIENT_IP']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_CLIENT_IP'])) {
3948 if (empty($_SERVER[
"HTTP_CF_CONNECTING_IP"])) {
3949 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
3951 $ip = $_SERVER[
"HTTP_CF_CONNECTING_IP"];
3954 $ip = $_SERVER[
'HTTP_CLIENT_IP'];
3957 $ip = $_SERVER[
'HTTP_X_FORWARDED_FOR'];
3973 if (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on') {
3975 } 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') {
3993 if (!empty($conf->geoipmaxmind->enabled)) {
3997 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
3998 $geoip =
new DolGeoIP(
'country', $datafile);
4000 $countrycode = $geoip->getCountryCodeFromIP($ip);
4003 return $countrycode;
4015 global $conf, $langs, $user;
4019 if (!empty($conf->geoipmaxmind->enabled)) {
4024 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4025 $geoip =
new DolGeoIP(
'country', $datafile);
4026 $countrycode = $geoip->getCountryCodeFromIP($ip);
4027 $ret = $countrycode;
4046 global $conf, $user, $langs, $hookmanager;
4052 $parameters = array(
'element' => $element,
'id' => $id);
4053 $reshook = $hookmanager->executeHooks(
'printAddress', $parameters, $address);
4054 $out .= $hookmanager->resPrint;
4056 if (empty($reshook)) {
4057 if (empty($charfornl)) {
4058 $out .= nl2br($address);
4060 $out .= preg_replace(
'/[\r\n]+/', $charfornl, $address);
4064 $showgmap = $showomap = 0;
4065 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS')) {
4068 if ($element ==
'contact' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_CONTACTS')) {
4071 if ($element ==
'member' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_MEMBERS')) {
4074 if ($element ==
'user' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_USERS')) {
4077 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS')) {
4080 if ($element ==
'contact' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_CONTACTS')) {
4083 if ($element ==
'member' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_MEMBERS')) {
4086 if ($element ==
'user' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_USERS')) {
4090 $url =
dol_buildpath(
'/google/gmaps.php?mode='.$element.
'&id='.$id, 1);
4091 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4094 $url =
dol_buildpath(
'/openstreetmap/maps.php?mode='.$element.
'&id='.$id, 1);
4095 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4116function isValidEmail($address, $acceptsupervisorkey = 0, $acceptuserkey = 0)
4118 if ($acceptsupervisorkey && $address ==
'__SUPERVISOREMAIL__') {
4121 if ($acceptuserkey && $address ==
'__USER_EMAIL__') {
4124 if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
4141 if (function_exists(
'idn_to_ascii') && function_exists(
'checkdnsrr')) {
4142 if (!checkdnsrr(idn_to_ascii($domain),
'MX')) {
4145 if (function_exists(
'getmxrr')) {
4148 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
4149 if (count($mxhosts) > 1) {
4152 if (count($mxhosts) == 1 && !empty($mxhosts[0])) {
4189 $tmparray = explode(
' ', $s);
4190 foreach ($tmparray as $tmps) {
4207 if (is_null($string)) {
4211 if (function_exists(
'mb_strlen')) {
4212 return mb_strlen($string, $stringencoding);
4214 return strlen($string);
4228function dol_substr($string, $start, $length =
null, $stringencoding =
'', $trunconbytes = 0)
4232 if (empty($stringencoding)) {
4233 $stringencoding = $langs->charset_output;
4237 if (empty($trunconbytes)) {
4238 if (function_exists(
'mb_substr')) {
4239 $ret = mb_substr($string, $start, $length, $stringencoding);
4241 $ret = substr($string, $start, $length);
4244 if (function_exists(
'mb_strcut')) {
4245 $ret = mb_strcut($string, $start, $length, $stringencoding);
4247 $ret = substr($string, $start, $length);
4267function dol_trunc($string, $size = 40, $trunc =
'right', $stringencoding =
'UTF-8', $nodot = 0, $display = 0)
4275 if (empty($stringencoding)) {
4276 $stringencoding =
'UTF-8';
4279 if ($conf->dol_optimize_smallscreen == 1 && $display == 1) {
4280 $size = round($size / 3);
4284 if ($trunc ==
'right') {
4286 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
4288 return dol_substr($newstring, 0, $size, $stringencoding).($nodot ?
'' :
'…');
4293 } elseif ($trunc ==
'middle') {
4295 if (
dol_strlen($newstring, $stringencoding) > 2 &&
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4296 $size1 = round($size / 2);
4297 $size2 = round($size / 2);
4298 return dol_substr($newstring, 0, $size1, $stringencoding).
'…'.
dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
4302 } elseif ($trunc ==
'left') {
4304 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
4306 return '…'.dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
4310 } elseif ($trunc ==
'wrap') {
4312 if (
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4318 return 'BadParam3CallingDolTrunc';
4331 $type2picto = array(
4335 'int'=>
'sort-numeric-down',
4336 'double'=>
'sort-numeric-down',
4337 'price'=>
'currency',
4338 'pricecy'=>
'multicurrency',
4339 'password' =>
'key',
4340 'boolean'=>
'check-square',
4342 'datetime'=>
'calendar',
4348 'sellist' =>
'list',
4349 'radio' =>
'check-circle',
4350 'checkbox' =>
'check-square',
4351 'chkbxlst' =>
'check-square',
4353 'separate'=>
'minus'
4356 if (!empty($type2picto[$key])) {
4357 return img_picto(
'', $type2picto[$key],
'class="pictofixedwidth"');
4360 return img_picto(
'',
'generic',
'class="pictofixedwidth"');
4385function img_picto($titlealt, $picto, $moreatt =
'', $pictoisfullpath =
false, $srconly = 0, $notitle = 0, $alt =
'', $morecss =
'', $marginleftonlyshort = 2)
4387 global $conf, $langs;
4390 $url = DOL_URL_ROOT;
4391 $theme = isset($conf->theme) ? $conf->theme :
null;
4392 $path =
'theme/'.$theme;
4393 if (empty($picto)) {
4398 if ($pictoisfullpath) {
4400 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
4403 $fullpathpicto = $picto;
4405 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4406 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4407 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4410 $pictowithouttext = preg_replace(
'/(\.png|\.gif|\.svg)$/',
'', (is_null($picto) ?
'' : $picto));
4411 $pictowithouttext = str_replace(
'object_',
'', $pictowithouttext);
4412 $pictowithouttext = str_replace(
'_nocolor',
'', $pictowithouttext);
4414 if (strpos($pictowithouttext,
'fontawesome_') === 0 || strpos($pictowithouttext,
'fa-') === 0) {
4416 $pictowithouttext = str_replace(
'fontawesome_',
'', $pictowithouttext);
4417 $pictowithouttext = str_replace(
'fa-',
'', $pictowithouttext);
4420 if ($pictowithouttext ==
'file-o') {
4421 $pictowithouttext =
'file';
4424 $pictowithouttextarray = explode(
'_', $pictowithouttext);
4425 $marginleftonlyshort = 0;
4427 if (!empty($pictowithouttextarray[1])) {
4429 $fakey =
'fa-'.$pictowithouttextarray[0];
4430 $faprefix = empty($pictowithouttextarray[1]) ?
'fas' : $pictowithouttextarray[1];
4431 $facolor = empty($pictowithouttextarray[2]) ?
'' : $pictowithouttextarray[2];
4432 $fasize = empty($pictowithouttextarray[3]) ?
'' : $pictowithouttextarray[3];
4434 $fakey =
'fa-'.$pictowithouttext;
4444 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4445 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4446 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4448 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
4449 $morestyle = $reg[1];
4450 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
4452 $moreatt = trim($moreatt);
4454 $enabledisablehtml =
'<span class="'.$faprefix.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
4455 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
4459 $enabledisablehtml .=
'</span>';
4461 return $enabledisablehtml;
4464 if (empty($srconly) && in_array($pictowithouttext, array(
4465 '1downarrow',
'1uparrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected',
4466 'accountancy',
'accounting_account',
'account',
'accountline',
'action',
'add',
'address',
'angle-double-down',
'angle-double-up',
'asset',
4467 'bank_account',
'barcode',
'bank',
'bell',
'bill',
'billa',
'billr',
'billd',
'birthday-cake',
'bookmark',
'bom',
'briefcase-medical',
'bug',
'building',
4468 'card',
'calendarlist',
'calendar',
'calendarmonth',
'calendarweek',
'calendarday',
'calendarperuser',
'calendarpertype',
4469 'cash-register',
'category',
'chart',
'check',
'clock',
'clone',
'close_title',
'code',
'cog',
'collab',
'company',
'contact',
'country',
'contract',
'conversation',
'cron',
'cross',
'cubes',
4470 'check-circle',
'check-square',
'currency',
'multicurrency',
4471 'chevron-left',
'chevron-right',
'chevron-down',
'chevron-top',
'commercial',
'companies',
4472 'delete',
'dolly',
'dollyrevert',
'donation',
'download',
'dynamicprice',
4473 'edit',
'ellipsis-h',
'email',
'entity',
'envelope',
'eraser',
'establishment',
'expensereport',
'external-link-alt',
'external-link-square-alt',
'eye',
4474 'filter',
'file',
'file-o',
'file-code',
'file-export',
'file-import',
'file-upload',
'autofill',
'folder',
'folder-open',
'folder-plus',
'font',
4475 'gears',
'generate',
'generic',
'globe',
'globe-americas',
'graph',
'grip',
'grip_title',
'group',
4476 'hands-helping',
'help',
'holiday',
4477 'id-card',
'images',
'incoterm',
'info',
'intervention',
'inventory',
'intracommreport',
'jobprofile',
4478 'key',
'knowledgemanagement',
4479 'label',
'language',
'line',
'link',
'list',
'list-alt',
'listlight',
'loan',
'lock',
'lot',
'long-arrow-alt-right',
4480 'margin',
'map-marker-alt',
'member',
'meeting',
'minus',
'money-bill-alt',
'movement',
'mrp',
'note',
'next',
4481 'off',
'on',
'order',
4482 'paiment',
'paragraph',
'play',
'pdf',
'phone',
'phoning',
'phoning_mobile',
'phoning_fax',
'playdisabled',
'previous',
'poll',
'pos',
'printer',
'product',
'propal',
'proposal',
'puce',
4483 'stock',
'resize',
'service',
'stats',
4484 'security',
'setup',
'share-alt',
'sign-out',
'split',
'stripe',
'stripe-s',
'switch_off',
'switch_on',
'switch_on_warning',
'switch_on_red',
'tools',
'unlink',
'uparrow',
'user',
'user-tie',
'vcard',
'wrench',
4485 'github',
'google',
'jabber',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'youtube',
'google-plus-g',
'whatsapp',
4486 'generic',
'home',
'hrm',
'members',
'products',
'invoicing',
4487 'partnership',
'payment',
'payment_vat',
'pencil-ruler',
'pictoconfirm',
'preview',
'project',
'projectpub',
'projecttask',
'question',
'refresh',
'region',
4488 'salary',
'shipment',
'state',
'supplier_invoice',
'supplier_invoicea',
'supplier_invoicer',
'supplier_invoiced',
4489 'technic',
'ticket',
4491 'recent',
'reception',
'recruitmentcandidature',
'recruitmentjobposition',
'replacement',
'resource',
'recurring',
'rss',
4492 'shapes',
'skill',
'square',
'sort-numeric-down',
'stop-circle',
'supplier',
'supplier_proposal',
'supplier_order',
'supplier_invoice',
4493 'tick',
'timespent',
'title_setup',
'title_accountancy',
'title_bank',
'title_hrm',
'title_agenda',
4494 'uncheck',
'url',
'user-cog',
'user-injured',
'user-md',
'vat',
'website',
'workstation',
'webhook',
'world',
'private',
4495 'conferenceorbooth',
'eventorganization',
4496 'stamp',
'signature'
4498 $fakey = $pictowithouttext;
4502 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'))) {
4505 if (in_array($pictowithouttext, array(
'black-tie',
'github',
'google',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'stripe',
'stripe-s',
'youtube',
'google-plus-g',
'whatsapp'))) {
4509 $arrayconvpictotofa = array(
4510 'account'=>
'university',
'accounting_account'=>
'clipboard-list',
'accountline'=>
'receipt',
'accountancy'=>
'search-dollar',
'action'=>
'calendar-alt',
'add'=>
'plus-circle',
'address'=>
'address-book',
'asset'=>
'money-check-alt',
'autofill'=>
'fill',
4511 'bank_account'=>
'university',
4512 'bill'=>
'file-invoice-dollar',
'billa'=>
'file-excel',
'billr'=>
'file-invoice-dollar',
'billd'=>
'file-medical',
4513 'supplier_invoice'=>
'file-invoice-dollar',
'supplier_invoicea'=>
'file-excel',
'supplier_invoicer'=>
'file-invoice-dollar',
'supplier_invoiced'=>
'file-medical',
4515 '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',
4516 'donation'=>
'file-alt',
'dynamicprice'=>
'hand-holding-usd',
4517 'setup'=>
'cog',
'companies'=>
'building',
'products'=>
'cube',
'commercial'=>
'suitcase',
'invoicing'=>
'coins',
4518 'accounting'=>
'search-dollar',
'category'=>
'tag',
'dollyrevert'=>
'dolly',
4519 'file-o'=>
'file',
'generate'=>
'plus-square',
'hrm'=>
'user-tie',
'incoterm'=>
'truck-loading',
4520 'margin'=>
'calculator',
'members'=>
'user-friends',
'ticket'=>
'ticket-alt',
'globe'=>
'external-link-alt',
'lot'=>
'barcode',
4521 'email'=>
'at',
'establishment'=>
'building',
'edit'=>
'pencil-alt',
'entity'=>
'globe',
4522 'graph'=>
'chart-line',
'grip_title'=>
'arrows-alt',
'grip'=>
'arrows-alt',
'help'=>
'question-circle',
4523 'generic'=>
'file',
'holiday'=>
'umbrella-beach',
4524 'info'=>
'info-circle',
'inventory'=>
'boxes',
'intracommreport'=>
'globe-europe',
'jobprofile'=>
'cogs',
4525 'knowledgemanagement'=>
'ticket-alt',
'label'=>
'layer-group',
'line'=>
'bars',
'loan'=>
'money-bill-alt',
4526 'member'=>
'user-alt',
'meeting'=>
'chalkboard-teacher',
'mrp'=>
'cubes',
'next'=>
'arrow-alt-circle-right',
4527 'trip'=>
'wallet',
'expensereport'=>
'wallet',
'group'=>
'users',
'movement'=>
'people-carry',
4528 'sign-out'=>
'sign-out-alt',
4529 'switch_off'=>
'toggle-off',
'switch_on'=>
'toggle-on',
'switch_on_warning'=>
'toggle-on',
'switch_on_red'=>
'toggle-on',
'check'=>
'check',
'bookmark'=>
'star',
4530 'bank'=>
'university',
'close_title'=>
'times',
'delete'=>
'trash',
'filter'=>
'filter',
4531 'list-alt'=>
'list-alt',
'calendarlist'=>
'bars',
'calendar'=>
'calendar-alt',
'calendarmonth'=>
'calendar-alt',
'calendarweek'=>
'calendar-week',
'calendarday'=>
'calendar-day',
'calendarperuser'=>
'table',
4532 'intervention'=>
'ambulance',
'invoice'=>
'file-invoice-dollar',
'order'=>
'file-invoice',
4533 'error'=>
'exclamation-triangle',
'warning'=>
'exclamation-triangle',
4535 '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',
4536 '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',
4537 'recent' =>
'check-square',
'reception'=>
'dolly',
'recruitmentjobposition'=>
'id-card-alt',
'recruitmentcandidature'=>
'id-badge',
4538 'resize'=>
'crop',
'supplier_order'=>
'dol-order_supplier',
'supplier_proposal'=>
'file-signature',
4539 'refresh'=>
'redo',
'region'=>
'map-marked',
'replacement'=>
'exchange-alt',
'resource'=>
'laptop-house',
'recurring'=>
'history',
4540 'service'=>
'concierge-bell',
4541 'skill'=>
'shapes',
'state'=>
'map-marked-alt',
'security'=>
'key',
'salary'=>
'wallet',
'shipment'=>
'dolly',
'stock'=>
'box-open',
'stats' =>
'chart-bar',
'split'=>
'code-branch',
'stripe'=>
'stripe-s',
4542 'supplier'=>
'building',
'technic'=>
'cogs',
4543 'timespent'=>
'clock',
'tick' =>
'check',
'title_setup'=>
'tools',
'title_accountancy'=>
'money-check-alt',
'title_bank'=>
'university',
'title_hrm'=>
'umbrella-beach',
4544 'title_agenda'=>
'calendar-alt',
4545 'uncheck'=>
'times',
'uparrow'=>
'share',
'url'=>
'external-link-alt',
'vat'=>
'money-check-alt',
'vcard'=>
'arrow-alt-circle-down',
4546 'jabber'=>
'comment-o',
4547 'website'=>
'globe-americas',
'workstation'=>
'pallet',
'webhook'=>
'bullseye',
'world'=>
'globe',
'private'=>
'user-lock',
4548 'conferenceorbooth'=>
'chalkboard-teacher',
'eventorganization'=>
'project-diagram'
4550 if ($conf->currency ==
'EUR') {
4551 $arrayconvpictotofa[
'currency'] =
'euro-sign';
4552 $arrayconvpictotofa[
'multicurrency'] =
'dollar-sign';
4554 $arrayconvpictotofa[
'currency'] =
'dollar-sign';
4555 $arrayconvpictotofa[
'multicurrency'] =
'euro-sign';
4557 if ($pictowithouttext ==
'off') {
4558 $fakey =
'fa-square';
4560 } elseif ($pictowithouttext ==
'on') {
4561 $fakey =
'fa-check-square';
4563 } elseif ($pictowithouttext ==
'listlight') {
4564 $fakey =
'fa-download';
4565 $marginleftonlyshort = 1;
4566 } elseif ($pictowithouttext ==
'printer') {
4567 $fakey =
'fa-print';
4569 } elseif ($pictowithouttext ==
'note') {
4570 $fakey =
'fa-sticky-note';
4571 $marginleftonlyshort = 1;
4572 } elseif (in_array($pictowithouttext, array(
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'))) {
4573 $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');
4574 $fakey =
'fa-'.$convertarray[$pictowithouttext];
4575 if (preg_match(
'/selected/', $pictowithouttext)) {
4578 $marginleftonlyshort = 1;
4579 } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) {
4580 $fakey =
'fa-'.$arrayconvpictotofa[$pictowithouttext];
4582 $fakey =
'fa-'.$pictowithouttext;
4585 if (in_array($pictowithouttext, array(
'dollyrevert',
'member',
'members',
'contract',
'group',
'resource',
'shipment'))) {
4586 $morecss .=
' em092';
4588 if (in_array($pictowithouttext, array(
'conferenceorbooth',
'collab',
'eventorganization',
'holiday',
'info',
'project',
'workstation'))) {
4589 $morecss .=
' em088';
4591 if (in_array($pictowithouttext, array(
'asset',
'intervention',
'payment',
'loan',
'partnership',
'stock',
'technic'))) {
4592 $morecss .=
' em080';
4596 $arrayconvpictotomarginleftonly = array(
4597 'bank',
'check',
'delete',
'generic',
'grip',
'grip_title',
'jabber',
4598 'grip_title',
'grip',
'listlight',
'note',
'on',
'off',
'playdisabled',
'printer',
'resize',
'sign-out',
'stats',
'switch_on',
'switch_on_red',
'switch_off',
4599 'uparrow',
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'
4601 if (!isset($arrayconvpictotomarginleftonly[$pictowithouttext])) {
4602 $marginleftonlyshort = 0;
4606 $arrayconvpictotomorcess = array(
4607 'action'=>
'infobox-action',
'account'=>
'infobox-bank_account',
'accounting_account'=>
'infobox-bank_account',
'accountline'=>
'infobox-bank_account',
'accountancy'=>
'infobox-bank_account',
'asset'=>
'infobox-bank_account',
4608 'bank_account'=>
'infobox-bank_account',
4609 'bill'=>
'infobox-commande',
'billa'=>
'infobox-commande',
'billr'=>
'infobox-commande',
'billd'=>
'infobox-commande',
4610 'margin'=>
'infobox-bank_account',
'conferenceorbooth'=>
'infobox-project',
4611 'cash-register'=>
'infobox-bank_account',
'contract'=>
'infobox-contrat',
'check'=>
'font-status4',
'collab'=>
'infobox-action',
'conversation'=>
'infobox-contrat',
4612 'donation'=>
'infobox-commande',
'dolly'=>
'infobox-commande',
'dollyrevert'=>
'flip infobox-order_supplier',
4613 'ecm'=>
'infobox-action',
'eventorganization'=>
'infobox-project',
4614 'hrm'=>
'infobox-adherent',
'group'=>
'infobox-adherent',
'intervention'=>
'infobox-contrat',
4615 'incoterm'=>
'infobox-supplier_proposal',
4616 'currency'=>
'infobox-bank_account',
'multicurrency'=>
'infobox-bank_account',
4617 'members'=>
'infobox-adherent',
'member'=>
'infobox-adherent',
'money-bill-alt'=>
'infobox-bank_account',
4618 'order'=>
'infobox-commande',
4619 'user'=>
'infobox-adherent',
'users'=>
'infobox-adherent',
4620 'error'=>
'pictoerror',
'warning'=>
'pictowarning',
'switch_on'=>
'font-status4',
'switch_on_warning'=>
'font-status4 warning',
'switch_on_red'=>
'font-status8',
4621 'holiday'=>
'infobox-holiday',
'info'=>
'opacityhigh',
'invoice'=>
'infobox-commande',
4622 'knowledgemanagement'=>
'infobox-contrat rotate90',
'loan'=>
'infobox-bank_account',
4623 'payment'=>
'infobox-bank_account',
'payment_vat'=>
'infobox-bank_account',
'poll'=>
'infobox-adherent',
'pos'=>
'infobox-bank_account',
'project'=>
'infobox-project',
'projecttask'=>
'infobox-project',
4624 'propal'=>
'infobox-propal',
'proposal'=>
'infobox-propal',
'private'=>
'infobox-project',
4625 'reception'=>
'flip',
'recruitmentjobposition'=>
'infobox-adherent',
'recruitmentcandidature'=>
'infobox-adherent',
4626 'resource'=>
'infobox-action',
4627 'salary'=>
'infobox-bank_account',
'shapes'=>
'infobox-adherent',
'shipment'=>
'infobox-commande',
'supplier_invoice'=>
'infobox-order_supplier',
'supplier_invoicea'=>
'infobox-order_supplier',
'supplier_invoiced'=>
'infobox-order_supplier',
4628 'supplier'=>
'infobox-order_supplier',
'supplier_order'=>
'infobox-order_supplier',
'supplier_proposal'=>
'infobox-supplier_proposal',
4629 'ticket'=>
'infobox-contrat',
'title_accountancy'=>
'infobox-bank_account',
'title_hrm'=>
'infobox-holiday',
'expensereport'=>
'infobox-expensereport',
'trip'=>
'infobox-expensereport',
'title_agenda'=>
'infobox-action',
4630 'vat'=>
'infobox-bank_account',
4632 'list-alt'=>
'imgforviewmode',
'calendar'=>
'imgforviewmode',
'calendarweek'=>
'imgforviewmode',
'calendarmonth'=>
'imgforviewmode',
'calendarday'=>
'imgforviewmode',
'calendarperuser'=>
'imgforviewmode'
4634 if (!empty($arrayconvpictotomorcess[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
4635 $morecss .= ($morecss ?
' ' :
'').$arrayconvpictotomorcess[$pictowithouttext];
4639 $arrayconvpictotocolor = array(
4640 'address'=>
'#6c6aa8',
'building'=>
'#6c6aa8',
'bom'=>
'#a69944',
4641 'clone'=>
'#999',
'cog'=>
'#999',
'companies'=>
'#6c6aa8',
'company'=>
'#6c6aa8',
'contact'=>
'#6c6aa8',
'cron'=>
'#555',
4642 'dynamicprice'=>
'#a69944',
4643 'edit'=>
'#444',
'note'=>
'#999',
'error'=>
'',
'help'=>
'#bbb',
'listlight'=>
'#999',
'language'=>
'#555',
4645 'lock'=>
'#ddd',
'lot'=>
'#a69944',
4646 'map-marker-alt'=>
'#aaa',
'mrp'=>
'#a69944',
'product'=>
'#a69944',
'service'=>
'#a69944',
'inventory'=>
'#a69944',
'stock'=>
'#a69944',
'movement'=>
'#a69944',
4647 'other'=>
'#ddd',
'world'=>
'#986c6a',
4648 'partnership'=>
'#6c6aa8',
'playdisabled'=>
'#ccc',
'printer'=>
'#444',
'projectpub'=>
'#986c6a',
'reception'=>
'#a69944',
'resize'=>
'#444',
'rss'=>
'#cba',
4650 'security'=>
'#999',
'square'=>
'#888',
'stop-circle'=>
'#888',
'stats'=>
'#444',
'switch_off'=>
'#999',
4651 'technic' =>
'#999',
'tick' =>
'#282',
'timespent' =>
'#555',
4652 'uncheck'=>
'#800',
'uparrow'=>
'#555',
'user-cog'=>
'#999',
'country'=>
'#aaa',
'globe-americas'=>
'#aaa',
'region'=>
'#aaa',
'state'=>
'#aaa',
4653 'website'=>
'#304',
'workstation'=>
'#a69944'
4655 if (isset($arrayconvpictotocolor[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
4656 $facolor = $arrayconvpictotocolor[$pictowithouttext];
4663 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4664 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4665 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4667 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
4668 $morestyle = $reg[1];
4669 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
4671 $moreatt = trim($moreatt);
4673 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
4674 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
4678 $enabledisablehtml .=
'</span>';
4680 return $enabledisablehtml;
4687 } elseif (!empty($conf->modules_parts[
'theme']) && array_key_exists($theme, $conf->modules_parts[
'theme'])) {
4688 $path = $theme.
'/theme/'.$theme;
4693 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
4699 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
4704 foreach ($conf->file->dol_document_root as $type => $dirroot) {
4705 if ($type ==
'main') {
4709 if (file_exists($dirroot.
'/'.$path.
'/img/'.$picto)) {
4710 $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type];
4716 $fullpathpicto = $url.
'/'.$path.
'/img/'.$picto;
4720 return $fullpathpicto;
4724 return '<img src="'.$fullpathpicto.
'"'.($notitle ?
'' :
' alt="'.dol_escape_htmltag($alt).
'"').(($notitle || empty($titlealt)) ?
'' :
' title="'.dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt.($morecss ?
' class="'.$morecss.
'"' :
'') :
' class="inline-block'.($morecss ?
' '.$morecss :
'').
'"').
'>';
4740function img_object($titlealt, $picto, $moreatt =
'', $pictoisfullpath =
false, $srconly = 0, $notitle = 0)
4742 if (strpos($picto,
'^') === 0) {
4743 return img_picto($titlealt, str_replace(
'^',
'', $picto), $moreatt, $pictoisfullpath, $srconly, $notitle);
4745 return img_picto($titlealt,
'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
4760function img_weather($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $morecss =
'')
4764 if (is_numeric($picto)) {
4767 return '<i class="fa fa-weather-level'.$picto.
'"></i>';
4768 } elseif (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
4772 $path = DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/weather/'.$picto;
4774 return img_picto($titlealt, $path, $moreatt, 1, 0, 0,
'', $morecss);
4792 if (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
4796 if ($pictoisfullpath) {
4799 $path = DOL_URL_ROOT.
'/theme/common/'.$picto;
4802 $themepath = DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/img/'.$picto;
4804 if (file_exists($themepath)) {
4810 return img_picto($titlealt, $path, $moreatt, 1, 0, $notitle);
4826function img_action($titlealt, $numaction, $picto =
'', $moreatt =
'')
4830 if (empty($titlealt) || $titlealt ==
'default') {
4831 if ($numaction ==
'-1' || $numaction ==
'ST_NO') {
4833 $titlealt = $langs->transnoentitiesnoconv(
'ChangeDoNotContact');
4834 } elseif ($numaction ==
'0' || $numaction ==
'ST_NEVER') {
4836 $titlealt = $langs->transnoentitiesnoconv(
'ChangeNeverContacted');
4837 } elseif ($numaction ==
'1' || $numaction ==
'ST_TODO') {
4839 $titlealt = $langs->transnoentitiesnoconv(
'ChangeToContact');
4840 } elseif ($numaction ==
'2' || $numaction ==
'ST_PEND') {
4842 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactInProcess');
4843 } elseif ($numaction ==
'3' || $numaction ==
'ST_DONE') {
4845 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactDone');
4847 $titlealt = $langs->transnoentitiesnoconv(
'ChangeStatus '.$numaction);
4851 if (!is_numeric($numaction)) {
4855 return img_picto($titlealt, (empty($picto) ?
'stcomm'.$numaction.
'.png' : $picto), $moreatt);
4869 if ($titlealt ==
'default') {
4870 $titlealt = $langs->trans(
'Show');
4873 return img_picto($titlealt,
'pdf'.$size.
'.png');
4887 if ($titlealt ==
'default') {
4888 $titlealt = $langs->trans(
'Add');
4891 return img_picto($titlealt,
'edit_add.png', $other);
4904 if ($titlealt ==
'default') {
4905 $titlealt = $langs->trans(
'Remove');
4908 return img_picto($titlealt,
'edit_remove.png', $other);
4919function img_edit($titlealt =
'default', $float = 0, $other =
'')
4923 if ($titlealt ==
'default') {
4924 $titlealt = $langs->trans(
'Modify');
4927 return img_picto($titlealt,
'edit.png', ($float ?
'style="float: '.($langs->tab_translate[
"DIRECTION"] ==
'rtl' ?
'left' :
'right').
'"' :
"").($other ?
' '.$other :
''));
4938function img_view($titlealt =
'default', $float = 0, $other =
'class="valignmiddle"')
4942 if ($titlealt ==
'default') {
4943 $titlealt = $langs->trans(
'View');
4946 $moreatt = ($float ?
'style="float: right" ' :
'').$other;
4948 return img_picto($titlealt,
'eye', $moreatt);
4959function img_delete($titlealt =
'default', $other =
'class="pictodelete"', $morecss =
'')
4963 if ($titlealt ==
'default') {
4964 $titlealt = $langs->trans(
'Delete');
4967 return img_picto($titlealt,
'delete.png', $other,
false, 0, 0,
'', $morecss);
4980 if ($titlealt ==
"default") {
4981 $titlealt = $langs->trans(
"Print");
4983 return img_picto($titlealt,
'printer.png', $other);
4993function img_split($titlealt =
'default', $other =
'class="pictosplit"')
4997 if ($titlealt ==
'default') {
4998 $titlealt = $langs->trans(
'Split');
5001 return img_picto($titlealt,
'split.png', $other);
5016 if (is_string($usealttitle)) {
5019 $usealttitle = $langs->trans(
'Info');
5023 return img_picto($usealttitle,
'info.png',
'style="vertical-align: middle;'.($usehelpcursor == 1 ?
' cursor: help' : ($usehelpcursor == 2 ?
' cursor: pointer' :
'')).
'"');
5036 if ($titlealt ==
'default') {
5037 $titlealt = $langs->trans(
'Informations');
5040 return img_picto($titlealt,
'info.png',
'style="vertical-align: middle;"');
5051function img_warning($titlealt =
'default', $moreatt =
'', $morecss =
'pictowarning')
5055 if ($titlealt ==
'default') {
5056 $titlealt = $langs->trans(
'Warning');
5060 return img_picto($titlealt,
'warning.png',
'class="'.$morecss.
'"'.($moreatt ? ($moreatt ==
'1' ?
' style="float: right"' :
' '.$moreatt) :
''));
5073 if ($titlealt ==
'default') {
5074 $titlealt = $langs->trans(
'Error');
5077 return img_picto($titlealt,
'error.png');
5091 if ($titlealt ==
'default') {
5092 $titlealt = $langs->trans(
'Next');
5096 return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
5110 if ($titlealt ==
'default') {
5111 $titlealt = $langs->trans(
'Previous');
5115 return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
5126function img_down($titlealt =
'default', $selected = 0, $moreclass =
'')
5130 if ($titlealt ==
'default') {
5131 $titlealt = $langs->trans(
'Down');
5134 return img_picto($titlealt, ($selected ?
'1downarrow_selected.png' :
'1downarrow.png'),
'class="imgdown'.($moreclass ?
" ".$moreclass :
"").
'"');
5145function img_up($titlealt =
'default', $selected = 0, $moreclass =
'')
5149 if ($titlealt ==
'default') {
5150 $titlealt = $langs->trans(
'Up');
5153 return img_picto($titlealt, ($selected ?
'1uparrow_selected.png' :
'1uparrow.png'),
'class="imgup'.($moreclass ?
" ".$moreclass :
"").
'"');
5164function img_left($titlealt =
'default', $selected = 0, $moreatt =
'')
5168 if ($titlealt ==
'default') {
5169 $titlealt = $langs->trans(
'Left');
5172 return img_picto($titlealt, ($selected ?
'1leftarrow_selected.png' :
'1leftarrow.png'), $moreatt);
5183function img_right($titlealt =
'default', $selected = 0, $moreatt =
'')
5187 if ($titlealt ==
'default') {
5188 $titlealt = $langs->trans(
'Right');
5191 return img_picto($titlealt, ($selected ?
'1rightarrow_selected.png' :
'1rightarrow.png'), $moreatt);
5205 if ($titlealt ==
'default') {
5206 $titlealt = $langs->trans(
'Active');
5210 return img_picto($titlealt,
'tick.png');
5225 if (is_null($morecss)) {
5229 if ($brand ==
'visa' || $brand ==
'Visa') {
5231 } elseif ($brand ==
'mastercard' || $brand ==
'MasterCard') {
5232 $brand =
'cc-mastercard';
5233 } elseif ($brand ==
'amex' || $brand ==
'American Express') {
5235 } elseif ($brand ==
'discover' || $brand ==
'Discover') {
5236 $brand =
'cc-discover';
5237 } elseif ($brand ==
'jcb' || $brand ==
'JCB') {
5239 } elseif ($brand ==
'diners' || $brand ==
'Diners club') {
5240 $brand =
'cc-diners-club';
5241 } elseif (!in_array($brand, array(
'cc-visa',
'cc-mastercard',
'cc-amex',
'cc-discover',
'cc-jcb',
'cc-diners-club'))) {
5242 $brand =
'credit-card';
5245 return '<span class="fa fa-'.$brand.
' fa-fw'.($morecss ?
' '.$morecss :
'').
'"></span>';
5258 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
5264 if (empty($titlealt)) {
5265 $titlealt =
'Mime type: '.$mimetype;
5269 return '<i class="fa fa-'.$mimefa.
' paddingright'.($morecss ?
' '.$morecss :
'').
'"'.($titlealt ?
' title="'.$titlealt.
'"' :
'').
'></i>';
5282 global $conf, $langs;
5284 if ($titlealt ==
'default') {
5285 $titlealt = $langs->trans(
'Search');
5288 $img =
img_picto($titlealt,
'search.png', $other,
false, 1);
5290 $input =
'<input type="image" class="liste_titre" name="button_search" src="'.$img.
'" ';
5291 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
5305 global $conf, $langs;
5307 if ($titlealt ==
'default') {
5308 $titlealt = $langs->trans(
'Search');
5311 $img =
img_picto($titlealt,
'searchclear.png', $other,
false, 1);
5313 $input =
'<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.
'" ';
5314 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
5330function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin =
'1', $morecss =
'hideonsmartphone', $textfordropdown =
'')
5332 global $conf, $langs;
5334 if ($infoonimgalt) {
5335 $result =
img_picto($text,
'info',
'class="'.($morecss ?
' '.$morecss :
'').
'"');
5337 if (empty($conf->use_javascript_ajax)) {
5338 $textfordropdown =
'';
5341 $class = (empty($admin) ?
'undefined' : ($admin ==
'1' ?
'info' : $admin));
5342 $result = ($nodiv ?
'' :
'<div class="'.$class.($morecss ?
' '.$morecss :
'').($textfordropdown ?
' hidden' :
'').
'">').
'<span class="fa fa-info-circle" title="'.
dol_escape_htmltag($admin ? $langs->trans(
'InfoAdmin') : $langs->trans(
'Note')).
'"></span> '.$text.($nodiv ?
'' :
'</div>');
5344 if ($textfordropdown) {
5345 $tmpresult =
'<span class="'.$class.
'text opacitymedium cursorpointer">'.$langs->trans($textfordropdown).
' '.
img_picto($langs->trans($textfordropdown),
'1downarrow').
'</span>';
5346 $tmpresult .=
'<script nonce="'.getNonce().
'" type="text/javascript">
5347 jQuery(document).ready(function() {
5348 jQuery(".'.$class.
'text").click(function() {
5349 console.log("toggle text");
5350 jQuery(".'.$class.
'").toggle();
5355 $result = $tmpresult.$result;
5376 global $conf, $langs, $argv;
5377 global $dolibarr_main_prod;
5384 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
5386 $langs->load(
"main");
5390 $langs->loadLangs(array(
'main',
'errors'));
5392 if ($_SERVER[
'DOCUMENT_ROOT']) {
5393 $out .= $langs->trans(
"DolibarrHasDetectedError").
".<br>\n";
5395 $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";
5397 $out .= $langs->trans(
"InformationToHelpDiagnose").
":<br>\n";
5399 $out .=
"<b>".$langs->trans(
"Date").
":</b> ".
dol_print_date(time(),
'dayhourlog').
"<br>\n";
5400 $out .=
"<b>".$langs->trans(
"Dolibarr").
":</b> ".DOL_VERSION.
" - https://www.dolibarr.org<br>\n";
5401 if (isset($conf->global->MAIN_FEATURES_LEVEL)) {
5402 $out .=
"<b>".$langs->trans(
"LevelOfFeature").
":</b> ".
getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
"<br>\n";
5404 if (function_exists(
"phpversion")) {
5405 $out .=
"<b>".$langs->trans(
"PHP").
":</b> ".phpversion().
"<br>\n";
5407 $out .=
"<b>".$langs->trans(
"Server").
":</b> ".(isset($_SERVER[
"SERVER_SOFTWARE"]) ?
dol_htmlentities($_SERVER[
"SERVER_SOFTWARE"], ENT_COMPAT) :
'').
"<br>\n";
5408 if (function_exists(
"php_uname")) {
5409 $out .=
"<b>".$langs->trans(
"OS").
":</b> ".php_uname().
"<br>\n";
5411 $out .=
"<b>".$langs->trans(
"UserAgent").
":</b> ".(isset($_SERVER[
"HTTP_USER_AGENT"]) ?
dol_htmlentities($_SERVER[
"HTTP_USER_AGENT"], ENT_COMPAT) :
'').
"<br>\n";
5413 $out .=
"<b>".$langs->trans(
"RequestedUrl").
":</b> ".
dol_htmlentities($_SERVER[
"REQUEST_URI"], ENT_COMPAT).
"<br>\n";
5414 $out .=
"<b>".$langs->trans(
"Referer").
":</b> ".(isset($_SERVER[
"HTTP_REFERER"]) ?
dol_htmlentities($_SERVER[
"HTTP_REFERER"], ENT_COMPAT) :
'').
"<br>\n";
5415 $out .=
"<b>".$langs->trans(
"MenuManager").
":</b> ".(isset($conf->standard_menu) ?
dol_htmlentities($conf->standard_menu, ENT_COMPAT) :
'').
"<br>\n";
5417 $syslog .=
"url=".dol_escape_htmltag($_SERVER[
"REQUEST_URI"]);
5418 $syslog .=
", query_string=".dol_escape_htmltag($_SERVER[
"QUERY_STRING"]);
5420 $out .=
'> '.$langs->transnoentities(
"ErrorInternalErrorDetected").
":\n".$argv[0].
"\n";
5421 $syslog .=
"pid=".dol_getmypid();
5424 if (!empty($conf->modules)) {
5425 $out .=
"<b>".$langs->trans(
"Modules").
":</b> ".join(
', ', $conf->modules).
"<br>\n";
5428 if (is_object($db)) {
5429 if ($_SERVER[
'DOCUMENT_ROOT']) {
5430 $out .=
"<b>".$langs->trans(
"DatabaseTypeManager").
":</b> ".$db->type.
"<br>\n";
5431 $lastqueryerror = $db->lastqueryerror();
5433 $lastqueryerror =
"SQL error string is not a valid UTF8 string. We can't show it.";
5435 $out .=
"<b>".$langs->trans(
"RequestLastAccessInError").
":</b> ".($lastqueryerror ?
dol_escape_htmltag($lastqueryerror) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5436 $out .=
"<b>".$langs->trans(
"ReturnCodeLastAccessInError").
":</b> ".($db->lasterrno() ?
dol_escape_htmltag($db->lasterrno()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5437 $out .=
"<b>".$langs->trans(
"InformationLastAccessInError").
":</b> ".($db->lasterror() ?
dol_escape_htmltag($db->lasterror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5441 $out .=
'> '.$langs->transnoentities(
"DatabaseTypeManager").
":\n".$db->type.
"\n";
5442 $out .=
'> '.$langs->transnoentities(
"RequestLastAccessInError").
":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5443 $out .=
'> '.$langs->transnoentities(
"ReturnCodeLastAccessInError").
":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5444 $out .=
'> '.$langs->transnoentities(
"InformationLastAccessInError").
":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5446 $syslog .=
", sql=".$db->lastquery();
5447 $syslog .=
", db_error=".$db->lasterror();
5450 if ($error || $errors) {
5451 $langs->load(
"errors");
5454 if (is_array($error) && is_array($errors)) {
5455 $errors = array_merge($error, $errors);
5456 } elseif (is_array($error)) {
5458 } elseif (is_array($errors)) {
5459 $errors = array_merge(array($error), $errors);
5461 $errors = array_merge(array($error), array($errors));
5464 foreach ($errors as $msg) {
5468 if ($_SERVER[
'DOCUMENT_ROOT']) {
5471 $out .=
'> '.$langs->transnoentities(
"Message").
":\n".$msg.
"\n";
5473 $syslog .=
", msg=".$msg;
5476 if (empty($dolibarr_main_prod) && $_SERVER[
'DOCUMENT_ROOT'] && function_exists(
'xdebug_print_function_stack') && function_exists(
'xdebug_call_file')) {
5477 xdebug_print_function_stack();
5478 $out .=
'<b>XDebug informations:</b>'.
"<br>\n";
5479 $out .=
'File: '.xdebug_call_file().
"<br>\n";
5480 $out .=
'Line: '.xdebug_call_line().
"<br>\n";
5481 $out .=
'Function: '.xdebug_call_function().
"<br>\n";
5486 if (!headers_sent()) {
5487 if (function_exists(
'top_httphead')) {
5491 http_response_code(202);
5494 if (empty($dolibarr_main_prod)) {
5497 if (empty($langs->defaultlang)) {
5498 $langs->setDefaultLang();
5500 $langs->loadLangs(array(
"main",
"errors"));
5502 print
'This website or feature is currently temporarly 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";
5503 print $langs->trans(
"DolibarrHasDetectedError").
'. ';
5504 print $langs->trans(
"YouCanSetOptionDolibarrMainProdToZero");
5505 if (!defined(
"MAIN_CORE_ERROR")) {
5506 define(
"MAIN_CORE_ERROR", 1);
5523function dol_print_error_email($prefixcode, $errormessage =
'', $errormessages = array(), $morecss =
'error', $email =
'')
5525 global $langs, $conf;
5527 if (empty($email)) {
5528 $email = $conf->global->MAIN_INFO_SOCIETE_MAIL;
5531 $langs->load(
"errors");
5534 print
'<br><div class="center login_main_message"><div class="'.$morecss.
'">';
5535 print $langs->trans(
"ErrorContactEMail", $email, $prefixcode.
'-'.
dol_print_date($now,
'%Y%m%d%H%M%S'));
5536 if ($errormessage) {
5537 print
'<br><br>'.$errormessage;
5539 if (is_array($errormessages) && count($errormessages)) {
5540 foreach ($errormessages as $mesgtoshow) {
5541 print
'<br><br>'.$mesgtoshow;
5544 print
'</div></div>';
5563function print_liste_field_titre($name, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $tooltip =
"", $forcenowrapcolumntitle = 0)
5565 print
getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip, $forcenowrapcolumntitle);
5586function getTitleFieldOfList($name, $thead = 0, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $disablesortlink = 0, $tooltip =
'', $forcenowrapcolumntitle = 0)
5588 global $conf, $langs, $form;
5591 if ($moreattrib ==
'class="right"') {
5592 $prefix .=
'right ';
5595 $sortorder = strtoupper($sortorder);
5604 $tmpsortfield = explode(
',', $sortfield);
5605 $sortfield1 = trim($tmpsortfield[0]);
5606 $tmpfield = explode(
',', $field);
5607 $field1 = trim($tmpfield[0]);
5609 if (!
getDolGlobalString(
'MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE') && empty($forcenowrapcolumntitle)) {
5610 $prefix =
'wrapcolumntitle '.$prefix;
5616 $liste_titre =
'liste_titre';
5617 if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace(
"/^[^\.]+\./",
"", $field1))) {
5618 $liste_titre =
'liste_titre_sel';
5621 $tagstart =
'<'.$tag.
' class="'.$prefix.$liste_titre.
'" '.$moreattrib;
5626 if (empty($thead) && $field && empty($disablesortlink)) {
5627 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
5628 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
5629 $options = preg_replace(
'/&+/i',
'&', $options);
5630 if (!preg_match(
'/^&/', $options)) {
5631 $options =
'&'.$options;
5634 $sortordertouseinlink =
'';
5635 if ($field1 != $sortfield1) {
5636 if (preg_match(
'/^DESC/i', $sortorder)) {
5637 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
5639 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
5642 if (preg_match(
'/^ASC/i', $sortorder)) {
5643 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
5645 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
5648 $sortordertouseinlink = preg_replace(
'/,$/',
'', $sortordertouseinlink);
5649 $out .=
'<a class="reposition" href="'.$file.
'?sortfield='.$field.
'&sortorder='.$sortordertouseinlink.
'&begin='.$begin.$options.
'"';
5655 if (preg_match(
'/:\w+$/', $tooltip)) {
5656 $tmptooltip = explode(
':', $tooltip);
5658 $tmptooltip = array($tooltip);
5660 $out .= $form->textwithpicto($langs->trans($name), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.str_replace(
'.',
'_', $field).
'_'.$tmptooltip[1]));
5662 $out .= $langs->trans($name);
5665 if (empty($thead) && $field && empty($disablesortlink)) {
5669 if (empty($thead) && $field) {
5670 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
5671 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
5672 $options = preg_replace(
'/&+/i',
'&', $options);
5673 if (!preg_match(
'/^&/', $options)) {
5674 $options =
'&'.$options;
5677 if (!$sortorder || ($field1 != $sortfield1)) {
5681 if (preg_match(
'/^DESC/', $sortorder)) {
5684 $sortimg .=
'<span class="nowrap">'.img_up(
"Z-A", 0,
'paddingright').
'</span>';
5686 if (preg_match(
'/^ASC/', $sortorder)) {
5689 $sortimg .=
'<span class="nowrap">'.img_down(
"A-Z", 0,
'paddingright').
'</span>';
5694 $tagend =
'</'.$tag.
'>';
5696 $out = $tagstart.$sortimg.$out.$tagend;
5711 dol_syslog(__FUNCTION__.
" is deprecated", LOG_WARNING);
5713 print
'<div class="titre">'.$title.
'</div>';
5745function load_fiche_titre($titre, $morehtmlright =
'', $picto =
'generic', $pictoisfullpath = 0, $id =
'', $morecssontable =
'', $morehtmlcenter =
'')
5751 if ($picto ==
'setup') {
5756 $return .=
'<table '.($id ?
'id="'.$id.
'" ' :
'').
'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ?
' '.$morecssontable :
'').
'">';
5757 $return .=
'<tr class="titre">';
5759 $return .=
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).
'</td>';
5761 $return .=
'<td class="nobordernopadding valignmiddle col-title">';
5762 $return .=
'<div class="titre inline-block">'.$titre.
'</div>';
5765 $return .=
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
5768 $return .=
'<td class="nobordernopadding titre_right wordbreakimp right valignmiddle col-right">'.$morehtmlright.
'</td>';
5770 $return .=
'</tr></table>'.
"\n";
5798function print_barre_liste($titre, $page, $file, $options =
'', $sortfield =
'', $sortorder =
'', $morehtmlcenter =
'', $num = -1, $totalnboflines =
'', $picto =
'generic', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limit = -1, $hideselectlimit = 0, $hidenavigation = 0, $pagenavastextinput = 0, $morehtmlrightbeforearrow =
'')
5803 $savtotalnboflines = $totalnboflines;
5804 $totalnboflines = abs((
int) $totalnboflines);
5806 $page = (int) $page;
5808 if ($picto ==
'setup') {
5809 $picto =
'title_setup.png';
5811 if (($conf->browser->name ==
'ie') && $picto ==
'generic') {
5812 $picto =
'title.gif';
5815 $limit = $conf->liste_limit;
5818 if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
5826 print
"<!-- Begin title -->\n";
5827 print
'<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ?
' '.$morecss :
'').
'"><tr>';
5831 if ($picto && $titre) {
5832 print
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath).
'</td>';
5835 print
'<td class="nobordernopadding valignmiddle col-title">';
5836 print
'<div class="titre inline-block">'.$titre;
5837 if (!empty($titre) && $savtotalnboflines >= 0 && (
string) $savtotalnboflines !=
'') {
5838 print
'<span class="opacitymedium colorblack paddingleft">('.$totalnboflines.
')</span>';
5840 print
'</div></td>';
5843 if ($morehtmlcenter && empty($conf->dol_optimize_smallscreen)) {
5844 print
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
5848 print
'<td class="nobordernopadding valignmiddle right col-right">';
5849 print
'<input type="hidden" name="pageplusoneold" value="'.((int) $page + 1).
'">';
5851 $options .=
"&sortfield=".urlencode($sortfield);
5854 $options .=
"&sortorder=".urlencode($sortorder);
5858 if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
5859 if ($totalnboflines) {
5861 $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 0);
5864 $nbpages = ceil($totalnboflines / $limit);
5868 $cpt = ($page - $maxnbofpage);
5874 if (empty($pagenavastextinput)) {
5875 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page=0'.$options.
'">1</a></li>';
5877 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
5878 } elseif ($cpt == 2) {
5879 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page=1'.$options.
'">2</a></li>';
5885 if ($pagenavastextinput) {
5886 if ($cpt == $page) {
5887 $pagelist .=
'<li class="pagination"><input type="text" class="'.($totalnboflines > 100 ?
'width40' :
'width25').
' center pageplusone" name="pageplusone" value="'.($page + 1).
'"></li>';
5891 if ($cpt == $page) {
5892 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
'</span></li>';
5894 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.$cpt.$options.
'">'.($cpt + 1).
'</a></li>';
5898 }
while ($cpt < $nbpages && $cpt <= ($page + $maxnbofpage));
5900 if (empty($pagenavastextinput)) {
5901 if ($cpt < $nbpages) {
5902 if ($cpt < $nbpages - 2) {
5903 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
5904 } elseif ($cpt == $nbpages - 2) {
5905 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.($nbpages - 2).$options.
'">'.($nbpages - 1).
'</a></li>';
5907 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
5911 $pagelist .=
'<li class="pagination paginationlastpage"><a class="reposition" href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
5914 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
"</li>";
5918 if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
5919 print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow, $hidenavigation);
5923 if ($pagenavastextinput) {
5930 print
'</table>'.
"\n";
5933 if ($morehtmlcenter && !empty($conf->dol_optimize_smallscreen)) {
5934 print
'<div class="nobordernopadding marginbottomonly center valignmiddle col-center centpercent">'.$morehtmlcenter.
'</div>';
5937 print
"<!-- End title -->\n\n";
5956function print_fleche_navigation($page, $file, $options =
'', $nextpage = 0, $betweenarrows =
'', $afterarrows =
'', $limit = -1, $totalnboflines = 0, $hideselectlimit = 0, $beforearrows =
'', $hidenavigation = 0)
5958 global $conf, $langs;
5960 print
'<div class="pagination"><ul>';
5961 if ($beforearrows) {
5962 print
'<li class="paginationbeforearrows">';
5963 print $beforearrows;
5967 if (empty($hidenavigation)) {
5968 if ((
int) $limit > 0 && empty($hideselectlimit)) {
5969 $pagesizechoices =
'10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000';
5970 $pagesizechoices .=
',5000:5000,10000:10000,20000:20000';
5974 $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES;
5977 print
'<li class="pagination">';
5978 print
'<select class="flat selectlimit" name="limit" title="'.dol_escape_htmltag($langs->trans(
"MaxNbOfRecordPerPage")).
'">';
5979 $tmpchoice = explode(
',', $pagesizechoices);
5980 $tmpkey = $limit.
':'.$limit;
5981 if (!in_array($tmpkey, $tmpchoice)) {
5982 $tmpchoice[] = $tmpkey;
5984 $tmpkey = $conf->liste_limit.
':'.$conf->liste_limit;
5985 if (!in_array($tmpkey, $tmpchoice)) {
5986 $tmpchoice[] = $tmpkey;
5988 asort($tmpchoice, SORT_NUMERIC);
5989 foreach ($tmpchoice as $val) {
5991 $tmp = explode(
':', $val);
5994 if ($key !=
'' && $val !=
'') {
5995 if ((
int) $key == (
int) $limit) {
5996 $selected =
' selected="selected"';
5998 print
'<option name="'.$key.
'"'.$selected.
'>'.
dol_escape_htmltag($val).
'</option>'.
"\n";
6002 if ($conf->use_javascript_ajax) {
6003 print
'<!-- JS CODE TO ENABLE select limit to launch submit of page -->
6005 jQuery(document).ready(function () {
6006 jQuery(".selectlimit").change(function() {
6007 console.log("Change limit. Send submit");
6008 $(this).parents(\'form:first\').submit();
6017 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>';
6019 if ($betweenarrows) {
6020 print
'<!--<div class="betweenarrows nowraponall inline-block">-->';
6021 print $betweenarrows;
6022 print
'<!--</div>-->';
6024 if ($nextpage > 0) {
6025 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>';
6028 print
'<li class="paginationafterarrows">';
6033 print
'</ul></div>'.
"\n";
6048function vatrate($rate, $addpercent =
false, $info_bits = 0, $usestarfornpr = 0, $html = 0)
6052 if (preg_match(
'/%/', $rate)) {
6053 $rate = str_replace(
'%',
'', $rate);
6057 if (preg_match(
'/\((.*)\)/', $rate, $reg)) {
6058 $morelabel =
' ('.$reg[1].
')';
6059 $rate = preg_replace(
'/\s*'.preg_quote($morelabel,
'/').
'/',
'', $rate);
6060 $morelabel =
' '.($html ?
'<span class="opacitymedium">' :
'').
'('.$reg[1].
')'.($html ?
'</span>' :
'');
6062 if (preg_match(
'/\*/', $rate)) {
6063 $rate = str_replace(
'*',
'', $rate);
6068 if (!preg_match(
'/\//', $rate)) {
6069 $ret =
price($rate, 0,
'', 0, 0).($addpercent ?
'%' :
'');
6072 $ret = $rate.($addpercent ?
'%' :
'');
6074 if (($info_bits & 1) && $usestarfornpr >= 0) {
6097function price($amount, $form = 0, $outlangs =
'', $trunc = 1, $rounding = -1, $forcerounding = -1, $currency_code =
'')
6099 global $langs, $conf;
6102 if (empty($amount)) {
6105 $amount = (is_numeric($amount) ? $amount : 0);
6106 if ($rounding == -1) {
6109 $nbdecimal = $rounding;
6111 if ($outlangs ===
'none') {
6121 if (!is_object($outlangs)) {
6125 if ($outlangs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
6126 $dec = $outlangs->transnoentitiesnoconv(
"SeparatorDecimal");
6128 if ($outlangs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
6129 $thousand = $outlangs->transnoentitiesnoconv(
"SeparatorThousand");
6131 if ($thousand ==
'None') {
6133 } elseif ($thousand ==
'Space') {
6140 $amount = str_replace(
',',
'.', $amount);
6142 $datas = explode(
'.', $amount);
6143 $decpart = isset($datas[1]) ? $datas[1] :
'';
6144 $decpart = preg_replace(
'/0+$/i',
'', $decpart);
6154 $nbdecimalmaxshown = (int) str_replace(
'...',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN'));
6155 if ($trunc && $nbdecimal > $nbdecimalmaxshown) {
6156 $nbdecimal = $nbdecimalmaxshown;
6164 if ((
string) $forcerounding !=
'-1') {
6165 if ($forcerounding ===
'MU') {
6167 } elseif ($forcerounding ===
'MT') {
6169 } elseif ($forcerounding >= 0) {
6170 $nbdecimal = $forcerounding;
6175 $output = number_format($amount, $nbdecimal, $dec, $thousand);
6177 $output = preg_replace(
'/\s/',
' ', $output);
6178 $output = preg_replace(
'/\'/',
''', $output);
6181 $cursymbolbefore = $cursymbolafter =
'';
6182 if ($currency_code && is_object($outlangs)) {
6183 if ($currency_code ==
'auto') {
6184 $currency_code = $conf->currency;
6187 $listofcurrenciesbefore = array(
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD',
'CRC',
'ZAR');
6188 $listoflanguagesbefore = array(
'nl_NL');
6189 if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) {
6190 $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
6192 $tmpcur = $outlangs->getCurrencySymbol($currency_code);
6193 $cursymbolafter .= ($tmpcur == $currency_code ?
' '.$tmpcur : $tmpcur);
6196 $output = $cursymbolbefore.$output.$end.($cursymbolafter ?
' ' :
'').$cursymbolafter;
6227 global $langs, $conf;
6230 if (is_null($amount)) {
6239 if (is_null($langs)) {
6243 if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
6244 $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
6246 if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
6247 $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
6250 if ($thousand ==
'None') {
6252 } elseif ($thousand ==
'Space') {
6260 if (!is_numeric($amount)) {
6261 $amount = preg_replace(
'/[a-zA-Z\/\\\*\(\)<>\_]/',
'', $amount);
6264 if ($option == 2 && $thousand ==
'.' && preg_match(
'/\.(\d\d\d)$/', (
string) $amount)) {
6265 $amount = str_replace($thousand,
'', $amount);
6271 if (is_numeric($amount)) {
6273 $temps = sprintf(
"%0.10F", $amount - intval($amount));
6274 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
6276 $amount = number_format($amount, $nbofdec, $dec, $thousand);
6281 if ($thousand !=
',' && $thousand !=
'.') {
6282 $amount = str_replace(
',',
'.', $amount);
6285 $amount = str_replace(
' ',
'', $amount);
6286 $amount = str_replace($thousand,
'', $amount);
6287 $amount = str_replace($dec,
'.', $amount);
6289 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
6295 $nbofdectoround =
'';
6296 if ($rounding ==
'MU') {
6297 $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT;
6298 } elseif ($rounding ==
'MT') {
6299 $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT;
6300 } elseif ($rounding ==
'MS') {
6301 $nbofdectoround = isset($conf->global->MAIN_MAX_DECIMALS_STOCK) ? $conf->global->MAIN_MAX_DECIMALS_STOCK : 5;
6302 } elseif ($rounding ==
'CU') {
6304 } elseif ($rounding ==
'CT') {
6306 } elseif (is_numeric($rounding)) {
6307 $nbofdectoround = (int) $rounding;
6312 $amount = round(is_string($amount) ? (
float) $amount : $amount, $nbofdectoround);
6314 return 'ErrorBadParameterProvidedToFunction';
6320 if (is_numeric($amount)) {
6322 $temps = sprintf(
"%0.10F", $amount - intval($amount));
6323 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
6325 $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand);
6331 if ($thousand !=
',' && $thousand !=
'.') {
6332 $amount = str_replace(
',',
'.', $amount);
6335 $amount = str_replace(
' ',
'', $amount);
6336 $amount = str_replace($thousand,
'', $amount);
6337 $amount = str_replace($dec,
'.', $amount);
6339 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
6357function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput =
'no', $use_short_label = 0)
6359 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
6361 if (($forceunitoutput ==
'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
6362 $dimension = $dimension * 1000000;
6364 } elseif (($forceunitoutput ==
'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) {
6365 $dimension = $dimension * 1000;
6367 } elseif (($forceunitoutput ==
'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) {
6368 $dimension = $dimension / 1000000;
6370 } elseif (($forceunitoutput ==
'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) {
6371 $dimension = $dimension / 1000;
6387 $ret =
price($dimension, 0, $outputlangs, 0, 0, $round);
6388 $ret .=
' '.measuringUnitString(0, $type, $unit, $use_short_label, $outputlangs);
6406function get_localtax($vatrate, $local, $thirdparty_buyer =
"", $thirdparty_seller =
"", $vatnpr = 0)
6408 global $db, $conf, $mysoc;
6410 if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) {
6411 $thirdparty_seller = $mysoc;
6414 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);
6416 $vatratecleaned = $vatrate;
6418 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
6419 $vatratecleaned = trim($reg[1]);
6420 $vatratecode = $reg[2];
6429 if ($mysoc->country_code ==
'ES') {
6431 if (!$mysoc->localtax1_assuj || (
string) $vatratecleaned ==
"0") {
6434 if ($thirdparty_seller->id == $mysoc->id) {
6435 if (!$thirdparty_buyer->localtax1_assuj) {
6439 if (!$thirdparty_seller->localtax1_assuj) {
6447 if (!$mysoc->localtax2_assuj) {
6450 if ($thirdparty_seller->id == $mysoc->id) {
6451 if (!$thirdparty_buyer->localtax2_assuj) {
6455 if (!$thirdparty_seller->localtax2_assuj) {
6461 if ($local == 1 && !$thirdparty_seller->localtax1_assuj) {
6464 if ($local == 2 && !$thirdparty_seller->localtax2_assuj) {
6470 if (in_array($mysoc->country_code, array(
'ES'))) {
6471 $conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY = 1;
6477 if ($thirdparty_seller != $mysoc) {
6479 return $thirdparty_seller->localtax1_value;
6483 return $conf->global->MAIN_INFO_VALUE_LOCALTAX1;
6488 if ($thirdparty_seller != $mysoc) {
6491 return $thirdparty_seller->localtax2_value;
6494 if (in_array($mysoc->country_code, array(
'ES'))) {
6495 return $thirdparty_buyer->localtax2_value;
6497 return $conf->global->MAIN_INFO_VALUE_LOCALTAX2;
6504 $sql =
"SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
6505 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
6506 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdparty_seller->country_code).
"'";
6507 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
6508 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
6509 if (!empty($vatratecode)) {
6510 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
6512 $sql .=
" AND t.recuperableonly = '".$db->escape($vatnpr).
"'";
6515 $resql = $db->query($sql);
6518 $obj = $db->fetch_object($resql);
6521 return $obj->localtax1;
6522 } elseif ($local == 2) {
6523 return $obj->localtax2;
6544 $valors = explode(
":", $tax);
6546 if (count($valors) > 1) {
6563 $sql =
" SELECT t.localtax".$local.
" as localtax";
6564 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t INNER JOIN ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid = t.fk_pays";
6565 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.active = 1 AND t.entity IN (".
getEntity(
'c_tva').
") AND t.taux = (";
6566 $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";
6567 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.entity IN (".
getEntity(
'c_tva').
") AND tt.active = 1)";
6568 $sql .=
" AND t.localtax".$local.
"_type <> '0'";
6569 $sql .=
" ORDER BY t.rowid DESC";
6571 $resql = $db->query($sql);
6573 $obj = $db->fetch_object($resql);
6575 return $obj->localtax;
6600 dol_syslog(
"getTaxesFromId vat id or rate = ".$vatrate);
6603 $sql =
"SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy,";
6604 $sql .=
" t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
6605 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
6606 if ($firstparamisid) {
6607 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
6609 $vatratecleaned = $vatrate;
6612 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
6613 $vatratecleaned = $reg[1];
6614 $vatratecode = $reg[2];
6617 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
6620 $sql .=
" WHERE t.fk_pays = c.rowid";
6622 $sql .=
" AND c.code = '".$db->escape($buyer->country_code).
"'";
6624 $sql .=
" AND c.code = '".$db->escape($seller->country_code).
"'";
6626 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
6627 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
6629 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
6633 $resql = $db->query($sql);
6635 $obj = $db->fetch_object($resql);
6638 'rowid'=>$obj->rowid,
6641 'localtax1'=>$obj->localtax1,
6642 'localtax1_type'=>$obj->localtax1_type,
6643 'localtax2'=>$obj->localtax2,
6644 'localtax2_type'=>$obj->localtax2_type,
6646 'accountancy_code_sell'=>$obj->accountancy_code_sell,
6647 'accountancy_code_buy'=>$obj->accountancy_code_buy
6679 dol_syslog(
"getLocalTaxesFromRate vatrate=".$vatrate.
" local=".$local);
6682 $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";
6683 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
6684 if ($firstparamisid) {
6685 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
6687 $vatratecleaned = $vatrate;
6690 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
6691 $vatratecleaned = $reg[1];
6692 $vatratecode = $reg[2];
6695 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
6696 if (!empty($mysoc) && $mysoc->country_code ==
'ES') {
6697 $countrycodetouse = ((empty($buyer) || empty($buyer->country_code)) ? $mysoc->country_code : $buyer->country_code);
6698 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
6700 $countrycodetouse = ((empty($seller) || empty($seller->country_code)) ? $mysoc->country_code : $seller->country_code);
6701 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
6703 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
6705 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
6709 $resql = $db->query($sql);
6711 $obj = $db->fetch_object($resql);
6714 $vateratestring = $obj->rate.($obj->code ?
' ('.$obj->code.
')' :
'');
6717 return array($obj->localtax1_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
6718 } elseif ($local == 2) {
6719 return array($obj->localtax2_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
6721 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);
6741 global $db, $conf, $mysoc;
6743 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
6751 $product->fetch($idprod);
6753 if ($mysoc->country_code == $thirdpartytouse->country_code) {
6755 if ($idprodfournprice > 0) {
6756 $result = $product->get_buyprice($idprodfournprice, 0, 0, 0);
6758 $ret = $product->vatrate_supplier;
6759 if ($product->default_vat_code_supplier) {
6760 $ret .=
' ('.$product->default_vat_code_supplier.
')';
6766 $ret = $product->tva_tx;
6767 if ($product->default_vat_code) {
6768 $ret .=
' ('.$product->default_vat_code.
')';
6781 $sql =
"SELECT t.taux as vat_rate, t.code as default_vat_code";
6782 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
6783 $sql .=
" WHERE t.active = 1 AND t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdpartytouse->country_code).
"'";
6784 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
6785 $sql .=
" ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC";
6786 $sql .= $db->plimit(1);
6788 $resql = $db->query($sql);
6790 $obj = $db->fetch_object($resql);
6792 $ret = $obj->vat_rate;
6793 if ($obj->default_vat_code) {
6794 $ret .=
' ('.$obj->default_vat_code.
')';
6807 $defaulttx = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
6818 dol_syslog(
"get_product_vat_for_country: ret=".$ret);
6835 if (!class_exists(
'Product')) {
6836 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
6845 $result = $product->fetch($idprod);
6847 if ($mysoc->country_code == $thirdpartytouse->country_code) {
6861 $sql =
"SELECT taux as vat_rate, localtax1, localtax2";
6862 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
6863 $sql .=
" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdpartytouse->country_code).
"'";
6864 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
6865 $sql .=
" ORDER BY t.taux DESC, t.recuperableonly ASC";
6866 $sql .= $db->plimit(1);
6868 $resql = $db->query($sql);
6870 $obj = $db->fetch_object($resql);
6873 $ret = $obj->localtax1;
6874 } elseif ($local == 2) {
6875 $ret = $obj->localtax2;
6883 dol_syslog(
"get_product_localtax_for_country: ret=".$ret);
6907 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
6910 $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;
6912 $seller_country_code = $thirdparty_seller->country_code;
6913 $seller_in_cee =
isInEEC($thirdparty_seller);
6915 $buyer_country_code = $thirdparty_buyer->country_code;
6916 $buyer_in_cee =
isInEEC($thirdparty_buyer);
6918 dol_syslog(
"get_default_tva: seller use vat=".$seller_use_vat.
", seller country=".$seller_country_code.
", seller in cee=".$seller_in_cee.
", buyer vat number=".$thirdparty_buyer->tva_intra.
" buyer country=".$buyer_country_code.
", buyer in cee=".$buyer_in_cee.
", idprod=".$idprod.
", idprodfournprice=".$idprodfournprice.
", SERVICE_ARE_ECOMMERCE_200238EC=".(
getDolGlobalString(
'SERVICES_ARE_ECOMMERCE_200238EC') ? $conf->global->SERVICES_ARE_ECOMMERCE_200238EC :
''));
6923 if ($seller_in_cee && $buyer_in_cee) {
6924 $isacompany = $thirdparty_buyer->
isACompany();
6925 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
6926 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
6940 if (!$seller_use_vat) {
6946 if (($seller_country_code == $buyer_country_code)
6947 || (in_array($seller_country_code, array(
'FR',
'MC')) && in_array($buyer_country_code, array(
'FR',
'MC')))) {
6951 if ($seller_country_code ==
'IN' &&
getDolGlobalString(
'MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA')) {
6955 if (preg_match(
'/C+S-(\d+)/', $tmpvat, $reg) && $thirdparty_seller->state_id != $thirdparty_buyer->state_id) {
6957 $tmpvat = str_replace(
"C+S",
"I", $tmpvat);
6958 } elseif (preg_match(
'/I-(\d+)/', $tmpvat, $reg) && $thirdparty_seller->state_id == $thirdparty_buyer->state_id) {
6960 $tmpvat = str_replace(
"I",
"C+S", $tmpvat);
6972 if (($seller_in_cee && $buyer_in_cee)) {
6973 $isacompany = $thirdparty_buyer->
isACompany();
6974 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
6975 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
6992 if (
getDolGlobalString(
'MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC') && empty($buyer_in_cee)) {
6993 $isacompany = $thirdparty_buyer->
isACompany();
7021 if ($idprodfournprice > 0) {
7022 if (!class_exists(
'ProductFournisseur')) {
7023 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
7026 $prodprice->fetch_product_fournisseur_price($idprodfournprice);
7027 return $prodprice->fourn_tva_npr;
7028 } elseif ($idprod > 0) {
7029 if (!class_exists(
'Product')) {
7030 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
7033 $prod->fetch($idprod);
7034 return $prod->tva_npr;
7057 if (!is_object($thirdparty_seller)) {
7060 if (!is_object($thirdparty_buyer)) {
7065 if ($mysoc->country_code ==
'ES') {
7066 if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) {
7071 if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) {
7074 if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj ==
'localtax1off') {
7078 } elseif ($local == 2) {
7080 if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) {
7083 if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj ==
'localtax2off') {
7088 if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
7103function yn($yesno, $case = 1, $color = 0)
7107 $result =
'unknown';
7109 if ($yesno == 1 || (isset($yesno) && (strtolower($yesno) ==
'yes' || strtolower($yesno) ==
'true'))) {
7110 $result = $langs->trans(
'yes');
7111 if ($case == 1 || $case == 3) {
7112 $result = $langs->trans(
"Yes");
7115 $result =
'<input type="checkbox" value="1" checked disabled>';
7118 $result =
'<input type="checkbox" value="1" checked disabled> '.$result;
7122 } elseif ($yesno == 0 || strtolower($yesno) ==
'no' || strtolower($yesno) ==
'false') {
7123 $result = $langs->trans(
"no");
7124 if ($case == 1 || $case == 3) {
7125 $result = $langs->trans(
"No");
7128 $result =
'<input type="checkbox" value="0" disabled>';
7131 $result =
'<input type="checkbox" value="0" disabled> '.$result;
7137 $classname =
'error';
7141 return '<span class="'.$classname.
'">'.$result.
'</span>';
7161function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart =
'')
7165 if (empty($modulepart) && !empty($object->module)) {
7166 $modulepart = $object->module;
7171 $arrayforoldpath = array(
'cheque',
'category',
'holiday',
'supplier_invoice',
'invoice_supplier',
'mailing',
'supplier_payment');
7173 $arrayforoldpath[] =
'product';
7175 if (!empty($level) && in_array($modulepart, $arrayforoldpath)) {
7177 if (empty($alpha)) {
7178 $num = preg_replace(
'/([^0-9])/i',
'', $num);
7180 $num = preg_replace(
'/^.*\-/i',
'', $num);
7182 $num = substr(
"000".$num, -$level);
7184 $path = substr($num, 0, 1);
7187 $path = substr($num, 1, 1).
'/'.substr($num, 0, 1);
7190 $path = substr($num, 2, 1).
'/'.substr($num, 1, 1).
'/'.substr($num, 0, 1);
7200 if (empty($withoutslash) && !empty($path)) {
7219 dol_syslog(
"functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
7222 if (@is_dir($dir_osencoded)) {
7230 if (!empty($dataroot)) {
7232 $dir = str_replace($dataroot.
'/',
'', $dir);
7233 $ccdir = $dataroot.
'/';
7236 $cdir = explode(
"/", $dir);
7237 $num = count($cdir);
7238 for ($i = 0; $i < $num; $i++) {
7240 $ccdir .=
'/'.$cdir[$i];
7242 $ccdir .= $cdir[$i];
7245 if (preg_match(
"/^.:$/", $ccdir, $regs)) {
7253 if (!@is_dir($ccdir_osencoded)) {
7254 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG);
7257 $dirmaskdec = octdec((
string) $newmask);
7258 if (empty($newmask)) {
7259 $dirmaskdec = !
getDolGlobalString(
'MAIN_UMASK') ? octdec(
'0755') : octdec($conf->global->MAIN_UMASK);
7261 $dirmaskdec |= octdec(
'0111');
7262 if (!@mkdir($ccdir_osencoded, $dirmaskdec)) {
7264 dol_syslog(
"functions.lib::dol_mkdir: Fails to create directory '".$ccdir.
"' or directory already exists.", LOG_WARNING);
7267 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' created", LOG_DEBUG);
7276 return ($nberr ? -$nberr : $nbcreated);
7291 if (!empty($newmask)) {
7292 @chmod($filepath, octdec($newmask));
7294 @chmod($filepath, octdec($conf->global->MAIN_UMASK));
7306 return '<span class="fieldrequired">*</span>';
7326function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
'UTF-8', $strip_tags = 0, $removedoublespaces = 1)
7328 if (is_null($stringtoclean)) {
7332 if ($removelinefeed == 2) {
7333 $stringtoclean = preg_replace(
'/<br[^>]*>(\n|\r)+/ims',
'<br>', $stringtoclean);
7335 $temp = preg_replace(
'/<br[^>]*>/i',
"\n", $stringtoclean);
7340 $temp = str_replace(
'< ',
'__ltspace__', $temp);
7343 $temp = strip_tags($temp);
7346 $pattern =
"/<[^<>]+>/";
7353 $tempbis = str_replace(
'<>',
'', $temp);
7354 $tempbis = preg_replace($pattern,
'', $tempbis);
7356 }
while ($tempbis != $temp);
7361 $temp = preg_replace(
'/<+([a-z]+)/i',
'\1', $temp);
7367 if ($removelinefeed == 1) {
7368 $temp = str_replace(array(
"\r\n",
"\r",
"\n"),
" ", $temp);
7372 if ($removedoublespaces) {
7373 while (strpos($temp,
" ")) {
7374 $temp = str_replace(
" ",
" ", $temp);
7378 $temp = str_replace(
'__ltspace__',
'< ', $temp);
7398function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $removeclassattribute = 1, $cleanalsojavascript = 0, $allowiframe = 0, $allowed_tags = array(), $allowlink = 0)
7400 if (empty($allowed_tags)) {
7401 $allowed_tags = array(
7402 "html",
"head",
"meta",
"body",
"article",
"a",
"abbr",
"b",
"blockquote",
"br",
"cite",
"div",
"dl",
"dd",
"dt",
"em",
"font",
"img",
"ins",
"hr",
"i",
"li",
7403 "ol",
"p",
"q",
"s",
"span",
"strike",
"strong",
"title",
"table",
"tr",
"th",
"td",
"u",
"ul",
"sup",
"sub",
"blockquote",
"pre",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
7404 "header",
"footer",
"nav",
"section",
"menu",
"menuitem"
7407 $allowed_tags[] =
"comment";
7409 if (!in_array(
'iframe', $allowed_tags)) {
7410 $allowed_tags[] =
"iframe";
7414 if (!in_array(
'link', $allowed_tags)) {
7415 $allowed_tags[] =
"link";
7419 $allowed_tags_string = join(
"><", $allowed_tags);
7420 $allowed_tags_string =
'<'.$allowed_tags_string.
'>';
7422 $stringtoclean = str_replace(
'<!DOCTYPE html>',
'__!DOCTYPE_HTML__', $stringtoclean);
7427 $stringtoclean = preg_replace(
'/<!--([^>]*)-->/',
'<comment>\1</comment>', $stringtoclean);
7429 $stringtoclean = preg_replace(
'/:/i',
':', $stringtoclean);
7430 $stringtoclean = preg_replace(
'/:|�+58|:/i',
'', $stringtoclean);
7432 $temp = strip_tags($stringtoclean, $allowed_tags_string);
7434 if ($cleanalsosomestyles) {
7435 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/i',
'', $temp);
7437 if ($removeclassattribute) {
7438 $temp = preg_replace(
'/(<[^>]+)\s+class=((["\']).*?\\3|\\w*)/i',
'\\1', $temp);
7443 if ($cleanalsojavascript) {
7444 $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);
7447 $temp = str_replace(
'__!DOCTYPE_HTML__',
'<!DOCTYPE html>', $temp);
7449 $temp = preg_replace(
'/<comment>([^>]*)<\/comment>/',
'<!--\1-->', $temp);
7469 if (is_null($allowed_attributes)) {
7470 $allowed_attributes = array(
7471 "allow",
"allowfullscreen",
"alt",
"class",
"contenteditable",
"data-html",
"frameborder",
"height",
"href",
"id",
"name",
"src",
"style",
"target",
"title",
"width",
7473 "header",
"footer",
"nav",
"section",
"menu",
"menuitem"
7477 if (class_exists(
'DOMDocument') && !empty($stringtoclean)) {
7478 $stringtoclean =
'<?xml encoding="UTF-8"><html><body>'.$stringtoclean.
'</body></html>';
7481 $dom =
new DOMDocument(
null,
'UTF-8');
7482 $dom->loadHTML($stringtoclean, LIBXML_ERR_NONE|LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD|LIBXML_NONET|LIBXML_NOWARNING|LIBXML_NOXMLDECL);
7484 if (is_object($dom)) {
7485 for ($els = $dom->getElementsByTagname(
'*'), $i = $els->length - 1; $i >= 0; $i--) {
7486 for ($attrs = $els->item($i)->attributes, $ii = $attrs->length - 1; $ii >= 0; $ii--) {
7488 if (!empty($attrs->item($ii)->name)) {
7489 if (! in_array($attrs->item($ii)->name, $allowed_attributes)) {
7491 $els->item($i)->removeAttribute($attrs->item($ii)->name);
7492 } elseif (in_array($attrs->item($ii)->name, array(
'style'))) {
7494 $valuetoclean = $attrs->item($ii)->value;
7496 if (isset($valuetoclean)) {
7498 $oldvaluetoclean = $valuetoclean;
7499 $valuetoclean = preg_replace(
'/\/\*.*\*\//m',
'', $valuetoclean);
7500 $valuetoclean = preg_replace(
'/position\s*:\s*[a-z]+/mi',
'', $valuetoclean);
7501 if ($els->item($i)->tagName ==
'a') {
7502 $valuetoclean = preg_replace(
'/display\s*:/mi',
'', $valuetoclean);
7503 $valuetoclean = preg_replace(
'/z-index\s*:/mi',
'', $valuetoclean);
7504 $valuetoclean = preg_replace(
'/\s+(top|left|right|bottom)\s*:/mi',
'', $valuetoclean);
7508 $valuetoclean = preg_replace(
'/(logout|passwordforgotten)\.php/mi',
'', $valuetoclean);
7509 $valuetoclean = preg_replace(
'/action=/mi',
'', $valuetoclean);
7510 }
while ($oldvaluetoclean != $valuetoclean);
7513 $attrs->item($ii)->value = $valuetoclean;
7520 $return = $dom->saveHTML();
7523 $return = preg_replace(
'/^'.preg_quote(
'<?xml encoding="UTF-8">',
'/').
'/',
'', $return);
7524 $return = preg_replace(
'/^'.preg_quote(
'<html><body>',
'/').
'/',
'', $return);
7525 $return = preg_replace(
'/'.preg_quote(
'</body></html>',
'/').
'$/',
'', $return);
7526 return trim($return);
7528 return $stringtoclean;
7545 $temp = $stringtoclean;
7546 foreach ($disallowed_tags as $tagtoremove) {
7547 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'>/',
'', $temp);
7548 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'\s+[^>]*>/',
'', $temp);
7551 if ($cleanalsosomestyles) {
7552 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/',
'', $temp);
7570 if ($nboflines == 1) {
7572 $firstline = preg_replace(
'/<br[^>]*>.*$/s',
'', $text);
7573 $firstline = preg_replace(
'/<div[^>]*>.*$/s',
'', $firstline);
7576 $firstline = preg_replace(
'/[\n\r].*/',
'', $text);
7581 return $firstline.(isset($firstline) && isset($text) && (strlen($firstline) != strlen($text)) ?
'...' :
'');
7585 $text = preg_replace(
'/\n/',
'', $text);
7587 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7589 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7592 $text = strtr($text, $repTable);
7593 if ($charset ==
'UTF-8') {
7594 $pattern =
'/(<br[^>]*>)/Uu';
7597 $pattern =
'/(<br[^>]*>)/U';
7599 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
7604 $lastaddediscontent = 1;
7605 while ($countline < $nboflines && isset($a[$i])) {
7606 if (preg_match(
'/<br[^>]*>/', $a[$i])) {
7607 if (array_key_exists($i+1, $a) && !empty($a[$i+1])) {
7608 $firstline .= ($ishtml ?
"<br>\n" :
"\n");
7610 if (!$lastaddediscontent) {
7613 $lastaddediscontent = 0;
7616 $firstline .= $a[$i];
7617 $lastaddediscontent = 1;
7623 $adddots = (isset($a[$i]) && (!preg_match(
'/<br[^>]*>/', $a[$i]) || (array_key_exists($i+1, $a) && !empty($a[$i+1]))));
7625 $ret = $firstline.($adddots ?
'...' :
'');
7643function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml =
false)
7645 if (is_null($stringtoencode)) {
7650 return nl2br($stringtoencode, $forxml);
7652 $ret = preg_replace(
'/(\r\n|\r|\n)/i', ($forxml ?
'<br />' :
'<br>'), $stringtoencode);
7668 if (empty($nouseofiframesandbox) &&
getDolGlobalString(
'MAIN_SECURITY_USE_SANDBOX_FOR_HTMLWITHNOJS')) {
7673 return $stringtoencode;
7675 $out = $stringtoencode;
7678 $oldstringtoclean = $out;
7680 if (!empty($out) &&
getDolGlobalString(
'MAIN_RESTRICTHTML_ONLY_VALID_HTML') && $check !=
'restricthtmlallowunvalid') {
7682 libxml_use_internal_errors(
false);
7683 if (LIBXML_VERSION < 20900) {
7686 libxml_disable_entity_loader(
true);
7689 $dom =
new DOMDocument();
7695 $out =
'<?xml encoding="UTF-8"><div class="tricktoremove">'.$out.
'</div>';
7697 $out =
'<?xml encoding="UTF-8"><div class="tricktoremove">'.dol_nl2br($out).
'</div>';
7699 $dom->loadHTML($out, LIBXML_HTML_NODEFDTD | LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOERROR | LIBXML_NOXMLDECL);
7700 $out = trim($dom->saveHTML());
7703 $out = preg_replace(
'/^<\?xml encoding="UTF-8"><div class="tricktoremove">/',
'', $out);
7704 $out = preg_replace(
'/<\/div>$/',
'', $out);
7708 $out =
'InvalidHTMLStringCantBeCleaned '.$e->getMessage();
7712 if (!empty($out) &&
getDolGlobalString(
'MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY') && $check !=
'restricthtmlallowunvalid') {
7715 if (extension_loaded(
'tidy') && class_exists(
"tidy")) {
7721 'quote-marks' =>
false,
7722 'doctype' =>
'strict',
7723 'show-body-only' =>
true,
7724 "indent-attributes" =>
false,
7725 "vertical-space" =>
false,
7737 $out = $tidy->repairString($out, $config,
'utf8');
7744 $out =
'InvalidHTMLStringCantBeCleaned '.$e->getMessage();
7749 $out = preg_replace(
'/[\x{200B}-\x{200D}\x{FEFF}]/u',
' ', $out);
7752 $out = preg_replace(
'/&(tab|newline);/i',
' ', $out);
7756 $out = preg_replace(
'/'/i',
''', $out);
7761 $out = preg_replace_callback(
'/&#(x?[0-9][0-9a-f]+;?)/i',
function ($m) {
7767 $out = preg_replace(
'/&#x?[0-9]+/i',
'', $out);
7778 $out = preg_replace(
'/'/i',
"'", $out);
7779 }
while ($oldstringtoclean != $out);
7786 $tmpout = preg_replace(
'/<img src="data:/mi',
'<__IMG_SRC_DATA__ src="data:', $out);
7787 preg_match_all(
'/(<img|url\(|<link)/i', $tmpout, $reg);
7788 $nblinks = count($reg[0]);
7789 if ($nblinks >
getDolGlobalInt(
"MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 1000)) {
7790 $out =
'ErrorTooManyLinksIntoHTMLString';
7793 if (
getDolGlobalInt(
'MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 2 || $check ==
'restricthtmlnolink') {
7795 $out =
'ErrorHTMLLinksNotAllowed';
7797 } elseif (
getDolGlobalInt(
'MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 1) {
7800 $pattern =
'/src=["\']?(http[^"\']+)|url\(["\']?(http[^\)]+)/';
7803 if (preg_match_all($pattern, $out, $matches)) {
7805 $urls = $matches[1];
7808 foreach ($urls as $url) {
7810 echo
"Found url = ".$url .
"\n";
7813 $out =
'ErrorHTMLExternalLinksNotAllowed';
7843function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom =
'UTF-8', $removelasteolbr = 1)
7845 if (is_null($stringtoencode)) {
7849 $newstring = $stringtoencode;
7851 $newstring = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
'<br>', $newstring);
7852 if ($removelasteolbr) {
7853 $newstring = preg_replace(
'/<br>$/i',
'', $newstring);
7855 $newstring = preg_replace(
'/[\x{200B}-\x{200D}\x{FEFF}]/u',
' ', $newstring);
7856 $newstring = strtr($newstring, array(
'&'=>
'__and__',
'<'=>
'__lt__',
'>'=>
'__gt__',
'"'=>
'__dquot__'));
7858 $newstring = strtr($newstring, array(
'__and__'=>
'&',
'__lt__'=>
'<',
'__gt__'=>
'>',
'__dquot__'=>
'"'));
7860 if ($removelasteolbr) {
7861 $newstring = preg_replace(
'/(\r\n|\r|\n)$/i',
'', $newstring);
7880 $ret = preg_replace(
'/'.
"\r\n".
'<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"<br>", $ret);
7881 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\r\n".
'/i',
"\r\n", $ret);
7882 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\n".
'/i',
"\n", $ret);
7883 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"\n", $ret);
7895 $ret = preg_replace(
'/ $/i',
"", $stringtodecode);
7896 $ret = preg_replace(
'/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'.
"\n".
'|'.
"\r".
')+$/i',
"", $ret);
7912 if ($keepsomeentities) {
7913 $newstring = strtr($newstring, array(
'&'=>
'__andamp__',
'<'=>
'__andlt__',
'>'=>
'__andgt__',
'"'=>
'__dquot__'));
7915 $newstring = html_entity_decode((
string) $newstring, (
int) $b, (
string) $c);
7916 if ($keepsomeentities) {
7917 $newstring = strtr($newstring, array(
'__andamp__'=>
'&',
'__andlt__'=>
'<',
'__andgt__'=>
'>',
'__dquot__'=>
'"'));
7933function dol_htmlentities($string, $flags = ENT_QUOTES|ENT_SUBSTITUTE, $encoding =
'UTF-8', $double_encode =
false)
7935 return htmlentities($string, $flags, $encoding, $double_encode);
7954 for ($scursor = 0; $scursor < $len; $scursor++) {
7955 $ordchar = ord($s[$scursor]);
7957 if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) {
7960 } elseif ($ordchar > 126 && $ordchar < 160) {
7964 $out .= $s[$scursor];
7986 $arraystring = explode(
"\n", $s);
7987 $nb = count($arraystring);
8004 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8006 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8009 $text = strtr($text, $repTable);
8010 if ($charset ==
'UTF-8') {
8011 $pattern =
'/(<br[^>]*>)/Uu';
8014 $pattern =
'/(<br[^>]*>)/U';
8016 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
8018 $nblines = (int) floor((count($a) + 1) / 2);
8021 foreach ($a as $line) {
8024 $line_dec = html_entity_decode($line);
8026 $line_dec = wordwrap($line_dec, $maxlinesize,
'\n',
true);
8027 $nblines += substr_count($line_dec,
'\n');
8047 if (is_null($msg)) {
8052 if (preg_match(
'/<html/i', $msg)) {
8054 } elseif (preg_match(
'/<body/i', $msg)) {
8056 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
8058 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
8060 } elseif (preg_match(
'/<br/i', $msg)) {
8066 $msg = preg_replace(
'/https?:\/\/[^"\'\s]+/i',
'', $msg);
8067 if (preg_match(
'/<html/i', $msg)) {
8069 } elseif (preg_match(
'/<body/i', $msg)) {
8071 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
8073 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
8075 } elseif (preg_match(
'/<(br|hr)\/>/i', $msg)) {
8077 } elseif (preg_match(
'/<(br|hr|div|font|li|p|span|strong|table)>/i', $msg)) {
8079 } elseif (preg_match(
'/<(br|hr|div|font|li|p|span|strong|table)\s+[^<>\/]*\/?>/i', $msg)) {
8081 } elseif (preg_match(
'/<img\s+[^<>]*src[^<>]*>/i', $msg)) {
8083 } elseif (preg_match(
'/<a\s+[^<>]*href[^<>]*>/i', $msg)) {
8085 } elseif (preg_match(
'/<h[0-9]>/i', $msg)) {
8087 } elseif (preg_match(
'/&[A-Z0-9]{1,6};/i', $msg)) {
8090 } elseif (preg_match(
'/&#[0-9]{2,3};/i', $msg)) {
8114 if (!empty($invert)) {
8122 $ret .= (!empty($text1) && !empty($text2)) ? ((
dol_textishtml($text1) ||
dol_textishtml($text2)) ? ($forxml ?
"<br >\n" :
"<br>\n") :
"\n") :
"";
8142 global $db, $conf, $mysoc, $user, $extrafields;
8144 $substitutionarray = array();
8146 if ((empty($exclude) || !in_array(
'user', $exclude)) && (empty($include) || in_array(
'user', $include))) {
8150 $emailsendersignature = $user->signature;
8151 $usersignature = $user->signature;
8152 $substitutionarray = array_merge($substitutionarray, array(
8153 '__SENDEREMAIL_SIGNATURE__' => (
string) ((!
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? ($onlykey == 2 ?
dol_trunc(
'SignatureFromTheSelectedSenderProfile', 30) : $emailsendersignature) :
''),
8157 if (is_object($user)) {
8158 $substitutionarray = array_merge($substitutionarray, array(
8159 '__USER_ID__' => (
string) $user->id,
8160 '__USER_LOGIN__' => (
string) $user->login,
8161 '__USER_EMAIL__' => (
string) $user->email,
8162 '__USER_PHONE__' => (
string)
dol_print_phone($user->office_phone,
'', 0, 0,
'',
" ",
'',
'', -1),
8163 '__USER_PHONEPRO__' => (
string)
dol_print_phone($user->user_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
8164 '__USER_PHONEMOBILE__' => (
string)
dol_print_phone($user->personal_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
8165 '__USER_FAX__' => (
string) $user->office_fax,
8166 '__USER_LASTNAME__' => (
string) $user->lastname,
8167 '__USER_FIRSTNAME__' => (
string) $user->firstname,
8168 '__USER_FULLNAME__' => (
string) $user->getFullName($outputlangs),
8169 '__USER_SUPERVISOR_ID__' => (
string) ($user->fk_user ? $user->fk_user :
'0'),
8170 '__USER_JOB__' => (
string) $user->job,
8172 '__USER_VCARD_URL__' => (string) $user->getOnlineVirtualCardUrl(
'',
'external')
8176 if ((empty($exclude) || !in_array(
'mycompany', $exclude)) && is_object($mysoc) && (empty($include) || in_array(
'mycompany', $include))) {
8177 $substitutionarray = array_merge($substitutionarray, array(
8178 '__MYCOMPANY_NAME__' => $mysoc->name,
8179 '__MYCOMPANY_EMAIL__' => $mysoc->email,
8180 '__MYCOMPANY_PHONE__' =>
dol_print_phone($mysoc->phone,
'', 0, 0,
'',
" ",
'',
'', -1),
8181 '__MYCOMPANY_FAX__' =>
dol_print_phone($mysoc->fax,
'', 0, 0,
'',
" ",
'',
'', -1),
8182 '__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
8183 '__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
8184 '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
8185 '__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
8186 '__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
8187 '__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
8188 '__MYCOMPANY_CAPITAL__' => $mysoc->capital,
8189 '__MYCOMPANY_FULLADDRESS__' => (method_exists($mysoc,
'getFullAddress') ? $mysoc->getFullAddress(1,
', ') :
''),
8190 '__MYCOMPANY_ADDRESS__' => $mysoc->address,
8191 '__MYCOMPANY_ZIP__' => $mysoc->zip,
8192 '__MYCOMPANY_TOWN__' => $mysoc->town,
8193 '__MYCOMPANY_COUNTRY__' => $mysoc->country,
8194 '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id,
8195 '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code,
8196 '__MYCOMPANY_CURRENCY_CODE__' => $conf->currency
8200 if (($onlykey || is_object($object)) && (empty($exclude) || !in_array(
'object', $exclude)) && (empty($include) || in_array(
'object', $include))) {
8202 $substitutionarray[
'__ID__'] =
'__ID__';
8203 $substitutionarray[
'__REF__'] =
'__REF__';
8204 $substitutionarray[
'__NEWREF__'] =
'__NEWREF__';
8205 $substitutionarray[
'__LABEL__'] =
'__LABEL__';
8206 $substitutionarray[
'__REF_CLIENT__'] =
'__REF_CLIENT__';
8207 $substitutionarray[
'__REF_SUPPLIER__'] =
'__REF_SUPPLIER__';
8208 $substitutionarray[
'__NOTE_PUBLIC__'] =
'__NOTE_PUBLIC__';
8209 $substitutionarray[
'__NOTE_PRIVATE__'] =
'__NOTE_PRIVATE__';
8210 $substitutionarray[
'__EXTRAFIELD_XXX__'] =
'__EXTRAFIELD_XXX__';
8212 if (isModEnabled(
"societe")) {
8213 $substitutionarray[
'__THIRDPARTY_ID__'] =
'__THIRDPARTY_ID__';
8214 $substitutionarray[
'__THIRDPARTY_NAME__'] =
'__THIRDPARTY_NAME__';
8215 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
'__THIRDPARTY_NAME_ALIAS__';
8216 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
'__THIRDPARTY_CODE_CLIENT__';
8217 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
'__THIRDPARTY_CODE_FOURNISSEUR__';
8218 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
'__THIRDPARTY_EMAIL__';
8219 $substitutionarray[
'__THIRDPARTY_PHONE__'] =
'__THIRDPARTY_PHONE__';
8220 $substitutionarray[
'__THIRDPARTY_FAX__'] =
'__THIRDPARTY_FAX__';
8221 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
'__THIRDPARTY_ADDRESS__';
8222 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
'__THIRDPARTY_ZIP__';
8223 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
'__THIRDPARTY_TOWN__';
8224 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
'__THIRDPARTY_IDPROF1__';
8225 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
'__THIRDPARTY_IDPROF2__';
8226 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
'__THIRDPARTY_IDPROF3__';
8227 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
'__THIRDPARTY_IDPROF4__';
8228 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
'__THIRDPARTY_IDPROF5__';
8229 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
'__THIRDPARTY_IDPROF6__';
8230 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
'__THIRDPARTY_TVAINTRA__';
8231 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] =
'__THIRDPARTY_NOTE_PUBLIC__';
8232 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] =
'__THIRDPARTY_NOTE_PRIVATE__';
8234 if (isModEnabled(
'adherent') && (!is_object($object) || $object->element ==
'adherent') && (empty($exclude) || !in_array(
'member', $exclude)) && (empty($include) || in_array(
'member', $include))) {
8235 $substitutionarray[
'__MEMBER_ID__'] =
'__MEMBER_ID__';
8236 $substitutionarray[
'__MEMBER_CIVILITY__'] =
'__MEMBER_CIVILITY__';
8237 $substitutionarray[
'__MEMBER_FIRSTNAME__'] =
'__MEMBER_FIRSTNAME__';
8238 $substitutionarray[
'__MEMBER_LASTNAME__'] =
'__MEMBER_LASTNAME__';
8239 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'Login and pass of the external user account';
8244 if (isModEnabled(
'ticket') && (!is_object($object) || $object->element ==
'ticket') && (empty($exclude) || !in_array(
'ticket', $exclude)) && (empty($include) || in_array(
'ticket', $include))) {
8245 $substitutionarray[
'__TICKET_TRACKID__'] =
'__TICKET_TRACKID__';
8246 $substitutionarray[
'__TICKET_SUBJECT__'] =
'__TICKET_SUBJECT__';
8247 $substitutionarray[
'__TICKET_TYPE__'] =
'__TICKET_TYPE__';
8248 $substitutionarray[
'__TICKET_SEVERITY__'] =
'__TICKET_SEVERITY__';
8249 $substitutionarray[
'__TICKET_CATEGORY__'] =
'__TICKET_CATEGORY__';
8250 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
'__TICKET_ANALYTIC_CODE__';
8251 $substitutionarray[
'__TICKET_MESSAGE__'] =
'__TICKET_MESSAGE__';
8252 $substitutionarray[
'__TICKET_PROGRESSION__'] =
'__TICKET_PROGRESSION__';
8253 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
'__TICKET_USER_ASSIGN__';
8256 if (isModEnabled(
'recruitment') && (!is_object($object) || $object->element ==
'recruitmentcandidature') && (empty($exclude) || !in_array(
'recruitment', $exclude)) && (empty($include) || in_array(
'recruitment', $include))) {
8257 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
'__CANDIDATE_FULLNAME__';
8258 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] =
'__CANDIDATE_FIRSTNAME__';
8259 $substitutionarray[
'__CANDIDATE_LASTNAME__'] =
'__CANDIDATE_LASTNAME__';
8261 if (isModEnabled(
'project') && (empty($exclude) || !in_array(
'project', $exclude)) && (empty($include) || in_array(
'project', $include))) {
8262 $substitutionarray[
'__PROJECT_ID__'] =
'__PROJECT_ID__';
8263 $substitutionarray[
'__PROJECT_REF__'] =
'__PROJECT_REF__';
8264 $substitutionarray[
'__PROJECT_NAME__'] =
'__PROJECT_NAME__';
8268 if (isModEnabled(
'contrat') && (!is_object($object) || $object->element ==
'contract') && (empty($exclude) || !in_array(
'contract', $exclude)) && (empty($include) || in_array(
'contract', $include))) {
8269 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
'Highest date planned for a service start';
8270 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
'Highest date and hour planned for service start';
8271 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
'Lowest data for planned expiration of service';
8272 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
'Lowest date and hour for planned expiration of service';
8274 if (isModEnabled(
"propal") && (!is_object($object) || $object->element ==
'propal') && (empty($exclude) || !in_array(
'propal', $exclude)) && (empty($include) || in_array(
'propal', $include))) {
8275 $substitutionarray[
'__ONLINE_SIGN_URL__'] =
'ToOfferALinkForOnlineSignature';
8277 if (isModEnabled(
"ficheinter") && (!is_object($object) || $object->element ==
'fichinter') && (empty($exclude) || !in_array(
'intervention', $exclude)) && (empty($include) || in_array(
'intervention', $include))) {
8278 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] =
'ToOfferALinkForOnlineSignature';
8280 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'UrlToPayOnlineIfApplicable';
8281 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'TextAndUrlToPayOnlineIfApplicable';
8282 $substitutionarray[
'__SECUREKEYPAYMENT__'] =
'Security key (if key is not unique per record)';
8283 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
'Security key for payment on a member subscription (one key per member)';
8284 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
'Security key for payment on an order';
8285 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
'Security key for payment on an invoice';
8286 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
'Security key for payment on a service of a contract';
8288 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'Direct download url of a proposal';
8289 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'Direct download url of an order';
8290 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'Direct download url of an invoice';
8291 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'Direct download url of a contract';
8292 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'Direct download url of a supplier proposal';
8294 if (isModEnabled(
"expedition") && (!is_object($object) || $object->element ==
'shipping')) {
8295 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
'Shipping tracking number';
8296 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
'Shipping tracking url';
8297 $substitutionarray[
'__SHIPPINGMETHOD__'] =
'Shipping method';
8299 if (isModEnabled(
"reception") && (!is_object($object) || $object->element ==
'reception')) {
8300 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
'Shippin tracking number of shipment';
8301 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
'Shipping tracking url';
8304 $substitutionarray[
'__ID__'] = $object->id;
8305 $substitutionarray[
'__REF__'] = $object->ref;
8306 $substitutionarray[
'__NEWREF__'] = $object->newref;
8307 $substitutionarray[
'__LABEL__'] = (isset($object->label) ? $object->label : (isset($object->title) ? $object->title :
null));
8308 $substitutionarray[
'__REF_CLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer :
null));
8309 $substitutionarray[
'__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier :
null);
8310 $substitutionarray[
'__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public :
null);
8311 $substitutionarray[
'__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private :
null);
8313 $date_delivery =
null;
8314 if (property_exists($object,
'date_delivery')) {
8315 $date_delivery = $object->date_delivery;
8316 } elseif (property_exists($object,
'delivery_date')) {
8317 $date_delivery = $object->delivery_date;
8319 $substitutionarray[
'__DATE_DELIVERY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
'day', 0, $outputlangs) :
'');
8320 $substitutionarray[
'__DATE_DELIVERY_DAY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%d") :
'');
8321 $substitutionarray[
'__DATE_DELIVERY_DAY_TEXT__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%A") :
'');
8322 $substitutionarray[
'__DATE_DELIVERY_MON__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%m") :
'');
8323 $substitutionarray[
'__DATE_DELIVERY_MON_TEXT__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%b") :
'');
8324 $substitutionarray[
'__DATE_DELIVERY_YEAR__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%Y") :
'');
8325 $substitutionarray[
'__DATE_DELIVERY_HH__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%H") :
'');
8326 $substitutionarray[
'__DATE_DELIVERY_MM__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%M") :
'');
8327 $substitutionarray[
'__DATE_DELIVERY_SS__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%S") :
'');
8330 $substitutionarray[
'__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer :
null));
8331 $substitutionarray[
'__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier :
null);
8332 $substitutionarray[
'__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
'day', 0, $outputlangs) :
'');
8333 $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 :
'')) :
'');
8334 $substitutionarray[
'__EXPIRATION_DATE__'] = (isset($object->fin_validite) ?
dol_print_date($object->fin_validite,
'daytext') :
'');
8336 if (is_object($object) && ($object->element ==
'adherent' || $object->element ==
'member') && $object->id > 0) {
8337 $birthday = (empty($object->birth) ?
'' :
dol_print_date($object->birth,
'day'));
8339 $substitutionarray[
'__MEMBER_ID__'] = (isset($object->id) ? $object->id :
'');
8340 if (method_exists($object,
'getCivilityLabel')) {
8341 $substitutionarray[
'__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
8343 $substitutionarray[
'__MEMBER_FIRSTNAME__'] = (isset($object->firstname) ? $object->firstname :
'');
8344 $substitutionarray[
'__MEMBER_LASTNAME__'] = (isset($object->lastname) ? $object->lastname :
'');
8345 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'';
8346 if (method_exists($object,
'getFullName')) {
8347 $substitutionarray[
'__MEMBER_FULLNAME__'] = $object->getFullName($outputlangs);
8349 $substitutionarray[
'__MEMBER_COMPANY__'] = (isset($object->societe) ? $object->societe :
'');
8350 $substitutionarray[
'__MEMBER_ADDRESS__'] = (isset($object->address) ? $object->address :
'');
8351 $substitutionarray[
'__MEMBER_ZIP__'] = (isset($object->zip) ? $object->zip :
'');
8352 $substitutionarray[
'__MEMBER_TOWN__'] = (isset($object->town) ? $object->town :
'');
8353 $substitutionarray[
'__MEMBER_COUNTRY__'] = (isset($object->country) ? $object->country :
'');
8354 $substitutionarray[
'__MEMBER_EMAIL__'] = (isset($object->email) ? $object->email :
'');
8355 $substitutionarray[
'__MEMBER_BIRTH__'] = (isset($birthday) ? $birthday :
'');
8356 $substitutionarray[
'__MEMBER_PHOTO__'] = (isset($object->photo) ? $object->photo :
'');
8357 $substitutionarray[
'__MEMBER_LOGIN__'] = (isset($object->login) ? $object->login :
'');
8358 $substitutionarray[
'__MEMBER_PASSWORD__'] = (isset($object->pass) ? $object->pass :
'');
8359 $substitutionarray[
'__MEMBER_PHONE__'] = (isset($object->phone) ?
dol_print_phone($object->phone) :
'');
8360 $substitutionarray[
'__MEMBER_PHONEPRO__'] = (isset($object->phone_perso) ?
dol_print_phone($object->phone_perso) :
'');
8361 $substitutionarray[
'__MEMBER_PHONEMOBILE__'] = (isset($object->phone_mobile) ?
dol_print_phone($object->phone_mobile) :
'');
8362 $substitutionarray[
'__MEMBER_TYPE__'] = (isset($object->type) ? $object->type :
'');
8363 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE__'] =
dol_print_date($object->first_subscription_date,
'day');
8364 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = (isset($object->first_subscription_date_start) ?
dol_print_date($object->first_subscription_date_start,
'day') :
'');
8365 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = (isset($object->first_subscription_date_end) ?
dol_print_date($object->first_subscription_date_end,
'day') :
'');
8366 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE__'] =
dol_print_date($object->last_subscription_date,
'day');
8367 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] =
dol_print_date($object->last_subscription_date_start,
'day');
8368 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] =
dol_print_date($object->last_subscription_date_end,
'day');
8371 if (is_object($object) && $object->element ==
'societe') {
8372 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object($object) ? $object->id :
'');
8373 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object($object) ? $object->name :
'');
8374 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object($object) ? $object->name_alias :
'');
8375 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object($object) ? $object->code_client :
'');
8376 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object) ? $object->code_fournisseur :
'');
8377 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object($object) ? $object->email :
'');
8378 $substitutionarray[
'__THIRDPARTY_PHONE__'] = (is_object($object) ?
dol_print_phone($object->phone) :
'');
8379 $substitutionarray[
'__THIRDPARTY_FAX__'] = (is_object($object) ?
dol_print_phone($object->fax) :
'');
8380 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object($object) ? $object->address :
'');
8381 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object($object) ? $object->zip :
'');
8382 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object($object) ? $object->town :
'');
8383 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object($object) ? $object->country_id :
'');
8384 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object) ? $object->country_code :
'');
8385 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object($object) ? $object->idprof1 :
'');
8386 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object($object) ? $object->idprof2 :
'');
8387 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object($object) ? $object->idprof3 :
'');
8388 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object($object) ? $object->idprof4 :
'');
8389 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object($object) ? $object->idprof5 :
'');
8390 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object($object) ? $object->idprof6 :
'');
8391 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object($object) ? $object->tva_intra :
'');
8392 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object) ?
dol_htmlentitiesbr($object->note_public) :
'');
8393 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object) ?
dol_htmlentitiesbr($object->note_private) :
'');
8394 } elseif (is_object($object->thirdparty)) {
8395 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->id :
'');
8396 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object($object->thirdparty) ? $object->thirdparty->name :
'');
8397 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty) ? $object->thirdparty->name_alias :
'');
8398 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_client :
'');
8399 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_fournisseur :
'');
8400 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty) ? $object->thirdparty->email :
'');
8401 $substitutionarray[
'__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty) ?
dol_print_phone($object->thirdparty->phone) :
'');
8402 $substitutionarray[
'__THIRDPARTY_FAX__'] = (is_object($object->thirdparty) ?
dol_print_phone($object->thirdparty->fax) :
'');
8403 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty) ? $object->thirdparty->address :
'');
8404 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty) ? $object->thirdparty->zip :
'');
8405 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty) ? $object->thirdparty->town :
'');
8406 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_id :
'');
8407 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_code :
'');
8408 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof1 :
'');
8409 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof2 :
'');
8410 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof3 :
'');
8411 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof4 :
'');
8412 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof5 :
'');
8413 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof6 :
'');
8414 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty) ? $object->thirdparty->tva_intra :
'');
8415 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object->thirdparty) ?
dol_htmlentitiesbr($object->thirdparty->note_public) :
'');
8416 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object->thirdparty) ?
dol_htmlentitiesbr($object->thirdparty->note_private) :
'');
8419 if (is_object($object) && $object->element ==
'recruitmentcandidature') {
8420 $substitutionarray[
'__CANDIDATE_FULLNAME__'] = $object->getFullName($outputlangs);
8421 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname :
'';
8422 $substitutionarray[
'__CANDIDATE_LASTNAME__'] = isset($object->lastname) ? $object->lastname :
'';
8424 if (is_object($object) && $object->element ==
'conferenceorboothattendee') {
8425 $substitutionarray[
'__ATTENDEE_FULLNAME__'] = $object->getFullName($outputlangs);
8426 $substitutionarray[
'__ATTENDEE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname :
'';
8427 $substitutionarray[
'__ATTENDEE_LASTNAME__'] = isset($object->lastname) ? $object->lastname :
'';
8430 if (is_object($object) && $object->element ==
'project') {
8431 $substitutionarray[
'__PROJECT_ID__'] = $object->id;
8432 $substitutionarray[
'__PROJECT_REF__'] = $object->ref;
8433 $substitutionarray[
'__PROJECT_NAME__'] = $object->title;
8434 } elseif (is_object($object)) {
8436 if (!empty($object->project)) {
8437 $project = $object->project;
8438 } elseif (!empty($object->projet)) {
8439 $project = $object->projet;
8441 if (!is_null($project) && is_object($project)) {
8442 $substitutionarray[
'__PROJECT_ID__'] = $project->id;
8443 $substitutionarray[
'__PROJECT_REF__'] = $project->ref;
8444 $substitutionarray[
'__PROJECT_NAME__'] = $project->title;
8448 if (!empty($object->fk_project) && $object->fk_project > 0) {
8449 $project_id = $object->fk_project;
8450 } elseif (!empty($object->fk_projet) && $object->fk_projet > 0) {
8451 $project_id = $object->fk_project;
8453 if ($project_id > 0) {
8455 $substitutionarray[
'__PROJECT_ID__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
8456 $substitutionarray[
'__PROJECT_REF__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
8457 $substitutionarray[
'__PROJECT_NAME__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
8462 if (is_object($object) && $object->element ==
'shipping') {
8463 $substitutionarray[
'__SHIPPINGTRACKNUM__'] = $object->tracking_number;
8464 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] = $object->tracking_url;
8465 $substitutionarray[
'__SHIPPINGMETHOD__'] = $object->shipping_method;
8467 if (is_object($object) && $object->element ==
'reception') {
8468 $substitutionarray[
'__RECEPTIONTRACKNUM__'] = $object->tracking_number;
8469 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] = $object->tracking_url;
8472 if (is_object($object) && $object->element ==
'contrat' && $object->id > 0 && is_array($object->lines)) {
8473 $dateplannedstart =
'';
8474 $datenextexpiration =
'';
8475 foreach ($object->lines as $line) {
8476 if ($line->date_start > $dateplannedstart) {
8477 $dateplannedstart = $line->date_start;
8479 if ($line->statut == 4 && $line->date_end && (!$datenextexpiration || $line->date_end < $datenextexpiration)) {
8480 $datenextexpiration = $line->date_end;
8483 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
dol_print_date($dateplannedstart,
'day');
8484 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
dol_print_date($dateplannedstart,
'standard');
8485 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
dol_print_date($datenextexpiration,
'day');
8486 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
dol_print_date($datenextexpiration,
'standard');
8489 if (is_object($object) && $object->element ==
'ticket') {
8490 $substitutionarray[
'__TICKET_TRACKID__'] = $object->track_id;
8491 $substitutionarray[
'__REF__'] = $object->ref;
8492 $substitutionarray[
'__TICKET_SUBJECT__'] = $object->subject;
8493 $substitutionarray[
'__TICKET_TYPE__'] = $object->type_code;
8494 $substitutionarray[
'__TICKET_SEVERITY__'] = $object->severity_code;
8495 $substitutionarray[
'__TICKET_CATEGORY__'] = $object->category_code;
8496 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] = $object->category_code;
8497 $substitutionarray[
'__TICKET_MESSAGE__'] = $object->message;
8498 $substitutionarray[
'__TICKET_PROGRESSION__'] = $object->progress;
8499 $userstat =
new User($db);
8500 if ($object->fk_user_assign > 0) {
8501 $userstat->fetch($object->fk_user_assign);
8502 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
8505 if ($object->fk_user_create > 0) {
8506 $userstat->fetch($object->fk_user_create);
8507 $substitutionarray[
'__USER_CREATE__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
8512 if ($object->table_element && $object->id > 0) {
8513 if (!is_object($extrafields)) {
8516 $extrafields->fetch_name_optionals_label($object->table_element,
true);
8518 if ($object->fetch_optionals() > 0) {
8519 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label']) > 0) {
8520 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $label) {
8521 if ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'date') {
8522 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_date($object->array_options[
'options_'.$key],
'day');
8523 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] =
dol_print_date($object->array_options[
'options_'.$key],
'day',
'tzserver', $outputlangs);
8524 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] =
dol_print_date($object->array_options[
'options_'.$key],
'dayrfc');
8525 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'datetime') {
8526 $datetime = $object->array_options[
'options_'.$key];
8527 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
8528 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
8529 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_DAY_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'day',
'tzserver', $outputlangs) :
'');
8530 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
8531 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'phone') {
8532 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_phone($object->array_options[
'options_'.$key]);
8533 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'price') {
8534 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = $object->array_options[
'options_'.$key];
8535 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATED__'] =
price($object->array_options[
'options_'.$key]);
8536 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separator') {
8537 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = !empty($object->array_options[
'options_'.$key]) ? $object->array_options[
'options_'.$key] :
'';
8546 if (empty($substitutionarray[
'__REF__'])) {
8550 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
8551 $outputlangs->loadLangs(array(
'paypal',
'other'));
8554 $typeforonlinepayment =
'free';
8555 if (is_object($object) && $object->element ==
'commande') {
8556 $typeforonlinepayment =
'order';
8558 if (is_object($object) && $object->element ==
'facture') {
8559 $typeforonlinepayment =
'invoice';
8561 if (is_object($object) && $object->element ==
'member') {
8562 $typeforonlinepayment =
'member';
8563 if (!empty($object->last_subscription_amount)) {
8564 $amounttouse = $object->last_subscription_amount;
8567 if (is_object($object) && $object->element ==
'contrat') {
8568 $typeforonlinepayment =
'contract';
8570 if (is_object($object) && $object->element ==
'fichinter') {
8571 $typeforonlinepayment =
'ficheinter';
8574 $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray[
'__REF__'], $amounttouse);
8578 if ($object->id > 0) {
8579 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ? str_replace(
'\n',
"\n", $outputlangs->trans(
"PredefinedMailContentLink", $paymenturl)) :
'');
8580 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] = $paymenturl;
8582 if (
getDolGlobalString(
'PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD') && is_object($object) && $object->element ==
'propal') {
8583 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
8585 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'';
8587 if (
getDolGlobalString(
'ORDER_ALLOW_EXTERNAL_DOWNLOAD') && is_object($object) && $object->element ==
'commande') {
8588 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element);
8590 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'';
8592 if (
getDolGlobalString(
'INVOICE_ALLOW_EXTERNAL_DOWNLOAD') && is_object($object) && $object->element ==
'facture') {
8593 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element);
8595 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'';
8597 if (
getDolGlobalString(
'CONTRACT_ALLOW_EXTERNAL_DOWNLOAD') && is_object($object) && $object->element ==
'contrat') {
8598 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] = $object->getLastMainDocLink($object->element);
8600 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'';
8602 if (
getDolGlobalString(
'FICHINTER_ALLOW_EXTERNAL_DOWNLOAD') && is_object($object) && $object->element ==
'fichinter') {
8603 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] = $object->getLastMainDocLink($object->element);
8605 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] =
'';
8607 if (
getDolGlobalString(
'SUPPLIER_PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD') && is_object($object) && $object->element ==
'supplier_proposal') {
8608 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
8610 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'';
8613 if (is_object($object) && $object->element ==
'propal') {
8614 $substitutionarray[
'__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/comm/propal/card.php?id=".$object->id;
8615 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
8616 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'proposal', $object->ref);
8618 if (is_object($object) && $object->element ==
'commande') {
8619 $substitutionarray[
'__URL_ORDER__'] = DOL_MAIN_URL_ROOT.
"/commande/card.php?id=".$object->id;
8621 if (is_object($object) && $object->element ==
'facture') {
8622 $substitutionarray[
'__URL_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/compta/facture/card.php?id=".$object->id;
8624 if (is_object($object) && $object->element ==
'contrat') {
8625 $substitutionarray[
'__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT.
"/contrat/card.php?id=".$object->id;
8626 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
8627 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'contract', $object->ref);
8629 if (is_object($object) && $object->element ==
'fichinter') {
8630 $substitutionarray[
'__URL_FICHINTER__'] = DOL_MAIN_URL_ROOT.
"/fichinter/card.php?id=".$object->id;
8631 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
8632 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0,
'fichinter', $object->ref);
8634 if (is_object($object) && $object->element ==
'supplier_proposal') {
8635 $substitutionarray[
'__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/supplier_proposal/card.php?id=".$object->id;
8637 if (is_object($object) && $object->element ==
'shipping') {
8638 $substitutionarray[
'__URL_SHIPMENT__'] = DOL_MAIN_URL_ROOT.
"/expedition/card.php?id=".$object->id;
8642 if (is_object($object) && $object->element ==
'action') {
8643 $substitutionarray[
'__EVENT_LABEL__'] = $object->label;
8644 $substitutionarray[
'__EVENT_TYPE__'] = $outputlangs->trans(
"Action".$object->type_code);
8645 $substitutionarray[
'__EVENT_DATE__'] =
dol_print_date($object->datep,
'day',
'auto', $outputlangs);
8646 $substitutionarray[
'__EVENT_TIME__'] =
dol_print_date($object->datep,
'hour',
'auto', $outputlangs);
8650 if ((empty($exclude) || !in_array(
'objectamount', $exclude)) && (empty($include) || in_array(
'objectamount', $include))) {
8651 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functionsnumtoword.lib.php';
8653 $substitutionarray[
'__DATE_YMD__'] = is_object($object) ? (isset($object->date) ?
dol_print_date($object->date,
'day', 0, $outputlangs) :
null) :
'';
8654 $substitutionarray[
'__DATE_DUE_YMD__'] = is_object($object) ? (isset($object->date_lim_reglement) ?
dol_print_date($object->date_lim_reglement,
'day', 0, $outputlangs) :
null) :
'';
8656 $already_payed_all = 0;
8657 if (is_object($object) && ($object instanceof
Facture)) {
8658 $already_payed_all = $object->sumpayed + $object->sumdeposit + $object->sumcreditnote;
8661 $substitutionarray[
'__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht :
'';
8663 $substitutionarray[
'__AMOUNT__'] = is_object($object) ? $object->total_ttc :
'';
8664 $substitutionarray[
'__AMOUNT_TEXT__'] = is_object($object) ?
dol_convertToWord($object->total_ttc, $outputlangs,
'',
true) :
'';
8665 $substitutionarray[
'__AMOUNT_TEXTCURRENCY__'] = is_object($object) ?
dol_convertToWord($object->total_ttc, $outputlangs, $conf->currency,
true) :
'';
8667 $substitutionarray[
'__AMOUNT_REMAIN__'] = is_object($object) ?
price2num($object->total_ttc - $already_payed_all,
'MT') :
'';
8669 $substitutionarray[
'__AMOUNT_VAT__'] = is_object($object) ? (isset($object->total_vat) ? $object->total_vat : $object->total_tva) :
'';
8670 $substitutionarray[
'__AMOUNT_VAT_TEXT__'] = is_object($object) ? (isset($object->total_vat) ?
dol_convertToWord($object->total_vat, $outputlangs,
'',
true) :
dol_convertToWord($object->total_tva, $outputlangs,
'',
true)) :
'';
8671 $substitutionarray[
'__AMOUNT_VAT_TEXTCURRENCY__'] = is_object($object) ? (isset($object->total_vat) ?
dol_convertToWord($object->total_vat, $outputlangs, $conf->currency,
true) :
dol_convertToWord($object->total_tva, $outputlangs, $conf->currency,
true)) :
'';
8673 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
8674 $substitutionarray[
'__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 :
'';
8676 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
8677 $substitutionarray[
'__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 :
'';
8681 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object) ? ($object->total_ht ?
price($object->total_ht, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8682 $substitutionarray[
'__AMOUNT_FORMATED__'] = is_object($object) ? ($object->total_ttc ?
price($object->total_ttc, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8683 $substitutionarray[
'__AMOUNT_REMAIN_FORMATED__'] = is_object($object) ? ($object->total_ttc ?
price($object->total_ttc - $already_payed_all, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8684 $substitutionarray[
'__AMOUNT_VAT_FORMATED__'] = 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)) :
'';
8685 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
8686 $substitutionarray[
'__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? ($object->total_localtax1 ?
price($object->total_localtax1, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8688 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
8689 $substitutionarray[
'__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? ($object->total_localtax2 ?
price($object->total_localtax2, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8692 $substitutionarray[
'__AMOUNT_MULTICURRENCY__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ? $object->multicurrency_total_ttc :
'';
8693 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXT__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ?
dol_convertToWord($object->multicurrency_total_ttc, $outputlangs,
'',
true) :
'';
8694 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXTCURRENCY__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ?
dol_convertToWord($object->multicurrency_total_ttc, $outputlangs, $object->multicurrency_code,
true) :
'';
8698 if ($onlykey != 2) {
8699 $substitutionarray[
'__TOTAL_TTC__'] = is_object($object) ? $object->total_ttc :
'';
8700 $substitutionarray[
'__TOTAL_HT__'] = is_object($object) ? $object->total_ht :
'';
8701 $substitutionarray[
'__TOTAL_VAT__'] = is_object($object) ? (isset($object->total_vat) ? $object->total_vat : $object->total_tva) :
'';
8706 if ((empty($exclude) || !in_array(
'date', $exclude)) && (empty($include) || in_array(
'date', $include))) {
8707 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
8717 $daytext = $outputlangs->trans(
'Day'.$tmp[
'wday']);
8719 $substitutionarray = array_merge($substitutionarray, array(
8720 '__NOW_TMS__' => (
string) $now,
8721 '__NOW_TMS_YMD__' =>
dol_print_date($now,
'day',
'auto', $outputlangs),
8722 '__DAY__' => (
string) $tmp[
'mday'],
8723 '__DAY_TEXT__' => $daytext,
8724 '__DAY_TEXT_SHORT__' =>
dol_trunc($daytext, 3,
'right',
'UTF-8', 1),
8725 '__DAY_TEXT_MIN__' =>
dol_trunc($daytext, 1,
'right',
'UTF-8', 1),
8726 '__MONTH__' => (
string) $tmp[
'mon'],
8727 '__MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp[
'mon'])),
8728 '__MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp[
'mon'])),
8729 '__MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp[
'mon'])),
8730 '__YEAR__' => (
string) $tmp[
'year'],
8731 '__PREVIOUS_DAY__' => (
string) $tmp2[
'day'],
8732 '__PREVIOUS_MONTH__' => (
string) $tmp3[
'month'],
8733 '__PREVIOUS_YEAR__' => (
string) ($tmp[
'year'] - 1),
8734 '__NEXT_DAY__' => (
string) $tmp4[
'day'],
8735 '__NEXT_MONTH__' => (
string) $tmp5[
'month'],
8736 '__NEXT_MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp5[
'month'])),
8737 '__NEXT_MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp5[
'month'])),
8738 '__NEXT_MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp5[
'month'])),
8739 '__NEXT_YEAR__' => (
string) ($tmp[
'year'] + 1),
8743 if (isModEnabled(
'multicompany')) {
8744 $substitutionarray = array_merge($substitutionarray, array(
'__ENTITY_ID__' => $conf->entity));
8746 if ((empty($exclude) || !in_array(
'system', $exclude)) && (empty($include) || in_array(
'user', $include))) {
8747 $substitutionarray[
'__DOL_MAIN_URL_ROOT__'] = DOL_MAIN_URL_ROOT;
8748 $substitutionarray[
'__(AnyTranslationKey)__'] = $outputlangs->trans(
'TranslationOfKey');
8749 $substitutionarray[
'__(AnyTranslationKey|langfile)__'] = $outputlangs->trans(
'TranslationOfKey').
' (load also language file before)';
8750 $substitutionarray[
'__[AnyConstantKey]__'] = $outputlangs->trans(
'ValueOfConstantKey');
8755 return $substitutionarray;
8774function make_substitutions($text, $substitutionarray, $outputlangs =
null, $converttextinhtmlifnecessary = 0)
8776 global $conf, $db, $langs;
8778 if (!is_array($substitutionarray)) {
8779 return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
8782 if (empty($outputlangs)) {
8783 $outputlangs = $langs;
8793 if (is_object($outputlangs)) {
8795 while (preg_match(
'/__\(([^\)]+)\)__/', $text, $reg)) {
8797 $tmp = explode(
'|', $reg[1]);
8798 if (!empty($tmp[1])) {
8799 $outputlangs->load($tmp[1]);
8802 $value = $outputlangs->transnoentitiesnoconv($reg[1]);
8804 if (empty($converttextinhtmlifnecessary)) {
8806 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
8820 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $value, $text);
8828 while (preg_match(
'/__\[([^\]]+)\]__/', $text, $reg)) {
8829 $keyfound = $reg[1];
8831 $value =
'*****forbidden*****';
8833 $value = empty($conf->global->$keyfound) ?
'' : $conf->global->$keyfound;
8836 if (empty($converttextinhtmlifnecessary)) {
8838 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
8851 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $value, $text);
8856 foreach ($substitutionarray as $key => $value) {
8857 if (!isset($value)) {
8861 if (($key ==
'__USER_SIGNATURE__' || $key ==
'__SENDEREMAIL_SIGNATURE__') && (
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN'))) {
8865 if (empty($converttextinhtmlifnecessary)) {
8866 $text = str_replace(
"$key",
"$value", $text);
8878 $text = str_replace(
"$key",
"$value", $text);
8894 $memory_object_list = array();
8895 foreach ($substitutionarray as $key => $value) {
8896 $lazy_load_arr = array();
8897 if (preg_match(
'/(__[A-Z\_]+__)@lazyload$/', $key, $lazy_load_arr)) {
8898 if (isset($lazy_load_arr[1]) && !empty($lazy_load_arr[1])) {
8899 $key_to_substitute = $lazy_load_arr[1];
8900 if (preg_match(
'/' . preg_quote($key_to_substitute,
'/') .
'/', $text)) {
8901 $param_arr = explode(
':', $value);
8903 if (count($param_arr) == 4) {
8904 $path = $param_arr[0];
8905 $class = $param_arr[1];
8906 $method = $param_arr[2];
8907 $id = (int) $param_arr[3];
8910 if (!isset($memory_object_list[$class])) {
8912 require_once DOL_DOCUMENT_ROOT . $path;
8913 if (class_exists($class)) {
8914 $memory_object_list[$class] = array(
8922 if (isset($memory_object_list[$class]) && isset($memory_object_list[$class][
'list'])) {
8923 if (method_exists($class, $method)) {
8924 if (!isset($memory_object_list[$class][
'list'][$id])) {
8925 $tmpobj =
new $class($db);
8926 $valuetouseforsubstitution = $tmpobj->$method($id, $key_to_substitute);
8927 $memory_object_list[$class][
'list'][$id] = $tmpobj;
8929 $tmpobj = $memory_object_list[$class][
'list'][$id];
8930 $valuetouseforsubstitution = $tmpobj->$method($id, $key_to_substitute,
true);
8933 $text = str_replace(
"$key_to_substitute",
"$valuetouseforsubstitution", $text);
8959 global $conf, $user;
8961 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
8966 $dirsubstitutions = array_merge(array(), (array) $conf->modules_parts[
'substitutions']);
8968 foreach ($dirsubstitutions as $reldir) {
8976 $substitfiles =
dol_dir_list($dir,
'files', 0,
'functions_');
8977 foreach ($substitfiles as $substitfile) {
8979 if (preg_match(
'/functions_(.*)\.lib\.php/i', $substitfile[
'name'], $reg)) {
8982 dol_syslog(
"Library ".$substitfile[
'name'].
" found into ".$dir);
8984 require_once $dir.$substitfile[
'name'];
8986 $function_name = $module.
"_".$callfunc;
8987 if (function_exists($function_name)) {
8988 $function_name($substitutionarray, $outputlangs, $object, $parameters);
8996 foreach ($substitutionarray as $key => $value) {
8997 $tags .=
'{'.$key.
'} => '.$value.
"\n";
8999 $substitutionarray = array_merge($substitutionarray, array(
'__ALL_TAGS__' => $tags));
9014 print
get_date_range($date_start, $date_end, $format, $outputlangs);
9027function get_date_range($date_start, $date_end, $format =
'', $outputlangs =
'', $withparenthesis = 1)
9033 if (!is_object($outputlangs)) {
9034 $outputlangs = $langs;
9037 if ($date_start && $date_end) {
9038 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFromTo',
dol_print_date($date_start, $format,
false, $outputlangs),
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
9040 if ($date_start && !$date_end) {
9041 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($date_start, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
9043 if (!$date_start && $date_end) {
9044 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
9064 if ($nameorder < 0) {
9067 if ($nameorder == 1) {
9069 if ($firstname && $lastname) {
9073 } elseif ($nameorder == 2 || $nameorder == 3) {
9075 if (empty($ret) && $nameorder == 3) {
9080 if (empty($ret) && $nameorder == 5) {
9083 if ($nameorder == 0) {
9084 if ($firstname && $lastname) {
9108 if (!is_array($mesgs)) {
9109 $mesgs = trim((
string) $mesgs);
9112 if (!empty($noduplicate) && isset($_SESSION[
'dol_events'][$style]) && in_array($mesgs, $_SESSION[
'dol_events'][$style])) {
9115 $_SESSION[
'dol_events'][$style][] = $mesgs;
9119 foreach ($mesgs as $mesg) {
9120 $mesg = trim((
string) $mesg);
9122 if (!empty($noduplicate) && isset($_SESSION[
'dol_events'][$style]) && in_array($mesg, $_SESSION[
'dol_events'][$style])) {
9125 $_SESSION[
'dol_events'][$style][] = $mesg;
9145 if (empty($mesg) && empty($mesgs)) {
9146 dol_syslog(
"Try to add a message in stack, but value to add is empty message", LOG_WARNING);
9153 if (empty($messagekey) || empty($_COOKIE[
"DOLHIDEMESSAGE".$messagekey])) {
9154 if (!in_array((
string) $style, array(
'mesgs',
'warnings',
'errors'))) {
9155 dol_print_error(
'',
'Bad parameter style='.$style.
' for setEventMessages');
9157 if (empty($mesgs)) {
9160 if (!empty($mesg) && !in_array($mesg, $mesgs)) {
9181 if (isset($_SESSION[
'dol_events'][
'mesgs'])) {
9182 if (empty($disabledoutputofmessages)) {
9185 unset($_SESSION[
'dol_events'][
'mesgs']);
9188 if (isset($_SESSION[
'dol_events'][
'errors'])) {
9189 if (empty($disabledoutputofmessages)) {
9192 unset($_SESSION[
'dol_events'][
'errors']);
9196 if (isset($_SESSION[
'dol_events'][
'warnings'])) {
9197 if (empty($disabledoutputofmessages)) {
9200 unset($_SESSION[
'dol_events'][
'warnings']);
9220 global $conf, $langs;
9225 $divstart = $divend =
'';
9228 if ((empty($conf->use_javascript_ajax) ||
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') || $keepembedded) && !preg_match(
'/<div class=".*">/i', $out)) {
9229 $divstart =
'<div class="'.$style.
' clearboth">';
9233 if ((is_array($mesgarray) && count($mesgarray)) || $mesgstring) {
9234 $langs->load(
"errors");
9236 if (is_array($mesgarray) && count($mesgarray)) {
9237 foreach ($mesgarray as $message) {
9239 $out .= $langs->trans($message);
9240 if ($ret < count($mesgarray)) {
9247 $out .= $langs->trans($mesgstring);
9253 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') && empty($keepembedded)) {
9254 $return =
'<script nonce="'.getNonce().
'">
9255 $(document).ready(function() {
9260 /* jnotify(message, preset of message type, keepmessage) */
9262 "'.($style ==
"ok" ? 3000 : $style).
'",
9263 '.($style ==
"ok" ?
"false" :
"true").
',
9264 { remove: function (){} } );
9307 if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) {
9313 if (is_array($mesgarray)) {
9314 foreach ($mesgarray as $val) {
9315 if ($val && preg_match(
'/class="error"/i', $val)) {
9319 if ($val && preg_match(
'/class="warning"/i', $val)) {
9324 } elseif ($mesgstring && preg_match(
'/class="error"/i', $mesgstring)) {
9326 } elseif ($mesgstring && preg_match(
'/class="warning"/i', $mesgstring)) {
9329 if ($style ==
'error') {
9332 if ($style ==
'warning') {
9336 if ($iserror || $iswarning) {
9338 $mesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $mesgstring);
9339 $mesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $mesgstring);
9340 $mesgstring = preg_replace(
'/<\/div>/',
'', $mesgstring);
9342 if (is_array($mesgarray)) {
9343 $newmesgarray = array();
9344 foreach ($mesgarray as $val) {
9345 if (is_string($val)) {
9346 $tmpmesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $val);
9347 $tmpmesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $tmpmesgstring);
9348 $tmpmesgstring = preg_replace(
'/<\/div>/',
'', $tmpmesgstring);
9349 $newmesgarray[] = $tmpmesgstring;
9351 dol_syslog(
"Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING);
9354 $mesgarray = $newmesgarray;
9356 print
get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ?
'error' :
'warning'), $keepembedded);
9392function dol_sort_array(&$array, $index, $order =
'asc', $natsort = 0, $case_sensitive = 0, $keepindex = 0)
9395 $order = strtolower($order);
9397 if (is_array($array)) {
9398 $sizearray = count($array);
9399 if ($sizearray > 0) {
9401 foreach (array_keys($array) as $key) {
9402 if (is_object($array[$key])) {
9403 $temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index;
9405 $temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index];
9407 if ($natsort == -1) {
9408 $temp[$key] =
'___'.$temp[$key];
9412 if (empty($natsort) || $natsort == -1) {
9413 if ($order ==
'asc') {
9419 if ($case_sensitive) {
9424 if ($order !=
'asc') {
9425 $temp = array_reverse($temp,
true);
9431 foreach (array_keys($temp) as $key) {
9432 (is_numeric($key) && empty($keepindex)) ? $sorted[] = $array[$key] : $sorted[$key] = $array[$key];
9451 $str = (string) $str;
9454 $strLength = strlen($str);
9455 for ($i = 0; $i < $strLength; $i++) {
9456 if (ord($str[$i]) < 0x80) {
9458 } elseif ((ord($str[$i]) & 0xE0) == 0xC0) {
9460 } elseif ((ord($str[$i]) & 0xF0) == 0xE0) {
9462 } elseif ((ord($str[$i]) & 0xF8) == 0xF0) {
9464 } elseif ((ord($str[$i]) & 0xFC) == 0xF8) {
9466 } elseif ((ord($str[$i]) & 0xFE) == 0xFC) {
9471 for ($j = 0; $j < $n; $j++) {
9472 if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) {
9493 return preg_match(
'//u', $str) ? true :
false;
9505 if (function_exists(
'mb_check_encoding')) {
9507 if (!mb_check_encoding($str,
'ASCII')) {
9511 if (preg_match(
'/[^\x00-\x7f]/', $str)) {
9531 $tmp = ini_get(
"unicode.filesystem_encoding");
9532 if (empty($tmp) && !empty($_SERVER[
"WINDIR"])) {
9533 $tmp =
'iso-8859-1';
9539 $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING;
9542 if ($tmp ==
'iso-8859-1') {
9543 return mb_convert_encoding($str,
'ISO-8859-1',
'UTF-8');
9564function dol_getIdFromCode($db, $key, $tablename, $fieldkey =
'code', $fieldid =
'id', $entityfilter = 0, $filters =
'', $useCache =
true)
9566 global $cache_codes;
9574 if ($useCache && isset($cache_codes[$tablename][$fieldkey][$fieldid][$entityfilter][$filters][$key])) {
9575 return $cache_codes[$tablename][$fieldkey][$fieldid][$entityfilter][$filters][$key];
9578 dol_syslog(
'dol_getIdFromCode (value for field '.$fieldid.
' from key '.$key.
' not found into cache)', LOG_DEBUG);
9580 $sql =
"SELECT ".$fieldid.
" as valuetoget";
9581 $sql .=
" FROM ".MAIN_DB_PREFIX.$tablename;
9582 $sql .=
" WHERE ".$fieldkey.
" = '".$db->escape($key).
"'";
9583 if (!empty($entityfilter)) {
9584 $sql .=
" AND entity IN (".getEntity($tablename).
")";
9590 $resql = $db->query($sql);
9592 $obj = $db->fetch_object($resql);
9595 $valuetoget = $obj->valuetoget;
9599 $cache_codes[$tablename][$fieldkey][$fieldid][$entityfilter][$filters][$key] = $valuetoget;
9618 if ($matchrule == 1) {
9619 if ($var ==
'mainmenu') {
9621 return (preg_match(
'/^'.$regextext.
'/', $mainmenu));
9622 } elseif ($var ==
'leftmenu') {
9624 return (preg_match(
'/^'.$regextext.
'/', $leftmenu));
9626 return 'This variable is not accessible with dol_eval';
9629 return 'This value for matchrule is not implemented';
9644 if (isset($strToEvaluate) && $strToEvaluate !==
'') {
9647 $rep =
dol_eval($strToEvaluate, 1, 1,
'1');
9648 $rights = $rep && (!is_string($rep) || strpos($rep,
'Bad string syntax to evaluate') ===
false);
9667function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring =
'1')
9671 global $db, $langs, $user, $website, $websitepage;
9672 global $action, $mainmenu, $leftmenu;
9674 global $objectoffield;
9680 if (!in_array($onlysimplestring, array(
'0',
'1',
'2'))) {
9681 return "Bad call of dol_eval. Parameter onlysimplestring must be '0' (deprecated), '1' or '2'";
9686 if ($onlysimplestring ==
'1') {
9689 $specialcharsallowed =
'^$_+-.*>&|=!?():"\',/@';
9691 $specialcharsallowed .=
getDolGlobalString(
'MAIN_ALLOW_UNSECURED_SPECIAL_CHARS_IN_DOL_EVAL');
9693 if (preg_match(
'/[^a-z0-9\s'.preg_quote($specialcharsallowed,
'/').
']/i', $s)) {
9695 return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s;
9697 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s);
9703 while ($scheck && $savescheck != $scheck) {
9704 $savescheck = $scheck;
9705 $scheck = preg_replace(
'/->[a-zA-Z0-9_]+\(/',
'->__METHOD__', $scheck);
9706 $scheck = preg_replace(
'/^\(/',
'__PARENTHESIS__ ', $scheck);
9707 $scheck = preg_replace(
'/\s\(/',
'__PARENTHESIS__ ', $scheck);
9708 $scheck = preg_replace(
'/^!?[a-zA-Z0-9_]+\(/',
'__FUNCTION__', $scheck);
9709 $scheck = preg_replace(
'/\s!?[a-zA-Z0-9_]+\(/',
'__FUNCTION__', $scheck);
9710 $scheck = preg_replace(
'/(\^|\')\(/',
'__REGEXSTART__', $scheck);
9713 if (strpos($scheck,
'(') !==
false) {
9715 return 'Bad string syntax to evaluate (mode 1, found call of a function or method without using the direct name of the function): '.$s;
9717 dol_syslog(
'Bad string syntax to evaluate (mode 1, found call of a function or method without using the direct name of the function): '.$s);
9723 } elseif ($onlysimplestring ==
'2') {
9725 $specialcharsallowed =
'^$_+-.*>&|=!?():"\',/@[]';
9727 $specialcharsallowed .=
getDolGlobalString(
'MAIN_ALLOW_UNSECURED_SPECIAL_CHARS_IN_DOL_EVAL');
9729 if (preg_match(
'/[^a-z0-9\s'.preg_quote($specialcharsallowed,
'/').
']/i', $s)) {
9731 return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s;
9733 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s);
9739 while ($scheck && $savescheck != $scheck) {
9740 $savescheck = $scheck;
9741 $scheck = preg_replace(
'/->[a-zA-Z0-9_]+\(/',
'->__METHOD__', $scheck);
9742 $scheck = preg_replace(
'/^\(/',
'__PARENTHESIS__ ', $scheck);
9743 $scheck = preg_replace(
'/\s\(/',
'__PARENTHESIS__ ', $scheck);
9744 $scheck = preg_replace(
'/^!?[a-zA-Z0-9_]+\(/',
'__FUNCTION__', $scheck);
9745 $scheck = preg_replace(
'/\s!?[a-zA-Z0-9_]+\(/',
'__FUNCTION__', $scheck);
9746 $scheck = preg_replace(
'/(\^|\')\(/',
'__REGEXSTART__', $scheck);
9749 if (strpos($scheck,
'(') !==
false) {
9751 return 'Bad string syntax to evaluate (mode 2, found call of a function or method without using the direct name of the function): '.$s;
9753 dol_syslog(
'Bad string syntax to evaluate (mode 2, found call of a function or method without using the direct name of the function): '.$s);
9760 if (is_array($s) || $s ===
'Array') {
9761 return 'Bad string syntax to evaluate (value is Array) '.var_export($s,
true);
9763 if (strpos($s,
'::') !==
false) {
9765 return 'Bad string syntax to evaluate (double : char is forbidden): '.$s;
9767 dol_syslog(
'Bad string syntax to evaluate (double : char is forbidden): '.$s);
9771 if (strpos($s,
'`') !==
false) {
9773 return 'Bad string syntax to evaluate (backtick char is forbidden): '.$s;
9775 dol_syslog(
'Bad string syntax to evaluate (backtick char is forbidden): '.$s);
9779 if (preg_match(
'/[^0-9]+\.[^0-9]+/', $s)) {
9781 return 'Bad string syntax to evaluate (dot char is forbidden): '.$s;
9783 dol_syslog(
'Bad string syntax to evaluate (dot char is forbidden): '.$s);
9789 $forbiddenphpstrings = array(
'$$');
9790 $forbiddenphpstrings = array_merge($forbiddenphpstrings, array(
'_ENV',
'_SESSION',
'_COOKIE',
'_GET',
'_POST',
'_REQUEST',
'ReflectionFunction'));
9792 $forbiddenphpfunctions = array(
"exec",
"passthru",
"shell_exec",
"system",
"proc_open",
"popen");
9793 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_eval",
"executeCLI",
"verifCond"));
9794 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"base64_decode",
"rawurldecode",
"urldecode",
"str_rot13",
"hex2bin"));
9795 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"fopen",
"file_put_contents",
"fputs",
"fputscsv",
"fwrite",
"fpassthru",
"require",
"include",
"mkdir",
"rmdir",
"symlink",
"touch",
"unlink",
"umask"));
9796 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"get_defined_functions",
"get_defined_vars",
"get_defined_constants",
"get_declared_classes"));
9797 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"function",
"call_user_func"));
9798 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"require",
"include",
"require_once",
"include_once"));
9799 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"eval",
"create_function",
"assert",
"mb_ereg_replace"));
9801 $forbiddenphpmethods = array(
'invoke',
'invokeArgs');
9803 $forbiddenphpregex =
'global\s+\$|\b('.implode(
'|', $forbiddenphpfunctions).
')\b';
9805 $forbiddenphpmethodsregex =
'->('.implode(
'|', $forbiddenphpmethods).
')';
9808 $oldstringtoclean = $s;
9809 $s = str_ireplace($forbiddenphpstrings,
'__forbiddenstring__', $s);
9810 $s = preg_replace(
'/'.$forbiddenphpregex.
'/i',
'__forbiddenstring__', $s);
9811 $s = preg_replace(
'/'.$forbiddenphpmethodsregex.
'/i',
'__forbiddenstring__', $s);
9813 }
while ($oldstringtoclean != $s);
9815 if (strpos($s,
'__forbiddenstring__') !==
false) {
9816 dol_syslog(
'Bad string syntax to evaluate: '.$s, LOG_WARNING);
9818 return 'Bad string syntax to evaluate: '.$s;
9820 dol_syslog(
'Bad string syntax to evaluate: '.$s);
9828 return @eval(
'return '.$s.
';');
9830 return eval(
'return '.$s.
';');
9839 }
catch (Error $e) {
9840 $error =
'dol_eval try/catch error : ';
9841 $error .= $e->getMessage();
9855 return (trim($element) !=
'');
9868 if (empty($codelang)) {
9872 if ($codelang ==
'auto') {
9873 return '<span class="fa fa-language"></span>';
9876 $langtocountryflag = array(
9878 'ca_ES' =>
'catalonia',
9882 'sw_SW' =>
'unknown',
9892 if (isset($langtocountryflag[$codelang])) {
9893 $flagImage = $langtocountryflag[$codelang];
9895 $tmparray = explode(
'_', $codelang);
9896 $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
9901 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
9907 return '<span class="flag-sprite '.strtolower($flagImage).($morecss ?
' '.$morecss :
'').
'"'.($moreatt ?
' '.$moreatt :
'').(!$notitlealt ?
' title="'.$codelang.
'"' :
'').
'></span>';
9921 if (empty($countrycode)) {
9925 if (strtoupper($countrycode) ==
'MQ') {
9928 if (strtoupper($countrycode) ==
'SE') {
9931 if (strtoupper($countrycode) ==
'CH') {
9932 if ($mysoc->country_code ==
'FR') {
9935 if ($mysoc->country_code ==
'DE') {
9938 if ($mysoc->country_code ==
'IT') {
10120 $buildprimarykeytotest = strtolower($countrycode).
'-'.strtoupper($countrycode);
10121 if (in_array($buildprimarykeytotest, $locales)) {
10122 return strtolower($countrycode).
'_'.strtoupper($countrycode);
10125 if (function_exists(
'locale_get_primary_language') && function_exists(
'locale_get_region')) {
10126 foreach ($locales as $locale) {
10127 $locale_language = locale_get_primary_language($locale);
10128 $locale_region = locale_get_region($locale);
10129 if (strtoupper($countrycode) == $locale_region) {
10131 return strtolower($locale_language).
'_'.strtoupper($locale_region);
10135 dol_syslog(
"Warning Exention php-intl is not available", LOG_WARNING);
10173 global $hookmanager, $db;
10175 if (isset($conf->modules_parts[
'tabs'][$type]) && is_array($conf->modules_parts[
'tabs'][$type])) {
10176 foreach ($conf->modules_parts[
'tabs'][$type] as $value) {
10177 $values = explode(
':', $value);
10180 if ($mode ==
'add' && !preg_match(
'/^\-/', $values[1])) {
10185 $posstart = strpos($str,
'(');
10186 if ($posstart > 0) {
10187 $posend = strpos($str,
')');
10188 if ($posstart > 0) {
10189 $res1 = substr($str, $posstart + 1, $posend - $posstart -1);
10190 if (is_numeric($res1)) {
10191 $postab = (int) $res1;
10192 $values[1] =
'+' . substr($str, $posend + 1);
10196 if (count($values) == 6) {
10200 if ($values[0] != $type) {
10206 if ($filterorigmodule) {
10207 if (strpos($values[3],
'@')) {
10208 if ($filterorigmodule !=
'external') {
10212 if ($filterorigmodule !=
'core') {
10217 $langs->load($values[3]);
10219 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
10221 $substitutionarray = array();
10226 $labeltemp = explode(
',', $values[2]);
10227 $label = $langs->trans($labeltemp[0]);
10229 if (!empty($labeltemp[1]) && is_object($object) && !empty($object->id)) {
10231 $classtoload = $labeltemp[1];
10232 if (class_exists($classtoload)) {
10233 $obj =
new $classtoload($db);
10234 $function = $labeltemp[3];
10235 if ($obj && $function && method_exists($obj, $function)) {
10236 $nbrec = $obj->$function($object->id, $obj);
10237 if (!empty($nbrec)) {
10238 $label .=
'<span class="badge marginleftonlyshort">'.$nbrec.
'</span>';
10245 $newtab[0] =
dol_buildpath(preg_replace(
'/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id :
''), $values[5]), 1);
10246 $newtab[1] = $label;
10247 $newtab[2] = str_replace(
'+',
'', $values[1]);
10252 } elseif (count($values) == 5) {
10253 dol_syslog(
'Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
10255 if ($values[0] != $type) {
10259 if ($filterorigmodule) {
10260 if (strpos($values[3],
'@')) {
10261 if ($filterorigmodule !=
'external') {
10265 if ($filterorigmodule !=
'core') {
10270 $langs->load($values[3]);
10272 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
10273 $substitutionarray = array();
10277 $label = $langs->trans($values[2]);
10280 $newtab[0] =
dol_buildpath(preg_replace(
'/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id :
''), $values[4]), 1);
10281 $newtab[1] = $label;
10282 $newtab[2] = str_replace(
'+',
'', $values[1]);
10286 $head = array_merge(array_slice($head, 0, $postab), array($newtab), array_slice($head, $postab));
10287 } elseif ($mode ==
'remove' && preg_match(
'/^\-/', $values[1])) {
10288 if ($values[0] != $type) {
10291 $tabname = str_replace(
'-',
'', $values[1]);
10292 foreach ($head as $key => $val) {
10293 $condition = (!empty($values[3]) ?
verifCond($values[3]) : 1);
10295 if ($head[$key][2] == $tabname && $condition) {
10296 unset($head[$key]);
10305 if (!empty($hookmanager)) {
10306 $parameters = array(
'object' => $object,
'mode' => $mode,
'head' => &$head,
'filterorigmodule' => $filterorigmodule);
10307 $reshook = $hookmanager->executeHooks(
'completeTabsHead', $parameters, $object);
10308 if ($reshook > 0) {
10309 $head = $hookmanager->resArray;
10311 $head = array_merge($head, $hookmanager->resArray);
10330 global $conf, $hookmanager, $user, $debugbar;
10332 global $micro_start_time;
10334 if ($zone ==
'private') {
10335 print
"\n".
'<!-- Common footer for private page -->'.
"\n";
10337 print
"\n".
'<!-- Common footer for public page -->'.
"\n";
10341 print
"\n<!-- A div to store page_y POST parameter -->\n";
10342 print
'<div id="page_y" style="display: none;">'.(GETPOST(
'page_y') ?
GETPOST(
'page_y') :
'').
'</div>'.
"\n";
10344 $parameters = array();
10345 $reshook = $hookmanager->executeHooks(
'printCommonFooter', $parameters);
10346 if (empty($reshook)) {
10352 if (!empty($conf->use_javascript_ajax)) {
10353 print
"\n<!-- A script section to add menuhider handler on backoffice, manage focus and madatory fields, tuning info, ... -->\n";
10354 print
'<script>'.
"\n";
10355 print
'jQuery(document).ready(function() {'.
"\n";
10357 if ($zone ==
'private' && empty($conf->dol_use_jmobile)) {
10359 print
'/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'.
"\n";
10360 print
'jQuery("li.menuhider").click(function(event) {';
10361 print
' if (!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'.
"\n";
10362 print
' console.log("We click on .menuhider");'.
"\n";
10363 print
' $("body").toggleClass("sidebar-collapse")'.
"\n";
10368 if ($action ==
'create' || $action ==
'edit' || (empty($action) && (preg_match(
'/new\.php/', $_SERVER[
"PHP_SELF"]))) || ((empty($action) || $action ==
'addline') && (preg_match(
'/card\.php/', $_SERVER[
"PHP_SELF"])))) {
10369 print
'/* JS CODE TO ENABLE to manage focus and mandatory form fields */'.
"\n";
10370 $relativepathstring = $_SERVER[
"PHP_SELF"];
10372 if (constant(
'DOL_URL_ROOT')) {
10373 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
10375 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
10376 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
10378 if (!empty($user->default_values[$relativepathstring][
'focus'])) {
10379 foreach ($user->default_values[$relativepathstring][
'focus'] as $defkey => $defval) {
10381 if ($defkey !=
'_noquery_') {
10382 $tmpqueryarraytohave = explode(
'&', $defkey);
10384 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
10385 $tmpquerytohaveparam = explode(
'=', $tmpquerytohave);
10387 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] !=
GETPOST($tmpquerytohaveparam[0]))) {
10391 if (!$foundintru) {
10400 foreach ($defval as $paramkey => $paramval) {
10402 print
'jQuery("input[name=\''.$paramkey.
'\']
").focus();'."\n
";
10403 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").focus();'."\n
";
10404 print 'jQuery("select[
name=\
''.$paramkey.
'\']
").focus();'."\n
"; // Not really usefull, but we keep it in case of.
10409 if (!empty($user->default_values[$relativepathstring]['mandatory'])) {
10410 foreach ($user->default_values[$relativepathstring]['mandatory'] as $defkey => $defval) {
10412 if ($defkey != '_noquery_') {
10413 $tmpqueryarraytohave = explode('&', $defkey);
10415 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
10416 $tmpquerytohaveparam = explode('=', $tmpquerytohave);
10417 //print "console.log(
'".$tmpquerytohaveparam[0]." ".$tmpquerytohaveparam[1]." ".GETPOST($tmpquerytohaveparam[0])."');
";
10418 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] != GETPOST($tmpquerytohaveparam[0]))) {
10422 if (!$foundintru) {
10425 //var_dump($defkey.'-'.$qualified);
10431 foreach ($defval as $paramkey => $paramval) {
10432 // Add property 'required' on input
10433 print 'jQuery("input[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
10434 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
10435 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
";
10436 print 'jQuery("select[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
10437 print 'jQuery("select[
name=\
''.$paramkey.
'\'] option[value=\
'-1\']").prop(\'value\', \'\');'.
"\n";
10438 print
'jQuery("select[name=\''.$paramkey.
'\'] option[value=\
'0\']").prop(\'value\', \'\');'.
"\n";
10441 print
'jQuery(":input[name=\'' . $paramkey .
'\']
").closest("tr
").find("td:first
").addClass("fieldrequired
");' . "\n
";
10443 // If we submit the cancel button we remove the required attributes
10444 print 'jQuery("input[
name=\
'cancel\']").click(function() {
10445 console.log("We click on cancel button so removed all required attribute");
10446 jQuery("input, textarea, select").each(function(){this.removeAttribute(\'required\');});
10456 if (!empty($_SERVER[
'MAIN_SHOW_TUNING_INFO']) ||
getDolGlobalString(
'MAIN_SHOW_TUNING_INFO')) {
10458 print
"/* JS CODE TO ENABLE to add memory info */\n";
10459 print
'window.console && console.log("';
10463 print
'MAIN_OPTIMIZE_SPEED='.(isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED :
'off');
10464 if (!empty($micro_start_time)) {
10465 $micro_end_time = microtime(
true);
10466 print
' - Build time: '.ceil(1000 * ($micro_end_time - $micro_start_time)).
' ms';
10469 if (function_exists(
"memory_get_usage")) {
10470 print
' - Mem: '.memory_get_usage();
10472 if (function_exists(
"memory_get_peak_usage")) {
10473 print
' - Real mem peak: '.memory_get_peak_usage(
true);
10475 if (function_exists(
"zend_loader_file_encoded")) {
10476 print
' - Zend encoded file: '.(zend_loader_file_encoded() ?
'yes' :
'no');
10481 print
"\n".
'</script>'.
"\n";
10487 foreach ($tmptagarray as $tmptag) {
10489 print
"<!-- JS CODE TO ENABLE for google analtics tag -->\n";
10491 <!-- Global site tag (gtag.js) - Google Analytics -->
10492 <script nonce="'.getNonce().
'" async src="https://www.googletagmanager.com/gtag/js?id='.trim($tmptag).
'"></script>
10494 window.dataLayer = window.dataLayer || [];
10495 function gtag(){dataLayer.push(arguments);}
10496 gtag(\'js\', new Date());
10498 gtag(\'config\', \''.trim($tmptag).
'\');
10505 // Add Xdebug coverage of code
10506 if (defined('XDEBUGCOVERAGE
')) {
10507 print_r(xdebug_get_code_coverage());
10510 // Add DebugBar data
10511 if ($user->hasRight('debugbar
', 'read
') && is_object($debugbar)) {
10512 $debugbar['time
']->stopMeasure('pageaftermaster
');
10513 print '<!-- Output debugbar data -->
'."\n";
10514 $renderer = $debugbar->getRenderer();
10515 print $debugbar->getRenderer()->render();
10516 } elseif (count($conf->logbuffer)) { // If there is some logs in buffer to show
10518 print "<!-- Start of log output\n";
10519 //print '<div
class=
"hidden">
'."\n";
10520 foreach ($conf->logbuffer as $logline) {
10521 print $logline."<br>\n";
10523 //print '</div>
'."\n";
10524 print "End of log output -->\n";
10538function dolExplodeIntoArray($string, $delimiter = ';
', $kv = '=
')
10540 if (is_null($string)) {
10544 if (preg_match('/^\[.*\]$/sm
', $delimiter) || preg_match('/^\(.*\)$/sm
', $delimiter)) {
10545 // This is a regex string
10546 $newdelimiter = $delimiter;
10548 // This is a simple string
10549 $newdelimiter = preg_quote($delimiter, '/
');
10552 if ($a = preg_split('/
'.$newdelimiter.'/
', $string)) {
10554 foreach ($a as $s) { // each part
10556 if ($pos = strpos($s, $kv)) { // key/value delimiter
10557 $ka[trim(substr($s, 0, $pos))] = trim(substr($s, $pos + strlen($kv)));
10558 } else { // key delimiter not found
10576function dol_set_focus($selector)
10578 print "\n".'<!-- Set focus onto a specific field -->
'."\n";
10579 print '<script nonce=
"'.getNonce().'">jQuery(document).ready(
function() { jQuery(
"'.dol_escape_js($selector).'").focus(); });</script>
'."\n";
10590function dol_getmypid()
10592 if (!function_exists('getmypid
')) {
10593 return mt_rand(99900000, 99965535);
10595 return getmypid(); // May be a number on 64 bits (depending on OS)
10617function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
10619 global $db, $langs;
10621 $value = trim($value);
10624 $value = preg_replace('/\*/
', '%
', $value); // Replace * with %
10627 $value = preg_replace('/([!<>=]+)\s+([0-9
'.preg_quote($langs->trans("DecimalSeparator"), '/
').'\-])/
', '\1\2
', $value); // Clean string '< 10
' into '<10
' so we can then explode on space to get all tests to do
10630 $value = preg_replace('/\s*\|\s*/
', '|
', $value);
10632 $crits = explode(' ', $value);
10634 if (!is_array($fields)) {
10635 $fields = array($fields);
10638 $i1 = 0; // count the nb of and criteria added (all fields / criterias)
10639 foreach ($crits as $crit) { // Loop on each AND criteria
10640 $crit = trim($crit);
10641 $i2 = 0; // count the nb of valid criteria added for this this first criteria
10643 foreach ($fields as $field) {
10645 $tmpcrits = explode('|
', $crit);
10646 $i3 = 0; // count the nb of valid criteria added for this current field
10647 foreach ($tmpcrits as $tmpcrit) {
10648 if ($tmpcrit !== '0
' && empty($tmpcrit)) {
10651 $tmpcrit = trim($tmpcrit);
10653 $newres .= (($i2 > 0 || $i3 > 0) ? ' OR
' : '');
10656 $newcrit = preg_replace('/([!<>=]+)/
', '', $tmpcrit);
10659 preg_match('/([!<>=]+)/
', $tmpcrit, $reg);
10660 if (!empty($reg[1])) {
10661 $operator = $reg[1];
10663 if ($newcrit != '') {
10664 $numnewcrit = price2num($newcrit);
10665 if (is_numeric($numnewcrit)) {
10666 $newres .= $field.' '.$operator.' '.((float) $numnewcrit); // should be a numeric
10668 $newres .= '1 = 2
'; // force false, we received a corrupted data
10670 $i3++; // a criteria was added to string
10673 $i2++; // a criteria for 1 more field was added to string
10674 } elseif ($mode == 2 || $mode == -2) {
10675 $crit = preg_replace('/[^0-9,]/
', '', $crit); // ID are always integer
10676 $newres .= ($i2 > 0 ? ' OR
' : '').$field." ".($mode == -2 ? 'NOT
' : '');
10677 $newres .= $crit ? "IN (".$db->sanitize($db->escape($crit)).")" : "IN (0)";
10679 $newres .= ' OR
'.$field.' IS NULL
';
10681 $i2++; // a criteria for 1 more field was added to string
10682 } elseif ($mode == 3 || $mode == -3) {
10683 $tmparray = explode(',
', $crit);
10684 if (count($tmparray)) {
10686 foreach ($tmparray as $val) {
10689 $listofcodes .= ($listofcodes ? ',
' : '');
10690 $listofcodes .= "'".$db->escape($val)."'";
10693 $newres .= ($i2 > 0 ? ' OR
' : '').$field." ".($mode == -3 ? 'NOT
' : '')."IN (".$db->sanitize($listofcodes, 1).")";
10694 $i2++; // a criteria for 1 more field was added to string
10697 $newres .= ' OR
'.$field.' IS NULL
';
10699 } elseif ($mode == 4) {
10700 $tmparray = explode(',
', $crit);
10701 if (count($tmparray)) {
10703 foreach ($tmparray as $val) {
10706 $newres .= ($i2 > 0 ? " OR (" : "(").$field." LIKE '".$db->escape($val).",%
'";
10707 $newres .= ' OR
'.$field." = '".$db->escape($val)."'";
10708 $newres .= ' OR
'.$field." LIKE '%,
".$db->escape($val)."'";
10709 $newres .= ' OR
'.$field." LIKE '%,
".$db->escape($val).",%
'";
10711 $i2++; // a criteria for 1 more field was added to string (we can add several citeria for the same field as it is a multiselect search criteria)
10715 } else { // $mode=0
10716 $tmpcrits = explode('|
', $crit);
10717 $i3 = 0; // count the nb of valid criteria added for the current couple criteria/field
10718 foreach ($tmpcrits as $tmpcrit) { // loop on each OR criteria
10719 if ($tmpcrit !== '0
' && empty($tmpcrit)) {
10722 $tmpcrit = trim($tmpcrit);
10724 if ($tmpcrit == '^$
' || strpos($crit, '!
') === 0) { // If we search empty, we must combined different OR fields with AND
10725 $newres .= (($i2 > 0 || $i3 > 0) ? ' AND
' : '');
10727 $newres .= (($i2 > 0 || $i3 > 0) ? ' OR
' : '');
10730 if (preg_match('/\.(
id|
rowid)$/
', $field)) { // Special case for rowid that is sometimes a ref so used as a search field
10731 $newres .= $field." = ".(is_numeric($tmpcrit) ? ((float) $tmpcrit) : '0
');
10733 $tmpcrit2 = $tmpcrit;
10738 if (preg_match('/^!/
', $tmpcrit)) {
10739 $tmps .= $field." NOT LIKE "; // ! as exclude character
10740 $tmpcrit2 = preg_replace('/^!/
', '', $tmpcrit2);
10742 $tmps .= $field." LIKE ";
10746 if (preg_match('/^[\^\$]/', $tmpcrit)) {
10748 $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
10750 if (preg_match('/[\^\$]$/', $tmpcrit)) {
10752 $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
10755 if ($tmpcrit2 == '' || preg_match('/^!/', $tmpcrit)) {
10759 $newres .= $tmpbefore;
10760 $newres .= $db->escape($tmpcrit2);
10761 $newres .= $tmpafter;
10763 if ($tmpcrit2 == '' || preg_match('/^!/
', $tmpcrit)) {
10764 $newres .= " OR ".$field." IS NULL)";
10771 $i2++; // a criteria for 1 more field was added to string
10776 $res = $res.($res ? ' AND
' : '').($i2 > 1 ? '(
' : '').$newres.($i2 > 1 ? ')
' : '');
10780 $res = ($nofirstand ? "" : " AND ")."(".$res.")";
10791function showDirectDownloadLink($object)
10793 global $conf, $langs;
10796 $url = $object->getLastMainDocLink($object->element);
10798 $out .= img_picto($langs->trans("PublicDownloadLinkDesc"), 'globe
').' <span
class=
"opacitymedium">
'.$langs->trans("DirectDownloadLink").'</span><br>
';
10800 $out .= '<div
class=
"urllink"><input
type=
"text" id=
"directdownloadlink" class=
"quatrevingtpercent" value=
"'.$url.'"></div>
';
10801 $out .= ajax_autoselect("directdownloadlink", 0);
10803 $out .= '<div
class=
"urllink">
'.$langs->trans("FileNotShared").'</div>
';
10817function getImageFileNameForSize($file, $extName, $extImgTarget = '
')
10819 $dirName = dirname($file);
10820 if ($dirName == '.
') {
10824 $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp|\.webp)$/i
', '', $file); // We remove extension, whatever is its case
10825 $fileName = basename($fileName);
10827 if (empty($extImgTarget)) {
10828 $extImgTarget = (preg_match('/\.jpg$/i
', $file) ? '.jpg
' : '');
10830 if (empty($extImgTarget)) {
10831 $extImgTarget = (preg_match('/\.jpeg$/i
', $file) ? '.jpeg
' : '');
10833 if (empty($extImgTarget)) {
10834 $extImgTarget = (preg_match('/\.gif$/i
', $file) ? '.gif
' : '');
10836 if (empty($extImgTarget)) {
10837 $extImgTarget = (preg_match('/\.png$/i
', $file) ? '.png
' : '');
10839 if (empty($extImgTarget)) {
10840 $extImgTarget = (preg_match('/\.bmp$/i
', $file) ? '.bmp
' : '');
10842 if (empty($extImgTarget)) {
10843 $extImgTarget = (preg_match('/\.webp$/i
', $file) ? '.webp
' : '');
10846 if (!$extImgTarget) {
10852 $subdir = 'thumbs/
';
10855 return ($dirName ? $dirName.'/
' : '').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb
10868function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param = '
')
10870 global $conf, $langs;
10872 if (empty($conf->use_javascript_ajax)) {
10876 $isAllowedForPreview = dolIsAllowedForPreview($relativepath);
10878 if ($alldata == 1) {
10879 if ($isAllowedForPreview) {
10880 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));
10886 // old behavior, return a string
10887 if ($isAllowedForPreview) {
10888 $tmpurl = DOL_URL_ROOT.'/document.php?modulepart=
'.urlencode($modulepart).'&attachment=0&file=
'.urlencode($relativepath).($param ? '&
'.$param : '');
10890 $title = $langs->trans("Preview");
10891 //$title = '%27-alert(document.domain)-%27
';
10892 //$tmpurl = 'file=
'.urlencode("'-alert(document.domain)-
'_small.jpg");
10894 // We need to urlencode the parameter after the dol_escape_js($tmpurl) because $tmpurl may contain n url with param file=abc%27def if file has a ' inside.
10911function ajax_autoselect($htmlname, $addlink = '
', $textonlink = 'Link')
10914 $out = '<script nonce=
"'.getNonce().'">
10915 jQuery(document).ready(
function () {
10916 jQuery(
"'.((strpos($htmlname, '.') === 0 ? '' : '#').$htmlname).'").click(
function() { jQuery(
this).select(); } );
10920 if ($textonlink === 'image
') {
10921 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.img_picto('', 'globe
').'</a>
';
10923 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.$langs->trans("Link").'</a>
';
10936function dolIsAllowedForPreview($file)
10940 // Check .noexe extension in filename
10941 if (preg_match('/\.noexe$/i
', $file)) {
10945 // Check mime types
10946 $mime_preview = array('bmp
', 'jpeg
', 'png
', 'gif
', 'tiff
', 'pdf
', 'plain
', 'css
', 'webp
');
10947 if (getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES
')) {
10948 $mime_preview[] = 'svg+xml
';
10950 //$mime_preview[]='vnd.oasis.opendocument.presentation
';
10951 //$mime_preview[]='archive
';
10952 $num_mime = array_search(dol_mimetype($file, '', 1), $mime_preview);
10953 if ($num_mime !== false) {
10957 // By default, not allowed for preview
10971function dol_mimetype($file, $default = 'application/octet-stream
', $mode = 0)
10974 $imgmime = 'other.png
';
10975 $famime = 'file-o
';
10978 $tmpfile = preg_replace('/\.noexe$/
', '', $file);
10980 // Plain text files
10981 if (preg_match('/\.txt$/i
', $tmpfile)) {
10982 $mime = 'text/plain
';
10983 $imgmime = 'text.png
';
10984 $famime = 'file-alt
';
10985 } elseif (preg_match('/\.rtx$/i
', $tmpfile)) {
10986 $mime = 'text/richtext
';
10987 $imgmime = 'text.png
';
10988 $famime = 'file-alt
';
10989 } elseif (preg_match('/\.csv$/i
', $tmpfile)) {
10990 $mime = 'text/csv
';
10991 $imgmime = 'text.png
';
10992 $famime = 'file-csv
';
10993 } elseif (preg_match('/\.tsv$/i
', $tmpfile)) {
10994 $mime = 'text/tab-separated-values
';
10995 $imgmime = 'text.png
';
10996 $famime = 'file-alt
';
10997 } elseif (preg_match('/\.(cf|
conf|log)$/i
', $tmpfile)) {
10998 $mime = 'text/plain
';
10999 $imgmime = 'text.png
';
11000 $famime = 'file-alt
';
11001 } elseif (preg_match('/\.ini$/i
', $tmpfile)) {
11002 $mime = 'text/plain
';
11003 $imgmime = 'text.png
';
11005 $famime = 'file-alt
';
11006 } elseif (preg_match('/\.md$/i
', $tmpfile)) {
11007 $mime = 'text/plain
';
11008 $imgmime = 'text.png
';
11010 $famime = 'file-alt
';
11011 } elseif (preg_match('/\.css$/i
', $tmpfile)) {
11012 $mime = 'text/css
';
11013 $imgmime = 'css.png
';
11015 $famime = 'file-alt
';
11016 } elseif (preg_match('/\.lang$/i
', $tmpfile)) {
11017 $mime = 'text/plain
';
11018 $imgmime = 'text.png
';
11020 $famime = 'file-alt
';
11021 } elseif (preg_match('/\.(crt|cer|key|pub)$/i
', $tmpfile)) { // Certificate files
11022 $mime = 'text/plain
';
11023 $imgmime = 'text.png
';
11024 $famime = 'file-alt
';
11025 } elseif (preg_match('/\.(html|htm|shtml)$/i
', $tmpfile)) { // XML based (HTML/XML/XAML)
11026 $mime = 'text/html
';
11027 $imgmime = 'html.png
';
11029 $famime = 'file-alt
';
11030 } elseif (preg_match('/\.(xml|xhtml)$/i
', $tmpfile)) {
11031 $mime = 'text/xml
';
11032 $imgmime = 'other.png
';
11034 $famime = 'file-alt
';
11035 } elseif (preg_match('/\.xaml$/i
', $tmpfile)) {
11036 $mime = 'text/xml
';
11037 $imgmime = 'other.png
';
11039 $famime = 'file-alt
';
11040 } elseif (preg_match('/\.bas$/i
', $tmpfile)) { // Languages
11041 $mime = 'text/plain
';
11042 $imgmime = 'text.png
';
11044 $famime = 'file-code
';
11045 } elseif (preg_match('/\.(c)$/i
', $tmpfile)) {
11046 $mime = 'text/plain
';
11047 $imgmime = 'text.png
';
11049 $famime = 'file-code
';
11050 } elseif (preg_match('/\.(cpp)$/i
', $tmpfile)) {
11051 $mime = 'text/plain
';
11052 $imgmime = 'text.png
';
11054 $famime = 'file-code
';
11055 } elseif (preg_match('/\.cs$/i
', $tmpfile)) {
11056 $mime = 'text/plain
';
11057 $imgmime = 'text.png
';
11059 $famime = 'file-code
';
11060 } elseif (preg_match('/\.(h)$/i
', $tmpfile)) {
11061 $mime = 'text/plain
';
11062 $imgmime = 'text.png
';
11064 $famime = 'file-code
';
11065 } elseif (preg_match('/\.(java|jsp)$/i
', $tmpfile)) {
11066 $mime = 'text/plain
';
11067 $imgmime = 'text.png
';
11069 $famime = 'file-code
';
11070 } elseif (preg_match('/\.php([0-9]{1})?$/i
', $tmpfile)) {
11071 $mime = 'text/plain
';
11072 $imgmime = 'php.png
';
11074 $famime = 'file-code
';
11075 } elseif (preg_match('/\.phtml$/i
', $tmpfile)) {
11076 $mime = 'text/plain
';
11077 $imgmime = 'php.png
';
11079 $famime = 'file-code
';
11080 } elseif (preg_match('/\.(pl|pm)$/i
', $tmpfile)) {
11081 $mime = 'text/plain
';
11082 $imgmime = 'pl.png
';
11084 $famime = 'file-code
';
11085 } elseif (preg_match('/\.sql$/i
', $tmpfile)) {
11086 $mime = 'text/plain
';
11087 $imgmime = 'text.png
';
11089 $famime = 'file-code
';
11090 } elseif (preg_match('/\.js$/i
', $tmpfile)) {
11091 $mime = 'text/x-javascript
';
11092 $imgmime = 'jscript.png
';
11094 $famime = 'file-code
';
11095 } elseif (preg_match('/\.odp$/i
', $tmpfile)) { // Open office
11096 $mime = 'application/vnd.oasis.opendocument.presentation
';
11097 $imgmime = 'ooffice.png
';
11098 $famime = 'file-powerpoint
';
11099 } elseif (preg_match('/\.ods$/i
', $tmpfile)) {
11100 $mime = 'application/vnd.oasis.opendocument.spreadsheet
';
11101 $imgmime = 'ooffice.png
';
11102 $famime = 'file-excel
';
11103 } elseif (preg_match('/\.odt$/i
', $tmpfile)) {
11104 $mime = 'application/vnd.oasis.opendocument.text
';
11105 $imgmime = 'ooffice.png
';
11106 $famime = 'file-word
';
11107 } elseif (preg_match('/\.mdb$/i
', $tmpfile)) { // MS Office
11108 $mime = 'application/msaccess
';
11109 $imgmime = 'mdb.png
';
11111 } elseif (preg_match('/\.doc[xm]?$/i
', $tmpfile)) {
11112 $mime = 'application/msword
';
11113 $imgmime = 'doc.png
';
11114 $famime = 'file-word
';
11115 } elseif (preg_match('/\.dot[xm]?$/i
', $tmpfile)) {
11116 $mime = 'application/msword
';
11117 $imgmime = 'doc.png
';
11118 $famime = 'file-word
';
11119 } elseif (preg_match('/\.xlt(x)?$/i
', $tmpfile)) {
11120 $mime = 'application/vnd.ms-excel
';
11121 $imgmime = 'xls.png
';
11122 $famime = 'file-excel
';
11123 } elseif (preg_match('/\.xla(m)?$/i
', $tmpfile)) {
11124 $mime = 'application/vnd.ms-excel
';
11125 $imgmime = 'xls.png
';
11126 $famime = 'file-excel
';
11127 } elseif (preg_match('/\.xls$/i
', $tmpfile)) {
11128 $mime = 'application/vnd.ms-excel
';
11129 $imgmime = 'xls.png
';
11130 $famime = 'file-excel
';
11131 } elseif (preg_match('/\.xls[bmx]$/i
', $tmpfile)) {
11132 $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
';
11133 $imgmime = 'xls.png
';
11134 $famime = 'file-excel
';
11135 } elseif (preg_match('/\.pps[mx]?$/i
', $tmpfile)) {
11136 $mime = 'application/vnd.ms-powerpoint
';
11137 $imgmime = 'ppt.png
';
11138 $famime = 'file-powerpoint
';
11139 } elseif (preg_match('/\.ppt[mx]?$/i
', $tmpfile)) {
11140 $mime = 'application/x-mspowerpoint
';
11141 $imgmime = 'ppt.png
';
11142 $famime = 'file-powerpoint
';
11143 } elseif (preg_match('/\.pdf$/i
', $tmpfile)) { // Other
11144 $mime = 'application/pdf
';
11145 $imgmime = 'pdf.png
';
11146 $famime = 'file-pdf
';
11147 } elseif (preg_match('/\.bat$/i
', $tmpfile)) { // Scripts
11148 $mime = 'text/x-bat
';
11149 $imgmime = 'script.png
';
11151 $famime = 'file-code
';
11152 } elseif (preg_match('/\.sh$/i
', $tmpfile)) {
11153 $mime = 'text/x-sh
';
11154 $imgmime = 'script.png
';
11156 $famime = 'file-code
';
11157 } elseif (preg_match('/\.ksh$/i
', $tmpfile)) {
11158 $mime = 'text/x-ksh
';
11159 $imgmime = 'script.png
';
11161 $famime = 'file-code
';
11162 } elseif (preg_match('/\.bash$/i
', $tmpfile)) {
11163 $mime = 'text/x-bash
';
11164 $imgmime = 'script.png
';
11166 $famime = 'file-code
';
11167 } elseif (preg_match('/\.ico$/i
', $tmpfile)) { // Images
11168 $mime = 'image/x-icon
';
11169 $imgmime = 'image.png
';
11170 $famime = 'file-image
';
11171 } elseif (preg_match('/\.(jpg|jpeg)$/i
', $tmpfile)) {
11172 $mime = 'image/jpeg
';
11173 $imgmime = 'image.png
';
11174 $famime = 'file-image
';
11175 } elseif (preg_match('/\.png$/i
', $tmpfile)) {
11176 $mime = 'image/png
';
11177 $imgmime = 'image.png
';
11178 $famime = 'file-image
';
11179 } elseif (preg_match('/\.gif$/i
', $tmpfile)) {
11180 $mime = 'image/gif
';
11181 $imgmime = 'image.png
';
11182 $famime = 'file-image
';
11183 } elseif (preg_match('/\.bmp$/i
', $tmpfile)) {
11184 $mime = 'image/bmp
';
11185 $imgmime = 'image.png
';
11186 $famime = 'file-image
';
11187 } elseif (preg_match('/\.(tif|tiff)$/i
', $tmpfile)) {
11188 $mime = 'image/tiff
';
11189 $imgmime = 'image.png
';
11190 $famime = 'file-image
';
11191 } elseif (preg_match('/\.svg$/i
', $tmpfile)) {
11192 $mime = 'image/svg+xml
';
11193 $imgmime = 'image.png
';
11194 $famime = 'file-image
';
11195 } elseif (preg_match('/\.webp$/i
', $tmpfile)) {
11196 $mime = 'image/webp
';
11197 $imgmime = 'image.png
';
11198 $famime = 'file-image
';
11199 } elseif (preg_match('/\.vcs$/i
', $tmpfile)) { // Calendar
11200 $mime = 'text/calendar
';
11201 $imgmime = 'other.png
';
11202 $famime = 'file-alt
';
11203 } elseif (preg_match('/\.ics$/i
', $tmpfile)) {
11204 $mime = 'text/calendar
';
11205 $imgmime = 'other.png
';
11206 $famime = 'file-alt
';
11207 } elseif (preg_match('/\.torrent$/i
', $tmpfile)) { // Other
11208 $mime = 'application/x-bittorrent
';
11209 $imgmime = 'other.png
';
11210 $famime = 'file-o
';
11211 } elseif (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i
', $tmpfile)) { // Audio
11213 $imgmime = 'audio.png
';
11214 $famime = 'file-audio
';
11215 } elseif (preg_match('/\.mp4$/i
', $tmpfile)) { // Video
11216 $mime = 'video/mp4
';
11217 $imgmime = 'video.png
';
11218 $famime = 'file-video
';
11219 } elseif (preg_match('/\.ogv$/i
', $tmpfile)) {
11220 $mime = 'video/ogg
';
11221 $imgmime = 'video.png
';
11222 $famime = 'file-video
';
11223 } elseif (preg_match('/\.webm$/i
', $tmpfile)) {
11224 $mime = 'video/webm
';
11225 $imgmime = 'video.png
';
11226 $famime = 'file-video
';
11227 } elseif (preg_match('/\.avi$/i
', $tmpfile)) {
11228 $mime = 'video/x-msvideo
';
11229 $imgmime = 'video.png
';
11230 $famime = 'file-video
';
11231 } elseif (preg_match('/\.divx$/i
', $tmpfile)) {
11232 $mime = 'video/divx
';
11233 $imgmime = 'video.png
';
11234 $famime = 'file-video
';
11235 } elseif (preg_match('/\.xvid$/i
', $tmpfile)) {
11236 $mime = 'video/xvid
';
11237 $imgmime = 'video.png
';
11238 $famime = 'file-video
';
11239 } elseif (preg_match('/\.(wmv|mpg|mpeg)$/i
', $tmpfile)) {
11241 $imgmime = 'video.png
';
11242 $famime = 'file-video
';
11243 } elseif (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh|zst)$/i
', $tmpfile)) { // Archive
11244 // application/xxx where zzz is zip, ...
11246 $imgmime = 'archive.png
';
11247 $famime = 'file-archive
';
11248 } elseif (preg_match('/\.(exe|com)$/i
', $tmpfile)) { // Exe
11249 $mime = 'application/octet-stream
';
11250 $imgmime = 'other.png
';
11251 $famime = 'file-o
';
11252 } elseif (preg_match('/\.(dll|lib|o|so|a)$/i
', $tmpfile)) { // Lib
11254 $imgmime = 'library.png
';
11255 $famime = 'file-o
';
11256 } elseif (preg_match('/\.err$/i
', $tmpfile)) { // phpcs:ignore
11258 $imgmime = 'error.png
';
11259 $famime = 'file-alt
';
11262 // Return mimetype string
11263 switch ((int) $mode) {
11265 $tmp = explode('/
', $mime);
11266 return (!empty($tmp[1]) ? $tmp[1] : $tmp[0]);
11288function getDictionaryValue($tablename, $field, $id, $checkentity = false, $rowidfield = '
rowid')
11292 $tablename = preg_replace('/^
'.preg_quote(MAIN_DB_PREFIX, '/
').'/
', '', $tablename); // Clean name of table for backward compatibility.
11294 $dictvalues = (isset($conf->cache['dictvalues_
'.$tablename]) ? $conf->cache['dictvalues_
'.$tablename] : null);
11296 if (is_null($dictvalues)) {
11297 $dictvalues = array();
11299 $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
11300 if ($checkentity) {
11301 $sql .=
' AND entity IN (0,'.getEntity($tablename).
')';
11304 $resql = $db->query($sql);
11306 while ($obj = $db->fetch_object($resql)) {
11307 $dictvalues[$obj->$rowidfield] = $obj;
11313 $conf->cache[
'dictvalues_'.$tablename] = $dictvalues;
11316 if (!empty($dictvalues[$id])) {
11318 $tmp = $dictvalues[$id];
11319 return (property_exists($tmp, $field) ? $tmp->$field :
'');
11334 $stringcolor = str_replace(
'#',
'', $stringcolor);
11336 if (!empty($stringcolor)) {
11338 $tmp = explode(
',', $stringcolor);
11339 if (count($tmp) > 1) {
11344 $hexr = $stringcolor[0].$stringcolor[1];
11345 $hexg = $stringcolor[2].$stringcolor[3];
11346 $hexb = $stringcolor[4].$stringcolor[5];
11347 $r = hexdec($hexr);
11348 $g = hexdec($hexg);
11349 $b = hexdec($hexb);
11351 $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0;
11352 if ($bright > 0.6) {
11373 if (empty($menuentry[
'enabled'])) {
11376 if ($type_user && $menuentry[
'module']) {
11377 $tmploops = explode(
'|', $menuentry[
'module']);
11379 foreach ($tmploops as $tmploop) {
11380 if (in_array($tmploop, $listofmodulesforexternal)) {
11389 if (!$menuentry[
'perms'] && $type_user) {
11395 if (!$menuentry[
'perms']) {
11410 return (ceil($n) % $x === 0) ? ceil($n) : round(($n + $x / 2) / $x) * $x;
11424function dolGetBadge($label, $html =
'', $type =
'primary', $mode =
'', $url =
'', $params = array())
11427 'class'=>
'badge '.(!empty($mode) ?
' badge-'.$mode :
'').(!empty($type) ?
' badge-'.$type :
'').(empty($params[
'css']) ?
'' :
' '.$params[
'css'])
11430 if (empty($html)) {
11434 if (!empty($url)) {
11435 $attr[
'href'] = $url;
11438 if ($mode ===
'dot') {
11439 $attr[
'class'] .=
' classfortooltip';
11440 $attr[
'title'] = $html;
11441 $attr[
'aria-label'] = $label;
11446 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
11447 foreach ($params[
'attr'] as $key => $value) {
11448 if ($key ==
'class') {
11449 $attr[
'class'] .=
' '.$value;
11450 } elseif ($key ==
'classOverride') {
11451 $attr[
'class'] = $value;
11453 $attr[$key] = $value;
11461 $attr = array_map(
'dol_escape_htmltag', $attr);
11463 $TCompiledAttr = array();
11464 foreach ($attr as $key => $value) {
11465 $TCompiledAttr[] = $key.
'="'.$value.
'"';
11468 $compiledAttributes = !empty($TCompiledAttr) ? implode(
' ', $TCompiledAttr) :
'';
11470 $tag = !empty($url) ?
'a' :
'span';
11472 return '<'.$tag.
' '.$compiledAttributes.
'>'.$html.
'</'.$tag.
'>';
11488function dolGetStatus($statusLabel =
'', $statusLabelShort =
'', $html =
'', $statusType =
'status0', $displayMode = 0, $url =
'', $params = array())
11493 $dolGetBadgeParams = array();
11495 if (!empty($params[
'badgeParams'])) {
11496 $dolGetBadgeParams = $params[
'badgeParams'];
11500 if ($displayMode == 0) {
11501 $return = !empty($html) ? $html : (empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort));
11502 } elseif ($displayMode == 1) {
11503 $return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
11507 $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ?
'<span class="hideonsmartphone">' :
'').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ?
'</span>' :
'');
11508 $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>' :
'');
11511 if (!empty($conf->dol_optimize_smallscreen)) {
11512 if ($displayMode == 0) {
11514 } elseif ($displayMode == 4) {
11516 } elseif ($displayMode == 6) {
11522 $statusImg = array(
11523 'status0' =>
'statut0',
11524 'status1' =>
'statut1',
11525 'status2' =>
'statut2',
11526 'status3' =>
'statut3',
11527 'status4' =>
'statut4',
11528 'status5' =>
'statut5',
11529 'status6' =>
'statut6',
11530 'status7' =>
'statut7',
11531 'status8' =>
'statut8',
11532 'status9' =>
'statut9'
11535 if (!empty($statusImg[$statusType])) {
11536 $htmlImg =
img_picto($statusLabel, $statusImg[$statusType]);
11538 $htmlImg =
img_picto($statusLabel, $statusType);
11541 if ($displayMode === 2) {
11542 $return = $htmlImg.
' '.$htmlLabelShort;
11543 } elseif ($displayMode === 3) {
11544 $return = $htmlImg;
11545 } elseif ($displayMode === 4) {
11546 $return = $htmlImg.
' '.$htmlLabel;
11547 } elseif ($displayMode === 5) {
11548 $return = $htmlLabelShort.
' '.$htmlImg;
11550 $return = $htmlLabel.
' '.$htmlImg;
11554 $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
11556 $dolGetBadgeParams[
'attr'][
'class'] =
'badge-status';
11557 $dolGetBadgeParams[
'attr'][
'title'] = empty($params[
'tooltip']) ? $statusLabel : ($params[
'tooltip'] !=
'no' ? $params[
'tooltip'] :
'');
11559 if ($displayMode == 3) {
11560 $return = dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)),
'', $statusType,
'dot', $url, $dolGetBadgeParams);
11561 } elseif ($displayMode === 5) {
11562 $return = dolGetBadge($statusLabelShort, $html, $statusType,
'', $url, $dolGetBadgeParams);
11564 $return = dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), $html, $statusType,
'', $url, $dolGetBadgeParams);
11606function dolGetButtonAction($label, $text =
'', $actionType =
'default', $url =
'', $id =
'', $userRight = 1, $params = array())
11608 global $hookmanager, $action, $object, $langs;
11611 if (is_array($url)) {
11613 foreach ($url as $key => $subbutton) {
11614 if (isset($subbutton[
'enabled']) && empty($subbutton[
'enabled'])) {
11621 if (count($url) > 1) {
11622 $out .=
'<div class="dropdown inline-block dropdown-holder">';
11623 $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>';
11624 $out .=
'<div class="dropdown-content">';
11625 foreach ($url as $subbutton) {
11626 if (!empty($subbutton[
'lang'])) {
11627 $langs->load($subbutton[
'lang']);
11629 $tmpurl = DOL_URL_ROOT.$subbutton[
'url'].(empty($params[
'backtopage']) ?
'' :
'&backtopage='.urlencode($params[
'backtopage']));
11630 $out .=
dolGetButtonAction(
'', $langs->trans($subbutton[
'label']),
'default', $tmpurl,
'', $subbutton[
'perm'], array(
'isDropDown' =>
true));
11635 foreach ($url as $subbutton) {
11636 if (!empty($subbutton[
'lang'])) {
11637 $langs->load($subbutton[
'lang']);
11639 $tmpurl = DOL_URL_ROOT.$subbutton[
'url'].(empty($params[
'backtopage']) ?
'' :
'&backtopage='.urlencode($params[
'backtopage']));
11640 $out .=
dolGetButtonAction(
'', $langs->trans($subbutton[
'label']),
'default', $tmpurl,
'', $subbutton[
'perm']);
11649 if (!empty($params[
'isDropdown'])) {
11650 $class =
"dropdown-item";
11652 $class =
'butAction';
11653 if ($actionType ==
'danger' || $actionType ==
'delete') {
11654 $class =
'butActionDelete';
11655 if (!empty($url) && strpos($url,
'token=') ===
false) {
11656 $url .=
'&token='.newToken();
11662 'href' => empty($url) ?
'' : $url,
11666 if (empty($text)) {
11668 $attr[
'title'] =
'';
11670 $attr[
'title'] = $label;
11671 $attr[
'aria-label'] = $label;
11674 if (empty($userRight)) {
11675 $attr[
'class'] =
'butActionRefused';
11676 $attr[
'href'] =
'';
11677 $attr[
'title'] = (($label && $text && $label != $text) ? $label : $langs->trans(
'NotEnoughPermissions'));
11685 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
11686 foreach ($params[
'attr'] as $key => $value) {
11687 if ($key ==
'class') {
11688 $attr[
'class'] .=
' '.$value;
11689 } elseif ($key ==
'classOverride') {
11690 $attr[
'class'] = $value;
11692 $attr[$key] = $value;
11698 if (!empty($attr[
'title']) && !empty($attr[
'class']) && strpos($attr[
'class'],
'classfortooltip') ===
false) {
11699 $attr[
'class'].=
' classfortooltip';
11703 if ($userRight && !empty($params[
'confirm'])) {
11704 if (!is_array($params[
'confirm'])) {
11705 $params[
'confirm'] = array();
11708 if (empty($params[
'confirm'][
'url'])) {
11709 $params[
'confirm'][
'url'] = $url . (strpos($url,
'?') > 0 ?
'&' :
'?') .
'confirm=yes';
11713 $attr[
'data-confirm-url'] = $params[
'confirm'][
'url'];
11714 $attr[
'data-confirm-title'] = !empty($params[
'confirm'][
'title']) ? $params[
'confirm'][
'title'] : $langs->trans(
'ConfirmBtnCommonTitle', $label);
11715 $attr[
'data-confirm-content'] = !empty($params[
'confirm'][
'content']) ? $params[
'confirm'][
'content'] : $langs->trans(
'ConfirmBtnCommonContent', $label);
11716 $attr[
'data-confirm-content'] = preg_replace(
"/\r|\n/",
"", $attr[
'data-confirm-content']);
11717 $attr[
'data-confirm-action-btn-label'] = !empty($params[
'confirm'][
'action-btn-label']) ? $params[
'confirm'][
'action-btn-label'] : $langs->trans(
'Confirm');
11718 $attr[
'data-confirm-cancel-btn-label'] = !empty($params[
'confirm'][
'cancel-btn-label']) ? $params[
'confirm'][
'cancel-btn-label'] : $langs->trans(
'CloseDialog');
11719 $attr[
'data-confirm-modal'] = !empty($params[
'confirm'][
'modal']) ? $params[
'confirm'][
'modal'] :
true;
11721 $attr[
'class'].=
' butActionConfirm';
11724 if (isset($attr[
'href']) && empty($attr[
'href'])) {
11725 unset($attr[
'href']);
11729 $attr = array_map(
'dol_escape_htmltag', $attr);
11731 $TCompiledAttr = array();
11732 foreach ($attr as $key => $value) {
11733 $TCompiledAttr[] = $key.
'= "'.$value.
'"';
11736 $compiledAttributes = empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr);
11738 $tag = !empty($attr[
'href']) ?
'a' :
'span';
11741 $parameters = array(
11742 'TCompiledAttr' => $TCompiledAttr,
11743 'compiledAttributes' => $compiledAttributes,
11748 'actionType' => $actionType,
11751 'userRight' => $userRight,
11752 'params' => $params
11755 $reshook = $hookmanager->executeHooks(
'dolGetButtonAction', $parameters, $object, $action);
11756 if ($reshook < 0) {
11760 if (empty($reshook)) {
11762 return '<' . $tag .
' ' . $compiledAttributes .
'>' . $text .
'</' . $tag .
'>';
11764 return '<' . $tag .
' ' . $compiledAttributes .
'>' .
dol_escape_htmltag($text) .
'</' . $tag .
'>';
11767 return $hookmanager->resPrint;
11779 return '<span class="button-title-separator '.$moreClass.
'" ></span>';
11791 if (!empty($fieldValidationErrorMsg)) {
11792 $out.=
'<span class="field-error-icon classfortooltip" title="'.dol_escape_htmltag($fieldValidationErrorMsg, 1).
'" role="alert" >';
11793 $out.=
'<span class="fa fa-exclamation-circle" aria-hidden="true" ></span>';
11812function dolGetButtonTitle($label, $helpText =
'', $iconClass =
'fa fa-file', $url =
'', $id =
'', $status = 1, $params = array())
11814 global $langs, $conf, $user;
11817 if (
getDolGlobalString(
'MAIN_BUTTON_HIDE_UNAUTHORIZED') && (!$user->admin) && $status <= 0) {
11821 $class =
'btnTitle';
11822 if (in_array($iconClass, array(
'fa fa-plus-circle',
'fa fa-plus-circle size15x',
'fa fa-comment-dots',
'fa fa-paper-plane'))) {
11823 $class .=
' btnTitlePlus';
11825 $useclassfortooltip = 1;
11827 if (!empty($params[
'morecss'])) {
11828 $class .=
' '.$params[
'morecss'];
11833 'href' => empty($url) ?
'' : $url
11836 if (!empty($helpText)) {
11838 } elseif (empty($attr[
'title']) && $label) {
11839 $attr[
'title'] = $label;
11840 $useclassfortooltip = 0;
11843 if ($status == 2) {
11844 $attr[
'class'] .=
' btnTitleSelected';
11845 } elseif ($status <= 0) {
11846 $attr[
'class'] .=
' refused';
11848 $attr[
'href'] =
'';
11850 if ($status == -1) {
11851 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"FeatureDisabled"));
11852 } elseif ($status == 0) {
11853 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions"));
11857 if (!empty($attr[
'title']) && $useclassfortooltip) {
11858 $attr[
'class'] .=
' classfortooltip';
11866 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
11867 foreach ($params[
'attr'] as $key => $value) {
11868 if ($key ==
'class') {
11869 $attr[
'class'] .=
' '.$value;
11870 } elseif ($key ==
'classOverride') {
11871 $attr[
'class'] = $value;
11873 $attr[$key] = $value;
11878 if (isset($attr[
'href']) && empty($attr[
'href'])) {
11879 unset($attr[
'href']);
11885 $attr = array_map(
'dol_escape_htmltag', $attr);
11887 $TCompiledAttr = array();
11888 foreach ($attr as $key => $value) {
11889 $TCompiledAttr[] = $key.
'="'.$value.
'"';
11892 $compiledAttributes = (empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr));
11894 $tag = (empty($attr[
'href']) ?
'span' :
'a');
11896 $button =
'<'.$tag.
' '.$compiledAttributes.
'>';
11897 $button .=
'<span class="'.$iconClass.
' valignmiddle btnTitle-icon"></span>';
11898 if (!empty($params[
'forcenohideoftext'])) {
11899 $button .=
'<span class="valignmiddle text-plus-circle btnTitle-label'.(empty($params[
'forcenohideoftext']) ?
' hideonsmartphone' :
'').
'">'.$label.
'</span>';
11901 $button .=
'</'.$tag.
'>';
11918 global $conf, $db, $hookmanager;
11924 $classfile = $classname = $classpath = $subdir = $dir_output =
'';
11927 $module = $element_type;
11928 $element = $element_type;
11929 $subelement = $element_type;
11930 $table_element = $element_type;
11933 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $element_type, $regs)) {
11934 $element = $subelement = $regs[1];
11935 $module = $regs[2];
11940 if (preg_match(
'/^([^_]+)_([^_]+)/i', $element, $regs)) {
11941 $module = $element = $regs[1];
11942 $subelement = $regs[2];
11946 if ($element_type ==
"action" || $element_type ==
"actioncomm") {
11947 $classpath =
'comm/action/class';
11948 $subelement =
'Actioncomm';
11949 $module =
'agenda';
11950 $table_element =
'actioncomm';
11951 } elseif ($element_type ==
'cronjob') {
11952 $classpath =
'cron/class';
11954 $table_element =
'cron';
11955 } elseif ($element_type ==
'adherent_type') {
11956 $classpath =
'adherents/class';
11957 $classfile =
'adherent_type';
11958 $module =
'adherent';
11959 $subelement =
'adherent_type';
11960 $classname =
'AdherentType';
11961 $table_element =
'adherent_type';
11962 } elseif ($element_type ==
'bank_account') {
11963 $classpath =
'compta/bank/class';
11965 $classfile =
'account';
11966 $classname =
'Account';
11967 } elseif ($element_type ==
'category') {
11968 $classpath =
'categories/class';
11969 $module =
'categorie';
11970 $subelement =
'categorie';
11971 $table_element =
'categorie';
11972 } elseif ($element_type ==
'contact') {
11973 $classpath =
'contact/class';
11974 $classfile =
'contact';
11975 $module =
'societe';
11976 $subelement =
'contact';
11977 $table_element =
'socpeople';
11978 } elseif ($element_type ==
'inventory') {
11979 $module =
'product';
11980 $classpath =
'product/inventory/class';
11981 } elseif ($element_type ==
'stock' || $element_type ==
'entrepot') {
11983 $classpath =
'product/stock/class';
11984 $classfile =
'entrepot';
11985 $classname =
'Entrepot';
11986 $table_element =
'entrepot';
11987 } elseif ($element_type ==
'project') {
11988 $classpath =
'projet/class';
11989 $module =
'projet';
11990 $table_element =
'projet';
11991 } elseif ($element_type ==
'project_task') {
11992 $classpath =
'projet/class';
11993 $module =
'projet';
11994 $subelement =
'task';
11995 $table_element =
'projet_task';
11996 } elseif ($element_type ==
'facture' || $element_type ==
'invoice') {
11997 $classpath =
'compta/facture/class';
11998 $module =
'facture';
11999 $subelement =
'facture';
12000 $table_element =
'facture';
12001 } elseif ($element_type ==
'commande' || $element_type ==
'order') {
12002 $classpath =
'commande/class';
12003 $module =
'commande';
12004 $subelement =
'commande';
12005 $table_element =
'commande';
12006 } elseif ($element_type ==
'propal') {
12007 $classpath =
'comm/propal/class';
12008 $table_element =
'propal';
12009 } elseif ($element_type ==
'shipping') {
12010 $classpath =
'expedition/class';
12011 $classfile =
'expedition';
12012 $classname =
'Expedition';
12013 $module =
'expedition';
12014 $table_element =
'expedition';
12015 } elseif ($element_type ==
'supplier_proposal') {
12016 $classpath =
'supplier_proposal/class';
12017 $module =
'supplier_proposal';
12018 $element =
'supplierproposal';
12019 $classfile =
'supplier_proposal';
12020 $subelement =
'supplierproposal';
12021 } elseif ($element_type ==
'shipping') {
12022 $classpath =
'expedition/class';
12023 $subelement =
'expedition';
12024 $module =
'expedition_bon';
12025 } elseif ($element_type ==
'delivery') {
12026 $classpath =
'delivery/class';
12027 $subelement =
'delivery';
12028 $module =
'expedition';
12029 } elseif ($element_type ==
'contract') {
12030 $classpath =
'contrat/class';
12031 $module =
'contrat';
12032 $subelement =
'contrat';
12033 $table_element =
'contract';
12034 } elseif ($element_type ==
'mailing') {
12035 $classpath =
'comm/mailing/class';
12036 $module =
'mailing';
12037 $classfile =
'mailing';
12038 $classname =
'Mailing';
12040 } elseif ($element_type ==
'member') {
12041 $classpath =
'adherents/class';
12042 $module =
'adherent';
12043 $subelement =
'adherent';
12044 $table_element =
'adherent';
12045 } elseif ($element_type ==
'usergroup') {
12046 $classpath =
'user/class';
12048 } elseif ($element_type ==
'mo') {
12049 $classpath =
'mrp/class';
12054 $table_element =
'mrp_mo';
12055 } elseif ($element_type ==
'cabinetmed_cons') {
12056 $classpath =
'cabinetmed/class';
12057 $module =
'cabinetmed';
12058 $subelement =
'cabinetmedcons';
12059 $table_element =
'cabinetmedcons';
12060 } elseif ($element_type ==
'fichinter') {
12061 $classpath =
'fichinter/class';
12062 $module =
'ficheinter';
12063 $subelement =
'fichinter';
12064 $table_element =
'fichinter';
12065 } elseif ($element_type ==
'dolresource' || $element_type ==
'resource') {
12066 $classpath =
'resource/class';
12067 $module =
'resource';
12068 $subelement =
'dolresource';
12069 $table_element =
'resource';
12070 } elseif ($element_type ==
'propaldet') {
12071 $classpath =
'comm/propal/class';
12072 $module =
'propal';
12073 $subelement =
'propaleligne';
12074 } elseif ($element_type ==
'opensurvey_sondage') {
12075 $classpath =
'opensurvey/class';
12076 $module =
'opensurvey';
12077 $subelement =
'opensurveysondage';
12078 } elseif ($element_type ==
'order_supplier') {
12079 $classpath =
'fourn/class';
12080 $module =
'fournisseur';
12081 $classfile =
'fournisseur.commande';
12082 $element =
'order_supplier';
12084 $classname =
'CommandeFournisseur';
12085 $table_element =
'commande_fournisseur';
12086 } elseif ($element_type ==
'commande_fournisseurdet') {
12087 $classpath =
'fourn/class';
12088 $module =
'fournisseur';
12089 $classfile =
'fournisseur.commande';
12090 $element =
'commande_fournisseurdet';
12092 $classname =
'CommandeFournisseurLigne';
12093 $table_element =
'commande_fournisseurdet';
12094 } elseif ($element_type ==
'invoice_supplier') {
12095 $classpath =
'fourn/class';
12096 $module =
'fournisseur';
12097 $classfile =
'fournisseur.facture';
12098 $element =
'invoice_supplier';
12100 $classname =
'FactureFournisseur';
12101 $table_element =
'facture_fourn';
12102 } elseif ($element_type ==
"service") {
12103 $classpath =
'product/class';
12104 $subelement =
'product';
12105 $table_element =
'product';
12106 } elseif ($element_type ==
'salary') {
12107 $classpath =
'salaries/class';
12108 $module =
'salaries';
12109 } elseif ($element_type ==
'payment_salary') {
12110 $classpath =
'salaries/class';
12111 $classfile =
'paymentsalary';
12112 $classname =
'PaymentSalary';
12113 $module =
'salaries';
12114 } elseif ($element_type ==
'productlot') {
12115 $module =
'productbatch';
12116 $classpath =
'product/stock/class';
12117 $classfile =
'productlot';
12118 $classname =
'Productlot';
12119 $element =
'productlot';
12121 $table_element =
'product_lot';
12122 } elseif ($element_type ==
'websitepage') {
12123 $classpath =
'website/class';
12124 $classfile =
'websitepage';
12125 $classname =
'Websitepage';
12126 $module =
'website';
12127 $subelement =
'websitepage';
12128 $table_element =
'website_page';
12129 } elseif ($element_type ==
'fiscalyear') {
12130 $classpath =
'core/class';
12131 $module =
'accounting';
12132 $subelement =
'fiscalyear';
12133 } elseif ($element_type ==
'chargesociales') {
12134 $classpath =
'compta/sociales/class';
12136 $table_element =
'chargesociales';
12137 } elseif ($element_type ==
'tva') {
12138 $classpath =
'compta/tva/class';
12141 $table_element =
'tva';
12142 } elseif ($element_type ==
'emailsenderprofile') {
12144 $classpath =
'core/class';
12145 $classfile =
'emailsenderprofile';
12146 $classname =
'EmailSenderProfile';
12147 $table_element =
'c_email_senderprofile';
12149 } elseif ($element_type ==
'ccountry') {
12151 $classpath =
'core/class';
12152 $classfile =
'ccountry';
12153 $classname =
'Ccountry';
12154 $table_element =
'c_country';
12158 if (empty($classfile)) {
12159 $classfile = strtolower($subelement);
12161 if (empty($classname)) {
12162 $classname = ucfirst($subelement);
12164 if (empty($classpath)) {
12165 $classpath = $module.
'/class';
12171 if ($module && isset($conf->$module)) {
12172 if (!empty($conf->$module->multidir_output[$conf->entity])) {
12173 $dir_output = $conf->$module->multidir_output[$conf->entity];
12174 } elseif (!empty($conf->$module->output[$conf->entity])) {
12175 $dir_output = $conf->$module->output[$conf->entity];
12176 } elseif (!empty($conf->$module->dir_output)) {
12177 $dir_output = $conf->$module->dir_output;
12182 if ($element ==
'order_supplier') {
12183 $dir_output = $conf->fournisseur->commande->dir_output;
12184 } elseif ($element ==
'invoice_supplier') {
12185 $dir_output = $conf->fournisseur->facture->dir_output;
12187 $dir_output .= $subdir;
12189 $elementProperties = array(
12190 'module' => $module,
12191 'element' => $element,
12192 'table_element' => $table_element,
12193 'subelement' => $subelement,
12194 'classpath' => $classpath,
12195 'classfile' => $classfile,
12196 'classname' => $classname,
12197 'dir_output' => $dir_output
12202 if (!is_object($hookmanager)) {
12203 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
12206 $hookmanager->initHooks(array(
'elementproperties'));
12210 $parameters = array(
12211 'elementType' => $element_type,
12212 'elementProperties' => $elementProperties
12215 $reshook = $hookmanager->executeHooks(
'getElementProperties', $parameters);
12218 $elementProperties = $hookmanager->resArray;
12219 } elseif (!empty($hookmanager->resArray) && is_array($hookmanager->resArray)) {
12220 $elementProperties = array_replace($elementProperties, $hookmanager->resArray);
12224 if (($key = array_search(
'elementproperties', $hookmanager->contextarray)) !==
false) {
12225 unset($hookmanager->contextarray[$key]);
12228 return $elementProperties;
12249 if ($element_prop[
'module'] ==
'product' || $element_prop[
'module'] ==
'service') {
12254 $ismodenabled = (isModEnabled(
'product') || isModEnabled(
'service'));
12256 $ismodenabled = isModEnabled($element_prop[
'module']);
12261 if (is_array($element_prop) && (empty($element_prop[
'module']) || $ismodenabled)) {
12262 dol_include_once(
'/'.$element_prop[
'classpath'].
'/'.$element_prop[
'classfile'].
'.class.php');
12264 if (class_exists($element_prop[
'classname'])) {
12265 $classname = $element_prop[
'classname'];
12266 $objecttmp =
new $classname($db);
12268 if ($element_id > 0 || !empty($element_ref)) {
12269 $ret = $objecttmp->fetch($element_id, $element_ref);
12271 if (empty($objecttmp->module)) {
12272 $objecttmp->module = $element_prop[
'module'];
12295 if (preg_match(
'/\.(htm|html|js|phar|php|php\d+|phtml|pht|pl|py|cgi|ksh|sh|shtml|bash|bat|cmd|wpk|exe|dmg)$/i', $filename)) {
12311 return empty($_SESSION[
'newtoken']) ?
'' : $_SESSION[
'newtoken'];
12323 return isset($_SESSION[
'token']) ? $_SESSION[
'token'] :
'';
12335 if (empty($conf->cache[
'nonce'])) {
12339 return $conf->cache[
'nonce'];
12359 print
'<div class="div-table-responsive-no-min">';
12360 print
'<table class="noborder centpercent">';
12361 print
'<tr class="liste_titre">';
12363 print $emptyRows < 1 ?
'<th>' :
'<th colspan="'.($emptyRows + 1).
'">';
12365 print $langs->trans($header);
12368 if ($number > -1) {
12372 if (!empty($link)) {
12373 if (!empty($arguments)) {
12374 print
'<a href="'.DOL_URL_ROOT.
'/'.$link.
'?'.$arguments.
'">';
12376 print
'<a href="'.DOL_URL_ROOT.
'/'.$link.
'">';
12380 if ($number > -1) {
12381 print
'<span class="badge">'.$number.
'</span>';
12384 if (!empty($link)) {
12390 if ($number < 0 && !empty($link)) {
12391 print
'<th class="right">';
12393 if (!empty($arguments)) {
12394 print
'<a class="commonlink" href="'.DOL_URL_ROOT.
'/'.$link.
'?'.$arguments.
'">';
12396 print
'<a class="commonlink" href="'.DOL_URL_ROOT.
'/'.$link.
'">';
12399 print $langs->trans(
"FullList");
12420 if ($addLineBreak) {
12436function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord =
"None", $extraRightColumn =
false)
12441 print
'<tr class="oddeven">';
12442 print
'<td colspan="'.$tableColumnCount.
'"><span class="opacitymedium">'.$langs->trans($noneWord).
'</span></td>';
12447 if ($nbofloop === 0) {
12453 $colspan = $tableColumnCount;
12454 } elseif ($num > $nbofloop) {
12455 $colspan = $tableColumnCount;
12457 $colspan = $tableColumnCount - 1;
12460 if ($extraRightColumn) {
12464 print
'<tr class="liste_total">';
12466 if ($nbofloop > 0 && $num > $nbofloop) {
12467 print
'<td colspan="'.$colspan.
'" class="right">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
'</td>';
12469 print
'<td colspan="'.$colspan.
'" class="right"> '.$langs->trans(
"Total").
'</td>';
12470 print
'<td class="right centpercent">'.price($total).
'</td>';
12473 if ($extraRightColumn) {
12490 if ($method == -1) {
12501 while (ob_get_level()) {
12506 if ($method == 0) {
12507 readfile($fullpath_original_file_osencoded);
12508 } elseif ($method == 1) {
12510 $handle = fopen($fullpath_original_file_osencoded,
"rb");
12511 while (!feof($handle)) {
12512 print fread($handle, 8192);
12515 } elseif ($method == 2) {
12517 $handle1 = fopen($fullpath_original_file_osencoded,
"rb");
12518 $handle2 = fopen(
"php://output",
"wb");
12519 stream_copy_to_stream($handle1, $handle2);
12544 if ($texttoshow ===
'none') {
12545 $result =
'<span class="clipboardCP'.($showonlyonhover ?
' clipboardCPShowOnHover' :
'').
'"><'.$tag.
' class="clipboardCPValue hidewithsize">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'><span class="clipboardCPValueToPrint"></span><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText"></span></span>';
12546 } elseif ($texttoshow) {
12547 $result =
'<span class="clipboardCP'.($showonlyonhover ?
' clipboardCPShowOnHover' :
'').
'"><'.$tag.
' class="clipboardCPValue hidewithsize">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'><span class="clipboardCPValueToPrint">'.
dol_escape_htmltag($texttoshow, 1, 1).
'</span><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText"></span></span>';
12549 $result =
'<span class="clipboardCP'.($showonlyonhover ?
' clipboardCPShowOnHover' :
'').
'"><'.$tag.
' class="clipboardCPValue">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText"></span></span>';
12564 $result = json_decode($stringtodecode);
12565 if ($result ===
null) {
12566 $result = unserialize($stringtodecode);
12588 if (empty($filter)) {
12592 if (!preg_match(
'/^\(.*\)$/', $filter)) {
12593 $filter =
'(' . $filter .
')';
12596 $regexstring =
'\(([a-zA-Z0-9_\.]+:[<>!=insotlke]+:[^\(\)]+)\)';
12602 return 'Filter syntax error - '.$errorstr;
12607 $t = preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeDummyCriteriaCallback', $filter);
12608 $t = str_replace(array(
'and',
'or',
'AND',
'OR',
' '),
'', $t);
12610 if (preg_match(
'/[^\(\)]/', $t)) {
12611 $errorstr =
'Bad syntax of the search string';
12615 return 'Filter syntax error - '.$errorstr;
12619 return ($noand ?
"" :
" AND ").($nopar ?
"" :
'(').preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeCriteriaCallback', $filter).($nopar ?
"" :
')');
12633 $tmp = $sqlfilters;
12635 $nb = strlen($tmp);
12638 if ($tmp[$i] ==
'(') {
12641 if ($tmp[$i] ==
')') {
12644 if ($counter < 0) {
12645 $error =
"Wrond balance of parenthesis in sqlfilters=".$sqlfilters;
12664 if (empty($matches[1])) {
12667 $tmp = explode(
':', $matches[1]);
12668 if (count($tmp) < 3) {
12688 if (empty($matches[1])) {
12691 $tmp = explode(
':', $matches[1]);
12692 if (count($tmp) < 3) {
12696 $operand = preg_replace(
'/[^a-z0-9\._]/i',
'', trim($tmp[0]));
12698 $operator = strtoupper(preg_replace(
'/[^a-z<>!=]/i',
'', trim($tmp[1])));
12701 'NOTLIKE' =>
'NOT LIKE',
12702 'ISNOT' =>
'IS NOT',
12703 'NOTIN' =>
'NOT IN',
12707 if (array_key_exists($operator, $realOperator)) {
12708 $operator = $realOperator[$operator];
12712 $tmpescaped = $tmp[2];
12715 if ($operator ==
'IN' || $operator ==
'NOT IN') {
12717 $tmpescaped2 =
'(';
12719 $tmpelemarray = explode(
',', $tmpescaped);
12720 foreach ($tmpelemarray as $tmpkey => $tmpelem) {
12722 if (preg_match(
'/^\'(.*)\'$/', $tmpelem, $reg)) {
12723 $tmpelemarray[$tmpkey] =
"'".$db->escape($db->sanitize($reg[1], 1, 1, 1)).
"'";
12725 $tmpelemarray[$tmpkey] = $db->escape($db->sanitize($tmpelem, 1, 1, 1));
12728 $tmpescaped2 .= join(
',', $tmpelemarray);
12729 $tmpescaped2 .=
')';
12731 $tmpescaped = $tmpescaped2;
12732 } elseif ($operator ==
'LIKE' || $operator ==
'NOT LIKE') {
12733 if (preg_match(
'/^\'(.*)\'$/', $tmpescaped, $regbis)) {
12734 $tmpescaped = $regbis[1];
12737 $tmpescaped =
"'".$db->escape($tmpescaped).
"'";
12738 } elseif (preg_match(
'/^\'(.*)\'$/', $tmpescaped, $regbis)) {
12739 $tmpescaped =
"'".$db->escape($regbis[1]).
"'";
12741 if (strtoupper($tmpescaped) ==
'NULL') {
12742 $tmpescaped =
'NULL';
12743 } elseif (is_int($tmpescaped)) {
12744 $tmpescaped = (int) $tmpescaped;
12746 $tmpescaped = (float) $tmpescaped;
12750 return '('.$db->escape($operand).
' '.strtoupper($operator).
' '.$tmpescaped.
')';
12765 global $conf, $langs;
12767 $out =
'<!-- timeline icon -->'.
"\n";
12768 $iconClass =
'fa fa-comments';
12773 if ($histo[$key][
'percent'] == -1) {
12774 $colorClass =
'timeline-icon-not-applicble';
12775 $pictoTitle = $langs->trans(
'StatusNotApplicable');
12776 } elseif ($histo[$key][
'percent'] == 0) {
12777 $colorClass =
'timeline-icon-todo';
12778 $pictoTitle = $langs->trans(
'StatusActionToDo').
' (0%)';
12779 } elseif ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100) {
12780 $colorClass =
'timeline-icon-in-progress';
12781 $pictoTitle = $langs->trans(
'StatusActionInProcess').
' ('.$histo[$key][
'percent'].
'%)';
12782 } elseif ($histo[$key][
'percent'] >= 100) {
12783 $colorClass =
'timeline-icon-done';
12784 $pictoTitle = $langs->trans(
'StatusActionDone').
' (100%)';
12787 if ($actionstatic->code ==
'AC_TICKET_CREATE') {
12788 $iconClass =
'fa fa-ticket';
12789 } elseif ($actionstatic->code ==
'AC_TICKET_MODIFY') {
12790 $iconClass =
'fa fa-pencilxxx';
12791 } elseif (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
12792 $iconClass =
'fa fa-comments';
12793 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
12794 $iconClass =
'fa fa-mask';
12796 if ($actionstatic->type_picto) {
12797 $img_picto =
img_picto(
'', $actionstatic->type_picto);
12799 if ($actionstatic->type_code ==
'AC_RDV') {
12800 $iconClass =
'fa fa-handshake';
12801 } elseif ($actionstatic->type_code ==
'AC_TEL') {
12802 $iconClass =
'fa fa-phone';
12803 } elseif ($actionstatic->type_code ==
'AC_FAX') {
12804 $iconClass =
'fa fa-fax';
12805 } elseif ($actionstatic->type_code ==
'AC_EMAIL') {
12806 $iconClass =
'fa fa-envelope';
12807 } elseif ($actionstatic->type_code ==
'AC_INT') {
12808 $iconClass =
'fa fa-shipping-fast';
12809 } elseif ($actionstatic->type_code ==
'AC_OTH_AUTO') {
12810 $iconClass =
'fa fa-robot';
12811 } elseif (!preg_match(
'/_AUTO/', $actionstatic->type_code)) {
12812 $iconClass =
'fa fa-robot';
12817 $out .=
'<i class="'.$iconClass.
' '.$colorClass.
'" title="'.$pictoTitle.
'">'.$img_picto.
'</i>'.
"\n";
12831 $documents = array();
12833 $sql =
'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.filepath, ecm.filename';
12834 $sql .=
' FROM '.MAIN_DB_PREFIX.
'ecm_files ecm';
12835 $sql .=
" WHERE ecm.filepath = 'agenda/".((int) $object->id).
"'";
12837 $sql .=
' ORDER BY ecm.position ASC';
12839 $resql = $db->query($sql);
12841 if ($db->num_rows($resql)) {
12842 while ($obj = $db->fetch_object($resql)) {
12843 $documents[$obj->id] = $obj;
12870function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon =
'', $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC')
12872 global $user, $conf;
12875 global $param, $massactionbutton;
12880 if (!is_object($filterobj) && !is_object($objcon)) {
12888 $sortfield_list = explode(
',', $sortfield);
12889 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
12890 $sortfield_new_list = array();
12891 foreach ($sortfield_list as $sortfield_value) {
12892 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
12894 $sortfield_new = implode(
',', $sortfield_new_list);
12896 if (isModEnabled(
'agenda')) {
12898 if (is_object($objcon) && $objcon->id > 0) {
12899 $sql =
"SELECT DISTINCT a.id, a.label as label,";
12901 $sql =
"SELECT a.id, a.label as label,";
12903 $sql .=
" a.datep as dp,";
12904 $sql .=
" a.note as message,";
12905 $sql .=
" a.datep2 as dp2,";
12906 $sql .=
" a.percent as percent, 'action' as type,";
12907 $sql .=
" a.fk_element, a.elementtype,";
12908 $sql .=
" a.fk_contact,";
12909 $sql .=
" a.email_from as msg_from,";
12910 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
12911 $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";
12912 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
12913 $sql .=
", sp.lastname, sp.firstname";
12914 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
12915 $sql .=
", m.lastname, m.firstname";
12916 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
12918 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
12920 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
12922 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
12924 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
12927 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
12928 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
12929 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
12931 $force_filter_contact =
false;
12932 if (is_object($objcon) && $objcon->id > 0) {
12933 $force_filter_contact =
true;
12934 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as r ON a.id = r.fk_actioncomm";
12935 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id);
12938 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
12939 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
12940 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
12941 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
12942 $sql .=
" ON er.resource_type = 'dolresource'";
12943 $sql .=
" AND er.element_id = a.id";
12944 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
12945 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
12946 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
12947 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
12948 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
12949 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
12950 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
12951 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
12952 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
12953 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
12954 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
12955 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
12956 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
12959 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
12960 if ($force_filter_contact ===
false) {
12961 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
12962 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
12963 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
12964 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
12965 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
12966 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
12967 if ($filterobj->id) {
12968 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
12970 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
12971 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
12972 if ($filterobj->id) {
12973 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
12975 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
12976 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
12977 if ($filterobj->id) {
12978 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
12980 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
12981 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
12982 if ($filterobj->id) {
12983 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
12985 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
12986 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
12987 if ($filterobj->id) {
12988 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
12990 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
12991 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
12992 if ($filterobj->id) {
12993 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
12999 if (!empty($actioncode)) {
13001 if ($actioncode ==
'AC_NON_AUTO') {
13002 $sql .=
" AND c.type != 'systemauto'";
13003 } elseif ($actioncode ==
'AC_ALL_AUTO') {
13004 $sql .=
" AND c.type = 'systemauto'";
13006 if ($actioncode ==
'AC_OTH') {
13007 $sql .=
" AND c.type != 'systemauto'";
13008 } elseif ($actioncode ==
'AC_OTH_AUTO') {
13009 $sql .=
" AND c.type = 'systemauto'";
13013 if ($actioncode ==
'AC_NON_AUTO') {
13014 $sql .=
" AND c.type != 'systemauto'";
13015 } elseif ($actioncode ==
'AC_ALL_AUTO') {
13016 $sql .=
" AND c.type = 'systemauto'";
13018 $sql .=
" AND c.code = '".$db->escape($actioncode).
"'";
13022 if ($donetodo ==
'todo') {
13023 $sql .=
" AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now).
"'))";
13024 } elseif ($donetodo ==
'done') {
13025 $sql .=
" AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now).
"'))";
13027 if (is_array($filters) && $filters[
'search_agenda_label']) {
13028 $sql .=
natural_search(
'a.label', $filters[
'search_agenda_label']);
13033 if (isModEnabled(
'mailing') && !empty($objcon->email)
13034 && (empty($actioncode) || $actioncode ==
'AC_OTH_AUTO' || $actioncode ==
'AC_EMAILING')) {
13035 $langs->load(
"mails");
13037 $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";
13038 $sql2 .=
", null as fk_element, '' as elementtype, null as contact_id";
13039 $sql2 .=
", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
13040 $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";
13041 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
13042 $sql2 .=
", '' as lastname, '' as firstname";
13043 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
13044 $sql2 .=
", '' as lastname, '' as firstname";
13045 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
13046 $sql2 .=
", '' as ref";
13047 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
13048 $sql2 .=
", '' as ref";
13049 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
13050 $sql2 .=
", '' as ref";
13052 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"user as u";
13053 $sql2 .=
" WHERE mc.email = '".$db->escape($objcon->email).
"'";
13054 $sql2 .=
" AND mc.statut = 1";
13055 $sql2 .=
" AND u.rowid = m.fk_user_valid";
13056 $sql2 .=
" AND mc.fk_mailing=m.rowid";
13059 if (!empty($sql) && !empty($sql2)) {
13060 $sql = $sql.
" UNION ".$sql2;
13061 } elseif (empty($sql) && !empty($sql2)) {
13067 $sql .= $db->order($sortfield_new, $sortorder);
13069 dol_syslog(
"function.lib::show_actions_messaging", LOG_DEBUG);
13070 $resql = $db->query($sql);
13073 $num = $db->num_rows($resql);
13075 while ($i < $num) {
13076 $obj = $db->fetch_object($resql);
13078 if ($obj->type ==
'action') {
13080 $contactaction->id = $obj->id;
13081 $result = $contactaction->fetchResources();
13084 setEventMessage(
"actions.lib::show_actions_messaging Error fetch ressource",
'errors');
13090 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->dp > $now)) {
13091 $tododone =
'todo';
13094 $histo[$numaction] = array(
13095 'type'=>$obj->type,
13096 'tododone'=>$tododone,
13098 'datestart'=>$db->jdate($obj->dp),
13099 'dateend'=>$db->jdate($obj->dp2),
13100 'note'=>$obj->label,
13101 'message'=>$obj->message,
13102 'percent'=>$obj->percent,
13104 'userid'=>$obj->user_id,
13105 'login'=>$obj->user_login,
13106 'userfirstname'=>$obj->user_firstname,
13107 'userlastname'=>$obj->user_lastname,
13108 'userphoto'=>$obj->user_photo,
13109 'msg_from'=>$obj->msg_from,
13111 'contact_id'=>$obj->fk_contact,
13112 'socpeopleassigned' => $contactaction->socpeopleassigned,
13113 'lastname' => (empty($obj->lastname) ?
'' : $obj->lastname),
13114 'firstname' => (empty($obj->firstname) ?
'' : $obj->firstname),
13115 'fk_element'=>$obj->fk_element,
13116 'elementtype'=>$obj->elementtype,
13118 'acode'=>$obj->acode,
13119 'alabel'=>$obj->alabel,
13120 'libelle'=>$obj->alabel,
13121 'apicto'=>$obj->apicto
13124 $histo[$numaction] = array(
13125 'type'=>$obj->type,
13126 'tododone'=>
'done',
13128 'datestart'=>$db->jdate($obj->dp),
13129 'dateend'=>$db->jdate($obj->dp2),
13130 'note'=>$obj->label,
13131 'message'=>$obj->message,
13132 'percent'=>$obj->percent,
13133 'acode'=>$obj->acode,
13135 'userid'=>$obj->user_id,
13136 'login'=>$obj->user_login,
13137 'userfirstname'=>$obj->user_firstname,
13138 'userlastname'=>$obj->user_lastname,
13139 'userphoto'=>$obj->user_photo
13154 if (!isModEnabled(
'agenda')) {
13155 $langs->loadLangs(array(
"admin",
"errors"));
13156 $out =
info_admin($langs->trans(
"WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv(
"Module2400Name")), 0, 0,
'warning');
13159 if (isModEnabled(
'agenda') || (isModEnabled(
'mailing') && !empty($objcon->email))) {
13160 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
13162 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
13163 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
13164 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
13165 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
13170 $userstatic =
new User($db);
13171 $contactstatic =
new Contact($db);
13172 $userGetNomUrlCache = array();
13173 $contactGetNomUrlCache = array();
13175 $out .=
'<div class="filters-container" >';
13176 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
13177 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
13179 if ($objcon && get_class($objcon) ==
'Contact' &&
13180 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
13181 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
13183 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
13185 if ($filterobj && get_class($filterobj) ==
'Societe') {
13186 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
13191 $out .=
'<div class="div-table-responsive-no-min">';
13192 $out .=
'<table class="noborder borderbottom centpercent">';
13194 $out .=
'<tr class="liste_titre">';
13198 $out .=
'<th class="liste_titre width50 middle">';
13199 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
13200 $out .= $searchpicto;
13204 $out .=
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
13206 $out .=
'<th class="liste_titre"><strong class="hideonsmartphone">'.$langs->trans(
"Search").
' : </strong></th>';
13208 $out .=
'<th class="liste_titre"></th>';
13210 $out .=
'<th class="liste_titre">';
13211 $out .=
'<span class="fas fa-square inline-block fawidth30" style=" color: #ddd;" title="'.$langs->trans(
"ActionType").
'"></span>';
13213 $out .=
$formactions->select_type_actions($actioncode,
"actioncode",
'', !
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 1 : -1, 0, 0, 1,
'minwidth200imp');
13215 $out .=
'<th class="liste_titre maxwidth100onsmartphone">';
13216 $out .=
'<input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'" placeholder="'.$langs->trans(
"Label").
'">';
13221 $out .=
'<th class="liste_titre width50 middle">';
13222 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
13223 $out .= $searchpicto;
13230 $out .=
'</table>';
13237 $out .=
'<ul class="timeline">';
13241 if (get_class($filterobj) ==
'Societe') {
13242 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
13244 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
13245 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
13246 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
13248 if (get_class($filterobj) ==
'Societe') {
13254 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
13256 $arraylist = $caction->liste_array(1,
'code',
'', (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 1 : 0),
'', 1);
13258 $actualCycleDate =
false;
13261 foreach ($histo as $key => $value) {
13262 $actionstatic->fetch($histo[$key][
'id']);
13264 $actionstatic->type_picto = $histo[$key][
'apicto'];
13265 $actionstatic->type_code = $histo[$key][
'acode'];
13267 $labeltype = $actionstatic->type_code;
13268 if (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labeltype])) {
13269 $labeltype =
'AC_OTH';
13271 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
13272 $labeltype = $langs->trans(
"Message");
13274 if (!empty($arraylist[$labeltype])) {
13275 $labeltype = $arraylist[$labeltype];
13277 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
13278 $labeltype .=
' - '.$arraylist[$actionstatic->code];
13282 $url = DOL_URL_ROOT.
'/comm/action/card.php?id='.$histo[$key][
'id'];
13284 $tmpa =
dol_getdate($histo[$key][
'datestart'],
false);
13286 if (isset($tmpa[
'year']) && isset($tmpa[
'yday']) && $actualCycleDate !== $tmpa[
'year'].
'-'.$tmpa[
'yday']) {
13287 $actualCycleDate = $tmpa[
'year'].
'-'.$tmpa[
'yday'];
13288 $out .=
'<!-- timeline time label -->';
13289 $out .=
'<li class="time-label">';
13290 $out .=
'<span class="timeline-badge-date">';
13291 $out .=
dol_print_date($histo[$key][
'datestart'],
'daytext',
'tzuserrel', $langs);
13294 $out .=
'<!-- /.timeline-label -->';
13298 $out .=
'<!-- timeline item -->'.
"\n";
13299 $out .=
'<li class="timeline-code-'.strtolower($actionstatic->code).
'">';
13302 $typeicon = $actionstatic->getTypePicto(
'pictofixedwidth timeline-icon-not-applicble', $labeltype);
13307 $out .=
'<div class="timeline-item">'.
"\n";
13309 $out .=
'<span class="time timeline-header-action2">';
13311 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
13312 $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").
' ';
13313 $out .= $histo[$key][
'id'];
13316 $out .= $actionstatic->getNomUrl(1, -1,
'valignmiddle').
' ';
13319 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
13320 (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
13321 $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).
'">';
13323 $out .=
img_picto($langs->trans(
"Modify"),
'edit',
'class="edita"');
13330 $out .=
'<span class="time"><i class="fa fa-clock-o valignmiddle"></i> <span class="valignmiddle">';
13331 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
13332 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
13333 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
13334 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
13335 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
13336 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
13338 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
13342 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
13345 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
13348 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
13351 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
13357 $out .=
"</span></span>\n";
13360 $out .=
'<h3 class="timeline-header">';
13363 $out .=
'<div class="messaging-author inline-block tdoverflowmax150 valignmiddle marginrightonly">';
13364 if ($histo[$key][
'userid'] > 0) {
13365 if (!isset($userGetNomUrlCache[$histo[$key][
'userid']])) {
13366 $userstatic->fetch($histo[$key][
'userid']);
13367 $userGetNomUrlCache[$histo[$key][
'userid']] = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
13369 $out .= $userGetNomUrlCache[$histo[$key][
'userid']];
13370 } elseif (!empty($histo[$key][
'msg_from']) && $actionstatic->code ==
'TICKET_MSG') {
13371 if (!isset($contactGetNomUrlCache[$histo[$key][
'msg_from']])) {
13372 if ($contactstatic->fetch(0,
null,
'', $histo[$key][
'msg_from']) > 0) {
13373 $contactGetNomUrlCache[$histo[$key][
'msg_from']] = $contactstatic->getNomUrl(-1,
'', 16);
13375 $contactGetNomUrlCache[$histo[$key][
'msg_from']] = $histo[$key][
'msg_from'];
13378 $out .= $contactGetNomUrlCache[$histo[$key][
'msg_from']];
13383 $out .=
' <div class="messaging-title inline-block">';
13385 if (empty($conf->dol_optimize_smallscreen) && $actionstatic->type_code !=
'AC_OTH_AUTO') {
13386 $out .= $labeltype.
' - ';
13390 if (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
13391 $out .= $langs->trans(
'TicketNewMessage');
13392 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
13393 $out .= $langs->trans(
'TicketNewMessage').
' <em>('.$langs->trans(
'Private').
')</em>';
13394 } elseif (isset($histo[$key][
'type'])) {
13395 if ($histo[$key][
'type'] ==
'action') {
13396 $transcode = $langs->transnoentitiesnoconv(
"Action".$histo[$key][
'acode']);
13397 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode : $histo[$key][
'alabel']);
13398 $libelle = $histo[$key][
'note'];
13399 $actionstatic->id = $histo[$key][
'id'];
13401 } elseif ($histo[$key][
'type'] ==
'mailing') {
13402 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
13403 $transcode = $langs->transnoentitiesnoconv(
"Action".$histo[$key][
'acode']);
13404 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
13407 $libelle .= $histo[$key][
'note'];
13412 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
13413 if (isset($conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']]) && isset($conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
13414 $link = $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
13416 if (!isset($conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']])) {
13417 $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']] = array();
13419 $link =
dolGetElementUrl($histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
13420 $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
13423 $out .=
' - '.$link;
13432 if (!empty($histo[$key][
'message'] && $histo[$key][
'message'] != $libelle)
13433 && $actionstatic->code !=
'AC_TICKET_CREATE'
13434 && $actionstatic->code !=
'AC_TICKET_MODIFY'
13436 $out .=
'<div class="timeline-body wordbreak">';
13437 $truncateLines =
getDolGlobalInt(
'MAIN_TRUNCATE_TIMELINE_MESSAGE', 3);
13439 if ($truncateLines > 0 && strlen($histo[$key][
'message']) > strlen($truncatedText)) {
13440 $out .=
'<div class="readmore-block --closed" >';
13441 $out .=
' <div class="readmore-block__excerpt" >';
13442 $out .= $truncatedText ;
13443 $out .=
' <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>';
13445 $out .=
' <div class="readmore-block__full-text" >';
13446 $out .= $histo[$key][
'message'];
13447 $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>';
13451 $out .= $histo[$key][
'message'];
13461 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
13463 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $Tab) {
13464 if (empty($conf->cache[
'contact'][$histo[$key][
'contact_id']])) {
13466 $contact->fetch($cid);
13467 $conf->cache[
'contact'][$histo[$key][
'contact_id']] = $contact;
13469 $contact = $conf->cache[
'contact'][$histo[$key][
'contact_id']];
13473 $contactList .= !empty($contactList) ?
', ' :
'';
13474 $contactList .= $contact->getNomUrl(1);
13475 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
13476 if (!empty($contact->phone_pro)) {
13477 $contactList .=
'('.dol_print_phone($contact->phone_pro).
')';
13483 $footer .= $langs->trans(
'ActionOnContact').
' : '.$contactList;
13484 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
13485 if (empty($conf->cache[
'contact'][$histo[$key][
'contact_id']])) {
13487 $result = $contact->fetch($histo[$key][
'contact_id']);
13488 $conf->cache[
'contact'][$histo[$key][
'contact_id']] = $contact;
13490 $contact = $conf->cache[
'contact'][$histo[$key][
'contact_id']];
13494 $footer .= $contact->getNomUrl(1);
13495 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
13496 if (!empty($contact->phone_pro)) {
13497 $footer .=
'('.dol_print_phone($contact->phone_pro).
')';
13504 if (!empty($documents)) {
13505 $footer .=
'<div class="timeline-documents-container">';
13506 foreach ($documents as $doc) {
13507 $footer .=
'<span id="document_'.$doc->id.
'" class="timeline-documents" ';
13508 $footer .=
' data-id="'.$doc->id.
'" ';
13509 $footer .=
' data-path="'.$doc->filepath.
'"';
13510 $footer .=
' data-filename="'.dol_escape_htmltag($doc->filename).
'" ';
13513 $filePath = DOL_DATA_ROOT.
'/'.$doc->filepath.
'/'.$doc->filename;
13515 $file = $actionstatic->id.
'/'.$doc->filename;
13516 $thumb = $actionstatic->id.
'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename,
'.')).
'_mini'.substr($doc->filename, strrpos($doc->filename,
'.'));
13517 $doclink =
dol_buildpath(
'document.php', 1).
'?modulepart=actions&attachment=0&file='.urlencode($file).
'&entity='.$conf->entity;
13518 $viewlink =
dol_buildpath(
'viewimage.php', 1).
'?modulepart=actions&file='.urlencode($thumb).
'&entity='.$conf->entity;
13520 $mimeAttr =
' mime="'.$mime.
'" ';
13522 if (in_array($mime, array(
'image/png',
'image/jpeg',
'application/pdf'))) {
13523 $class .=
' documentpreview';
13526 $footer .=
'<a href="'.$doclink.
'" class="btn-link '.$class.
'" target="_blank" rel="noopener noreferrer" '.$mimeAttr.
' >';
13527 $footer .=
img_mime($filePath).
' '.$doc->filename;
13530 $footer .=
'</span>';
13532 $footer .=
'</div>';
13535 if (!empty($footer)) {
13536 $out .=
'<div class="timeline-footer">'.$footer.
'</div>';
13539 $out .=
'</div>'.
"\n";
13542 $out .=
'<!-- END timeline item -->';
13550 jQuery(document).ready(function () {
13551 $(document).on("click", "[data-read-more-action]", function(e){
13552 let readMoreBloc = $(this).closest(".readmore-block");
13553 if(readMoreBloc.length > 0){
13554 e.preventDefault();
13555 if($(this).attr("data-read-more-action") == "close"){
13556 readMoreBloc.addClass("--closed").removeClass("--open");
13557 $("html, body").animate({
13558 scrollTop: readMoreBloc.offset().top - 200
13561 readMoreBloc.addClass("--open").removeClass("--closed");
13569 if (empty($histo)) {
13570 $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
13593 if ($hourTime ===
'getpost') {
13597 } elseif (preg_match(
'/^(\d\d):(\d\d):(\d\d)$/', $hourTime, $m)) {
13598 $hour = intval($m[1]);
13599 $minute = intval($m[2]);
13600 $second = intval($m[3]);
13602 $hour = $minute = $second = 0;
13605 $hour = min($hour, 23);
13606 $minute = min($minute, 59);
13607 $second = min($second, 59);
13624 if ($timestamp ===
null) {
13625 $timestamp =
GETPOSTDATE($prefix, $hourTime, $gm);
13632 if ($hourTime ===
'getpost' || ($timestamp !==
null &&
dol_print_date($timestamp,
'%H:%M:%S') !==
'00:00:00')) {
13633 $TParam = array_merge($TParam, array(
13640 return '&' . http_build_query($TParam);
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array(), $morecss='', $htmlname='', $forcenojs=0)
On/off button to change a property status of an object This uses the ajax service objectonoff....
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...)
isACompany()
Return if third party is a company (Business) or an end user (Consumer)
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($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.
dolCheckFilters($sqlfilters, &$error='')
Return if a $sqlfilters parameter has a valid balance of parenthesis.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
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 informations (by default a local PHP server timestamp) Re...
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) Si ...
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.
finishSimpleTable($addLineBreak=false)
Add the correct HTML close tags for "startSimpleTable(...)" (use after the last table line)
startSimpleTable($header, $link="", $arguments="", $emptyRows=0, $number=-1)
Start a table with headers and a optinal clickable number (don't forget to use "finishSimpleTable()" ...
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
setEntity($currentobject)
Set entity id to use when to create an object.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetworks=array())
Show social network link.
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.
img_right($titlealt='default', $selected=0, $moreatt='')
Show right arrow logo.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_left($titlealt='default', $selected=0, $moreatt='')
Show left arrow logo.
dol_print_ip($ip, $mode=0)
Return an IP formated to be shown on screen.
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 value of a param into GET or POST supervariable.
isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal)
Function to test if an entry is enabled or not.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dolPrintHTML($s, $allowiframe=0)
Return a string ready to be output on HTML page To use text inside an attribute, you can simply use d...
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 To use text inside an attribute,...
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0, $beforearrows='', $hidenavigation=0)
Function to show navigation arrows into lists.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
get_date_range($date_start, $date_end, $format='', $outputlangs='', $withparenthesis=1)
Format output for start and end date.
get_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Get formated error messages to output (Used to show messages on html output).
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
roundUpToNextMultiple($n, $x=5)
Round to next multiple.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dol_user_country()
Return country code for current user.
dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes=null)
Clean a string from some undesirable HTML tags.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs='', $mode=0, $extralangcode='')
Return a formated address (part address/zip/town/state) according to country rules.
isHTTPS()
Return if we are using a HTTPS connexion Check HTTPS (no way to be modified by user but may be empty ...
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
picto_required()
Return picto saying a field is required.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
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...
GETPOSTDATE($prefix, $hourTime='', $gm='auto')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
dol_print_url($url, $target='_blank', $max=32, $withpicto=0, $morecss='')
Show Url link.
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.
utf8_valid($str)
Check if a string is in UTF8.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
img_allow($allow, $titlealt='default')
Show tick logo if allowed.
isValidMXRecord($domain)
Return if the domain name has a valid MX record.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
get_htmloutput_mesg($mesgstring='', $mesgarray='', $style='ok', $keepembedded=0)
Get formated messages to output (Used to show messages on html output).
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0)
Format phone numbers according to country.
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 '.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0)
Clean a string to keep only desirable HTML tags.
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.
dolPrintHTMLForAttribute($s)
Return a string ready to be output on an HTML attribute (alt, title, data-html, .....
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
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_strtoupper($string, $encoding="UTF-8")
Convert a string to upper.
dol_sanitizeUrl($stringtoclean, $type=1)
Clean a string to use it as an URL (into a href or src attribute)
img_printer($titlealt="default", $other='')
Show printer logo.
dol_htmloutput_events($disabledoutputofmessages=0)
Print formated 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.
getPictoForType($key)
Return the picto for a data type.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
getArrayOfSocialNetworks()
Get array of social network dictionary.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
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, ...)
colorIsLight($stringcolor)
Return true if the color is light.
dol_escape_all($stringtoescape)
Returns text escaped for all protocols (so only alpha chars and numbers)
readfileLowMemory($fullpath_original_file_osencoded, $method=-1)
Return a file on output using a low memory.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
dol_shutdown()
Function called at end of web php process.
dol_print_address($address, $htmlid, $element, $id, $noprint=0, $charfornl='')
Format address string.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error_email($prefixcode, $errormessage='', $errormessages=array(), $morecss='error', $email='')
Show a public email and error code to contact if technical error.
dol_print_profids($profID, $profIDtype, $countrycode='', $addcpButton=1)
Format professional IDs according to their country.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_bc($var, $moreclass='')
Return string to add class property on html element with pair/impair.
print_titre($title)
Show a title.
getElementProperties($element_type)
Get an array with properties of an element.
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).
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
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 formated messages to output (Used to show messages on html output).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
buildParamDate($prefix, $timestamp=null, $hourTime='', $gm='auto')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
img_next($titlealt='default', $moreatt='')
Show next logo.
print_date_range($date_start, $date_end, $format='', $outputlangs='')
Format output for start and end date.
isAFileWithExecutableContent($filename)
Return if a file can contains executable content.
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 start with $text.
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).
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...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
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 link.
jsonOrUnserialize($stringtodecode)
Decode an encode string.
addSummaryTableLine($tableColumnCount, $num, $nbofloop=0, $total=0, $noneWord="None", $extraRightColumn=false)
Add a summary line to the current open table ("None", "XMoreLines" or "Total xxx")
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 +.
verifCond($strToEvaluate)
Verify if condition in string is ok or not.
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='')
Return the full path of the directory where a module (or an object of a module) stores its files.
print_fiche_titre($title, $mesg='', $picto='generic', $pictoisfullpath=0, $id='')
Show a title with picto.
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_escape_json($stringtoescape)
Returns text escaped for inclusion into javascript code.
dolForgeCriteriaCallback($matches)
Function to forge a SQL criteria from a Dolibarr filter syntax string.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getUserRemoteIP()
Return the IP of remote user.
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.
img_credit_card($brand, $morecss=null)
Return image of a credit card according to its brand name.
img_searchclear($titlealt='default', $other='')
Show search logo.
dolPrintLabel($s)
Return a string label (so on 1 line only and that should not contains any HTML) ready to be output on...
fetchObjectByElement($element_id, $element_type, $element_ref='')
Fetch an object from its id and element_type Inclusion of classes is automatic.
utf8_check($str)
Check if a string is in UTF8.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
show_actions_messaging($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC')
Show html area with actions in messaging format.
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 formated error messages to output (Used to show messages on html output).
getFieldErrorIcon($fieldValidationErrorMsg)
get field error icon
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.
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 formated text with and (WARNING: string must not have mixed and br sepa...
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...
dol_convertToWord($num, $langs, $currency='', $centimes=false)
Function to return a number into a text.
conf($dolibarr_main_document_root)
Load conf file (file must exists)
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e rowid
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
if(!empty( $_SERVER[ 'MAIN_SHOW_TUNING_INFO'])) realCharForNumericEntities($matches)
Return the real char for a numeric entities.
dol_setcache($memoryid, $data, $expire=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid)
Read a memory area shared by all users, all sessions on server.
if(preg_match('/crypted:/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.
dolGetRandomBytes($length)
Return a string of random bytes (hexa string) with length = $length fro cryptographic purposes.