46 include_once DOL_DOCUMENT_ROOT.
'/core/lib/json.lib.php';
49 if (!function_exists(
'utf8_encode')) {
56 function utf8_encode($elements)
58 return mb_convert_encoding($elements,
'UTF-8',
'ISO-8859-1');
62 if (!function_exists(
'utf8_decode')) {
69 function utf8_decode($elements)
71 return mb_convert_encoding($elements,
'ISO-8859-1',
'UTF-8');
74 if (!function_exists(
'str_starts_with')) {
82 function str_starts_with($haystack, $needle)
84 return (
string) $needle !==
'' && strncmp($haystack, $needle, strlen($needle)) === 0;
87 if (!function_exists(
'str_ends_with')) {
95 function str_ends_with($haystack, $needle)
97 return $needle !==
'' && substr($haystack, -strlen($needle)) === (string) $needle;
100 if (!function_exists(
'str_contains')) {
108 function str_contains($haystack, $needle)
110 return $needle !==
'' && mb_strpos($haystack, $needle) !==
false;
126 if (!is_object($object) && empty($module)) {
129 if (empty($module) && !empty($object->element)) {
130 $module = $object->element;
132 return $conf->$module->multidir_output[(!empty($object->entity) ? $object->entity : $conf->entity)];
146 return (
string) (isset($conf->global->$key) ? $conf->global->$key : $default);
160 return (
int) (isset($conf->global->$key) ? $conf->global->$key : $default);
173 if (empty($tmpuser)) {
179 return (
string) (empty($tmpuser->conf->$key) ? $default : $tmpuser->conf->$key);
192 if (empty($tmpuser)) {
198 return (
int) (empty($tmpuser->conf->$key) ? $default : $tmpuser->conf->$key);
213 'project' =>
'projet',
214 'contract' =>
'contrat',
217 if (empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) {
218 $arrayconv[
'supplier_order'] =
'fournisseur';
219 $arrayconv[
'supplier_invoice'] =
'fournisseur';
221 if (!empty($arrayconv[$module])) {
222 $module = $arrayconv[$module];
225 return !empty($conf->modules[$module]);
242 require_once DOL_DOCUMENT_ROOT.
"/core/db/".$type.
'.class.php';
244 $class =
'DoliDB'.ucfirst($type);
245 $dolidb =
new $class($type, $host, $user, $pass, $name, $port);
266 function getEntity($element, $shared = 1, $currentobject =
null)
268 global $conf, $mc, $hookmanager, $object, $action, $db;
270 if (!is_object($hookmanager)) {
271 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
278 $element =
'contract';
280 case 'order_supplier':
281 $element =
'supplier_order';
283 case 'invoice_supplier':
284 $element =
'supplier_invoice';
288 if (is_object($mc)) {
289 $out = $mc->getEntity($element, $shared, $currentobject);
292 $addzero = array(
'user',
'usergroup',
'cronjob',
'c_email_templates',
'email_template',
'default_values');
293 if (in_array($element, $addzero)) {
296 $out .= ((int) $conf->entity);
301 'element' => $element,
304 'currentobject' => $currentobject,
307 $reshook = $hookmanager->executeHooks(
'hookGetEntity', $parameters, $currentobject, $action);
309 if (is_numeric($reshook)) {
310 if ($reshook == 0 && !empty($hookmanager->resPrint)) {
311 $out .=
','.$hookmanager->resPrint;
312 } elseif ($reshook == 1) {
313 $out = $hookmanager->resPrint;
330 if (is_object($mc) && method_exists($mc,
'setEntity')) {
331 return $mc->setEntity($currentobject);
333 return ((is_object($currentobject) && $currentobject->id > 0 && $currentobject->entity > 0) ? $currentobject->entity : $conf->entity);
345 return preg_match(
'/(_pass|password|_pw|_key|securekey|serverkey|secret\d?|p12key|exportkey|_PW_[a-z]+|token)$/i', $keyname);
357 for ($r =
""; $n >= 0; $n = intval($n / 26) - 1)
358 $r = chr($n % 26 + 0x41) . $r;
381 include_once DOL_DOCUMENT_ROOT.
'/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php';
388 $user_agent = substr($user_agent, 0, 512);
390 $detectmobile =
new Mobile_Detect(
null, $user_agent);
391 $tablet = $detectmobile->isTablet();
393 if ($detectmobile->isMobile()) {
397 if ($detectmobile->is(
'AndroidOS')) {
398 $os = $phone =
'android';
399 } elseif ($detectmobile->is(
'BlackBerryOS')) {
400 $os = $phone =
'blackberry';
401 } elseif ($detectmobile->is(
'iOS')) {
404 } elseif ($detectmobile->is(
'PalmOS')) {
405 $os = $phone =
'palm';
406 } elseif ($detectmobile->is(
'SymbianOS')) {
408 } elseif ($detectmobile->is(
'webOS')) {
410 } elseif ($detectmobile->is(
'MaemoOS')) {
412 } elseif ($detectmobile->is(
'WindowsMobileOS') || $detectmobile->is(
'WindowsPhoneOS')) {
418 if (preg_match(
'/linux/i', $user_agent)) {
420 } elseif (preg_match(
'/macintosh/i', $user_agent)) {
422 } elseif (preg_match(
'/windows/i', $user_agent)) {
428 if (preg_match(
'/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
430 $version = empty($reg[2]) ?
'' : $reg[2];
431 } elseif (preg_match(
'/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
433 $version = empty($reg[2]) ?
'' : $reg[2];
434 } elseif (preg_match(
'/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) {
436 $version = empty($reg[2]) ?
'' : $reg[2];
437 } elseif (preg_match(
'/chrome/i', $user_agent, $reg)) {
440 } elseif (preg_match(
'/iceweasel/i', $user_agent)) {
442 } elseif (preg_match(
'/epiphany/i', $user_agent)) {
444 } elseif (preg_match(
'/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
446 $version = empty($reg[2]) ?
'' : $reg[2];
447 } elseif (preg_match(
'/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
450 $version = empty($reg[2]) ?
'' : $reg[2];
451 } elseif (preg_match(
'/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
453 $version = end($reg);
454 } elseif (preg_match(
'/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
457 $version = end($reg);
458 } elseif (preg_match(
'/l[iy]n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) {
461 $version = empty($reg[3]) ?
'' : $reg[3];
473 'browsername' => $name,
474 'browserversion' => $version,
476 'browserua' => $user_agent,
490 global $user, $langs, $db;
491 $disconnectdone =
false;
493 if (is_object($db) && !empty($db->connected)) {
494 $depth = $db->transaction_opened;
495 $disconnectdone = $db->close();
497 dol_syslog(
"--- End access to ".$_SERVER[
"PHP_SELF"].(($disconnectdone && $depth) ?
' (Warn: db disconnection forced, transaction depth was '.$depth.
')' :
''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO));
513 $relativepathstring = $_SERVER[
"PHP_SELF"];
515 if (constant(
'DOL_URL_ROOT')) {
516 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
518 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
519 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
525 if (!empty($_GET[
'restore_lastsearch_values'])) {
526 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
527 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
528 if (is_array($tmp)) {
529 foreach ($tmp as $key => $val) {
530 if ($key == $paramname) {
538 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
540 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
542 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
544 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
548 $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname]));
565 if (empty($method)) {
566 $val = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
567 } elseif ($method == 1) {
568 $val = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
569 } elseif ($method == 2) {
570 $val = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
571 } elseif ($method == 3) {
572 $val = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
574 $val =
'BadFirstParameterForGETPOST';
577 return is_array($val);
609 function GETPOST($paramname, $check =
'alphanohtml', $method = 0, $filter =
null, $options =
null, $noreplace = 0)
611 global $mysoc, $user, $conf;
613 if (empty($paramname)) {
614 return 'BadFirstParameterForGETPOST';
617 dol_syslog(
"Deprecated use of GETPOST, called with 1st param = ".$paramname.
" and 2nd param is '', when calling page ".$_SERVER[
"PHP_SELF"], LOG_WARNING);
622 if (empty($method)) {
623 $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
624 } elseif ($method == 1) {
625 $out = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
626 } elseif ($method == 2) {
627 $out = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
628 } elseif ($method == 3) {
629 $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
631 return 'BadThirdParameterForGETPOST';
634 if (empty($method) || $method == 3 || $method == 4) {
635 $relativepathstring = $_SERVER[
"PHP_SELF"];
637 if (constant(
'DOL_URL_ROOT')) {
638 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
640 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
641 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
647 if (!empty($_GET[
'restore_lastsearch_values'])) {
648 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
649 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
650 if (is_array($tmp)) {
651 foreach ($tmp as $key => $val) {
652 if ($key == $paramname) {
660 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
661 $out = $_SESSION[
'lastsearch_contextpage_'.$relativepathstring];
662 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
663 $out = $_SESSION[
'lastsearch_limit_'.$relativepathstring];
664 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
665 $out = $_SESSION[
'lastsearch_page_'.$relativepathstring];
666 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
667 $out = $_SESSION[
'lastsearch_mode_'.$relativepathstring];
669 } elseif (!isset($_GET[
'sortfield'])) {
672 if (!empty($_GET[
'action']) && $_GET[
'action'] ==
'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
675 if (is_object($object) && isset($object->fields[$paramname][
'default'])) {
676 $out = $object->fields[$paramname][
'default'];
679 if (!empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
680 if (!empty($_GET[
'action']) && (preg_match(
'/^create/', $_GET[
'action']) || preg_match(
'/^presend/', $_GET[
'action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
682 if (!empty($user->default_values)) {
683 if (isset($user->default_values[$relativepathstring][
'createform'])) {
684 foreach ($user->default_values[$relativepathstring][
'createform'] as $defkey => $defval) {
686 if ($defkey !=
'_noquery_') {
687 $tmpqueryarraytohave = explode(
'&', $defkey);
690 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
691 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
704 if (isset($user->default_values[$relativepathstring][
'createform'][$defkey][$paramname])) {
705 $out = $user->default_values[$relativepathstring][
'createform'][$defkey][$paramname];
712 } elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
714 if (!empty($user->default_values)) {
717 if ($paramname ==
'sortfield' || $paramname ==
'sortorder') {
719 if (isset($user->default_values[$relativepathstring][
'sortorder'])) {
721 foreach ($user->default_values[$relativepathstring][
'sortorder'] as $defkey => $defval) {
723 if ($defkey !=
'_noquery_') {
724 $tmpqueryarraytohave = explode(
'&', $defkey);
727 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
728 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
741 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
742 foreach ($user->default_values[$relativepathstring][
'sortorder'][$defkey] as $key => $val) {
746 if ($paramname ==
'sortfield') {
749 if ($paramname ==
'sortorder') {
757 } elseif (isset($user->default_values[$relativepathstring][
'filters'])) {
758 foreach ($user->default_values[$relativepathstring][
'filters'] as $defkey => $defval) {
759 if (!empty($_GET[
'disabledefaultvalues'])) {
763 if ($defkey !=
'_noquery_') {
764 $tmpqueryarraytohave = explode(
'&', $defkey);
767 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
768 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
780 if ($qualified && isset($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname])) {
782 if (isset($_POST[
'sall']) || isset($_POST[
'search_all']) || isset($_GET[
'sall']) || isset($_GET[
'search_all'])) {
784 if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH)) {
785 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
786 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
789 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
790 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
805 if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
809 while (preg_match(
'/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) {
813 if ($reg[1] ==
'DAY') {
815 $newout = $tmp[
'mday'];
816 } elseif ($reg[1] ==
'MONTH') {
818 $newout = $tmp[
'mon'];
819 } elseif ($reg[1] ==
'YEAR') {
821 $newout = $tmp[
'year'];
822 } elseif ($reg[1] ==
'PREVIOUS_DAY') {
825 $newout = $tmp2[
'day'];
826 } elseif ($reg[1] ==
'PREVIOUS_MONTH') {
829 $newout = $tmp2[
'month'];
830 } elseif ($reg[1] ==
'PREVIOUS_YEAR') {
832 $newout = ($tmp[
'year'] - 1);
833 } elseif ($reg[1] ==
'NEXT_DAY') {
836 $newout = $tmp2[
'day'];
837 } elseif ($reg[1] ==
'NEXT_MONTH') {
840 $newout = $tmp2[
'month'];
841 } elseif ($reg[1] ==
'NEXT_YEAR') {
843 $newout = ($tmp[
'year'] + 1);
844 } elseif ($reg[1] ==
'MYCOMPANY_COUNTRY_ID' || $reg[1] ==
'MYCOUNTRY_ID' || $reg[1] ==
'MYCOUNTRYID') {
845 $newout = $mysoc->country_id;
846 } elseif ($reg[1] ==
'USER_ID' || $reg[1] ==
'USERID') {
848 } elseif ($reg[1] ==
'USER_SUPERVISOR_ID' || $reg[1] ==
'SUPERVISOR_ID' || $reg[1] ==
'SUPERVISORID') {
849 $newout = $user->fk_user;
850 } elseif ($reg[1] ==
'ENTITY_ID' || $reg[1] ==
'ENTITYID') {
851 $newout = $conf->entity;
856 $out = preg_replace(
'/__'.preg_quote($reg[1],
'/').
'__/', $newout, $out);
861 if (preg_match(
'/^array/', $check)) {
862 if (!is_array($out) || empty($out)) {
865 $tmparray = explode(
':', $check);
866 if (!empty($tmparray[1])) {
867 $tmpcheck = $tmparray[1];
869 $tmpcheck =
'alphanohtml';
871 foreach ($out as $outkey => $outval) {
872 $out[$outkey] =
sanitizeVal($outval, $tmpcheck, $filter, $options);
878 if (strpos($paramname,
'search_') === 0) {
879 $out = preg_replace(
'/([<>])([-+]?\d)/',
'\1 \2', $out);
882 $out =
sanitizeVal($out, $check, $filter, $options);
887 if ($paramname ==
'backtopage' || $paramname ==
'backtolist' || $paramname ==
'backtourl') {
888 $out = str_replace(
'\\',
'/', $out);
889 $out = str_replace(array(
':',
';',
'@',
"\t",
' '),
'', $out);
891 $oldstringtoclean = $out;
892 $out = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $out);
893 $out = preg_replace(array(
'/^[^\?]*%/'),
'', $out);
894 $out = preg_replace(array(
'/^[a-z]*\/\s*\/+/i'),
'', $out);
895 }
while ($oldstringtoclean != $out);
900 if (empty($method) || $method == 3 || $method == 4) {
901 if (preg_match(
'/^search_/', $paramname) || in_array($paramname, array(
'sortorder',
'sortfield'))) {
908 if ($out !=
'' && isset($user)) {
909 $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out;
928 return (
int)
GETPOST($paramname,
'int', $method,
null,
null, 0);
942 function checkVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
944 return sanitizeVal($out, $check, $filter, $options);
956 function sanitizeVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
964 if (!is_numeric($out)) {
969 if (preg_match(
'/[^0-9,-]+/i', $out)) {
974 $out = filter_var($out, FILTER_SANITIZE_STRING);
977 $out = filter_var($out, FILTER_SANITIZE_EMAIL);
980 if (!is_array($out)) {
982 if (preg_match(
'/[^a-z]+/i', $out)) {
988 if (!is_array($out)) {
990 if (preg_match(
'/[^a-z0-9_\-\.]+/i', $out)) {
996 if (!is_array($out)) {
998 if (preg_match(
'/[^a-z0-9_\-\.@]+/i', $out)) {
1004 if (!is_array($out)) {
1006 if (preg_match(
'/[^a-z0-9_\-\.,]+/i', $out)) {
1013 if (!is_array($out)) {
1016 $oldstringtoclean = $out;
1023 $out = str_ireplace(array(
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'\',
'\',
'/',
'../',
'..\\'),
'', $out);
1024 }
while ($oldstringtoclean != $out);
1028 case 'alphawithlgt':
1029 if (!is_array($out)) {
1032 $oldstringtoclean = $out;
1038 $out = str_ireplace(array(
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'\',
'\',
'/',
'../',
'..\\'),
'', $out);
1039 }
while ($oldstringtoclean != $out);
1045 case 'restricthtmlnolink':
1046 case 'restricthtml':
1047 case 'restricthtmlallowclass':
1048 case 'restricthtmlallowunvalid':
1053 if (empty($filter)) {
1054 return 'BadParameterForGETPOST - Param 3 of sanitizeVal()';
1059 $out = filter_var($out, $filter, $options);
1068 if (!function_exists(
'dol_getprefix')) {
1078 function dol_getprefix($mode =
'')
1081 if ($mode ==
'email') {
1084 if (!empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) {
1085 if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID !=
'SERVER_NAME') {
1086 return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
1087 } elseif (isset($_SERVER[
"SERVER_NAME"])) {
1088 return $_SERVER[
"SERVER_NAME"];
1093 if (!empty($conf->file->instance_unique_id)) {
1094 return sha1(
'dolibarr'.$conf->file->instance_unique_id);
1098 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1102 global $dolibarr_main_instance_unique_id, $dolibarr_main_cookie_cryptkey;
1103 $tmp_instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ?
'' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
1106 if (!empty($tmp_instance_unique_id)) {
1107 return sha1(
'dolibarr'.$tmp_instance_unique_id);
1111 if (isset($_SERVER[
"SERVER_NAME"]) && isset($_SERVER[
"DOCUMENT_ROOT"])) {
1112 return sha1($_SERVER[
"SERVER_NAME"].$_SERVER[
"DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1114 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1131 global $conf, $langs, $user, $mysoc;
1135 if (!file_exists($fullpath)) {
1136 dol_syslog(
'functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_WARNING);
1140 if (!empty($classname) && !class_exists($classname)) {
1141 return include $fullpath;
1143 return include_once $fullpath;
1162 $path = preg_replace(
'/^\//',
'', $path);
1165 $res = DOL_DOCUMENT_ROOT.
'/'.$path;
1166 if (is_array($conf->file->dol_document_root)) {
1167 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1168 if ($key ==
'main') {
1171 if (file_exists($dirroot.
'/'.$path)) {
1172 $res = $dirroot.
'/'.$path;
1177 if ($returnemptyifnotfound) {
1179 if ($returnemptyifnotfound == 1 || !file_exists($res)) {
1191 $res = DOL_URL_ROOT.
'/'.$path;
1194 $res = DOL_MAIN_URL_ROOT.
'/'.$path;
1197 $res = DOL_URL_ROOT.
'/'.$path;
1200 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1201 if ($key ==
'main') {
1203 global $dolibarr_main_url_root;
1206 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1207 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1210 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
'/'.$path;
1215 preg_match(
'/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);
1216 if (!empty($regs[1])) {
1218 if (file_exists($dirroot.
'/'.$regs[1])) {
1220 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1223 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1226 global $dolibarr_main_url_root;
1229 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1230 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1233 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).$conf->file->dol_url_root[$key].
'/'.$path;
1260 if (isset($object->db) && isset($object->db->db) && is_object($object->db->db) && get_class($object->db->db) ==
'PgSql\Connection') {
1261 $tmpsavdb = $object->db;
1265 $myclone = unserialize(serialize($object));
1267 if (!empty($tmpsavdb)) {
1268 $object->db = $tmpsavdb;
1270 } elseif ($native == 2) {
1272 $myclone =
new stdClass();
1273 $tmparray = get_object_vars($object);
1275 if (is_array($tmparray)) {
1276 foreach ($tmparray as $propertykey => $propertyval) {
1277 if (is_scalar($propertyval) || is_array($propertyval)) {
1278 $myclone->$propertykey = $propertyval;
1283 $myclone = clone $object;
1301 if (empty($conf->dol_optimize_smallscreen)) {
1304 if ($type ==
'width' && $size > 250) {
1329 $filesystem_forbidden_chars = array(
'<',
'>',
'/',
'\\',
'?',
'*',
'|',
'"',
':',
'°',
'$',
';',
'`');
1331 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1332 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1333 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1334 $tmp = str_replace(
'..',
'', $tmp);
1354 $filesystem_forbidden_chars = array(
'<',
'>',
'?',
'*',
'|',
'"',
'°',
'$',
';',
'`');
1356 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1357 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1358 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1359 $tmp = str_replace(
'..',
'', $tmp);
1374 $stringtoclean = preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $stringtoclean);
1376 $stringtoclean = preg_replace(
'/<!--[^>]*-->/',
'', $stringtoclean);
1378 $stringtoclean = str_replace(
'\\',
'/', $stringtoclean);
1382 $stringtoclean = str_replace(array(
':',
';',
'@'),
'', $stringtoclean);
1386 $oldstringtoclean = $stringtoclean;
1389 $stringtoclean = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $stringtoclean);
1390 }
while ($oldstringtoclean != $stringtoclean);
1394 $stringtoclean = preg_replace(array(
'/^[a-z]*\/\/+/i'),
'', $stringtoclean);
1397 return $stringtoclean;
1409 $oldstringtoclean = $stringtoclean;
1410 $stringtoclean = str_ireplace(array(
'"',
':',
'[',
']',
"\n",
"\r",
'\\',
'\/'),
'', $stringtoclean);
1411 }
while ($oldstringtoclean != $stringtoclean);
1413 return $stringtoclean;
1428 if (is_null($str)) {
1433 if (extension_loaded(
'intl') && !empty($conf->global->MAIN_UNACCENT_USE_TRANSLITERATOR)) {
1434 $transliterator = Transliterator::createFromRules(
':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', Transliterator::FORWARD);
1435 return $transliterator->transliterate($str);
1438 $string = rawurlencode($str);
1439 $replacements = array(
1440 '%C3%80' =>
'A',
'%C3%81' =>
'A',
'%C3%82' =>
'A',
'%C3%83' =>
'A',
'%C3%84' =>
'A',
'%C3%85' =>
'A',
1442 '%C3%88' =>
'E',
'%C3%89' =>
'E',
'%C3%8A' =>
'E',
'%C3%8B' =>
'E',
1443 '%C3%8C' =>
'I',
'%C3%8D' =>
'I',
'%C3%8E' =>
'I',
'%C3%8F' =>
'I',
1445 '%C3%92' =>
'O',
'%C3%93' =>
'O',
'%C3%94' =>
'O',
'%C3%95' =>
'O',
'%C3%96' =>
'O',
1447 '%C3%99' =>
'U',
'%C3%9A' =>
'U',
'%C3%9B' =>
'U',
'%C3%9C' =>
'U',
1448 '%C3%9D' =>
'Y',
'%C5%B8' =>
'y',
1449 '%C3%A0' =>
'a',
'%C3%A1' =>
'a',
'%C3%A2' =>
'a',
'%C3%A3' =>
'a',
'%C3%A4' =>
'a',
'%C3%A5' =>
'a',
1451 '%C3%A8' =>
'e',
'%C3%A9' =>
'e',
'%C3%AA' =>
'e',
'%C3%AB' =>
'e',
1452 '%C3%AC' =>
'i',
'%C3%AD' =>
'i',
'%C3%AE' =>
'i',
'%C3%AF' =>
'i',
1454 '%C3%B2' =>
'o',
'%C3%B3' =>
'o',
'%C3%B4' =>
'o',
'%C3%B5' =>
'o',
'%C3%B6' =>
'o',
1456 '%C3%B9' =>
'u',
'%C3%BA' =>
'u',
'%C3%BB' =>
'u',
'%C3%BC' =>
'u',
1457 '%C3%BD' =>
'y',
'%C3%BF' =>
'y'
1459 $string = strtr($string, $replacements);
1460 return rawurldecode($string);
1465 "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
1466 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
1467 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
1468 \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
1469 \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
1470 \xF9\xFA\xFB\xFC\xFD\xFF",
1478 $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"));
1496 function dol_string_nospecial($str, $newstr =
'_', $badcharstoreplace =
'', $badcharstoremove =
'', $keepspaces = 0)
1498 $forbidden_chars_to_replace = array(
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
",",
";",
"=",
'°',
'$',
';');
1499 if (empty($keepspaces)) {
1500 $forbidden_chars_to_replace[] =
" ";
1502 $forbidden_chars_to_remove = array();
1505 if (is_array($badcharstoreplace)) {
1506 $forbidden_chars_to_replace = $badcharstoreplace;
1508 if (is_array($badcharstoremove)) {
1509 $forbidden_chars_to_remove = $badcharstoremove;
1512 return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove,
"", $str));
1531 if ($removetabcrlf) {
1532 return preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $str);
1534 return preg_replace(
'/[\x00-\x08\x11-\x12\x14-\x1F\x7F]/u',
'', $str);
1548 if (is_null($stringtoescape)) {
1553 $substitjs = array(
"'"=>
"\\'",
"\r"=>
'\\r');
1555 if (empty($noescapebackslashn)) {
1556 $substitjs[
"\n"] =
'\\n';
1557 $substitjs[
'\\'] =
'\\\\';
1560 $substitjs[
"'"] =
"\\'";
1561 $substitjs[
'"'] =
"\\'";
1562 } elseif ($mode == 1) {
1563 $substitjs[
"'"] =
"\\'";
1564 } elseif ($mode == 2) {
1565 $substitjs[
'"'] =
'\\"';
1566 } elseif ($mode == 3) {
1567 $substitjs[
"'"] =
"\\'";
1568 $substitjs[
'"'] =
"\\\"";
1570 return strtr($stringtoescape, $substitjs);
1581 return str_replace(
'"',
'\"', $stringtoescape);
1600 function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags =
'', $escapeonlyhtmltags = 0, $cleanalsojavascript = 0)
1602 if ($noescapetags ==
'common') {
1603 $noescapetags =
'html,body,a,b,em,hr,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody';
1605 if ($cleanalsojavascript) {
1610 if ($escapeonlyhtmltags) {
1611 $tmp = htmlspecialchars_decode((
string) $stringtoescape, ENT_COMPAT);
1613 $tmp = html_entity_decode((
string) $stringtoescape, ENT_COMPAT,
'UTF-8');
1616 $tmp = strtr($tmp, array(
"<b>"=>
'',
'</b>'=>
''));
1619 $tmp = strtr($tmp, array(
"\r"=>
'\\r',
"\n"=>
'\\n'));
1622 if ($escapeonlyhtmltags) {
1623 return htmlspecialchars($tmp, ENT_COMPAT,
'UTF-8');
1627 $tmparrayoftags = array();
1628 if ($noescapetags) {
1629 $tmparrayoftags = explode(
',', $noescapetags);
1631 if (count($tmparrayoftags)) {
1632 foreach ($tmparrayoftags as $tagtoreplace) {
1633 $tmp = str_ireplace(
'<'.$tagtoreplace.
'>',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1634 $tmp = str_ireplace(
'</'.$tagtoreplace.
'>',
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1635 $tmp = str_ireplace(
'<'.$tagtoreplace.
' />',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1639 $result = htmlentities($tmp, ENT_COMPAT,
'UTF-8');
1641 if (count($tmparrayoftags)) {
1642 foreach ($tmparrayoftags as $tagtoreplace) {
1643 $result = str_ireplace(
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
'>', $result);
1644 $result = str_ireplace(
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__',
'</'.$tagtoreplace.
'>', $result);
1645 $result = str_ireplace(
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
' />', $result);
1662 if (function_exists(
'mb_strtolower')) {
1663 return mb_strtolower($string, $encoding);
1665 return strtolower($string);
1679 if (function_exists(
'mb_strtoupper')) {
1680 return mb_strtoupper($string, $encoding);
1682 return strtoupper($string);
1696 if (function_exists(
'mb_substr')) {
1697 return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1,
null, $encoding);
1699 return ucfirst($string);
1713 if (function_exists(
'mb_convert_case')) {
1714 return mb_convert_case($string, MB_CASE_TITLE, $encoding);
1716 return ucwords($string);
1741 function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
'', $restricttologhandler =
'', $logcontext =
null)
1743 global $conf, $user, $debugbar;
1751 if (defined(
'USEEXTERNALSERVER') && !defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
1752 global $website, $websitekey;
1753 if (is_object($website) && !empty($website->ref)) {
1754 $suffixinfilename .=
'_website_'.$website->ref;
1755 } elseif (!empty($websitekey)) {
1756 $suffixinfilename .=
'_website_'.$websitekey;
1761 if (defined(
'USESUFFIXINLOG')) {
1762 $suffixinfilename .= constant(
'USESUFFIXINLOG');
1766 foreach ($conf->loghandlers as $loghandlerinstance) {
1767 $loghandlerinstance->setIdent($ident);
1771 if (!empty($message)) {
1773 $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');
1774 if (!array_key_exists($level, $logLevels)) {
1775 throw new Exception(
'Incorrect log level');
1781 if (empty($conf->global->MAIN_SHOW_PASSWORD_INTO_LOG)) {
1782 $message = preg_replace(
'/password=\'[^\']*\'/',
'password=\'hidden\'', $message);
1786 if ((!empty($_REQUEST[
'logtohtml']) && !empty($conf->global->MAIN_ENABLE_LOG_TO_HTML))
1787 || (!empty($user->rights->debugbar->read) && is_object($debugbar))) {
1788 $conf->logbuffer[] =
dol_print_date(time(),
"%Y-%m-%d %H:%M:%S").
" ".$logLevels[$level].
" ".$message;
1793 if (!empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && !empty($_GET[
"log"])) {
1794 print
"\n\n<!-- Log start\n";
1796 print
"Log end -->\n";
1800 'message' => $message,
1801 'script' => (isset($_SERVER[
'PHP_SELF']) ? basename($_SERVER[
'PHP_SELF'],
'.php') :
false),
1803 'user' => ((is_object($user) && $user->id) ? $user->login :
false),
1808 if (!empty($remoteip)) {
1809 $data[
'ip'] = $remoteip;
1811 if (!empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) && $_SERVER[
'HTTP_X_FORWARDED_FOR'] != $remoteip) {
1812 $data[
'ip'] = $_SERVER[
'HTTP_X_FORWARDED_FOR'].
' -> '.$data[
'ip'];
1813 } elseif (!empty($_SERVER[
'HTTP_CLIENT_IP']) && $_SERVER[
'HTTP_CLIENT_IP'] != $remoteip) {
1814 $data[
'ip'] = $_SERVER[
'HTTP_CLIENT_IP'].
' -> '.$data[
'ip'];
1816 } elseif (!empty($_SERVER[
'SERVER_ADDR'])) {
1818 $data[
'ip'] = $_SERVER[
'SERVER_ADDR'];
1819 } elseif (!empty($_SERVER[
'COMPUTERNAME'])) {
1821 $data[
'ip'] = $_SERVER[
'COMPUTERNAME'].(empty($_SERVER[
'USERNAME']) ?
'' :
'@'.$_SERVER[
'USERNAME']);
1822 } elseif (!empty($_SERVER[
'LOGNAME'])) {
1824 $data[
'ip'] =
'???@'.$_SERVER[
'LOGNAME'];
1828 foreach ($conf->loghandlers as $loghandlerinstance) {
1829 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
1832 $loghandlerinstance->export($data, $suffixinfilename);
1838 foreach ($conf->loghandlers as $loghandlerinstance) {
1839 $loghandlerinstance->setIdent($ident);
1860 function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled =
'', $morecss =
'classlink button bordertransp', $jsonopen =
'', $backtopagejsfields =
'', $accesskey =
'')
1864 if (strpos($url,
'?') > 0) {
1865 $url .=
'&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name);
1867 $url .=
'?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name);
1872 $backtopagejsfieldsid =
''; $backtopagejsfieldslabel =
'';
1873 if ($backtopagejsfields) {
1874 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
1875 if (empty($tmpbacktopagejsfields[1])) {
1876 $backtopagejsfields = $name.
":".$backtopagejsfields;
1877 $tmp2backtopagejsfields = explode(
',', $tmpbacktopagejsfields[0]);
1879 $tmp2backtopagejsfields = explode(
',', $tmpbacktopagejsfields[1]);
1881 $backtopagejsfieldsid = empty($tmp2backtopagejsfields[0]) ?
'' : $tmp2backtopagejsfields[0];
1882 $backtopagejsfieldslabel = empty($tmp2backtopagejsfields[1]) ?
'' : $tmp2backtopagejsfields[1];
1883 $url .=
'&backtopagejsfields='.urlencode($backtopagejsfields);
1887 $out .=
'<!-- a link for button to open url into a dialog popup with backtopagejsfields = '.$backtopagejsfields.
' -->';
1888 $out .=
'<a '.($accesskey ?
' accesskey="'.$accesskey.
'"' :
'').
' class="cursorpointer reposition button_'.$name.($morecss ?
' '.$morecss :
'').
'"'.$disabled.
' title="'.
dol_escape_htmltag($label).
'"';
1889 if (empty($conf->use_javascript_ajax)) {
1890 $out .=
' href="'.DOL_URL_ROOT.$url.
'" target="_blank"';
1891 } elseif ($jsonopen) {
1892 $out .=
' href="#" onclick="'.$jsonopen.
'"';
1894 $out .=
' href="#"';
1896 $out .=
'>'.$buttonstring.
'</a>';
1898 if (!empty($conf->use_javascript_ajax)) {
1900 $out .=
'<!-- code to open popup and variables to retreive returned variables -->';
1901 $out .=
'<div id="idfordialog'.$name.
'" class="hidden">div for dialog</div>';
1902 $out .=
'<div id="varforreturndialogid'.$name.
'" class="hidden">div for returned id</div>';
1903 $out .=
'<div id="varforreturndialoglabel'.$name.
'" class="hidden">div for returned label</div>';
1904 $out .=
'<!-- Add js code to open dialog popup on dialog -->';
1905 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">
1906 jQuery(document).ready(function () {
1907 jQuery(".button_'.$name.
'").click(function () {
1908 console.log(\'Open popup with jQuery(...).dialog() on URL '.
dol_escape_js(DOL_URL_ROOT.$url).
'\');
1909 var $tmpdialog = $(\
'#idfordialog'.$name.
'\');
1910 $tmpdialog.html(\
'<iframe class="iframedialog" id="iframedialog'.$name.
'" style="border: 0px;" src="'.DOL_URL_ROOT.$url.
'" width="100%" height="98%"></iframe>\');
1914 height: (window.innerHeight - 150),
1917 open:
function (event, ui) {
1918 console.log(
"open popup name='.$name.', backtopagejsfields='.$backtopagejsfields.'");
1920 close:
function (event, ui) {
1921 var returnedid = jQuery(
"#varforreturndialogid'.$name.'").text();
1922 var returnedlabel = jQuery(
"#varforreturndialoglabel'.$name.'").text();
1923 console.log(
"popup has been closed. returnedid (js var defined into parent page)="+returnedid+
" returnedlabel="+returnedlabel);
1924 if (returnedid !=
"" && returnedid !=
"div for returned id") {
1925 jQuery(
"#'.(empty($backtopagejsfieldsid)?"none
":$backtopagejsfieldsid).'").val(returnedid);
1927 if (returnedlabel !=
"" && returnedlabel !=
"div for returned label") {
1928 jQuery(
"#'.(empty($backtopagejsfieldslabel)?"none
":$backtopagejsfieldslabel).'").val(returnedlabel);
1933 $tmpdialog.dialog(\
'open\');
1958 function dol_fiche_head($links = array(), $active =
'0', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
1960 print
dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow, $moretabssuffix);
1979 function dol_get_fiche_head($links = array(), $active =
'', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'', $dragdropfile = 0)
1981 global $conf, $langs, $hookmanager;
1985 if (!empty($conf->dol_optimize_smallscreen)) {
1989 $out =
"\n".
'<!-- dol_fiche_head - dol_get_fiche_head -->';
1991 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
1992 $out .=
'<div class="tabs'.($picto ?
'' :
' nopaddingleft').
'" data-role="controlgroup" data-type="horizontal">'.
"\n";
1996 if ($morehtmlright) {
1997 $out .=
'<div class="inline-block floatright tabsElem">'.$morehtmlright.
'</div>';
2001 if (!empty($title) && $showtitle && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2003 $out .=
'<a class="tabTitle">';
2005 $noprefix = $pictoisfullpath;
2006 if (strpos($picto,
'fontawesome_') !==
false) {
2009 $out .=
img_picto($title, ($noprefix ?
'' :
'object_').$picto,
'', $pictoisfullpath, 0, 0,
'',
'imgTabTitle').
' ';
2011 $out .=
'<span class="tabTitleText">'.dol_escape_htmltag(
dol_trunc($title, $limittitle)).
'</span>';
2019 if (is_array($links) && !empty($links)) {
2020 $keys = array_keys($links);
2022 $maxkey = max($keys);
2028 if (empty($limittoshow)) {
2029 $limittoshow = (empty($conf->global->MAIN_MAXTABS_IN_CARD) ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD);
2031 if (!empty($conf->dol_optimize_smallscreen)) {
2039 for ($i = 0; $i <= $maxkey; $i++) {
2040 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2042 if ($i >= $limittoshow) {
2048 for ($i = 0; $i <= $maxkey; $i++) {
2049 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2055 if ($i < $limittoshow || $isactive) {
2057 $out .=
'<div class="inline-block tabsElem'.($isactive ?
' tabsElemActive' :
'').((!$isactive && !empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT)) ?
' hideonprint' :
'').
'"><!-- id tab = '.(empty($links[$i][2]) ?
'' :
dol_escape_htmltag($links[$i][2])).
' -->';
2059 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2060 if (!empty($links[$i][0])) {
2061 $out .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2063 $out .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2065 } elseif (!empty($links[$i][1])) {
2067 $out .=
'<div class="tab tab'.($isactive?
'active':
'unactive').
'" style="margin: 0 !important">';
2068 if (!empty($links[$i][0])) {
2069 $titletoshow = preg_replace(
'/<.*$/',
'', $links[$i][1]);
2070 $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).
'">';
2072 $out .= $links[$i][1];
2073 if (!empty($links[$i][0])) {
2074 $out .=
'</a>'.
"\n";
2076 $out .= empty($links[$i][4]) ?
'' : $links[$i][4];
2085 $outmore .=
'<div class="popuptabset wordwrap">';
2087 $outmore .=
'<div class="popuptab wordwrap" style="display:inherit;">';
2088 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2089 if (!empty($links[$i][0])) {
2090 $outmore .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2092 $outmore .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2094 } elseif (!empty($links[$i][1])) {
2095 $outmore .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="wordwrap inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
2096 $outmore .= preg_replace(
'/([a-z])\|([a-z])/i',
'\\1 | \\2', $links[$i][1]);
2097 $outmore .=
'</a>'.
"\n";
2099 $outmore .=
'</div>';
2106 $outmore .=
'</div>';
2110 $left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
2111 $right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
2112 $widthofpopup = 200;
2114 $tabsname = $moretabssuffix;
2115 if (empty($tabsname)) {
2116 $tabsname = str_replace(
"@",
"", $picto);
2118 $out .=
'<div id="moretabs'.$tabsname.
'" class="inline-block tabsElem valignmiddle">';
2119 $out .=
'<div class="tab"><a href="#" class="tab moretab inline-block tabunactive"><span class="hideonsmartphone">'.$langs->trans(
"More").
'</span>... ('.$nbintab.
')</a></div>';
2120 $out .=
'<div id="moretabsList'.$tabsname.
'" style="width: '.$widthofpopup.
'px; position: absolute; '.$left.
': -999em; text-align: '.$left.
'; margin:0px; padding:2px; z-index:10;">';
2123 $out .=
'<div></div>';
2126 $out .=
'<script nonce="'.getNonce().
'">';
2127 $out .=
"$('#moretabs".$tabsname.
"').mouseenter( function() {
2128 var x = this.offsetLeft, y = this.offsetTop;
2129 console.log('mouseenter ".$left.
" x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
2130 if ((window.innerWidth - x) < ".($widthofpopup + 10).
") {
2131 $('#moretabsList".$tabsname.
"').css('".$right.
"','8px');
2133 $('#moretabsList".$tabsname.
"').css('".$left.
"','auto');
2136 $out .=
"$('#moretabs".$tabsname.
"').mouseleave( function() { console.log('mouseleave ".$left.
"'); $('#moretabsList".$tabsname.
"').css('".$left.
"','-999em');});";
2137 $out .=
"</script>";
2140 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2144 if (!$notab || $notab == -1 || $notab == -2 || $notab == -3) {
2145 $out .=
"\n".
'<div id="dragDropAreaTabBar" class="tabBar'.($notab == -1 ?
'' : ($notab == -2 ?
' tabBarNoTop' : (($notab == -3 ?
' noborderbottom' :
'').
' tabBarWithBottom'))).
'">'.
"\n";
2147 if (!empty($dragdropfile)) {
2150 $parameters = array(
'tabname' => $active,
'out' => $out);
2151 $reshook = $hookmanager->executeHooks(
'printTabsHead', $parameters);
2153 $out = $hookmanager->resPrint;
2179 if (!$notab || $notab == -1) {
2180 return "\n</div>\n";
2205 function dol_banner_tab($object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $onlybanner = 0, $morehtmlright =
'')
2207 global $conf,
$form, $user, $langs, $hookmanager, $action;
2211 $maxvisiblephotos = 1;
2213 $entity = (empty($object->entity) ? $conf->entity : $object->entity);
2214 $showbarcode = empty($conf->barcode->enabled) ? 0 : (empty($object->barcode) ? 0 : 1);
2215 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
2218 $modulepart =
'unknown';
2220 if ($object->element ==
'societe' || $object->element ==
'contact' || $object->element ==
'product' || $object->element ==
'ticket') {
2221 $modulepart = $object->element;
2222 } elseif ($object->element ==
'member') {
2223 $modulepart =
'memberphoto';
2224 } elseif ($object->element ==
'user') {
2225 $modulepart =
'userphoto';
2228 if (class_exists(
"Imagick")) {
2229 if ($object->element ==
'expensereport' || $object->element ==
'propal' || $object->element ==
'commande' || $object->element ==
'facture' || $object->element ==
'supplier_proposal') {
2230 $modulepart = $object->element;
2231 } elseif ($object->element ==
'fichinter') {
2232 $modulepart =
'ficheinter';
2233 } elseif ($object->element ==
'contrat') {
2234 $modulepart =
'contract';
2235 } elseif ($object->element ==
'order_supplier') {
2236 $modulepart =
'supplier_order';
2237 } elseif ($object->element ==
'invoice_supplier') {
2238 $modulepart =
'supplier_invoice';
2242 if ($object->element ==
'product') {
2244 $cssclass =
'photowithmargin photoref';
2245 $showimage = $object->is_photo_available($conf->product->multidir_output[$entity]);
2246 $maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5);
2247 if ($conf->browser->layout ==
'phone') {
2248 $maxvisiblephotos = 1;
2251 $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>';
2253 if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
2255 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2257 $nophoto =
'/public/theme/common/nophoto.png';
2258 $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>';
2261 } elseif ($object->element ==
'ticket') {
2263 $cssclass =
'photoref';
2264 $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity].
'/'.$object->ref);
2265 $maxvisiblephotos = (isset($conf->global->TICKET_MAX_VISIBLE_PHOTO) ? $conf->global->TICKET_MAX_VISIBLE_PHOTO : 2);
2266 if ($conf->browser->layout ==
'phone') {
2267 $maxvisiblephotos = 1;
2271 $showphoto = $object->show_photos(
'ticket', $conf->ticket->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0);
2272 if ($object->nbphoto > 0) {
2273 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$showphoto.
'</div>';
2279 if (!empty($conf->global->TICKET_NODISPLAYIFNOPHOTO)) {
2281 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2283 $nophoto =
img_picto(
'No photo',
'object_ticket');
2284 $morehtmlleft .=
'<!-- No photo to show -->';
2285 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2286 $morehtmlleft .= $nophoto;
2287 $morehtmlleft .=
'</div></div>';
2292 if ($modulepart !=
'unknown') {
2295 if (in_array($modulepart, array(
'propal',
'commande',
'facture',
'ficheinter',
'contract',
'supplier_order',
'supplier_proposal',
'supplier_invoice',
'expensereport')) && class_exists(
"Imagick")) {
2297 $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]).
"/";
2298 if (in_array($modulepart, array(
'invoice_supplier',
'supplier_invoice'))) {
2299 $subdir =
get_exdir($object->id, 2, 0, 1, $object, $modulepart);
2300 $subdir .= ((!empty($subdir) && !preg_match(
'/\/$/', $subdir)) ?
'/' :
'').$objectref;
2302 $subdir =
get_exdir($object->id, 0, 0, 1, $object, $modulepart);
2304 if (empty($subdir)) {
2305 $subdir =
'errorgettingsubdirofobject';
2308 $filepath = $dir_output.$subdir.
"/";
2310 $filepdf = $filepath.$objectref.
".pdf";
2311 $relativepath = $subdir.
'/'.$objectref.
'.pdf';
2314 $fileimage = $filepdf.
'_preview.png';
2315 $relativepathimage = $relativepath.
'_preview.png';
2317 $pdfexists = file_exists($filepdf);
2322 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2323 if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) {
2324 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2333 if ($pdfexists && !$error) {
2334 $heightforphotref = 80;
2335 if (!empty($conf->dol_optimize_smallscreen)) {
2336 $heightforphotref = 60;
2339 if (file_exists($fileimage)) {
2340 $phototoshow =
'<div class="photoref">';
2341 $phototoshow .=
'<img height="'.$heightforphotref.
'" class="photo photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2342 $phototoshow .=
'</div>';
2345 } elseif (!$phototoshow) {
2346 $phototoshow .=
$form->showphoto($modulepart, $object, 0, 0, 0,
'photowithmargin photoref',
'small', 1, 0, $maxvisiblephotos);
2350 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
2351 $morehtmlleft .= $phototoshow;
2352 $morehtmlleft .=
'</div>';
2356 if (empty($phototoshow)) {
2357 if ($object->element ==
'action') {
2359 $cssclass =
'photorefcenter';
2360 $nophoto =
img_picto(
'No photo',
'title_agenda');
2363 $cssclass =
'photorefcenter';
2364 $picto = $object->picto;
2365 $prefix =
'object_';
2366 if ($object->element ==
'project' && !$object->public) {
2369 if (strpos($picto,
'fontawesome_') !==
false) {
2372 $nophoto =
img_picto(
'No photo', $prefix.$picto);
2374 $morehtmlleft .=
'<!-- No photo to show -->';
2375 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2376 $morehtmlleft .= $nophoto;
2377 $morehtmlleft .=
'</div></div>';
2384 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object, 100,
'photoref valignmiddle').
'</div>';
2387 if ($object->element ==
'societe') {
2388 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'societe',
'creer') && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
2389 $morehtmlstatus .=
ajax_object_onoff($object,
'status',
'status',
'InActivity',
'ActivityCeased');
2391 $morehtmlstatus .= $object->getLibStatut(6);
2393 } elseif ($object->element ==
'product') {
2395 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
2396 $morehtmlstatus .=
ajax_object_onoff($object,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
2398 $morehtmlstatus .=
'<span class="statusrefsell">'.$object->getLibStatut(6, 0).
'</span>';
2400 $morehtmlstatus .=
' ';
2402 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
2403 $morehtmlstatus .=
ajax_object_onoff($object,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
2405 $morehtmlstatus .=
'<span class="statusrefbuy">'.$object->getLibStatut(6, 1).
'</span>';
2407 } elseif (in_array($object->element, array(
'facture',
'invoice',
'invoice_supplier',
'chargesociales',
'loan',
'tva',
'salary'))) {
2408 $tmptxt = $object->getLibStatut(6, $object->totalpaid);
2409 if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
2410 $tmptxt = $object->getLibStatut(5, $object->totalpaid);
2412 $morehtmlstatus .= $tmptxt;
2413 } elseif ($object->element ==
'contrat' || $object->element ==
'contract') {
2414 if ($object->statut == 0) {
2415 $morehtmlstatus .= $object->getLibStatut(5);
2417 $morehtmlstatus .= $object->getLibStatut(4);
2419 } elseif ($object->element ==
'facturerec') {
2420 if ($object->frequency == 0) {
2421 $morehtmlstatus .= $object->getLibStatut(2);
2423 $morehtmlstatus .= $object->getLibStatut(5);
2425 } elseif ($object->element ==
'project_task') {
2426 $object->fk_statut = 1;
2427 if ($object->progress > 0) {
2428 $object->fk_statut = 2;
2430 if ($object->progress >= 100) {
2431 $object->fk_statut = 3;
2433 $tmptxt = $object->getLibStatut(5);
2434 $morehtmlstatus .= $tmptxt;
2435 } elseif (method_exists($object,
'getLibStatut')) {
2436 $tmptxt = $object->getLibStatut(6);
2437 if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
2438 $tmptxt = $object->getLibStatut(5);
2440 $morehtmlstatus .= $tmptxt;
2444 if (
isModEnabled(
'accounting') && in_array($object->element, array(
'bank',
'paiementcharge',
'facture',
'invoice',
'invoice_supplier',
'expensereport',
'payment_various'))) {
2446 if (method_exists($object,
'getVentilExportCompta')) {
2447 $accounted = $object->getVentilExportCompta();
2448 $langs->load(
"accountancy");
2449 $morehtmlstatus .=
'</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? $langs->trans(
"Accounted") : $langs->trans(
"NotYetAccounted")).
'</span>';
2454 if (!empty($object->name_alias)) {
2455 $morehtmlref .=
'<div class="refidno opacitymedium">'.dol_escape_htmltag($object->name_alias).
'</div>';
2459 if (in_array($object->element, array(
'product',
'bank_account',
'project_task'))) {
2460 if (!empty($object->label)) {
2461 $morehtmlref .=
'<div class="refidno opacitymedium">'.$object->label.
'</div>';
2466 if (method_exists($object,
'getBannerAddress') && !in_array($object->element, array(
'product',
'bookmark',
'ecm_directories',
'ecm_files'))) {
2467 $moreaddress = $object->getBannerAddress(
'refaddress', $object);
2469 $morehtmlref .=
'<div class="refidno refaddress">';
2470 $morehtmlref .= $moreaddress;
2471 $morehtmlref .=
'</div>';
2474 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && ($conf->global->MAIN_SHOW_TECHNICAL_ID ==
'1' || preg_match(
'/'.preg_quote($object->element,
'/').
'/i', $conf->global->MAIN_SHOW_TECHNICAL_ID)) && !empty($object->id)) {
2475 $morehtmlref .=
'<div style="clear: both;"></div>';
2476 $morehtmlref .=
'<div class="refidno opacitymedium">';
2477 $morehtmlref .= $langs->trans(
"TechnicalID").
': '.((int) $object->id);
2478 $morehtmlref .=
'</div>';
2481 $parameters=array(
'morehtmlref'=>$morehtmlref);
2482 $reshook = $hookmanager->executeHooks(
'formDolBanner', $parameters, $object, $action);
2485 } elseif (empty($reshook)) {
2486 $morehtmlref .= $hookmanager->resPrint;
2487 } elseif ($reshook > 0) {
2488 $morehtmlref = $hookmanager->resPrint;
2492 print
'<div class="'.($onlybanner ?
'arearefnobottom ' :
'arearef ').
'heightref valignmiddle centpercent">';
2493 print
$form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
2495 print
'<div class="underrefbanner clearboth"></div>';
2511 if ($fieldrequired) {
2512 $ret .=
'<span class="fieldrequired">';
2514 $ret .=
'<label for="'.$fieldkey.
'">';
2515 $ret .= $langs->trans($langkey);
2517 if ($fieldrequired) {
2533 $ret =
' '.$bc[$var];
2535 $ret = preg_replace(
'/class=\"/',
'class="'.$moreclass.
' ', $ret);
2553 function dol_format_address($object, $withcountry = 0, $sep =
"\n", $outputlangs =
'', $mode = 0, $extralangcode =
'')
2555 global $conf, $langs, $hookmanager;
2558 $countriesusingstate = array(
'AU',
'CA',
'US',
'IN',
'GB',
'ES',
'UK',
'TR',
'CN');
2563 $ret .= ($extralangcode ? $object->array_languages[
'address'][$extralangcode] : (empty($object->address) ?
'' : preg_replace(
'/[\n\r]/', $sep, $object->address)));
2566 if (isset($object->country_code) && in_array($object->country_code, array(
'AU',
'CA',
'US',
'CN')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) {
2568 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2569 $ret .= (($ret && $town) ? $sep :
'').$town;
2571 if (!empty($object->state)) {
2572 $ret .= ($ret ? ($town ?
", " : $sep) :
'').$object->state;
2574 if (!empty($object->zip)) {
2575 $ret .= ($ret ? (($town || $object->state) ?
", " : $sep) :
'').$object->zip;
2577 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'GB',
'UK'))) {
2579 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2580 $ret .= ($ret ? $sep :
'').$town;
2581 if (!empty($object->state)) {
2582 $ret .= ($ret ?
", " :
'').$object->state;
2584 if (!empty($object->zip)) {
2585 $ret .= ($ret ? $sep :
'').$object->zip;
2587 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'ES',
'TR'))) {
2589 $ret .= ($ret ? $sep :
'').$object->zip;
2590 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2591 $ret .= ($town ? (($object->zip ?
' ' :
'').$town) :
'');
2592 if (!empty($object->state)) {
2593 $ret .= $sep.$object->state;
2595 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'JP'))) {
2598 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2599 $ret .= ($ret ? $sep :
'').($object->state ? $object->state.
', ' :
'').$town.($object->zip ?
' ' :
'').$object->zip;
2600 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'IT'))) {
2602 $ret .= ($ret ? $sep :
'').$object->zip;
2603 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2604 $ret .= ($town ? (($object->zip ?
' ' :
'').$town) :
'');
2605 $ret .= (empty($object->state_code) ?
'' : (
' '.$object->state_code));
2608 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2609 $ret .= !empty($object->zip) ? (($ret ? $sep :
'').$object->zip) :
'';
2610 $ret .= ($town ? (($object->zip ?
' ' : ($ret ? $sep :
'')).$town) :
'');
2611 if (!empty($object->state) && in_array($object->country_code, $countriesusingstate)) {
2612 $ret .= ($ret ?
", " :
'').$object->state;
2616 if (!is_object($outputlangs)) {
2617 $outputlangs = $langs;
2620 $langs->load(
"dict");
2621 $ret .= (empty($object->country_code) ?
'' : ($ret ? $sep :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$object->country_code)));
2624 $parameters = array(
'withcountry' => $withcountry,
'sep' => $sep,
'outputlangs' => $outputlangs,
'mode' => $mode,
'extralangcode' => $extralangcode);
2625 $reshook = $hookmanager->executeHooks(
'formatAddress', $parameters, $object);
2629 $ret .= $hookmanager->resPrint;
2647 if ((abs($ts) <= 0x7FFFFFFF)) {
2648 return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts);
2650 return 'Error date into a not supported range';
2675 function dol_print_date($time, $format =
'', $tzoutput =
'auto', $outputlangs =
'', $encodetooutput =
false)
2677 global $conf, $langs;
2684 if ($tzoutput ===
'auto') {
2685 $tzoutput = (empty($conf) ?
'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey :
'tzserver'));
2690 $offsettz = $offsetdst = 0;
2693 if (is_string($tzoutput)) {
2694 if ($tzoutput ==
'tzserver') {
2696 $offsettzstring = @date_default_timezone_get();
2699 } elseif ($tzoutput ==
'tzuser' || $tzoutput ==
'tzuserrel') {
2701 $offsettzstring = (empty($_SESSION[
'dol_tz_string']) ?
'UTC' : $_SESSION[
'dol_tz_string']);
2703 if (class_exists(
'DateTimeZone')) {
2704 $user_date_tz =
new DateTimeZone($offsettzstring);
2705 $user_dt =
new DateTime();
2706 $user_dt->setTimezone($user_date_tz);
2707 $user_dt->setTimestamp($tzoutput ==
'tzuser' ?
dol_now() : (
int) $time);
2708 $offsettz = $user_dt->getOffset();
2710 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
2711 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
2716 if (!is_object($outputlangs)) {
2717 $outputlangs = $langs;
2720 $format =
'daytextshort';
2725 $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array(
'day',
'dayhour'))) ? 1 : 0;
2726 $format = preg_replace(
'/inputnoreduce/',
'', $format);
2727 $formatwithoutreduce = preg_replace(
'/reduceformat/',
'', $format);
2728 if ($formatwithoutreduce != $format) {
2729 $format = $formatwithoutreduce;
2735 if ($format ==
'day') {
2736 $format = ($outputlangs->trans(
"FormatDateShort") !=
"FormatDateShort" ? $outputlangs->trans(
"FormatDateShort") : $conf->format_date_short);
2737 } elseif ($format ==
'hour') {
2738 $format = ($outputlangs->trans(
"FormatHourShort") !=
"FormatHourShort" ? $outputlangs->trans(
"FormatHourShort") : $conf->format_hour_short);
2739 } elseif ($format ==
'hourduration') {
2740 $format = ($outputlangs->trans(
"FormatHourShortDuration") !=
"FormatHourShortDuration" ? $outputlangs->trans(
"FormatHourShortDuration") : $conf->format_hour_short_duration);
2741 } elseif ($format ==
'daytext') {
2742 $format = ($outputlangs->trans(
"FormatDateText") !=
"FormatDateText" ? $outputlangs->trans(
"FormatDateText") : $conf->format_date_text);
2743 } elseif ($format ==
'daytextshort') {
2744 $format = ($outputlangs->trans(
"FormatDateTextShort") !=
"FormatDateTextShort" ? $outputlangs->trans(
"FormatDateTextShort") : $conf->format_date_text_short);
2745 } elseif ($format ==
'dayhour') {
2746 $format = ($outputlangs->trans(
"FormatDateHourShort") !=
"FormatDateHourShort" ? $outputlangs->trans(
"FormatDateHourShort") : $conf->format_date_hour_short);
2747 } elseif ($format ==
'dayhoursec') {
2748 $format = ($outputlangs->trans(
"FormatDateHourSecShort") !=
"FormatDateHourSecShort" ? $outputlangs->trans(
"FormatDateHourSecShort") : $conf->format_date_hour_sec_short);
2749 } elseif ($format ==
'dayhourtext') {
2750 $format = ($outputlangs->trans(
"FormatDateHourText") !=
"FormatDateHourText" ? $outputlangs->trans(
"FormatDateHourText") : $conf->format_date_hour_text);
2751 } elseif ($format ==
'dayhourtextshort') {
2752 $format = ($outputlangs->trans(
"FormatDateHourTextShort") !=
"FormatDateHourTextShort" ? $outputlangs->trans(
"FormatDateHourTextShort") : $conf->format_date_hour_text_short);
2753 } elseif ($format ==
'dayhourlog') {
2755 $format =
'%Y%m%d%H%M%S';
2756 } elseif ($format ==
'dayhourlogsmall') {
2758 $format =
'%y%m%d%H%M';
2759 } elseif ($format ==
'dayhourldap') {
2760 $format =
'%Y%m%d%H%M%SZ';
2761 } elseif ($format ==
'dayhourxcard') {
2762 $format =
'%Y%m%dT%H%M%SZ';
2763 } elseif ($format ==
'dayxcard') {
2765 } elseif ($format ==
'dayrfc') {
2766 $format =
'%Y-%m-%d';
2767 } elseif ($format ==
'dayhourrfc') {
2768 $format =
'%Y-%m-%dT%H:%M:%SZ';
2769 } elseif ($format ==
'standard') {
2770 $format =
'%Y-%m-%d %H:%M:%S';
2773 if ($reduceformat) {
2774 $format = str_replace(
'%Y',
'%y', $format);
2775 $format = str_replace(
'yyyy',
'yy', $format);
2779 if (preg_match(
'/%b/i', $format)) {
2781 $format = str_replace(
'%b',
'__b__', $format);
2782 $format = str_replace(
'%B',
'__B__', $format);
2784 if (preg_match(
'/%a/i', $format)) {
2786 $format = str_replace(
'%a',
'__a__', $format);
2787 $format = str_replace(
'%A',
'__A__', $format);
2792 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)) {
2793 dol_print_error(
'',
"Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER[
"PHP_SELF"]);
2795 } elseif (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)) {
2797 dol_syslog(
"Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER[
"PHP_SELF"], LOG_WARNING);
2800 $syear = (!empty($reg[1]) ? $reg[1] :
'');
2801 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
2802 $sday = (!empty($reg[3]) ? $reg[3] :
'');
2803 $shour = (!empty($reg[4]) ? $reg[4] :
'');
2804 $smin = (!empty($reg[5]) ? $reg[5] :
'');
2805 $ssec = (!empty($reg[6]) ? $reg[6] :
'');
2807 $time =
dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear,
true);
2810 $tzo =
new DateTimeZone(
'UTC');
2812 $tzo =
new DateTimeZone(date_default_timezone_get());
2814 $dtts =
new DateTime();
2815 $dtts->setTimestamp($time);
2816 $dtts->setTimezone($tzo);
2817 $newformat = str_replace(
2818 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2819 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2821 $ret = $dtts->format($newformat);
2823 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2824 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2829 if ($time < 100000000000) {
2830 $timetouse = $time + $offsettz + $offsetdst;
2833 $tzo =
new DateTimeZone(
'UTC');
2835 $tzo =
new DateTimeZone(date_default_timezone_get());
2837 $dtts =
new DateTime();
2838 $dtts->setTimestamp($timetouse);
2839 $dtts->setTimezone($tzo);
2840 $newformat = str_replace(
2841 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'%w',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2842 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'w',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2844 $ret = $dtts->format($newformat);
2846 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2847 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2852 $ret =
'Bad value '.$time.
' for date';
2856 if (preg_match(
'/__b__/i', $format)) {
2857 $timetouse = $time + $offsettz + $offsetdst;
2860 $tzo =
new DateTimeZone(
'UTC');
2862 $tzo =
new DateTimeZone(date_default_timezone_get());
2864 $dtts =
new DateTime();
2865 $dtts->setTimestamp($timetouse);
2866 $dtts->setTimezone($tzo);
2867 $month = $dtts->format(
"m");
2868 $month = sprintf(
"%02d", $month);
2869 if ($encodetooutput) {
2870 $monthtext = $outputlangs->transnoentities(
'Month'.$month);
2871 $monthtextshort = $outputlangs->transnoentities(
'MonthShort'.$month);
2873 $monthtext = $outputlangs->transnoentitiesnoconv(
'Month'.$month);
2874 $monthtextshort = $outputlangs->transnoentitiesnoconv(
'MonthShort'.$month);
2877 $ret = str_replace(
'__b__', $monthtextshort, $ret);
2878 $ret = str_replace(
'__B__', $monthtext, $ret);
2882 if (preg_match(
'/__a__/i', $format)) {
2884 $timetouse = $time + $offsettz + $offsetdst;
2887 $tzo =
new DateTimeZone(
'UTC');
2889 $tzo =
new DateTimeZone(date_default_timezone_get());
2891 $dtts =
new DateTime();
2892 $dtts->setTimestamp($timetouse);
2893 $dtts->setTimezone($tzo);
2894 $w = $dtts->format(
"w");
2895 $dayweek = $outputlangs->transnoentitiesnoconv(
'Day'.$w);
2897 $ret = str_replace(
'__A__', $dayweek, $ret);
2898 $ret = str_replace(
'__a__',
dol_substr($dayweek, 0, 3), $ret);
2927 $datetimeobj =
new DateTime();
2928 $datetimeobj->setTimestamp($timestamp);
2929 if ($forcetimezone) {
2930 $datetimeobj->setTimezone(
new DateTimeZone($forcetimezone ==
'gmt' ?
'UTC' : $forcetimezone));
2933 'year'=>((
int) date_format($datetimeobj,
'Y')),
2934 'mon'=>((
int) date_format($datetimeobj,
'm')),
2935 'mday'=>((
int) date_format($datetimeobj,
'd')),
2936 'wday'=>((
int) date_format($datetimeobj,
'w')),
2937 'yday'=>((
int) date_format($datetimeobj,
'z')),
2938 'hours'=>((
int) date_format($datetimeobj,
'H')),
2939 'minutes'=>((
int) date_format($datetimeobj,
'i')),
2940 'seconds'=>((
int) date_format($datetimeobj,
's')),
2968 function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm =
'auto', $check = 1)
2973 if ($gm ===
'auto') {
2974 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
2979 if ($hour == -1 || empty($hour)) {
2982 if ($minute == -1 || empty($minute)) {
2985 if ($second == -1 || empty($second)) {
2991 if (!$month || !$day) {
3000 if ($hour < 0 || $hour > 24) {
3003 if ($minute < 0 || $minute > 60) {
3006 if ($second < 0 || $second > 60) {
3011 if (empty($gm) || ($gm ===
'server' || $gm ===
'tzserver')) {
3012 $default_timezone = @date_default_timezone_get();
3013 $localtz =
new DateTimeZone($default_timezone);
3014 } elseif ($gm ===
'user' || $gm ===
'tzuser' || $gm ===
'tzuserrel') {
3016 $default_timezone = (empty($_SESSION[
"dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION[
"dol_tz_string"]);
3018 $localtz =
new DateTimeZone($default_timezone);
3020 dol_syslog(
"Warning dol_tz_string contains an invalid value ".$_SESSION[
"dol_tz_string"], LOG_WARNING);
3021 $default_timezone = @date_default_timezone_get();
3023 } elseif (strrpos($gm,
"tz,") !==
false) {
3024 $timezone = str_replace(
"tz,",
"", $gm);
3026 $localtz =
new DateTimeZone($timezone);
3028 dol_syslog(
"Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
3032 if (empty($localtz)) {
3033 $localtz =
new DateTimeZone(
'UTC');
3037 $dt =
new DateTime(
'now', $localtz);
3038 $dt->setDate((
int) $year, (
int) $month, (
int) $day);
3039 $dt->setTime((
int) $hour, (
int) $minute, (
int) $second);
3040 $date = $dt->getTimestamp();
3060 if ($mode ===
'auto') {
3064 if ($mode ==
'gmt') {
3066 } elseif ($mode ==
'tzserver') {
3067 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
3069 $ret = (int) (
dol_now(
'gmt') + ($tzsecond * 3600));
3075 } elseif ($mode ==
'tzuser' || $mode ==
'tzuserrel') {
3078 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3079 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3080 $ret = (int) (
dol_now(
'gmt') + ($offsettz + $offsetdst));
3097 global $conf, $langs;
3100 if (!empty($conf->dol_optimize_smallscreen)) {
3105 if (empty($shortvalue) || $size < ($level * 10)) {
3107 $textunitshort = $langs->trans(
"b");
3108 $textunitlong = $langs->trans(
"Bytes");
3110 $ret = round($size / $level, 0);
3111 $textunitshort = $langs->trans(
"Kb");
3112 $textunitlong = $langs->trans(
"KiloBytes");
3115 if (empty($shortunit)) {
3116 $ret .=
' '.$textunitlong;
3118 $ret .=
' '.$textunitshort;
3134 function dol_print_url($url, $target =
'_blank', $max = 32, $withpicto = 0, $morecss =
'float')
3142 $link =
'<a href="';
3143 if (!preg_match(
'/^http/i', $url)) {
3149 $link .=
' target="'.$target.
'"';
3152 if (!preg_match(
'/^http/i', $url)) {
3158 if ($morecss ==
'float') {
3159 return '<div class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe').
' ' :
'').$link.
'</div>';
3161 return '<span class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe').
' ' :
'').$link.
'</span>';
3177 function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0)
3179 global $conf, $user, $langs, $hookmanager;
3183 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpicto) {
3187 if (empty($email)) {
3191 if (!empty($addlink)) {
3192 $newemail =
'<a style="text-overflow: ellipsis;" href="';
3193 if (!preg_match(
'/^mailto:/i', $email)) {
3194 $newemail .=
'mailto:';
3196 $newemail .= $email;
3199 $newemail .=
'</a>';
3201 $langs->load(
"errors");
3202 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
3205 if (($cid || $socid) &&
isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
3208 if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) {
3209 $link =
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&backtopage=1&actioncode='.$type.
'&contactid='.$cid.
'&socid='.$socid.
'">'.
img_object($langs->trans(
"AddAction"),
"calendar").
'</a>';
3212 $newemail =
'<div>'.$newemail.
' '.$link.
'</div>';
3217 $langs->load(
"errors");
3218 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
3223 $rep = ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto)).
' ' :
'').$newemail;
3226 $parameters = array(
'cid' => $cid,
'socid' => $socid,
'addlink' => $addlink,
'picto' => $withpicto);
3228 $reshook = $hookmanager->executeHooks(
'printEmail', $parameters, $email);
3232 $rep .= $hookmanager->resPrint;
3247 $socialnetworks = array();
3249 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
3250 $cachekey =
'socialnetworks_' . $conf->entity;
3252 if (!is_null($dataretrieved)) {
3253 $socialnetworks = $dataretrieved;
3255 $sql =
"SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX.
"c_socialnetworks";
3256 $sql .=
" WHERE entity=".$conf->entity;
3257 $resql = $db->query(
$sql);
3259 while ($obj = $db->fetch_object($resql)) {
3260 $socialnetworks[$obj->code] = array(
3261 'rowid' => $obj->rowid,
3262 'label' => $obj->label,
3264 'icon' => $obj->icon,
3265 'active' => $obj->active,
3272 return $socialnetworks;
3287 global $conf, $user, $langs;
3291 if (empty($value)) {
3295 if (!empty($type)) {
3296 $htmllink =
'<div class="divsocialnetwork inline-block valignmiddle">';
3298 $htmllink .=
'<span class="fa pictofixedwidth '.($dictsocialnetworks[$type][
'icon'] ? $dictsocialnetworks[$type][
'icon'] :
'fa-link').
'"></span>';
3299 if ($type ==
'skype') {
3301 $htmllink .=
' <a href="skype:';
3303 $htmllink .=
'?call" alt="'.$langs->trans(
"Call").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Call").
' '.$value).
'">';
3304 $htmllink .=
'<img src="'.DOL_URL_ROOT.
'/theme/common/skype_callbutton.png" border="0">';
3305 $htmllink .=
'</a><a href="skype:';
3307 $htmllink .=
'?chat" alt="'.$langs->trans(
"Chat").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Chat").
' '.$value).
'">';
3308 $htmllink .=
'<img class="paddingleft" src="'.DOL_URL_ROOT.
'/theme/common/skype_chatbutton.png" border="0">';
3309 $htmllink .=
'</a>';
3310 if (($cid || $socid) &&
isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
3311 $addlink =
'AC_SKYPE';
3313 if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) {
3314 $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>';
3316 $htmllink .= ($link ?
' '.$link :
'');
3319 if (!empty($dictsocialnetworks[$type][
'url'])) {
3320 $tmpvirginurl = preg_replace(
'/\/?{socialid}/',
'', $dictsocialnetworks[$type][
'url']);
3321 if ($tmpvirginurl) {
3322 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3323 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3325 $tmpvirginurl3 = preg_replace(
'/^https:\/\//i',
'https://www.', $tmpvirginurl);
3326 if ($tmpvirginurl3) {
3327 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3328 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3331 $tmpvirginurl2 = preg_replace(
'/^https?:\/\//i',
'', $tmpvirginurl);
3332 if ($tmpvirginurl2) {
3333 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3334 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3337 $link = str_replace(
'{socialid}', $value, $dictsocialnetworks[$type][
'url']);
3338 if (preg_match(
'/^https?:\/\//i', $link)) {
3339 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3341 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3347 $htmllink .=
'</div>';
3349 $langs->load(
"errors");
3350 $htmllink .=
img_warning($langs->trans(
"ErrorBadSocialNetworkValue", $value));
3365 function dol_print_profids($profID, $profIDtype, $countrycode =
'', $addcpButton = 1, $separ =
' ')
3369 if (empty($profID) || empty($profIDtype)) {
3372 if (empty($countrycode)) $countrycode = $mysoc->country_code;
3373 $newProfID = $profID;
3374 $id = substr($profIDtype, -1);
3376 if (strtoupper($countrycode) ==
'FR') {
3378 if ($id == 1 &&
dol_strlen($newProfID) == 9) $newProfID = substr($newProfID, 0, 3).$separ.substr($newProfID, 3, 3).$separ.substr($newProfID, 6, 3);
3379 if ($id == 2 &&
dol_strlen($newProfID) == 14) $newProfID = substr($newProfID, 0, 3).$separ.substr($newProfID, 3, 3).$separ.substr($newProfID, 6, 3).$separ.substr($newProfID, 9, 5);
3380 if ($profIDtype ===
'VAT' &&
dol_strlen($newProfID) == 13) $newProfID = substr($newProfID, 0, 4).$separ.substr($newProfID, 4, 3).$separ.substr($newProfID, 7, 3).$separ.substr($newProfID, 10, 3);
3383 else $ret = $newProfID;
3401 function dol_print_phone($phone, $countrycode =
'', $cid = 0, $socid = 0, $addlink =
'', $separ =
" ", $withpicto =
'', $titlealt =
'', $adddivfloat = 0)
3403 global $conf, $user, $langs, $mysoc, $hookmanager;
3406 $phone = is_null($phone) ?
'' : preg_replace(
"/[\s.-]/",
"", trim($phone));
3407 if (empty($phone)) {
3410 if (!empty($conf->global->MAIN_PHONE_SEPAR)) {
3411 $separ = $conf->global->MAIN_PHONE_SEPAR;
3413 if (empty($countrycode) && is_object($mysoc)) {
3414 $countrycode = $mysoc->country_code;
3418 if ($conf->dol_optimize_smallscreen) {
3423 if (strtoupper($countrycode) ==
"FR") {
3426 $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);
3428 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
3430 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
3432 $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);
3434 $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);
3436 $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);
3438 } elseif (strtoupper($countrycode) ==
"CA") {
3440 $newphone = ($separ !=
'' ?
'(' :
'').substr($newphone, 0, 3).($separ !=
'' ?
')' :
'').$separ.substr($newphone, 3, 3).($separ !=
'' ?
'-' :
'').substr($newphone, 6, 4);
3442 } elseif (strtoupper($countrycode) ==
"PT") {
3444 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3446 } elseif (strtoupper($countrycode) ==
"SR") {
3448 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
3450 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
3452 } elseif (strtoupper($countrycode) ==
"DE") {
3454 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
3456 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
3458 } elseif (strtoupper($countrycode) ==
"ES") {
3460 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3462 } elseif (strtoupper($countrycode) ==
"BF") {
3464 $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);
3466 } elseif (strtoupper($countrycode) ==
"RO") {
3468 $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);
3470 } elseif (strtoupper($countrycode) ==
"TR") {
3472 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
3474 } elseif (strtoupper($countrycode) ==
"US") {
3476 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
3478 } elseif (strtoupper($countrycode) ==
"MX") {
3480 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
3482 $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);
3484 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
3486 } elseif (strtoupper($countrycode) ==
"ML") {
3488 $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);
3490 } elseif (strtoupper($countrycode) ==
"TH") {
3492 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
3494 $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);
3496 } elseif (strtoupper($countrycode) ==
"MU") {
3499 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
3501 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
3503 } elseif (strtoupper($countrycode) ==
"ZA") {
3505 $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);
3507 } elseif (strtoupper($countrycode) ==
"SY") {
3509 $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);
3511 $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);
3513 } elseif (strtoupper($countrycode) ==
"AE") {
3515 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
3517 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3519 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
3521 } elseif (strtoupper($countrycode) ==
"DZ") {
3523 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3525 } elseif (strtoupper($countrycode) ==
"BE") {
3527 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
3529 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3531 } elseif (strtoupper($countrycode) ==
"PF") {
3533 $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);
3535 } elseif (strtoupper($countrycode) ==
"CO") {
3537 $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);
3539 } elseif (strtoupper($countrycode) ==
"JO") {
3541 $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);
3543 } elseif (strtoupper($countrycode) ==
"JM") {
3545 $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
3547 } elseif (strtoupper($countrycode) ==
"MG") {
3549 $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);
3551 } elseif (strtoupper($countrycode) ==
"GB") {
3553 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3555 } elseif (strtoupper($countrycode) ==
"CH") {
3557 $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);
3559 $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);
3561 } elseif (strtoupper($countrycode) ==
"TN") {
3563 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3565 } elseif (strtoupper($countrycode) ==
"GF") {
3567 $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);
3569 } elseif (strtoupper($countrycode) ==
"GP") {
3571 $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);
3573 } elseif (strtoupper($countrycode) ==
"MQ") {
3575 $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);
3577 } elseif (strtoupper($countrycode) ==
"IT") {
3579 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3581 $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);
3583 } elseif (strtoupper($countrycode) ==
"AU") {
3587 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
3589 } elseif (strtoupper($countrycode) ==
"LU") {
3592 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
3594 $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);
3596 $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);
3598 $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);
3601 if (!empty($addlink)) {
3602 if ($addlink ==
'tel' || $conf->browser->layout ==
'phone' || (
isModEnabled(
'clicktodial') && !empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) {
3603 $newphoneform = $newphone;
3604 $newphone =
'<a href="tel:'.$phone.
'"';
3605 $newphone .=
'>'.$newphoneform.
'</a>';
3606 } elseif (
isModEnabled(
'clicktodial') && $addlink ==
'AC_TEL') {
3607 if (empty($user->clicktodial_loaded)) {
3608 $user->fetch_clicktodial();
3612 $urlmask =
'ErrorClickToDialModuleNotConfigured';
3613 if (!empty($conf->global->CLICKTODIAL_URL)) {
3614 $urlmask = $conf->global->CLICKTODIAL_URL;
3616 if (!empty($user->clicktodial_url)) {
3617 $urlmask = $user->clicktodial_url;
3620 $clicktodial_poste = (!empty($user->clicktodial_poste) ?urlencode($user->clicktodial_poste) :
'');
3621 $clicktodial_login = (!empty($user->clicktodial_login) ?urlencode($user->clicktodial_login) :
'');
3622 $clicktodial_password = (!empty($user->clicktodial_password) ?urlencode($user->clicktodial_password) :
'');
3624 $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
3626 $substitarray = array(
'__PHONEFROM__'=>$clicktodial_poste,
3627 '__PHONETO__'=>urlencode($phone),
3628 '__LOGIN__'=>$clicktodial_login,
3629 '__PASS__'=>$clicktodial_password);
3631 $newphonesav = $newphone;
3632 if (empty($conf->global->CLICKTODIAL_DO_NOT_USE_AJAX_CALL)) {
3634 $newphone =
'<a href="'.$url.
'" class="cssforclicktodial"';
3635 $newphone .=
'>'.$newphonesav.
'</a>';
3638 $newphone =
'<a href="'.$url.
'"';
3639 if (!empty($conf->global->CLICKTODIAL_FORCENEWTARGET)) {
3640 $newphone .=
' target="_blank" rel="noopener noreferrer"';
3642 $newphone .=
'>'.$newphonesav.
'</a>';
3647 if (
isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
3650 if ($addlink ==
'AC_FAX') {
3653 if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE)) {
3654 $link =
'<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>';
3657 $newphone =
'<div>'.$newphone.
' '.$link.
'</div>';
3662 if (empty($titlealt)) {
3663 $titlealt = ($withpicto ==
'fax' ? $langs->trans(
"Fax") : $langs->trans(
"Phone"));
3668 $parameters = array(
'countrycode' => $countrycode,
'cid' => $cid,
'socid' => $socid,
'titlealt' => $titlealt,
'picto' => $withpicto);
3669 $reshook = $hookmanager->executeHooks(
'printPhone', $parameters, $phone);
3670 $rep .= $hookmanager->resPrint;
3672 if (empty($reshook)) {
3675 if ($withpicto ==
'fax') {
3676 $picto =
'phoning_fax';
3677 } elseif ($withpicto ==
'phone') {
3679 } elseif ($withpicto ==
'mobile') {
3680 $picto =
'phoning_mobile';
3685 if ($adddivfloat == 1) {
3686 $rep .=
'<div class="nospan float" style="margin-right: 10px">';
3687 } elseif (empty($adddivfloat)) {
3688 $rep .=
'<span style="margin-right: 10px;">';
3690 $rep .= ($withpicto ?
img_picto($titlealt,
'object_'.$picto.
'.png').
' ' :
'').$newphone;
3691 if ($adddivfloat == 1) {
3693 } elseif (empty($adddivfloat)) {
3710 global $conf, $langs;
3721 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/common/flags/'.$countrycode.
'.png')) {
3722 $ret .=
' '.img_picto($countrycode.
' '.$langs->trans(
"AccordingToGeoIPDatabase"), DOL_URL_ROOT.
'/theme/common/flags/'.$countrycode.
'.png',
'', 1);
3724 $ret .=
' ('.$countrycode.
')';
3744 if (empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
3745 if (empty($_SERVER[
'HTTP_CLIENT_IP']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_CLIENT_IP'])) {
3746 if (empty($_SERVER[
"HTTP_CF_CONNECTING_IP"])) {
3747 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
3749 $ip = $_SERVER[
"HTTP_CF_CONNECTING_IP"];
3752 $ip = $_SERVER[
'HTTP_CLIENT_IP'];
3755 $ip = $_SERVER[
'HTTP_X_FORWARDED_FOR'];
3771 if (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on') {
3773 } 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') {
3791 if (!empty($conf->geoipmaxmind->enabled)) {
3795 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
3796 $geoip =
new DolGeoIP(
'country', $datafile);
3798 $countrycode = $geoip->getCountryCodeFromIP($ip);
3801 return $countrycode;
3813 global $conf, $langs, $user;
3817 if (!empty($conf->geoipmaxmind->enabled)) {
3822 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
3823 $geoip =
new DolGeoIP(
'country', $datafile);
3824 $countrycode = $geoip->getCountryCodeFromIP($ip);
3825 $ret = $countrycode;
3844 global $conf, $user, $langs, $hookmanager;
3850 $parameters = array(
'element' => $element,
'id' => $id);
3851 $reshook = $hookmanager->executeHooks(
'printAddress', $parameters, $address);
3852 $out .= $hookmanager->resPrint;
3854 if (empty($reshook)) {
3855 if (empty($charfornl)) {
3856 $out .= nl2br($address);
3858 $out .= preg_replace(
'/[\r\n]+/', $charfornl, $address);
3862 $showgmap = $showomap = 0;
3863 if (($element ==
'thirdparty' || $element ==
'societe') &&
isModEnabled(
'google') && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) {
3866 if ($element ==
'contact' &&
isModEnabled(
'google') && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) {
3869 if ($element ==
'member' &&
isModEnabled(
'google') && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) {
3872 if (($element ==
'thirdparty' || $element ==
'societe') &&
isModEnabled(
'openstreetmap') && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) {
3875 if ($element ==
'contact' &&
isModEnabled(
'openstreetmap') && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) {
3878 if ($element ==
'member' &&
isModEnabled(
'openstreetmap') && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) {
3882 $url =
dol_buildpath(
'/google/gmaps.php?mode='.$element.
'&id='.$id, 1);
3883 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
3886 $url =
dol_buildpath(
'/openstreetmap/maps.php?mode='.$element.
'&id='.$id, 1);
3887 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
3908 function isValidEmail($address, $acceptsupervisorkey = 0, $acceptuserkey = 0)
3910 if ($acceptsupervisorkey && $address ==
'__SUPERVISOREMAIL__') {
3913 if ($acceptuserkey && $address ==
'__USER_EMAIL__') {
3916 if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
3933 if (function_exists(
'idn_to_ascii') && function_exists(
'checkdnsrr')) {
3934 if (!checkdnsrr(idn_to_ascii($domain),
'MX')) {
3937 if (function_exists(
'getmxrr')) {
3940 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
3941 if (count($mxhosts) > 1) {
3944 if (count($mxhosts) == 1 && !empty($mxhosts[0])) {
3981 $tmparray = explode(
' ', $s);
3982 foreach ($tmparray as $tmps) {
3999 if (is_null($string)) {
4003 if (function_exists(
'mb_strlen')) {
4004 return mb_strlen($string, $stringencoding);
4006 return strlen($string);
4020 function dol_substr($string, $start, $length =
null, $stringencoding =
'', $trunconbytes = 0)
4024 if (empty($stringencoding)) {
4025 $stringencoding = $langs->charset_output;
4029 if (empty($trunconbytes)) {
4030 if (function_exists(
'mb_substr')) {
4031 $ret = mb_substr($string, $start, $length, $stringencoding);
4033 $ret = substr($string, $start, $length);
4036 if (function_exists(
'mb_strcut')) {
4037 $ret = mb_strcut($string, $start, $length, $stringencoding);
4039 $ret = substr($string, $start, $length);
4059 function dol_trunc($string, $size = 40, $trunc =
'right', $stringencoding =
'UTF-8', $nodot = 0, $display = 0)
4063 if (empty($size) || !empty($conf->global->MAIN_DISABLE_TRUNC)) {
4067 if (empty($stringencoding)) {
4068 $stringencoding =
'UTF-8';
4071 if ($conf->dol_optimize_smallscreen == 1 && $display == 1) {
4072 $size = round($size / 3);
4076 if ($trunc ==
'right') {
4078 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
4080 return dol_substr($newstring, 0, $size, $stringencoding).($nodot ?
'' :
'…');
4085 } elseif ($trunc ==
'middle') {
4087 if (
dol_strlen($newstring, $stringencoding) > 2 &&
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4088 $size1 = round($size / 2);
4089 $size2 = round($size / 2);
4090 return dol_substr($newstring, 0, $size1, $stringencoding).
'…'.
dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
4094 } elseif ($trunc ==
'left') {
4096 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
4098 return '…'.dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
4102 } elseif ($trunc ==
'wrap') {
4104 if (
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4110 return 'BadParam3CallingDolTrunc';
4135 function img_picto($titlealt, $picto, $moreatt =
'', $pictoisfullpath =
false, $srconly = 0, $notitle = 0, $alt =
'', $morecss =
'', $marginleftonlyshort = 2)
4137 global $conf, $langs;
4140 $url = DOL_URL_ROOT;
4141 $theme = isset($conf->theme) ? $conf->theme :
null;
4142 $path =
'theme/'.$theme;
4144 if ($pictoisfullpath) {
4146 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
4149 $fullpathpicto = $picto;
4151 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4152 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4153 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4156 $pictowithouttext = preg_replace(
'/(\.png|\.gif|\.svg)$/',
'', $picto);
4157 $pictowithouttext = str_replace(
'object_',
'', $pictowithouttext);
4158 $pictowithouttext = str_replace(
'_nocolor',
'', $pictowithouttext);
4160 if (strpos($pictowithouttext,
'fontawesome_') !==
false || preg_match(
'/^fa-/', $pictowithouttext)) {
4162 $pictowithouttext = str_replace(
'fontawesome_',
'', $pictowithouttext);
4163 $pictowithouttext = str_replace(
'fa-',
'', $pictowithouttext);
4165 $pictowithouttextarray = explode(
'_', $pictowithouttext);
4166 $marginleftonlyshort = 0;
4168 if (!empty($pictowithouttextarray[1])) {
4170 $fakey =
'fa-'.$pictowithouttextarray[0];
4171 $fa = empty($pictowithouttextarray[1]) ?
'fa' : $pictowithouttextarray[1];
4172 $facolor = empty($pictowithouttextarray[2]) ?
'' : $pictowithouttextarray[2];
4173 $fasize = empty($pictowithouttextarray[3]) ?
'' : $pictowithouttextarray[3];
4175 $fakey =
'fa-'.$pictowithouttext;
4185 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4186 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4187 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4189 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
4190 $morestyle = $reg[1];
4191 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
4193 $moreatt = trim($moreatt);
4195 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
4196 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
4200 $enabledisablehtml .=
'</span>';
4202 return $enabledisablehtml;
4205 if (empty($srconly) && in_array($pictowithouttext, array(
4206 '1downarrow',
'1uparrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected',
4207 'accountancy',
'accounting_account',
'account',
'accountline',
'action',
'add',
'address',
'angle-double-down',
'angle-double-up',
'asset',
4208 'bank_account',
'barcode',
'bank',
'bell',
'bill',
'billa',
'billr',
'billd',
'birthday-cake',
'bookmark',
'bom',
'briefcase-medical',
'bug',
'building',
4209 'card',
'calendarlist',
'calendar',
'calendarmonth',
'calendarweek',
'calendarday',
'calendarperuser',
'calendarpertype',
4210 'cash-register',
'category',
'chart',
'check',
'clock',
'clone',
'close_title',
'cog',
'collab',
'company',
'contact',
'country',
'contract',
'conversation',
'cron',
'cross',
'cubes',
4211 'currency',
'multicurrency',
4212 'delete',
'dolly',
'dollyrevert',
'donation',
'download',
'dynamicprice',
4213 'edit',
'ellipsis-h',
'email',
'entity',
'envelope',
'eraser',
'establishment',
'expensereport',
'external-link-alt',
'external-link-square-alt',
'eye',
4214 'filter',
'file-code',
'file-export',
'file-import',
'file-upload',
'autofill',
'folder',
'folder-open',
'folder-plus',
4215 'gears',
'generate',
'generic',
'globe',
'globe-americas',
'graph',
'grip',
'grip_title',
'group',
4216 'hands-helping',
'help',
'holiday',
4217 'id-card',
'images',
'incoterm',
'info',
'intervention',
'inventory',
'intracommreport',
'jobprofile',
4218 'knowledgemanagement',
4219 'label',
'language',
'line',
'link',
'list',
'list-alt',
'listlight',
'loan',
'lock',
'lot',
'long-arrow-alt-right',
4220 'margin',
'map-marker-alt',
'member',
'meeting',
'money-bill-alt',
'movement',
'mrp',
'note',
'next',
4221 'off',
'on',
'order',
4222 'paiment',
'paragraph',
'play',
'pdf',
'phone',
'phoning',
'phoning_mobile',
'phoning_fax',
'playdisabled',
'previous',
'poll',
'pos',
'printer',
'product',
'propal',
'proposal',
'puce',
4223 'stock',
'resize',
'service',
'stats',
'trip',
4224 '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',
4225 'github',
'google',
'jabber',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'youtube',
'google-plus-g',
'whatsapp',
4226 'chevron-left',
'chevron-right',
'chevron-down',
'chevron-top',
'commercial',
'companies',
4227 'generic',
'home',
'hrm',
'members',
'products',
'invoicing',
4228 'partnership',
'payment',
'payment_vat',
'pencil-ruler',
'pictoconfirm',
'preview',
'project',
'projectpub',
'projecttask',
'question',
'refresh',
'region',
4229 'salary',
'shipment',
'state',
'supplier_invoice',
'supplier_invoicea',
'supplier_invoicer',
'supplier_invoiced',
4230 'technic',
'ticket',
4232 'recent',
'reception',
'recruitmentcandidature',
'recruitmentjobposition',
'replacement',
'resource',
'recurring',
'rss',
4233 'shapes',
'skill',
'square',
'stop-circle',
'supplier',
'supplier_proposal',
'supplier_order',
'supplier_invoice',
4234 'timespent',
'title_setup',
'title_accountancy',
'title_bank',
'title_hrm',
'title_agenda',
4235 'uncheck',
'url',
'user-cog',
'user-injured',
'user-md',
'vat',
'website',
'workstation',
'webhook',
'world',
'private',
4236 'conferenceorbooth',
'eventorganization',
4237 'stamp',
'signature'
4239 $fakey = $pictowithouttext;
4243 if (in_array($pictowithouttext, array(
'card',
'bell',
'clock',
'establishment',
'generic',
'minus-square',
'object_generic',
'pdf',
'plus-square',
'timespent',
'note',
'off',
'on',
'object_bookmark',
'bookmark',
'vcard'))) {
4246 if (in_array($pictowithouttext, array(
'black-tie',
'github',
'google',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'stripe',
'stripe-s',
'youtube',
'google-plus-g',
'whatsapp'))) {
4250 $arrayconvpictotofa = array(
4251 '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',
4252 'bank_account'=>
'university',
4253 'bill'=>
'file-invoice-dollar',
'billa'=>
'file-excel',
'billr'=>
'file-invoice-dollar',
'billd'=>
'file-medical',
4254 'supplier_invoice'=>
'file-invoice-dollar',
'supplier_invoicea'=>
'file-excel',
'supplier_invoicer'=>
'file-invoice-dollar',
'supplier_invoiced'=>
'file-medical',
4256 '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',
4257 'donation'=>
'file-alt',
'dynamicprice'=>
'hand-holding-usd',
4258 'setup'=>
'cog',
'companies'=>
'building',
'products'=>
'cube',
'commercial'=>
'suitcase',
'invoicing'=>
'coins',
4259 'accounting'=>
'search-dollar',
'category'=>
'tag',
'dollyrevert'=>
'dolly',
4260 'generate'=>
'plus-square',
'hrm'=>
'user-tie',
'incoterm'=>
'truck-loading',
4261 'margin'=>
'calculator',
'members'=>
'user-friends',
'ticket'=>
'ticket-alt',
'globe'=>
'external-link-alt',
'lot'=>
'barcode',
4262 'email'=>
'at',
'establishment'=>
'building',
'edit'=>
'pencil-alt',
'entity'=>
'globe',
4263 'graph'=>
'chart-line',
'grip_title'=>
'arrows-alt',
'grip'=>
'arrows-alt',
'help'=>
'question-circle',
4264 'generic'=>
'file',
'holiday'=>
'umbrella-beach',
4265 'info'=>
'info-circle',
'inventory'=>
'boxes',
'intracommreport'=>
'globe-europe',
'jobprofile'=>
'cogs',
4266 'knowledgemanagement'=>
'ticket-alt',
'label'=>
'layer-group',
'line'=>
'bars',
'loan'=>
'money-bill-alt',
4267 'member'=>
'user-alt',
'meeting'=>
'chalkboard-teacher',
'mrp'=>
'cubes',
'next'=>
'arrow-alt-circle-right',
4268 'trip'=>
'wallet',
'expensereport'=>
'wallet',
'group'=>
'users',
'movement'=>
'people-carry',
4269 'sign-out'=>
'sign-out-alt',
4270 'switch_off'=>
'toggle-off',
'switch_on'=>
'toggle-on',
'switch_on_warning'=>
'toggle-on',
'switch_on_red'=>
'toggle-on',
'check'=>
'check',
'bookmark'=>
'star',
4271 'bank'=>
'university',
'close_title'=>
'times',
'delete'=>
'trash',
'filter'=>
'filter',
4272 'list-alt'=>
'list-alt',
'calendarlist'=>
'bars',
'calendar'=>
'calendar-alt',
'calendarmonth'=>
'calendar-alt',
'calendarweek'=>
'calendar-week',
'calendarday'=>
'calendar-day',
'calendarperuser'=>
'table',
4273 'intervention'=>
'ambulance',
'invoice'=>
'file-invoice-dollar',
'currency'=>
'dollar-sign',
'multicurrency'=>
'dollar-sign',
'order'=>
'file-invoice',
4274 'error'=>
'exclamation-triangle',
'warning'=>
'exclamation-triangle',
4276 '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',
4277 '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',
4278 'recent' =>
'check-square',
'reception'=>
'dolly',
'recruitmentjobposition'=>
'id-card-alt',
'recruitmentcandidature'=>
'id-badge',
4279 'resize'=>
'crop',
'supplier_order'=>
'dol-order_supplier',
'supplier_proposal'=>
'file-signature',
4280 'refresh'=>
'redo',
'region'=>
'map-marked',
'replacement'=>
'exchange-alt',
'resource'=>
'laptop-house',
'recurring'=>
'history',
4281 'service'=>
'concierge-bell',
4282 'skill'=>
'shapes',
'state'=>
'map-marked-alt',
'security'=>
'key',
'salary'=>
'wallet',
'shipment'=>
'dolly',
'stock'=>
'box-open',
'stats' =>
'chart-bar',
'split'=>
'code-branch',
'stripe'=>
'stripe-s',
4283 'supplier'=>
'building',
'technic'=>
'cogs',
4284 'timespent'=>
'clock',
'title_setup'=>
'tools',
'title_accountancy'=>
'money-check-alt',
'title_bank'=>
'university',
'title_hrm'=>
'umbrella-beach',
4285 'title_agenda'=>
'calendar-alt',
4286 'uncheck'=>
'times',
'uparrow'=>
'share',
'url'=>
'external-link-alt',
'vat'=>
'money-check-alt',
'vcard'=>
'arrow-alt-circle-down',
4287 'jabber'=>
'comment-o',
4288 'website'=>
'globe-americas',
'workstation'=>
'pallet',
'webhook'=>
'bullseye',
'world'=>
'globe',
'private'=>
'user-lock',
4289 'conferenceorbooth'=>
'chalkboard-teacher',
'eventorganization'=>
'project-diagram'
4291 if ($pictowithouttext ==
'off') {
4292 $fakey =
'fa-square';
4294 } elseif ($pictowithouttext ==
'on') {
4295 $fakey =
'fa-check-square';
4297 } elseif ($pictowithouttext ==
'listlight') {
4298 $fakey =
'fa-download';
4299 $marginleftonlyshort = 1;
4300 } elseif ($pictowithouttext ==
'printer') {
4301 $fakey =
'fa-print';
4303 } elseif ($pictowithouttext ==
'note') {
4304 $fakey =
'fa-sticky-note';
4305 $marginleftonlyshort = 1;
4306 } elseif (in_array($pictowithouttext, array(
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'))) {
4307 $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');
4308 $fakey =
'fa-'.$convertarray[$pictowithouttext];
4309 if (preg_match(
'/selected/', $pictowithouttext)) {
4312 $marginleftonlyshort = 1;
4313 } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) {
4314 $fakey =
'fa-'.$arrayconvpictotofa[$pictowithouttext];
4316 $fakey =
'fa-'.$pictowithouttext;
4319 if (in_array($pictowithouttext, array(
'dollyrevert',
'member',
'members',
'contract',
'group',
'resource',
'shipment'))) {
4320 $morecss .=
' em092';
4322 if (in_array($pictowithouttext, array(
'conferenceorbooth',
'collab',
'eventorganization',
'holiday',
'info',
'project',
'workstation'))) {
4323 $morecss .=
' em088';
4325 if (in_array($pictowithouttext, array(
'asset',
'intervention',
'payment',
'loan',
'partnership',
'stock',
'technic'))) {
4326 $morecss .=
' em080';
4330 $arrayconvpictotomarginleftonly = array(
4331 'bank',
'check',
'delete',
'generic',
'grip',
'grip_title',
'jabber',
4332 'grip_title',
'grip',
'listlight',
'note',
'on',
'off',
'playdisabled',
'printer',
'resize',
'sign-out',
'stats',
'switch_on',
'switch_on_red',
'switch_off',
4333 'uparrow',
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'
4335 if (!isset($arrayconvpictotomarginleftonly[$pictowithouttext])) {
4336 $marginleftonlyshort = 0;
4340 $arrayconvpictotomorcess = array(
4341 'action'=>
'infobox-action',
'account'=>
'infobox-bank_account',
'accounting_account'=>
'infobox-bank_account',
'accountline'=>
'infobox-bank_account',
'accountancy'=>
'infobox-bank_account',
'asset'=>
'infobox-bank_account',
4342 'bank_account'=>
'infobox-bank_account',
4343 'bill'=>
'infobox-commande',
'billa'=>
'infobox-commande',
'billr'=>
'infobox-commande',
'billd'=>
'infobox-commande',
4344 'margin'=>
'infobox-bank_account',
'conferenceorbooth'=>
'infobox-project',
4345 'cash-register'=>
'infobox-bank_account',
'contract'=>
'infobox-contrat',
'check'=>
'font-status4',
'collab'=>
'infobox-action',
'conversation'=>
'infobox-contrat',
4346 'donation'=>
'infobox-commande',
'dolly'=>
'infobox-commande',
'dollyrevert'=>
'flip infobox-order_supplier',
4347 'ecm'=>
'infobox-action',
'eventorganization'=>
'infobox-project',
4348 'hrm'=>
'infobox-adherent',
'group'=>
'infobox-adherent',
'intervention'=>
'infobox-contrat',
4349 'incoterm'=>
'infobox-supplier_proposal',
4350 'currency'=>
'infobox-bank_account',
'multicurrency'=>
'infobox-bank_account',
4351 'members'=>
'infobox-adherent',
'member'=>
'infobox-adherent',
'money-bill-alt'=>
'infobox-bank_account',
4352 'order'=>
'infobox-commande',
4353 'user'=>
'infobox-adherent',
'users'=>
'infobox-adherent',
4354 'error'=>
'pictoerror',
'warning'=>
'pictowarning',
'switch_on'=>
'font-status4',
'switch_on_warning'=>
'font-status4 warning',
'switch_on_red'=>
'font-status8',
4355 'holiday'=>
'infobox-holiday',
'info'=>
'opacityhigh',
'invoice'=>
'infobox-commande',
4356 'knowledgemanagement'=>
'infobox-contrat rotate90',
'loan'=>
'infobox-bank_account',
4357 'payment'=>
'infobox-bank_account',
'payment_vat'=>
'infobox-bank_account',
'poll'=>
'infobox-adherent',
'pos'=>
'infobox-bank_account',
'project'=>
'infobox-project',
'projecttask'=>
'infobox-project',
4358 'propal'=>
'infobox-propal',
'proposal'=>
'infobox-propal',
'private'=>
'infobox-project',
4359 'reception'=>
'flip',
'recruitmentjobposition'=>
'infobox-adherent',
'recruitmentcandidature'=>
'infobox-adherent',
4360 'resource'=>
'infobox-action',
4361 'salary'=>
'infobox-bank_account',
'shipment'=>
'infobox-commande',
'supplier_invoice'=>
'infobox-order_supplier',
'supplier_invoicea'=>
'infobox-order_supplier',
'supplier_invoiced'=>
'infobox-order_supplier',
4362 'supplier'=>
'infobox-order_supplier',
'supplier_order'=>
'infobox-order_supplier',
'supplier_proposal'=>
'infobox-supplier_proposal',
4363 'ticket'=>
'infobox-contrat',
'title_accountancy'=>
'infobox-bank_account',
'title_hrm'=>
'infobox-holiday',
'expensereport'=>
'infobox-expensereport',
'trip'=>
'infobox-expensereport',
'title_agenda'=>
'infobox-action',
4364 'vat'=>
'infobox-bank_account',
4366 'list-alt'=>
'imgforviewmode',
'calendar'=>
'imgforviewmode',
'calendarweek'=>
'imgforviewmode',
'calendarmonth'=>
'imgforviewmode',
'calendarday'=>
'imgforviewmode',
'calendarperuser'=>
'imgforviewmode'
4368 if (!empty($arrayconvpictotomorcess[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
4369 $morecss .= ($morecss ?
' ' :
'').$arrayconvpictotomorcess[$pictowithouttext];
4373 $arrayconvpictotocolor = array(
4374 'address'=>
'#6c6aa8',
'building'=>
'#6c6aa8',
'bom'=>
'#a69944',
4375 'clone'=>
'#999',
'cog'=>
'#999',
'companies'=>
'#6c6aa8',
'company'=>
'#6c6aa8',
'contact'=>
'#6c6aa8',
'cron'=>
'#555',
4376 'dynamicprice'=>
'#a69944',
4377 'edit'=>
'#444',
'note'=>
'#999',
'error'=>
'',
'help'=>
'#bbb',
'listlight'=>
'#999',
'language'=>
'#555',
4379 'lock'=>
'#ddd',
'lot'=>
'#a69944',
4380 'map-marker-alt'=>
'#aaa',
'mrp'=>
'#a69944',
'product'=>
'#a69944',
'service'=>
'#a69944',
'inventory'=>
'#a69944',
'stock'=>
'#a69944',
'movement'=>
'#a69944',
4381 'other'=>
'#ddd',
'world'=>
'#986c6a',
4382 'partnership'=>
'#6c6aa8',
'playdisabled'=>
'#ccc',
'printer'=>
'#444',
'projectpub'=>
'#986c6a',
'reception'=>
'#a69944',
'resize'=>
'#444',
'rss'=>
'#cba',
4384 'security'=>
'#999',
'square'=>
'#888',
'stop-circle'=>
'#888',
'stats'=>
'#444',
'switch_off'=>
'#999',
'technic'=>
'#999',
'timespent'=>
'#555',
4385 'uncheck'=>
'#800',
'uparrow'=>
'#555',
'user-cog'=>
'#999',
'country'=>
'#aaa',
'globe-americas'=>
'#aaa',
'region'=>
'#aaa',
'state'=>
'#aaa',
4386 'website'=>
'#304',
'workstation'=>
'#a69944'
4388 if (isset($arrayconvpictotocolor[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
4389 $facolor = $arrayconvpictotocolor[$pictowithouttext];
4396 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4397 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4398 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4400 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
4401 $morestyle = $reg[1];
4402 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
4404 $moreatt = trim($moreatt);
4406 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
4407 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
4411 $enabledisablehtml .=
'</span>';
4413 return $enabledisablehtml;
4416 if (!empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) {
4417 $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.
'/theme/'.$theme;
4418 } elseif (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) {
4419 $path = $conf->global->MAIN_OVERWRITE_THEME_RES.
'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES;
4420 } elseif (!empty($conf->modules_parts[
'theme']) && array_key_exists($theme, $conf->modules_parts[
'theme'])) {
4421 $path = $theme.
'/theme/'.$theme;
4426 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
4432 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
4437 foreach ($conf->file->dol_document_root as $type => $dirroot) {
4438 if ($type ==
'main') {
4442 if (file_exists($dirroot.
'/'.$path.
'/img/'.$picto)) {
4443 $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type];
4449 $fullpathpicto = $url.
'/'.$path.
'/img/'.$picto;
4453 return $fullpathpicto;
4457 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 :
'').
'"').
'>';
4473 function img_object($titlealt, $picto, $moreatt =
'', $pictoisfullpath =
false, $srconly = 0, $notitle = 0)
4475 if (strpos($picto,
'^') === 0) {
4476 return img_picto($titlealt, str_replace(
'^',
'', $picto), $moreatt, $pictoisfullpath, $srconly, $notitle);
4478 return img_picto($titlealt,
'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
4493 function img_weather($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $morecss =
'')
4497 if (is_numeric($picto)) {
4500 return '<i class="fa fa-weather-level'.$picto.
'"></i>';
4501 } elseif (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
4505 $path = DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/weather/'.$picto;
4507 return img_picto($titlealt, $path, $moreatt, 1, 0, 0,
'', $morecss);
4521 function img_picto_common($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $notitle = 0)
4525 if (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
4529 if ($pictoisfullpath) {
4532 $path = DOL_URL_ROOT.
'/theme/common/'.$picto;
4534 if (!empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) {
4535 $themepath = DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/img/'.$picto;
4537 if (file_exists($themepath)) {
4543 return img_picto($titlealt, $path, $moreatt, 1, 0, $notitle);
4559 function img_action($titlealt, $numaction, $picto =
'', $moreatt =
'')
4563 if (empty($titlealt) || $titlealt ==
'default') {
4564 if ($numaction ==
'-1' || $numaction ==
'ST_NO') {
4566 $titlealt = $langs->transnoentitiesnoconv(
'ChangeDoNotContact');
4567 } elseif ($numaction ==
'0' || $numaction ==
'ST_NEVER') {
4569 $titlealt = $langs->transnoentitiesnoconv(
'ChangeNeverContacted');
4570 } elseif ($numaction ==
'1' || $numaction ==
'ST_TODO') {
4572 $titlealt = $langs->transnoentitiesnoconv(
'ChangeToContact');
4573 } elseif ($numaction ==
'2' || $numaction ==
'ST_PEND') {
4575 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactInProcess');
4576 } elseif ($numaction ==
'3' || $numaction ==
'ST_DONE') {
4578 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactDone');
4580 $titlealt = $langs->transnoentitiesnoconv(
'ChangeStatus '.$numaction);
4584 if (!is_numeric($numaction)) {
4588 return img_picto($titlealt, (empty($picto) ?
'stcomm'.$numaction.
'.png' : $picto), $moreatt);
4598 function img_pdf($titlealt =
'default', $size = 3)
4602 if ($titlealt ==
'default') {
4603 $titlealt = $langs->trans(
'Show');
4606 return img_picto($titlealt,
'pdf'.$size.
'.png');
4620 if ($titlealt ==
'default') {
4621 $titlealt = $langs->trans(
'Add');
4624 return img_picto($titlealt,
'edit_add.png', $other);
4637 if ($titlealt ==
'default') {
4638 $titlealt = $langs->trans(
'Remove');
4641 return img_picto($titlealt,
'edit_remove.png', $other);
4652 function img_edit($titlealt =
'default', $float = 0, $other =
'')
4656 if ($titlealt ==
'default') {
4657 $titlealt = $langs->trans(
'Modify');
4660 return img_picto($titlealt,
'edit.png', ($float ?
'style="float: '.($langs->tab_translate[
"DIRECTION"] ==
'rtl' ?
'left' :
'right').
'"' :
"").($other ?
' '.$other :
''));
4671 function img_view($titlealt =
'default', $float = 0, $other =
'class="valignmiddle"')
4675 if ($titlealt ==
'default') {
4676 $titlealt = $langs->trans(
'View');
4679 $moreatt = ($float ?
'style="float: right" ' :
'').$other;
4681 return img_picto($titlealt,
'eye', $moreatt);
4692 function img_delete($titlealt =
'default', $other =
'class="pictodelete"', $morecss =
'')
4696 if ($titlealt ==
'default') {
4697 $titlealt = $langs->trans(
'Delete');
4700 return img_picto($titlealt,
'delete.png', $other,
false, 0, 0,
'', $morecss);
4713 if ($titlealt ==
"default") {
4714 $titlealt = $langs->trans(
"Print");
4716 return img_picto($titlealt,
'printer.png', $other);
4726 function img_split($titlealt =
'default', $other =
'class="pictosplit"')
4730 if ($titlealt ==
'default') {
4731 $titlealt = $langs->trans(
'Split');
4734 return img_picto($titlealt,
'split.png', $other);
4744 function img_help($usehelpcursor = 1, $usealttitle = 1)
4749 if (is_string($usealttitle)) {
4752 $usealttitle = $langs->trans(
'Info');
4756 return img_picto($usealttitle,
'info.png',
'style="vertical-align: middle;'.($usehelpcursor == 1 ?
' cursor: help' : ($usehelpcursor == 2 ?
' cursor: pointer' :
'')).
'"');
4769 if ($titlealt ==
'default') {
4770 $titlealt = $langs->trans(
'Informations');
4773 return img_picto($titlealt,
'info.png',
'style="vertical-align: middle;"');
4784 function img_warning($titlealt =
'default', $moreatt =
'', $morecss =
'pictowarning')
4788 if ($titlealt ==
'default') {
4789 $titlealt = $langs->trans(
'Warning');
4793 return img_picto($titlealt,
'warning.png',
'class="'.$morecss.
'"'.($moreatt ? ($moreatt ==
'1' ?
' style="float: right"' :
' '.$moreatt) :
''));
4806 if ($titlealt ==
'default') {
4807 $titlealt = $langs->trans(
'Error');
4810 return img_picto($titlealt,
'error.png');
4820 function img_next($titlealt =
'default', $moreatt =
'')
4824 if ($titlealt ==
'default') {
4825 $titlealt = $langs->trans(
'Next');
4829 return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
4843 if ($titlealt ==
'default') {
4844 $titlealt = $langs->trans(
'Previous');
4848 return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
4859 function img_down($titlealt =
'default', $selected = 0, $moreclass =
'')
4863 if ($titlealt ==
'default') {
4864 $titlealt = $langs->trans(
'Down');
4867 return img_picto($titlealt, ($selected ?
'1downarrow_selected.png' :
'1downarrow.png'),
'class="imgdown'.($moreclass ?
" ".$moreclass :
"").
'"');
4878 function img_up($titlealt =
'default', $selected = 0, $moreclass =
'')
4882 if ($titlealt ==
'default') {
4883 $titlealt = $langs->trans(
'Up');
4886 return img_picto($titlealt, ($selected ?
'1uparrow_selected.png' :
'1uparrow.png'),
'class="imgup'.($moreclass ?
" ".$moreclass :
"").
'"');
4897 function img_left($titlealt =
'default', $selected = 0, $moreatt =
'')
4901 if ($titlealt ==
'default') {
4902 $titlealt = $langs->trans(
'Left');
4905 return img_picto($titlealt, ($selected ?
'1leftarrow_selected.png' :
'1leftarrow.png'), $moreatt);
4916 function img_right($titlealt =
'default', $selected = 0, $moreatt =
'')
4920 if ($titlealt ==
'default') {
4921 $titlealt = $langs->trans(
'Right');
4924 return img_picto($titlealt, ($selected ?
'1rightarrow_selected.png' :
'1rightarrow.png'), $moreatt);
4938 if ($titlealt ==
'default') {
4939 $titlealt = $langs->trans(
'Active');
4943 return img_picto($titlealt,
'tick.png');
4958 if (is_null($morecss)) {
4962 if ($brand ==
'visa' || $brand ==
'Visa') {
4964 } elseif ($brand ==
'mastercard' || $brand ==
'MasterCard') {
4965 $brand =
'cc-mastercard';
4966 } elseif ($brand ==
'amex' || $brand ==
'American Express') {
4968 } elseif ($brand ==
'discover' || $brand ==
'Discover') {
4969 $brand =
'cc-discover';
4970 } elseif ($brand ==
'jcb' || $brand ==
'JCB') {
4972 } elseif ($brand ==
'diners' || $brand ==
'Diners club') {
4973 $brand =
'cc-diners-club';
4974 } elseif (!in_array($brand, array(
'cc-visa',
'cc-mastercard',
'cc-amex',
'cc-discover',
'cc-jcb',
'cc-diners-club'))) {
4975 $brand =
'credit-card';
4978 return '<span class="fa fa-'.$brand.
' fa-fw'.($morecss ?
' '.$morecss :
'').
'"></span>';
4989 function img_mime($file, $titlealt =
'', $morecss =
'')
4991 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
4997 if (empty($titlealt)) {
4998 $titlealt =
'Mime type: '.$mimetype;
5002 return '<i class="fa fa-'.$mimefa.
' paddingright'.($morecss ?
' '.$morecss :
'').
'"'.($titlealt ?
' title="'.$titlealt.
'"' :
'').
'></i>';
5015 global $conf, $langs;
5017 if ($titlealt ==
'default') {
5018 $titlealt = $langs->trans(
'Search');
5021 $img =
img_picto($titlealt,
'search.png', $other,
false, 1);
5023 $input =
'<input type="image" class="liste_titre" name="button_search" src="'.$img.
'" ';
5024 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
5038 global $conf, $langs;
5040 if ($titlealt ==
'default') {
5041 $titlealt = $langs->trans(
'Search');
5044 $img =
img_picto($titlealt,
'searchclear.png', $other,
false, 1);
5046 $input =
'<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.
'" ';
5047 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
5063 function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin =
'1', $morecss =
'hideonsmartphone', $textfordropdown =
'')
5065 global $conf, $langs;
5067 if ($infoonimgalt) {
5068 $result =
img_picto($text,
'info',
'class="'.($morecss ?
' '.$morecss :
'').
'"');
5070 if (empty($conf->use_javascript_ajax)) {
5071 $textfordropdown =
'';
5074 $class = (empty($admin) ?
'undefined' : ($admin ==
'1' ?
'info' : $admin));
5075 $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>');
5077 if ($textfordropdown) {
5078 $tmpresult =
'<span class="'.$class.
'text opacitymedium cursorpointer">'.$langs->trans($textfordropdown).
' '.
img_picto($langs->trans($textfordropdown),
'1downarrow').
'</span>';
5079 $tmpresult .=
'<script nonce="'.getNonce().
'" type="text/javascript">
5080 jQuery(document).ready(function() {
5081 jQuery(".'.$class.
'text").click(function() {
5082 console.log("toggle text");
5083 jQuery(".'.$class.
'").toggle();
5088 $result = $tmpresult.$result;
5109 global $conf, $langs, $argv;
5110 global $dolibarr_main_prod;
5117 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
5119 $langs->load(
"main");
5123 $langs->loadLangs(array(
'main',
'errors'));
5125 if ($_SERVER[
'DOCUMENT_ROOT']) {
5126 $out .= $langs->trans(
"DolibarrHasDetectedError").
".<br>\n";
5128 $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";
5130 $out .= $langs->trans(
"InformationToHelpDiagnose").
":<br>\n";
5132 $out .=
"<b>".$langs->trans(
"Date").
":</b> ".
dol_print_date(time(),
'dayhourlog').
"<br>\n";
5133 $out .=
"<b>".$langs->trans(
"Dolibarr").
":</b> ".DOL_VERSION.
" - https://www.dolibarr.org<br>\n";
5134 if (isset($conf->global->MAIN_FEATURES_LEVEL)) {
5135 $out .=
"<b>".$langs->trans(
"LevelOfFeature").
":</b> ".
getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
"<br>\n";
5137 if (function_exists(
"phpversion")) {
5138 $out .=
"<b>".$langs->trans(
"PHP").
":</b> ".phpversion().
"<br>\n";
5140 $out .=
"<b>".$langs->trans(
"Server").
":</b> ".(isset($_SERVER[
"SERVER_SOFTWARE"]) ?
dol_htmlentities($_SERVER[
"SERVER_SOFTWARE"], ENT_COMPAT) :
'').
"<br>\n";
5141 if (function_exists(
"php_uname")) {
5142 $out .=
"<b>".$langs->trans(
"OS").
":</b> ".php_uname().
"<br>\n";
5144 $out .=
"<b>".$langs->trans(
"UserAgent").
":</b> ".(isset($_SERVER[
"HTTP_USER_AGENT"]) ?
dol_htmlentities($_SERVER[
"HTTP_USER_AGENT"], ENT_COMPAT) :
'').
"<br>\n";
5146 $out .=
"<b>".$langs->trans(
"RequestedUrl").
":</b> ".
dol_htmlentities($_SERVER[
"REQUEST_URI"], ENT_COMPAT).
"<br>\n";
5147 $out .=
"<b>".$langs->trans(
"Referer").
":</b> ".(isset($_SERVER[
"HTTP_REFERER"]) ?
dol_htmlentities($_SERVER[
"HTTP_REFERER"], ENT_COMPAT) :
'').
"<br>\n";
5148 $out .=
"<b>".$langs->trans(
"MenuManager").
":</b> ".(isset($conf->standard_menu) ?
dol_htmlentities($conf->standard_menu, ENT_COMPAT) :
'').
"<br>\n";
5150 $syslog .=
"url=".dol_escape_htmltag($_SERVER[
"REQUEST_URI"]);
5151 $syslog .=
", query_string=".dol_escape_htmltag($_SERVER[
"QUERY_STRING"]);
5153 $out .=
'> '.$langs->transnoentities(
"ErrorInternalErrorDetected").
":\n".$argv[0].
"\n";
5154 $syslog .=
"pid=".dol_getmypid();
5157 if (!empty($conf->modules)) {
5158 $out .=
"<b>".$langs->trans(
"Modules").
":</b> ".join(
', ', $conf->modules).
"<br>\n";
5161 if (is_object($db)) {
5162 if ($_SERVER[
'DOCUMENT_ROOT']) {
5163 $out .=
"<b>".$langs->trans(
"DatabaseTypeManager").
":</b> ".$db->type.
"<br>\n";
5164 $lastqueryerror = $db->lastqueryerror();
5166 $lastqueryerror =
"SQL error string is not a valid UTF8 string. We can't show it.";
5168 $out .=
"<b>".$langs->trans(
"RequestLastAccessInError").
":</b> ".($lastqueryerror ?
dol_escape_htmltag($lastqueryerror) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5169 $out .=
"<b>".$langs->trans(
"ReturnCodeLastAccessInError").
":</b> ".($db->lasterrno() ?
dol_escape_htmltag($db->lasterrno()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5170 $out .=
"<b>".$langs->trans(
"InformationLastAccessInError").
":</b> ".($db->lasterror() ?
dol_escape_htmltag($db->lasterror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5174 $out .=
'> '.$langs->transnoentities(
"DatabaseTypeManager").
":\n".$db->type.
"\n";
5175 $out .=
'> '.$langs->transnoentities(
"RequestLastAccessInError").
":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5176 $out .=
'> '.$langs->transnoentities(
"ReturnCodeLastAccessInError").
":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5177 $out .=
'> '.$langs->transnoentities(
"InformationLastAccessInError").
":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5179 $syslog .=
", sql=".$db->lastquery();
5180 $syslog .=
", db_error=".$db->lasterror();
5183 if ($error || $errors) {
5184 $langs->load(
"errors");
5187 if (is_array($error) && is_array($errors)) {
5188 $errors = array_merge($error, $errors);
5189 } elseif (is_array($error)) {
5191 } elseif (is_array($errors)) {
5192 $errors = array_merge(array($error), $errors);
5194 $errors = array_merge(array($error), array($errors));
5197 foreach ($errors as $msg) {
5201 if ($_SERVER[
'DOCUMENT_ROOT']) {
5205 $out .=
'> '.$langs->transnoentities(
"Message").
":\n".$msg.
"\n";
5207 $syslog .=
", msg=".$msg;
5210 if (empty($dolibarr_main_prod) && $_SERVER[
'DOCUMENT_ROOT'] && function_exists(
'xdebug_print_function_stack') && function_exists(
'xdebug_call_file')) {
5211 xdebug_print_function_stack();
5212 $out .=
'<b>XDebug informations:</b>'.
"<br>\n";
5213 $out .=
'File: '.xdebug_call_file().
"<br>\n";
5214 $out .=
'Line: '.xdebug_call_line().
"<br>\n";
5215 $out .=
'Function: '.xdebug_call_function().
"<br>\n";
5220 if (!headers_sent()) {
5221 if (function_exists(
'top_httphead')) {
5225 http_response_code(202);
5228 if (empty($dolibarr_main_prod)) {
5231 if (empty($langs->defaultlang)) {
5232 $langs->setDefaultLang();
5234 $langs->loadLangs(array(
"main",
"errors"));
5236 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";
5237 print $langs->trans(
"DolibarrHasDetectedError").
'. ';
5238 print $langs->trans(
"YouCanSetOptionDolibarrMainProdToZero");
5239 define(
"MAIN_CORE_ERROR", 1);
5255 function dol_print_error_email($prefixcode, $errormessage =
'', $errormessages = array(), $morecss =
'error', $email =
'')
5257 global $langs, $conf;
5259 if (empty($email)) {
5260 $email = $conf->global->MAIN_INFO_SOCIETE_MAIL;
5263 $langs->load(
"errors");
5266 print
'<br><div class="center login_main_message"><div class="'.$morecss.
'">';
5267 print $langs->trans(
"ErrorContactEMail", $email, $prefixcode.
'-'.
dol_print_date($now,
'%Y%m%d%H%M%S'));
5268 if ($errormessage) {
5269 print
'<br><br>'.$errormessage;
5271 if (is_array($errormessages) && count($errormessages)) {
5272 foreach ($errormessages as $mesgtoshow) {
5273 print
'<br><br>'.$mesgtoshow;
5276 print
'</div></div>';
5295 function print_liste_field_titre($name, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $tooltip =
"", $forcenowrapcolumntitle = 0)
5297 print
getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip, $forcenowrapcolumntitle);
5318 function getTitleFieldOfList($name, $thead = 0, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $disablesortlink = 0, $tooltip =
'', $forcenowrapcolumntitle = 0)
5320 global $conf, $langs,
$form;
5323 if ($moreattrib ==
'class="right"') {
5324 $prefix .=
'right ';
5327 $sortorder = strtoupper($sortorder);
5336 $tmpsortfield = explode(
',', $sortfield);
5337 $sortfield1 = trim($tmpsortfield[0]);
5338 $tmpfield = explode(
',', $field);
5339 $field1 = trim($tmpfield[0]);
5341 if (empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && empty($forcenowrapcolumntitle)) {
5342 $prefix =
'wrapcolumntitle '.$prefix;
5348 $liste_titre =
'liste_titre';
5349 if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace(
"/^[^\.]+\./",
"", $field1))) {
5350 $liste_titre =
'liste_titre_sel';
5353 $tagstart =
'<'.$tag.
' class="'.$prefix.$liste_titre.
'" '.$moreattrib;
5355 $tagstart .= ($name && empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && empty($forcenowrapcolumntitle) && !
dol_textishtml($name)) ?
' title="'.
dol_escape_htmltag($langs->trans($name)).
'"' :
'';
5358 if (empty($thead) && $field && empty($disablesortlink)) {
5359 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
5360 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
5361 $options = preg_replace(
'/&+/i',
'&', $options);
5362 if (!preg_match(
'/^&/', $options)) {
5363 $options =
'&'.$options;
5366 $sortordertouseinlink =
'';
5367 if ($field1 != $sortfield1) {
5368 if (preg_match(
'/^DESC/i', $sortorder)) {
5369 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
5371 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
5374 if (preg_match(
'/^ASC/i', $sortorder)) {
5375 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
5377 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
5380 $sortordertouseinlink = preg_replace(
'/,$/',
'', $sortordertouseinlink);
5381 $out .=
'<a class="reposition" href="'.$file.
'?sortfield='.$field.
'&sortorder='.$sortordertouseinlink.
'&begin='.$begin.$options.
'"';
5387 if (preg_match(
'/:\w+$/', $tooltip)) {
5388 $tmptooltip = explode(
':', $tooltip);
5390 $tmptooltip = array($tooltip);
5392 $out .=
$form->textwithpicto($langs->trans($name), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.str_replace(
'.',
'_', $field).
'_'.$tmptooltip[1]));
5394 $out .= $langs->trans($name);
5397 if (empty($thead) && $field && empty($disablesortlink)) {
5401 if (empty($thead) && $field) {
5402 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
5403 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
5404 $options = preg_replace(
'/&+/i',
'&', $options);
5405 if (!preg_match(
'/^&/', $options)) {
5406 $options =
'&'.$options;
5409 if (!$sortorder || ($field1 != $sortfield1)) {
5413 if (preg_match(
'/^DESC/', $sortorder)) {
5416 $sortimg .=
'<span class="nowrap">'.img_up(
"Z-A", 0,
'paddingright').
'</span>';
5418 if (preg_match(
'/^ASC/', $sortorder)) {
5421 $sortimg .=
'<span class="nowrap">'.img_down(
"A-Z", 0,
'paddingright').
'</span>';
5426 $tagend =
'</'.$tag.
'>';
5428 $out = $tagstart.$sortimg.$out.$tagend;
5443 dol_syslog(__FUNCTION__.
" is deprecated", LOG_WARNING);
5445 print
'<div class="titre">'.$title.
'</div>';
5477 function load_fiche_titre($titre, $morehtmlright =
'', $picto =
'generic', $pictoisfullpath = 0, $id =
'', $morecssontable =
'', $morehtmlcenter =
'')
5483 if ($picto ==
'setup') {
5488 $return .=
'<table '.($id ?
'id="'.$id.
'" ' :
'').
'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ?
' '.$morecssontable :
'').
'">';
5489 $return .=
'<tr class="titre">';
5491 $return .=
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).
'</td>';
5493 $return .=
'<td class="nobordernopadding valignmiddle col-title">';
5494 $return .=
'<div class="titre inline-block">'.$titre.
'</div>';
5497 $return .=
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
5500 $return .=
'<td class="nobordernopadding titre_right wordbreakimp right valignmiddle col-right">'.$morehtmlright.
'</td>';
5502 $return .=
'</tr></table>'.
"\n";
5530 function 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 =
'')
5532 global $conf, $langs;
5535 $savtotalnboflines = $totalnboflines;
5536 $totalnboflines = abs((
int) $totalnboflines);
5538 $page = (int) $page;
5540 if ($picto ==
'setup') {
5541 $picto =
'title_setup.png';
5543 if (($conf->browser->name ==
'ie') && $picto ==
'generic') {
5544 $picto =
'title.gif';
5547 $limit = $conf->liste_limit;
5550 if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
5558 print
"<!-- Begin title -->\n";
5559 print
'<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ?
' '.$morecss :
'').
'"><tr>';
5563 if ($picto && $titre) {
5564 print
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath).
'</td>';
5567 print
'<td class="nobordernopadding valignmiddle col-title">';
5568 print
'<div class="titre inline-block">'.$titre;
5569 if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines !=
'') {
5570 print
'<span class="opacitymedium colorblack paddingleft">('.$totalnboflines.
')</span>';
5572 print
'</div></td>';
5575 if ($morehtmlcenter && empty($conf->dol_optimize_smallscreen)) {
5576 print
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
5580 print
'<td class="nobordernopadding valignmiddle right col-right">';
5581 print
'<input type="hidden" name="pageplusoneold" value="'.((int) $page + 1).
'">';
5583 $options .=
"&sortfield=".urlencode($sortfield);
5586 $options .=
"&sortorder=".urlencode($sortorder);
5590 if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
5591 if ($totalnboflines) {
5593 $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 0);
5596 $nbpages = ceil($totalnboflines / $limit);
5600 $cpt = ($page - $maxnbofpage);
5606 if (empty($pagenavastextinput)) {
5607 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page=0'.$options.
'">1</a></li>';
5609 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
5610 } elseif ($cpt == 2) {
5611 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page=1'.$options.
'">2</a></li>';
5617 if ($pagenavastextinput) {
5618 if ($cpt == $page) {
5619 $pagelist .=
'<li class="pagination"><input type="text" class="'.($totalnboflines > 100 ?
'width40' :
'width25').
' center pageplusone" name="pageplusone" value="'.($page + 1).
'"></li>';
5623 if ($cpt == $page) {
5624 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
'</span></li>';
5626 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.$cpt.$options.
'">'.($cpt + 1).
'</a></li>';
5630 }
while ($cpt < $nbpages && $cpt <= ($page + $maxnbofpage));
5632 if (empty($pagenavastextinput)) {
5633 if ($cpt < $nbpages) {
5634 if ($cpt < $nbpages - 2) {
5635 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
5636 } elseif ($cpt == $nbpages - 2) {
5637 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.($nbpages - 2).$options.
'">'.($nbpages - 1).
'</a></li>';
5639 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
5643 $pagelist .=
'<li class="pagination paginationlastpage"><a href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
5646 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
"</li>";
5650 if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
5651 print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow, $hidenavigation);
5655 if ($pagenavastextinput) {
5662 print
'</table>'.
"\n";
5665 if ($morehtmlcenter && !empty($conf->dol_optimize_smallscreen)) {
5666 print
'<div class="nobordernopadding marginbottomonly center valignmiddle col-center centpercent">'.$morehtmlcenter.
'</div>';
5669 print
"<!-- End title -->\n\n";
5688 function print_fleche_navigation($page, $file, $options =
'', $nextpage = 0, $betweenarrows =
'', $afterarrows =
'', $limit = -1, $totalnboflines = 0, $hideselectlimit = 0, $beforearrows =
'', $hidenavigation = 0)
5690 global $conf, $langs;
5692 print
'<div class="pagination"><ul>';
5693 if ($beforearrows) {
5694 print
'<li class="paginationbeforearrows">';
5695 print $beforearrows;
5699 if (empty($hidenavigation)) {
5700 if ((
int) $limit > 0 && empty($hideselectlimit)) {
5701 $pagesizechoices =
'10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000';
5702 $pagesizechoices .=
',5000:5000,10000:10000,20000:20000';
5705 if (!empty($conf->global->MAIN_PAGESIZE_CHOICES)) {
5706 $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES;
5709 print
'<li class="pagination">';
5710 print
'<select class="flat selectlimit" name="limit" title="'.dol_escape_htmltag($langs->trans(
"MaxNbOfRecordPerPage")).
'">';
5711 $tmpchoice = explode(
',', $pagesizechoices);
5712 $tmpkey = $limit.
':'.$limit;
5713 if (!in_array($tmpkey, $tmpchoice)) {
5714 $tmpchoice[] = $tmpkey;
5716 $tmpkey = $conf->liste_limit.
':'.$conf->liste_limit;
5717 if (!in_array($tmpkey, $tmpchoice)) {
5718 $tmpchoice[] = $tmpkey;
5720 asort($tmpchoice, SORT_NUMERIC);
5721 foreach ($tmpchoice as $val) {
5723 $tmp = explode(
':', $val);
5726 if ($key !=
'' && $val !=
'') {
5727 if ((
int) $key == (
int) $limit) {
5728 $selected =
' selected="selected"';
5730 print
'<option name="'.$key.
'"'.$selected.
'>'.
dol_escape_htmltag($val).
'</option>'.
"\n";
5734 if ($conf->use_javascript_ajax) {
5735 print
'<!-- JS CODE TO ENABLE select limit to launch submit of page -->
5737 jQuery(document).ready(function () {
5738 jQuery(".selectlimit").change(function() {
5739 console.log("Change limit. Send submit");
5740 $(this).parents(\'form:first\').submit();
5749 print
'<li class="pagination paginationpage paginationpageleft"><a class="paginationprevious" href="'.$file.
'?page='.($page - 1).$options.
'"><i class="fa fa-chevron-left" title="'.
dol_escape_htmltag($langs->trans(
"Previous")).
'"></i></a></li>';
5751 if ($betweenarrows) {
5752 print
'<!--<div class="betweenarrows nowraponall inline-block">-->';
5753 print $betweenarrows;
5754 print
'<!--</div>-->';
5756 if ($nextpage > 0) {
5757 print
'<li class="pagination paginationpage paginationpageright"><a class="paginationnext" href="'.$file.
'?page='.($page + 1).$options.
'"><i class="fa fa-chevron-right" title="'.
dol_escape_htmltag($langs->trans(
"Next")).
'"></i></a></li>';
5760 print
'<li class="paginationafterarrows">';
5765 print
'</ul></div>'.
"\n";
5780 function vatrate($rate, $addpercent =
false, $info_bits = 0, $usestarfornpr = 0, $html = 0)
5784 if (preg_match(
'/%/', $rate)) {
5785 $rate = str_replace(
'%',
'', $rate);
5789 if (preg_match(
'/\((.*)\)/', $rate, $reg)) {
5790 $morelabel =
' ('.$reg[1].
')';
5791 $rate = preg_replace(
'/\s*'.preg_quote($morelabel,
'/').
'/',
'', $rate);
5792 $morelabel =
' '.($html ?
'<span class="opacitymedium">' :
'').
'('.$reg[1].
')'.($html ?
'</span>' :
'');
5794 if (preg_match(
'/\*/', $rate)) {
5795 $rate = str_replace(
'*',
'', $rate);
5800 if (!preg_match(
'/\//', $rate)) {
5801 $ret =
price($rate, 0,
'', 0, 0).($addpercent ?
'%' :
'');
5804 $ret = $rate.($addpercent ?
'%' :
'');
5806 if (($info_bits & 1) && $usestarfornpr >= 0) {
5829 function price($amount,
$form = 0, $outlangs =
'', $trunc = 1, $rounding = -1, $forcerounding = -1, $currency_code =
'')
5831 global $langs, $conf;
5834 if (empty($amount)) {
5837 $amount = (is_numeric($amount) ? $amount : 0);
5838 if ($rounding == -1) {
5839 $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
5841 $nbdecimal = $rounding;
5843 if ($outlangs ===
'none') {
5853 if (!is_object($outlangs)) {
5857 if ($outlangs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
5858 $dec = $outlangs->transnoentitiesnoconv(
"SeparatorDecimal");
5860 if ($outlangs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
5861 $thousand = $outlangs->transnoentitiesnoconv(
"SeparatorThousand");
5863 if ($thousand ==
'None') {
5865 } elseif ($thousand ==
'Space') {
5872 $amount = str_replace(
',',
'.', $amount);
5874 $datas = explode(
'.', $amount);
5875 $decpart = isset($datas[1]) ? $datas[1] :
'';
5876 $decpart = preg_replace(
'/0+$/i',
'', $decpart);
5885 if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN) {
5886 $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_SHOWN;
5887 if (preg_match(
'/\.\.\./i', $conf->global->MAIN_MAX_DECIMALS_SHOWN)) {
5894 if ((
string) $forcerounding !=
'-1') {
5895 if ($forcerounding ===
'MU') {
5896 $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_UNIT;
5897 } elseif ($forcerounding ===
'MT') {
5898 $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_TOT;
5899 } elseif ($forcerounding >= 0) {
5900 $nbdecimal = $forcerounding;
5905 $output = number_format($amount, $nbdecimal, $dec, $thousand);
5907 $output = preg_replace(
'/\s/',
' ', $output);
5908 $output = preg_replace(
'/\'/',
''', $output);
5911 $cursymbolbefore = $cursymbolafter =
'';
5912 if ($currency_code && is_object($outlangs)) {
5913 if ($currency_code ==
'auto') {
5914 $currency_code = $conf->currency;
5917 $listofcurrenciesbefore = array(
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD',
'CRC');
5918 $listoflanguagesbefore = array(
'nl_NL');
5919 if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) {
5920 $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
5922 $tmpcur = $outlangs->getCurrencySymbol($currency_code);
5923 $cursymbolafter .= ($tmpcur == $currency_code ?
' '.$tmpcur : $tmpcur);
5926 $output = $cursymbolbefore.$output.$end.($cursymbolafter ?
' ' :
'').$cursymbolafter;
5957 global $langs, $conf;
5960 if (is_null($amount)) {
5969 if (is_null($langs)) {
5973 if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
5974 $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
5976 if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
5977 $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
5980 if ($thousand ==
'None') {
5982 } elseif ($thousand ==
'Space') {
5990 if (!is_numeric($amount)) {
5991 $amount = preg_replace(
'/[a-zA-Z\/\\\*\(\)<>\_]/',
'', $amount);
5994 if ($option == 2 && $thousand ==
'.' && preg_match(
'/\.(\d\d\d)$/', (
string) $amount)) {
5995 $amount = str_replace($thousand,
'', $amount);
6001 if (is_numeric($amount)) {
6003 $temps = sprintf(
"%0.10F", $amount - intval($amount));
6004 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
6006 $amount = number_format($amount, $nbofdec, $dec, $thousand);
6011 if ($thousand !=
',' && $thousand !=
'.') {
6012 $amount = str_replace(
',',
'.', $amount);
6015 $amount = str_replace(
' ',
'', $amount);
6016 $amount = str_replace($thousand,
'', $amount);
6017 $amount = str_replace($dec,
'.', $amount);
6019 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
6025 $nbofdectoround =
'';
6026 if ($rounding ==
'MU') {
6027 $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT;
6028 } elseif ($rounding ==
'MT') {
6029 $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT;
6030 } elseif ($rounding ==
'MS') {
6031 $nbofdectoround = isset($conf->global->MAIN_MAX_DECIMALS_STOCK) ? $conf->global->MAIN_MAX_DECIMALS_STOCK : 5;
6032 } elseif ($rounding ==
'CU') {
6033 $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_UNIT, 8);
6034 } elseif ($rounding ==
'CT') {
6035 $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_TOT, 8);
6036 } elseif (is_numeric($rounding)) {
6037 $nbofdectoround = (int) $rounding;
6042 $amount = round(is_string($amount) ? (
float) $amount : $amount, $nbofdectoround);
6044 return 'ErrorBadParameterProvidedToFunction';
6050 if (is_numeric($amount)) {
6052 $temps = sprintf(
"%0.10F", $amount - intval($amount));
6053 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
6055 $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand);
6061 if ($thousand !=
',' && $thousand !=
'.') {
6062 $amount = str_replace(
',',
'.', $amount);
6065 $amount = str_replace(
' ',
'', $amount);
6066 $amount = str_replace($thousand,
'', $amount);
6067 $amount = str_replace($dec,
'.', $amount);
6069 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
6087 function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput =
'no', $use_short_label = 0)
6089 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
6091 if (($forceunitoutput ==
'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
6092 $dimension = $dimension * 1000000;
6094 } elseif (($forceunitoutput ==
'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) {
6095 $dimension = $dimension * 1000;
6097 } elseif (($forceunitoutput ==
'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) {
6098 $dimension = $dimension / 1000000;
6100 } elseif (($forceunitoutput ==
'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) {
6101 $dimension = $dimension / 1000;
6117 $ret =
price($dimension, 0, $outputlangs, 0, 0, $round);
6118 $ret .=
' '.measuringUnitString(0, $type, $unit, $use_short_label, $outputlangs);
6136 function get_localtax($vatrate, $local, $thirdparty_buyer =
"", $thirdparty_seller =
"", $vatnpr = 0)
6138 global $db, $conf, $mysoc;
6140 if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) {
6141 $thirdparty_seller = $mysoc;
6144 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);
6146 $vatratecleaned = $vatrate;
6148 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
6149 $vatratecleaned = trim($reg[1]);
6150 $vatratecode = $reg[2];
6159 if ($mysoc->country_code ==
'ES') {
6161 if (!$mysoc->localtax1_assuj || (
string) $vatratecleaned ==
"0") {
6164 if ($thirdparty_seller->id == $mysoc->id) {
6165 if (!$thirdparty_buyer->localtax1_assuj) {
6169 if (!$thirdparty_seller->localtax1_assuj) {
6177 if (!$mysoc->localtax2_assuj) {
6180 if ($thirdparty_seller->id == $mysoc->id) {
6181 if (!$thirdparty_buyer->localtax2_assuj) {
6185 if (!$thirdparty_seller->localtax2_assuj) {
6191 if ($local == 1 && !$thirdparty_seller->localtax1_assuj) {
6194 if ($local == 2 && !$thirdparty_seller->localtax2_assuj) {
6200 if (in_array($mysoc->country_code, array(
'ES'))) {
6201 $conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY = 1;
6205 if (!empty($conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY)) {
6207 if ($thirdparty_seller != $mysoc) {
6209 return $thirdparty_seller->localtax1_value;
6213 return $conf->global->MAIN_INFO_VALUE_LOCALTAX1;
6218 if ($thirdparty_seller != $mysoc) {
6221 return $thirdparty_seller->localtax2_value;
6224 if (in_array($mysoc->country_code, array(
'ES'))) {
6225 return $thirdparty_buyer->localtax2_value;
6227 return $conf->global->MAIN_INFO_VALUE_LOCALTAX2;
6234 $sql =
"SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
6235 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
6236 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdparty_seller->country_code).
"'";
6237 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
6238 if (!empty($vatratecode)) {
6239 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
6241 $sql .=
" AND t.recuperableonly = '".$db->escape($vatnpr).
"'";
6244 $resql = $db->query(
$sql);
6247 $obj = $db->fetch_object($resql);
6250 return $obj->localtax1;
6251 } elseif ($local == 2) {
6252 return $obj->localtax2;
6273 $valors = explode(
":", $tax);
6275 if (count($valors) > 1) {
6292 $sql =
" SELECT t.localtax".$local.
" as localtax";
6293 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t INNER JOIN ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid = t.fk_pays";
6294 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.active = 1 AND t.taux = (";
6295 $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";
6296 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND tt.active = 1)";
6297 $sql .=
" AND t.localtax".$local.
"_type <> '0'";
6298 $sql .=
" ORDER BY t.rowid DESC";
6300 $resql = $db->query(
$sql);
6302 $obj = $db->fetch_object($resql);
6304 return $obj->localtax;
6325 function getTaxesFromId($vatrate, $buyer =
null, $seller =
null, $firstparamisid = 1)
6329 dol_syslog(
"getTaxesFromId vat id or rate = ".$vatrate);
6332 $sql =
"SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy,";
6333 $sql .=
" t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
6334 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
6335 if ($firstparamisid) {
6336 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
6338 $vatratecleaned = $vatrate;
6341 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
6342 $vatratecleaned = $reg[1];
6343 $vatratecode = $reg[2];
6346 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
6349 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($seller->country_code).
"'";
6350 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
6352 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
6356 $resql = $db->query(
$sql);
6358 $obj = $db->fetch_object($resql);
6361 'rowid'=>$obj->rowid,
6364 'localtax1'=>$obj->localtax1,
6365 'localtax1_type'=>$obj->localtax1_type,
6366 'localtax2'=>$obj->localtax2,
6367 'localtax2_type'=>$obj->localtax2_type,
6369 'accountancy_code_sell'=>$obj->accountancy_code_sell,
6370 'accountancy_code_buy'=>$obj->accountancy_code_buy
6402 dol_syslog(
"getLocalTaxesFromRate vatrate=".$vatrate.
" local=".$local);
6405 $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";
6406 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
6407 if ($firstparamisid) {
6408 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
6410 $vatratecleaned = $vatrate;
6413 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
6414 $vatratecleaned = $reg[1];
6415 $vatratecode = $reg[2];
6418 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
6419 if (!empty($mysoc) && $mysoc->country_code ==
'ES') {
6420 $countrycodetouse = ((empty($buyer) || empty($buyer->country_code)) ? $mysoc->country_code : $buyer->country_code);
6421 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
6423 $countrycodetouse = ((empty($seller) || empty($seller->country_code)) ? $mysoc->country_code : $seller->country_code);
6424 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
6426 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
6428 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
6432 $resql = $db->query(
$sql);
6434 $obj = $db->fetch_object($resql);
6437 $vateratestring = $obj->rate.($obj->code ?
' ('.$obj->code.
')' :
'');
6440 return array($obj->localtax1_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
6441 } elseif ($local == 2) {
6442 return array($obj->localtax2_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
6444 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);
6464 global $db, $conf, $mysoc;
6466 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
6474 $product->fetch($idprod);
6476 if ($mysoc->country_code == $thirdpartytouse->country_code) {
6478 if ($idprodfournprice > 0) {
6479 $result = $product->get_buyprice($idprodfournprice, 0, 0, 0);
6481 $ret = $product->vatrate_supplier;
6482 if ($product->default_vat_code_supplier) {
6483 $ret .=
' ('.$product->default_vat_code_supplier.
')';
6489 $ret = $product->tva_tx;
6490 if ($product->default_vat_code) {
6491 $ret .=
' ('.$product->default_vat_code.
')';
6502 if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
6504 $sql =
"SELECT t.taux as vat_rate, t.code as default_vat_code";
6505 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
6506 $sql .=
" WHERE t.active = 1 AND t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdpartytouse->country_code).
"'";
6507 $sql .=
" ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC";
6508 $sql .= $db->plimit(1);
6510 $resql = $db->query(
$sql);
6512 $obj = $db->fetch_object($resql);
6514 $ret = $obj->vat_rate;
6515 if ($obj->default_vat_code) {
6516 $ret .=
' ('.$obj->default_vat_code.
')';
6528 if ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS !=
'none') {
6529 $defaulttx = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
6540 dol_syslog(
"get_product_vat_for_country: ret=".$ret);
6557 if (!class_exists(
'Product')) {
6558 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
6567 $result = $product->fetch($idprod);
6569 if ($mysoc->country_code == $thirdpartytouse->country_code) {
6583 $sql =
"SELECT taux as vat_rate, localtax1, localtax2";
6584 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
6585 $sql .=
" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdpartytouse->country_code).
"'";
6586 $sql .=
" ORDER BY t.taux DESC, t.recuperableonly ASC";
6587 $sql .= $db->plimit(1);
6589 $resql = $db->query(
$sql);
6591 $obj = $db->fetch_object($resql);
6594 $ret = $obj->localtax1;
6595 } elseif ($local == 2) {
6596 $ret = $obj->localtax2;
6604 dol_syslog(
"get_product_localtax_for_country: ret=".$ret);
6628 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
6631 $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;
6633 $seller_country_code = $thirdparty_seller->country_code;
6634 $seller_in_cee =
isInEEC($thirdparty_seller);
6636 $buyer_country_code = $thirdparty_buyer->country_code;
6637 $buyer_in_cee =
isInEEC($thirdparty_buyer);
6639 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=".(!empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC) ? $conf->global->SERVICES_ARE_ECOMMERCE_200238EC :
''));
6643 if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
6644 if ($seller_in_cee && $buyer_in_cee) {
6645 $isacompany = $thirdparty_buyer->
isACompany();
6646 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
6647 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
6661 if (!$seller_use_vat) {
6667 if (($seller_country_code == $buyer_country_code)
6668 || (in_array($seller_country_code, array(
'FR',
'MC')) && in_array($buyer_country_code, array(
'FR',
'MC')))) {
6672 if ($seller_country_code ==
'IN' &&
getDolGlobalString(
'MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA')) {
6676 if (preg_match(
'/C+S-(\d+)/', $tmpvat, $reg) && $thirdparty_seller->state_id != $thirdparty_buyer->state_id) {
6678 $tmpvat = str_replace(
"C+S",
"I", $tmpvat);
6679 } elseif (preg_match(
'/I-(\d+)/', $tmpvat, $reg) && $thirdparty_seller->state_id == $thirdparty_buyer->state_id) {
6681 $tmpvat = str_replace(
"I",
"C+S", $tmpvat);
6693 if (($seller_in_cee && $buyer_in_cee)) {
6694 $isacompany = $thirdparty_buyer->
isACompany();
6695 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
6696 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
6713 if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC) && empty($buyer_in_cee)) {
6714 $isacompany = $thirdparty_buyer->
isACompany();
6742 if ($idprodfournprice > 0) {
6743 if (!class_exists(
'ProductFournisseur')) {
6744 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
6747 $prodprice->fetch_product_fournisseur_price($idprodfournprice);
6748 return $prodprice->fourn_tva_npr;
6749 } elseif ($idprod > 0) {
6750 if (!class_exists(
'Product')) {
6751 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
6754 $prod->fetch($idprod);
6755 return $prod->tva_npr;
6778 if (!is_object($thirdparty_seller)) {
6781 if (!is_object($thirdparty_buyer)) {
6786 if ($mysoc->country_code ==
'ES') {
6787 if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) {
6792 if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) {
6795 if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj ==
'localtax1off') {
6799 } elseif ($local == 2) {
6801 if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) {
6804 if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj ==
'localtax2off') {
6809 if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
6824 function yn($yesno, $case = 1, $color = 0)
6828 $result =
'unknown';
6830 if ($yesno == 1 || (isset($yesno) && (strtolower($yesno) ==
'yes' || strtolower($yesno) ==
'true'))) {
6831 $result = $langs->trans(
'yes');
6832 if ($case == 1 || $case == 3) {
6833 $result = $langs->trans(
"Yes");
6836 $result =
'<input type="checkbox" value="1" checked disabled>';
6839 $result =
'<input type="checkbox" value="1" checked disabled> '.$result;
6843 } elseif ($yesno == 0 || strtolower($yesno) ==
'no' || strtolower($yesno) ==
'false') {
6844 $result = $langs->trans(
"no");
6845 if ($case == 1 || $case == 3) {
6846 $result = $langs->trans(
"No");
6849 $result =
'<input type="checkbox" value="0" disabled>';
6852 $result =
'<input type="checkbox" value="0" disabled> '.$result;
6858 $classname =
'error';
6862 return '<span class="'.$classname.
'">'.$result.
'</span>';
6882 function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart =
'')
6886 if (empty($modulepart) && !empty($object->module)) {
6887 $modulepart = $object->module;
6892 $arrayforoldpath = array(
'cheque',
'category',
'holiday',
'supplier_invoice',
'invoice_supplier',
'mailing',
'supplier_payment');
6894 $arrayforoldpath[] =
'product';
6896 if (!empty($level) && in_array($modulepart, $arrayforoldpath)) {
6898 if (empty($alpha)) {
6899 $num = preg_replace(
'/([^0-9])/i',
'', $num);
6901 $num = preg_replace(
'/^.*\-/i',
'', $num);
6903 $num = substr(
"000".$num, -$level);
6905 $path = substr($num, 0, 1);
6908 $path = substr($num, 1, 1).
'/'.substr($num, 0, 1);
6911 $path = substr($num, 2, 1).
'/'.substr($num, 1, 1).
'/'.substr($num, 0, 1);
6921 if (empty($withoutslash) && !empty($path)) {
6940 dol_syslog(
"functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
6943 if (@is_dir($dir_osencoded)) {
6951 if (!empty($dataroot)) {
6953 $dir = str_replace($dataroot.
'/',
'', $dir);
6954 $ccdir = $dataroot.
'/';
6957 $cdir = explode(
"/", $dir);
6958 $num = count($cdir);
6959 for ($i = 0; $i < $num; $i++) {
6961 $ccdir .=
'/'.$cdir[$i];
6963 $ccdir .= $cdir[$i];
6965 if (preg_match(
"/^.:$/", $ccdir, $regs)) {
6973 if (!@is_dir($ccdir_osencoded)) {
6974 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG);
6977 $dirmaskdec = octdec((
string) $newmask);
6978 if (empty($newmask)) {
6979 $dirmaskdec = empty($conf->global->MAIN_UMASK) ? octdec(
'0755') : octdec($conf->global->MAIN_UMASK);
6981 $dirmaskdec |= octdec(
'0111');
6982 if (!@mkdir($ccdir_osencoded, $dirmaskdec)) {
6984 dol_syslog(
"functions.lib::dol_mkdir: Fails to create directory '".$ccdir.
"' or directory already exists.", LOG_WARNING);
6987 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' created", LOG_DEBUG);
6996 return ($nberr ? -$nberr : $nbcreated);
7011 if (!empty($newmask)) {
7012 @chmod($filepath, octdec($newmask));
7013 } elseif (!empty($conf->global->MAIN_UMASK)) {
7014 @chmod($filepath, octdec($conf->global->MAIN_UMASK));
7026 return '<span class="fieldrequired">*</span>';
7046 function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
'UTF-8', $strip_tags = 0, $removedoublespaces = 1)
7048 if (is_null($stringtoclean)) {
7052 if ($removelinefeed == 2) {
7053 $stringtoclean = preg_replace(
'/<br[^>]*>(\n|\r)+/ims',
'<br>', $stringtoclean);
7055 $temp = preg_replace(
'/<br[^>]*>/i',
"\n", $stringtoclean);
7060 $temp = str_replace(
'< ',
'__ltspace__', $temp);
7063 $temp = strip_tags($temp);
7066 $pattern =
"/<[^<>]+>/";
7073 $tempbis = str_replace(
'<>',
'', $temp);
7074 $tempbis = preg_replace($pattern,
'', $tempbis);
7076 }
while ($tempbis != $temp);
7081 $temp = preg_replace(
'/<+([a-z]+)/i',
'\1', $temp);
7087 if ($removelinefeed == 1) {
7088 $temp = str_replace(array(
"\r\n",
"\r",
"\n"),
" ", $temp);
7092 if ($removedoublespaces) {
7093 while (strpos($temp,
" ")) {
7094 $temp = str_replace(
" ",
" ", $temp);
7098 $temp = str_replace(
'__ltspace__',
'< ', $temp);
7118 function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $removeclassattribute = 1, $cleanalsojavascript = 0, $allowiframe = 0, $allowed_tags = array(), $allowlink = 0)
7120 if (empty($allowed_tags)) {
7121 $allowed_tags = array(
7122 "html",
"head",
"meta",
"body",
"article",
"a",
"abbr",
"b",
"blockquote",
"br",
"cite",
"div",
"dl",
"dd",
"dt",
"em",
"font",
"img",
"ins",
"hr",
"i",
"li",
7123 "ol",
"p",
"q",
"s",
"section",
"span",
"strike",
"strong",
"title",
"table",
"tr",
"th",
"td",
"u",
"ul",
"sup",
"sub",
"blockquote",
"pre",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6"
7126 $allowed_tags[] =
"comment";
7128 if (!in_array(
'iframe', $allowed_tags)) {
7129 $allowed_tags[] =
"iframe";
7133 if (!in_array(
'link', $allowed_tags)) {
7134 $allowed_tags[] =
"link";
7138 $allowed_tags_string = join(
"><", $allowed_tags);
7139 $allowed_tags_string =
'<'.$allowed_tags_string.
'>';
7141 $stringtoclean = str_replace(
'<!DOCTYPE html>',
'__!DOCTYPE_HTML__', $stringtoclean);
7146 $stringtoclean = preg_replace(
'/<!--([^>]*)-->/',
'<comment>\1</comment>', $stringtoclean);
7148 $stringtoclean = preg_replace(
'/:/i',
':', $stringtoclean);
7149 $stringtoclean = preg_replace(
'/:|�+58|:/i',
'', $stringtoclean);
7151 $temp = strip_tags($stringtoclean, $allowed_tags_string);
7153 if ($cleanalsosomestyles) {
7154 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/i',
'', $temp);
7156 if ($removeclassattribute) {
7157 $temp = preg_replace(
'/(<[^>]+)\s+class=((["\']).*?\\3|\\w*)/i',
'\\1', $temp);
7162 if ($cleanalsojavascript) {
7163 $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);
7166 $temp = str_replace(
'__!DOCTYPE_HTML__',
'<!DOCTYPE html>', $temp);
7168 $temp = preg_replace(
'/<comment>([^>]*)<\/comment>/',
'<!--\1-->', $temp);
7186 function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes = array(
"allow",
"allowfullscreen",
"alt",
"class",
"contenteditable",
"data-html",
"frameborder",
"height",
"href",
"id",
"name",
"src",
"style",
"target",
"title",
"width"))
7188 if (class_exists(
'DOMDocument') && !empty($stringtoclean)) {
7189 $stringtoclean =
'<?xml encoding="UTF-8"><html><body>'.$stringtoclean.
'</body></html>';
7191 $dom =
new DOMDocument(
null,
'UTF-8');
7192 $dom->loadHTML($stringtoclean, LIBXML_ERR_NONE|LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD|LIBXML_NONET|LIBXML_NOWARNING|LIBXML_NOXMLDECL);
7194 if (is_object($dom)) {
7195 for ($els = $dom->getElementsByTagname(
'*'), $i = $els->length - 1; $i >= 0; $i--) {
7196 for ($attrs = $els->item($i)->attributes, $ii = $attrs->length - 1; $ii >= 0; $ii--) {
7198 if (!empty($attrs->item($ii)->name)) {
7199 if (! in_array($attrs->item($ii)->name, $allowed_attributes)) {
7201 $els->item($i)->removeAttribute($attrs->item($ii)->name);
7202 } elseif (in_array($attrs->item($ii)->name, array(
'style'))) {
7204 $valuetoclean = $attrs->item($ii)->value;
7206 if (isset($valuetoclean)) {
7208 $oldvaluetoclean = $valuetoclean;
7209 $valuetoclean = preg_replace(
'/\/\*.*\*\//m',
'', $valuetoclean);
7210 $valuetoclean = preg_replace(
'/position\s*:\s*[a-z]+/mi',
'', $valuetoclean);
7211 if ($els->item($i)->tagName ==
'a') {
7212 $valuetoclean = preg_replace(
'/display\s*:/mi',
'', $valuetoclean);
7213 $valuetoclean = preg_replace(
'/z-index\s*:/mi',
'', $valuetoclean);
7214 $valuetoclean = preg_replace(
'/\s+(top|left|right|bottom)\s*:/mi',
'', $valuetoclean);
7218 $valuetoclean = preg_replace(
'/(logout|passwordforgotten)\.php/mi',
'', $valuetoclean);
7219 $valuetoclean = preg_replace(
'/action=/mi',
'', $valuetoclean);
7220 }
while ($oldvaluetoclean != $valuetoclean);
7223 $attrs->item($ii)->value = $valuetoclean;
7230 $return = $dom->saveHTML();
7233 $return = preg_replace(
'/^'.preg_quote(
'<?xml encoding="UTF-8">',
'/').
'/',
'', $return);
7234 $return = preg_replace(
'/^'.preg_quote(
'<html><body>',
'/').
'/',
'', $return);
7235 $return = preg_replace(
'/'.preg_quote(
'</body></html>',
'/').
'$/',
'', $return);
7236 return trim($return);
7238 return $stringtoclean;
7255 $temp = $stringtoclean;
7256 foreach ($disallowed_tags as $tagtoremove) {
7257 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'>/',
'', $temp);
7258 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'\s+[^>]*>/',
'', $temp);
7261 if ($cleanalsosomestyles) {
7262 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/',
'', $temp);
7280 if ($nboflines == 1) {
7282 $firstline = preg_replace(
'/<br[^>]*>.*$/s',
'', $text);
7283 $firstline = preg_replace(
'/<div[^>]*>.*$/s',
'', $firstline);
7286 $firstline = preg_replace(
'/[\n\r].*/',
'', $text);
7291 return $firstline.(isset($firstline) && isset($text) && (strlen($firstline) != strlen($text)) ?
'...' :
'');
7295 $text = preg_replace(
'/\n/',
'', $text);
7297 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7299 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7302 $text = strtr($text, $repTable);
7303 if ($charset ==
'UTF-8') {
7304 $pattern =
'/(<br[^>]*>)/Uu';
7307 $pattern =
'/(<br[^>]*>)/U';
7309 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
7314 while (($i < $nba) && ($i < ($nboflines * 2))) {
7316 $firstline .= $a[$i];
7317 } elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) {
7318 $firstline .= ($ishtml ?
"<br>\n" :
"\n");
7323 return $firstline.(($i < $nba) ?
'...' :
'');
7339 function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml =
false)
7341 if (is_null($stringtoencode)) {
7346 return nl2br($stringtoencode, $forxml);
7348 $ret = preg_replace(
'/(\r\n|\r|\n)/i', ($forxml ?
'<br />' :
'<br>'), $stringtoencode);
7365 if (empty($nouseofiframesandbox) && !empty($conf->global->MAIN_SECURITY_USE_SANDBOX_FOR_HTMLWITHNOJS)) {
7370 return $stringtoencode;
7372 $out = $stringtoencode;
7375 $oldstringtoclean = $out;
7377 libxml_use_internal_errors(
false);
7379 if (!empty($out) && !empty($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML) && $check !=
'restricthtmlallowunvalid') {
7381 $dom =
new DOMDocument;
7385 $out =
'<div class="tricktoremove">'.$out.
'</div>';
7386 $dom->loadHTML($out, LIBXML_HTML_NODEFDTD|LIBXML_ERR_NONE|LIBXML_HTML_NOIMPLIED|LIBXML_NONET|LIBXML_NOWARNING|LIBXML_NOXMLDECL);
7387 $out = trim($dom->saveHTML());
7390 $out = preg_replace(
'/^<div class="tricktoremove">/',
'', $out);
7391 $out = preg_replace(
'/<\/div>$/',
'', $out);
7395 $out =
'InvalidHTMLString';
7400 $out = preg_replace(
'/&(tab|newline);/i',
' ', $out);
7404 $out = preg_replace(
'/'/i',
''', $out);
7409 $out = preg_replace_callback(
'/&#(x?[0-9][0-9a-f]+;?)/i',
function ($m) {
7414 $out = preg_replace(
'/&#x?[0-9]+/i',
'', $out);
7420 if (!empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)) {
7426 $out = preg_replace(
'/'/i',
"'", $out);
7427 }
while ($oldstringtoclean != $out);
7434 preg_match_all(
'/(<img|url\(|<link)/i', $out, $reg);
7435 $nbextlink = count($reg[0]);
7436 if ($nbextlink >
getDolGlobalInt(
"MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 1000)) {
7437 $out =
'TooManyLinksIntoHTMLString';
7440 if (!empty($conf->global->MAIN_DISALLOW_EXT_URL_INTO_DESCRIPTIONS) || $check ==
'restricthtmlnolink') {
7441 if ($nbextlink > 0) {
7442 $out =
'ExternalLinksNotAllowed';
7469 function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom =
'UTF-8', $removelasteolbr = 1)
7471 if (is_null($stringtoencode)) {
7475 $newstring = $stringtoencode;
7477 $newstring = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
'<br>', $newstring);
7478 if ($removelasteolbr) {
7479 $newstring = preg_replace(
'/<br>$/i',
'', $newstring);
7481 $newstring = strtr($newstring, array(
'&'=>
'__and__',
'<'=>
'__lt__',
'>'=>
'__gt__',
'"'=>
'__dquot__'));
7483 $newstring = strtr($newstring, array(
'__and__'=>
'&',
'__lt__'=>
'<',
'__gt__'=>
'>',
'__dquot__'=>
'"'));
7485 if ($removelasteolbr) {
7486 $newstring = preg_replace(
'/(\r\n|\r|\n)$/i',
'', $newstring);
7505 $ret = preg_replace(
'/'.
"\r\n".
'<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"<br>", $ret);
7506 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\r\n".
'/i',
"\r\n", $ret);
7507 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\n".
'/i',
"\n", $ret);
7508 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"\n", $ret);
7520 $ret = preg_replace(
'/ $/i',
"", $stringtodecode);
7521 $ret = preg_replace(
'/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'.
"\n".
'|'.
"\r".
')+$/i',
"", $ret);
7537 if ($keepsomeentities) {
7538 $newstring = strtr($newstring, array(
'&'=>
'__andamp__',
'<'=>
'__andlt__',
'>'=>
'__andgt__',
'"'=>
'__dquot__'));
7540 $newstring = html_entity_decode((
string) $newstring, (
int) $b, (
string) $c);
7541 if ($keepsomeentities) {
7542 $newstring = strtr($newstring, array(
'__andamp__'=>
'&',
'__andlt__'=>
'<',
'__andgt__'=>
'>',
'__dquot__'=>
'"'));
7557 function dol_htmlentities($string, $flags = ENT_QUOTES|ENT_SUBSTITUTE, $encoding =
'UTF-8', $double_encode =
false)
7559 return htmlentities($string, $flags, $encoding, $double_encode);
7576 for ($scursor = 0; $scursor < $len; $scursor++) {
7577 $ordchar = ord($s[$scursor]);
7579 if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) {
7582 } elseif ($ordchar > 126 && $ordchar < 160) {
7586 $out .= $s[$scursor];
7608 $arraystring = explode(
"\n", $s);
7609 $nb = count($arraystring);
7626 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7628 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7631 $text = strtr($text, $repTable);
7632 if ($charset ==
'UTF-8') {
7633 $pattern =
'/(<br[^>]*>)/Uu';
7636 $pattern =
'/(<br[^>]*>)/U';
7638 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
7640 $nblines = (int) floor((count($a) + 1) / 2);
7643 foreach ($a as $line) {
7646 $line_dec = html_entity_decode($line);
7648 $line_dec = wordwrap($line_dec, $maxlinesize,
'\n',
true);
7649 $nblines += substr_count($line_dec,
'\n');
7669 if (is_null($msg)) {
7674 if (preg_match(
'/<html/i', $msg)) {
7676 } elseif (preg_match(
'/<body/i', $msg)) {
7678 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
7680 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
7682 } elseif (preg_match(
'/<br/i', $msg)) {
7688 $msg = preg_replace(
'/https?:\/\/[^"\'\s]+/i',
'', $msg);
7689 if (preg_match(
'/<html/i', $msg)) {
7691 } elseif (preg_match(
'/<body/i', $msg)) {
7693 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
7695 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
7697 } elseif (preg_match(
'/<(br|hr)\/>/i', $msg)) {
7699 } elseif (preg_match(
'/<(br|hr|div|font|li|p|span|strong|table)>/i', $msg)) {
7701 } elseif (preg_match(
'/<(br|hr|div|font|li|p|span|strong|table)\s+[^<>\/]*\/?>/i', $msg)) {
7703 } elseif (preg_match(
'/<img\s+[^<>]*src[^<>]*>/i', $msg)) {
7705 } elseif (preg_match(
'/<a\s+[^<>]*href[^<>]*>/i', $msg)) {
7707 } elseif (preg_match(
'/<h[0-9]>/i', $msg)) {
7709 } elseif (preg_match(
'/&[A-Z0-9]{1,6};/i', $msg)) {
7712 } elseif (preg_match(
'/&#[0-9]{2,3};/i', $msg)) {
7736 if (!empty($invert)) {
7744 $ret .= (!empty($text1) && !empty($text2)) ? ((
dol_textishtml($text1) ||
dol_textishtml($text2)) ? ($forxml ?
"<br >\n" :
"<br>\n") :
"\n") :
"";
7764 global $db, $conf, $mysoc, $user, $extrafields;
7766 $substitutionarray = array();
7768 if ((empty($exclude) || !in_array(
'user', $exclude)) && (empty($include) || in_array(
'user', $include))) {
7772 $emailsendersignature = $user->signature;
7773 $usersignature = $user->signature;
7774 $substitutionarray = array_merge($substitutionarray, array(
7775 '__SENDEREMAIL_SIGNATURE__' => (
string) ((empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ?
dol_trunc(
'SignatureFromTheSelectedSenderProfile', 30) : $emailsendersignature) :
''),
7776 '__USER_SIGNATURE__' => (
string) (($usersignature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ?
dol_trunc(
dol_string_nohtmltag($usersignature), 30) : $usersignature) :
'')
7779 if (is_object($user)) {
7780 $substitutionarray = array_merge($substitutionarray, array(
7781 '__USER_ID__' => (
string) $user->id,
7782 '__USER_LOGIN__' => (
string) $user->login,
7783 '__USER_EMAIL__' => (
string) $user->email,
7784 '__USER_PHONE__' => (
string)
dol_print_phone($user->office_phone,
'', 0, 0,
'',
" ",
'',
'', -1),
7785 '__USER_PHONEPRO__' => (
string)
dol_print_phone($user->user_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
7786 '__USER_PHONEMOBILE__' => (
string)
dol_print_phone($user->personal_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
7787 '__USER_FAX__' => (
string) $user->office_fax,
7788 '__USER_LASTNAME__' => (
string) $user->lastname,
7789 '__USER_FIRSTNAME__' => (
string) $user->firstname,
7790 '__USER_FULLNAME__' => (
string) $user->getFullName($outputlangs),
7791 '__USER_SUPERVISOR_ID__' => (
string) ($user->fk_user ? $user->fk_user :
'0'),
7792 '__USER_JOB__' => (
string) $user->job,
7794 '__USER_VCARD_URL__' => (
string) $user->getOnlineVirtualCardUrl(
'',
'external')
7798 if ((empty($exclude) || !in_array(
'mycompany', $exclude)) && is_object($mysoc) && (empty($include) || in_array(
'mycompany', $include))) {
7799 $substitutionarray = array_merge($substitutionarray, array(
7800 '__MYCOMPANY_NAME__' => $mysoc->name,
7801 '__MYCOMPANY_EMAIL__' => $mysoc->email,
7802 '__MYCOMPANY_PHONE__' =>
dol_print_phone($mysoc->phone,
'', 0, 0,
'',
" ",
'',
'', -1),
7803 '__MYCOMPANY_FAX__' =>
dol_print_phone($mysoc->fax,
'', 0, 0,
'',
" ",
'',
'', -1),
7804 '__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
7805 '__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
7806 '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
7807 '__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
7808 '__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
7809 '__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
7810 '__MYCOMPANY_CAPITAL__' => $mysoc->capital,
7811 '__MYCOMPANY_FULLADDRESS__' => (method_exists($mysoc,
'getFullAddress') ? $mysoc->getFullAddress(1,
', ') :
''),
7812 '__MYCOMPANY_ADDRESS__' => $mysoc->address,
7813 '__MYCOMPANY_ZIP__' => $mysoc->zip,
7814 '__MYCOMPANY_TOWN__' => $mysoc->town,
7815 '__MYCOMPANY_COUNTRY__' => $mysoc->country,
7816 '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id,
7817 '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code,
7818 '__MYCOMPANY_CURRENCY_CODE__' => $conf->currency
7822 if (($onlykey || is_object($object)) && (empty($exclude) || !in_array(
'object', $exclude)) && (empty($include) || in_array(
'object', $include))) {
7824 $substitutionarray[
'__ID__'] =
'__ID__';
7825 $substitutionarray[
'__REF__'] =
'__REF__';
7826 $substitutionarray[
'__NEWREF__'] =
'__NEWREF__';
7827 $substitutionarray[
'__LABEL__'] =
'__LABEL__';
7828 $substitutionarray[
'__REF_CLIENT__'] =
'__REF_CLIENT__';
7829 $substitutionarray[
'__REF_SUPPLIER__'] =
'__REF_SUPPLIER__';
7830 $substitutionarray[
'__NOTE_PUBLIC__'] =
'__NOTE_PUBLIC__';
7831 $substitutionarray[
'__NOTE_PRIVATE__'] =
'__NOTE_PRIVATE__';
7832 $substitutionarray[
'__EXTRAFIELD_XXX__'] =
'__EXTRAFIELD_XXX__';
7835 $substitutionarray[
'__THIRDPARTY_ID__'] =
'__THIRDPARTY_ID__';
7836 $substitutionarray[
'__THIRDPARTY_NAME__'] =
'__THIRDPARTY_NAME__';
7837 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
'__THIRDPARTY_NAME_ALIAS__';
7838 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
'__THIRDPARTY_CODE_CLIENT__';
7839 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
'__THIRDPARTY_CODE_FOURNISSEUR__';
7840 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
'__THIRDPARTY_EMAIL__';
7841 $substitutionarray[
'__THIRDPARTY_PHONE__'] =
'__THIRDPARTY_PHONE__';
7842 $substitutionarray[
'__THIRDPARTY_FAX__'] =
'__THIRDPARTY_FAX__';
7843 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
'__THIRDPARTY_ADDRESS__';
7844 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
'__THIRDPARTY_ZIP__';
7845 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
'__THIRDPARTY_TOWN__';
7846 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
'__THIRDPARTY_IDPROF1__';
7847 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
'__THIRDPARTY_IDPROF2__';
7848 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
'__THIRDPARTY_IDPROF3__';
7849 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
'__THIRDPARTY_IDPROF4__';
7850 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
'__THIRDPARTY_IDPROF5__';
7851 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
'__THIRDPARTY_IDPROF6__';
7852 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
'__THIRDPARTY_TVAINTRA__';
7853 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] =
'__THIRDPARTY_NOTE_PUBLIC__';
7854 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] =
'__THIRDPARTY_NOTE_PRIVATE__';
7856 if (
isModEnabled(
'adherent') && (!is_object($object) || $object->element ==
'adherent') && (empty($exclude) || !in_array(
'member', $exclude)) && (empty($include) || in_array(
'member', $include))) {
7857 $substitutionarray[
'__MEMBER_ID__'] =
'__MEMBER_ID__';
7858 $substitutionarray[
'__MEMBER_CIVILITY__'] =
'__MEMBER_CIVILITY__';
7859 $substitutionarray[
'__MEMBER_FIRSTNAME__'] =
'__MEMBER_FIRSTNAME__';
7860 $substitutionarray[
'__MEMBER_LASTNAME__'] =
'__MEMBER_LASTNAME__';
7861 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'Login and pass of the external user account';
7866 if (
isModEnabled(
'ticket') && (!is_object($object) || $object->element ==
'ticket') && (empty($exclude) || !in_array(
'ticket', $exclude)) && (empty($include) || in_array(
'ticket', $include))) {
7867 $substitutionarray[
'__TICKET_TRACKID__'] =
'__TICKET_TRACKID__';
7868 $substitutionarray[
'__TICKET_SUBJECT__'] =
'__TICKET_SUBJECT__';
7869 $substitutionarray[
'__TICKET_TYPE__'] =
'__TICKET_TYPE__';
7870 $substitutionarray[
'__TICKET_SEVERITY__'] =
'__TICKET_SEVERITY__';
7871 $substitutionarray[
'__TICKET_CATEGORY__'] =
'__TICKET_CATEGORY__';
7872 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
'__TICKET_ANALYTIC_CODE__';
7873 $substitutionarray[
'__TICKET_MESSAGE__'] =
'__TICKET_MESSAGE__';
7874 $substitutionarray[
'__TICKET_PROGRESSION__'] =
'__TICKET_PROGRESSION__';
7875 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
'__TICKET_USER_ASSIGN__';
7878 if (
isModEnabled(
'recruitment') && (!is_object($object) || $object->element ==
'recruitmentcandidature') && (empty($exclude) || !in_array(
'recruitment', $exclude)) && (empty($include) || in_array(
'recruitment', $include))) {
7879 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
'__CANDIDATE_FULLNAME__';
7880 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] =
'__CANDIDATE_FIRSTNAME__';
7881 $substitutionarray[
'__CANDIDATE_LASTNAME__'] =
'__CANDIDATE_LASTNAME__';
7883 if (
isModEnabled(
'project') && (empty($exclude) || !in_array(
'project', $exclude)) && (empty($include) || in_array(
'project', $include))) {
7884 $substitutionarray[
'__PROJECT_ID__'] =
'__PROJECT_ID__';
7885 $substitutionarray[
'__PROJECT_REF__'] =
'__PROJECT_REF__';
7886 $substitutionarray[
'__PROJECT_NAME__'] =
'__PROJECT_NAME__';
7890 if (
isModEnabled(
'contrat') && (!is_object($object) || $object->element ==
'contract') && (empty($exclude) || !in_array(
'contract', $exclude)) && (empty($include) || in_array(
'contract', $include))) {
7891 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
'Highest date planned for a service start';
7892 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
'Highest date and hour planned for service start';
7893 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
'Lowest data for planned expiration of service';
7894 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
'Lowest date and hour for planned expiration of service';
7896 if (
isModEnabled(
"propal") && (!is_object($object) || $object->element ==
'propal') && (empty($exclude) || !in_array(
'propal', $exclude)) && (empty($include) || in_array(
'propal', $include))) {
7897 $substitutionarray[
'__ONLINE_SIGN_URL__'] =
'ToOfferALinkForOnlineSignature';
7899 if (
isModEnabled(
"ficheinter") && (!is_object($object) || $object->element ==
'fichinter') && (empty($exclude) || !in_array(
'intervention', $exclude)) && (empty($include) || in_array(
'intervention', $include))) {
7900 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] =
'ToOfferALinkForOnlineSignature';
7902 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'UrlToPayOnlineIfApplicable';
7903 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'TextAndUrlToPayOnlineIfApplicable';
7904 $substitutionarray[
'__SECUREKEYPAYMENT__'] =
'Security key (if key is not unique per record)';
7905 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
'Security key for payment on a member subscription (one key per member)';
7906 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
'Security key for payment on an order';
7907 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
'Security key for payment on an invoice';
7908 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
'Security key for payment on a service of a contract';
7910 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'Direct download url of a proposal';
7911 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'Direct download url of an order';
7912 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'Direct download url of an invoice';
7913 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'Direct download url of a contract';
7914 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'Direct download url of a supplier proposal';
7916 if (
isModEnabled(
"expedition") && (!is_object($object) || $object->element ==
'shipping')) {
7917 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
'Shipping tracking number';
7918 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
'Shipping tracking url';
7920 if (
isModEnabled(
"reception") && (!is_object($object) || $object->element ==
'reception')) {
7921 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
'Shippin tracking number of shipment';
7922 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
'Shipping tracking url';
7925 $substitutionarray[
'__ID__'] = $object->id;
7926 $substitutionarray[
'__REF__'] = $object->ref;
7927 $substitutionarray[
'__NEWREF__'] = $object->newref;
7928 $substitutionarray[
'__LABEL__'] = (isset($object->label) ? $object->label : (isset($object->title) ? $object->title :
null));
7929 $substitutionarray[
'__REF_CLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer :
null));
7930 $substitutionarray[
'__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier :
null);
7931 $substitutionarray[
'__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public :
null);
7932 $substitutionarray[
'__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private :
null);
7933 if ($object->element ==
"shipping") {
7934 $substitutionarray[
'__DATE_DELIVERY__'] = (isset($object->date_delivery) ?
dol_print_date($object->date_delivery,
'day', 0, $outputlangs) :
'');
7936 $substitutionarray[
'__DATE_DELIVERY__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
'day', 0, $outputlangs) :
'');
7938 $substitutionarray[
'__DATE_DELIVERY_DAY__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%d") :
'');
7939 $substitutionarray[
'__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%A") :
'');
7940 $substitutionarray[
'__DATE_DELIVERY_MON__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%m") :
'');
7941 $substitutionarray[
'__DATE_DELIVERY_MON_TEXT__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%b") :
'');
7942 $substitutionarray[
'__DATE_DELIVERY_YEAR__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%Y") :
'');
7943 $substitutionarray[
'__DATE_DELIVERY_HH__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%H") :
'');
7944 $substitutionarray[
'__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%M") :
'');
7945 $substitutionarray[
'__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%S") :
'');
7948 $substitutionarray[
'__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer :
null));
7949 $substitutionarray[
'__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier :
null);
7950 $substitutionarray[
'__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
'day', 0, $outputlangs) :
'');
7951 $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 :
'')) :
'');
7953 if (is_object($object) && ($object->element ==
'adherent' || $object->element ==
'member') && $object->id > 0) {
7954 $birthday = (empty($object->birth) ?
'' :
dol_print_date($object->birth,
'day'));
7956 $substitutionarray[
'__MEMBER_ID__'] = (isset($object->id) ? $object->id :
'');
7957 if (method_exists($object,
'getCivilityLabel')) {
7958 $substitutionarray[
'__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
7960 $substitutionarray[
'__MEMBER_FIRSTNAME__'] = (isset($object->firstname) ? $object->firstname :
'');
7961 $substitutionarray[
'__MEMBER_LASTNAME__'] = (isset($object->lastname) ? $object->lastname :
'');
7962 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'';
7963 if (method_exists($object,
'getFullName')) {
7964 $substitutionarray[
'__MEMBER_FULLNAME__'] = $object->getFullName($outputlangs);
7966 $substitutionarray[
'__MEMBER_COMPANY__'] = (isset($object->societe) ? $object->societe :
'');
7967 $substitutionarray[
'__MEMBER_ADDRESS__'] = (isset($object->address) ? $object->address :
'');
7968 $substitutionarray[
'__MEMBER_ZIP__'] = (isset($object->zip) ? $object->zip :
'');
7969 $substitutionarray[
'__MEMBER_TOWN__'] = (isset($object->town) ? $object->town :
'');
7970 $substitutionarray[
'__MEMBER_COUNTRY__'] = (isset($object->country) ? $object->country :
'');
7971 $substitutionarray[
'__MEMBER_EMAIL__'] = (isset($object->email) ? $object->email :
'');
7972 $substitutionarray[
'__MEMBER_BIRTH__'] = (isset($birthday) ? $birthday :
'');
7973 $substitutionarray[
'__MEMBER_PHOTO__'] = (isset($object->photo) ? $object->photo :
'');
7974 $substitutionarray[
'__MEMBER_LOGIN__'] = (isset($object->login) ? $object->login :
'');
7975 $substitutionarray[
'__MEMBER_PASSWORD__'] = (isset($object->pass) ? $object->pass :
'');
7976 $substitutionarray[
'__MEMBER_PHONE__'] = (isset($object->phone) ?
dol_print_phone($object->phone) :
'');
7977 $substitutionarray[
'__MEMBER_PHONEPRO__'] = (isset($object->phone_perso) ?
dol_print_phone($object->phone_perso) :
'');
7978 $substitutionarray[
'__MEMBER_PHONEMOBILE__'] = (isset($object->phone_mobile) ?
dol_print_phone($object->phone_mobile) :
'');
7979 $substitutionarray[
'__MEMBER_TYPE__'] = (isset($object->type) ? $object->type :
'');
7980 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE__'] =
dol_print_date($object->first_subscription_date,
'dayrfc');
7981 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = (isset($object->first_subscription_date_start) ?
dol_print_date($object->first_subscription_date_start,
'dayrfc') :
'');
7982 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = (isset($object->first_subscription_date_end) ?
dol_print_date($object->first_subscription_date_end,
'dayrfc') :
'');
7983 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE__'] =
dol_print_date($object->last_subscription_date,
'dayrfc');
7984 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] =
dol_print_date($object->last_subscription_date_start,
'dayrfc');
7985 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] =
dol_print_date($object->last_subscription_date_end,
'dayrfc');
7988 if (is_object($object) && $object->element ==
'societe') {
7989 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object($object) ? $object->id :
'');
7990 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object($object) ? $object->name :
'');
7991 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object($object) ? $object->name_alias :
'');
7992 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object($object) ? $object->code_client :
'');
7993 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object) ? $object->code_fournisseur :
'');
7994 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object($object) ? $object->email :
'');
7995 $substitutionarray[
'__THIRDPARTY_PHONE__'] = (is_object($object) ?
dol_print_phone($object->phone) :
'');
7996 $substitutionarray[
'__THIRDPARTY_FAX__'] = (is_object($object) ?
dol_print_phone($object->fax) :
'');
7997 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object($object) ? $object->address :
'');
7998 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object($object) ? $object->zip :
'');
7999 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object($object) ? $object->town :
'');
8000 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object($object) ? $object->country_id :
'');
8001 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object) ? $object->country_code :
'');
8002 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object($object) ? $object->idprof1 :
'');
8003 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object($object) ? $object->idprof2 :
'');
8004 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object($object) ? $object->idprof3 :
'');
8005 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object($object) ? $object->idprof4 :
'');
8006 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object($object) ? $object->idprof5 :
'');
8007 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object($object) ? $object->idprof6 :
'');
8008 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object($object) ? $object->tva_intra :
'');
8009 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object) ?
dol_htmlentitiesbr($object->note_public) :
'');
8010 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object) ?
dol_htmlentitiesbr($object->note_private) :
'');
8011 } elseif (is_object($object->thirdparty)) {
8012 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->id :
'');
8013 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object($object->thirdparty) ? $object->thirdparty->name :
'');
8014 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty) ? $object->thirdparty->name_alias :
'');
8015 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_client :
'');
8016 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_fournisseur :
'');
8017 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty) ? $object->thirdparty->email :
'');
8018 $substitutionarray[
'__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty) ?
dol_print_phone($object->thirdparty->phone) :
'');
8019 $substitutionarray[
'__THIRDPARTY_FAX__'] = (is_object($object->thirdparty) ?
dol_print_phone($object->thirdparty->fax) :
'');
8020 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty) ? $object->thirdparty->address :
'');
8021 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty) ? $object->thirdparty->zip :
'');
8022 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty) ? $object->thirdparty->town :
'');
8023 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_id :
'');
8024 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_code :
'');
8025 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof1 :
'');
8026 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof2 :
'');
8027 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof3 :
'');
8028 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof4 :
'');
8029 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof5 :
'');
8030 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof6 :
'');
8031 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty) ? $object->thirdparty->tva_intra :
'');
8032 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object->thirdparty) ?
dol_htmlentitiesbr($object->thirdparty->note_public) :
'');
8033 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object->thirdparty) ?
dol_htmlentitiesbr($object->thirdparty->note_private) :
'');
8036 if (is_object($object) && $object->element ==
'recruitmentcandidature') {
8037 $substitutionarray[
'__CANDIDATE_FULLNAME__'] = $object->getFullName($outputlangs);
8038 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname :
'';
8039 $substitutionarray[
'__CANDIDATE_LASTNAME__'] = isset($object->lastname) ? $object->lastname :
'';
8041 if (is_object($object) && $object->element ==
'conferenceorboothattendee') {
8042 $substitutionarray[
'__ATTENDEE_FULLNAME__'] = $object->getFullName($outputlangs);
8043 $substitutionarray[
'__ATTENDEE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname :
'';
8044 $substitutionarray[
'__ATTENDEE_LASTNAME__'] = isset($object->lastname) ? $object->lastname :
'';
8047 if (is_object($object->project)) {
8048 $substitutionarray[
'__PROJECT_ID__'] = (is_object($object->project) ? $object->project->id :
'');
8049 $substitutionarray[
'__PROJECT_REF__'] = (is_object($object->project) ? $object->project->ref :
'');
8050 $substitutionarray[
'__PROJECT_NAME__'] = (is_object($object->project) ? $object->project->title :
'');
8052 if (is_object($object->projet)) {
8053 $substitutionarray[
'__PROJECT_ID__'] = (is_object($object->projet) ? $object->projet->id :
'');
8054 $substitutionarray[
'__PROJECT_REF__'] = (is_object($object->projet) ? $object->projet->ref :
'');
8055 $substitutionarray[
'__PROJECT_NAME__'] = (is_object($object->projet) ? $object->projet->title :
'');
8057 if (is_object($object) && $object->element ==
'project') {
8058 $substitutionarray[
'__PROJECT_NAME__'] = $object->title;
8061 if (is_object($object) && $object->element ==
'shipping') {
8062 $substitutionarray[
'__SHIPPINGTRACKNUM__'] = $object->tracking_number;
8063 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] = $object->tracking_url;
8065 if (is_object($object) && $object->element ==
'reception') {
8066 $substitutionarray[
'__RECEPTIONTRACKNUM__'] = $object->tracking_number;
8067 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] = $object->tracking_url;
8070 if (is_object($object) && $object->element ==
'contrat' && $object->id > 0 && is_array($object->lines)) {
8071 $dateplannedstart =
'';
8072 $datenextexpiration =
'';
8073 foreach ($object->lines as $line) {
8074 if ($line->date_start > $dateplannedstart) {
8075 $dateplannedstart = $line->date_start;
8077 if ($line->statut == 4 && $line->date_end && (!$datenextexpiration || $line->date_end < $datenextexpiration)) {
8078 $datenextexpiration = $line->date_end;
8081 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
dol_print_date($dateplannedstart,
'dayrfc');
8082 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
dol_print_date($dateplannedstart,
'standard');
8083 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
dol_print_date($datenextexpiration,
'dayrfc');
8084 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
dol_print_date($datenextexpiration,
'standard');
8087 if (is_object($object) && $object->element ==
'ticket') {
8088 $substitutionarray[
'__TICKET_TRACKID__'] = $object->track_id;
8089 $substitutionarray[
'__REF__'] = $object->ref;
8090 $substitutionarray[
'__TICKET_SUBJECT__'] = $object->subject;
8091 $substitutionarray[
'__TICKET_TYPE__'] = $object->type_code;
8092 $substitutionarray[
'__TICKET_SEVERITY__'] = $object->severity_code;
8093 $substitutionarray[
'__TICKET_CATEGORY__'] = $object->category_code;
8094 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] = $object->category_code;
8095 $substitutionarray[
'__TICKET_MESSAGE__'] = $object->message;
8096 $substitutionarray[
'__TICKET_PROGRESSION__'] = $object->progress;
8097 $userstat =
new User($db);
8098 if ($object->fk_user_assign > 0) {
8099 $userstat->fetch($object->fk_user_assign);
8100 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
8103 if ($object->fk_user_create > 0) {
8104 $userstat->fetch($object->fk_user_create);
8105 $substitutionarray[
'__USER_CREATE__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
8110 if ($object->table_element && $object->id > 0) {
8111 if (!is_object($extrafields)) {
8114 $extrafields->fetch_name_optionals_label($object->table_element,
true);
8116 if ($object->fetch_optionals() > 0) {
8117 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label']) > 0) {
8118 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $label) {
8119 if ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'date') {
8120 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_date($object->array_options[
'options_'.$key],
'day');
8121 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] =
dol_print_date($object->array_options[
'options_'.$key],
'day',
'tzserver', $outputlangs);
8122 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] =
dol_print_date($object->array_options[
'options_'.$key],
'dayrfc');
8123 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'datetime') {
8124 $datetime = $object->array_options[
'options_'.$key];
8125 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
8126 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
8127 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_DAY_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'day',
'tzserver', $outputlangs) :
'');
8128 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
8129 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'phone') {
8130 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_phone($object->array_options[
'options_'.$key]);
8131 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'price') {
8132 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = $object->array_options[
'options_'.$key];
8133 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATED__'] =
price($object->array_options[
'options_'.$key]);
8134 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separator') {
8135 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = !empty($object->array_options[
'options_'.$key]) ? $object->array_options[
'options_'.$key] :
'';
8144 if (empty($substitutionarray[
'__REF__'])) {
8148 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
8149 $outputlangs->loadLangs(array(
'paypal',
'other'));
8152 $typeforonlinepayment =
'free';
8153 if (is_object($object) && $object->element ==
'commande') {
8154 $typeforonlinepayment =
'order';
8156 if (is_object($object) && $object->element ==
'facture') {
8157 $typeforonlinepayment =
'invoice';
8159 if (is_object($object) && $object->element ==
'member') {
8160 $typeforonlinepayment =
'member';
8161 if (!empty($object->last_subscription_amount)) {
8162 $amounttouse = $object->last_subscription_amount;
8165 if (is_object($object) && $object->element ==
'contrat') {
8166 $typeforonlinepayment =
'contract';
8168 if (is_object($object) && $object->element ==
'fichinter') {
8169 $typeforonlinepayment =
'ficheinter';
8172 $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray[
'__REF__'], $amounttouse);
8176 if ($object->id > 0) {
8177 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ?str_replace(
'\n',
"\n", $outputlangs->trans(
"PredefinedMailContentLink", $paymenturl)) :
'');
8178 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] = $paymenturl;
8180 if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'propal') {
8181 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
8183 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'';
8185 if (!empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'commande') {
8186 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element);
8188 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'';
8190 if (!empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'facture') {
8191 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element);
8193 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'';
8195 if (!empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'contrat') {
8196 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] = $object->getLastMainDocLink($object->element);
8198 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'';
8200 if (!empty($conf->global->FICHINTER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'fichinter') {
8201 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] = $object->getLastMainDocLink($object->element);
8203 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] =
'';
8205 if (!empty($conf->global->SUPPLIER_PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'supplier_proposal') {
8206 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
8208 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'';
8211 if (is_object($object) && $object->element ==
'propal') {
8212 $substitutionarray[
'__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/comm/propal/card.php?id=".$object->id;
8213 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
8214 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'proposal', $object->ref);
8216 if (is_object($object) && $object->element ==
'commande') {
8217 $substitutionarray[
'__URL_ORDER__'] = DOL_MAIN_URL_ROOT.
"/commande/card.php?id=".$object->id;
8219 if (is_object($object) && $object->element ==
'facture') {
8220 $substitutionarray[
'__URL_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/compta/facture/card.php?id=".$object->id;
8222 if (is_object($object) && $object->element ==
'contrat') {
8223 $substitutionarray[
'__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT.
"/contrat/card.php?id=".$object->id;
8224 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
8225 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'contract', $object->ref);
8227 if (is_object($object) && $object->element ==
'fichinter') {
8228 $substitutionarray[
'__URL_FICHINTER__'] = DOL_MAIN_URL_ROOT.
"/fichinter/card.php?id=".$object->id;
8229 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
8230 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0,
'fichinter', $object->ref);
8232 if (is_object($object) && $object->element ==
'supplier_proposal') {
8233 $substitutionarray[
'__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/supplier_proposal/card.php?id=".$object->id;
8235 if (is_object($object) && $object->element ==
'shipping') {
8236 $substitutionarray[
'__URL_SHIPMENT__'] = DOL_MAIN_URL_ROOT.
"/expedition/card.php?id=".$object->id;
8240 if (is_object($object) && $object->element ==
'action') {
8241 $substitutionarray[
'__EVENT_LABEL__'] = $object->label;
8242 $substitutionarray[
'__EVENT_DATE__'] =
dol_print_date($object->datep,
'%A %d %b %Y');
8243 $substitutionarray[
'__EVENT_TIME__'] =
dol_print_date($object->datep,
'%H:%M:%S');
8247 if ((empty($exclude) || !in_array(
'objectamount', $exclude)) && (empty($include) || in_array(
'objectamount', $include))) {
8248 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functionsnumtoword.lib.php';
8250 $substitutionarray[
'__DATE_YMD__'] = is_object($object) ? (isset($object->date) ?
dol_print_date($object->date,
'day', 0, $outputlangs) :
null) :
'';
8251 $substitutionarray[
'__DATE_DUE_YMD__'] = is_object($object) ? (isset($object->date_lim_reglement) ?
dol_print_date($object->date_lim_reglement,
'day', 0, $outputlangs) :
null) :
'';
8253 $already_payed_all = 0;
8254 if (is_object($object) && ($object instanceof
Facture)) {
8255 $already_payed_all = $object->sumpayed + $object->sumdeposit + $object->sumcreditnote;
8258 $substitutionarray[
'__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht :
'';
8260 $substitutionarray[
'__AMOUNT__'] = is_object($object) ? $object->total_ttc :
'';
8261 $substitutionarray[
'__AMOUNT_TEXT__'] = is_object($object) ?
dol_convertToWord($object->total_ttc, $outputlangs,
'',
true) :
'';
8262 $substitutionarray[
'__AMOUNT_TEXTCURRENCY__'] = is_object($object) ?
dol_convertToWord($object->total_ttc, $outputlangs, $conf->currency,
true) :
'';
8264 $substitutionarray[
'__AMOUNT_REMAIN__'] = is_object($object) ?
price2num($object->total_ttc - $already_payed_all,
'MT') :
'';
8266 $substitutionarray[
'__AMOUNT_VAT__'] = is_object($object) ? (isset($object->total_vat) ? $object->total_vat : $object->total_tva) :
'';
8267 $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)) :
'';
8268 $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)) :
'';
8270 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
8271 $substitutionarray[
'__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 :
'';
8273 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
8274 $substitutionarray[
'__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 :
'';
8278 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object) ? ($object->total_ht ?
price($object->total_ht, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8279 $substitutionarray[
'__AMOUNT_FORMATED__'] = is_object($object) ? ($object->total_ttc ?
price($object->total_ttc, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8280 $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) :
'';
8281 $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)) :
'';
8282 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
8283 $substitutionarray[
'__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? ($object->total_localtax1 ?
price($object->total_localtax1, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8285 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
8286 $substitutionarray[
'__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? ($object->total_localtax2 ?
price($object->total_localtax2, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8289 $substitutionarray[
'__AMOUNT_MULTICURRENCY__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ? $object->multicurrency_total_ttc :
'';
8290 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXT__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ?
dol_convertToWord($object->multicurrency_total_ttc, $outputlangs,
'',
true) :
'';
8291 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXTCURRENCY__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ?
dol_convertToWord($object->multicurrency_total_ttc, $outputlangs, $object->multicurrency_code,
true) :
'';
8295 if ($onlykey != 2) {
8296 $substitutionarray[
'__TOTAL_TTC__'] = is_object($object) ? $object->total_ttc :
'';
8297 $substitutionarray[
'__TOTAL_HT__'] = is_object($object) ? $object->total_ht :
'';
8298 $substitutionarray[
'__TOTAL_VAT__'] = is_object($object) ? (isset($object->total_vat) ? $object->total_vat : $object->total_tva) :
'';
8303 if ((empty($exclude) || !in_array(
'date', $exclude)) && (empty($include) || in_array(
'date', $include))) {
8304 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
8314 $daytext = $outputlangs->trans(
'Day'.$tmp[
'wday']);
8316 $substitutionarray = array_merge($substitutionarray, array(
8317 '__NOW_TMS__' => (
int) $now,
8318 '__NOW_TMS_YMD__' =>
dol_print_date($now,
'day', 0, $outputlangs),
8319 '__DAY__' => (
string) $tmp[
'mday'],
8320 '__DAY_TEXT__' => $daytext,
8321 '__DAY_TEXT_SHORT__' =>
dol_trunc($daytext, 3,
'right',
'UTF-8', 1),
8322 '__DAY_TEXT_MIN__' =>
dol_trunc($daytext, 1,
'right',
'UTF-8', 1),
8323 '__MONTH__' => (
string) $tmp[
'mon'],
8324 '__MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp[
'mon'])),
8325 '__MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp[
'mon'])),
8326 '__MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp[
'mon'])),
8327 '__YEAR__' => (
string) $tmp[
'year'],
8328 '__PREVIOUS_DAY__' => (
string) $tmp2[
'day'],
8329 '__PREVIOUS_MONTH__' => (
string) $tmp3[
'month'],
8330 '__PREVIOUS_YEAR__' => (
string) ($tmp[
'year'] - 1),
8331 '__NEXT_DAY__' => (
string) $tmp4[
'day'],
8332 '__NEXT_MONTH__' => (
string) $tmp5[
'month'],
8333 '__NEXT_YEAR__' => (
string) ($tmp[
'year'] + 1),
8338 $substitutionarray = array_merge($substitutionarray, array(
'__ENTITY_ID__' => $conf->entity));
8340 if ((empty($exclude) || !in_array(
'system', $exclude)) && (empty($include) || in_array(
'user', $include))) {
8341 $substitutionarray[
'__DOL_MAIN_URL_ROOT__'] = DOL_MAIN_URL_ROOT;
8342 $substitutionarray[
'__(AnyTranslationKey)__'] = $outputlangs->trans(
'TranslationOfKey');
8343 $substitutionarray[
'__(AnyTranslationKey|langfile)__'] = $outputlangs->trans(
'TranslationOfKey').
' (load also language file before)';
8344 $substitutionarray[
'__[AnyConstantKey]__'] = $outputlangs->trans(
'ValueOfConstantKey');
8347 return $substitutionarray;
8366 function make_substitutions($text, $substitutionarray, $outputlangs =
null, $converttextinhtmlifnecessary = 0)
8368 global $conf, $langs;
8370 if (!is_array($substitutionarray)) {
8371 return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
8374 if (empty($outputlangs)) {
8375 $outputlangs = $langs;
8385 if (is_object($outputlangs)) {
8387 while (preg_match(
'/__\(([^\)]+)\)__/', $text, $reg)) {
8389 $tmp = explode(
'|', $reg[1]);
8390 if (!empty($tmp[1])) {
8391 $outputlangs->load($tmp[1]);
8394 $value = $outputlangs->transnoentitiesnoconv($reg[1]);
8396 if (empty($converttextinhtmlifnecessary)) {
8398 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
8412 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $value, $text);
8420 while (preg_match(
'/__\[([^\]]+)\]__/', $text, $reg)) {
8421 $keyfound = $reg[1];
8423 $value =
'*****forbidden*****';
8425 $value = empty($conf->global->$keyfound) ?
'' : $conf->global->$keyfound;
8428 if (empty($converttextinhtmlifnecessary)) {
8430 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
8443 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $value, $text);
8448 foreach ($substitutionarray as $key => $value) {
8449 if (!isset($value)) {
8453 if (($key ==
'__USER_SIGNATURE__' || $key ==
'__SENDEREMAIL_SIGNATURE__') && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) {
8457 if (empty($converttextinhtmlifnecessary)) {
8458 $text = str_replace(
"$key",
"$value", $text);
8470 $text = str_replace(
"$key",
"$value", $text);
8491 global $conf, $user;
8493 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
8498 $dirsubstitutions = array_merge(array(), (array) $conf->modules_parts[
'substitutions']);
8500 foreach ($dirsubstitutions as $reldir) {
8508 $substitfiles =
dol_dir_list($dir,
'files', 0,
'functions_');
8509 foreach ($substitfiles as $substitfile) {
8511 if (preg_match(
'/functions_(.*)\.lib\.php/i', $substitfile[
'name'], $reg)) {
8514 dol_syslog(
"Library ".$substitfile[
'name'].
" found into ".$dir);
8516 require_once $dir.$substitfile[
'name'];
8518 $function_name = $module.
"_".$callfunc;
8519 if (function_exists($function_name)) {
8520 $function_name($substitutionarray, $outputlangs, $object, $parameters);
8525 if (!empty($conf->global->ODT_ENABLE_ALL_TAGS_IN_SUBSTITUTIONS)) {
8528 foreach ($substitutionarray as $key => $value) {
8529 $tags .=
'{'.$key.
'} => '.$value.
"\n";
8531 $substitutionarray = array_merge($substitutionarray, array(
'__ALL_TAGS__' => $tags));
8546 print
get_date_range($date_start, $date_end, $format, $outputlangs);
8559 function get_date_range($date_start, $date_end, $format =
'', $outputlangs =
'', $withparenthesis = 1)
8565 if (!is_object($outputlangs)) {
8566 $outputlangs = $langs;
8569 if ($date_start && $date_end) {
8570 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFromTo',
dol_print_date($date_start, $format,
false, $outputlangs),
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
8572 if ($date_start && !$date_end) {
8573 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($date_start, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
8575 if (!$date_start && $date_end) {
8576 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
8596 if ($nameorder < 0) {
8597 $nameorder = (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0);
8599 if ($nameorder == 1) {
8601 if ($firstname && $lastname) {
8605 } elseif ($nameorder == 2 || $nameorder == 3) {
8607 if (empty($ret) && $nameorder == 3) {
8612 if (empty($ret) && $nameorder == 5) {
8615 if ($nameorder == 0) {
8616 if ($firstname && $lastname) {
8640 if (!is_array($mesgs)) {
8643 if (!empty($noduplicate) && isset($_SESSION[
'dol_events'][$style]) && in_array($mesgs, $_SESSION[
'dol_events'][$style])) {
8646 $_SESSION[
'dol_events'][$style][] = $mesgs;
8650 foreach ($mesgs as $mesg) {
8652 if (!empty($noduplicate) && isset($_SESSION[
'dol_events'][$style]) && in_array($mesg, $_SESSION[
'dol_events'][$style])) {
8655 $_SESSION[
'dol_events'][$style][] = $mesg;
8675 if (empty($mesg) && empty($mesgs)) {
8676 dol_syslog(
"Try to add a message in stack, but value to add is empty message", LOG_WARNING);
8683 if (empty($messagekey) || empty($_COOKIE[
"DOLHIDEMESSAGE".$messagekey])) {
8684 if (!in_array((
string) $style, array(
'mesgs',
'warnings',
'errors'))) {
8685 dol_print_error(
'',
'Bad parameter style='.$style.
' for setEventMessages');
8687 if (empty($mesgs)) {
8690 if (!empty($mesg) && !in_array($mesg, $mesgs)) {
8711 if (isset($_SESSION[
'dol_events'][
'mesgs'])) {
8712 if (empty($disabledoutputofmessages)) {
8715 unset($_SESSION[
'dol_events'][
'mesgs']);
8718 if (isset($_SESSION[
'dol_events'][
'errors'])) {
8719 if (empty($disabledoutputofmessages)) {
8722 unset($_SESSION[
'dol_events'][
'errors']);
8726 if (isset($_SESSION[
'dol_events'][
'warnings'])) {
8727 if (empty($disabledoutputofmessages)) {
8730 unset($_SESSION[
'dol_events'][
'warnings']);
8750 global $conf, $langs;
8755 $divstart = $divend =
'';
8758 if ((empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && !preg_match(
'/<div class=".*">/i', $out)) {
8759 $divstart =
'<div class="'.$style.
' clearboth">';
8763 if ((is_array($mesgarray) && count($mesgarray)) || $mesgstring) {
8764 $langs->load(
"errors");
8766 if (is_array($mesgarray) && count($mesgarray)) {
8767 foreach ($mesgarray as $message) {
8769 $out .= $langs->trans($message);
8770 if ($ret < count($mesgarray)) {
8777 $out .= $langs->trans($mesgstring);
8783 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && empty($keepembedded)) {
8784 $return =
'<script nonce="'.getNonce().
'">
8785 $(document).ready(function() {
8786 var block = '.(!empty($conf->global->MAIN_USE_JQUERY_BLOCKUI) ?
"true" :
"false").
'
8790 /* jnotify(message, preset of message type, keepmessage) */
8792 "'.($style ==
"ok" ? 3000 : $style).
'",
8793 '.($style ==
"ok" ?
"false" :
"true").
',
8794 { remove: function (){} } );
8837 if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) {
8843 if (is_array($mesgarray)) {
8844 foreach ($mesgarray as $val) {
8845 if ($val && preg_match(
'/class="error"/i', $val)) {
8849 if ($val && preg_match(
'/class="warning"/i', $val)) {
8854 } elseif ($mesgstring && preg_match(
'/class="error"/i', $mesgstring)) {
8856 } elseif ($mesgstring && preg_match(
'/class="warning"/i', $mesgstring)) {
8859 if ($style ==
'error') {
8862 if ($style ==
'warning') {
8866 if ($iserror || $iswarning) {
8868 $mesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $mesgstring);
8869 $mesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $mesgstring);
8870 $mesgstring = preg_replace(
'/<\/div>/',
'', $mesgstring);
8872 if (is_array($mesgarray)) {
8873 $newmesgarray = array();
8874 foreach ($mesgarray as $val) {
8875 if (is_string($val)) {
8876 $tmpmesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $val);
8877 $tmpmesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $tmpmesgstring);
8878 $tmpmesgstring = preg_replace(
'/<\/div>/',
'', $tmpmesgstring);
8879 $newmesgarray[] = $tmpmesgstring;
8881 dol_syslog(
"Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING);
8884 $mesgarray = $newmesgarray;
8886 print
get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ?
'error' :
'warning'), $keepembedded);
8922 function dol_sort_array(&$array, $index, $order =
'asc', $natsort = 0, $case_sensitive = 0, $keepindex = 0)
8925 $order = strtolower($order);
8927 if (is_array($array)) {
8928 $sizearray = count($array);
8929 if ($sizearray > 0) {
8931 foreach (array_keys($array) as $key) {
8932 if (is_object($array[$key])) {
8933 $temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index;
8935 $temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index];
8937 if ($natsort == -1) {
8938 $temp[$key] =
'___'.$temp[$key];
8942 if (empty($natsort) || $natsort == -1) {
8943 if ($order ==
'asc') {
8949 if ($case_sensitive) {
8954 if ($order !=
'asc') {
8955 $temp = array_reverse($temp,
true);
8961 foreach (array_keys($temp) as $key) {
8962 (is_numeric($key) && empty($keepindex)) ? $sorted[] = $array[$key] : $sorted[$key] = $array[$key];
8980 $str = (string) $str;
8984 for ($i = 0; $i < $strLength; $i++) {
8985 if (ord($str[$i]) < 0x80) {
8987 } elseif ((ord($str[$i]) & 0xE0) == 0xC0) {
8989 } elseif ((ord($str[$i]) & 0xF0) == 0xE0) {
8991 } elseif ((ord($str[$i]) & 0xF8) == 0xF0) {
8993 } elseif ((ord($str[$i]) & 0xFC) == 0xF8) {
8995 } elseif ((ord($str[$i]) & 0xFE) == 0xFC) {
9000 for ($j = 0; $j < $n; $j++) {
9001 if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) {
9021 return preg_match(
'//u', $str) ? true :
false;
9033 if (function_exists(
'mb_check_encoding')) {
9035 if (!mb_check_encoding($str,
'ASCII')) {
9039 if (preg_match(
'/[^\x00-\x7f]/', $str)) {
9059 $tmp = ini_get(
"unicode.filesystem_encoding");
9060 if (empty($tmp) && !empty($_SERVER[
"WINDIR"])) {
9061 $tmp =
'iso-8859-1';
9066 if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING)) {
9067 $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING;
9070 if ($tmp ==
'iso-8859-1') {
9071 return mb_convert_encoding($str,
'ISO-8859-1',
'UTF-8');
9091 function dol_getIdFromCode($db, $key, $tablename, $fieldkey =
'code', $fieldid =
'id', $entityfilter = 0, $filters =
'')
9093 global $cache_codes;
9101 if (isset($cache_codes[$tablename][$key][$fieldid])) {
9102 return $cache_codes[$tablename][$key][$fieldid];
9105 dol_syslog(
'dol_getIdFromCode (value for field '.$fieldid.
' from key '.$key.
' not found into cache)', LOG_DEBUG);
9107 $sql =
"SELECT ".$fieldid.
" as valuetoget";
9108 $sql .=
" FROM ".MAIN_DB_PREFIX.$tablename;
9109 $sql .=
" WHERE ".$fieldkey.
" = '".$db->escape($key).
"'";
9110 if (!empty($entityfilter)) {
9111 $sql .=
" AND entity IN (".getEntity($tablename).
")";
9117 $resql = $db->query(
$sql);
9119 $obj = $db->fetch_object($resql);
9121 $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget;
9123 $cache_codes[$tablename][$key][$fieldid] =
'';
9126 return $cache_codes[$tablename][$key][$fieldid];
9140 global $user, $conf, $langs;
9146 if (isset($strToEvaluate) && $strToEvaluate !==
'') {
9148 $rep =
dol_eval($strToEvaluate, 1, 1,
'1');
9149 $rights = $rep && (!is_string($rep) || strpos($rep,
'Bad string syntax to evaluate') ===
false);
9165 function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring =
'1')
9168 global $db, $langs, $user, $conf, $website, $websitepage;
9169 global $action, $mainmenu, $leftmenu;
9171 global $objectoffield;
9181 if ($onlysimplestring ==
'1') {
9185 if (preg_match(
'/[^a-z0-9\s'.preg_quote(
'^$_+-.*>&|=!?():"\',/@',
'/').
']/i', $s)) {
9187 return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s;
9189 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s);
9196 } elseif ($onlysimplestring ==
'2') {
9198 if (preg_match(
'/[^a-z0-9\s'.preg_quote(
'^$_+-.*>&|=!?():"\',/@[]',
'/').
']/i', $s)) {
9200 return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s;
9202 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s);
9210 if (is_array($s) || $s ===
'Array') {
9211 return 'Bad string syntax to evaluate (value is Array) '.var_export($s,
true);
9213 if (strpos($s,
'::') !==
false) {
9215 return 'Bad string syntax to evaluate (double : char is forbidden): '.$s;
9217 dol_syslog(
'Bad string syntax to evaluate (double : char is forbidden): '.$s);
9221 if (strpos($s,
'`') !==
false) {
9223 return 'Bad string syntax to evaluate (backtick char is forbidden): '.$s;
9225 dol_syslog(
'Bad string syntax to evaluate (backtick char is forbidden): '.$s);
9229 if (preg_match(
'/[^0-9]+\.[^0-9]+/', $s)) {
9231 return 'Bad string syntax to evaluate (dot char is forbidden): '.$s;
9233 dol_syslog(
'Bad string syntax to evaluate (dot char is forbidden): '.$s);
9239 $forbiddenphpstrings = array(
'$$');
9240 $forbiddenphpstrings = array_merge($forbiddenphpstrings, array(
'_ENV',
'_SESSION',
'_COOKIE',
'_GET',
'_POST',
'_REQUEST'));
9242 $forbiddenphpfunctions = array(
"exec",
"passthru",
"shell_exec",
"system",
"proc_open",
"popen",
"eval",
"dol_eval",
"executeCLI",
"verifCond",
"base64_decode");
9243 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"fopen",
"file_put_contents",
"fputs",
"fputscsv",
"fwrite",
"fpassthru",
"require",
"include",
"mkdir",
"rmdir",
"symlink",
"touch",
"unlink",
"umask"));
9244 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"function",
"call_user_func"));
9246 $forbiddenphpregex =
'global\s+\$|\b('.implode(
'|', $forbiddenphpfunctions).
')\b';
9249 $oldstringtoclean = $s;
9250 $s = str_ireplace($forbiddenphpstrings,
'__forbiddenstring__', $s);
9251 $s = preg_replace(
'/'.$forbiddenphpregex.
'/i',
'__forbiddenstring__', $s);
9253 }
while ($oldstringtoclean != $s);
9255 if (strpos($s,
'__forbiddenstring__') !==
false) {
9256 dol_syslog(
'Bad string syntax to evaluate: '.$s, LOG_WARNING);
9258 return 'Bad string syntax to evaluate: '.$s;
9260 dol_syslog(
'Bad string syntax to evaluate: '.$s);
9268 return @eval(
'return '.$s.
';');
9270 return eval(
'return '.$s.
';');
9279 }
catch (Error $e) {
9280 $error =
'dol_eval try/catch error : ';
9281 $error .= $e->getMessage();
9294 return (trim($element) !=
'');
9307 if (empty($codelang)) {
9311 if ($codelang ==
'auto') {
9312 return '<span class="fa fa-language"></span>';
9315 $langtocountryflag = array(
9317 'ca_ES' =>
'catalonia',
9321 'sw_SW' =>
'unknown',
9331 if (isset($langtocountryflag[$codelang])) {
9332 $flagImage = $langtocountryflag[$codelang];
9334 $tmparray = explode(
'_', $codelang);
9335 $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
9338 return img_picto_common($codelang,
'flags/'.strtolower($flagImage).
'.png', $moreatt, 0, $notitlealt);
9352 if (empty($countrycode)) {
9356 if (strtoupper($countrycode) ==
'MQ') {
9359 if (strtoupper($countrycode) ==
'SE') {
9362 if (strtoupper($countrycode) ==
'CH') {
9363 if ($mysoc->country_code ==
'FR') {
9366 if ($mysoc->country_code ==
'DE') {
9369 if ($mysoc->country_code ==
'IT') {
9551 $buildprimarykeytotest = strtolower($countrycode).
'-'.strtoupper($countrycode);
9552 if (in_array($buildprimarykeytotest, $locales)) {
9553 return strtolower($countrycode).
'_'.strtoupper($countrycode);
9556 if (function_exists(
'locale_get_primary_language') && function_exists(
'locale_get_region')) {
9557 foreach ($locales as $locale) {
9558 $locale_language = locale_get_primary_language($locale);
9559 $locale_region = locale_get_region($locale);
9560 if (strtoupper($countrycode) == $locale_region) {
9562 return strtolower($locale_language).
'_'.strtoupper($locale_region);
9566 dol_syslog(
"Warning Exention php-intl is not available", LOG_WARNING);
9604 global $hookmanager, $db;
9606 if (isset($conf->modules_parts[
'tabs'][$type]) && is_array($conf->modules_parts[
'tabs'][$type])) {
9607 foreach ($conf->modules_parts[
'tabs'][$type] as $value) {
9608 $values = explode(
':', $value);
9611 if ($mode ==
'add' && !preg_match(
'/^\-/', $values[1])) {
9612 if (count($values) == 6) {
9616 if ($values[0] != $type) {
9622 if ($filterorigmodule) {
9623 if (strpos($values[3],
'@')) {
9624 if ($filterorigmodule !=
'external') {
9628 if ($filterorigmodule !=
'core') {
9633 $langs->load($values[3]);
9635 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
9637 $substitutionarray = array();
9642 $labeltemp = explode(
',', $values[2]);
9643 $label = $langs->trans($labeltemp[0]);
9645 if (!empty($labeltemp[1]) && is_object($object) && !empty($object->id)) {
9647 $classtoload = $labeltemp[1];
9648 if (class_exists($classtoload)) {
9649 $obj =
new $classtoload($db);
9650 $function = $labeltemp[3];
9651 if ($obj && $function && method_exists($obj, $function)) {
9652 $nbrec = $obj->$function($object->id, $obj);
9653 if (!empty($nbrec)) {
9654 $label .=
'<span class="badge marginleftonlyshort">'.$nbrec.
'</span>';
9661 $head[$h][0] =
dol_buildpath(preg_replace(
'/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id :
''), $values[5]), 1);
9662 $head[$h][1] = $label;
9663 $head[$h][2] = str_replace(
'+',
'', $values[1]);
9666 } elseif (count($values) == 5) {
9667 dol_syslog(
'Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
9669 if ($values[0] != $type) {
9673 if ($filterorigmodule) {
9674 if (strpos($values[3],
'@')) {
9675 if ($filterorigmodule !=
'external') {
9679 if ($filterorigmodule !=
'core') {
9684 $langs->load($values[3]);
9686 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
9687 $substitutionarray = array();
9691 $label = $langs->trans($values[2]);
9694 $head[$h][0] =
dol_buildpath(preg_replace(
'/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id :
''), $values[4]), 1);
9695 $head[$h][1] = $label;
9696 $head[$h][2] = str_replace(
'+',
'', $values[1]);
9699 } elseif ($mode ==
'remove' && preg_match(
'/^\-/', $values[1])) {
9700 if ($values[0] != $type) {
9703 $tabname = str_replace(
'-',
'', $values[1]);
9704 foreach ($head as $key => $val) {
9705 $condition = (!empty($values[3]) ?
verifCond($values[3]) : 1);
9707 if ($head[$key][2] == $tabname && $condition) {
9717 if (!empty($hookmanager)) {
9718 $parameters = array(
'object' => $object,
'mode' => $mode,
'head' => &$head,
'filterorigmodule' => $filterorigmodule);
9719 $reshook = $hookmanager->executeHooks(
'completeTabsHead', $parameters, $object);
9721 $head = $hookmanager->resArray;
9723 $head = array_merge($head, $hookmanager->resArray);
9742 global $conf, $hookmanager, $user, $debugbar;
9744 global $micro_start_time;
9746 if ($zone ==
'private') {
9747 print
"\n".
'<!-- Common footer for private page -->'.
"\n";
9749 print
"\n".
'<!-- Common footer for public page -->'.
"\n";
9753 print
"\n<!-- A div to store page_y POST parameter -->\n";
9754 print
'<div id="page_y" style="display: none;">'.(GETPOST(
'page_y') ?
GETPOST(
'page_y') :
'').
'</div>'.
"\n";
9756 $parameters = array();
9757 $reshook = $hookmanager->executeHooks(
'printCommonFooter', $parameters);
9758 if (empty($reshook)) {
9759 if (!empty($conf->global->MAIN_HTML_FOOTER)) {
9760 print $conf->global->MAIN_HTML_FOOTER.
"\n";
9764 if (!empty($conf->use_javascript_ajax)) {
9765 print
"\n<!-- A script section to add menuhider handler on backoffice, manage focus and madatory fields, tuning info, ... -->\n";
9766 print
'<script>'.
"\n";
9767 print
'jQuery(document).ready(function() {'.
"\n";
9769 if ($zone ==
'private' && empty($conf->dol_use_jmobile)) {
9771 print
'/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'.
"\n";
9772 print
'jQuery("li.menuhider").click(function(event) {';
9773 print
' if (!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'.
"\n";
9774 print
' console.log("We click on .menuhider");'.
"\n";
9775 print
' $("body").toggleClass("sidebar-collapse")'.
"\n";
9780 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"])))) {
9781 print
'/* JS CODE TO ENABLE to manage focus and mandatory form fields */'.
"\n";
9782 $relativepathstring = $_SERVER[
"PHP_SELF"];
9784 if (constant(
'DOL_URL_ROOT')) {
9785 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
9787 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
9788 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
9790 if (!empty($user->default_values[$relativepathstring][
'focus'])) {
9791 foreach ($user->default_values[$relativepathstring][
'focus'] as $defkey => $defval) {
9793 if ($defkey !=
'_noquery_') {
9794 $tmpqueryarraytohave = explode(
'&', $defkey);
9796 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
9797 $tmpquerytohaveparam = explode(
'=', $tmpquerytohave);
9799 if (!
GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] !=
GETPOST($tmpquerytohaveparam[0]))) {
9812 foreach ($defval as $paramkey => $paramval) {
9814 print
'jQuery("input[name=\''.$paramkey.
'\']
").focus();'."\n
";
9815 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").focus();'."\n
";
9816 print 'jQuery("select[
name=\
''.$paramkey.
'\']
").focus();'."\n
"; // Not really usefull, but we keep it in case of.
9821 if (!empty($user->default_values[$relativepathstring]['mandatory'])) {
9822 foreach ($user->default_values[$relativepathstring]['mandatory'] as $defkey => $defval) {
9824 if ($defkey != '_noquery_') {
9825 $tmpqueryarraytohave = explode('&', $defkey);
9827 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
9828 $tmpquerytohaveparam = explode('=', $tmpquerytohave);
9829 //print "console.log(
'".$tmpquerytohaveparam[0]." ".$tmpquerytohaveparam[1]." ".GETPOST($tmpquerytohaveparam[0])."');
";
9830 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] != GETPOST($tmpquerytohaveparam[0]))) {
9837 //var_dump($defkey.'-'.$qualified);
9843 foreach ($defval as $paramkey => $paramval) {
9844 // Add property 'required' on input
9845 print 'jQuery("input[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
9846 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
9847 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
";
9848 print 'jQuery("select[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
9849 print 'jQuery("select[
name=\
''.$paramkey.
'\'] option[value=\
'-1\']").prop(\'value\', \'\');'.
"\n";
9850 print
'jQuery("select[name=\''.$paramkey.
'\'] option[value=\
'0\']").prop(\'value\', \'\');'.
"\n";
9853 print
'jQuery(":input[name=\'' . $paramkey .
'\']
").closest("tr
").find("td:first
").addClass("fieldrequired
");' . "\n
";
9863 if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO']) || !empty($conf->global->MAIN_SHOW_TUNING_INFO)) {
9866 print 'window.console && console.log("';
9867 if (!empty($conf->global->MEMCACHED_SERVER)) {
9868 print 'MEMCACHED_SERVER=
'.$conf->global->MEMCACHED_SERVER.' -
';
9870 print 'MAIN_OPTIMIZE_SPEED=
'.(isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off
');
9871 if (!empty($micro_start_time)) { // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable.
9872 $micro_end_time = microtime(true);
9873 print ' - Build time:
'.ceil(1000 * ($micro_end_time - $micro_start_time)).' ms
';
9876 if (function_exists("memory_get_usage")) {
9877 print ' - Mem:
'.memory_get_usage(); // Do not use true here, it seems it takes the peak amount
9879 if (function_exists("memory_get_peak_usage")) {
9880 print ' - Real mem peak:
'.memory_get_peak_usage(true);
9882 if (function_exists("zend_loader_file_encoded")) {
9883 print ' - Zend encoded file:
'.(zend_loader_file_encoded() ? 'yes
' : 'no
');
9888 print "\n
".'</script>'."\n
";
9891 // TODO Add a hook here
9892 if (isModEnabled('google') && !empty($conf->global->MAIN_GOOGLE_AN_ID)) {
9893 $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID);
9894 foreach ($tmptagarray as $tmptag) {
9896 print "<!-- JS CODE TO ENABLE
for google analtics tag -->\n
";
9898 <!-- Global site tag (gtag.js) - Google Analytics -->
9899 <script nonce="'.getNonce().'" async src="https:
9901 window.dataLayer = window.dataLayer || [];
9902 function gtag(){dataLayer.push(arguments);}
9903 gtag(\
'js\', new Date());
9905 gtag(\'config\', \''.trim($tmptag).
'\');
9912 // Add Xdebug coverage of code
9913 if (defined('XDEBUGCOVERAGE
')) {
9914 print_r(xdebug_get_code_coverage());
9917 // Add DebugBar data
9918 if (!empty($user->rights->debugbar->read) && is_object($debugbar)) {
9919 $debugbar['time
']->stopMeasure('pageaftermaster
');
9920 print '<!-- Output debugbar data -->
'."\n";
9921 $renderer = $debugbar->getRenderer();
9922 print $debugbar->getRenderer()->render();
9923 } elseif (count($conf->logbuffer)) { // If there is some logs in buffer to show
9925 print "<!-- Start of log output\n";
9926 //print '<div
class=
"hidden">
'."\n";
9927 foreach ($conf->logbuffer as $logline) {
9928 print $logline."<br>\n";
9930 //print '</div>
'."\n";
9931 print "End of log output -->\n";
9945 function dolExplodeIntoArray($string, $delimiter = ';
', $kv = '=
')
9947 if (is_null($string)) {
9951 if (preg_match('/^\[.*\]$/sm
', $delimiter) || preg_match('/^\(.*\)$/sm
', $delimiter)) {
9952 // This is a regex string
9953 $newdelimiter = $delimiter;
9955 // This is a simple string
9956 $newdelimiter = preg_quote($delimiter, '/
');
9959 if ($a = preg_split('/
'.$newdelimiter.'/
', $string)) {
9961 foreach ($a as $s) { // each part
9963 if ($pos = strpos($s, $kv)) { // key/value delimiter
9964 $ka[trim(substr($s, 0, $pos))] = trim(substr($s, $pos + strlen($kv)));
9965 } else { // key delimiter not found
9983 function dol_set_focus($selector)
9985 print "\n".'<!-- Set focus onto a specific field -->
'."\n";
9986 print '<script nonce=
"'.getNonce().'">jQuery(document).ready(
function() { jQuery(
"'.dol_escape_js($selector).'").focus(); });</script>
'."\n";
9997 function dol_getmypid()
9999 if (!function_exists('getmypid
')) {
10000 return mt_rand(99900000, 99965535);
10002 return getmypid(); // May be a number on 64 bits (depending on OS)
10024 function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
10026 global $db, $langs;
10028 $value = trim($value);
10031 $value = preg_replace('/\*/
', '%
', $value); // Replace * with %
10034 $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
10037 $value = preg_replace('/\s*\|\s*/
', '|
', $value);
10039 $crits = explode(' ', $value);
10041 if (!is_array($fields)) {
10042 $fields = array($fields);
10045 $i1 = 0; // count the nb of and criteria added (all fields / criterias)
10046 foreach ($crits as $crit) { // Loop on each AND criteria
10047 $crit = trim($crit);
10048 $i2 = 0; // count the nb of valid criteria added for this this first criteria
10050 foreach ($fields as $field) {
10052 $tmpcrits = explode('|
', $crit);
10053 $i3 = 0; // count the nb of valid criteria added for this current field
10054 foreach ($tmpcrits as $tmpcrit) {
10055 if ($tmpcrit !== '0
' && empty($tmpcrit)) {
10058 $tmpcrit = trim($tmpcrit);
10060 $newres .= (($i2 > 0 || $i3 > 0) ? ' OR
' : '');
10063 $newcrit = preg_replace('/([!<>=]+)/
', '', $tmpcrit);
10066 preg_match('/([!<>=]+)/
', $tmpcrit, $reg);
10067 if (!empty($reg[1])) {
10068 $operator = $reg[1];
10070 if ($newcrit != '') {
10071 $numnewcrit = price2num($newcrit);
10072 if (is_numeric($numnewcrit)) {
10073 $newres .= $field.' '.$operator.' '.((float) $numnewcrit); // should be a numeric
10075 $newres .= '1 = 2
'; // force false, we received a corrupted data
10077 $i3++; // a criteria was added to string
10080 $i2++; // a criteria for 1 more field was added to string
10081 } elseif ($mode == 2 || $mode == -2) {
10082 $crit = preg_replace('/[^0-9,]/
', '', $crit); // ID are always integer
10083 $newres .= ($i2 > 0 ? ' OR
' : '').$field." ".($mode == -2 ? 'NOT
' : '');
10084 $newres .= $crit ? "IN (".$db->sanitize($db->escape($crit)).")" : "IN (0)";
10086 $newres .= ' OR
'.$field.' IS NULL
';
10088 $i2++; // a criteria for 1 more field was added to string
10089 } elseif ($mode == 3 || $mode == -3) {
10090 $tmparray = explode(',
', $crit);
10091 if (count($tmparray)) {
10093 foreach ($tmparray as $val) {
10096 $listofcodes .= ($listofcodes ? ',
' : '');
10097 $listofcodes .= "'".$db->escape($val)."'";
10100 $newres .= ($i2 > 0 ? ' OR
' : '').$field." ".($mode == -3 ? 'NOT
' : '')."IN (".$db->sanitize($listofcodes, 1).")";
10101 $i2++; // a criteria for 1 more field was added to string
10104 $newres .= ' OR
'.$field.' IS NULL
';
10106 } elseif ($mode == 4) {
10107 $tmparray = explode(',
', $crit);
10108 if (count($tmparray)) {
10110 foreach ($tmparray as $val) {
10113 $newres .= ($i2 > 0 ? " OR (" : "(").$field." LIKE '".$db->escape($val).",%
'";
10114 $newres .= ' OR
'.$field." = '".$db->escape($val)."'";
10115 $newres .= ' OR
'.$field." LIKE '%,
".$db->escape($val)."'";
10116 $newres .= ' OR
'.$field." LIKE '%,
".$db->escape($val).",%
'";
10118 $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)
10122 } else { // $mode=0
10123 $tmpcrits = explode('|
', $crit);
10124 $i3 = 0; // count the nb of valid criteria added for the current couple criteria/field
10125 foreach ($tmpcrits as $tmpcrit) { // loop on each OR criteria
10126 if ($tmpcrit !== '0
' && empty($tmpcrit)) {
10129 $tmpcrit = trim($tmpcrit);
10131 if ($tmpcrit == '^$
' || strpos($crit, '!
') === 0) { // If we search empty, we must combined different OR fields with AND
10132 $newres .= (($i2 > 0 || $i3 > 0) ? ' AND
' : '');
10134 $newres .= (($i2 > 0 || $i3 > 0) ? ' OR
' : '');
10137 if (preg_match('/\.(
id|
rowid)$/
', $field)) { // Special case for rowid that is sometimes a ref so used as a search field
10138 $newres .= $field." = ".(is_numeric($tmpcrit) ? ((float) $tmpcrit) : '0
');
10140 $tmpcrit2 = $tmpcrit;
10145 if (preg_match('/^!/
', $tmpcrit)) {
10146 $tmps .= $field." NOT LIKE "; // ! as exclude character
10147 $tmpcrit2 = preg_replace('/^!/
', '', $tmpcrit2);
10149 $tmps .= $field." LIKE ";
10153 if (preg_match('/^[\^\$]/', $tmpcrit)) {
10155 $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
10157 if (preg_match('/[\^\$]$/', $tmpcrit)) {
10159 $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
10162 if ($tmpcrit2 == '' || preg_match('/^!/', $tmpcrit)) {
10166 $newres .= $tmpbefore;
10167 $newres .= $db->escape($tmpcrit2);
10168 $newres .= $tmpafter;
10170 if ($tmpcrit2 == '' || preg_match('/^!/
', $tmpcrit)) {
10171 $newres .= " OR ".$field." IS NULL)";
10178 $i2++; // a criteria for 1 more field was added to string
10183 $res = $res.($res ? ' AND
' : '').($i2 > 1 ? '(
' : '').$newres.($i2 > 1 ? ')
' : '');
10187 $res = ($nofirstand ? "" : " AND ")."(".$res.")";
10198 function showDirectDownloadLink($object)
10200 global $conf, $langs;
10203 $url = $object->getLastMainDocLink($object->element);
10205 $out .= img_picto($langs->trans("PublicDownloadLinkDesc"), 'globe
').' <span
class=
"opacitymedium">
'.$langs->trans("DirectDownloadLink").'</span><br>
';
10207 $out .= '<div
class=
"urllink"><input
type=
"text" id=
"directdownloadlink" class=
"quatrevingtpercent" value=
"'.$url.'"></div>
';
10208 $out .= ajax_autoselect("directdownloadlink", 0);
10210 $out .= '<div
class=
"urllink">
'.$langs->trans("FileNotShared").'</div>
';
10224 function getImageFileNameForSize($file, $extName, $extImgTarget = '')
10226 $dirName = dirname($file);
10227 if ($dirName == '.
') {
10231 $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp|\.webp)$/i
', '', $file); // We remove extension, whatever is its case
10232 $fileName = basename($fileName);
10234 if (empty($extImgTarget)) {
10235 $extImgTarget = (preg_match('/\.jpg$/i
', $file) ? '.jpg
' : '');
10237 if (empty($extImgTarget)) {
10238 $extImgTarget = (preg_match('/\.jpeg$/i
', $file) ? '.jpeg
' : '');
10240 if (empty($extImgTarget)) {
10241 $extImgTarget = (preg_match('/\.gif$/i
', $file) ? '.gif
' : '');
10243 if (empty($extImgTarget)) {
10244 $extImgTarget = (preg_match('/\.png$/i
', $file) ? '.png
' : '');
10246 if (empty($extImgTarget)) {
10247 $extImgTarget = (preg_match('/\.bmp$/i
', $file) ? '.bmp
' : '');
10249 if (empty($extImgTarget)) {
10250 $extImgTarget = (preg_match('/\.webp$/i
', $file) ? '.webp
' : '');
10253 if (!$extImgTarget) {
10259 $subdir = 'thumbs/
';
10262 return ($dirName ? $dirName.'/
' : '').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb
10275 function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param = '')
10277 global $conf, $langs;
10279 if (empty($conf->use_javascript_ajax)) {
10283 $isAllowedForPreview = dolIsAllowedForPreview($relativepath);
10285 if ($alldata == 1) {
10286 if ($isAllowedForPreview) {
10287 return array('target
'=>'_blank
', 'css
'=>'documentpreview
', 'url
'=>DOL_URL_ROOT.'/document.php?modulepart=
'.$modulepart.'&attachment=0&file=
'.urlencode($relativepath).($param ? '&
'.$param : ''), 'mime
'=>dol_mimetype($relativepath));
10293 // old behavior, return a string
10294 if ($isAllowedForPreview) {
10295 return 'javascript:
document_preview(\
''.
dol_escape_js(DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart.
'&attachment=0&file='.urlencode($relativepath).($param ?
'&'.$param :
'')).
'\', \
''.
dol_mimetype($relativepath).
'\', \
''.
dol_escape_js($langs->trans(
'Preview')).
'\')
';
10310 function ajax_autoselect($htmlname, $addlink = '', $textonlink = 'Link')
10313 $out = '<script nonce=
"'.getNonce().'">
10314 jQuery(document).ready(
function () {
10315 jQuery(
"'.((strpos($htmlname, '.') === 0 ? '' : '#').$htmlname).'").click(
function() { jQuery(
this).select(); } );
10319 if ($textonlink === 'image
') {
10320 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.img_picto('', 'globe
').'</a>
';
10322 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.$langs->trans("Link").'</a>
';
10335 function dolIsAllowedForPreview($file)
10339 // Check .noexe extension in filename
10340 if (preg_match('/\.noexe$/i
', $file)) {
10344 // Check mime types
10345 $mime_preview = array('bmp
', 'jpeg
', 'png
', 'gif
', 'tiff
', 'pdf
', 'plain
', 'css
', 'webp
');
10346 if (!empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) {
10347 $mime_preview[] = 'svg+xml
';
10349 //$mime_preview[]='vnd.oasis.opendocument.presentation
';
10350 //$mime_preview[]='archive
';
10351 $num_mime = array_search(dol_mimetype($file, '', 1), $mime_preview);
10352 if ($num_mime !== false) {
10356 // By default, not allowed for preview
10370 function dol_mimetype($file, $default = 'application/octet-stream
', $mode = 0)
10373 $imgmime = 'other.png
';
10374 $famime = 'file-o
';
10377 $tmpfile = preg_replace('/\.noexe$/
', '', $file);
10379 // Plain text files
10380 if (preg_match('/\.txt$/i
', $tmpfile)) {
10381 $mime = 'text/plain
';
10382 $imgmime = 'text.png
';
10383 $famime = 'file-text-o
';
10385 if (preg_match('/\.rtx$/i
', $tmpfile)) {
10386 $mime = 'text/richtext
';
10387 $imgmime = 'text.png
';
10388 $famime = 'file-text-o
';
10390 if (preg_match('/\.csv$/i
', $tmpfile)) {
10391 $mime = 'text/csv
';
10392 $imgmime = 'text.png
';
10393 $famime = 'file-text-o
';
10395 if (preg_match('/\.tsv$/i
', $tmpfile)) {
10396 $mime = 'text/tab-separated-values
';
10397 $imgmime = 'text.png
';
10398 $famime = 'file-text-o
';
10400 if (preg_match('/\.(cf|
conf|log)$/i
', $tmpfile)) {
10401 $mime = 'text/plain
';
10402 $imgmime = 'text.png
';
10403 $famime = 'file-text-o
';
10405 if (preg_match('/\.ini$/i
', $tmpfile)) {
10406 $mime = 'text/plain
';
10407 $imgmime = 'text.png
';
10409 $famime = 'file-text-o
';
10411 if (preg_match('/\.md$/i
', $tmpfile)) {
10412 $mime = 'text/plain
';
10413 $imgmime = 'text.png
';
10415 $famime = 'file-text-o
';
10417 if (preg_match('/\.css$/i
', $tmpfile)) {
10418 $mime = 'text/css
';
10419 $imgmime = 'css.png
';
10421 $famime = 'file-text-o
';
10423 if (preg_match('/\.lang$/i
', $tmpfile)) {
10424 $mime = 'text/plain
';
10425 $imgmime = 'text.png
';
10427 $famime = 'file-text-o
';
10429 // Certificate files
10430 if (preg_match('/\.(crt|cer|key|pub)$/i
', $tmpfile)) {
10431 $mime = 'text/plain
';
10432 $imgmime = 'text.png
';
10433 $famime = 'file-text-o
';
10435 // XML based (HTML/XML/XAML)
10436 if (preg_match('/\.(html|htm|shtml)$/i
', $tmpfile)) {
10437 $mime = 'text/html
';
10438 $imgmime = 'html.png
';
10440 $famime = 'file-text-o
';
10442 if (preg_match('/\.(xml|xhtml)$/i
', $tmpfile)) {
10443 $mime = 'text/xml
';
10444 $imgmime = 'other.png
';
10446 $famime = 'file-text-o
';
10448 if (preg_match('/\.xaml$/i
', $tmpfile)) {
10449 $mime = 'text/xml
';
10450 $imgmime = 'other.png
';
10452 $famime = 'file-text-o
';
10455 if (preg_match('/\.bas$/i
', $tmpfile)) {
10456 $mime = 'text/plain
';
10457 $imgmime = 'text.png
';
10459 $famime = 'file-
code-o
';
10461 if (preg_match('/\.(c)$/i
', $tmpfile)) {
10462 $mime = 'text/plain
';
10463 $imgmime = 'text.png
';
10465 $famime = 'file-
code-o
';
10467 if (preg_match('/\.(cpp)$/i
', $tmpfile)) {
10468 $mime = 'text/plain
';
10469 $imgmime = 'text.png
';
10471 $famime = 'file-
code-o
';
10473 if (preg_match('/\.cs$/i
', $tmpfile)) {
10474 $mime = 'text/plain
';
10475 $imgmime = 'text.png
';
10477 $famime = 'file-
code-o
';
10479 if (preg_match('/\.(h)$/i
', $tmpfile)) {
10480 $mime = 'text/plain
';
10481 $imgmime = 'text.png
';
10483 $famime = 'file-
code-o
';
10485 if (preg_match('/\.(java|jsp)$/i
', $tmpfile)) {
10486 $mime = 'text/plain
';
10487 $imgmime = 'text.png
';
10489 $famime = 'file-
code-o
';
10491 if (preg_match('/\.php([0-9]{1})?$/i
', $tmpfile)) {
10492 $mime = 'text/plain
';
10493 $imgmime = 'php.png
';
10495 $famime = 'file-
code-o
';
10497 if (preg_match('/\.phtml$/i
', $tmpfile)) {
10498 $mime = 'text/plain
';
10499 $imgmime = 'php.png
';
10501 $famime = 'file-
code-o
';
10503 if (preg_match('/\.(pl|pm)$/i
', $tmpfile)) {
10504 $mime = 'text/plain
';
10505 $imgmime = 'pl.png
';
10507 $famime = 'file-
code-o
';
10509 if (preg_match('/\.sql$/i
', $tmpfile)) {
10510 $mime = 'text/plain
';
10511 $imgmime = 'text.png
';
10513 $famime = 'file-
code-o
';
10515 if (preg_match('/\.js$/i
', $tmpfile)) {
10516 $mime = 'text/x-javascript
';
10517 $imgmime = 'jscript.png
';
10519 $famime = 'file-
code-o
';
10522 if (preg_match('/\.odp$/i
', $tmpfile)) {
10523 $mime = 'application/vnd.oasis.opendocument.presentation
';
10524 $imgmime = 'ooffice.png
';
10525 $famime = 'file-powerpoint-o
';
10527 if (preg_match('/\.ods$/i
', $tmpfile)) {
10528 $mime = 'application/vnd.oasis.opendocument.spreadsheet
';
10529 $imgmime = 'ooffice.png
';
10530 $famime = 'file-excel-o
';
10532 if (preg_match('/\.odt$/i
', $tmpfile)) {
10533 $mime = 'application/vnd.oasis.opendocument.text
';
10534 $imgmime = 'ooffice.png
';
10535 $famime = 'file-word-o
';
10538 if (preg_match('/\.mdb$/i
', $tmpfile)) {
10539 $mime = 'application/msaccess
';
10540 $imgmime = 'mdb.png
';
10541 $famime = 'file-o
';
10543 if (preg_match('/\.doc[xm]?$/i
', $tmpfile)) {
10544 $mime = 'application/msword
';
10545 $imgmime = 'doc.png
';
10546 $famime = 'file-word-o
';
10548 if (preg_match('/\.dot[xm]?$/i
', $tmpfile)) {
10549 $mime = 'application/msword
';
10550 $imgmime = 'doc.png
';
10551 $famime = 'file-word-o
';
10553 if (preg_match('/\.xlt(x)?$/i
', $tmpfile)) {
10554 $mime = 'application/vnd.ms-excel
';
10555 $imgmime = 'xls.png
';
10556 $famime = 'file-excel-o
';
10558 if (preg_match('/\.xla(m)?$/i
', $tmpfile)) {
10559 $mime = 'application/vnd.ms-excel
';
10560 $imgmime = 'xls.png
';
10561 $famime = 'file-excel-o
';
10563 if (preg_match('/\.xls$/i
', $tmpfile)) {
10564 $mime = 'application/vnd.ms-excel
';
10565 $imgmime = 'xls.png
';
10566 $famime = 'file-excel-o
';
10568 if (preg_match('/\.xls[bmx]$/i
', $tmpfile)) {
10569 $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
';
10570 $imgmime = 'xls.png
';
10571 $famime = 'file-excel-o
';
10573 if (preg_match('/\.pps[mx]?$/i
', $tmpfile)) {
10574 $mime = 'application/vnd.ms-powerpoint
';
10575 $imgmime = 'ppt.png
';
10576 $famime = 'file-powerpoint-o
';
10578 if (preg_match('/\.ppt[mx]?$/i
', $tmpfile)) {
10579 $mime = 'application/x-mspowerpoint
';
10580 $imgmime = 'ppt.png
';
10581 $famime = 'file-powerpoint-o
';
10584 if (preg_match('/\.pdf$/i
', $tmpfile)) {
10585 $mime = 'application/pdf
';
10586 $imgmime = 'pdf.png
';
10587 $famime = 'file-pdf-o
';
10590 if (preg_match('/\.bat$/i
', $tmpfile)) {
10591 $mime = 'text/x-bat
';
10592 $imgmime = 'script.png
';
10594 $famime = 'file-
code-o
';
10596 if (preg_match('/\.sh$/i
', $tmpfile)) {
10597 $mime = 'text/x-sh
';
10598 $imgmime = 'script.png
';
10600 $famime = 'file-
code-o
';
10602 if (preg_match('/\.ksh$/i
', $tmpfile)) {
10603 $mime = 'text/x-ksh
';
10604 $imgmime = 'script.png
';
10606 $famime = 'file-
code-o
';
10608 if (preg_match('/\.bash$/i
', $tmpfile)) {
10609 $mime = 'text/x-bash
';
10610 $imgmime = 'script.png
';
10612 $famime = 'file-
code-o
';
10615 if (preg_match('/\.ico$/i
', $tmpfile)) {
10616 $mime = 'image/x-icon
';
10617 $imgmime = 'image.png
';
10618 $famime = 'file-image-o
';
10620 if (preg_match('/\.(jpg|jpeg)$/i
', $tmpfile)) {
10621 $mime = 'image/jpeg
';
10622 $imgmime = 'image.png
';
10623 $famime = 'file-image-o
';
10625 if (preg_match('/\.png$/i
', $tmpfile)) {
10626 $mime = 'image/png
';
10627 $imgmime = 'image.png
';
10628 $famime = 'file-image-o
';
10630 if (preg_match('/\.gif$/i
', $tmpfile)) {
10631 $mime = 'image/gif
';
10632 $imgmime = 'image.png
';
10633 $famime = 'file-image-o
';
10635 if (preg_match('/\.bmp$/i
', $tmpfile)) {
10636 $mime = 'image/bmp
';
10637 $imgmime = 'image.png
';
10638 $famime = 'file-image-o
';
10640 if (preg_match('/\.(tif|tiff)$/i
', $tmpfile)) {
10641 $mime = 'image/tiff
';
10642 $imgmime = 'image.png
';
10643 $famime = 'file-image-o
';
10645 if (preg_match('/\.svg$/i
', $tmpfile)) {
10646 $mime = 'image/svg+xml
';
10647 $imgmime = 'image.png
';
10648 $famime = 'file-image-o
';
10650 if (preg_match('/\.webp$/i
', $tmpfile)) {
10651 $mime = 'image/webp
';
10652 $imgmime = 'image.png
';
10653 $famime = 'file-image-o
';
10656 if (preg_match('/\.vcs$/i
', $tmpfile)) {
10657 $mime = 'text/calendar
';
10658 $imgmime = 'other.png
';
10659 $famime = 'file-text-o
';
10661 if (preg_match('/\.ics$/i
', $tmpfile)) {
10662 $mime = 'text/calendar
';
10663 $imgmime = 'other.png
';
10664 $famime = 'file-text-o
';
10667 if (preg_match('/\.torrent$/i
', $tmpfile)) {
10668 $mime = 'application/x-bittorrent
';
10669 $imgmime = 'other.png
';
10670 $famime = 'file-o
';
10673 if (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i
', $tmpfile)) {
10675 $imgmime = 'audio.png
';
10676 $famime = 'file-audio-o
';
10679 if (preg_match('/\.mp4$/i
', $tmpfile)) {
10680 $mime = 'video/mp4
';
10681 $imgmime = 'video.png
';
10682 $famime = 'file-video-o
';
10684 if (preg_match('/\.ogv$/i
', $tmpfile)) {
10685 $mime = 'video/ogg
';
10686 $imgmime = 'video.png
';
10687 $famime = 'file-video-o
';
10689 if (preg_match('/\.webm$/i
', $tmpfile)) {
10690 $mime = 'video/webm
';
10691 $imgmime = 'video.png
';
10692 $famime = 'file-video-o
';
10694 if (preg_match('/\.avi$/i
', $tmpfile)) {
10695 $mime = 'video/x-msvideo
';
10696 $imgmime = 'video.png
';
10697 $famime = 'file-video-o
';
10699 if (preg_match('/\.divx$/i
', $tmpfile)) {
10700 $mime = 'video/divx
';
10701 $imgmime = 'video.png
';
10702 $famime = 'file-video-o
';
10704 if (preg_match('/\.xvid$/i
', $tmpfile)) {
10705 $mime = 'video/xvid
';
10706 $imgmime = 'video.png
';
10707 $famime = 'file-video-o
';
10709 if (preg_match('/\.(wmv|mpg|mpeg)$/i
', $tmpfile)) {
10711 $imgmime = 'video.png
';
10712 $famime = 'file-video-o
';
10715 if (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh|zst)$/i
', $tmpfile)) {
10717 $imgmime = 'archive.png
';
10718 $famime = 'file-archive-o
';
10719 } // application/xxx where zzz is zip, ...
10721 if (preg_match('/\.(exe|com)$/i
', $tmpfile)) {
10722 $mime = 'application/octet-stream
';
10723 $imgmime = 'other.png
';
10724 $famime = 'file-o
';
10727 if (preg_match('/\.(dll|lib|o|so|a)$/i
', $tmpfile)) {
10729 $imgmime = 'library.png
';
10730 $famime = 'file-o
';
10733 if (preg_match('/\.err$/i
', $tmpfile)) {
10735 $imgmime = 'error.png
';
10736 $famime = 'file-text-o
';
10741 $tmp = explode('/
', $mime);
10742 return (!empty($tmp[1]) ? $tmp[1] : $tmp[0]);
10767 function getDictionaryValue($tablename, $field, $id, $checkentity = false, $rowidfield = 'rowid')
10771 $tablename = preg_replace('/^
'.preg_quote(MAIN_DB_PREFIX, '/
').'/
', '', $tablename); // Clean name of table for backward compatibility.
10773 $dictvalues = (isset($conf->cache['dictvalues_
'.$tablename]) ? $conf->cache['dictvalues_
'.$tablename] : null);
10775 if (is_null($dictvalues)) {
10776 $dictvalues = array();
10778 $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
10779 if ($checkentity) {
10780 $sql .=
' AND entity IN (0,'.getEntity($tablename).
')';
10783 $resql = $db->query(
$sql);
10785 while ($obj = $db->fetch_object($resql)) {
10786 $dictvalues[$obj->$rowidfield] = $obj;
10792 $conf->cache[
'dictvalues_'.$tablename] = $dictvalues;
10795 if (!empty($dictvalues[$id])) {
10797 $tmp = $dictvalues[$id];
10798 return (property_exists($tmp, $field) ? $tmp->$field :
'');
10813 $stringcolor = str_replace(
'#',
'', $stringcolor);
10815 if (!empty($stringcolor)) {
10817 $tmp = explode(
',', $stringcolor);
10818 if (count($tmp) > 1) {
10823 $hexr = $stringcolor[0].$stringcolor[1];
10824 $hexg = $stringcolor[2].$stringcolor[3];
10825 $hexb = $stringcolor[4].$stringcolor[5];
10826 $r = hexdec($hexr);
10827 $g = hexdec($hexg);
10828 $b = hexdec($hexb);
10830 $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0;
10831 if ($bright > 0.6) {
10852 if (empty($menuentry[
'enabled'])) {
10855 if ($type_user && $menuentry[
'module']) {
10856 $tmploops = explode(
'|', $menuentry[
'module']);
10858 foreach ($tmploops as $tmploop) {
10859 if (in_array($tmploop, $listofmodulesforexternal)) {
10868 if (!$menuentry[
'perms'] && $type_user) {
10871 if (!$menuentry[
'perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) {
10874 if (!$menuentry[
'perms']) {
10889 return (ceil($n) % $x === 0) ? ceil($n) : round(($n + $x / 2) / $x) * $x;
10903 function dolGetBadge($label, $html =
'', $type =
'primary', $mode =
'', $url =
'', $params = array())
10906 'class'=>
'badge '.(!empty($mode) ?
' badge-'.$mode :
'').(!empty($type) ?
' badge-'.$type :
'').(empty($params[
'css']) ?
'' :
' '.$params[
'css'])
10909 if (empty($html)) {
10913 if (!empty($url)) {
10914 $attr[
'href'] = $url;
10917 if ($mode ===
'dot') {
10918 $attr[
'class'] .=
' classfortooltip';
10919 $attr[
'title'] = $html;
10920 $attr[
'aria-label'] = $label;
10925 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
10926 foreach ($params[
'attr'] as $key => $value) {
10927 if ($key ==
'class') {
10928 $attr[
'class'] .=
' '.$value;
10929 } elseif ($key ==
'classOverride') {
10930 $attr[
'class'] = $value;
10932 $attr[$key] = $value;
10940 $attr = array_map(
'dol_escape_htmltag', $attr);
10942 $TCompiledAttr = array();
10943 foreach ($attr as $key => $value) {
10944 $TCompiledAttr[] = $key.
'="'.$value.
'"';
10947 $compiledAttributes = !empty($TCompiledAttr) ?implode(
' ', $TCompiledAttr) :
'';
10949 $tag = !empty($url) ?
'a' :
'span';
10951 return '<'.$tag.
' '.$compiledAttributes.
'>'.$html.
'</'.$tag.
'>';
10967 function dolGetStatus($statusLabel =
'', $statusLabelShort =
'', $html =
'', $statusType =
'status0', $displayMode = 0, $url =
'', $params = array())
10972 $dolGetBadgeParams = array();
10974 if (!empty($params[
'badgeParams'])) {
10975 $dolGetBadgeParams = $params[
'badgeParams'];
10979 if ($displayMode == 0) {
10980 $return = !empty($html) ? $html : (empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort));
10981 } elseif ($displayMode == 1) {
10982 $return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
10983 } elseif (!empty($conf->global->MAIN_STATUS_USES_IMAGES)) {
10986 $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ?
'<span class="hideonsmartphone">' :
'').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ?
'</span>' :
'');
10987 $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>' :
'');
10990 if (!empty($conf->dol_optimize_smallscreen)) {
10991 if ($displayMode == 0) {
10993 } elseif ($displayMode == 4) {
10995 } elseif ($displayMode == 6) {
11001 $statusImg = array(
11002 'status0' =>
'statut0',
11003 'status1' =>
'statut1',
11004 'status2' =>
'statut2',
11005 'status3' =>
'statut3',
11006 'status4' =>
'statut4',
11007 'status5' =>
'statut5',
11008 'status6' =>
'statut6',
11009 'status7' =>
'statut7',
11010 'status8' =>
'statut8',
11011 'status9' =>
'statut9'
11014 if (!empty($statusImg[$statusType])) {
11015 $htmlImg =
img_picto($statusLabel, $statusImg[$statusType]);
11017 $htmlImg =
img_picto($statusLabel, $statusType);
11020 if ($displayMode === 2) {
11021 $return = $htmlImg.
' '.$htmlLabelShort;
11022 } elseif ($displayMode === 3) {
11023 $return = $htmlImg;
11024 } elseif ($displayMode === 4) {
11025 $return = $htmlImg.
' '.$htmlLabel;
11026 } elseif ($displayMode === 5) {
11027 $return = $htmlLabelShort.
' '.$htmlImg;
11029 $return = $htmlLabel.
' '.$htmlImg;
11031 } elseif (empty($conf->global->MAIN_STATUS_USES_IMAGES) && !empty($displayMode)) {
11033 $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
11035 $dolGetBadgeParams[
'attr'][
'class'] =
'badge-status';
11036 $dolGetBadgeParams[
'attr'][
'title'] = empty($params[
'tooltip']) ? $statusLabel : ($params[
'tooltip'] !=
'no' ? $params[
'tooltip'] :
'');
11038 if ($displayMode == 3) {
11039 $return =
dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)),
'', $statusType,
'dot', $url, $dolGetBadgeParams);
11040 } elseif ($displayMode === 5) {
11041 $return =
dolGetBadge($statusLabelShort, $html, $statusType,
'', $url, $dolGetBadgeParams);
11043 $return =
dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), $html, $statusType,
'', $url, $dolGetBadgeParams);
11080 function dolGetButtonAction($label, $text =
'', $actionType =
'default', $url =
'', $id =
'', $userRight = 1, $params = array())
11082 global $hookmanager, $action, $object, $langs;
11085 if (is_array($url)) {
11086 $out =
'<div class="dropdown inline-block dropdown-holder">';
11087 $out .=
'<a style="margin-right: auto;" class="dropdown-toggle butAction" data-toggle="dropdown">'.$label.
'</a>';
11088 $out .=
'<div class="dropdown-content">';
11089 foreach ($url as $subbutton) {
11090 if ($subbutton[
'enabled'] && $subbutton[
'perm']) {
11091 if (!empty($subbutton[
'lang'])) {
11092 $langs->load($subbutton[
'lang']);
11094 $out .=
dolGetButtonAction(
'', $langs->trans($subbutton[
'label']),
'default', DOL_URL_ROOT.$subbutton[
'url'].(empty($params[
'backtopage']) ?
'' :
'&backtopage='.urlencode($params[
'backtopage'])),
'', 1, array(
'isDropDown' =>
true));
11104 if (!empty($params[
'isDropdown']))
11105 $class =
"dropdown-item";
11107 $class =
'butAction';
11108 if ($actionType ==
'danger' || $actionType ==
'delete') {
11109 $class =
'butActionDelete';
11110 if (!empty($url) && strpos($url,
'token=') ===
false) $url .=
'&token='.
newToken();
11115 'href' => empty($url) ?
'' : $url,
11119 if (empty($text)) {
11121 $attr[
'title'] =
'';
11123 $attr[
'title'] = $label;
11124 $attr[
'aria-label'] = $label;
11127 if (empty($userRight)) {
11128 $attr[
'class'] =
'butActionRefused';
11129 $attr[
'href'] =
'';
11130 $attr[
'title'] = (($label && $text && $label != $text) ? $label : $langs->trans(
'NotEnoughPermissions'));
11138 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
11139 foreach ($params[
'attr'] as $key => $value) {
11140 if ($key ==
'class') {
11141 $attr[
'class'] .=
' '.$value;
11142 } elseif ($key ==
'classOverride') {
11143 $attr[
'class'] = $value;
11145 $attr[$key] = $value;
11151 if (!empty($attr[
'title']) && !empty($attr[
'class']) && strpos($attr[
'class'],
'classfortooltip') ===
false) {
11152 $attr[
'class'].=
' classfortooltip';
11156 if ($userRight && !empty($params[
'confirm'])) {
11157 if (!is_array($params[
'confirm'])) {
11158 $params[
'confirm'] = array();
11161 if (empty($params[
'confirm'][
'url'])) {
11162 $params[
'confirm'][
'url'] = $url . (strpos($url,
'?') > 0 ?
'&' :
'?') .
'confirm=yes';
11166 $attr[
'data-confirm-url'] = $params[
'confirm'][
'url'];
11167 $attr[
'data-confirm-title'] = !empty($params[
'confirm'][
'title']) ? $params[
'confirm'][
'title'] : $langs->trans(
'ConfirmBtnCommonTitle', $label);
11168 $attr[
'data-confirm-content'] = !empty($params[
'confirm'][
'content']) ? $params[
'confirm'][
'content'] : $langs->trans(
'ConfirmBtnCommonContent', $label);
11169 $attr[
'data-confirm-content'] = preg_replace(
"/\r|\n/",
"", $attr[
'data-confirm-content']);
11170 $attr[
'data-confirm-action-btn-label'] = !empty($params[
'confirm'][
'action-btn-label']) ? $params[
'confirm'][
'action-btn-label'] : $langs->trans(
'Confirm');
11171 $attr[
'data-confirm-cancel-btn-label'] = !empty($params[
'confirm'][
'cancel-btn-label']) ? $params[
'confirm'][
'cancel-btn-label'] : $langs->trans(
'CloseDialog');
11172 $attr[
'data-confirm-modal'] = !empty($params[
'confirm'][
'modal']) ? $params[
'confirm'][
'modal'] :
true;
11174 $attr[
'class'].=
' butActionConfirm';
11177 if (isset($attr[
'href']) && empty($attr[
'href'])) {
11178 unset($attr[
'href']);
11182 $attr = array_map(
'dol_escape_htmltag', $attr);
11184 $TCompiledAttr = array();
11185 foreach ($attr as $key => $value) {
11186 $TCompiledAttr[] = $key.
'= "'.$value.
'"';
11189 $compiledAttributes = empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr);
11191 $tag = !empty($attr[
'href']) ?
'a' :
'span';
11194 $parameters = array(
11195 'TCompiledAttr' => $TCompiledAttr,
11196 'compiledAttributes' => $compiledAttributes,
11201 'actionType' => $actionType,
11204 'userRight' => $userRight,
11205 'params' => $params
11208 $reshook = $hookmanager->executeHooks(
'dolGetButtonAction', $parameters, $object, $action);
11209 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
11211 if (empty($reshook)) {
11213 return '<' . $tag .
' ' . $compiledAttributes .
'>' . $text .
'</' . $tag .
'>';
11215 return '<' . $tag .
' ' . $compiledAttributes .
'>' .
dol_escape_htmltag($text) .
'</' . $tag .
'>';
11218 return $hookmanager->resPrint;
11230 return '<span class="button-title-separator '.$moreClass.
'" ></span>';
11242 if (!empty($fieldValidationErrorMsg)) {
11243 $out.=
'<span class="field-error-icon classfortooltip" title="'.dol_escape_htmltag($fieldValidationErrorMsg, 1).
'" role="alert" >';
11244 $out.=
'<span class="fa fa-exclamation-circle" aria-hidden="true" ></span>';
11263 function dolGetButtonTitle($label, $helpText =
'', $iconClass =
'fa fa-file', $url =
'', $id =
'', $status = 1, $params = array())
11265 global $langs, $conf, $user;
11268 if (!empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (!$user->admin) && $status <= 0) {
11272 $class =
'btnTitle';
11273 if (in_array($iconClass, array(
'fa fa-plus-circle',
'fa fa-plus-circle size15x',
'fa fa-comment-dots',
'fa fa-paper-plane'))) {
11274 $class .=
' btnTitlePlus';
11276 $useclassfortooltip = 1;
11278 if (!empty($params[
'morecss'])) {
11279 $class .=
' '.$params[
'morecss'];
11284 'href' => empty($url) ?
'' : $url
11287 if (!empty($helpText)) {
11289 } elseif (empty($attr[
'title']) && $label) {
11290 $attr[
'title'] = $label;
11291 $useclassfortooltip = 0;
11294 if ($status == 2) {
11295 $attr[
'class'] .=
' btnTitleSelected';
11296 } elseif ($status <= 0) {
11297 $attr[
'class'] .=
' refused';
11299 $attr[
'href'] =
'';
11301 if ($status == -1) {
11302 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"FeatureDisabled"));
11303 } elseif ($status == 0) {
11304 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions"));
11308 if (!empty($attr[
'title']) && $useclassfortooltip) {
11309 $attr[
'class'] .=
' classfortooltip';
11317 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
11318 foreach ($params[
'attr'] as $key => $value) {
11319 if ($key ==
'class') {
11320 $attr[
'class'] .=
' '.$value;
11321 } elseif ($key ==
'classOverride') {
11322 $attr[
'class'] = $value;
11324 $attr[$key] = $value;
11329 if (isset($attr[
'href']) && empty($attr[
'href'])) {
11330 unset($attr[
'href']);
11336 $attr = array_map(
'dol_escape_htmltag', $attr);
11338 $TCompiledAttr = array();
11339 foreach ($attr as $key => $value) {
11340 $TCompiledAttr[] = $key.
'="'.$value.
'"';
11343 $compiledAttributes = (empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr));
11345 $tag = (empty($attr[
'href']) ?
'span' :
'a');
11347 $button =
'<'.$tag.
' '.$compiledAttributes.
'>';
11348 $button .=
'<span class="'.$iconClass.
' valignmiddle btnTitle-icon"></span>';
11349 if (!empty($params[
'forcenohideoftext'])) {
11350 $button .=
'<span class="valignmiddle text-plus-circle btnTitle-label'.(empty($params[
'forcenohideoftext']) ?
' hideonsmartphone' :
'').
'">'.$label.
'</span>';
11352 $button .=
'</'.$tag.
'>';
11373 $classfile = $classname = $classpath = $subdir = $dir_output =
'';
11376 $module = $element_type;
11377 $element = $element_type;
11378 $subelement = $element_type;
11381 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $element_type, $regs)) {
11382 $element = $subelement = $regs[1];
11383 $module = $regs[2];
11388 if (preg_match(
'/^([^_]+)_([^_]+)/i', $element, $regs)) {
11389 $module = $element = $regs[1];
11390 $subelement = $regs[2];
11394 if ($element_type ==
"action") {
11395 $classpath =
'comm/action/class';
11396 $subelement =
'Actioncomm';
11397 $module =
'agenda';
11398 } elseif ($element_type ==
'cronjob') {
11399 $classpath =
'cron/class';
11401 } elseif ($element_type ==
'adherent_type') {
11402 $classpath =
'adherents/class';
11403 $classfile =
'adherent_type';
11404 $module =
'adherent';
11405 $subelement =
'adherent_type';
11406 $classname =
'AdherentType';
11407 } elseif ($element_type ==
'bank_account') {
11408 $classpath =
'compta/bank/class';
11410 $classfile =
'account';
11411 $classname =
'Account';
11412 } elseif ($element_type ==
'category') {
11413 $classpath =
'categories/class';
11414 $module =
'categorie';
11415 $subelement =
'categorie';
11416 } elseif ($element_type ==
'contact') {
11417 $classpath =
'contact/class';
11418 $classfile =
'contact';
11419 $module =
'societe';
11420 $subelement =
'contact';
11421 } elseif ($element_type ==
'stock') {
11422 $classpath =
'product/stock/class';
11423 $classfile =
'entrepot';
11424 $classname =
'Entrepot';
11425 } elseif ($element_type ==
'project') {
11426 $classpath =
'projet/class';
11427 $module =
'projet';
11428 } elseif ($element_type ==
'project_task') {
11429 $classpath =
'projet/class';
11430 $module =
'projet';
11431 $subelement =
'task';
11432 } elseif ($element_type ==
'facture' || $element_type ==
'invoice') {
11433 $classpath =
'compta/facture/class';
11434 $module =
'facture';
11435 $subelement =
'facture';
11436 } elseif ($element_type ==
'commande' || $element_type ==
'order') {
11437 $classpath =
'commande/class';
11438 $module =
'commande';
11439 $subelement =
'commande';
11440 } elseif ($element_type ==
'propal') {
11441 $classpath =
'comm/propal/class';
11442 } elseif ($element_type ==
'shipping') {
11443 $classpath =
'expedition/class';
11444 $classfile =
'expedition';
11445 $classname =
'Expedition';
11446 $module =
'expedition';
11447 } elseif ($element_type ==
'supplier_proposal') {
11448 $classpath =
'supplier_proposal/class';
11449 $module =
'supplier_proposal';
11450 $element =
'supplierproposal';
11451 $classfile =
'supplier_proposal';
11452 $subelement =
'supplierproposal';
11453 } elseif ($element_type ==
'shipping') {
11454 $classpath =
'expedition/class';
11455 $subelement =
'expedition';
11456 $module =
'expedition_bon';
11457 } elseif ($element_type ==
'delivery') {
11458 $classpath =
'delivery/class';
11459 $subelement =
'delivery';
11460 $module =
'delivery_note';
11461 } elseif ($element_type ==
'contract') {
11462 $classpath =
'contrat/class';
11463 $module =
'contrat';
11464 $subelement =
'contrat';
11465 } elseif ($element_type ==
'mailing') {
11466 $classpath =
'comm/mailing/class';
11467 $module =
'mailing';
11468 $classfile =
'mailing';
11469 $classname =
'Mailing';
11471 } elseif ($element_type ==
'member') {
11472 $classpath =
'adherents/class';
11473 $module =
'adherent';
11474 $subelement =
'adherent';
11475 } elseif ($element_type ==
'usergroup') {
11476 $classpath =
'user/class';
11478 } elseif ($element_type ==
'mo') {
11479 $classpath =
'mrp/class';
11484 } elseif ($element_type ==
'cabinetmed_cons') {
11485 $classpath =
'cabinetmed/class';
11486 $module =
'cabinetmed';
11487 $subelement =
'cabinetmedcons';
11488 } elseif ($element_type ==
'fichinter') {
11489 $classpath =
'fichinter/class';
11490 $module =
'ficheinter';
11491 $subelement =
'fichinter';
11492 } elseif ($element_type ==
'dolresource' || $element_type ==
'resource') {
11493 $classpath =
'resource/class';
11494 $module =
'resource';
11495 $subelement =
'dolresource';
11496 } elseif ($element_type ==
'propaldet') {
11497 $classpath =
'comm/propal/class';
11498 $module =
'propal';
11499 $subelement =
'propaleligne';
11500 } elseif ($element_type ==
'opensurvey_sondage') {
11501 $classpath =
'opensurvey/class';
11502 $module =
'opensurvey';
11503 $subelement =
'opensurveysondage';
11504 } elseif ($element_type ==
'order_supplier') {
11505 $classpath =
'fourn/class';
11506 $module =
'fournisseur';
11507 $classfile =
'fournisseur.commande';
11508 $element =
'order_supplier';
11510 $classname =
'CommandeFournisseur';
11511 } elseif ($element_type ==
'invoice_supplier') {
11512 $classpath =
'fourn/class';
11513 $module =
'fournisseur';
11514 $classfile =
'fournisseur.facture';
11515 $element =
'invoice_supplier';
11517 $classname =
'FactureFournisseur';
11518 } elseif ($element_type ==
"service") {
11519 $classpath =
'product/class';
11520 $subelement =
'product';
11521 } elseif ($element_type ==
'salary') {
11522 $classpath =
'salaries/class';
11523 $module =
'salaries';
11524 } elseif ($element_type ==
'productlot') {
11525 $module =
'productbatch';
11526 $classpath =
'product/stock/class';
11527 $classfile =
'productlot';
11528 $classname =
'Productlot';
11529 $element =
'productlot';
11531 } elseif ($element_type ==
'websitepage') {
11532 $classpath =
'website/class';
11533 $classfile =
'websitepage';
11534 $classname =
'Websitepage';
11535 $module =
'website';
11536 $subelement =
'websitepage';
11537 } elseif ($element_type ==
'fiscalyear') {
11538 $classpath =
'core/class';
11539 $module =
'accounting';
11540 $subelement =
'fiscalyear';
11541 } elseif ($element_type ==
'chargesociales') {
11542 $classpath =
'compta/sociales/class';
11544 } elseif ($element_type ==
'tva') {
11545 $classpath =
'compta/tva/class';
11550 if (empty($classfile)) {
11551 $classfile = strtolower($subelement);
11553 if (empty($classname)) {
11554 $classname = ucfirst($subelement);
11556 if (empty($classpath)) {
11557 $classpath = $module.
'/class';
11563 if ($module && isset($conf->$module)) {
11564 if (!empty($conf->$module->multidir_output[$conf->entity])) {
11565 $dir_output = $conf->$module->multidir_output[$conf->entity];
11566 } elseif (!empty($conf->$module->output[$conf->entity])) {
11567 $dir_output = $conf->$module->output[$conf->entity];
11568 } elseif (!empty($conf->$module->dir_output)) {
11569 $dir_output = $conf->$module->dir_output;
11574 if ($element ==
'order_supplier') {
11575 $dir_output = $conf->fournisseur->commande->dir_output;
11576 } elseif ($element ==
'invoice_supplier') {
11577 $dir_output = $conf->fournisseur->facture->dir_output;
11579 $dir_output .= $subdir;
11581 $element_properties = array(
11582 'module' => $module,
11583 'element' => $element,
11584 'subelement' => $subelement,
11585 'classpath' => $classpath,
11586 'classfile' => $classfile,
11587 'classname' => $classname,
11588 'dir_output' => $dir_output
11590 return $element_properties;
11610 if (is_array($element_prop) &&
isModEnabled($element_prop[
'module'])) {
11611 dol_include_once(
'/'.$element_prop[
'classpath'].
'/'.$element_prop[
'classfile'].
'.class.php');
11613 if (class_exists($element_prop[
'classname'])) {
11614 $classname = $element_prop[
'classname'];
11615 $objecttmp =
new $classname($db);
11616 $ret = $objecttmp->fetch($element_id, $element_ref);
11618 if (empty($objecttmp->module)) {
11619 $objecttmp->module = $element_prop[
'module'];
11640 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)) {
11656 return empty($_SESSION[
'newtoken']) ?
'' : $_SESSION[
'newtoken'];
11668 return isset($_SESSION[
'token']) ? $_SESSION[
'token'] :
'';
11680 if (empty($conf->cache[
'nonce'])) {
11684 return $conf->cache[
'nonce'];
11704 print
'<div class="div-table-responsive-no-min">';
11705 print
'<table class="noborder centpercent">';
11706 print
'<tr class="liste_titre">';
11708 print $emptyRows < 1 ? '<th>
' : '<th colspan=
"'.($emptyRows + 1).'">
';
11710 print $langs->trans($header);
11712 // extra space between the first header and the number
11713 if ($number > -1) {
11717 if (!empty($link)) {
11718 if (!empty($arguments)) {
11719 print '<a href=
"'.DOL_URL_ROOT.'/'.$link.'?'.$arguments.'">
';
11721 print '<a href=
"'.DOL_URL_ROOT.'/'.$link.'">
';
11725 if ($number > -1) {
11726 print '<span
class=
"badge">
'.$number.'</span>
';
11729 if (!empty($link)) {
11735 if ($number < 0 && !empty($link)) {
11736 print '<th
class=
"right">
';
11738 if (!empty($arguments)) {
11739 print '<a
class=
"commonlink" href=
"'.DOL_URL_ROOT.'/'.$link.'?'.$arguments.'">
';
11741 print '<a
class=
"commonlink" href=
"'.DOL_URL_ROOT.'/'.$link.'">
';
11744 print $langs->trans("FullList");
11760 function finishSimpleTable($addLineBreak = false)
11765 if ($addLineBreak) {
11781 function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord = "None", $extraRightColumn = false)
11786 print '<tr
class=
"oddeven">
';
11787 print '<td colspan=
"'.$tableColumnCount.'" class=
"opacitymedium">
'.$langs->trans($noneWord).'</td>
';
11792 if ($nbofloop === 0) {
11793 // don't show a summary line
11798 $colspan = $tableColumnCount;
11799 } elseif ($num > $nbofloop) {
11800 $colspan = $tableColumnCount;
11802 $colspan = $tableColumnCount - 1;
11805 if ($extraRightColumn) {
11809 print
'<tr class="liste_total">';
11811 if ($nbofloop > 0 && $num > $nbofloop) {
11812 print
'<td colspan="'.$colspan.
'" class="right">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
'</td>';
11814 print
'<td colspan="'.$colspan.
'" class="right"> '.$langs->trans(
"Total").
'</td>';
11815 print
'<td class="right" width="100">'.price($total).
'</td>';
11818 if ($extraRightColumn) {
11837 if ($method == -1) {
11839 if (!empty($conf->global->MAIN_FORCE_READFILE_WITH_FREAD)) {
11842 if (!empty($conf->global->MAIN_FORCE_READFILE_WITH_STREAM_COPY)) {
11848 while (ob_get_level()) {
11853 if ($method == 0) {
11854 readfile($fullpath_original_file_osencoded);
11855 } elseif ($method == 1) {
11857 $handle = fopen($fullpath_original_file_osencoded,
"rb");
11858 while (!feof($handle)) {
11859 print fread($handle, 8192);
11862 } elseif ($method == 2) {
11864 $handle1 = fopen($fullpath_original_file_osencoded,
"rb");
11865 $handle2 = fopen(
"php://output",
"wb");
11866 stream_copy_to_stream($handle1, $handle2);
11891 if ($texttoshow ===
'none') {
11892 $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>';
11893 } elseif ($texttoshow) {
11894 $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>';
11896 $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>';
11911 $result = json_decode($stringtodecode);
11912 if ($result ===
null) {
11913 $result = unserialize($stringtodecode);
11935 if (!preg_match(
'/^\(.*\)$/', $filter)) {
11936 $filter =
'(' . $filter .
')';
11939 $regexstring =
'\(([a-zA-Z0-9_\.]+:[<>!=insotlke]+:[^\(\)]+)\)';
11945 return 'Filter syntax error - '.$errorstr;
11950 $t = preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeDummyCriteriaCallback', $filter);
11951 $t = str_replace(array(
'and',
'or',
'AND',
'OR',
' '),
'', $t);
11953 if (preg_match(
'/[^\(\)]/', $t)) {
11954 $errorstr =
'Bad syntax of the search string';
11958 return 'Filter syntax error - '.$errorstr;
11962 return ($noand ?
"" :
" AND ").($nopar ?
"" :
'(').preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeCriteriaCallback', $filter).($nopar ?
"" :
')');
11976 $tmp = $sqlfilters;
11977 $i = 0; $nb = strlen($tmp);
11980 if ($tmp[$i] ==
'(') {
11983 if ($tmp[$i] ==
')') {
11986 if ($counter < 0) {
11987 $error =
"Wrond balance of parenthesis in sqlfilters=".$sqlfilters;
12006 if (empty($matches[1])) {
12009 $tmp = explode(
':', $matches[1]);
12010 if (count($tmp) < 3) {
12030 if (empty($matches[1])) {
12033 $tmp = explode(
':', $matches[1]);
12034 if (count($tmp) < 3) {
12038 $operand = preg_replace(
'/[^a-z0-9\._]/i',
'', trim($tmp[0]));
12040 $operator = strtoupper(preg_replace(
'/[^a-z<>!=]/i',
'', trim($tmp[1])));
12042 if ($operator ==
'NOTLIKE') {
12043 $operator =
'NOT LIKE';
12045 if ($operator ==
'ISNOT') {
12046 $operator =
'IS NOT';
12048 if ($operator ==
'!=') {
12052 $tmpescaped = $tmp[2];
12055 if ($operator ==
'IN') {
12057 $tmpescaped =
'('.$db->escape($db->sanitize($tmpescaped, 1, 0)).
')';
12061 } elseif ($operator ==
'LIKE' || $operator ==
'NOT LIKE') {
12062 if (preg_match(
'/^\'(.*)\'$/', $tmpescaped, $regbis)) {
12063 $tmpescaped = $regbis[1];
12066 $tmpescaped =
"'".$db->escape($tmpescaped).
"'";
12067 } elseif (preg_match(
'/^\'(.*)\'$/', $tmpescaped, $regbis)) {
12068 $tmpescaped =
"'".$db->escape($regbis[1]).
"'";
12070 if (strtoupper($tmpescaped) ==
'NULL') {
12071 $tmpescaped =
'NULL';
12072 } elseif (is_int($tmpescaped)) {
12073 $tmpescaped = (int) $tmpescaped;
12075 $tmpescaped = (
float) $tmpescaped;
12079 return '('.$db->escape($operand).
' '.strtoupper($operator).
' '.$tmpescaped.
')';
12093 global $conf, $langs;
12094 $out =
'<!-- timeline icon -->'.
"\n";
12095 $iconClass =
'fa fa-comments';
12100 if ($histo[$key][
'percent'] == -1) {
12101 $colorClass =
'timeline-icon-not-applicble';
12102 $pictoTitle = $langs->trans(
'StatusNotApplicable');
12103 } elseif ($histo[$key][
'percent'] == 0) {
12104 $colorClass =
'timeline-icon-todo';
12105 $pictoTitle = $langs->trans(
'StatusActionToDo').
' (0%)';
12106 } elseif ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100) {
12107 $colorClass =
'timeline-icon-in-progress';
12108 $pictoTitle = $langs->trans(
'StatusActionInProcess').
' ('.$histo[$key][
'percent'].
'%)';
12109 } elseif ($histo[$key][
'percent'] >= 100) {
12110 $colorClass =
'timeline-icon-done';
12111 $pictoTitle = $langs->trans(
'StatusActionDone').
' (100%)';
12114 if ($actionstatic->code ==
'AC_TICKET_CREATE') {
12115 $iconClass =
'fa fa-ticket';
12116 } elseif ($actionstatic->code ==
'AC_TICKET_MODIFY') {
12117 $iconClass =
'fa fa-pencilxxx';
12118 } elseif (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
12119 $iconClass =
'fa fa-comments';
12120 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
12121 $iconClass =
'fa fa-mask';
12122 } elseif (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
12123 if ($actionstatic->type_picto) {
12124 $img_picto =
img_picto(
'', $actionstatic->type_picto);
12126 if ($actionstatic->type_code ==
'AC_RDV') {
12127 $iconClass =
'fa fa-handshake';
12128 } elseif ($actionstatic->type_code ==
'AC_TEL') {
12129 $iconClass =
'fa fa-phone';
12130 } elseif ($actionstatic->type_code ==
'AC_FAX') {
12131 $iconClass =
'fa fa-fax';
12132 } elseif ($actionstatic->type_code ==
'AC_EMAIL') {
12133 $iconClass =
'fa fa-envelope';
12134 } elseif ($actionstatic->type_code ==
'AC_INT') {
12135 $iconClass =
'fa fa-shipping-fast';
12136 } elseif ($actionstatic->type_code ==
'AC_OTH_AUTO') {
12137 $iconClass =
'fa fa-robot';
12138 } elseif (!preg_match(
'/_AUTO/', $actionstatic->type_code)) {
12139 $iconClass =
'fa fa-robot';
12144 $out .=
'<i class="'.$iconClass.
' '.$colorClass.
'" title="'.$pictoTitle.
'">'.$img_picto.
'</i>'.
"\n";
12158 $documents = array();
12160 $sql =
'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.filepath, ecm.filename';
12161 $sql .=
' FROM '.MAIN_DB_PREFIX.
'ecm_files ecm';
12162 $sql .=
" WHERE ecm.filepath = 'agenda/".((int) $object->id).
"'";
12164 $sql .=
' ORDER BY ecm.position ASC';
12166 $resql = $db->query(
$sql);
12168 if ($db->num_rows($resql)) {
12169 while ($obj = $db->fetch_object($resql)) {
12170 $documents[$obj->id] = $obj;
12197 function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon =
'', $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC')
12199 global $user, $conf;
12202 global $param, $massactionbutton;
12207 if (!is_object($filterobj) && !is_object($objcon)) {
12215 $sortfield_list = explode(
',', $sortfield);
12216 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
12217 $sortfield_new_list = array();
12218 foreach ($sortfield_list as $sortfield_value) {
12219 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
12221 $sortfield_new = implode(
',', $sortfield_new_list);
12225 if (is_object($objcon) && $objcon->id > 0) {
12226 $sql =
"SELECT DISTINCT a.id, a.label as label,";
12228 $sql =
"SELECT a.id, a.label as label,";
12230 $sql .=
" a.datep as dp,";
12231 $sql .=
" a.note as message,";
12232 $sql .=
" a.datep2 as dp2,";
12233 $sql .=
" a.percent as percent, 'action' as type,";
12234 $sql .=
" a.fk_element, a.elementtype,";
12235 $sql .=
" a.fk_contact,";
12236 $sql .=
" a.email_from as msg_from,";
12237 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
12238 $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";
12239 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
12240 $sql .=
", sp.lastname, sp.firstname";
12241 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
12242 $sql .=
", m.lastname, m.firstname";
12243 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
12245 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
12247 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
12249 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
12251 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
12254 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
12255 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
12256 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
12258 $force_filter_contact =
false;
12259 if (is_object($objcon) && $objcon->id > 0) {
12260 $force_filter_contact =
true;
12261 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as r ON a.id = r.fk_actioncomm";
12262 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id);
12265 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
12266 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
12267 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
12268 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
12269 $sql .=
" ON er.resource_type = 'dolresource'";
12270 $sql .=
" AND er.element_id = a.id";
12271 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
12272 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
12273 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
12274 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
12275 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
12276 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
12277 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
12278 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
12279 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
12280 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
12281 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
12282 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
12283 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
12286 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
12287 if ($force_filter_contact ===
false) {
12288 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
12289 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
12290 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
12291 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
12292 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
12293 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
12294 if ($filterobj->id) {
12295 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
12297 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
12298 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
12299 if ($filterobj->id) {
12300 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
12302 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
12303 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
12304 if ($filterobj->id) {
12305 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
12307 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
12308 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
12309 if ($filterobj->id) {
12310 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
12312 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
12313 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
12314 if ($filterobj->id) {
12315 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
12317 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
12318 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
12319 if ($filterobj->id) {
12320 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
12326 if (!empty($actioncode)) {
12327 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
12328 if ($actioncode ==
'AC_NON_AUTO') {
12329 $sql .=
" AND c.type != 'systemauto'";
12330 } elseif ($actioncode ==
'AC_ALL_AUTO') {
12331 $sql .=
" AND c.type = 'systemauto'";
12333 if ($actioncode ==
'AC_OTH') {
12334 $sql .=
" AND c.type != 'systemauto'";
12335 } elseif ($actioncode ==
'AC_OTH_AUTO') {
12336 $sql .=
" AND c.type = 'systemauto'";
12340 if ($actioncode ==
'AC_NON_AUTO') {
12341 $sql .=
" AND c.type != 'systemauto'";
12342 } elseif ($actioncode ==
'AC_ALL_AUTO') {
12343 $sql .=
" AND c.type = 'systemauto'";
12345 $sql .=
" AND c.code = '".$db->escape($actioncode).
"'";
12349 if ($donetodo ==
'todo') {
12350 $sql .=
" AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now).
"'))";
12351 } elseif ($donetodo ==
'done') {
12352 $sql .=
" AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now).
"'))";
12354 if (is_array($filters) && $filters[
'search_agenda_label']) {
12361 && (empty($actioncode) || $actioncode ==
'AC_OTH_AUTO' || $actioncode ==
'AC_EMAILING')) {
12362 $langs->load(
"mails");
12364 $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";
12365 $sql2 .=
", null as fk_element, '' as elementtype, null as contact_id";
12366 $sql2 .=
", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
12367 $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";
12368 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
12369 $sql2 .=
", '' as lastname, '' as firstname";
12370 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
12371 $sql2 .=
", '' as lastname, '' as firstname";
12372 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
12373 $sql2 .=
", '' as ref";
12374 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
12375 $sql2 .=
", '' as ref";
12376 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
12377 $sql2 .=
", '' as ref";
12379 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"user as u";
12380 $sql2 .=
" WHERE mc.email = '".$db->escape($objcon->email).
"'";
12381 $sql2 .=
" AND mc.statut = 1";
12382 $sql2 .=
" AND u.rowid = m.fk_user_valid";
12383 $sql2 .=
" AND mc.fk_mailing=m.rowid";
12386 if (!empty(
$sql) && !empty($sql2)) {
12388 } elseif (empty(
$sql) && !empty($sql2)) {
12394 $sql .= $db->order($sortfield_new, $sortorder);
12396 dol_syslog(
"function.lib::show_actions_messaging", LOG_DEBUG);
12397 $resql = $db->query(
$sql);
12400 $num = $db->num_rows($resql);
12402 while ($i < $num) {
12403 $obj = $db->fetch_object($resql);
12405 if ($obj->type ==
'action') {
12407 $contactaction->id = $obj->id;
12408 $result = $contactaction->fetchResources();
12411 setEventMessage(
"actions.lib::show_actions_messaging Error fetch ressource",
'errors');
12417 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->dp > $now)) {
12418 $tododone =
'todo';
12421 $histo[$numaction] = array(
12422 'type'=>$obj->type,
12423 'tododone'=>$tododone,
12425 'datestart'=>$db->jdate($obj->dp),
12426 'dateend'=>$db->jdate($obj->dp2),
12427 'note'=>$obj->label,
12428 'message'=>$obj->message,
12429 'percent'=>$obj->percent,
12431 'userid'=>$obj->user_id,
12432 'login'=>$obj->user_login,
12433 'userfirstname'=>$obj->user_firstname,
12434 'userlastname'=>$obj->user_lastname,
12435 'userphoto'=>$obj->user_photo,
12436 'msg_from'=>$obj->msg_from,
12438 'contact_id'=>$obj->fk_contact,
12439 'socpeopleassigned' => $contactaction->socpeopleassigned,
12440 'lastname' => (empty($obj->lastname) ?
'' : $obj->lastname),
12441 'firstname' => (empty($obj->firstname) ?
'' : $obj->firstname),
12442 'fk_element'=>$obj->fk_element,
12443 'elementtype'=>$obj->elementtype,
12445 'acode'=>$obj->acode,
12446 'alabel'=>$obj->alabel,
12447 'libelle'=>$obj->alabel,
12448 'apicto'=>$obj->apicto
12451 $histo[$numaction] = array(
12452 'type'=>$obj->type,
12453 'tododone'=>
'done',
12455 'datestart'=>$db->jdate($obj->dp),
12456 'dateend'=>$db->jdate($obj->dp2),
12457 'note'=>$obj->label,
12458 'message'=>$obj->message,
12459 'percent'=>$obj->percent,
12460 'acode'=>$obj->acode,
12462 'userid'=>$obj->user_id,
12463 'login'=>$obj->user_login,
12464 'userfirstname'=>$obj->user_firstname,
12465 'userlastname'=>$obj->user_lastname,
12466 'userphoto'=>$obj->user_photo
12482 $langs->loadLangs(array(
"admin",
"errors"));
12483 $out =
info_admin($langs->trans(
"WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv(
"Module2400Name")), 0, 0,
'warning');
12487 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
12489 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
12490 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
12491 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
12492 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
12497 $userstatic =
new User($db);
12498 $contactstatic =
new Contact($db);
12499 $userGetNomUrlCache = array();
12500 $contactGetNomUrlCache = array();
12502 $out .=
'<div class="filters-container" >';
12503 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
12504 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
12506 if ($objcon && get_class($objcon) ==
'Contact' &&
12507 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
12508 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
12510 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
12512 if ($filterobj && get_class($filterobj) ==
'Societe') {
12513 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
12518 $out .=
'<div class="div-table-responsive-no-min">';
12519 $out .=
'<table class="noborder borderbottom centpercent">';
12521 $out .=
'<tr class="liste_titre">';
12525 $out .=
'<th class="liste_titre width50 middle">';
12526 $searchpicto =
$form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
12527 $out .= $searchpicto;
12531 $out .=
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
12533 $out .=
'<th class="liste_titre"><strong class="hideonsmartphone">'.$langs->trans(
"Search").
' : </strong></th>';
12535 $out .=
'<th class="liste_titre"></th>';
12537 $out .=
'<th class="liste_titre">';
12538 $out .=
'<span class="fas fa-square inline-block fawidth30" style=" color: #ddd;" title="'.$langs->trans(
"ActionType").
'"></span>';
12540 $out .=
$formactions->select_type_actions($actioncode,
"actioncode",
'', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, 0, 1,
'minwidth200imp');
12542 $out .=
'<th class="liste_titre maxwidth100onsmartphone">';
12543 $out .=
'<input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'" placeholder="'.$langs->trans(
"Label").
'">';
12548 $out .=
'<th class="liste_titre width50 middle">';
12549 $searchpicto =
$form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
12550 $out .= $searchpicto;
12557 $out .=
'</table>';
12564 $out .=
'<ul class="timeline">';
12568 if (get_class($filterobj) ==
'Societe') {
12569 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
12571 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
12572 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
12573 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
12575 if (get_class($filterobj) ==
'Societe') {
12586 $actualCycleDate =
false;
12589 foreach ($histo as $key => $value) {
12590 $actionstatic->fetch($histo[$key][
'id']);
12592 $actionstatic->type_picto = $histo[$key][
'apicto'];
12593 $actionstatic->type_code = $histo[$key][
'acode'];
12595 $url = DOL_URL_ROOT.
'/comm/action/card.php?id='.$histo[$key][
'id'];
12597 $tmpa =
dol_getdate($histo[$key][
'datestart'],
false);
12598 if ($actualCycleDate !== $tmpa[
'year'].
'-'.$tmpa[
'yday']) {
12599 $actualCycleDate = $tmpa[
'year'].
'-'.$tmpa[
'yday'];
12600 $out .=
'<!-- timeline time label -->';
12601 $out .=
'<li class="time-label">';
12602 $out .=
'<span class="timeline-badge-date">';
12603 $out .=
dol_print_date($histo[$key][
'datestart'],
'daytext',
'tzuserrel', $langs);
12606 $out .=
'<!-- /.timeline-label -->';
12610 $out .=
'<!-- timeline item -->'.
"\n";
12611 $out .=
'<li class="timeline-code-'.strtolower($actionstatic->code).
'">';
12615 $out .=
'<div class="timeline-item">'.
"\n";
12617 $out .=
'<span class="timeline-header-action">';
12619 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
12620 $out .=
'<a class="timeline-btn" href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
12621 $out .= $histo[$key][
'id'];
12624 $out .= $actionstatic->getNomUrl(1, -1,
'valignmiddle').
' ';
12627 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
12628 (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
12629 $out .=
'<a class="timeline-btn" href="'.DOL_MAIN_URL_ROOT.
'/comm/action/card.php?action=edit&token='.
newToken().
'&id='.$actionstatic->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?'.$param).
'"><i class="fa fa-pencil" title="'.$langs->trans(
"Modify").
'" ></i></a>';
12634 $out .=
'<span class="time"><i class="fa fa-clock-o valignmiddle"></i> <span class="valignmiddle">';
12635 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
12636 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
12637 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
12638 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
12639 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
12640 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
12642 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
12646 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
12649 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
12652 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
12655 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
12661 $out .=
"</span></span>\n";
12664 $out .=
'<h3 class="timeline-header">';
12667 $out .=
'<div class="messaging-author inline-block tdoverflowmax150 valignmiddle marginrightonly">';
12668 if ($histo[$key][
'userid'] > 0) {
12669 if (!isset($userGetNomUrlCache[$histo[$key][
'userid']])) {
12670 $userstatic->fetch($histo[$key][
'userid']);
12671 $userGetNomUrlCache[$histo[$key][
'userid']] = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
12673 $out .= $userGetNomUrlCache[$histo[$key][
'userid']];
12674 } elseif (!empty($histo[$key][
'msg_from']) && $actionstatic->code ==
'TICKET_MSG') {
12675 if (!isset($contactGetNomUrlCache[$histo[$key][
'msg_from']])) {
12676 if ($contactstatic->fetch(0,
null,
'', $histo[$key][
'msg_from']) > 0) {
12677 $contactGetNomUrlCache[$histo[$key][
'msg_from']] = $contactstatic->getNomUrl(-1,
'', 16);
12679 $contactGetNomUrlCache[$histo[$key][
'msg_from']] = $histo[$key][
'msg_from'];
12682 $out .= $contactGetNomUrlCache[$histo[$key][
'msg_from']];
12688 $out .=
' <div class="messaging-title inline-block">';
12690 if (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
12691 $out .= $langs->trans(
'TicketNewMessage');
12692 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
12693 $out .= $langs->trans(
'TicketNewMessage').
' <em>('.$langs->trans(
'Private').
')</em>';
12694 } elseif (isset($histo[$key][
'type'])) {
12695 if ($histo[$key][
'type'] ==
'action') {
12696 $transcode = $langs->transnoentitiesnoconv(
"Action".$histo[$key][
'acode']);
12697 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode : $histo[$key][
'alabel']);
12698 $libelle = $histo[$key][
'note'];
12699 $actionstatic->id = $histo[$key][
'id'];
12701 } elseif ($histo[$key][
'type'] ==
'mailing') {
12702 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
12703 $transcode = $langs->transnoentitiesnoconv(
"Action".$histo[$key][
'acode']);
12704 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
12707 $libelle .= $histo[$key][
'note'];
12716 if (!empty($histo[$key][
'message'] && $histo[$key][
'message'] != $libelle)
12717 && $actionstatic->code !=
'AC_TICKET_CREATE'
12718 && $actionstatic->code !=
'AC_TICKET_MODIFY'
12720 $out .=
'<div class="timeline-body">';
12721 $out .= $histo[$key][
'message'];
12729 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
12731 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $Tab) {
12733 $result = $contact->fetch($cid);
12740 $contactList .= !empty($contactList) ?
', ' :
'';
12741 $contactList .= $contact->getNomUrl(1);
12742 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
12743 if (!empty($contact->phone_pro)) {
12744 $contactList .=
'('.dol_print_phone($contact->phone_pro).
')';
12750 $footer .= $langs->trans(
'ActionOnContact').
' : '.$contactList;
12751 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
12753 $result = $contact->fetch($histo[$key][
'contact_id']);
12760 $footer .= $contact->getNomUrl(1);
12761 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
12762 if (!empty($contact->phone_pro)) {
12763 $footer .=
'('.dol_print_phone($contact->phone_pro).
')';
12770 if (!empty($documents)) {
12771 $footer .=
'<div class="timeline-documents-container">';
12772 foreach ($documents as $doc) {
12773 $footer .=
'<span id="document_'.$doc->id.
'" class="timeline-documents" ';
12774 $footer .=
' data-id="'.$doc->id.
'" ';
12775 $footer .=
' data-path="'.$doc->filepath.
'"';
12776 $footer .=
' data-filename="'.dol_escape_htmltag($doc->filename).
'" ';
12779 $filePath = DOL_DATA_ROOT.
'/'.$doc->filepath.
'/'.$doc->filename;
12781 $file = $actionstatic->id.
'/'.$doc->filename;
12782 $thumb = $actionstatic->id.
'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename,
'.')).
'_mini'.substr($doc->filename, strrpos($doc->filename,
'.'));
12783 $doclink =
dol_buildpath(
'document.php', 1).
'?modulepart=actions&attachment=0&file='.urlencode($file).
'&entity='.$conf->entity;
12784 $viewlink =
dol_buildpath(
'viewimage.php', 1).
'?modulepart=actions&file='.urlencode($thumb).
'&entity='.$conf->entity;
12786 $mimeAttr =
' mime="'.$mime.
'" ';
12788 if (in_array($mime, array(
'image/png',
'image/jpeg',
'application/pdf'))) {
12789 $class .=
' documentpreview';
12792 $footer .=
'<a href="'.$doclink.
'" class="btn-link '.$class.
'" target="_blank" rel="noopener noreferrer" '.$mimeAttr.
' >';
12793 $footer .=
img_mime($filePath).
' '.$doc->filename;
12796 $footer .=
'</span>';
12798 $footer .=
'</div>';
12801 if (!empty($footer)) {
12802 $out .=
'<div class="timeline-footer">'.$footer.
'</div>';
12805 $out .=
'</div>'.
"\n";
12808 $out .=
'<!-- END timeline item -->';
12815 if (empty($histo)) {
12816 $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
12839 if ($hourTime ===
'getpost') {
12843 } elseif (preg_match(
'/^(\d\d):(\d\d):(\d\d)$/', $hourTime, $m)) {
12844 $hour = intval($m[1]);
12845 $minute = intval($m[2]);
12846 $second = intval($m[3]);
12848 $hour = $minute = $second = 0;
12851 $hour = min($hour, 23);
12852 $minute = min($minute, 59);
12853 $second = min($second, 59);
12870 if ($timestamp ===
null) $timestamp =
GETPOSTDATE($prefix, $hourTime, $gm);
12876 if ($hourTime ===
'getpost' || ($timestamp !==
null &&
dol_print_date($timestamp,
'%H:%M:%S') !==
'00:00:00')) {
12877 $TParam = array_merge($TParam, array(
12884 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 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)
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid
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_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.
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.
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)
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.
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.
isASecretKey($keyname)
Return if string has a name dedicated to store a secret.
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.
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,...
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.
dolGetBadge($label, $html='', $type='primary', $mode='', $url='', $params=array())
Function dolGetBadge.
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.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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.
getDolGlobalInt($key, $default=0)
Return 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_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
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.
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...
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.
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.
dol_print_profids($profID, $profIDtype, $countrycode='', $addcpButton=1, $separ=' ')
Format profIDs according to country.
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...
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
ascii_check($str)
Check if a string is in ASCII.
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.
dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes=array("allow", "allowfullscreen", "alt", "class", "contenteditable", "data-html", "frameborder", "height", "href", "id", "name", "src", "style", "target", "title", "width"))
Clean a string from some undesirable HTML tags.
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.
colorIsLight($stringcolor)
Return true if the color is light.
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_url($url, $target='_blank', $max=32, $withpicto=0, $morecss='float')
Show Url link.
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 we considered not HTML encoded even if it i...
getNonce()
Return a random string to be used as a nonce value for js.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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 and dangerous content.
jsonOrUnserialize($stringtodecode)
Decode an encode string.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
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.
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.
isModEnabled($module)
Is Dolibarr module enabled.
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.
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)
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
document_preview(file, type, title)
Function show document preview.
if(!empty($_SERVER['MAIN_SHOW_TUNING_INFO'])) realCharForNumericEntities($matches)
Return the real char for a numeric entities.
if(!defined('NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
div float
Buy price without taxes.
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.
print *****$script_file(".$version.") pid code
! Closing after partial payment: discount_vat, badcustomer or badsupplier, bankcharge,...