41 include_once DOL_DOCUMENT_ROOT.
'/core/lib/json.lib.php';
57 require_once DOL_DOCUMENT_ROOT.
"/core/db/".$type.
'.class.php';
59 $class =
'DoliDB'.ucfirst($type);
60 $dolidb =
new $class($type, $host, $user, $pass, $name, $port);
81 function getEntity($element, $shared = 1, $currentobject = null)
87 case 'contrat': $element =
'contract';
break;
88 case 'order_supplier': $element =
'supplier_order';
break;
93 return $mc->getEntity($element, $shared, $currentobject);
96 $addzero = array(
'user',
'usergroup',
'c_email_templates',
'email_template',
'default_values');
97 if (in_array($element, $addzero)) $out .=
'0,';
98 $out .= ((int) $conf->entity);
113 if (is_object($mc) && method_exists($mc,
'setEntity'))
115 return $mc->setEntity($currentobject);
117 return ((is_object($currentobject) && $currentobject->id > 0 && $currentobject->entity > 0) ? $currentobject->entity : $conf->entity);
129 return preg_match(
'/(_pass|password|_pw|_key|securekey|serverkey|secret\d?|p12key|exportkey|_PW_[a-z]+|token)$/i', $keyname);
150 include_once DOL_DOCUMENT_ROOT.
'/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php';
157 $user_agent = substr($user_agent, 0, 512);
159 $detectmobile =
new Mobile_Detect(null, $user_agent);
160 $tablet = $detectmobile->isTablet();
162 if ($detectmobile->isMobile()) {
166 if ($detectmobile->is(
'AndroidOS')) {
167 $os = $phone =
'android';
168 } elseif ($detectmobile->is(
'BlackBerryOS')) {
169 $os = $phone =
'blackberry';
170 } elseif ($detectmobile->is(
'iOS')) {
173 } elseif ($detectmobile->is(
'PalmOS')) {
174 $os = $phone =
'palm';
175 } elseif ($detectmobile->is(
'SymbianOS')) {
177 } elseif ($detectmobile->is(
'webOS')) {
179 } elseif ($detectmobile->is(
'MaemoOS')) {
181 } elseif ($detectmobile->is(
'WindowsMobileOS') || $detectmobile->is(
'WindowsPhoneOS')) {
187 if (preg_match(
'/linux/i', $user_agent)) { $os =
'linux'; } elseif (preg_match(
'/macintosh/i', $user_agent)) { $os =
'macintosh'; } elseif (preg_match(
'/windows/i', $user_agent)) { $os =
'windows'; }
191 if (preg_match(
'/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name =
'firefox'; $version = $reg[2]; } elseif (preg_match(
'/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name =
'edge'; $version = $reg[2]; } elseif (preg_match(
'/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) { $name =
'chrome'; $version = $reg[2]; }
192 elseif (preg_match(
'/chrome/i', $user_agent, $reg)) { $name =
'chrome'; } elseif (preg_match(
'/iceweasel/i', $user_agent)) { $name =
'iceweasel'; } elseif (preg_match(
'/epiphany/i', $user_agent)) { $name =
'epiphany'; } elseif (preg_match(
'/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name =
'safari'; $version = $reg[2]; }
193 elseif (preg_match(
'/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name =
'opera'; $version = $reg[2]; } elseif (preg_match(
'/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name =
'ie'; $version = end($reg); }
194 elseif (preg_match(
'/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name =
'ie'; $version = end($reg); }
195 elseif (preg_match(
'/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { $name =
'lynxlinks'; $version = $reg[4]; }
206 'browsername' => $name,
207 'browserversion' => $version,
222 global $conf, $user, $langs, $db;
223 $disconnectdone =
false; $depth = 0;
224 if (is_object($db) && !empty($db->connected)) { $depth = $db->transaction_opened; $disconnectdone = $db->close(); }
225 dol_syslog(
"--- End access to ".
$_SERVER[
"PHP_SELF"].(($disconnectdone && $depth) ?
' (Warn: db disconnection forced, transaction depth was '.$depth.
')' :
''), (($disconnectdone && $depth) ?LOG_WARNING:LOG_INFO));
238 $relativepathstring =
$_SERVER[
"PHP_SELF"];
240 if (constant(
'DOL_URL_ROOT')) $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
241 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
242 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
248 if (!empty($_GET[
'restore_lastsearch_values']))
250 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring]))
252 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
255 foreach ($tmp as $key => $val)
257 if ($key == $paramname)
266 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring]))
269 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring]))
272 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring]))
277 $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname]));
309 function GETPOST($paramname, $check =
'alphanohtml', $method = 0, $filter = null, $options = null, $noreplace = 0)
311 global $mysoc, $user, $conf;
313 if (empty($paramname))
return 'BadFirstParameterForGETPOST';
316 dol_syslog(
"Deprecated use of GETPOST, called with 1st param = ".$paramname.
" and 2nd param is '', when calling page ".
$_SERVER[
"PHP_SELF"], LOG_WARNING);
321 if (empty($method)) $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
322 elseif ($method == 1) $out = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
323 elseif ($method == 2) $out = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
324 elseif ($method == 3) $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
325 else return 'BadThirdParameterForGETPOST';
327 if (empty($method) || $method == 3 || $method == 4)
329 $relativepathstring =
$_SERVER[
"PHP_SELF"];
331 if (constant(
'DOL_URL_ROOT')) $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
332 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
333 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
339 if (!empty($_GET[
'restore_lastsearch_values']))
341 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring]))
343 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
346 foreach ($tmp as $key => $val)
348 if ($key == $paramname)
357 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring]))
359 $out = $_SESSION[
'lastsearch_contextpage_'.$relativepathstring];
360 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring]))
362 $out = $_SESSION[
'lastsearch_page_'.$relativepathstring];
363 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring]))
365 $out = $_SESSION[
'lastsearch_limit_'.$relativepathstring];
368 elseif (!isset($_GET[
'sortfield']))
370 if (!empty($_GET[
'action']) && $_GET[
'action'] ==
'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname]))
374 if (is_object($object) && isset($object->fields[$paramname][
'default']))
376 $out = $object->fields[$paramname][
'default'];
379 if (!empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES))
381 if (!empty($_GET[
'action']) && (preg_match(
'/^create/', $_GET[
'action']) || preg_match(
'/^presend/', $_GET[
'action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname]))
384 if (!empty($user->default_values))
386 if (isset($user->default_values[$relativepathstring][
'createform']))
388 foreach ($user->default_values[$relativepathstring][
'createform'] as $defkey => $defval)
391 if ($defkey !=
'_noquery_')
393 $tmpqueryarraytohave = explode(
'&', $defkey);
396 foreach ($tmpqueryarraytohave as $tmpquerytohave)
398 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru = 1;
400 if (!$foundintru) $qualified = 1;
402 }
else $qualified = 1;
406 if (isset($user->default_values[$relativepathstring][
'createform'][$defkey][$paramname]))
408 $out = $user->default_values[$relativepathstring][
'createform'][$defkey][$paramname];
416 elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname]))
418 if (!empty($user->default_values))
421 if ($paramname ==
'sortfield' || $paramname ==
'sortorder')
423 if (isset($user->default_values[$relativepathstring][
'sortorder']))
425 foreach ($user->default_values[$relativepathstring][
'sortorder'] as $defkey => $defval)
428 if ($defkey !=
'_noquery_')
430 $tmpqueryarraytohave = explode(
'&', $defkey);
433 foreach ($tmpqueryarraytohave as $tmpquerytohave)
435 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru = 1;
437 if (!$foundintru) $qualified = 1;
439 }
else $qualified = 1;
443 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
444 foreach ($user->default_values[$relativepathstring][
'sortorder'][$defkey] as $key => $val)
446 if ($out) $out .=
', ';
447 if ($paramname ==
'sortfield')
451 if ($paramname ==
'sortorder')
460 } elseif (isset($user->default_values[$relativepathstring][
'filters']))
462 foreach ($user->default_values[$relativepathstring][
'filters'] as $defkey => $defval)
465 if ($defkey !=
'_noquery_')
467 $tmpqueryarraytohave = explode(
'&', $defkey);
470 foreach ($tmpqueryarraytohave as $tmpquerytohave)
472 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru = 1;
474 if (!$foundintru) $qualified = 1;
476 }
else $qualified = 1;
481 if (isset($_POST[
'sall']) || isset($_POST[
'search_all']) || isset($_GET[
'sall']) || isset($_GET[
'search_all']))
484 if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH))
486 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
487 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
490 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
491 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
506 if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace))
509 $maxloop = 20; $loopnb = 0;
510 while (preg_match(
'/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop))
512 $loopnb++; $newout =
'';
514 if ($reg[1] ==
'DAY') {
516 $newout = $tmp[
'mday'];
517 } elseif ($reg[1] ==
'MONTH') {
519 $newout = $tmp[
'mon'];
520 } elseif ($reg[1] ==
'YEAR') {
522 $newout = $tmp[
'year'];
523 } elseif ($reg[1] ==
'PREVIOUS_DAY') {
526 $newout = $tmp2[
'day'];
527 } elseif ($reg[1] ==
'PREVIOUS_MONTH') {
530 $newout = $tmp2[
'month'];
531 } elseif ($reg[1] ==
'PREVIOUS_YEAR') {
533 $newout = ($tmp[
'year'] - 1);
534 } elseif ($reg[1] ==
'NEXT_DAY') {
537 $newout = $tmp2[
'day'];
538 } elseif ($reg[1] ==
'NEXT_MONTH') {
541 $newout = $tmp2[
'month'];
542 } elseif ($reg[1] ==
'NEXT_YEAR') {
544 $newout = ($tmp[
'year'] + 1);
545 } elseif ($reg[1] ==
'MYCOMPANY_COUNTRY_ID' || $reg[1] ==
'MYCOUNTRY_ID' || $reg[1] ==
'MYCOUNTRYID') {
546 $newout = $mysoc->country_id;
547 } elseif ($reg[1] ==
'USER_ID' || $reg[1] ==
'USERID') {
549 } elseif ($reg[1] ==
'USER_SUPERVISOR_ID' || $reg[1] ==
'SUPERVISOR_ID' || $reg[1] ==
'SUPERVISORID') {
550 $newout = $user->fk_user;
551 } elseif ($reg[1] ==
'ENTITY_ID' || $reg[1] ==
'ENTITYID') {
552 $newout = $conf->entity;
557 $out = preg_replace(
'/__'.preg_quote($reg[1],
'/').
'__/', $newout, $out);
562 if (preg_match(
'/^array/', $check)) {
563 if (!is_array($out) || empty($out)) {
566 $tmparray = explode(
':', $check);
567 if (!empty($tmparray[1])) {
568 $tmpcheck = $tmparray[1];
570 $tmpcheck =
'alphanohtml';
572 foreach ($out as $outkey => $outval) {
573 $out[$outkey] =
checkVal($outval, $tmpcheck, $filter, $options);
578 $out =
checkVal($out, $check, $filter, $options);
582 if ($paramname ==
'backtopage') {
583 $out = str_replace(
'\\',
'/', $out);
584 $out = preg_replace(array(
'/^\/\/+/',
'/^[a-z]*:/i'),
'', $out);
589 if (empty($method) || $method == 3 || $method == 4)
591 if (preg_match(
'/^search_/', $paramname) || in_array($paramname, array(
'sortorder',
'sortfield')))
601 $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out;
621 function GETPOSTINT($paramname, $method = 0, $filter = null, $options = null, $noreplace = 0)
623 return (
int)
GETPOST($paramname,
'int', $method, $filter, $options, $noreplace);
635 function checkVal($out =
'', $check =
'alphanohtml', $filter = null, $options = null)
643 if (!is_numeric($out)) { $out =
''; }
646 if (preg_match(
'/[^0-9,-]+/i', $out)) $out =
'';
649 $out = filter_var($out, FILTER_SANITIZE_STRING);
652 $out = filter_var($out, FILTER_SANITIZE_EMAIL);
658 if (preg_match(
'/[^a-z]+/i', $out)) $out =
'';
665 if (preg_match(
'/[^a-z0-9_\-\.]+/i', $out)) $out =
'';
672 if (preg_match(
'/[^a-z0-9_\-\.,]+/i', $out)) $out =
'';
680 if (!is_array($out)) {
683 $out = str_replace(array(
'"',
'"'),
'', trim($out));
684 $out = str_replace(array(
'../'),
'', $out);
690 if (!is_array($out)) {
693 $out = str_replace(array(
'"',
'"'),
'', trim($out));
694 $out = str_replace(array(
'../'),
'', $out);
701 if (empty($filter))
return 'BadFourthParameterForGETPOST';
702 $out = filter_var($out, $filter, $options);
711 if (!function_exists(
'dol_getprefix'))
721 function dol_getprefix($mode =
'')
724 if ($mode ==
'email')
728 if (!empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID))
730 if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID !=
'SERVER_NAME')
return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
735 if (!empty($conf->file->instance_unique_id)) return $conf->file->instance_unique_id;
738 return
dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3');
742 global $dolibarr_main_instance_unique_id, $dolibarr_main_cookie_cryptkey;
743 $tmp_instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ? '' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
746 if (!empty($tmp_instance_unique_id)) {
747 return $tmp_instance_unique_id;
755 return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT,
'3');
771 global $conf, $langs, $user, $mysoc;
775 if (!file_exists($fullpath)) {
776 dol_syslog(
'functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_WARNING);
780 if (!empty($classname) && !class_exists($classname)) {
781 return include $fullpath;
783 return include_once $fullpath;
802 $path = preg_replace(
'/^\//',
'', $path);
806 $res = DOL_DOCUMENT_ROOT.
'/'.$path;
807 if (is_array($conf->file->dol_document_root))
809 foreach ($conf->file->dol_document_root as $key => $dirroot)
815 if (file_exists($dirroot.
'/'.$path))
817 $res = $dirroot.
'/'.$path;
822 if ($returnemptyifnotfound)
824 if ($returnemptyifnotfound == 1 || !file_exists($res))
return '';
833 if ($type == 1) $res = DOL_URL_ROOT.
'/'.$path;
834 if ($type == 2) $res = DOL_MAIN_URL_ROOT.
'/'.$path;
835 if ($type == 3) $res = DOL_URL_ROOT.
'/'.$path;
837 foreach ($conf->file->dol_document_root as $key => $dirroot)
843 global $dolibarr_main_url_root;
846 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
847 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
850 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
'/'.$path;
854 preg_match(
'/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);
855 if (!empty($regs[1]))
858 if (file_exists($dirroot.
'/'.$regs[1]))
862 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
866 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
870 global $dolibarr_main_url_root;
873 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
874 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
877 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).$conf->file->dol_url_root[$key].
'/'.$path;
902 $myclone = unserialize(serialize($object));
904 $myclone = clone $object;
922 if (empty($conf->dol_optimize_smallscreen))
return $size;
923 if ($type ==
'width' && $size > 250)
return 250;
944 $filesystem_forbidden_chars = array(
'<',
'>',
'/',
'\\',
'?',
'*',
'|',
'"',
':',
'°',
'$',
';',
'--');
960 $filesystem_forbidden_chars = array(
'<',
'>',
'?',
'*',
'|',
'"',
'°');
977 $string = rawurlencode($str);
978 $replacements = array(
979 '%C3%80' =>
'A',
'%C3%81' =>
'A',
'%C3%82' =>
'A',
'%C3%83' =>
'A',
'%C3%84' =>
'A',
'%C3%85' =>
'A',
980 '%C3%88' =>
'E',
'%C3%89' =>
'E',
'%C3%8A' =>
'E',
'%C3%8B' =>
'E',
981 '%C3%8C' =>
'I',
'%C3%8D' =>
'I',
'%C3%8E' =>
'I',
'%C3%8F' =>
'I',
982 '%C3%92' =>
'O',
'%C3%93' =>
'O',
'%C3%94' =>
'O',
'%C3%95' =>
'O',
'%C3%96' =>
'O',
983 '%C3%99' =>
'U',
'%C3%9A' =>
'U',
'%C3%9B' =>
'U',
'%C3%9C' =>
'U',
984 '%C3%A0' =>
'a',
'%C3%A1' =>
'a',
'%C3%A2' =>
'a',
'%C3%A3' =>
'a',
'%C3%A4' =>
'a',
'%C3%A5' =>
'a',
986 '%C3%A8' =>
'e',
'%C3%A9' =>
'e',
'%C3%AA' =>
'e',
'%C3%AB' =>
'e',
987 '%C3%AC' =>
'i',
'%C3%AD' =>
'i',
'%C3%AE' =>
'i',
'%C3%AF' =>
'i',
989 '%C3%B2' =>
'o',
'%C3%B3' =>
'o',
'%C3%B4' =>
'o',
'%C3%B5' =>
'o',
'%C3%B6' =>
'o',
990 '%C3%B9' =>
'u',
'%C3%BA' =>
'u',
'%C3%BB' =>
'u',
'%C3%BC' =>
'u',
993 $string = strtr($string, $replacements);
994 return rawurldecode($string);
999 "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
1000 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
1001 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
1002 \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
1003 \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
1004 \xF9\xFA\xFB\xFC\xFD\xFF",
1012 $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"));
1030 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
",",
";",
"=",
'°');
1031 $forbidden_chars_to_remove = array();
1032 if (is_array($badcharstoreplace)) $forbidden_chars_to_replace = $badcharstoreplace;
1035 return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove,
"", $str));
1054 if ($removetabcrlf) {
1055 return preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $str);
1057 return preg_replace(
'/[\x00-\x08\x11-\x12\x14-\x1F\x7F]/u',
'', $str);
1073 $substitjs = array(
"'"=>
"\\'",
"\r"=>
'\\r');
1075 if (empty($noescapebackslashn)) { $substitjs[
"\n"] =
'\\n'; $substitjs[
'\\'] =
'\\\\'; }
1076 if (empty($mode)) { $substitjs[
"'"] =
"\\'"; $substitjs[
'"'] =
"\\'"; } elseif ($mode == 1) $substitjs[
"'"] =
"\\'";
1077 elseif ($mode == 2) { $substitjs[
'"'] =
'\\"'; } elseif ($mode == 3) { $substitjs[
"'"] =
"\\'"; $substitjs[
'"'] =
"\\\""; }
1078 return strtr($stringtoescape, $substitjs);
1089 return str_replace(
'"',
'\"', $stringtoescape);
1103 function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $keepmoretags =
'', $escapeonlyhtmltags = 0)
1105 if ($keepmoretags ==
'common') $keepmoretags =
'html,body,a,b,em,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody';
1109 if ($escapeonlyhtmltags) {
1110 $tmp = htmlspecialchars_decode($stringtoescape, ENT_COMPAT);
1112 $tmp = html_entity_decode($stringtoescape, ENT_COMPAT,
'UTF-8');
1114 if (!$keepb) $tmp = strtr($tmp, array(
"<b>"=>
'',
'</b>'=>
''));
1115 if (!$keepn) $tmp = strtr($tmp, array(
"\r"=>
'\\r',
"\n"=>
'\\n'));
1116 if ($escapeonlyhtmltags) {
1117 return htmlspecialchars($tmp, ENT_COMPAT,
'UTF-8');
1119 return htmlentities($tmp, ENT_COMPAT,
'UTF-8');
1132 if (function_exists(
'mb_strtolower')) {
1133 return mb_strtolower($string, $encoding);
1135 return strtolower($string);
1148 if (function_exists(
'mb_strtoupper')) {
1149 return mb_strtoupper($string, $encoding);
1151 return strtoupper($string);
1164 if (function_exists(
'mb_substr')) {
1165 return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1, null, $encoding);
1167 return ucfirst($string);
1180 if (function_exists(
'mb_convert_case')) {
1181 return mb_convert_case($string, MB_CASE_TITLE, $encoding);
1183 return ucwords($string);
1208 function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
'', $restricttologhandler =
'', $logcontext = null)
1210 global $conf, $user, $debugbar;
1213 if (empty($conf->syslog->enabled))
return;
1216 if (defined(
'USEEXTERNALSERVER') && !defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
1217 global $website, $websitekey;
1218 if (is_object($website) && !empty($website->ref)) $suffixinfilename .=
'_website_'.$website->ref;
1219 elseif (!empty($websitekey)) $suffixinfilename .=
'_website_'.$websitekey;
1224 foreach ($conf->loghandlers as $loghandlerinstance)
1226 $loghandlerinstance->setIdent($ident);
1230 if (!empty($message))
1233 $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');
1234 if (!array_key_exists($level, $logLevels))
1236 throw new Exception(
'Incorrect log level');
1238 if ($level > $conf->global->SYSLOG_LEVEL)
return;
1240 $message = preg_replace(
'/password=\'[^\']*\'/',
'password=\'hidden\'', $message);
1243 if ((!empty($_REQUEST[
'logtohtml']) && !empty($conf->global->MAIN_ENABLE_LOG_TO_HTML))
1244 || (!empty($user->rights->debugbar->read) && is_object($debugbar)))
1246 $conf->logbuffer[] =
dol_print_date(time(),
"%Y-%m-%d %H:%M:%S").
" ".$logLevels[$level].
" ".$message;
1251 if (!empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && !empty($_GET[
"log"]))
1253 print "\n\n<!-- Log start\n";
1254 print $message.
"\n";
1255 print "Log end -->\n";
1259 'message' => $message,
1260 'script' => (isset(
$_SERVER[
'PHP_SELF']) ? basename(
$_SERVER[
'PHP_SELF'],
'.php') :
false),
1262 'user' => ((is_object($user) && $user->id) ? $user->login :
false),
1267 if (!empty($remoteip)) {
1268 $data[
'ip'] = $remoteip;
1270 if (!empty(
$_SERVER[
'HTTP_X_FORWARDED_FOR']) &&
$_SERVER[
'HTTP_X_FORWARDED_FOR'] != $remoteip) $data[
'ip'] =
$_SERVER[
'HTTP_X_FORWARDED_FOR'].
' -> '.$data[
'ip'];
1271 elseif (!empty(
$_SERVER[
'HTTP_CLIENT_IP']) &&
$_SERVER[
'HTTP_CLIENT_IP'] != $remoteip) $data[
'ip'] =
$_SERVER[
'HTTP_CLIENT_IP'].
' -> '.$data[
'ip'];
1273 elseif (!empty(
$_SERVER[
'SERVER_ADDR'])) $data[
'ip'] =
$_SERVER[
'SERVER_ADDR'];
1275 elseif (!empty(
$_SERVER[
'COMPUTERNAME'])) $data[
'ip'] =
$_SERVER[
'COMPUTERNAME'].(empty(
$_SERVER[
'USERNAME']) ?
'' :
'@'.$_SERVER[
'USERNAME']);
1277 elseif (!empty(
$_SERVER[
'LOGNAME'])) $data[
'ip'] =
'???@'.$_SERVER[
'LOGNAME'];
1279 foreach ($conf->loghandlers as $loghandlerinstance)
1281 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler)
continue;
1282 $loghandlerinstance->export($data, $suffixinfilename);
1289 foreach ($conf->loghandlers as $loghandlerinstance)
1291 $loghandlerinstance->setIdent($ident);
1309 if (strpos($url,
'?') > 0) {
1310 $url .=
'&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=1';
1312 $url .=
'?dol_hide_menuinpopup=1&dol_hide_leftmenu=1&dol_openinpopup=1';
1316 $out =
'<a class="button bordertransp button_'.$name.
'"'.$disabled.
' title="'.
dol_escape_htmltag($label).
'">'.$buttonstring.
'</a>';
1317 $out .=
'<script language="javascript">
1318 jQuery(document).ready(function () {
1319 jQuery(".button_'.$name.
'").click(function () {
1320 var $dialog = $(\'<div></div>\').html(\'<iframe class="iframedialog" style="border: 0px;" src="'.DOL_URL_ROOT.$url.
'" width="100%" height="98%"></iframe>\')
1324 height: (window.innerHeight - 150),
1328 $dialog.dialog(\'open\');
1351 function dol_fiche_head($links = array(), $active =
'0', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
1353 print dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow, $moretabssuffix);
1371 function dol_get_fiche_head($links = array(), $active =
'', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
1373 global $conf, $langs, $hookmanager;
1377 if (!empty($conf->dol_optimize_smallscreen)) $showtitle = 0;
1379 $out =
"\n".
'<!-- dol_fiche_head - dol_get_fiche_head -->';
1381 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
1382 $out .=
'<div class="tabs'.($picto ?
'' :
' nopaddingleft').
'" data-role="controlgroup" data-type="horizontal">'.
"\n";
1386 if ($morehtmlright) $out .=
'<div class="inline-block floatright tabsElem">'.$morehtmlright.
'</div>';
1389 if (!empty($title) && $showtitle && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
1392 $out .=
'<a class="tabTitle">';
1393 if ($picto) $out .=
img_picto($title, ($pictoisfullpath ?
'' :
'object_').$picto,
'', $pictoisfullpath, 0, 0,
'',
'imgTabTitle').
' ';
1394 $out .=
'<span class="tabTitleText">'.dol_trunc($title, $limittitle).
'</span>';
1402 if (is_array($links) && !empty($links))
1404 $keys = array_keys($links);
1405 if (count($keys)) $maxkey = max($keys);
1410 if (empty($limittoshow)) {
1411 $limittoshow = (empty($conf->global->MAIN_MAXTABS_IN_CARD) ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD);
1413 if (!empty($conf->dol_optimize_smallscreen)) $limittoshow = 2;
1419 for ($i = 0; $i <= $maxkey; $i++)
1421 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
1423 if ($i >= $limittoshow) $limittoshow--;
1427 for ($i = 0; $i <= $maxkey; $i++)
1429 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
1435 if ($i < $limittoshow || $isactive)
1437 $out .=
'<div class="inline-block tabsElem'.($isactive ?
' tabsElemActive' :
'').((!$isactive && !empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT)) ?
' hideonprint' :
'').
'"><!-- id tab = '.(empty($links[$i][2]) ?
'' : $links[$i][2]).
' -->';
1438 if (isset($links[$i][2]) && $links[$i][2] ==
'image')
1440 if (!empty($links[$i][0]))
1442 $out .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
1444 $out .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
1446 } elseif (!empty($links[$i][1]))
1451 $out .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="tabactive tab inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
1452 $out .= $links[$i][1];
1453 $out .=
'</a>'.
"\n";
1455 $out .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="tabunactive tab inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
1456 $out .= $links[$i][1];
1457 $out .=
'</a>'.
"\n";
1466 $outmore .=
'<div class="popuptabset wordwrap">';
1468 $outmore .=
'<div class="popuptab wordwrap" style="display:inherit;">';
1469 if (isset($links[$i][2]) && $links[$i][2] ==
'image')
1471 if (!empty($links[$i][0]))
1472 $outmore .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
1473 else $outmore .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
1474 } elseif (!empty($links[$i][1]))
1476 $outmore .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="wordwrap inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
1477 $outmore .= preg_replace(
'/([a-z])\/([a-z])/i',
'\\1 / \\2', $links[$i][1]);
1478 $outmore .=
'</a>'.
"\n";
1480 $outmore .=
'</div>';
1486 if ($popuptab) $outmore .=
'</div>';
1490 $left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
1491 $right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
1492 $widthofpopup = 200;
1494 $tabsname = $moretabssuffix;
1495 if (empty($tabsname)) { $tabsname = str_replace(
"@",
"", $picto); }
1496 $out .=
'<div id="moretabs'.$tabsname.
'" class="inline-block tabsElem">';
1497 $out .=
'<a href="#" class="tab moretab inline-block tabunactive">'.$langs->trans(
"More").
'... ('.$nbintab.
')</a>';
1498 $out .=
'<div id="moretabsList'.$tabsname.
'" style="width: '.$widthofpopup.
'px; position: absolute; '.$left.
': -999em; text-align: '.$left.
'; margin:0px; padding:2px; z-index:10;">';
1501 $out .=
'<div></div>';
1505 $out .=
"$('#moretabs".$tabsname.
"').mouseenter( function() {
1506 var x = this.offsetLeft, y = this.offsetTop;
1507 console.log('mouseenter ".$left.
" x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
1508 if ((window.innerWidth - x) < ".($widthofpopup + 10).
") {
1509 $('#moretabsList".$tabsname.
"').css('".$right.
"','8px');
1511 $('#moretabsList".$tabsname.
"').css('".$left.
"','auto');
1514 $out .=
"$('#moretabs".$tabsname.
"').mouseleave( function() { console.log('mouseleave ".$left.
"'); $('#moretabsList".$tabsname.
"').css('".$left.
"','-999em');});";
1515 $out .=
"</script>";
1518 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
1522 if (!$notab || $notab == -1 || $notab == -2) $out .=
"\n".
'<div class="tabBar'.($notab == -1 ?
'' : ($notab == -2 ?
' tabBarNoTop' :
' tabBarWithBottom')).
'">'.
"\n";
1524 $parameters = array(
'tabname' => $active,
'out' => $out);
1525 $reshook = $hookmanager->executeHooks(
'printTabsHead', $parameters);
1528 $out = $hookmanager->resPrint;
1554 if (!$notab || $notab == -1)
return "\n</div>\n";
1577 function dol_banner_tab($object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $onlybanner = 0, $morehtmlright =
'')
1579 global $conf, $form, $user, $langs;
1583 $maxvisiblephotos = 1;
1585 $entity = (empty($object->entity) ? $conf->entity : $object->entity);
1586 $showbarcode = empty($conf->barcode->enabled) ? 0 : ($object->barcode ? 1 : 0);
1587 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0;
1588 $modulepart =
'unknown';
1590 if ($object->element ==
'societe') $modulepart =
'societe';
1591 if ($object->element ==
'contact') $modulepart =
'contact';
1592 if ($object->element ==
'member') $modulepart =
'memberphoto';
1593 if ($object->element ==
'user') $modulepart =
'userphoto';
1594 if ($object->element ==
'product') $modulepart =
'product';
1595 if ($object->element ==
'ticket') $modulepart =
'ticket';
1597 if (class_exists(
"Imagick"))
1599 if ($object->element ==
'propal') $modulepart =
'propal';
1600 if ($object->element ==
'commande') $modulepart =
'commande';
1601 if ($object->element ==
'facture') $modulepart =
'facture';
1602 if ($object->element ==
'fichinter') $modulepart =
'ficheinter';
1603 if ($object->element ==
'contrat') $modulepart =
'contract';
1604 if ($object->element ==
'supplier_proposal') $modulepart =
'supplier_proposal';
1605 if ($object->element ==
'order_supplier') $modulepart =
'supplier_order';
1606 if ($object->element ==
'invoice_supplier') $modulepart =
'supplier_invoice';
1607 if ($object->element ==
'expensereport') $modulepart =
'expensereport';
1610 if ($object->element ==
'product')
1612 $width = 80; $cssclass =
'photoref';
1613 $showimage = $object->is_photo_available($conf->product->multidir_output[$entity]);
1614 $maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5);
1615 if ($conf->browser->layout ==
'phone') $maxvisiblephotos = 1;
1617 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos(
'product', $conf->product->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0).
'</div>';
1619 if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
1621 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
1623 $nophoto =
'/public/theme/common/nophoto.png';
1624 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" alt="No photo"'.($width ?
' style="width: '.$width.
'px"' :
'').
' src="'.DOL_URL_ROOT.$nophoto.
'"></div>';
1627 } elseif ($object->element ==
'ticket') {
1628 $width = 80; $cssclass =
'photoref';
1629 $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity].
'/'.$object->ref);
1630 $maxvisiblephotos = (isset($conf->global->TICKET_MAX_VISIBLE_PHOTO) ? $conf->global->TICKET_MAX_VISIBLE_PHOTO : 2);
1631 if ($conf->browser->layout ==
'phone') $maxvisiblephotos = 1;
1635 $showphoto = $object->show_photos(
'ticket', $conf->ticket->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0);
1636 if ($object->nbphoto > 0)
1638 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$showphoto.
'</div>';
1645 if (!empty($conf->global->TICKET_NODISPLAYIFNOPHOTO)) {
1647 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
1649 $nophoto =
img_picto(
'No photo',
'object_ticket');
1650 $morehtmlleft .=
'<!-- No photo to show -->';
1651 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
1652 $morehtmlleft .= $nophoto;
1653 $morehtmlleft .=
'</div></div>';
1659 if ($modulepart !=
'unknown')
1663 if (in_array($modulepart, array(
'propal',
'commande',
'facture',
'ficheinter',
'contract',
'supplier_order',
'supplier_proposal',
'supplier_invoice',
'expensereport')) && class_exists(
"Imagick"))
1666 $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]).
"/";
1667 if (in_array($modulepart, array(
'invoice_supplier',
'supplier_invoice')))
1669 $subdir =
get_exdir($object->id, 2, 0, 1, $object, $modulepart);
1670 $subdir .= ((!empty($subdir) && !preg_match(
'/\/$/', $subdir)) ?
'/' :
'').$objectref;
1672 $subdir =
get_exdir($object->id, 0, 0, 1, $object, $modulepart);
1674 if (empty($subdir)) $subdir =
'errorgettingsubdirofobject';
1676 $filepath = $dir_output.$subdir.
"/";
1678 $filepdf = $filepath.$objectref.
".pdf";
1679 $relativepath = $subdir.
'/'.$objectref.
'.pdf';
1682 $fileimage = $filepdf.
'_preview.png';
1683 $relativepathimage = $relativepath.
'_preview.png';
1685 $pdfexists = file_exists($filepdf);
1691 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf)))
1693 if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS))
1695 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1697 if ($ret < 0) $error++;
1702 if ($pdfexists && !$error)
1704 $heightforphotref = 80;
1705 if (!empty($conf->dol_optimize_smallscreen)) $heightforphotref = 60;
1707 if (file_exists($fileimage))
1709 $phototoshow =
'<div class="photoref">';
1710 $phototoshow .=
'<img height="'.$heightforphotref.
'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
1711 $phototoshow .=
'</div>';
1714 } elseif (!$phototoshow) {
1715 $phototoshow .= $form->showphoto($modulepart, $object, 0, 0, 0,
'photoref',
'small', 1, 0, $maxvisiblephotos);
1719 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
1720 $morehtmlleft .= $phototoshow;
1721 $morehtmlleft .=
'</div>';
1727 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
1728 if ($object->element ==
'action')
1731 $cssclass =
'photorefcenter';
1732 $nophoto =
img_picto(
'No photo',
'title_agenda');
1734 $width = 14; $cssclass =
'photorefcenter';
1735 $picto = $object->picto;
1736 if ($object->element ==
'project' && !$object->public) $picto =
'project';
1737 $nophoto =
img_picto(
'No photo',
'object_'.$picto);
1739 $morehtmlleft .=
'<!-- No photo to show -->';
1740 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
1741 $morehtmlleft .= $nophoto;
1742 $morehtmlleft .=
'</div></div>';
1744 $morehtmlleft .=
'</div>';
1749 if ($showbarcode) $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object).
'</div>';
1751 if ($object->element ==
'societe')
1753 if (!empty($conf->use_javascript_ajax) && $user->rights->societe->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE))
1755 $morehtmlstatus .=
ajax_object_onoff($object,
'status',
'status',
'InActivity',
'ActivityCeased');
1757 $morehtmlstatus .= $object->getLibStatut(6);
1759 } elseif ($object->element ==
'product')
1762 if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
1763 $morehtmlstatus .=
ajax_object_onoff($object,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
1765 $morehtmlstatus .=
'<span class="statusrefsell">'.$object->getLibStatut(6, 0).
'</span>';
1767 $morehtmlstatus .=
' ';
1769 if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
1770 $morehtmlstatus .=
ajax_object_onoff($object,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
1772 $morehtmlstatus .=
'<span class="statusrefbuy">'.$object->getLibStatut(6, 1).
'</span>';
1774 } elseif (in_array($object->element, array(
'facture',
'invoice',
'invoice_supplier',
'chargesociales',
'loan'))) {
1775 $tmptxt = $object->getLibStatut(6, $object->totalpaye);
1776 if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt = $object->getLibStatut(5, $object->totalpaye);
1777 $morehtmlstatus .= $tmptxt;
1778 } elseif ($object->element ==
'contrat' || $object->element ==
'contract') {
1779 if ($object->statut == 0) $morehtmlstatus .= $object->getLibStatut(5);
1780 else $morehtmlstatus .= $object->getLibStatut(4);
1781 } elseif ($object->element ==
'facturerec') {
1782 if ($object->frequency == 0) $morehtmlstatus .= $object->getLibStatut(2);
1783 else $morehtmlstatus .= $object->getLibStatut(5);
1784 } elseif ($object->element ==
'project_task') {
1785 $object->fk_statut = 1;
1786 if ($object->progress > 0) $object->fk_statut = 2;
1787 if ($object->progress >= 100) $object->fk_statut = 3;
1788 $tmptxt = $object->getLibStatut(5);
1789 $morehtmlstatus .= $tmptxt;
1791 $tmptxt = $object->getLibStatut(6);
1792 if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt = $object->getLibStatut(5);
1793 $morehtmlstatus .= $tmptxt;
1797 if (!empty($conf->accounting->enabled) && in_array($object->element, array(
'bank',
'paiementcharge',
'facture',
'invoice',
'invoice_supplier',
'expensereport',
'payment_various')))
1800 if (method_exists($object,
'getVentilExportCompta'))
1802 $accounted = $object->getVentilExportCompta();
1803 $langs->load(
"accountancy");
1804 $morehtmlstatus .=
'</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? $langs->trans(
"Accounted") : $langs->trans(
"NotYetAccounted")).
'</span>';
1809 if (!empty($object->name_alias)) $morehtmlref .=
'<div class="refidno">'.$object->name_alias.
'</div>';
1812 if (in_array($object->element, array(
'product',
'bank_account',
'project_task')))
1814 if (!empty($object->label)) $morehtmlref .=
'<div class="refidno">'.$object->label.
'</div>';
1817 if (method_exists($object,
'getBannerAddress') && !in_array($object->element, array(
'product',
'bookmark',
'ecm_directories',
'ecm_files')))
1819 $moreaddress = $object->getBannerAddress(
'refaddress', $object);
1821 $morehtmlref .=
'<div class="refidno">';
1822 $morehtmlref .= $moreaddress;
1823 $morehtmlref .=
'</div>';
1826 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))
1828 $morehtmlref .=
'<div style="clear: both;"></div>';
1829 $morehtmlref .=
'<div class="refidno">';
1830 $morehtmlref .= $langs->trans(
"TechnicalID").
': '.$object->id;
1831 $morehtmlref .=
'</div>';
1834 print '<div class="'.($onlybanner ?
'arearefnobottom ' :
'arearef ').
'heightref valignmiddle centpercent">';
1835 print $form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
1837 print '<div class="underrefbanner clearboth"></div>';
1853 if ($fieldrequired) $ret .=
'<span class="fieldrequired">';
1854 $ret .=
'<label for="'.$fieldkey.
'">';
1855 $ret .= $langs->trans($langkey);
1857 if ($fieldrequired) $ret .=
'</span>';
1871 $ret =
' '.$bc[$var];
1872 if ($moreclass) $ret = preg_replace(
'/class=\"/',
'class="'.$moreclass.
' ', $ret);
1889 function dol_format_address($object, $withcountry = 0, $sep =
"\n", $outputlangs =
'', $mode = 0, $extralangcode =
'')
1891 global $conf, $langs;
1894 $countriesusingstate = array(
'AU',
'CA',
'US',
'IN',
'GB',
'ES',
'UK',
'TR');
1899 $ret .= ($extralangcode ? $object->array_languages[
'address'][$extralangcode] : $object->address);
1902 if (isset($object->country_code) && in_array($object->country_code, array(
'AU',
'CA',
'US')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) {
1903 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : $object->town);
1904 $ret .= ($ret ? $sep :
'').$town;
1905 if (!empty($object->state)) {
1906 $ret .= ($ret ?
", " :
'').$object->state;
1908 if ($object->zip) $ret .= ($ret ?
", " :
'').$object->zip;
1909 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'GB',
'UK'))) {
1910 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : $object->town);
1911 $ret .= ($ret ? $sep :
'').$town;
1912 if (!empty($object->state)) {
1913 $ret .= ($ret ?
", " :
'').$object->state;
1915 if ($object->zip) $ret .= ($ret ? $sep :
'').$object->zip;
1916 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'ES',
'TR'))) {
1917 $ret .= ($ret ? $sep :
'').$object->zip;
1918 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : $object->town);
1919 $ret .= ($town ? (($object->zip ?
' ' :
'').$town) :
'');
1920 if (!empty($object->state)) {
1921 $ret .=
"\n".$object->state;
1923 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'IT'))) {
1924 $ret .= ($ret ? $sep :
'').$object->zip;
1925 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : $object->town);
1926 $ret .= ($town ? (($object->zip ?
' ' :
'').$town) :
'');
1927 $ret .= (empty($object->state_code) ?
'' : (
' '.$object->state_code));
1929 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : $object->town);
1930 $ret .= $object->zip ? (($ret ? $sep :
'').$object->zip) :
'';
1931 $ret .= ($town ? (($object->zip ?
' ' : ($ret ? $sep :
'')).$town) :
'');
1932 if (!empty($object->state) && in_array($object->country_code, $countriesusingstate)) {
1933 $ret .= ($ret ?
", " :
'').$object->state;
1936 if (!is_object($outputlangs)) $outputlangs = $langs;
1938 $langs->load(
"dict");
1939 $ret .= (empty($object->country_code) ?
'' : ($ret ? $sep :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$object->country_code)));
1957 if ((abs($ts) <= 0x7FFFFFFF)) {
1958 return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts);
1959 }
else return 'Error date into a not supported range';
1983 function dol_print_date($time, $format =
'', $tzoutput =
'auto', $outputlangs =
'', $encodetooutput =
false)
1985 global $conf, $langs;
1987 if ($tzoutput ===
'auto') {
1988 $tzoutput = (empty($conf) ?
'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey :
'tzserver'));
1993 $offsettz = $offsetdst = 0;
1997 if (is_string($tzoutput))
1999 if ($tzoutput ==
'tzserver')
2002 $offsettzstring = @date_default_timezone_get();
2005 } elseif ($tzoutput ==
'tzuser' || $tzoutput ==
'tzuserrel')
2008 $offsettzstring = (empty($_SESSION[
'dol_tz_string']) ?
'UTC' : $_SESSION[
'dol_tz_string']);
2009 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
2010 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
2014 if (!is_object($outputlangs)) $outputlangs = $langs;
2015 if (!$format) $format =
'daytextshort';
2019 $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array(
'day',
'dayhour'))) ? 1 : 0;
2020 $format = preg_replace(
'/inputnoreduce/',
'', $format);
2021 $formatwithoutreduce = preg_replace(
'/reduceformat/',
'', $format);
2022 if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat = 1; }
2026 if ($format ==
'day') $format = ($outputlangs->trans(
"FormatDateShort") !=
"FormatDateShort" ? $outputlangs->trans(
"FormatDateShort") : $conf->format_date_short);
2027 elseif ($format ==
'hour') $format = ($outputlangs->trans(
"FormatHourShort") !=
"FormatHourShort" ? $outputlangs->trans(
"FormatHourShort") : $conf->format_hour_short);
2028 elseif ($format ==
'hourduration') $format = ($outputlangs->trans(
"FormatHourShortDuration") !=
"FormatHourShortDuration" ? $outputlangs->trans(
"FormatHourShortDuration") : $conf->format_hour_short_duration);
2029 elseif ($format ==
'daytext') $format = ($outputlangs->trans(
"FormatDateText") !=
"FormatDateText" ? $outputlangs->trans(
"FormatDateText") : $conf->format_date_text);
2030 elseif ($format ==
'daytextshort') $format = ($outputlangs->trans(
"FormatDateTextShort") !=
"FormatDateTextShort" ? $outputlangs->trans(
"FormatDateTextShort") : $conf->format_date_text_short);
2031 elseif ($format ==
'dayhour') $format = ($outputlangs->trans(
"FormatDateHourShort") !=
"FormatDateHourShort" ? $outputlangs->trans(
"FormatDateHourShort") : $conf->format_date_hour_short);
2032 elseif ($format ==
'dayhoursec') $format = ($outputlangs->trans(
"FormatDateHourSecShort") !=
"FormatDateHourSecShort" ? $outputlangs->trans(
"FormatDateHourSecShort") : $conf->format_date_hour_sec_short);
2033 elseif ($format ==
'dayhourtext') $format = ($outputlangs->trans(
"FormatDateHourText") !=
"FormatDateHourText" ? $outputlangs->trans(
"FormatDateHourText") : $conf->format_date_hour_text);
2034 elseif ($format ==
'dayhourtextshort') $format = ($outputlangs->trans(
"FormatDateHourTextShort") !=
"FormatDateHourTextShort" ? $outputlangs->trans(
"FormatDateHourTextShort") : $conf->format_date_hour_text_short);
2036 elseif ($format ==
'dayhourlog') $format =
'%Y%m%d%H%M%S';
2037 elseif ($format ==
'dayhourldap') $format =
'%Y%m%d%H%M%SZ';
2038 elseif ($format ==
'dayhourxcard') $format =
'%Y%m%dT%H%M%SZ';
2039 elseif ($format ==
'dayxcard') $format =
'%Y%m%d';
2040 elseif ($format ==
'dayrfc') $format =
'%Y-%m-%d';
2041 elseif ($format ==
'dayhourrfc') $format =
'%Y-%m-%dT%H:%M:%SZ';
2042 elseif ($format ==
'standard') $format =
'%Y-%m-%d %H:%M:%S';
2046 $format = str_replace(
'%Y',
'%y', $format);
2047 $format = str_replace(
'yyyy',
'yy', $format);
2054 if (preg_match(
'/%b/i', $format))
2057 $format = str_replace(
'%b',
'__b__', $format);
2058 $format = str_replace(
'%B',
'__B__', $format);
2060 if (preg_match(
'/%a/i', $format))
2063 $format = str_replace(
'%a',
'__a__', $format);
2064 $format = str_replace(
'%A',
'__A__', $format);
2070 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))
2072 dol_print_error(
"Functions.lib::dol_print_date function called with a bad value from page ".
$_SERVER[
"PHP_SELF"]);
2074 } elseif (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg))
2077 dol_syslog(
"Functions.lib::dol_print_date function called with a bad value from page ".
$_SERVER[
"PHP_SELF"], LOG_WARNING);
2080 $syear = (!empty($reg[1]) ? $reg[1] :
'');
2081 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
2082 $sday = (!empty($reg[3]) ? $reg[3] :
'');
2083 $shour = (!empty($reg[4]) ? $reg[4] :
'');
2084 $smin = (!empty($reg[5]) ? $reg[5] :
'');
2085 $ssec = (!empty($reg[6]) ? $reg[6] :
'');
2087 $time =
dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear,
true);
2088 $ret = adodb_strftime($format, $time + $offsettz + $offsetdst, $to_gmt);
2091 if ($time < 100000000000)
2093 $timetouse = $time + $offsettz + $offsetdst;
2095 $ret = adodb_strftime($format, $timetouse, $to_gmt);
2096 }
else $ret =
'Bad value '.$time.
' for date';
2099 if (preg_match(
'/__b__/i', $format))
2101 $timetouse = $time + $offsettz + $offsetdst;
2104 $month = adodb_strftime(
'%m', $timetouse);
2105 $month = sprintf(
"%02d", $month);
2106 if ($encodetooutput)
2108 $monthtext = $outputlangs->transnoentities(
'Month'.$month);
2109 $monthtextshort = $outputlangs->transnoentities(
'MonthShort'.$month);
2111 $monthtext = $outputlangs->transnoentitiesnoconv(
'Month'.$month);
2112 $monthtextshort = $outputlangs->transnoentitiesnoconv(
'MonthShort'.$month);
2115 $ret = str_replace(
'__b__', $monthtextshort, $ret);
2116 $ret = str_replace(
'__B__', $monthtext, $ret);
2120 if (preg_match(
'/__a__/i', $format))
2122 $timetouse = $time + $offsettz + $offsetdst;
2124 $w = adodb_strftime(
'%w', $timetouse);
2125 $dayweek = $outputlangs->transnoentitiesnoconv(
'Day'.$w);
2126 $ret = str_replace(
'__A__', $dayweek, $ret);
2127 $ret = str_replace(
'__a__',
dol_substr($dayweek, 0, 3), $ret);
2158 if (empty($conf->global->MAIN_USE_OLD_FUNCTIONS_FOR_GETDATE)) {
2160 $datetimeobj =
new DateTime();
2161 $datetimeobj->setTimestamp($timestamp);
2162 if ($forcetimezone) $datetimeobj->setTimezone(
new DateTimeZone($forcetimezone));
2164 'year'=>((
int) date_format($datetimeobj,
'Y')),
2165 'mon'=>((
int) date_format($datetimeobj,
'm')),
2166 'mday'=>((
int) date_format($datetimeobj,
'd')),
2167 'wday'=>((
int) date_format($datetimeobj,
'w')),
2168 'yday'=>((
int) date_format($datetimeobj,
'z')),
2169 'hours'=>((
int) date_format($datetimeobj,
'H')),
2170 'minutes'=>((
int) date_format($datetimeobj,
'i')),
2171 'seconds'=>((
int) date_format($datetimeobj,
's')),
2176 $usealternatemethod =
false;
2177 if ($timestamp <= 0) $usealternatemethod =
true;
2178 if ($timestamp >= 2145913200) $usealternatemethod =
true;
2180 if ($usealternatemethod)
2182 $arrayinfo = adodb_getdate($timestamp, $fast);
2184 $arrayinfo = getdate($timestamp);
2212 function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm =
'auto', $check = 1)
2218 if ($gm ===
'auto') {
2219 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
2223 if ($hour == -1 || empty($hour)) $hour = 0;
2224 if ($minute == -1 || empty($minute)) $minute = 0;
2225 if ($second == -1 || empty($second)) $second = 0;
2230 if (!$month || !$day)
return '';
2231 if ($day > 31)
return '';
2232 if ($month > 12)
return '';
2233 if ($hour < 0 || $hour > 24)
return '';
2234 if ($minute < 0 || $minute > 60)
return '';
2235 if ($second < 0 || $second > 60)
return '';
2238 if (empty($gm) || ($gm ===
'server' || $gm ===
'tzserver'))
2240 $default_timezone = @date_default_timezone_get();
2241 $localtz =
new DateTimeZone($default_timezone);
2242 } elseif ($gm ===
'user' || $gm ===
'tzuser' || $gm ===
'tzuserrel')
2245 $default_timezone = (empty($_SESSION[
"dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION[
"dol_tz_string"]);
2247 $localtz =
new DateTimeZone($default_timezone);
2250 dol_syslog(
"Warning dol_tz_string contains an invalid value ".$_SESSION[
"dol_tz_string"], LOG_WARNING);
2251 $default_timezone = @date_default_timezone_get();
2253 } elseif (strrpos($gm,
"tz,") !==
false)
2255 $timezone = str_replace(
"tz,",
"", $gm);
2257 $localtz =
new DateTimeZone($timezone);
2260 dol_syslog(
"Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
2264 if (empty($localtz)) {
2265 $localtz =
new DateTimeZone(
'UTC');
2269 $dt =
new DateTime(null, $localtz);
2270 $dt->setDate((
int) $year, (
int) $month, (
int) $day);
2271 $dt->setTime((
int) $hour, (
int) $minute, (
int) $second);
2272 $date = $dt->getTimestamp();
2292 if ($mode ===
'auto') {
2296 if ($mode ==
'gmt') $ret = time();
2297 elseif ($mode ==
'tzserver')
2299 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
2301 $ret = (int) (
dol_now(
'gmt') + ($tzsecond * 3600));
2308 elseif ($mode ==
'tzuser' || $mode ==
'tzuserrel')
2311 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
2312 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
2313 $ret = (int) (
dol_now(
'gmt') + ($offsettz + $offsetdst));
2330 global $conf, $langs;
2333 if (!empty($conf->dol_optimize_smallscreen)) $shortunit = 1;
2336 if (empty($shortvalue) || $size < ($level * 10))
2339 $textunitshort = $langs->trans(
"b");
2340 $textunitlong = $langs->trans(
"Bytes");
2342 $ret = round($size / $level, 0);
2343 $textunitshort = $langs->trans(
"Kb");
2344 $textunitlong = $langs->trans(
"KiloBytes");
2347 if (empty($shortunit)) { $ret .=
' '.$textunitlong; }
else { $ret .=
' '.$textunitshort; }
2365 if (empty($url))
return '';
2367 $link =
'<a href="';
2368 if (!preg_match(
'/^http/i', $url)) $link .=
'http://';
2371 if ($target) $link .=
' target="'.$target.
'"';
2373 if (!preg_match(
'/^http/i', $url)) $link .=
'http://';
2376 return '<div class="nospan float" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe').
' ' :
'').$link.
'</div>';
2391 function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0)
2393 global $conf, $user, $langs, $hookmanager;
2397 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpicto) $withpicto = 0;
2399 if (empty($email))
return ' ';
2401 if (!empty($addlink))
2403 $newemail =
'<a style="text-overflow: ellipsis;" href="';
2404 if (!preg_match(
'/^mailto:/i', $email)) $newemail .=
'mailto:';
2405 $newemail .= $email;
2408 $newemail .=
'</a>';
2411 $langs->load(
"errors");
2412 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
2415 if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create)
2417 $type =
'AC_EMAIL'; $link =
'';
2418 if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) $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>';
2419 if ($link) $newemail =
'<div>'.$newemail.
' '.$link.
'</div>';
2424 $langs->load(
"errors");
2425 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
2430 $rep = ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email,
'object_email.png').
' ' :
'').$newemail;
2433 $parameters = array(
'cid' => $cid,
'socid' => $socid,
'addlink' => $addlink,
'picto' => $withpicto);
2434 $reshook = $hookmanager->executeHooks(
'printEmail', $parameters, $email);
2438 $rep .= $hookmanager->resPrint;
2452 $sql =
"SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX.
"c_socialnetworks";
2453 $sql .=
" WHERE entity=".$conf->entity;
2454 $socialnetworks = array();
2455 $resql = $db->query($sql);
2457 while ($obj = $db->fetch_object(
$resql)) {
2458 $socialnetworks[$obj->code] = array(
2459 'rowid' => $obj->rowid,
2460 'label' => $obj->label,
2462 'icon' => $obj->icon,
2463 'active' => $obj->active,
2467 return $socialnetworks;
2482 global $conf, $user, $langs;
2486 if (empty($value))
return ' ';
2488 if (!empty($type)) {
2489 $htmllink =
'<div class="divsocialnetwork inline-block valignmiddle">';
2491 $htmllink .=
img_picto($langs->trans(
dol_ucfirst($type)), $type.
'.png',
'',
false, 0, 0,
'',
'paddingright', 0);
2492 if ($type ==
'skype') {
2493 $htmllink .= $value;
2494 $htmllink .=
' ';
2495 $htmllink .=
'<a href="skype:';
2496 $htmllink .= $value;
2497 $htmllink .=
'?call" alt="'.$langs->trans(
"Call").
' '.$value.
'" title="'.$langs->trans(
"Call").
' '.$value.
'">';
2498 $htmllink .=
'<img src="'.DOL_URL_ROOT.
'/theme/common/skype_callbutton.png" border="0">';
2499 $htmllink .=
'</a><a href="skype:';
2500 $htmllink .= $value;
2501 $htmllink .=
'?chat" alt="'.$langs->trans(
"Chat").
' '.$value.
'" title="'.$langs->trans(
"Chat").
' '.$value.
'">';
2502 $htmllink .=
'<img class="paddingleft" src="'.DOL_URL_ROOT.
'/theme/common/skype_chatbutton.png" border="0">';
2503 $htmllink .=
'</a>';
2504 if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
2505 $addlink =
'AC_SKYPE';
2507 if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $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>';
2508 $htmllink .= ($link ?
' '.$link :
'');
2511 if (!empty($dictsocialnetworks[$type][
'url'])) {
2512 $link = str_replace(
'{socialid}', $value, $dictsocialnetworks[$type][
'url']);
2513 $htmllink .=
' <a href="'.$link.
'" target="_blank">'.$value.
'</a>';
2515 $htmllink .= $value;
2518 $htmllink .=
'</div>';
2520 $langs->load(
"errors");
2521 $htmllink .=
img_warning($langs->trans(
"ErrorBadSocialNetworkValue", $value));
2540 function dol_print_phone($phone, $countrycode =
'', $cid = 0, $socid = 0, $addlink =
'', $separ =
" ", $withpicto =
'', $titlealt =
'', $adddivfloat = 0)
2542 global $conf, $user, $langs, $mysoc, $hookmanager;
2545 $phone = preg_replace(
"/[\s.-]/",
"", trim($phone));
2546 if (empty($phone)) {
return ''; }
2547 if (!empty($conf->global->MAIN_PHONE_SEPAR)) $separ = $conf->global->MAIN_PHONE_SEPAR;
2548 if (empty($countrycode)) $countrycode = $mysoc->country_code;
2551 if ($conf->dol_optimize_smallscreen) $separ =
'';
2554 if (strtoupper($countrycode) ==
"FR")
2558 $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);
2561 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
2564 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
2567 $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);
2570 $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);
2572 } elseif (strtoupper($countrycode) ==
"CA")
2575 $newphone = ($separ !=
'' ?
'(' :
'').substr($newphone, 0, 3).($separ !=
'' ?
')' :
'').$separ.substr($newphone, 3, 3).($separ !=
'' ?
'-' :
'').substr($newphone, 6, 4);
2577 } elseif (strtoupper($countrycode) ==
"PT")
2581 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
2583 } elseif (strtoupper($countrycode) ==
"SR")
2587 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
2590 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
2592 } elseif (strtoupper($countrycode) ==
"DE")
2596 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
2599 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
2601 } elseif (strtoupper($countrycode) ==
"ES")
2605 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
2607 } elseif (strtoupper($countrycode) ==
"BF")
2611 $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);
2613 } elseif (strtoupper($countrycode) ==
"RO")
2617 $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);
2619 } elseif (strtoupper($countrycode) ==
"TR")
2623 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
2625 } elseif (strtoupper($countrycode) ==
"US")
2629 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
2631 } elseif (strtoupper($countrycode) ==
"MX")
2635 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
2638 $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);
2641 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
2643 } elseif (strtoupper($countrycode) ==
"ML")
2647 $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);
2649 } elseif (strtoupper($countrycode) ==
"TH")
2653 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
2656 $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);
2658 } elseif (strtoupper($countrycode) ==
"MU")
2663 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
2666 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2668 } elseif (strtoupper($countrycode) ==
"ZA")
2672 $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);
2674 } elseif (strtoupper($countrycode) ==
"SY")
2678 $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);
2681 $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);
2683 } elseif (strtoupper($countrycode) ==
"AE")
2687 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
2690 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
2693 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
2695 } elseif (strtoupper($countrycode) ==
"DZ")
2699 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
2701 } elseif (strtoupper($countrycode) ==
"BE")
2705 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
2708 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
2710 } elseif (strtoupper($countrycode) ==
"PF")
2714 $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);
2716 } elseif (strtoupper($countrycode) ==
"CO")
2720 $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);
2722 } elseif (strtoupper($countrycode) ==
"JO")
2726 $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);
2728 } elseif (strtoupper($countrycode) ==
"JM")
2732 $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
2734 } elseif (strtoupper($countrycode) ==
"MG")
2738 $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);
2740 } elseif (strtoupper($countrycode) ==
"GB")
2744 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
2746 } elseif (strtoupper($countrycode) ==
"CH")
2750 $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);
2753 $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);
2755 } elseif (strtoupper($countrycode) ==
"TN")
2759 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
2761 } elseif (strtoupper($countrycode) ==
"GF")
2765 $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);
2767 } elseif (strtoupper($countrycode) ==
"GP")
2771 $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);
2773 } elseif (strtoupper($countrycode) ==
"MQ")
2777 $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);
2779 } elseif (strtoupper($countrycode) ==
"IT")
2783 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
2786 $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);
2788 } elseif (strtoupper($countrycode) ==
"AU")
2794 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
2797 if (!empty($addlink))
2799 if ($conf->browser->layout ==
'phone' || (!empty($conf->clicktodial->enabled) && !empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS)))
2801 $newphoneform = $newphone;
2802 $newphone =
'<a href="tel:'.$phone.
'"';
2803 $newphone .=
'>'.$newphoneform.
'</a>';
2804 } elseif (!empty($conf->clicktodial->enabled) && $addlink ==
'AC_TEL')
2806 if (empty($user->clicktodial_loaded)) $user->fetch_clicktodial();
2809 $urlmask =
'ErrorClickToDialModuleNotConfigured';
2810 if (!empty($conf->global->CLICKTODIAL_URL)) $urlmask = $conf->global->CLICKTODIAL_URL;
2811 if (!empty($user->clicktodial_url)) $urlmask = $user->clicktodial_url;
2813 $clicktodial_poste = (!empty($user->clicktodial_poste) ?urlencode($user->clicktodial_poste) :
'');
2814 $clicktodial_login = (!empty($user->clicktodial_login) ?urlencode($user->clicktodial_login) :
'');
2815 $clicktodial_password = (!empty($user->clicktodial_password) ?urlencode($user->clicktodial_password) :
'');
2817 $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
2819 $substitarray = array(
'__PHONEFROM__'=>$clicktodial_poste,
2820 '__PHONETO__'=>urlencode($phone),
2821 '__LOGIN__'=>$clicktodial_login,
2822 '__PASS__'=>$clicktodial_password);
2824 $newphonesav = $newphone;
2825 $newphone =
'<a href="'.$url.
'"';
2826 if (!empty($conf->global->CLICKTODIAL_FORCENEWTARGET)) $newphone .=
' target="_blank"';
2827 $newphone .=
'>'.$newphonesav.
'</a>';
2831 if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create)
2833 $type =
'AC_TEL'; $link =
'';
2834 if ($addlink ==
'AC_FAX') $type =
'AC_FAX';
2835 if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE)) $link =
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&backtopage=1&actioncode='.$type.($cid ?
'&contactid='.$cid :
'').($socid ?
'&socid='.$socid :
'').
'">'.
img_object($langs->trans(
"AddAction"),
"calendar").
'</a>';
2836 if ($link) $newphone =
'<div>'.$newphone.
' '.$link.
'</div>';
2840 if (empty($titlealt))
2842 $titlealt = ($withpicto ==
'fax' ? $langs->trans(
"Fax") : $langs->trans(
"Phone"));
2847 $parameters = array(
'countrycode' => $countrycode,
'cid' => $cid,
'socid' => $socid,
'titlealt' => $titlealt,
'picto' => $withpicto);
2848 $reshook = $hookmanager->executeHooks(
'printPhone', $parameters, $phone);
2849 $rep .= $hookmanager->resPrint;
2851 if (empty($reshook))
2855 if ($withpicto ==
'fax') {
2856 $picto =
'phoning_fax';
2857 } elseif ($withpicto ==
'phone') {
2859 } elseif ($withpicto ==
'mobile') {
2860 $picto =
'phoning_mobile';
2865 if ($adddivfloat) $rep .=
'<div class="nospan float" style="margin-right: 10px">';
2866 else $rep .=
'<span style="margin-right: 10px;">';
2867 $rep .= ($withpicto ?
img_picto($titlealt,
'object_'.$picto.
'.png').
' ' :
'').$newphone;
2868 if ($adddivfloat) $rep .=
'</div>';
2869 else $rep .=
'</span>';
2884 global $conf, $langs;
2888 if (empty($mode)) $ret .= $ip;
2895 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/common/flags/'.$countrycode.
'.png'))
2897 $ret .=
' '.img_picto($countrycode.
' '.$langs->trans(
"AccordingToGeoIPDatabase"), DOL_URL_ROOT.
'/theme/common/flags/'.$countrycode.
'.png',
'', 1);
2898 }
else $ret .=
' ('.$countrycode.
')';
2917 if (empty(
$_SERVER[
'HTTP_X_FORWARDED_FOR']) || preg_match(
'/[^0-9\.\:,\[\]]/',
$_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
2918 if (empty(
$_SERVER[
'HTTP_CLIENT_IP']) || preg_match(
'/[^0-9\.\:,\[\]]/',
$_SERVER[
'HTTP_CLIENT_IP'])) {
2919 if (empty(
$_SERVER[
"HTTP_CF_CONNECTING_IP"])) {
2922 $ip =
$_SERVER[
"HTTP_CF_CONNECTING_IP"];
2928 $ip =
$_SERVER[
'HTTP_X_FORWARDED_FOR'];
2947 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') {
2965 if (!empty($conf->geoipmaxmind->enabled))
2967 $datafile = $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE;
2970 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
2971 $geoip =
new DolGeoIP(
'country', $datafile);
2973 $countrycode = $geoip->getCountryCodeFromIP($ip);
2976 return $countrycode;
2988 global $conf, $langs, $user;
2992 if (!empty($conf->geoipmaxmind->enabled))
2995 $datafile = $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE;
2998 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
2999 $geoip =
new DolGeoIP(
'country', $datafile);
3000 $countrycode = $geoip->getCountryCodeFromIP($ip);
3001 $ret = $countrycode;
3020 global $conf, $user, $langs, $hookmanager;
3027 $parameters = array(
'element' => $element,
'id' => $id);
3028 $reshook = $hookmanager->executeHooks(
'printAddress', $parameters, $address);
3029 $out .= $hookmanager->resPrint;
3031 if (empty($reshook))
3033 if (empty($charfornl)) $out .= nl2br($address);
3034 else $out .= preg_replace(
'/[\r\n]+/', $charfornl, $address);
3037 $showgmap = $showomap = 0;
3038 if (($element ==
'thirdparty' || $element ==
'societe') && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) $showgmap = 1;
3039 if ($element ==
'contact' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) $showgmap = 1;
3040 if ($element ==
'member' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) $showgmap = 1;
3041 if (($element ==
'thirdparty' || $element ==
'societe') && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) $showomap = 1;
3042 if ($element ==
'contact' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) $showomap = 1;
3043 if ($element ==
'member' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) $showomap = 1;
3046 $url =
dol_buildpath(
'/google/gmaps.php?mode='.$element.
'&id='.$id, 1);
3047 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
3051 $url =
dol_buildpath(
'/openstreetmap/maps.php?mode='.$element.
'&id='.$id, 1);
3052 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
3056 if ($noprint)
return $out;
3071 if ($acceptsupervisorkey && $address ==
'__SUPERVISOREMAIL__')
return true;
3072 if (filter_var($address, FILTER_VALIDATE_EMAIL))
return true;
3087 if (function_exists(
'idn_to_ascii') && function_exists(
'checkdnsrr'))
3089 if (!checkdnsrr(idn_to_ascii($domain),
'MX'))
3093 if (function_exists(
'getmxrr'))
3097 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
3098 if (count($mxhosts) > 1)
return 1;
3099 if (count($mxhosts) == 1 && !empty($mxhosts[0]))
return 1;
3129 if (function_exists(
'mb_strlen'))
return mb_strlen($string, $stringencoding);
3130 else return strlen($string);
3143 function dol_substr($string, $start, $length, $stringencoding =
'', $trunconbytes = 0)
3147 if (empty($stringencoding)) $stringencoding = $langs->charset_output;
3150 if (empty($trunconbytes))
3152 if (function_exists(
'mb_substr'))
3154 $ret = mb_substr($string, $start, $length, $stringencoding);
3156 $ret = substr($string, $start, $length);
3159 if (function_exists(
'mb_strcut'))
3161 $ret = mb_strcut($string, $start, $length, $stringencoding);
3163 $ret = substr($string, $start, $length);
3183 function dol_trunc($string, $size = 40, $trunc =
'right', $stringencoding =
'UTF-8', $nodot = 0, $display = 0)
3187 if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC))
return $string;
3189 if (empty($stringencoding)) $stringencoding =
'UTF-8';
3191 if ($conf->dol_optimize_smallscreen == 1 && $display == 1) $size = round($size / 3);
3194 if ($trunc ==
'right')
3197 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3)))
3198 return dol_substr($newstring, 0, $size, $stringencoding).($nodot ?
'' :
'...');
3201 } elseif ($trunc ==
'middle')
3204 if (
dol_strlen($newstring, $stringencoding) > 2 &&
dol_strlen($newstring, $stringencoding) > ($size + 1))
3206 $size1 = round($size / 2);
3207 $size2 = round($size / 2);
3208 return dol_substr($newstring, 0, $size1, $stringencoding).
'...'.
dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
3209 }
else return $string;
3210 } elseif ($trunc ==
'left')
3213 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3)))
3214 return '...'.dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
3215 else return $string;
3216 } elseif ($trunc ==
'wrap')
3219 if (
dol_strlen($newstring, $stringencoding) > ($size + 1))
3221 else return $string;
3222 }
else return 'BadParam3CallingDolTrunc';
3244 function img_picto($titlealt, $picto, $moreatt =
'', $pictoisfullpath =
false, $srconly = 0, $notitle = 0, $alt =
'', $morecss =
'', $marginleftonlyshort = 2)
3246 global $conf, $langs;
3249 $url = DOL_URL_ROOT;
3250 $theme = isset($conf->theme) ? $conf->theme : null;
3251 $path =
'theme/'.$theme;
3253 if ($pictoisfullpath) {
3255 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
3258 $fullpathpicto = $picto;
3260 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
3261 $morecss .= ($morecss ?
' ' :
'').$reg[1];
3262 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
3265 $pictowithouttext = preg_replace(
'/(\.png|\.gif|\.svg)$/',
'', $picto);
3266 if (empty($srconly) && in_array($pictowithouttext, array(
3267 '1downarrow',
'1uparrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected',
3268 'accountancy',
'account',
'accountline',
'action',
'add',
'address',
'bank_account',
'barcode',
'bank',
'bill',
'billa',
'billr',
'billd',
'bookmark',
'bom',
'building',
3269 'cash-register',
'category',
'check',
'clock',
'close_title',
'company',
'contact',
'contract',
'cron',
'cubes',
3270 'delete',
'dolly',
'dollyrevert',
'donation',
'download',
'edit',
'ellipsis-h',
'email',
'eraser',
'external-link-alt',
'external-link-square-alt',
3271 'filter',
'file-code',
'file-export',
'file-import',
'file-upload',
'folder',
'folder-open',
'globe',
'globe-americas',
'grip',
'grip_title',
'group',
3273 'intervention',
'label',
'language',
'link',
'list',
'listlight',
'lot',
3274 'map-marker-alt',
'member',
'money-bill-alt',
'mrp',
'note',
'next',
3275 'object_accounting',
'object_account',
'object_accountline',
'object_action',
'object_barcode',
'object_bill',
'object_billa',
'object_billr',
'object_billd',
'object_bom',
3276 'object_category',
'object_conversation',
'object_bookmark',
'object_bug',
'object_clock',
'object_dolly',
'object_dollyrevert',
'object_generic',
'object_folder',
3277 'object_list-alt',
'object_calendar',
'object_calendarweek',
'object_calendarmonth',
'object_calendarday',
'object_calendarperuser',
3278 'object_cash-register',
'object_company',
'object_contact',
'object_contract',
'object_donation',
'object_dynamicprice',
3279 'object_globe',
'object_holiday',
'object_hrm',
'object_invoice',
'object_intervention',
'object_label',
3280 'object_margin',
'object_money-bill-alt',
'object_multicurrency',
'object_order',
'object_payment',
3281 'object_lot',
'object_mrp',
'object_other',
3282 'object_payment',
'object_pdf',
'object_product',
'object_propal',
3283 'object_paragraph',
'object_poll',
'object_printer',
'object_project',
'object_projectpub',
'object_propal',
'object_resource',
'object_rss',
'object_projecttask',
3284 'object_recruitmentjobposition',
'object_recruitmentcandidature',
3285 'object_shipment',
'object_share-alt',
'object_supplier_invoice',
'object_supplier_invoicea',
'object_supplier_invoiced',
'object_supplier_order',
'object_supplier_proposal',
'object_service',
'object_stock',
3286 'object_technic',
'object_ticket',
'object_trip',
'object_user',
'object_group',
'object_member',
3287 'object_phoning',
'object_phoning_mobile',
'object_phoning_fax',
'object_email',
'object_website',
'object_movement',
3288 'off',
'on',
'order',
3289 'paiment',
'play',
'pdf',
'playdisabled',
'previous',
'poll',
'printer',
'product',
'propal',
'projecttask',
'stock',
'resize',
'service',
'stats',
'trip',
3290 'setup',
'share-alt',
'sign-out',
'split',
'stripe-s',
'switch_off',
'switch_on',
'tools',
'unlink',
'uparrow',
'user',
'vcard',
'wrench',
3291 'jabber',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'youtube',
'google-plus-g',
'whatsapp',
3292 'chevron-left',
'chevron-right',
'chevron-down',
'chevron-top',
'commercial',
'companies',
3293 'generic',
'home',
'hrm',
'members',
'products',
'invoicing',
3294 'payment',
'pencil-ruler',
'preview',
'project',
'projectpub',
'refresh',
'supplier_invoice',
'ticket',
3296 'recruitmentcandidature',
'recruitmentjobposition',
'resource',
3297 'supplier_proposal',
'supplier_order',
'supplier_invoice',
3298 'title_setup',
'title_accountancy',
'title_bank',
'title_hrm',
'title_agenda'
3301 $pictowithouttext = str_replace(
'object_',
'', $pictowithouttext);
3303 $fakey = $pictowithouttext;
3304 $facolor =
''; $fasize =
'';
3306 if (in_array($pictowithouttext, array(
'clock',
'generic',
'minus-square',
'object_generic',
'pdf',
'plus-square',
'note',
'off',
'on',
'object_bookmark',
'bookmark',
'vcard'))) {
3309 if (in_array($pictowithouttext, array(
'black-tie',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'stripe-s',
'youtube',
'google-plus-g',
'whatsapp'))) {
3313 $arrayconvpictotofa = array(
3314 'account'=>
'university',
'accountline'=>
'receipt',
'accountancy'=>
'money-check-alt',
'action'=>
'calendar-alt',
'add'=>
'plus-circle',
'address'=>
'address-book',
3315 'bank_account'=>
'university',
'bill'=>
'file-invoice-dollar',
'billa'=>
'file-excel',
'billr'=>
'file-invoice-dollar',
'supplier_invoicea'=>
'file-excel',
'billd'=>
'file-medical',
'supplier_invoiced'=>
'file-medical',
'bom'=>
'cubes',
3316 'company'=>
'building',
'contact'=>
'address-book',
'contract'=>
'suitcase',
'conversation'=>
'comments',
'donation'=>
'file-alt',
'dynamicprice'=>
'hand-holding-usd',
3317 'setup'=>
'cog',
'companies'=>
'building',
'products'=>
'cube',
'commercial'=>
'suitcase',
'invoicing'=>
'coins',
3318 'accounting'=>
'chart-line',
'category'=>
'tag',
'dollyrevert'=>
'dolly',
3319 'hrm'=>
'user-tie',
'margin'=>
'calculator',
'members'=>
'users',
'ticket'=>
'ticket-alt',
'globe'=>
'external-link-alt',
'lot'=>
'barcode',
3321 'edit'=>
'pencil-alt',
'grip_title'=>
'arrows-alt',
'grip'=>
'arrows-alt',
'help'=>
'question-circle',
3322 'generic'=>
'file',
'holiday'=>
'umbrella-beach',
'label'=>
'layer-group',
3323 'member'=>
'users',
'mrp'=>
'cubes',
'next'=>
'arrow-alt-circle-right',
3324 'trip'=>
'wallet',
'group'=>
'users',
'movement'=>
'people-carry',
3325 'sign-out'=>
'sign-out-alt',
3326 'switch_off'=>
'toggle-off',
'switch_on'=>
'toggle-on',
'check'=>
'check',
'bookmark'=>
'star',
'bookmark'=>
'star',
3327 'bank'=>
'university',
'close_title'=>
'times',
'delete'=>
'trash',
'edit'=>
'pencil-alt',
'filter'=>
'filter',
3328 'list-alt'=>
'list-alt',
'calendar'=>
'calendar-alt',
'calendarweek'=>
'calendar-week',
'calendarmonth'=>
'calendar-alt',
'calendarday'=>
'calendar-day',
'calendarperuser'=>
'table',
3329 'intervention'=>
'ambulance',
'invoice'=>
'file-invoice-dollar',
'multicurrency'=>
'dollar-sign',
'order'=>
'file-invoice',
3330 'error'=>
'exclamation-triangle',
'warning'=>
'exclamation-triangle',
3332 'playdisabled'=>
'play',
'pdf'=>
'file-pdf',
'poll'=>
'check-double',
'preview'=>
'binoculars',
'project'=>
'sitemap',
'projectpub'=>
'sitemap',
'projecttask'=>
'tasks',
'propal'=>
'file-signature',
3333 'payment'=>
'money-check-alt',
'phoning'=>
'phone',
'phoning_mobile'=>
'mobile-alt',
'phoning_fax'=>
'fax',
'previous'=>
'arrow-alt-circle-left',
'printer'=>
'print',
'product'=>
'cube',
'service'=>
'concierge-bell',
3334 'recruitmentjobposition'=>
'id-card-alt',
'recruitmentcandidature'=>
'id-badge',
3335 'resize'=>
'crop',
'supplier_order'=>
'dol-order_supplier',
'supplier_proposal'=>
'file-signature',
3336 'refresh'=>
'redo',
'resource'=>
'laptop-house',
3337 'shipment'=>
'dolly',
'stock'=>
'box-open',
'stats' =>
'chart-bar',
'split'=>
'code-branch',
'supplier_invoice'=>
'file-invoice-dollar',
'technic'=>
'cogs',
'ticket'=>
'ticket-alt',
3338 'title_setup'=>
'tools',
'title_accountancy'=>
'money-check-alt',
'title_bank'=>
'university',
'title_hrm'=>
'umbrella-beach',
3339 'title_agenda'=>
'calendar-alt',
3340 'uparrow'=>
'mail-forward',
'vcard'=>
'address-card',
3341 'jabber'=>
'comment-o',
3342 'website'=>
'globe-americas'
3344 if ($pictowithouttext ==
'off') {
3345 $fakey =
'fa-square';
3347 } elseif ($pictowithouttext ==
'on') {
3348 $fakey =
'fa-check-square';
3350 } elseif ($pictowithouttext ==
'listlight') {
3351 $fakey =
'fa-download';
3352 $marginleftonlyshort = 1;
3353 } elseif ($pictowithouttext ==
'printer') {
3354 $fakey =
'fa-print';
3356 } elseif ($pictowithouttext ==
'note') {
3357 $fakey =
'fa-sticky-note';
3358 $marginleftonlyshort = 1;
3359 } elseif (in_array($pictowithouttext, array(
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'))) {
3360 $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');
3361 $fakey =
'fa-'.$convertarray[$pictowithouttext];
3362 if (preg_match(
'/selected/', $pictowithouttext)) $facolor =
'#888';
3363 $marginleftonlyshort = 1;
3364 } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) {
3365 $fakey =
'fa-'.$arrayconvpictotofa[$pictowithouttext];
3367 $fakey =
'fa-'.$pictowithouttext;
3371 $arrayconvpictotomarginleftonly = array(
3372 'bank',
'check',
'delete',
'generic',
'grip',
'grip_title',
'jabber',
3373 'grip_title',
'grip',
'listlight',
'note',
'on',
'off',
'playdisabled',
'printer',
'resize',
'sign-out',
'stats',
'switch_on',
'switch_off',
3374 'uparrow',
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'
3376 if (!isset($arrayconvpictotomarginleftonly[$pictowithouttext])) {
3377 $marginleftonlyshort = 0;
3381 $arrayconvpictotomorcess = array(
3382 'action'=>
'infobox-action',
'account'=>
'infobox-bank_account',
'accountline'=>
'infobox-bank_account',
'accountancy'=>
'infobox-bank_account',
3383 'bank_account'=>
'bg-infobox-bank_account',
3384 'bill'=>
'infobox-commande',
'billa'=>
'infobox-commande',
'billr'=>
'infobox-commande',
'billd'=>
'infobox-commande',
3385 'cash-register'=>
'infobox-bank_account',
'contract'=>
'infobox-contrat',
'check'=>
'font-status4',
'conversation'=>
'infobox-contrat',
3386 'donation'=>
'infobox-commande',
'dollyrevert'=>
'flip',
'ecm'=>
'infobox-action',
3387 'hrm'=>
'infobox-adherent',
'group'=>
'infobox-adherent',
'intervention'=>
'infobox-contrat',
3388 'multicurrency'=>
'infobox-bank_account',
3389 'members'=>
'infobox-adherent',
'member'=>
'infobox-adherent',
'money-bill-alt'=>
'infobox-bank_account',
3390 'order'=>
'infobox-commande',
3391 'user'=>
'infobox-adherent',
'users'=>
'infobox-adherent',
3392 'error'=>
'pictoerror',
'warning'=>
'pictowarning',
'switch_on'=>
'font-status4',
3393 'holiday'=>
'infobox-holiday',
'invoice'=>
'infobox-commande',
3394 'payment'=>
'infobox-bank_account',
'poll'=>
'infobox-adherent',
'project'=>
'infobox-project',
'projecttask'=>
'infobox-project',
'propal'=>
'infobox-propal',
3395 'recruitmentjobposition'=>
'infobox-adherent',
'recruitmentcandidature'=>
'infobox-adherent',
3396 'resource'=>
'infobox-action',
3397 'supplier_invoice'=>
'infobox-order_supplier',
'supplier_invoicea'=>
'infobox-order_supplier',
'supplier_invoiced'=>
'infobox-order_supplier',
3398 'supplier_order'=>
'infobox-order_supplier',
'supplier_proposal'=>
'infobox-supplier_proposal',
3399 'ticket'=>
'infobox-contrat',
'title_accountancy'=>
'infobox-bank_account',
'title_hrm'=>
'infobox-holiday',
'trip'=>
'infobox-expensereport',
'title_agenda'=>
'infobox-action',
3401 'list-alt'=>
'imgforviewmode',
'calendar'=>
'imgforviewmode',
'calendarweek'=>
'imgforviewmode',
'calendarmonth'=>
'imgforviewmode',
'calendarday'=>
'imgforviewmode',
'calendarperuser'=>
'imgforviewmode'
3403 if (!empty($arrayconvpictotomorcess[$pictowithouttext])) {
3404 $morecss .= ($morecss ?
' ' :
'').$arrayconvpictotomorcess[$pictowithouttext];
3408 $arrayconvpictotocolor = array(
3409 'address'=>
'#6c6aa8',
'building'=>
'#6c6aa8',
'bom'=>
'#a69944',
3410 'companies'=>
'#6c6aa8',
'company'=>
'#6c6aa8',
'contact'=>
'#6c6aa8',
'dynamicprice'=>
'#a69944',
3411 'edit'=>
'#444',
'note'=>
'#999',
'error'=>
'',
'help'=>
'#bbb',
'listlight'=>
'#999',
3412 'dolly'=>
'#a69944',
'dollyrevert'=>
'#a69944',
'lot'=>
'#a69944',
3413 'map-marker-alt'=>
'#aaa',
'mrp'=>
'#a69944',
'product'=>
'#a69944',
'service'=>
'#a69944',
'stock'=>
'#a69944',
'movement'=>
'#a69944',
3415 'playdisabled'=>
'#ccc',
'printer'=>
'#444',
'projectpub'=>
'#986c6a',
'resize'=>
'#444',
'rss'=>
'#cba',
3416 'shipment'=>
'#a69944',
'stats'=>
'#444',
'switch_off'=>
'#999',
'uparrow'=>
'#555',
'globe-americas'=>
'#aaa',
3419 if (isset($arrayconvpictotocolor[$pictowithouttext])) {
3420 $facolor = $arrayconvpictotocolor[$pictowithouttext];
3427 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
3428 $morecss .= ($morecss ?
' ' :
'').$reg[1];
3429 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
3431 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
3432 $morestyle = $reg[1];
3433 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
3435 $moreatt = trim($moreatt);
3437 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
3438 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
3442 $enabledisablehtml .=
'</span>';
3444 return $enabledisablehtml;
3447 if (!empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) {
3448 $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.
'/theme/'.$theme;
3449 } elseif (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) {
3450 $path = $conf->global->MAIN_OVERWRITE_THEME_RES.
'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES;
3451 } elseif (!empty($conf->modules_parts[
'theme']) && array_key_exists($theme, $conf->modules_parts[
'theme'])) {
3452 $path = $theme.
'/theme/'.$theme;
3457 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
3463 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
3468 foreach ($conf->file->dol_document_root as $type => $dirroot) {
3469 if ($type ==
'main') {
3473 if (file_exists($dirroot.
'/'.$path.
'/img/'.$picto)) {
3474 $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type];
3480 $fullpathpicto = $url.
'/'.$path.
'/img/'.$picto;
3484 return $fullpathpicto;
3487 return '<img src="'.$fullpathpicto.
'" alt="'.
dol_escape_htmltag($alt).
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt.($morecss ?
' class="'.$morecss.
'"' :
'') :
' class="inline-block'.($morecss ?
' '.$morecss :
'').
'"').
'>';
3503 function img_object($titlealt, $picto, $moreatt =
'', $pictoisfullpath =
false, $srconly = 0, $notitle = 0)
3505 if (strpos($picto,
'^') === 0)
return img_picto($titlealt, str_replace(
'^',
'', $picto), $moreatt, $pictoisfullpath, $srconly, $notitle);
3506 else return img_picto($titlealt,
'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
3520 function img_weather($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $morecss =
'')
3524 if (is_numeric($picto)) {
3527 return '<i class="fa fa-weather-level'.$picto.
'"></i>';
3528 } elseif (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
3532 $path = DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/weather/'.$picto;
3534 return img_picto($titlealt, $path, $moreatt, 1, 0, 0,
'', $morecss);
3551 if (!preg_match(
'/(\.png|\.gif)$/i', $picto)) $picto .=
'.png';
3553 if ($pictoisfullpath) $path = $picto;
3555 $path = DOL_URL_ROOT.
'/theme/common/'.$picto;
3557 if (!empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS))
3559 $themepath = DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/img/'.$picto;
3561 if (file_exists($themepath)) $path = $themepath;
3565 return img_picto($titlealt, $path, $moreatt, 1);
3584 if (empty($titlealt) || $titlealt ==
'default')
3586 if ($numaction ==
'-1' || $numaction ==
'ST_NO') {
3588 $titlealt = $langs->transnoentitiesnoconv(
'ChangeDoNotContact');
3589 } elseif ($numaction ==
'0' || $numaction ==
'ST_NEVER') {
3591 $titlealt = $langs->transnoentitiesnoconv(
'ChangeNeverContacted');
3592 } elseif ($numaction ==
'1' || $numaction ==
'ST_TODO') {
3594 $titlealt = $langs->transnoentitiesnoconv(
'ChangeToContact');
3595 } elseif ($numaction ==
'2' || $numaction ==
'ST_PEND') {
3597 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactInProcess');
3598 } elseif ($numaction ==
'3' || $numaction ==
'ST_DONE') {
3600 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactDone');
3602 $titlealt = $langs->transnoentitiesnoconv(
'ChangeStatus '.$numaction);
3606 if (!is_numeric($numaction)) $numaction = 0;
3608 return img_picto($titlealt, !empty($picto) ? $picto :
'stcomm'.$numaction.
'.png');
3618 function img_pdf($titlealt =
'default', $size = 3)
3622 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Show');
3624 return img_picto($titlealt,
'pdf'.$size.
'.png');
3638 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Add');
3640 return img_picto($titlealt,
'edit_add.png', $other);
3653 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Remove');
3655 return img_picto($titlealt,
'edit_remove.png', $other);
3666 function img_edit($titlealt =
'default', $float = 0, $other =
'')
3670 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Modify');
3672 return img_picto($titlealt,
'edit.png', ($float ?
'style="float: '.($langs->tab_translate[
"DIRECTION"] ==
'rtl' ?
'left' :
'right').
'"' :
"").($other ?
' '.$other :
''));
3683 function img_view($titlealt =
'default', $float = 0, $other =
'')
3687 if ($titlealt ==
'default') $titlealt = $langs->trans(
'View');
3689 $moreatt = ($float ?
'style="float: right" ' :
'').$other;
3691 return img_picto($titlealt,
'view.png', $moreatt);
3702 function img_delete($titlealt =
'default', $other =
'class="pictodelete"', $morecss =
'')
3706 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Delete');
3708 return img_picto($titlealt,
'delete.png', $other,
false, 0, 0,
'', $morecss);
3721 if ($titlealt ==
"default") $titlealt = $langs->trans(
"Print");
3722 return img_picto($titlealt,
'printer.png', $other);
3732 function img_split($titlealt =
'default', $other =
'class="pictosplit"')
3736 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Split');
3738 return img_picto($titlealt,
'split.png', $other);
3748 function img_help($usehelpcursor = 1, $usealttitle = 1)
3755 else $usealttitle = $langs->trans(
'Info');
3758 return img_picto($usealttitle,
'info.png',
'style="vertical-align: middle;'.($usehelpcursor == 1 ?
' cursor: help' : ($usehelpcursor == 2 ?
' cursor: pointer' :
'')).
'"');
3771 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Informations');
3773 return img_picto($titlealt,
'info.png',
'style="vertical-align: middle;"');
3784 function img_warning($titlealt =
'default', $moreatt =
'', $morecss =
'pictowarning')
3788 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Warning');
3791 return img_picto($titlealt,
'warning.png',
'class="'.$morecss.
'"'.($moreatt ? ($moreatt ==
'1' ?
' style="float: right"' :
' '.$moreatt) :
''));
3804 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Error');
3806 return img_picto($titlealt,
'error.png');
3816 function img_next($titlealt =
'default', $moreatt =
'')
3820 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Next');
3823 return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
3837 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Previous');
3840 return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
3851 function img_down($titlealt =
'default', $selected = 0, $moreclass =
'')
3855 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Down');
3857 return img_picto($titlealt, ($selected ?
'1downarrow_selected.png' :
'1downarrow.png'),
'class="imgdown'.($moreclass ?
" ".$moreclass :
"").
'"');
3868 function img_up($titlealt =
'default', $selected = 0, $moreclass =
'')
3872 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Up');
3874 return img_picto($titlealt, ($selected ?
'1uparrow_selected.png' :
'1uparrow.png'),
'class="imgup'.($moreclass ?
" ".$moreclass :
"").
'"');
3885 function img_left($titlealt =
'default', $selected = 0, $moreatt =
'')
3889 if ($titlealt ==
'default') {
3890 $titlealt = $langs->trans(
'Left');
3893 return img_picto($titlealt, ($selected ?
'1leftarrow_selected.png' :
'1leftarrow.png'), $moreatt);
3904 function img_right($titlealt =
'default', $selected = 0, $moreatt =
'')
3908 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Right');
3910 return img_picto($titlealt, ($selected ?
'1rightarrow_selected.png' :
'1rightarrow.png'), $moreatt);
3924 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Active');
3926 if ($allow == 1)
return img_picto($titlealt,
'tick.png');
3940 if (is_null($morecss)) $morecss =
'fa-2x';
3942 if ($brand ==
'visa' || $brand ==
'Visa') {
3944 } elseif ($brand ==
'mastercard' || $brand ==
'MasterCard') {
3945 $brand =
'cc-mastercard';
3946 } elseif ($brand ==
'amex' || $brand ==
'American Express') {
3948 } elseif ($brand ==
'discover' || $brand ==
'Discover') {
3949 $brand =
'cc-discover';
3950 } elseif ($brand ==
'jcb' || $brand ==
'JCB') {
3952 } elseif ($brand ==
'diners' || $brand ==
'Diners club') {
3953 $brand =
'cc-diners-club';
3954 } elseif (!in_array($brand, array(
'cc-visa',
'cc-mastercard',
'cc-amex',
'cc-discover',
'cc-jcb',
'cc-diners-club'))) {
3955 $brand =
'credit-card';
3958 return '<span class="fa fa-'.$brand.
' fa-fw'.($morecss ?
' '.$morecss :
'').
'"></span>';
3969 function img_mime($file, $titlealt =
'', $morecss =
'')
3971 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
3977 if (empty($titlealt)) $titlealt =
'Mime type: '.$mimetype;
3980 return '<i class="fa fa-'.$mimefa.
' paddingright"'.($titlealt ?
' title="'.$titlealt.
'"' :
'').
'></i>';
3993 global $conf, $langs;
3995 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Search');
3997 $img =
img_picto($titlealt,
'search.png', $other,
false, 1);
3999 $input =
'<input type="image" class="liste_titre" name="button_search" src="'.$img.
'" ';
4000 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
4014 global $conf, $langs;
4016 if ($titlealt ==
'default') $titlealt = $langs->trans(
'Search');
4018 $img =
img_picto($titlealt,
'searchclear.png', $other,
false, 1);
4020 $input =
'<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.
'" ';
4021 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
4037 function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin =
'1', $morecss =
'', $textfordropdown =
'')
4039 global $conf, $langs;
4043 $result =
img_picto($text,
'info',
'class="hideonsmartphone'.($morecss ?
' '.$morecss :
'').
'"');
4045 if (empty($conf->use_javascript_ajax)) $textfordropdown =
'';
4047 $class = (empty($admin) ?
'undefined' : ($admin ==
'1' ?
'info' : $admin));
4048 $result = ($nodiv ?
'' :
'<div class="'.$class.
' hideonsmartphone'.($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>');
4050 if ($textfordropdown) {
4051 $tmpresult .=
'<span class="'.$class.
'text opacitymedium cursorpointer">'.$langs->trans($textfordropdown).
' '.
img_picto($langs->trans($textfordropdown),
'1downarrow').
'</span>';
4052 $tmpresult .=
'<script type="text/javascript" language="javascript">
4053 jQuery(document).ready(function() {
4054 jQuery(".'.$class.
'text").click(function() {
4055 console.log("toggle text");
4056 jQuery(".'.$class.
'").toggle();
4061 $result = $tmpresult.$result;
4082 global $conf, $langs, $argv;
4083 global $dolibarr_main_prod;
4091 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
4093 $langs->load(
"main");
4097 $langs->loadLangs(array(
'main',
'errors'));
4101 $out .= $langs->trans(
"DolibarrHasDetectedError").
".<br>\n";
4102 if (!empty($conf->global->MAIN_FEATURES_LEVEL)) $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";
4103 $out .= $langs->trans(
"InformationToHelpDiagnose").
":<br>\n";
4105 $out .=
"<b>".$langs->trans(
"Date").
":</b> ".
dol_print_date(time(),
'dayhourlog').
"<br>\n";
4106 $out .=
"<b>".$langs->trans(
"Dolibarr").
":</b> ".DOL_VERSION.
" - https://www.dolibarr.org<br>\n";
4107 if (isset($conf->global->MAIN_FEATURES_LEVEL)) $out .=
"<b>".$langs->trans(
"LevelOfFeature").
":</b> ".$conf->global->MAIN_FEATURES_LEVEL.
"<br>\n";
4108 if (function_exists(
"phpversion"))
4110 $out .=
"<b>".$langs->trans(
"PHP").
":</b> ".phpversion().
"<br>\n";
4113 if (function_exists(
"php_uname"))
4115 $out .=
"<b>".$langs->trans(
"OS").
":</b> ".php_uname().
"<br>\n";
4117 $out .=
"<b>".$langs->trans(
"UserAgent").
":</b> ".
dol_htmlentities(
$_SERVER[
"HTTP_USER_AGENT"], ENT_COMPAT,
'UTF-8').
"<br>\n";
4119 $out .=
"<b>".$langs->trans(
"RequestedUrl").
":</b> ".
dol_htmlentities(
$_SERVER[
"REQUEST_URI"], ENT_COMPAT,
'UTF-8').
"<br>\n";
4120 $out .=
"<b>".$langs->trans(
"Referer").
":</b> ".(isset(
$_SERVER[
"HTTP_REFERER"]) ?
dol_htmlentities(
$_SERVER[
"HTTP_REFERER"], ENT_COMPAT,
'UTF-8') :
'').
"<br>\n";
4121 $out .=
"<b>".$langs->trans(
"MenuManager").
":</b> ".(isset($conf->standard_menu) ?
dol_htmlentities($conf->standard_menu) :
'').
"<br>\n";
4123 $syslog .=
"url=".dol_escape_htmltag(
$_SERVER[
"REQUEST_URI"]);
4124 $syslog .=
", query_string=".dol_escape_htmltag(
$_SERVER[
"QUERY_STRING"]);
4127 $out .=
'> '.$langs->transnoentities(
"ErrorInternalErrorDetected").
":\n".$argv[0].
"\n";
4128 $syslog .=
"pid=".dol_getmypid();
4131 if (!empty($conf->modules))
4133 $out .=
"<b>".$langs->trans(
"Modules").
":</b> ".join(
', ', $conf->modules).
"<br>\n";
4140 $out .=
"<b>".$langs->trans(
"DatabaseTypeManager").
":</b> ".$db->type.
"<br>\n";
4141 $out .=
"<b>".$langs->trans(
"RequestLastAccessInError").
":</b> ".($db->lastqueryerror() ?
dol_escape_htmltag($db->lastqueryerror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
4142 $out .=
"<b>".$langs->trans(
"ReturnCodeLastAccessInError").
":</b> ".($db->lasterrno() ?
dol_escape_htmltag($db->lasterrno()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
4143 $out .=
"<b>".$langs->trans(
"InformationLastAccessInError").
":</b> ".($db->lasterror() ?
dol_escape_htmltag($db->lasterror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
4148 $out .=
'> '.$langs->transnoentities(
"DatabaseTypeManager").
":\n".$db->type.
"\n";
4149 $out .=
'> '.$langs->transnoentities(
"RequestLastAccessInError").
":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
4150 $out .=
'> '.$langs->transnoentities(
"ReturnCodeLastAccessInError").
":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
4151 $out .=
'> '.$langs->transnoentities(
"InformationLastAccessInError").
":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
4153 $syslog .=
", sql=".$db->lastquery();
4154 $syslog .=
", db_error=".$db->lasterror();
4157 if ($error || $errors)
4159 $langs->load(
"errors");
4162 if (is_array($error) && is_array($errors)) $errors = array_merge($error, $errors);
4163 elseif (is_array($error)) $errors = $error;
4164 elseif (is_array($errors)) $errors = array_merge(array($error), $errors);
4165 else $errors = array_merge(array($error));
4167 foreach ($errors as $msg)
4169 if (empty($msg))
continue;
4175 $out .=
'> '.$langs->transnoentities(
"Message").
":\n".$msg.
"\n";
4177 $syslog .=
", msg=".$msg;
4180 if (empty($dolibarr_main_prod) &&
$_SERVER[
'DOCUMENT_ROOT'] && function_exists(
'xdebug_print_function_stack') && function_exists(
'xdebug_call_file'))
4182 xdebug_print_function_stack();
4183 $out .=
'<b>XDebug informations:</b>'.
"<br>\n";
4184 $out .=
'File: '.xdebug_call_file().
"<br>\n";
4185 $out .=
'Line: '.xdebug_call_line().
"<br>\n";
4186 $out .=
'Function: '.xdebug_call_function().
"<br>\n";
4191 if (!headers_sent()) {
4192 http_response_code(500);
4195 if (empty($dolibarr_main_prod)) {
4198 if (empty($langs->defaultlang)) $langs->setDefaultLang();
4199 $langs->loadLangs(array(
"main",
"errors"));
4201 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 are on next line...<br><br>'.
"\n";
4202 print $langs->trans(
"DolibarrHasDetectedError").
'. ';
4203 print $langs->trans(
"YouCanSetOptionDolibarrMainProdToZero");
4204 define(
"MAIN_CORE_ERROR", 1);
4220 function dol_print_error_email($prefixcode, $errormessage =
'', $errormessages = array(), $morecss =
'error', $email =
'')
4222 global $langs, $conf;
4224 if (empty($email)) $email = $conf->global->MAIN_INFO_SOCIETE_MAIL;
4226 $langs->load(
"errors");
4229 print '<br><div class="center login_main_message"><div class="'.$morecss.
'">';
4230 print $langs->trans(
"ErrorContactEMail", $email, $prefixcode.dol_print_date($now,
'%Y%m%d%H%M%S'));
4231 if ($errormessage)
print '<br><br>'.$errormessage;
4232 if (is_array($errormessages) && count($errormessages))
4234 foreach ($errormessages as $mesgtoshow)
4236 print '<br><br>'.$mesgtoshow;
4239 print '</div></div>';
4258 function print_liste_field_titre($name, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $tooltip =
"", $forcenowrapcolumntitle = 0)
4260 print getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip, $forcenowrapcolumntitle);
4281 function getTitleFieldOfList($name, $thead = 0, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $disablesortlink = 0, $tooltip =
'', $forcenowrapcolumntitle = 0)
4283 global $conf, $langs, $form;
4286 if ($moreattrib ==
'class="right"') $prefix .=
'right ';
4288 $sortorder = strtoupper($sortorder);
4293 if ($thead == 2) $tag =
'div';
4295 $tmpsortfield = explode(
',', $sortfield);
4296 $sortfield1 = trim($tmpsortfield[0]);
4297 $tmpfield = explode(
',', $field);
4298 $field1 = trim($tmpfield[0]);
4300 if (empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && empty($forcenowrapcolumntitle)) {
4301 $prefix =
'wrapcolumntitle '.$prefix;
4307 $liste_titre =
'liste_titre';
4308 if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace(
"/^[^\.]+\./",
"", $field1))) {
4309 $liste_titre =
'liste_titre_sel';
4311 $out .=
'<'.$tag.
' class="'.$prefix.$liste_titre.
'" '.$moreattrib;
4313 $out .= ($name && empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && empty($forcenowrapcolumntitle) && !
dol_textishtml($name)) ?
' title="'.
dol_escape_htmltag($langs->trans($name)).
'"' :
'';
4316 if (empty($thead) && $field && empty($disablesortlink))
4318 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
4319 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
4320 $options = preg_replace(
'/&+/i',
'&', $options);
4321 if (!preg_match(
'/^&/', $options)) $options =
'&'.$options;
4323 $sortordertouseinlink =
'';
4324 if ($field1 != $sortfield1)
4326 if (preg_match(
'/^DESC/i', $sortorder))
4328 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
4331 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
4335 if (preg_match(
'/^ASC/i', $sortorder))
4337 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
4339 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
4342 $sortordertouseinlink = preg_replace(
'/,$/',
'', $sortordertouseinlink);
4343 $out .=
'<a class="reposition" href="'.$file.
'?sortfield='.$field.
'&sortorder='.$sortordertouseinlink.
'&begin='.$begin.$options.
'"';
4350 $tmptooltip = explode(
':', $tooltip);
4351 $out .= $form->textwithpicto($langs->trans($name), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.str_replace(
'.',
'_', $field).
'_'.$tmptooltip[1]));
4353 else $out .= $langs->trans($name);
4355 if (empty($thead) && $field && empty($disablesortlink))
4360 if (empty($thead) && $field)
4362 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
4363 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
4364 $options = preg_replace(
'/&+/i',
'&', $options);
4365 if (!preg_match(
'/^&/', $options)) $options =
'&'.$options;
4367 if (!$sortorder || $field1 != $sortfield1)
4372 if (preg_match(
'/^DESC/', $sortorder)) {
4375 $sortimg .=
'<span class="nowrap">'.img_up(
"Z-A", 0,
'paddingleft').
'</span>';
4377 if (preg_match(
'/^ASC/', $sortorder)) {
4380 $sortimg .=
'<span class="nowrap">'.img_down(
"A-Z", 0,
'paddingleft').
'</span>';
4387 $out .=
'</'.$tag.
'>';
4402 dol_syslog(__FUNCTION__.
" is deprecated", LOG_WARNING);
4404 print '<div class="titre">'.$title.
'</div>';
4436 function load_fiche_titre($titre, $morehtmlright =
'', $picto =
'generic', $pictoisfullpath = 0, $id =
'', $morecssontable =
'', $morehtmlcenter =
'')
4442 if ($picto ==
'setup') $picto =
'generic';
4445 $return .=
'<table '.($id ?
'id="'.$id.
'" ' :
'').
'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ?
' '.$morecssontable :
'').
'">';
4446 $return .=
'<tr class="titre">';
4447 if ($picto) $return .=
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).
'</td>';
4448 $return .=
'<td class="nobordernopadding valignmiddle col-title">';
4449 $return .=
'<div class="titre inline-block">'.$titre.
'</div>';
4453 $return .=
'<td class="nobordernopadding center valignmiddle">'.$morehtmlcenter.
'</td>';
4457 $return .=
'<td class="nobordernopadding titre_right wordbreakimp right valignmiddle">'.$morehtmlright.
'</td>';
4459 $return .=
'</tr></table>'.
"\n";
4487 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 =
'')
4489 global $conf, $langs;
4492 $savtotalnboflines = $totalnboflines;
4493 $totalnboflines = abs((
int) $totalnboflines);
4495 if ($picto ==
'setup') $picto =
'title_setup.png';
4496 if (($conf->browser->name ==
'ie') && $picto ==
'generic') $picto =
'title.gif';
4497 if ($limit < 0) $limit = $conf->liste_limit;
4498 if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0)))
4507 print "<!-- Begin title -->\n";
4508 print '<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ?
' '.$morecss :
'').
'"><tr>';
4512 if ($picto && $titre)
print '<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath).
'</td>';
4513 print '<td class="nobordernopadding valignmiddle col-title">';
4514 print '<div class="titre inline-block">'.$titre;
4515 if (!empty($titre) && $savtotalnboflines >= 0 && (
string) $savtotalnboflines !=
'')
print '<span class="opacitymedium colorblack paddingleft">('.$totalnboflines.
')</span>';
4516 print '</div></td>';
4519 if ($morehtmlcenter)
4521 print '<td class="nobordernopadding center valignmiddle">'.$morehtmlcenter.
'</td>';
4525 print '<td class="nobordernopadding valignmiddle right">';
4526 print '<input type="hidden" name="pageplusoneold" value="'.((int) $page + 1).
'">';
4527 if ($sortfield) $options .=
"&sortfield=".urlencode($sortfield);
4528 if ($sortorder) $options .=
"&sortorder=".urlencode($sortorder);
4531 if ($savlimit != 0 && ($page > 0 || $num > $limit))
4533 if ($totalnboflines)
4536 $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 0);
4538 if ($limit > 0) $nbpages = ceil($totalnboflines / $limit);
4540 $cpt = ($page - $maxnbofpage);
4541 if ($cpt < 0) { $cpt = 0; }
4545 if (empty($pagenavastextinput)) {
4546 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page=0'.$options.
'">1</a></li>';
4547 if ($cpt > 2) $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
4548 elseif ($cpt == 2) $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page=1'.$options.
'">2</a></li>';
4553 if ($pagenavastextinput) {
4556 $pagelist .=
'<li class="pagination"><input type="text" class="width25 center pageplusone" name="pageplusone" value="'.($page + 1).
'"></li>';
4563 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
'</span></li>';
4565 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.$cpt.$options.
'">'.($cpt + 1).
'</a></li>';
4569 }
while ($cpt < $nbpages && $cpt <= ($page + $maxnbofpage));
4571 if (empty($pagenavastextinput)) {
4572 if ($cpt < $nbpages)
4574 if ($cpt < $nbpages - 2) $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
4575 elseif ($cpt == $nbpages - 2) $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.($nbpages - 2).$options.
'">'.($nbpages - 1).
'</a></li>';
4576 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
4581 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
4585 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
"</li>";
4589 if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
4590 print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow);
4594 if ($pagenavastextinput) {
4600 print '</tr></table>'.
"\n";
4601 print "<!-- End title -->\n\n";
4619 function print_fleche_navigation($page, $file, $options =
'', $nextpage = 0, $betweenarrows =
'', $afterarrows =
'', $limit = -1, $totalnboflines = 0, $hideselectlimit = 0, $beforearrows =
'')
4621 global $conf, $langs;
4623 print '<div class="pagination"><ul>';
4626 print '<li class="paginationbeforearrows">';
4627 print $beforearrows;
4630 if ((
int) $limit > 0 && empty($hideselectlimit))
4632 $pagesizechoices =
'10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000,25000:25000';
4635 if (!empty($conf->global->MAIN_PAGESIZE_CHOICES)) $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES;
4637 print '<li class="pagination">';
4638 print '<select class="flat selectlimit" name="limit" title="'.dol_escape_htmltag($langs->trans(
"MaxNbOfRecordPerPage")).
'">';
4639 $tmpchoice = explode(
',', $pagesizechoices);
4640 $tmpkey = $limit.
':'.$limit;
4641 if (!in_array($tmpkey, $tmpchoice)) $tmpchoice[] = $tmpkey;
4642 $tmpkey = $conf->liste_limit.
':'.$conf->liste_limit;
4643 if (!in_array($tmpkey, $tmpchoice)) $tmpchoice[] = $tmpkey;
4644 asort($tmpchoice, SORT_NUMERIC);
4645 foreach ($tmpchoice as $val)
4648 $tmp = explode(
':', $val);
4651 if ($key !=
'' && $val !=
'')
4653 if ((
int) $key == (
int) $limit)
4655 $selected =
' selected="selected"';
4661 if ($conf->use_javascript_ajax)
4663 print '<!-- JS CODE TO ENABLE select limit to launch submit of page -->
4665 jQuery(document).ready(function () {
4666 jQuery(".selectlimit").change(function() {
4667 console.log("Change limit. Send submit");
4668 $(this).parents(\'form:first\').submit();
4678 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>';
4682 print '<!--<div class="betweenarrows nowraponall inline-block">-->';
4683 print $betweenarrows;
4684 print '<!--</div>-->';
4688 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>';
4692 print '<li class="paginationafterarrows">';
4696 print '</ul></div>'.
"\n";
4710 function vatrate($rate, $addpercent =
false, $info_bits = 0, $usestarfornpr = 0)
4714 if (preg_match(
'/%/', $rate))
4716 $rate = str_replace(
'%',
'', $rate);
4719 if (preg_match(
'/\((.*)\)/', $rate, $reg))
4721 $morelabel =
' ('.$reg[1].
')';
4722 $rate = preg_replace(
'/\s*'.preg_quote($morelabel,
'/').
'/',
'', $rate);
4724 if (preg_match(
'/\*/', $rate))
4726 $rate = str_replace(
'*',
'', $rate);
4731 if (!preg_match(
'/\//', $rate)) $ret =
price($rate, 0,
'', 0, 0).($addpercent ?
'%' :
'');
4734 $ret = $rate.($addpercent ?
'%' :
'');
4736 if (($info_bits & 1) && $usestarfornpr >= 0) $ret .=
' *';
4757 function price($amount, $form = 0, $outlangs =
'', $trunc = 1, $rounding = -1, $forcerounding = -1, $currency_code =
'')
4759 global $langs, $conf;
4762 if (empty($amount)) $amount = 0;
4763 $amount = (is_numeric($amount) ? $amount : 0);
4764 if ($rounding < 0) $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
4765 $nbdecimal = $rounding;
4768 $dec =
','; $thousand =
' ';
4771 if (!is_object($outlangs)) $outlangs = $langs;
4773 if ($outlangs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") $dec = $outlangs->transnoentitiesnoconv(
"SeparatorDecimal");
4774 if ($outlangs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") $thousand = $outlangs->transnoentitiesnoconv(
"SeparatorThousand");
4775 if ($thousand ==
'None') $thousand =
'';
4776 elseif ($thousand ==
'Space') $thousand =
' ';
4780 $amount = str_replace(
',',
'.', $amount);
4782 $datas = explode(
'.', $amount);
4783 $decpart = isset($datas[1]) ? $datas[1] :
'';
4784 $decpart = preg_replace(
'/0+$/i',
'', $decpart);
4791 if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN)
4793 $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_SHOWN;
4794 if (preg_match(
'/\.\.\./i', $conf->global->MAIN_MAX_DECIMALS_SHOWN))
4802 if ($forcerounding >= 0) $nbdecimal = $forcerounding;
4805 $output = number_format($amount, $nbdecimal, $dec, $thousand);
4808 $output = preg_replace(
'/\s/',
' ', $output);
4809 $output = preg_replace(
'/\'/',
''', $output);
4812 $cursymbolbefore = $cursymbolafter =
'';
4815 if ($currency_code ==
'auto') $currency_code = $conf->currency;
4817 $listofcurrenciesbefore = array(
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD');
4818 $listoflanguagesbefore = array(
'nl_NL');
4819 if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore))
4821 $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
4823 $tmpcur = $outlangs->getCurrencySymbol($currency_code);
4824 $cursymbolafter .= ($tmpcur == $currency_code ?
' '.$tmpcur : $tmpcur);
4827 $output = $cursymbolbefore.$output.$end.($cursymbolafter ?
' ' :
'').$cursymbolafter;
4855 global $langs, $conf;
4860 $dec =
','; $thousand =
' ';
4861 if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
4862 if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
4863 if ($thousand ==
'None') $thousand =
'';
4864 elseif ($thousand ==
'Space') $thousand =
' ';
4870 if (!is_numeric($amount)) {
4871 $amount = preg_replace(
'/[a-zA-Z\/\\\*\(\)<>\_]/',
'', $amount);
4874 if ($option == 2 && $thousand ==
'.' && preg_match(
'/\.(\d\d\d)$/', (
string) $amount)) {
4875 $amount = str_replace($thousand,
'', $amount);
4881 if (is_numeric($amount))
4884 $temps = sprintf(
"%0.10F", $amount - intval($amount));
4885 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
4887 $amount = number_format($amount, $nbofdec, $dec, $thousand);
4892 if ($thousand !=
',' && $thousand !=
'.') {
4893 $amount = str_replace(
',',
'.', $amount);
4895 $amount = str_replace(
' ',
'', $amount);
4896 $amount = str_replace($thousand,
'', $amount);
4897 $amount = str_replace($dec,
'.', $amount);
4904 $nbofdectoround =
'';
4905 if ($rounding ==
'MU') {
4906 $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT;
4908 elseif ($rounding ==
'MT') {
4909 $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT;
4911 elseif ($rounding ==
'MS') {
4912 $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK;
4914 elseif ($rounding ==
'CU') {
4915 $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_UNIT, 8);
4917 elseif ($rounding ==
'CT') {
4918 $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_TOT, 8);
4920 elseif (is_numeric($rounding)) $nbofdectoround = $rounding;
4922 if (
dol_strlen($nbofdectoround)) $amount = round(is_string($amount) ? (
float) $amount : $amount, $nbofdectoround);
4923 else return 'ErrorBadParameterProvidedToFunction';
4928 if (is_numeric($amount))
4931 $temps = sprintf(
"%0.10F", $amount - intval($amount));
4932 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
4934 $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand);
4940 if ($thousand !=
',' && $thousand !=
'.') $amount = str_replace(
',',
'.', $amount);
4941 $amount = str_replace(
' ',
'', $amount);
4942 $amount = str_replace($thousand,
'', $amount);
4943 $amount = str_replace($dec,
'.', $amount);
4962 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
4964 if (($forceunitoutput ==
'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6))
4966 $dimension = $dimension * 1000000;
4968 } elseif (($forceunitoutput ==
'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3))
4970 $dimension = $dimension * 1000;
4972 } elseif (($forceunitoutput ==
'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6))
4974 $dimension = $dimension / 1000000;
4976 } elseif (($forceunitoutput ==
'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3))
4978 $dimension = $dimension / 1000;
5012 function get_localtax($vatrate, $local, $thirdparty_buyer =
"", $thirdparty_seller =
"", $vatnpr = 0)
5014 global $db, $conf, $mysoc;
5016 if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) $thirdparty_seller = $mysoc;
5018 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);
5020 $vatratecleaned = $vatrate;
5022 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
5023 $vatratecleaned = trim($reg[1]);
5024 $vatratecode = $reg[2];
5033 if ($mysoc->country_code ==
'ES') {
5035 if (!$mysoc->localtax1_assuj || (
string) $vatratecleaned ==
"0")
return 0;
5036 if ($thirdparty_seller->id == $mysoc->id) {
5037 if (!$thirdparty_buyer->localtax1_assuj)
return 0;
5039 if (!$thirdparty_seller->localtax1_assuj)
return 0;
5045 if (!$mysoc->localtax2_assuj)
return 0;
5046 if ($thirdparty_seller->id == $mysoc->id) {
5047 if (!$thirdparty_buyer->localtax2_assuj)
return 0;
5049 if (!$thirdparty_seller->localtax2_assuj)
return 0;
5053 if ($local == 1 && !$thirdparty_seller->localtax1_assuj)
return 0;
5054 if ($local == 2 && !$thirdparty_seller->localtax2_assuj)
return 0;
5058 if (in_array($mysoc->country_code, array(
'ES'))) {
5059 $conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY = 1;
5063 if (!empty($conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY))
5066 if ($thirdparty_seller != $mysoc) {
5069 return $thirdparty_seller->localtax1_value;
5073 return $conf->global->MAIN_INFO_VALUE_LOCALTAX1;
5078 if ($thirdparty_seller != $mysoc) {
5082 return $thirdparty_seller->localtax2_value;
5085 if (in_array($mysoc->country_code, array(
'ES'))) {
5086 return $thirdparty_buyer->localtax2_value;
5088 return $conf->global->MAIN_INFO_VALUE_LOCALTAX2;
5095 $sql =
"SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
5096 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
5097 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdparty_seller->country_code).
"'";
5098 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
5099 if (!empty($vatratecode)) $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
5100 else $sql .=
" AND t.recuperableonly = '".$db->escape($vatnpr).
"'";
5102 $resql = $db->query($sql);
5106 $obj = $db->fetch_object(
$resql);
5108 if ($local == 1)
return $obj->localtax1;
5109 elseif ($local == 2)
return $obj->localtax2;
5129 $valors = explode(
":", $tax);
5131 if (count($valors) > 1) {
5147 $sql =
"SELECT t.localtax1, t.localtax2 ";
5148 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t inner join ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid=t.fk_pays";
5149 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.active = 1 AND t.taux=(";
5150 $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";
5151 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND tt.active = 1";
5154 $resql = $db->query($sql);
5157 $obj = $db->fetch_object(
$resql);
5158 if ($local == 1)
return $obj->localtax1;
5159 elseif ($local == 2)
return $obj->localtax2;
5177 function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid = 1)
5181 dol_syslog(
"getTaxesFromId vat id or rate = ".$vatrate);
5184 $sql =
"SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy,";
5185 $sql .=
" t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
5186 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
5187 if ($firstparamisid) {
5188 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
5190 $vatratecleaned = $vatrate;
5193 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg))
5195 $vatratecleaned = $reg[1];
5196 $vatratecode = $reg[2];
5199 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
5202 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($seller->country_code).
"'";
5203 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
5204 if ($vatratecode) $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
5207 $resql = $db->query($sql);
5209 $obj = $db->fetch_object(
$resql);
5210 if ($obj)
return array(
5211 'rowid'=>$obj->rowid,
5214 'localtax1'=>$obj->localtax1,
5215 'localtax1_type'=>$obj->localtax1_type,
5216 'localtax2'=>$obj->localtax2,
5217 'localtax2_type'=>$obj->localtax2_type,
5219 'accountancy_code_sell'=>$obj->accountancy_code_sell,
5220 'accountancy_code_buy'=>$obj->accountancy_code_buy
5222 else return array();
5248 dol_syslog(
"getLocalTaxesFromRate vatrate=".$vatrate.
" local=".$local);
5251 $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";
5252 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
5253 if ($firstparamisid) {
5254 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
5256 $vatratecleaned = $vatrate;
5259 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
5260 $vatratecleaned = $reg[1];
5261 $vatratecode = $reg[2];
5264 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
5265 if ($mysoc->country_code ==
'ES') $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($buyer->country_code).
"'";
5266 else $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(empty($seller->country_code) ? $mysoc->country_code : $seller->country_code).
"'";
5267 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
5268 if ($vatratecode) $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
5271 $resql = $db->query($sql);
5273 $obj = $db->fetch_object(
$resql);
5276 $vateratestring = $obj->rate.($obj->code ?
' ('.$obj->code.
')' :
'');
5279 return array($obj->localtax1_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
5280 } elseif ($local == 2) {
5281 return array($obj->localtax2_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
5283 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);
5303 global $db, $conf, $mysoc;
5305 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
5314 $result = $product->fetch($idprod);
5316 if ($mysoc->country_code == $thirdparty_seller->country_code)
5318 if ($idprodfournprice > 0)
5320 $product->get_buyprice($idprodfournprice, 0, 0, 0);
5321 $ret = $product->vatrate_supplier;
5322 if ($product->default_vat_code) $ret .=
' ('.$product->default_vat_code.
')';
5324 $ret = $product->tva_tx;
5325 if ($product->default_vat_code) $ret .=
' ('.$product->default_vat_code.
')';
5336 if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS))
5339 $sql =
"SELECT t.taux as vat_rate, t.code as default_vat_code";
5340 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
5341 $sql .=
" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdparty_seller->country_code).
"'";
5342 $sql .=
" ORDER BY t.taux DESC, t.code ASC, t.recuperableonly ASC";
5343 $sql .= $db->plimit(1);
5345 $resql = $db->query($sql);
5348 $obj = $db->fetch_object(
$resql);
5351 $ret = $obj->vat_rate;
5352 if ($obj->default_vat_code) $ret .=
' ('.$obj->default_vat_code.
')';
5356 }
else $ret = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
5359 dol_syslog(
"get_product_vat_for_country: ret=".$ret);
5376 if (!class_exists(
'Product')) {
5377 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
5387 $result = $product->fetch($idprod);
5389 if ($mysoc->country_code == $thirdparty_seller->country_code)
5404 $sql =
"SELECT taux as vat_rate, localtax1, localtax2";
5405 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
5406 $sql .=
" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdparty_seller->country_code).
"'";
5407 $sql .=
" ORDER BY t.taux DESC, t.recuperableonly ASC";
5408 $sql .= $db->plimit(1);
5410 $resql = $db->query($sql);
5413 $obj = $db->fetch_object(
$resql);
5416 if ($local == 1) $ret = $obj->localtax1;
5417 elseif ($local == 2) $ret = $obj->localtax2;
5422 dol_syslog(
"get_product_localtax_for_country: ret=".$ret);
5446 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
5449 $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;
5451 $seller_country_code = $thirdparty_seller->country_code;
5452 $seller_in_cee =
isInEEC($thirdparty_seller);
5454 $buyer_country_code = $thirdparty_buyer->country_code;
5455 $buyer_in_cee =
isInEEC($thirdparty_buyer);
5457 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 :
''));
5461 if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC))
5463 if ($seller_in_cee && $buyer_in_cee && !$thirdparty_buyer->
isACompany())
5471 if (!$seller_use_vat)
5480 if (($seller_country_code == $buyer_country_code)
5481 || (in_array($seller_country_code, array(
'FR,MC')) && in_array($buyer_country_code, array(
'FR',
'MC'))))
5492 if (($seller_in_cee && $buyer_in_cee))
5494 $isacompany = $thirdparty_buyer->
isACompany();
5497 if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID) && !
isValidVATID($thirdparty_buyer)) {
5510 if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC) && empty($buyer_in_cee) && !$thirdparty_buyer->
isACompany()) {
5535 if ($idprodfournprice > 0)
5537 if (!class_exists(
'ProductFournisseur')) {
5538 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
5541 $prodprice->fetch_product_fournisseur_price($idprodfournprice);
5542 return $prodprice->fourn_tva_npr;
5543 } elseif ($idprod > 0)
5545 if (!class_exists(
'Product')) {
5546 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
5549 $prod->fetch($idprod);
5550 return $prod->tva_npr;
5573 if (!is_object($thirdparty_seller))
return -1;
5574 if (!is_object($thirdparty_buyer))
return -1;
5578 if ($mysoc->country_code ==
'ES')
5580 if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj)
return 0;
5583 if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj)
return 0;
5584 if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj ==
'localtax1off')
return 0;
5586 } elseif ($local == 2)
5589 if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj)
return 0;
5590 if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj ==
'localtax2off')
return 0;
5593 if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code)
5609 function yn($yesno, $case = 1, $color = 0)
5612 $result =
'unknown'; $classname =
'';
5613 if ($yesno == 1 || strtolower($yesno) ==
'yes' || strtolower($yesno) ==
'true')
5615 $result = $langs->trans(
'yes');
5616 if ($case == 1 || $case == 3) $result = $langs->trans(
"Yes");
5617 if ($case == 2) $result =
'<input type="checkbox" value="1" checked disabled>';
5618 if ($case == 3) $result =
'<input type="checkbox" value="1" checked disabled> '.$result;
5621 } elseif ($yesno == 0 || strtolower($yesno) ==
'no' || strtolower($yesno) ==
'false')
5623 $result = $langs->trans(
"no");
5624 if ($case == 1 || $case == 3) $result = $langs->trans(
"No");
5625 if ($case == 2) $result =
'<input type="checkbox" value="0" disabled>';
5626 if ($case == 3) $result =
'<input type="checkbox" value="0" disabled> '.$result;
5628 if ($color == 2) $classname =
'ok';
5629 else $classname =
'error';
5631 if ($color)
return '<font class="'.$classname.
'">'.$result.
'</font>';
5650 function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart =
'')
5654 if (empty($modulepart) && !empty($object->module)) $modulepart = $object->module;
5658 $arrayforoldpath = array(
'cheque',
'category',
'holiday',
'supplier_invoice',
'invoice_supplier',
'mailing',
'supplier_payment');
5659 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[] =
'product';
5660 if (!empty($level) && in_array($modulepart, $arrayforoldpath)) {
5662 if (empty($alpha)) $num = preg_replace(
'/([^0-9])/i',
'', $num);
5663 else $num = preg_replace(
'/^.*\-/i',
'', $num);
5664 $num = substr(
"000".$num, -$level);
5665 if ($level == 1) $path = substr($num, 0, 1);
5666 if ($level == 2) $path = substr($num, 1, 1).
'/'.substr($num, 0, 1);
5667 if ($level == 3) $path = substr($num, 2, 1).
'/'.substr($num, 1, 1).
'/'.substr($num, 0, 1);
5676 if (empty($withoutslash) && !empty($path)) $path .=
'/';
5693 dol_syslog(
"functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
5696 if (@is_dir($dir_osencoded))
return 0;
5702 if (!empty($dataroot)) {
5704 $dir = str_replace($dataroot.
'/',
'', $dir);
5705 $ccdir = $dataroot.
'/';
5708 $cdir = explode(
"/", $dir);
5709 $num = count($cdir);
5710 for ($i = 0; $i < $num; $i++)
5712 if ($i > 0) $ccdir .=
'/'.$cdir[$i];
5713 else $ccdir .= $cdir[$i];
5714 if (preg_match(
"/^.:$/", $ccdir, $regs))
continue;
5721 if (!@is_dir($ccdir_osencoded))
5723 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG);
5726 $dirmaskdec = octdec($newmask);
5727 if (empty($newmask)) {
5728 $dirmaskdec = empty($conf->global->MAIN_UMASK) ? octdec(
'0755') : octdec($conf->global->MAIN_UMASK);
5730 $dirmaskdec |= octdec(
'0111');
5731 if (!@mkdir($ccdir_osencoded, $dirmaskdec))
5734 dol_syslog(
"functions.lib::dol_mkdir: Fails to create directory '".$ccdir.
"' or directory already exists.", LOG_WARNING);
5737 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' created", LOG_DEBUG);
5746 return ($nberr ? -$nberr : $nbcreated);
5757 return '<span class="fieldrequired">*</span>';
5777 function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
'UTF-8', $strip_tags = 0, $removedoublespaces = 1)
5779 if ($removelinefeed == 2) $stringtoclean = preg_replace(
'/<br[^>]*>(\n|\r)+/ims',
'<br>', $stringtoclean);
5780 $temp = preg_replace(
'/<br[^>]*>/i',
"\n", $stringtoclean);
5785 $temp = str_replace(
'< ',
'__ltspace__', $temp);
5788 $temp = strip_tags($temp);
5790 $pattern =
"/<[^<>]+>/";
5792 $temp = preg_replace($pattern,
"", $temp);
5793 $temp = preg_replace($pattern,
"", $temp);
5795 $temp = preg_replace(
'/<([a-z]+)/i',
'\1', $temp);
5801 if ($removelinefeed == 1) $temp = str_replace(array(
"\r\n",
"\r",
"\n"),
" ", $temp);
5804 if ($removedoublespaces) {
5805 while (strpos($temp,
" ")) {
5806 $temp = str_replace(
" ",
" ", $temp);
5810 $temp = str_replace(
'__ltspace__',
'< ', $temp);
5829 $allowed_tags = array(
5830 "html",
"head",
"meta",
"body",
"article",
"a",
"abbr",
"b",
"blockquote",
"br",
"cite",
"div",
"dl",
"dd",
"dt",
"em",
"font",
"img",
"ins",
"hr",
"i",
"li",
"link",
5831 "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"
5834 $allowed_tags_string = join(
"><", $allowed_tags);
5835 $allowed_tags_string =
'<'.$allowed_tags_string.
'>';
5837 $stringtoclean = str_replace(
'<!DOCTYPE html>',
'__!DOCTYPE_HTML__', $stringtoclean);
5840 $stringtoclean = preg_replace(
'/:/i',
':', $stringtoclean);
5842 $stringtoclean = preg_replace(
'/<!--[^>]*-->/',
'', $stringtoclean);
5843 $stringtoclean = preg_replace(
'/:|:|:/i',
'', $stringtoclean);
5844 $stringtoclean = preg_replace(
'/javascript\s*:/i',
'', $stringtoclean);
5846 $temp = strip_tags($stringtoclean, $allowed_tags_string);
5848 if ($cleanalsosomestyles) {
5849 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/i',
'', $temp);
5851 if ($removeclassattribute) {
5852 $temp = preg_replace(
'/(<[^>]+)\s+class=((["\']).*?\\3|\\w*)/i',
'\\1', $temp);
5857 if ($cleanalsojavascript) {
5858 $temp = preg_replace(
'/javascript\s*:/i',
'', $temp);
5861 $temp = str_replace(
'__!DOCTYPE_HTML__',
'<!DOCTYPE html>', $temp);
5879 $temp = $stringtoclean;
5880 foreach ($disallowed_tags as $tagtoremove)
5882 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'>/',
'', $temp);
5883 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'\s+[^>]*>/',
'', $temp);
5886 if ($cleanalsosomestyles) {
5887 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/',
'', $temp);
5905 if ($nboflines == 1)
5909 $firstline = preg_replace(
'/<br[^>]*>.*$/s',
'', $text);
5910 $firstline = preg_replace(
'/<div[^>]*>.*$/s',
'', $firstline);
5912 $firstline = preg_replace(
'/[\n\r].*/',
'', $text);
5914 return $firstline.((strlen($firstline) != strlen($text)) ?
'...' :
'');
5919 $text = preg_replace(
'/\n/',
'', $text);
5921 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
5923 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
5926 $text = strtr($text, $repTable);
5927 if ($charset ==
'UTF-8') { $pattern =
'/(<br[^>]*>)/Uu'; }
5928 else $pattern =
'/(<br[^>]*>)/U';
5929 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
5934 while (($i < $nba) && ($i < ($nboflines * 2)))
5936 if ($i % 2 == 0) $firstline .= $a[$i];
5937 elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) $firstline .= ($ishtml ?
"<br>\n" :
"\n");
5941 return $firstline.(($i < $nba) ?
'...' :
'');
5956 function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml =
false)
5959 return nl2br($stringtoencode, $forxml);
5961 $ret = preg_replace(
'/(\r\n|\r|\n)/i', ($forxml ?
'<br />' :
'<br>'), $stringtoencode);
5984 function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom =
'UTF-8', $removelasteolbr = 1)
5986 $newstring = $stringtoencode;
5989 $newstring = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
'<br>', $newstring);
5990 if ($removelasteolbr) $newstring = preg_replace(
'/<br>$/i',
'', $newstring);
5991 $newstring = strtr($newstring, array(
'&'=>
'__and__',
'<'=>
'__lt__',
'>'=>
'__gt__',
'"'=>
'__dquot__'));
5993 $newstring = strtr($newstring, array(
'__and__'=>
'&',
'__lt__'=>
'<',
'__gt__'=>
'>',
'__dquot__'=>
'"'));
5995 if ($removelasteolbr) $newstring = preg_replace(
'/(\r\n|\r|\n)$/i',
'', $newstring);
6013 $ret = preg_replace(
'/'.
"\r\n".
'<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"<br>", $ret);
6014 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\r\n".
'/i',
"\r\n", $ret);
6015 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\n".
'/i',
"\n", $ret);
6016 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"\n", $ret);
6028 $ret = preg_replace(
'/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'.
"\n".
'|'.
"\r".
')+$/i',
"", $stringtodecode);
6044 if ($keepsomeentities) $newstring = strtr($newstring, array(
'&'=>
'__andamp__',
'<'=>
'__andlt__',
'>'=>
'__andgt__',
'"'=>
'__dquot__'));
6045 $newstring = html_entity_decode($newstring, $b, $c);
6046 if ($keepsomeentities) $newstring = strtr($newstring, array(
'__andamp__'=>
'&',
'__andlt__'=>
'<',
'__andgt__'=>
'>',
'__dquot__'=>
'"'));
6062 return htmlentities($string, $flags, $encoding, $double_encode);
6079 for ($scursor = 0; $scursor < $len; $scursor++)
6081 $ordchar = ord($s[$scursor]);
6083 if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) { $ok = 0;
break; } elseif ($ordchar > 126 && $ordchar < 160) { $ok = 0;
break; } elseif ($clean) {
6084 $out .= $s[$scursor];
6087 if ($clean)
return $out;
6101 if ($s ==
'')
return 0;
6102 $arraystring = explode(
"\n", $s);
6103 $nb = count($arraystring);
6120 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
6121 if (
dol_textishtml($text)) $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
6123 $text = strtr($text, $repTable);
6124 if ($charset ==
'UTF-8') { $pattern =
'/(<br[^>]*>)/Uu'; }
6125 else $pattern =
'/(<br[^>]*>)/U';
6126 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
6128 $nblines = (int) floor((count($a) + 1) / 2);
6132 foreach ($a as $line)
6137 $line_dec = html_entity_decode($line);
6140 $line_dec = wordwrap($line_dec, $maxlinesize,
'\n',
true);
6141 $nblines += substr_count($line_dec,
'\n');
6163 if (preg_match(
'/<html/i', $msg))
return true;
6164 elseif (preg_match(
'/<body/i', $msg))
return true;
6165 elseif (preg_match(
'/<\/textarea/i', $msg))
return true;
6166 elseif (preg_match(
'/<br/i', $msg))
return true;
6169 if (preg_match(
'/<html/i', $msg))
return true;
6170 elseif (preg_match(
'/<body/i', $msg))
return true;
6171 elseif (preg_match(
'/<\/textarea/i', $msg))
return true;
6172 elseif (preg_match(
'/<(b|em|i|u)>/i', $msg))
return true;
6173 elseif (preg_match(
'/<br\/>/i', $msg))
return true;
6174 elseif (preg_match(
'/<(br|div|font|li|p|span|strong|table)>/i', $msg))
return true;
6175 elseif (preg_match(
'/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg))
return true;
6176 elseif (preg_match(
'/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg))
return true;
6177 elseif (preg_match(
'/<img\s+[^<>]*src[^<>]*>/i', $msg))
return true;
6178 elseif (preg_match(
'/<a\s+[^<>]*href[^<>]*>/i', $msg))
return true;
6179 elseif (preg_match(
'/<h[0-9]>/i', $msg))
return true;
6180 elseif (preg_match(
'/&[A-Z0-9]{1,6};/i', $msg))
return true;
6181 elseif (preg_match(
'/&#[0-9]{2,3};/i', $msg))
return true;
6203 if (!empty($invert))
6212 $ret .= (!empty($text1) && !empty($text2)) ? ((
dol_textishtml($text1) ||
dol_textishtml($text2)) ? ($forxml ?
"<br >\n" :
"<br>\n") :
"\n") :
"";
6231 global $db, $conf, $mysoc, $user, $extrafields;
6233 $substitutionarray = array();
6235 if (empty($exclude) || !in_array(
'user', $exclude))
6239 $signature = $user->signature;
6240 $substitutionarray = array_merge($substitutionarray, array(
6241 '__USER_SIGNATURE__' => (
string) (($signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ?
dol_trunc(
dol_string_nohtmltag($signature), 30) : $signature) :
'')
6245 $substitutionarray = array_merge($substitutionarray, array(
6246 '__USER_ID__' => (
string) $user->id,
6247 '__USER_LOGIN__' => (
string) $user->login,
6248 '__USER_EMAIL__' => (
string) $user->email,
6249 '__USER_LASTNAME__' => (
string) $user->lastname,
6250 '__USER_FIRSTNAME__' => (
string) $user->firstname,
6251 '__USER_FULLNAME__' => (
string) $user->getFullName($outputlangs),
6252 '__USER_SUPERVISOR_ID__' => (string) ($user->fk_user ? $user->fk_user :
'0'),
6257 if ((empty($exclude) || !in_array(
'mycompany', $exclude)) && is_object($mysoc))
6259 $substitutionarray = array_merge($substitutionarray, array(
6260 '__MYCOMPANY_NAME__' => $mysoc->name,
6261 '__MYCOMPANY_EMAIL__' => $mysoc->email,
6262 '__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
6263 '__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
6264 '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
6265 '__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
6266 '__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
6267 '__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
6268 '__MYCOMPANY_CAPITAL__' => $mysoc->capital,
6269 '__MYCOMPANY_FULLADDRESS__' => $mysoc->getFullAddress(1,
', '),
6270 '__MYCOMPANY_ADDRESS__' => $mysoc->address,
6271 '__MYCOMPANY_ZIP__' => $mysoc->zip,
6272 '__MYCOMPANY_TOWN__' => $mysoc->town,
6273 '__MYCOMPANY_COUNTRY__' => $mysoc->country,
6274 '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id,
6275 '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code,
6276 '__MYCOMPANY_CURRENCY_CODE__' => $conf->currency
6280 if (($onlykey || is_object($object)) && (empty($exclude) || !in_array(
'object', $exclude)))
6284 $substitutionarray[
'__ID__'] =
'__ID__';
6285 $substitutionarray[
'__REF__'] =
'__REF__';
6286 $substitutionarray[
'__REF_CLIENT__'] =
'__REF_CLIENT__';
6287 $substitutionarray[
'__REF_SUPPLIER__'] =
'__REF_SUPPLIER__';
6288 $substitutionarray[
'__NOTE_PUBLIC__'] =
'__NOTE_PUBLIC__';
6289 $substitutionarray[
'__NOTE_PRIVATE__'] =
'__NOTE_PRIVATE__';
6290 $substitutionarray[
'__EXTRAFIELD_XXX__'] =
'__EXTRAFIELD_XXX__';
6292 if (!empty($conf->societe->enabled))
6294 $substitutionarray[
'__THIRDPARTY_ID__'] =
'__THIRDPARTY_ID__';
6295 $substitutionarray[
'__THIRDPARTY_NAME__'] =
'__THIRDPARTY_NAME__';
6296 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
'__THIRDPARTY_NAME_ALIAS__';
6297 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
'__THIRDPARTY_CODE_CLIENT__';
6298 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
'__THIRDPARTY_CODE_FOURNISSEUR__';
6299 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
'__THIRDPARTY_EMAIL__';
6300 $substitutionarray[
'__THIRDPARTY_PHONE__'] =
'__THIRDPARTY_PHONE__';
6301 $substitutionarray[
'__THIRDPARTY_FAX__'] =
'__THIRDPARTY_FAX__';
6302 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
'__THIRDPARTY_ADDRESS__';
6303 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
'__THIRDPARTY_ZIP__';
6304 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
'__THIRDPARTY_TOWN__';
6305 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
'__THIRDPARTY_IDPROF1__';
6306 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
'__THIRDPARTY_IDPROF2__';
6307 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
'__THIRDPARTY_IDPROF3__';
6308 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
'__THIRDPARTY_IDPROF4__';
6309 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
'__THIRDPARTY_IDPROF5__';
6310 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
'__THIRDPARTY_IDPROF6__';
6311 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
'__THIRDPARTY_TVAINTRA__';
6312 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] =
'__THIRDPARTY_NOTE_PUBLIC__';
6313 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] =
'__THIRDPARTY_NOTE_PRIVATE__';
6315 if (!empty($conf->adherent->enabled) && (!is_object($object) || $object->element ==
'adherent'))
6317 $substitutionarray[
'__MEMBER_ID__'] =
'__MEMBER_ID__';
6318 $substitutionarray[
'__MEMBER_CIVILITY__'] =
'__MEMBER_CIVILITY__';
6319 $substitutionarray[
'__MEMBER_FIRSTNAME__'] =
'__MEMBER_FIRSTNAME__';
6320 $substitutionarray[
'__MEMBER_LASTNAME__'] =
'__MEMBER_LASTNAME__';
6324 if (!empty($conf->recruitment->enabled) && (!is_object($object) || $object->element ==
'candidature'))
6326 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
'__CANDIDATE_FULLNAME__';
6327 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] =
'__CANDIDATE_FIRSTNAME__';
6328 $substitutionarray[
'__CANDIDATE_LASTNAME__'] =
'__CANDIDATE_LASTNAME__';
6330 if (!empty($conf->projet->enabled))
6332 $substitutionarray[
'__PROJECT_ID__'] =
'__PROJECT_ID__';
6333 $substitutionarray[
'__PROJECT_REF__'] =
'__PROJECT_REF__';
6334 $substitutionarray[
'__PROJECT_NAME__'] =
'__PROJECT_NAME__';
6338 if (!empty($conf->contrat->enabled) && (!is_object($object) || $object->element ==
'contract'))
6340 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
'Highest date planned for a service start';
6341 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
'Highest date and hour planned for service start';
6342 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
'Lowest data for planned expiration of service';
6343 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
'Lowest date and hour for planned expiration of service';
6345 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'UrlToPayOnlineIfApplicable';
6346 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'TextAndUrlToPayOnlineIfApplicable';
6347 $substitutionarray[
'__SECUREKEYPAYMENT__'] =
'Security key (if key is not unique per record)';
6348 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
'Security key for payment on a member subscription (one key per member)';
6349 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
'Security key for payment on an order';
6350 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
'Security key for payment on an invoice';
6351 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
'Security key for payment on a a service';
6353 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'Direct download url of a proposal';
6354 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'Direct download url of an order';
6355 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'Direct download url of an invoice';
6357 if (!empty($conf->expedition->enabled) && (!is_object($object) || $object->element ==
'shipping'))
6359 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
'Shipping tracking number';
6360 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
'Shipping tracking url';
6362 if (!empty($conf->reception->enabled) && (!is_object($object) || $object->element ==
'reception'))
6364 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
'Shippin tracking number of shipment';
6365 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
'Shipping tracking url';
6368 $substitutionarray[
'__ID__'] = $object->id;
6369 $substitutionarray[
'__REF__'] = $object->ref;
6370 $substitutionarray[
'__REF_CLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null));
6371 $substitutionarray[
'__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null);
6372 $substitutionarray[
'__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null);
6373 $substitutionarray[
'__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null);
6375 $substitutionarray[
'__DATE_DELIVERY__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
'day', 0, $outputlangs) :
'');
6378 $substitutionarray[
'__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null));
6379 $substitutionarray[
'__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null);
6380 $substitutionarray[
'__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null));
6381 $substitutionarray[
'__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null);
6382 $substitutionarray[
'__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
'day', 0, $outputlangs) :
'');
6383 $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 :
'')) :
'');
6385 if (is_object($object) && ($object->element ==
'adherent' || $object->element ==
'member') && $object->id > 0)
6387 $birthday = (empty($object->birth) ?
'' :
dol_print_date($object->birth,
'day'));
6389 $substitutionarray[
'__MEMBER_ID__'] = (isset($object->id) ? $object->id :
'');
6390 if (method_exists($object,
'getCivilityLabel')) $substitutionarray[
'__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
6391 $substitutionarray[
'__MEMBER_FIRSTNAME__'] = (isset($object->firstname) ? $object->firstname :
'');
6392 $substitutionarray[
'__MEMBER_LASTNAME__'] = (isset($object->lastname) ? $object->lastname :
'');
6393 if (method_exists($object,
'getFullName')) $substitutionarray[
'__MEMBER_FULLNAME__'] = $object->getFullName($outputlangs);
6394 $substitutionarray[
'__MEMBER_COMPANY__'] = (isset($object->societe) ? $object->societe :
'');
6395 $substitutionarray[
'__MEMBER_ADDRESS__'] = (isset($object->address) ? $object->address :
'');
6396 $substitutionarray[
'__MEMBER_ZIP__'] = (isset($object->zip) ? $object->zip :
'');
6397 $substitutionarray[
'__MEMBER_TOWN__'] = (isset($object->town) ? $object->town :
'');
6398 $substitutionarray[
'__MEMBER_COUNTRY__'] = (isset($object->country) ? $object->country :
'');
6399 $substitutionarray[
'__MEMBER_EMAIL__'] = (isset($object->email) ? $object->email :
'');
6400 $substitutionarray[
'__MEMBER_BIRTH__'] = (isset($birthday) ? $birthday :
'');
6401 $substitutionarray[
'__MEMBER_PHOTO__'] = (isset($object->photo) ? $object->photo :
'');
6402 $substitutionarray[
'__MEMBER_LOGIN__'] = (isset($object->login) ? $object->login :
'');
6403 $substitutionarray[
'__MEMBER_PASSWORD__'] = (isset($object->pass) ? $object->pass :
'');
6404 $substitutionarray[
'__MEMBER_PHONE__'] = (isset($object->phone) ? $object->phone :
'');
6405 $substitutionarray[
'__MEMBER_PHONEPRO__'] = (isset($object->phone_perso) ? $object->phone_perso :
'');
6406 $substitutionarray[
'__MEMBER_PHONEMOBILE__'] = (isset($object->phone_mobile) ? $object->phone_mobile :
'');
6407 $substitutionarray[
'__MEMBER_TYPE__'] = (isset($object->type) ? $object->type :
'');
6408 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE__'] =
dol_print_date($object->first_subscription_date,
'dayrfc');
6409 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] =
dol_print_date($object->first_subscription_date_start,
'dayrfc');
6410 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] =
dol_print_date($object->first_subscription_date_end,
'dayrfc');
6411 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE__'] =
dol_print_date($object->last_subscription_date,
'dayrfc');
6412 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] =
dol_print_date($object->last_subscription_date_start,
'dayrfc');
6413 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] =
dol_print_date($object->last_subscription_date_end,
'dayrfc');
6416 if (is_object($object) && $object->element ==
'societe') {
6417 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object($object) ? $object->id :
'');
6418 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object($object) ? $object->name :
'');
6419 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object($object) ? $object->name_alias :
'');
6420 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object($object) ? $object->code_client :
'');
6421 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object) ? $object->code_fournisseur :
'');
6422 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object($object) ? $object->email :
'');
6423 $substitutionarray[
'__THIRDPARTY_PHONE__'] = (is_object($object) ? $object->phone :
'');
6424 $substitutionarray[
'__THIRDPARTY_FAX__'] = (is_object($object) ? $object->fax :
'');
6425 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object($object) ? $object->address :
'');
6426 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object($object) ? $object->zip :
'');
6427 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object($object) ? $object->town :
'');
6428 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object($object) ? $object->country_id :
'');
6429 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object) ? $object->country_code :
'');
6430 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object($object) ? $object->idprof1 :
'');
6431 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object($object) ? $object->idprof2 :
'');
6432 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object($object) ? $object->idprof3 :
'');
6433 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object($object) ? $object->idprof4 :
'');
6434 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object($object) ? $object->idprof5 :
'');
6435 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object($object) ? $object->idprof6 :
'');
6436 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object($object) ? $object->tva_intra :
'');
6437 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object) ?
dol_htmlentitiesbr($object->note_public) :
'');
6438 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object) ?
dol_htmlentitiesbr($object->note_private) :
'');
6439 } elseif (is_object($object->thirdparty)) {
6440 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->id :
'');
6441 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object($object->thirdparty) ? $object->thirdparty->name :
'');
6442 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty) ? $object->thirdparty->name_alias :
'');
6443 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_client :
'');
6444 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_fournisseur :
'');
6445 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty) ? $object->thirdparty->email :
'');
6446 $substitutionarray[
'__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty) ? $object->thirdparty->phone :
'');
6447 $substitutionarray[
'__THIRDPARTY_FAX__'] = (is_object($object->thirdparty) ? $object->thirdparty->fax :
'');
6448 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty) ? $object->thirdparty->address :
'');
6449 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty) ? $object->thirdparty->zip :
'');
6450 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty) ? $object->thirdparty->town :
'');
6451 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_id :
'');
6452 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_code :
'');
6453 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof1 :
'');
6454 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof2 :
'');
6455 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof3 :
'');
6456 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof4 :
'');
6457 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof5 :
'');
6458 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof6 :
'');
6459 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty) ? $object->thirdparty->tva_intra :
'');
6460 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object->thirdparty) ?
dol_htmlentitiesbr($object->thirdparty->note_public) :
'');
6461 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object->thirdparty) ?
dol_htmlentitiesbr($object->thirdparty->note_private) :
'');
6464 if (is_object($object) && $object->element ==
'recruitmentcandidature') {
6465 $substitutionarray[
'__CANDIDATE_FULLNAME__'] = $object->getFullName($outputlangs);
6466 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] = $object->firstname;
6467 $substitutionarray[
'__CANDIDATE_LASTNAME__'] = $object->lastname;
6470 if (is_object($object->project))
6472 $substitutionarray[
'__PROJECT_ID__'] = (is_object($object->project) ? $object->project->id :
'');
6473 $substitutionarray[
'__PROJECT_REF__'] = (is_object($object->project) ? $object->project->ref :
'');
6474 $substitutionarray[
'__PROJECT_NAME__'] = (is_object($object->project) ? $object->project->title :
'');
6476 if (is_object($object->projet))
6478 $substitutionarray[
'__PROJECT_ID__'] = (is_object($object->projet) ? $object->projet->id :
'');
6479 $substitutionarray[
'__PROJECT_REF__'] = (is_object($object->projet) ? $object->projet->ref :
'');
6480 $substitutionarray[
'__PROJECT_NAME__'] = (is_object($object->projet) ? $object->projet->title :
'');
6483 if (is_object($object) && $object->element ==
'shipping')
6485 $substitutionarray[
'__SHIPPINGTRACKNUM__'] = $object->tracking_number;
6486 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] = $object->tracking_url;
6488 if (is_object($object) && $object->element ==
'reception')
6490 $substitutionarray[
'__RECEPTIONTRACKNUM__'] = $object->tracking_number;
6491 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] = $object->tracking_url;
6494 if (is_object($object) && $object->element ==
'contrat' && $object->id > 0 && is_array($object->lines))
6496 $dateplannedstart =
'';
6497 $datenextexpiration =
'';
6498 foreach ($object->lines as $line)
6500 if ($line->date_ouverture_prevue > $dateplannedstart) $dateplannedstart = $line->date_ouverture_prevue;
6501 if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) $datenextexpiration = $line->date_fin_prevue;
6503 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
dol_print_date($dateplannedstart,
'dayrfc');
6504 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
dol_print_date($dateplannedstart,
'standard');
6505 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
dol_print_date($datenextexpiration,
'dayrfc');
6506 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
dol_print_date($datenextexpiration,
'standard');
6510 if ($object->table_element && $object->id > 0)
6512 if (!is_object($extrafields)) $extrafields =
new ExtraFields($db);
6513 $extrafields->fetch_name_optionals_label($object->table_element,
true);
6515 if ($object->fetch_optionals() > 0)
6517 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label']) > 0)
6519 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $label) {
6520 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = $object->array_options[
'options_'.$key];
6521 if ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'date') {
6522 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_date($object->array_options[
'options_'.$key],
'day');
6523 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] =
dol_print_date($object->array_options[
'options_'.$key],
'day',
'tzserver', $outputlangs);
6524 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] =
dol_print_date($object->array_options[
'options_'.$key],
'dayrfc');
6525 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'datetime') {
6526 $datetime = $object->array_options[
'options_'.$key];
6527 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
6528 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
6529 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_DAY_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'day',
'tzserver', $outputlangs) :
'');
6530 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
6539 if (empty($substitutionarray[
'__REF__']))
6544 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
6545 $outputlangs->loadLangs(array(
'paypal',
'other'));
6546 $typeforonlinepayment =
'free';
6547 if (is_object($object) && $object->element ==
'commande') $typeforonlinepayment =
'order';
6548 if (is_object($object) && $object->element ==
'facture') $typeforonlinepayment =
'invoice';
6549 if (is_object($object) && $object->element ==
'member') $typeforonlinepayment =
'member';
6550 $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray[
'__REF__']);
6554 if ($object->id > 0)
6556 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ?str_replace(
'\n',
"\n", $outputlangs->trans(
"PredefinedMailContentLink", $paymenturl)) :
'');
6557 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] = $paymenturl;
6559 if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'propal')
6561 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
6562 }
else $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'';
6563 if (!empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'commande')
6565 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element);
6566 }
else $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'';
6567 if (!empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'facture')
6569 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element);
6570 }
else $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'';
6572 if (is_object($object) && $object->element ==
'propal') $substitutionarray[
'__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/comm/propal/card.php?id=".$object->id;
6573 if (is_object($object) && $object->element ==
'commande') $substitutionarray[
'__URL_ORDER__'] = DOL_MAIN_URL_ROOT.
"/commande/card.php?id=".$object->id;
6574 if (is_object($object) && $object->element ==
'facture') $substitutionarray[
'__URL_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/compta/facture/card.php?id=".$object->id;
6577 if (is_object($object) && $object->element ==
'action')
6579 $substitutionarray[
'__EVENT_LABEL__'] = $object->label;
6580 $substitutionarray[
'__EVENT_DATE__'] =
dol_print_date($object->datep,
'%A %d %b %Y');
6581 $substitutionarray[
'__EVENT_TIME__'] =
dol_print_date($object->datep,
'%H:%M:%S');
6585 if (empty($exclude) || !in_array(
'objectamount', $exclude))
6587 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functionsnumtoword.lib.php';
6589 $substitutionarray[
'__DATE_YMD__'] = is_object($object) ? (isset($object->date) ?
dol_print_date($object->date,
'day', 0, $outputlangs) : null) :
'';
6590 $substitutionarray[
'__DATE_DUE_YMD__'] = is_object($object) ? (isset($object->date_lim_reglement) ?
dol_print_date($object->date_lim_reglement,
'day', 0, $outputlangs) : null) :
'';
6592 $substitutionarray[
'__AMOUNT__'] = is_object($object) ? $object->total_ttc :
'';
6593 $substitutionarray[
'__AMOUNT_TEXT__'] = is_object($object) ?
dol_convertToWord($object->total_ttc, $outputlangs,
'',
true) :
'';
6594 $substitutionarray[
'__AMOUNT_TEXTCURRENCY__'] = is_object($object) ?
dol_convertToWord($object->total_ttc, $outputlangs, $conf->currency,
true) :
'';
6595 $substitutionarray[
'__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht :
'';
6596 $substitutionarray[
'__AMOUNT_VAT__'] = is_object($object) ? (isset($object->total_vat) ? $object->total_vat : $object->total_tva) :
'';
6597 $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)) :
'';
6598 $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)) :
'';
6599 if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray[
'__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 :
'';
6600 if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray[
'__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 :
'';
6602 $substitutionarray[
'__AMOUNT_FORMATED__'] = is_object($object) ? ($object->total_ttc ?
price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency) : null) :
'';
6603 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object) ? ($object->total_ht ?
price($object->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency) : null) :
'';
6604 $substitutionarray[
'__AMOUNT_VAT_FORMATED__'] = is_object($object) ? (isset($object->total_vat) ?
price($object->total_vat, 0, $outputlangs, 0, 0, -1, $conf->currency) : ($object->total_tva ?
price($object->total_tva, 0, $outputlangs, 0, 0, -1, $conf->currency) : null)) :
'';
6605 if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray[
'__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? ($object->total_localtax1 ?
price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency) : null) :
'';
6606 if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray[
'__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? ($object->total_localtax2 ?
price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency) : null) :
'';
6608 $substitutionarray[
'__AMOUNT_MULTICURRENCY__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ? $object->multicurrency_total_ttc :
'';
6609 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXT__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ?
dol_convertToWord($object->multicurrency_total_ttc, $outputlangs,
'',
true) :
'';
6610 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXTCURRENCY__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ?
dol_convertToWord($object->multicurrency_total_ttc, $outputlangs, $object->multicurrency_code,
true) :
'';
6616 $substitutionarray[
'__TOTAL_TTC__'] = is_object($object) ? $object->total_ttc :
'';
6617 $substitutionarray[
'__TOTAL_HT__'] = is_object($object) ? $object->total_ht :
'';
6618 $substitutionarray[
'__TOTAL_VAT__'] = is_object($object) ? (isset($object->total_vat) ? $object->total_vat : $object->total_tva) :
'';
6623 if (empty($exclude) || !in_array(
'date', $exclude))
6625 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
6633 $daytext = $outputlangs->trans(
'Day'.$tmp[
'wday']);
6635 $substitutionarray = array_merge($substitutionarray, array(
6636 '__DAY__' => (
string) $tmp[
'mday'],
6637 '__DAY_TEXT__' => $daytext,
6638 '__DAY_TEXT_SHORT__' =>
dol_trunc($daytext, 3,
'right',
'UTF-8', 1),
6639 '__DAY_TEXT_MIN__' =>
dol_trunc($daytext, 1,
'right',
'UTF-8', 1),
6640 '__MONTH__' => (
string) $tmp[
'mon'],
6641 '__MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp[
'mon'])),
6642 '__MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp[
'mon'])),
6643 '__MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp[
'mon'])),
6644 '__YEAR__' => (
string) $tmp[
'year'],
6645 '__PREVIOUS_DAY__' => (string) $tmp2[
'day'],
6646 '__PREVIOUS_MONTH__' => (
string) $tmp3[
'month'],
6647 '__PREVIOUS_YEAR__' => (string) ($tmp[
'year'] - 1),
6648 '__NEXT_DAY__' => (string) $tmp4[
'day'],
6649 '__NEXT_MONTH__' => (
string) $tmp5[
'month'],
6650 '__NEXT_YEAR__' => (string) ($tmp[
'year'] + 1),
6654 if (!empty($conf->multicompany->enabled))
6656 $substitutionarray = array_merge($substitutionarray, array(
'__ENTITY_ID__' => $conf->entity));
6658 if (empty($exclude) || !in_array(
'system', $exclude))
6660 $substitutionarray[
'__DOL_MAIN_URL_ROOT__'] = DOL_MAIN_URL_ROOT;
6661 $substitutionarray[
'__(AnyTranslationKey)__'] = $outputlangs->trans(
'TranslationOfKey');
6662 $substitutionarray[
'__(AnyTranslationKey|langfile)__'] = $outputlangs->trans(
'TranslationOfKey').
' (load also language file before)';
6663 $substitutionarray[
'__[AnyConstantKey]__'] = $outputlangs->trans(
'ValueOfConstantKey');
6666 return $substitutionarray;
6685 global $conf, $langs;
6687 if (!is_array($substitutionarray))
return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
6689 if (empty($outputlangs)) $outputlangs = $langs;
6692 if (is_object($outputlangs))
6695 while (preg_match(
'/__\(([^\)]+)\)__/', $text, $reg))
6701 $tmp = explode(
'|', $reg[1]);
6702 if (!empty($tmp[1])) $outputlangs->load($tmp[1]);
6704 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $msgishtml ?
dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])) : $outputlangs->transnoentitiesnoconv($reg[1]), $text);
6711 while (preg_match(
'/__\[([^\]]+)\]__/', $text, $reg))
6716 $keyfound = $reg[1];
6717 if (
isASecretKey($keyfound)) $newval =
'*****forbidden*****';
6718 else $newval = empty($conf->global->$keyfound) ?
'' : $conf->global->$keyfound;
6719 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $msgishtml ?
dol_htmlentitiesbr($newval) : $newval, $text);
6723 foreach ($substitutionarray as $key => $value)
6725 if (!isset($value))
continue;
6727 if ($key ==
'__USER_SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value =
'';
6729 $text = str_replace(
"$key",
"$value", $text);
6749 global $conf, $user;
6751 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
6767 $dirsubstitutions = array_merge(array(), (array) $conf->modules_parts[
'substitutions']);
6769 foreach ($dirsubstitutions as $reldir)
6776 $substitfiles =
dol_dir_list($dir,
'files', 0,
'functions_');
6777 foreach ($substitfiles as $substitfile)
6780 if (preg_match(
'/functions_(.*)\.lib\.php/i', $substitfile[
'name'], $reg))
6784 dol_syslog(
"Library ".$substitfile[
'name'].
" found into ".$dir);
6786 require_once $dir.$substitfile[
'name'];
6788 $function_name = $module.
"_".$callfunc;
6789 if (function_exists($function_name)) {
6790 $function_name($substitutionarray, $outputlangs, $object, $parameters);
6795 if (!empty($conf->global->ODT_ENABLE_ALL_TAGS_IN_SUBSTITUTIONS)) {
6798 foreach ($substitutionarray as $key => $value) {
6799 $tags .=
'{'.$key.
'} => '.$value.
"\n";
6801 $substitutionarray = array_merge($substitutionarray, array(
'__ALL_TAGS__' => $tags));
6829 function get_date_range($date_start, $date_end, $format =
'', $outputlangs =
'', $withparenthesis = 1)
6835 if (!is_object($outputlangs)) $outputlangs = $langs;
6837 if ($date_start && $date_end)
6839 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFromTo',
dol_print_date($date_start, $format,
false, $outputlangs),
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
6841 if ($date_start && !$date_end)
6843 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($date_start, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
6845 if (!$date_start && $date_end)
6847 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
6867 if ($nameorder < 0) $nameorder = (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0);
6868 if ($nameorder == 1) {
6870 if ($firstname && $lastname) $ret .=
' ';
6872 } elseif ($nameorder == 2 || $nameorder == 3) {
6874 if (empty($ret) && $nameorder == 3) {
6879 if (empty($ret) && $nameorder == 5) {
6882 if ($nameorder == 0) {
6883 if ($firstname && $lastname) $ret .=
' ';
6904 if (!is_array($mesgs)) {
6906 if ($mesgs) $_SESSION[
'dol_events'][$style][] = $mesgs;
6909 foreach ($mesgs as $mesg)
6911 if ($mesg) $_SESSION[
'dol_events'][$style][] = $mesg;
6929 if (empty($mesg) && empty($mesgs))
6931 dol_syslog(
"Try to add a message in stack with empty message", LOG_WARNING);
6939 if (empty($messagekey) || empty($_COOKIE[
"DOLHIDEMESSAGE".$messagekey]))
6941 if (!in_array((
string) $style, array(
'mesgs',
'warnings',
'errors')))
dol_print_error(
'',
'Bad parameter style='.$style.
' for setEventMessages');
6944 if (!empty($mesg) && !in_array($mesg, $mesgs))
setEventMessage($mesg, $style);
6963 if (isset($_SESSION[
'dol_events'][
'mesgs'])) {
6964 if (empty($disabledoutputofmessages))
dol_htmloutput_mesg(
'', $_SESSION[
'dol_events'][
'mesgs']);
6965 unset($_SESSION[
'dol_events'][
'mesgs']);
6969 if (isset($_SESSION[
'dol_events'][
'errors'])) {
6970 if (empty($disabledoutputofmessages))
dol_htmloutput_mesg(
'', $_SESSION[
'dol_events'][
'errors'],
'error');
6971 unset($_SESSION[
'dol_events'][
'errors']);
6975 if (isset($_SESSION[
'dol_events'][
'warnings'])) {
6976 if (empty($disabledoutputofmessages))
dol_htmloutput_mesg(
'', $_SESSION[
'dol_events'][
'warnings'],
'warning');
6977 unset($_SESSION[
'dol_events'][
'warnings']);
6997 global $conf, $langs;
6999 $ret = 0; $return =
'';
7001 $divstart = $divend =
'';
7004 if ((empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && !preg_match(
'/<div class=".*">/i', $out))
7006 $divstart =
'<div class="'.$style.
' clearboth">';
7010 if ((is_array($mesgarray) && count($mesgarray)) || $mesgstring)
7012 $langs->load(
"errors");
7014 if (is_array($mesgarray) && count($mesgarray))
7016 foreach ($mesgarray as $message)
7019 $out .= $langs->trans($message);
7020 if ($ret < count($mesgarray)) $out .=
"<br>\n";
7025 $langs->load(
"errors");
7027 $out .= $langs->trans($mesgstring);
7034 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && empty($keepembedded))
7037 $(document).ready(function() {
7038 var block = '.(!empty($conf->global->MAIN_USE_JQUERY_BLOCKUI) ?
"true" :
"false").
'
7042 /* jnotify(message, preset of message type, keepmessage) */
7044 "'.($style ==
"ok" ? 3000 : $style).
'",
7045 '.($style ==
"ok" ?
"false" :
"true").
',
7046 { remove: function (){} } );
7089 if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0))
return;
7093 if (is_array($mesgarray))
7095 foreach ($mesgarray as $val)
7097 if ($val && preg_match(
'/class="error"/i', $val)) { $iserror++;
break; }
7098 if ($val && preg_match(
'/class="warning"/i', $val)) { $iswarning++;
break; }
7100 } elseif ($mesgstring && preg_match(
'/class="error"/i', $mesgstring)) $iserror++;
7101 elseif ($mesgstring && preg_match(
'/class="warning"/i', $mesgstring)) $iswarning++;
7102 if ($style ==
'error') $iserror++;
7103 if ($style ==
'warning') $iswarning++;
7105 if ($iserror || $iswarning)
7108 $mesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $mesgstring);
7109 $mesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $mesgstring);
7110 $mesgstring = preg_replace(
'/<\/div>/',
'', $mesgstring);
7112 if (is_array($mesgarray))
7114 $newmesgarray = array();
7115 foreach ($mesgarray as $val)
7117 if (is_string($val))
7119 $tmpmesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $val);
7120 $tmpmesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $tmpmesgstring);
7121 $tmpmesgstring = preg_replace(
'/<\/div>/',
'', $tmpmesgstring);
7122 $newmesgarray[] = $tmpmesgstring;
7124 dol_syslog(
"Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING);
7127 $mesgarray = $newmesgarray;
7162 function dol_sort_array(&$array, $index, $order =
'asc', $natsort = 0, $case_sensitive = 0, $keepindex = 0)
7165 $order = strtolower($order);
7167 if (is_array($array))
7169 $sizearray = count($array);
7173 foreach (array_keys($array) as $key)
7175 if (is_object($array[$key])) {
7176 $temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index;
7178 $temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index];
7183 ($order ==
'asc') ? asort($temp) : arsort($temp);
7185 ($case_sensitive) ? natsort($temp) : natcasesort($temp);
7186 if ($order !=
'asc') $temp = array_reverse($temp,
true);
7191 foreach (array_keys($temp) as $key)
7193 (is_numeric($key) && empty($keepindex)) ? $sorted[] = $array[$key] : $sorted[$key] = $array[$key];
7211 $str = (string) $str;
7215 for ($i = 0; $i < $strLength; $i++) {
7216 if (ord($str[$i]) < 0x80)
continue;
7217 elseif ((ord($str[$i]) & 0xE0) == 0xC0) $n = 1;
7218 elseif ((ord($str[$i]) & 0xF0) == 0xE0) $n = 2;
7219 elseif ((ord($str[$i]) & 0xF8) == 0xF0) $n = 3;
7220 elseif ((ord($str[$i]) & 0xFC) == 0xF8) $n = 4;
7221 elseif ((ord($str[$i]) & 0xFE) == 0xFC) $n = 5;
7223 for ($j = 0; $j < $n; $j++) {
7224 if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80))
7239 if (function_exists(
'mb_check_encoding')) {
7241 if (!mb_check_encoding($str,
'ASCII'))
return false;
7243 if (preg_match(
'/[^\x00-\x7f]/', $str))
return false;
7261 $tmp = ini_get(
"unicode.filesystem_encoding");
7262 if (empty($tmp) && !empty(
$_SERVER[
"WINDIR"])) $tmp =
'iso-8859-1';
7263 if (empty($tmp)) $tmp =
'utf-8';
7264 if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING)) $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING;
7266 if ($tmp ==
'iso-8859-1')
return utf8_decode($str);
7284 function dol_getIdFromCode($db, $key, $tablename, $fieldkey =
'code', $fieldid =
'id', $entityfilter = 0)
7286 global $cache_codes;
7289 if ($key ==
'')
return '';
7292 if (isset($cache_codes[$tablename][$key][$fieldid]))
7294 return $cache_codes[$tablename][$key][$fieldid];
7297 dol_syslog(
'dol_getIdFromCode (value for field '.$fieldid.
' from key '.$key.
' not found into cache)', LOG_DEBUG);
7299 $sql =
"SELECT ".$fieldid.
" as valuetoget";
7300 $sql .=
" FROM ".MAIN_DB_PREFIX.$tablename;
7301 $sql .=
" WHERE ".$fieldkey.
" = '".$db->escape($key).
"'";
7302 if (!empty($entityfilter))
7303 $sql .=
" AND entity IN (".getEntity($tablename).
")";
7305 $resql = $db->query($sql);
7308 $obj = $db->fetch_object(
$resql);
7309 if ($obj) $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget;
7310 else $cache_codes[$tablename][$key][$fieldid] =
'';
7312 return $cache_codes[$tablename][$key][$fieldid];
7326 global $user, $conf, $langs;
7332 if ($strRights !=
'')
7334 $str =
'if(!('.$strRights.
')) { $rights = false; }';
7349 function dol_eval($s, $returnvalue = 0, $hideerrors = 1)
7352 global $db, $langs, $user, $conf, $website, $websitepage;
7353 global $action, $mainmenu, $leftmenu;
7363 if ($hideerrors)
return @eval(
'return '.$s.
';');
7364 else return eval(
'return '.$s.
';');
7366 if ($hideerrors) @eval($s);
7379 return (trim($element) !=
'');
7391 if (empty($codelang))
return '';
7393 if ($codelang ==
'auto')
7395 return '<span class="fa fa-globe"></span>';
7398 $langtocountryflag = array(
7400 'ca_ES' =>
'catalonia',
7404 'sw_SW' =>
'unknown',
7414 if (isset($langtocountryflag[$codelang])) $flagImage = $langtocountryflag[$codelang];
7416 $tmparray = explode(
'_', $codelang);
7417 $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
7420 return img_picto_common($codelang,
'flags/'.strtolower($flagImage).
'.png', $moreatt);
7434 if (empty($countrycode))
return null;
7436 if (strtoupper($countrycode) ==
'MQ')
return 'fr_CA';
7437 if (strtoupper($countrycode) ==
'SE')
return 'sv_SE';
7438 if (strtoupper($countrycode) ==
'CH')
7440 if ($mysoc->country_code ==
'FR')
return 'fr_CH';
7441 if ($mysoc->country_code ==
'DE')
return 'de_CH';
7618 $buildprimarykeytotest = strtolower($countrycode).
'-'.strtoupper($countrycode);
7619 if (in_array($buildprimarykeytotest, $locales))
return strtolower($countrycode).
'_'.strtoupper($countrycode);
7621 if (function_exists(
'locale_get_primary_language') && function_exists(
'locale_get_region'))
7623 foreach ($locales as $locale)
7625 $locale_language = locale_get_primary_language($locale);
7626 $locale_region = locale_get_region($locale);
7627 if (strtoupper($countrycode) == $locale_region)
7630 return strtolower($locale_language).
'_'.strtoupper($locale_region);
7634 dol_syslog(
"Warning Exention php-intl is not available", LOG_WARNING);
7671 global $hookmanager;
7673 if (isset($conf->modules_parts[
'tabs'][$type]) && is_array($conf->modules_parts[
'tabs'][$type]))
7675 foreach ($conf->modules_parts[
'tabs'][$type] as $value)
7677 $values = explode(
':', $value);
7679 if ($mode ==
'add' && !preg_match(
'/^\-/', $values[1]))
7681 if (count($values) == 6)
7683 if ($values[0] != $type)
continue;
7687 if ($values[3]) $langs->load($values[3]);
7688 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg))
7690 $substitutionarray = array();
7693 }
else $label = $langs->trans($values[2]);
7695 $head[$h][0] =
dol_buildpath(preg_replace(
'/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id :
''), $values[5]), 1);
7696 $head[$h][1] = $label;
7697 $head[$h][2] = str_replace(
'+',
'', $values[1]);
7700 } elseif (count($values) == 5)
7702 dol_syslog(
'Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
7704 if ($values[0] != $type)
continue;
7705 if ($values[3]) $langs->load($values[3]);
7706 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg))
7708 $substitutionarray = array();
7711 }
else $label = $langs->trans($values[2]);
7713 $head[$h][0] =
dol_buildpath(preg_replace(
'/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id :
''), $values[4]), 1);
7714 $head[$h][1] = $label;
7715 $head[$h][2] = str_replace(
'+',
'', $values[1]);
7718 } elseif ($mode ==
'remove' && preg_match(
'/^\-/', $values[1]))
7720 if ($values[0] != $type)
continue;
7721 $tabname = str_replace(
'-',
'', $values[1]);
7722 foreach ($head as $key => $val)
7724 $condition = (!empty($values[3]) ?
verifCond($values[3]) : 1);
7726 if ($head[$key][2] == $tabname && $condition)
7737 if (!empty($hookmanager))
7739 $parameters = array(
'object' => $object,
'mode' => $mode,
'head' => $head);
7740 $reshook = $hookmanager->executeHooks(
'completeTabsHead', $parameters);
7743 $head = $hookmanager->resArray;
7762 global $conf, $hookmanager, $user, $debugbar;
7764 global $micro_start_time;
7766 if ($zone ==
'private')
print "\n".
'<!-- Common footer for private page -->'.
"\n";
7767 else print "\n".
'<!-- Common footer for public page -->'.
"\n";
7770 print "\n<!-- A div to store page_y POST parameter -->\n";
7771 print '<div id="page_y" style="display: none;">'.(empty($_POST[
'page_y']) ?
'' : $_POST[
'page_y']).
'</div>'.
"\n";
7773 $parameters = array();
7774 $reshook = $hookmanager->executeHooks(
'printCommonFooter', $parameters);
7775 if (empty($reshook))
7777 if (!empty($conf->global->MAIN_HTML_FOOTER))
print $conf->global->MAIN_HTML_FOOTER.
"\n";
7780 if (!empty($conf->use_javascript_ajax))
7782 print '<script>'.
"\n";
7783 print 'jQuery(document).ready(function() {'.
"\n";
7785 if ($zone ==
'private' && empty($conf->dol_use_jmobile))
7788 print '/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'.
"\n";
7789 print 'jQuery("li.menuhider").click(function(event) {';
7790 print ' if (!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'.
"\n";
7791 print ' console.log("We click on .menuhider");'.
"\n";
7792 print ' $("body").toggleClass("sidebar-collapse")'.
"\n";
7797 if ($action ==
'create' || $action ==
'edit' || (empty($action) && (preg_match(
'/new\.php/',
$_SERVER[
"PHP_SELF"]))))
7799 print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */'.
"\n";
7800 $relativepathstring =
$_SERVER[
"PHP_SELF"];
7802 if (constant(
'DOL_URL_ROOT')) $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
7803 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
7804 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
7806 if (!empty($user->default_values[$relativepathstring][
'focus']))
7808 foreach ($user->default_values[$relativepathstring][
'focus'] as $defkey => $defval)
7811 if ($defkey !=
'_noquery_')
7813 $tmpqueryarraytohave = explode(
'&', $defkey);
7815 foreach ($tmpqueryarraytohave as $tmpquerytohave)
7817 $tmpquerytohaveparam = explode(
'=', $tmpquerytohave);
7819 if (!
GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] !=
GETPOST($tmpquerytohaveparam[0]))) $foundintru = 1;
7821 if (!$foundintru) $qualified = 1;
7823 }
else $qualified = 1;
7827 foreach ($defval as $paramkey => $paramval)
7830 print 'jQuery("input[name=\''.$paramkey.
'\']
").focus();'."\n";
7831 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").focus();'."\n";
7832 print 'jQuery("select[name=\
''.$paramkey.
'\']
").focus();'."\n"; // Not really usefull, but we keep it in case of.
7837 if (!empty($user->default_values[$relativepathstring]['mandatory']))
7839 foreach ($user->default_values[$relativepathstring]['mandatory'] as $defkey => $defval)
7842 if ($defkey != '_noquery_')
7844 $tmpqueryarraytohave = explode('&', $defkey);
7846 foreach ($tmpqueryarraytohave as $tmpquerytohave)
7848 $tmpquerytohaveparam = explode('=', $tmpquerytohave);
7849 //print "console.log(
'".$tmpquerytohaveparam[0]." ".$tmpquerytohaveparam[1]." ".GETPOST($tmpquerytohaveparam[0])."');
";
7850 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] != GETPOST($tmpquerytohaveparam[0]))) $foundintru = 1;
7852 if (!$foundintru) $qualified = 1;
7853 //var_dump($defkey.'-'.$qualified);
7854 } else $qualified = 1;
7858 foreach ($defval as $paramkey => $paramval)
7860 // Add property 'required' on input
7861 print 'jQuery("input[name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n";
7862 print 'jQuery("textarea[name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n";
7863 print 'jQuery("select[name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n"; // required on a select works only if key is "", this does not happen in Dolibarr
7873 if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO']) || !empty($conf->global->MAIN_SHOW_TUNING_INFO))
7877 print 'window.console && console.log("';
7878 if (!empty($conf->global->MEMCACHED_SERVER)) print 'MEMCACHED_SERVER=
'.$conf->global->MEMCACHED_SERVER.' -
';
7879 print 'MAIN_OPTIMIZE_SPEED=
'.(isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off
');
7880 if (!empty($micro_start_time)) // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable.
7882 $micro_end_time = microtime(true);
7883 print ' - Build time:
'.ceil(1000 * ($micro_end_time - $micro_start_time)).' ms
';
7886 if (function_exists("memory_get_usage")) {
7887 print ' - Mem:
'.memory_get_usage(); // Do not use true here, it seems it takes the peak amount
7889 if (function_exists("memory_get_peak_usage")) {
7890 print ' - Real mem peak:
'.memory_get_peak_usage(true);
7892 if (function_exists("zend_loader_file_encoded"))
7894 print ' - Zend encoded file:
'.(zend_loader_file_encoded() ? 'yes
' : 'no
');
7899 print "\n".'</script>'."\n";
7902 // TODO Add a hook here
7903 if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID))
7905 $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID);
7906 foreach ($tmptagarray as $tmptag) {
7908 print "<!-- JS CODE TO ENABLE
for google analtics tag -->\n
";
7910 <!-- Global site tag (gtag.js) - Google Analytics -->
7911 <script async src=\
"https://www.googletagmanager.com/gtag/js?id=".trim($tmptag).
"\"></script>
7913 window.dataLayer = window.dataLayer || [];
7914 function gtag(){dataLayer.push(arguments);}
7915 gtag('js', new Date());
7917 gtag('config', '".trim($tmptag).
"');
7925 if (defined(
'XDEBUGCOVERAGE'))
7927 print_r(xdebug_get_code_coverage());
7931 if (!empty($user->rights->debugbar->read) && is_object($debugbar))
7933 $debugbar[
'time']->stopMeasure(
'pageaftermaster');
7934 print '<!-- Output debugbar data -->'.
"\n";
7935 $renderer = $debugbar->getRenderer();
7936 print $debugbar->getRenderer()->render();
7937 } elseif (count($conf->logbuffer))
7940 print "<!-- Start of log output\n";
7942 foreach ($conf->logbuffer as $logline)
7944 print $logline.
"<br>\n";
7947 print "End of log output -->\n";
7963 if ($a = explode($delimiter, $string))
7966 foreach ($a as $s) {
7968 if ($pos = strpos($s, $kv)) {
7969 $ka[trim(substr($s, 0, $pos))] = trim(substr($s, $pos + strlen($kv)));
7989 print "\n".
'<!-- Set focus onto a specific field -->'.
"\n";
7990 print '<script>jQuery(document).ready(function() { jQuery("'.dol_escape_js($selector).
'").focus(); });</script>'.
"\n";
8003 if (!function_exists(
'getmypid')) {
8004 return mt_rand(1, 32768);
8031 $value = trim($value);
8035 $value = preg_replace(
'/\*/',
'%', $value);
8039 $value = preg_replace(
'/([<>=]+)\s+([0-9'.preg_quote($langs->trans(
"DecimalSeparator"),
'/').
'\-])/',
'\1\2', $value);
8042 $value = preg_replace(
'/\s*\|\s*/',
'|', $value);
8044 $crits = explode(
' ', $value);
8046 if (!is_array($fields)) $fields = array($fields);
8049 foreach ($crits as $crit)
8051 $crit = trim($crit);
8054 foreach ($fields as $field)
8059 $newcrit = preg_replace(
'/([<>=]+)/',
'', $crit);
8062 preg_match(
'/([<>=]+)/', $crit, $reg);
8065 $operator = $reg[1];
8070 if (is_numeric($numnewcrit))
8072 $newres .= ($i2 > 0 ?
' OR ' :
'').$field.
' '.$operator.
' '.$db->sanitize($numnewcrit);
8074 $newres .= ($i2 > 0 ?
' OR ' :
'').
'1 = 2';
8078 } elseif ($mode == 2 || $mode == -2)
8080 $crit = preg_replace(
'/[^0-9,]/',
'', $crit);
8081 $newres .= ($i2 > 0 ?
' OR ' :
'').$field.
" ".($mode == -2 ?
'NOT ' :
'');
8082 $newres .= $crit ?
"IN (".$db->sanitize($db->escape($crit)).
")" :
"IN (0)";
8083 if ($mode == -2) $newres .=
' OR '.$field.
' IS NULL';
8085 } elseif ($mode == 3 || $mode == -3)
8087 $tmparray = explode(
',', $crit);
8088 if (count($tmparray))
8091 foreach ($tmparray as $val)
8096 $listofcodes .= ($listofcodes ?
',' :
'');
8097 $listofcodes .=
"'".$db->escape($val).
"'";
8100 $newres .= ($i2 > 0 ?
' OR ' :
'').$field.
" ".($mode == -3 ?
'NOT ' :
'').
"IN (".$db->sanitize($listofcodes, 1).
")";
8103 if ($mode == -3) $newres .=
' OR '.$field.
' IS NULL';
8104 } elseif ($mode == 4)
8106 $tmparray = explode(
',', $crit);
8107 if (count($tmparray))
8110 foreach ($tmparray as $val)
8115 $newres .= ($i2 > 0 ?
' OR (' :
'(').$field.
' LIKE \''.$db->escape($val).
',%\'';
8116 $newres .=
' OR '.$field.
' = \''.$db->escape($val).
'\'';
8117 $newres .=
' OR '.$field.
' LIKE \'%,'.$db->escape($val).
'\'';
8118 $newres .=
' OR '.$field.
' LIKE \'%,'.$db->escape($val).
',%\'';
8126 $tmpcrits = explode(
'|', $crit);
8128 foreach ($tmpcrits as $tmpcrit)
8130 if ($tmpcrit !==
'0' && empty($tmpcrit))
continue;
8132 $newres .= (($i2 > 0 || $i3 > 0) ?
' OR ' :
'');
8134 if (preg_match(
'/\.(id|rowid)$/', $field))
8136 $newres .= $field.
" = ".(is_numeric(trim($tmpcrit)) ?trim($tmpcrit) :
'0');
8138 $newres .= $field.
" LIKE '";
8140 $tmpcrit = trim($tmpcrit);
8141 $tmpcrit2 = $tmpcrit;
8142 $tmpbefore =
'%'; $tmpafter =
'%';
8143 if (preg_match(
'/^[\^\$]/', $tmpcrit))
8146 $tmpcrit2 = preg_replace(
'/^[\^\$]/',
'', $tmpcrit2);
8148 if (preg_match(
'/[\^\$]$/', $tmpcrit))
8151 $tmpcrit2 = preg_replace(
'/[\^\$]$/',
'', $tmpcrit2);
8153 $newres .= $tmpbefore;
8154 $newres .= $db->escape($tmpcrit2);
8155 $newres .= $tmpafter;
8157 if ($tmpcrit2 ==
'')
8159 $newres .=
' OR '.$field.
" IS NULL";
8169 if ($newres) $res = $res.($res ?
' AND ' :
'').($i2 > 1 ?
'(' :
'').$newres.($i2 > 1 ?
')' :
'');
8172 $res = ($nofirstand ?
"" :
" AND ").
"(".$res.
")";
8185 global $conf, $langs;
8188 $url = $object->getLastMainDocLink($object->element);
8192 $out .=
img_picto(
'',
'globe').
' '.$langs->trans(
"DirectDownloadLink").
'<br>';
8193 $out .=
'<input type="text" id="directdownloadlink" class="quatrevingtpercent" value="'.$url.
'">';
8209 $dirName = dirname($file);
8210 if ($dirName ==
'.') $dirName =
'';
8212 $fileName = preg_replace(
'/(\.gif|\.jpeg|\.jpg|\.png|\.bmp|\.webp)$/i',
'', $file);
8213 $fileName = basename($fileName);
8215 if (empty($extImgTarget)) $extImgTarget = (preg_match(
'/\.jpg$/i', $file) ?
'.jpg' :
'');
8216 if (empty($extImgTarget)) $extImgTarget = (preg_match(
'/\.jpeg$/i', $file) ?
'.jpeg' :
'');
8217 if (empty($extImgTarget)) $extImgTarget = (preg_match(
'/\.gif$/i', $file) ?
'.gif' :
'');
8218 if (empty($extImgTarget)) $extImgTarget = (preg_match(
'/\.png$/i', $file) ?
'.png' :
'');
8219 if (empty($extImgTarget)) $extImgTarget = (preg_match(
'/\.bmp$/i', $file) ?
'.bmp' :
'');
8220 if (empty($extImgTarget)) $extImgTarget = (preg_match(
'/\.webp$/i', $file) ?
'.webp' :
'');
8222 if (!$extImgTarget)
return $file;
8225 if ($extName) $subdir =
'thumbs/';
8227 return ($dirName ? $dirName.
'/' :
'').$subdir.$fileName.$extName.$extImgTarget;
8242 global $conf, $langs;
8244 if (empty($conf->use_javascript_ajax))
return '';
8250 if ($isAllowedForPreview)
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));
8251 else return array();
8255 if ($isAllowedForPreview)
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')).
'\')
';
8267 function ajax_autoselect($htmlname, $addlink = '')
8271 jQuery(document).ready(
function () {
8272 jQuery(
"'.((strpos($htmlname, '.') === 0 ? '' : '#').$htmlname).'").click(
function() { jQuery(
this).select(); } );
8275 if ($addlink) $out .= ' <a href=
"'.$addlink.'" target=
"_blank">
'.$langs->trans("Link").'</a>
';
8286 function dolIsAllowedForPreview($file)
8290 // Check .noexe extension in filename
8291 if (preg_match('/\.noexe$/i
', $file)) return 0;
8294 $mime_preview = array('bmp
', 'jpeg
', 'png
', 'gif
', 'tiff
', 'pdf
', 'plain
', 'css
', 'webp
');
8295 if (!empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) $mime_preview[] = 'svg+xml
';
8296 //$mime_preview[]='vnd.oasis.opendocument.presentation
';
8297 //$mime_preview[]='archive
';
8298 $num_mime = array_search(dol_mimetype($file, '', 1), $mime_preview);
8299 if ($num_mime !== false) return 1;
8301 // By default, not allowed for preview
8315 function dol_mimetype($file, $default = 'application/octet-stream
', $mode = 0)
8318 $imgmime = 'other.png
';
8322 $tmpfile = preg_replace('/\.noexe$/
', '', $file);
8325 if (preg_match('/\.txt$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'text.png
'; $famime = 'file-text-o
'; }
8326 if (preg_match('/\.rtx$/i
', $tmpfile)) { $mime = 'text/richtext
'; $imgmime = 'text.png
'; $famime = 'file-text-o
'; }
8327 if (preg_match('/\.csv$/i
', $tmpfile)) { $mime = 'text/csv
'; $imgmime = 'text.png
'; $famime = 'file-text-o
'; }
8328 if (preg_match('/\.tsv$/i
', $tmpfile)) { $mime = 'text/tab-separated-values
'; $imgmime = 'text.png
'; $famime = 'file-text-o
'; }
8329 if (preg_match('/\.(cf|
conf|log)$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'text.png
'; $famime = 'file-text-o
'; }
8330 if (preg_match('/\.ini$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'text.png
'; $srclang = 'ini
'; $famime = 'file-text-o
'; }
8331 if (preg_match('/\.md$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'text.png
'; $srclang = 'md
'; $famime = 'file-text-o
'; }
8332 if (preg_match('/\.css$/i
', $tmpfile)) { $mime = 'text/css
'; $imgmime = 'css.png
'; $srclang = 'css
'; $famime = 'file-text-o
'; }
8333 if (preg_match('/\.lang$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'text.png
'; $srclang = 'lang
'; $famime = 'file-text-o
'; }
8334 // Certificate files
8335 if (preg_match('/\.(crt|cer|key|pub)$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'text.png
'; $famime = 'file-text-o
'; }
8336 // XML based (HTML/XML/XAML)
8337 if (preg_match('/\.(html|htm|shtml)$/i
', $tmpfile)) { $mime = 'text/html
'; $imgmime = 'html.png
'; $srclang = 'html
'; $famime = 'file-text-o
'; }
8338 if (preg_match('/\.(xml|xhtml)$/i
', $tmpfile)) { $mime = 'text/xml
'; $imgmime = 'other.png
'; $srclang = 'xml
'; $famime = 'file-text-o
'; }
8339 if (preg_match('/\.xaml$/i
', $tmpfile)) { $mime = 'text/xml
'; $imgmime = 'other.png
'; $srclang = 'xaml
'; $famime = 'file-text-o
'; }
8341 if (preg_match('/\.bas$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'text.png
'; $srclang = 'bas
'; $famime = 'file-
code-o
'; }
8342 if (preg_match('/\.(c)$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'text.png
'; $srclang = 'c
'; $famime = 'file-
code-o
'; }
8343 if (preg_match('/\.(cpp)$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'text.png
'; $srclang = 'cpp
'; $famime = 'file-
code-o
'; }
8344 if (preg_match('/\.cs$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'text.png
'; $srclang = 'cs
'; $famime = 'file-
code-o
'; }
8345 if (preg_match('/\.(h)$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'text.png
'; $srclang = 'h
'; $famime = 'file-
code-o
'; }
8346 if (preg_match('/\.(java|jsp)$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'text.png
'; $srclang = 'java
'; $famime = 'file-
code-o
'; }
8347 if (preg_match('/\.php([0-9]{1})?$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'php.png
'; $srclang = 'php
'; $famime = 'file-
code-o
'; }
8348 if (preg_match('/\.phtml$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'php.png
'; $srclang = 'php
'; $famime = 'file-
code-o
'; }
8349 if (preg_match('/\.(pl|pm)$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'pl.png
'; $srclang = 'perl
'; $famime = 'file-
code-o
'; }
8350 if (preg_match('/\.sql$/i
', $tmpfile)) { $mime = 'text/plain
'; $imgmime = 'text.png
'; $srclang = 'sql
'; $famime = 'file-
code-o
'; }
8351 if (preg_match('/\.js$/i
', $tmpfile)) { $mime = 'text/x-javascript
'; $imgmime = 'jscript.png
'; $srclang = 'js
'; $famime = 'file-
code-o
'; }
8353 if (preg_match('/\.odp$/i
', $tmpfile)) { $mime = 'application/vnd.oasis.opendocument.presentation
'; $imgmime = 'ooffice.png
'; $famime = 'file-powerpoint-o
'; }
8354 if (preg_match('/\.ods$/i
', $tmpfile)) { $mime = 'application/vnd.oasis.opendocument.spreadsheet
'; $imgmime = 'ooffice.png
'; $famime = 'file-excel-o
'; }
8355 if (preg_match('/\.odt$/i
', $tmpfile)) { $mime = 'application/vnd.oasis.opendocument.text
'; $imgmime = 'ooffice.png
'; $famime = 'file-word-o
'; }
8357 if (preg_match('/\.mdb$/i
', $tmpfile)) { $mime = 'application/msaccess
'; $imgmime = 'mdb.png
'; $famime = 'file-o
'; }
8358 if (preg_match('/\.doc(x|m)?$/i
', $tmpfile)) { $mime = 'application/msword
'; $imgmime = 'doc.png
'; $famime = 'file-word-o
'; }
8359 if (preg_match('/\.dot(x|m)?$/i
', $tmpfile)) { $mime = 'application/msword
'; $imgmime = 'doc.png
'; $famime = 'file-word-o
'; }
8360 if (preg_match('/\.xlt(x)?$/i
', $tmpfile)) { $mime = 'application/vnd.ms-excel
'; $imgmime = 'xls.png
'; $famime = 'file-excel-o
'; }
8361 if (preg_match('/\.xla(m)?$/i
', $tmpfile)) { $mime = 'application/vnd.ms-excel
'; $imgmime = 'xls.png
'; $famime = 'file-excel-o
'; }
8362 if (preg_match('/\.xls$/i
', $tmpfile)) { $mime = 'application/vnd.ms-excel
'; $imgmime = 'xls.png
'; $famime = 'file-excel-o
'; }
8363 if (preg_match('/\.xls(b|m|x)$/i
', $tmpfile)) { $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
'; $imgmime = 'xls.png
'; $famime = 'file-excel-o
'; }
8364 if (preg_match('/\.pps(m|x)?$/i
', $tmpfile)) { $mime = 'application/vnd.ms-powerpoint
'; $imgmime = 'ppt.png
'; $famime = 'file-powerpoint-o
'; }
8365 if (preg_match('/\.ppt(m|x)?$/i
', $tmpfile)) { $mime = 'application/x-mspowerpoint
'; $imgmime = 'ppt.png
'; $famime = 'file-powerpoint-o
'; }
8367 if (preg_match('/\.pdf$/i
', $tmpfile)) { $mime = 'application/pdf
'; $imgmime = 'pdf.png
'; $famime = 'file-pdf-o
'; }
8369 if (preg_match('/\.bat$/i
', $tmpfile)) { $mime = 'text/x-bat
'; $imgmime = 'script.png
'; $srclang = 'dos
'; $famime = 'file-
code-o
'; }
8370 if (preg_match('/\.sh$/i
', $tmpfile)) { $mime = 'text/x-sh
'; $imgmime = 'script.png
'; $srclang = 'bash
'; $famime = 'file-
code-o
'; }
8371 if (preg_match('/\.ksh$/i
', $tmpfile)) { $mime = 'text/x-ksh
'; $imgmime = 'script.png
'; $srclang = 'bash
'; $famime = 'file-
code-o
'; }
8372 if (preg_match('/\.bash$/i
', $tmpfile)) { $mime = 'text/x-bash
'; $imgmime = 'script.png
'; $srclang = 'bash
'; $famime = 'file-
code-o
'; }
8374 if (preg_match('/\.ico$/i
', $tmpfile)) { $mime = 'image/x-icon
'; $imgmime = 'image.png
'; $famime = 'file-image-o
'; }
8375 if (preg_match('/\.(jpg|jpeg)$/i
', $tmpfile)) { $mime = 'image/jpeg
'; $imgmime = 'image.png
'; $famime = 'file-image-o
'; }
8376 if (preg_match('/\.png$/i
', $tmpfile)) { $mime = 'image/png
'; $imgmime = 'image.png
'; $famime = 'file-image-o
'; }
8377 if (preg_match('/\.gif$/i
', $tmpfile)) { $mime = 'image/gif
'; $imgmime = 'image.png
'; $famime = 'file-image-o
'; }
8378 if (preg_match('/\.bmp$/i
', $tmpfile)) { $mime = 'image/bmp
'; $imgmime = 'image.png
'; $famime = 'file-image-o
'; }
8379 if (preg_match('/\.(tif|tiff)$/i
', $tmpfile)) { $mime = 'image/tiff
'; $imgmime = 'image.png
'; $famime = 'file-image-o
'; }
8380 if (preg_match('/\.svg$/i
', $tmpfile)) { $mime = 'image/svg+xml
'; $imgmime = 'image.png
'; $famime = 'file-image-o
'; }
8381 if (preg_match('/\.webp$/i
', $tmpfile)) { $mime = 'image/webp
'; $imgmime = 'image.png
'; $famime = 'file-image-o
'; }
8383 if (preg_match('/\.vcs$/i
', $tmpfile)) { $mime = 'text/calendar
'; $imgmime = 'other.png
'; $famime = 'file-text-o
'; }
8384 if (preg_match('/\.ics$/i
', $tmpfile)) { $mime = 'text/calendar
'; $imgmime = 'other.png
'; $famime = 'file-text-o
'; }
8386 if (preg_match('/\.torrent$/i
', $tmpfile)) { $mime = 'application/x-bittorrent
'; $imgmime = 'other.png
'; $famime = 'file-o
'; }
8388 if (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i
', $tmpfile)) { $mime = 'audio
'; $imgmime = 'audio.png
'; $famime = 'file-audio-o
'; }
8390 if (preg_match('/\.mp4$/i
', $tmpfile)) { $mime = 'video/mp4
'; $imgmime = 'video.png
'; $famime = 'file-video-o
'; }
8391 if (preg_match('/\.ogv$/i
', $tmpfile)) { $mime = 'video/ogg
'; $imgmime = 'video.png
'; $famime = 'file-video-o
'; }
8392 if (preg_match('/\.webm$/i
', $tmpfile)) { $mime = 'video/webm
'; $imgmime = 'video.png
'; $famime = 'file-video-o
'; }
8393 if (preg_match('/\.avi$/i
', $tmpfile)) { $mime = 'video/x-msvideo
'; $imgmime = 'video.png
'; $famime = 'file-video-o
'; }
8394 if (preg_match('/\.divx$/i
', $tmpfile)) { $mime = 'video/divx
'; $imgmime = 'video.png
'; $famime = 'file-video-o
'; }
8395 if (preg_match('/\.xvid$/i
', $tmpfile)) { $mime = 'video/xvid
'; $imgmime = 'video.png
'; $famime = 'file-video-o
'; }
8396 if (preg_match('/\.(wmv|mpg|mpeg)$/i
', $tmpfile)) { $mime = 'video
'; $imgmime = 'video.png
'; $famime = 'file-video-o
'; }
8398 if (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh)$/i
', $tmpfile)) { $mime = 'archive
'; $imgmime = 'archive.png
'; $famime = 'file-archive-o
'; } // application/xxx where zzz is zip, ...
8400 if (preg_match('/\.(exe|com)$/i
', $tmpfile)) { $mime = 'application/octet-stream
'; $imgmime = 'other.png
'; $famime = 'file-o
'; }
8402 if (preg_match('/\.(dll|lib|o|so|a)$/i
', $tmpfile)) { $mime = 'library
'; $imgmime = 'library.png
'; $famime = 'file-o
'; }
8404 if (preg_match('/\.err$/i
', $tmpfile)) { $mime = 'error
'; $imgmime = 'error.png
'; $famime = 'file-text-o
'; }
8409 $tmp = explode('/
', $mime);
8410 return (!empty($tmp[1]) ? $tmp[1] : $tmp[0]);
8437 function getDictvalue($tablename, $field, $id, $checkentity = false, $rowidfield = 'rowid')
8439 global $dictvalues, $db, $langs;
8441 if (!isset($dictvalues[$tablename]))
8443 $dictvalues[$tablename] = array();
8444 $sql = 'SELECT * FROM
'.$tablename.' WHERE 1
'; // Here select * is allowed as it is generic code and we don't have list of
fields
8445 if ($checkentity) $sql .=
' AND entity IN (0,'.getEntity($tablename).
')';
8447 $resql = $db->query($sql);
8450 while ($obj = $db->fetch_object(
$resql))
8452 $dictvalues[$tablename][$obj->{$rowidfield}] = $obj;
8459 if (!empty($dictvalues[$tablename][$id]))
return $dictvalues[$tablename][$id]->{$field};
8462 if ($id > 0)
return $id;
8475 $stringcolor = str_replace(
'#',
'', $stringcolor);
8477 if (!empty($stringcolor))
8480 $tmp = explode(
',', $stringcolor);
8481 if (count($tmp) > 1)
8487 $hexr = $stringcolor[0].$stringcolor[1];
8488 $hexg = $stringcolor[2].$stringcolor[3];
8489 $hexb = $stringcolor[4].$stringcolor[5];
8494 $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0;
8495 if ($bright > 0.6) $res = 1;
8514 if (empty($menuentry[
'enabled']))
return 0;
8515 if ($type_user && $menuentry[
'module'])
8517 $tmploops = explode(
'|', $menuentry[
'module']);
8519 foreach ($tmploops as $tmploop)
8521 if (in_array($tmploop, $listofmodulesforexternal)) {
8525 if (!$found)
return 0;
8527 if (!$menuentry[
'perms'] && $type_user)
return 0;
8528 if (!$menuentry[
'perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
return 0;
8529 if (!$menuentry[
'perms'])
return 2;
8542 return (ceil($n) % $x === 0) ? ceil($n) : round(($n + $x / 2) / $x) * $x;
8556 function dolGetBadge($label, $html =
'', $type =
'primary', $mode =
'', $url =
'', $params = array())
8559 'class'=>
'badge '.(!empty($mode) ?
' badge-'.$mode :
'').(!empty($type) ?
' badge-'.$type :
'').(empty($params[
'css']) ?
'' :
' '.$params[
'css'])
8567 $attr[
'href'] = $url;
8570 if ($mode ===
'dot') {
8571 $attr[
'class'] .=
' classfortooltip';
8572 $attr[
'title'] = $html;
8573 $attr[
'aria-label'] = $label;
8578 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
8579 foreach ($params[
'attr']as $key => $value) {
8580 if ($key ==
'class') {
8581 $attr[
'class'] .=
' '.$value;
8582 } elseif ($key ==
'classOverride') {
8583 $attr[
'class'] = $value;
8585 $attr[$key] = $value;
8593 $attr = array_map(
'dol_escape_htmltag', $attr);
8595 $TCompiledAttr = array();
8596 foreach ($attr as $key => $value) {
8597 $TCompiledAttr[] = $key.
'="'.$value.
'"';
8600 $compiledAttributes = !empty($TCompiledAttr) ?implode(
' ', $TCompiledAttr) :
'';
8602 $tag = !empty($url) ?
'a' :
'span';
8604 return '<'.$tag.
' '.$compiledAttributes.
'>'.$html.
'</'.$tag.
'>';
8620 function dolGetStatus($statusLabel =
'', $statusLabelShort =
'', $html =
'', $statusType =
'status0', $displayMode = 0, $url =
'', $params = array())
8625 $dolGetBadgeParams = array();
8627 if (!empty($params[
'badgeParams'])) {
8628 $dolGetBadgeParams = $params[
'badgeParams'];
8632 if ($displayMode == 0) {
8633 $return = !empty($html) ? $html : (empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort));
8634 } elseif ($displayMode == 1) {
8635 $return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
8637 elseif (!empty($conf->global->MAIN_STATUS_USES_IMAGES)) {
8639 $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ?
'<span class="hideonsmartphone">' :
'').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ?
'</span>' :
'');
8640 $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>' :
'');
8643 if (!empty($conf->dol_optimize_smallscreen))
8645 if ($displayMode == 0) $displayMode = 1;
8646 elseif ($displayMode == 4) $displayMode = 2;
8647 elseif ($displayMode == 6) $displayMode = 5;
8652 'status0' =>
'statut0',
8653 'status1' =>
'statut1',
8654 'status2' =>
'statut2',
8655 'status3' =>
'statut3',
8656 'status4' =>
'statut4',
8657 'status5' =>
'statut5',
8658 'status6' =>
'statut6',
8659 'status7' =>
'statut7',
8660 'status8' =>
'statut8',
8661 'status9' =>
'statut9'
8664 if (!empty($statusImg[$statusType])) {
8665 $htmlImg =
img_picto($statusLabel, $statusImg[$statusType]);
8667 $htmlImg =
img_picto($statusLabel, $statusType);
8670 if ($displayMode === 2) {
8671 $return = $htmlImg.
' '.$htmlLabelShort;
8672 } elseif ($displayMode === 3) {
8674 } elseif ($displayMode === 4) {
8675 $return = $htmlImg.
' '.$htmlLabel;
8676 } elseif ($displayMode === 5) {
8677 $return = $htmlLabelShort.
' '.$htmlImg;
8679 $return = $htmlLabel.
' '.$htmlImg;
8682 elseif (empty($conf->global->MAIN_STATUS_USES_IMAGES) && !empty($displayMode)) {
8683 $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
8685 $dolGetBadgeParams[
'attr'][
'class'] =
'badge-status';
8686 $dolGetBadgeParams[
'attr'][
'title'] = empty($params[
'tooltip']) ? $statusLabel : ($params[
'tooltip'] !=
'no' ? $params[
'tooltip'] :
'');
8688 if ($displayMode == 3) {
8689 $return =
dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)),
'', $statusType,
'dot', $url, $dolGetBadgeParams);
8690 } elseif ($displayMode === 5) {
8691 $return =
dolGetBadge($statusLabelShort, $html, $statusType,
'', $url, $dolGetBadgeParams);
8693 $return =
dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), $html, $statusType,
'', $url, $dolGetBadgeParams);
8713 function dolGetButtonAction($label, $html =
'', $actionType =
'default', $url =
'', $id =
'', $userRight = 1, $params = array())
8715 $class =
'butAction';
8716 if ($actionType ==
'danger' || $actionType ==
'delete') {
8717 $class =
'butActionDelete';
8722 ,
'href' => empty($url) ?
'' : $url
8728 $attr[
'aria-label'] = $label;
8731 if (empty($userRight)) {
8732 $attr[
'class'] =
'butActionRefused';
8741 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
8742 foreach ($params[
'attr'] as $key => $value) {
8743 if ($key ==
'class') {
8744 $attr[
'class'] .=
' '.$value;
8745 } elseif ($key ==
'classOverride') {
8746 $attr[
'class'] = $value;
8748 $attr[$key] = $value;
8753 if (isset($attr[
'href']) && empty($attr[
'href'])) {
8754 unset($attr[
'href']);
8760 $attr = array_map(
'dol_escape_htmltag', $attr);
8762 $TCompiledAttr = array();
8763 foreach ($attr as $key => $value) {
8764 $TCompiledAttr[] = $key.
'="'.$value.
'"';
8767 $compiledAttributes = !empty($TCompiledAttr) ?implode(
' ', $TCompiledAttr) :
'';
8769 $tag = !empty($attr[
'href']) ?
'a' :
'span';
8771 return '<div class="inline-block divButAction"><'.$tag.
' '.$compiledAttributes.
'>'.$html.
'</'.$tag.
'></div>';
8786 function dolGetButtonTitle($label, $helpText =
'', $iconClass =
'fa fa-file', $url =
'', $id =
'', $status = 1, $params = array())
8788 global $langs, $conf, $user;
8791 if (!empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (!$user->admin) && $status <= 0) {
8795 $class =
'btnTitle';
8796 if (in_array($iconClass, array(
'fa fa-plus-circle',
'fa fa-comment-dots'))) $class .=
' btnTitlePlus';
8797 $useclassfortooltip = 1;
8799 if (!empty($params[
'morecss'])) $class .=
' '.$params[
'morecss'];
8803 'href' => empty($url) ?
'' : $url
8806 if (!empty($helpText)) {
8808 } elseif (empty($attr[
'title']) && $label) {
8809 $attr[
'title'] = $label;
8810 $useclassfortooltip = 0;
8814 $attr[
'class'] .=
' refused';
8818 if ($status == -1) {
8819 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"FeatureDisabled"));
8820 } elseif ($status == 0) {
8821 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions"));
8825 if (!empty($attr[
'title']) && $useclassfortooltip) {
8826 $attr[
'class'] .=
' classfortooltip';
8834 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
8835 foreach ($params[
'attr'] as $key => $value) {
8836 if ($key ==
'class') {
8837 $attr[
'class'] .=
' '.$value;
8838 } elseif ($key ==
'classOverride') {
8839 $attr[
'class'] = $value;
8841 $attr[$key] = $value;
8846 if (isset($attr[
'href']) && empty($attr[
'href'])) {
8847 unset($attr[
'href']);
8853 $attr = array_map(
'dol_escape_htmltag', $attr);
8855 $TCompiledAttr = array();
8856 foreach ($attr as $key => $value) {
8857 $TCompiledAttr[] = $key.
'="'.$value.
'"';
8860 $compiledAttributes = (empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr));
8862 $tag = (empty($attr[
'href']) ?
'span' :
'a');
8864 $button =
'<'.$tag.
' '.$compiledAttributes.
'>';
8865 $button .=
'<span class="'.$iconClass.
' valignmiddle btnTitle-icon"></span>';
8866 if (!empty($params[
'forcenohideoftext'])) {
8867 $button .=
'<span class="valignmiddle text-plus-circle btnTitle-label'.(empty($params[
'forcenohideoftext']) ?
' hideonsmartphone' :
'').
'">'.$label.
'</span>';
8869 $button .=
'</'.$tag.
'>';
8885 $classfile = $classname = $classpath =
'';
8888 $module = $element_type;
8889 $element = $element_type;
8890 $subelement = $element_type;
8893 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $element_type, $regs)) {
8894 $element = $subelement = $regs[1];
8899 if (preg_match(
'/^([^_]+)_([^_]+)/i', $element, $regs)) {
8900 $module = $element = $regs[1];
8901 $subelement = $regs[2];
8905 if ($element_type ==
"action") {
8906 $classpath =
'comm/action/class';
8907 $subelement =
'Actioncomm';
8912 if ($element_type ==
'facture' || $element_type ==
'invoice') {
8913 $classpath =
'compta/facture/class';
8914 $module =
'facture';
8915 $subelement =
'facture';
8917 if ($element_type ==
'commande' || $element_type ==
'order') {
8918 $classpath =
'commande/class';
8919 $module =
'commande';
8920 $subelement =
'commande';
8922 if ($element_type ==
'propal') {
8923 $classpath =
'comm/propal/class';
8925 if ($element_type ==
'supplier_proposal') {
8926 $classpath =
'supplier_proposal/class';
8928 if ($element_type ==
'shipping') {
8929 $classpath =
'expedition/class';
8930 $subelement =
'expedition';
8931 $module =
'expedition_bon';
8933 if ($element_type ==
'delivery') {
8934 $classpath =
'delivery/class';
8935 $subelement =
'delivery';
8936 $module =
'delivery_note';
8938 if ($element_type ==
'contract') {
8939 $classpath =
'contrat/class';
8940 $module =
'contrat';
8941 $subelement =
'contrat';
8943 if ($element_type ==
'member') {
8944 $classpath =
'adherents/class';
8945 $module =
'adherent';
8946 $subelement =
'adherent';
8948 if ($element_type ==
'cabinetmed_cons') {
8949 $classpath =
'cabinetmed/class';
8950 $module =
'cabinetmed';
8951 $subelement =
'cabinetmedcons';
8953 if ($element_type ==
'fichinter') {
8954 $classpath =
'fichinter/class';
8955 $module =
'ficheinter';
8956 $subelement =
'fichinter';
8958 if ($element_type ==
'dolresource' || $element_type ==
'resource') {
8959 $classpath =
'resource/class';
8960 $module =
'resource';
8961 $subelement =
'dolresource';
8963 if ($element_type ==
'propaldet') {
8964 $classpath =
'comm/propal/class';
8966 $subelement =
'propaleligne';
8968 if ($element_type ==
'order_supplier') {
8969 $classpath =
'fourn/class';
8970 $module =
'fournisseur';
8971 $subelement =
'commandefournisseur';
8972 $classfile =
'fournisseur.commande';
8974 if ($element_type ==
'invoice_supplier') {
8975 $classpath =
'fourn/class';
8976 $module =
'fournisseur';
8977 $subelement =
'facturefournisseur';
8978 $classfile =
'fournisseur.facture';
8980 if ($element_type ==
"service") {
8981 $classpath =
'product/class';
8982 $subelement =
'product';
8985 if (empty($classfile)) $classfile = strtolower($subelement);
8986 if (empty($classname)) $classname = ucfirst($subelement);
8987 if (empty($classpath)) $classpath = $module.
'/class';
8989 $element_properties = array(
8990 'module' => $module,
8991 'classpath' => $classpath,
8992 'element' => $element,
8993 'subelement' => $subelement,
8994 'classfile' => $classfile,
8995 'classname' => $classname
8997 return $element_properties;
9014 if (is_array($element_prop) && $conf->{$element_prop[
'module']}->enabled)
9016 dol_include_once(
'/'.$element_prop[
'classpath'].
'/'.$element_prop[
'classfile'].
'.class.php');
9018 $objecttmp =
new $element_prop[
'classname']($db);
9019 $ret = $objecttmp->fetch($element_id, $element_ref);
9036 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))
9052 return $_SESSION[
'newtoken'];
9062 return $_SESSION[
'token'];
9081 print '<div class="div-table-responsive-no-min">';
9082 print '<table class="noborder centpercent">';
9083 print '<tr class="liste_titre">';
9085 print $emptyRows < 1 ? '<th>
' : '<th colspan=
"'.($emptyRows + 1).'">
';
9087 print $langs->trans($header);
9089 // extra space between the first header and the number
9094 if (!empty($link)) {
9095 if (!empty($arguments)) {
9096 print '<a href=
"'.DOL_URL_ROOT.'/'.$link.'?'.$arguments.'">
';
9098 print '<a href=
"'.DOL_URL_ROOT.'/'.$link.'">
';
9103 print '<span
class=
"badge">
'.$number.'</span>
';
9106 if (!empty($link)) {
9112 if ($number < 0 && !empty($link)) {
9113 print '<th
class=
"right">
';
9115 if (!empty($arguments)) {
9116 print '<a
class=
"commonlink" href=
"'.DOL_URL_ROOT.'/'.$link.'?'.$arguments.'">
';
9118 print '<a
class=
"commonlink" href=
"'.DOL_URL_ROOT.'/'.$link.'">
';
9121 print $langs->trans("FullList");
9137 function finishSimpleTable($addLineBreak = false)
9142 if ($addLineBreak) {
9158 function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord = "None", $extraRightColumn = false)
9163 print '<tr
class=
"oddeven">
';
9164 print '<td colspan=
"'.$tableColumnCount.'" class=
"opacitymedium">
'.$langs->trans($noneWord).'</td>
';
9169 if ($nbofloop === 0)
9171 // don't show a summary line
9176 $colspan = $tableColumnCount;
9178 elseif ($num > $nbofloop) {
9179 $colspan = $tableColumnCount;
9181 $colspan = $tableColumnCount - 1;
9184 if ($extraRightColumn) {
9188 print '<tr class="liste_total">';
9190 if ($nbofloop > 0 && $num > $nbofloop) {
9191 print '<td colspan="'.$colspan.
'" class="right">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
'</td>';
9193 print '<td colspan="'.$colspan.
'" class="right"> '.$langs->trans(
"Total").
'</td>';
9194 print '<td class="right" width="100">'.price($total).
'</td>';
9197 if ($extraRightColumn) {
9216 if ($method == -1) {
9218 if (!empty($conf->global->MAIN_FORCE_READFILE_WITH_FREAD)) $method = 1;
9219 if (!empty($conf->global->MAIN_FORCE_READFILE_WITH_STREAM_COPY)) $method = 2;
9223 while (ob_get_level()) ob_end_flush();
9227 readfile($fullpath_original_file_osencoded);
9230 elseif ($method == 1) {
9231 $handle = fopen($fullpath_original_file_osencoded,
"rb");
9232 while (!feof($handle)) {
9233 print fread($handle, 8192);
9238 elseif ($method == 2) {
9239 $handle1 = fopen($fullpath_original_file_osencoded,
"rb");
9240 $handle2 = fopen(
"php://output",
"wb");
9241 stream_copy_to_stream($handle1, $handle2);
dol_convert_file($fileinput, $ext= 'png', $fileoutput= '', $page= '')
Convert an image file into another format.
verifCond($strRights)
Verify if condition in string is ok or not.
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...
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolIsAllowedForPreview($file)
Return if a file is qualified for preview.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_sanitizePathName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a path name.
dol_hash($chain, $type= '0')
Returns a hash of a string.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
dol_htmloutput_events($disabledoutputofmessages=0)
Print formated messages to output (Used to show messages on html output).
img_picto_common($titlealt, $picto, $moreatt= '', $pictoisfullpath=0)
Show picto (generic function)
dol_substr($string, $start, $length, $stringencoding= '', $trunconbytes=0)
Make a substring.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
dol_eval($s, $returnvalue=0, $hideerrors=1)
Replace eval function to add more security.
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...
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled= '')
Return HTML code to output a button to open a dialog popup box.
getUserRemoteIP()
Return the IP of remote user.
dol_get_prev_month($month, $year)
Return previous month.
isACompany()
Return if third party is a company (Business) or an end user (Consumer)
if(!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'] country if(!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'] typent code
dol_print_url($url, $target= '_blank', $max=32, $withpicto=0)
Show Url link.
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.
conf($dolibarr_main_document_root)
Load conf file (file must exists)
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
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.
getArrayOfSocialNetworks()
Get array of social network dictionary.
setEntity($currentobject)
Set entity id to use when to create an object.
printCommonFooter($zone= 'private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
img_weather($titlealt, $picto, $moreatt= '', $pictoisfullpath=0, $morecss= '')
Show weather picto.
img_credit_card($brand, $morecss=null)
Return image of a credit card according to its brand name.
</td >< tdcolspan="3">< spanclass="opacitymedium"></span ></td ></tr >< trclass="liste_total"> CREANCES DETTES< tdcolspan="3"class="right"></td >< tdcolspan="3"class="right"></td ></tr > CREANCES DETTES RECETTES DEPENSES trips CREANCES DETTES Y m expensereport p date_valid Y m expensereport pe datep $db idate($date_start)."' AND $column < p rowid
foreach($object->fields as $key=> $val) if(is_array($extrafields->attributes[$object->table_element]['label'])&&count($extrafields->attributes[$object->table_element]['label']) > 0) $object fields
dol_escape_json($stringtoescape)
Returns text escaped for inclusion into javascript code.
dol_shutdown()
Function called at end of web php process.
dol_html_entity_decode($a, $b, $c= 'UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
Class to manage products or services.
dol_fiche_head($links=array(), $active= '0', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tab header of a card.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_now($mode= 'auto')
Return date for now.
picto_required()
Return picto saying a field is required.
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).
getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
Get tax (VAT) main information from Id.
dol_strtoupper($string, $encoding="UTF-8")
Convert a string to upper.
isASecretKey($keyname)
Return if string has a name dedicated to store a secret.
dol_print_phone($phone, $countrycode= '', $cid=0, $socid=0, $addlink= '', $separ=" ", $withpicto= '', $titlealt= '', $adddivfloat=0)
Format phone numbers according to country.
dol_htmlentities($string, $flags=null, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
setEventMessage($mesgs, $style= 'mesgs')
Set event message in dol_events session object.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
dol_getmypid()
Return getmypid() or random PID when function is disabled Some web hosts disable this php function fo...
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...
dolGetButtonAction($label, $html= '', $actionType= 'default', $url= '', $id= '', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_is_dir($folder)
Test if filename is a directory.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Fonction qui renvoie si tva doit etre tva percue recuperable.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
$conf db name
Only used if Module[ID]Name translation string is not found.
checkVal($out= '', $check= 'alphanohtml', $filter=null, $options=null)
Return a value after checking on a rule.
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_get_prev_day($day, $month, $year)
Return previous day.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error_email($prefixcode, $errormessage= '', $errormessages=array(), $morecss= 'error', $email= '')
Show a public email and error code to contact if technical error.
dol_validElement($element)
Return if var element is ok.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate, from a $thirdparty_buyer to a $thirdparty_seller Note: This function applies same rules than get_default_tva.
img_left($titlealt= 'default', $selected=0, $moreatt= '')
Show left arrow logo.
img_mime($file, $titlealt= '', $morecss= '')
Show MIME img of a file.
get_product_localtax_for_country($idprod, $local, $thirdparty_seller)
Return localtax vat rate of a product in a particular selling country or default country vat if produ...
img_action($titlealt, $numaction, $picto= '')
Show logo action.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
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...
dol_string_nounprintableascii($str, $removetabcrlf=1)
Clean a string from all non printable ASCII chars (0x00-0x1F and 0x7F).
img_search($titlealt= 'default', $other= '')
Show search logo.
dol_print_ip($ip, $mode=0)
Return an IP formated to be shown on screen.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
dol_string_nospecial($str, $newstr= '_', $badcharstoreplace= '')
Clean a string from all punctuation characters to use it as a ref or login.
dol_nboflines($s, $maxchar=0)
Return nb of lines of a clear text.
getImageFileNameForSize($file, $extName, $extImgTarget= '')
Return the filename of file to get the thumbs.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
img_error($titlealt= 'default')
Show error logo.
showDirectDownloadLink($object)
Return string with full Url.
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.
isValidMXRecord($domain)
Return if the domain name has a valid MX record.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
img_down($titlealt= 'default', $selected=0, $moreclass= '')
Show down arrow logo.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetworks=array())
Show social network link.
img_pdf($titlealt= 'default', $size=3)
Show pdf logo.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags=array('textarea'), $cleanalsosomestyles=0)
Clean a string from some undesirable HTML tags.
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 ...
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
get_htmloutput_mesg($mesgstring= '', $mesgarray= '', $style= 'ok', $keepembedded=0)
Get formated messages to output (Used to show messages on html output).
dol_convertToWord($num, $langs, $currency= '', $centimes=false)
Function to return a number into a text.
dolGetCountryCodeFromIp($ip)
Return a country code from IP.
getServerTimeZoneInt($refgmtdate= 'now')
Return server timezone int.
dol_mimetype($file, $default= 'application/octet-stream', $mode=0)
Return mime type of a file.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
img_up($titlealt= 'default', $selected=0, $moreclass= '')
Show top arrow logo.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal)
Function to test if an entry is enabled or not.
img_searchclear($titlealt= 'default', $other= '')
Show search logo.
dol_size($size, $type= '')
Optimize a size for some browsers (phone, smarphone, ...)
img_printer($titlealt="default", $other= '')
Show printer logo.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput= 'no')
Output a dimension with best unit.
dol_get_next_month($month, $year)
Return next month.
dol_fiche_end($notab=0)
Show tab footer of a card.
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_ucfirst($string, $encoding="UTF-8")
Convert first character of the first word of a string to upper.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_get_next_day($day, $month, $year)
Return next day.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
readfileLowMemory($fullpath_original_file_osencoded, $method=-1)
Return a file on output using a low memory.
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
getBrowserInfo($user_agent)
Return information about user browser.
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...
Class to manage translations.
isValidVATID($company)
Check if VAT numero is valid (check done on syntax only, no database or remote access) ...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
dol_user_country()
Return country code for current user.
utf8_check($str)
Check if a string is in UTF8.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
img_right($titlealt= 'default', $selected=0, $moreatt= '')
Show right arrow logo.
ajax_autoselect($htmlname, $addlink= '')
Make content of an input box selected when we click into input field.
print $_SERVER["PHP_SELF"]
Edit parameters.
img_next($titlealt= 'default', $moreatt= '')
Show next logo.
dolExplodeIntoArray($string, $delimiter= ';', $kv= '=')
Split a string with 2 keys into key array.
getElementProperties($element_type)
Get an array with properties of an element.
img_edit_add($titlealt= 'default', $other= '')
Show logo +.
GETPOSTINT($paramname, $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_fiche_titre($title, $mesg= '', $picto= 'generic', $pictoisfullpath=0, $id= '')
Show a title with picto.
img_edit_remove($titlealt= 'default', $other= '')
Show logo -.
img_allow($allow, $titlealt= 'default')
Show tick logo if allowed.
dolGetFirstLineOfText($text, $nboflines=1, $charset= 'UTF-8')
Return first line of text.
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...
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
dol_ucwords($string, $encoding="UTF-8")
Convert first character of all the words of a string to upper.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_htmloutput_mesg($mesgstring= '', $mesgarray=array(), $style= 'ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
print
Draft customers invoices.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_previous($titlealt= 'default', $moreatt= '')
Show previous logo.
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...
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array())
On/off button to change status of an object This is called when MAIN_DIRECT_STATUS_UPDATE is set and ...
print_fleche_navigation($page, $file, $options= '', $nextpage=0, $betweenarrows= '', $afterarrows= '', $limit=-1, $totalnboflines=0, $hideselectlimit=0, $beforearrows= '')
Function to show navigation arrows into lists.
isAFileWithExecutableContent($filename)
Return if a file can contains executable content.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
isHTTPS()
Return if we are using a HTTPS connexion Check HTTPS (no way to be modified by user but may be empty ...
startSimpleTable($header, $link="", $arguments="", $emptyRows=0, $number=-1)
Start a table with headers and a optinal clickable number (don't forget to use "finishSimpleTable()" ...
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0)
Clean a string to keep only desirable HTML tags.
get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice=0)
Return vat rate of a product in a particular selling country or default country vat if product is unk...
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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) Si ...
dolGetBadge($label, $html= '', $type= 'primary', $mode= '', $url= '', $params=array())
Function dolGetBadge.
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
img_info($titlealt= 'default')
Show info logo.
get_localtax_by_third($local)
Get values of localtaxes (1 or 2) for company country for the common vat with the highest value...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto= 'UTF-8')
This function is called to decode a HTML string (it decodes entities and br tags) ...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_view($titlealt= 'default', $float=0, $other= '')
Show logo view card.
print_titre($title)
Show a title.
print $_SERVER["PHP_SELF"] n
Edit parameters.
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.
print_date_range($date_start, $date_end, $format= '', $outputlangs= '')
Format output for start and end date.
dolGetStatus($statusLabel= '', $statusLabelShort= '', $html= '', $statusType= 'status0', $displayMode=0, $url= '', $params=array())
Output the badge of a status.
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
fieldLabel($langkey, $fieldkey, $fieldrequired=0)
Show a string with the label tag dedicated to the HTML edit field.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
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.
dol_htmloutput_errors($mesgstring= '', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
fetchObjectByElement($element_id, $element_type, $element_ref= '')
Fetch an object from its id and element_type Inclusion of classes is automatic.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode= 'add')
Complete or removed entries into a head array (used to build tabs).
colorIsLight($stringcolor)
Return true if the color is light.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
img_split($titlealt= 'default', $other= 'class="pictosplit"')
Show split logo.
isValidEmail($address, $acceptsupervisorkey=0)
Return true if email syntax is ok.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
currentToken()
Return the value of token currently saved into session with name 'token'.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param= '')
Return URL we can use for advanced preview links.
dol_print_address($address, $htmlid, $element, $id, $noprint=0, $charfornl= '')
Format address string.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
picto_from_langcode($codelang, $moreatt= '')
Return img flag of country for a language code or country code.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
Class to manage predefined suppliers products.
ascii_check($str)
Check if a string is in ASCII.
isValidPhone($phone)
Return true if phone number syntax is ok TODO Decide what to do with this.
dol_strtolower($string, $encoding="UTF-8")
Convert a string to lower.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
roundUpToNextMultiple($n, $x=5)
Round to next multiple.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
measuringUnitString($unit, $measuring_style= '', $scale= '', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
dol_strftime($fmt, $ts=false, $is_gmt=false)
Format a string.
dol_bc($var, $moreclass= '')
Return string to add class property on html element with pair/impair.
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...
Classe to manage GeoIP Usage: $geoip=new GeoIP('country',$datfile); $geoip->getCountryCodeFromIP($ip)...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
dol_textishtml($msg, $option=0)
Return if a text is a html content.