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) (empty($conf->global->$key) ? $default : $conf->global->$key);
100 return (
int) (empty($conf->global->$key) ? $default : $conf->global->$key);
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));
422 $relativepathstring = $_SERVER[
"PHP_SELF"];
424 if (constant(
'DOL_URL_ROOT')) {
425 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
427 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
428 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
434 if (!empty($_GET[
'restore_lastsearch_values'])) {
435 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
436 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
437 if (is_array($tmp)) {
438 foreach ($tmp as $key => $val) {
439 if ($key == $paramname) {
447 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
449 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
451 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
453 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
457 $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname]));
474 if (empty($method)) {
475 $val = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
476 } elseif ($method == 1) {
477 $val = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
478 } elseif ($method == 2) {
479 $val = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
480 } elseif ($method == 3) {
481 $val = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
483 $val =
'BadFirstParameterForGETPOST';
486 return is_array($val);
517 function GETPOST($paramname, $check =
'alphanohtml', $method = 0, $filter =
null, $options =
null, $noreplace = 0)
519 global $mysoc, $user, $conf;
521 if (empty($paramname)) {
522 return 'BadFirstParameterForGETPOST';
525 dol_syslog(
"Deprecated use of GETPOST, called with 1st param = ".$paramname.
" and 2nd param is '', when calling page ".$_SERVER[
"PHP_SELF"], LOG_WARNING);
530 if (empty($method)) {
531 $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
532 } elseif ($method == 1) {
533 $out = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
534 } elseif ($method == 2) {
535 $out = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
536 } elseif ($method == 3) {
537 $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
539 return 'BadThirdParameterForGETPOST';
542 if (empty($method) || $method == 3 || $method == 4) {
543 $relativepathstring = $_SERVER[
"PHP_SELF"];
545 if (constant(
'DOL_URL_ROOT')) {
546 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
548 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
549 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
555 if (!empty($_GET[
'restore_lastsearch_values'])) {
556 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
557 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
558 if (is_array($tmp)) {
559 foreach ($tmp as $key => $val) {
560 if ($key == $paramname) {
568 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
569 $out = $_SESSION[
'lastsearch_contextpage_'.$relativepathstring];
570 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
571 $out = $_SESSION[
'lastsearch_limit_'.$relativepathstring];
572 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
573 $out = $_SESSION[
'lastsearch_page_'.$relativepathstring];
574 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
575 $out = $_SESSION[
'lastsearch_mode_'.$relativepathstring];
577 } elseif (!isset($_GET[
'sortfield'])) {
580 if (!empty($_GET[
'action']) && $_GET[
'action'] ==
'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
583 if (is_object($object) && isset($object->fields[$paramname][
'default'])) {
584 $out = $object->fields[$paramname][
'default'];
587 if (!empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
588 if (!empty($_GET[
'action']) && (preg_match(
'/^create/', $_GET[
'action']) || preg_match(
'/^presend/', $_GET[
'action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
590 if (!empty($user->default_values)) {
591 if (isset($user->default_values[$relativepathstring][
'createform'])) {
592 foreach ($user->default_values[$relativepathstring][
'createform'] as $defkey => $defval) {
594 if ($defkey !=
'_noquery_') {
595 $tmpqueryarraytohave = explode(
'&', $defkey);
598 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
599 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
612 if (isset($user->default_values[$relativepathstring][
'createform'][$defkey][$paramname])) {
613 $out = $user->default_values[$relativepathstring][
'createform'][$defkey][$paramname];
620 } elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
622 if (!empty($user->default_values)) {
625 if ($paramname ==
'sortfield' || $paramname ==
'sortorder') {
627 if (isset($user->default_values[$relativepathstring][
'sortorder'])) {
629 foreach ($user->default_values[$relativepathstring][
'sortorder'] as $defkey => $defval) {
631 if ($defkey !=
'_noquery_') {
632 $tmpqueryarraytohave = explode(
'&', $defkey);
635 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
636 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
649 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
650 foreach ($user->default_values[$relativepathstring][
'sortorder'][$defkey] as $key => $val) {
654 if ($paramname ==
'sortfield') {
657 if ($paramname ==
'sortorder') {
665 } elseif (isset($user->default_values[$relativepathstring][
'filters'])) {
666 foreach ($user->default_values[$relativepathstring][
'filters'] as $defkey => $defval) {
667 if (!empty($_GET[
'disabledefaultvalues'])) {
671 if ($defkey !=
'_noquery_') {
672 $tmpqueryarraytohave = explode(
'&', $defkey);
675 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
676 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
690 if (isset($_POST[
'sall']) || isset($_POST[
'search_all']) || isset($_GET[
'sall']) || isset($_GET[
'search_all'])) {
692 if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH)) {
693 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
694 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
697 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
698 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
713 if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
717 while (preg_match(
'/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) {
721 if ($reg[1] ==
'DAY') {
723 $newout = $tmp[
'mday'];
724 } elseif ($reg[1] ==
'MONTH') {
726 $newout = $tmp[
'mon'];
727 } elseif ($reg[1] ==
'YEAR') {
729 $newout = $tmp[
'year'];
730 } elseif ($reg[1] ==
'PREVIOUS_DAY') {
733 $newout = $tmp2[
'day'];
734 } elseif ($reg[1] ==
'PREVIOUS_MONTH') {
737 $newout = $tmp2[
'month'];
738 } elseif ($reg[1] ==
'PREVIOUS_YEAR') {
740 $newout = ($tmp[
'year'] - 1);
741 } elseif ($reg[1] ==
'NEXT_DAY') {
744 $newout = $tmp2[
'day'];
745 } elseif ($reg[1] ==
'NEXT_MONTH') {
748 $newout = $tmp2[
'month'];
749 } elseif ($reg[1] ==
'NEXT_YEAR') {
751 $newout = ($tmp[
'year'] + 1);
752 } elseif ($reg[1] ==
'MYCOMPANY_COUNTRY_ID' || $reg[1] ==
'MYCOUNTRY_ID' || $reg[1] ==
'MYCOUNTRYID') {
753 $newout = $mysoc->country_id;
754 } elseif ($reg[1] ==
'USER_ID' || $reg[1] ==
'USERID') {
756 } elseif ($reg[1] ==
'USER_SUPERVISOR_ID' || $reg[1] ==
'SUPERVISOR_ID' || $reg[1] ==
'SUPERVISORID') {
757 $newout = $user->fk_user;
758 } elseif ($reg[1] ==
'ENTITY_ID' || $reg[1] ==
'ENTITYID') {
759 $newout = $conf->entity;
764 $out = preg_replace(
'/__'.preg_quote($reg[1],
'/').
'__/', $newout, $out);
769 if (preg_match(
'/^array/', $check)) {
770 if (!is_array($out) || empty($out)) {
773 $tmparray = explode(
':', $check);
774 if (!empty($tmparray[1])) {
775 $tmpcheck = $tmparray[1];
777 $tmpcheck =
'alphanohtml';
779 foreach ($out as $outkey => $outval) {
780 $out[$outkey] =
sanitizeVal($outval, $tmpcheck, $filter, $options);
784 $out =
sanitizeVal($out, $check, $filter, $options);
789 if ($paramname ==
'backtopage' || $paramname ==
'backtolist' || $paramname ==
'backtourl') {
790 $out = str_replace(
'\\',
'/', $out);
791 $out = str_replace(array(
':',
';',
'@',
"\t",
' '),
'', $out);
793 $oldstringtoclean = $out;
794 $out = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $out);
795 $out = preg_replace(array(
'/^[^\?]*%/'),
'', $out);
796 $out = preg_replace(array(
'/^[a-z]*\/\s*\/+/i'),
'', $out);
797 }
while ($oldstringtoclean != $out);
802 if (empty($method) || $method == 3 || $method == 4) {
803 if (preg_match(
'/^search_/', $paramname) || in_array($paramname, array(
'sortorder',
'sortfield'))) {
810 if ($out !=
'' && isset($user)) {
811 $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out;
830 return (
int)
GETPOST($paramname,
'int', $method,
null,
null, 0);
844 function checkVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
846 return sanitizeVal($out, $check, $filter, $options);
858 function sanitizeVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
868 if (!is_numeric($out)) {
873 if (preg_match(
'/[^0-9,-]+/i', $out)) {
878 $out = filter_var($out, FILTER_SANITIZE_STRING);
881 $out = filter_var($out, FILTER_SANITIZE_EMAIL);
884 if (!is_array($out)) {
886 if (preg_match(
'/[^a-z]+/i', $out)) {
892 if (!is_array($out)) {
894 if (preg_match(
'/[^a-z0-9_\-\.]+/i', $out)) {
900 if (!is_array($out)) {
902 if (preg_match(
'/[^a-z0-9_\-\.,]+/i', $out)) {
912 if (!is_array($out)) {
915 $oldstringtoclean = $out;
922 $out = str_ireplace(array(
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'\',
'\',
'/',
'../',
'..\\'),
'', $out);
923 }
while ($oldstringtoclean != $out);
928 if (!is_array($out)) {
931 $oldstringtoclean = $out;
937 $out = str_ireplace(array(
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'\',
'\',
'/',
'../',
'..\\'),
'', $out);
938 }
while ($oldstringtoclean != $out);
942 case 'restricthtmlallowunvalid':
947 if (empty($filter)) {
948 return 'BadParameterForGETPOST - Param 3 of sanitizeVal()';
953 $out = filter_var($out, $filter, $options);
962 if (!function_exists(
'dol_getprefix')) {
972 function dol_getprefix($mode =
'')
975 if ($mode ==
'email') {
978 if (!empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) {
979 if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID !=
'SERVER_NAME') {
980 return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
981 } elseif (isset($_SERVER[
"SERVER_NAME"])) {
982 return $_SERVER[
"SERVER_NAME"];
987 if (!empty($conf->file->instance_unique_id)) {
988 return sha1(
'dolibarr'.$conf->file->instance_unique_id);
992 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
996 global $dolibarr_main_instance_unique_id, $dolibarr_main_cookie_cryptkey;
997 $tmp_instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ?
'' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
1000 if (!empty($tmp_instance_unique_id)) {
1001 return sha1(
'dolibarr'.$tmp_instance_unique_id);
1005 if (isset($_SERVER[
"SERVER_NAME"]) && isset($_SERVER[
"DOCUMENT_ROOT"])) {
1006 return sha1($_SERVER[
"SERVER_NAME"].$_SERVER[
"DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1008 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1025 global $conf, $langs, $user, $mysoc;
1029 if (!file_exists($fullpath)) {
1030 dol_syslog(
'functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_WARNING);
1034 if (!empty($classname) && !class_exists($classname)) {
1035 return include $fullpath;
1037 return include_once $fullpath;
1056 $path = preg_replace(
'/^\//',
'', $path);
1059 $res = DOL_DOCUMENT_ROOT.
'/'.$path;
1060 if (is_array($conf->file->dol_document_root)) {
1061 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1062 if ($key ==
'main') {
1065 if (file_exists($dirroot.
'/'.$path)) {
1066 $res = $dirroot.
'/'.$path;
1071 if ($returnemptyifnotfound) {
1073 if ($returnemptyifnotfound == 1 || !file_exists($res)) {
1085 $res = DOL_URL_ROOT.
'/'.$path;
1088 $res = DOL_MAIN_URL_ROOT.
'/'.$path;
1091 $res = DOL_URL_ROOT.
'/'.$path;
1094 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1095 if ($key ==
'main') {
1097 global $dolibarr_main_url_root;
1100 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1101 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1104 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
'/'.$path;
1108 preg_match(
'/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);
1109 if (!empty($regs[1])) {
1111 if (file_exists($dirroot.
'/'.$regs[1])) {
1113 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1116 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1119 global $dolibarr_main_url_root;
1122 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1123 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1126 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).$conf->file->dol_url_root[$key].
'/'.$path;
1153 if (isset($object->db) && isset($object->db->db) && is_object($object->db->db) && get_class($object->db->db) ==
'PgSql\Connection') {
1154 $tmpsavdb = $object->db;
1158 $myclone = unserialize(serialize($object));
1160 if (!empty($tmpsavdb)) {
1161 $object->db = $tmpsavdb;
1163 } elseif ($native == 2) {
1165 $myclone =
new stdClass();
1166 $tmparray = get_object_vars($object);
1168 if (is_array($tmparray)) {
1169 foreach ($tmparray as $propertykey => $propertyval) {
1170 if (is_scalar($propertyval) || is_array($propertyval)) {
1171 $myclone->$propertykey = $propertyval;
1176 $myclone = clone $object;
1194 if (empty($conf->dol_optimize_smallscreen)) {
1197 if ($type ==
'width' && $size > 250) {
1222 $filesystem_forbidden_chars = array(
'<',
'>',
'/',
'\\',
'?',
'*',
'|',
'"',
':',
'°',
'$',
';');
1224 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1225 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1226 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1227 $tmp = str_replace(
'..',
'', $tmp);
1247 $filesystem_forbidden_chars = array(
'<',
'>',
'?',
'*',
'|',
'"',
'°',
'$',
';');
1249 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1250 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1251 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1252 $tmp = str_replace(
'..',
'', $tmp);
1267 $stringtoclean = preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $stringtoclean);
1269 $stringtoclean = preg_replace(
'/<!--[^>]*-->/',
'', $stringtoclean);
1271 $stringtoclean = str_replace(
'\\',
'/', $stringtoclean);
1275 $stringtoclean = str_replace(array(
':',
';',
'@'),
'', $stringtoclean);
1279 $oldstringtoclean = $stringtoclean;
1282 $stringtoclean = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $stringtoclean);
1283 }
while ($oldstringtoclean != $stringtoclean);
1287 $stringtoclean = preg_replace(array(
'/^[a-z]*\/\/+/i'),
'', $stringtoclean);
1290 return $stringtoclean;
1302 $oldstringtoclean = $stringtoclean;
1303 $stringtoclean = str_ireplace(array(
'"',
':',
'[',
']',
"\n",
"\r",
'\\',
'\/'),
'', $stringtoclean);
1304 }
while ($oldstringtoclean != $stringtoclean);
1306 return $stringtoclean;
1322 if (extension_loaded(
'intl') && !empty($conf->global->MAIN_UNACCENT_USE_TRANSLITERATOR)) {
1323 $transliterator = \Transliterator::createFromRules(
':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', \Transliterator::FORWARD);
1324 return $transliterator->transliterate($str);
1327 $string = rawurlencode($str);
1328 $replacements = array(
1329 '%C3%80' =>
'A',
'%C3%81' =>
'A',
'%C3%82' =>
'A',
'%C3%83' =>
'A',
'%C3%84' =>
'A',
'%C3%85' =>
'A',
1331 '%C3%88' =>
'E',
'%C3%89' =>
'E',
'%C3%8A' =>
'E',
'%C3%8B' =>
'E',
1332 '%C3%8C' =>
'I',
'%C3%8D' =>
'I',
'%C3%8E' =>
'I',
'%C3%8F' =>
'I',
1334 '%C3%92' =>
'O',
'%C3%93' =>
'O',
'%C3%94' =>
'O',
'%C3%95' =>
'O',
'%C3%96' =>
'O',
1336 '%C3%99' =>
'U',
'%C3%9A' =>
'U',
'%C3%9B' =>
'U',
'%C3%9C' =>
'U',
1337 '%C3%9D' =>
'Y',
'%C5%B8' =>
'y',
1338 '%C3%A0' =>
'a',
'%C3%A1' =>
'a',
'%C3%A2' =>
'a',
'%C3%A3' =>
'a',
'%C3%A4' =>
'a',
'%C3%A5' =>
'a',
1340 '%C3%A8' =>
'e',
'%C3%A9' =>
'e',
'%C3%AA' =>
'e',
'%C3%AB' =>
'e',
1341 '%C3%AC' =>
'i',
'%C3%AD' =>
'i',
'%C3%AE' =>
'i',
'%C3%AF' =>
'i',
1343 '%C3%B2' =>
'o',
'%C3%B3' =>
'o',
'%C3%B4' =>
'o',
'%C3%B5' =>
'o',
'%C3%B6' =>
'o',
1345 '%C3%B9' =>
'u',
'%C3%BA' =>
'u',
'%C3%BB' =>
'u',
'%C3%BC' =>
'u',
1346 '%C3%BD' =>
'y',
'%C3%BF' =>
'y'
1348 $string = strtr($string, $replacements);
1349 return rawurldecode($string);
1354 "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
1355 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
1356 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
1357 \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
1358 \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
1359 \xF9\xFA\xFB\xFC\xFD\xFF",
1367 $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"));
1386 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
",",
";",
"=",
'°');
1387 $forbidden_chars_to_remove = array();
1390 if (is_array($badcharstoreplace)) {
1391 $forbidden_chars_to_replace = $badcharstoreplace;
1393 if (is_array($badcharstoremove)) {
1394 $forbidden_chars_to_remove = $badcharstoremove;
1397 return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove,
"", $str));
1416 if ($removetabcrlf) {
1417 return preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $str);
1419 return preg_replace(
'/[\x00-\x08\x11-\x12\x14-\x1F\x7F]/u',
'', $str);
1434 $substitjs = array(
"'"=>
"\\'",
"\r"=>
'\\r');
1436 if (empty($noescapebackslashn)) {
1437 $substitjs[
"\n"] =
'\\n';
1438 $substitjs[
'\\'] =
'\\\\';
1441 $substitjs[
"'"] =
"\\'";
1442 $substitjs[
'"'] =
"\\'";
1443 } elseif ($mode == 1) {
1444 $substitjs[
"'"] =
"\\'";
1445 } elseif ($mode == 2) {
1446 $substitjs[
'"'] =
'\\"';
1447 } elseif ($mode == 3) {
1448 $substitjs[
"'"] =
"\\'";
1449 $substitjs[
'"'] =
"\\\"";
1451 return strtr($stringtoescape, $substitjs);
1462 return str_replace(
'"',
'\"', $stringtoescape);
1476 function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags =
'', $escapeonlyhtmltags = 0)
1478 if ($noescapetags ==
'common') {
1479 $noescapetags =
'html,body,a,b,em,hr,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody';
1483 if ($escapeonlyhtmltags) {
1484 $tmp = htmlspecialchars_decode((
string) $stringtoescape, ENT_COMPAT);
1486 $tmp = html_entity_decode((
string) $stringtoescape, ENT_COMPAT,
'UTF-8');
1489 $tmp = strtr($tmp, array(
"<b>"=>
'',
'</b>'=>
''));
1492 $tmp = strtr($tmp, array(
"\r"=>
'\\r',
"\n"=>
'\\n'));
1495 if ($escapeonlyhtmltags) {
1496 return htmlspecialchars($tmp, ENT_COMPAT,
'UTF-8');
1500 $tmparrayoftags = array();
1501 if ($noescapetags) {
1502 $tmparrayoftags = explode(
',', $noescapetags);
1504 if (count($tmparrayoftags)) {
1505 foreach ($tmparrayoftags as $tagtoreplace) {
1506 $tmp = str_ireplace(
'<'.$tagtoreplace.
'>',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1507 $tmp = str_ireplace(
'</'.$tagtoreplace.
'>',
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1508 $tmp = str_ireplace(
'<'.$tagtoreplace.
' />',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1512 $result = htmlentities($tmp, ENT_COMPAT,
'UTF-8');
1514 if (count($tmparrayoftags)) {
1515 foreach ($tmparrayoftags as $tagtoreplace) {
1516 $result = str_ireplace(
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
'>', $result);
1517 $result = str_ireplace(
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__',
'</'.$tagtoreplace.
'>', $result);
1518 $result = str_ireplace(
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
' />', $result);
1535 if (function_exists(
'mb_strtolower')) {
1536 return mb_strtolower($string, $encoding);
1538 return strtolower($string);
1551 if (function_exists(
'mb_strtoupper')) {
1552 return mb_strtoupper($string, $encoding);
1554 return strtoupper($string);
1567 if (function_exists(
'mb_substr')) {
1568 return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1,
null, $encoding);
1570 return ucfirst($string);
1583 if (function_exists(
'mb_convert_case')) {
1584 return mb_convert_case($string, MB_CASE_TITLE, $encoding);
1586 return ucwords($string);
1611 function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
'', $restricttologhandler =
'', $logcontext =
null)
1613 global $conf, $user, $debugbar;
1616 if (empty($conf->syslog->enabled)) {
1621 if (defined(
'USEEXTERNALSERVER') && !defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
1622 global $website, $websitekey;
1623 if (is_object($website) && !empty($website->ref)) {
1624 $suffixinfilename .=
'_website_'.$website->ref;
1625 } elseif (!empty($websitekey)) {
1626 $suffixinfilename .=
'_website_'.$websitekey;
1631 if (defined(
'USESUFFIXINLOG')) {
1632 $suffixinfilename .= constant(
'USESUFFIXINLOG');
1636 foreach ($conf->loghandlers as $loghandlerinstance) {
1637 $loghandlerinstance->setIdent($ident);
1641 if (!empty($message)) {
1643 $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');
1644 if (!array_key_exists($level, $logLevels)) {
1645 throw new Exception(
'Incorrect log level');
1647 if ($level > $conf->global->SYSLOG_LEVEL) {
1651 if (empty($conf->global->MAIN_SHOW_PASSWORD_INTO_LOG)) {
1652 $message = preg_replace(
'/password=\'[^\']*\'/',
'password=\'hidden\'', $message);
1656 if ((!empty($_REQUEST[
'logtohtml']) && !empty($conf->global->MAIN_ENABLE_LOG_TO_HTML))
1657 || (!empty($user->rights->debugbar->read) && is_object($debugbar))) {
1658 $conf->logbuffer[] =
dol_print_date(time(),
"%Y-%m-%d %H:%M:%S").
" ".$logLevels[$level].
" ".$message;
1663 if (!empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && !empty($_GET[
"log"])) {
1664 print
"\n\n<!-- Log start\n";
1666 print
"Log end -->\n";
1670 'message' => $message,
1671 'script' => (isset($_SERVER[
'PHP_SELF']) ? basename($_SERVER[
'PHP_SELF'],
'.php') :
false),
1673 'user' => ((is_object($user) && $user->id) ? $user->login :
false),
1678 if (!empty($remoteip)) {
1679 $data[
'ip'] = $remoteip;
1681 if (!empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) && $_SERVER[
'HTTP_X_FORWARDED_FOR'] != $remoteip) {
1682 $data[
'ip'] = $_SERVER[
'HTTP_X_FORWARDED_FOR'].
' -> '.$data[
'ip'];
1683 } elseif (!empty($_SERVER[
'HTTP_CLIENT_IP']) && $_SERVER[
'HTTP_CLIENT_IP'] != $remoteip) {
1684 $data[
'ip'] = $_SERVER[
'HTTP_CLIENT_IP'].
' -> '.$data[
'ip'];
1686 } elseif (!empty($_SERVER[
'SERVER_ADDR'])) {
1688 $data[
'ip'] = $_SERVER[
'SERVER_ADDR'];
1689 } elseif (!empty($_SERVER[
'COMPUTERNAME'])) {
1691 $data[
'ip'] = $_SERVER[
'COMPUTERNAME'].(empty($_SERVER[
'USERNAME']) ?
'' :
'@'.$_SERVER[
'USERNAME']);
1692 } elseif (!empty($_SERVER[
'LOGNAME'])) {
1694 $data[
'ip'] =
'???@'.$_SERVER[
'LOGNAME'];
1698 foreach ($conf->loghandlers as $loghandlerinstance) {
1699 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
1702 $loghandlerinstance->export($data, $suffixinfilename);
1708 foreach ($conf->loghandlers as $loghandlerinstance) {
1709 $loghandlerinstance->setIdent($ident);
1732 if (strpos($url,
'?') > 0) {
1733 $url .=
'&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name);
1735 $url .=
'?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name);
1740 $backtopagejsfieldsid =
''; $backtopagejsfieldslabel =
'';
1741 if ($backtopagejsfields) {
1742 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
1743 if (empty($tmpbacktopagejsfields[1])) {
1744 $backtopagejsfields = $name.
":".$backtopagejsfields;
1745 $tmp2backtopagejsfields = explode(
',', $tmpbacktopagejsfields[0]);
1747 $tmp2backtopagejsfields = explode(
',', $tmpbacktopagejsfields[1]);
1749 $backtopagejsfieldsid = empty($tmp2backtopagejsfields[0]) ?
'' : $tmp2backtopagejsfields[0];
1750 $backtopagejsfieldslabel = empty($tmp2backtopagejsfields[1]) ?
'' : $tmp2backtopagejsfields[1];
1751 $url .=
'&backtopagejsfields='.urlencode($backtopagejsfields);
1755 $out .=
'<!-- a link for button to open url into a dialog popup with backtopagejsfields = '.$backtopagejsfields.
' -->';
1756 $out .=
'<a class="cursorpointer classlink button_'.$name.($morecss ?
' '.$morecss :
'').
'"'.$disabled.
' title="'.
dol_escape_htmltag($label).
'"';
1757 if (empty($conf->use_javascript_ajax)) {
1758 $out .=
' href="'.DOL_URL_ROOT.$url.
'" target="_blank"';
1760 $out .=
'>'.$buttonstring.
'</a>';
1762 if (!empty($conf->use_javascript_ajax)) {
1764 $out .=
'<!-- code to open popup and variables to retreive returned variables -->';
1765 $out .=
'<div id="idfordialog'.$name.
'" class="hidden">div for dialog</div>';
1766 $out .=
'<div id="varforreturndialogid'.$name.
'" class="hidden">div for returned id</div>';
1767 $out .=
'<div id="varforreturndialoglabel'.$name.
'" class="hidden">div for returned label</div>';
1768 $out .=
'<!-- Add js code to open dialog popup on dialog -->';
1769 $out .=
'<script type="text/javascript">
1770 jQuery(document).ready(function () {
1771 jQuery(".button_'.$name.
'").click(function () {
1772 console.log(\'Open popup with jQuery(...).dialog() on URL '.
dol_escape_js(DOL_URL_ROOT.$url).
'\');
1773 var $tmpdialog = $(\
'#idfordialog'.$name.
'\');
1774 $tmpdialog.html(\
'<iframe class="iframedialog" id="iframedialog'.$name.
'" style="border: 0px;" src="'.DOL_URL_ROOT.$url.
'" width="100%" height="98%"></iframe>\');
1778 height: (window.innerHeight - 150),
1781 open:
function (event, ui) {
1782 console.log(
"open popup name='.$name.', backtopagejsfields='.$backtopagejsfields.'");
1784 close:
function (event, ui) {
1785 returnedid = jQuery(
"#varforreturndialogid'.$name.'").text();
1786 returnedlabel = jQuery(
"#varforreturndialoglabel'.$name.'").text();
1787 console.log(
"popup has been closed. returnedid (js var defined into parent page)="+returnedid+
" returnedlabel="+returnedlabel);
1788 if (returnedid !=
"" && returnedid !=
"div for returned id") {
1789 jQuery(
"#'.(empty($backtopagejsfieldsid)?"none
":$backtopagejsfieldsid).'").val(returnedid);
1791 if (returnedlabel !=
"" && returnedlabel !=
"div for returned label") {
1792 jQuery(
"#'.(empty($backtopagejsfieldslabel)?"none
":$backtopagejsfieldslabel).'").val(returnedlabel);
1797 $tmpdialog.dialog(\
'open\');
1821 function dol_fiche_head($links = array(), $active =
'0', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
1823 print
dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow, $moretabssuffix);
1841 function dol_get_fiche_head($links = array(), $active =
'', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
1843 global $conf, $langs, $hookmanager;
1847 if (!empty($conf->dol_optimize_smallscreen)) {
1851 $out =
"\n".
'<!-- dol_fiche_head - dol_get_fiche_head -->';
1853 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
1854 $out .=
'<div class="tabs'.($picto ?
'' :
' nopaddingleft').
'" data-role="controlgroup" data-type="horizontal">'.
"\n";
1858 if ($morehtmlright) {
1859 $out .=
'<div class="inline-block floatright tabsElem">'.$morehtmlright.
'</div>';
1863 if (!empty($title) && $showtitle && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1865 $out .=
'<a class="tabTitle">';
1867 $noprefix = $pictoisfullpath;
1868 if (strpos($picto,
'fontawesome_') !==
false) {
1871 $out .=
img_picto($title, ($noprefix ?
'' :
'object_').$picto,
'', $pictoisfullpath, 0, 0,
'',
'imgTabTitle').
' ';
1873 $out .=
'<span class="tabTitleText">'.dol_escape_htmltag(
dol_trunc($title, $limittitle)).
'</span>';
1881 if (is_array($links) && !empty($links)) {
1882 $keys = array_keys($links);
1884 $maxkey = max($keys);
1890 if (empty($limittoshow)) {
1891 $limittoshow = (empty($conf->global->MAIN_MAXTABS_IN_CARD) ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD);
1893 if (!empty($conf->dol_optimize_smallscreen)) {
1901 for ($i = 0; $i <= $maxkey; $i++) {
1902 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
1904 if ($i >= $limittoshow) {
1910 for ($i = 0; $i <= $maxkey; $i++) {
1911 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
1917 if ($i < $limittoshow || $isactive) {
1919 $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])).
' -->';
1921 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
1922 if (!empty($links[$i][0])) {
1923 $out .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
1925 $out .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
1927 } elseif (!empty($links[$i][1])) {
1929 $out .=
'<div class="tab tab'.($isactive?
'active':
'unactive').
'" style="margin: 0 !important">';
1930 if (!empty($links[$i][0])) {
1931 $titletoshow = preg_replace(
'/<.*$/',
'', $links[$i][1]);
1932 $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).
'">';
1934 $out .= $links[$i][1];
1935 if (!empty($links[$i][0])) {
1936 $out .=
'</a>'.
"\n";
1938 $out .= empty($links[$i][4]) ?
'' : $links[$i][4];
1947 $outmore .=
'<div class="popuptabset wordwrap">';
1949 $outmore .=
'<div class="popuptab wordwrap" style="display:inherit;">';
1950 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
1951 if (!empty($links[$i][0])) {
1952 $outmore .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
1954 $outmore .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
1956 } elseif (!empty($links[$i][1])) {
1957 $outmore .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="wordwrap inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
1958 $outmore .= preg_replace(
'/([a-z])\/([a-z])/i',
'\\1 / \\2', $links[$i][1]);
1959 $outmore .=
'</a>'.
"\n";
1961 $outmore .=
'</div>';
1968 $outmore .=
'</div>';
1972 $left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
1973 $right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
1974 $widthofpopup = 200;
1976 $tabsname = $moretabssuffix;
1977 if (empty($tabsname)) {
1978 $tabsname = str_replace(
"@",
"", $picto);
1980 $out .=
'<div id="moretabs'.$tabsname.
'" class="inline-block tabsElem valignmiddle">';
1981 $out .=
'<div class="tab"><a href="#" class="tab moretab inline-block tabunactive"><span class="hideonsmartphone">'.$langs->trans(
"More").
'</span>... ('.$nbintab.
')</a></div>';
1982 $out .=
'<div id="moretabsList'.$tabsname.
'" style="width: '.$widthofpopup.
'px; position: absolute; '.$left.
': -999em; text-align: '.$left.
'; margin:0px; padding:2px; z-index:10;">';
1985 $out .=
'<div></div>';
1989 $out .=
"$('#moretabs".$tabsname.
"').mouseenter( function() {
1990 var x = this.offsetLeft, y = this.offsetTop;
1991 console.log('mouseenter ".$left.
" x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
1992 if ((window.innerWidth - x) < ".($widthofpopup + 10).
") {
1993 $('#moretabsList".$tabsname.
"').css('".$right.
"','8px');
1995 $('#moretabsList".$tabsname.
"').css('".$left.
"','auto');
1998 $out .=
"$('#moretabs".$tabsname.
"').mouseleave( function() { console.log('mouseleave ".$left.
"'); $('#moretabsList".$tabsname.
"').css('".$left.
"','-999em');});";
1999 $out .=
"</script>";
2002 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2006 if (!$notab || $notab == -1 || $notab == -2 || $notab == -3) {
2007 $out .=
"\n".
'<div class="tabBar'.($notab == -1 ?
'' : ($notab == -2 ?
' tabBarNoTop' : (($notab == -3 ?
' noborderbottom' :
'').
' tabBarWithBottom'))).
'">'.
"\n";
2010 $parameters = array(
'tabname' => $active,
'out' => $out);
2011 $reshook = $hookmanager->executeHooks(
'printTabsHead', $parameters);
2013 $out = $hookmanager->resPrint;
2039 if (!$notab || $notab == -1) {
2040 return "\n</div>\n";
2065 function dol_banner_tab($object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $onlybanner = 0, $morehtmlright =
'')
2067 global $conf,
$form, $user, $langs, $hookmanager, $action;
2071 $maxvisiblephotos = 1;
2073 $entity = (empty($object->entity) ? $conf->entity : $object->entity);
2074 $showbarcode = empty($conf->barcode->enabled) ? 0 : (empty($object->barcode) ? 0 : 1);
2075 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
2078 $modulepart =
'unknown';
2080 if ($object->element ==
'societe' || $object->element ==
'contact' || $object->element ==
'product' || $object->element ==
'ticket') {
2081 $modulepart = $object->element;
2082 } elseif ($object->element ==
'member') {
2083 $modulepart =
'memberphoto';
2084 } elseif ($object->element ==
'user') {
2085 $modulepart =
'userphoto';
2088 if (class_exists(
"Imagick")) {
2089 if ($object->element ==
'expensereport' || $object->element ==
'propal' || $object->element ==
'commande' || $object->element ==
'facture' || $object->element ==
'supplier_proposal') {
2090 $modulepart = $object->element;
2091 } elseif ($object->element ==
'fichinter') {
2092 $modulepart =
'ficheinter';
2093 } elseif ($object->element ==
'contrat') {
2094 $modulepart =
'contract';
2095 } elseif ($object->element ==
'order_supplier') {
2096 $modulepart =
'supplier_order';
2097 } elseif ($object->element ==
'invoice_supplier') {
2098 $modulepart =
'supplier_invoice';
2102 if ($object->element ==
'product') {
2104 $cssclass =
'photowithmargin photoref';
2105 $showimage = $object->is_photo_available($conf->product->multidir_output[$entity]);
2106 $maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5);
2107 if ($conf->browser->layout ==
'phone') {
2108 $maxvisiblephotos = 1;
2111 $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>';
2113 if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
2115 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2117 $nophoto =
'/public/theme/common/nophoto.png';
2118 $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>';
2121 } elseif ($object->element ==
'ticket') {
2123 $cssclass =
'photoref';
2124 $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity].
'/'.$object->ref);
2125 $maxvisiblephotos = (isset($conf->global->TICKET_MAX_VISIBLE_PHOTO) ? $conf->global->TICKET_MAX_VISIBLE_PHOTO : 2);
2126 if ($conf->browser->layout ==
'phone') {
2127 $maxvisiblephotos = 1;
2131 $showphoto = $object->show_photos(
'ticket', $conf->ticket->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0);
2132 if ($object->nbphoto > 0) {
2133 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$showphoto.
'</div>';
2139 if (!empty($conf->global->TICKET_NODISPLAYIFNOPHOTO)) {
2141 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2143 $nophoto =
img_picto(
'No photo',
'object_ticket');
2144 $morehtmlleft .=
'<!-- No photo to show -->';
2145 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2146 $morehtmlleft .= $nophoto;
2147 $morehtmlleft .=
'</div></div>';
2152 if ($modulepart !=
'unknown') {
2155 if (in_array($modulepart, array(
'propal',
'commande',
'facture',
'ficheinter',
'contract',
'supplier_order',
'supplier_proposal',
'supplier_invoice',
'expensereport')) && class_exists(
"Imagick")) {
2157 $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]).
"/";
2158 if (in_array($modulepart, array(
'invoice_supplier',
'supplier_invoice'))) {
2159 $subdir =
get_exdir($object->id, 2, 0, 1, $object, $modulepart);
2160 $subdir .= ((!empty($subdir) && !preg_match(
'/\/$/', $subdir)) ?
'/' :
'').$objectref;
2162 $subdir =
get_exdir($object->id, 0, 0, 1, $object, $modulepart);
2164 if (empty($subdir)) {
2165 $subdir =
'errorgettingsubdirofobject';
2168 $filepath = $dir_output.$subdir.
"/";
2170 $filepdf = $filepath.$objectref.
".pdf";
2171 $relativepath = $subdir.
'/'.$objectref.
'.pdf';
2174 $fileimage = $filepdf.
'_preview.png';
2175 $relativepathimage = $relativepath.
'_preview.png';
2177 $pdfexists = file_exists($filepdf);
2182 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2183 if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) {
2184 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2193 if ($pdfexists && !$error) {
2194 $heightforphotref = 80;
2195 if (!empty($conf->dol_optimize_smallscreen)) {
2196 $heightforphotref = 60;
2199 if (file_exists($fileimage)) {
2200 $phototoshow =
'<div class="photoref">';
2201 $phototoshow .=
'<img height="'.$heightforphotref.
'" class="photo photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2202 $phototoshow .=
'</div>';
2205 } elseif (!$phototoshow) {
2206 $phototoshow .=
$form->showphoto($modulepart, $object, 0, 0, 0,
'photowithmargin photoref',
'small', 1, 0, $maxvisiblephotos);
2210 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
2211 $morehtmlleft .= $phototoshow;
2212 $morehtmlleft .=
'</div>';
2216 if (empty($phototoshow)) {
2217 if ($object->element ==
'action') {
2219 $cssclass =
'photorefcenter';
2220 $nophoto =
img_picto(
'No photo',
'title_agenda');
2223 $cssclass =
'photorefcenter';
2224 $picto = $object->picto;
2225 $prefix =
'object_';
2226 if ($object->element ==
'project' && !$object->public) {
2229 if (strpos($picto,
'fontawesome_') !==
false) {
2232 $nophoto =
img_picto(
'No photo', $prefix.$picto);
2234 $morehtmlleft .=
'<!-- No photo to show -->';
2235 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2236 $morehtmlleft .= $nophoto;
2237 $morehtmlleft .=
'</div></div>';
2243 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object, 100,
'photoref valignmiddle').
'</div>';
2246 if ($object->element ==
'societe') {
2247 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'societe',
'creer') && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
2248 $morehtmlstatus .=
ajax_object_onoff($object,
'status',
'status',
'InActivity',
'ActivityCeased');
2250 $morehtmlstatus .= $object->getLibStatut(6);
2252 } elseif ($object->element ==
'product') {
2254 if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
2255 $morehtmlstatus .=
ajax_object_onoff($object,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
2257 $morehtmlstatus .=
'<span class="statusrefsell">'.$object->getLibStatut(6, 0).
'</span>';
2259 $morehtmlstatus .=
' ';
2261 if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
2262 $morehtmlstatus .=
ajax_object_onoff($object,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
2264 $morehtmlstatus .=
'<span class="statusrefbuy">'.$object->getLibStatut(6, 1).
'</span>';
2266 } elseif (in_array($object->element, array(
'facture',
'invoice',
'invoice_supplier',
'chargesociales',
'loan',
'tva',
'salary'))) {
2267 $tmptxt = $object->getLibStatut(6, $object->totalpaid);
2268 if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
2269 $tmptxt = $object->getLibStatut(5, $object->totalpaid);
2271 $morehtmlstatus .= $tmptxt;
2272 } elseif ($object->element ==
'contrat' || $object->element ==
'contract') {
2273 if ($object->statut == 0) {
2274 $morehtmlstatus .= $object->getLibStatut(5);
2276 $morehtmlstatus .= $object->getLibStatut(4);
2278 } elseif ($object->element ==
'facturerec') {
2279 if ($object->frequency == 0) {
2280 $morehtmlstatus .= $object->getLibStatut(2);
2282 $morehtmlstatus .= $object->getLibStatut(5);
2284 } elseif ($object->element ==
'project_task') {
2285 $object->fk_statut = 1;
2286 if ($object->progress > 0) {
2287 $object->fk_statut = 2;
2289 if ($object->progress >= 100) {
2290 $object->fk_statut = 3;
2292 $tmptxt = $object->getLibStatut(5);
2293 $morehtmlstatus .= $tmptxt;
2295 if (isset($object->status)) {
2296 $tmptxt = $object->getLibStatut(6);
2297 if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
2298 $tmptxt = $object->getLibStatut(5);
2300 $morehtmlstatus .= $tmptxt;
2305 if (
isModEnabled(
'accounting') && in_array($object->element, array(
'bank',
'paiementcharge',
'facture',
'invoice',
'invoice_supplier',
'expensereport',
'payment_various'))) {
2307 if (method_exists($object,
'getVentilExportCompta')) {
2308 $accounted = $object->getVentilExportCompta();
2309 $langs->load(
"accountancy");
2310 $morehtmlstatus .=
'</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? $langs->trans(
"Accounted") : $langs->trans(
"NotYetAccounted")).
'</span>';
2315 if (!empty($object->name_alias)) {
2316 $morehtmlref .=
'<div class="refidno opacitymedium">'.$object->name_alias.
'</div>';
2320 if (in_array($object->element, array(
'product',
'bank_account',
'project_task'))) {
2321 if (!empty($object->label)) {
2322 $morehtmlref .=
'<div class="refidno opacitymedium">'.$object->label.
'</div>';
2327 if (method_exists($object,
'getBannerAddress') && !in_array($object->element, array(
'product',
'bookmark',
'ecm_directories',
'ecm_files'))) {
2328 $moreaddress = $object->getBannerAddress(
'refaddress', $object);
2330 $morehtmlref .=
'<div class="refidno">';
2331 $morehtmlref .= $moreaddress;
2332 $morehtmlref .=
'</div>';
2335 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)) {
2336 $morehtmlref .=
'<div style="clear: both;"></div>';
2337 $morehtmlref .=
'<div class="refidno opacitymedium">';
2338 $morehtmlref .= $langs->trans(
"TechnicalID").
': '.$object->id;
2339 $morehtmlref .=
'</div>';
2342 $parameters=array(
'morehtmlref'=>$morehtmlref);
2343 $reshook = $hookmanager->executeHooks(
'formDolBanner', $parameters, $object, $action);
2346 } elseif (empty($reshook)) {
2347 $morehtmlref .= $hookmanager->resPrint;
2348 } elseif ($reshook > 0) {
2349 $morehtmlref = $hookmanager->resPrint;
2353 print
'<div class="'.($onlybanner ?
'arearefnobottom ' :
'arearef ').
'heightref valignmiddle centpercent">';
2354 print
$form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
2356 print
'<div class="underrefbanner clearboth"></div>';
2372 if ($fieldrequired) {
2373 $ret .=
'<span class="fieldrequired">';
2375 $ret .=
'<label for="'.$fieldkey.
'">';
2376 $ret .= $langs->trans($langkey);
2378 if ($fieldrequired) {
2394 $ret =
' '.$bc[$var];
2396 $ret = preg_replace(
'/class=\"/',
'class="'.$moreclass.
' ', $ret);
2414 function dol_format_address($object, $withcountry = 0, $sep =
"\n", $outputlangs =
'', $mode = 0, $extralangcode =
'')
2416 global $conf, $langs, $hookmanager;
2419 $countriesusingstate = array(
'AU',
'CA',
'US',
'IN',
'GB',
'ES',
'UK',
'TR',
'CN');
2424 $ret .= ($extralangcode ? $object->array_languages[
'address'][$extralangcode] : (empty($object->address) ?
'' : $object->address));
2427 if (isset($object->country_code) && in_array($object->country_code, array(
'AU',
'CA',
'US',
'CN')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) {
2429 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2430 $ret .= (($ret && $town) ? $sep :
'').$town;
2432 if (!empty($object->state)) {
2433 $ret .= ($ret ? ($town ?
", " : $sep) :
'').$object->state;
2435 if (!empty($object->zip)) {
2436 $ret .= ($ret ? (($town || $object->state) ?
", " : $sep) :
'').$object->zip;
2438 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'GB',
'UK'))) {
2440 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2441 $ret .= ($ret ? $sep :
'').$town;
2442 if (!empty($object->state)) {
2443 $ret .= ($ret ?
", " :
'').$object->state;
2445 if (!empty($object->zip)) {
2446 $ret .= ($ret ? $sep :
'').$object->zip;
2448 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'ES',
'TR'))) {
2450 $ret .= ($ret ? $sep :
'').$object->zip;
2451 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2452 $ret .= ($town ? (($object->zip ?
' ' :
'').$town) :
'');
2453 if (!empty($object->state)) {
2454 $ret .=
"\n".$object->state;
2456 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'JP'))) {
2459 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2460 $ret .= ($ret ? $sep :
'').($object->state ? $object->state.
', ' :
'').$town.($object->zip ?
' ' :
'').$object->zip;
2461 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'IT'))) {
2463 $ret .= ($ret ? $sep :
'').$object->zip;
2464 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2465 $ret .= ($town ? (($object->zip ?
' ' :
'').$town) :
'');
2466 $ret .= (empty($object->state_code) ?
'' : (
' '.$object->state_code));
2469 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2470 $ret .= !empty($object->zip) ? (($ret ? $sep :
'').$object->zip) :
'';
2471 $ret .= ($town ? (($object->zip ?
' ' : ($ret ? $sep :
'')).$town) :
'');
2472 if (!empty($object->state) && in_array($object->country_code, $countriesusingstate)) {
2473 $ret .= ($ret ?
", " :
'').$object->state;
2476 if (!is_object($outputlangs)) {
2477 $outputlangs = $langs;
2480 $langs->load(
"dict");
2481 $ret .= (empty($object->country_code) ?
'' : ($ret ? $sep :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$object->country_code)));
2484 $parameters = array(
'withcountry' => $withcountry,
'sep' => $sep,
'outputlangs' => $outputlangs,
'mode' => $mode,
'extralangcode' => $extralangcode);
2485 $reshook = $hookmanager->executeHooks(
'formatAddress', $parameters, $object);
2489 $ret .= $hookmanager->resPrint;
2507 if ((abs($ts) <= 0x7FFFFFFF)) {
2508 return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts);
2510 return 'Error date into a not supported range';
2535 function dol_print_date($time, $format =
'', $tzoutput =
'auto', $outputlangs =
'', $encodetooutput =
false)
2537 global $conf, $langs;
2544 if ($tzoutput ===
'auto') {
2545 $tzoutput = (empty($conf) ?
'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey :
'tzserver'));
2550 $offsettz = $offsetdst = 0;
2553 if (is_string($tzoutput)) {
2554 if ($tzoutput ==
'tzserver') {
2556 $offsettzstring = @date_default_timezone_get();
2559 } elseif ($tzoutput ==
'tzuser' || $tzoutput ==
'tzuserrel') {
2561 $offsettzstring = (empty($_SESSION[
'dol_tz_string']) ?
'UTC' : $_SESSION[
'dol_tz_string']);
2563 if (class_exists(
'DateTimeZone')) {
2564 $user_date_tz =
new DateTimeZone($offsettzstring);
2565 $user_dt =
new DateTime();
2566 $user_dt->setTimezone($user_date_tz);
2567 $user_dt->setTimestamp($tzoutput ==
'tzuser' ?
dol_now() : (
int) $time);
2568 $offsettz = $user_dt->getOffset();
2570 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
2571 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
2576 if (!is_object($outputlangs)) {
2577 $outputlangs = $langs;
2580 $format =
'daytextshort';
2585 $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array(
'day',
'dayhour'))) ? 1 : 0;
2586 $format = preg_replace(
'/inputnoreduce/',
'', $format);
2587 $formatwithoutreduce = preg_replace(
'/reduceformat/',
'', $format);
2588 if ($formatwithoutreduce != $format) {
2589 $format = $formatwithoutreduce;
2595 if ($format ==
'day') {
2596 $format = ($outputlangs->trans(
"FormatDateShort") !=
"FormatDateShort" ? $outputlangs->trans(
"FormatDateShort") : $conf->format_date_short);
2597 } elseif ($format ==
'hour') {
2598 $format = ($outputlangs->trans(
"FormatHourShort") !=
"FormatHourShort" ? $outputlangs->trans(
"FormatHourShort") : $conf->format_hour_short);
2599 } elseif ($format ==
'hourduration') {
2600 $format = ($outputlangs->trans(
"FormatHourShortDuration") !=
"FormatHourShortDuration" ? $outputlangs->trans(
"FormatHourShortDuration") : $conf->format_hour_short_duration);
2601 } elseif ($format ==
'daytext') {
2602 $format = ($outputlangs->trans(
"FormatDateText") !=
"FormatDateText" ? $outputlangs->trans(
"FormatDateText") : $conf->format_date_text);
2603 } elseif ($format ==
'daytextshort') {
2604 $format = ($outputlangs->trans(
"FormatDateTextShort") !=
"FormatDateTextShort" ? $outputlangs->trans(
"FormatDateTextShort") : $conf->format_date_text_short);
2605 } elseif ($format ==
'dayhour') {
2606 $format = ($outputlangs->trans(
"FormatDateHourShort") !=
"FormatDateHourShort" ? $outputlangs->trans(
"FormatDateHourShort") : $conf->format_date_hour_short);
2607 } elseif ($format ==
'dayhoursec') {
2608 $format = ($outputlangs->trans(
"FormatDateHourSecShort") !=
"FormatDateHourSecShort" ? $outputlangs->trans(
"FormatDateHourSecShort") : $conf->format_date_hour_sec_short);
2609 } elseif ($format ==
'dayhourtext') {
2610 $format = ($outputlangs->trans(
"FormatDateHourText") !=
"FormatDateHourText" ? $outputlangs->trans(
"FormatDateHourText") : $conf->format_date_hour_text);
2611 } elseif ($format ==
'dayhourtextshort') {
2612 $format = ($outputlangs->trans(
"FormatDateHourTextShort") !=
"FormatDateHourTextShort" ? $outputlangs->trans(
"FormatDateHourTextShort") : $conf->format_date_hour_text_short);
2613 } elseif ($format ==
'dayhourlog') {
2615 $format =
'%Y%m%d%H%M%S';
2616 } elseif ($format ==
'dayhourlogsmall') {
2618 $format =
'%Y%m%d%H%M';
2619 } elseif ($format ==
'dayhourldap') {
2620 $format =
'%Y%m%d%H%M%SZ';
2621 } elseif ($format ==
'dayhourxcard') {
2622 $format =
'%Y%m%dT%H%M%SZ';
2623 } elseif ($format ==
'dayxcard') {
2625 } elseif ($format ==
'dayrfc') {
2626 $format =
'%Y-%m-%d';
2627 } elseif ($format ==
'dayhourrfc') {
2628 $format =
'%Y-%m-%dT%H:%M:%SZ';
2629 } elseif ($format ==
'standard') {
2630 $format =
'%Y-%m-%d %H:%M:%S';
2633 if ($reduceformat) {
2634 $format = str_replace(
'%Y',
'%y', $format);
2635 $format = str_replace(
'yyyy',
'yy', $format);
2639 if (preg_match(
'/%b/i', $format)) {
2641 $format = str_replace(
'%b',
'__b__', $format);
2642 $format = str_replace(
'%B',
'__B__', $format);
2644 if (preg_match(
'/%a/i', $format)) {
2646 $format = str_replace(
'%a',
'__a__', $format);
2647 $format = str_replace(
'%A',
'__A__', $format);
2652 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)) {
2653 dol_print_error(
'',
"Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER[
"PHP_SELF"]);
2655 } elseif (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)) {
2657 dol_syslog(
"Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER[
"PHP_SELF"], LOG_WARNING);
2660 $syear = (!empty($reg[1]) ? $reg[1] :
'');
2661 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
2662 $sday = (!empty($reg[3]) ? $reg[3] :
'');
2663 $shour = (!empty($reg[4]) ? $reg[4] :
'');
2664 $smin = (!empty($reg[5]) ? $reg[5] :
'');
2665 $ssec = (!empty($reg[6]) ? $reg[6] :
'');
2667 $time =
dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear,
true);
2670 $tzo =
new DateTimeZone(
'UTC');
2672 $tzo =
new DateTimeZone(date_default_timezone_get());
2674 $dtts =
new DateTime();
2675 $dtts->setTimestamp($time);
2676 $dtts->setTimezone($tzo);
2677 $newformat = str_replace(
2678 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2679 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2681 $ret = $dtts->format($newformat);
2683 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2684 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2689 if ($time < 100000000000) {
2690 $timetouse = $time + $offsettz + $offsetdst;
2693 $tzo =
new DateTimeZone(
'UTC');
2695 $tzo =
new DateTimeZone(date_default_timezone_get());
2697 $dtts =
new DateTime();
2698 $dtts->setTimestamp($timetouse);
2699 $dtts->setTimezone($tzo);
2700 $newformat = str_replace(
2701 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2702 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2704 $ret = $dtts->format($newformat);
2706 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
2707 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
2712 $ret =
'Bad value '.$time.
' for date';
2716 if (preg_match(
'/__b__/i', $format)) {
2717 $timetouse = $time + $offsettz + $offsetdst;
2720 $tzo =
new DateTimeZone(
'UTC');
2722 $tzo =
new DateTimeZone(date_default_timezone_get());
2724 $dtts =
new DateTime();
2725 $dtts->setTimestamp($timetouse);
2726 $dtts->setTimezone($tzo);
2727 $month = $dtts->format(
"m");
2728 $month = sprintf(
"%02d", $month);
2729 if ($encodetooutput) {
2730 $monthtext = $outputlangs->transnoentities(
'Month'.$month);
2731 $monthtextshort = $outputlangs->transnoentities(
'MonthShort'.$month);
2733 $monthtext = $outputlangs->transnoentitiesnoconv(
'Month'.$month);
2734 $monthtextshort = $outputlangs->transnoentitiesnoconv(
'MonthShort'.$month);
2737 $ret = str_replace(
'__b__', $monthtextshort, $ret);
2738 $ret = str_replace(
'__B__', $monthtext, $ret);
2742 if (preg_match(
'/__a__/i', $format)) {
2744 $timetouse = $time + $offsettz + $offsetdst;
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 $w = $dtts->format(
"w");
2755 $dayweek = $outputlangs->transnoentitiesnoconv(
'Day'.$w);
2757 $ret = str_replace(
'__A__', $dayweek, $ret);
2758 $ret = str_replace(
'__a__',
dol_substr($dayweek, 0, 3), $ret);
2787 $datetimeobj =
new DateTime();
2788 $datetimeobj->setTimestamp($timestamp);
2789 if ($forcetimezone) {
2790 $datetimeobj->setTimezone(
new DateTimeZone($forcetimezone ==
'gmt' ?
'UTC' : $forcetimezone));
2793 'year'=>((
int) date_format($datetimeobj,
'Y')),
2794 'mon'=>((
int) date_format($datetimeobj,
'm')),
2795 'mday'=>((
int) date_format($datetimeobj,
'd')),
2796 'wday'=>((
int) date_format($datetimeobj,
'w')),
2797 'yday'=>((
int) date_format($datetimeobj,
'z')),
2798 'hours'=>((
int) date_format($datetimeobj,
'H')),
2799 'minutes'=>((
int) date_format($datetimeobj,
'i')),
2800 'seconds'=>((
int) date_format($datetimeobj,
's')),
2828 function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm =
'auto', $check = 1)
2833 if ($gm ===
'auto') {
2834 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
2839 if ($hour == -1 || empty($hour)) {
2842 if ($minute == -1 || empty($minute)) {
2845 if ($second == -1 || empty($second)) {
2851 if (!$month || !$day) {
2860 if ($hour < 0 || $hour > 24) {
2863 if ($minute < 0 || $minute > 60) {
2866 if ($second < 0 || $second > 60) {
2871 if (empty($gm) || ($gm ===
'server' || $gm ===
'tzserver')) {
2872 $default_timezone = @date_default_timezone_get();
2873 $localtz =
new DateTimeZone($default_timezone);
2874 } elseif ($gm ===
'user' || $gm ===
'tzuser' || $gm ===
'tzuserrel') {
2876 $default_timezone = (empty($_SESSION[
"dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION[
"dol_tz_string"]);
2878 $localtz =
new DateTimeZone($default_timezone);
2880 dol_syslog(
"Warning dol_tz_string contains an invalid value ".$_SESSION[
"dol_tz_string"], LOG_WARNING);
2881 $default_timezone = @date_default_timezone_get();
2883 } elseif (strrpos($gm,
"tz,") !==
false) {
2884 $timezone = str_replace(
"tz,",
"", $gm);
2886 $localtz =
new DateTimeZone($timezone);
2888 dol_syslog(
"Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
2892 if (empty($localtz)) {
2893 $localtz =
new DateTimeZone(
'UTC');
2897 $dt =
new DateTime(
'now', $localtz);
2898 $dt->setDate((
int) $year, (
int) $month, (
int) $day);
2899 $dt->setTime((
int) $hour, (
int) $minute, (
int) $second);
2900 $date = $dt->getTimestamp();
2920 if ($mode ===
'auto') {
2924 if ($mode ==
'gmt') {
2926 } elseif ($mode ==
'tzserver') {
2927 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
2929 $ret = (int) (
dol_now(
'gmt') + ($tzsecond * 3600));
2935 } elseif ($mode ==
'tzuser' || $mode ==
'tzuserrel') {
2938 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
2939 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
2940 $ret = (int) (
dol_now(
'gmt') + ($offsettz + $offsetdst));
2957 global $conf, $langs;
2960 if (!empty($conf->dol_optimize_smallscreen)) {
2965 if (empty($shortvalue) || $size < ($level * 10)) {
2967 $textunitshort = $langs->trans(
"b");
2968 $textunitlong = $langs->trans(
"Bytes");
2970 $ret = round($size / $level, 0);
2971 $textunitshort = $langs->trans(
"Kb");
2972 $textunitlong = $langs->trans(
"KiloBytes");
2975 if (empty($shortunit)) {
2976 $ret .=
' '.$textunitlong;
2978 $ret .=
' '.$textunitshort;
3001 $link =
'<a href="';
3002 if (!preg_match(
'/^http/i', $url)) {
3008 $link .=
' target="'.$target.
'"';
3011 if (!preg_match(
'/^http/i', $url)) {
3016 return '<div class="nospan float" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe').
' ' :
'').$link.
'</div>';
3031 function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0)
3033 global $conf, $user, $langs, $hookmanager;
3037 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpicto) {
3041 if (empty($email)) {
3045 if (!empty($addlink)) {
3046 $newemail =
'<a style="text-overflow: ellipsis;" href="';
3047 if (!preg_match(
'/^mailto:/i', $email)) {
3048 $newemail .=
'mailto:';
3050 $newemail .= $email;
3053 $newemail .=
'</a>';
3055 $langs->load(
"errors");
3056 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
3059 if (($cid || $socid) &&
isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
3062 if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) {
3063 $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>';
3066 $newemail =
'<div>'.$newemail.
' '.$link.
'</div>';
3071 $langs->load(
"errors");
3072 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
3077 $rep = ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto)).
' ' :
'').$newemail;
3080 $parameters = array(
'cid' => $cid,
'socid' => $socid,
'addlink' => $addlink,
'picto' => $withpicto);
3082 $reshook = $hookmanager->executeHooks(
'printEmail', $parameters, $email);
3086 $rep .= $hookmanager->resPrint;
3101 $socialnetworks = array();
3103 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
3104 $cachekey =
'socialnetworks_' . $conf->entity;
3106 if (!is_null($dataretrieved)) {
3107 $socialnetworks = $dataretrieved;
3109 $sql =
"SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX.
"c_socialnetworks";
3110 $sql .=
" WHERE entity=".$conf->entity;
3111 $resql = $db->query($sql);
3113 while ($obj = $db->fetch_object(
$resql)) {
3114 $socialnetworks[$obj->code] = array(
3115 'rowid' => $obj->rowid,
3116 'label' => $obj->label,
3118 'icon' => $obj->icon,
3119 'active' => $obj->active,
3126 return $socialnetworks;
3141 global $conf, $user, $langs;
3145 if (empty($value)) {
3149 if (!empty($type)) {
3150 $htmllink =
'<div class="divsocialnetwork inline-block valignmiddle">';
3152 $htmllink .=
'<span class="fa paddingright '.($dictsocialnetworks[$type][
'icon'] ? $dictsocialnetworks[$type][
'icon'] :
'fa-link').
'"></span>';
3153 if ($type ==
'skype') {
3155 $htmllink .=
' ';
3156 $htmllink .=
'<a href="skype:';
3158 $htmllink .=
'?call" alt="'.$langs->trans(
"Call").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Call").
' '.$value).
'">';
3159 $htmllink .=
'<img src="'.DOL_URL_ROOT.
'/theme/common/skype_callbutton.png" border="0">';
3160 $htmllink .=
'</a><a href="skype:';
3162 $htmllink .=
'?chat" alt="'.$langs->trans(
"Chat").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Chat").
' '.$value).
'">';
3163 $htmllink .=
'<img class="paddingleft" src="'.DOL_URL_ROOT.
'/theme/common/skype_chatbutton.png" border="0">';
3164 $htmllink .=
'</a>';
3165 if (($cid || $socid) &&
isModEnabled(
'agenda') && $user->rights->agenda->myactions->create) {
3166 $addlink =
'AC_SKYPE';
3168 if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) {
3169 $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>';
3171 $htmllink .= ($link ?
' '.$link :
'');
3174 if (!empty($dictsocialnetworks[$type][
'url'])) {
3175 $tmpvirginurl = preg_replace(
'/\/?{socialid}/',
'', $dictsocialnetworks[$type][
'url']);
3176 if ($tmpvirginurl) {
3177 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3178 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3180 $tmpvirginurl3 = preg_replace(
'/^https:\/\//i',
'https://www.', $tmpvirginurl);
3181 if ($tmpvirginurl3) {
3182 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3183 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3186 $tmpvirginurl2 = preg_replace(
'/^https?:\/\//i',
'', $tmpvirginurl);
3187 if ($tmpvirginurl2) {
3188 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3189 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3192 $link = str_replace(
'{socialid}', $value, $dictsocialnetworks[$type][
'url']);
3193 if (preg_match(
'/^https?:\/\//i', $link)) {
3194 $htmllink .=
' <a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3196 $htmllink .=
' <a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3202 $htmllink .=
'</div>';
3204 $langs->load(
"errors");
3205 $htmllink .=
img_warning($langs->trans(
"ErrorBadSocialNetworkValue", $value));
3220 function dol_print_profids($profID, $profIDtype, $countrycode =
'', $addcpButton = 1, $separ =
' ')
3224 if (empty($profID) || empty($profIDtype)) {
3227 if (empty($countrycode)) $countrycode = $mysoc->country_code;
3228 $newProfID = $profID;
3229 $id = substr($profIDtype, -1);
3231 if (strtoupper($countrycode) ==
'FR') {
3233 if ($id == 1 &&
dol_strlen($newProfID) == 9) $newProfID = substr($newProfID, 0, 3).$separ.substr($newProfID, 3, 3).$separ.substr($newProfID, 6, 3);
3234 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);
3235 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);
3238 else $ret = $newProfID;
3256 function dol_print_phone($phone, $countrycode =
'', $cid = 0, $socid = 0, $addlink =
'', $separ =
" ", $withpicto =
'', $titlealt =
'', $adddivfloat = 0)
3258 global $conf, $user, $langs, $mysoc, $hookmanager;
3261 $phone = is_null($phone) ?
'' : preg_replace(
"/[\s.-]/",
"", trim($phone));
3262 if (empty($phone)) {
3265 if (!empty($conf->global->MAIN_PHONE_SEPAR)) {
3266 $separ = $conf->global->MAIN_PHONE_SEPAR;
3268 if (empty($countrycode) && is_object($mysoc)) {
3269 $countrycode = $mysoc->country_code;
3273 if ($conf->dol_optimize_smallscreen) {
3278 if (strtoupper($countrycode) ==
"FR") {
3281 $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);
3283 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
3285 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
3287 $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);
3289 $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);
3291 $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);
3293 } elseif (strtoupper($countrycode) ==
"CA") {
3295 $newphone = ($separ !=
'' ?
'(' :
'').substr($newphone, 0, 3).($separ !=
'' ?
')' :
'').$separ.substr($newphone, 3, 3).($separ !=
'' ?
'-' :
'').substr($newphone, 6, 4);
3297 } elseif (strtoupper($countrycode) ==
"PT") {
3299 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3301 } elseif (strtoupper($countrycode) ==
"SR") {
3303 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
3305 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
3307 } elseif (strtoupper($countrycode) ==
"DE") {
3309 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
3311 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
3313 } elseif (strtoupper($countrycode) ==
"ES") {
3315 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3317 } elseif (strtoupper($countrycode) ==
"BF") {
3319 $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);
3321 } elseif (strtoupper($countrycode) ==
"RO") {
3323 $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);
3325 } elseif (strtoupper($countrycode) ==
"TR") {
3327 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
3329 } elseif (strtoupper($countrycode) ==
"US") {
3331 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
3333 } elseif (strtoupper($countrycode) ==
"MX") {
3335 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
3337 $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);
3339 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
3341 } elseif (strtoupper($countrycode) ==
"ML") {
3343 $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);
3345 } elseif (strtoupper($countrycode) ==
"TH") {
3347 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
3349 $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);
3351 } elseif (strtoupper($countrycode) ==
"MU") {
3354 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
3356 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
3358 } elseif (strtoupper($countrycode) ==
"ZA") {
3360 $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);
3362 } elseif (strtoupper($countrycode) ==
"SY") {
3364 $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);
3366 $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);
3368 } elseif (strtoupper($countrycode) ==
"AE") {
3370 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
3372 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3374 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
3376 } elseif (strtoupper($countrycode) ==
"DZ") {
3378 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3380 } elseif (strtoupper($countrycode) ==
"BE") {
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, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3386 } elseif (strtoupper($countrycode) ==
"PF") {
3388 $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);
3390 } elseif (strtoupper($countrycode) ==
"CO") {
3392 $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);
3394 } elseif (strtoupper($countrycode) ==
"JO") {
3396 $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);
3398 } elseif (strtoupper($countrycode) ==
"JM") {
3400 $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
3402 } elseif (strtoupper($countrycode) ==
"MG") {
3404 $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);
3406 } elseif (strtoupper($countrycode) ==
"GB") {
3408 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3410 } elseif (strtoupper($countrycode) ==
"CH") {
3412 $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);
3414 $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);
3416 } elseif (strtoupper($countrycode) ==
"TN") {
3418 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3420 } elseif (strtoupper($countrycode) ==
"GF") {
3422 $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);
3424 } elseif (strtoupper($countrycode) ==
"GP") {
3426 $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);
3428 } elseif (strtoupper($countrycode) ==
"MQ") {
3430 $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);
3432 } elseif (strtoupper($countrycode) ==
"IT") {
3434 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3436 $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);
3438 } elseif (strtoupper($countrycode) ==
"AU") {
3442 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
3444 } elseif (strtoupper($countrycode) ==
"LU") {
3447 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
3449 $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);
3451 $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);
3453 $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);
3456 if (!empty($addlink)) {
3457 if ($conf->browser->layout ==
'phone' || (
isModEnabled(
'clicktodial') && !empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) {
3458 $newphoneform = $newphone;
3459 $newphone =
'<a href="tel:'.$phone.
'"';
3460 $newphone .=
'>'.$newphoneform.
'</a>';
3461 } elseif (
isModEnabled(
'clicktodial') && $addlink ==
'AC_TEL') {
3462 if (empty($user->clicktodial_loaded)) {
3463 $user->fetch_clicktodial();
3467 $urlmask =
'ErrorClickToDialModuleNotConfigured';
3468 if (!empty($conf->global->CLICKTODIAL_URL)) {
3469 $urlmask = $conf->global->CLICKTODIAL_URL;
3471 if (!empty($user->clicktodial_url)) {
3472 $urlmask = $user->clicktodial_url;
3475 $clicktodial_poste = (!empty($user->clicktodial_poste) ?urlencode($user->clicktodial_poste) :
'');
3476 $clicktodial_login = (!empty($user->clicktodial_login) ?urlencode($user->clicktodial_login) :
'');
3477 $clicktodial_password = (!empty($user->clicktodial_password) ?urlencode($user->clicktodial_password) :
'');
3479 $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
3481 $substitarray = array(
'__PHONEFROM__'=>$clicktodial_poste,
3482 '__PHONETO__'=>urlencode($phone),
3483 '__LOGIN__'=>$clicktodial_login,
3484 '__PASS__'=>$clicktodial_password);
3486 $newphonesav = $newphone;
3487 if (empty($conf->global->CLICKTODIAL_DO_NOT_USE_AJAX_CALL)) {
3489 $newphone =
'<a href="'.$url.
'" class="cssforclicktodial"';
3490 $newphone .=
'>'.$newphonesav.
'</a>';
3493 $newphone =
'<a href="'.$url.
'"';
3494 if (!empty($conf->global->CLICKTODIAL_FORCENEWTARGET)) {
3495 $newphone .=
' target="_blank" rel="noopener noreferrer"';
3497 $newphone .=
'>'.$newphonesav.
'</a>';
3502 if (
isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
3505 if ($addlink ==
'AC_FAX') {
3508 if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE)) {
3509 $link =
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&backtopage=1&actioncode='.$type.($cid ?
'&contactid='.$cid :
'').($socid ?
'&socid='.$socid :
'').
'">'.
img_object($langs->trans(
"AddAction"),
"calendar").
'</a>';
3512 $newphone =
'<div>'.$newphone.
' '.$link.
'</div>';
3517 if (empty($titlealt)) {
3518 $titlealt = ($withpicto ==
'fax' ? $langs->trans(
"Fax") : $langs->trans(
"Phone"));
3523 $parameters = array(
'countrycode' => $countrycode,
'cid' => $cid,
'socid' => $socid,
'titlealt' => $titlealt,
'picto' => $withpicto);
3524 $reshook = $hookmanager->executeHooks(
'printPhone', $parameters, $phone);
3525 $rep .= $hookmanager->resPrint;
3527 if (empty($reshook)) {
3530 if ($withpicto ==
'fax') {
3531 $picto =
'phoning_fax';
3532 } elseif ($withpicto ==
'phone') {
3534 } elseif ($withpicto ==
'mobile') {
3535 $picto =
'phoning_mobile';
3541 $rep .=
'<div class="nospan float" style="margin-right: 10px">';
3543 $rep .=
'<span style="margin-right: 10px;">';
3545 $rep .= ($withpicto ?
img_picto($titlealt,
'object_'.$picto.
'.png').
' ' :
'').$newphone;
3565 global $conf, $langs;
3576 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/common/flags/'.$countrycode.
'.png')) {
3577 $ret .=
' '.img_picto($countrycode.
' '.$langs->trans(
"AccordingToGeoIPDatabase"), DOL_URL_ROOT.
'/theme/common/flags/'.$countrycode.
'.png',
'', 1);
3579 $ret .=
' ('.$countrycode.
')';
3599 if (empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
3600 if (empty($_SERVER[
'HTTP_CLIENT_IP']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_CLIENT_IP'])) {
3601 if (empty($_SERVER[
"HTTP_CF_CONNECTING_IP"])) {
3602 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
3604 $ip = $_SERVER[
"HTTP_CF_CONNECTING_IP"];
3607 $ip = $_SERVER[
'HTTP_CLIENT_IP'];
3610 $ip = $_SERVER[
'HTTP_X_FORWARDED_FOR'];
3626 if (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on') {
3628 } 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') {
3646 if (!empty($conf->geoipmaxmind->enabled)) {
3650 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
3651 $geoip =
new DolGeoIP(
'country', $datafile);
3653 $countrycode = $geoip->getCountryCodeFromIP($ip);
3656 return $countrycode;
3668 global $conf, $langs, $user;
3672 if (!empty($conf->geoipmaxmind->enabled)) {
3677 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
3678 $geoip =
new DolGeoIP(
'country', $datafile);
3679 $countrycode = $geoip->getCountryCodeFromIP($ip);
3680 $ret = $countrycode;
3699 global $conf, $user, $langs, $hookmanager;
3705 $parameters = array(
'element' => $element,
'id' => $id);
3706 $reshook = $hookmanager->executeHooks(
'printAddress', $parameters, $address);
3707 $out .= $hookmanager->resPrint;
3709 if (empty($reshook)) {
3710 if (empty($charfornl)) {
3711 $out .= nl2br($address);
3713 $out .= preg_replace(
'/[\r\n]+/', $charfornl, $address);
3717 $showgmap = $showomap = 0;
3718 if (($element ==
'thirdparty' || $element ==
'societe') && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) {
3721 if ($element ==
'contact' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) {
3724 if ($element ==
'member' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) {
3727 if (($element ==
'thirdparty' || $element ==
'societe') && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) {
3730 if ($element ==
'contact' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) {
3733 if ($element ==
'member' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) {
3737 $url =
dol_buildpath(
'/google/gmaps.php?mode='.$element.
'&id='.$id, 1);
3738 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
3741 $url =
dol_buildpath(
'/openstreetmap/maps.php?mode='.$element.
'&id='.$id, 1);
3742 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
3763 function isValidEmail($address, $acceptsupervisorkey = 0, $acceptuserkey = 0)
3765 if ($acceptsupervisorkey && $address ==
'__SUPERVISOREMAIL__') {
3768 if ($acceptuserkey && $address ==
'__USER_EMAIL__') {
3771 if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
3788 if (function_exists(
'idn_to_ascii') && function_exists(
'checkdnsrr')) {
3789 if (!checkdnsrr(idn_to_ascii($domain),
'MX')) {
3792 if (function_exists(
'getmxrr')) {
3795 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
3796 if (count($mxhosts) > 1) {
3799 if (count($mxhosts) == 1 && !empty($mxhosts[0])) {
3836 $tmparray = explode(
' ', $s);
3837 foreach ($tmparray as $tmps) {
3854 if (is_null($string)) {
3858 if (function_exists(
'mb_strlen')) {
3859 return mb_strlen($string, $stringencoding);
3861 return strlen($string);
3875 function dol_substr($string, $start, $length, $stringencoding =
'', $trunconbytes = 0)
3879 if (empty($stringencoding)) {
3880 $stringencoding = $langs->charset_output;
3884 if (empty($trunconbytes)) {
3885 if (function_exists(
'mb_substr')) {
3886 $ret = mb_substr($string, $start, $length, $stringencoding);
3888 $ret = substr($string, $start, $length);
3891 if (function_exists(
'mb_strcut')) {
3892 $ret = mb_strcut($string, $start, $length, $stringencoding);
3894 $ret = substr($string, $start, $length);
3914 function dol_trunc($string, $size = 40, $trunc =
'right', $stringencoding =
'UTF-8', $nodot = 0, $display = 0)
3918 if (empty($size) || !empty($conf->global->MAIN_DISABLE_TRUNC)) {
3922 if (empty($stringencoding)) {
3923 $stringencoding =
'UTF-8';
3926 if ($conf->dol_optimize_smallscreen == 1 && $display == 1) {
3927 $size = round($size / 3);
3931 if ($trunc ==
'right') {
3933 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
3935 return dol_substr($newstring, 0, $size, $stringencoding).($nodot ?
'' :
'…');
3940 } elseif ($trunc ==
'middle') {
3942 if (
dol_strlen($newstring, $stringencoding) > 2 &&
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
3943 $size1 = round($size / 2);
3944 $size2 = round($size / 2);
3945 return dol_substr($newstring, 0, $size1, $stringencoding).
'…'.
dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
3949 } elseif ($trunc ==
'left') {
3951 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
3953 return '…'.dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
3957 } elseif ($trunc ==
'wrap') {
3959 if (
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
3965 return 'BadParam3CallingDolTrunc';
3989 function img_picto($titlealt, $picto, $moreatt =
'', $pictoisfullpath =
false, $srconly = 0, $notitle = 0, $alt =
'', $morecss =
'', $marginleftonlyshort = 2)
3991 global $conf, $langs;
3994 $url = DOL_URL_ROOT;
3995 $theme = isset($conf->theme) ? $conf->theme :
null;
3996 $path =
'theme/'.$theme;
3998 if ($pictoisfullpath) {
4000 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
4003 $fullpathpicto = $picto;
4005 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4006 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4007 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4010 $pictowithouttext = preg_replace(
'/(\.png|\.gif|\.svg)$/',
'', $picto);
4011 $pictowithouttext = str_replace(
'object_',
'', $pictowithouttext);
4013 if (strpos($pictowithouttext,
'fontawesome_') !==
false || preg_match(
'/^fa-/', $pictowithouttext)) {
4015 $pictowithouttext = str_replace(
'fontawesome_',
'', $pictowithouttext);
4016 $pictowithouttext = str_replace(
'fa-',
'', $pictowithouttext);
4018 $pictowithouttextarray = explode(
'_', $pictowithouttext);
4019 $marginleftonlyshort = 0;
4021 if (!empty($pictowithouttextarray[1])) {
4023 $fakey =
'fa-'.$pictowithouttextarray[0];
4024 $fa = empty($pictowithouttextarray[1]) ?
'fa' : $pictowithouttextarray[1];
4025 $facolor = empty($pictowithouttextarray[2]) ?
'' : $pictowithouttextarray[2];
4026 $fasize = empty($pictowithouttextarray[3]) ?
'' : $pictowithouttextarray[3];
4028 $fakey =
'fa-'.$pictowithouttext;
4038 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4039 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4040 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4042 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
4043 $morestyle = $reg[1];
4044 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
4046 $moreatt = trim($moreatt);
4048 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
4049 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
4053 $enabledisablehtml .=
'</span>';
4055 return $enabledisablehtml;
4058 if (empty($srconly) && in_array($pictowithouttext, array(
4059 '1downarrow',
'1uparrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected',
4060 'accountancy',
'accounting_account',
'account',
'accountline',
'action',
'add',
'address',
'angle-double-down',
'angle-double-up',
'asset',
4061 'bank_account',
'barcode',
'bank',
'bell',
'bill',
'billa',
'billr',
'billd',
'bookmark',
'bom',
'briefcase-medical',
'bug',
'building',
4062 'card',
'calendarlist',
'calendar',
'calendarmonth',
'calendarweek',
'calendarday',
'calendarperuser',
'calendarpertype',
4063 'cash-register',
'category',
'chart',
'check',
'clock',
'close_title',
'cog',
'collab',
'company',
'contact',
'country',
'contract',
'conversation',
'cron',
'cubes',
4064 'currency',
'multicurrency',
4065 'delete',
'dolly',
'dollyrevert',
'donation',
'download',
'dynamicprice',
4066 'edit',
'ellipsis-h',
'email',
'entity',
'envelope',
'eraser',
'establishment',
'expensereport',
'external-link-alt',
'external-link-square-alt',
'eye',
4067 'filter',
'file-code',
'file-export',
'file-import',
'file-upload',
'autofill',
'folder',
'folder-open',
'folder-plus',
4068 'generate',
'globe',
'globe-americas',
'graph',
'grip',
'grip_title',
'group',
4070 'images',
'incoterm',
'info',
'intervention',
'inventory',
'intracommreport',
'knowledgemanagement',
4071 'label',
'language',
'line',
'link',
'list',
'list-alt',
'listlight',
'loan',
'lock',
'lot',
'long-arrow-alt-right',
4072 'margin',
'map-marker-alt',
'member',
'meeting',
'money-bill-alt',
'movement',
'mrp',
'note',
'next',
4073 'off',
'on',
'order',
4074 'paiment',
'paragraph',
'play',
'pdf',
'phone',
'phoning',
'phoning_mobile',
'phoning_fax',
'playdisabled',
'previous',
'poll',
'pos',
'printer',
'product',
'propal',
'proposal',
'puce',
4075 'stock',
'resize',
'service',
'stats',
'trip',
4076 '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',
4077 'github',
'google',
'jabber',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'youtube',
'google-plus-g',
'whatsapp',
4078 'chevron-left',
'chevron-right',
'chevron-down',
'chevron-top',
'commercial',
'companies',
4079 'generic',
'home',
'hrm',
'members',
'products',
'invoicing',
4080 'partnership',
'payment',
'payment_vat',
'pencil-ruler',
'preview',
'project',
'projectpub',
'projecttask',
'question',
'refresh',
'region',
4081 'salary',
'shipment',
'state',
'supplier_invoice',
'supplier_invoicea',
'supplier_invoicer',
'supplier_invoiced',
4082 'technic',
'ticket',
4084 'recent',
'reception',
'recruitmentcandidature',
'recruitmentjobposition',
'replacement',
'resource',
'recurring',
'rss',
4085 'shapes',
'square',
'stop-circle',
'supplier',
'supplier_proposal',
'supplier_order',
'supplier_invoice',
4086 'timespent',
'title_setup',
'title_accountancy',
'title_bank',
'title_hrm',
'title_agenda',
4087 'uncheck',
'url',
'user-cog',
'user-injured',
'user-md',
'vat',
'website',
'workstation',
'webhook',
'world',
'private',
4088 'conferenceorbooth',
'eventorganization',
4089 'stamp',
'signature'
4091 $fakey = $pictowithouttext;
4095 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'))) {
4098 if (in_array($pictowithouttext, array(
'black-tie',
'github',
'google',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'stripe',
'stripe-s',
'youtube',
'google-plus-g',
'whatsapp'))) {
4102 $arrayconvpictotofa = array(
4103 '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',
4104 'bank_account'=>
'university',
4105 'bill'=>
'file-invoice-dollar',
'billa'=>
'file-excel',
'billr'=>
'file-invoice-dollar',
'billd'=>
'file-medical',
4106 'supplier_invoice'=>
'file-invoice-dollar',
'supplier_invoicea'=>
'file-excel',
'supplier_invoicer'=>
'file-invoice-dollar',
'supplier_invoiced'=>
'file-medical',
4108 'card'=>
'address-card',
'chart'=>
'chart-line',
'company'=>
'building',
'contact'=>
'address-book',
'contract'=>
'suitcase',
'collab'=>
'people-arrows',
'conversation'=>
'comments',
'country'=>
'globe-americas',
'cron'=>
'business-time',
4109 'donation'=>
'file-alt',
'dynamicprice'=>
'hand-holding-usd',
4110 'setup'=>
'cog',
'companies'=>
'building',
'products'=>
'cube',
'commercial'=>
'suitcase',
'invoicing'=>
'coins',
4111 'accounting'=>
'search-dollar',
'category'=>
'tag',
'dollyrevert'=>
'dolly',
4112 'generate'=>
'plus-square',
'hrm'=>
'user-tie',
'incoterm'=>
'truck-loading',
4113 'margin'=>
'calculator',
'members'=>
'user-friends',
'ticket'=>
'ticket-alt',
'globe'=>
'external-link-alt',
'lot'=>
'barcode',
4114 'email'=>
'at',
'establishment'=>
'building',
'edit'=>
'pencil-alt',
'entity'=>
'globe',
4115 'graph'=>
'chart-line',
'grip_title'=>
'arrows-alt',
'grip'=>
'arrows-alt',
'help'=>
'question-circle',
4116 'generic'=>
'file',
'holiday'=>
'umbrella-beach',
4117 'info'=>
'info-circle',
'inventory'=>
'boxes',
'intracommreport'=>
'globe-europe',
'knowledgemanagement'=>
'ticket-alt',
'label'=>
'layer-group',
'line'=>
'bars',
'loan'=>
'money-bill-alt',
4118 'member'=>
'user-alt',
'meeting'=>
'chalkboard-teacher',
'mrp'=>
'cubes',
'next'=>
'arrow-alt-circle-right',
4119 'trip'=>
'wallet',
'expensereport'=>
'wallet',
'group'=>
'users',
'movement'=>
'people-carry',
4120 'sign-out'=>
'sign-out-alt',
4121 'switch_off'=>
'toggle-off',
'switch_on'=>
'toggle-on',
'switch_on_red'=>
'toggle-on',
'check'=>
'check',
'bookmark'=>
'star',
4122 'bank'=>
'university',
'close_title'=>
'times',
'delete'=>
'trash',
'filter'=>
'filter',
4123 'list-alt'=>
'list-alt',
'calendarlist'=>
'bars',
'calendar'=>
'calendar-alt',
'calendarmonth'=>
'calendar-alt',
'calendarweek'=>
'calendar-week',
'calendarday'=>
'calendar-day',
'calendarperuser'=>
'table',
4124 'intervention'=>
'ambulance',
'invoice'=>
'file-invoice-dollar',
'currency'=>
'dollar-sign',
'multicurrency'=>
'dollar-sign',
'order'=>
'file-invoice',
4125 'error'=>
'exclamation-triangle',
'warning'=>
'exclamation-triangle',
4127 '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',
4128 'partnership'=>
'handshake',
'payment'=>
'money-check-alt',
'payment_vat'=>
'money-check-alt',
'phoning'=>
'phone',
'phoning_mobile'=>
'mobile-alt',
'phoning_fax'=>
'fax',
'previous'=>
'arrow-alt-circle-left',
'printer'=>
'print',
'product'=>
'cube',
'puce'=>
'angle-right',
4129 'recent' =>
'question',
'reception'=>
'dolly',
'recruitmentjobposition'=>
'id-card-alt',
'recruitmentcandidature'=>
'id-badge',
4130 'resize'=>
'crop',
'supplier_order'=>
'dol-order_supplier',
'supplier_proposal'=>
'file-signature',
4131 'refresh'=>
'redo',
'region'=>
'map-marked',
'replacement'=>
'exchange-alt',
'resource'=>
'laptop-house',
'recurring'=>
'history',
4132 'service'=>
'concierge-bell',
4133 'state'=>
'map-marked-alt',
'security'=>
'key',
'salary'=>
'wallet',
'shipment'=>
'dolly',
'stock'=>
'box-open',
'stats' =>
'chart-bar',
'split'=>
'code-branch',
'stripe'=>
'stripe-s',
4134 'supplier'=>
'building',
'technic'=>
'cogs',
4135 'timespent'=>
'clock',
'title_setup'=>
'tools',
'title_accountancy'=>
'money-check-alt',
'title_bank'=>
'university',
'title_hrm'=>
'umbrella-beach',
4136 'title_agenda'=>
'calendar-alt',
4137 'uncheck'=>
'times',
'uparrow'=>
'share',
'url'=>
'external-link-alt',
'vat'=>
'money-check-alt',
'vcard'=>
'address-card',
4138 'jabber'=>
'comment-o',
4139 'website'=>
'globe-americas',
'workstation'=>
'pallet',
'webhook'=>
'bullseye',
'world'=>
'globe',
'private'=>
'user-lock',
4140 'conferenceorbooth'=>
'chalkboard-teacher',
'eventorganization'=>
'project-diagram'
4142 if ($pictowithouttext ==
'off') {
4143 $fakey =
'fa-square';
4145 } elseif ($pictowithouttext ==
'on') {
4146 $fakey =
'fa-check-square';
4148 } elseif ($pictowithouttext ==
'listlight') {
4149 $fakey =
'fa-download';
4150 $marginleftonlyshort = 1;
4151 } elseif ($pictowithouttext ==
'printer') {
4152 $fakey =
'fa-print';
4154 } elseif ($pictowithouttext ==
'note') {
4155 $fakey =
'fa-sticky-note';
4156 $marginleftonlyshort = 1;
4157 } elseif (in_array($pictowithouttext, array(
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'))) {
4158 $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');
4159 $fakey =
'fa-'.$convertarray[$pictowithouttext];
4160 if (preg_match(
'/selected/', $pictowithouttext)) {
4163 $marginleftonlyshort = 1;
4164 } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) {
4165 $fakey =
'fa-'.$arrayconvpictotofa[$pictowithouttext];
4167 $fakey =
'fa-'.$pictowithouttext;
4170 if (in_array($pictowithouttext, array(
'dollyrevert',
'member',
'members',
'contract',
'group',
'resource',
'shipment'))) {
4171 $morecss .=
' em092';
4173 if (in_array($pictowithouttext, array(
'conferenceorbooth',
'collab',
'eventorganization',
'holiday',
'info',
'project',
'workstation'))) {
4174 $morecss .=
' em088';
4176 if (in_array($pictowithouttext, array(
'asset',
'intervention',
'payment',
'loan',
'partnership',
'stock',
'technic'))) {
4177 $morecss .=
' em080';
4181 $arrayconvpictotomarginleftonly = array(
4182 'bank',
'check',
'delete',
'generic',
'grip',
'grip_title',
'jabber',
4183 'grip_title',
'grip',
'listlight',
'note',
'on',
'off',
'playdisabled',
'printer',
'resize',
'sign-out',
'stats',
'switch_on',
'switch_on_red',
'switch_off',
4184 'uparrow',
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'
4186 if (!isset($arrayconvpictotomarginleftonly[$pictowithouttext])) {
4187 $marginleftonlyshort = 0;
4191 $arrayconvpictotomorcess = array(
4192 'action'=>
'infobox-action',
'account'=>
'infobox-bank_account',
'accounting_account'=>
'infobox-bank_account',
'accountline'=>
'infobox-bank_account',
'accountancy'=>
'infobox-bank_account',
'asset'=>
'infobox-bank_account',
4193 'bank_account'=>
'infobox-bank_account',
4194 'bill'=>
'infobox-commande',
'billa'=>
'infobox-commande',
'billr'=>
'infobox-commande',
'billd'=>
'infobox-commande',
4195 'margin'=>
'infobox-bank_account',
'conferenceorbooth'=>
'infobox-project',
4196 'cash-register'=>
'infobox-bank_account',
'contract'=>
'infobox-contrat',
'check'=>
'font-status4',
'collab'=>
'infobox-action',
'conversation'=>
'infobox-contrat',
4197 'donation'=>
'infobox-commande',
'dolly'=>
'infobox-commande',
'dollyrevert'=>
'flip infobox-order_supplier',
4198 'ecm'=>
'infobox-action',
'eventorganization'=>
'infobox-project',
4199 'hrm'=>
'infobox-adherent',
'group'=>
'infobox-adherent',
'intervention'=>
'infobox-contrat',
4200 'incoterm'=>
'infobox-supplier_proposal',
4201 'currency'=>
'infobox-bank_account',
'multicurrency'=>
'infobox-bank_account',
4202 'members'=>
'infobox-adherent',
'member'=>
'infobox-adherent',
'money-bill-alt'=>
'infobox-bank_account',
4203 'order'=>
'infobox-commande',
4204 'user'=>
'infobox-adherent',
'users'=>
'infobox-adherent',
4205 'error'=>
'pictoerror',
'warning'=>
'pictowarning',
'switch_on'=>
'font-status4',
'switch_on_red'=>
'font-status8',
4206 'holiday'=>
'infobox-holiday',
'info'=>
'opacityhigh',
'invoice'=>
'infobox-commande',
4207 'knowledgemanagement'=>
'infobox-contrat rotate90',
'loan'=>
'infobox-bank_account',
4208 'payment'=>
'infobox-bank_account',
'payment_vat'=>
'infobox-bank_account',
'poll'=>
'infobox-adherent',
'pos'=>
'infobox-bank_account',
'project'=>
'infobox-project',
'projecttask'=>
'infobox-project',
4209 'propal'=>
'infobox-propal',
'proposal'=>
'infobox-propal',
'private'=>
'infobox-project',
4210 'reception'=>
'flip',
'recruitmentjobposition'=>
'infobox-adherent',
'recruitmentcandidature'=>
'infobox-adherent',
4211 'resource'=>
'infobox-action',
4212 'salary'=>
'infobox-bank_account',
'shipment'=>
'infobox-commande',
'supplier_invoice'=>
'infobox-order_supplier',
'supplier_invoicea'=>
'infobox-order_supplier',
'supplier_invoiced'=>
'infobox-order_supplier',
4213 'supplier'=>
'infobox-order_supplier',
'supplier_order'=>
'infobox-order_supplier',
'supplier_proposal'=>
'infobox-supplier_proposal',
4214 'ticket'=>
'infobox-contrat',
'title_accountancy'=>
'infobox-bank_account',
'title_hrm'=>
'infobox-holiday',
'expensereport'=>
'infobox-expensereport',
'trip'=>
'infobox-expensereport',
'title_agenda'=>
'infobox-action',
4215 'vat'=>
'infobox-bank_account',
4217 'list-alt'=>
'imgforviewmode',
'calendar'=>
'imgforviewmode',
'calendarweek'=>
'imgforviewmode',
'calendarmonth'=>
'imgforviewmode',
'calendarday'=>
'imgforviewmode',
'calendarperuser'=>
'imgforviewmode'
4219 if (!empty($arrayconvpictotomorcess[$pictowithouttext])) {
4220 $morecss .= ($morecss ?
' ' :
'').$arrayconvpictotomorcess[$pictowithouttext];
4224 $arrayconvpictotocolor = array(
4225 'address'=>
'#6c6aa8',
'building'=>
'#6c6aa8',
'bom'=>
'#a69944',
4226 'cog'=>
'#999',
'companies'=>
'#6c6aa8',
'company'=>
'#6c6aa8',
'contact'=>
'#6c6aa8',
'cron'=>
'#555',
4227 'dynamicprice'=>
'#a69944',
4228 'edit'=>
'#444',
'note'=>
'#999',
'error'=>
'',
'help'=>
'#bbb',
'listlight'=>
'#999',
'language'=>
'#555',
4230 'lock'=>
'#ddd',
'lot'=>
'#a69944',
4231 'map-marker-alt'=>
'#aaa',
'mrp'=>
'#a69944',
'product'=>
'#a69944',
'service'=>
'#a69944',
'inventory'=>
'#a69944',
'stock'=>
'#a69944',
'movement'=>
'#a69944',
4232 'other'=>
'#ddd',
'world'=>
'#986c6a',
4233 'partnership'=>
'#6c6aa8',
'playdisabled'=>
'#ccc',
'printer'=>
'#444',
'projectpub'=>
'#986c6a',
'reception'=>
'#a69944',
'resize'=>
'#444',
'rss'=>
'#cba',
4235 'security'=>
'#999',
'square'=>
'#888',
'stop-circle'=>
'#888',
'stats'=>
'#444',
'switch_off'=>
'#999',
'technic'=>
'#999',
'timespent'=>
'#555',
4236 'uncheck'=>
'#800',
'uparrow'=>
'#555',
'user-cog'=>
'#999',
'country'=>
'#aaa',
'globe-americas'=>
'#aaa',
'region'=>
'#aaa',
'state'=>
'#aaa',
4237 'website'=>
'#304',
'workstation'=>
'#a69944'
4239 if (isset($arrayconvpictotocolor[$pictowithouttext])) {
4240 $facolor = $arrayconvpictotocolor[$pictowithouttext];
4247 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4248 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4249 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4251 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
4252 $morestyle = $reg[1];
4253 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
4255 $moreatt = trim($moreatt);
4257 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
4258 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
4262 $enabledisablehtml .=
'</span>';
4264 return $enabledisablehtml;
4267 if (!empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) {
4268 $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.
'/theme/'.$theme;
4269 } elseif (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) {
4270 $path = $conf->global->MAIN_OVERWRITE_THEME_RES.
'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES;
4271 } elseif (!empty($conf->modules_parts[
'theme']) && array_key_exists($theme, $conf->modules_parts[
'theme'])) {
4272 $path = $theme.
'/theme/'.$theme;
4277 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
4283 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
4288 foreach ($conf->file->dol_document_root as $type => $dirroot) {
4289 if ($type ==
'main') {
4293 if (file_exists($dirroot.
'/'.$path.
'/img/'.$picto)) {
4294 $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type];
4300 $fullpathpicto = $url.
'/'.$path.
'/img/'.$picto;
4304 return $fullpathpicto;
4307 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 :
'').
'"').
'>';
4323 function img_object($titlealt, $picto, $moreatt =
'', $pictoisfullpath =
false, $srconly = 0, $notitle = 0)
4325 if (strpos($picto,
'^') === 0) {
4326 return img_picto($titlealt, str_replace(
'^',
'', $picto), $moreatt, $pictoisfullpath, $srconly, $notitle);
4328 return img_picto($titlealt,
'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
4343 function img_weather($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $morecss =
'')
4347 if (is_numeric($picto)) {
4350 return '<i class="fa fa-weather-level'.$picto.
'"></i>';
4351 } elseif (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
4355 $path = DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/weather/'.$picto;
4357 return img_picto($titlealt, $path, $moreatt, 1, 0, 0,
'', $morecss);
4371 function img_picto_common($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $notitle = 0)
4375 if (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
4379 if ($pictoisfullpath) {
4382 $path = DOL_URL_ROOT.
'/theme/common/'.$picto;
4384 if (!empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) {
4385 $themepath = DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/img/'.$picto;
4387 if (file_exists($themepath)) {
4393 return img_picto($titlealt, $path, $moreatt, 1, 0, $notitle);
4412 if (empty($titlealt) || $titlealt ==
'default') {
4413 if ($numaction ==
'-1' || $numaction ==
'ST_NO') {
4415 $titlealt = $langs->transnoentitiesnoconv(
'ChangeDoNotContact');
4416 } elseif ($numaction ==
'0' || $numaction ==
'ST_NEVER') {
4418 $titlealt = $langs->transnoentitiesnoconv(
'ChangeNeverContacted');
4419 } elseif ($numaction ==
'1' || $numaction ==
'ST_TODO') {
4421 $titlealt = $langs->transnoentitiesnoconv(
'ChangeToContact');
4422 } elseif ($numaction ==
'2' || $numaction ==
'ST_PEND') {
4424 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactInProcess');
4425 } elseif ($numaction ==
'3' || $numaction ==
'ST_DONE') {
4427 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactDone');
4429 $titlealt = $langs->transnoentitiesnoconv(
'ChangeStatus '.$numaction);
4433 if (!is_numeric($numaction)) {
4437 return img_picto($titlealt, !empty($picto) ? $picto :
'stcomm'.$numaction.
'.png');
4447 function img_pdf($titlealt =
'default', $size = 3)
4451 if ($titlealt ==
'default') {
4452 $titlealt = $langs->trans(
'Show');
4455 return img_picto($titlealt,
'pdf'.$size.
'.png');
4469 if ($titlealt ==
'default') {
4470 $titlealt = $langs->trans(
'Add');
4473 return img_picto($titlealt,
'edit_add.png', $other);
4486 if ($titlealt ==
'default') {
4487 $titlealt = $langs->trans(
'Remove');
4490 return img_picto($titlealt,
'edit_remove.png', $other);
4501 function img_edit($titlealt =
'default', $float = 0, $other =
'')
4505 if ($titlealt ==
'default') {
4506 $titlealt = $langs->trans(
'Modify');
4509 return img_picto($titlealt,
'edit.png', ($float ?
'style="float: '.($langs->tab_translate[
"DIRECTION"] ==
'rtl' ?
'left' :
'right').
'"' :
"").($other ?
' '.$other :
''));
4520 function img_view($titlealt =
'default', $float = 0, $other =
'class="valignmiddle"')
4524 if ($titlealt ==
'default') {
4525 $titlealt = $langs->trans(
'View');
4528 $moreatt = ($float ?
'style="float: right" ' :
'').$other;
4530 return img_picto($titlealt,
'eye', $moreatt);
4541 function img_delete($titlealt =
'default', $other =
'class="pictodelete"', $morecss =
'')
4545 if ($titlealt ==
'default') {
4546 $titlealt = $langs->trans(
'Delete');
4549 return img_picto($titlealt,
'delete.png', $other,
false, 0, 0,
'', $morecss);
4562 if ($titlealt ==
"default") {
4563 $titlealt = $langs->trans(
"Print");
4565 return img_picto($titlealt,
'printer.png', $other);
4575 function img_split($titlealt =
'default', $other =
'class="pictosplit"')
4579 if ($titlealt ==
'default') {
4580 $titlealt = $langs->trans(
'Split');
4583 return img_picto($titlealt,
'split.png', $other);
4593 function img_help($usehelpcursor = 1, $usealttitle = 1)
4598 if (is_string($usealttitle)) {
4601 $usealttitle = $langs->trans(
'Info');
4605 return img_picto($usealttitle,
'info.png',
'style="vertical-align: middle;'.($usehelpcursor == 1 ?
' cursor: help' : ($usehelpcursor == 2 ?
' cursor: pointer' :
'')).
'"');
4618 if ($titlealt ==
'default') {
4619 $titlealt = $langs->trans(
'Informations');
4622 return img_picto($titlealt,
'info.png',
'style="vertical-align: middle;"');
4633 function img_warning($titlealt =
'default', $moreatt =
'', $morecss =
'pictowarning')
4637 if ($titlealt ==
'default') {
4638 $titlealt = $langs->trans(
'Warning');
4642 return img_picto($titlealt,
'warning.png',
'class="'.$morecss.
'"'.($moreatt ? ($moreatt ==
'1' ?
' style="float: right"' :
' '.$moreatt) :
''));
4655 if ($titlealt ==
'default') {
4656 $titlealt = $langs->trans(
'Error');
4659 return img_picto($titlealt,
'error.png');
4669 function img_next($titlealt =
'default', $moreatt =
'')
4673 if ($titlealt ==
'default') {
4674 $titlealt = $langs->trans(
'Next');
4678 return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
4692 if ($titlealt ==
'default') {
4693 $titlealt = $langs->trans(
'Previous');
4697 return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
4708 function img_down($titlealt =
'default', $selected = 0, $moreclass =
'')
4712 if ($titlealt ==
'default') {
4713 $titlealt = $langs->trans(
'Down');
4716 return img_picto($titlealt, ($selected ?
'1downarrow_selected.png' :
'1downarrow.png'),
'class="imgdown'.($moreclass ?
" ".$moreclass :
"").
'"');
4727 function img_up($titlealt =
'default', $selected = 0, $moreclass =
'')
4731 if ($titlealt ==
'default') {
4732 $titlealt = $langs->trans(
'Up');
4735 return img_picto($titlealt, ($selected ?
'1uparrow_selected.png' :
'1uparrow.png'),
'class="imgup'.($moreclass ?
" ".$moreclass :
"").
'"');
4746 function img_left($titlealt =
'default', $selected = 0, $moreatt =
'')
4750 if ($titlealt ==
'default') {
4751 $titlealt = $langs->trans(
'Left');
4754 return img_picto($titlealt, ($selected ?
'1leftarrow_selected.png' :
'1leftarrow.png'), $moreatt);
4765 function img_right($titlealt =
'default', $selected = 0, $moreatt =
'')
4769 if ($titlealt ==
'default') {
4770 $titlealt = $langs->trans(
'Right');
4773 return img_picto($titlealt, ($selected ?
'1rightarrow_selected.png' :
'1rightarrow.png'), $moreatt);
4787 if ($titlealt ==
'default') {
4788 $titlealt = $langs->trans(
'Active');
4792 return img_picto($titlealt,
'tick.png');
4807 if (is_null($morecss)) {
4811 if ($brand ==
'visa' || $brand ==
'Visa') {
4813 } elseif ($brand ==
'mastercard' || $brand ==
'MasterCard') {
4814 $brand =
'cc-mastercard';
4815 } elseif ($brand ==
'amex' || $brand ==
'American Express') {
4817 } elseif ($brand ==
'discover' || $brand ==
'Discover') {
4818 $brand =
'cc-discover';
4819 } elseif ($brand ==
'jcb' || $brand ==
'JCB') {
4821 } elseif ($brand ==
'diners' || $brand ==
'Diners club') {
4822 $brand =
'cc-diners-club';
4823 } elseif (!in_array($brand, array(
'cc-visa',
'cc-mastercard',
'cc-amex',
'cc-discover',
'cc-jcb',
'cc-diners-club'))) {
4824 $brand =
'credit-card';
4827 return '<span class="fa fa-'.$brand.
' fa-fw'.($morecss ?
' '.$morecss :
'').
'"></span>';
4838 function img_mime($file, $titlealt =
'', $morecss =
'')
4840 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
4846 if (empty($titlealt)) {
4847 $titlealt =
'Mime type: '.$mimetype;
4851 return '<i class="fa fa-'.$mimefa.
' paddingright'.($morecss ?
' '.$morecss :
'').
'"'.($titlealt ?
' title="'.$titlealt.
'"' :
'').
'></i>';
4864 global $conf, $langs;
4866 if ($titlealt ==
'default') {
4867 $titlealt = $langs->trans(
'Search');
4870 $img =
img_picto($titlealt,
'search.png', $other,
false, 1);
4872 $input =
'<input type="image" class="liste_titre" name="button_search" src="'.$img.
'" ';
4873 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
4887 global $conf, $langs;
4889 if ($titlealt ==
'default') {
4890 $titlealt = $langs->trans(
'Search');
4893 $img =
img_picto($titlealt,
'searchclear.png', $other,
false, 1);
4895 $input =
'<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.
'" ';
4896 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
4912 function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin =
'1', $morecss =
'hideonsmartphone', $textfordropdown =
'')
4914 global $conf, $langs;
4916 if ($infoonimgalt) {
4917 $result =
img_picto($text,
'info',
'class="'.($morecss ?
' '.$morecss :
'').
'"');
4919 if (empty($conf->use_javascript_ajax)) {
4920 $textfordropdown =
'';
4923 $class = (empty($admin) ?
'undefined' : ($admin ==
'1' ?
'info' : $admin));
4924 $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>');
4926 if ($textfordropdown) {
4927 $tmpresult =
'<span class="'.$class.
'text opacitymedium cursorpointer">'.$langs->trans($textfordropdown).
' '.
img_picto($langs->trans($textfordropdown),
'1downarrow').
'</span>';
4928 $tmpresult .=
'<script type="text/javascript">
4929 jQuery(document).ready(function() {
4930 jQuery(".'.$class.
'text").click(function() {
4931 console.log("toggle text");
4932 jQuery(".'.$class.
'").toggle();
4937 $result = $tmpresult.$result;
4958 global $conf, $langs, $argv;
4959 global $dolibarr_main_prod;
4966 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
4968 $langs->load(
"main");
4972 $langs->loadLangs(array(
'main',
'errors'));
4974 if ($_SERVER[
'DOCUMENT_ROOT']) {
4975 $out .= $langs->trans(
"DolibarrHasDetectedError").
".<br>\n";
4977 $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";
4979 $out .= $langs->trans(
"InformationToHelpDiagnose").
":<br>\n";
4981 $out .=
"<b>".$langs->trans(
"Date").
":</b> ".
dol_print_date(time(),
'dayhourlog').
"<br>\n";
4982 $out .=
"<b>".$langs->trans(
"Dolibarr").
":</b> ".DOL_VERSION.
" - https://www.dolibarr.org<br>\n";
4983 if (isset($conf->global->MAIN_FEATURES_LEVEL)) {
4984 $out .=
"<b>".$langs->trans(
"LevelOfFeature").
":</b> ".
getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
"<br>\n";
4986 if (function_exists(
"phpversion")) {
4987 $out .=
"<b>".$langs->trans(
"PHP").
":</b> ".phpversion().
"<br>\n";
4989 $out .=
"<b>".$langs->trans(
"Server").
":</b> ".(isset($_SERVER[
"SERVER_SOFTWARE"]) ?
dol_htmlentities($_SERVER[
"SERVER_SOFTWARE"], ENT_COMPAT) :
'').
"<br>\n";
4990 if (function_exists(
"php_uname")) {
4991 $out .=
"<b>".$langs->trans(
"OS").
":</b> ".php_uname().
"<br>\n";
4993 $out .=
"<b>".$langs->trans(
"UserAgent").
":</b> ".(isset($_SERVER[
"HTTP_USER_AGENT"]) ?
dol_htmlentities($_SERVER[
"HTTP_USER_AGENT"], ENT_COMPAT) :
'').
"<br>\n";
4995 $out .=
"<b>".$langs->trans(
"RequestedUrl").
":</b> ".
dol_htmlentities($_SERVER[
"REQUEST_URI"], ENT_COMPAT).
"<br>\n";
4996 $out .=
"<b>".$langs->trans(
"Referer").
":</b> ".(isset($_SERVER[
"HTTP_REFERER"]) ?
dol_htmlentities($_SERVER[
"HTTP_REFERER"], ENT_COMPAT) :
'').
"<br>\n";
4997 $out .=
"<b>".$langs->trans(
"MenuManager").
":</b> ".(isset($conf->standard_menu) ?
dol_htmlentities($conf->standard_menu, ENT_COMPAT) :
'').
"<br>\n";
4999 $syslog .=
"url=".dol_escape_htmltag($_SERVER[
"REQUEST_URI"]);
5000 $syslog .=
", query_string=".dol_escape_htmltag($_SERVER[
"QUERY_STRING"]);
5003 $out .=
'> '.$langs->transnoentities(
"ErrorInternalErrorDetected").
":\n".$argv[0].
"\n";
5004 $syslog .=
"pid=".dol_getmypid();
5007 if (!empty($conf->modules)) {
5008 $out .=
"<b>".$langs->trans(
"Modules").
":</b> ".join(
', ', $conf->modules).
"<br>\n";
5011 if (is_object($db)) {
5012 if ($_SERVER[
'DOCUMENT_ROOT']) {
5013 $out .=
"<b>".$langs->trans(
"DatabaseTypeManager").
":</b> ".$db->type.
"<br>\n";
5014 $out .=
"<b>".$langs->trans(
"RequestLastAccessInError").
":</b> ".($db->lastqueryerror() ?
dol_escape_htmltag($db->lastqueryerror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5015 $out .=
"<b>".$langs->trans(
"ReturnCodeLastAccessInError").
":</b> ".($db->lasterrno() ?
dol_escape_htmltag($db->lasterrno()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5016 $out .=
"<b>".$langs->trans(
"InformationLastAccessInError").
":</b> ".($db->lasterror() ?
dol_escape_htmltag($db->lasterror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5021 $out .=
'> '.$langs->transnoentities(
"DatabaseTypeManager").
":\n".$db->type.
"\n";
5022 $out .=
'> '.$langs->transnoentities(
"RequestLastAccessInError").
":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5023 $out .=
'> '.$langs->transnoentities(
"ReturnCodeLastAccessInError").
":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5024 $out .=
'> '.$langs->transnoentities(
"InformationLastAccessInError").
":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5026 $syslog .=
", sql=".$db->lastquery();
5027 $syslog .=
", db_error=".$db->lasterror();
5030 if ($error || $errors) {
5031 $langs->load(
"errors");
5034 if (is_array($error) && is_array($errors)) {
5035 $errors = array_merge($error, $errors);
5036 } elseif (is_array($error)) {
5038 } elseif (is_array($errors)) {
5039 $errors = array_merge(array($error), $errors);
5041 $errors = array_merge(array($error), array($errors));
5044 foreach ($errors as $msg) {
5048 if ($_SERVER[
'DOCUMENT_ROOT']) {
5052 $out .=
'> '.$langs->transnoentities(
"Message").
":\n".$msg.
"\n";
5054 $syslog .=
", msg=".$msg;
5057 if (empty($dolibarr_main_prod) && $_SERVER[
'DOCUMENT_ROOT'] && function_exists(
'xdebug_print_function_stack') && function_exists(
'xdebug_call_file')) {
5058 xdebug_print_function_stack();
5059 $out .=
'<b>XDebug informations:</b>'.
"<br>\n";
5060 $out .=
'File: '.xdebug_call_file().
"<br>\n";
5061 $out .=
'Line: '.xdebug_call_line().
"<br>\n";
5062 $out .=
'Function: '.xdebug_call_function().
"<br>\n";
5067 if (!headers_sent()) {
5068 if (function_exists(
'top_httphead')) {
5071 http_response_code(500);
5074 if (empty($dolibarr_main_prod)) {
5077 if (empty($langs->defaultlang)) {
5078 $langs->setDefaultLang();
5080 $langs->loadLangs(array(
"main",
"errors"));
5082 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";
5083 print $langs->trans(
"DolibarrHasDetectedError").
'. ';
5084 print $langs->trans(
"YouCanSetOptionDolibarrMainProdToZero");
5085 define(
"MAIN_CORE_ERROR", 1);
5101 function dol_print_error_email($prefixcode, $errormessage =
'', $errormessages = array(), $morecss =
'error', $email =
'')
5103 global $langs, $conf;
5105 if (empty($email)) {
5106 $email = $conf->global->MAIN_INFO_SOCIETE_MAIL;
5109 $langs->load(
"errors");
5112 print
'<br><div class="center login_main_message"><div class="'.$morecss.
'">';
5113 print $langs->trans(
"ErrorContactEMail", $email, $prefixcode.dol_print_date($now,
'%Y%m%d%H%M%S'));
5114 if ($errormessage) {
5115 print
'<br><br>'.$errormessage;
5117 if (is_array($errormessages) && count($errormessages)) {
5118 foreach ($errormessages as $mesgtoshow) {
5119 print
'<br><br>'.$mesgtoshow;
5122 print
'</div></div>';
5141 function print_liste_field_titre($name, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $tooltip =
"", $forcenowrapcolumntitle = 0)
5143 print
getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip, $forcenowrapcolumntitle);
5164 function getTitleFieldOfList($name, $thead = 0, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $disablesortlink = 0, $tooltip =
'', $forcenowrapcolumntitle = 0)
5166 global $conf, $langs,
$form;
5169 if ($moreattrib ==
'class="right"') {
5170 $prefix .=
'right ';
5173 $sortorder = strtoupper($sortorder);
5182 $tmpsortfield = explode(
',', $sortfield);
5183 $sortfield1 = trim($tmpsortfield[0]);
5184 $tmpfield = explode(
',', $field);
5185 $field1 = trim($tmpfield[0]);
5187 if (empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && empty($forcenowrapcolumntitle)) {
5188 $prefix =
'wrapcolumntitle '.$prefix;
5194 $liste_titre =
'liste_titre';
5195 if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace(
"/^[^\.]+\./",
"", $field1))) {
5196 $liste_titre =
'liste_titre_sel';
5199 $tagstart =
'<'.$tag.
' class="'.$prefix.$liste_titre.
'" '.$moreattrib;
5201 $tagstart .= ($name && empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && empty($forcenowrapcolumntitle) && !
dol_textishtml($name)) ?
' title="'.
dol_escape_htmltag($langs->trans($name)).
'"' :
'';
5204 if (empty($thead) && $field && empty($disablesortlink)) {
5205 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
5206 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
5207 $options = preg_replace(
'/&+/i',
'&', $options);
5208 if (!preg_match(
'/^&/', $options)) {
5209 $options =
'&'.$options;
5212 $sortordertouseinlink =
'';
5213 if ($field1 != $sortfield1) {
5214 if (preg_match(
'/^DESC/i', $sortorder)) {
5215 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
5217 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
5220 if (preg_match(
'/^ASC/i', $sortorder)) {
5221 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
5223 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
5226 $sortordertouseinlink = preg_replace(
'/,$/',
'', $sortordertouseinlink);
5227 $out .=
'<a class="reposition" href="'.$file.
'?sortfield='.$field.
'&sortorder='.$sortordertouseinlink.
'&begin='.$begin.$options.
'"';
5233 if (preg_match(
'/:\w+$/', $tooltip)) {
5234 $tmptooltip = explode(
':', $tooltip);
5236 $tmptooltip = array($tooltip);
5238 $out .=
$form->textwithpicto($langs->trans($name), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.str_replace(
'.',
'_', $field).
'_'.$tmptooltip[1]));
5240 $out .= $langs->trans($name);
5243 if (empty($thead) && $field && empty($disablesortlink)) {
5247 if (empty($thead) && $field) {
5248 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
5249 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
5250 $options = preg_replace(
'/&+/i',
'&', $options);
5251 if (!preg_match(
'/^&/', $options)) {
5252 $options =
'&'.$options;
5255 if (!$sortorder || $field1 != $sortfield1) {
5259 if (preg_match(
'/^DESC/', $sortorder)) {
5262 $sortimg .=
'<span class="nowrap">'.img_up(
"Z-A", 0,
'paddingright').
'</span>';
5264 if (preg_match(
'/^ASC/', $sortorder)) {
5267 $sortimg .=
'<span class="nowrap">'.img_down(
"A-Z", 0,
'paddingright').
'</span>';
5272 $tagend =
'</'.$tag.
'>';
5274 $out = $tagstart.$sortimg.$out.$tagend;
5289 dol_syslog(__FUNCTION__.
" is deprecated", LOG_WARNING);
5291 print
'<div class="titre">'.$title.
'</div>';
5323 function load_fiche_titre($titre, $morehtmlright =
'', $picto =
'generic', $pictoisfullpath = 0, $id =
'', $morecssontable =
'', $morehtmlcenter =
'')
5329 if ($picto ==
'setup') {
5334 $return .=
'<table '.($id ?
'id="'.$id.
'" ' :
'').
'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ?
' '.$morecssontable :
'').
'">';
5335 $return .=
'<tr class="titre">';
5337 $return .=
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).
'</td>';
5339 $return .=
'<td class="nobordernopadding valignmiddle col-title">';
5340 $return .=
'<div class="titre inline-block">'.$titre.
'</div>';
5343 $return .=
'<td class="nobordernopadding center valignmiddle">'.$morehtmlcenter.
'</td>';
5346 $return .=
'<td class="nobordernopadding titre_right wordbreakimp right valignmiddle">'.$morehtmlright.
'</td>';
5348 $return .=
'</tr></table>'.
"\n";
5376 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 =
'')
5378 global $conf, $langs;
5381 $savtotalnboflines = $totalnboflines;
5382 $totalnboflines = abs((
int) $totalnboflines);
5384 if ($picto ==
'setup') {
5385 $picto =
'title_setup.png';
5387 if (($conf->browser->name ==
'ie') && $picto ==
'generic') {
5388 $picto =
'title.gif';
5391 $limit = $conf->liste_limit;
5393 if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
5401 print
"<!-- Begin title -->\n";
5402 print
'<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ?
' '.$morecss :
'').
'"><tr>';
5406 if ($picto && $titre) {
5407 print
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath).
'</td>';
5409 print
'<td class="nobordernopadding valignmiddle col-title">';
5410 print
'<div class="titre inline-block">'.$titre;
5411 if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines !=
'') {
5412 print
'<span class="opacitymedium colorblack paddingleft">('.$totalnboflines.
')</span>';
5414 print
'</div></td>';
5417 if ($morehtmlcenter) {
5418 print
'<td class="nobordernopadding center valignmiddle">'.$morehtmlcenter.
'</td>';
5422 print
'<td class="nobordernopadding valignmiddle right">';
5423 print
'<input type="hidden" name="pageplusoneold" value="'.((int) $page + 1).
'">';
5425 $options .=
"&sortfield=".urlencode($sortfield);
5428 $options .=
"&sortorder=".urlencode($sortorder);
5432 if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
5433 if ($totalnboflines) {
5435 $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 0);
5438 $nbpages = ceil($totalnboflines / $limit);
5442 $cpt = ($page - $maxnbofpage);
5448 if (empty($pagenavastextinput)) {
5449 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page=0'.$options.
'">1</a></li>';
5451 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
5452 } elseif ($cpt == 2) {
5453 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page=1'.$options.
'">2</a></li>';
5459 if ($pagenavastextinput) {
5460 if ($cpt == $page) {
5461 $pagelist .=
'<li class="pagination"><input type="text" class="width25 center pageplusone" name="pageplusone" value="'.($page + 1).
'"></li>';
5465 if ($cpt == $page) {
5466 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
'</span></li>';
5468 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.$cpt.$options.
'">'.($cpt + 1).
'</a></li>';
5472 }
while ($cpt < $nbpages && $cpt <= ($page + $maxnbofpage));
5474 if (empty($pagenavastextinput)) {
5475 if ($cpt < $nbpages) {
5476 if ($cpt < $nbpages - 2) {
5477 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
5478 } elseif ($cpt == $nbpages - 2) {
5479 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.($nbpages - 2).$options.
'">'.($nbpages - 1).
'</a></li>';
5481 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
5485 $pagelist .=
'<li class="pagination paginationlastpage"><a href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
5488 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
"</li>";
5492 if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
5493 print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow);
5497 if ($pagenavastextinput) {
5503 print
'</tr></table>'.
"\n";
5504 print
"<!-- End title -->\n\n";
5522 function print_fleche_navigation($page, $file, $options =
'', $nextpage = 0, $betweenarrows =
'', $afterarrows =
'', $limit = -1, $totalnboflines = 0, $hideselectlimit = 0, $beforearrows =
'')
5524 global $conf, $langs;
5526 print
'<div class="pagination"><ul>';
5527 if ($beforearrows) {
5528 print
'<li class="paginationbeforearrows">';
5529 print $beforearrows;
5532 if ((
int) $limit > 0 && empty($hideselectlimit)) {
5533 $pagesizechoices =
'10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000';
5534 $pagesizechoices .=
',5000:5000,10000:10000,20000:20000';
5537 if (!empty($conf->global->MAIN_PAGESIZE_CHOICES)) {
5538 $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES;
5541 print
'<li class="pagination">';
5542 print
'<select class="flat selectlimit" name="limit" title="'.dol_escape_htmltag($langs->trans(
"MaxNbOfRecordPerPage")).
'">';
5543 $tmpchoice = explode(
',', $pagesizechoices);
5544 $tmpkey = $limit.
':'.$limit;
5545 if (!in_array($tmpkey, $tmpchoice)) {
5546 $tmpchoice[] = $tmpkey;
5548 $tmpkey = $conf->liste_limit.
':'.$conf->liste_limit;
5549 if (!in_array($tmpkey, $tmpchoice)) {
5550 $tmpchoice[] = $tmpkey;
5552 asort($tmpchoice, SORT_NUMERIC);
5553 foreach ($tmpchoice as $val) {
5555 $tmp = explode(
':', $val);
5558 if ($key !=
'' && $val !=
'') {
5559 if ((
int) $key == (
int) $limit) {
5560 $selected =
' selected="selected"';
5562 print
'<option name="'.$key.
'"'.$selected.
'>'.
dol_escape_htmltag($val).
'</option>'.
"\n";
5566 if ($conf->use_javascript_ajax) {
5567 print
'<!-- JS CODE TO ENABLE select limit to launch submit of page -->
5569 jQuery(document).ready(function () {
5570 jQuery(".selectlimit").change(function() {
5571 console.log("Change limit. Send submit");
5572 $(this).parents(\'form:first\').submit();
5581 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>';
5583 if ($betweenarrows) {
5584 print
'<!--<div class="betweenarrows nowraponall inline-block">-->';
5585 print $betweenarrows;
5586 print
'<!--</div>-->';
5588 if ($nextpage > 0) {
5589 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>';
5592 print
'<li class="paginationafterarrows">';
5596 print
'</ul></div>'.
"\n";
5611 function vatrate($rate, $addpercent =
false, $info_bits = 0, $usestarfornpr = 0, $html = 0)
5615 if (preg_match(
'/%/', $rate)) {
5616 $rate = str_replace(
'%',
'', $rate);
5620 if (preg_match(
'/\((.*)\)/', $rate, $reg)) {
5621 $morelabel =
' ('.$reg[1].
')';
5622 $rate = preg_replace(
'/\s*'.preg_quote($morelabel,
'/').
'/',
'', $rate);
5623 $morelabel =
' '.($html ?
'<span class="opacitymedium">' :
'').
'('.$reg[1].
')'.($html ?
'</span>' :
'');
5625 if (preg_match(
'/\*/', $rate)) {
5626 $rate = str_replace(
'*',
'', $rate);
5631 if (!preg_match(
'/\//', $rate)) {
5632 $ret =
price($rate, 0,
'', 0, 0).($addpercent ?
'%' :
'');
5635 $ret = $rate.($addpercent ?
'%' :
'');
5637 if (($info_bits & 1) && $usestarfornpr >= 0) {
5660 function price($amount,
$form = 0, $outlangs =
'', $trunc = 1, $rounding = -1, $forcerounding = -1, $currency_code =
'')
5662 global $langs, $conf;
5665 if (empty($amount)) {
5668 $amount = (is_numeric($amount) ? $amount : 0);
5669 if ($rounding < 0) {
5670 $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
5672 $nbdecimal = $rounding;
5674 if ($outlangs ===
'none') {
5684 if (!is_object($outlangs)) {
5688 if ($outlangs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
5689 $dec = $outlangs->transnoentitiesnoconv(
"SeparatorDecimal");
5691 if ($outlangs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
5692 $thousand = $outlangs->transnoentitiesnoconv(
"SeparatorThousand");
5694 if ($thousand ==
'None') {
5696 } elseif ($thousand ==
'Space') {
5703 $amount = str_replace(
',',
'.', $amount);
5705 $datas = explode(
'.', $amount);
5706 $decpart = isset($datas[1]) ? $datas[1] :
'';
5707 $decpart = preg_replace(
'/0+$/i',
'', $decpart);
5716 if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN) {
5717 $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_SHOWN;
5718 if (preg_match(
'/\.\.\./i', $conf->global->MAIN_MAX_DECIMALS_SHOWN)) {
5725 if ((
string) $forcerounding !=
'-1') {
5726 if ($forcerounding ==
'MU') {
5727 $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_UNIT;
5728 } elseif ($forcerounding ==
'MT') {
5729 $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_TOT;
5730 } elseif ($forcerounding >= 0) {
5731 $nbdecimal = $forcerounding;
5736 $output = number_format($amount, $nbdecimal, $dec, $thousand);
5738 $output = preg_replace(
'/\s/',
' ', $output);
5739 $output = preg_replace(
'/\'/',
''', $output);
5742 $cursymbolbefore = $cursymbolafter =
'';
5743 if ($currency_code && is_object($outlangs)) {
5744 if ($currency_code ==
'auto') {
5745 $currency_code = $conf->currency;
5748 $listofcurrenciesbefore = array(
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD',
'CRC');
5749 $listoflanguagesbefore = array(
'nl_NL');
5750 if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) {
5751 $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
5753 $tmpcur = $outlangs->getCurrencySymbol($currency_code);
5754 $cursymbolafter .= ($tmpcur == $currency_code ?
' '.$tmpcur : $tmpcur);
5757 $output = $cursymbolbefore.$output.$end.($cursymbolafter ?
' ' :
'').$cursymbolafter;
5788 global $langs, $conf;
5791 if (is_null($amount)) {
5800 if (is_null($langs)) {
5804 if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
5805 $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
5807 if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
5808 $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
5811 if ($thousand ==
'None') {
5813 } elseif ($thousand ==
'Space') {
5821 if (!is_numeric($amount)) {
5822 $amount = preg_replace(
'/[a-zA-Z\/\\\*\(\)<>\_]/',
'', $amount);
5825 if ($option == 2 && $thousand ==
'.' && preg_match(
'/\.(\d\d\d)$/', (
string) $amount)) {
5826 $amount = str_replace($thousand,
'', $amount);
5832 if (is_numeric($amount)) {
5834 $temps = sprintf(
"%0.10F", $amount - intval($amount));
5835 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
5837 $amount = number_format($amount, $nbofdec, $dec, $thousand);
5842 if ($thousand !=
',' && $thousand !=
'.') {
5843 $amount = str_replace(
',',
'.', $amount);
5846 $amount = str_replace(
' ',
'', $amount);
5847 $amount = str_replace($thousand,
'', $amount);
5848 $amount = str_replace($dec,
'.', $amount);
5850 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
5856 $nbofdectoround =
'';
5857 if ($rounding ==
'MU') {
5858 $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT;
5859 } elseif ($rounding ==
'MT') {
5860 $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT;
5861 } elseif ($rounding ==
'MS') {
5862 $nbofdectoround = isset($conf->global->MAIN_MAX_DECIMALS_STOCK) ? $conf->global->MAIN_MAX_DECIMALS_STOCK : 5;
5863 } elseif ($rounding ==
'CU') {
5864 $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_UNIT, 8);
5865 } elseif ($rounding ==
'CT') {
5866 $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_TOT, 8);
5867 } elseif (is_numeric($rounding)) {
5868 $nbofdectoround = (int) $rounding;
5873 $amount = round(is_string($amount) ? (
float) $amount : $amount, $nbofdectoround);
5875 return 'ErrorBadParameterProvidedToFunction';
5881 if (is_numeric($amount)) {
5883 $temps = sprintf(
"%0.10F", $amount - intval($amount));
5884 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
5886 $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand);
5892 if ($thousand !=
',' && $thousand !=
'.') {
5893 $amount = str_replace(
',',
'.', $amount);
5896 $amount = str_replace(
' ',
'', $amount);
5897 $amount = str_replace($thousand,
'', $amount);
5898 $amount = str_replace($dec,
'.', $amount);
5900 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
5918 function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput =
'no', $use_short_label = 0)
5920 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
5922 if (($forceunitoutput ==
'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
5923 $dimension = $dimension * 1000000;
5925 } elseif (($forceunitoutput ==
'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) {
5926 $dimension = $dimension * 1000;
5928 } elseif (($forceunitoutput ==
'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) {
5929 $dimension = $dimension / 1000000;
5931 } elseif (($forceunitoutput ==
'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) {
5932 $dimension = $dimension / 1000;
5948 $ret =
price($dimension, 0, $outputlangs, 0, 0, $round);
5949 $ret .=
' '.measuringUnitString(0, $type, $unit, $use_short_label, $outputlangs);
5967 function get_localtax($vatrate, $local, $thirdparty_buyer =
"", $thirdparty_seller =
"", $vatnpr = 0)
5969 global $db, $conf, $mysoc;
5971 if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) {
5972 $thirdparty_seller = $mysoc;
5975 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);
5977 $vatratecleaned = $vatrate;
5979 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
5980 $vatratecleaned = trim($reg[1]);
5981 $vatratecode = $reg[2];
5990 if ($mysoc->country_code ==
'ES') {
5992 if (!$mysoc->localtax1_assuj || (
string) $vatratecleaned ==
"0") {
5995 if ($thirdparty_seller->id == $mysoc->id) {
5996 if (!$thirdparty_buyer->localtax1_assuj) {
6000 if (!$thirdparty_seller->localtax1_assuj) {
6008 if (!$mysoc->localtax2_assuj) {
6011 if ($thirdparty_seller->id == $mysoc->id) {
6012 if (!$thirdparty_buyer->localtax2_assuj) {
6016 if (!$thirdparty_seller->localtax2_assuj) {
6022 if ($local == 1 && !$thirdparty_seller->localtax1_assuj) {
6025 if ($local == 2 && !$thirdparty_seller->localtax2_assuj) {
6031 if (in_array($mysoc->country_code, array(
'ES'))) {
6032 $conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY = 1;
6036 if (!empty($conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY)) {
6038 if ($thirdparty_seller != $mysoc) {
6040 return $thirdparty_seller->localtax1_value;
6044 return $conf->global->MAIN_INFO_VALUE_LOCALTAX1;
6049 if ($thirdparty_seller != $mysoc) {
6052 return $thirdparty_seller->localtax2_value;
6055 if (in_array($mysoc->country_code, array(
'ES'))) {
6056 return $thirdparty_buyer->localtax2_value;
6058 return $conf->global->MAIN_INFO_VALUE_LOCALTAX2;
6065 $sql =
"SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
6066 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
6067 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdparty_seller->country_code).
"'";
6068 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
6069 if (!empty($vatratecode)) {
6070 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
6072 $sql .=
" AND t.recuperableonly = '".$db->escape($vatnpr).
"'";
6075 $resql = $db->query($sql);
6078 $obj = $db->fetch_object(
$resql);
6081 return $obj->localtax1;
6082 } elseif ($local == 2) {
6083 return $obj->localtax2;
6104 $valors = explode(
":", $tax);
6106 if (count($valors) > 1) {
6122 $sql =
"SELECT t.localtax1, t.localtax2 ";
6123 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t inner join ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid=t.fk_pays";
6124 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.active = 1 AND t.taux=(";
6125 $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";
6126 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND tt.active = 1";
6129 $resql = $db->query($sql);
6131 $obj = $db->fetch_object(
$resql);
6133 return $obj->localtax1;
6134 } elseif ($local == 2) {
6135 return $obj->localtax2;
6154 function getTaxesFromId($vatrate, $buyer =
null, $seller =
null, $firstparamisid = 1)
6158 dol_syslog(
"getTaxesFromId vat id or rate = ".$vatrate);
6161 $sql =
"SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy,";
6162 $sql .=
" t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
6163 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
6164 if ($firstparamisid) {
6165 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
6167 $vatratecleaned = $vatrate;
6170 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
6171 $vatratecleaned = $reg[1];
6172 $vatratecode = $reg[2];
6175 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
6178 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($seller->country_code).
"'";
6179 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
6181 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
6185 $resql = $db->query($sql);
6187 $obj = $db->fetch_object(
$resql);
6190 'rowid'=>$obj->rowid,
6193 'localtax1'=>$obj->localtax1,
6194 'localtax1_type'=>$obj->localtax1_type,
6195 'localtax2'=>$obj->localtax2,
6196 'localtax2_type'=>$obj->localtax2_type,
6198 'accountancy_code_sell'=>$obj->accountancy_code_sell,
6199 'accountancy_code_buy'=>$obj->accountancy_code_buy
6231 dol_syslog(
"getLocalTaxesFromRate vatrate=".$vatrate.
" local=".$local);
6234 $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";
6235 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
6236 if ($firstparamisid) {
6237 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
6239 $vatratecleaned = $vatrate;
6242 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
6243 $vatratecleaned = $reg[1];
6244 $vatratecode = $reg[2];
6247 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
6248 if ($mysoc->country_code ==
'ES') {
6249 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($buyer->country_code).
"'";
6251 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(empty($seller->country_code) ? $mysoc->country_code : $seller->country_code).
"'";
6253 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
6255 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
6259 $resql = $db->query($sql);
6261 $obj = $db->fetch_object(
$resql);
6264 $vateratestring = $obj->rate.($obj->code ?
' ('.$obj->code.
')' :
'');
6267 return array($obj->localtax1_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
6268 } elseif ($local == 2) {
6269 return array($obj->localtax2_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
6271 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);
6291 global $db, $conf, $mysoc;
6293 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
6301 $product->fetch($idprod);
6303 if ($mysoc->country_code == $thirdpartytouse->country_code) {
6305 if ($idprodfournprice > 0) {
6306 $result = $product->get_buyprice($idprodfournprice, 0, 0, 0);
6308 $ret = $product->vatrate_supplier;
6309 if ($product->default_vat_code_supplier) {
6310 $ret .=
' ('.$product->default_vat_code_supplier.
')';
6316 $ret = $product->tva_tx;
6317 if ($product->default_vat_code) {
6318 $ret .=
' ('.$product->default_vat_code.
')';
6329 if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
6331 $sql =
"SELECT t.taux as vat_rate, t.code as default_vat_code";
6332 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
6333 $sql .=
" WHERE t.active = 1 AND t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdpartytouse->country_code).
"'";
6334 $sql .=
" ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC";
6335 $sql .= $db->plimit(1);
6337 $resql = $db->query($sql);
6339 $obj = $db->fetch_object(
$resql);
6341 $ret = $obj->vat_rate;
6342 if ($obj->default_vat_code) {
6343 $ret .=
' ('.$obj->default_vat_code.
')';
6355 if ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS !=
'none') {
6356 $defaulttx = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
6367 dol_syslog(
"get_product_vat_for_country: ret=".$ret);
6384 if (!class_exists(
'Product')) {
6385 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
6394 $result = $product->fetch($idprod);
6396 if ($mysoc->country_code == $thirdpartytouse->country_code) {
6410 $sql =
"SELECT taux as vat_rate, localtax1, localtax2";
6411 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
6412 $sql .=
" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdpartytouse->country_code).
"'";
6413 $sql .=
" ORDER BY t.taux DESC, t.recuperableonly ASC";
6414 $sql .= $db->plimit(1);
6416 $resql = $db->query($sql);
6418 $obj = $db->fetch_object(
$resql);
6421 $ret = $obj->localtax1;
6422 } elseif ($local == 2) {
6423 $ret = $obj->localtax2;
6431 dol_syslog(
"get_product_localtax_for_country: ret=".$ret);
6455 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
6458 $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;
6460 $seller_country_code = $thirdparty_seller->country_code;
6461 $seller_in_cee =
isInEEC($thirdparty_seller);
6463 $buyer_country_code = $thirdparty_buyer->country_code;
6464 $buyer_in_cee =
isInEEC($thirdparty_buyer);
6466 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 :
''));
6470 if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
6471 if ($seller_in_cee && $buyer_in_cee) {
6472 $isacompany = $thirdparty_buyer->
isACompany();
6473 if ($isacompany && !empty($conf->global->MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL)) {
6474 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
6488 if (!$seller_use_vat) {
6496 if (($seller_country_code == $buyer_country_code)
6497 || (in_array($seller_country_code, array(
'FR',
'MC')) && in_array($buyer_country_code, array(
'FR',
'MC')))) {
6507 if (($seller_in_cee && $buyer_in_cee)) {
6508 $isacompany = $thirdparty_buyer->
isACompany();
6509 if ($isacompany && !empty($conf->global->MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL)) {
6510 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
6527 if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC) && empty($buyer_in_cee)) {
6528 $isacompany = $thirdparty_buyer->
isACompany();
6556 if ($idprodfournprice > 0) {
6557 if (!class_exists(
'ProductFournisseur')) {
6558 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
6561 $prodprice->fetch_product_fournisseur_price($idprodfournprice);
6562 return $prodprice->fourn_tva_npr;
6563 } elseif ($idprod > 0) {
6564 if (!class_exists(
'Product')) {
6565 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
6568 $prod->fetch($idprod);
6569 return $prod->tva_npr;
6592 if (!is_object($thirdparty_seller)) {
6595 if (!is_object($thirdparty_buyer)) {
6600 if ($mysoc->country_code ==
'ES') {
6601 if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) {
6606 if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) {
6609 if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj ==
'localtax1off') {
6613 } elseif ($local == 2) {
6615 if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) {
6618 if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj ==
'localtax2off') {
6623 if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
6638 function yn($yesno, $case = 1, $color = 0)
6642 $result =
'unknown';
6644 if ($yesno == 1 || strtolower($yesno) ==
'yes' || strtolower($yesno) ==
'true') {
6645 $result = $langs->trans(
'yes');
6646 if ($case == 1 || $case == 3) {
6647 $result = $langs->trans(
"Yes");
6650 $result =
'<input type="checkbox" value="1" checked disabled>';
6653 $result =
'<input type="checkbox" value="1" checked disabled> '.$result;
6657 } elseif ($yesno == 0 || strtolower($yesno) ==
'no' || strtolower($yesno) ==
'false') {
6658 $result = $langs->trans(
"no");
6659 if ($case == 1 || $case == 3) {
6660 $result = $langs->trans(
"No");
6663 $result =
'<input type="checkbox" value="0" disabled>';
6666 $result =
'<input type="checkbox" value="0" disabled> '.$result;
6672 $classname =
'error';
6676 return '<span class="'.$classname.
'">'.$result.
'</span>';
6696 function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart =
'')
6700 if (empty($modulepart) && !empty($object->module)) {
6701 $modulepart = $object->module;
6706 $arrayforoldpath = array(
'cheque',
'category',
'holiday',
'supplier_invoice',
'invoice_supplier',
'mailing',
'supplier_payment');
6708 $arrayforoldpath[] =
'product';
6710 if (!empty($level) && in_array($modulepart, $arrayforoldpath)) {
6712 if (empty($alpha)) {
6713 $num = preg_replace(
'/([^0-9])/i',
'', $num);
6715 $num = preg_replace(
'/^.*\-/i',
'', $num);
6717 $num = substr(
"000".$num, -$level);
6719 $path = substr($num, 0, 1);
6722 $path = substr($num, 1, 1).
'/'.substr($num, 0, 1);
6725 $path = substr($num, 2, 1).
'/'.substr($num, 1, 1).
'/'.substr($num, 0, 1);
6735 if (empty($withoutslash) && !empty($path)) {
6754 dol_syslog(
"functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
6757 if (@is_dir($dir_osencoded)) {
6765 if (!empty($dataroot)) {
6767 $dir = str_replace($dataroot.
'/',
'', $dir);
6768 $ccdir = $dataroot.
'/';
6771 $cdir = explode(
"/", $dir);
6772 $num = count($cdir);
6773 for ($i = 0; $i < $num; $i++) {
6775 $ccdir .=
'/'.$cdir[$i];
6777 $ccdir .= $cdir[$i];
6779 if (preg_match(
"/^.:$/", $ccdir, $regs)) {
6787 if (!@is_dir($ccdir_osencoded)) {
6788 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG);
6791 $dirmaskdec = octdec((
string) $newmask);
6792 if (empty($newmask)) {
6793 $dirmaskdec = empty($conf->global->MAIN_UMASK) ? octdec(
'0755') : octdec($conf->global->MAIN_UMASK);
6795 $dirmaskdec |= octdec(
'0111');
6796 if (!@mkdir($ccdir_osencoded, $dirmaskdec)) {
6798 dol_syslog(
"functions.lib::dol_mkdir: Fails to create directory '".$ccdir.
"' or directory already exists.", LOG_WARNING);
6801 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' created", LOG_DEBUG);
6810 return ($nberr ? -$nberr : $nbcreated);
6821 return '<span class="fieldrequired">*</span>';
6841 function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
'UTF-8', $strip_tags = 0, $removedoublespaces = 1)
6843 if (is_null($stringtoclean)) {
6847 if ($removelinefeed == 2) {
6848 $stringtoclean = preg_replace(
'/<br[^>]*>(\n|\r)+/ims',
'<br>', $stringtoclean);
6850 $temp = preg_replace(
'/<br[^>]*>/i',
"\n", $stringtoclean);
6855 $temp = str_replace(
'< ',
'__ltspace__', $temp);
6858 $temp = strip_tags($temp);
6861 $pattern =
"/<[^<>]+>/";
6868 $tempbis = str_replace(
'<>',
'', $temp);
6869 $tempbis = preg_replace($pattern,
'', $tempbis);
6871 }
while ($tempbis != $temp);
6876 $temp = preg_replace(
'/<+([a-z]+)/i',
'\1', $temp);
6882 if ($removelinefeed == 1) {
6883 $temp = str_replace(array(
"\r\n",
"\r",
"\n"),
" ", $temp);
6887 if ($removedoublespaces) {
6888 while (strpos($temp,
" ")) {
6889 $temp = str_replace(
" ",
" ", $temp);
6893 $temp = str_replace(
'__ltspace__',
'< ', $temp);
6912 function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $removeclassattribute = 1, $cleanalsojavascript = 0, $allowiframe = 0, $allowed_tags = array())
6914 if (empty($allowed_tags)) {
6915 $allowed_tags = array(
6916 "html",
"head",
"meta",
"body",
"article",
"a",
"abbr",
"b",
"blockquote",
"br",
"cite",
"div",
"dl",
"dd",
"dt",
"em",
"font",
"img",
"ins",
"hr",
"i",
"li",
"link",
6917 "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"
6920 $allowed_tags[] =
"comment";
6922 $allowed_tags[] =
"iframe";
6925 $allowed_tags_string = join(
"><", $allowed_tags);
6926 $allowed_tags_string =
'<'.$allowed_tags_string.
'>';
6928 $stringtoclean = str_replace(
'<!DOCTYPE html>',
'__!DOCTYPE_HTML__', $stringtoclean);
6933 $stringtoclean = preg_replace(
'/<!--([^>]*)-->/',
'<comment>\1</comment>', $stringtoclean);
6935 $stringtoclean = preg_replace(
'/:/i',
':', $stringtoclean);
6936 $stringtoclean = preg_replace(
'/:|�+58|:/i',
'', $stringtoclean);
6938 $temp = strip_tags($stringtoclean, $allowed_tags_string);
6940 if ($cleanalsosomestyles) {
6941 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/i',
'', $temp);
6943 if ($removeclassattribute) {
6944 $temp = preg_replace(
'/(<[^>]+)\s+class=((["\']).*?\\3|\\w*)/i',
'\\1', $temp);
6949 if ($cleanalsojavascript) {
6950 $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);
6953 $temp = str_replace(
'__!DOCTYPE_HTML__',
'<!DOCTYPE html>', $temp);
6955 $temp = preg_replace(
'/<comment>([^>]*)<\/comment>/',
'<!--\1-->', $temp);
6973 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"))
6975 if (class_exists(
'DOMDocument') && !empty($stringtoclean)) {
6976 $stringtoclean =
'<?xml encoding="UTF-8"><html><body>'.$stringtoclean.
'</body></html>';
6978 $dom =
new DOMDocument(
null,
'UTF-8');
6979 $dom->loadHTML($stringtoclean, LIBXML_ERR_NONE|LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD|LIBXML_NONET|LIBXML_NOWARNING|LIBXML_NOXMLDECL);
6981 if (is_object($dom)) {
6982 for ($els = $dom->getElementsByTagname(
'*'), $i = $els->length - 1; $i >= 0; $i--) {
6983 for ($attrs = $els->item($i)->attributes, $ii = $attrs->length - 1; $ii >= 0; $ii--) {
6985 if (!empty($attrs->item($ii)->name)) {
6986 if (! in_array($attrs->item($ii)->name, $allowed_attributes)) {
6988 $els->item($i)->removeAttribute($attrs->item($ii)->name);
6989 } elseif (in_array($attrs->item($ii)->name, array(
'style'))) {
6991 $valuetoclean = $attrs->item($ii)->value;
6993 if (isset($valuetoclean)) {
6995 $oldvaluetoclean = $valuetoclean;
6996 $valuetoclean = preg_replace(
'/\/\*.*\*\//m',
'', $valuetoclean);
6997 $valuetoclean = preg_replace(
'/position\s*:\s*[a-z]+/mi',
'', $valuetoclean);
6998 if ($els->item($i)->tagName ==
'a') {
6999 $valuetoclean = preg_replace(
'/display\s*:/mi',
'', $valuetoclean);
7000 $valuetoclean = preg_replace(
'/z-index\s*:/mi',
'', $valuetoclean);
7001 $valuetoclean = preg_replace(
'/\s+(top|left|right|bottom)\s*:/mi',
'', $valuetoclean);
7005 $valuetoclean = preg_replace(
'/(logout|passwordforgotten)\.php/mi',
'', $valuetoclean);
7006 $valuetoclean = preg_replace(
'/action=/mi',
'', $valuetoclean);
7007 }
while ($oldvaluetoclean != $valuetoclean);
7010 $attrs->item($ii)->value = $valuetoclean;
7017 $return = $dom->saveHTML();
7020 $return = preg_replace(
'/^'.preg_quote(
'<?xml encoding="UTF-8">',
'/').
'/',
'', $return);
7021 $return = preg_replace(
'/^'.preg_quote(
'<html><body>',
'/').
'/',
'', $return);
7022 $return = preg_replace(
'/'.preg_quote(
'</body></html>',
'/').
'$/',
'', $return);
7023 return trim($return);
7025 return $stringtoclean;
7042 $temp = $stringtoclean;
7043 foreach ($disallowed_tags as $tagtoremove) {
7044 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'>/',
'', $temp);
7045 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'\s+[^>]*>/',
'', $temp);
7048 if ($cleanalsosomestyles) {
7049 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/',
'', $temp);
7067 if ($nboflines == 1) {
7069 $firstline = preg_replace(
'/<br[^>]*>.*$/s',
'', $text);
7070 $firstline = preg_replace(
'/<div[^>]*>.*$/s',
'', $firstline);
7072 $firstline = preg_replace(
'/[\n\r].*/',
'', $text);
7074 return $firstline.((strlen($firstline) != strlen($text)) ?
'...' :
'');
7078 $text = preg_replace(
'/\n/',
'', $text);
7080 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7082 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7085 $text = strtr($text, $repTable);
7086 if ($charset ==
'UTF-8') {
7087 $pattern =
'/(<br[^>]*>)/Uu';
7090 $pattern =
'/(<br[^>]*>)/U';
7092 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
7097 while (($i < $nba) && ($i < ($nboflines * 2))) {
7099 $firstline .= $a[$i];
7100 } elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) {
7101 $firstline .= ($ishtml ?
"<br>\n" :
"\n");
7106 return $firstline.(($i < $nba) ?
'...' :
'');
7121 function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml =
false)
7124 return nl2br($stringtoencode, $forxml);
7126 $ret = preg_replace(
'/(\r\n|\r|\n)/i', ($forxml ?
'<br />' :
'<br>'), $stringtoencode);
7143 if (empty($nouseofiframesandbox) && !empty($conf->global->MAIN_SECURITY_USE_SANDBOX_FOR_HTMLWITHNOJS)) {
7148 return $stringtoencode;
7150 $out = $stringtoencode;
7153 $oldstringtoclean = $out;
7155 if (!empty($out) && !empty($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML) && $check !=
'restricthtmlallowunvalid') {
7157 $dom =
new DOMDocument;
7161 $out =
'<div class="tricktoremove">'.$out.
'</div>';
7163 $dom->loadHTML($out, LIBXML_ERR_NONE|LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD|LIBXML_NONET|LIBXML_NOWARNING|LIBXML_NOXMLDECL);
7164 $out = trim($dom->saveHTML());
7167 $out = preg_replace(
'/^<div class="tricktoremove">/',
'', $out);
7168 $out = preg_replace(
'/<\/div>$/',
'', $out);
7172 $out =
'InvalidHTMLString';
7177 $out = preg_replace(
'/&(tab|newline);/i',
' ', $out);
7181 $out = preg_replace(
'/'/i',
''', $out);
7186 $out = preg_replace_callback(
'/&#(x?[0-9][0-9a-f]+;?)/i',
function ($m) {
7191 $out = preg_replace(
'/&#x?[0-9]+/i',
'', $out);
7197 if (!empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)) {
7203 $out = preg_replace(
'/'/i',
"'", $out);
7204 }
while ($oldstringtoclean != $out);
7208 preg_match_all(
'/(<img|url\()/i', $out, $reg);
7209 if (count($reg[0]) >
getDolGlobalInt(
"MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 1000)) {
7210 $out =
'TooManyLinksIntoHTMLString';
7234 function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom =
'UTF-8', $removelasteolbr = 1)
7236 if (is_null($stringtoencode)) {
7240 $newstring = $stringtoencode;
7242 $newstring = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
'<br>', $newstring);
7243 if ($removelasteolbr) {
7244 $newstring = preg_replace(
'/<br>$/i',
'', $newstring);
7246 $newstring = strtr($newstring, array(
'&'=>
'__and__',
'<'=>
'__lt__',
'>'=>
'__gt__',
'"'=>
'__dquot__'));
7248 $newstring = strtr($newstring, array(
'__and__'=>
'&',
'__lt__'=>
'<',
'__gt__'=>
'>',
'__dquot__'=>
'"'));
7250 if ($removelasteolbr) {
7251 $newstring = preg_replace(
'/(\r\n|\r|\n)$/i',
'', $newstring);
7270 $ret = preg_replace(
'/'.
"\r\n".
'<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"<br>", $ret);
7271 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\r\n".
'/i',
"\r\n", $ret);
7272 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\n".
'/i',
"\n", $ret);
7273 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"\n", $ret);
7285 $ret = preg_replace(
'/ $/i',
"", $stringtodecode);
7286 $ret = preg_replace(
'/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'.
"\n".
'|'.
"\r".
')+$/i',
"", $ret);
7302 if ($keepsomeentities) {
7303 $newstring = strtr($newstring, array(
'&'=>
'__andamp__',
'<'=>
'__andlt__',
'>'=>
'__andgt__',
'"'=>
'__dquot__'));
7305 $newstring = html_entity_decode((
string) $newstring, (
int) $b, (
string) $c);
7306 if ($keepsomeentities) {
7307 $newstring = strtr($newstring, array(
'__andamp__'=>
'&',
'__andlt__'=>
'<',
'__andgt__'=>
'>',
'__dquot__'=>
'"'));
7322 function dol_htmlentities($string, $flags = ENT_QUOTES|ENT_SUBSTITUTE, $encoding =
'UTF-8', $double_encode =
false)
7324 return htmlentities($string, $flags, $encoding, $double_encode);
7341 for ($scursor = 0; $scursor < $len; $scursor++) {
7342 $ordchar = ord($s[$scursor]);
7344 if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) {
7347 } elseif ($ordchar > 126 && $ordchar < 160) {
7351 $out .= $s[$scursor];
7373 $arraystring = explode(
"\n", $s);
7374 $nb = count($arraystring);
7391 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7393 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7396 $text = strtr($text, $repTable);
7397 if ($charset ==
'UTF-8') {
7398 $pattern =
'/(<br[^>]*>)/Uu';
7401 $pattern =
'/(<br[^>]*>)/U';
7403 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
7405 $nblines = (int) floor((count($a) + 1) / 2);
7408 foreach ($a as $line) {
7411 $line_dec = html_entity_decode($line);
7413 $line_dec = wordwrap($line_dec, $maxlinesize,
'\n',
true);
7414 $nblines += substr_count($line_dec,
'\n');
7434 if (is_null($msg)) {
7439 if (preg_match(
'/<html/i', $msg)) {
7441 } elseif (preg_match(
'/<body/i', $msg)) {
7443 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
7445 } elseif (preg_match(
'/<(b|em|i|u)>/i', $msg)) {
7447 } elseif (preg_match(
'/<br/i', $msg)) {
7453 $msg = preg_replace(
'/https?:\/\/[^"\'\s]+/i',
'', $msg);
7454 if (preg_match(
'/<html/i', $msg)) {
7456 } elseif (preg_match(
'/<body/i', $msg)) {
7458 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
7460 } elseif (preg_match(
'/<(b|em|i|u)>/i', $msg)) {
7462 } elseif (preg_match(
'/<br\/>/i', $msg)) {
7464 } elseif (preg_match(
'/<(br|div|font|li|p|span|strong|table)>/i', $msg)) {
7466 } elseif (preg_match(
'/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/?>/i', $msg)) {
7468 } elseif (preg_match(
'/<img\s+[^<>]*src[^<>]*>/i', $msg)) {
7470 } elseif (preg_match(
'/<a\s+[^<>]*href[^<>]*>/i', $msg)) {
7472 } elseif (preg_match(
'/<h[0-9]>/i', $msg)) {
7474 } elseif (preg_match(
'/&[A-Z0-9]{1,6};/i', $msg)) {
7477 } elseif (preg_match(
'/&#[0-9]{2,3};/i', $msg)) {
7501 if (!empty($invert)) {
7509 $ret .= (!empty($text1) && !empty($text2)) ? ((
dol_textishtml($text1) ||
dol_textishtml($text2)) ? ($forxml ?
"<br >\n" :
"<br>\n") :
"\n") :
"";
7528 global $db, $conf, $mysoc, $user, $extrafields;
7530 $substitutionarray = array();
7532 if (empty($exclude) || !in_array(
'user', $exclude)) {
7536 $emailsendersignature = $user->signature;
7537 $usersignature = $user->signature;
7538 $substitutionarray = array_merge($substitutionarray, array(
7539 '__SENDEREMAIL_SIGNATURE__' => (
string) ((empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ?
dol_trunc(
'SignatureFromTheSelectedSenderProfile', 30) : $emailsendersignature) :
''),
7540 '__USER_SIGNATURE__' => (
string) (($usersignature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ?
dol_trunc(
dol_string_nohtmltag($usersignature), 30) : $usersignature) :
'')
7543 if (is_object($user)) {
7544 $substitutionarray = array_merge($substitutionarray, array(
7545 '__USER_ID__' => (
string) $user->id,
7546 '__USER_LOGIN__' => (
string) $user->login,
7547 '__USER_EMAIL__' => (
string) $user->email,
7550 '__USER_PHONEMOBILE__' => (
string)
dol_print_phone($user->personal_mobile),
7551 '__USER_FAX__' => (
string) $user->office_fax,
7552 '__USER_LASTNAME__' => (
string) $user->lastname,
7553 '__USER_FIRSTNAME__' => (
string) $user->firstname,
7554 '__USER_FULLNAME__' => (
string) $user->getFullName($outputlangs),
7555 '__USER_SUPERVISOR_ID__' => (
string) ($user->fk_user ? $user->fk_user :
'0'),
7556 '__USER_JOB__' => (
string) $user->job,
7561 if ((empty($exclude) || !in_array(
'mycompany', $exclude)) && is_object($mysoc)) {
7562 $substitutionarray = array_merge($substitutionarray, array(
7563 '__MYCOMPANY_NAME__' => $mysoc->name,
7564 '__MYCOMPANY_EMAIL__' => $mysoc->email,
7567 '__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
7568 '__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
7569 '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
7570 '__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
7571 '__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
7572 '__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
7573 '__MYCOMPANY_CAPITAL__' => $mysoc->capital,
7574 '__MYCOMPANY_FULLADDRESS__' => (method_exists($mysoc,
'getFullAddress') ? $mysoc->getFullAddress(1,
', ') :
''),
7575 '__MYCOMPANY_ADDRESS__' => $mysoc->address,
7576 '__MYCOMPANY_ZIP__' => $mysoc->zip,
7577 '__MYCOMPANY_TOWN__' => $mysoc->town,
7578 '__MYCOMPANY_COUNTRY__' => $mysoc->country,
7579 '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id,
7580 '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code,
7581 '__MYCOMPANY_CURRENCY_CODE__' => $conf->currency
7585 if (($onlykey || is_object($object)) && (empty($exclude) || !in_array(
'object', $exclude))) {
7587 $substitutionarray[
'__ID__'] =
'__ID__';
7588 $substitutionarray[
'__REF__'] =
'__REF__';
7589 $substitutionarray[
'__NEWREF__'] =
'__NEWREF__';
7590 $substitutionarray[
'__LABEL__'] =
'__LABEL__';
7591 $substitutionarray[
'__REF_CLIENT__'] =
'__REF_CLIENT__';
7592 $substitutionarray[
'__REF_SUPPLIER__'] =
'__REF_SUPPLIER__';
7593 $substitutionarray[
'__NOTE_PUBLIC__'] =
'__NOTE_PUBLIC__';
7594 $substitutionarray[
'__NOTE_PRIVATE__'] =
'__NOTE_PRIVATE__';
7595 $substitutionarray[
'__EXTRAFIELD_XXX__'] =
'__EXTRAFIELD_XXX__';
7598 $substitutionarray[
'__THIRDPARTY_ID__'] =
'__THIRDPARTY_ID__';
7599 $substitutionarray[
'__THIRDPARTY_NAME__'] =
'__THIRDPARTY_NAME__';
7600 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
'__THIRDPARTY_NAME_ALIAS__';
7601 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
'__THIRDPARTY_CODE_CLIENT__';
7602 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
'__THIRDPARTY_CODE_FOURNISSEUR__';
7603 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
'__THIRDPARTY_EMAIL__';
7604 $substitutionarray[
'__THIRDPARTY_PHONE__'] =
'__THIRDPARTY_PHONE__';
7605 $substitutionarray[
'__THIRDPARTY_FAX__'] =
'__THIRDPARTY_FAX__';
7606 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
'__THIRDPARTY_ADDRESS__';
7607 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
'__THIRDPARTY_ZIP__';
7608 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
'__THIRDPARTY_TOWN__';
7609 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
'__THIRDPARTY_IDPROF1__';
7610 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
'__THIRDPARTY_IDPROF2__';
7611 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
'__THIRDPARTY_IDPROF3__';
7612 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
'__THIRDPARTY_IDPROF4__';
7613 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
'__THIRDPARTY_IDPROF5__';
7614 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
'__THIRDPARTY_IDPROF6__';
7615 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
'__THIRDPARTY_TVAINTRA__';
7616 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] =
'__THIRDPARTY_NOTE_PUBLIC__';
7617 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] =
'__THIRDPARTY_NOTE_PRIVATE__';
7619 if (
isModEnabled(
'adherent') && (!is_object($object) || $object->element ==
'adherent')) {
7620 $substitutionarray[
'__MEMBER_ID__'] =
'__MEMBER_ID__';
7621 $substitutionarray[
'__MEMBER_CIVILITY__'] =
'__MEMBER_CIVILITY__';
7622 $substitutionarray[
'__MEMBER_FIRSTNAME__'] =
'__MEMBER_FIRSTNAME__';
7623 $substitutionarray[
'__MEMBER_LASTNAME__'] =
'__MEMBER_LASTNAME__';
7624 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'Login and pass of the external user account';
7629 if (
isModEnabled(
'ticket') && (!is_object($object) || $object->element ==
'ticket')) {
7630 $substitutionarray[
'__TICKET_TRACKID__'] =
'__TICKET_TRACKID__';
7631 $substitutionarray[
'__TICKET_SUBJECT__'] =
'__TICKET_SUBJECT__';
7632 $substitutionarray[
'__TICKET_TYPE__'] =
'__TICKET_TYPE__';
7633 $substitutionarray[
'__TICKET_SEVERITY__'] =
'__TICKET_SEVERITY__';
7634 $substitutionarray[
'__TICKET_CATEGORY__'] =
'__TICKET_CATEGORY__';
7635 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
'__TICKET_ANALYTIC_CODE__';
7636 $substitutionarray[
'__TICKET_MESSAGE__'] =
'__TICKET_MESSAGE__';
7637 $substitutionarray[
'__TICKET_PROGRESSION__'] =
'__TICKET_PROGRESSION__';
7638 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
'__TICKET_USER_ASSIGN__';
7641 if (
isModEnabled(
'recruitment') && (!is_object($object) || $object->element ==
'recruitmentcandidature')) {
7642 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
'__CANDIDATE_FULLNAME__';
7643 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] =
'__CANDIDATE_FIRSTNAME__';
7644 $substitutionarray[
'__CANDIDATE_LASTNAME__'] =
'__CANDIDATE_LASTNAME__';
7647 $substitutionarray[
'__PROJECT_ID__'] =
'__PROJECT_ID__';
7648 $substitutionarray[
'__PROJECT_REF__'] =
'__PROJECT_REF__';
7649 $substitutionarray[
'__PROJECT_NAME__'] =
'__PROJECT_NAME__';
7653 if (
isModEnabled(
'contrat') && (!is_object($object) || $object->element ==
'contract')) {
7654 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
'Highest date planned for a service start';
7655 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
'Highest date and hour planned for service start';
7656 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
'Lowest data for planned expiration of service';
7657 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
'Lowest date and hour for planned expiration of service';
7659 if (
isModEnabled(
"propal") && (!is_object($object) || $object->element ==
'propal')) {
7660 $substitutionarray[
'__ONLINE_SIGN_URL__'] =
'ToOfferALinkForOnlineSignature';
7662 if (
isModEnabled(
"ficheinter") && (!is_object($object) || $object->element ==
'fichinter')) {
7663 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] =
'ToOfferALinkForOnlineSignature';
7665 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'UrlToPayOnlineIfApplicable';
7666 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'TextAndUrlToPayOnlineIfApplicable';
7667 $substitutionarray[
'__SECUREKEYPAYMENT__'] =
'Security key (if key is not unique per record)';
7668 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
'Security key for payment on a member subscription (one key per member)';
7669 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
'Security key for payment on an order';
7670 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
'Security key for payment on an invoice';
7671 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
'Security key for payment on a service of a contract';
7673 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'Direct download url of a proposal';
7674 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'Direct download url of an order';
7675 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'Direct download url of an invoice';
7676 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'Direct download url of a contract';
7677 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'Direct download url of a supplier proposal';
7679 if (
isModEnabled(
"expedition") && (!is_object($object) || $object->element ==
'shipping')) {
7680 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
'Shipping tracking number';
7681 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
'Shipping tracking url';
7683 if (
isModEnabled(
"reception") && (!is_object($object) || $object->element ==
'reception')) {
7684 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
'Shippin tracking number of shipment';
7685 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
'Shipping tracking url';
7688 $substitutionarray[
'__ID__'] = $object->id;
7689 $substitutionarray[
'__REF__'] = $object->ref;
7690 $substitutionarray[
'__NEWREF__'] = $object->newref;
7691 $substitutionarray[
'__LABEL__'] = (isset($object->label) ? $object->label : (isset($object->title) ? $object->title :
null));
7692 $substitutionarray[
'__REF_CLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer :
null));
7693 $substitutionarray[
'__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier :
null);
7694 $substitutionarray[
'__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public :
null);
7695 $substitutionarray[
'__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private :
null);
7696 if ($object->element ==
"shipping") {
7697 $substitutionarray[
'__DATE_DELIVERY__'] = (isset($object->date_delivery) ?
dol_print_date($object->date_delivery,
'day', 0, $outputlangs) :
'');
7699 $substitutionarray[
'__DATE_DELIVERY__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
'day', 0, $outputlangs) :
'');
7701 $substitutionarray[
'__DATE_DELIVERY_DAY__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%d") :
'');
7702 $substitutionarray[
'__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%A") :
'');
7703 $substitutionarray[
'__DATE_DELIVERY_MON__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%m") :
'');
7704 $substitutionarray[
'__DATE_DELIVERY_MON_TEXT__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%b") :
'');
7705 $substitutionarray[
'__DATE_DELIVERY_YEAR__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%Y") :
'');
7706 $substitutionarray[
'__DATE_DELIVERY_HH__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%H") :
'');
7707 $substitutionarray[
'__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%M") :
'');
7708 $substitutionarray[
'__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%S") :
'');
7711 $substitutionarray[
'__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer :
null));
7712 $substitutionarray[
'__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier :
null);
7713 $substitutionarray[
'__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
'day', 0, $outputlangs) :
'');
7714 $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 :
'')) :
'');
7716 if (is_object($object) && ($object->element ==
'adherent' || $object->element ==
'member') && $object->id > 0) {
7717 $birthday = (empty($object->birth) ?
'' :
dol_print_date($object->birth,
'day'));
7719 $substitutionarray[
'__MEMBER_ID__'] = (isset($object->id) ? $object->id :
'');
7720 if (method_exists($object,
'getCivilityLabel')) {
7721 $substitutionarray[
'__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
7723 $substitutionarray[
'__MEMBER_FIRSTNAME__'] = (isset($object->firstname) ? $object->firstname :
'');
7724 $substitutionarray[
'__MEMBER_LASTNAME__'] = (isset($object->lastname) ? $object->lastname :
'');
7725 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'';
7726 if (method_exists($object,
'getFullName')) {
7727 $substitutionarray[
'__MEMBER_FULLNAME__'] = $object->getFullName($outputlangs);
7729 $substitutionarray[
'__MEMBER_COMPANY__'] = (isset($object->societe) ? $object->societe :
'');
7730 $substitutionarray[
'__MEMBER_ADDRESS__'] = (isset($object->address) ? $object->address :
'');
7731 $substitutionarray[
'__MEMBER_ZIP__'] = (isset($object->zip) ? $object->zip :
'');
7732 $substitutionarray[
'__MEMBER_TOWN__'] = (isset($object->town) ? $object->town :
'');
7733 $substitutionarray[
'__MEMBER_COUNTRY__'] = (isset($object->country) ? $object->country :
'');
7734 $substitutionarray[
'__MEMBER_EMAIL__'] = (isset($object->email) ? $object->email :
'');
7735 $substitutionarray[
'__MEMBER_BIRTH__'] = (isset($birthday) ? $birthday :
'');
7736 $substitutionarray[
'__MEMBER_PHOTO__'] = (isset($object->photo) ? $object->photo :
'');
7737 $substitutionarray[
'__MEMBER_LOGIN__'] = (isset($object->login) ? $object->login :
'');
7738 $substitutionarray[
'__MEMBER_PASSWORD__'] = (isset($object->pass) ? $object->pass :
'');
7739 $substitutionarray[
'__MEMBER_PHONE__'] = (isset($object->phone) ?
dol_print_phone($object->phone) :
'');
7740 $substitutionarray[
'__MEMBER_PHONEPRO__'] = (isset($object->phone_perso) ?
dol_print_phone($object->phone_perso) :
'');
7741 $substitutionarray[
'__MEMBER_PHONEMOBILE__'] = (isset($object->phone_mobile) ?
dol_print_phone($object->phone_mobile) :
'');
7742 $substitutionarray[
'__MEMBER_TYPE__'] = (isset($object->type) ? $object->type :
'');
7743 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE__'] =
dol_print_date($object->first_subscription_date,
'dayrfc');
7744 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = (isset($object->first_subscription_date_start) ?
dol_print_date($object->first_subscription_date_start,
'dayrfc') :
'');
7745 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = (isset($object->first_subscription_date_end) ?
dol_print_date($object->first_subscription_date_end,
'dayrfc') :
'');
7746 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE__'] =
dol_print_date($object->last_subscription_date,
'dayrfc');
7747 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] =
dol_print_date($object->last_subscription_date_start,
'dayrfc');
7748 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] =
dol_print_date($object->last_subscription_date_end,
'dayrfc');
7751 if (is_object($object) && $object->element ==
'societe') {
7752 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object($object) ? $object->id :
'');
7753 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object($object) ? $object->name :
'');
7754 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object($object) ? $object->name_alias :
'');
7755 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object($object) ? $object->code_client :
'');
7756 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object) ? $object->code_fournisseur :
'');
7757 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object($object) ? $object->email :
'');
7758 $substitutionarray[
'__THIRDPARTY_PHONE__'] = (is_object($object) ?
dol_print_phone($object->phone) :
'');
7759 $substitutionarray[
'__THIRDPARTY_FAX__'] = (is_object($object) ?
dol_print_phone($object->fax) :
'');
7760 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object($object) ? $object->address :
'');
7761 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object($object) ? $object->zip :
'');
7762 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object($object) ? $object->town :
'');
7763 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object($object) ? $object->country_id :
'');
7764 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object) ? $object->country_code :
'');
7765 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object($object) ? $object->idprof1 :
'');
7766 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object($object) ? $object->idprof2 :
'');
7767 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object($object) ? $object->idprof3 :
'');
7768 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object($object) ? $object->idprof4 :
'');
7769 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object($object) ? $object->idprof5 :
'');
7770 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object($object) ? $object->idprof6 :
'');
7771 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object($object) ? $object->tva_intra :
'');
7772 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object) ?
dol_htmlentitiesbr($object->note_public) :
'');
7773 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object) ?
dol_htmlentitiesbr($object->note_private) :
'');
7774 } elseif (is_object($object->thirdparty)) {
7775 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->id :
'');
7776 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object($object->thirdparty) ? $object->thirdparty->name :
'');
7777 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty) ? $object->thirdparty->name_alias :
'');
7778 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_client :
'');
7779 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_fournisseur :
'');
7780 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty) ? $object->thirdparty->email :
'');
7781 $substitutionarray[
'__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty) ?
dol_print_phone($object->thirdparty->phone) :
'');
7782 $substitutionarray[
'__THIRDPARTY_FAX__'] = (is_object($object->thirdparty) ?
dol_print_phone($object->thirdparty->fax) :
'');
7783 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty) ? $object->thirdparty->address :
'');
7784 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty) ? $object->thirdparty->zip :
'');
7785 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty) ? $object->thirdparty->town :
'');
7786 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_id :
'');
7787 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_code :
'');
7788 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof1 :
'');
7789 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof2 :
'');
7790 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof3 :
'');
7791 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof4 :
'');
7792 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof5 :
'');
7793 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof6 :
'');
7794 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty) ? $object->thirdparty->tva_intra :
'');
7795 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object->thirdparty) ?
dol_htmlentitiesbr($object->thirdparty->note_public) :
'');
7796 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object->thirdparty) ?
dol_htmlentitiesbr($object->thirdparty->note_private) :
'');
7799 if (is_object($object) && $object->element ==
'recruitmentcandidature') {
7800 $substitutionarray[
'__CANDIDATE_FULLNAME__'] = $object->getFullName($outputlangs);
7801 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname :
'';
7802 $substitutionarray[
'__CANDIDATE_LASTNAME__'] = isset($object->lastname) ? $object->lastname :
'';
7805 if (is_object($object->project)) {
7806 $substitutionarray[
'__PROJECT_ID__'] = (is_object($object->project) ? $object->project->id :
'');
7807 $substitutionarray[
'__PROJECT_REF__'] = (is_object($object->project) ? $object->project->ref :
'');
7808 $substitutionarray[
'__PROJECT_NAME__'] = (is_object($object->project) ? $object->project->title :
'');
7810 if (is_object($object->projet)) {
7811 $substitutionarray[
'__PROJECT_ID__'] = (is_object($object->projet) ? $object->projet->id :
'');
7812 $substitutionarray[
'__PROJECT_REF__'] = (is_object($object->projet) ? $object->projet->ref :
'');
7813 $substitutionarray[
'__PROJECT_NAME__'] = (is_object($object->projet) ? $object->projet->title :
'');
7815 if (is_object($object) && $object->element ==
'project') {
7816 $substitutionarray[
'__PROJECT_NAME__'] = $object->title;
7819 if (is_object($object) && $object->element ==
'shipping') {
7820 $substitutionarray[
'__SHIPPINGTRACKNUM__'] = $object->tracking_number;
7821 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] = $object->tracking_url;
7823 if (is_object($object) && $object->element ==
'reception') {
7824 $substitutionarray[
'__RECEPTIONTRACKNUM__'] = $object->tracking_number;
7825 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] = $object->tracking_url;
7828 if (is_object($object) && $object->element ==
'contrat' && $object->id > 0 && is_array($object->lines)) {
7829 $dateplannedstart =
'';
7830 $datenextexpiration =
'';
7831 foreach ($object->lines as $line) {
7832 if ($line->date_start > $dateplannedstart) {
7833 $dateplannedstart = $line->date_start;
7835 if ($line->statut == 4 && $line->date_end && (!$datenextexpiration || $line->date_end < $datenextexpiration)) {
7836 $datenextexpiration = $line->date_end;
7839 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
dol_print_date($dateplannedstart,
'dayrfc');
7840 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
dol_print_date($dateplannedstart,
'standard');
7841 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
dol_print_date($datenextexpiration,
'dayrfc');
7842 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
dol_print_date($datenextexpiration,
'standard');
7845 if (is_object($object) && $object->element ==
'ticket') {
7846 $substitutionarray[
'__TICKET_TRACKID__'] = $object->track_id;
7847 $substitutionarray[
'__REF__'] = $object->ref;
7848 $substitutionarray[
'__TICKET_SUBJECT__'] = $object->subject;
7849 $substitutionarray[
'__TICKET_TYPE__'] = $object->type_code;
7850 $substitutionarray[
'__TICKET_SEVERITY__'] = $object->severity_code;
7851 $substitutionarray[
'__TICKET_CATEGORY__'] = $object->category_code;
7852 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] = $object->category_code;
7853 $substitutionarray[
'__TICKET_MESSAGE__'] = $object->message;
7854 $substitutionarray[
'__TICKET_PROGRESSION__'] = $object->progress;
7855 $userstat =
new User($db);
7856 if ($object->fk_user_assign > 0) {
7857 $userstat->fetch($object->fk_user_assign);
7858 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
7861 if ($object->fk_user_create > 0) {
7862 $userstat->fetch($object->fk_user_create);
7863 $substitutionarray[
'__USER_CREATE__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
7868 if ($object->table_element && $object->id > 0) {
7869 if (!is_object($extrafields)) {
7872 $extrafields->fetch_name_optionals_label($object->table_element,
true);
7874 if ($object->fetch_optionals() > 0) {
7875 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label']) > 0) {
7876 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $label) {
7877 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = $object->array_options[
'options_'.$key];
7878 if ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'date') {
7879 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_date($object->array_options[
'options_'.$key],
'day');
7880 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] =
dol_print_date($object->array_options[
'options_'.$key],
'day',
'tzserver', $outputlangs);
7881 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] =
dol_print_date($object->array_options[
'options_'.$key],
'dayrfc');
7882 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'datetime') {
7883 $datetime = $object->array_options[
'options_'.$key];
7884 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
7885 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
7886 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_DAY_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'day',
'tzserver', $outputlangs) :
'');
7887 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
7888 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'phone') {
7889 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_phone($object->array_options[
'options_'.$key]);
7890 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'price') {
7891 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = $object->array_options[
'options_'.$key];
7892 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATED__'] =
price($object->array_options[
'options_'.$key]);
7901 if (empty($substitutionarray[
'__REF__'])) {
7905 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
7906 $outputlangs->loadLangs(array(
'paypal',
'other'));
7907 $typeforonlinepayment =
'free';
7908 if (is_object($object) && $object->element ==
'commande') {
7909 $typeforonlinepayment =
'order';
7911 if (is_object($object) && $object->element ==
'facture') {
7912 $typeforonlinepayment =
'invoice';
7914 if (is_object($object) && $object->element ==
'member') {
7915 $typeforonlinepayment =
'member';
7917 if (is_object($object) && $object->element ==
'contrat') {
7918 $typeforonlinepayment =
'contract';
7920 if (is_object($object) && $object->element ==
'fichinter') {
7921 $typeforonlinepayment =
'ficheinter';
7923 $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray[
'__REF__']);
7927 if ($object->id > 0) {
7928 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ?str_replace(
'\n',
"\n", $outputlangs->trans(
"PredefinedMailContentLink", $paymenturl)) :
'');
7929 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] = $paymenturl;
7931 if (is_object($object) && $object->element ==
'propal') {
7932 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
7933 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'proposal', $object->ref);
7935 if (is_object($object) && $object->element ==
'fichinter') {
7936 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
7937 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0,
'fichinter', $object->ref);
7939 if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'propal') {
7940 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
7942 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'';
7944 if (!empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'commande') {
7945 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element);
7947 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'';
7949 if (!empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'facture') {
7950 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element);
7952 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'';
7954 if (!empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'contrat') {
7955 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] = $object->getLastMainDocLink($object->element);
7957 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'';
7959 if (!empty($conf->global->FICHINTER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'fichinter') {
7960 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] = $object->getLastMainDocLink($object->element);
7962 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] =
'';
7964 if (!empty($conf->global->SUPPLIER_PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'supplier_proposal') {
7965 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
7967 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'';
7970 if (is_object($object) && $object->element ==
'propal') {
7971 $substitutionarray[
'__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/comm/propal/card.php?id=".$object->id;
7973 if (is_object($object) && $object->element ==
'commande') {
7974 $substitutionarray[
'__URL_ORDER__'] = DOL_MAIN_URL_ROOT.
"/commande/card.php?id=".$object->id;
7976 if (is_object($object) && $object->element ==
'facture') {
7977 $substitutionarray[
'__URL_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/compta/facture/card.php?id=".$object->id;
7979 if (is_object($object) && $object->element ==
'contrat') {
7980 $substitutionarray[
'__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT.
"/contrat/card.php?id=".$object->id;
7982 if (is_object($object) && $object->element ==
'fichinter') {
7983 $substitutionarray[
'__URL_FICHINTER__'] = DOL_MAIN_URL_ROOT.
"/fichinter/card.php?id=".$object->id;
7985 if (is_object($object) && $object->element ==
'supplier_proposal') {
7986 $substitutionarray[
'__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/supplier_proposal/card.php?id=".$object->id;
7988 if (is_object($object) && $object->element ==
'shipping') {
7989 $substitutionarray[
'__URL_SHIPMENT__'] = DOL_MAIN_URL_ROOT.
"/expedition/card.php?id=".$object->id;
7993 if (is_object($object) && $object->element ==
'action') {
7994 $substitutionarray[
'__EVENT_LABEL__'] = $object->label;
7995 $substitutionarray[
'__EVENT_DATE__'] =
dol_print_date($object->datep,
'%A %d %b %Y');
7996 $substitutionarray[
'__EVENT_TIME__'] =
dol_print_date($object->datep,
'%H:%M:%S');
8000 if (empty($exclude) || !in_array(
'objectamount', $exclude)) {
8001 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functionsnumtoword.lib.php';
8003 $substitutionarray[
'__DATE_YMD__'] = is_object($object) ? (isset($object->date) ?
dol_print_date($object->date,
'day', 0, $outputlangs) :
null) :
'';
8004 $substitutionarray[
'__DATE_DUE_YMD__'] = is_object($object) ? (isset($object->date_lim_reglement) ?
dol_print_date($object->date_lim_reglement,
'day', 0, $outputlangs) :
null) :
'';
8006 $already_payed_all = 0;
8007 if (is_object($object) && ($object instanceof
Facture)) {
8008 $already_payed_all = $object->sumpayed + $object->sumdeposit + $object->sumcreditnote;
8011 $substitutionarray[
'__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht :
'';
8013 $substitutionarray[
'__AMOUNT__'] = is_object($object) ? $object->total_ttc :
'';
8014 $substitutionarray[
'__AMOUNT_TEXT__'] = is_object($object) ?
dol_convertToWord($object->total_ttc, $outputlangs,
'',
true) :
'';
8015 $substitutionarray[
'__AMOUNT_TEXTCURRENCY__'] = is_object($object) ?
dol_convertToWord($object->total_ttc, $outputlangs, $conf->currency,
true) :
'';
8017 $substitutionarray[
'__AMOUNT_REMAIN__'] = is_object($object) ? $object->total_ttc - $already_payed_all :
'';
8019 $substitutionarray[
'__AMOUNT_VAT__'] = is_object($object) ? (isset($object->total_vat) ? $object->total_vat : $object->total_tva) :
'';
8020 $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)) :
'';
8021 $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)) :
'';
8023 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
8024 $substitutionarray[
'__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 :
'';
8026 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
8027 $substitutionarray[
'__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 :
'';
8031 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object) ? ($object->total_ht ?
price($object->total_ht, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8032 $substitutionarray[
'__AMOUNT_FORMATED__'] = is_object($object) ? ($object->total_ttc ?
price($object->total_ttc, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8033 $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) :
'';
8034 $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)) :
'';
8035 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
8036 $substitutionarray[
'__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? ($object->total_localtax1 ?
price($object->total_localtax1, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8038 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
8039 $substitutionarray[
'__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? ($object->total_localtax2 ?
price($object->total_localtax2, 0, $outputlangs, 0, -1, -1, $conf->currency) :
null) :
'';
8042 $substitutionarray[
'__AMOUNT_MULTICURRENCY__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ? $object->multicurrency_total_ttc :
'';
8043 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXT__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ?
dol_convertToWord($object->multicurrency_total_ttc, $outputlangs,
'',
true) :
'';
8044 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXTCURRENCY__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ?
dol_convertToWord($object->multicurrency_total_ttc, $outputlangs, $object->multicurrency_code,
true) :
'';
8048 if ($onlykey != 2) {
8049 $substitutionarray[
'__TOTAL_TTC__'] = is_object($object) ? $object->total_ttc :
'';
8050 $substitutionarray[
'__TOTAL_HT__'] = is_object($object) ? $object->total_ht :
'';
8051 $substitutionarray[
'__TOTAL_VAT__'] = is_object($object) ? (isset($object->total_vat) ? $object->total_vat : $object->total_tva) :
'';
8056 if (empty($exclude) || !in_array(
'date', $exclude)) {
8057 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
8067 $daytext = $outputlangs->trans(
'Day'.$tmp[
'wday']);
8069 $substitutionarray = array_merge($substitutionarray, array(
8070 '__NOW_TMS__' => (
int) $now,
8071 '__NOW_TMS_YMD__' =>
dol_print_date($now,
'day', 0, $outputlangs),
8072 '__DAY__' => (
string) $tmp[
'mday'],
8073 '__DAY_TEXT__' => $daytext,
8074 '__DAY_TEXT_SHORT__' =>
dol_trunc($daytext, 3,
'right',
'UTF-8', 1),
8075 '__DAY_TEXT_MIN__' =>
dol_trunc($daytext, 1,
'right',
'UTF-8', 1),
8076 '__MONTH__' => (
string) $tmp[
'mon'],
8077 '__MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp[
'mon'])),
8078 '__MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp[
'mon'])),
8079 '__MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp[
'mon'])),
8080 '__YEAR__' => (
string) $tmp[
'year'],
8081 '__PREVIOUS_DAY__' => (
string) $tmp2[
'day'],
8082 '__PREVIOUS_MONTH__' => (
string) $tmp3[
'month'],
8083 '__PREVIOUS_YEAR__' => (
string) ($tmp[
'year'] - 1),
8084 '__NEXT_DAY__' => (
string) $tmp4[
'day'],
8085 '__NEXT_MONTH__' => (
string) $tmp5[
'month'],
8086 '__NEXT_YEAR__' => (
string) ($tmp[
'year'] + 1),
8091 $substitutionarray = array_merge($substitutionarray, array(
'__ENTITY_ID__' => $conf->entity));
8093 if (empty($exclude) || !in_array(
'system', $exclude)) {
8094 $substitutionarray[
'__DOL_MAIN_URL_ROOT__'] = DOL_MAIN_URL_ROOT;
8095 $substitutionarray[
'__(AnyTranslationKey)__'] = $outputlangs->trans(
'TranslationOfKey');
8096 $substitutionarray[
'__(AnyTranslationKey|langfile)__'] = $outputlangs->trans(
'TranslationOfKey').
' (load also language file before)';
8097 $substitutionarray[
'__[AnyConstantKey]__'] = $outputlangs->trans(
'ValueOfConstantKey');
8100 return $substitutionarray;
8119 function make_substitutions($text, $substitutionarray, $outputlangs =
null, $converttextinhtmlifnecessary = 0)
8121 global $conf, $langs;
8123 if (!is_array($substitutionarray)) {
8124 return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
8127 if (empty($outputlangs)) {
8128 $outputlangs = $langs;
8138 if (is_object($outputlangs)) {
8140 while (preg_match(
'/__\(([^\)]+)\)__/', $text, $reg)) {
8142 $tmp = explode(
'|', $reg[1]);
8143 if (!empty($tmp[1])) {
8144 $outputlangs->load($tmp[1]);
8147 $value = $outputlangs->transnoentitiesnoconv($reg[1]);
8149 if (empty($converttextinhtmlifnecessary)) {
8151 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
8165 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $value, $text);
8173 while (preg_match(
'/__\[([^\]]+)\]__/', $text, $reg)) {
8174 $keyfound = $reg[1];
8176 $value =
'*****forbidden*****';
8178 $value = empty($conf->global->$keyfound) ?
'' : $conf->global->$keyfound;
8181 if (empty($converttextinhtmlifnecessary)) {
8183 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
8196 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $value, $text);
8201 foreach ($substitutionarray as $key => $value) {
8202 if (!isset($value)) {
8206 if (($key ==
'__USER_SIGNATURE__' || $key ==
'__SENDEREMAIL_SIGNATURE__') && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) {
8210 if (empty($converttextinhtmlifnecessary)) {
8211 $text = str_replace(
"$key",
"$value", $text);
8223 $text = str_replace(
"$key",
"$value", $text);
8244 global $conf, $user;
8246 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
8251 $dirsubstitutions = array_merge(array(), (array) $conf->modules_parts[
'substitutions']);
8253 foreach ($dirsubstitutions as $reldir) {
8261 $substitfiles =
dol_dir_list($dir,
'files', 0,
'functions_');
8262 foreach ($substitfiles as $substitfile) {
8264 if (preg_match(
'/functions_(.*)\.lib\.php/i', $substitfile[
'name'], $reg)) {
8267 dol_syslog(
"Library ".$substitfile[
'name'].
" found into ".$dir);
8269 require_once $dir.$substitfile[
'name'];
8271 $function_name = $module.
"_".$callfunc;
8272 if (function_exists($function_name)) {
8273 $function_name($substitutionarray, $outputlangs, $object, $parameters);
8278 if (!empty($conf->global->ODT_ENABLE_ALL_TAGS_IN_SUBSTITUTIONS)) {
8281 foreach ($substitutionarray as $key => $value) {
8282 $tags .=
'{'.$key.
'} => '.$value.
"\n";
8284 $substitutionarray = array_merge($substitutionarray, array(
'__ALL_TAGS__' => $tags));
8299 print
get_date_range($date_start, $date_end, $format, $outputlangs);
8312 function get_date_range($date_start, $date_end, $format =
'', $outputlangs =
'', $withparenthesis = 1)
8318 if (!is_object($outputlangs)) {
8319 $outputlangs = $langs;
8322 if ($date_start && $date_end) {
8323 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFromTo',
dol_print_date($date_start, $format,
false, $outputlangs),
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
8325 if ($date_start && !$date_end) {
8326 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($date_start, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
8328 if (!$date_start && $date_end) {
8329 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
8349 if ($nameorder < 0) {
8350 $nameorder = (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0);
8352 if ($nameorder == 1) {
8354 if ($firstname && $lastname) {
8358 } elseif ($nameorder == 2 || $nameorder == 3) {
8360 if (empty($ret) && $nameorder == 3) {
8365 if (empty($ret) && $nameorder == 5) {
8368 if ($nameorder == 0) {
8369 if ($firstname && $lastname) {
8392 if (!is_array($mesgs)) {
8395 $_SESSION[
'dol_events'][$style][] = $mesgs;
8399 foreach ($mesgs as $mesg) {
8401 $_SESSION[
'dol_events'][$style][] = $mesg;
8420 if (empty($mesg) && empty($mesgs)) {
8421 dol_syslog(
"Try to add a message in stack with empty message", LOG_WARNING);
8428 if (empty($messagekey) || empty($_COOKIE[
"DOLHIDEMESSAGE".$messagekey])) {
8429 if (!in_array((
string) $style, array(
'mesgs',
'warnings',
'errors'))) {
8430 dol_print_error(
'',
'Bad parameter style='.$style.
' for setEventMessages');
8432 if (empty($mesgs)) {
8435 if (!empty($mesg) && !in_array($mesg, $mesgs)) {
8456 if (isset($_SESSION[
'dol_events'][
'mesgs'])) {
8457 if (empty($disabledoutputofmessages)) {
8460 unset($_SESSION[
'dol_events'][
'mesgs']);
8463 if (isset($_SESSION[
'dol_events'][
'errors'])) {
8464 if (empty($disabledoutputofmessages)) {
8467 unset($_SESSION[
'dol_events'][
'errors']);
8471 if (isset($_SESSION[
'dol_events'][
'warnings'])) {
8472 if (empty($disabledoutputofmessages)) {
8475 unset($_SESSION[
'dol_events'][
'warnings']);
8495 global $conf, $langs;
8500 $divstart = $divend =
'';
8503 if ((empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && !preg_match(
'/<div class=".*">/i', $out)) {
8504 $divstart =
'<div class="'.$style.
' clearboth">';
8508 if ((is_array($mesgarray) && count($mesgarray)) || $mesgstring) {
8509 $langs->load(
"errors");
8511 if (is_array($mesgarray) && count($mesgarray)) {
8512 foreach ($mesgarray as $message) {
8514 $out .= $langs->trans($message);
8515 if ($ret < count($mesgarray)) {
8522 $out .= $langs->trans($mesgstring);
8528 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && empty($keepembedded)) {
8530 $(document).ready(function() {
8531 var block = '.(!empty($conf->global->MAIN_USE_JQUERY_BLOCKUI) ?
"true" :
"false").
'
8535 /* jnotify(message, preset of message type, keepmessage) */
8537 "'.($style ==
"ok" ? 3000 : $style).
'",
8538 '.($style ==
"ok" ?
"false" :
"true").
',
8539 { remove: function (){} } );
8582 if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) {
8588 if (is_array($mesgarray)) {
8589 foreach ($mesgarray as $val) {
8590 if ($val && preg_match(
'/class="error"/i', $val)) {
8594 if ($val && preg_match(
'/class="warning"/i', $val)) {
8599 } elseif ($mesgstring && preg_match(
'/class="error"/i', $mesgstring)) {
8601 } elseif ($mesgstring && preg_match(
'/class="warning"/i', $mesgstring)) {
8604 if ($style ==
'error') {
8607 if ($style ==
'warning') {
8611 if ($iserror || $iswarning) {
8613 $mesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $mesgstring);
8614 $mesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $mesgstring);
8615 $mesgstring = preg_replace(
'/<\/div>/',
'', $mesgstring);
8617 if (is_array($mesgarray)) {
8618 $newmesgarray = array();
8619 foreach ($mesgarray as $val) {
8620 if (is_string($val)) {
8621 $tmpmesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $val);
8622 $tmpmesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $tmpmesgstring);
8623 $tmpmesgstring = preg_replace(
'/<\/div>/',
'', $tmpmesgstring);
8624 $newmesgarray[] = $tmpmesgstring;
8626 dol_syslog(
"Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING);
8629 $mesgarray = $newmesgarray;
8631 print
get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ?
'error' :
'warning'), $keepembedded);
8667 function dol_sort_array(&$array, $index, $order =
'asc', $natsort = 0, $case_sensitive = 0, $keepindex = 0)
8670 $order = strtolower($order);
8672 if (is_array($array)) {
8673 $sizearray = count($array);
8674 if ($sizearray > 0) {
8676 foreach (array_keys($array) as $key) {
8677 if (is_object($array[$key])) {
8678 $temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index;
8680 $temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index];
8682 if ($natsort == -1) {
8683 $temp[$key] =
'___'.$temp[$key];
8687 if (empty($natsort) || $natsort == -1) {
8688 if ($order ==
'asc') {
8694 if ($case_sensitive) {
8699 if ($order !=
'asc') {
8700 $temp = array_reverse($temp,
true);
8706 foreach (array_keys($temp) as $key) {
8707 (is_numeric($key) && empty($keepindex)) ? $sorted[] = $array[$key] : $sorted[$key] = $array[$key];
8725 $str = (string) $str;
8729 for ($i = 0; $i < $strLength; $i++) {
8730 if (ord($str[$i]) < 0x80) {
8732 } elseif ((ord($str[$i]) & 0xE0) == 0xC0) {
8734 } elseif ((ord($str[$i]) & 0xF0) == 0xE0) {
8736 } elseif ((ord($str[$i]) & 0xF8) == 0xF0) {
8738 } elseif ((ord($str[$i]) & 0xFC) == 0xF8) {
8740 } elseif ((ord($str[$i]) & 0xFE) == 0xFC) {
8745 for ($j = 0; $j < $n; $j++) {
8746 if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) {
8762 if (function_exists(
'mb_check_encoding')) {
8764 if (!mb_check_encoding($str,
'ASCII')) {
8768 if (preg_match(
'/[^\x00-\x7f]/', $str)) {
8788 $tmp = ini_get(
"unicode.filesystem_encoding");
8789 if (empty($tmp) && !empty($_SERVER[
"WINDIR"])) {
8790 $tmp =
'iso-8859-1';
8795 if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING)) {
8796 $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING;
8799 if ($tmp ==
'iso-8859-1') {
8800 return utf8_decode($str);
8820 function dol_getIdFromCode($db, $key, $tablename, $fieldkey =
'code', $fieldid =
'id', $entityfilter = 0, $filters =
'')
8822 global $cache_codes;
8830 if (isset($cache_codes[$tablename][$key][$fieldid])) {
8831 return $cache_codes[$tablename][$key][$fieldid];
8834 dol_syslog(
'dol_getIdFromCode (value for field '.$fieldid.
' from key '.$key.
' not found into cache)', LOG_DEBUG);
8836 $sql =
"SELECT ".$fieldid.
" as valuetoget";
8837 $sql .=
" FROM ".MAIN_DB_PREFIX.$tablename;
8838 $sql .=
" WHERE ".$fieldkey.
" = '".$db->escape($key).
"'";
8839 if (!empty($entityfilter)) {
8840 $sql .=
" AND entity IN (".getEntity($tablename).
")";
8846 $resql = $db->query($sql);
8848 $obj = $db->fetch_object(
$resql);
8850 $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget;
8852 $cache_codes[$tablename][$key][$fieldid] =
'';
8855 return $cache_codes[$tablename][$key][$fieldid];
8869 global $user, $conf, $langs;
8875 if (isset($strToEvaluate) && $strToEvaluate !==
'') {
8877 $rep =
dol_eval($strToEvaluate, 1, 1,
'1');
8878 $rights = $rep && (!is_string($rep) || strpos($rep,
'Bad string syntax to evaluate') ===
false);
8894 function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring =
'1')
8897 global $db, $langs, $user, $conf, $website, $websitepage;
8898 global $action, $mainmenu, $leftmenu;
8907 if ($onlysimplestring ==
'1') {
8911 if (preg_match(
'/[^a-z0-9\s'.preg_quote(
'^$_+-.*>&|=!?():"\',/@',
'/').
']/i', $s)) {
8913 return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s;
8915 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s);
8922 } elseif ($onlysimplestring ==
'2') {
8924 if (preg_match(
'/[^a-z0-9\s'.preg_quote(
'^$_+-.*>&|=!?():"\',/@;[]',
'/').
']/i', $s)) {
8926 return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s;
8928 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s);
8933 if (strpos($s,
'::') !==
false) {
8935 return 'Bad string syntax to evaluate (double : char is forbidden): '.$s;
8937 dol_syslog(
'Bad string syntax to evaluate (double : char is forbidden): '.$s);
8941 if (strpos($s,
'`') !==
false) {
8943 return 'Bad string syntax to evaluate (backtick char is forbidden): '.$s;
8945 dol_syslog(
'Bad string syntax to evaluate (backtick char is forbidden): '.$s);
8949 if (preg_match(
'/[^0-9]+\.[^0-9]+/', $s)) {
8951 return 'Bad string syntax to evaluate (dot char is forbidden): '.$s;
8953 dol_syslog(
'Bad string syntax to evaluate (dot char is forbidden): '.$s);
8959 $forbiddenphpstrings = array(
'$$');
8960 $forbiddenphpstrings = array_merge($forbiddenphpstrings, array(
'_ENV',
'_SESSION',
'_COOKIE',
'_GET',
'_POST',
'_REQUEST'));
8962 $forbiddenphpfunctions = array(
"exec",
"passthru",
"shell_exec",
"system",
"proc_open",
"popen",
"eval",
"dol_eval",
"executeCLI",
"verifCond",
"base64_decode");
8963 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"fopen",
"file_put_contents",
"fputs",
"fputscsv",
"fwrite",
"fpassthru",
"require",
"include",
"mkdir",
"rmdir",
"symlink",
"touch",
"unlink",
"umask"));
8964 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"function",
"call_user_func"));
8966 $forbiddenphpregex =
'global\s+\$|\b('.implode(
'|', $forbiddenphpfunctions).
')\b';
8969 $oldstringtoclean = $s;
8970 $s = str_ireplace($forbiddenphpstrings,
'__forbiddenstring__', $s);
8971 $s = preg_replace(
'/'.$forbiddenphpregex.
'/i',
'__forbiddenstring__', $s);
8973 }
while ($oldstringtoclean != $s);
8975 if (strpos($s,
'__forbiddenstring__') !==
false) {
8976 dol_syslog(
'Bad string syntax to evaluate: '.$s, LOG_WARNING);
8978 return 'Bad string syntax to evaluate: '.$s;
8980 dol_syslog(
'Bad string syntax to evaluate: '.$s);
8988 return @eval(
'return '.$s.
';');
8990 return eval(
'return '.$s.
';');
9009 return (trim($element) !=
'');
9022 if (empty($codelang)) {
9026 if ($codelang ==
'auto') {
9027 return '<span class="fa fa-language"></span>';
9030 $langtocountryflag = array(
9032 'ca_ES' =>
'catalonia',
9036 'sw_SW' =>
'unknown',
9046 if (isset($langtocountryflag[$codelang])) {
9047 $flagImage = $langtocountryflag[$codelang];
9049 $tmparray = explode(
'_', $codelang);
9050 $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
9053 return img_picto_common($codelang,
'flags/'.strtolower($flagImage).
'.png', $moreatt, 0, $notitlealt);
9067 if (empty($countrycode)) {
9071 if (strtoupper($countrycode) ==
'MQ') {
9074 if (strtoupper($countrycode) ==
'SE') {
9077 if (strtoupper($countrycode) ==
'CH') {
9078 if ($mysoc->country_code ==
'FR') {
9081 if ($mysoc->country_code ==
'DE') {
9084 if ($mysoc->country_code ==
'IT') {
9266 $buildprimarykeytotest = strtolower($countrycode).
'-'.strtoupper($countrycode);
9267 if (in_array($buildprimarykeytotest, $locales)) {
9268 return strtolower($countrycode).
'_'.strtoupper($countrycode);
9271 if (function_exists(
'locale_get_primary_language') && function_exists(
'locale_get_region')) {
9272 foreach ($locales as $locale) {
9273 $locale_language = locale_get_primary_language($locale);
9274 $locale_region = locale_get_region($locale);
9275 if (strtoupper($countrycode) == $locale_region) {
9277 return strtolower($locale_language).
'_'.strtoupper($locale_region);
9281 dol_syslog(
"Warning Exention php-intl is not available", LOG_WARNING);
9319 global $hookmanager, $db;
9321 if (isset($conf->modules_parts[
'tabs'][$type]) && is_array($conf->modules_parts[
'tabs'][$type])) {
9322 foreach ($conf->modules_parts[
'tabs'][$type] as $value) {
9323 $values = explode(
':', $value);
9326 if ($mode ==
'add' && !preg_match(
'/^\-/', $values[1])) {
9327 if (count($values) == 6) {
9331 if ($values[0] != $type) {
9337 if ($filterorigmodule) {
9338 if (strpos($values[3],
'@')) {
9339 if ($filterorigmodule !=
'external') {
9343 if ($filterorigmodule !=
'core') {
9348 $langs->load($values[3]);
9350 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
9352 $substitutionarray = array();
9357 $labeltemp = explode(
',', $values[2]);
9358 $label = $langs->trans($labeltemp[0]);
9360 if (!empty($labeltemp[1]) && is_object($object) && !empty($object->id)) {
9362 $classtoload = $labeltemp[1];
9363 if (class_exists($classtoload)) {
9364 $obj =
new $classtoload($db);
9365 $function = $labeltemp[3];
9366 if ($obj && $function && method_exists($obj, $function)) {
9367 $nbrec = $obj->$function($object->id, $obj);
9368 $label .=
'<span class="badge marginleftonlyshort">'.$nbrec.
'</span>';
9374 $head[$h][0] =
dol_buildpath(preg_replace(
'/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id :
''), $values[5]), 1);
9375 $head[$h][1] = $label;
9376 $head[$h][2] = str_replace(
'+',
'', $values[1]);
9379 } elseif (count($values) == 5) {
9380 dol_syslog(
'Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
9382 if ($values[0] != $type) {
9386 if ($filterorigmodule) {
9387 if (strpos($values[3],
'@')) {
9388 if ($filterorigmodule !=
'external') {
9392 if ($filterorigmodule !=
'core') {
9397 $langs->load($values[3]);
9399 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
9400 $substitutionarray = array();
9404 $label = $langs->trans($values[2]);
9407 $head[$h][0] =
dol_buildpath(preg_replace(
'/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id :
''), $values[4]), 1);
9408 $head[$h][1] = $label;
9409 $head[$h][2] = str_replace(
'+',
'', $values[1]);
9412 } elseif ($mode ==
'remove' && preg_match(
'/^\-/', $values[1])) {
9413 if ($values[0] != $type) {
9416 $tabname = str_replace(
'-',
'', $values[1]);
9417 foreach ($head as $key => $val) {
9418 $condition = (!empty($values[3]) ?
verifCond($values[3]) : 1);
9420 if ($head[$key][2] == $tabname && $condition) {
9430 if (!empty($hookmanager)) {
9431 $parameters = array(
'object' => $object,
'mode' => $mode,
'head' => &$head,
'filterorigmodule' => $filterorigmodule);
9432 $reshook = $hookmanager->executeHooks(
'completeTabsHead', $parameters);
9434 $head = $hookmanager->resArray;
9436 $head = array_merge($head, $hookmanager->resArray);
9455 global $conf, $hookmanager, $user, $debugbar;
9457 global $micro_start_time;
9459 if ($zone ==
'private') {
9460 print
"\n".
'<!-- Common footer for private page -->'.
"\n";
9462 print
"\n".
'<!-- Common footer for public page -->'.
"\n";
9466 print
"\n<!-- A div to store page_y POST parameter -->\n";
9467 print
'<div id="page_y" style="display: none;">'.(GETPOST(
'page_y') ?
GETPOST(
'page_y') :
'').
'</div>'.
"\n";
9469 $parameters = array();
9470 $reshook = $hookmanager->executeHooks(
'printCommonFooter', $parameters);
9471 if (empty($reshook)) {
9472 if (!empty($conf->global->MAIN_HTML_FOOTER)) {
9473 print $conf->global->MAIN_HTML_FOOTER.
"\n";
9477 if (!empty($conf->use_javascript_ajax)) {
9478 print
"\n<!-- A script section to add menuhider handler on backoffice, manage focus and madatory fields, tuning info, ... -->\n";
9479 print
'<script>'.
"\n";
9480 print
'jQuery(document).ready(function() {'.
"\n";
9482 if ($zone ==
'private' && empty($conf->dol_use_jmobile)) {
9484 print
'/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'.
"\n";
9485 print
'jQuery("li.menuhider").click(function(event) {';
9486 print
' if (!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'.
"\n";
9487 print
' console.log("We click on .menuhider");'.
"\n";
9488 print
' $("body").toggleClass("sidebar-collapse")'.
"\n";
9493 if ($action ==
'create' || $action ==
'edit' || (empty($action) && (preg_match(
'/new\.php/', $_SERVER[
"PHP_SELF"])))) {
9494 print
'/* JS CODE TO ENABLE to manage focus and mandatory form fields */'.
"\n";
9495 $relativepathstring = $_SERVER[
"PHP_SELF"];
9497 if (constant(
'DOL_URL_ROOT')) {
9498 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
9500 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
9501 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
9503 if (!empty($user->default_values[$relativepathstring][
'focus'])) {
9504 foreach ($user->default_values[$relativepathstring][
'focus'] as $defkey => $defval) {
9506 if ($defkey !=
'_noquery_') {
9507 $tmpqueryarraytohave = explode(
'&', $defkey);
9509 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
9510 $tmpquerytohaveparam = explode(
'=', $tmpquerytohave);
9512 if (!
GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] !=
GETPOST($tmpquerytohaveparam[0]))) {
9525 foreach ($defval as $paramkey => $paramval) {
9527 print
'jQuery("input[name=\''.$paramkey.
'\']
").focus();'."\n
";
9528 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").focus();'."\n
";
9529 print 'jQuery("select[
name=\
''.$paramkey.
'\']
").focus();'."\n
"; // Not really usefull, but we keep it in case of.
9534 if (!empty($user->default_values[$relativepathstring]['mandatory'])) {
9535 foreach ($user->default_values[$relativepathstring]['mandatory'] as $defkey => $defval) {
9537 if ($defkey != '_noquery_') {
9538 $tmpqueryarraytohave = explode('&', $defkey);
9540 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
9541 $tmpquerytohaveparam = explode('=', $tmpquerytohave);
9542 //print "console.log(
'".$tmpquerytohaveparam[0]." ".$tmpquerytohaveparam[1]." ".GETPOST($tmpquerytohaveparam[0])."');
";
9543 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] != GETPOST($tmpquerytohaveparam[0]))) {
9550 //var_dump($defkey.'-'.$qualified);
9556 foreach ($defval as $paramkey => $paramval) {
9557 // Add property 'required' on input
9558 print 'jQuery("input[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
9559 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
9560 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
";
9561 print 'jQuery("select[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
9562 print 'jQuery("select[
name=\
''.$paramkey.
'\'] option[value=\
'-1\']").prop(\'value\', \'\');'.
"\n";
9563 print
'jQuery("select[name=\''.$paramkey.
'\'] option[value=\
'0\']").prop(\'value\', \'\');'.
"\n";
9566 print
'jQuery(":input[name=\'' . $paramkey .
'\']
").closest("tr
").find("td:first
").addClass("fieldrequired
");' . "\n
";
9576 if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO']) || !empty($conf->global->MAIN_SHOW_TUNING_INFO)) {
9579 print 'window.console && console.log("';
9580 if (!empty($conf->global->MEMCACHED_SERVER)) {
9581 print 'MEMCACHED_SERVER=
'.$conf->global->MEMCACHED_SERVER.' -
';
9583 print 'MAIN_OPTIMIZE_SPEED=
'.(isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off
');
9584 if (!empty($micro_start_time)) { // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable.
9585 $micro_end_time = microtime(true);
9586 print ' - Build time:
'.ceil(1000 * ($micro_end_time - $micro_start_time)).' ms
';
9589 if (function_exists("memory_get_usage")) {
9590 print ' - Mem:
'.memory_get_usage(); // Do not use true here, it seems it takes the peak amount
9592 if (function_exists("memory_get_peak_usage")) {
9593 print ' - Real mem peak:
'.memory_get_peak_usage(true);
9595 if (function_exists("zend_loader_file_encoded")) {
9596 print ' - Zend encoded file:
'.(zend_loader_file_encoded() ? 'yes
' : 'no
');
9601 print "\n
".'</script>'."\n
";
9604 // TODO Add a hook here
9605 if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) {
9606 $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID);
9607 foreach ($tmptagarray as $tmptag) {
9609 print "<!-- JS CODE TO ENABLE
for google analtics tag -->\n
";
9611 <!-- Global site tag (gtag.js) - Google Analytics -->
9612 <script async src=\
"https://www.googletagmanager.com/gtag/js?id=".trim($tmptag).
"\"></script>
9614 window.dataLayer = window.dataLayer || [];
9615 function gtag(){dataLayer.push(arguments);}
9616 gtag('js', new Date());
9618 gtag('config', '".trim($tmptag).
"');
9626 if (defined(
'XDEBUGCOVERAGE')) {
9627 print_r(xdebug_get_code_coverage());
9631 if (!empty($user->rights->debugbar->read) && is_object($debugbar)) {
9632 $debugbar[
'time']->stopMeasure(
'pageaftermaster');
9633 print
'<!-- Output debugbar data -->'.
"\n";
9634 $renderer = $debugbar->getRenderer();
9635 print $debugbar->getRenderer()->render();
9636 } elseif (count($conf->logbuffer)) {
9638 print
"<!-- Start of log output\n";
9640 foreach ($conf->logbuffer as $logline) {
9641 print $logline.
"<br>\n";
9644 print
"End of log output -->\n";
9660 if ($a = explode($delimiter, $string)) {
9662 foreach ($a as $s) {
9664 if ($pos = strpos($s, $kv)) {
9665 $ka[trim(substr($s, 0, $pos))] = trim(substr($s, $pos + strlen($kv)));
9685 print
"\n".
'<!-- Set focus onto a specific field -->'.
"\n";
9686 print
'<script>jQuery(document).ready(function() { jQuery("'.dol_escape_js($selector).
'").focus(); });</script>'.
"\n";
9699 if (!function_exists(
'getmypid')) {
9700 return mt_rand(99900000, 99965535);
9728 $value = trim($value);
9731 $value = preg_replace(
'/\*/',
'%', $value);
9734 $value = preg_replace(
'/([<>=]+)\s+([0-9'.preg_quote($langs->trans(
"DecimalSeparator"),
'/').
'\-])/',
'\1\2', $value);
9737 $value = preg_replace(
'/\s*\|\s*/',
'|', $value);
9739 $crits = explode(
' ', $value);
9741 if (!is_array($fields)) {
9742 $fields = array($fields);
9746 foreach ($crits as $crit) {
9747 $crit = trim($crit);
9751 foreach ($fields as $field) {
9754 $newcrit = preg_replace(
'/([<>=]+)/',
'', $crit);
9757 preg_match(
'/([<>=]+)/', $crit, $reg);
9758 if (!empty($reg[1])) {
9759 $operator = $reg[1];
9761 if ($newcrit !=
'') {
9763 if (is_numeric($numnewcrit)) {
9764 $newres .= ($i2 > 0 ?
' OR ' :
'').$field.
' '.$operator.
' '.((
float) $numnewcrit);
9766 $newres .= ($i2 > 0 ?
' OR ' :
'').
'1 = 2';
9770 } elseif ($mode == 2 || $mode == -2) {
9771 $crit = preg_replace(
'/[^0-9,]/',
'', $crit);
9772 $newres .= ($i2 > 0 ?
' OR ' :
'').$field.
" ".($mode == -2 ?
'NOT ' :
'');
9773 $newres .= $crit ?
"IN (".$db->sanitize($db->escape($crit)).
")" :
"IN (0)";
9775 $newres .=
' OR '.$field.
' IS NULL';
9778 } elseif ($mode == 3 || $mode == -3) {
9779 $tmparray = explode(
',', $crit);
9780 if (count($tmparray)) {
9782 foreach ($tmparray as $val) {
9785 $listofcodes .= ($listofcodes ?
',' :
'');
9786 $listofcodes .=
"'".$db->escape($val).
"'";
9789 $newres .= ($i2 > 0 ?
' OR ' :
'').$field.
" ".($mode == -3 ?
'NOT ' :
'').
"IN (".$db->sanitize($listofcodes, 1).
")";
9793 $newres .=
' OR '.$field.
' IS NULL';
9795 } elseif ($mode == 4) {
9796 $tmparray = explode(
',', $crit);
9797 if (count($tmparray)) {
9799 foreach ($tmparray as $val) {
9802 $newres .= ($i2 > 0 ?
" OR (" :
"(").$field.
" LIKE '".$db->escape($val).
",%'";
9803 $newres .=
' OR '.$field.
" = '".$db->escape($val).
"'";
9804 $newres .=
' OR '.$field.
" LIKE '%,".$db->escape($val).
"'";
9805 $newres .=
' OR '.$field.
" LIKE '%,".$db->escape($val).
",%'";
9813 $tmpcrits = explode(
'|', $crit);
9815 foreach ($tmpcrits as $tmpcrit) {
9816 if ($tmpcrit !==
'0' && empty($tmpcrit)) {
9820 $newres .= (($i2 > 0 || $i3 > 0) ?
' OR ' :
'');
9822 if (preg_match(
'/\.(id|rowid)$/', $field)) {
9823 $newres .= $field.
" = ".(is_numeric(trim($tmpcrit)) ? ((
float) trim($tmpcrit)) :
'0');
9825 $tmpcrit = trim($tmpcrit);
9826 $tmpcrit2 = $tmpcrit;
9829 if (preg_match(
'/^!/', $tmpcrit)) {
9830 $newres .= $field.
" NOT LIKE '";
9831 $tmpcrit2 = preg_replace(
'/^!/',
'', $tmpcrit2);
9832 }
else $newres .= $field.
" LIKE '";
9834 if (preg_match(
'/^[\^\$]/', $tmpcrit)) {
9836 $tmpcrit2 = preg_replace(
'/^[\^\$]/',
'', $tmpcrit2);
9838 if (preg_match(
'/[\^\$]$/', $tmpcrit)) {
9840 $tmpcrit2 = preg_replace(
'/[\^\$]$/',
'', $tmpcrit2);
9842 $newres .= $tmpbefore;
9843 $newres .= $db->escape($tmpcrit2);
9844 $newres .= $tmpafter;
9846 if ($tmpcrit2 ==
'') {
9847 $newres .=
" OR ".$field.
" IS NULL";
9858 $res = $res.($res ?
' AND ' :
'').($i2 > 1 ?
'(' :
'').$newres.($i2 > 1 ?
')' :
'');
9862 $res = ($nofirstand ?
"" :
" AND ").
"(".$res.
")";
9875 global $conf, $langs;
9878 $url = $object->getLastMainDocLink($object->element);
9880 $out .=
img_picto($langs->trans(
"PublicDownloadLinkDesc"),
'globe').
' <span class="opacitymedium">'.$langs->trans(
"DirectDownloadLink").
'</span><br>';
9882 $out .=
'<div class="urllink"><input type="text" id="directdownloadlink" class="quatrevingtpercent" value="'.$url.
'"></div>';
9885 $out .=
'<div class="urllink">'.$langs->trans(
"FileNotShared").
'</div>';
9901 $dirName = dirname($file);
9902 if ($dirName ==
'.') {
9906 $fileName = preg_replace(
'/(\.gif|\.jpeg|\.jpg|\.png|\.bmp|\.webp)$/i',
'', $file);
9907 $fileName = basename($fileName);
9909 if (empty($extImgTarget)) {
9910 $extImgTarget = (preg_match(
'/\.jpg$/i', $file) ?
'.jpg' :
'');
9912 if (empty($extImgTarget)) {
9913 $extImgTarget = (preg_match(
'/\.jpeg$/i', $file) ?
'.jpeg' :
'');
9915 if (empty($extImgTarget)) {
9916 $extImgTarget = (preg_match(
'/\.gif$/i', $file) ?
'.gif' :
'');
9918 if (empty($extImgTarget)) {
9919 $extImgTarget = (preg_match(
'/\.png$/i', $file) ?
'.png' :
'');
9921 if (empty($extImgTarget)) {
9922 $extImgTarget = (preg_match(
'/\.bmp$/i', $file) ?
'.bmp' :
'');
9924 if (empty($extImgTarget)) {
9925 $extImgTarget = (preg_match(
'/\.webp$/i', $file) ?
'.webp' :
'');
9928 if (!$extImgTarget) {
9934 $subdir =
'thumbs/';
9937 return ($dirName ? $dirName.
'/' :
'').$subdir.$fileName.$extName.$extImgTarget;
9952 global $conf, $langs;
9954 if (empty($conf->use_javascript_ajax)) {
9960 if ($alldata == 1) {
9961 if ($isAllowedForPreview) {
9962 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));
9969 if ($isAllowedForPreview) {
9970 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')).
'\')
';
9985 function ajax_autoselect($htmlname, $addlink = '', $textonlink = 'Link')
9989 jQuery(document).ready(
function () {
9990 jQuery(
"'.((strpos($htmlname, '.') === 0 ? '' : '#').$htmlname).'").click(
function() { jQuery(
this).select(); } );
9994 if ($textonlink === 'image
') {
9995 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.img_picto('', 'globe
').'</a>
';
9997 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.$langs->trans("Link").'</a>
';
10010 function dolIsAllowedForPreview($file)
10014 // Check .noexe extension in filename
10015 if (preg_match('/\.noexe$/i
', $file)) {
10019 // Check mime types
10020 $mime_preview = array('bmp
', 'jpeg
', 'png
', 'gif
', 'tiff
', 'pdf
', 'plain
', 'css
', 'webp
');
10021 if (!empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) {
10022 $mime_preview[] = 'svg+xml
';
10024 //$mime_preview[]='vnd.oasis.opendocument.presentation
';
10025 //$mime_preview[]='archive
';
10026 $num_mime = array_search(dol_mimetype($file, '', 1), $mime_preview);
10027 if ($num_mime !== false) {
10031 // By default, not allowed for preview
10045 function dol_mimetype($file, $default = 'application/octet-stream
', $mode = 0)
10048 $imgmime = 'other.png
';
10049 $famime = 'file-o
';
10052 $tmpfile = preg_replace('/\.noexe$/
', '', $file);
10054 // Plain text files
10055 if (preg_match('/\.txt$/i
', $tmpfile)) {
10056 $mime = 'text/plain
';
10057 $imgmime = 'text.png
';
10058 $famime = 'file-text-o
';
10060 if (preg_match('/\.rtx$/i
', $tmpfile)) {
10061 $mime = 'text/richtext
';
10062 $imgmime = 'text.png
';
10063 $famime = 'file-text-o
';
10065 if (preg_match('/\.csv$/i
', $tmpfile)) {
10066 $mime = 'text/csv
';
10067 $imgmime = 'text.png
';
10068 $famime = 'file-text-o
';
10070 if (preg_match('/\.tsv$/i
', $tmpfile)) {
10071 $mime = 'text/tab-separated-values
';
10072 $imgmime = 'text.png
';
10073 $famime = 'file-text-o
';
10075 if (preg_match('/\.(cf|
conf|log)$/i
', $tmpfile)) {
10076 $mime = 'text/plain
';
10077 $imgmime = 'text.png
';
10078 $famime = 'file-text-o
';
10080 if (preg_match('/\.ini$/i
', $tmpfile)) {
10081 $mime = 'text/plain
';
10082 $imgmime = 'text.png
';
10084 $famime = 'file-text-o
';
10086 if (preg_match('/\.md$/i
', $tmpfile)) {
10087 $mime = 'text/plain
';
10088 $imgmime = 'text.png
';
10090 $famime = 'file-text-o
';
10092 if (preg_match('/\.css$/i
', $tmpfile)) {
10093 $mime = 'text/css
';
10094 $imgmime = 'css.png
';
10096 $famime = 'file-text-o
';
10098 if (preg_match('/\.lang$/i
', $tmpfile)) {
10099 $mime = 'text/plain
';
10100 $imgmime = 'text.png
';
10102 $famime = 'file-text-o
';
10104 // Certificate files
10105 if (preg_match('/\.(crt|cer|key|pub)$/i
', $tmpfile)) {
10106 $mime = 'text/plain
';
10107 $imgmime = 'text.png
';
10108 $famime = 'file-text-o
';
10110 // XML based (HTML/XML/XAML)
10111 if (preg_match('/\.(html|htm|shtml)$/i
', $tmpfile)) {
10112 $mime = 'text/html
';
10113 $imgmime = 'html.png
';
10115 $famime = 'file-text-o
';
10117 if (preg_match('/\.(xml|xhtml)$/i
', $tmpfile)) {
10118 $mime = 'text/xml
';
10119 $imgmime = 'other.png
';
10121 $famime = 'file-text-o
';
10123 if (preg_match('/\.xaml$/i
', $tmpfile)) {
10124 $mime = 'text/xml
';
10125 $imgmime = 'other.png
';
10127 $famime = 'file-text-o
';
10130 if (preg_match('/\.bas$/i
', $tmpfile)) {
10131 $mime = 'text/plain
';
10132 $imgmime = 'text.png
';
10134 $famime = 'file-
code-o
';
10136 if (preg_match('/\.(c)$/i
', $tmpfile)) {
10137 $mime = 'text/plain
';
10138 $imgmime = 'text.png
';
10140 $famime = 'file-
code-o
';
10142 if (preg_match('/\.(cpp)$/i
', $tmpfile)) {
10143 $mime = 'text/plain
';
10144 $imgmime = 'text.png
';
10146 $famime = 'file-
code-o
';
10148 if (preg_match('/\.cs$/i
', $tmpfile)) {
10149 $mime = 'text/plain
';
10150 $imgmime = 'text.png
';
10152 $famime = 'file-
code-o
';
10154 if (preg_match('/\.(h)$/i
', $tmpfile)) {
10155 $mime = 'text/plain
';
10156 $imgmime = 'text.png
';
10158 $famime = 'file-
code-o
';
10160 if (preg_match('/\.(java|jsp)$/i
', $tmpfile)) {
10161 $mime = 'text/plain
';
10162 $imgmime = 'text.png
';
10164 $famime = 'file-
code-o
';
10166 if (preg_match('/\.php([0-9]{1})?$/i
', $tmpfile)) {
10167 $mime = 'text/plain
';
10168 $imgmime = 'php.png
';
10170 $famime = 'file-
code-o
';
10172 if (preg_match('/\.phtml$/i
', $tmpfile)) {
10173 $mime = 'text/plain
';
10174 $imgmime = 'php.png
';
10176 $famime = 'file-
code-o
';
10178 if (preg_match('/\.(pl|pm)$/i
', $tmpfile)) {
10179 $mime = 'text/plain
';
10180 $imgmime = 'pl.png
';
10182 $famime = 'file-
code-o
';
10184 if (preg_match('/\.sql$/i
', $tmpfile)) {
10185 $mime = 'text/plain
';
10186 $imgmime = 'text.png
';
10188 $famime = 'file-
code-o
';
10190 if (preg_match('/\.js$/i
', $tmpfile)) {
10191 $mime = 'text/x-javascript
';
10192 $imgmime = 'jscript.png
';
10194 $famime = 'file-
code-o
';
10197 if (preg_match('/\.odp$/i
', $tmpfile)) {
10198 $mime = 'application/vnd.oasis.opendocument.presentation
';
10199 $imgmime = 'ooffice.png
';
10200 $famime = 'file-powerpoint-o
';
10202 if (preg_match('/\.ods$/i
', $tmpfile)) {
10203 $mime = 'application/vnd.oasis.opendocument.spreadsheet
';
10204 $imgmime = 'ooffice.png
';
10205 $famime = 'file-excel-o
';
10207 if (preg_match('/\.odt$/i
', $tmpfile)) {
10208 $mime = 'application/vnd.oasis.opendocument.text
';
10209 $imgmime = 'ooffice.png
';
10210 $famime = 'file-word-o
';
10213 if (preg_match('/\.mdb$/i
', $tmpfile)) {
10214 $mime = 'application/msaccess
';
10215 $imgmime = 'mdb.png
';
10216 $famime = 'file-o
';
10218 if (preg_match('/\.doc[xm]?$/i
', $tmpfile)) {
10219 $mime = 'application/msword
';
10220 $imgmime = 'doc.png
';
10221 $famime = 'file-word-o
';
10223 if (preg_match('/\.dot[xm]?$/i
', $tmpfile)) {
10224 $mime = 'application/msword
';
10225 $imgmime = 'doc.png
';
10226 $famime = 'file-word-o
';
10228 if (preg_match('/\.xlt(x)?$/i
', $tmpfile)) {
10229 $mime = 'application/vnd.ms-excel
';
10230 $imgmime = 'xls.png
';
10231 $famime = 'file-excel-o
';
10233 if (preg_match('/\.xla(m)?$/i
', $tmpfile)) {
10234 $mime = 'application/vnd.ms-excel
';
10235 $imgmime = 'xls.png
';
10236 $famime = 'file-excel-o
';
10238 if (preg_match('/\.xls$/i
', $tmpfile)) {
10239 $mime = 'application/vnd.ms-excel
';
10240 $imgmime = 'xls.png
';
10241 $famime = 'file-excel-o
';
10243 if (preg_match('/\.xls[bmx]$/i
', $tmpfile)) {
10244 $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
';
10245 $imgmime = 'xls.png
';
10246 $famime = 'file-excel-o
';
10248 if (preg_match('/\.pps[mx]?$/i
', $tmpfile)) {
10249 $mime = 'application/vnd.ms-powerpoint
';
10250 $imgmime = 'ppt.png
';
10251 $famime = 'file-powerpoint-o
';
10253 if (preg_match('/\.ppt[mx]?$/i
', $tmpfile)) {
10254 $mime = 'application/x-mspowerpoint
';
10255 $imgmime = 'ppt.png
';
10256 $famime = 'file-powerpoint-o
';
10259 if (preg_match('/\.pdf$/i
', $tmpfile)) {
10260 $mime = 'application/pdf
';
10261 $imgmime = 'pdf.png
';
10262 $famime = 'file-pdf-o
';
10265 if (preg_match('/\.bat$/i
', $tmpfile)) {
10266 $mime = 'text/x-bat
';
10267 $imgmime = 'script.png
';
10269 $famime = 'file-
code-o
';
10271 if (preg_match('/\.sh$/i
', $tmpfile)) {
10272 $mime = 'text/x-sh
';
10273 $imgmime = 'script.png
';
10275 $famime = 'file-
code-o
';
10277 if (preg_match('/\.ksh$/i
', $tmpfile)) {
10278 $mime = 'text/x-ksh
';
10279 $imgmime = 'script.png
';
10281 $famime = 'file-
code-o
';
10283 if (preg_match('/\.bash$/i
', $tmpfile)) {
10284 $mime = 'text/x-bash
';
10285 $imgmime = 'script.png
';
10287 $famime = 'file-
code-o
';
10290 if (preg_match('/\.ico$/i
', $tmpfile)) {
10291 $mime = 'image/x-icon
';
10292 $imgmime = 'image.png
';
10293 $famime = 'file-image-o
';
10295 if (preg_match('/\.(jpg|jpeg)$/i
', $tmpfile)) {
10296 $mime = 'image/jpeg
';
10297 $imgmime = 'image.png
';
10298 $famime = 'file-image-o
';
10300 if (preg_match('/\.png$/i
', $tmpfile)) {
10301 $mime = 'image/png
';
10302 $imgmime = 'image.png
';
10303 $famime = 'file-image-o
';
10305 if (preg_match('/\.gif$/i
', $tmpfile)) {
10306 $mime = 'image/gif
';
10307 $imgmime = 'image.png
';
10308 $famime = 'file-image-o
';
10310 if (preg_match('/\.bmp$/i
', $tmpfile)) {
10311 $mime = 'image/bmp
';
10312 $imgmime = 'image.png
';
10313 $famime = 'file-image-o
';
10315 if (preg_match('/\.(tif|tiff)$/i
', $tmpfile)) {
10316 $mime = 'image/tiff
';
10317 $imgmime = 'image.png
';
10318 $famime = 'file-image-o
';
10320 if (preg_match('/\.svg$/i
', $tmpfile)) {
10321 $mime = 'image/svg+xml
';
10322 $imgmime = 'image.png
';
10323 $famime = 'file-image-o
';
10325 if (preg_match('/\.webp$/i
', $tmpfile)) {
10326 $mime = 'image/webp
';
10327 $imgmime = 'image.png
';
10328 $famime = 'file-image-o
';
10331 if (preg_match('/\.vcs$/i
', $tmpfile)) {
10332 $mime = 'text/calendar
';
10333 $imgmime = 'other.png
';
10334 $famime = 'file-text-o
';
10336 if (preg_match('/\.ics$/i
', $tmpfile)) {
10337 $mime = 'text/calendar
';
10338 $imgmime = 'other.png
';
10339 $famime = 'file-text-o
';
10342 if (preg_match('/\.torrent$/i
', $tmpfile)) {
10343 $mime = 'application/x-bittorrent
';
10344 $imgmime = 'other.png
';
10345 $famime = 'file-o
';
10348 if (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i
', $tmpfile)) {
10350 $imgmime = 'audio.png
';
10351 $famime = 'file-audio-o
';
10354 if (preg_match('/\.mp4$/i
', $tmpfile)) {
10355 $mime = 'video/mp4
';
10356 $imgmime = 'video.png
';
10357 $famime = 'file-video-o
';
10359 if (preg_match('/\.ogv$/i
', $tmpfile)) {
10360 $mime = 'video/ogg
';
10361 $imgmime = 'video.png
';
10362 $famime = 'file-video-o
';
10364 if (preg_match('/\.webm$/i
', $tmpfile)) {
10365 $mime = 'video/webm
';
10366 $imgmime = 'video.png
';
10367 $famime = 'file-video-o
';
10369 if (preg_match('/\.avi$/i
', $tmpfile)) {
10370 $mime = 'video/x-msvideo
';
10371 $imgmime = 'video.png
';
10372 $famime = 'file-video-o
';
10374 if (preg_match('/\.divx$/i
', $tmpfile)) {
10375 $mime = 'video/divx
';
10376 $imgmime = 'video.png
';
10377 $famime = 'file-video-o
';
10379 if (preg_match('/\.xvid$/i
', $tmpfile)) {
10380 $mime = 'video/xvid
';
10381 $imgmime = 'video.png
';
10382 $famime = 'file-video-o
';
10384 if (preg_match('/\.(wmv|mpg|mpeg)$/i
', $tmpfile)) {
10386 $imgmime = 'video.png
';
10387 $famime = 'file-video-o
';
10390 if (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh|zst)$/i
', $tmpfile)) {
10392 $imgmime = 'archive.png
';
10393 $famime = 'file-archive-o
';
10394 } // application/xxx where zzz is zip, ...
10396 if (preg_match('/\.(exe|com)$/i
', $tmpfile)) {
10397 $mime = 'application/octet-stream
';
10398 $imgmime = 'other.png
';
10399 $famime = 'file-o
';
10402 if (preg_match('/\.(dll|lib|o|so|a)$/i
', $tmpfile)) {
10404 $imgmime = 'library.png
';
10405 $famime = 'file-o
';
10408 if (preg_match('/\.err$/i
', $tmpfile)) {
10410 $imgmime = 'error.png
';
10411 $famime = 'file-text-o
';
10416 $tmp = explode('/
', $mime);
10417 return (!empty($tmp[1]) ? $tmp[1] : $tmp[0]);
10442 function getDictionaryValue($tablename, $field, $id, $checkentity = false, $rowidfield = 'rowid')
10446 $tablename = preg_replace('/^
'.preg_quote(MAIN_DB_PREFIX, '/
').'/
', '', $tablename); // Clean name of table for backward compatibility.
10448 $dictvalues = (isset($conf->cache['dictvalues_
'.$tablename]) ? $conf->cache['dictvalues_
'.$tablename] : null);
10450 if (is_null($dictvalues)) {
10451 $dictvalues = array();
10453 $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
10454 if ($checkentity) {
10455 $sql .=
' AND entity IN (0,'.getEntity($tablename).
')';
10458 $resql = $db->query($sql);
10460 while ($obj = $db->fetch_object(
$resql)) {
10461 $dictvalues[$obj->{$rowidfield}] = $obj;
10467 $conf->cache[
'dictvalues_'.$tablename] = $dictvalues;
10470 if (!empty($dictvalues[$id])) {
10472 $tmp = $dictvalues[$id];
10473 return (property_exists($tmp, $field) ? $tmp->$field :
'');
10488 $stringcolor = str_replace(
'#',
'', $stringcolor);
10490 if (!empty($stringcolor)) {
10492 $tmp = explode(
',', $stringcolor);
10493 if (count($tmp) > 1) {
10498 $hexr = $stringcolor[0].$stringcolor[1];
10499 $hexg = $stringcolor[2].$stringcolor[3];
10500 $hexb = $stringcolor[4].$stringcolor[5];
10501 $r = hexdec($hexr);
10502 $g = hexdec($hexg);
10503 $b = hexdec($hexb);
10505 $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0;
10506 if ($bright > 0.6) {
10527 if (empty($menuentry[
'enabled'])) {
10530 if ($type_user && $menuentry[
'module']) {
10531 $tmploops = explode(
'|', $menuentry[
'module']);
10533 foreach ($tmploops as $tmploop) {
10534 if (in_array($tmploop, $listofmodulesforexternal)) {
10543 if (!$menuentry[
'perms'] && $type_user) {
10546 if (!$menuentry[
'perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) {
10549 if (!$menuentry[
'perms']) {
10564 return (ceil($n) % $x === 0) ? ceil($n) : round(($n + $x / 2) / $x) * $x;
10578 function dolGetBadge($label, $html =
'', $type =
'primary', $mode =
'', $url =
'', $params = array())
10581 'class'=>
'badge '.(!empty($mode) ?
' badge-'.$mode :
'').(!empty($type) ?
' badge-'.$type :
'').(empty($params[
'css']) ?
'' :
' '.$params[
'css'])
10584 if (empty($html)) {
10588 if (!empty($url)) {
10589 $attr[
'href'] = $url;
10592 if ($mode ===
'dot') {
10593 $attr[
'class'] .=
' classfortooltip';
10594 $attr[
'title'] = $html;
10595 $attr[
'aria-label'] = $label;
10600 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
10601 foreach ($params[
'attr'] as $key => $value) {
10602 if ($key ==
'class') {
10603 $attr[
'class'] .=
' '.$value;
10604 } elseif ($key ==
'classOverride') {
10605 $attr[
'class'] = $value;
10607 $attr[$key] = $value;
10615 $attr = array_map(
'dol_escape_htmltag', $attr);
10617 $TCompiledAttr = array();
10618 foreach ($attr as $key => $value) {
10619 $TCompiledAttr[] = $key.
'="'.$value.
'"';
10622 $compiledAttributes = !empty($TCompiledAttr) ?implode(
' ', $TCompiledAttr) :
'';
10624 $tag = !empty($url) ?
'a' :
'span';
10626 return '<'.$tag.
' '.$compiledAttributes.
'>'.$html.
'</'.$tag.
'>';
10642 function dolGetStatus($statusLabel =
'', $statusLabelShort =
'', $html =
'', $statusType =
'status0', $displayMode = 0, $url =
'', $params = array())
10647 $dolGetBadgeParams = array();
10649 if (!empty($params[
'badgeParams'])) {
10650 $dolGetBadgeParams = $params[
'badgeParams'];
10654 if ($displayMode == 0) {
10655 $return = !empty($html) ? $html : (empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort));
10656 } elseif ($displayMode == 1) {
10657 $return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
10658 } elseif (!empty($conf->global->MAIN_STATUS_USES_IMAGES)) {
10661 $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ?
'<span class="hideonsmartphone">' :
'').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ?
'</span>' :
'');
10662 $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>' :
'');
10665 if (!empty($conf->dol_optimize_smallscreen)) {
10666 if ($displayMode == 0) {
10668 } elseif ($displayMode == 4) {
10670 } elseif ($displayMode == 6) {
10676 $statusImg = array(
10677 'status0' =>
'statut0',
10678 'status1' =>
'statut1',
10679 'status2' =>
'statut2',
10680 'status3' =>
'statut3',
10681 'status4' =>
'statut4',
10682 'status5' =>
'statut5',
10683 'status6' =>
'statut6',
10684 'status7' =>
'statut7',
10685 'status8' =>
'statut8',
10686 'status9' =>
'statut9'
10689 if (!empty($statusImg[$statusType])) {
10690 $htmlImg =
img_picto($statusLabel, $statusImg[$statusType]);
10692 $htmlImg =
img_picto($statusLabel, $statusType);
10695 if ($displayMode === 2) {
10696 $return = $htmlImg.
' '.$htmlLabelShort;
10697 } elseif ($displayMode === 3) {
10698 $return = $htmlImg;
10699 } elseif ($displayMode === 4) {
10700 $return = $htmlImg.
' '.$htmlLabel;
10701 } elseif ($displayMode === 5) {
10702 $return = $htmlLabelShort.
' '.$htmlImg;
10704 $return = $htmlLabel.
' '.$htmlImg;
10706 } elseif (empty($conf->global->MAIN_STATUS_USES_IMAGES) && !empty($displayMode)) {
10708 $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
10710 $dolGetBadgeParams[
'attr'][
'class'] =
'badge-status';
10711 $dolGetBadgeParams[
'attr'][
'title'] = empty($params[
'tooltip']) ? $statusLabel : ($params[
'tooltip'] !=
'no' ? $params[
'tooltip'] :
'');
10713 if ($displayMode == 3) {
10714 $return =
dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)),
'', $statusType,
'dot', $url, $dolGetBadgeParams);
10715 } elseif ($displayMode === 5) {
10716 $return =
dolGetBadge($statusLabelShort, $html, $statusType,
'', $url, $dolGetBadgeParams);
10718 $return =
dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), $html, $statusType,
'', $url, $dolGetBadgeParams);
10755 function dolGetButtonAction($label, $text =
'', $actionType =
'default', $url =
'', $id =
'', $userRight = 1, $params = array())
10757 global $hookmanager, $action, $object, $langs;
10760 if (!empty($params[
'isDropdown']))
10761 $class =
"dropdown-item";
10763 $class =
'butAction';
10764 if ($actionType ==
'danger' || $actionType ==
'delete') {
10765 $class =
'butActionDelete';
10766 if (!empty($url) && strpos($url,
'token=') ===
false) $url .=
'&token='.newToken();
10771 'href' => empty($url) ?
'' : $url,
10775 if (empty($text)) {
10777 $attr[
'title'] =
'';
10779 $attr[
'title'] = $label;
10780 $attr[
'aria-label'] = $label;
10783 if (empty($userRight)) {
10784 $attr[
'class'] =
'butActionRefused';
10785 $attr[
'href'] =
'';
10786 $attr[
'title'] = (($label && $text && $label != $text) ? $label : $langs->trans(
'NotEnoughPermissions'));
10794 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
10795 foreach ($params[
'attr'] as $key => $value) {
10796 if ($key ==
'class') {
10797 $attr[
'class'] .=
' '.$value;
10798 } elseif ($key ==
'classOverride') {
10799 $attr[
'class'] = $value;
10801 $attr[$key] = $value;
10807 if (!empty($attr[
'title']) && !empty($attr[
'class']) && strpos($attr[
'class'],
'classfortooltip') ===
false) {
10808 $attr[
'class'].=
' classfortooltip';
10812 if ($userRight && !empty($params[
'confirm'])) {
10813 if (!is_array($params[
'confirm'])) {
10814 $params[
'confirm'] = array();
10817 if (empty($params[
'confirm'][
'url'])) {
10818 $params[
'confirm'][
'url'] = $url . (strpos($url,
'?') > 0 ?
'&' :
'?') .
'confirm=yes';
10822 $attr[
'data-confirm-url'] = $params[
'confirm'][
'url'];
10823 $attr[
'data-confirm-title'] = !empty($params[
'confirm'][
'title']) ? $params[
'confirm'][
'title'] : $langs->trans(
'ConfirmBtnCommonTitle', $label);
10824 $attr[
'data-confirm-content'] = !empty($params[
'confirm'][
'content']) ? $params[
'confirm'][
'content'] : $langs->trans(
'ConfirmBtnCommonContent', $label);
10825 $attr[
'data-confirm-content'] = preg_replace(
"/\r|\n/",
"", $attr[
'data-confirm-content']);
10826 $attr[
'data-confirm-action-btn-label'] = !empty($params[
'confirm'][
'action-btn-label']) ? $params[
'confirm'][
'action-btn-label'] : $langs->trans(
'Confirm');
10827 $attr[
'data-confirm-cancel-btn-label'] = !empty($params[
'confirm'][
'cancel-btn-label']) ? $params[
'confirm'][
'cancel-btn-label'] : $langs->trans(
'CloseDialog');
10828 $attr[
'data-confirm-modal'] = !empty($params[
'confirm'][
'modal']) ? $params[
'confirm'][
'modal'] :
true;
10830 $attr[
'class'].=
' butActionConfirm';
10833 if (isset($attr[
'href']) && empty($attr[
'href'])) {
10834 unset($attr[
'href']);
10838 $attr = array_map(
'dol_escape_htmltag', $attr);
10840 $TCompiledAttr = array();
10841 foreach ($attr as $key => $value) {
10842 $TCompiledAttr[] = $key.
'= "'.$value.
'"';
10845 $compiledAttributes = empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr);
10847 $tag = !empty($attr[
'href']) ?
'a' :
'span';
10850 $parameters = array(
10851 'TCompiledAttr' => $TCompiledAttr,
10852 'compiledAttributes' => $compiledAttributes,
10857 'actionType' => $actionType,
10860 'userRight' => $userRight,
10861 'params' => $params
10864 $reshook = $hookmanager->executeHooks(
'dolGetButtonAction', $parameters, $object, $action);
10865 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
10867 if (empty($reshook)) {
10869 return '<' . $tag .
' ' . $compiledAttributes .
'>' . $text .
'</' . $tag .
'>';
10871 return '<' . $tag .
' ' . $compiledAttributes .
'>' .
dol_escape_htmltag($text) .
'</' . $tag .
'>';
10874 return $hookmanager->resPrint;
10886 return '<span class="button-title-separator '.$moreClass.
'" ></span>';
10898 if (!empty($fieldValidationErrorMsg)) {
10899 $out.=
'<span class="field-error-icon classfortooltip" title="'.dol_escape_htmltag($fieldValidationErrorMsg, 1).
'" role="alert" >';
10900 $out.=
'<span class="fa fa-exclamation-circle" aria-hidden="true" ></span>';
10919 function dolGetButtonTitle($label, $helpText =
'', $iconClass =
'fa fa-file', $url =
'', $id =
'', $status = 1, $params = array())
10921 global $langs, $conf, $user;
10924 if (!empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (!$user->admin) && $status <= 0) {
10928 $class =
'btnTitle';
10929 if (in_array($iconClass, array(
'fa fa-plus-circle',
'fa fa-plus-circle size15x',
'fa fa-comment-dots',
'fa fa-paper-plane'))) {
10930 $class .=
' btnTitlePlus';
10932 $useclassfortooltip = 1;
10934 if (!empty($params[
'morecss'])) {
10935 $class .=
' '.$params[
'morecss'];
10940 'href' => empty($url) ?
'' : $url
10943 if (!empty($helpText)) {
10945 } elseif (empty($attr[
'title']) && $label) {
10946 $attr[
'title'] = $label;
10947 $useclassfortooltip = 0;
10950 if ($status == 2) {
10951 $attr[
'class'] .=
' btnTitleSelected';
10952 } elseif ($status <= 0) {
10953 $attr[
'class'] .=
' refused';
10955 $attr[
'href'] =
'';
10957 if ($status == -1) {
10958 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"FeatureDisabled"));
10959 } elseif ($status == 0) {
10960 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions"));
10964 if (!empty($attr[
'title']) && $useclassfortooltip) {
10965 $attr[
'class'] .=
' classfortooltip';
10973 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
10974 foreach ($params[
'attr'] as $key => $value) {
10975 if ($key ==
'class') {
10976 $attr[
'class'] .=
' '.$value;
10977 } elseif ($key ==
'classOverride') {
10978 $attr[
'class'] = $value;
10980 $attr[$key] = $value;
10985 if (isset($attr[
'href']) && empty($attr[
'href'])) {
10986 unset($attr[
'href']);
10992 $attr = array_map(
'dol_escape_htmltag', $attr);
10994 $TCompiledAttr = array();
10995 foreach ($attr as $key => $value) {
10996 $TCompiledAttr[] = $key.
'="'.$value.
'"';
10999 $compiledAttributes = (empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr));
11001 $tag = (empty($attr[
'href']) ?
'span' :
'a');
11003 $button =
'<'.$tag.
' '.$compiledAttributes.
'>';
11004 $button .=
'<span class="'.$iconClass.
' valignmiddle btnTitle-icon"></span>';
11005 if (!empty($params[
'forcenohideoftext'])) {
11006 $button .=
'<span class="valignmiddle text-plus-circle btnTitle-label'.(empty($params[
'forcenohideoftext']) ?
' hideonsmartphone' :
'').
'">'.$label.
'</span>';
11008 $button .=
'</'.$tag.
'>';
11024 $classfile = $classname = $classpath =
'';
11027 $module = $element_type;
11028 $element = $element_type;
11029 $subelement = $element_type;
11032 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $element_type, $regs)) {
11033 $element = $subelement = $regs[1];
11034 $module = $regs[2];
11038 if (preg_match(
'/^([^_]+)_([^_]+)/i', $element, $regs)) {
11039 $module = $element = $regs[1];
11040 $subelement = $regs[2];
11044 if ($element_type ==
"action") {
11045 $classpath =
'comm/action/class';
11046 $subelement =
'Actioncomm';
11047 $module =
'agenda';
11051 if ($element_type ==
'facture' || $element_type ==
'invoice') {
11052 $classpath =
'compta/facture/class';
11053 $module =
'facture';
11054 $subelement =
'facture';
11056 if ($element_type ==
'commande' || $element_type ==
'order') {
11057 $classpath =
'commande/class';
11058 $module =
'commande';
11059 $subelement =
'commande';
11061 if ($element_type ==
'propal') {
11062 $classpath =
'comm/propal/class';
11064 if ($element_type ==
'supplier_proposal') {
11065 $classpath =
'supplier_proposal/class';
11067 if ($element_type ==
'shipping') {
11068 $classpath =
'expedition/class';
11069 $subelement =
'expedition';
11070 $module =
'expedition_bon';
11072 if ($element_type ==
'delivery') {
11073 $classpath =
'delivery/class';
11074 $subelement =
'delivery';
11075 $module =
'delivery_note';
11077 if ($element_type ==
'contract') {
11078 $classpath =
'contrat/class';
11079 $module =
'contrat';
11080 $subelement =
'contrat';
11082 if ($element_type ==
'member') {
11083 $classpath =
'adherents/class';
11084 $module =
'adherent';
11085 $subelement =
'adherent';
11087 if ($element_type ==
'cabinetmed_cons') {
11088 $classpath =
'cabinetmed/class';
11089 $module =
'cabinetmed';
11090 $subelement =
'cabinetmedcons';
11092 if ($element_type ==
'fichinter') {
11093 $classpath =
'fichinter/class';
11094 $module =
'ficheinter';
11095 $subelement =
'fichinter';
11097 if ($element_type ==
'dolresource' || $element_type ==
'resource') {
11098 $classpath =
'resource/class';
11099 $module =
'resource';
11100 $subelement =
'dolresource';
11102 if ($element_type ==
'propaldet') {
11103 $classpath =
'comm/propal/class';
11104 $module =
'propal';
11105 $subelement =
'propaleligne';
11107 if ($element_type ==
'order_supplier') {
11108 $classpath =
'fourn/class';
11109 $module =
'fournisseur';
11110 $subelement =
'commandefournisseur';
11111 $classfile =
'fournisseur.commande';
11113 if ($element_type ==
'invoice_supplier') {
11114 $classpath =
'fourn/class';
11115 $module =
'fournisseur';
11116 $subelement =
'facturefournisseur';
11117 $classfile =
'fournisseur.facture';
11119 if ($element_type ==
"service") {
11120 $classpath =
'product/class';
11121 $subelement =
'product';
11124 if (empty($classfile)) {
11125 $classfile = strtolower($subelement);
11127 if (empty($classname)) {
11128 $classname = ucfirst($subelement);
11130 if (empty($classpath)) {
11131 $classpath = $module.
'/class';
11134 $element_properties = array(
11135 'module' => $module,
11136 'classpath' => $classpath,
11137 'element' => $element,
11138 'subelement' => $subelement,
11139 'classfile' => $classfile,
11140 'classname' => $classname
11142 return $element_properties;
11159 if (is_array($element_prop) && $conf->{$element_prop[
'module']}->enabled) {
11160 dol_include_once(
'/'.$element_prop[
'classpath'].
'/'.$element_prop[
'classfile'].
'.class.php');
11162 $objecttmp =
new $element_prop[
'classname']($db);
11163 $ret = $objecttmp->fetch($element_id, $element_ref);
11179 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)) {
11194 return empty($_SESSION[
'newtoken']) ?
'' : $_SESSION[
'newtoken'];
11205 return isset($_SESSION[
'token']) ? $_SESSION[
'token'] :
'';
11224 print
'<div class="div-table-responsive-no-min">';
11225 print
'<table class="noborder centpercent">';
11226 print
'<tr class="liste_titre">';
11228 print $emptyRows < 1 ? '<th>
' : '<th colspan=
"'.($emptyRows + 1).'">
';
11230 print $langs->trans($header);
11232 // extra space between the first header and the number
11233 if ($number > -1) {
11237 if (!empty($link)) {
11238 if (!empty($arguments)) {
11239 print '<a href=
"'.DOL_URL_ROOT.'/'.$link.'?'.$arguments.'">
';
11241 print '<a href=
"'.DOL_URL_ROOT.'/'.$link.'">
';
11245 if ($number > -1) {
11246 print '<span
class=
"badge">
'.$number.'</span>
';
11249 if (!empty($link)) {
11255 if ($number < 0 && !empty($link)) {
11256 print '<th
class=
"right">
';
11258 if (!empty($arguments)) {
11259 print '<a
class=
"commonlink" href=
"'.DOL_URL_ROOT.'/'.$link.'?'.$arguments.'">
';
11261 print '<a
class=
"commonlink" href=
"'.DOL_URL_ROOT.'/'.$link.'">
';
11264 print $langs->trans("FullList");
11280 function finishSimpleTable($addLineBreak = false)
11285 if ($addLineBreak) {
11301 function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord = "None", $extraRightColumn = false)
11306 print '<tr
class=
"oddeven">
';
11307 print '<td colspan=
"'.$tableColumnCount.'" class=
"opacitymedium">
'.$langs->trans($noneWord).'</td>
';
11312 if ($nbofloop === 0) {
11313 // don't show a summary line
11318 $colspan = $tableColumnCount;
11319 } elseif ($num > $nbofloop) {
11320 $colspan = $tableColumnCount;
11322 $colspan = $tableColumnCount - 1;
11325 if ($extraRightColumn) {
11329 print
'<tr class="liste_total">';
11331 if ($nbofloop > 0 && $num > $nbofloop) {
11332 print
'<td colspan="'.$colspan.
'" class="right">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
'</td>';
11334 print
'<td colspan="'.$colspan.
'" class="right"> '.$langs->trans(
"Total").
'</td>';
11335 print
'<td class="right" width="100">'.price($total).
'</td>';
11338 if ($extraRightColumn) {
11357 if ($method == -1) {
11359 if (!empty($conf->global->MAIN_FORCE_READFILE_WITH_FREAD)) {
11362 if (!empty($conf->global->MAIN_FORCE_READFILE_WITH_STREAM_COPY)) {
11368 while (ob_get_level()) {
11373 if ($method == 0) {
11374 readfile($fullpath_original_file_osencoded);
11375 } elseif ($method == 1) {
11377 $handle = fopen($fullpath_original_file_osencoded,
"rb");
11378 while (!feof($handle)) {
11379 print fread($handle, 8192);
11382 } elseif ($method == 2) {
11384 $handle1 = fopen($fullpath_original_file_osencoded,
"rb");
11385 $handle2 = fopen(
"php://output",
"wb");
11386 stream_copy_to_stream($handle1, $handle2);
11411 if ($texttoshow ===
'none') {
11412 $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>';
11413 } elseif ($texttoshow) {
11414 $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>';
11416 $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>';
11431 $result = json_decode($stringtodecode);
11432 if ($result ===
null) {
11433 $result = unserialize($stringtodecode);
11459 $tmp = $sqlfilters;
11460 $i = 0; $nb = strlen($tmp);
11463 if ($tmp[$i] ==
'(') {
11466 if ($tmp[$i] ==
')') {
11469 if ($counter < 0) {
11470 $error =
"Bad sqlfilters=".$sqlfilters;
11499 if (empty($matches[1])) {
11502 $tmp = explode(
':', $matches[1], 3);
11504 if (count($tmp) < 3) {
11508 $operand = preg_replace(
'/[^a-z0-9\._]/i',
'', trim($tmp[0]));
11510 $operator = strtoupper(preg_replace(
'/[^a-z<>=]/i',
'', trim($tmp[1])));
11511 if ($operator ==
'NOTLIKE') {
11512 $operator =
'NOT LIKE';
11515 $tmpescaped = trim($tmp[2]);
11517 if ($operator ==
'IN') {
11518 $tmpescaped =
"(".$db->sanitize($tmpescaped, 1).
")";
11519 } elseif (preg_match(
'/^\'(.*)\'$/', $tmpescaped, $regbis)) {
11520 $tmpescaped =
"'".$db->escape($regbis[1]).
"'";
11522 $tmpescaped = $db->sanitize($db->escape($tmpescaped));
11525 return $db->escape($operand).
' '.$db->escape($operator).
" ".$tmpescaped;
11539 global $conf, $langs;
11540 $out =
'<!-- timeline icon -->'.
"\n";
11541 $iconClass =
'fa fa-comments';
11546 if ($histo[$key][
'percent'] == -1) {
11547 $colorClass =
'timeline-icon-not-applicble';
11548 $pictoTitle = $langs->trans(
'StatusNotApplicable');
11549 } elseif ($histo[$key][
'percent'] == 0) {
11550 $colorClass =
'timeline-icon-todo';
11551 $pictoTitle = $langs->trans(
'StatusActionToDo').
' (0%)';
11552 } elseif ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100) {
11553 $colorClass =
'timeline-icon-in-progress';
11554 $pictoTitle = $langs->trans(
'StatusActionInProcess').
' ('.$histo[$key][
'percent'].
'%)';
11555 } elseif ($histo[$key][
'percent'] >= 100) {
11556 $colorClass =
'timeline-icon-done';
11557 $pictoTitle = $langs->trans(
'StatusActionDone').
' (100%)';
11560 if ($actionstatic->code ==
'AC_TICKET_CREATE') {
11561 $iconClass =
'fa fa-ticket';
11562 } elseif ($actionstatic->code ==
'AC_TICKET_MODIFY') {
11563 $iconClass =
'fa fa-pencilxxx';
11564 } elseif (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
11565 $iconClass =
'fa fa-comments';
11566 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
11567 $iconClass =
'fa fa-mask';
11568 } elseif (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
11569 if ($actionstatic->type_picto) {
11570 $img_picto =
img_picto(
'', $actionstatic->type_picto);
11572 if ($actionstatic->type_code ==
'AC_RDV') {
11573 $iconClass =
'fa fa-handshake';
11574 } elseif ($actionstatic->type_code ==
'AC_TEL') {
11575 $iconClass =
'fa fa-phone';
11576 } elseif ($actionstatic->type_code ==
'AC_FAX') {
11577 $iconClass =
'fa fa-fax';
11578 } elseif ($actionstatic->type_code ==
'AC_EMAIL') {
11579 $iconClass =
'fa fa-envelope';
11580 } elseif ($actionstatic->type_code ==
'AC_INT') {
11581 $iconClass =
'fa fa-shipping-fast';
11582 } elseif ($actionstatic->type_code ==
'AC_OTH_AUTO') {
11583 $iconClass =
'fa fa-robot';
11584 } elseif (!preg_match(
'/_AUTO/', $actionstatic->type_code)) {
11585 $iconClass =
'fa fa-robot';
11590 $out .=
'<i class="'.$iconClass.
' '.$colorClass.
'" title="'.$pictoTitle.
'">'.$img_picto.
'</i>'.
"\n";
11604 $documents = array();
11606 $sql =
'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.filepath, ecm.filename';
11607 $sql .=
' FROM '.MAIN_DB_PREFIX.
'ecm_files ecm';
11608 $sql .=
" WHERE ecm.filepath = 'agenda/".((int) $object->id).
"'";
11610 $sql .=
' ORDER BY ecm.position ASC';
11612 $resql = $db->query($sql);
11614 if ($db->num_rows(
$resql)) {
11615 while ($obj = $db->fetch_object(
$resql)) {
11616 $documents[$obj->id] = $obj;
11643 function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon =
'', $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC')
11645 global $user, $conf;
11648 global $param, $massactionbutton;
11653 if (!is_object($filterobj) && !is_object($objcon)) {
11661 $sortfield_list = explode(
',', $sortfield);
11662 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
11663 $sortfield_new_list = array();
11664 foreach ($sortfield_list as $sortfield_value) {
11665 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
11667 $sortfield_new = implode(
',', $sortfield_new_list);
11671 if (is_object($objcon) && $objcon->id > 0) {
11672 $sql =
"SELECT DISTINCT a.id, a.label as label,";
11674 $sql =
"SELECT a.id, a.label as label,";
11676 $sql .=
" a.datep as dp,";
11677 $sql .=
" a.note as message,";
11678 $sql .=
" a.datep2 as dp2,";
11679 $sql .=
" a.percent as percent, 'action' as type,";
11680 $sql .=
" a.fk_element, a.elementtype,";
11681 $sql .=
" a.fk_contact,";
11682 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
11683 $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";
11684 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
11685 $sql .=
", sp.lastname, sp.firstname";
11686 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
11687 $sql .=
", m.lastname, m.firstname";
11688 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
11690 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
11692 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
11694 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
11696 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
11699 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
11700 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
11701 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
11703 $force_filter_contact =
false;
11704 if (is_object($objcon) && $objcon->id > 0) {
11705 $force_filter_contact =
true;
11706 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as r ON a.id = r.fk_actioncomm";
11707 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id);
11710 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
11711 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
11712 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
11713 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
11714 $sql .=
" ON er.resource_type = 'dolresource'";
11715 $sql .=
" AND er.element_id = a.id";
11716 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
11717 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
11718 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
11719 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
11720 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
11721 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
11722 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
11723 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
11724 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
11725 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
11726 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
11727 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
11728 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
11731 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
11732 if ($force_filter_contact ===
false) {
11733 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
11734 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
11735 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
11736 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
11737 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
11738 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
11739 if ($filterobj->id) {
11740 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
11742 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
11743 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
11744 if ($filterobj->id) {
11745 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
11747 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
11748 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
11749 if ($filterobj->id) {
11750 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
11752 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
11753 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
11754 if ($filterobj->id) {
11755 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
11757 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
11758 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
11759 if ($filterobj->id) {
11760 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
11762 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
11763 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
11764 if ($filterobj->id) {
11765 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
11771 if (!empty($actioncode)) {
11772 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
11773 if ($actioncode ==
'AC_NON_AUTO') {
11774 $sql .=
" AND c.type != 'systemauto'";
11775 } elseif ($actioncode ==
'AC_ALL_AUTO') {
11776 $sql .=
" AND c.type = 'systemauto'";
11778 if ($actioncode ==
'AC_OTH') {
11779 $sql .=
" AND c.type != 'systemauto'";
11780 } elseif ($actioncode ==
'AC_OTH_AUTO') {
11781 $sql .=
" AND c.type = 'systemauto'";
11785 if ($actioncode ==
'AC_NON_AUTO') {
11786 $sql .=
" AND c.type != 'systemauto'";
11787 } elseif ($actioncode ==
'AC_ALL_AUTO') {
11788 $sql .=
" AND c.type = 'systemauto'";
11790 $sql .=
" AND c.code = '".$db->escape($actioncode).
"'";
11794 if ($donetodo ==
'todo') {
11795 $sql .=
" AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now).
"'))";
11796 } elseif ($donetodo ==
'done') {
11797 $sql .=
" AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now).
"'))";
11799 if (is_array($filters) && $filters[
'search_agenda_label']) {
11800 $sql .=
natural_search(
'a.label', $filters[
'search_agenda_label']);
11806 && (empty($actioncode) || $actioncode ==
'AC_OTH_AUTO' || $actioncode ==
'AC_EMAILING')) {
11807 $langs->load(
"mails");
11809 $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";
11810 $sql2 .=
", null as fk_element, '' as elementtype, null as contact_id";
11811 $sql2 .=
", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
11812 $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";
11813 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
11814 $sql2 .=
", '' as lastname, '' as firstname";
11815 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
11816 $sql2 .=
", '' as lastname, '' as firstname";
11817 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
11818 $sql2 .=
", '' as ref";
11819 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
11820 $sql2 .=
", '' as ref";
11821 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
11822 $sql2 .=
", '' as ref";
11824 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"user as u";
11825 $sql2 .=
" WHERE mc.email = '".$db->escape($objcon->email).
"'";
11826 $sql2 .=
" AND mc.statut = 1";
11827 $sql2 .=
" AND u.rowid = m.fk_user_valid";
11828 $sql2 .=
" AND mc.fk_mailing=m.rowid";
11831 if (!empty($sql) && !empty($sql2)) {
11832 $sql = $sql.
" UNION ".$sql2;
11833 } elseif (empty($sql) && !empty($sql2)) {
11839 $sql .= $db->order($sortfield_new, $sortorder);
11841 dol_syslog(
"function.lib::show_actions_messaging", LOG_DEBUG);
11842 $resql = $db->query($sql);
11845 $num = $db->num_rows(
$resql);
11847 while ($i < $num) {
11848 $obj = $db->fetch_object(
$resql);
11850 if ($obj->type ==
'action') {
11852 $contactaction->id = $obj->id;
11853 $result = $contactaction->fetchResources();
11856 setEventMessage(
"actions.lib::show_actions_messaging Error fetch ressource",
'errors');
11862 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->dp > $now)) {
11863 $tododone =
'todo';
11866 $histo[$numaction] = array(
11867 'type'=>$obj->type,
11868 'tododone'=>$tododone,
11870 'datestart'=>$db->jdate($obj->dp),
11871 'dateend'=>$db->jdate($obj->dp2),
11872 'note'=>$obj->label,
11873 'message'=>$obj->message,
11874 'percent'=>$obj->percent,
11876 'userid'=>$obj->user_id,
11877 'login'=>$obj->user_login,
11878 'userfirstname'=>$obj->user_firstname,
11879 'userlastname'=>$obj->user_lastname,
11880 'userphoto'=>$obj->user_photo,
11882 'contact_id'=>$obj->fk_contact,
11883 'socpeopleassigned' => $contactaction->socpeopleassigned,
11884 'lastname'=>$obj->lastname,
11885 'firstname'=>$obj->firstname,
11886 'fk_element'=>$obj->fk_element,
11887 'elementtype'=>$obj->elementtype,
11889 'acode'=>$obj->acode,
11890 'alabel'=>$obj->alabel,
11891 'libelle'=>$obj->alabel,
11892 'apicto'=>$obj->apicto
11895 $histo[$numaction] = array(
11896 'type'=>$obj->type,
11897 'tododone'=>
'done',
11899 'datestart'=>$db->jdate($obj->dp),
11900 'dateend'=>$db->jdate($obj->dp2),
11901 'note'=>$obj->label,
11902 'message'=>$obj->message,
11903 'percent'=>$obj->percent,
11904 'acode'=>$obj->acode,
11906 'userid'=>$obj->user_id,
11907 'login'=>$obj->user_login,
11908 'userfirstname'=>$obj->user_firstname,
11909 'userlastname'=>$obj->user_lastname,
11910 'userphoto'=>$obj->user_photo
11926 $langs->loadLangs(array(
"admin",
"errors"));
11927 $out =
info_admin($langs->trans(
"WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv(
"Module2400Name")), 0, 0,
'warning');
11931 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
11933 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
11934 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
11935 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
11936 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
11941 $userstatic =
new User($db);
11942 $contactstatic =
new Contact($db);
11943 $userGetNomUrlCache = array();
11945 $out .=
'<div class="filters-container" >';
11946 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
11947 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
11949 if ($objcon && get_class($objcon) ==
'Contact' &&
11950 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
11951 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
11953 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
11955 if ($filterobj && get_class($filterobj) ==
'Societe') {
11956 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
11961 $out .=
'<div class="div-table-responsive-no-min">';
11962 $out .=
'<table class="noborder borderbottom centpercent">';
11964 $out .=
'<tr class="liste_titre">';
11966 $out .=
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
11968 $out .=
'<th class="liste_titre"><strong class="hideonsmartphone">'.$langs->trans(
"Search").
' : </strong></th>';
11970 $out .=
'<th class="liste_titre"></th>';
11972 $out .=
'<th class="liste_titre">';
11973 $out .=
'<span class="fas fa-square inline-block fawidth30" style=" color: #ddd;" title="'.$langs->trans(
"ActionType").
'"></span>';
11975 $out .=
$formactions->select_type_actions($actioncode,
"actioncode",
'', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, 0, 1,
'minwidth200imp');
11977 $out .=
'<th class="liste_titre maxwidth100onsmartphone">';
11978 $out .=
'<input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'" placeholder="'.$langs->trans(
"Label").
'">';
11981 $out .=
'<th class="liste_titre width50 middle">';
11982 $searchpicto =
$form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
11983 $out .= $searchpicto;
11988 $out .=
'</table>';
11995 $out .=
'<ul class="timeline">';
11999 if (get_class($filterobj) ==
'Societe') {
12000 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
12002 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
12003 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
12004 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
12006 if (get_class($filterobj) ==
'Societe') {
12017 $actualCycleDate =
false;
12020 foreach ($histo as $key => $value) {
12021 $actionstatic->fetch($histo[$key][
'id']);
12023 $actionstatic->type_picto = $histo[$key][
'apicto'];
12024 $actionstatic->type_code = $histo[$key][
'acode'];
12026 $url = DOL_URL_ROOT.
'/comm/action/card.php?id='.$histo[$key][
'id'];
12028 $tmpa =
dol_getdate($histo[$key][
'datestart'],
false);
12029 if ($actualCycleDate !== $tmpa[
'year'].
'-'.$tmpa[
'yday']) {
12030 $actualCycleDate = $tmpa[
'year'].
'-'.$tmpa[
'yday'];
12031 $out .=
'<!-- timeline time label -->';
12032 $out .=
'<li class="time-label">';
12033 $out .=
'<span class="timeline-badge-date">';
12034 $out .=
dol_print_date($histo[$key][
'datestart'],
'daytext',
'tzuserrel', $langs);
12037 $out .=
'<!-- /.timeline-label -->';
12041 $out .=
'<!-- timeline item -->'.
"\n";
12042 $out .=
'<li class="timeline-code-'.strtolower($actionstatic->code).
'">';
12046 $out .=
'<div class="timeline-item">'.
"\n";
12048 $out .=
'<span class="timeline-header-action">';
12050 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
12051 $out .=
'<a class="timeline-btn" href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
12052 $out .= $histo[$key][
'id'];
12055 $out .= $actionstatic->getNomUrl(1, -1,
'valignmiddle').
' ';
12058 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
12059 (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && !empty($user->rights->agenda->myactions->create))) {
12060 $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>';
12065 $out .=
'<span class="time"><i class="fa fa-clock-o"></i> ';
12066 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
12067 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
12068 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
12069 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
12070 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
12071 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
12073 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
12077 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
12080 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
12083 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
12086 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
12092 $out .=
"</span>\n";
12095 $out .=
'<h3 class="timeline-header">';
12098 $out .=
'<span class="messaging-author">';
12099 if ($histo[$key][
'userid'] > 0) {
12100 if (!isset($userGetNomUrlCache[$histo[$key][
'userid']])) {
12101 $userstatic->fetch($histo[$key][
'userid']);
12102 $userGetNomUrlCache[$histo[$key][
'userid']] = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
12104 $out .= $userGetNomUrlCache[$histo[$key][
'userid']];
12109 $out .=
' <span class="messaging-title">';
12111 if (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
12112 $out .= $langs->trans(
'TicketNewMessage');
12113 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
12114 $out .= $langs->trans(
'TicketNewMessage').
' <em>('.$langs->trans(
'Private').
')</em>';
12116 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'action') {
12117 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
12118 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode : $histo[$key][
'alabel']);
12119 $libelle = $histo[$key][
'note'];
12120 $actionstatic->id = $histo[$key][
'id'];
12123 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
12124 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
12125 $transcode = $langs->trans(
"Action".$histo[$key][
'acode']);
12126 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
12135 if (!empty($histo[$key][
'message'])
12136 && $actionstatic->code !=
'AC_TICKET_CREATE'
12137 && $actionstatic->code !=
'AC_TICKET_MODIFY'
12139 $out .=
'<div class="timeline-body">';
12140 $out .= $histo[$key][
'message'];
12148 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
12150 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $Tab) {
12152 $result = $contact->fetch($cid);
12159 $contactList .= !empty($contactList) ?
', ' :
'';
12160 $contactList .= $contact->getNomUrl(1);
12161 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
12162 if (!empty($contact->phone_pro)) {
12163 $contactList .=
'('.dol_print_phone($contact->phone_pro).
')';
12169 $footer .= $langs->trans(
'ActionOnContact').
' : '.$contactList;
12170 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
12172 $result = $contact->fetch($histo[$key][
'contact_id']);
12179 $footer .= $contact->getNomUrl(1);
12180 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
12181 if (!empty($contact->phone_pro)) {
12182 $footer .=
'('.dol_print_phone($contact->phone_pro).
')';
12189 if (!empty($documents)) {
12190 $footer .=
'<div class="timeline-documents-container">';
12191 foreach ($documents as $doc) {
12192 $footer .=
'<span id="document_'.$doc->id.
'" class="timeline-documents" ';
12193 $footer .=
' data-id="'.$doc->id.
'" ';
12194 $footer .=
' data-path="'.$doc->filepath.
'"';
12195 $footer .=
' data-filename="'.dol_escape_htmltag($doc->filename).
'" ';
12198 $filePath = DOL_DATA_ROOT.
'/'.$doc->filepath.
'/'.$doc->filename;
12200 $file = $actionstatic->id.
'/'.$doc->filename;
12201 $thumb = $actionstatic->id.
'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename,
'.')).
'_mini'.substr($doc->filename, strrpos($doc->filename,
'.'));
12202 $doclink =
dol_buildpath(
'document.php', 1).
'?modulepart=actions&attachment=0&file='.urlencode($file).
'&entity='.$conf->entity;
12203 $viewlink =
dol_buildpath(
'viewimage.php', 1).
'?modulepart=actions&file='.urlencode($thumb).
'&entity='.$conf->entity;
12205 $mimeAttr =
' mime="'.$mime.
'" ';
12207 if (in_array($mime, array(
'image/png',
'image/jpeg',
'application/pdf'))) {
12208 $class .=
' documentpreview';
12211 $footer .=
'<a href="'.$doclink.
'" class="btn-link '.$class.
'" target="_blank" rel="noopener noreferrer" '.$mimeAttr.
' >';
12212 $footer .=
img_mime($filePath).
' '.$doc->filename;
12215 $footer .=
'</span>';
12217 $footer .=
'</div>';
12220 if (!empty($footer)) {
12221 $out .=
'<div class="timeline-footer">'.$footer.
'</div>';
12224 $out .=
'</div>'.
"\n";
12227 $out .=
'<!-- END timeline item -->';
12234 if (empty($histo)) {
12235 $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 is valid and will pass the preg_replace_callback() to replace Gener...
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.
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.
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...
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.
dol_escape_json($stringtoescape)
Returns text escaped for inclusion into javascript code.
dolForgeCriteriaCallback($matches)
Function to forge a SQL criteria from a Generic filter 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.
print *****$script_file(".$version.") pid code
! Closing after partial payment: discount_vat, badcustomer or badsupplier, bankcharge,...