45 include_once DOL_DOCUMENT_ROOT.
'/core/lib/json.lib.php';
48 if (!function_exists(
'utf8_encode')) {
55 function utf8_encode($elements)
57 return mb_convert_encoding($elements,
'UTF-8',
'ISO-8859-1');
61 if (!function_exists(
'utf8_decode')) {
68 function utf8_decode($elements)
70 return mb_convert_encoding($elements,
'ISO-8859-1',
'UTF-8');
86 return (
string) (isset($conf->global->$key) ? $conf->global->$key : $default);
100 return (
int) (isset($conf->global->$key) ? $conf->global->$key : $default);
114 return (
string) (empty($user->conf->$key) ? $default : $user->conf->$key);
128 return (
int) (empty($user->conf->$key) ? $default : $user->conf->$key);
140 return !empty($conf->$module->enabled);
156 require_once DOL_DOCUMENT_ROOT.
"/core/db/".$type.
'.class.php';
158 $class =
'DoliDB'.ucfirst($type);
159 $dolidb =
new $class($type, $host, $user, $pass, $name, $port);
180 function getEntity($element, $shared = 1, $currentobject =
null)
182 global $conf, $mc, $hookmanager, $object, $action, $db;
184 if (! is_object($hookmanager)) {
191 $element =
'contract';
193 case 'order_supplier':
194 $element =
'supplier_order';
196 case 'invoice_supplier':
197 $element =
'supplier_invoice';
201 if (is_object($mc)) {
202 $out = $mc->getEntity($element, $shared, $currentobject);
205 $addzero = array(
'user',
'usergroup',
'c_email_templates',
'email_template',
'default_values');
206 if (in_array($element, $addzero)) {
209 $out .= ((int) $conf->entity);
214 'element' => $element,
217 'currentobject' => $currentobject,
220 $reshook = $hookmanager->executeHooks(
'hookGetEntity', $parameters, $currentobject, $action);
222 if (is_numeric($reshook)) {
223 if ($reshook == 0 && !empty($hookmanager->resPrint)) {
224 $out .=
','.$hookmanager->resPrint;
225 } elseif ($reshook == 1) {
226 $out = $hookmanager->resPrint;
243 if (is_object($mc) && method_exists($mc,
'setEntity')) {
244 return $mc->setEntity($currentobject);
246 return ((is_object($currentobject) && $currentobject->id > 0 && $currentobject->entity > 0) ? $currentobject->entity : $conf->entity);
258 return preg_match(
'/(_pass|password|_pw|_key|securekey|serverkey|secret\d?|p12key|exportkey|_PW_[a-z]+|token)$/i', $keyname);
270 for ($r =
""; $n >= 0; $n = intval($n / 26) - 1)
271 $r = chr($n % 26 + 0x41) . $r;
294 include_once DOL_DOCUMENT_ROOT.
'/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php';
301 $user_agent = substr($user_agent, 0, 512);
303 $detectmobile =
new Mobile_Detect(
null, $user_agent);
304 $tablet = $detectmobile->isTablet();
306 if ($detectmobile->isMobile()) {
310 if ($detectmobile->is(
'AndroidOS')) {
311 $os = $phone =
'android';
312 } elseif ($detectmobile->is(
'BlackBerryOS')) {
313 $os = $phone =
'blackberry';
314 } elseif ($detectmobile->is(
'iOS')) {
317 } elseif ($detectmobile->is(
'PalmOS')) {
318 $os = $phone =
'palm';
319 } elseif ($detectmobile->is(
'SymbianOS')) {
321 } elseif ($detectmobile->is(
'webOS')) {
323 } elseif ($detectmobile->is(
'MaemoOS')) {
325 } elseif ($detectmobile->is(
'WindowsMobileOS') || $detectmobile->is(
'WindowsPhoneOS')) {
331 if (preg_match(
'/linux/i', $user_agent)) {
333 } elseif (preg_match(
'/macintosh/i', $user_agent)) {
335 } elseif (preg_match(
'/windows/i', $user_agent)) {
341 if (preg_match(
'/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
343 $version = empty($reg[2]) ?
'' : $reg[2];
344 } elseif (preg_match(
'/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
346 $version = empty($reg[2]) ?
'' : $reg[2];
347 } elseif (preg_match(
'/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) {
349 $version = empty($reg[2]) ?
'' : $reg[2];
350 } elseif (preg_match(
'/chrome/i', $user_agent, $reg)) {
353 } elseif (preg_match(
'/iceweasel/i', $user_agent)) {
355 } elseif (preg_match(
'/epiphany/i', $user_agent)) {
357 } elseif (preg_match(
'/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
359 $version = empty($reg[2]) ?
'' : $reg[2];
360 } elseif (preg_match(
'/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
363 $version = empty($reg[2]) ?
'' : $reg[2];
364 } elseif (preg_match(
'/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
366 $version = end($reg);
367 } elseif (preg_match(
'/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
370 $version = end($reg);
371 } elseif (preg_match(
'/l[iy]n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) {
374 $version = empty($reg[3]) ?
'' : $reg[3];
386 'browsername' => $name,
387 'browserversion' => $version,
402 global $conf, $user, $langs, $db;
403 $disconnectdone =
false;
405 if (is_object($db) && !empty($db->connected)) {
406 $depth = $db->transaction_opened;
407 $disconnectdone = $db->close();
409 dol_syslog(
"--- End access to ".$_SERVER[
"PHP_SELF"].(($disconnectdone && $depth) ?
' (Warn: db disconnection forced, transaction depth was '.$depth.
')' :
''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO));
425 $relativepathstring = $_SERVER[
"PHP_SELF"];
427 if (constant(
'DOL_URL_ROOT')) {
428 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
430 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
431 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
437 if (!empty($_GET[
'restore_lastsearch_values'])) {
438 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
439 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
440 if (is_array($tmp)) {
441 foreach ($tmp as $key => $val) {
442 if ($key == $paramname) {
450 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
452 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
454 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
456 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
460 $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname]));
477 if (empty($method)) {
478 $val = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
479 } elseif ($method == 1) {
480 $val = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
481 } elseif ($method == 2) {
482 $val = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
483 } elseif ($method == 3) {
484 $val = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
486 $val =
'BadFirstParameterForGETPOST';
489 return is_array($val);
520 function GETPOST($paramname, $check =
'alphanohtml', $method = 0, $filter =
null, $options =
null, $noreplace = 0)
522 global $mysoc, $user, $conf;
524 if (empty($paramname)) {
525 return 'BadFirstParameterForGETPOST';
528 dol_syslog(
"Deprecated use of GETPOST, called with 1st param = ".$paramname.
" and 2nd param is '', when calling page ".$_SERVER[
"PHP_SELF"], LOG_WARNING);
533 if (empty($method)) {
534 $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
535 } elseif ($method == 1) {
536 $out = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
537 } elseif ($method == 2) {
538 $out = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
539 } elseif ($method == 3) {
540 $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
542 return 'BadThirdParameterForGETPOST';
545 if (empty($method) || $method == 3 || $method == 4) {
546 $relativepathstring = $_SERVER[
"PHP_SELF"];
548 if (constant(
'DOL_URL_ROOT')) {
549 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
551 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
552 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
558 if (!empty($_GET[
'restore_lastsearch_values'])) {
559 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
560 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
561 if (is_array($tmp)) {
562 foreach ($tmp as $key => $val) {
563 if ($key == $paramname) {
571 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
572 $out = $_SESSION[
'lastsearch_contextpage_'.$relativepathstring];
573 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
574 $out = $_SESSION[
'lastsearch_limit_'.$relativepathstring];
575 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
576 $out = $_SESSION[
'lastsearch_page_'.$relativepathstring];
577 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
578 $out = $_SESSION[
'lastsearch_mode_'.$relativepathstring];
580 } elseif (!isset($_GET[
'sortfield'])) {
583 if (!empty($_GET[
'action']) && $_GET[
'action'] ==
'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
586 if (is_object($object) && isset($object->fields[$paramname][
'default'])) {
587 $out = $object->fields[$paramname][
'default'];
590 if (!empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
591 if (!empty($_GET[
'action']) && (preg_match(
'/^create|^add_price|^make/', $_GET[
'action']) || preg_match(
'/^presend/', $_GET[
'action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
593 if (!empty($user->default_values)) {
594 if (isset($user->default_values[$relativepathstring][
'createform'])) {
595 foreach ($user->default_values[$relativepathstring][
'createform'] as $defkey => $defval) {
597 if ($defkey !=
'_noquery_') {
598 $tmpqueryarraytohave = explode(
'&', $defkey);
601 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
602 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
615 if (isset($user->default_values[$relativepathstring][
'createform'][$defkey][$paramname])) {
616 $out = $user->default_values[$relativepathstring][
'createform'][$defkey][$paramname];
623 } elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
625 if (!empty($user->default_values)) {
628 if ($paramname ==
'sortfield' || $paramname ==
'sortorder') {
630 if (isset($user->default_values[$relativepathstring][
'sortorder'])) {
632 foreach ($user->default_values[$relativepathstring][
'sortorder'] as $defkey => $defval) {
634 if ($defkey !=
'_noquery_') {
635 $tmpqueryarraytohave = explode(
'&', $defkey);
638 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
639 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
652 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
653 foreach ($user->default_values[$relativepathstring][
'sortorder'][$defkey] as $key => $val) {
657 if ($paramname ==
'sortfield') {
660 if ($paramname ==
'sortorder') {
668 } elseif (isset($user->default_values[$relativepathstring][
'filters'])) {
669 foreach ($user->default_values[$relativepathstring][
'filters'] as $defkey => $defval) {
670 if (!empty($_GET[
'disabledefaultvalues'])) {
674 if ($defkey !=
'_noquery_') {
675 $tmpqueryarraytohave = explode(
'&', $defkey);
678 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
679 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
693 if (isset($_POST[
'sall']) || isset($_POST[
'search_all']) || isset($_GET[
'sall']) || isset($_GET[
'search_all'])) {
695 if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH)) {
696 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
697 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
700 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
701 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
716 if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
720 while (preg_match(
'/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) {
724 if ($reg[1] ==
'DAY') {
726 $newout = $tmp[
'mday'];
727 } elseif ($reg[1] ==
'MONTH') {
729 $newout = $tmp[
'mon'];
730 } elseif ($reg[1] ==
'YEAR') {
732 $newout = $tmp[
'year'];
733 } elseif ($reg[1] ==
'PREVIOUS_DAY') {
736 $newout = $tmp2[
'day'];
737 } elseif ($reg[1] ==
'PREVIOUS_MONTH') {
740 $newout = $tmp2[
'month'];
741 } elseif ($reg[1] ==
'PREVIOUS_YEAR') {
743 $newout = ($tmp[
'year'] - 1);
744 } elseif ($reg[1] ==
'NEXT_DAY') {
747 $newout = $tmp2[
'day'];
748 } elseif ($reg[1] ==
'NEXT_MONTH') {
751 $newout = $tmp2[
'month'];
752 } elseif ($reg[1] ==
'NEXT_YEAR') {
754 $newout = ($tmp[
'year'] + 1);
755 } elseif ($reg[1] ==
'MYCOMPANY_COUNTRY_ID' || $reg[1] ==
'MYCOUNTRY_ID' || $reg[1] ==
'MYCOUNTRYID') {
756 $newout = $mysoc->country_id;
757 } elseif ($reg[1] ==
'USER_ID' || $reg[1] ==
'USERID') {
759 } elseif ($reg[1] ==
'USER_SUPERVISOR_ID' || $reg[1] ==
'SUPERVISOR_ID' || $reg[1] ==
'SUPERVISORID') {
760 $newout = $user->fk_user;
761 } elseif ($reg[1] ==
'ENTITY_ID' || $reg[1] ==
'ENTITYID') {
762 $newout = $conf->entity;
767 $out = preg_replace(
'/__'.preg_quote($reg[1],
'/').
'__/', $newout, $out);
772 if (preg_match(
'/^array/', $check)) {
773 if (!is_array($out) || empty($out)) {
776 $tmparray = explode(
':', $check);
777 if (!empty($tmparray[1])) {
778 $tmpcheck = $tmparray[1];
780 $tmpcheck =
'alphanohtml';
782 foreach ($out as $outkey => $outval) {
783 $out[$outkey] =
sanitizeVal($outval, $tmpcheck, $filter, $options);
789 if (strpos($paramname,
'search_') === 0) {
790 $out = preg_replace(
'/([<>])([-+]?\d)/',
'\1 \2', $out);
793 $out =
sanitizeVal($out, $check, $filter, $options);
798 if ($paramname ==
'backtopage' || $paramname ==
'backtolist' || $paramname ==
'backtourl') {
799 $out = str_replace(
'\\',
'/', $out);
800 $out = str_replace(array(
':',
';',
'@',
"\t",
' '),
'', $out);
802 $oldstringtoclean = $out;
803 $out = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $out);
804 $out = preg_replace(array(
'/^[^\?]*%/'),
'', $out);
805 $out = preg_replace(array(
'/^[a-z]*\/\s*\/+/i'),
'', $out);
806 }
while ($oldstringtoclean != $out);
811 if (empty($method) || $method == 3 || $method == 4) {
812 if (preg_match(
'/^search_/', $paramname) || in_array($paramname, array(
'sortorder',
'sortfield'))) {
819 if ($out !=
'' && isset($user)) {
820 $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out;
839 return (
int)
GETPOST($paramname,
'int', $method,
null,
null, 0);
853 function checkVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
855 return sanitizeVal($out, $check, $filter, $options);
867 function sanitizeVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
877 if (!is_numeric($out)) {
882 if (preg_match(
'/[^0-9,-]+/i', $out)) {
887 $out = filter_var($out, FILTER_SANITIZE_STRING);
890 $out = filter_var($out, FILTER_SANITIZE_EMAIL);
893 if (!is_array($out)) {
895 if (preg_match(
'/[^a-z]+/i', $out)) {
901 if (!is_array($out)) {
903 if (preg_match(
'/[^a-z0-9_\-\.]+/i', $out)) {
909 if (!is_array($out)) {
911 if (preg_match(
'/[^a-z0-9_\-\.,]+/i', $out)) {
921 if (!is_array($out)) {
924 $oldstringtoclean = $out;
931 $out = str_ireplace(array(
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'\',
'\',
'/',
'../',
'..\\'),
'', $out);
932 }
while ($oldstringtoclean != $out);
937 if (!is_array($out)) {
940 $oldstringtoclean = $out;
946 $out = str_ireplace(array(
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'\',
'\',
'/',
'../',
'..\\'),
'', $out);
947 }
while ($oldstringtoclean != $out);
951 case 'restricthtmlallowunvalid':
956 if (empty($filter)) {
957 return 'BadParameterForGETPOST - Param 3 of sanitizeVal()';
962 $out = filter_var($out, $filter, $options);
971 if (!function_exists(
'dol_getprefix')) {
981 function dol_getprefix($mode =
'')
984 if ($mode ==
'email') {
987 if (!empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) {
988 if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID !=
'SERVER_NAME') {
989 return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
990 } elseif (isset($_SERVER[
"SERVER_NAME"])) {
991 return $_SERVER[
"SERVER_NAME"];
996 if (!empty($conf->file->instance_unique_id)) {
997 return sha1(
'dolibarr'.$conf->file->instance_unique_id);
1001 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1005 global $dolibarr_main_instance_unique_id, $dolibarr_main_cookie_cryptkey;
1006 $tmp_instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ?
'' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
1009 if (!empty($tmp_instance_unique_id)) {
1010 return sha1(
'dolibarr'.$tmp_instance_unique_id);
1014 if (isset($_SERVER[
"SERVER_NAME"]) && isset($_SERVER[
"DOCUMENT_ROOT"])) {
1015 return sha1($_SERVER[
"SERVER_NAME"].$_SERVER[
"DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1017 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1034 global $conf, $langs, $user, $mysoc;
1038 if (!file_exists($fullpath)) {
1039 dol_syslog(
'functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_WARNING);
1043 if (!empty($classname) && !class_exists($classname)) {
1044 return include $fullpath;
1046 return include_once $fullpath;
1065 $path = preg_replace(
'/^\//',
'', $path);
1068 $res = DOL_DOCUMENT_ROOT.
'/'.$path;
1069 if (is_array($conf->file->dol_document_root)) {
1070 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1071 if ($key ==
'main') {
1074 if (file_exists($dirroot.
'/'.$path)) {
1075 $res = $dirroot.
'/'.$path;
1080 if ($returnemptyifnotfound) {
1082 if ($returnemptyifnotfound == 1 || !file_exists($res)) {
1094 $res = DOL_URL_ROOT.
'/'.$path;
1097 $res = DOL_MAIN_URL_ROOT.
'/'.$path;
1100 $res = DOL_URL_ROOT.
'/'.$path;
1103 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1104 if ($key ==
'main') {
1106 global $dolibarr_main_url_root;
1109 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1110 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1113 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
'/'.$path;
1117 preg_match(
'/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);
1118 if (!empty($regs[1])) {
1120 if (file_exists($dirroot.
'/'.$regs[1])) {
1122 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1125 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1128 global $dolibarr_main_url_root;
1131 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1132 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1135 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).$conf->file->dol_url_root[$key].
'/'.$path;
1162 if (isset($object->db) && isset($object->db->db) && is_object($object->db->db) && get_class($object->db->db) ==
'PgSql\Connection') {
1163 $tmpsavdb = $object->db;
1167 $myclone = unserialize(serialize($object));
1169 if (!empty($tmpsavdb)) {
1170 $object->db = $tmpsavdb;
1172 } elseif ($native == 2) {
1174 $myclone =
new stdClass();
1175 $tmparray = get_object_vars($object);
1177 if (is_array($tmparray)) {
1178 foreach ($tmparray as $propertykey => $propertyval) {
1179 if (is_scalar($propertyval) || is_array($propertyval)) {
1180 $myclone->$propertykey = $propertyval;
1185 $myclone = clone $object;
1203 if (empty($conf->dol_optimize_smallscreen)) {
1206 if ($type ==
'width' && $size > 250) {
1231 $filesystem_forbidden_chars = array(
'<',
'>',
'/',
'\\',
'?',
'*',
'|',
'"',
':',
'°',
'$',
';',
'`');
1233 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1234 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1235 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1236 $tmp = str_replace(
'..',
'', $tmp);
1256 $filesystem_forbidden_chars = array(
'<',
'>',
'?',
'*',
'|',
'"',
'°',
'$',
';',
'`');
1258 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1259 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1260 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1261 $tmp = str_replace(
'..',
'', $tmp);
1276 $stringtoclean = preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $stringtoclean);
1278 $stringtoclean = preg_replace(
'/<!--[^>]*-->/',
'', $stringtoclean);
1280 $stringtoclean = str_replace(
'\\',
'/', $stringtoclean);
1284 $stringtoclean = str_replace(array(
':',
';',
'@'),
'', $stringtoclean);
1288 $oldstringtoclean = $stringtoclean;
1291 $stringtoclean = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $stringtoclean);
1292 }
while ($oldstringtoclean != $stringtoclean);
1296 $stringtoclean = preg_replace(array(
'/^[a-z]*\/\/+/i'),
'', $stringtoclean);
1299 return $stringtoclean;
1311 $oldstringtoclean = $stringtoclean;
1312 $stringtoclean = str_ireplace(array(
'"',
':',
'[',
']',
"\n",
"\r",
'\\',
'\/'),
'', $stringtoclean);
1313 }
while ($oldstringtoclean != $stringtoclean);
1315 return $stringtoclean;
1330 if (is_null($str)) {
1335 if (extension_loaded(
'intl') && !empty($conf->global->MAIN_UNACCENT_USE_TRANSLITERATOR)) {
1336 $transliterator = \Transliterator::createFromRules(
':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', \Transliterator::FORWARD);
1337 return $transliterator->transliterate($str);
1340 $string = rawurlencode($str);
1341 $replacements = array(
1342 '%C3%80' =>
'A',
'%C3%81' =>
'A',
'%C3%82' =>
'A',
'%C3%83' =>
'A',
'%C3%84' =>
'A',
'%C3%85' =>
'A',
1344 '%C3%88' =>
'E',
'%C3%89' =>
'E',
'%C3%8A' =>
'E',
'%C3%8B' =>
'E',
1345 '%C3%8C' =>
'I',
'%C3%8D' =>
'I',
'%C3%8E' =>
'I',
'%C3%8F' =>
'I',
1347 '%C3%92' =>
'O',
'%C3%93' =>
'O',
'%C3%94' =>
'O',
'%C3%95' =>
'O',
'%C3%96' =>
'O',
1349 '%C3%99' =>
'U',
'%C3%9A' =>
'U',
'%C3%9B' =>
'U',
'%C3%9C' =>
'U',
1350 '%C3%9D' =>
'Y',
'%C5%B8' =>
'y',
1351 '%C3%A0' =>
'a',
'%C3%A1' =>
'a',
'%C3%A2' =>
'a',
'%C3%A3' =>
'a',
'%C3%A4' =>
'a',
'%C3%A5' =>
'a',
1353 '%C3%A8' =>
'e',
'%C3%A9' =>
'e',
'%C3%AA' =>
'e',
'%C3%AB' =>
'e',
1354 '%C3%AC' =>
'i',
'%C3%AD' =>
'i',
'%C3%AE' =>
'i',
'%C3%AF' =>
'i',
1356 '%C3%B2' =>
'o',
'%C3%B3' =>
'o',
'%C3%B4' =>
'o',
'%C3%B5' =>
'o',
'%C3%B6' =>
'o',
1358 '%C3%B9' =>
'u',
'%C3%BA' =>
'u',
'%C3%BB' =>
'u',
'%C3%BC' =>
'u',
1359 '%C3%BD' =>
'y',
'%C3%BF' =>
'y'
1361 $string = strtr($string, $replacements);
1362 return rawurldecode($string);
1367 "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
1368 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
1369 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
1370 \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
1371 \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
1372 \xF9\xFA\xFB\xFC\xFD\xFF",
1380 $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"));
1399 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
",",
";",
"=",
'°');
1400 $forbidden_chars_to_remove = array();
1403 if (is_array($badcharstoreplace)) {
1404 $forbidden_chars_to_replace = $badcharstoreplace;
1406 if (is_array($badcharstoremove)) {
1407 $forbidden_chars_to_remove = $badcharstoremove;
1410 return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove,
"", $str));
1429 if ($removetabcrlf) {
1430 return preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $str);
1432 return preg_replace(
'/[\x00-\x08\x11-\x12\x14-\x1F\x7F]/u',
'', $str);
1446 if (is_null($stringtoescape)) {
1451 $substitjs = array(
"'"=>
"\\'",
"\r"=>
'\\r');
1453 if (empty($noescapebackslashn)) {
1454 $substitjs[
"\n"] =
'\\n';
1455 $substitjs[
'\\'] =
'\\\\';
1458 $substitjs[
"'"] =
"\\'";
1459 $substitjs[
'"'] =
"\\'";
1460 } elseif ($mode == 1) {
1461 $substitjs[
"'"] =
"\\'";
1462 } elseif ($mode == 2) {
1463 $substitjs[
'"'] =
'\\"';
1464 } elseif ($mode == 3) {
1465 $substitjs[
"'"] =
"\\'";
1466 $substitjs[
'"'] =
"\\\"";
1468 return strtr($stringtoescape, $substitjs);
1479 return str_replace(
'"',
'\"', $stringtoescape);
1493 function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags =
'', $escapeonlyhtmltags = 0)
1495 if ($noescapetags ==
'common') {
1496 $noescapetags =
'html,body,a,b,em,hr,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody';
1500 if ($escapeonlyhtmltags) {
1501 $tmp = htmlspecialchars_decode((
string) $stringtoescape, ENT_COMPAT);
1503 $tmp = html_entity_decode((
string) $stringtoescape, ENT_COMPAT,
'UTF-8');
1506 $tmp = strtr($tmp, array(
"<b>"=>
'',
'</b>'=>
''));
1509 $tmp = strtr($tmp, array(
"\r"=>
'\\r',
"\n"=>
'\\n'));
1512 if ($escapeonlyhtmltags) {
1513 return htmlspecialchars($tmp, ENT_COMPAT,
'UTF-8');
1517 $tmparrayoftags = array();
1518 if ($noescapetags) {
1519 $tmparrayoftags = explode(
',', $noescapetags);
1521 if (count($tmparrayoftags)) {
1522 foreach ($tmparrayoftags as $tagtoreplace) {
1523 $tmp = str_ireplace(
'<'.$tagtoreplace.
'>',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1524 $tmp = str_ireplace(
'</'.$tagtoreplace.
'>',
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1525 $tmp = str_ireplace(
'<'.$tagtoreplace.
' />',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1529 $result = htmlentities($tmp, ENT_COMPAT,
'UTF-8');
1531 if (count($tmparrayoftags)) {
1532 foreach ($tmparrayoftags as $tagtoreplace) {
1533 $result = str_ireplace(
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
'>', $result);
1534 $result = str_ireplace(
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__',
'</'.$tagtoreplace.
'>', $result);
1535 $result = str_ireplace(
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
' />', $result);
1552 if (function_exists(
'mb_strtolower')) {
1553 return mb_strtolower($string, $encoding);
1555 return strtolower($string);
1568 if (function_exists(
'mb_strtoupper')) {
1569 return mb_strtoupper($string, $encoding);
1571 return strtoupper($string);
1584 if (function_exists(
'mb_substr')) {
1585 return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1,
null, $encoding);
1587 return ucfirst($string);
1600 if (function_exists(
'mb_convert_case')) {
1601 return mb_convert_case($string, MB_CASE_TITLE, $encoding);
1603 return ucwords($string);
1628 function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
'', $restricttologhandler =
'', $logcontext =
null)
1630 global $conf, $user, $debugbar;
1633 if (empty($conf->syslog->enabled)) {
1638 if (defined(
'USEEXTERNALSERVER') && !defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
1639 global $website, $websitekey;
1640 if (is_object($website) && !empty($website->ref)) {
1641 $suffixinfilename .=
'_website_'.$website->ref;
1642 } elseif (!empty($websitekey)) {
1643 $suffixinfilename .=
'_website_'.$websitekey;
1648 if (defined(
'USESUFFIXINLOG')) {
1649 $suffixinfilename .= constant(
'USESUFFIXINLOG');
1653 foreach ($conf->loghandlers as $loghandlerinstance) {
1654 $loghandlerinstance->setIdent($ident);
1658 if (!empty($message)) {
1660 $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');
1661 if (!array_key_exists($level, $logLevels)) {
1662 throw new Exception(
'Incorrect log level');
1664 if ($level > $conf->global->SYSLOG_LEVEL) {
1668 if (empty($conf->global->MAIN_SHOW_PASSWORD_INTO_LOG)) {
1669 $message = preg_replace(
'/password=\'[^\']*\'/',
'password=\'hidden\'', $message);
1673 if ((!empty($_REQUEST[
'logtohtml']) && !empty($conf->global->MAIN_ENABLE_LOG_TO_HTML))
1674 || (!empty($user->rights->debugbar->read) && is_object($debugbar))) {
1675 $conf->logbuffer[] =
dol_print_date(time(),
"%Y-%m-%d %H:%M:%S").
" ".$logLevels[$level].
" ".$message;
1680 if (!empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && !empty($_GET[
"log"])) {
1681 print
"\n\n<!-- Log start\n";
1683 print
"Log end -->\n";
1687 'message' => $message,
1688 'script' => (isset($_SERVER[
'PHP_SELF']) ? basename($_SERVER[
'PHP_SELF'],
'.php') :
false),
1690 'user' => ((is_object($user) && $user->id) ? $user->login :
false),
1695 if (!empty($remoteip)) {
1696 $data[
'ip'] = $remoteip;
1698 if (!empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) && $_SERVER[
'HTTP_X_FORWARDED_FOR'] != $remoteip) {
1699 $data[
'ip'] = $_SERVER[
'HTTP_X_FORWARDED_FOR'].
' -> '.$data[
'ip'];
1700 } elseif (!empty($_SERVER[
'HTTP_CLIENT_IP']) && $_SERVER[
'HTTP_CLIENT_IP'] != $remoteip) {
1701 $data[
'ip'] = $_SERVER[
'HTTP_CLIENT_IP'].
' -> '.$data[
'ip'];
1703 } elseif (!empty($_SERVER[
'SERVER_ADDR'])) {
1705 $data[
'ip'] = $_SERVER[
'SERVER_ADDR'];
1706 } elseif (!empty($_SERVER[
'COMPUTERNAME'])) {
1708 $data[
'ip'] = $_SERVER[
'COMPUTERNAME'].(empty($_SERVER[
'USERNAME']) ?
'' :
'@'.$_SERVER[
'USERNAME']);
1709 } elseif (!empty($_SERVER[
'LOGNAME'])) {
1711 $data[
'ip'] =
'???@'.$_SERVER[
'LOGNAME'];
1715 foreach ($conf->loghandlers as $loghandlerinstance) {
1716 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
1719 $loghandlerinstance->export($data, $suffixinfilename);
1725 foreach ($conf->loghandlers as $loghandlerinstance) {
1726 $loghandlerinstance->setIdent($ident);
1749 if (strpos($url,
'?') > 0) {
1750 $url .=
'&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name);
1752 $url .=
'?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name);
1757 $backtopagejsfieldsid =
''; $backtopagejsfieldslabel =
'';
1758 if ($backtopagejsfields) {
1759 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
1760 if (empty($tmpbacktopagejsfields[1])) {
1761 $backtopagejsfields = $name.
":".$backtopagejsfields;
1762 $tmp2backtopagejsfields = explode(
',', $tmpbacktopagejsfields[0]);
1764 $tmp2backtopagejsfields = explode(
',', $tmpbacktopagejsfields[1]);
1766 $backtopagejsfieldsid = empty($tmp2backtopagejsfields[0]) ?
'' : $tmp2backtopagejsfields[0];
1767 $backtopagejsfieldslabel = empty($tmp2backtopagejsfields[1]) ?
'' : $tmp2backtopagejsfields[1];
1768 $url .=
'&backtopagejsfields='.urlencode($backtopagejsfields);
1772 $out .=
'<!-- a link for button to open url into a dialog popup with backtopagejsfields = '.$backtopagejsfields.
' -->';
1773 $out .=
'<a class="cursorpointer classlink button_'.$name.($morecss ?
' '.$morecss :
'').
'"'.$disabled.
' title="'.
dol_escape_htmltag($label).
'"';
1774 if (empty($conf->use_javascript_ajax)) {
1775 $out .=
' href="'.DOL_URL_ROOT.$url.
'" target="_blank"';
1777 $out .=
'>'.$buttonstring.
'</a>';
1779 if (!empty($conf->use_javascript_ajax)) {
1781 $out .=
'<!-- code to open popup and variables to retreive returned variables -->';
1782 $out .=
'<div id="idfordialog'.$name.
'" class="hidden">div for dialog</div>';
1783 $out .=
'<div id="varforreturndialogid'.$name.
'" class="hidden">div for returned id</div>';
1784 $out .=
'<div id="varforreturndialoglabel'.$name.
'" class="hidden">div for returned label</div>';
1785 $out .=
'<!-- Add js code to open dialog popup on dialog -->';
1786 $out .=
'<script type="text/javascript">
1787 jQuery(document).ready(function () {
1788 jQuery(".button_'.$name.
'").click(function () {
1789 console.log(\'Open popup with jQuery(...).dialog() on URL '.
dol_escape_js(DOL_URL_ROOT.$url).
'\');
1790 var $tmpdialog = $(\
'#idfordialog'.$name.
'\');
1791 $tmpdialog.html(\
'<iframe class="iframedialog" id="iframedialog'.$name.
'" style="border: 0px;" src="'.DOL_URL_ROOT.$url.
'" width="100%" height="98%"></iframe>\');
1795 height: (window.innerHeight - 150),
1798 open:
function (event, ui) {
1799 console.log(
"open popup name='.$name.', backtopagejsfields='.$backtopagejsfields.'");
1801 close:
function (event, ui) {
1802 returnedid = jQuery(
"#varforreturndialogid'.$name.'").text();
1803 returnedlabel = jQuery(
"#varforreturndialoglabel'.$name.'").text();
1804 console.log(
"popup has been closed. returnedid (js var defined into parent page)="+returnedid+
" returnedlabel="+returnedlabel);
1805 if (returnedid !=
"" && returnedid !=
"div for returned id") {
1806 jQuery(
"#'.(empty($backtopagejsfieldsid)?"none
":$backtopagejsfieldsid).'").val(returnedid);
1808 if (returnedlabel !=
"" && returnedlabel !=
"div for returned label") {
1809 jQuery(
"#'.(empty($backtopagejsfieldslabel)?"none
":$backtopagejsfieldslabel).'").val(returnedlabel);
1814 $tmpdialog.dialog(\
'open\');
1838 function dol_fiche_head($links = array(), $active =
'0', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
1840 print
dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow, $moretabssuffix);
1858 function dol_get_fiche_head($links = array(), $active =
'', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
1860 global $conf, $langs, $hookmanager;
1864 if (!empty($conf->dol_optimize_smallscreen)) {
1868 $out =
"\n".
'<!-- dol_fiche_head - dol_get_fiche_head -->';
1870 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
1871 $out .=
'<div class="tabs'.($picto ?
'' :
' nopaddingleft').
'" data-role="controlgroup" data-type="horizontal">'.
"\n";
1875 if ($morehtmlright) {
1876 $out .=
'<div class="inline-block floatright tabsElem">'.$morehtmlright.
'</div>';
1880 if (!empty($title) && $showtitle && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1882 $out .=
'<a class="tabTitle">';
1884 $noprefix = $pictoisfullpath;
1885 if (strpos($picto,
'fontawesome_') !==
false) {
1888 $out .=
img_picto($title, ($noprefix ?
'' :
'object_').$picto,
'', $pictoisfullpath, 0, 0,
'',
'imgTabTitle').
' ';
1890 $out .=
'<span class="tabTitleText">'.dol_escape_htmltag(
dol_trunc($title, $limittitle)).
'</span>';
1898 if (is_array($links) && !empty($links)) {
1899 $keys = array_keys($links);
1901 $maxkey = max($keys);
1907 if (empty($limittoshow)) {
1908 $limittoshow = (empty($conf->global->MAIN_MAXTABS_IN_CARD) ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD);
1910 if (!empty($conf->dol_optimize_smallscreen)) {
1918 for ($i = 0; $i <= $maxkey; $i++) {
1919 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
1921 if ($i >= $limittoshow) {
1927 for ($i = 0; $i <= $maxkey; $i++) {
1928 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
1934 if ($i < $limittoshow || $isactive) {
1936 $out .=
'<div class="inline-block tabsElem'.($isactive ?
' tabsElemActive' :
'').((!$isactive && !empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT)) ?
' hideonprint' :
'').
'"><!-- id tab = '.(empty($links[$i][2]) ?
'' :
dol_escape_htmltag($links[$i][2])).
' -->';
1938 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
1939 if (!empty($links[$i][0])) {
1940 $out .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
1942 $out .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
1944 } elseif (!empty($links[$i][1])) {
1946 $out .=
'<div class="tab tab'.($isactive?
'active':
'unactive').
'" style="margin: 0 !important">';
1947 if (!empty($links[$i][0])) {
1948 $titletoshow = preg_replace(
'/<.*$/',
'', $links[$i][1]);
1949 $out .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="tab inline-block valignmiddle'.($morecss ?
' '.$morecss :
'').(!empty($links[$i][5]) ?
' '.$links[$i][5] :
'').
'" href="'.$links[$i][0].
'" title="'.
dol_escape_htmltag($titletoshow).
'">';
1951 $out .= $links[$i][1];
1952 if (!empty($links[$i][0])) {
1953 $out .=
'</a>'.
"\n";
1955 $out .= empty($links[$i][4]) ?
'' : $links[$i][4];
1964 $outmore .=
'<div class="popuptabset wordwrap">';
1966 $outmore .=
'<div class="popuptab wordwrap" style="display:inherit;">';
1967 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
1968 if (!empty($links[$i][0])) {
1969 $outmore .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
1971 $outmore .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
1973 } elseif (!empty($links[$i][1])) {
1974 $outmore .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="wordwrap inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
1975 $outmore .= preg_replace(
'/([a-z])\/([a-z])/i',
'\\1 / \\2', $links[$i][1]);
1976 $outmore .=
'</a>'.
"\n";
1978 $outmore .=
'</div>';
1985 $outmore .=
'</div>';
1989 $left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
1990 $right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
1991 $widthofpopup = 200;
1993 $tabsname = $moretabssuffix;
1994 if (empty($tabsname)) {
1995 $tabsname = str_replace(
"@",
"", $picto);
1997 $out .=
'<div id="moretabs'.$tabsname.
'" class="inline-block tabsElem valignmiddle">';
1998 $out .=
'<div class="tab"><a href="#" class="tab moretab inline-block tabunactive"><span class="hideonsmartphone">'.$langs->trans(
"More").
'</span>... ('.$nbintab.
')</a></div>';
1999 $out .=
'<div id="moretabsList'.$tabsname.
'" style="width: '.$widthofpopup.
'px; position: absolute; '.$left.
': -999em; text-align: '.$left.
'; margin:0px; padding:2px; z-index:10;">';
2002 $out .=
'<div></div>';
2006 $out .=
"$('#moretabs".$tabsname.
"').mouseenter( function() {
2007 var x = this.offsetLeft, y = this.offsetTop;
2008 console.log('mouseenter ".$left.
" x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
2009 if ((window.innerWidth - x) < ".($widthofpopup + 10).
") {
2010 $('#moretabsList".$tabsname.
"').css('".$right.
"','8px');
2012 $('#moretabsList".$tabsname.
"').css('".$left.
"','auto');
2015 $out .=
"$('#moretabs".$tabsname.
"').mouseleave( function() { console.log('mouseleave ".$left.
"'); $('#moretabsList".$tabsname.
"').css('".$left.
"','-999em');});";
2016 $out .=
"</script>";
2019 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2023 if (!$notab || $notab == -1 || $notab == -2 || $notab == -3) {
2024 $out .=
"\n".
'<div class="tabBar'.($notab == -1 ?
'' : ($notab == -2 ?
' tabBarNoTop' : (($notab == -3 ?
' noborderbottom' :
'').
' tabBarWithBottom'))).
'">'.
"\n";
2027 $parameters = array(
'tabname' => $active,
'out' => $out);
2028 $reshook = $hookmanager->executeHooks(
'printTabsHead', $parameters);
2030 $out = $hookmanager->resPrint;
2056 if (!$notab || $notab == -1) {
2057 return "\n</div>\n";
2082 function dol_banner_tab($object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $onlybanner = 0, $morehtmlright =
'')
2084 global $conf,
$form, $user, $langs, $hookmanager, $action;
2088 $maxvisiblephotos = 1;
2090 $entity = (empty($object->entity) ? $conf->entity : $object->entity);
2091 $showbarcode = empty($conf->barcode->enabled) ? 0 : (empty($object->barcode) ? 0 : 1);
2092 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
2095 $modulepart =
'unknown';
2097 if ($object->element ==
'societe' || $object->element ==
'contact' || $object->element ==
'product' || $object->element ==
'ticket') {
2098 $modulepart = $object->element;
2099 } elseif ($object->element ==
'member') {
2100 $modulepart =
'memberphoto';
2101 } elseif ($object->element ==
'user') {
2102 $modulepart =
'userphoto';
2105 if (class_exists(
"Imagick")) {
2106 if ($object->element ==
'expensereport' || $object->element ==
'propal' || $object->element ==
'commande' || $object->element ==
'facture' || $object->element ==
'supplier_proposal') {
2107 $modulepart = $object->element;
2108 } elseif ($object->element ==
'fichinter') {
2109 $modulepart =
'ficheinter';
2110 } elseif ($object->element ==
'contrat') {
2111 $modulepart =
'contract';
2112 } elseif ($object->element ==
'order_supplier') {
2113 $modulepart =
'supplier_order';
2114 } elseif ($object->element ==
'invoice_supplier') {
2115 $modulepart =
'supplier_invoice';
2119 if ($object->element ==
'product') {
2121 $cssclass =
'photowithmargin photoref';
2122 $showimage = $object->is_photo_available($conf->product->multidir_output[$entity]);
2123 $maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5);
2124 if ($conf->browser->layout ==
'phone') {
2125 $maxvisiblephotos = 1;
2128 $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>';
2130 if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
2132 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2134 $nophoto =
'/public/theme/common/nophoto.png';
2135 $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>';
2138 } elseif ($object->element ==
'ticket') {
2140 $cssclass =
'photoref';
2141 $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity].
'/'.$object->ref);
2142 $maxvisiblephotos = (isset($conf->global->TICKET_MAX_VISIBLE_PHOTO) ? $conf->global->TICKET_MAX_VISIBLE_PHOTO : 2);
2143 if ($conf->browser->layout ==
'phone') {
2144 $maxvisiblephotos = 1;
2148 $showphoto = $object->show_photos(
'ticket', $conf->ticket->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0);
2149 if ($object->nbphoto > 0) {
2150 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$showphoto.
'</div>';
2156 if (!empty($conf->global->TICKET_NODISPLAYIFNOPHOTO)) {
2158 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2160 $nophoto =
img_picto(
'No photo',
'object_ticket');
2161 $morehtmlleft .=
'<!-- No photo to show -->';
2162 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2163 $morehtmlleft .= $nophoto;
2164 $morehtmlleft .=
'</div></div>';
2169 if ($modulepart !=
'unknown') {
2172 if (in_array($modulepart, array(
'propal',
'commande',
'facture',
'ficheinter',
'contract',
'supplier_order',
'supplier_proposal',
'supplier_invoice',
'expensereport')) && class_exists(
"Imagick")) {
2174 $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]).
"/";
2175 if (in_array($modulepart, array(
'invoice_supplier',
'supplier_invoice'))) {
2176 $subdir =
get_exdir($object->id, 2, 0, 1, $object, $modulepart);
2177 $subdir .= ((!empty($subdir) && !preg_match(
'/\/$/', $subdir)) ?
'/' :
'').$objectref;
2179 $subdir =
get_exdir($object->id, 0, 0, 1, $object, $modulepart);
2181 if (empty($subdir)) {
2182 $subdir =
'errorgettingsubdirofobject';
2185 $filepath = $dir_output.$subdir.
"/";
2187 $filepdf = $filepath.$objectref.
".pdf";
2188 $relativepath = $subdir.
'/'.$objectref.
'.pdf';
2191 $fileimage = $filepdf.
'_preview.png';
2192 $relativepathimage = $relativepath.
'_preview.png';
2194 $pdfexists = file_exists($filepdf);
2199 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2200 if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) {
2201 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2210 if ($pdfexists && !$error) {
2211 $heightforphotref = 80;
2212 if (!empty($conf->dol_optimize_smallscreen)) {
2213 $heightforphotref = 60;
2216 if (file_exists($fileimage)) {
2217 $phototoshow =
'<div class="photoref">';
2218 $phototoshow .=
'<img height="'.$heightforphotref.
'" class="photo photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2219 $phototoshow .=
'</div>';
2222 } elseif (!$phototoshow) {
2223 $phototoshow .=
$form->showphoto($modulepart, $object, 0, 0, 0,
'photowithmargin photoref',
'small', 1, 0, $maxvisiblephotos);
2227 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
2228 $morehtmlleft .= $phototoshow;
2229 $morehtmlleft .=
'</div>';
2233 if (empty($phototoshow)) {
2234 if ($object->element ==
'action') {
2236 $cssclass =
'photorefcenter';
2237 $nophoto =
img_picto(
'No photo',
'title_agenda');
2240 $cssclass =
'photorefcenter';
2241 $picto = $object->picto;
2242 $prefix =
'object_';
2243 if ($object->element ==
'project' && !$object->public) {
2246 if (strpos($picto,
'fontawesome_') !==
false) {
2249 $nophoto =
img_picto(
'No photo', $prefix.$picto);
2251 $morehtmlleft .=
'<!-- No photo to show -->';
2252 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2253 $morehtmlleft .= $nophoto;
2254 $morehtmlleft .=
'</div></div>';
2260 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object, 100,
'photoref valignmiddle').
'</div>';
2263 if ($object->element ==
'societe') {
2264 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'societe',
'creer') && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
2265 $morehtmlstatus .=
ajax_object_onoff($object,
'status',
'status',
'InActivity',
'ActivityCeased');
2267 $morehtmlstatus .= $object->getLibStatut(6);
2269 } elseif ($object->element ==
'product') {
2271 if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
2272 $morehtmlstatus .=
ajax_object_onoff($object,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
2274 $morehtmlstatus .=
'<span class="statusrefsell">'.$object->getLibStatut(6, 0).
'</span>';
2276 $morehtmlstatus .=
' ';
2278 if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
2279 $morehtmlstatus .=
ajax_object_onoff($object,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
2281 $morehtmlstatus .=
'<span class="statusrefbuy">'.$object->getLibStatut(6, 1).
'</span>';
2283 } elseif (in_array($object->element, array(
'facture',
'invoice',
'invoice_supplier',
'chargesociales',
'loan',
'tva',
'salary'))) {
2284 $tmptxt = $object->getLibStatut(6, $object->totalpaid);
2285 if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
2286 $tmptxt = $object->getLibStatut(5, $object->totalpaid);
2288 $morehtmlstatus .= $tmptxt;
2289 } elseif ($object->element ==
'contrat' || $object->element ==
'contract') {
2290 if ($object->statut == 0) {
2291 $morehtmlstatus .= $object->getLibStatut(5);
2293 $morehtmlstatus .= $object->getLibStatut(4);
2295 } elseif ($object->element ==
'facturerec') {
2296 if ($object->frequency == 0) {
2297 $morehtmlstatus .= $object->getLibStatut(2);
2299 $morehtmlstatus .= $object->getLibStatut(5);
2301 } elseif ($object->element ==
'project_task') {
2302 $object->fk_statut = 1;
2303 if ($object->progress > 0) {
2304 $object->fk_statut = 2;
2306 if ($object->progress >= 100) {
2307 $object->fk_statut = 3;
2309 $tmptxt = $object->getLibStatut(5);
2310 $morehtmlstatus .= $tmptxt;
2311 } elseif (method_exists($object,
'getLibStatut')) {
2312 $tmptxt = $object->getLibStatut(6);
2313 if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
2314 $tmptxt = $object->getLibStatut(5);
2316 $morehtmlstatus .= $tmptxt;
2320 if (
isModEnabled(
'accounting') && in_array($object->element, array(
'bank',
'paiementcharge',
'facture',
'invoice',
'invoice_supplier',
'expensereport',
'payment_various'))) {
2322 if (method_exists($object,
'getVentilExportCompta')) {
2323 $accounted = $object->getVentilExportCompta();
2324 $langs->load(
"accountancy");
2325 $morehtmlstatus .=
'</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? $langs->trans(
"Accounted") : $langs->trans(
"NotYetAccounted")).
'</span>';
2330 if (!empty($object->name_alias)) {
2331 $morehtmlref .=
'<div class="refidno opacitymedium">'.$object->name_alias.
'</div>';
2335 if (in_array($object->element, array(
'product',
'bank_account',
'project_task'))) {
2336 if (!empty($object->label)) {
2337 $morehtmlref .=
'<div class="refidno opacitymedium">'.$object->label.
'</div>';
2342 if (method_exists($object,
'getBannerAddress') && !in_array($object->element, array(
'product',
'bookmark',
'ecm_directories',
'ecm_files'))) {
2343 $moreaddress = $object->getBannerAddress(
'refaddress', $object);
2345 $morehtmlref .=
'<div class="refidno refaddress">';
2346 $morehtmlref .= $moreaddress;
2347 $morehtmlref .=
'</div>';
2350 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)) {
2351 $morehtmlref .=
'<div style="clear: both;"></div>';
2352 $morehtmlref .=
'<div class="refidno opacitymedium">';
2353 $morehtmlref .= $langs->trans(
"TechnicalID").
': '.$object->id;
2354 $morehtmlref .=
'</div>';
2357 $parameters=array(
'morehtmlref'=>$morehtmlref);
2358 $reshook = $hookmanager->executeHooks(
'formDolBanner', $parameters, $object, $action);
2361 } elseif (empty($reshook)) {
2362 $morehtmlref .= $hookmanager->resPrint;
2363 } elseif ($reshook > 0) {
2364 $morehtmlref = $hookmanager->resPrint;
2368 print
'<div class="'.($onlybanner ?
'arearefnobottom ' :
'arearef ').
'heightref valignmiddle centpercent">';
2369 print
$form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
2371 print
'<div class="underrefbanner clearboth"></div>';
2387 if ($fieldrequired) {
2388 $ret .=
'<span class="fieldrequired">';
2390 $ret .=
'<label for="'.$fieldkey.
'">';
2391 $ret .= $langs->trans($langkey);
2393 if ($fieldrequired) {
2409 $ret =
' '.$bc[$var];
2411 $ret = preg_replace(
'/class=\"/',
'class="'.$moreclass.
' ', $ret);
2429 function dol_format_address($object, $withcountry = 0, $sep =
"\n", $outputlangs =
'', $mode = 0, $extralangcode =
'')
2431 global $conf, $langs, $hookmanager;
2434 $countriesusingstate = array(
'AU',
'CA',
'US',
'IN',
'GB',
'ES',
'UK',
'TR',
'CN');
2439 $ret .= ($extralangcode ? $object->array_languages[
'address'][$extralangcode] : (empty($object->address) ?
'' : $object->address));
2442 if (isset($object->country_code) && in_array($object->country_code, array(
'AU',
'CA',
'US',
'CN')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) {
2444 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2445 $ret .= (($ret && $town) ? $sep :
'').$town;
2447 if (!empty($object->state)) {
2448 $ret .= ($ret ? ($town ?
", " : $sep) :
'').$object->state;
2450 if (!empty($object->zip)) {
2451 $ret .= ($ret ? (($town || $object->state) ?
", " : $sep) :
'').$object->zip;
2453 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'GB',
'UK'))) {
2455 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2456 $ret .= ($ret ? $sep :
'').$town;
2457 if (!empty($object->state)) {
2458 $ret .= ($ret ?
", " :
'').$object->state;
2460 if (!empty($object->zip)) {
2461 $ret .= ($ret ? $sep :
'').$object->zip;
2463 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'ES',
'TR'))) {
2465 $ret .= ($ret ? $sep :
'').$object->zip;
2466 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2467 $ret .= ($town ? (($object->zip ?
' ' :
'').$town) :
'');
2468 if (!empty($object->state)) {
2469 $ret .=
"\n".$object->state;
2471 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'JP'))) {
2474 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2475 $ret .= ($ret ? $sep :
'').($object->state ? $object->state.
', ' :
'').$town.($object->zip ?
' ' :
'').$object->zip;
2476 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'IT'))) {
2478 $ret .= ($ret ? $sep :
'').$object->zip;
2479 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2480 $ret .= ($town ? (($object->zip ?
' ' :
'').$town) :
'');
2481 $ret .= (empty($object->state_code) ?
'' : (
' '.$object->state_code));
2484 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2485 $ret .= !empty($object->zip) ? (($ret ? $sep :
'').$object->zip) :
'';
2486 $ret .= ($town ? (($object->zip ?
' ' : ($ret ? $sep :
'')).$town) :
'');
2487 if (!empty($object->state) && in_array($object->country_code, $countriesusingstate)) {
2488 $ret .= ($ret ?
", " :
'').$object->state;
2491 if (!is_object($outputlangs)) {
2492 $outputlangs = $langs;
2495 $langs->load(
"dict");
2496 $ret .= (empty($object->country_code) ?
'' : ($ret ? $sep :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$object->country_code)));
2499 $parameters = array(
'withcountry' => $withcountry,
'sep' => $sep,
'outputlangs' => $outputlangs,
'mode' => $mode,
'extralangcode' => $extralangcode);
2500 $reshook = $hookmanager->executeHooks(
'formatAddress', $parameters, $object);
2504 $ret .= $hookmanager->resPrint;
2522 if ((abs($ts) <= 0x7FFFFFFF)) {
2523 return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts);
2525 return 'Error date into a not supported range';
2550 function dol_print_date($time, $format =
'', $tzoutput =
'auto', $outputlangs =
'', $encodetooutput =
false)
2552 global $conf, $langs;
2559 if ($tzoutput ===
'auto') {
2560 $tzoutput = (empty($conf) ?
'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey :
'tzserver'));
2565 $offsettz = $offsetdst = 0;
2568 if (is_string($tzoutput)) {
2569 if ($tzoutput ==
'tzserver') {
2571 $offsettzstring = @date_default_timezone_get();
2574 } elseif ($tzoutput ==
'tzuser' || $tzoutput ==
'tzuserrel') {
2576 $offsettzstring = (empty($_SESSION[
'dol_tz_string']) ?
'UTC' : $_SESSION[
'dol_tz_string']);
2578 if (class_exists(
'DateTimeZone')) {
2579 $user_date_tz =
new DateTimeZone($offsettzstring);
2580 $user_dt =
new DateTime();
2581 $user_dt->setTimezone($user_date_tz);
2582 $user_dt->setTimestamp($tzoutput ==
'tzuser' ?
dol_now() : (
int) $time);
2583 $offsettz = $user_dt->getOffset();
2585 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
2586 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
2591 if (!is_object($outputlangs)) {
2592 $outputlangs = $langs;
2595 $format =
'daytextshort';
2600 $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array(
'day',
'dayhour'))) ? 1 : 0;
2601 $format = preg_replace(
'/inputnoreduce/',
'', $format);
2602 $formatwithoutreduce = preg_replace(
'/reduceformat/',
'', $format);
2603 if ($formatwithoutreduce != $format) {
2604 $format = $formatwithoutreduce;
2610 if ($format ==
'day') {
2611 $format = ($outputlangs->trans(
"FormatDateShort") !=
"FormatDateShort" ? $outputlangs->trans(
"FormatDateShort") : $conf->format_date_short);
2612 } elseif ($format ==
'hour') {
2613 $format = ($outputlangs->trans(
"FormatHourShort") !=
"FormatHourShort" ? $outputlangs->trans(
"FormatHourShort") : $conf->format_hour_short);
2614 } elseif ($format ==
'hourduration') {
2615 $format = ($outputlangs->trans(
"FormatHourShortDuration") !=
"FormatHourShortDuration" ? $outputlangs->trans(
"FormatHourShortDuration") : $conf->format_hour_short_duration);
2616 } elseif ($format ==
'daytext') {
2617 $format = ($outputlangs->trans(
"FormatDateText") !=
"FormatDateText" ? $outputlangs->trans(
"FormatDateText") : $conf->format_date_text);
2618 } elseif ($format ==
'daytextshort') {
2619 $format = ($outputlangs->trans(
"FormatDateTextShort") !=
"FormatDateTextShort" ? $outputlangs->trans(
"FormatDateTextShort") : $conf->format_date_text_short);
2620 } elseif ($format ==
'dayhour') {
2621 $format = ($outputlangs->trans(
"FormatDateHourShort") !=
"FormatDateHourShort" ? $outputlangs->trans(
"FormatDateHourShort") : $conf->format_date_hour_short);
2622 } elseif ($format ==
'dayhoursec') {
2623 $format = ($outputlangs->trans(
"FormatDateHourSecShort") !=
"FormatDateHourSecShort" ? $outputlangs->trans(
"FormatDateHourSecShort") : $conf->format_date_hour_sec_short);
2624 } elseif ($format ==
'dayhourtext') {
2625 $format = ($outputlangs->trans(
"FormatDateHourText") !=
"FormatDateHourText" ? $outputlangs->trans(
"FormatDateHourText") : $conf->format_date_hour_text);
2626 } elseif ($format ==
'dayhourtextshort') {
2627 $format = ($outputlangs->trans(
"FormatDateHourTextShort") !=
"FormatDateHourTextShort" ? $outputlangs->trans(
"FormatDateHourTextShort") : $conf->format_date_hour_text_short);
2628 } elseif ($format ==
'dayhourlog') {
2630 $format =
'%Y%m%d%H%M%S';
2631 } elseif ($format ==
'dayhourlogsmall') {
2633 $format =
'%y%m%d%H%M';
2634 } elseif ($format ==
'dayhourldap') {
2635 $format =
'%Y%m%d%H%M%SZ';
2636 } elseif ($format ==
'dayhourxcard') {
2637 $format =
'%Y%m%dT%H%M%SZ';
2638 } elseif ($format ==
'dayxcard') {
2640 } elseif ($format ==
'dayrfc') {
2641 $format =
'%Y-%m-%d';
2642 } elseif ($format ==
'dayhourrfc') {
2643 $format =
'%Y-%m-%dT%H:%M:%SZ';
2644 } elseif ($format ==
'standard') {
2645 $format =
'%Y-%m-%d %H:%M:%S';
2648 if ($reduceformat) {
2649 $format = str_replace(
'%Y',
'%y', $format);
2650 $format = str_replace(
'yyyy',
'yy', $format);
2654 if (preg_match(
'/%b/i', $format)) {
2656 $format = str_replace(
'%b',
'__b__', $format);
2657 $format = str_replace(
'%B',
'__B__', $format);
2659 if (preg_match(
'/%a/i', $format)) {
2661 $format = str_replace(
'%a',
'__a__', $format);
2662 $format = str_replace(
'%A',
'__A__', $format);
2667 if (!empty($useadodb)) {
2668 include_once DOL_DOCUMENT_ROOT.
'/includes/adodbtime/adodb-time.inc.php';
2673 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)) {
2674 dol_print_error(
'',
"Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER[
"PHP_SELF"]);
2676 } elseif (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)) {
2678 dol_syslog(
"Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER[
"PHP_SELF"], LOG_WARNING);
2681 $syear = (!empty($reg[1]) ? $reg[1] :
'');
2682 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
2683 $sday = (!empty($reg[3]) ? $reg[3] :
'');
2684 $shour = (!empty($reg[4]) ? $reg[4] :
'');
2685 $smin = (!empty($reg[5]) ? $reg[5] :
'');
2686 $ssec = (!empty($reg[6]) ? $reg[6] :
'');
2688 $time =
dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear,
true);
2689 if (empty($useadodb)) {
2691 $tzo =
new DateTimeZone(
'UTC');
2693 $tzo =
new DateTimeZone(date_default_timezone_get());
2695 $dtts =
new DateTime();
2696 $dtts->setTimestamp($time);
2697 $dtts->setTimezone($tzo);
2698 $newformat = str_replace(
2699 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'%w',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2700 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'w',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2702 $ret = $dtts->format($newformat);
2704 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2705 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2708 $ret = adodb_strftime($format, $time + $offsettz + $offsetdst, $to_gmt);
2712 if ($time < 100000000000) {
2713 $timetouse = $time + $offsettz + $offsetdst;
2715 if (empty($useadodb)) {
2717 $tzo =
new DateTimeZone(
'UTC');
2719 $tzo =
new DateTimeZone(date_default_timezone_get());
2721 $dtts =
new DateTime();
2722 $dtts->setTimestamp($timetouse);
2723 $dtts->setTimezone($tzo);
2724 $newformat = str_replace(
2725 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'%w',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2726 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'w',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2728 $ret = $dtts->format($newformat);
2730 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2731 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2734 $ret = adodb_strftime($format, $timetouse, $to_gmt);
2738 $ret =
'Bad value '.$time.
' for date';
2742 if (preg_match(
'/__b__/i', $format)) {
2743 $timetouse = $time + $offsettz + $offsetdst;
2745 if (empty($useadodb)) {
2747 $tzo =
new DateTimeZone(
'UTC');
2749 $tzo =
new DateTimeZone(date_default_timezone_get());
2751 $dtts =
new DateTime();
2752 $dtts->setTimestamp($timetouse);
2753 $dtts->setTimezone($tzo);
2754 $month = $dtts->format(
"m");
2757 $month = adodb_strftime(
'%m', $timetouse, $to_gmt);
2759 $month = sprintf(
"%02d", $month);
2760 if ($encodetooutput) {
2761 $monthtext = $outputlangs->transnoentities(
'Month'.$month);
2762 $monthtextshort = $outputlangs->transnoentities(
'MonthShort'.$month);
2764 $monthtext = $outputlangs->transnoentitiesnoconv(
'Month'.$month);
2765 $monthtextshort = $outputlangs->transnoentitiesnoconv(
'MonthShort'.$month);
2768 $ret = str_replace(
'__b__', $monthtextshort, $ret);
2769 $ret = str_replace(
'__B__', $monthtext, $ret);
2773 if (preg_match(
'/__a__/i', $format)) {
2775 $timetouse = $time + $offsettz + $offsetdst;
2777 if (empty($useadodb)) {
2779 $tzo =
new DateTimeZone(
'UTC');
2781 $tzo =
new DateTimeZone(date_default_timezone_get());
2783 $dtts =
new DateTime();
2784 $dtts->setTimestamp($timetouse);
2785 $dtts->setTimezone($tzo);
2786 $w = $dtts->format(
"w");
2788 $w = adodb_strftime(
'%w', $timetouse, $to_gmt);
2790 $dayweek = $outputlangs->transnoentitiesnoconv(
'Day'.$w);
2792 $ret = str_replace(
'__A__', $dayweek, $ret);
2793 $ret = str_replace(
'__a__',
dol_substr($dayweek, 0, 3), $ret);
2822 $datetimeobj =
new DateTime();
2823 $datetimeobj->setTimestamp($timestamp);
2824 if ($forcetimezone) {
2825 $datetimeobj->setTimezone(
new DateTimeZone($forcetimezone ==
'gmt' ?
'UTC' : $forcetimezone));
2828 'year'=>((
int) date_format($datetimeobj,
'Y')),
2829 'mon'=>((
int) date_format($datetimeobj,
'm')),
2830 'mday'=>((
int) date_format($datetimeobj,
'd')),
2831 'wday'=>((
int) date_format($datetimeobj,
'w')),
2832 'yday'=>((
int) date_format($datetimeobj,
'z')),
2833 'hours'=>((
int) date_format($datetimeobj,
'H')),
2834 'minutes'=>((
int) date_format($datetimeobj,
'i')),
2835 'seconds'=>((
int) date_format($datetimeobj,
's')),
2863 function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm =
'auto', $check = 1)
2868 if ($gm ===
'auto') {
2869 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
2874 if ($hour == -1 || empty($hour)) {
2877 if ($minute == -1 || empty($minute)) {
2880 if ($second == -1 || empty($second)) {
2886 if (!$month || !$day) {
2895 if ($hour < 0 || $hour > 24) {
2898 if ($minute < 0 || $minute > 60) {
2901 if ($second < 0 || $second > 60) {
2906 if (empty($gm) || ($gm ===
'server' || $gm ===
'tzserver')) {
2907 $default_timezone = @date_default_timezone_get();
2908 $localtz =
new DateTimeZone($default_timezone);
2909 } elseif ($gm ===
'user' || $gm ===
'tzuser' || $gm ===
'tzuserrel') {
2911 $default_timezone = (empty($_SESSION[
"dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION[
"dol_tz_string"]);
2913 $localtz =
new DateTimeZone($default_timezone);
2915 dol_syslog(
"Warning dol_tz_string contains an invalid value ".$_SESSION[
"dol_tz_string"], LOG_WARNING);
2916 $default_timezone = @date_default_timezone_get();
2918 } elseif (strrpos($gm,
"tz,") !==
false) {
2919 $timezone = str_replace(
"tz,",
"", $gm);
2921 $localtz =
new DateTimeZone($timezone);
2923 dol_syslog(
"Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
2927 if (empty($localtz)) {
2928 $localtz =
new DateTimeZone(
'UTC');
2932 $dt =
new DateTime(
'now', $localtz);
2933 $dt->setDate((
int) $year, (
int) $month, (
int) $day);
2934 $dt->setTime((
int) $hour, (
int) $minute, (
int) $second);
2935 $date = $dt->getTimestamp();
2955 if ($mode ===
'auto') {
2959 if ($mode ==
'gmt') {
2961 } elseif ($mode ==
'tzserver') {
2962 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
2964 $ret = (int) (
dol_now(
'gmt') + ($tzsecond * 3600));
2970 } elseif ($mode ==
'tzuser' || $mode ==
'tzuserrel') {
2973 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
2974 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
2975 $ret = (int) (
dol_now(
'gmt') + ($offsettz + $offsetdst));
2992 global $conf, $langs;
2995 if (!empty($conf->dol_optimize_smallscreen)) {
3000 if (empty($shortvalue) || $size < ($level * 10)) {
3002 $textunitshort = $langs->trans(
"b");
3003 $textunitlong = $langs->trans(
"Bytes");
3005 $ret = round($size / $level, 0);
3006 $textunitshort = $langs->trans(
"Kb");
3007 $textunitlong = $langs->trans(
"KiloBytes");
3010 if (empty($shortunit)) {
3011 $ret .=
' '.$textunitlong;
3013 $ret .=
' '.$textunitshort;
3036 $link =
'<a href="';
3037 if (!preg_match(
'/^http/i', $url)) {
3043 $link .=
' target="'.$target.
'"';
3046 if (!preg_match(
'/^http/i', $url)) {
3051 return '<div class="nospan float" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe').
' ' :
'').$link.
'</div>';
3066 function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0)
3068 global $conf, $user, $langs, $hookmanager;
3072 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpicto) {
3076 if (empty($email)) {
3080 if (!empty($addlink)) {
3081 $newemail =
'<a style="text-overflow: ellipsis;" href="';
3082 if (!preg_match(
'/^mailto:/i', $email)) {
3083 $newemail .=
'mailto:';
3085 $newemail .= $email;
3088 $newemail .=
'</a>';
3090 $langs->load(
"errors");
3091 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
3094 if (($cid || $socid) &&
isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
3097 if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) {
3098 $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>';
3101 $newemail =
'<div>'.$newemail.
' '.$link.
'</div>';
3106 $langs->load(
"errors");
3107 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
3112 $rep = ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto)).
' ' :
'').$newemail;
3115 $parameters = array(
'cid' => $cid,
'socid' => $socid,
'addlink' => $addlink,
'picto' => $withpicto);
3117 $reshook = $hookmanager->executeHooks(
'printEmail', $parameters, $email);
3121 $rep .= $hookmanager->resPrint;
3136 $socialnetworks = array();
3138 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
3139 $cachekey =
'socialnetworks_' . $conf->entity;
3141 if (!is_null($dataretrieved)) {
3142 $socialnetworks = $dataretrieved;
3144 $sql =
"SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX.
"c_socialnetworks";
3145 $sql .=
" WHERE entity=".$conf->entity;
3146 $resql = $db->query($sql);
3148 while ($obj = $db->fetch_object(
$resql)) {
3149 $socialnetworks[$obj->code] = array(
3150 'rowid' => $obj->rowid,
3151 'label' => $obj->label,
3153 'icon' => $obj->icon,
3154 'active' => $obj->active,
3161 return $socialnetworks;
3176 global $conf, $user, $langs;
3180 if (empty($value)) {
3184 if (!empty($type)) {
3185 $htmllink =
'<div class="divsocialnetwork inline-block valignmiddle">';
3187 $htmllink .=
'<span class="fa paddingright '.($dictsocialnetworks[$type][
'icon'] ? $dictsocialnetworks[$type][
'icon'] :
'fa-link').
'"></span>';
3188 if ($type ==
'skype') {
3190 $htmllink .=
' ';
3191 $htmllink .=
'<a href="skype:';
3193 $htmllink .=
'?call" alt="'.$langs->trans(
"Call").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Call").
' '.$value).
'">';
3194 $htmllink .=
'<img src="'.DOL_URL_ROOT.
'/theme/common/skype_callbutton.png" border="0">';
3195 $htmllink .=
'</a><a href="skype:';
3197 $htmllink .=
'?chat" alt="'.$langs->trans(
"Chat").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Chat").
' '.$value).
'">';
3198 $htmllink .=
'<img class="paddingleft" src="'.DOL_URL_ROOT.
'/theme/common/skype_chatbutton.png" border="0">';
3199 $htmllink .=
'</a>';
3200 if (($cid || $socid) &&
isModEnabled(
'agenda') && $user->rights->agenda->myactions->create) {
3201 $addlink =
'AC_SKYPE';
3203 if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) {
3204 $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>';
3206 $htmllink .= ($link ?
' '.$link :
'');
3209 if (!empty($dictsocialnetworks[$type][
'url'])) {
3210 $tmpvirginurl = preg_replace(
'/\/?{socialid}/',
'', $dictsocialnetworks[$type][
'url']);
3211 if ($tmpvirginurl) {
3212 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3213 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3215 $tmpvirginurl3 = preg_replace(
'/^https:\/\//i',
'https://www.', $tmpvirginurl);
3216 if ($tmpvirginurl3) {
3217 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3218 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3221 $tmpvirginurl2 = preg_replace(
'/^https?:\/\//i',
'', $tmpvirginurl);
3222 if ($tmpvirginurl2) {
3223 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3224 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3227 $link = str_replace(
'{socialid}', $value, $dictsocialnetworks[$type][
'url']);
3228 if (preg_match(
'/^https?:\/\//i', $link)) {
3229 $htmllink .=
' <a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3231 $htmllink .=
' <a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3237 $htmllink .=
'</div>';
3239 $langs->load(
"errors");
3240 $htmllink .=
img_warning($langs->trans(
"ErrorBadSocialNetworkValue", $value));
3255 function dol_print_profids($profID, $profIDtype, $countrycode =
'', $addcpButton = 1, $separ =
' ')
3259 if (empty($profID) || empty($profIDtype)) {
3262 if (empty($countrycode)) $countrycode = $mysoc->country_code;
3263 $newProfID = $profID;
3264 $id = substr($profIDtype, -1);
3266 if (strtoupper($countrycode) ==
'FR') {
3268 if ($id == 1 &&
dol_strlen($newProfID) == 9) $newProfID = substr($newProfID, 0, 3).$separ.substr($newProfID, 3, 3).$separ.substr($newProfID, 6, 3);
3269 if ($id == 2 &&
dol_strlen($newProfID) == 14) $newProfID = substr($newProfID, 0, 3).$separ.substr($newProfID, 3, 3).$separ.substr($newProfID, 6, 3).$separ.substr($newProfID, 9, 5);
3270 if ($profIDtype ===
'VAT' &&
dol_strlen($newProfID) == 13) $newProfID = substr($newProfID, 0, 4).$separ.substr($newProfID, 4, 3).$separ.substr($newProfID, 7, 3).$separ.substr($newProfID, 10, 3);
3273 else $ret = $newProfID;
3291 function dol_print_phone($phone, $countrycode =
'', $cid = 0, $socid = 0, $addlink =
'', $separ =
" ", $withpicto =
'', $titlealt =
'', $adddivfloat = 0)
3293 global $conf, $user, $langs, $mysoc, $hookmanager;
3296 $phone = is_null($phone) ?
'' : preg_replace(
"/[\s.-]/",
"", trim($phone));
3297 if (empty($phone)) {
3300 if (!empty($conf->global->MAIN_PHONE_SEPAR)) {
3301 $separ = $conf->global->MAIN_PHONE_SEPAR;
3303 if (empty($countrycode) && is_object($mysoc)) {
3304 $countrycode = $mysoc->country_code;
3308 if ($conf->dol_optimize_smallscreen) {
3313 if (strtoupper($countrycode) ==
"FR") {
3316 $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);
3318 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
3320 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
3322 $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);
3324 $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);
3326 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 2);
3328 } elseif (strtoupper($countrycode) ==
"CA") {
3330 $newphone = ($separ !=
'' ?
'(' :
'').substr($newphone, 0, 3).($separ !=
'' ?
')' :
'').$separ.substr($newphone, 3, 3).($separ !=
'' ?
'-' :
'').substr($newphone, 6, 4);
3332 } elseif (strtoupper($countrycode) ==
"PT") {
3334 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3336 } elseif (strtoupper($countrycode) ==
"SR") {
3338 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
3340 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
3342 } elseif (strtoupper($countrycode) ==
"DE") {
3344 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
3346 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
3348 } elseif (strtoupper($countrycode) ==
"ES") {
3350 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3352 } elseif (strtoupper($countrycode) ==
"BF") {
3354 $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);
3356 } elseif (strtoupper($countrycode) ==
"RO") {
3358 $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);
3360 } elseif (strtoupper($countrycode) ==
"TR") {
3362 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
3364 } elseif (strtoupper($countrycode) ==
"US") {
3366 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
3368 } elseif (strtoupper($countrycode) ==
"MX") {
3370 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
3372 $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);
3374 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
3376 } elseif (strtoupper($countrycode) ==
"ML") {
3378 $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);
3380 } elseif (strtoupper($countrycode) ==
"TH") {
3382 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
3384 $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);
3386 } elseif (strtoupper($countrycode) ==
"MU") {
3389 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
3391 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
3393 } elseif (strtoupper($countrycode) ==
"ZA") {
3395 $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);
3397 } elseif (strtoupper($countrycode) ==
"SY") {
3399 $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);
3401 $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);
3403 } elseif (strtoupper($countrycode) ==
"AE") {
3405 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
3407 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3409 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
3411 } elseif (strtoupper($countrycode) ==
"DZ") {
3413 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3415 } elseif (strtoupper($countrycode) ==
"BE") {
3417 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
3419 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3421 } elseif (strtoupper($countrycode) ==
"PF") {
3423 $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);
3425 } elseif (strtoupper($countrycode) ==
"CO") {
3427 $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);
3429 } elseif (strtoupper($countrycode) ==
"JO") {
3431 $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);
3433 } elseif (strtoupper($countrycode) ==
"JM") {
3435 $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
3437 } elseif (strtoupper($countrycode) ==
"MG") {
3439 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 2);
3441 } elseif (strtoupper($countrycode) ==
"GB") {
3443 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3445 } elseif (strtoupper($countrycode) ==
"CH") {
3447 $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);
3449 $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);
3451 } elseif (strtoupper($countrycode) ==
"TN") {
3453 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3455 } elseif (strtoupper($countrycode) ==
"GF") {
3457 $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);
3459 } elseif (strtoupper($countrycode) ==
"GP") {
3461 $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);
3463 } elseif (strtoupper($countrycode) ==
"MQ") {
3465 $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);
3467 } elseif (strtoupper($countrycode) ==
"IT") {
3469 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3471 $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);
3473 } elseif (strtoupper($countrycode) ==
"AU") {
3477 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
3479 } elseif (strtoupper($countrycode) ==
"LU") {
3482 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
3484 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 1);
3486 $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);
3488 $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);
3491 if (!empty($addlink)) {
3492 if ($conf->browser->layout ==
'phone' || (
isModEnabled(
'clicktodial') && !empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) {
3493 $newphoneform = $newphone;
3494 $newphone =
'<a href="tel:'.$phone.
'"';
3495 $newphone .=
'>'.$newphoneform.
'</a>';
3496 } elseif (
isModEnabled(
'clicktodial') && $addlink ==
'AC_TEL') {
3497 if (empty($user->clicktodial_loaded)) {
3498 $user->fetch_clicktodial();
3502 $urlmask =
'ErrorClickToDialModuleNotConfigured';
3503 if (!empty($conf->global->CLICKTODIAL_URL)) {
3504 $urlmask = $conf->global->CLICKTODIAL_URL;
3506 if (!empty($user->clicktodial_url)) {
3507 $urlmask = $user->clicktodial_url;
3510 $clicktodial_poste = (!empty($user->clicktodial_poste) ?urlencode($user->clicktodial_poste) :
'');
3511 $clicktodial_login = (!empty($user->clicktodial_login) ?urlencode($user->clicktodial_login) :
'');
3512 $clicktodial_password = (!empty($user->clicktodial_password) ?urlencode($user->clicktodial_password) :
'');
3514 $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
3516 $substitarray = array(
'__PHONEFROM__'=>$clicktodial_poste,
3517 '__PHONETO__'=>urlencode($phone),
3518 '__LOGIN__'=>$clicktodial_login,
3519 '__PASS__'=>$clicktodial_password);
3521 $newphonesav = $newphone;
3522 if (empty($conf->global->CLICKTODIAL_DO_NOT_USE_AJAX_CALL)) {
3524 $newphone =
'<a href="'.$url.
'" class="cssforclicktodial"';
3525 $newphone .=
'>'.$newphonesav.
'</a>';
3528 $newphone =
'<a href="'.$url.
'"';
3529 if (!empty($conf->global->CLICKTODIAL_FORCENEWTARGET)) {
3530 $newphone .=
' target="_blank" rel="noopener noreferrer"';
3532 $newphone .=
'>'.$newphonesav.
'</a>';
3537 if (
isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
3540 if ($addlink ==
'AC_FAX') {
3543 if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE)) {
3544 $link =
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&backtopage='. urlencode($_SERVER[
'REQUEST_URI']) .
'&actioncode='.$type.($cid ?
'&contactid='.$cid :
'').($socid ?
'&socid='.$socid :
'').
'">'.
img_object($langs->trans(
"AddAction"),
"calendar").
'</a>';
3547 $newphone =
'<div>'.$newphone.
' '.$link.
'</div>';
3552 if (empty($titlealt)) {
3553 $titlealt = ($withpicto ==
'fax' ? $langs->trans(
"Fax") : $langs->trans(
"Phone"));
3558 $parameters = array(
'countrycode' => $countrycode,
'cid' => $cid,
'socid' => $socid,
'titlealt' => $titlealt,
'picto' => $withpicto);
3559 $reshook = $hookmanager->executeHooks(
'printPhone', $parameters, $phone);
3560 $rep .= $hookmanager->resPrint;
3562 if (empty($reshook)) {
3565 if ($withpicto ==
'fax') {
3566 $picto =
'phoning_fax';
3567 } elseif ($withpicto ==
'phone') {
3569 } elseif ($withpicto ==
'mobile') {
3570 $picto =
'phoning_mobile';
3575 if ($adddivfloat == 1) {
3576 $rep .=
'<div class="nospan float" style="margin-right: 10px">';
3577 } elseif (empty($adddivfloat)) {
3578 $rep .=
'<span style="margin-right: 10px;">';
3580 $rep .= ($withpicto ?
img_picto($titlealt,
'object_'.$picto.
'.png').
' ' :
'').$newphone;
3581 if ($adddivfloat == 1) {
3583 } elseif (empty($adddivfloat)) {
3600 global $conf, $langs;
3611 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/common/flags/'.$countrycode.
'.png')) {
3612 $ret .=
' '.img_picto($countrycode.
' '.$langs->trans(
"AccordingToGeoIPDatabase"), DOL_URL_ROOT.
'/theme/common/flags/'.$countrycode.
'.png',
'', 1);
3614 $ret .=
' ('.$countrycode.
')';
3634 if (empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
3635 if (empty($_SERVER[
'HTTP_CLIENT_IP']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_CLIENT_IP'])) {
3636 if (empty($_SERVER[
"HTTP_CF_CONNECTING_IP"])) {
3637 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
3639 $ip = $_SERVER[
"HTTP_CF_CONNECTING_IP"];
3642 $ip = $_SERVER[
'HTTP_CLIENT_IP'];
3645 $ip = $_SERVER[
'HTTP_X_FORWARDED_FOR'];
3661 if (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on') {
3663 } 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') {
3681 if (!empty($conf->geoipmaxmind->enabled)) {
3685 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
3686 $geoip =
new DolGeoIP(
'country', $datafile);
3688 $countrycode = $geoip->getCountryCodeFromIP($ip);
3691 return $countrycode;
3703 global $conf, $langs, $user;
3707 if (!empty($conf->geoipmaxmind->enabled)) {
3712 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
3713 $geoip =
new DolGeoIP(
'country', $datafile);
3714 $countrycode = $geoip->getCountryCodeFromIP($ip);
3715 $ret = $countrycode;
3734 global $conf, $user, $langs, $hookmanager;
3740 $parameters = array(
'element' => $element,
'id' => $id);
3741 $reshook = $hookmanager->executeHooks(
'printAddress', $parameters, $address);
3742 $out .= $hookmanager->resPrint;
3744 if (empty($reshook)) {
3745 if (empty($charfornl)) {
3746 $out .= nl2br($address);
3748 $out .= preg_replace(
'/[\r\n]+/', $charfornl, $address);
3752 $showgmap = $showomap = 0;
3753 if (($element ==
'thirdparty' || $element ==
'societe') && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) {
3756 if ($element ==
'contact' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) {
3759 if ($element ==
'member' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) {
3762 if (($element ==
'thirdparty' || $element ==
'societe') && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) {
3765 if ($element ==
'contact' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) {
3768 if ($element ==
'member' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) {
3772 $url =
dol_buildpath(
'/google/gmaps.php?mode='.$element.
'&id='.$id, 1);
3773 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
3776 $url =
dol_buildpath(
'/openstreetmap/maps.php?mode='.$element.
'&id='.$id, 1);
3777 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
3798 function isValidEmail($address, $acceptsupervisorkey = 0, $acceptuserkey = 0)
3800 if ($acceptsupervisorkey && $address ==
'__SUPERVISOREMAIL__') {
3803 if ($acceptuserkey && $address ==
'__USER_EMAIL__') {
3806 if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
3823 if (function_exists(
'idn_to_ascii') && function_exists(
'checkdnsrr')) {
3824 if (!checkdnsrr(idn_to_ascii($domain),
'MX')) {
3827 if (function_exists(
'getmxrr')) {
3830 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
3831 if (count($mxhosts) > 1) {
3834 if (count($mxhosts) == 1 && !empty($mxhosts[0])) {
3871 $tmparray = explode(
' ', $s);
3872 foreach ($tmparray as $tmps) {
3889 if (is_null($string)) {
3893 if (function_exists(
'mb_strlen')) {
3894 return mb_strlen($string, $stringencoding);
3896 return strlen($string);
3910 function dol_substr($string, $start, $length, $stringencoding =
'', $trunconbytes = 0)
3914 if (empty($stringencoding)) {
3915 $stringencoding = $langs->charset_output;
3919 if (empty($trunconbytes)) {
3920 if (function_exists(
'mb_substr')) {
3921 $ret = mb_substr($string, $start, $length, $stringencoding);
3923 $ret = substr($string, $start, $length);
3926 if (function_exists(
'mb_strcut')) {
3927 $ret = mb_strcut($string, $start, $length, $stringencoding);
3929 $ret = substr($string, $start, $length);
3949 function dol_trunc($string, $size = 40, $trunc =
'right', $stringencoding =
'UTF-8', $nodot = 0, $display = 0)
3953 if (empty($size) || !empty($conf->global->MAIN_DISABLE_TRUNC)) {
3957 if (empty($stringencoding)) {
3958 $stringencoding =
'UTF-8';
3961 if ($conf->dol_optimize_smallscreen == 1 && $display == 1) {
3962 $size = round($size / 3);
3966 if ($trunc ==
'right') {
3968 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
3970 return dol_substr($newstring, 0, $size, $stringencoding).($nodot ?
'' :
'…');
3975 } elseif ($trunc ==
'middle') {
3977 if (
dol_strlen($newstring, $stringencoding) > 2 &&
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
3978 $size1 = round($size / 2);
3979 $size2 = round($size / 2);
3980 return dol_substr($newstring, 0, $size1, $stringencoding).
'…'.
dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
3984 } elseif ($trunc ==
'left') {
3986 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
3988 return '…'.dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
3992 } elseif ($trunc ==
'wrap') {
3994 if (
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4000 return 'BadParam3CallingDolTrunc';
4024 function img_picto($titlealt, $picto, $moreatt =
'', $pictoisfullpath =
false, $srconly = 0, $notitle = 0, $alt =
'', $morecss =
'', $marginleftonlyshort = 2)
4026 global $conf, $langs;
4029 $url = DOL_URL_ROOT;
4030 $theme = isset($conf->theme) ? $conf->theme :
null;
4031 $path =
'theme/'.$theme;
4033 if ($pictoisfullpath) {
4035 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
4038 $fullpathpicto = $picto;
4040 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4041 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4042 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4045 $pictowithouttext = preg_replace(
'/(\.png|\.gif|\.svg)$/',
'', $picto);
4046 $pictowithouttext = str_replace(
'object_',
'', $pictowithouttext);
4048 if (strpos($pictowithouttext,
'fontawesome_') !==
false || preg_match(
'/^fa-/', $pictowithouttext)) {
4050 $pictowithouttext = str_replace(
'fontawesome_',
'', $pictowithouttext);
4051 $pictowithouttext = str_replace(
'fa-',
'', $pictowithouttext);
4053 $pictowithouttextarray = explode(
'_', $pictowithouttext);
4054 $marginleftonlyshort = 0;
4056 if (!empty($pictowithouttextarray[1])) {
4058 $fakey =
'fa-'.$pictowithouttextarray[0];
4059 $fa = empty($pictowithouttextarray[1]) ?
'fa' : $pictowithouttextarray[1];
4060 $facolor = empty($pictowithouttextarray[2]) ?
'' : $pictowithouttextarray[2];
4061 $fasize = empty($pictowithouttextarray[3]) ?
'' : $pictowithouttextarray[3];
4063 $fakey =
'fa-'.$pictowithouttext;
4073 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4074 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4075 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4077 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
4078 $morestyle = $reg[1];
4079 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
4081 $moreatt = trim($moreatt);
4083 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
4084 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
4088 $enabledisablehtml .=
'</span>';
4090 return $enabledisablehtml;
4093 if (empty($srconly) && in_array($pictowithouttext, array(
4094 '1downarrow',
'1uparrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected',
4095 'accountancy',
'accounting_account',
'account',
'accountline',
'action',
'add',
'address',
'angle-double-down',
'angle-double-up',
'asset',
4096 'bank_account',
'barcode',
'bank',
'bell',
'bill',
'billa',
'billr',
'billd',
'bookmark',
'bom',
'briefcase-medical',
'bug',
'building',
4097 'card',
'calendarlist',
'calendar',
'calendarmonth',
'calendarweek',
'calendarday',
'calendarperuser',
'calendarpertype',
4098 'cash-register',
'category',
'chart',
'check',
'clock',
'close_title',
'cog',
'collab',
'company',
'contact',
'country',
'contract',
'conversation',
'cron',
'cubes',
4099 'currency',
'multicurrency',
4100 'delete',
'dolly',
'dollyrevert',
'donation',
'download',
'dynamicprice',
4101 'edit',
'ellipsis-h',
'email',
'entity',
'envelope',
'eraser',
'establishment',
'expensereport',
'external-link-alt',
'external-link-square-alt',
'eye',
4102 'filter',
'file-code',
'file-export',
'file-import',
'file-upload',
'autofill',
'folder',
'folder-open',
'folder-plus',
4103 'gears',
'generate',
'globe',
'globe-americas',
'graph',
'grip',
'grip_title',
'group',
4105 'images',
'incoterm',
'info',
'intervention',
'inventory',
'intracommreport',
'jobprofile',
4106 'knowledgemanagement',
4107 'label',
'language',
'line',
'link',
'list',
'list-alt',
'listlight',
'loan',
'lock',
'lot',
'long-arrow-alt-right',
4108 'margin',
'map-marker-alt',
'member',
'meeting',
'money-bill-alt',
'movement',
'mrp',
'note',
'next',
4109 'off',
'on',
'order',
4110 'paiment',
'paragraph',
'play',
'pdf',
'phone',
'phoning',
'phoning_mobile',
'phoning_fax',
'playdisabled',
'previous',
'poll',
'pos',
'printer',
'product',
'propal',
'proposal',
'puce',
4111 'stock',
'resize',
'service',
'stats',
'trip',
4112 'security',
'setup',
'share-alt',
'sign-out',
'split',
'stripe',
'stripe-s',
'switch_off',
'switch_on',
'switch_on_red',
'tools',
'unlink',
'uparrow',
'user',
'user-tie',
'vcard',
'wrench',
4113 'github',
'google',
'jabber',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'youtube',
'google-plus-g',
'whatsapp',
4114 'chevron-left',
'chevron-right',
'chevron-down',
'chevron-top',
'commercial',
'companies',
4115 'generic',
'home',
'hrm',
'members',
'products',
'invoicing',
4116 'partnership',
'payment',
'payment_vat',
'pencil-ruler',
'pictoconfirm',
'preview',
'project',
'projectpub',
'projecttask',
'question',
'refresh',
'region',
4117 'salary',
'shipment',
'state',
'supplier_invoice',
'supplier_invoicea',
'supplier_invoicer',
'supplier_invoiced',
4118 'technic',
'ticket',
4120 'recent',
'reception',
'recruitmentcandidature',
'recruitmentjobposition',
'replacement',
'resource',
'recurring',
'rss',
4121 'shapes',
'skill',
'square',
'stop-circle',
'supplier',
'supplier_proposal',
'supplier_order',
'supplier_invoice',
4122 'timespent',
'title_setup',
'title_accountancy',
'title_bank',
'title_hrm',
'title_agenda',
4123 'uncheck',
'url',
'user-cog',
'user-injured',
'user-md',
'vat',
'website',
'workstation',
'webhook',
'world',
'private',
4124 'conferenceorbooth',
'eventorganization',
4125 'stamp',
'signature'
4127 $fakey = $pictowithouttext;
4131 if (in_array($pictowithouttext, array(
'card',
'bell',
'clock',
'establishment',
'generic',
'minus-square',
'object_generic',
'pdf',
'plus-square',
'timespent',
'note',
'off',
'on',
'object_bookmark',
'bookmark',
'vcard'))) {
4134 if (in_array($pictowithouttext, array(
'black-tie',
'github',
'google',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'stripe',
'stripe-s',
'youtube',
'google-plus-g',
'whatsapp'))) {
4138 $arrayconvpictotofa = array(
4139 'account'=>
'university',
'accounting_account'=>
'clipboard-list',
'accountline'=>
'receipt',
'accountancy'=>
'search-dollar',
'action'=>
'calendar-alt',
'add'=>
'plus-circle',
'address'=>
'address-book',
'asset'=>
'money-check-alt',
'autofill'=>
'fill',
4140 'bank_account'=>
'university',
4141 'bill'=>
'file-invoice-dollar',
'billa'=>
'file-excel',
'billr'=>
'file-invoice-dollar',
'billd'=>
'file-medical',
4142 'supplier_invoice'=>
'file-invoice-dollar',
'supplier_invoicea'=>
'file-excel',
'supplier_invoicer'=>
'file-invoice-dollar',
'supplier_invoiced'=>
'file-medical',
4144 'card'=>
'address-card',
'chart'=>
'chart-line',
'company'=>
'building',
'contact'=>
'address-book',
'contract'=>
'suitcase',
'collab'=>
'people-arrows',
'conversation'=>
'comments',
'country'=>
'globe-americas',
'cron'=>
'business-time',
4145 'donation'=>
'file-alt',
'dynamicprice'=>
'hand-holding-usd',
4146 'setup'=>
'cog',
'companies'=>
'building',
'products'=>
'cube',
'commercial'=>
'suitcase',
'invoicing'=>
'coins',
4147 'accounting'=>
'search-dollar',
'category'=>
'tag',
'dollyrevert'=>
'dolly',
4148 'generate'=>
'plus-square',
'hrm'=>
'user-tie',
'incoterm'=>
'truck-loading',
4149 'margin'=>
'calculator',
'members'=>
'user-friends',
'ticket'=>
'ticket-alt',
'globe'=>
'external-link-alt',
'lot'=>
'barcode',
4150 'email'=>
'at',
'establishment'=>
'building',
'edit'=>
'pencil-alt',
'entity'=>
'globe',
4151 'graph'=>
'chart-line',
'grip_title'=>
'arrows-alt',
'grip'=>
'arrows-alt',
'help'=>
'question-circle',
4152 'generic'=>
'file',
'holiday'=>
'umbrella-beach',
4153 'info'=>
'info-circle',
'inventory'=>
'boxes',
'intracommreport'=>
'globe-europe',
'jobprofile'=>
'cogs',
4154 'knowledgemanagement'=>
'ticket-alt',
'label'=>
'layer-group',
'line'=>
'bars',
'loan'=>
'money-bill-alt',
4155 'member'=>
'user-alt',
'meeting'=>
'chalkboard-teacher',
'mrp'=>
'cubes',
'next'=>
'arrow-alt-circle-right',
4156 'trip'=>
'wallet',
'expensereport'=>
'wallet',
'group'=>
'users',
'movement'=>
'people-carry',
4157 'sign-out'=>
'sign-out-alt',
4158 'switch_off'=>
'toggle-off',
'switch_on'=>
'toggle-on',
'switch_on_red'=>
'toggle-on',
'check'=>
'check',
'bookmark'=>
'star',
4159 'bank'=>
'university',
'close_title'=>
'times',
'delete'=>
'trash',
'filter'=>
'filter',
4160 'list-alt'=>
'list-alt',
'calendarlist'=>
'bars',
'calendar'=>
'calendar-alt',
'calendarmonth'=>
'calendar-alt',
'calendarweek'=>
'calendar-week',
'calendarday'=>
'calendar-day',
'calendarperuser'=>
'table',
4161 'intervention'=>
'ambulance',
'invoice'=>
'file-invoice-dollar',
'currency'=>
'dollar-sign',
'multicurrency'=>
'dollar-sign',
'order'=>
'file-invoice',
4162 'error'=>
'exclamation-triangle',
'warning'=>
'exclamation-triangle',
4164 'playdisabled'=>
'play',
'pdf'=>
'file-pdf',
'poll'=>
'check-double',
'pos'=>
'cash-register',
'preview'=>
'binoculars',
'project'=>
'project-diagram',
'projectpub'=>
'project-diagram',
'projecttask'=>
'tasks',
'propal'=>
'file-signature',
'proposal'=>
'file-signature',
4165 'partnership'=>
'handshake',
'payment'=>
'money-check-alt',
'payment_vat'=>
'money-check-alt',
'pictoconfirm'=>
'check-square',
'phoning'=>
'phone',
'phoning_mobile'=>
'mobile-alt',
'phoning_fax'=>
'fax',
'previous'=>
'arrow-alt-circle-left',
'printer'=>
'print',
'product'=>
'cube',
'puce'=>
'angle-right',
4166 'recent' =>
'check-square',
'reception'=>
'dolly',
'recruitmentjobposition'=>
'id-card-alt',
'recruitmentcandidature'=>
'id-badge',
4167 'resize'=>
'crop',
'supplier_order'=>
'dol-order_supplier',
'supplier_proposal'=>
'file-signature',
4168 'refresh'=>
'redo',
'region'=>
'map-marked',
'replacement'=>
'exchange-alt',
'resource'=>
'laptop-house',
'recurring'=>
'history',
4169 'service'=>
'concierge-bell',
4170 'skill'=>
'shapes',
'state'=>
'map-marked-alt',
'security'=>
'key',
'salary'=>
'wallet',
'shipment'=>
'dolly',
'stock'=>
'box-open',
'stats' =>
'chart-bar',
'split'=>
'code-branch',
'stripe'=>
'stripe-s',
4171 'supplier'=>
'building',
'technic'=>
'cogs',
4172 'timespent'=>
'clock',
'title_setup'=>
'tools',
'title_accountancy'=>
'money-check-alt',
'title_bank'=>
'university',
'title_hrm'=>
'umbrella-beach',
4173 'title_agenda'=>
'calendar-alt',
4174 'uncheck'=>
'times',
'uparrow'=>
'share',
'url'=>
'external-link-alt',
'vat'=>
'money-check-alt',
'vcard'=>
'address-card',
4175 'jabber'=>
'comment-o',
4176 'website'=>
'globe-americas',
'workstation'=>
'pallet',
'webhook'=>
'bullseye',
'world'=>
'globe',
'private'=>
'user-lock',
4177 'conferenceorbooth'=>
'chalkboard-teacher',
'eventorganization'=>
'project-diagram'
4179 if ($pictowithouttext ==
'off') {
4180 $fakey =
'fa-square';
4182 } elseif ($pictowithouttext ==
'on') {
4183 $fakey =
'fa-check-square';
4185 } elseif ($pictowithouttext ==
'listlight') {
4186 $fakey =
'fa-download';
4187 $marginleftonlyshort = 1;
4188 } elseif ($pictowithouttext ==
'printer') {
4189 $fakey =
'fa-print';
4191 } elseif ($pictowithouttext ==
'note') {
4192 $fakey =
'fa-sticky-note';
4193 $marginleftonlyshort = 1;
4194 } elseif (in_array($pictowithouttext, array(
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'))) {
4195 $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');
4196 $fakey =
'fa-'.$convertarray[$pictowithouttext];
4197 if (preg_match(
'/selected/', $pictowithouttext)) {
4200 $marginleftonlyshort = 1;
4201 } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) {
4202 $fakey =
'fa-'.$arrayconvpictotofa[$pictowithouttext];
4204 $fakey =
'fa-'.$pictowithouttext;
4207 if (in_array($pictowithouttext, array(
'dollyrevert',
'member',
'members',
'contract',
'group',
'resource',
'shipment'))) {
4208 $morecss .=
' em092';
4210 if (in_array($pictowithouttext, array(
'conferenceorbooth',
'collab',
'eventorganization',
'holiday',
'info',
'project',
'workstation'))) {
4211 $morecss .=
' em088';
4213 if (in_array($pictowithouttext, array(
'asset',
'intervention',
'payment',
'loan',
'partnership',
'stock',
'technic'))) {
4214 $morecss .=
' em080';
4218 $arrayconvpictotomarginleftonly = array(
4219 'bank',
'check',
'delete',
'generic',
'grip',
'grip_title',
'jabber',
4220 'grip_title',
'grip',
'listlight',
'note',
'on',
'off',
'playdisabled',
'printer',
'resize',
'sign-out',
'stats',
'switch_on',
'switch_on_red',
'switch_off',
4221 'uparrow',
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'
4223 if (!isset($arrayconvpictotomarginleftonly[$pictowithouttext])) {
4224 $marginleftonlyshort = 0;
4228 $arrayconvpictotomorcess = array(
4229 'action'=>
'infobox-action',
'account'=>
'infobox-bank_account',
'accounting_account'=>
'infobox-bank_account',
'accountline'=>
'infobox-bank_account',
'accountancy'=>
'infobox-bank_account',
'asset'=>
'infobox-bank_account',
4230 'bank_account'=>
'infobox-bank_account',
4231 'bill'=>
'infobox-commande',
'billa'=>
'infobox-commande',
'billr'=>
'infobox-commande',
'billd'=>
'infobox-commande',
4232 'margin'=>
'infobox-bank_account',
'conferenceorbooth'=>
'infobox-project',
4233 'cash-register'=>
'infobox-bank_account',
'contract'=>
'infobox-contrat',
'check'=>
'font-status4',
'collab'=>
'infobox-action',
'conversation'=>
'infobox-contrat',
4234 'donation'=>
'infobox-commande',
'dolly'=>
'infobox-commande',
'dollyrevert'=>
'flip infobox-order_supplier',
4235 'ecm'=>
'infobox-action',
'eventorganization'=>
'infobox-project',
4236 'hrm'=>
'infobox-adherent',
'group'=>
'infobox-adherent',
'intervention'=>
'infobox-contrat',
4237 'incoterm'=>
'infobox-supplier_proposal',
4238 'currency'=>
'infobox-bank_account',
'multicurrency'=>
'infobox-bank_account',
4239 'members'=>
'infobox-adherent',
'member'=>
'infobox-adherent',
'money-bill-alt'=>
'infobox-bank_account',
4240 'order'=>
'infobox-commande',
4241 'user'=>
'infobox-adherent',
'users'=>
'infobox-adherent',
4242 'error'=>
'pictoerror',
'warning'=>
'pictowarning',
'switch_on'=>
'font-status4',
'switch_on_red'=>
'font-status8',
4243 'holiday'=>
'infobox-holiday',
'info'=>
'opacityhigh',
'invoice'=>
'infobox-commande',
4244 'knowledgemanagement'=>
'infobox-contrat rotate90',
'loan'=>
'infobox-bank_account',
4245 'payment'=>
'infobox-bank_account',
'payment_vat'=>
'infobox-bank_account',
'poll'=>
'infobox-adherent',
'pos'=>
'infobox-bank_account',
'project'=>
'infobox-project',
'projecttask'=>
'infobox-project',
4246 'propal'=>
'infobox-propal',
'proposal'=>
'infobox-propal',
'private'=>
'infobox-project',
4247 'reception'=>
'flip',
'recruitmentjobposition'=>
'infobox-adherent',
'recruitmentcandidature'=>
'infobox-adherent',
4248 'resource'=>
'infobox-action',
4249 'salary'=>
'infobox-bank_account',
'shipment'=>
'infobox-commande',
'supplier_invoice'=>
'infobox-order_supplier',
'supplier_invoicea'=>
'infobox-order_supplier',
'supplier_invoiced'=>
'infobox-order_supplier',
4250 'supplier'=>
'infobox-order_supplier',
'supplier_order'=>
'infobox-order_supplier',
'supplier_proposal'=>
'infobox-supplier_proposal',
4251 'ticket'=>
'infobox-contrat',
'title_accountancy'=>
'infobox-bank_account',
'title_hrm'=>
'infobox-holiday',
'expensereport'=>
'infobox-expensereport',
'trip'=>
'infobox-expensereport',
'title_agenda'=>
'infobox-action',
4252 'vat'=>
'infobox-bank_account',
4254 'list-alt'=>
'imgforviewmode',
'calendar'=>
'imgforviewmode',
'calendarweek'=>
'imgforviewmode',
'calendarmonth'=>
'imgforviewmode',
'calendarday'=>
'imgforviewmode',
'calendarperuser'=>
'imgforviewmode'
4256 if (!empty($arrayconvpictotomorcess[$pictowithouttext])) {
4257 $morecss .= ($morecss ?
' ' :
'').$arrayconvpictotomorcess[$pictowithouttext];
4261 $arrayconvpictotocolor = array(
4262 'address'=>
'#6c6aa8',
'building'=>
'#6c6aa8',
'bom'=>
'#a69944',
4263 'cog'=>
'#999',
'companies'=>
'#6c6aa8',
'company'=>
'#6c6aa8',
'contact'=>
'#6c6aa8',
'cron'=>
'#555',
4264 'dynamicprice'=>
'#a69944',
4265 'edit'=>
'#444',
'note'=>
'#999',
'error'=>
'',
'help'=>
'#bbb',
'listlight'=>
'#999',
'language'=>
'#555',
4267 'lock'=>
'#ddd',
'lot'=>
'#a69944',
4268 'map-marker-alt'=>
'#aaa',
'mrp'=>
'#a69944',
'product'=>
'#a69944',
'service'=>
'#a69944',
'inventory'=>
'#a69944',
'stock'=>
'#a69944',
'movement'=>
'#a69944',
4269 'other'=>
'#ddd',
'world'=>
'#986c6a',
4270 'partnership'=>
'#6c6aa8',
'playdisabled'=>
'#ccc',
'printer'=>
'#444',
'projectpub'=>
'#986c6a',
'reception'=>
'#a69944',
'resize'=>
'#444',
'rss'=>
'#cba',
4272 'security'=>
'#999',
'square'=>
'#888',
'stop-circle'=>
'#888',
'stats'=>
'#444',
'switch_off'=>
'#999',
'technic'=>
'#999',
'timespent'=>
'#555',
4273 'uncheck'=>
'#800',
'uparrow'=>
'#555',
'user-cog'=>
'#999',
'country'=>
'#aaa',
'globe-americas'=>
'#aaa',
'region'=>
'#aaa',
'state'=>
'#aaa',
4274 'website'=>
'#304',
'workstation'=>
'#a69944'
4276 if (isset($arrayconvpictotocolor[$pictowithouttext])) {
4277 $facolor = $arrayconvpictotocolor[$pictowithouttext];
4284 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4285 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4286 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4288 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
4289 $morestyle = $reg[1];
4290 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
4292 $moreatt = trim($moreatt);
4294 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
4295 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
4299 $enabledisablehtml .=
'</span>';
4301 return $enabledisablehtml;
4304 if (!empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) {
4305 $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.
'/theme/'.$theme;
4306 } elseif (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) {
4307 $path = $conf->global->MAIN_OVERWRITE_THEME_RES.
'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES;
4308 } elseif (!empty($conf->modules_parts[
'theme']) && array_key_exists($theme, $conf->modules_parts[
'theme'])) {
4309 $path = $theme.
'/theme/'.$theme;
4314 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
4320 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
4325 foreach ($conf->file->dol_document_root as $type => $dirroot) {
4326 if ($type ==
'main') {
4330 if (file_exists($dirroot.
'/'.$path.
'/img/'.$picto)) {
4331 $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type];
4337 $fullpathpicto = $url.
'/'.$path.
'/img/'.$picto;
4341 return $fullpathpicto;
4344 return '<img src="'.$fullpathpicto.
'"'.($notitle ?
'' :
' alt="'.dol_escape_htmltag($alt).
'"').(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt.($morecss ?
' class="'.$morecss.
'"' :
'') :
' class="inline-block'.($morecss ?
' '.$morecss :
'').
'"').
'>';
4360 function img_object($titlealt, $picto, $moreatt =
'', $pictoisfullpath =
false, $srconly = 0, $notitle = 0)
4362 if (strpos($picto,
'^') === 0) {
4363 return img_picto($titlealt, str_replace(
'^',
'', $picto), $moreatt, $pictoisfullpath, $srconly, $notitle);
4365 return img_picto($titlealt,
'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
4380 function img_weather($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $morecss =
'')
4384 if (is_numeric($picto)) {
4387 return '<i class="fa fa-weather-level'.$picto.
'"></i>';
4388 } elseif (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
4392 $path = DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/weather/'.$picto;
4394 return img_picto($titlealt, $path, $moreatt, 1, 0, 0,
'', $morecss);
4408 function img_picto_common($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $notitle = 0)
4412 if (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
4416 if ($pictoisfullpath) {
4419 $path = DOL_URL_ROOT.
'/theme/common/'.$picto;
4421 if (!empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) {
4422 $themepath = DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/img/'.$picto;
4424 if (file_exists($themepath)) {
4430 return img_picto($titlealt, $path, $moreatt, 1, 0, $notitle);
4449 if (empty($titlealt) || $titlealt ==
'default') {
4450 if ($numaction ==
'-1' || $numaction ==
'ST_NO') {
4452 $titlealt = $langs->transnoentitiesnoconv(
'ChangeDoNotContact');
4453 } elseif ($numaction ==
'0' || $numaction ==
'ST_NEVER') {
4455 $titlealt = $langs->transnoentitiesnoconv(
'ChangeNeverContacted');
4456 } elseif ($numaction ==
'1' || $numaction ==
'ST_TODO') {
4458 $titlealt = $langs->transnoentitiesnoconv(
'ChangeToContact');
4459 } elseif ($numaction ==
'2' || $numaction ==
'ST_PEND') {
4461 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactInProcess');
4462 } elseif ($numaction ==
'3' || $numaction ==
'ST_DONE') {
4464 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactDone');
4466 $titlealt = $langs->transnoentitiesnoconv(
'ChangeStatus '.$numaction);
4470 if (!is_numeric($numaction)) {
4474 return img_picto($titlealt, !empty($picto) ? $picto :
'stcomm'.$numaction.
'.png');
4484 function img_pdf($titlealt =
'default', $size = 3)
4488 if ($titlealt ==
'default') {
4489 $titlealt = $langs->trans(
'Show');
4492 return img_picto($titlealt,
'pdf'.$size.
'.png');
4506 if ($titlealt ==
'default') {
4507 $titlealt = $langs->trans(
'Add');
4510 return img_picto($titlealt,
'edit_add.png', $other);
4523 if ($titlealt ==
'default') {
4524 $titlealt = $langs->trans(
'Remove');
4527 return img_picto($titlealt,
'edit_remove.png', $other);
4538 function img_edit($titlealt =
'default', $float = 0, $other =
'')
4542 if ($titlealt ==
'default') {
4543 $titlealt = $langs->trans(
'Modify');
4546 return img_picto($titlealt,
'edit.png', ($float ?
'style="float: '.($langs->tab_translate[
"DIRECTION"] ==
'rtl' ?
'left' :
'right').
'"' :
"").($other ?
' '.$other :
''));
4557 function img_view($titlealt =
'default', $float = 0, $other =
'class="valignmiddle"')
4561 if ($titlealt ==
'default') {
4562 $titlealt = $langs->trans(
'View');
4565 $moreatt = ($float ?
'style="float: right" ' :
'').$other;
4567 return img_picto($titlealt,
'eye', $moreatt);
4578 function img_delete($titlealt =
'default', $other =
'class="pictodelete"', $morecss =
'')
4582 if ($titlealt ==
'default') {
4583 $titlealt = $langs->trans(
'Delete');
4586 return img_picto($titlealt,
'delete.png', $other,
false, 0, 0,
'', $morecss);
4599 if ($titlealt ==
"default") {
4600 $titlealt = $langs->trans(
"Print");
4602 return img_picto($titlealt,
'printer.png', $other);
4612 function img_split($titlealt =
'default', $other =
'class="pictosplit"')
4616 if ($titlealt ==
'default') {
4617 $titlealt = $langs->trans(
'Split');
4620 return img_picto($titlealt,
'split.png', $other);
4630 function img_help($usehelpcursor = 1, $usealttitle = 1)
4635 if (is_string($usealttitle)) {
4638 $usealttitle = $langs->trans(
'Info');
4642 return img_picto($usealttitle,
'info.png',
'style="vertical-align: middle;'.($usehelpcursor == 1 ?
' cursor: help' : ($usehelpcursor == 2 ?
' cursor: pointer' :
'')).
'"');
4655 if ($titlealt ==
'default') {
4656 $titlealt = $langs->trans(
'Informations');
4659 return img_picto($titlealt,
'info.png',
'style="vertical-align: middle;"');
4670 function img_warning($titlealt =
'default', $moreatt =
'', $morecss =
'pictowarning')
4674 if ($titlealt ==
'default') {
4675 $titlealt = $langs->trans(
'Warning');
4679 return img_picto($titlealt,
'warning.png',
'class="'.$morecss.
'"'.($moreatt ? ($moreatt ==
'1' ?
' style="float: right"' :
' '.$moreatt) :
''));
4692 if ($titlealt ==
'default') {
4693 $titlealt = $langs->trans(
'Error');
4696 return img_picto($titlealt,
'error.png');
4706 function img_next($titlealt =
'default', $moreatt =
'')
4710 if ($titlealt ==
'default') {
4711 $titlealt = $langs->trans(
'Next');
4715 return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
4729 if ($titlealt ==
'default') {
4730 $titlealt = $langs->trans(
'Previous');
4734 return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
4745 function img_down($titlealt =
'default', $selected = 0, $moreclass =
'')
4749 if ($titlealt ==
'default') {
4750 $titlealt = $langs->trans(
'Down');
4753 return img_picto($titlealt, ($selected ?
'1downarrow_selected.png' :
'1downarrow.png'),
'class="imgdown'.($moreclass ?
" ".$moreclass :
"").
'"');
4764 function img_up($titlealt =
'default', $selected = 0, $moreclass =
'')
4768 if ($titlealt ==
'default') {
4769 $titlealt = $langs->trans(
'Up');
4772 return img_picto($titlealt, ($selected ?
'1uparrow_selected.png' :
'1uparrow.png'),
'class="imgup'.($moreclass ?
" ".$moreclass :
"").
'"');
4783 function img_left($titlealt =
'default', $selected = 0, $moreatt =
'')
4787 if ($titlealt ==
'default') {
4788 $titlealt = $langs->trans(
'Left');
4791 return img_picto($titlealt, ($selected ?
'1leftarrow_selected.png' :
'1leftarrow.png'), $moreatt);
4802 function img_right($titlealt =
'default', $selected = 0, $moreatt =
'')
4806 if ($titlealt ==
'default') {
4807 $titlealt = $langs->trans(
'Right');
4810 return img_picto($titlealt, ($selected ?
'1rightarrow_selected.png' :
'1rightarrow.png'), $moreatt);
4824 if ($titlealt ==
'default') {
4825 $titlealt = $langs->trans(
'Active');
4829 return img_picto($titlealt,
'tick.png');
4844 if (is_null($morecss)) {
4848 if ($brand ==
'visa' || $brand ==
'Visa') {
4850 } elseif ($brand ==
'mastercard' || $brand ==
'MasterCard') {
4851 $brand =
'cc-mastercard';
4852 } elseif ($brand ==
'amex' || $brand ==
'American Express') {
4854 } elseif ($brand ==
'discover' || $brand ==
'Discover') {
4855 $brand =
'cc-discover';
4856 } elseif ($brand ==
'jcb' || $brand ==
'JCB') {
4858 } elseif ($brand ==
'diners' || $brand ==
'Diners club') {
4859 $brand =
'cc-diners-club';
4860 } elseif (!in_array($brand, array(
'cc-visa',
'cc-mastercard',
'cc-amex',
'cc-discover',
'cc-jcb',
'cc-diners-club'))) {
4861 $brand =
'credit-card';
4864 return '<span class="fa fa-'.$brand.
' fa-fw'.($morecss ?
' '.$morecss :
'').
'"></span>';
4875 function img_mime($file, $titlealt =
'', $morecss =
'')
4877 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
4883 if (empty($titlealt)) {
4884 $titlealt =
'Mime type: '.$mimetype;
4888 return '<i class="fa fa-'.$mimefa.
' paddingright'.($morecss ?
' '.$morecss :
'').
'"'.($titlealt ?
' title="'.$titlealt.
'"' :
'').
'></i>';
4901 global $conf, $langs;
4903 if ($titlealt ==
'default') {
4904 $titlealt = $langs->trans(
'Search');
4907 $img =
img_picto($titlealt,
'search.png', $other,
false, 1);
4909 $input =
'<input type="image" class="liste_titre" name="button_search" src="'.$img.
'" ';
4910 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
4924 global $conf, $langs;
4926 if ($titlealt ==
'default') {
4927 $titlealt = $langs->trans(
'Search');
4930 $img =
img_picto($titlealt,
'searchclear.png', $other,
false, 1);
4932 $input =
'<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.
'" ';
4933 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
4949 function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin =
'1', $morecss =
'hideonsmartphone', $textfordropdown =
'')
4951 global $conf, $langs;
4953 if ($infoonimgalt) {
4954 $result =
img_picto($text,
'info',
'class="'.($morecss ?
' '.$morecss :
'').
'"');
4956 if (empty($conf->use_javascript_ajax)) {
4957 $textfordropdown =
'';
4960 $class = (empty($admin) ?
'undefined' : ($admin ==
'1' ?
'info' : $admin));
4961 $result = ($nodiv ?
'' :
'<div class="'.$class.($morecss ?
' '.$morecss :
'').($textfordropdown ?
' hidden' :
'').
'">').
'<span class="fa fa-info-circle" title="'.
dol_escape_htmltag($admin ? $langs->trans(
'InfoAdmin') : $langs->trans(
'Note')).
'"></span> '.$text.($nodiv ?
'' :
'</div>');
4963 if ($textfordropdown) {
4964 $tmpresult =
'<span class="'.$class.
'text opacitymedium cursorpointer">'.$langs->trans($textfordropdown).
' '.
img_picto($langs->trans($textfordropdown),
'1downarrow').
'</span>';
4965 $tmpresult .=
'<script type="text/javascript">
4966 jQuery(document).ready(function() {
4967 jQuery(".'.$class.
'text").click(function() {
4968 console.log("toggle text");
4969 jQuery(".'.$class.
'").toggle();
4974 $result = $tmpresult.$result;
4995 global $conf, $langs, $argv;
4996 global $dolibarr_main_prod;
5003 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
5005 $langs->load(
"main");
5009 $langs->loadLangs(array(
'main',
'errors'));
5011 if ($_SERVER[
'DOCUMENT_ROOT']) {
5012 $out .= $langs->trans(
"DolibarrHasDetectedError").
".<br>\n";
5014 $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";
5016 $out .= $langs->trans(
"InformationToHelpDiagnose").
":<br>\n";
5018 $out .=
"<b>".$langs->trans(
"Date").
":</b> ".
dol_print_date(time(),
'dayhourlog').
"<br>\n";
5019 $out .=
"<b>".$langs->trans(
"Dolibarr").
":</b> ".DOL_VERSION.
" - https://www.dolibarr.org<br>\n";
5020 if (isset($conf->global->MAIN_FEATURES_LEVEL)) {
5021 $out .=
"<b>".$langs->trans(
"LevelOfFeature").
":</b> ".
getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
"<br>\n";
5023 if (function_exists(
"phpversion")) {
5024 $out .=
"<b>".$langs->trans(
"PHP").
":</b> ".phpversion().
"<br>\n";
5026 $out .=
"<b>".$langs->trans(
"Server").
":</b> ".(isset($_SERVER[
"SERVER_SOFTWARE"]) ?
dol_htmlentities($_SERVER[
"SERVER_SOFTWARE"], ENT_COMPAT) :
'').
"<br>\n";
5027 if (function_exists(
"php_uname")) {
5028 $out .=
"<b>".$langs->trans(
"OS").
":</b> ".php_uname().
"<br>\n";
5030 $out .=
"<b>".$langs->trans(
"UserAgent").
":</b> ".(isset($_SERVER[
"HTTP_USER_AGENT"]) ?
dol_htmlentities($_SERVER[
"HTTP_USER_AGENT"], ENT_COMPAT) :
'').
"<br>\n";
5032 $out .=
"<b>".$langs->trans(
"RequestedUrl").
":</b> ".
dol_htmlentities($_SERVER[
"REQUEST_URI"], ENT_COMPAT).
"<br>\n";
5033 $out .=
"<b>".$langs->trans(
"Referer").
":</b> ".(isset($_SERVER[
"HTTP_REFERER"]) ?
dol_htmlentities($_SERVER[
"HTTP_REFERER"], ENT_COMPAT) :
'').
"<br>\n";
5034 $out .=
"<b>".$langs->trans(
"MenuManager").
":</b> ".(isset($conf->standard_menu) ?
dol_htmlentities($conf->standard_menu, ENT_COMPAT) :
'').
"<br>\n";
5036 $syslog .=
"url=".dol_escape_htmltag($_SERVER[
"REQUEST_URI"]);
5037 $syslog .=
", query_string=".dol_escape_htmltag($_SERVER[
"QUERY_STRING"]);
5040 $out .=
'> '.$langs->transnoentities(
"ErrorInternalErrorDetected").
":\n".$argv[0].
"\n";
5041 $syslog .=
"pid=".dol_getmypid();
5044 if (!empty($conf->modules)) {
5045 $out .=
"<b>".$langs->trans(
"Modules").
":</b> ".join(
', ', $conf->modules).
"<br>\n";
5048 if (is_object($db)) {
5049 if ($_SERVER[
'DOCUMENT_ROOT']) {
5050 $out .=
"<b>".$langs->trans(
"DatabaseTypeManager").
":</b> ".$db->type.
"<br>\n";
5051 $out .=
"<b>".$langs->trans(
"RequestLastAccessInError").
":</b> ".($db->lastqueryerror() ?
dol_escape_htmltag($db->lastqueryerror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5052 $out .=
"<b>".$langs->trans(
"ReturnCodeLastAccessInError").
":</b> ".($db->lasterrno() ?
dol_escape_htmltag($db->lasterrno()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5053 $out .=
"<b>".$langs->trans(
"InformationLastAccessInError").
":</b> ".($db->lasterror() ?
dol_escape_htmltag($db->lasterror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5058 $out .=
'> '.$langs->transnoentities(
"DatabaseTypeManager").
":\n".$db->type.
"\n";
5059 $out .=
'> '.$langs->transnoentities(
"RequestLastAccessInError").
":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5060 $out .=
'> '.$langs->transnoentities(
"ReturnCodeLastAccessInError").
":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5061 $out .=
'> '.$langs->transnoentities(
"InformationLastAccessInError").
":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5063 $syslog .=
", sql=".$db->lastquery();
5064 $syslog .=
", db_error=".$db->lasterror();
5067 if ($error || $errors) {
5068 $langs->load(
"errors");
5071 if (is_array($error) && is_array($errors)) {
5072 $errors = array_merge($error, $errors);
5073 } elseif (is_array($error)) {
5075 } elseif (is_array($errors)) {
5076 $errors = array_merge(array($error), $errors);
5078 $errors = array_merge(array($error), array($errors));
5081 foreach ($errors as $msg) {
5085 if ($_SERVER[
'DOCUMENT_ROOT']) {
5089 $out .=
'> '.$langs->transnoentities(
"Message").
":\n".$msg.
"\n";
5091 $syslog .=
", msg=".$msg;
5094 if (empty($dolibarr_main_prod) && $_SERVER[
'DOCUMENT_ROOT'] && function_exists(
'xdebug_print_function_stack') && function_exists(
'xdebug_call_file')) {
5095 xdebug_print_function_stack();
5096 $out .=
'<b>XDebug informations:</b>'.
"<br>\n";
5097 $out .=
'File: '.xdebug_call_file().
"<br>\n";
5098 $out .=
'Line: '.xdebug_call_line().
"<br>\n";
5099 $out .=
'Function: '.xdebug_call_function().
"<br>\n";
5104 if (!headers_sent()) {
5105 if (function_exists(
'top_httphead')) {
5108 http_response_code(500);
5111 if (empty($dolibarr_main_prod)) {
5114 if (empty($langs->defaultlang)) {
5115 $langs->setDefaultLang();
5117 $langs->loadLangs(array(
"main",
"errors"));
5119 print
'This website or feature is currently temporarly not available or failed after a technical error.<br><br>This may be due to a maintenance operation. Current status of operation ('.dol_print_date(
dol_now(),
'dayhourrfc').
') are on next line...<br><br>'.
"\n";
5120 print $langs->trans(
"DolibarrHasDetectedError").
'. ';
5121 print $langs->trans(
"YouCanSetOptionDolibarrMainProdToZero");
5122 define(
"MAIN_CORE_ERROR", 1);
5138 function dol_print_error_email($prefixcode, $errormessage =
'', $errormessages = array(), $morecss =
'error', $email =
'')
5140 global $langs, $conf;
5142 if (empty($email)) {
5143 $email = $conf->global->MAIN_INFO_SOCIETE_MAIL;
5146 $langs->load(
"errors");
5149 print
'<br><div class="center login_main_message"><div class="'.$morecss.
'">';
5150 print $langs->trans(
"ErrorContactEMail", $email, $prefixcode.dol_print_date($now,
'%Y%m%d%H%M%S'));
5151 if ($errormessage) {
5152 print
'<br><br>'.$errormessage;
5154 if (is_array($errormessages) && count($errormessages)) {
5155 foreach ($errormessages as $mesgtoshow) {
5156 print
'<br><br>'.$mesgtoshow;
5159 print
'</div></div>';
5178 function print_liste_field_titre($name, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $tooltip =
"", $forcenowrapcolumntitle = 0)
5180 print
getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip, $forcenowrapcolumntitle);
5201 function getTitleFieldOfList($name, $thead = 0, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $disablesortlink = 0, $tooltip =
'', $forcenowrapcolumntitle = 0)
5203 global $conf, $langs,
$form;
5206 if ($moreattrib ==
'class="right"') {
5207 $prefix .=
'right ';
5210 $sortorder = strtoupper($sortorder);
5219 $tmpsortfield = explode(
',', $sortfield);
5220 $sortfield1 = trim($tmpsortfield[0]);
5221 $tmpfield = explode(
',', $field);
5222 $field1 = trim($tmpfield[0]);
5224 if (empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && empty($forcenowrapcolumntitle)) {
5225 $prefix =
'wrapcolumntitle '.$prefix;
5231 $liste_titre =
'liste_titre';
5232 if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace(
"/^[^\.]+\./",
"", $field1))) {
5233 $liste_titre =
'liste_titre_sel';
5236 $tagstart =
'<'.$tag.
' class="'.$prefix.$liste_titre.
'" '.$moreattrib;
5238 $tagstart .= ($name && empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && empty($forcenowrapcolumntitle) && !
dol_textishtml($name)) ?
' title="'.
dol_escape_htmltag($langs->trans($name)).
'"' :
'';
5241 if (empty($thead) && $field && empty($disablesortlink)) {
5242 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
5243 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
5244 $options = preg_replace(
'/&+/i',
'&', $options);
5245 if (!preg_match(
'/^&/', $options)) {
5246 $options =
'&'.$options;
5249 $sortordertouseinlink =
'';
5250 if ($field1 != $sortfield1) {
5251 if (preg_match(
'/^DESC/i', $sortorder)) {
5252 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
5254 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
5257 if (preg_match(
'/^ASC/i', $sortorder)) {
5258 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
5260 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
5263 $sortordertouseinlink = preg_replace(
'/,$/',
'', $sortordertouseinlink);
5264 $out .=
'<a class="reposition" href="'.$file.
'?sortfield='.$field.
'&sortorder='.$sortordertouseinlink.
'&begin='.$begin.$options.
'"';
5270 if (preg_match(
'/:\w+$/', $tooltip)) {
5271 $tmptooltip = explode(
':', $tooltip);
5273 $tmptooltip = array($tooltip);
5275 $out .=
$form->textwithpicto($langs->trans($name), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.str_replace(
'.',
'_', $field).
'_'.$tmptooltip[1]));
5277 $out .= $langs->trans($name);
5280 if (empty($thead) && $field && empty($disablesortlink)) {
5284 if (empty($thead) && $field) {
5285 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
5286 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
5287 $options = preg_replace(
'/&+/i',
'&', $options);
5288 if (!preg_match(
'/^&/', $options)) {
5289 $options =
'&'.$options;
5292 if (!$sortorder || $field1 != $sortfield1) {
5296 if (preg_match(
'/^DESC/', $sortorder)) {
5299 $sortimg .=
'<span class="nowrap">'.img_up(
"Z-A", 0,
'paddingright').
'</span>';
5301 if (preg_match(
'/^ASC/', $sortorder)) {
5304 $sortimg .=
'<span class="nowrap">'.img_down(
"A-Z", 0,
'paddingright').
'</span>';
5309 $tagend =
'</'.$tag.
'>';
5311 $out = $tagstart.$sortimg.$out.$tagend;
5326 dol_syslog(__FUNCTION__.
" is deprecated", LOG_WARNING);
5328 print
'<div class="titre">'.$title.
'</div>';
5360 function load_fiche_titre($titre, $morehtmlright =
'', $picto =
'generic', $pictoisfullpath = 0, $id =
'', $morecssontable =
'', $morehtmlcenter =
'')
5366 if ($picto ==
'setup') {
5371 $return .=
'<table '.($id ?
'id="'.$id.
'" ' :
'').
'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ?
' '.$morecssontable :
'').
'">';
5372 $return .=
'<tr class="titre">';
5374 $return .=
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).
'</td>';
5376 $return .=
'<td class="nobordernopadding valignmiddle col-title">';
5377 $return .=
'<div class="titre inline-block">'.$titre.
'</div>';
5380 $return .=
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
5383 $return .=
'<td class="nobordernopadding titre_right wordbreakimp right valignmiddle col-right">'.$morehtmlright.
'</td>';
5385 $return .=
'</tr></table>'.
"\n";
5413 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 =
'')
5415 global $conf, $langs;
5418 $savtotalnboflines = $totalnboflines;
5419 $totalnboflines = abs((
int) $totalnboflines);
5421 if ($picto ==
'setup') {
5422 $picto =
'title_setup.png';
5424 if (($conf->browser->name ==
'ie') && $picto ==
'generic') {
5425 $picto =
'title.gif';
5428 $limit = $conf->liste_limit;
5430 if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
5438 print
"<!-- Begin title -->\n";
5439 print
'<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ?
' '.$morecss :
'').
'"><tr>';
5443 if ($picto && $titre) {
5444 print
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath).
'</td>';
5446 print
'<td class="nobordernopadding valignmiddle col-title">';
5447 print
'<div class="titre inline-block">'.$titre;
5448 if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines !=
'') {
5449 print
'<span class="opacitymedium colorblack paddingleft">('.$totalnboflines.
')</span>';
5451 print
'</div></td>';
5454 if ($morehtmlcenter) {
5455 print
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
5459 print
'<td class="nobordernopadding valignmiddle right col-right">';
5460 print
'<input type="hidden" name="pageplusoneold" value="'.((int) $page + 1).
'">';
5462 $options .=
"&sortfield=".urlencode($sortfield);
5465 $options .=
"&sortorder=".urlencode($sortorder);
5469 if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
5470 if ($totalnboflines) {
5472 $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 0);
5475 $nbpages = ceil($totalnboflines / $limit);
5479 $cpt = ($page - $maxnbofpage);
5485 if (empty($pagenavastextinput)) {
5486 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page=0'.$options.
'">1</a></li>';
5488 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
5489 } elseif ($cpt == 2) {
5490 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page=1'.$options.
'">2</a></li>';
5496 if ($pagenavastextinput) {
5497 if ($cpt == $page) {
5498 $pagelist .=
'<li class="pagination"><input type="text" class="width25 center pageplusone" name="pageplusone" value="'.($page + 1).
'"></li>';
5502 if ($cpt == $page) {
5503 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
'</span></li>';
5505 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.$cpt.$options.
'">'.($cpt + 1).
'</a></li>';
5509 }
while ($cpt < $nbpages && $cpt <= ($page + $maxnbofpage));
5511 if (empty($pagenavastextinput)) {
5512 if ($cpt < $nbpages) {
5513 if ($cpt < $nbpages - 2) {
5514 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
5515 } elseif ($cpt == $nbpages - 2) {
5516 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.($nbpages - 2).$options.
'">'.($nbpages - 1).
'</a></li>';
5518 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
5522 $pagelist .=
'<li class="pagination paginationlastpage"><a href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
5525 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
"</li>";
5529 if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
5530 print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow);
5534 if ($pagenavastextinput) {
5540 print
'</tr></table>'.
"\n";
5541 print
"<!-- End title -->\n\n";
5559 function print_fleche_navigation($page, $file, $options =
'', $nextpage = 0, $betweenarrows =
'', $afterarrows =
'', $limit = -1, $totalnboflines = 0, $hideselectlimit = 0, $beforearrows =
'')
5561 global $conf, $langs;
5563 print
'<div class="pagination"><ul>';
5564 if ($beforearrows) {
5565 print
'<li class="paginationbeforearrows">';
5566 print $beforearrows;
5569 if ((
int) $limit > 0 && empty($hideselectlimit)) {
5570 $pagesizechoices =
'10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000';
5571 $pagesizechoices .=
',5000:5000,10000:10000,20000:20000';
5574 if (!empty($conf->global->MAIN_PAGESIZE_CHOICES)) {
5575 $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES;
5578 print
'<li class="pagination">';
5579 print
'<select class="flat selectlimit" name="limit" title="'.dol_escape_htmltag($langs->trans(
"MaxNbOfRecordPerPage")).
'">';
5580 $tmpchoice = explode(
',', $pagesizechoices);
5581 $tmpkey = $limit.
':'.$limit;
5582 if (!in_array($tmpkey, $tmpchoice)) {
5583 $tmpchoice[] = $tmpkey;
5585 $tmpkey = $conf->liste_limit.
':'.$conf->liste_limit;
5586 if (!in_array($tmpkey, $tmpchoice)) {
5587 $tmpchoice[] = $tmpkey;
5589 asort($tmpchoice, SORT_NUMERIC);
5590 foreach ($tmpchoice as $val) {
5592 $tmp = explode(
':', $val);
5595 if ($key !=
'' && $val !=
'') {
5596 if ((
int) $key == (
int) $limit) {
5597 $selected =
' selected="selected"';
5599 print
'<option name="'.$key.
'"'.$selected.
'>'.
dol_escape_htmltag($val).
'</option>'.
"\n";
5603 if ($conf->use_javascript_ajax) {
5604 print
'<!-- JS CODE TO ENABLE select limit to launch submit of page -->
5606 jQuery(document).ready(function () {
5607 jQuery(".selectlimit").change(function() {
5608 console.log("Change limit. Send submit");
5609 $(this).parents(\'form:first\').submit();
5618 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>';
5620 if ($betweenarrows) {
5621 print
'<!--<div class="betweenarrows nowraponall inline-block">-->';
5622 print $betweenarrows;
5623 print
'<!--</div>-->';
5625 if ($nextpage > 0) {
5626 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>';
5629 print
'<li class="paginationafterarrows">';
5633 print
'</ul></div>'.
"\n";
5648 function vatrate($rate, $addpercent =
false, $info_bits = 0, $usestarfornpr = 0, $html = 0)
5652 if (preg_match(
'/%/', $rate)) {
5653 $rate = str_replace(
'%',
'', $rate);
5657 if (preg_match(
'/\((.*)\)/', $rate, $reg)) {
5658 $morelabel =
' ('.$reg[1].
')';
5659 $rate = preg_replace(
'/\s*'.preg_quote($morelabel,
'/').
'/',
'', $rate);
5660 $morelabel =
' '.($html ?
'<span class="opacitymedium">' :
'').
'('.$reg[1].
')'.($html ?
'</span>' :
'');
5662 if (preg_match(
'/\*/', $rate)) {
5663 $rate = str_replace(
'*',
'', $rate);
5668 if (!preg_match(
'/\//', $rate)) {
5669 $ret =
price($rate, 0,
'', 0, 0).($addpercent ?
'%' :
'');
5672 $ret = $rate.($addpercent ?
'%' :
'');
5674 if (($info_bits & 1) && $usestarfornpr >= 0) {
5697 function price($amount,
$form = 0, $outlangs =
'', $trunc = 1, $rounding = -1, $forcerounding = -1, $currency_code =
'')
5699 global $langs, $conf;
5702 if (empty($amount)) {
5705 $amount = (is_numeric($amount) ? $amount : 0);
5706 if ($rounding < 0) {
5707 $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
5709 $nbdecimal = $rounding;
5711 if ($outlangs ===
'none') {
5721 if (!is_object($outlangs)) {
5725 if ($outlangs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
5726 $dec = $outlangs->transnoentitiesnoconv(
"SeparatorDecimal");
5728 if ($outlangs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
5729 $thousand = $outlangs->transnoentitiesnoconv(
"SeparatorThousand");
5731 if ($thousand ==
'None') {
5733 } elseif ($thousand ==
'Space') {
5740 $amount = str_replace(
',',
'.', $amount);
5742 $datas = explode(
'.', $amount);
5743 $decpart = isset($datas[1]) ? $datas[1] :
'';
5744 $decpart = preg_replace(
'/0+$/i',
'', $decpart);
5753 if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN) {
5754 $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_SHOWN;
5755 if (preg_match(
'/\.\.\./i', $conf->global->MAIN_MAX_DECIMALS_SHOWN)) {
5762 if ((
string) $forcerounding !=
'-1') {
5763 if ($forcerounding ===
'MU') {
5764 $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_UNIT;
5765 } elseif ($forcerounding ===
'MT') {
5766 $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_TOT;
5767 } elseif ($forcerounding >= 0) {
5768 $nbdecimal = $forcerounding;
5773 $output = number_format($amount, $nbdecimal, $dec, $thousand);
5775 $output = preg_replace(
'/\s/',
' ', $output);
5776 $output = preg_replace(
'/\'/',
''', $output);
5779 $cursymbolbefore = $cursymbolafter =
'';
5780 if ($currency_code && is_object($outlangs)) {
5781 if ($currency_code ==
'auto') {
5782 $currency_code = $conf->currency;
5785 $listofcurrenciesbefore = array(
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD',
'CRC');
5786 $listoflanguagesbefore = array(
'nl_NL');
5787 if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) {
5788 $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
5790 $tmpcur = $outlangs->getCurrencySymbol($currency_code);
5791 $cursymbolafter .= ($tmpcur == $currency_code ?
' '.$tmpcur : $tmpcur);
5794 $output = $cursymbolbefore.$output.$end.($cursymbolafter ?
' ' :
'').$cursymbolafter;
5825 global $langs, $conf;
5828 if (is_null($amount)) {
5837 if (is_null($langs)) {
5841 if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
5842 $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
5844 if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
5845 $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
5848 if ($thousand ==
'None') {
5850 } elseif ($thousand ==
'Space') {
5858 if (!is_numeric($amount)) {
5859 $amount = preg_replace(
'/[a-zA-Z\/\\\*\(\)<>\_]/',
'', $amount);
5862 if ($option == 2 && $thousand ==
'.' && preg_match(
'/\.(\d\d\d)$/', (
string) $amount)) {
5863 $amount = str_replace($thousand,
'', $amount);
5869 if (is_numeric($amount)) {
5871 $temps = sprintf(
"%0.10F", $amount - intval($amount));
5872 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
5874 $amount = number_format($amount, $nbofdec, $dec, $thousand);
5879 if ($thousand !=
',' && $thousand !=
'.') {
5880 $amount = str_replace(
',',
'.', $amount);
5883 $amount = str_replace(
' ',
'', $amount);
5884 $amount = str_replace($thousand,
'', $amount);
5885 $amount = str_replace($dec,
'.', $amount);
5887 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
5893 $nbofdectoround =
'';
5894 if ($rounding ==
'MU') {
5895 $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT;
5896 } elseif ($rounding ==
'MT') {
5897 $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT;
5898 } elseif ($rounding ==
'MS') {
5899 $nbofdectoround = isset($conf->global->MAIN_MAX_DECIMALS_STOCK) ? $conf->global->MAIN_MAX_DECIMALS_STOCK : 5;
5900 } elseif ($rounding ==
'CU') {
5901 $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_UNIT, 8);
5902 } elseif ($rounding ==
'CT') {
5903 $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_TOT, 8);
5904 } elseif (is_numeric($rounding)) {
5905 $nbofdectoround = (int) $rounding;
5910 $amount = round(is_string($amount) ? (
float) $amount : $amount, $nbofdectoround);
5912 return 'ErrorBadParameterProvidedToFunction';
5918 if (is_numeric($amount)) {
5920 $temps = sprintf(
"%0.10F", $amount - intval($amount));
5921 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
5923 $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand);
5929 if ($thousand !=
',' && $thousand !=
'.') {
5930 $amount = str_replace(
',',
'.', $amount);
5933 $amount = str_replace(
' ',
'', $amount);
5934 $amount = str_replace($thousand,
'', $amount);
5935 $amount = str_replace($dec,
'.', $amount);
5937 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
5955 function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput =
'no', $use_short_label = 0)
5957 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
5959 if (($forceunitoutput ==
'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
5960 $dimension = $dimension * 1000000;
5962 } elseif (($forceunitoutput ==
'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) {
5963 $dimension = $dimension * 1000;
5965 } elseif (($forceunitoutput ==
'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) {
5966 $dimension = $dimension / 1000000;
5968 } elseif (($forceunitoutput ==
'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) {
5969 $dimension = $dimension / 1000;
5985 $ret =
price($dimension, 0, $outputlangs, 0, 0, $round);
5986 $ret .=
' '.measuringUnitString(0, $type, $unit, $use_short_label, $outputlangs);
6004 function get_localtax($vatrate, $local, $thirdparty_buyer =
"", $thirdparty_seller =
"", $vatnpr = 0)
6006 global $db, $conf, $mysoc;
6008 if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) {
6009 $thirdparty_seller = $mysoc;
6012 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);
6014 $vatratecleaned = $vatrate;
6016 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
6017 $vatratecleaned = trim($reg[1]);
6018 $vatratecode = $reg[2];
6027 if ($mysoc->country_code ==
'ES') {
6029 if (!$mysoc->localtax1_assuj || (
string) $vatratecleaned ==
"0") {
6032 if ($thirdparty_seller->id == $mysoc->id) {
6033 if (!$thirdparty_buyer->localtax1_assuj) {
6037 if (!$thirdparty_seller->localtax1_assuj) {
6045 if (!$mysoc->localtax2_assuj) {
6048 if ($thirdparty_seller->id == $mysoc->id) {
6049 if (!$thirdparty_buyer->localtax2_assuj) {
6053 if (!$thirdparty_seller->localtax2_assuj) {
6059 if ($local == 1 && !$thirdparty_seller->localtax1_assuj) {
6062 if ($local == 2 && !$thirdparty_seller->localtax2_assuj) {
6068 if (in_array($mysoc->country_code, array(
'ES'))) {
6069 $conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY = 1;
6073 if (!empty($conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY)) {
6075 if ($thirdparty_seller != $mysoc) {
6077 return $thirdparty_seller->localtax1_value;
6081 return $conf->global->MAIN_INFO_VALUE_LOCALTAX1;
6086 if ($thirdparty_seller != $mysoc) {
6089 return $thirdparty_seller->localtax2_value;
6092 if (in_array($mysoc->country_code, array(
'ES'))) {
6093 return $thirdparty_buyer->localtax2_value;
6095 return $conf->global->MAIN_INFO_VALUE_LOCALTAX2;
6102 $sql =
"SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
6103 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
6104 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdparty_seller->country_code).
"'";
6105 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
6106 if (!empty($vatratecode)) {
6107 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
6109 $sql .=
" AND t.recuperableonly = '".$db->escape($vatnpr).
"'";
6112 $resql = $db->query($sql);
6115 $obj = $db->fetch_object(
$resql);
6118 return $obj->localtax1;
6119 } elseif ($local == 2) {
6120 return $obj->localtax2;
6141 $valors = explode(
":", $tax);
6143 if (count($valors) > 1) {
6160 $sql =
" SELECT t.localtax".$local.
" as localtax";
6161 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t INNER JOIN ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid = t.fk_pays";
6162 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.active = 1 AND t.taux = (";
6163 $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";
6164 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND tt.active = 1)";
6165 $sql .=
" AND t.localtax".$local.
"_type <> '0'";
6166 $sql .=
" ORDER BY t.rowid DESC";
6168 $resql = $db->query($sql);
6170 $obj = $db->fetch_object(
$resql);
6171 return $obj->localtax;
6191 function getTaxesFromId($vatrate, $buyer =
null, $seller =
null, $firstparamisid = 1)
6195 dol_syslog(
"getTaxesFromId vat id or rate = ".$vatrate);
6198 $sql =
"SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy,";
6199 $sql .=
" t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
6200 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
6201 if ($firstparamisid) {
6202 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
6204 $vatratecleaned = $vatrate;
6207 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
6208 $vatratecleaned = $reg[1];
6209 $vatratecode = $reg[2];
6212 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
6215 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($seller->country_code).
"'";
6216 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
6218 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
6222 $resql = $db->query($sql);
6224 $obj = $db->fetch_object(
$resql);
6227 'rowid'=>$obj->rowid,
6230 'localtax1'=>$obj->localtax1,
6231 'localtax1_type'=>$obj->localtax1_type,
6232 'localtax2'=>$obj->localtax2,
6233 'localtax2_type'=>$obj->localtax2_type,
6235 'accountancy_code_sell'=>$obj->accountancy_code_sell,
6236 'accountancy_code_buy'=>$obj->accountancy_code_buy
6268 dol_syslog(
"getLocalTaxesFromRate vatrate=".$vatrate.
" local=".$local);
6271 $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";
6272 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
6273 if ($firstparamisid) {
6274 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
6276 $vatratecleaned = $vatrate;
6279 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
6280 $vatratecleaned = $reg[1];
6281 $vatratecode = $reg[2];
6284 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
6285 if (!empty($mysoc) && $mysoc->country_code ==
'ES') {
6286 $countrycodetouse = ((empty($buyer) || empty($buyer->country_code)) ? $mysoc->country_code : $buyer->country_code);
6287 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
6289 $countrycodetouse = ((empty($seller) || empty($seller->country_code)) ? $mysoc->country_code : $seller->country_code);
6290 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
6292 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
6294 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
6298 $resql = $db->query($sql);
6300 $obj = $db->fetch_object(
$resql);
6303 $vateratestring = $obj->rate.($obj->code ?
' ('.$obj->code.
')' :
'');
6306 return array($obj->localtax1_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
6307 } elseif ($local == 2) {
6308 return array($obj->localtax2_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
6310 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);
6330 global $db, $conf, $mysoc;
6332 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
6340 $product->fetch($idprod);
6342 if ($mysoc->country_code == $thirdpartytouse->country_code) {
6344 if ($idprodfournprice > 0) {
6345 $result = $product->get_buyprice($idprodfournprice, 0, 0, 0);
6347 $ret = $product->vatrate_supplier;
6348 if ($product->default_vat_code_supplier) {
6349 $ret .=
' ('.$product->default_vat_code_supplier.
')';
6355 $ret = $product->tva_tx;
6356 if ($product->default_vat_code) {
6357 $ret .=
' ('.$product->default_vat_code.
')';
6368 if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
6370 $sql =
"SELECT t.taux as vat_rate, t.code as default_vat_code";
6371 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
6372 $sql .=
" WHERE t.active = 1 AND t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdpartytouse->country_code).
"'";
6373 $sql .=
" ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC";
6374 $sql .= $db->plimit(1);
6376 $resql = $db->query($sql);
6378 $obj = $db->fetch_object(
$resql);
6380 $ret = $obj->vat_rate;
6381 if ($obj->default_vat_code) {
6382 $ret .=
' ('.$obj->default_vat_code.
')';
6394 if ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS !=
'none') {
6395 $defaulttx = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
6406 dol_syslog(
"get_product_vat_for_country: ret=".$ret);
6423 if (!class_exists(
'Product')) {
6424 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
6433 $result = $product->fetch($idprod);
6435 if ($mysoc->country_code == $thirdpartytouse->country_code) {
6449 $sql =
"SELECT taux as vat_rate, localtax1, localtax2";
6450 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
6451 $sql .=
" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdpartytouse->country_code).
"'";
6452 $sql .=
" ORDER BY t.taux DESC, t.recuperableonly ASC";
6453 $sql .= $db->plimit(1);
6455 $resql = $db->query($sql);
6457 $obj = $db->fetch_object(
$resql);
6460 $ret = $obj->localtax1;
6461 } elseif ($local == 2) {
6462 $ret = $obj->localtax2;
6470 dol_syslog(
"get_product_localtax_for_country: ret=".$ret);
6494 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
6497 $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;
6499 $seller_country_code = $thirdparty_seller->country_code;
6500 $seller_in_cee =
isInEEC($thirdparty_seller);
6502 $buyer_country_code = $thirdparty_buyer->country_code;
6503 $buyer_in_cee =
isInEEC($thirdparty_buyer);
6505 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 :
''));
6509 if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
6510 if ($seller_in_cee && $buyer_in_cee) {
6511 $isacompany = $thirdparty_buyer->
isACompany();
6512 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
6513 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
6527 if (!$seller_use_vat) {
6535 if (($seller_country_code == $buyer_country_code)
6536 || (in_array($seller_country_code, array(
'FR',
'MC')) && in_array($buyer_country_code, array(
'FR',
'MC')))) {
6546 if (($seller_in_cee && $buyer_in_cee)) {
6547 $isacompany = $thirdparty_buyer->
isACompany();
6548 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
6549 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
6566 if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC) && empty($buyer_in_cee)) {
6567 $isacompany = $thirdparty_buyer->
isACompany();
6595 if ($idprodfournprice > 0) {
6596 if (!class_exists(
'ProductFournisseur')) {
6597 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
6600 $prodprice->fetch_product_fournisseur_price($idprodfournprice);
6601 return $prodprice->fourn_tva_npr;
6602 } elseif ($idprod > 0) {
6603 if (!class_exists(
'Product')) {
6604 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
6607 $prod->fetch($idprod);
6608 return $prod->tva_npr;
6631 if (!is_object($thirdparty_seller)) {
6634 if (!is_object($thirdparty_buyer)) {
6639 if ($mysoc->country_code ==
'ES') {
6640 if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) {
6645 if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) {
6648 if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj ==
'localtax1off') {
6652 } elseif ($local == 2) {
6654 if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) {
6657 if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj ==
'localtax2off') {
6662 if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
6677 function yn($yesno, $case = 1, $color = 0)
6681 $result =
'unknown';
6683 if ($yesno == 1 || strtolower($yesno) ==
'yes' || strtolower($yesno) ==
'true') {
6684 $result = $langs->trans(
'yes');
6685 if ($case == 1 || $case == 3) {
6686 $result = $langs->trans(
"Yes");
6689 $result =
'<input type="checkbox" value="1" checked disabled>';
6692 $result =
'<input type="checkbox" value="1" checked disabled> '.$result;
6696 } elseif ($yesno == 0 || strtolower($yesno) ==
'no' || strtolower($yesno) ==
'false') {
6697 $result = $langs->trans(
"no");
6698 if ($case == 1 || $case == 3) {
6699 $result = $langs->trans(
"No");
6702 $result =
'<input type="checkbox" value="0" disabled>';
6705 $result =
'<input type="checkbox" value="0" disabled> '.$result;
6711 $classname =
'error';
6715 return '<span class="'.$classname.
'">'.$result.
'</span>';
6735 function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart =
'')
6739 if (empty($modulepart) && !empty($object->module)) {
6740 $modulepart = $object->module;
6745 $arrayforoldpath = array(
'cheque',
'category',
'holiday',
'supplier_invoice',
'invoice_supplier',
'mailing',
'supplier_payment');
6747 $arrayforoldpath[] =
'product';
6749 if (!empty($level) && in_array($modulepart, $arrayforoldpath)) {
6751 if (empty($alpha)) {
6752 $num = preg_replace(
'/([^0-9])/i',
'', $num);
6754 $num = preg_replace(
'/^.*\-/i',
'', $num);
6756 $num = substr(
"000".$num, -$level);
6758 $path = substr($num, 0, 1);
6761 $path = substr($num, 1, 1).
'/'.substr($num, 0, 1);
6764 $path = substr($num, 2, 1).
'/'.substr($num, 1, 1).
'/'.substr($num, 0, 1);
6774 if (empty($withoutslash) && !empty($path)) {
6793 dol_syslog(
"functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
6796 if (@is_dir($dir_osencoded)) {
6804 if (!empty($dataroot)) {
6806 $dir = str_replace($dataroot.
'/',
'', $dir);
6807 $ccdir = $dataroot.
'/';
6810 $cdir = explode(
"/", $dir);
6811 $num = count($cdir);
6812 for ($i = 0; $i < $num; $i++) {
6814 $ccdir .=
'/'.$cdir[$i];
6816 $ccdir .= $cdir[$i];
6818 if (preg_match(
"/^.:$/", $ccdir, $regs)) {
6826 if (!@is_dir($ccdir_osencoded)) {
6827 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG);
6830 $dirmaskdec = octdec((
string) $newmask);
6831 if (empty($newmask)) {
6832 $dirmaskdec = empty($conf->global->MAIN_UMASK) ? octdec(
'0755') : octdec($conf->global->MAIN_UMASK);
6834 $dirmaskdec |= octdec(
'0111');
6835 if (!@mkdir($ccdir_osencoded, $dirmaskdec)) {
6837 dol_syslog(
"functions.lib::dol_mkdir: Fails to create directory '".$ccdir.
"' or directory already exists.", LOG_WARNING);
6840 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' created", LOG_DEBUG);
6849 return ($nberr ? -$nberr : $nbcreated);
6860 return '<span class="fieldrequired">*</span>';
6880 function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
'UTF-8', $strip_tags = 0, $removedoublespaces = 1)
6882 if (is_null($stringtoclean)) {
6886 if ($removelinefeed == 2) {
6887 $stringtoclean = preg_replace(
'/<br[^>]*>(\n|\r)+/ims',
'<br>', $stringtoclean);
6889 $temp = preg_replace(
'/<br[^>]*>/i',
"\n", $stringtoclean);
6894 $temp = str_replace(
'< ',
'__ltspace__', $temp);
6897 $temp = strip_tags($temp);
6900 $pattern =
"/<[^<>]+>/";
6907 $tempbis = str_replace(
'<>',
'', $temp);
6908 $tempbis = preg_replace($pattern,
'', $tempbis);
6910 }
while ($tempbis != $temp);
6915 $temp = preg_replace(
'/<+([a-z]+)/i',
'\1', $temp);
6921 if ($removelinefeed == 1) {
6922 $temp = str_replace(array(
"\r\n",
"\r",
"\n"),
" ", $temp);
6926 if ($removedoublespaces) {
6927 while (strpos($temp,
" ")) {
6928 $temp = str_replace(
" ",
" ", $temp);
6932 $temp = str_replace(
'__ltspace__',
'< ', $temp);
6951 function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $removeclassattribute = 1, $cleanalsojavascript = 0, $allowiframe = 0, $allowed_tags = array())
6953 if (empty($allowed_tags)) {
6954 $allowed_tags = array(
6955 "html",
"head",
"meta",
"body",
"article",
"a",
"abbr",
"b",
"blockquote",
"br",
"cite",
"div",
"dl",
"dd",
"dt",
"em",
"font",
"img",
"ins",
"hr",
"i",
"li",
"link",
6956 "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"
6959 $allowed_tags[] =
"comment";
6961 $allowed_tags[] =
"iframe";
6964 $allowed_tags_string = join(
"><", $allowed_tags);
6965 $allowed_tags_string =
'<'.$allowed_tags_string.
'>';
6967 $stringtoclean = str_replace(
'<!DOCTYPE html>',
'__!DOCTYPE_HTML__', $stringtoclean);
6972 $stringtoclean = preg_replace(
'/<!--([^>]*)-->/',
'<comment>\1</comment>', $stringtoclean);
6974 $stringtoclean = preg_replace(
'/:/i',
':', $stringtoclean);
6975 $stringtoclean = preg_replace(
'/:|�+58|:/i',
'', $stringtoclean);
6977 $temp = strip_tags($stringtoclean, $allowed_tags_string);
6979 if ($cleanalsosomestyles) {
6980 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/i',
'', $temp);
6982 if ($removeclassattribute) {
6983 $temp = preg_replace(
'/(<[^>]+)\s+class=((["\']).*?\\3|\\w*)/i',
'\\1', $temp);
6988 if ($cleanalsojavascript) {
6989 $temp = preg_replace(
'/j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t\s*:/i',
'', $temp);
6992 $temp = str_replace(
'__!DOCTYPE_HTML__',
'<!DOCTYPE html>', $temp);
6994 $temp = preg_replace(
'/<comment>([^>]*)<\/comment>/',
'<!--\1-->', $temp);
7012 function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes = array(
"allow",
"allowfullscreen",
"alt",
"class",
"contenteditable",
"data-html",
"frameborder",
"height",
"href",
"id",
"name",
"src",
"style",
"target",
"title",
"width"))
7014 if (class_exists(
'DOMDocument') && !empty($stringtoclean)) {
7015 $stringtoclean =
'<?xml encoding="UTF-8"><html><body>'.$stringtoclean.
'</body></html>';
7017 $dom =
new DOMDocument(
null,
'UTF-8');
7018 $dom->loadHTML($stringtoclean, LIBXML_ERR_NONE|LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD|LIBXML_NONET|LIBXML_NOWARNING|LIBXML_NOXMLDECL);
7020 if (is_object($dom)) {
7021 for ($els = $dom->getElementsByTagname(
'*'), $i = $els->length - 1; $i >= 0; $i--) {
7022 for ($attrs = $els->item($i)->attributes, $ii = $attrs->length - 1; $ii >= 0; $ii--) {
7024 if (!empty($attrs->item($ii)->name)) {
7025 if (! in_array($attrs->item($ii)->name, $allowed_attributes)) {
7027 $els->item($i)->removeAttribute($attrs->item($ii)->name);
7028 } elseif (in_array($attrs->item($ii)->name, array(
'style'))) {
7030 $valuetoclean = $attrs->item($ii)->value;
7032 if (isset($valuetoclean)) {
7034 $oldvaluetoclean = $valuetoclean;
7035 $valuetoclean = preg_replace(
'/\/\*.*\*\//m',
'', $valuetoclean);
7036 $valuetoclean = preg_replace(
'/position\s*:\s*[a-z]+/mi',
'', $valuetoclean);
7037 if ($els->item($i)->tagName ==
'a') {
7038 $valuetoclean = preg_replace(
'/display\s*:/mi',
'', $valuetoclean);
7039 $valuetoclean = preg_replace(
'/z-index\s*:/mi',
'', $valuetoclean);
7040 $valuetoclean = preg_replace(
'/\s+(top|left|right|bottom)\s*:/mi',
'', $valuetoclean);
7044 $valuetoclean = preg_replace(
'/(logout|passwordforgotten)\.php/mi',
'', $valuetoclean);
7045 $valuetoclean = preg_replace(
'/action=/mi',
'', $valuetoclean);
7046 }
while ($oldvaluetoclean != $valuetoclean);
7049 $attrs->item($ii)->value = $valuetoclean;
7056 $return = $dom->saveHTML();
7059 $return = preg_replace(
'/^'.preg_quote(
'<?xml encoding="UTF-8">',
'/').
'/',
'', $return);
7060 $return = preg_replace(
'/^'.preg_quote(
'<html><body>',
'/').
'/',
'', $return);
7061 $return = preg_replace(
'/'.preg_quote(
'</body></html>',
'/').
'$/',
'', $return);
7062 return trim($return);
7064 return $stringtoclean;
7081 $temp = $stringtoclean;
7082 foreach ($disallowed_tags as $tagtoremove) {
7083 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'>/',
'', $temp);
7084 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'\s+[^>]*>/',
'', $temp);
7087 if ($cleanalsosomestyles) {
7088 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/',
'', $temp);
7106 if ($nboflines == 1) {
7108 $firstline = preg_replace(
'/<br[^>]*>.*$/s',
'', $text);
7109 $firstline = preg_replace(
'/<div[^>]*>.*$/s',
'', $firstline);
7111 $firstline = preg_replace(
'/[\n\r].*/',
'', $text);
7113 return $firstline.((strlen($firstline) != strlen($text)) ?
'...' :
'');
7117 $text = preg_replace(
'/\n/',
'', $text);
7119 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7121 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7124 $text = strtr($text, $repTable);
7125 if ($charset ==
'UTF-8') {
7126 $pattern =
'/(<br[^>]*>)/Uu';
7129 $pattern =
'/(<br[^>]*>)/U';
7131 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
7136 while (($i < $nba) && ($i < ($nboflines * 2))) {
7138 $firstline .= $a[$i];
7139 } elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) {
7140 $firstline .= ($ishtml ?
"<br>\n" :
"\n");
7145 return $firstline.(($i < $nba) ?
'...' :
'');
7160 function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml =
false)
7162 if (is_null($stringtoencode)) {
7167 return nl2br($stringtoencode, $forxml);
7169 $ret = preg_replace(
'/(\r\n|\r|\n)/i', ($forxml ?
'<br />' :
'<br>'), $stringtoencode);
7186 if (empty($nouseofiframesandbox) && !empty($conf->global->MAIN_SECURITY_USE_SANDBOX_FOR_HTMLWITHNOJS)) {
7191 return $stringtoencode;
7193 $out = $stringtoencode;
7196 $oldstringtoclean = $out;
7198 if (!empty($out) && !empty($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML) && $check !=
'restricthtmlallowunvalid') {
7200 $dom =
new DOMDocument;
7204 $out =
'<div class="tricktoremove">'.$out.
'</div>';
7206 $dom->loadHTML($out, LIBXML_ERR_NONE|LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD|LIBXML_NONET|LIBXML_NOWARNING|LIBXML_NOXMLDECL);
7207 $out = trim($dom->saveHTML());
7210 $out = preg_replace(
'/^<div class="tricktoremove">/',
'', $out);
7211 $out = preg_replace(
'/<\/div>$/',
'', $out);
7215 $out =
'InvalidHTMLString';
7220 $out = preg_replace(
'/&(tab|newline);/i',
' ', $out);
7224 $out = preg_replace(
'/'/i',
''', $out);
7229 $out = preg_replace_callback(
'/&#(x?[0-9][0-9a-f]+;?)/i',
function ($m) {
7234 $out = preg_replace(
'/&#x?[0-9]+/i',
'', $out);
7240 if (!empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)) {
7246 $out = preg_replace(
'/'/i',
"'", $out);
7247 }
while ($oldstringtoclean != $out);
7251 preg_match_all(
'/(<img|url\()/i', $out, $reg);
7252 if (count($reg[0]) >
getDolGlobalInt(
"MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 1000)) {
7253 $out =
'TooManyLinksIntoHTMLString';
7277 function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom =
'UTF-8', $removelasteolbr = 1)
7279 if (is_null($stringtoencode)) {
7283 $newstring = $stringtoencode;
7285 $newstring = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
'<br>', $newstring);
7286 if ($removelasteolbr) {
7287 $newstring = preg_replace(
'/<br>$/i',
'', $newstring);
7289 $newstring = strtr($newstring, array(
'&'=>
'__and__',
'<'=>
'__lt__',
'>'=>
'__gt__',
'"'=>
'__dquot__'));
7291 $newstring = strtr($newstring, array(
'__and__'=>
'&',
'__lt__'=>
'<',
'__gt__'=>
'>',
'__dquot__'=>
'"'));
7293 if ($removelasteolbr) {
7294 $newstring = preg_replace(
'/(\r\n|\r|\n)$/i',
'', $newstring);
7313 $ret = preg_replace(
'/'.
"\r\n".
'<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"<br>", $ret);
7314 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\r\n".
'/i',
"\r\n", $ret);
7315 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\n".
'/i',
"\n", $ret);
7316 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"\n", $ret);
7328 $ret = preg_replace(
'/ $/i',
"", $stringtodecode);
7329 $ret = preg_replace(
'/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'.
"\n".
'|'.
"\r".
')+$/i',
"", $ret);
7345 if ($keepsomeentities) {
7346 $newstring = strtr($newstring, array(
'&'=>
'__andamp__',
'<'=>
'__andlt__',
'>'=>
'__andgt__',
'"'=>
'__dquot__'));
7348 $newstring = html_entity_decode((
string) $newstring, (
int) $b, (
string) $c);
7349 if ($keepsomeentities) {
7350 $newstring = strtr($newstring, array(
'__andamp__'=>
'&',
'__andlt__'=>
'<',
'__andgt__'=>
'>',
'__dquot__'=>
'"'));
7365 function dol_htmlentities($string, $flags = ENT_QUOTES|ENT_SUBSTITUTE, $encoding =
'UTF-8', $double_encode =
false)
7367 return htmlentities($string, $flags, $encoding, $double_encode);
7384 for ($scursor = 0; $scursor < $len; $scursor++) {
7385 $ordchar = ord($s[$scursor]);
7387 if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) {
7390 } elseif ($ordchar > 126 && $ordchar < 160) {
7394 $out .= $s[$scursor];
7416 $arraystring = explode(
"\n", $s);
7417 $nb = count($arraystring);
7434 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7436 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7439 $text = strtr($text, $repTable);
7440 if ($charset ==
'UTF-8') {
7441 $pattern =
'/(<br[^>]*>)/Uu';
7444 $pattern =
'/(<br[^>]*>)/U';
7446 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
7448 $nblines = (int) floor((count($a) + 1) / 2);
7451 foreach ($a as $line) {
7454 $line_dec = html_entity_decode($line);
7456 $line_dec = wordwrap($line_dec, $maxlinesize,
'\n',
true);
7457 $nblines += substr_count($line_dec,
'\n');
7477 if (is_null($msg)) {
7482 if (preg_match(
'/<html/i', $msg)) {
7484 } elseif (preg_match(
'/<body/i', $msg)) {
7486 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
7488 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
7490 } elseif (preg_match(
'/<br/i', $msg)) {
7496 $msg = preg_replace(
'/https?:\/\/[^"\'\s]+/i',
'', $msg);
7497 if (preg_match(
'/<html/i', $msg)) {
7499 } elseif (preg_match(
'/<body/i', $msg)) {
7501 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
7503 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
7505 } elseif (preg_match(
'/<br\/>/i', $msg)) {
7507 } elseif (preg_match(
'/<(br|div|font|li|p|span|strong|table)>/i', $msg)) {
7509 } elseif (preg_match(
'/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/?>/i', $msg)) {
7511 } elseif (preg_match(
'/<img\s+[^<>]*src[^<>]*>/i', $msg)) {
7513 } elseif (preg_match(
'/<a\s+[^<>]*href[^<>]*>/i', $msg)) {
7515 } elseif (preg_match(
'/<h[0-9]>/i', $msg)) {
7517 } elseif (preg_match(
'/&[A-Z0-9]{1,6};/i', $msg)) {
7520 } elseif (preg_match(
'/&#[0-9]{2,3};/i', $msg)) {
7544 if (!empty($invert)) {
7552 $ret .= (!empty($text1) && !empty($text2)) ? ((
dol_textishtml($text1) ||
dol_textishtml($text2)) ? ($forxml ?
"<br >\n" :
"<br>\n") :
"\n") :
"";
7571 global $db, $conf, $mysoc, $user, $extrafields;
7573 $substitutionarray = array();
7575 if (empty($exclude) || !in_array(
'user', $exclude)) {
7579 $emailsendersignature = $user->signature;
7580 $usersignature = $user->signature;
7581 $substitutionarray = array_merge($substitutionarray, array(
7582 '__SENDEREMAIL_SIGNATURE__' => (
string) ((empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ?
dol_trunc(
'SignatureFromTheSelectedSenderProfile', 30) : $emailsendersignature) :
''),
7583 '__USER_SIGNATURE__' => (
string) (($usersignature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ?
dol_trunc(
dol_string_nohtmltag($usersignature), 30) : $usersignature) :
'')
7586 if (is_object($user)) {
7587 $substitutionarray = array_merge($substitutionarray, array(
7588 '__USER_ID__' => (
string) $user->id,
7589 '__USER_LOGIN__' => (
string) $user->login,
7590 '__USER_EMAIL__' => (
string) $user->email,
7591 '__USER_PHONE__' => (
string)
dol_print_phone($user->office_phone,
'', 0, 0,
'',
" ",
'',
'', -1),
7592 '__USER_PHONEPRO__' => (
string)
dol_print_phone($user->user_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
7593 '__USER_PHONEMOBILE__' => (
string)
dol_print_phone($user->personal_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
7594 '__USER_FAX__' => (
string) $user->office_fax,
7595 '__USER_LASTNAME__' => (
string) $user->lastname,
7596 '__USER_FIRSTNAME__' => (
string) $user->firstname,
7597 '__USER_FULLNAME__' => (
string) $user->getFullName($outputlangs),
7598 '__USER_SUPERVISOR_ID__' => (
string) ($user->fk_user ? $user->fk_user :
'0'),
7599 '__USER_JOB__' => (
string) $user->job,
7604 if ((empty($exclude) || !in_array(
'mycompany', $exclude)) && is_object($mysoc)) {
7605 $substitutionarray = array_merge($substitutionarray, array(
7606 '__MYCOMPANY_NAME__' => $mysoc->name,
7607 '__MYCOMPANY_EMAIL__' => $mysoc->email,
7608 '__MYCOMPANY_PHONE__' =>
dol_print_phone($mysoc->phone,
'', 0, 0,
'',
" ",
'',
'', -1),
7609 '__MYCOMPANY_FAX__' =>
dol_print_phone($mysoc->fax,
'', 0, 0,
'',
" ",
'',
'', -1),
7610 '__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
7611 '__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
7612 '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
7613 '__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
7614 '__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
7615 '__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
7616 '__MYCOMPANY_CAPITAL__' => $mysoc->capital,
7617 '__MYCOMPANY_FULLADDRESS__' => (method_exists($mysoc,
'getFullAddress') ? $mysoc->getFullAddress(1,
', ') :
''),
7618 '__MYCOMPANY_ADDRESS__' => $mysoc->address,
7619 '__MYCOMPANY_ZIP__' => $mysoc->zip,
7620 '__MYCOMPANY_TOWN__' => $mysoc->town,
7621 '__MYCOMPANY_COUNTRY__' => $mysoc->country,
7622 '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id,
7623 '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code,
7624 '__MYCOMPANY_CURRENCY_CODE__' => $conf->currency
7628 if (($onlykey || is_object($object)) && (empty($exclude) || !in_array(
'object', $exclude))) {
7630 $substitutionarray[
'__ID__'] =
'__ID__';
7631 $substitutionarray[
'__REF__'] =
'__REF__';
7632 $substitutionarray[
'__NEWREF__'] =
'__NEWREF__';
7633 $substitutionarray[
'__LABEL__'] =
'__LABEL__';
7634 $substitutionarray[
'__REF_CLIENT__'] =
'__REF_CLIENT__';
7635 $substitutionarray[
'__REF_SUPPLIER__'] =
'__REF_SUPPLIER__';
7636 $substitutionarray[
'__NOTE_PUBLIC__'] =
'__NOTE_PUBLIC__';
7637 $substitutionarray[
'__NOTE_PRIVATE__'] =
'__NOTE_PRIVATE__';
7638 $substitutionarray[
'__EXTRAFIELD_XXX__'] =
'__EXTRAFIELD_XXX__';
7641 $substitutionarray[
'__THIRDPARTY_ID__'] =
'__THIRDPARTY_ID__';
7642 $substitutionarray[
'__THIRDPARTY_NAME__'] =
'__THIRDPARTY_NAME__';
7643 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
'__THIRDPARTY_NAME_ALIAS__';
7644 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
'__THIRDPARTY_CODE_CLIENT__';
7645 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
'__THIRDPARTY_CODE_FOURNISSEUR__';
7646 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
'__THIRDPARTY_EMAIL__';
7647 $substitutionarray[
'__THIRDPARTY_PHONE__'] =
'__THIRDPARTY_PHONE__';
7648 $substitutionarray[
'__THIRDPARTY_FAX__'] =
'__THIRDPARTY_FAX__';
7649 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
'__THIRDPARTY_ADDRESS__';
7650 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
'__THIRDPARTY_ZIP__';
7651 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
'__THIRDPARTY_TOWN__';
7652 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
'__THIRDPARTY_IDPROF1__';
7653 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
'__THIRDPARTY_IDPROF2__';
7654 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
'__THIRDPARTY_IDPROF3__';
7655 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
'__THIRDPARTY_IDPROF4__';
7656 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
'__THIRDPARTY_IDPROF5__';
7657 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
'__THIRDPARTY_IDPROF6__';
7658 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
'__THIRDPARTY_TVAINTRA__';
7659 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] =
'__THIRDPARTY_NOTE_PUBLIC__';
7660 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] =
'__THIRDPARTY_NOTE_PRIVATE__';
7662 if (
isModEnabled(
'adherent') && (!is_object($object) || $object->element ==
'adherent')) {
7663 $substitutionarray[
'__MEMBER_ID__'] =
'__MEMBER_ID__';
7664 $substitutionarray[
'__MEMBER_CIVILITY__'] =
'__MEMBER_CIVILITY__';
7665 $substitutionarray[
'__MEMBER_FIRSTNAME__'] =
'__MEMBER_FIRSTNAME__';
7666 $substitutionarray[
'__MEMBER_LASTNAME__'] =
'__MEMBER_LASTNAME__';
7667 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'Login and pass of the external user account';
7672 if (
isModEnabled(
'ticket') && (!is_object($object) || $object->element ==
'ticket')) {
7673 $substitutionarray[
'__TICKET_TRACKID__'] =
'__TICKET_TRACKID__';
7674 $substitutionarray[
'__TICKET_SUBJECT__'] =
'__TICKET_SUBJECT__';
7675 $substitutionarray[
'__TICKET_TYPE__'] =
'__TICKET_TYPE__';
7676 $substitutionarray[
'__TICKET_SEVERITY__'] =
'__TICKET_SEVERITY__';
7677 $substitutionarray[
'__TICKET_CATEGORY__'] =
'__TICKET_CATEGORY__';
7678 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
'__TICKET_ANALYTIC_CODE__';
7679 $substitutionarray[
'__TICKET_MESSAGE__'] =
'__TICKET_MESSAGE__';
7680 $substitutionarray[
'__TICKET_PROGRESSION__'] =
'__TICKET_PROGRESSION__';
7681 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
'__TICKET_USER_ASSIGN__';
7684 if (
isModEnabled(
'recruitment') && (!is_object($object) || $object->element ==
'recruitmentcandidature')) {
7685 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
'__CANDIDATE_FULLNAME__';
7686 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] =
'__CANDIDATE_FIRSTNAME__';
7687 $substitutionarray[
'__CANDIDATE_LASTNAME__'] =
'__CANDIDATE_LASTNAME__';
7690 $substitutionarray[
'__PROJECT_ID__'] =
'__PROJECT_ID__';
7691 $substitutionarray[
'__PROJECT_REF__'] =
'__PROJECT_REF__';
7692 $substitutionarray[
'__PROJECT_NAME__'] =
'__PROJECT_NAME__';
7696 if (
isModEnabled(
'contrat') && (!is_object($object) || $object->element ==
'contract')) {
7697 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
'Highest date planned for a service start';
7698 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
'Highest date and hour planned for service start';
7699 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
'Lowest data for planned expiration of service';
7700 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
'Lowest date and hour for planned expiration of service';
7702 if (
isModEnabled(
"propal") && (!is_object($object) || $object->element ==
'propal')) {
7703 $substitutionarray[
'__ONLINE_SIGN_URL__'] =
'ToOfferALinkForOnlineSignature';
7705 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'UrlToPayOnlineIfApplicable';
7706 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'TextAndUrlToPayOnlineIfApplicable';
7707 $substitutionarray[
'__SECUREKEYPAYMENT__'] =
'Security key (if key is not unique per record)';
7708 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
'Security key for payment on a member subscription (one key per member)';
7709 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
'Security key for payment on an order';
7710 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
'Security key for payment on an invoice';
7711 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
'Security key for payment on a service of a contract';
7713 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'Direct download url of a proposal';
7714 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'Direct download url of an order';
7715 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'Direct download url of an invoice';
7716 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'Direct download url of a contract';
7717 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'Direct download url of a supplier proposal';
7719 if (
isModEnabled(
"expedition") && (!is_object($object) || $object->element ==
'shipping')) {
7720 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
'Shipping tracking number';
7721 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
'Shipping tracking url';
7723 if (
isModEnabled(
"reception") && (!is_object($object) || $object->element ==
'reception')) {
7724 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
'Shippin tracking number of shipment';
7725 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
'Shipping tracking url';
7728 $substitutionarray[
'__ID__'] = $object->id;
7729 $substitutionarray[
'__REF__'] = $object->ref;
7730 $substitutionarray[
'__NEWREF__'] = $object->newref;
7731 $substitutionarray[
'__LABEL__'] = (isset($object->label) ? $object->label : (isset($object->title) ? $object->title :
null));
7732 $substitutionarray[
'__REF_CLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer :
null));
7733 $substitutionarray[
'__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier :
null);
7734 $substitutionarray[
'__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public :
null);
7735 $substitutionarray[
'__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private :
null);
7736 if ($object->element ==
"shipping") {
7737 $substitutionarray[
'__DATE_DELIVERY__'] = (isset($object->date_delivery) ?
dol_print_date($object->date_delivery,
'day', 0, $outputlangs) :
'');
7739 $substitutionarray[
'__DATE_DELIVERY__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
'day', 0, $outputlangs) :
'');
7741 $substitutionarray[
'__DATE_DELIVERY_DAY__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%d") :
'');
7742 $substitutionarray[
'__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%A") :
'');
7743 $substitutionarray[
'__DATE_DELIVERY_MON__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%m") :
'');
7744 $substitutionarray[
'__DATE_DELIVERY_MON_TEXT__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%b") :
'');
7745 $substitutionarray[
'__DATE_DELIVERY_YEAR__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%Y") :
'');
7746 $substitutionarray[
'__DATE_DELIVERY_HH__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%H") :
'');
7747 $substitutionarray[
'__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%M") :
'');
7748 $substitutionarray[
'__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%S") :
'');
7751 $substitutionarray[
'__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer :
null));
7752 $substitutionarray[
'__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier :
null);
7753 $substitutionarray[
'__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
'day', 0, $outputlangs) :
'');
7754 $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 :
'')) :
'');
7756 if (is_object($object) && ($object->element ==
'adherent' || $object->element ==
'member') && $object->id > 0) {
7757 $birthday = (empty($object->birth) ?
'' :
dol_print_date($object->birth,
'day'));
7759 $substitutionarray[
'__MEMBER_ID__'] = (isset($object->id) ? $object->id :
'');
7760 if (method_exists($object,
'getCivilityLabel')) {
7761 $substitutionarray[
'__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
7763 $substitutionarray[
'__MEMBER_FIRSTNAME__'] = (isset($object->firstname) ? $object->firstname :
'');
7764 $substitutionarray[
'__MEMBER_LASTNAME__'] = (isset($object->lastname) ? $object->lastname :
'');
7765 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'';
7766 if (method_exists($object,
'getFullName')) {
7767 $substitutionarray[
'__MEMBER_FULLNAME__'] = $object->getFullName($outputlangs);
7769 $substitutionarray[
'__MEMBER_COMPANY__'] = (isset($object->societe) ? $object->societe :
'');
7770 $substitutionarray[
'__MEMBER_ADDRESS__'] = (isset($object->address) ? $object->address :
'');
7771 $substitutionarray[
'__MEMBER_ZIP__'] = (isset($object->zip) ? $object->zip :
'');
7772 $substitutionarray[
'__MEMBER_TOWN__'] = (isset($object->town) ? $object->town :
'');
7773 $substitutionarray[
'__MEMBER_COUNTRY__'] = (isset($object->country) ? $object->country :
'');
7774 $substitutionarray[
'__MEMBER_EMAIL__'] = (isset($object->email) ? $object->email :
'');
7775 $substitutionarray[
'__MEMBER_BIRTH__'] = (isset($birthday) ? $birthday :
'');
7776 $substitutionarray[
'__MEMBER_PHOTO__'] = (isset($object->photo) ? $object->photo :
'');
7777 $substitutionarray[
'__MEMBER_LOGIN__'] = (isset($object->login) ? $object->login :
'');
7778 $substitutionarray[
'__MEMBER_PASSWORD__'] = (isset($object->pass) ? $object->pass :
'');
7779 $substitutionarray[
'__MEMBER_PHONE__'] = (isset($object->phone) ?
dol_print_phone($object->phone) :
'');
7780 $substitutionarray[
'__MEMBER_PHONEPRO__'] = (isset($object->phone_perso) ?
dol_print_phone($object->phone_perso) :
'');
7781 $substitutionarray[
'__MEMBER_PHONEMOBILE__'] = (isset($object->phone_mobile) ?
dol_print_phone($object->phone_mobile) :
'');
7782 $substitutionarray[
'__MEMBER_TYPE__'] = (isset($object->type) ? $object->type :
'');
7783 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE__'] =
dol_print_date($object->first_subscription_date,
'dayrfc');
7784 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = (isset($object->first_subscription_date_start) ?
dol_print_date($object->first_subscription_date_start,
'dayrfc') :
'');
7785 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = (isset($object->first_subscription_date_end) ?
dol_print_date($object->first_subscription_date_end,
'dayrfc') :
'');
7786 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE__'] =
dol_print_date($object->last_subscription_date,
'dayrfc');
7787 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] =
dol_print_date($object->last_subscription_date_start,
'dayrfc');
7788 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] =
dol_print_date($object->last_subscription_date_end,
'dayrfc');
7791 if (is_object($object) && $object->element ==
'societe') {
7792 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object($object) ? $object->id :
'');
7793 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object($object) ? $object->name :
'');
7794 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object($object) ? $object->name_alias :
'');
7795 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object($object) ? $object->code_client :
'');
7796 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object) ? $object->code_fournisseur :
'');
7797 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object($object) ? $object->email :
'');
7798 $substitutionarray[
'__THIRDPARTY_PHONE__'] = (is_object($object) ?
dol_print_phone($object->phone) :
'');
7799 $substitutionarray[
'__THIRDPARTY_FAX__'] = (is_object($object) ?
dol_print_phone($object->fax) :
'');
7800 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object($object) ? $object->address :
'');
7801 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object($object) ? $object->zip :
'');
7802 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object($object) ? $object->town :
'');
7803 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object($object) ? $object->country_id :
'');
7804 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object) ? $object->country_code :
'');
7805 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object($object) ? $object->idprof1 :
'');
7806 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object($object) ? $object->idprof2 :
'');
7807 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object($object) ? $object->idprof3 :
'');
7808 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object($object) ? $object->idprof4 :
'');
7809 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object($object) ? $object->idprof5 :
'');
7810 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object($object) ? $object->idprof6 :
'');
7811 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object($object) ? $object->tva_intra :
'');
7812 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object) ?
dol_htmlentitiesbr($object->note_public) :
'');
7813 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object) ?
dol_htmlentitiesbr($object->note_private) :
'');
7814 } elseif (is_object($object->thirdparty)) {
7815 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->id :
'');
7816 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object($object->thirdparty) ? $object->thirdparty->name :
'');
7817 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty) ? $object->thirdparty->name_alias :
'');
7818 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_client :
'');
7819 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_fournisseur :
'');
7820 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty) ? $object->thirdparty->email :
'');
7821 $substitutionarray[
'__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty) ?
dol_print_phone($object->thirdparty->phone) :
'');
7822 $substitutionarray[
'__THIRDPARTY_FAX__'] = (is_object($object->thirdparty) ?
dol_print_phone($object->thirdparty->fax) :
'');
7823 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty) ? $object->thirdparty->address :
'');
7824 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty) ? $object->thirdparty->zip :
'');
7825 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty) ? $object->thirdparty->town :
'');
7826 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_id :
'');
7827 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_code :
'');
7828 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof1 :
'');
7829 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof2 :
'');
7830 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof3 :
'');
7831 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof4 :
'');
7832 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof5 :
'');
7833 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof6 :
'');
7834 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty) ? $object->thirdparty->tva_intra :
'');
7835 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object->thirdparty) ?
dol_htmlentitiesbr($object->thirdparty->note_public) :
'');
7836 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object->thirdparty) ?
dol_htmlentitiesbr($object->thirdparty->note_private) :
'');
7839 if (is_object($object) && $object->element ==
'recruitmentcandidature') {
7840 $substitutionarray[
'__CANDIDATE_FULLNAME__'] = $object->getFullName($outputlangs);
7841 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname :
'';
7842 $substitutionarray[
'__CANDIDATE_LASTNAME__'] = isset($object->lastname) ? $object->lastname :
'';
7844 if (is_object($object) && $object->element ==
'conferenceorboothattendee') {
7845 $substitutionarray[
'__ATTENDEE_FULLNAME__'] = $object->getFullName($outputlangs);
7846 $substitutionarray[
'__ATTENDEE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname :
'';
7847 $substitutionarray[
'__ATTENDEE_LASTNAME__'] = isset($object->lastname) ? $object->lastname :
'';
7851 if (is_object($object->project)) {
7852 $project = $object->project;
7853 } elseif (is_object($object->projet)) {
7854 $project = $object->projet;
7857 $substitutionarray[
'__PROJECT_ID__'] = $project->id;
7858 $substitutionarray[
'__PROJECT_REF__'] = $project->ref;
7859 $substitutionarray[
'__PROJECT_NAME__'] = $project->title;
7861 if (is_object($object) && $object->element ==
'project') {
7862 $substitutionarray[
'__PROJECT_NAME__'] = $object->title;
7865 if (is_object($object) && $object->element ==
'shipping') {
7866 $substitutionarray[
'__SHIPPINGTRACKNUM__'] = $object->tracking_number;
7867 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] = $object->tracking_url;
7869 if (is_object($object) && $object->element ==
'reception') {
7870 $substitutionarray[
'__RECEPTIONTRACKNUM__'] = $object->tracking_number;
7871 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] = $object->tracking_url;
7874 if (is_object($object) && $object->element ==
'contrat' && $object->id > 0 && is_array($object->lines)) {
7875 $dateplannedstart =
'';
7876 $datenextexpiration =
'';
7877 foreach ($object->lines as $line) {
7878 if ($line->date_start > $dateplannedstart) {
7879 $dateplannedstart = $line->date_start;
7881 if ($line->statut == 4 && $line->date_end && (!$datenextexpiration || $line->date_end < $datenextexpiration)) {
7882 $datenextexpiration = $line->date_end;
7885 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
dol_print_date($dateplannedstart,
'dayrfc');
7886 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
dol_print_date($dateplannedstart,
'standard');
7887 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
dol_print_date($datenextexpiration,
'dayrfc');
7888 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
dol_print_date($datenextexpiration,
'standard');
7891 if (is_object($object) && $object->element ==
'ticket') {
7892 $substitutionarray[
'__TICKET_TRACKID__'] = $object->track_id;
7893 $substitutionarray[
'__REF__'] = $object->ref;
7894 $substitutionarray[
'__TICKET_SUBJECT__'] = $object->subject;
7895 $substitutionarray[
'__TICKET_TYPE__'] = $object->type_code;
7896 $substitutionarray[
'__TICKET_SEVERITY__'] = $object->severity_code;
7897 $substitutionarray[
'__TICKET_CATEGORY__'] = $object->category_code;
7898 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] = $object->category_code;
7899 $substitutionarray[
'__TICKET_MESSAGE__'] = $object->message;
7900 $substitutionarray[
'__TICKET_PROGRESSION__'] = $object->progress;
7901 $userstat =
new User($db);
7902 if ($object->fk_user_assign > 0) {
7903 $userstat->fetch($object->fk_user_assign);
7904 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
7907 if ($object->fk_user_create > 0) {
7908 $userstat->fetch($object->fk_user_create);
7909 $substitutionarray[
'__USER_CREATE__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
7914 if ($object->table_element && $object->id > 0) {
7915 if (!is_object($extrafields)) {
7918 $extrafields->fetch_name_optionals_label($object->table_element,
true);
7920 if ($object->fetch_optionals() > 0) {
7921 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label']) > 0) {
7922 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $label) {
7923 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = $object->array_options[
'options_'.$key];
7924 if ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'date') {
7925 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_date($object->array_options[
'options_'.$key],
'day');
7926 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] =
dol_print_date($object->array_options[
'options_'.$key],
'day',
'tzserver', $outputlangs);
7927 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] =
dol_print_date($object->array_options[
'options_'.$key],
'dayrfc');
7928 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'datetime') {
7929 $datetime = $object->array_options[
'options_'.$key];
7930 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
7931 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
7932 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_DAY_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'day',
'tzserver', $outputlangs) :
'');
7933 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
7934 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'phone') {
7935 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_phone($object->array_options[
'options_'.$key]);
7936 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'price') {
7937 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = $object->array_options[
'options_'.$key];
7938 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATED__'] =
price($object->array_options[
'options_'.$key]);
7947 if (empty($substitutionarray[
'__REF__'])) {
7951 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
7952 $outputlangs->loadLangs(array(
'paypal',
'other'));
7955 $typeforonlinepayment =
'free';
7956 if (is_object($object) && $object->element ==
'commande') {
7957 $typeforonlinepayment =
'order';
7959 if (is_object($object) && $object->element ==
'facture') {
7960 $typeforonlinepayment =
'invoice';
7962 if (is_object($object) && $object->element ==
'member') {
7963 $typeforonlinepayment =
'member';
7964 if (!empty($object->last_subscription_amount)) {
7965 $amounttouse = $object->last_subscription_amount;
7968 if (is_object($object) && $object->element ==
'contrat') {
7969 $typeforonlinepayment =
'contract';
7971 if (is_object($object) && $object->element ==
'fichinter') {
7972 $typeforonlinepayment =
'ficheinter';
7975 $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray[
'__REF__'], $amounttouse);
7979 if ($object->id > 0) {
7980 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ?str_replace(
'\n',
"\n", $outputlangs->trans(
"PredefinedMailContentLink", $paymenturl)) :
'');
7981 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] = $paymenturl;
7983 if (is_object($object) && $object->element ==
'propal') {
7984 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
7985 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'proposal', $object->ref);
7987 if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'propal') {
7988 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
7990 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'';
7992 if (!empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'commande') {
7993 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element);
7995 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'';
7997 if (!empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'facture') {
7998 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element);
8000 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'';
8002 if (!empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'contrat') {
8003 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] = $object->getLastMainDocLink($object->element);
8005 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'';
8007 if (!empty($conf->global->FICHINTER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'fichinter') {
8008 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] = $object->getLastMainDocLink($object->element);
8010 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] =
'';
8012 if (!empty($conf->global->SUPPLIER_PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'supplier_proposal') {
8013 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
8015 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'';
8018 if (is_object($object) && $object->element ==
'propal') {
8019 $substitutionarray[
'__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/comm/propal/card.php?id=".$object->id;
8021 if (is_object($object) && $object->element ==
'commande') {
8022 $substitutionarray[
'__URL_ORDER__'] = DOL_MAIN_URL_ROOT.
"/commande/card.php?id=".$object->id;
8024 if (is_object($object) && $object->element ==
'facture') {
8025 $substitutionarray[
'__URL_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/compta/facture/card.php?id=".$object->id;
8027 if (is_object($object) && $object->element ==
'contrat') {
8028 $substitutionarray[
'__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT.
"/contrat/card.php?id=".$object->id;
8030 if (is_object($object) && $object->element ==
'fichinter') {
8031 $substitutionarray[
'__URL_FICHINTER__'] = DOL_MAIN_URL_ROOT.
"/fichinter/card.php?id=".$object->id;
8033 if (is_object($object) && $object->element ==
'supplier_proposal') {
8034 $substitutionarray[
'__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/supplier_proposal/card.php?id=".$object->id;
8036 if (is_object($object) && $object->element ==
'shipping') {
8037 $substitutionarray[
'__URL_SHIPMENT__'] = DOL_MAIN_URL_ROOT.
"/expedition/card.php?id=".$object->id;
8041 if (is_object($object) && $object->element ==
'action') {
8042 $substitutionarray[
'__EVENT_LABEL__'] = $object->label;
8043 $substitutionarray[
'__EVENT_DATE__'] =
dol_print_date($object->datep,
'%A %d %b %Y');
8044 $substitutionarray[
'__EVENT_TIME__'] =
dol_print_date($object->datep,
'%H:%M:%S');
8048 if (empty($exclude) || !in_array(
'objectamount', $exclude)) {
8049 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functionsnumtoword.lib.php';
8051 $substitutionarray[
'__DATE_YMD__'] = is_object($object) ? (isset($object->date) ?
dol_print_date($object->date,
'day', 0, $outputlangs) :
null) :
'';
8052 $substitutionarray[
'__DATE_DUE_YMD__'] = is_object($object) ? (isset($object->date_lim_reglement) ?
dol_print_date($object->date_lim_reglement,
'day', 0, $outputlangs) :
null) :
'';
8054 $already_payed_all = 0;
8055 if (is_object($object) && ($object instanceof
Facture)) {
8056 $already_payed_all = $object->sumpayed + $object->sumdeposit + $object->sumcreditnote;
8059 $substitutionarray[
'__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht :
'';
8061 $substitutionarray[
'__AMOUNT__'] = is_object($object) ? $object->total_ttc :
'';
8062 $substitutionarray[
'__AMOUNT_TEXT__'] = is_object($object) ?
dol_convertToWord($object->total_ttc, $outputlangs,
'',
true) :
'';
8063 $substitutionarray[
'__AMOUNT_TEXTCURRENCY__'] = is_object($object) ?
dol_convertToWord($object->total_ttc, $outputlangs, $conf->currency,
true) :
'';
8065 $substitutionarray[
'__AMOUNT_REMAIN__'] = is_object($object) ?
price2num($object->total_ttc - $already_payed_all,
'MT') :
'';
8067 $substitutionarray[
'__AMOUNT_VAT__'] = is_object($object) ? (isset($object->total_vat) ? $object->total_vat : $object->total_tva) :
'';
8068 $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)) :
'';
8069 $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)) :
'';
8071 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
8072 $substitutionarray[
'__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 :
'';
8074 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
8075 $substitutionarray[
'__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 :
'';
8079 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object) ? ($object->total_ht ?
price($object->total_ht, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8080 $substitutionarray[
'__AMOUNT_FORMATED__'] = is_object($object) ? ($object->total_ttc ?
price($object->total_ttc, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8081 $substitutionarray[
'__AMOUNT_REMAIN_FORMATED__'] = is_object($object) ? ($object->total_ttc ?
price($object->total_ttc - $already_payed_all, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8082 $substitutionarray[
'__AMOUNT_VAT_FORMATED__'] = is_object($object) ? (isset($object->total_vat) ?
price($object->total_vat, 0, $outputlangs, 0, -1, -1, $conf->currency) : ($object->total_tva ?
price($object->total_tva, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null)) :
'';
8083 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
8084 $substitutionarray[
'__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? ($object->total_localtax1 ?
price($object->total_localtax1, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8086 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
8087 $substitutionarray[
'__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? ($object->total_localtax2 ?
price($object->total_localtax2, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8090 $substitutionarray[
'__AMOUNT_MULTICURRENCY__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ? $object->multicurrency_total_ttc :
'';
8091 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXT__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ?
dol_convertToWord($object->multicurrency_total_ttc, $outputlangs,
'',
true) :
'';
8092 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXTCURRENCY__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ?
dol_convertToWord($object->multicurrency_total_ttc, $outputlangs, $object->multicurrency_code,
true) :
'';
8096 if ($onlykey != 2) {
8097 $substitutionarray[
'__TOTAL_TTC__'] = is_object($object) ? $object->total_ttc :
'';
8098 $substitutionarray[
'__TOTAL_HT__'] = is_object($object) ? $object->total_ht :
'';
8099 $substitutionarray[
'__TOTAL_VAT__'] = is_object($object) ? (isset($object->total_vat) ? $object->total_vat : $object->total_tva) :
'';
8104 if (empty($exclude) || !in_array(
'date', $exclude)) {
8105 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
8115 $daytext = $outputlangs->trans(
'Day'.$tmp[
'wday']);
8117 $substitutionarray = array_merge($substitutionarray, array(
8118 '__NOW_TMS__' => (
int) $now,
8119 '__NOW_TMS_YMD__' =>
dol_print_date($now,
'day', 0, $outputlangs),
8120 '__DAY__' => (
string) $tmp[
'mday'],
8121 '__DAY_TEXT__' => $daytext,
8122 '__DAY_TEXT_SHORT__' =>
dol_trunc($daytext, 3,
'right',
'UTF-8', 1),
8123 '__DAY_TEXT_MIN__' =>
dol_trunc($daytext, 1,
'right',
'UTF-8', 1),
8124 '__MONTH__' => (
string) $tmp[
'mon'],
8125 '__MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp[
'mon'])),
8126 '__MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp[
'mon'])),
8127 '__MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp[
'mon'])),
8128 '__YEAR__' => (
string) $tmp[
'year'],
8129 '__PREVIOUS_DAY__' => (
string) $tmp2[
'day'],
8130 '__PREVIOUS_MONTH__' => (
string) $tmp3[
'month'],
8131 '__PREVIOUS_YEAR__' => (
string) ($tmp[
'year'] - 1),
8132 '__NEXT_DAY__' => (
string) $tmp4[
'day'],
8133 '__NEXT_MONTH__' => (
string) $tmp5[
'month'],
8134 '__NEXT_YEAR__' => (
string) ($tmp[
'year'] + 1),
8139 $substitutionarray = array_merge($substitutionarray, array(
'__ENTITY_ID__' => $conf->entity));
8141 if (empty($exclude) || !in_array(
'system', $exclude)) {
8142 $substitutionarray[
'__DOL_MAIN_URL_ROOT__'] = DOL_MAIN_URL_ROOT;
8143 $substitutionarray[
'__(AnyTranslationKey)__'] = $outputlangs->trans(
'TranslationOfKey');
8144 $substitutionarray[
'__(AnyTranslationKey|langfile)__'] = $outputlangs->trans(
'TranslationOfKey').
' (load also language file before)';
8145 $substitutionarray[
'__[AnyConstantKey]__'] = $outputlangs->trans(
'ValueOfConstantKey');
8148 return $substitutionarray;
8167 function make_substitutions($text, $substitutionarray, $outputlangs =
null, $converttextinhtmlifnecessary = 0)
8169 global $conf, $langs;
8171 if (!is_array($substitutionarray)) {
8172 return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
8175 if (empty($outputlangs)) {
8176 $outputlangs = $langs;
8186 if (is_object($outputlangs)) {
8188 while (preg_match(
'/__\(([^\)]+)\)__/', $text, $reg)) {
8190 $tmp = explode(
'|', $reg[1]);
8191 if (!empty($tmp[1])) {
8192 $outputlangs->load($tmp[1]);
8195 $value = $outputlangs->transnoentitiesnoconv($reg[1]);
8197 if (empty($converttextinhtmlifnecessary)) {
8199 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
8213 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $value, $text);
8221 while (preg_match(
'/__\[([^\]]+)\]__/', $text, $reg)) {
8222 $keyfound = $reg[1];
8224 $value =
'*****forbidden*****';
8226 $value = empty($conf->global->$keyfound) ?
'' : $conf->global->$keyfound;
8229 if (empty($converttextinhtmlifnecessary)) {
8231 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
8244 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $value, $text);
8249 foreach ($substitutionarray as $key => $value) {
8250 if (!isset($value)) {
8254 if (($key ==
'__USER_SIGNATURE__' || $key ==
'__SENDEREMAIL_SIGNATURE__') && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) {
8258 if (empty($converttextinhtmlifnecessary)) {
8259 $text = str_replace(
"$key",
"$value", $text);
8271 $text = str_replace(
"$key",
"$value", $text);
8292 global $conf, $user;
8294 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
8299 $dirsubstitutions = array_merge(array(), (array) $conf->modules_parts[
'substitutions']);
8301 foreach ($dirsubstitutions as $reldir) {
8309 $substitfiles =
dol_dir_list($dir,
'files', 0,
'functions_');
8310 foreach ($substitfiles as $substitfile) {
8312 if (preg_match(
'/functions_(.*)\.lib\.php/i', $substitfile[
'name'], $reg)) {
8315 dol_syslog(
"Library ".$substitfile[
'name'].
" found into ".$dir);
8317 require_once $dir.$substitfile[
'name'];
8319 $function_name = $module.
"_".$callfunc;
8320 if (function_exists($function_name)) {
8321 $function_name($substitutionarray, $outputlangs, $object, $parameters);
8326 if (!empty($conf->global->ODT_ENABLE_ALL_TAGS_IN_SUBSTITUTIONS)) {
8329 foreach ($substitutionarray as $key => $value) {
8330 $tags .=
'{'.$key.
'} => '.$value.
"\n";
8332 $substitutionarray = array_merge($substitutionarray, array(
'__ALL_TAGS__' => $tags));
8347 print
get_date_range($date_start, $date_end, $format, $outputlangs);
8360 function get_date_range($date_start, $date_end, $format =
'', $outputlangs =
'', $withparenthesis = 1)
8366 if (!is_object($outputlangs)) {
8367 $outputlangs = $langs;
8370 if ($date_start && $date_end) {
8371 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFromTo',
dol_print_date($date_start, $format,
false, $outputlangs),
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
8373 if ($date_start && !$date_end) {
8374 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($date_start, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
8376 if (!$date_start && $date_end) {
8377 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
8397 if ($nameorder < 0) {
8398 $nameorder = (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0);
8400 if ($nameorder == 1) {
8402 if ($firstname && $lastname) {
8406 } elseif ($nameorder == 2 || $nameorder == 3) {
8408 if (empty($ret) && $nameorder == 3) {
8413 if (empty($ret) && $nameorder == 5) {
8416 if ($nameorder == 0) {
8417 if ($firstname && $lastname) {
8440 if (!is_array($mesgs)) {
8443 $_SESSION[
'dol_events'][$style][] = $mesgs;
8447 foreach ($mesgs as $mesg) {
8449 $_SESSION[
'dol_events'][$style][] = $mesg;
8468 if (empty($mesg) && empty($mesgs)) {
8469 dol_syslog(
"Try to add a message in stack with empty message", LOG_WARNING);
8476 if (empty($messagekey) || empty($_COOKIE[
"DOLHIDEMESSAGE".$messagekey])) {
8477 if (!in_array((
string) $style, array(
'mesgs',
'warnings',
'errors'))) {
8478 dol_print_error(
'',
'Bad parameter style='.$style.
' for setEventMessages');
8480 if (empty($mesgs)) {
8483 if (!empty($mesg) && !in_array($mesg, $mesgs)) {
8504 if (isset($_SESSION[
'dol_events'][
'mesgs'])) {
8505 if (empty($disabledoutputofmessages)) {
8508 unset($_SESSION[
'dol_events'][
'mesgs']);
8511 if (isset($_SESSION[
'dol_events'][
'errors'])) {
8512 if (empty($disabledoutputofmessages)) {
8515 unset($_SESSION[
'dol_events'][
'errors']);
8519 if (isset($_SESSION[
'dol_events'][
'warnings'])) {
8520 if (empty($disabledoutputofmessages)) {
8523 unset($_SESSION[
'dol_events'][
'warnings']);
8543 global $conf, $langs;
8548 $divstart = $divend =
'';
8551 if ((empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && !preg_match(
'/<div class=".*">/i', $out)) {
8552 $divstart =
'<div class="'.$style.
' clearboth">';
8556 if ((is_array($mesgarray) && count($mesgarray)) || $mesgstring) {
8557 $langs->load(
"errors");
8559 if (is_array($mesgarray) && count($mesgarray)) {
8560 foreach ($mesgarray as $message) {
8562 $out .= $langs->trans($message);
8563 if ($ret < count($mesgarray)) {
8570 $out .= $langs->trans($mesgstring);
8576 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && empty($keepembedded)) {
8578 $(document).ready(function() {
8579 var block = '.(!empty($conf->global->MAIN_USE_JQUERY_BLOCKUI) ?
"true" :
"false").
'
8583 /* jnotify(message, preset of message type, keepmessage) */
8585 "'.($style ==
"ok" ? 3000 : $style).
'",
8586 '.($style ==
"ok" ?
"false" :
"true").
',
8587 { remove: function (){} } );
8630 if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) {
8636 if (is_array($mesgarray)) {
8637 foreach ($mesgarray as $val) {
8638 if ($val && preg_match(
'/class="error"/i', $val)) {
8642 if ($val && preg_match(
'/class="warning"/i', $val)) {
8647 } elseif ($mesgstring && preg_match(
'/class="error"/i', $mesgstring)) {
8649 } elseif ($mesgstring && preg_match(
'/class="warning"/i', $mesgstring)) {
8652 if ($style ==
'error') {
8655 if ($style ==
'warning') {
8659 if ($iserror || $iswarning) {
8661 $mesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $mesgstring);
8662 $mesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $mesgstring);
8663 $mesgstring = preg_replace(
'/<\/div>/',
'', $mesgstring);
8665 if (is_array($mesgarray)) {
8666 $newmesgarray = array();
8667 foreach ($mesgarray as $val) {
8668 if (is_string($val)) {
8669 $tmpmesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $val);
8670 $tmpmesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $tmpmesgstring);
8671 $tmpmesgstring = preg_replace(
'/<\/div>/',
'', $tmpmesgstring);
8672 $newmesgarray[] = $tmpmesgstring;
8674 dol_syslog(
"Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING);
8677 $mesgarray = $newmesgarray;
8679 print
get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ?
'error' :
'warning'), $keepembedded);
8714 function dol_sort_array(&$array, $index, $order =
'asc', $natsort = 0, $case_sensitive = 0, $keepindex = 0)
8717 $order = strtolower($order);
8719 if (is_array($array)) {
8720 $sizearray = count($array);
8721 if ($sizearray > 0) {
8723 foreach (array_keys($array) as $key) {
8724 if (is_object($array[$key])) {
8725 $temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index;
8727 $temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index];
8732 if ($order ==
'asc') {
8738 if ($case_sensitive) {
8743 if ($order !=
'asc') {
8744 $temp = array_reverse($temp,
true);
8750 foreach (array_keys($temp) as $key) {
8751 (is_numeric($key) && empty($keepindex)) ? $sorted[] = $array[$key] : $sorted[$key] = $array[$key];
8769 $str = (string) $str;
8773 for ($i = 0; $i < $strLength; $i++) {
8774 if (ord($str[$i]) < 0x80) {
8776 } elseif ((ord($str[$i]) & 0xE0) == 0xC0) {
8778 } elseif ((ord($str[$i]) & 0xF0) == 0xE0) {
8780 } elseif ((ord($str[$i]) & 0xF8) == 0xF0) {
8782 } elseif ((ord($str[$i]) & 0xFC) == 0xF8) {
8784 } elseif ((ord($str[$i]) & 0xFE) == 0xFC) {
8789 for ($j = 0; $j < $n; $j++) {
8790 if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) {
8810 return preg_match(
'//u', $str) ? true :
false;
8822 if (function_exists(
'mb_check_encoding')) {
8824 if (!mb_check_encoding($str,
'ASCII')) {
8828 if (preg_match(
'/[^\x00-\x7f]/', $str)) {
8848 $tmp = ini_get(
"unicode.filesystem_encoding");
8849 if (empty($tmp) && !empty($_SERVER[
"WINDIR"])) {
8850 $tmp =
'iso-8859-1';
8855 if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING)) {
8856 $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING;
8859 if ($tmp ==
'iso-8859-1') {
8860 return utf8_decode($str);
8880 function dol_getIdFromCode($db, $key, $tablename, $fieldkey =
'code', $fieldid =
'id', $entityfilter = 0, $filters =
'')
8882 global $cache_codes;
8890 if (isset($cache_codes[$tablename][$key][$fieldid])) {
8891 return $cache_codes[$tablename][$key][$fieldid];
8894 dol_syslog(
'dol_getIdFromCode (value for field '.$fieldid.
' from key '.$key.
' not found into cache)', LOG_DEBUG);
8896 $sql =
"SELECT ".$fieldid.
" as valuetoget";
8897 $sql .=
" FROM ".MAIN_DB_PREFIX.$tablename;
8898 $sql .=
" WHERE ".$fieldkey.
" = '".$db->escape($key).
"'";
8899 if (!empty($entityfilter)) {
8900 $sql .=
" AND entity IN (".getEntity($tablename).
")";
8906 $resql = $db->query($sql);
8908 $obj = $db->fetch_object(
$resql);
8910 $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget;
8912 $cache_codes[$tablename][$key][$fieldid] =
'';
8915 return $cache_codes[$tablename][$key][$fieldid];
8929 global $user, $conf, $langs;
8935 if (isset($strToEvaluate) && $strToEvaluate !==
'') {
8937 $rep =
dol_eval($strToEvaluate, 1, 1,
'1');
8938 $rights = $rep && (!is_string($rep) || strpos($rep,
'Bad string syntax to evaluate') ===
false);
8954 function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring =
'1')
8957 global $db, $langs, $user, $conf, $website, $websitepage;
8958 global $action, $mainmenu, $leftmenu;
8960 global $objectoffield;
8970 if ($onlysimplestring ==
'1') {
8974 if (preg_match(
'/[^a-z0-9\s'.preg_quote(
'^$_+-.*>&|=!?():"\',/@',
'/').
']/i', $s)) {
8976 return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s;
8978 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s);
8985 } elseif ($onlysimplestring ==
'2') {
8987 if (preg_match(
'/[^a-z0-9\s'.preg_quote(
'^$_+-.*>&|=!?():"\',/@;[]',
'/').
']/i', $s)) {
8989 return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s;
8991 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s);
8996 if (is_array($s) || $s ===
'Array') {
8997 return 'Bad string syntax to evaluate (value is Array) '.var_export($s,
true);
8999 if (strpos($s,
'::') !==
false) {
9001 return 'Bad string syntax to evaluate (double : char is forbidden): '.$s;
9003 dol_syslog(
'Bad string syntax to evaluate (double : char is forbidden): '.$s);
9007 if (strpos($s,
'`') !==
false) {
9009 return 'Bad string syntax to evaluate (backtick char is forbidden): '.$s;
9011 dol_syslog(
'Bad string syntax to evaluate (backtick char is forbidden): '.$s);
9015 if (preg_match(
'/[^0-9]+\.[^0-9]+/', $s)) {
9017 return 'Bad string syntax to evaluate (dot char is forbidden): '.$s;
9019 dol_syslog(
'Bad string syntax to evaluate (dot char is forbidden): '.$s);
9025 $forbiddenphpstrings = array(
'$$');
9026 $forbiddenphpstrings = array_merge($forbiddenphpstrings, array(
'_ENV',
'_SESSION',
'_COOKIE',
'_GET',
'_POST',
'_REQUEST'));
9028 $forbiddenphpfunctions = array(
"exec",
"passthru",
"shell_exec",
"system",
"proc_open",
"popen");
9029 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_eval",
"executeCLI",
"verifCond"));
9030 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"base64_decode",
"rawurldecode",
"urldecode"));
9031 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"fopen",
"file_put_contents",
"fputs",
"fputscsv",
"fwrite",
"fpassthru",
"require",
"include",
"mkdir",
"rmdir",
"symlink",
"touch",
"unlink",
"umask"));
9032 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"get_defined_functions",
"get_defined_vars",
"get_defined_constants",
"get_declared_classes"));
9033 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"function",
"call_user_func"));
9034 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"eval",
"create_function",
"assert",
"mb_ereg_replace"));
9036 $forbiddenphpregex =
'global\s+\$|\b('.implode(
'|', $forbiddenphpfunctions).
')\b';
9039 $oldstringtoclean = $s;
9040 $s = str_ireplace($forbiddenphpstrings,
'__forbiddenstring__', $s);
9041 $s = preg_replace(
'/'.$forbiddenphpregex.
'/i',
'__forbiddenstring__', $s);
9043 }
while ($oldstringtoclean != $s);
9045 if (strpos($s,
'__forbiddenstring__') !==
false) {
9046 dol_syslog(
'Bad string syntax to evaluate: '.$s, LOG_WARNING);
9048 return 'Bad string syntax to evaluate: '.$s;
9050 dol_syslog(
'Bad string syntax to evaluate: '.$s);
9058 return @eval(
'return '.$s.
';');
9060 return eval(
'return '.$s.
';');
9069 }
catch (Error $e) {
9070 $error =
'dol_eval try/catch error : ';
9071 $error .= $e->getMessage();
9087 return (trim($element) !=
'');
9100 if (empty($codelang)) {
9104 if ($codelang ==
'auto') {
9105 return '<span class="fa fa-language"></span>';
9108 $langtocountryflag = array(
9110 'ca_ES' =>
'catalonia',
9114 'sw_SW' =>
'unknown',
9124 if (isset($langtocountryflag[$codelang])) {
9125 $flagImage = $langtocountryflag[$codelang];
9127 $tmparray = explode(
'_', $codelang);
9128 $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
9131 return img_picto_common($codelang,
'flags/'.strtolower($flagImage).
'.png', $moreatt, 0, $notitlealt);
9145 if (empty($countrycode)) {
9149 if (strtoupper($countrycode) ==
'MQ') {
9152 if (strtoupper($countrycode) ==
'SE') {
9155 if (strtoupper($countrycode) ==
'CH') {
9156 if ($mysoc->country_code ==
'FR') {
9159 if ($mysoc->country_code ==
'DE') {
9162 if ($mysoc->country_code ==
'IT') {
9344 $buildprimarykeytotest = strtolower($countrycode).
'-'.strtoupper($countrycode);
9345 if (in_array($buildprimarykeytotest, $locales)) {
9346 return strtolower($countrycode).
'_'.strtoupper($countrycode);
9349 if (function_exists(
'locale_get_primary_language') && function_exists(
'locale_get_region')) {
9350 foreach ($locales as $locale) {
9351 $locale_language = locale_get_primary_language($locale);
9352 $locale_region = locale_get_region($locale);
9353 if (strtoupper($countrycode) == $locale_region) {
9355 return strtolower($locale_language).
'_'.strtoupper($locale_region);
9359 dol_syslog(
"Warning Exention php-intl is not available", LOG_WARNING);
9397 global $hookmanager, $db;
9399 if (isset($conf->modules_parts[
'tabs'][$type]) && is_array($conf->modules_parts[
'tabs'][$type])) {
9400 foreach ($conf->modules_parts[
'tabs'][$type] as $value) {
9401 $values = explode(
':', $value);
9404 if ($mode ==
'add' && !preg_match(
'/^\-/', $values[1])) {
9405 if (count($values) == 6) {
9409 if ($values[0] != $type) {
9415 if ($filterorigmodule) {
9416 if (strpos($values[3],
'@')) {
9417 if ($filterorigmodule !=
'external') {
9421 if ($filterorigmodule !=
'core') {
9426 $langs->load($values[3]);
9428 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
9430 $substitutionarray = array();
9435 $labeltemp = explode(
',', $values[2]);
9436 $label = $langs->trans($labeltemp[0]);
9438 if (!empty($labeltemp[1]) && is_object($object) && !empty($object->id)) {
9440 $classtoload = $labeltemp[1];
9441 if (class_exists($classtoload)) {
9442 $obj =
new $classtoload($db);
9443 $function = $labeltemp[3];
9444 if ($obj && $function && method_exists($obj, $function)) {
9445 $nbrec = $obj->$function($object->id, $obj);
9446 $label .=
'<span class="badge marginleftonlyshort">'.$nbrec.
'</span>';
9452 $head[$h][0] =
dol_buildpath(preg_replace(
'/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id :
''), $values[5]), 1);
9453 $head[$h][1] = $label;
9454 $head[$h][2] = str_replace(
'+',
'', $values[1]);
9457 } elseif (count($values) == 5) {
9458 dol_syslog(
'Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
9460 if ($values[0] != $type) {
9464 if ($filterorigmodule) {
9465 if (strpos($values[3],
'@')) {
9466 if ($filterorigmodule !=
'external') {
9470 if ($filterorigmodule !=
'core') {
9475 $langs->load($values[3]);
9477 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
9478 $substitutionarray = array();
9482 $label = $langs->trans($values[2]);
9485 $head[$h][0] =
dol_buildpath(preg_replace(
'/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id :
''), $values[4]), 1);
9486 $head[$h][1] = $label;
9487 $head[$h][2] = str_replace(
'+',
'', $values[1]);
9490 } elseif ($mode ==
'remove' && preg_match(
'/^\-/', $values[1])) {
9491 if ($values[0] != $type) {
9494 $tabname = str_replace(
'-',
'', $values[1]);
9495 foreach ($head as $key => $val) {
9496 $condition = (!empty($values[3]) ?
verifCond($values[3]) : 1);
9498 if ($head[$key][2] == $tabname && $condition) {
9508 if (!empty($hookmanager)) {
9509 $parameters = array(
'object' => $object,
'mode' => $mode,
'head' => &$head,
'filterorigmodule' => $filterorigmodule);
9510 $reshook = $hookmanager->executeHooks(
'completeTabsHead', $parameters);
9512 $head = $hookmanager->resArray;
9514 $head = array_merge($head, $hookmanager->resArray);
9533 global $conf, $hookmanager, $user, $debugbar;
9535 global $micro_start_time;
9537 if ($zone ==
'private') {
9538 print
"\n".
'<!-- Common footer for private page -->'.
"\n";
9540 print
"\n".
'<!-- Common footer for public page -->'.
"\n";
9544 print
"\n<!-- A div to store page_y POST parameter -->\n";
9545 print
'<div id="page_y" style="display: none;">'.(GETPOST(
'page_y') ?
GETPOST(
'page_y') :
'').
'</div>'.
"\n";
9547 $parameters = array();
9548 $reshook = $hookmanager->executeHooks(
'printCommonFooter', $parameters);
9549 if (empty($reshook)) {
9550 if (!empty($conf->global->MAIN_HTML_FOOTER)) {
9551 print $conf->global->MAIN_HTML_FOOTER.
"\n";
9555 if (!empty($conf->use_javascript_ajax)) {
9556 print
"\n<!-- A script section to add menuhider handler on backoffice, manage focus and madatory fields, tuning info, ... -->\n";
9557 print
'<script>'.
"\n";
9558 print
'jQuery(document).ready(function() {'.
"\n";
9560 if ($zone ==
'private' && empty($conf->dol_use_jmobile)) {
9562 print
'/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'.
"\n";
9563 print
'jQuery("li.menuhider").click(function(event) {';
9564 print
' if (!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'.
"\n";
9565 print
' console.log("We click on .menuhider");'.
"\n";
9566 print
' $("body").toggleClass("sidebar-collapse")'.
"\n";
9571 if ($action ==
'create' || $action ==
'edit' || (empty($action) && (preg_match(
'/new\.php/', $_SERVER[
"PHP_SELF"])))) {
9572 print
'/* JS CODE TO ENABLE to manage focus and mandatory form fields */'.
"\n";
9573 $relativepathstring = $_SERVER[
"PHP_SELF"];
9575 if (constant(
'DOL_URL_ROOT')) {
9576 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
9578 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
9579 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
9581 if (!empty($user->default_values[$relativepathstring][
'focus'])) {
9582 foreach ($user->default_values[$relativepathstring][
'focus'] as $defkey => $defval) {
9584 if ($defkey !=
'_noquery_') {
9585 $tmpqueryarraytohave = explode(
'&', $defkey);
9587 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
9588 $tmpquerytohaveparam = explode(
'=', $tmpquerytohave);
9590 if (!
GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] !=
GETPOST($tmpquerytohaveparam[0]))) {
9603 foreach ($defval as $paramkey => $paramval) {
9605 print
'jQuery("input[name=\''.$paramkey.
'\']
").focus();'."\n
";
9606 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").focus();'."\n
";
9607 print 'jQuery("select[
name=\
''.$paramkey.
'\']
").focus();'."\n
"; // Not really usefull, but we keep it in case of.
9612 if (!empty($user->default_values[$relativepathstring]['mandatory'])) {
9613 foreach ($user->default_values[$relativepathstring]['mandatory'] as $defkey => $defval) {
9615 if ($defkey != '_noquery_') {
9616 $tmpqueryarraytohave = explode('&', $defkey);
9618 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
9619 $tmpquerytohaveparam = explode('=', $tmpquerytohave);
9620 //print "console.log(
'".$tmpquerytohaveparam[0]." ".$tmpquerytohaveparam[1]." ".GETPOST($tmpquerytohaveparam[0])."');
";
9621 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] != GETPOST($tmpquerytohaveparam[0]))) {
9628 //var_dump($defkey.'-'.$qualified);
9634 foreach ($defval as $paramkey => $paramval) {
9635 // Add property 'required' on input
9636 print 'jQuery("input[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
9637 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
9638 print '// required on a select works only if key is "", so we add the required attributes but also we reset the key -1 or 0 to an empty string'."\n
";
9639 print 'jQuery("select[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
9640 print 'jQuery("select[
name=\
''.$paramkey.
'\'] option[value=\
'-1\']").prop(\'value\', \'\');'.
"\n";
9641 print
'jQuery("select[name=\''.$paramkey.
'\'] option[value=\
'0\']").prop(\'value\', \'\');'.
"\n";
9644 print
'jQuery(":input[name=\'' . $paramkey .
'\']
").closest("tr
").find("td:first
").addClass("fieldrequired
");' . "\n
";
9654 if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO']) || !empty($conf->global->MAIN_SHOW_TUNING_INFO)) {
9657 print 'window.console && console.log("';
9658 if (!empty($conf->global->MEMCACHED_SERVER)) {
9659 print 'MEMCACHED_SERVER=
'.$conf->global->MEMCACHED_SERVER.' -
';
9661 print 'MAIN_OPTIMIZE_SPEED=
'.(isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off
');
9662 if (!empty($micro_start_time)) { // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable.
9663 $micro_end_time = microtime(true);
9664 print ' - Build time:
'.ceil(1000 * ($micro_end_time - $micro_start_time)).' ms
';
9667 if (function_exists("memory_get_usage")) {
9668 print ' - Mem:
'.memory_get_usage(); // Do not use true here, it seems it takes the peak amount
9670 if (function_exists("memory_get_peak_usage")) {
9671 print ' - Real mem peak:
'.memory_get_peak_usage(true);
9673 if (function_exists("zend_loader_file_encoded")) {
9674 print ' - Zend encoded file:
'.(zend_loader_file_encoded() ? 'yes
' : 'no
');
9679 print "\n
".'</script>'."\n
";
9682 // TODO Add a hook here
9683 if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) {
9684 $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID);
9685 foreach ($tmptagarray as $tmptag) {
9687 print "<!-- JS CODE TO ENABLE
for google analtics tag -->\n
";
9689 <!-- Global site tag (gtag.js) - Google Analytics -->
9690 <script async src=\
"https://www.googletagmanager.com/gtag/js?id=".trim($tmptag).
"\"></script>
9692 window.dataLayer = window.dataLayer || [];
9693 function gtag(){dataLayer.push(arguments);}
9694 gtag('js', new Date());
9696 gtag('config', '".trim($tmptag).
"');
9704 if (defined(
'XDEBUGCOVERAGE')) {
9705 print_r(xdebug_get_code_coverage());
9709 if (!empty($user->rights->debugbar->read) && is_object($debugbar)) {
9710 $debugbar[
'time']->stopMeasure(
'pageaftermaster');
9711 print
'<!-- Output debugbar data -->'.
"\n";
9712 $renderer = $debugbar->getRenderer();
9713 print $debugbar->getRenderer()->render();
9714 } elseif (count($conf->logbuffer)) {
9716 print
"<!-- Start of log output\n";
9718 foreach ($conf->logbuffer as $logline) {
9719 print $logline.
"<br>\n";
9722 print
"End of log output -->\n";
9738 if ($a = explode($delimiter, $string)) {
9740 foreach ($a as $s) {
9742 if ($pos = strpos($s, $kv)) {
9743 $ka[trim(substr($s, 0, $pos))] = trim(substr($s, $pos + strlen($kv)));
9763 print
"\n".
'<!-- Set focus onto a specific field -->'.
"\n";
9764 print
'<script>jQuery(document).ready(function() { jQuery("'.dol_escape_js($selector).
'").focus(); });</script>'.
"\n";
9777 if (!function_exists(
'getmypid')) {
9778 return mt_rand(99900000, 99965535);
9806 $value = trim($value);
9809 $value = preg_replace(
'/\*/',
'%', $value);
9812 $value = preg_replace(
'/([!<>=]+)\s+([0-9'.preg_quote($langs->trans(
"DecimalSeparator"),
'/').
'\-])/',
'\1\2', $value);
9815 $value = preg_replace(
'/\s*\|\s*/',
'|', $value);
9817 $crits = explode(
' ', $value);
9819 if (!is_array($fields)) {
9820 $fields = array($fields);
9824 foreach ($crits as $crit) {
9825 $crit = trim($crit);
9828 foreach ($fields as $field) {
9830 $tmpcrits = explode(
'|', $crit);
9832 foreach ($tmpcrits as $tmpcrit) {
9833 if ($tmpcrit !==
'0' && empty($tmpcrit)) {
9836 $tmpcrit = trim($tmpcrit);
9838 $newres .= (($i2 > 0 || $i3 > 0) ?
' OR ' :
'');
9841 $newcrit = preg_replace(
'/([!<>=]+)/',
'', $tmpcrit);
9844 preg_match(
'/([!<>=]+)/', $tmpcrit, $reg);
9845 if (!empty($reg[1])) {
9846 $operator = $reg[1];
9848 if ($newcrit !=
'') {
9850 if (is_numeric($numnewcrit)) {
9851 $newres .= $field.
' '.$operator.
' '.((
float) $numnewcrit);
9859 } elseif ($mode == 2 || $mode == -2) {
9860 $crit = preg_replace(
'/[^0-9,]/',
'', $crit);
9861 $newres .= ($i2 > 0 ?
' OR ' :
'').$field.
" ".($mode == -2 ?
'NOT ' :
'');
9862 $newres .= $crit ?
"IN (".$db->sanitize($db->escape($crit)).
")" :
"IN (0)";
9864 $newres .=
' OR '.$field.
' IS NULL';
9867 } elseif ($mode == 3 || $mode == -3) {
9868 $tmparray = explode(
',', $crit);
9869 if (count($tmparray)) {
9871 foreach ($tmparray as $val) {
9874 $listofcodes .= ($listofcodes ?
',' :
'');
9875 $listofcodes .=
"'".$db->escape($val).
"'";
9878 $newres .= ($i2 > 0 ?
' OR ' :
'').$field.
" ".($mode == -3 ?
'NOT ' :
'').
"IN (".$db->sanitize($listofcodes, 1).
")";
9882 $newres .=
' OR '.$field.
' IS NULL';
9884 } elseif ($mode == 4) {
9885 $tmparray = explode(
',', $crit);
9886 if (count($tmparray)) {
9888 foreach ($tmparray as $val) {
9891 $newres .= ($i2 > 0 ?
" OR (" :
"(").$field.
" LIKE '".$db->escape($val).
",%'";
9892 $newres .=
' OR '.$field.
" = '".$db->escape($val).
"'";
9893 $newres .=
' OR '.$field.
" LIKE '%,".$db->escape($val).
"'";
9894 $newres .=
' OR '.$field.
" LIKE '%,".$db->escape($val).
",%'";
9901 $tmpcrits = explode(
'|', $crit);
9903 foreach ($tmpcrits as $tmpcrit) {
9904 if ($tmpcrit !==
'0' && empty($tmpcrit)) {
9907 $tmpcrit = trim($tmpcrit);
9909 if ($tmpcrit ==
'^$' || strpos($crit,
'!') === 0) {
9910 $newres .= (($i2 > 0 || $i3 > 0) ?
' AND ' :
'');
9912 $newres .= (($i2 > 0 || $i3 > 0) ?
' OR ' :
'');
9915 if (preg_match(
'/\.(id|rowid)$/', $field)) {
9916 $newres .= $field.
" = ".(is_numeric($tmpcrit) ? ((
float) $tmpcrit) :
'0');
9918 $tmpcrit2 = $tmpcrit;
9923 if (preg_match(
'/^!/', $tmpcrit)) {
9924 $tmps .= $field.
" NOT LIKE ";
9925 $tmpcrit2 = preg_replace(
'/^!/',
'', $tmpcrit2);
9927 $tmps .= $field.
" LIKE ";
9931 if (preg_match(
'/^[\^\$]/', $tmpcrit)) {
9933 $tmpcrit2 = preg_replace(
'/^[\^\$]/',
'', $tmpcrit2);
9935 if (preg_match(
'/[\^\$]$/', $tmpcrit)) {
9937 $tmpcrit2 = preg_replace(
'/[\^\$]$/',
'', $tmpcrit2);
9940 if ($tmpcrit2 ==
'' || preg_match(
'/^!/', $tmpcrit)) {
9944 $newres .= $tmpbefore;
9945 $newres .= $db->escape($tmpcrit2);
9946 $newres .= $tmpafter;
9948 if ($tmpcrit2 ==
'' || preg_match(
'/^!/', $tmpcrit)) {
9949 $newres .=
" OR ".$field.
" IS NULL)";
9961 $res = $res.($res ?
' AND ' :
'').($i2 > 1 ?
'(' :
'').$newres.($i2 > 1 ?
')' :
'');
9965 $res = ($nofirstand ?
"" :
" AND ").
"(".$res.
")";
9978 global $conf, $langs;
9981 $url = $object->getLastMainDocLink($object->element);
9983 $out .=
img_picto($langs->trans(
"PublicDownloadLinkDesc"),
'globe').
' <span class="opacitymedium">'.$langs->trans(
"DirectDownloadLink").
'</span><br>';
9985 $out .=
'<div class="urllink"><input type="text" id="directdownloadlink" class="quatrevingtpercent" value="'.$url.
'"></div>';
9988 $out .=
'<div class="urllink">'.$langs->trans(
"FileNotShared").
'</div>';
10004 $dirName = dirname($file);
10005 if ($dirName ==
'.') {
10009 $fileName = preg_replace(
'/(\.gif|\.jpeg|\.jpg|\.png|\.bmp|\.webp)$/i',
'', $file);
10010 $fileName = basename($fileName);
10012 if (empty($extImgTarget)) {
10013 $extImgTarget = (preg_match(
'/\.jpg$/i', $file) ?
'.jpg' :
'');
10015 if (empty($extImgTarget)) {
10016 $extImgTarget = (preg_match(
'/\.jpeg$/i', $file) ?
'.jpeg' :
'');
10018 if (empty($extImgTarget)) {
10019 $extImgTarget = (preg_match(
'/\.gif$/i', $file) ?
'.gif' :
'');
10021 if (empty($extImgTarget)) {
10022 $extImgTarget = (preg_match(
'/\.png$/i', $file) ?
'.png' :
'');
10024 if (empty($extImgTarget)) {
10025 $extImgTarget = (preg_match(
'/\.bmp$/i', $file) ?
'.bmp' :
'');
10027 if (empty($extImgTarget)) {
10028 $extImgTarget = (preg_match(
'/\.webp$/i', $file) ?
'.webp' :
'');
10031 if (!$extImgTarget) {
10037 $subdir =
'thumbs/';
10040 return ($dirName ? $dirName.
'/' :
'').$subdir.$fileName.$extName.$extImgTarget;
10055 global $conf, $langs;
10057 if (empty($conf->use_javascript_ajax)) {
10063 if ($alldata == 1) {
10064 if ($isAllowedForPreview) {
10065 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));
10072 if ($isAllowedForPreview) {
10073 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')).
'\')
';
10088 function ajax_autoselect($htmlname, $addlink = '', $textonlink = 'Link')
10092 jQuery(document).ready(
function () {
10093 jQuery(
"'.((strpos($htmlname, '.') === 0 ? '' : '#').$htmlname).'").click(
function() { jQuery(
this).select(); } );
10097 if ($textonlink === 'image
') {
10098 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.img_picto('', 'globe
').'</a>
';
10100 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.$langs->trans("Link").'</a>
';
10113 function dolIsAllowedForPreview($file)
10117 // Check .noexe extension in filename
10118 if (preg_match('/\.noexe$/i
', $file)) {
10122 // Check mime types
10123 $mime_preview = array('bmp
', 'jpeg
', 'png
', 'gif
', 'tiff
', 'pdf
', 'plain
', 'css
', 'webp
');
10124 if (!empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) {
10125 $mime_preview[] = 'svg+xml
';
10127 //$mime_preview[]='vnd.oasis.opendocument.presentation
';
10128 //$mime_preview[]='archive
';
10129 $num_mime = array_search(dol_mimetype($file, '', 1), $mime_preview);
10130 if ($num_mime !== false) {
10134 // By default, not allowed for preview
10148 function dol_mimetype($file, $default = 'application/octet-stream
', $mode = 0)
10151 $imgmime = 'other.png
';
10152 $famime = 'file-o
';
10155 $tmpfile = preg_replace('/\.noexe$/
', '', $file);
10157 // Plain text files
10158 if (preg_match('/\.txt$/i
', $tmpfile)) {
10159 $mime = 'text/plain
';
10160 $imgmime = 'text.png
';
10161 $famime = 'file-text-o
';
10163 if (preg_match('/\.rtx$/i
', $tmpfile)) {
10164 $mime = 'text/richtext
';
10165 $imgmime = 'text.png
';
10166 $famime = 'file-text-o
';
10168 if (preg_match('/\.csv$/i
', $tmpfile)) {
10169 $mime = 'text/csv
';
10170 $imgmime = 'text.png
';
10171 $famime = 'file-text-o
';
10173 if (preg_match('/\.tsv$/i
', $tmpfile)) {
10174 $mime = 'text/tab-separated-values
';
10175 $imgmime = 'text.png
';
10176 $famime = 'file-text-o
';
10178 if (preg_match('/\.(cf|
conf|log)$/i
', $tmpfile)) {
10179 $mime = 'text/plain
';
10180 $imgmime = 'text.png
';
10181 $famime = 'file-text-o
';
10183 if (preg_match('/\.ini$/i
', $tmpfile)) {
10184 $mime = 'text/plain
';
10185 $imgmime = 'text.png
';
10187 $famime = 'file-text-o
';
10189 if (preg_match('/\.md$/i
', $tmpfile)) {
10190 $mime = 'text/plain
';
10191 $imgmime = 'text.png
';
10193 $famime = 'file-text-o
';
10195 if (preg_match('/\.css$/i
', $tmpfile)) {
10196 $mime = 'text/css
';
10197 $imgmime = 'css.png
';
10199 $famime = 'file-text-o
';
10201 if (preg_match('/\.lang$/i
', $tmpfile)) {
10202 $mime = 'text/plain
';
10203 $imgmime = 'text.png
';
10205 $famime = 'file-text-o
';
10207 // Certificate files
10208 if (preg_match('/\.(crt|cer|key|pub)$/i
', $tmpfile)) {
10209 $mime = 'text/plain
';
10210 $imgmime = 'text.png
';
10211 $famime = 'file-text-o
';
10213 // XML based (HTML/XML/XAML)
10214 if (preg_match('/\.(html|htm|shtml)$/i
', $tmpfile)) {
10215 $mime = 'text/html
';
10216 $imgmime = 'html.png
';
10218 $famime = 'file-text-o
';
10220 if (preg_match('/\.(xml|xhtml)$/i
', $tmpfile)) {
10221 $mime = 'text/xml
';
10222 $imgmime = 'other.png
';
10224 $famime = 'file-text-o
';
10226 if (preg_match('/\.xaml$/i
', $tmpfile)) {
10227 $mime = 'text/xml
';
10228 $imgmime = 'other.png
';
10230 $famime = 'file-text-o
';
10233 if (preg_match('/\.bas$/i
', $tmpfile)) {
10234 $mime = 'text/plain
';
10235 $imgmime = 'text.png
';
10237 $famime = 'file-
code-o
';
10239 if (preg_match('/\.(c)$/i
', $tmpfile)) {
10240 $mime = 'text/plain
';
10241 $imgmime = 'text.png
';
10243 $famime = 'file-
code-o
';
10245 if (preg_match('/\.(cpp)$/i
', $tmpfile)) {
10246 $mime = 'text/plain
';
10247 $imgmime = 'text.png
';
10249 $famime = 'file-
code-o
';
10251 if (preg_match('/\.cs$/i
', $tmpfile)) {
10252 $mime = 'text/plain
';
10253 $imgmime = 'text.png
';
10255 $famime = 'file-
code-o
';
10257 if (preg_match('/\.(h)$/i
', $tmpfile)) {
10258 $mime = 'text/plain
';
10259 $imgmime = 'text.png
';
10261 $famime = 'file-
code-o
';
10263 if (preg_match('/\.(java|jsp)$/i
', $tmpfile)) {
10264 $mime = 'text/plain
';
10265 $imgmime = 'text.png
';
10267 $famime = 'file-
code-o
';
10269 if (preg_match('/\.php([0-9]{1})?$/i
', $tmpfile)) {
10270 $mime = 'text/plain
';
10271 $imgmime = 'php.png
';
10273 $famime = 'file-
code-o
';
10275 if (preg_match('/\.phtml$/i
', $tmpfile)) {
10276 $mime = 'text/plain
';
10277 $imgmime = 'php.png
';
10279 $famime = 'file-
code-o
';
10281 if (preg_match('/\.(pl|pm)$/i
', $tmpfile)) {
10282 $mime = 'text/plain
';
10283 $imgmime = 'pl.png
';
10285 $famime = 'file-
code-o
';
10287 if (preg_match('/\.sql$/i
', $tmpfile)) {
10288 $mime = 'text/plain
';
10289 $imgmime = 'text.png
';
10291 $famime = 'file-
code-o
';
10293 if (preg_match('/\.js$/i
', $tmpfile)) {
10294 $mime = 'text/x-javascript
';
10295 $imgmime = 'jscript.png
';
10297 $famime = 'file-
code-o
';
10300 if (preg_match('/\.odp$/i
', $tmpfile)) {
10301 $mime = 'application/vnd.oasis.opendocument.presentation
';
10302 $imgmime = 'ooffice.png
';
10303 $famime = 'file-powerpoint-o
';
10305 if (preg_match('/\.ods$/i
', $tmpfile)) {
10306 $mime = 'application/vnd.oasis.opendocument.spreadsheet
';
10307 $imgmime = 'ooffice.png
';
10308 $famime = 'file-excel-o
';
10310 if (preg_match('/\.odt$/i
', $tmpfile)) {
10311 $mime = 'application/vnd.oasis.opendocument.text
';
10312 $imgmime = 'ooffice.png
';
10313 $famime = 'file-word-o
';
10316 if (preg_match('/\.mdb$/i
', $tmpfile)) {
10317 $mime = 'application/msaccess
';
10318 $imgmime = 'mdb.png
';
10319 $famime = 'file-o
';
10321 if (preg_match('/\.doc(x|m)?$/i
', $tmpfile)) {
10322 $mime = 'application/msword
';
10323 $imgmime = 'doc.png
';
10324 $famime = 'file-word-o
';
10326 if (preg_match('/\.dot(x|m)?$/i
', $tmpfile)) {
10327 $mime = 'application/msword
';
10328 $imgmime = 'doc.png
';
10329 $famime = 'file-word-o
';
10331 if (preg_match('/\.xlt(x)?$/i
', $tmpfile)) {
10332 $mime = 'application/vnd.ms-excel
';
10333 $imgmime = 'xls.png
';
10334 $famime = 'file-excel-o
';
10336 if (preg_match('/\.xla(m)?$/i
', $tmpfile)) {
10337 $mime = 'application/vnd.ms-excel
';
10338 $imgmime = 'xls.png
';
10339 $famime = 'file-excel-o
';
10341 if (preg_match('/\.xls$/i
', $tmpfile)) {
10342 $mime = 'application/vnd.ms-excel
';
10343 $imgmime = 'xls.png
';
10344 $famime = 'file-excel-o
';
10346 if (preg_match('/\.xls(b|m|x)$/i
', $tmpfile)) {
10347 $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
';
10348 $imgmime = 'xls.png
';
10349 $famime = 'file-excel-o
';
10351 if (preg_match('/\.pps(m|x)?$/i
', $tmpfile)) {
10352 $mime = 'application/vnd.ms-powerpoint
';
10353 $imgmime = 'ppt.png
';
10354 $famime = 'file-powerpoint-o
';
10356 if (preg_match('/\.ppt(m|x)?$/i
', $tmpfile)) {
10357 $mime = 'application/x-mspowerpoint
';
10358 $imgmime = 'ppt.png
';
10359 $famime = 'file-powerpoint-o
';
10362 if (preg_match('/\.pdf$/i
', $tmpfile)) {
10363 $mime = 'application/pdf
';
10364 $imgmime = 'pdf.png
';
10365 $famime = 'file-pdf-o
';
10368 if (preg_match('/\.bat$/i
', $tmpfile)) {
10369 $mime = 'text/x-bat
';
10370 $imgmime = 'script.png
';
10372 $famime = 'file-
code-o
';
10374 if (preg_match('/\.sh$/i
', $tmpfile)) {
10375 $mime = 'text/x-sh
';
10376 $imgmime = 'script.png
';
10378 $famime = 'file-
code-o
';
10380 if (preg_match('/\.ksh$/i
', $tmpfile)) {
10381 $mime = 'text/x-ksh
';
10382 $imgmime = 'script.png
';
10384 $famime = 'file-
code-o
';
10386 if (preg_match('/\.bash$/i
', $tmpfile)) {
10387 $mime = 'text/x-bash
';
10388 $imgmime = 'script.png
';
10390 $famime = 'file-
code-o
';
10393 if (preg_match('/\.ico$/i
', $tmpfile)) {
10394 $mime = 'image/x-icon
';
10395 $imgmime = 'image.png
';
10396 $famime = 'file-image-o
';
10398 if (preg_match('/\.(jpg|jpeg)$/i
', $tmpfile)) {
10399 $mime = 'image/jpeg
';
10400 $imgmime = 'image.png
';
10401 $famime = 'file-image-o
';
10403 if (preg_match('/\.png$/i
', $tmpfile)) {
10404 $mime = 'image/png
';
10405 $imgmime = 'image.png
';
10406 $famime = 'file-image-o
';
10408 if (preg_match('/\.gif$/i
', $tmpfile)) {
10409 $mime = 'image/gif
';
10410 $imgmime = 'image.png
';
10411 $famime = 'file-image-o
';
10413 if (preg_match('/\.bmp$/i
', $tmpfile)) {
10414 $mime = 'image/bmp
';
10415 $imgmime = 'image.png
';
10416 $famime = 'file-image-o
';
10418 if (preg_match('/\.(tif|tiff)$/i
', $tmpfile)) {
10419 $mime = 'image/tiff
';
10420 $imgmime = 'image.png
';
10421 $famime = 'file-image-o
';
10423 if (preg_match('/\.svg$/i
', $tmpfile)) {
10424 $mime = 'image/svg+xml
';
10425 $imgmime = 'image.png
';
10426 $famime = 'file-image-o
';
10428 if (preg_match('/\.webp$/i
', $tmpfile)) {
10429 $mime = 'image/webp
';
10430 $imgmime = 'image.png
';
10431 $famime = 'file-image-o
';
10434 if (preg_match('/\.vcs$/i
', $tmpfile)) {
10435 $mime = 'text/calendar
';
10436 $imgmime = 'other.png
';
10437 $famime = 'file-text-o
';
10439 if (preg_match('/\.ics$/i
', $tmpfile)) {
10440 $mime = 'text/calendar
';
10441 $imgmime = 'other.png
';
10442 $famime = 'file-text-o
';
10445 if (preg_match('/\.torrent$/i
', $tmpfile)) {
10446 $mime = 'application/x-bittorrent
';
10447 $imgmime = 'other.png
';
10448 $famime = 'file-o
';
10451 if (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i
', $tmpfile)) {
10453 $imgmime = 'audio.png
';
10454 $famime = 'file-audio-o
';
10457 if (preg_match('/\.mp4$/i
', $tmpfile)) {
10458 $mime = 'video/mp4
';
10459 $imgmime = 'video.png
';
10460 $famime = 'file-video-o
';
10462 if (preg_match('/\.ogv$/i
', $tmpfile)) {
10463 $mime = 'video/ogg
';
10464 $imgmime = 'video.png
';
10465 $famime = 'file-video-o
';
10467 if (preg_match('/\.webm$/i
', $tmpfile)) {
10468 $mime = 'video/webm
';
10469 $imgmime = 'video.png
';
10470 $famime = 'file-video-o
';
10472 if (preg_match('/\.avi$/i
', $tmpfile)) {
10473 $mime = 'video/x-msvideo
';
10474 $imgmime = 'video.png
';
10475 $famime = 'file-video-o
';
10477 if (preg_match('/\.divx$/i
', $tmpfile)) {
10478 $mime = 'video/divx
';
10479 $imgmime = 'video.png
';
10480 $famime = 'file-video-o
';
10482 if (preg_match('/\.xvid$/i
', $tmpfile)) {
10483 $mime = 'video/xvid
';
10484 $imgmime = 'video.png
';
10485 $famime = 'file-video-o
';
10487 if (preg_match('/\.(wmv|mpg|mpeg)$/i
', $tmpfile)) {
10489 $imgmime = 'video.png
';
10490 $famime = 'file-video-o
';
10493 if (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh|zst)$/i
', $tmpfile)) {
10495 $imgmime = 'archive.png
';
10496 $famime = 'file-archive-o
';
10497 } // application/xxx where zzz is zip, ...
10499 if (preg_match('/\.(exe|com)$/i
', $tmpfile)) {
10500 $mime = 'application/octet-stream
';
10501 $imgmime = 'other.png
';
10502 $famime = 'file-o
';
10505 if (preg_match('/\.(dll|lib|o|so|a)$/i
', $tmpfile)) {
10507 $imgmime = 'library.png
';
10508 $famime = 'file-o
';
10511 if (preg_match('/\.err$/i
', $tmpfile)) {
10513 $imgmime = 'error.png
';
10514 $famime = 'file-text-o
';
10519 $tmp = explode('/
', $mime);
10520 return (!empty($tmp[1]) ? $tmp[1] : $tmp[0]);
10545 function getDictionaryValue($tablename, $field, $id, $checkentity = false, $rowidfield = 'rowid')
10549 $tablename = preg_replace('/^
'.preg_quote(MAIN_DB_PREFIX, '/
').'/
', '', $tablename); // Clean name of table for backward compatibility.
10551 $dictvalues = (isset($conf->cache['dictvalues_
'.$tablename]) ? $conf->cache['dictvalues_
'.$tablename] : null);
10553 if (is_null($dictvalues)) {
10554 $dictvalues = array();
10556 $sql = "SELECT * FROM ".MAIN_DB_PREFIX.$tablename." WHERE 1 = 1"; // Here select * is allowed as it is generic code and we don't have list of fields
10557 if ($checkentity) {
10558 $sql .=
' AND entity IN (0,'.getEntity($tablename).
')';
10561 $resql = $db->query($sql);
10563 while ($obj = $db->fetch_object(
$resql)) {
10564 $dictvalues[$obj->{$rowidfield}] = $obj;
10570 $conf->cache[
'dictvalues_'.$tablename] = $dictvalues;
10573 if (!empty($dictvalues[$id])) {
10575 $tmp = $dictvalues[$id];
10576 return (property_exists($tmp, $field) ? $tmp->$field :
'');
10591 $stringcolor = str_replace(
'#',
'', $stringcolor);
10593 if (!empty($stringcolor)) {
10595 $tmp = explode(
',', $stringcolor);
10596 if (count($tmp) > 1) {
10601 $hexr = $stringcolor[0].$stringcolor[1];
10602 $hexg = $stringcolor[2].$stringcolor[3];
10603 $hexb = $stringcolor[4].$stringcolor[5];
10604 $r = hexdec($hexr);
10605 $g = hexdec($hexg);
10606 $b = hexdec($hexb);
10608 $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0;
10609 if ($bright > 0.6) {
10630 if (empty($menuentry[
'enabled'])) {
10633 if ($type_user && $menuentry[
'module']) {
10634 $tmploops = explode(
'|', $menuentry[
'module']);
10636 foreach ($tmploops as $tmploop) {
10637 if (in_array($tmploop, $listofmodulesforexternal)) {
10646 if (!$menuentry[
'perms'] && $type_user) {
10649 if (!$menuentry[
'perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) {
10652 if (!$menuentry[
'perms']) {
10667 return (ceil($n) % $x === 0) ? ceil($n) : round(($n + $x / 2) / $x) * $x;
10681 function dolGetBadge($label, $html =
'', $type =
'primary', $mode =
'', $url =
'', $params = array())
10684 'class'=>
'badge '.(!empty($mode) ?
' badge-'.$mode :
'').(!empty($type) ?
' badge-'.$type :
'').(empty($params[
'css']) ?
'' :
' '.$params[
'css'])
10687 if (empty($html)) {
10691 if (!empty($url)) {
10692 $attr[
'href'] = $url;
10695 if ($mode ===
'dot') {
10696 $attr[
'class'] .=
' classfortooltip';
10697 $attr[
'title'] = $html;
10698 $attr[
'aria-label'] = $label;
10703 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
10704 foreach ($params[
'attr'] as $key => $value) {
10705 if ($key ==
'class') {
10706 $attr[
'class'] .=
' '.$value;
10707 } elseif ($key ==
'classOverride') {
10708 $attr[
'class'] = $value;
10710 $attr[$key] = $value;
10718 $attr = array_map(
'dol_escape_htmltag', $attr);
10720 $TCompiledAttr = array();
10721 foreach ($attr as $key => $value) {
10722 $TCompiledAttr[] = $key.
'="'.$value.
'"';
10725 $compiledAttributes = !empty($TCompiledAttr) ?implode(
' ', $TCompiledAttr) :
'';
10727 $tag = !empty($url) ?
'a' :
'span';
10729 return '<'.$tag.
' '.$compiledAttributes.
'>'.$html.
'</'.$tag.
'>';
10745 function dolGetStatus($statusLabel =
'', $statusLabelShort =
'', $html =
'', $statusType =
'status0', $displayMode = 0, $url =
'', $params = array())
10750 $dolGetBadgeParams = array();
10752 if (!empty($params[
'badgeParams'])) {
10753 $dolGetBadgeParams = $params[
'badgeParams'];
10757 if ($displayMode == 0) {
10758 $return = !empty($html) ? $html : (empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort));
10759 } elseif ($displayMode == 1) {
10760 $return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
10761 } elseif (!empty($conf->global->MAIN_STATUS_USES_IMAGES)) {
10764 $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ?
'<span class="hideonsmartphone">' :
'').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ?
'</span>' :
'');
10765 $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>' :
'');
10768 if (!empty($conf->dol_optimize_smallscreen)) {
10769 if ($displayMode == 0) {
10771 } elseif ($displayMode == 4) {
10773 } elseif ($displayMode == 6) {
10779 $statusImg = array(
10780 'status0' =>
'statut0',
10781 'status1' =>
'statut1',
10782 'status2' =>
'statut2',
10783 'status3' =>
'statut3',
10784 'status4' =>
'statut4',
10785 'status5' =>
'statut5',
10786 'status6' =>
'statut6',
10787 'status7' =>
'statut7',
10788 'status8' =>
'statut8',
10789 'status9' =>
'statut9'
10792 if (!empty($statusImg[$statusType])) {
10793 $htmlImg =
img_picto($statusLabel, $statusImg[$statusType]);
10795 $htmlImg =
img_picto($statusLabel, $statusType);
10798 if ($displayMode === 2) {
10799 $return = $htmlImg.
' '.$htmlLabelShort;
10800 } elseif ($displayMode === 3) {
10801 $return = $htmlImg;
10802 } elseif ($displayMode === 4) {
10803 $return = $htmlImg.
' '.$htmlLabel;
10804 } elseif ($displayMode === 5) {
10805 $return = $htmlLabelShort.
' '.$htmlImg;
10807 $return = $htmlLabel.
' '.$htmlImg;
10809 } elseif (empty($conf->global->MAIN_STATUS_USES_IMAGES) && !empty($displayMode)) {
10811 $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
10813 $dolGetBadgeParams[
'attr'][
'class'] =
'badge-status';
10814 $dolGetBadgeParams[
'attr'][
'title'] = empty($params[
'tooltip']) ? $statusLabel : ($params[
'tooltip'] !=
'no' ? $params[
'tooltip'] :
'');
10816 if ($displayMode == 3) {
10817 $return =
dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)),
'', $statusType,
'dot', $url, $dolGetBadgeParams);
10818 } elseif ($displayMode === 5) {
10819 $return =
dolGetBadge($statusLabelShort, $html, $statusType,
'', $url, $dolGetBadgeParams);
10821 $return =
dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), $html, $statusType,
'', $url, $dolGetBadgeParams);
10858 function dolGetButtonAction($label, $text =
'', $actionType =
'default', $url =
'', $id =
'', $userRight = 1, $params = array())
10860 global $hookmanager, $action, $object, $langs;
10863 if (!empty($params[
'isDropdown']))
10864 $class =
"dropdown-item";
10866 $class =
'butAction';
10867 if ($actionType ==
'danger' || $actionType ==
'delete') {
10868 $class =
'butActionDelete';
10869 if (!empty($url) && strpos($url,
'token=') ===
false) $url .=
'&token='.newToken();
10874 'href' => empty($url) ?
'' : $url,
10878 if (empty($text)) {
10880 $attr[
'title'] =
'';
10882 $attr[
'title'] = $label;
10883 $attr[
'aria-label'] = $label;
10886 if (empty($userRight)) {
10887 $attr[
'class'] =
'butActionRefused';
10888 $attr[
'href'] =
'';
10889 $attr[
'title'] = (($label && $text && $label != $text) ? $label : $langs->trans(
'NotEnoughPermissions'));
10897 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
10898 foreach ($params[
'attr'] as $key => $value) {
10899 if ($key ==
'class') {
10900 $attr[
'class'] .=
' '.$value;
10901 } elseif ($key ==
'classOverride') {
10902 $attr[
'class'] = $value;
10904 $attr[$key] = $value;
10910 if (!empty($attr[
'title']) && !empty($attr[
'class']) && strpos($attr[
'class'],
'classfortooltip') ===
false) {
10911 $attr[
'class'].=
' classfortooltip';
10915 if ($userRight && !empty($params[
'confirm'])) {
10916 if (!is_array($params[
'confirm'])) {
10917 $params[
'confirm'] = array();
10920 if (empty($params[
'confirm'][
'url'])) {
10921 $params[
'confirm'][
'url'] = $url . (strpos($url,
'?') > 0 ?
'&' :
'?') .
'confirm=yes';
10925 $attr[
'data-confirm-url'] = $params[
'confirm'][
'url'];
10926 $attr[
'data-confirm-title'] = !empty($params[
'confirm'][
'title']) ? $params[
'confirm'][
'title'] : $langs->trans(
'ConfirmBtnCommonTitle', $label);
10927 $attr[
'data-confirm-content'] = !empty($params[
'confirm'][
'content']) ? $params[
'confirm'][
'content'] : $langs->trans(
'ConfirmBtnCommonContent', $label);
10928 $attr[
'data-confirm-content'] = preg_replace(
"/\r|\n/",
"", $attr[
'data-confirm-content']);
10929 $attr[
'data-confirm-action-btn-label'] = !empty($params[
'confirm'][
'action-btn-label']) ? $params[
'confirm'][
'action-btn-label'] : $langs->trans(
'Confirm');
10930 $attr[
'data-confirm-cancel-btn-label'] = !empty($params[
'confirm'][
'cancel-btn-label']) ? $params[
'confirm'][
'cancel-btn-label'] : $langs->trans(
'CloseDialog');
10931 $attr[
'data-confirm-modal'] = !empty($params[
'confirm'][
'modal']) ? $params[
'confirm'][
'modal'] :
true;
10933 $attr[
'class'].=
' butActionConfirm';
10936 if (isset($attr[
'href']) && empty($attr[
'href'])) {
10937 unset($attr[
'href']);
10941 $attr = array_map(
'dol_escape_htmltag', $attr);
10943 $TCompiledAttr = array();
10944 foreach ($attr as $key => $value) {
10945 $TCompiledAttr[] = $key.
'= "'.$value.
'"';
10948 $compiledAttributes = empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr);
10950 $tag = !empty($attr[
'href']) ?
'a' :
'span';
10953 $parameters = array(
10954 'TCompiledAttr' => $TCompiledAttr,
10955 'compiledAttributes' => $compiledAttributes,
10960 'actionType' => $actionType,
10963 'userRight' => $userRight,
10964 'params' => $params
10967 $reshook = $hookmanager->executeHooks(
'dolGetButtonAction', $parameters, $object, $action);
10968 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
10970 if (empty($reshook)) {
10972 return '<' . $tag .
' ' . $compiledAttributes .
'>' . $text .
'</' . $tag .
'>';
10974 return '<' . $tag .
' ' . $compiledAttributes .
'>' .
dol_escape_htmltag($text) .
'</' . $tag .
'>';
10977 return $hookmanager->resPrint;
10989 return '<span class="button-title-separator '.$moreClass.
'" ></span>';
11001 if (!empty($fieldValidationErrorMsg)) {
11002 $out.=
'<span class="field-error-icon classfortooltip" title="'.dol_escape_htmltag($fieldValidationErrorMsg, 1).
'" role="alert" >';
11003 $out.=
'<span class="fa fa-exclamation-circle" aria-hidden="true" ></span>';
11022 function dolGetButtonTitle($label, $helpText =
'', $iconClass =
'fa fa-file', $url =
'', $id =
'', $status = 1, $params = array())
11024 global $langs, $conf, $user;
11027 if (!empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (!$user->admin) && $status <= 0) {
11031 $class =
'btnTitle';
11032 if (in_array($iconClass, array(
'fa fa-plus-circle',
'fa fa-plus-circle size15x',
'fa fa-comment-dots',
'fa fa-paper-plane'))) {
11033 $class .=
' btnTitlePlus';
11035 $useclassfortooltip = 1;
11037 if (!empty($params[
'morecss'])) {
11038 $class .=
' '.$params[
'morecss'];
11043 'href' => empty($url) ?
'' : $url
11046 if (!empty($helpText)) {
11048 } elseif (empty($attr[
'title']) && $label) {
11049 $attr[
'title'] = $label;
11050 $useclassfortooltip = 0;
11053 if ($status == 2) {
11054 $attr[
'class'] .=
' btnTitleSelected';
11055 } elseif ($status <= 0) {
11056 $attr[
'class'] .=
' refused';
11058 $attr[
'href'] =
'';
11060 if ($status == -1) {
11061 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"FeatureDisabled"));
11062 } elseif ($status == 0) {
11063 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions"));
11067 if (!empty($attr[
'title']) && $useclassfortooltip) {
11068 $attr[
'class'] .=
' classfortooltip';
11076 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
11077 foreach ($params[
'attr'] as $key => $value) {
11078 if ($key ==
'class') {
11079 $attr[
'class'] .=
' '.$value;
11080 } elseif ($key ==
'classOverride') {
11081 $attr[
'class'] = $value;
11083 $attr[$key] = $value;
11088 if (isset($attr[
'href']) && empty($attr[
'href'])) {
11089 unset($attr[
'href']);
11095 $attr = array_map(
'dol_escape_htmltag', $attr);
11097 $TCompiledAttr = array();
11098 foreach ($attr as $key => $value) {
11099 $TCompiledAttr[] = $key.
'="'.$value.
'"';
11102 $compiledAttributes = (empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr));
11104 $tag = (empty($attr[
'href']) ?
'span' :
'a');
11106 $button =
'<'.$tag.
' '.$compiledAttributes.
'>';
11107 $button .=
'<span class="'.$iconClass.
' valignmiddle btnTitle-icon"></span>';
11108 if (!empty($params[
'forcenohideoftext'])) {
11109 $button .=
'<span class="valignmiddle text-plus-circle btnTitle-label'.(empty($params[
'forcenohideoftext']) ?
' hideonsmartphone' :
'').
'">'.$label.
'</span>';
11111 $button .=
'</'.$tag.
'>';
11127 $classfile = $classname = $classpath =
'';
11130 $module = $element_type;
11131 $element = $element_type;
11132 $subelement = $element_type;
11135 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $element_type, $regs)) {
11136 $element = $subelement = $regs[1];
11137 $module = $regs[2];
11141 if (preg_match(
'/^([^_]+)_([^_]+)/i', $element, $regs)) {
11142 $module = $element = $regs[1];
11143 $subelement = $regs[2];
11147 if ($element_type ==
"action") {
11148 $classpath =
'comm/action/class';
11149 $subelement =
'Actioncomm';
11150 $module =
'agenda';
11154 if ($element_type ==
'facture' || $element_type ==
'invoice') {
11155 $classpath =
'compta/facture/class';
11156 $module =
'facture';
11157 $subelement =
'facture';
11159 if ($element_type ==
'commande' || $element_type ==
'order') {
11160 $classpath =
'commande/class';
11161 $module =
'commande';
11162 $subelement =
'commande';
11164 if ($element_type ==
'propal') {
11165 $classpath =
'comm/propal/class';
11167 if ($element_type ==
'supplier_proposal') {
11168 $classpath =
'supplier_proposal/class';
11170 if ($element_type ==
'shipping') {
11171 $classpath =
'expedition/class';
11172 $subelement =
'expedition';
11173 $module =
'expedition_bon';
11175 if ($element_type ==
'delivery') {
11176 $classpath =
'delivery/class';
11177 $subelement =
'delivery';
11178 $module =
'delivery_note';
11180 if ($element_type ==
'contract') {
11181 $classpath =
'contrat/class';
11182 $module =
'contrat';
11183 $subelement =
'contrat';
11185 if ($element_type ==
'member') {
11186 $classpath =
'adherents/class';
11187 $module =
'adherent';
11188 $subelement =
'adherent';
11190 if ($element_type ==
'cabinetmed_cons') {
11191 $classpath =
'cabinetmed/class';
11192 $module =
'cabinetmed';
11193 $subelement =
'cabinetmedcons';
11195 if ($element_type ==
'fichinter') {
11196 $classpath =
'fichinter/class';
11197 $module =
'ficheinter';
11198 $subelement =
'fichinter';
11200 if ($element_type ==
'dolresource' || $element_type ==
'resource') {
11201 $classpath =
'resource/class';
11202 $module =
'resource';
11203 $subelement =
'dolresource';
11205 if ($element_type ==
'propaldet') {
11206 $classpath =
'comm/propal/class';
11207 $module =
'propal';
11208 $subelement =
'propaleligne';
11210 if ($element_type ==
'order_supplier') {
11211 $classpath =
'fourn/class';
11212 $module =
'fournisseur';
11213 $subelement =
'commandefournisseur';
11214 $classfile =
'fournisseur.commande';
11216 if ($element_type ==
'invoice_supplier') {
11217 $classpath =
'fourn/class';
11218 $module =
'fournisseur';
11219 $subelement =
'facturefournisseur';
11220 $classfile =
'fournisseur.facture';
11222 if ($element_type ==
"service") {
11223 $classpath =
'product/class';
11224 $subelement =
'product';
11227 if (empty($classfile)) {
11228 $classfile = strtolower($subelement);
11230 if (empty($classname)) {
11231 $classname = ucfirst($subelement);
11233 if (empty($classpath)) {
11234 $classpath = $module.
'/class';
11237 $element_properties = array(
11238 'module' => $module,
11239 'classpath' => $classpath,
11240 'element' => $element,
11241 'subelement' => $subelement,
11242 'classfile' => $classfile,
11243 'classname' => $classname
11245 return $element_properties;
11262 if (is_array($element_prop) && $conf->{$element_prop[
'module']}->enabled) {
11263 dol_include_once(
'/'.$element_prop[
'classpath'].
'/'.$element_prop[
'classfile'].
'.class.php');
11265 $objecttmp =
new $element_prop[
'classname']($db);
11266 $ret = $objecttmp->fetch($element_id, $element_ref);
11282 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)) {
11297 return empty($_SESSION[
'newtoken']) ?
'' : $_SESSION[
'newtoken'];
11308 return isset($_SESSION[
'token']) ? $_SESSION[
'token'] :
'';
11320 if (empty($conf->cache[
'nonce'])) {
11324 return $conf->cache[
'nonce'];
11343 print
'<div class="div-table-responsive-no-min">';
11344 print
'<table class="noborder centpercent">';
11345 print
'<tr class="liste_titre">';
11347 print $emptyRows < 1 ? '<th>
' : '<th colspan=
"'.($emptyRows + 1).'">
';
11349 print $langs->trans($header);
11351 // extra space between the first header and the number
11352 if ($number > -1) {
11356 if (!empty($link)) {
11357 if (!empty($arguments)) {
11358 print '<a href=
"'.DOL_URL_ROOT.'/'.$link.'?'.$arguments.'">
';
11360 print '<a href=
"'.DOL_URL_ROOT.'/'.$link.'">
';
11364 if ($number > -1) {
11365 print '<span
class=
"badge">
'.$number.'</span>
';
11368 if (!empty($link)) {
11374 if ($number < 0 && !empty($link)) {
11375 print '<th
class=
"right">
';
11377 if (!empty($arguments)) {
11378 print '<a
class=
"commonlink" href=
"'.DOL_URL_ROOT.'/'.$link.'?'.$arguments.'">
';
11380 print '<a
class=
"commonlink" href=
"'.DOL_URL_ROOT.'/'.$link.'">
';
11383 print $langs->trans("FullList");
11399 function finishSimpleTable($addLineBreak = false)
11404 if ($addLineBreak) {
11420 function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord = "None", $extraRightColumn = false)
11425 print '<tr
class=
"oddeven">
';
11426 print '<td colspan=
"'.$tableColumnCount.'" class=
"opacitymedium">
'.$langs->trans($noneWord).'</td>
';
11431 if ($nbofloop === 0) {
11432 // don't show a summary line
11437 $colspan = $tableColumnCount;
11438 } elseif ($num > $nbofloop) {
11439 $colspan = $tableColumnCount;
11441 $colspan = $tableColumnCount - 1;
11444 if ($extraRightColumn) {
11448 print
'<tr class="liste_total">';
11450 if ($nbofloop > 0 && $num > $nbofloop) {
11451 print
'<td colspan="'.$colspan.
'" class="right">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
'</td>';
11453 print
'<td colspan="'.$colspan.
'" class="right"> '.$langs->trans(
"Total").
'</td>';
11454 print
'<td class="right" width="100">'.price($total).
'</td>';
11457 if ($extraRightColumn) {
11476 if ($method == -1) {
11478 if (!empty($conf->global->MAIN_FORCE_READFILE_WITH_FREAD)) {
11481 if (!empty($conf->global->MAIN_FORCE_READFILE_WITH_STREAM_COPY)) {
11487 while (ob_get_level()) {
11492 if ($method == 0) {
11493 readfile($fullpath_original_file_osencoded);
11494 } elseif ($method == 1) {
11496 $handle = fopen($fullpath_original_file_osencoded,
"rb");
11497 while (!feof($handle)) {
11498 print fread($handle, 8192);
11501 } elseif ($method == 2) {
11503 $handle1 = fopen($fullpath_original_file_osencoded,
"rb");
11504 $handle2 = fopen(
"php://output",
"wb");
11505 stream_copy_to_stream($handle1, $handle2);
11530 if ($texttoshow ===
'none') {
11531 $result =
'<span class="clipboardCP'.($showonlyonhover ?
' clipboardCPShowOnHover' :
'').
'"><'.$tag.
' class="clipboardCPValue hidewithsize">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'><span class="clipboardCPValueToPrint"></span><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText"></span></span>';
11532 } elseif ($texttoshow) {
11533 $result =
'<span class="clipboardCP'.($showonlyonhover ?
' clipboardCPShowOnHover' :
'').
'"><'.$tag.
' class="clipboardCPValue hidewithsize">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'><span class="clipboardCPValueToPrint">'.
dol_escape_htmltag($texttoshow, 1, 1).
'</span><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText"></span></span>';
11535 $result =
'<span class="clipboardCP'.($showonlyonhover ?
' clipboardCPShowOnHover' :
'').
'"><'.$tag.
' class="clipboardCPValue">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText"></span></span>';
11550 $result = json_decode($stringtodecode);
11551 if ($result ===
null) {
11552 $result = unserialize($stringtodecode);
11568 $regexstring =
'\(([a-zA-Z0-9_\.]+:[<>!=insotlke]+:[^\(\)]+)\)';
11575 $t = preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeDummyCriteriaCallback', $filter);
11576 $t = str_replace(array(
'and',
'or',
'AND',
'OR',
' '),
'', $t);
11578 if (preg_match(
'/[^\(\)]/', $t)) {
11579 $error =
'Bad syntax of the search string, filter criteria is invalidated';
11583 return " AND (".preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeCriteriaCallback', $filter).
")";
11597 $tmp = $sqlfilters;
11598 $i = 0; $nb = strlen($tmp);
11601 if ($tmp[$i] ==
'(') {
11604 if ($tmp[$i] ==
')') {
11607 if ($counter < 0) {
11608 $error =
"Wrond balance of parenthesis in sqlfilters=".$sqlfilters;
11627 if (empty($matches[1])) {
11630 $tmp = explode(
':', $matches[1]);
11631 if (count($tmp) < 3) {
11651 if (empty($matches[1])) {
11654 $tmp = explode(
':', $matches[1]);
11655 if (count($tmp) < 3) {
11659 $operand = preg_replace(
'/[^a-z0-9\._]/i',
'', trim($tmp[0]));
11661 $operator = strtoupper(preg_replace(
'/[^a-z<>!=]/i',
'', trim($tmp[1])));
11663 if ($operator ==
'NOTLIKE') {
11664 $operator =
'NOT LIKE';
11666 if ($operator ==
'ISNOT') {
11667 $operator =
'IS NOT';
11669 if ($operator ==
'!=') {
11673 $tmpescaped = $tmp[2];
11676 if ($operator ==
'IN') {
11678 $tmpescaped =
'('.$db->escape($db->sanitize($tmpescaped, 1, 0)).
')';
11682 } elseif ($operator ==
'LIKE' || $operator ==
'NOT LIKE') {
11683 if (preg_match(
'/^\'(.*)\'$/', $tmpescaped, $regbis)) {
11684 $tmpescaped = $regbis[1];
11687 $tmpescaped =
"'".$db->escape($tmpescaped).
"'";
11688 } elseif (preg_match(
'/^\'(.*)\'$/', $tmpescaped, $regbis)) {
11689 $tmpescaped =
"'".$db->escape($regbis[1]).
"'";
11691 if (strtoupper($tmpescaped) ==
'NULL') {
11692 $tmpescaped =
'NULL';
11693 } elseif (is_int($tmpescaped)) {
11694 $tmpescaped = (int) $tmpescaped;
11696 $tmpescaped = (
float) $tmpescaped;
11700 return $db->escape($operand).
' '.strtoupper($operator).
' '.$tmpescaped;
11714 global $conf, $langs;
11715 $out =
'<!-- timeline icon -->'.
"\n";
11716 $iconClass =
'fa fa-comments';
11721 if ($histo[$key][
'percent'] == -1) {
11722 $colorClass =
'timeline-icon-not-applicble';
11723 $pictoTitle = $langs->trans(
'StatusNotApplicable');
11724 } elseif ($histo[$key][
'percent'] == 0) {
11725 $colorClass =
'timeline-icon-todo';
11726 $pictoTitle = $langs->trans(
'StatusActionToDo').
' (0%)';
11727 } elseif ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100) {
11728 $colorClass =
'timeline-icon-in-progress';
11729 $pictoTitle = $langs->trans(
'StatusActionInProcess').
' ('.$histo[$key][
'percent'].
'%)';
11730 } elseif ($histo[$key][
'percent'] >= 100) {
11731 $colorClass =
'timeline-icon-done';
11732 $pictoTitle = $langs->trans(
'StatusActionDone').
' (100%)';
11735 if ($actionstatic->code ==
'AC_TICKET_CREATE') {
11736 $iconClass =
'fa fa-ticket';
11737 } elseif ($actionstatic->code ==
'AC_TICKET_MODIFY') {
11738 $iconClass =
'fa fa-pencilxxx';
11739 } elseif (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
11740 $iconClass =
'fa fa-comments';
11741 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
11742 $iconClass =
'fa fa-mask';
11743 } elseif (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
11744 if ($actionstatic->type_picto) {
11745 $img_picto =
img_picto(
'', $actionstatic->type_picto);
11747 if ($actionstatic->type_code ==
'AC_RDV') {
11748 $iconClass =
'fa fa-handshake';
11749 } elseif ($actionstatic->type_code ==
'AC_TEL') {
11750 $iconClass =
'fa fa-phone';
11751 } elseif ($actionstatic->type_code ==
'AC_FAX') {
11752 $iconClass =
'fa fa-fax';
11753 } elseif ($actionstatic->type_code ==
'AC_EMAIL') {
11754 $iconClass =
'fa fa-envelope';
11755 } elseif ($actionstatic->type_code ==
'AC_INT') {
11756 $iconClass =
'fa fa-shipping-fast';
11757 } elseif ($actionstatic->type_code ==
'AC_OTH_AUTO') {
11758 $iconClass =
'fa fa-robot';
11759 } elseif (!preg_match(
'/_AUTO/', $actionstatic->type_code)) {
11760 $iconClass =
'fa fa-robot';
11765 $out .=
'<i class="'.$iconClass.
' '.$colorClass.
'" title="'.$pictoTitle.
'">'.$img_picto.
'</i>'.
"\n";
11779 $documents = array();
11781 $sql =
'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.filepath, ecm.filename';
11782 $sql .=
' FROM '.MAIN_DB_PREFIX.
'ecm_files ecm';
11783 $sql .=
" WHERE ecm.filepath = 'agenda/".((int) $object->id).
"'";
11785 $sql .=
' ORDER BY ecm.position ASC';
11787 $resql = $db->query($sql);
11789 if ($db->num_rows(
$resql)) {
11790 while ($obj = $db->fetch_object(
$resql)) {
11791 $documents[$obj->id] = $obj;
11818 function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon =
'', $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC')
11820 global $user, $conf;
11823 global $param, $massactionbutton;
11828 if (!is_object($filterobj) && !is_object($objcon)) {
11836 $sortfield_list = explode(
',', $sortfield);
11837 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
11838 $sortfield_new_list = array();
11839 foreach ($sortfield_list as $sortfield_value) {
11840 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
11842 $sortfield_new = implode(
',', $sortfield_new_list);
11846 if (is_object($objcon) && $objcon->id > 0) {
11847 $sql =
"SELECT DISTINCT a.id, a.label as label,";
11849 $sql =
"SELECT a.id, a.label as label,";
11851 $sql .=
" a.datep as dp,";
11852 $sql .=
" a.note as message,";
11853 $sql .=
" a.datep2 as dp2,";
11854 $sql .=
" a.percent as percent, 'action' as type,";
11855 $sql .=
" a.fk_element, a.elementtype,";
11856 $sql .=
" a.fk_contact,";
11857 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
11858 $sql .=
" u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
11859 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
11860 $sql .=
", sp.lastname, sp.firstname";
11861 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
11862 $sql .=
", m.lastname, m.firstname";
11863 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
11865 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
11867 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
11869 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
11871 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
11874 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
11875 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
11876 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
11878 $force_filter_contact =
false;
11879 if (is_object($objcon) && $objcon->id > 0) {
11880 $force_filter_contact =
true;
11881 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as r ON a.id = r.fk_actioncomm";
11882 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id);
11885 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
11886 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
11887 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
11888 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
11889 $sql .=
" ON er.resource_type = 'dolresource'";
11890 $sql .=
" AND er.element_id = a.id";
11891 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
11892 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
11893 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
11894 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
11895 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
11896 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
11897 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
11898 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
11899 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
11900 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
11901 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
11902 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
11903 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
11906 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
11907 if ($force_filter_contact ===
false) {
11908 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
11909 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
11910 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
11911 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
11912 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
11913 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
11914 if ($filterobj->id) {
11915 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
11917 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
11918 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
11919 if ($filterobj->id) {
11920 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
11922 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
11923 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
11924 if ($filterobj->id) {
11925 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
11927 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
11928 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
11929 if ($filterobj->id) {
11930 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
11932 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
11933 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
11934 if ($filterobj->id) {
11935 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
11937 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
11938 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
11939 if ($filterobj->id) {
11940 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
11946 if (!empty($actioncode)) {
11947 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
11948 if ($actioncode ==
'AC_NON_AUTO') {
11949 $sql .=
" AND c.type != 'systemauto'";
11950 } elseif ($actioncode ==
'AC_ALL_AUTO') {
11951 $sql .=
" AND c.type = 'systemauto'";
11953 if ($actioncode ==
'AC_OTH') {
11954 $sql .=
" AND c.type != 'systemauto'";
11955 } elseif ($actioncode ==
'AC_OTH_AUTO') {
11956 $sql .=
" AND c.type = 'systemauto'";
11960 if ($actioncode ==
'AC_NON_AUTO') {
11961 $sql .=
" AND c.type != 'systemauto'";
11962 } elseif ($actioncode ==
'AC_ALL_AUTO') {
11963 $sql .=
" AND c.type = 'systemauto'";
11965 $sql .=
" AND c.code = '".$db->escape($actioncode).
"'";
11969 if ($donetodo ==
'todo') {
11970 $sql .=
" AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now).
"'))";
11971 } elseif ($donetodo ==
'done') {
11972 $sql .=
" AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now).
"'))";
11974 if (is_array($filters) && $filters[
'search_agenda_label']) {
11975 $sql .=
natural_search(
'a.label', $filters[
'search_agenda_label']);
11981 && (empty($actioncode) || $actioncode ==
'AC_OTH_AUTO' || $actioncode ==
'AC_EMAILING')) {
11982 $langs->load(
"mails");
11984 $sql2 =
"SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type";
11985 $sql2 .=
", null as fk_element, '' as elementtype, null as contact_id";
11986 $sql2 .=
", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
11987 $sql2 .=
", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
11988 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
11989 $sql2 .=
", '' as lastname, '' as firstname";
11990 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
11991 $sql2 .=
", '' as lastname, '' as firstname";
11992 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
11993 $sql2 .=
", '' as ref";
11994 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
11995 $sql2 .=
", '' as ref";
11996 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
11997 $sql2 .=
", '' as ref";
11999 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"user as u";
12000 $sql2 .=
" WHERE mc.email = '".$db->escape($objcon->email).
"'";
12001 $sql2 .=
" AND mc.statut = 1";
12002 $sql2 .=
" AND u.rowid = m.fk_user_valid";
12003 $sql2 .=
" AND mc.fk_mailing=m.rowid";
12006 if (!empty($sql) && !empty($sql2)) {
12007 $sql = $sql.
" UNION ".$sql2;
12008 } elseif (empty($sql) && !empty($sql2)) {
12014 $sql .= $db->order($sortfield_new, $sortorder);
12016 dol_syslog(
"function.lib::show_actions_messaging", LOG_DEBUG);
12017 $resql = $db->query($sql);
12020 $num = $db->num_rows(
$resql);
12022 while ($i < $num) {
12023 $obj = $db->fetch_object(
$resql);
12025 if ($obj->type ==
'action') {
12027 $contactaction->id = $obj->id;
12028 $result = $contactaction->fetchResources();
12031 setEventMessage(
"actions.lib::show_actions_messaging Error fetch ressource",
'errors');
12037 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->dp > $now)) {
12038 $tododone =
'todo';
12041 $histo[$numaction] = array(
12042 'type'=>$obj->type,
12043 'tododone'=>$tododone,
12045 'datestart'=>$db->jdate($obj->dp),
12046 'dateend'=>$db->jdate($obj->dp2),
12047 'note'=>$obj->label,
12048 'message'=>$obj->message,
12049 'percent'=>$obj->percent,
12051 'userid'=>$obj->user_id,
12052 'login'=>$obj->user_login,
12053 'userfirstname'=>$obj->user_firstname,
12054 'userlastname'=>$obj->user_lastname,
12055 'userphoto'=>$obj->user_photo,
12057 'contact_id'=>$obj->fk_contact,
12058 'socpeopleassigned' => $contactaction->socpeopleassigned,
12059 'lastname' => (empty($obj->lastname) ?
'' : $obj->lastname),
12060 'firstname' => (empty($obj->firstname) ?
'' : $obj->firstname),
12061 'fk_element'=>$obj->fk_element,
12062 'elementtype'=>$obj->elementtype,
12064 'acode'=>$obj->acode,
12065 'alabel'=>$obj->alabel,
12066 'libelle'=>$obj->alabel,
12067 'apicto'=>$obj->apicto
12070 $histo[$numaction] = array(
12071 'type'=>$obj->type,
12072 'tododone'=>
'done',
12074 'datestart'=>$db->jdate($obj->dp),
12075 'dateend'=>$db->jdate($obj->dp2),
12076 'note'=>$obj->label,
12077 'message'=>$obj->message,
12078 'percent'=>$obj->percent,
12079 'acode'=>$obj->acode,
12081 'userid'=>$obj->user_id,
12082 'login'=>$obj->user_login,
12083 'userfirstname'=>$obj->user_firstname,
12084 'userlastname'=>$obj->user_lastname,
12085 'userphoto'=>$obj->user_photo
12101 $langs->loadLangs(array(
"admin",
"errors"));
12102 $out =
info_admin($langs->trans(
"WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv(
"Module2400Name")), 0, 0,
'warning');
12106 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
12108 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
12109 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
12110 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
12111 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
12116 $userstatic =
new User($db);
12117 $contactstatic =
new Contact($db);
12118 $userGetNomUrlCache = array();
12120 $out .=
'<div class="filters-container" >';
12121 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
12122 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
12124 if ($objcon && get_class($objcon) ==
'Contact' &&
12125 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
12126 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
12128 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
12130 if ($filterobj && get_class($filterobj) ==
'Societe') {
12131 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
12136 $out .=
'<div class="div-table-responsive-no-min">';
12137 $out .=
'<table class="noborder borderbottom centpercent">';
12139 $out .=
'<tr class="liste_titre">';
12141 $out .=
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
12143 $out .=
'<th class="liste_titre"><strong class="hideonsmartphone">'.$langs->trans(
"Search").
' : </strong></th>';
12145 $out .=
'<th class="liste_titre"></th>';
12147 $out .=
'<th class="liste_titre">';
12148 $out .=
'<span class="fas fa-square inline-block fawidth30" style=" color: #ddd;" title="'.$langs->trans(
"ActionType").
'"></span>';
12150 $out .=
$formactions->select_type_actions($actioncode,
"actioncode",
'', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, 0, 1,
'minwidth200imp');
12152 $out .=
'<th class="liste_titre maxwidth100onsmartphone">';
12153 $out .=
'<input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'" placeholder="'.$langs->trans(
"Label").
'">';
12156 $out .=
'<th class="liste_titre width50 middle">';
12157 $searchpicto =
$form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
12158 $out .= $searchpicto;
12163 $out .=
'</table>';
12170 $out .=
'<ul class="timeline">';
12174 if (get_class($filterobj) ==
'Societe') {
12175 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
12177 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
12178 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
12179 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
12181 if (get_class($filterobj) ==
'Societe') {
12192 $actualCycleDate =
false;
12195 foreach ($histo as $key => $value) {
12196 $actionstatic->fetch($histo[$key][
'id']);
12198 $actionstatic->type_picto = $histo[$key][
'apicto'];
12199 $actionstatic->type_code = $histo[$key][
'acode'];
12201 $url = DOL_URL_ROOT.
'/comm/action/card.php?id='.$histo[$key][
'id'];
12203 $tmpa =
dol_getdate($histo[$key][
'datestart'],
false);
12204 if ($actualCycleDate !== $tmpa[
'year'].
'-'.$tmpa[
'yday']) {
12205 $actualCycleDate = $tmpa[
'year'].
'-'.$tmpa[
'yday'];
12206 $out .=
'<!-- timeline time label -->';
12207 $out .=
'<li class="time-label">';
12208 $out .=
'<span class="timeline-badge-date">';
12209 $out .=
dol_print_date($histo[$key][
'datestart'],
'daytext',
'tzuserrel', $langs);
12212 $out .=
'<!-- /.timeline-label -->';
12216 $out .=
'<!-- timeline item -->'.
"\n";
12217 $out .=
'<li class="timeline-code-'.strtolower($actionstatic->code).
'">';
12221 $out .=
'<div class="timeline-item">'.
"\n";
12223 $out .=
'<span class="timeline-header-action">';
12225 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
12226 $out .=
'<a class="timeline-btn" href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
12227 $out .= $histo[$key][
'id'];
12230 $out .= $actionstatic->getNomUrl(1, -1,
'valignmiddle').
' ';
12233 if (!empty($user->rights->agenda->allactions->create) ||
12234 (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && !empty($user->rights->agenda->myactions->create))) {
12235 $out .=
'<a class="timeline-btn" href="'.DOL_MAIN_URL_ROOT.
'/comm/action/card.php?action=edit&token='.
newToken().
'&id='.$actionstatic->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?'.$param).
'"><i class="fa fa-pencil" title="'.$langs->trans(
"Modify").
'" ></i></a>';
12240 $out .=
'<span class="time"><i class="fa fa-clock-o"></i> ';
12241 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
12242 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
12243 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
12244 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
12245 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
12246 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
12248 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
12252 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
12255 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
12258 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
12261 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
12267 $out .=
"</span>\n";
12270 $out .=
'<h3 class="timeline-header">';
12273 $out .=
'<div class="messaging-author inline-block">';
12274 if ($histo[$key][
'userid'] > 0) {
12275 if (!isset($userGetNomUrlCache[$histo[$key][
'userid']])) {
12276 $userstatic->fetch($histo[$key][
'userid']);
12277 $userGetNomUrlCache[$histo[$key][
'userid']] = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
12279 $out .= $userGetNomUrlCache[$histo[$key][
'userid']];
12284 $out .=
' <div class="messaging-title inline-block">';
12286 if (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
12287 $out .= $langs->trans(
'TicketNewMessage');
12288 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
12289 $out .= $langs->trans(
'TicketNewMessage').
' <em>('.$langs->trans(
'Private').
')</em>';
12291 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'action') {
12292 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
12293 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode : $histo[$key][
'alabel']);
12294 $libelle = $histo[$key][
'note'];
12295 $actionstatic->id = $histo[$key][
'id'];
12298 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
12299 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
12300 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
12301 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
12310 if (!empty($histo[$key][
'message'])
12311 && $actionstatic->code !=
'AC_TICKET_CREATE'
12312 && $actionstatic->code !=
'AC_TICKET_MODIFY'
12314 $out .=
'<div class="timeline-body">';
12315 $out .= $histo[$key][
'message'];
12323 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
12325 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $Tab) {
12327 $result = $contact->fetch($cid);
12334 $contactList .= !empty($contactList) ?
', ' :
'';
12335 $contactList .= $contact->getNomUrl(1);
12336 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
12337 if (!empty($contact->phone_pro)) {
12338 $contactList .=
'('.dol_print_phone($contact->phone_pro).
')';
12344 $footer .= $langs->trans(
'ActionOnContact').
' : '.$contactList;
12345 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
12347 $result = $contact->fetch($histo[$key][
'contact_id']);
12354 $footer .= $contact->getNomUrl(1);
12355 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
12356 if (!empty($contact->phone_pro)) {
12357 $footer .=
'('.dol_print_phone($contact->phone_pro).
')';
12364 if (!empty($documents)) {
12365 $footer .=
'<div class="timeline-documents-container">';
12366 foreach ($documents as $doc) {
12367 $footer .=
'<span id="document_'.$doc->id.
'" class="timeline-documents" ';
12368 $footer .=
' data-id="'.$doc->id.
'" ';
12369 $footer .=
' data-path="'.$doc->filepath.
'"';
12370 $footer .=
' data-filename="'.dol_escape_htmltag($doc->filename).
'" ';
12373 $filePath = DOL_DATA_ROOT.
'/'.$doc->filepath.
'/'.$doc->filename;
12375 $file = $actionstatic->id.
'/'.$doc->filename;
12376 $thumb = $actionstatic->id.
'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename,
'.')).
'_mini'.substr($doc->filename, strrpos($doc->filename,
'.'));
12377 $doclink =
dol_buildpath(
'document.php', 1).
'?modulepart=actions&attachment=0&file='.urlencode($file).
'&entity='.$conf->entity;
12378 $viewlink =
dol_buildpath(
'viewimage.php', 1).
'?modulepart=actions&file='.urlencode($thumb).
'&entity='.$conf->entity;
12380 $mimeAttr =
' mime="'.$mime.
'" ';
12382 if (in_array($mime, array(
'image/png',
'image/jpeg',
'application/pdf'))) {
12383 $class .=
' documentpreview';
12386 $footer .=
'<a href="'.$doclink.
'" class="btn-link '.$class.
'" target="_blank" rel="noopener noreferrer" '.$mimeAttr.
' >';
12387 $footer .=
img_mime($filePath).
' '.$doc->filename;
12390 $footer .=
'</span>';
12392 $footer .=
'</div>';
12395 if (!empty($footer)) {
12396 $out .=
'<div class="timeline-footer">'.$footer.
'</div>';
12399 $out .=
'</div>'.
"\n";
12402 $out .=
'<!-- END timeline item -->';
12409 if (empty($histo)) {
12410 $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array(), $morecss='', $htmlname='')
On/off button to change status of an object This is called when MAIN_DIRECT_STATUS_UPDATE is set and ...
Class to manage agenda events (actions)
Classe to manage GeoIP Usage: $geoip=new GeoIP('country',$datfile); $geoip->getCountryCodeFromIP($ip)...
Class to manage invoices.
Class to manage predefined suppliers products.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
isACompany()
Return if third party is a company (Business) or an end user (Consumer)
Class to manage translations.
Class to manage Dolibarr users.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_get_prev_month($month, $year)
Return previous month.
dol_get_next_day($day, $month, $year)
Return next day.
getServerTimeZoneInt($refgmtdate='now')
Return server timezone int.
dol_get_prev_day($day, $month, $year)
Return previous day.
dol_get_next_month($month, $year)
Return next month.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid
dol_convert_file($fileinput, $ext='png', $fileoutput='', $page='')
Convert an image file or a PDF into another image format.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_is_dir($folder)
Test if filename is a directory.
isValidVATID($company)
Check if VAT numero is valid (check done on syntax only, no database or remote access)
dol_html_entity_decode($a, $b, $c='UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
dol_fiche_end($notab=0)
Show tab footer of a card.
dolCheckFilters($sqlfilters, &$error='')
Return if a $sqlfilters parameter has a valid balance of parenthesis.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
Function that return localtax of a product line (according to seller, buyer and product vat rate) Si ...
img_weather($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $morecss='')
Show weather picto.
startSimpleTable($header, $link="", $arguments="", $emptyRows=0, $number=-1)
Start a table with headers and a optinal clickable number (don't forget to use "finishSimpleTable()" ...
dol_getmypid()
Return getmypid() or random PID when function is disabled Some web hosts disable this php function fo...
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
setEntity($currentobject)
Set entity id to use when to create an object.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key array.
dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetworks=array())
Show social network link.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
dol_ucfirst($string, $encoding="UTF-8")
Convert first character of the first word of a string to upper.
img_right($titlealt='default', $selected=0, $moreatt='')
Show right arrow logo.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
dol_strtolower($string, $encoding="UTF-8")
Convert a string to lower.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto='UTF-8')
This function is called to decode a HTML string (it decodes entities and br tags)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_left($titlealt='default', $selected=0, $moreatt='')
Show left arrow logo.
dol_print_ip($ip, $mode=0)
Return an IP formated to be shown on screen.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal)
Function to test if an entry is enabled or not.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
isASecretKey($keyname)
Return if string has a name dedicated to store a secret.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
get_date_range($date_start, $date_end, $format='', $outputlangs='', $withparenthesis=1)
Format output for start and end date.
get_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Get formated error messages to output (Used to show messages on html output).
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
roundUpToNextMultiple($n, $x=5)
Round to next multiple.
dol_user_country()
Return country code for current user.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs='', $mode=0, $extralangcode='')
Return a formated address (part address/zip/town/state) according to country rules.
isHTTPS()
Return if we are using a HTTPS connexion Check HTTPS (no way to be modified by user but may be empty ...
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
picto_required()
Return picto saying a field is required.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
printCommonFooter($zone='private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='button bordertransp', $backtopagejsfields='')
Return HTML code to output a button to open a dialog popup box.
checkVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
dolGetBadge($label, $html='', $type='primary', $mode='', $url='', $params=array())
Function dolGetBadge.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
Get tax (VAT) main information from Id.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
utf8_valid($str)
Check if a string is in UTF8.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
img_allow($allow, $titlealt='default')
Show tick logo if allowed.
isValidMXRecord($domain)
Return if the domain name has a valid MX record.
forgeSQLFromUniversalSearchCriteria($filter, &$error='')
forgeSQLFromUniversalSearchCriteria
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
get_htmloutput_mesg($mesgstring='', $mesgarray='', $style='ok', $keepembedded=0)
Get formated messages to output (Used to show messages on html output).
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0)
Format phone numbers according to country.
dol_now($mode='auto')
Return date for now.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tab header of a card.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
get_localtax_by_third($local)
Get values of localtaxes (1 or 2) for company country for the common vat with the highest value.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
img_view($titlealt='default', $float=0, $other='class="valignmiddle"')
Show logo view card.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
dol_print_url($url, $target='_blank', $max=32, $withpicto=0)
Show Url link.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array())
Clean a string to keep only desirable HTML tags.
dol_strftime($fmt, $ts=false, $is_gmt=false)
Format a string.
img_picto_common($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $notitle=0)
Show picto (generic function)
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0, $beforearrows='')
Function to show navigation arrows into lists.
img_search($titlealt='default', $other='')
Show search logo.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags=array('textarea'), $cleanalsosomestyles=0)
Clean a string from some undesirable HTML tags.
isValidPhone($phone)
Return true if phone number syntax is ok TODO Decide what to do with this.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Fonction qui renvoie si tva doit etre tva percue recuperable.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_print_profids($profID, $profIDtype, $countrycode='', $addcpButton=1, $separ=' ')
Format profIDs according to country.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='')
Clean a string from all punctuation characters to use it as a ref or login.
fieldLabel($langkey, $fieldkey, $fieldrequired=0)
Show a string with the label tag dedicated to the HTML edit field.
getBrowserInfo($user_agent)
Return information about user browser.
dolGetFirstLetters($s, $nbofchar=1)
Return first letters of a strings.
dol_strtoupper($string, $encoding="UTF-8")
Convert a string to upper.
getDolUserInt($key, $default=0)
Return dolibarr user constant int value.
img_action($titlealt, $numaction, $picto='')
Show logo action.
dol_sanitizeUrl($stringtoclean, $type=1)
Clean a string to use it as an URL (into a href or src attribute)
getImageFileNameForSize($file, $extName, $extImgTarget='')
Return the filename of file to get the thumbs.
img_printer($titlealt="default", $other='')
Show printer logo.
dol_htmloutput_events($disabledoutputofmessages=0)
Print formated messages to output (Used to show messages on html output).
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
ascii_check($str)
Check if a string is in ASCII.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
getArrayOfSocialNetworks()
Get array of social network dictionary.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes=array("allow", "allowfullscreen", "alt", "class", "contenteditable", "data-html", "frameborder", "height", "href", "id", "name", "src", "style", "target", "title", "width"))
Clean a string from some undesirable HTML tags.
num2Alpha($n)
Return a numeric value into an Excel like column number.
dol_size($size, $type='')
Optimize a size for some browsers (phone, smarphone, ...)
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
img_pdf($titlealt='default', $size=3)
Show pdf logo.
dolGetCountryCodeFromIp($ip)
Return a country code from IP.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='')
Return URL we can use for advanced preview links.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
colorIsLight($stringcolor)
Return true if the color is light.
dol_substr($string, $start, $length, $stringencoding='', $trunconbytes=0)
Make a substring.
readfileLowMemory($fullpath_original_file_osencoded, $method=-1)
Return a file on output using a low memory.
dolIsAllowedForPreview($file)
Return if a file is qualified for preview.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
dol_shutdown()
Function called at end of web php process.
dol_print_address($address, $htmlid, $element, $id, $noprint=0, $charfornl='')
Format address string.
dol_print_error_email($prefixcode, $errormessage='', $errormessages=array(), $morecss='error', $email='')
Show a public email and error code to contact if technical error.
setEventMessage($mesgs, $style='mesgs')
Set event message in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_bc($var, $moreclass='')
Return string to add class property on html element with pair/impair.
print_titre($title)
Show a title.
getElementProperties($element_type)
Get an array with properties of an element.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_string_nounprintableascii($str, $removetabcrlf=1)
Clean a string from all non printable ASCII chars (0x00-0x1F and 0x7F).
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
showDirectDownloadLink($object)
Return string with full Url.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_error($titlealt='default')
Show error logo.
getTimelineIcon($actionstatic, &$histo, $key)
Get timeline icon.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolUserString($key, $default='')
Return dolibarr user constant string value.
img_next($titlealt='default', $moreatt='')
Show next logo.
print_date_range($date_start, $date_end, $format='', $outputlangs='')
Format output for start and end date.
isAFileWithExecutableContent($filename)
Return if a file can contains executable content.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_string_is_good_iso($s, $clean=0)
Check if a string is a correct iso string If not, it will we considered not HTML encoded even if it i...
getNonce()
Return a random string to be used as a nonce value for js.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
get_product_localtax_for_country($idprod, $local, $thirdpartytouse)
Return localtax vat rate of a product in a particular country or default country vat if product is un...
dol_nboflines($s, $maxchar=0)
Return nb of lines of a clear text.
dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox=0, $check='restricthtml')
Sanitize a HTML to remove js and dangerous content.
jsonOrUnserialize($stringtodecode)
Decode an encode string.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getActionCommEcmList($object)
getActionCommEcmList
dol_ucwords($string, $encoding="UTF-8")
Convert first character of all the words of a string to upper.
img_edit_add($titlealt='default', $other='')
Show logo +.
verifCond($strToEvaluate)
Verify if condition in string is ok or not.
print_fiche_titre($title, $mesg='', $picto='generic', $pictoisfullpath=0, $id='')
Show a title with picto.
get_product_vat_for_country($idprod, $thirdpartytouse, $idprodfournprice=0)
Return vat rate of a product in a particular country, or default country vat if product is unknown.
dolForgeDummyCriteriaCallback($matches)
Function to forge a SQL criteria from a Dolibarr filter syntax string.
dol_escape_json($stringtoescape)
Returns text escaped for inclusion into javascript code.
dolForgeCriteriaCallback($matches)
Function to forge a SQL criteria from a Dolibarr filter syntax string.
getUserRemoteIP()
Return the IP of remote user.
sanitizeVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
dol_validElement($element)
Return if var element is ok.
isModEnabled($module)
Is Dolibarr module enabled.
img_credit_card($brand, $morecss=null)
Return image of a credit card according to its brand name.
img_searchclear($titlealt='default', $other='')
Show search logo.
fetchObjectByElement($element_id, $element_type, $element_ref='')
Fetch an object from its id and element_type Inclusion of classes is automatic.
utf8_check($str)
Check if a string is in UTF8.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
show_actions_messaging($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC')
Show html area with actions in messaging format.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).
getFieldErrorIcon($fieldValidationErrorMsg)
get field error icon
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
img_edit_remove($titlealt='default', $other='')
Show logo -.
img_info($titlealt='default')
Show info logo.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
dol_sanitizeEmail($stringtoclean)
Clean a string to use it as an Email.
dol_nboflines_bis($text, $maxlinesize=0, $charset='UTF-8')
Return nb of lines of a formated text with and (WARNING: string must not have mixed and br sepa...
dol_convertToWord($num, $langs, $currency='', $centimes=false)
Function to return a number into a text.
conf($dolibarr_main_document_root)
Load conf file (file must exists)
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
if(!empty($_SERVER['MAIN_SHOW_TUNING_INFO'])) realCharForNumericEntities($matches)
Return the real char for a numeric entities.
div float
Buy price without taxes.
dol_setcache($memoryid, $data, $expire=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid)
Read a memory area shared by all users, all sessions on server.
$conf db name
Only used if Module[ID]Name translation string is not found.
dolGetRandomBytes($length)
Return a string of random bytes (hexa string) with length = $length fro cryptographic purposes.
print *****$script_file(".$version.") pid code
! Closing after partial payment: discount_vat, badcustomer or badsupplier, bankcharge,...