43 include_once DOL_DOCUMENT_ROOT.
'/core/lib/json.lib.php';
46 if (!function_exists(
'utf8_encode')) {
53 function utf8_encode($elements)
55 return mb_convert_encoding($elements,
'UTF-8',
'ISO-8859-1');
59 if (!function_exists(
'utf8_decode')) {
66 function utf8_decode($elements)
68 return mb_convert_encoding($elements,
'ISO-8859-1',
'UTF-8');
83 return (
string) (empty($conf->global->$key) ? $default : $conf->global->$key);
96 return (
int) (empty($conf->global->$key) ? $default : $conf->global->$key);
107 return !empty($conf->$module->enabled);
123 require_once DOL_DOCUMENT_ROOT.
"/core/db/".$type.
'.class.php';
125 $class =
'DoliDB'.ucfirst($type);
126 $dolidb =
new $class($type, $host, $user, $pass, $name, $port);
147 function getEntity($element, $shared = 1, $currentobject = null)
149 global $conf, $mc, $hookmanager, $object, $action, $db;
151 if (! is_object($hookmanager)) {
158 $element =
'contract';
160 case 'order_supplier':
161 $element =
'supplier_order';
163 case 'invoice_supplier':
164 $element =
'supplier_invoice';
168 if (is_object($mc)) {
169 $out = $mc->getEntity($element, $shared, $currentobject);
172 $addzero = array(
'user',
'usergroup',
'c_email_templates',
'email_template',
'default_values');
173 if (in_array($element, $addzero)) {
176 $out .= ((int) $conf->entity);
181 'element' => $element,
184 'currentobject' => $currentobject,
187 $reshook = $hookmanager->executeHooks(
'hookGetEntity', $parameters, $currentobject, $action);
189 if (is_numeric($reshook)) {
190 if ($reshook == 0 && !empty($hookmanager->resPrint)) {
191 $out .=
','.$hookmanager->resPrint;
192 } elseif ($reshook == 1) {
193 $out = $hookmanager->resPrint;
210 if (is_object($mc) && method_exists($mc,
'setEntity')) {
211 return $mc->setEntity($currentobject);
213 return ((is_object($currentobject) && $currentobject->id > 0 && $currentobject->entity > 0) ? $currentobject->entity : $conf->entity);
225 return preg_match(
'/(_pass|password|_pw|_key|securekey|serverkey|secret\d?|p12key|exportkey|_PW_[a-z]+|token)$/i', $keyname);
237 for ($r =
""; $n >= 0; $n = intval($n / 26) - 1)
238 $r = chr($n % 26 + 0x41) . $r;
261 include_once DOL_DOCUMENT_ROOT.
'/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php';
268 $user_agent = substr($user_agent, 0, 512);
270 $detectmobile =
new Mobile_Detect(null, $user_agent);
271 $tablet = $detectmobile->isTablet();
273 if ($detectmobile->isMobile()) {
277 if ($detectmobile->is(
'AndroidOS')) {
278 $os = $phone =
'android';
279 } elseif ($detectmobile->is(
'BlackBerryOS')) {
280 $os = $phone =
'blackberry';
281 } elseif ($detectmobile->is(
'iOS')) {
284 } elseif ($detectmobile->is(
'PalmOS')) {
285 $os = $phone =
'palm';
286 } elseif ($detectmobile->is(
'SymbianOS')) {
288 } elseif ($detectmobile->is(
'webOS')) {
290 } elseif ($detectmobile->is(
'MaemoOS')) {
292 } elseif ($detectmobile->is(
'WindowsMobileOS') || $detectmobile->is(
'WindowsPhoneOS')) {
298 if (preg_match(
'/linux/i', $user_agent)) {
300 } elseif (preg_match(
'/macintosh/i', $user_agent)) {
302 } elseif (preg_match(
'/windows/i', $user_agent)) {
308 if (preg_match(
'/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
311 } elseif (preg_match(
'/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
314 } elseif (preg_match(
'/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) {
317 } elseif (preg_match(
'/chrome/i', $user_agent, $reg)) {
320 } elseif (preg_match(
'/iceweasel/i', $user_agent)) {
322 } elseif (preg_match(
'/epiphany/i', $user_agent)) {
324 } elseif (preg_match(
'/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
327 } elseif (preg_match(
'/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
331 } elseif (preg_match(
'/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
333 $version = end($reg);
334 } elseif (preg_match(
'/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
337 $version = end($reg);
338 } elseif (preg_match(
'/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) {
353 'browsername' => $name,
354 'browserversion' => $version,
369 global $conf, $user, $langs, $db;
370 $disconnectdone =
false;
372 if (is_object($db) && !empty($db->connected)) {
373 $depth = $db->transaction_opened;
374 $disconnectdone = $db->close();
376 dol_syslog(
"--- End access to ".$_SERVER[
"PHP_SELF"].(($disconnectdone && $depth) ?
' (Warn: db disconnection forced, transaction depth was '.$depth.
')' :
''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO));
389 $relativepathstring = $_SERVER[
"PHP_SELF"];
391 if (constant(
'DOL_URL_ROOT')) {
392 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
394 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
395 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
401 if (!empty($_GET[
'restore_lastsearch_values'])) {
402 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
403 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
404 if (is_array($tmp)) {
405 foreach ($tmp as $key => $val) {
406 if ($key == $paramname) {
414 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
416 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
418 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
420 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
424 $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname]));
441 if (empty($method)) {
442 $val = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
443 } elseif ($method == 1) {
444 $val = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
445 } elseif ($method == 2) {
446 $val = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
447 } elseif ($method == 3) {
448 $val = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
450 $val =
'BadFirstParameterForGETPOST';
453 return is_array($val);
483 function GETPOST($paramname, $check =
'alphanohtml', $method = 0, $filter = null, $options = null, $noreplace = 0)
485 global $mysoc, $user, $conf;
487 if (empty($paramname)) {
488 return 'BadFirstParameterForGETPOST';
491 dol_syslog(
"Deprecated use of GETPOST, called with 1st param = ".$paramname.
" and 2nd param is '', when calling page ".$_SERVER[
"PHP_SELF"], LOG_WARNING);
496 if (empty($method)) {
497 $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
498 } elseif ($method == 1) {
499 $out = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
500 } elseif ($method == 2) {
501 $out = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
502 } elseif ($method == 3) {
503 $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
505 return 'BadThirdParameterForGETPOST';
508 if (empty($method) || $method == 3 || $method == 4) {
509 $relativepathstring = $_SERVER[
"PHP_SELF"];
511 if (constant(
'DOL_URL_ROOT')) {
512 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
514 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
515 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
521 if (!empty($_GET[
'restore_lastsearch_values'])) {
522 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
523 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
524 if (is_array($tmp)) {
525 foreach ($tmp as $key => $val) {
526 if ($key == $paramname) {
534 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
535 $out = $_SESSION[
'lastsearch_contextpage_'.$relativepathstring];
536 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
537 $out = $_SESSION[
'lastsearch_limit_'.$relativepathstring];
538 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
539 $out = $_SESSION[
'lastsearch_page_'.$relativepathstring];
540 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
541 $out = $_SESSION[
'lastsearch_mode_'.$relativepathstring];
543 } elseif (!isset($_GET[
'sortfield'])) {
546 if (!empty($_GET[
'action']) && $_GET[
'action'] ==
'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
549 if (is_object($object) && isset($object->fields[$paramname][
'default'])) {
550 $out = $object->fields[$paramname][
'default'];
553 if (!empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
554 if (!empty($_GET[
'action']) && (preg_match(
'/^create/', $_GET[
'action']) || preg_match(
'/^presend/', $_GET[
'action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
556 if (!empty($user->default_values)) {
557 if (isset($user->default_values[$relativepathstring][
'createform'])) {
558 foreach ($user->default_values[$relativepathstring][
'createform'] as $defkey => $defval) {
560 if ($defkey !=
'_noquery_') {
561 $tmpqueryarraytohave = explode(
'&', $defkey);
564 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
565 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
578 if (isset($user->default_values[$relativepathstring][
'createform'][$defkey][$paramname])) {
579 $out = $user->default_values[$relativepathstring][
'createform'][$defkey][$paramname];
586 } elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
588 if (!empty($user->default_values)) {
591 if ($paramname ==
'sortfield' || $paramname ==
'sortorder') {
593 if (isset($user->default_values[$relativepathstring][
'sortorder'])) {
595 foreach ($user->default_values[$relativepathstring][
'sortorder'] as $defkey => $defval) {
597 if ($defkey !=
'_noquery_') {
598 $tmpqueryarraytohave = explode(
'&', $defkey);
601 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
602 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
615 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
616 foreach ($user->default_values[$relativepathstring][
'sortorder'][$defkey] as $key => $val) {
620 if ($paramname ==
'sortfield') {
623 if ($paramname ==
'sortorder') {
631 } elseif (isset($user->default_values[$relativepathstring][
'filters'])) {
632 foreach ($user->default_values[$relativepathstring][
'filters'] as $defkey => $defval) {
633 if (!empty($_GET[
'disabledefaultvalues'])) {
637 if ($defkey !=
'_noquery_') {
638 $tmpqueryarraytohave = explode(
'&', $defkey);
641 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
642 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
656 if (isset($_POST[
'sall']) || isset($_POST[
'search_all']) || isset($_GET[
'sall']) || isset($_GET[
'search_all'])) {
658 if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH)) {
659 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
660 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
663 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
664 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
679 if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
683 while (preg_match(
'/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) {
687 if ($reg[1] ==
'DAY') {
689 $newout = $tmp[
'mday'];
690 } elseif ($reg[1] ==
'MONTH') {
692 $newout = $tmp[
'mon'];
693 } elseif ($reg[1] ==
'YEAR') {
695 $newout = $tmp[
'year'];
696 } elseif ($reg[1] ==
'PREVIOUS_DAY') {
699 $newout = $tmp2[
'day'];
700 } elseif ($reg[1] ==
'PREVIOUS_MONTH') {
703 $newout = $tmp2[
'month'];
704 } elseif ($reg[1] ==
'PREVIOUS_YEAR') {
706 $newout = ($tmp[
'year'] - 1);
707 } elseif ($reg[1] ==
'NEXT_DAY') {
710 $newout = $tmp2[
'day'];
711 } elseif ($reg[1] ==
'NEXT_MONTH') {
714 $newout = $tmp2[
'month'];
715 } elseif ($reg[1] ==
'NEXT_YEAR') {
717 $newout = ($tmp[
'year'] + 1);
718 } elseif ($reg[1] ==
'MYCOMPANY_COUNTRY_ID' || $reg[1] ==
'MYCOUNTRY_ID' || $reg[1] ==
'MYCOUNTRYID') {
719 $newout = $mysoc->country_id;
720 } elseif ($reg[1] ==
'USER_ID' || $reg[1] ==
'USERID') {
722 } elseif ($reg[1] ==
'USER_SUPERVISOR_ID' || $reg[1] ==
'SUPERVISOR_ID' || $reg[1] ==
'SUPERVISORID') {
723 $newout = $user->fk_user;
724 } elseif ($reg[1] ==
'ENTITY_ID' || $reg[1] ==
'ENTITYID') {
725 $newout = $conf->entity;
730 $out = preg_replace(
'/__'.preg_quote($reg[1],
'/').
'__/', $newout, $out);
735 if (preg_match(
'/^array/', $check)) {
736 if (!is_array($out) || empty($out)) {
739 $tmparray = explode(
':', $check);
740 if (!empty($tmparray[1])) {
741 $tmpcheck = $tmparray[1];
743 $tmpcheck =
'alphanohtml';
745 foreach ($out as $outkey => $outval) {
746 $out[$outkey] =
sanitizeVal($outval, $tmpcheck, $filter, $options);
750 $out =
sanitizeVal($out, $check, $filter, $options);
755 if ($paramname ==
'backtopage' || $paramname ==
'backtolist' || $paramname ==
'backtourl') {
756 $out = str_replace(
'\\',
'/', $out);
757 $out = str_replace(array(
':',
';',
'@',
"\t",
' '),
'', $out);
759 $oldstringtoclean = $out;
760 $out = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $out);
761 $out = preg_replace(array(
'/^[^\?]*%/'),
'', $out);
762 $out = preg_replace(array(
'/^[a-z]*\/\s*\/+/i'),
'', $out);
763 }
while ($oldstringtoclean != $out);
768 if (empty($method) || $method == 3 || $method == 4) {
769 if (preg_match(
'/^search_/', $paramname) || in_array($paramname, array(
'sortorder',
'sortfield'))) {
776 if ($out !=
'' && isset($user)) {
777 $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out;
796 return (
int)
GETPOST($paramname,
'int', $method, null, null, 0);
810 function checkVal($out =
'', $check =
'alphanohtml', $filter = null, $options = null)
812 return sanitizeVal($out, $check, $filter, $options);
824 function sanitizeVal($out =
'', $check =
'alphanohtml', $filter = null, $options = null)
834 if (!is_numeric($out)) {
839 if (preg_match(
'/[^0-9,-]+/i', $out)) {
844 $out = filter_var($out, FILTER_SANITIZE_STRING);
847 $out = filter_var($out, FILTER_SANITIZE_EMAIL);
850 if (!is_array($out)) {
852 if (preg_match(
'/[^a-z]+/i', $out)) {
858 if (!is_array($out)) {
860 if (preg_match(
'/[^a-z0-9_\-\.]+/i', $out)) {
866 if (!is_array($out)) {
868 if (preg_match(
'/[^a-z0-9_\-\.,]+/i', $out)) {
878 if (!is_array($out)) {
881 $oldstringtoclean = $out;
888 $out = str_ireplace(array(
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'\',
'\',
'/',
'../',
'..\\'),
'', $out);
889 }
while ($oldstringtoclean != $out);
894 if (!is_array($out)) {
897 $oldstringtoclean = $out;
903 $out = str_ireplace(array(
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'\',
'\',
'/',
'../',
'..\\'),
'', $out);
904 }
while ($oldstringtoclean != $out);
908 case 'restricthtmlallowunvalid':
910 $oldstringtoclean = $out;
912 if (!empty($out) && !empty($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML) && $check !=
'restricthtmlallowunvalid') {
914 $dom =
new DOMDocument;
918 $out =
'<div class="tricktoremove">'.$out.
'</div>';
920 $dom->loadHTML($out, LIBXML_ERR_NONE|LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD|LIBXML_NONET|LIBXML_NOWARNING|LIBXML_NOXMLDECL);
921 $out = trim($dom->saveHTML());
924 $out = preg_replace(
'/^<div class="tricktoremove">/',
'', $out);
925 $out = preg_replace(
'/<\/div>$/',
'', $out);
928 return 'InvalidHTMLString';
934 $out = preg_replace(
'/'/i',
''', $out);
940 $out = preg_replace_callback(
'/&#(x?[0-9][0-9a-f]+;?)/i',
function ($m) {
945 $out = preg_replace(
'/&#x?[0-9]+/i',
'', $out);
950 if (!empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)) {
956 $out = preg_replace(
'/'/i',
"'", $out);
957 }
while ($oldstringtoclean != $out);
960 if (empty($filter)) {
961 return 'BadFourthParameterForGETPOST';
963 $out = filter_var($out, $filter, $options);
971 if (!function_exists(
'dol_getprefix')) {
981 function dol_getprefix($mode =
'')
984 if ($mode ==
'email') {
987 if (!empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) {
988 if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID !=
'SERVER_NAME') {
989 return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
990 } elseif (isset($_SERVER[
"SERVER_NAME"])) {
991 return $_SERVER[
"SERVER_NAME"];
996 if (!empty($conf->file->instance_unique_id)) {
997 return sha1(
'dolibarr'.$conf->file->instance_unique_id);
1001 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1005 global $dolibarr_main_instance_unique_id, $dolibarr_main_cookie_cryptkey;
1006 $tmp_instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ?
'' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
1009 if (!empty($tmp_instance_unique_id)) {
1010 return sha1(
'dolibarr'.$tmp_instance_unique_id);
1014 if (isset($_SERVER[
"SERVER_NAME"]) && isset($_SERVER[
"DOCUMENT_ROOT"])) {
1015 return sha1($_SERVER[
"SERVER_NAME"].$_SERVER[
"DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1017 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1034 global $conf, $langs, $user, $mysoc;
1038 if (!file_exists($fullpath)) {
1039 dol_syslog(
'functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_WARNING);
1043 if (!empty($classname) && !class_exists($classname)) {
1044 return include $fullpath;
1046 return include_once $fullpath;
1065 $path = preg_replace(
'/^\//',
'', $path);
1068 $res = DOL_DOCUMENT_ROOT.
'/'.$path;
1069 if (is_array($conf->file->dol_document_root)) {
1070 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1071 if ($key ==
'main') {
1074 if (file_exists($dirroot.
'/'.$path)) {
1075 $res = $dirroot.
'/'.$path;
1080 if ($returnemptyifnotfound) {
1082 if ($returnemptyifnotfound == 1 || !file_exists($res)) {
1094 $res = DOL_URL_ROOT.
'/'.$path;
1097 $res = DOL_MAIN_URL_ROOT.
'/'.$path;
1100 $res = DOL_URL_ROOT.
'/'.$path;
1103 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1104 if ($key ==
'main') {
1106 global $dolibarr_main_url_root;
1109 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1110 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1113 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
'/'.$path;
1117 preg_match(
'/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);
1118 if (!empty($regs[1])) {
1120 if (file_exists($dirroot.
'/'.$regs[1])) {
1122 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1125 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1128 global $dolibarr_main_url_root;
1131 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1132 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1135 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).$conf->file->dol_url_root[$key].
'/'.$path;
1158 if (empty($native)) {
1160 if (isset($object->db) && isset($object->db->db) && is_object($object->db->db) && get_class($object->db->db) ==
'PgSql\Connection') {
1161 $tmpsavdb = $object->db;
1165 $myclone = unserialize(serialize($object));
1168 $object->db = $tmpsavdb;
1171 $myclone = clone $object;
1189 if (empty($conf->dol_optimize_smallscreen)) {
1192 if ($type ==
'width' && $size > 250) {
1217 $filesystem_forbidden_chars = array(
'<',
'>',
'/',
'\\',
'?',
'*',
'|',
'"',
':',
'°',
'$',
';');
1219 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1220 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1221 $tmp = str_replace(
'..',
'', $tmp);
1241 $filesystem_forbidden_chars = array(
'<',
'>',
'?',
'*',
'|',
'"',
'°',
'$',
';');
1243 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1244 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1245 $tmp = str_replace(
'..',
'', $tmp);
1260 $stringtoclean = preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $stringtoclean);
1262 $stringtoclean = preg_replace(
'/<!--[^>]*-->/',
'', $stringtoclean);
1264 $stringtoclean = str_replace(
'\\',
'/', $stringtoclean);
1268 $stringtoclean = str_replace(array(
':',
';',
'@'),
'', $stringtoclean);
1272 $oldstringtoclean = $stringtoclean;
1275 $stringtoclean = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $stringtoclean);
1276 }
while ($oldstringtoclean != $stringtoclean);
1280 $stringtoclean = preg_replace(array(
'/^[a-z]*\/\/+/i'),
'', $stringtoclean);
1283 return $stringtoclean;
1299 if (extension_loaded(
'intl') && !empty($conf->global->MAIN_UNACCENT_USE_TRANSLITERATOR)) {
1300 $transliterator = \Transliterator::createFromRules(
':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', \Transliterator::FORWARD);
1301 return $transliterator->transliterate($str);
1304 $string = rawurlencode($str);
1305 $replacements = array(
1306 '%C3%80' =>
'A',
'%C3%81' =>
'A',
'%C3%82' =>
'A',
'%C3%83' =>
'A',
'%C3%84' =>
'A',
'%C3%85' =>
'A',
1308 '%C3%88' =>
'E',
'%C3%89' =>
'E',
'%C3%8A' =>
'E',
'%C3%8B' =>
'E',
1309 '%C3%8C' =>
'I',
'%C3%8D' =>
'I',
'%C3%8E' =>
'I',
'%C3%8F' =>
'I',
1311 '%C3%92' =>
'O',
'%C3%93' =>
'O',
'%C3%94' =>
'O',
'%C3%95' =>
'O',
'%C3%96' =>
'O',
1313 '%C3%99' =>
'U',
'%C3%9A' =>
'U',
'%C3%9B' =>
'U',
'%C3%9C' =>
'U',
1314 '%C3%9D' =>
'Y',
'%C5%B8' =>
'y',
1315 '%C3%A0' =>
'a',
'%C3%A1' =>
'a',
'%C3%A2' =>
'a',
'%C3%A3' =>
'a',
'%C3%A4' =>
'a',
'%C3%A5' =>
'a',
1317 '%C3%A8' =>
'e',
'%C3%A9' =>
'e',
'%C3%AA' =>
'e',
'%C3%AB' =>
'e',
1318 '%C3%AC' =>
'i',
'%C3%AD' =>
'i',
'%C3%AE' =>
'i',
'%C3%AF' =>
'i',
1320 '%C3%B2' =>
'o',
'%C3%B3' =>
'o',
'%C3%B4' =>
'o',
'%C3%B5' =>
'o',
'%C3%B6' =>
'o',
1322 '%C3%B9' =>
'u',
'%C3%BA' =>
'u',
'%C3%BB' =>
'u',
'%C3%BC' =>
'u',
1323 '%C3%BD' =>
'y',
'%C3%BF' =>
'y'
1325 $string = strtr($string, $replacements);
1326 return rawurldecode($string);
1331 "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
1332 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
1333 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
1334 \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
1335 \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
1336 \xF9\xFA\xFB\xFC\xFD\xFF",
1344 $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"));
1363 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
",",
";",
"=",
'°');
1364 $forbidden_chars_to_remove = array();
1367 if (is_array($badcharstoreplace)) {
1368 $forbidden_chars_to_replace = $badcharstoreplace;
1370 if (is_array($badcharstoremove)) {
1371 $forbidden_chars_to_remove = $badcharstoremove;
1374 return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove,
"", $str));
1393 if ($removetabcrlf) {
1394 return preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $str);
1396 return preg_replace(
'/[\x00-\x08\x11-\x12\x14-\x1F\x7F]/u',
'', $str);
1411 $substitjs = array(
"'"=>
"\\'",
"\r"=>
'\\r');
1413 if (empty($noescapebackslashn)) {
1414 $substitjs[
"\n"] =
'\\n';
1415 $substitjs[
'\\'] =
'\\\\';
1418 $substitjs[
"'"] =
"\\'";
1419 $substitjs[
'"'] =
"\\'";
1420 } elseif ($mode == 1) {
1421 $substitjs[
"'"] =
"\\'";
1422 } elseif ($mode == 2) {
1423 $substitjs[
'"'] =
'\\"';
1424 } elseif ($mode == 3) {
1425 $substitjs[
"'"] =
"\\'";
1426 $substitjs[
'"'] =
"\\\"";
1428 return strtr($stringtoescape, $substitjs);
1439 return str_replace(
'"',
'\"', $stringtoescape);
1453 function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags =
'', $escapeonlyhtmltags = 0)
1455 if ($noescapetags ==
'common') {
1456 $noescapetags =
'html,body,a,b,em,hr,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody';
1460 if ($escapeonlyhtmltags) {
1461 $tmp = htmlspecialchars_decode((
string) $stringtoescape, ENT_COMPAT);
1463 $tmp = html_entity_decode((
string) $stringtoescape, ENT_COMPAT,
'UTF-8');
1466 $tmp = strtr($tmp, array(
"<b>"=>
'',
'</b>'=>
''));
1469 $tmp = strtr($tmp, array(
"\r"=>
'\\r',
"\n"=>
'\\n'));
1472 if ($escapeonlyhtmltags) {
1473 return htmlspecialchars($tmp, ENT_COMPAT,
'UTF-8');
1477 $tmparrayoftags = array();
1478 if ($noescapetags) {
1479 $tmparrayoftags = explode(
',', $noescapetags);
1481 if (count($tmparrayoftags)) {
1482 foreach ($tmparrayoftags as $tagtoreplace) {
1483 $tmp = str_ireplace(
'<'.$tagtoreplace.
'>',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1484 $tmp = str_ireplace(
'</'.$tagtoreplace.
'>',
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1485 $tmp = str_ireplace(
'<'.$tagtoreplace.
' />',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1489 $result = htmlentities($tmp, ENT_COMPAT,
'UTF-8');
1491 if (count($tmparrayoftags)) {
1492 foreach ($tmparrayoftags as $tagtoreplace) {
1493 $result = str_ireplace(
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
'>', $result);
1494 $result = str_ireplace(
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__',
'</'.$tagtoreplace.
'>', $result);
1495 $result = str_ireplace(
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
' />', $result);
1512 if (function_exists(
'mb_strtolower')) {
1513 return mb_strtolower($string, $encoding);
1515 return strtolower($string);
1528 if (function_exists(
'mb_strtoupper')) {
1529 return mb_strtoupper($string, $encoding);
1531 return strtoupper($string);
1544 if (function_exists(
'mb_substr')) {
1545 return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1, null, $encoding);
1547 return ucfirst($string);
1560 if (function_exists(
'mb_convert_case')) {
1561 return mb_convert_case($string, MB_CASE_TITLE, $encoding);
1563 return ucwords($string);
1588 function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
'', $restricttologhandler =
'', $logcontext = null)
1590 global $conf, $user, $debugbar;
1593 if (empty($conf->syslog->enabled)) {
1598 if (defined(
'USEEXTERNALSERVER') && !defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
1599 global $website, $websitekey;
1600 if (is_object($website) && !empty($website->ref)) {
1601 $suffixinfilename .=
'_website_'.$website->ref;
1602 } elseif (!empty($websitekey)) {
1603 $suffixinfilename .=
'_website_'.$websitekey;
1608 if (defined(
'USESUFFIXINLOG')) {
1609 $suffixinfilename .= constant(
'USESUFFIXINLOG');
1613 foreach ($conf->loghandlers as $loghandlerinstance) {
1614 $loghandlerinstance->setIdent($ident);
1618 if (!empty($message)) {
1620 $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');
1621 if (!array_key_exists($level, $logLevels)) {
1622 throw new Exception(
'Incorrect log level');
1624 if ($level > $conf->global->SYSLOG_LEVEL) {
1628 if (empty($conf->global->MAIN_SHOW_PASSWORD_INTO_LOG)) {
1629 $message = preg_replace(
'/password=\'[^\']*\'/',
'password=\'hidden\'', $message);
1633 if ((!empty($_REQUEST[
'logtohtml']) && !empty($conf->global->MAIN_ENABLE_LOG_TO_HTML))
1634 || (!empty($user->rights->debugbar->read) && is_object($debugbar))) {
1635 $conf->logbuffer[] =
dol_print_date(time(),
"%Y-%m-%d %H:%M:%S").
" ".$logLevels[$level].
" ".$message;
1640 if (!empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && !empty($_GET[
"log"])) {
1641 print
"\n\n<!-- Log start\n";
1643 print
"Log end -->\n";
1647 'message' => $message,
1648 'script' => (isset($_SERVER[
'PHP_SELF']) ? basename($_SERVER[
'PHP_SELF'],
'.php') :
false),
1650 'user' => ((is_object($user) && $user->id) ? $user->login :
false),
1655 if (!empty($remoteip)) {
1656 $data[
'ip'] = $remoteip;
1658 if (!empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) && $_SERVER[
'HTTP_X_FORWARDED_FOR'] != $remoteip) {
1659 $data[
'ip'] = $_SERVER[
'HTTP_X_FORWARDED_FOR'].
' -> '.$data[
'ip'];
1660 } elseif (!empty($_SERVER[
'HTTP_CLIENT_IP']) && $_SERVER[
'HTTP_CLIENT_IP'] != $remoteip) {
1661 $data[
'ip'] = $_SERVER[
'HTTP_CLIENT_IP'].
' -> '.$data[
'ip'];
1663 } elseif (!empty($_SERVER[
'SERVER_ADDR'])) {
1665 $data[
'ip'] = $_SERVER[
'SERVER_ADDR'];
1666 } elseif (!empty($_SERVER[
'COMPUTERNAME'])) {
1668 $data[
'ip'] = $_SERVER[
'COMPUTERNAME'].(empty($_SERVER[
'USERNAME']) ?
'' :
'@'.$_SERVER[
'USERNAME']);
1669 } elseif (!empty($_SERVER[
'LOGNAME'])) {
1671 $data[
'ip'] =
'???@'.$_SERVER[
'LOGNAME'];
1675 foreach ($conf->loghandlers as $loghandlerinstance) {
1676 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
1679 $loghandlerinstance->export($data, $suffixinfilename);
1685 foreach ($conf->loghandlers as $loghandlerinstance) {
1686 $loghandlerinstance->setIdent($ident);
1707 if (strpos($url,
'?') > 0) {
1708 $url .=
'&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name);
1710 $url .=
'?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name);
1715 $backtopagejsfieldsid =
''; $backtopagejsfieldslabel =
'';
1716 if ($backtopagejsfields) {
1717 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
1718 if (empty($tmpbacktopagejsfields[1])) {
1719 $backtopagejsfields = $name.
":".$backtopagejsfields;
1720 $tmp2backtopagejsfields = explode(
',', $tmpbacktopagejsfields[0]);
1722 $tmp2backtopagejsfields = explode(
',', $tmpbacktopagejsfields[1]);
1724 $backtopagejsfieldsid = empty($tmp2backtopagejsfields[0]) ?
'' : $tmp2backtopagejsfields[0];
1725 $backtopagejsfieldslabel = empty($tmp2backtopagejsfields[1]) ?
'' : $tmp2backtopagejsfields[1];
1726 $url .=
'&backtopagejsfields='.urlencode($backtopagejsfields);
1730 $out .=
'<!-- a link for button to open url into a dialog popup backtopagejsfields = '.$backtopagejsfields.
' -->'.
"\n";
1731 $out .=
'<a class="cursorpointer button_'.$name.($morecss ?
' '.$morecss :
'').
'"'.$disabled.
' title="'.
dol_escape_htmltag($label).
'">'.$buttonstring.
'</a>';
1732 $out .=
'<div id="idfordialog'.$name.
'" class="hidden">div for dialog</div>';
1733 $out .=
'<div id="varforreturndialogid'.$name.
'" class="hidden">div for returned id</div>';
1734 $out .=
'<div id="varforreturndialoglabel'.$name.
'" class="hidden">div for returned label</div>';
1735 $out .=
'<!-- Add js code to open dialog popup on dialog -->';
1736 $out .=
'<script type="text/javascript">
1737 jQuery(document).ready(function () {
1738 jQuery(".button_'.$name.
'").click(function () {
1739 console.log(\'Open popup with jQuery(...).dialog() on URL '.
dol_escape_js(DOL_URL_ROOT.$url).
'\');
1740 var $tmpdialog = $(\
'#idfordialog'.$name.
'\');
1741 $tmpdialog.html(\
'<iframe class="iframedialog" id="iframedialog'.$name.
'" style="border: 0px;" src="'.DOL_URL_ROOT.$url.
'" width="100%" height="98%"></iframe>\');
1745 height: (window.innerHeight - 150),
1748 open:
function (event, ui) {
1749 console.log(
"open popup name='.$name.', backtopagejsfields='.$backtopagejsfields.'");
1751 close:
function (event, ui) {
1752 returnedid = jQuery(
"#varforreturndialogid'.$name.'").text();
1753 returnedlabel = jQuery(
"#varforreturndialoglabel'.$name.'").text();
1754 console.log(
"popup has been closed. returnedid (js var defined into parent page)="+returnedid+
" returnedlabel="+returnedlabel);
1755 if (returnedid !=
"" && returnedid !=
"div for returned id") {
1756 jQuery(
"#'.(empty($backtopagejsfieldsid)?"none
":$backtopagejsfieldsid).'").val(returnedid);
1758 if (returnedlabel !=
"" && returnedlabel !=
"div for returned label") {
1759 jQuery(
"#'.(empty($backtopagejsfieldslabel)?"none
":$backtopagejsfieldslabel).'").val(returnedlabel);
1764 $tmpdialog.dialog(\
'open\');
1787 function dol_fiche_head($links = array(), $active =
'0', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
1789 print
dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow, $moretabssuffix);
1807 function dol_get_fiche_head($links = array(), $active =
'', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
1809 global $conf, $langs, $hookmanager;
1813 if (!empty($conf->dol_optimize_smallscreen)) {
1817 $out =
"\n".
'<!-- dol_fiche_head - dol_get_fiche_head -->';
1819 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
1820 $out .=
'<div class="tabs'.($picto ?
'' :
' nopaddingleft').
'" data-role="controlgroup" data-type="horizontal">'.
"\n";
1824 if ($morehtmlright) {
1825 $out .=
'<div class="inline-block floatright tabsElem">'.$morehtmlright.
'</div>';
1829 if (!empty($title) && $showtitle && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1831 $out .=
'<a class="tabTitle">';
1833 $noprefix = $pictoisfullpath;
1834 if (strpos($picto,
'fontawesome_') !==
false) {
1837 $out .=
img_picto($title, ($noprefix ?
'' :
'object_').$picto,
'', $pictoisfullpath, 0, 0,
'',
'imgTabTitle').
' ';
1839 $out .=
'<span class="tabTitleText">'.dol_escape_htmltag(
dol_trunc($title, $limittitle)).
'</span>';
1847 if (is_array($links) && !empty($links)) {
1848 $keys = array_keys($links);
1850 $maxkey = max($keys);
1856 if (empty($limittoshow)) {
1857 $limittoshow = (empty($conf->global->MAIN_MAXTABS_IN_CARD) ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD);
1859 if (!empty($conf->dol_optimize_smallscreen)) {
1867 for ($i = 0; $i <= $maxkey; $i++) {
1868 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
1870 if ($i >= $limittoshow) {
1876 for ($i = 0; $i <= $maxkey; $i++) {
1877 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
1883 if ($i < $limittoshow || $isactive) {
1885 $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])).
' -->';
1887 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
1888 if (!empty($links[$i][0])) {
1889 $out .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
1891 $out .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
1893 } elseif (!empty($links[$i][1])) {
1895 $out .=
'<div class="tab tab'.($isactive?
'active':
'unactive').
'" style="margin: 0 !important">';
1896 if (!empty($links[$i][0])) {
1897 $titletoshow = preg_replace(
'/<.*$/',
'', $links[$i][1]);
1898 $out .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="tab inline-block valignmiddle'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'" title="'.
dol_escape_htmltag($titletoshow).
'">';
1900 $out .= $links[$i][1];
1901 if (!empty($links[$i][0])) {
1902 $out .=
'</a>'.
"\n";
1904 $out .= empty($links[$i][4]) ?
'' : $links[$i][4];
1913 $outmore .=
'<div class="popuptabset wordwrap">';
1915 $outmore .=
'<div class="popuptab wordwrap" style="display:inherit;">';
1916 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
1917 if (!empty($links[$i][0])) {
1918 $outmore .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
1920 $outmore .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
1922 } elseif (!empty($links[$i][1])) {
1923 $outmore .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="wordwrap inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
1924 $outmore .= preg_replace(
'/([a-z])\/([a-z])/i',
'\\1 / \\2', $links[$i][1]);
1925 $outmore .=
'</a>'.
"\n";
1927 $outmore .=
'</div>';
1934 $outmore .=
'</div>';
1938 $left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
1939 $right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
1940 $widthofpopup = 200;
1942 $tabsname = $moretabssuffix;
1943 if (empty($tabsname)) {
1944 $tabsname = str_replace(
"@",
"", $picto);
1946 $out .=
'<div id="moretabs'.$tabsname.
'" class="inline-block tabsElem valignmiddle">';
1947 $out .=
'<div class="tab"><a href="#" class="tab moretab inline-block tabunactive"><span class="hideonsmartphone">'.$langs->trans(
"More").
'</span>... ('.$nbintab.
')</a></div>';
1948 $out .=
'<div id="moretabsList'.$tabsname.
'" style="width: '.$widthofpopup.
'px; position: absolute; '.$left.
': -999em; text-align: '.$left.
'; margin:0px; padding:2px; z-index:10;">';
1951 $out .=
'<div></div>';
1955 $out .=
"$('#moretabs".$tabsname.
"').mouseenter( function() {
1956 var x = this.offsetLeft, y = this.offsetTop;
1957 console.log('mouseenter ".$left.
" x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
1958 if ((window.innerWidth - x) < ".($widthofpopup + 10).
") {
1959 $('#moretabsList".$tabsname.
"').css('".$right.
"','8px');
1961 $('#moretabsList".$tabsname.
"').css('".$left.
"','auto');
1964 $out .=
"$('#moretabs".$tabsname.
"').mouseleave( function() { console.log('mouseleave ".$left.
"'); $('#moretabsList".$tabsname.
"').css('".$left.
"','-999em');});";
1965 $out .=
"</script>";
1968 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
1972 if (!$notab || $notab == -1 || $notab == -2) {
1973 $out .=
"\n".
'<div class="tabBar'.($notab == -1 ?
'' : ($notab == -2 ?
' tabBarNoTop' :
' tabBarWithBottom')).
'">'.
"\n";
1976 $parameters = array(
'tabname' => $active,
'out' => $out);
1977 $reshook = $hookmanager->executeHooks(
'printTabsHead', $parameters);
1979 $out = $hookmanager->resPrint;
2005 if (!$notab || $notab == -1) {
2006 return "\n</div>\n";
2031 function dol_banner_tab($object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $onlybanner = 0, $morehtmlright =
'')
2033 global $conf,
$form, $user, $langs, $hookmanager, $action;
2037 $maxvisiblephotos = 1;
2039 $entity = (empty($object->entity) ? $conf->entity : $object->entity);
2040 $showbarcode = empty($conf->barcode->enabled) ? 0 : (empty($object->barcode) ? 0 : 1);
2041 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
2044 $modulepart =
'unknown';
2046 if ($object->element ==
'societe' || $object->element ==
'contact' || $object->element ==
'product' || $object->element ==
'ticket') {
2047 $modulepart = $object->element;
2048 } elseif ($object->element ==
'member') {
2049 $modulepart =
'memberphoto';
2050 } elseif ($object->element ==
'user') {
2051 $modulepart =
'userphoto';
2054 if (class_exists(
"Imagick")) {
2055 if ($object->element ==
'expensereport' || $object->element ==
'propal' || $object->element ==
'commande' || $object->element ==
'facture' || $object->element ==
'supplier_proposal') {
2056 $modulepart = $object->element;
2057 } elseif ($object->element ==
'fichinter') {
2058 $modulepart =
'ficheinter';
2059 } elseif ($object->element ==
'contrat') {
2060 $modulepart =
'contract';
2061 } elseif ($object->element ==
'order_supplier') {
2062 $modulepart =
'supplier_order';
2063 } elseif ($object->element ==
'invoice_supplier') {
2064 $modulepart =
'supplier_invoice';
2068 if ($object->element ==
'product') {
2070 $cssclass =
'photowithmargin photoref';
2071 $showimage = $object->is_photo_available($conf->product->multidir_output[$entity]);
2072 $maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5);
2073 if ($conf->browser->layout ==
'phone') {
2074 $maxvisiblephotos = 1;
2077 $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>';
2079 if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
2081 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2083 $nophoto =
'/public/theme/common/nophoto.png';
2084 $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>';
2087 } elseif ($object->element ==
'ticket') {
2089 $cssclass =
'photoref';
2090 $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity].
'/'.$object->ref);
2091 $maxvisiblephotos = (isset($conf->global->TICKET_MAX_VISIBLE_PHOTO) ? $conf->global->TICKET_MAX_VISIBLE_PHOTO : 2);
2092 if ($conf->browser->layout ==
'phone') {
2093 $maxvisiblephotos = 1;
2097 $showphoto = $object->show_photos(
'ticket', $conf->ticket->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0);
2098 if ($object->nbphoto > 0) {
2099 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$showphoto.
'</div>';
2105 if (!empty($conf->global->TICKET_NODISPLAYIFNOPHOTO)) {
2107 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2109 $nophoto =
img_picto(
'No photo',
'object_ticket');
2110 $morehtmlleft .=
'<!-- No photo to show -->';
2111 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2112 $morehtmlleft .= $nophoto;
2113 $morehtmlleft .=
'</div></div>';
2118 if ($modulepart !=
'unknown') {
2121 if (in_array($modulepart, array(
'propal',
'commande',
'facture',
'ficheinter',
'contract',
'supplier_order',
'supplier_proposal',
'supplier_invoice',
'expensereport')) && class_exists(
"Imagick")) {
2123 $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]).
"/";
2124 if (in_array($modulepart, array(
'invoice_supplier',
'supplier_invoice'))) {
2125 $subdir =
get_exdir($object->id, 2, 0, 1, $object, $modulepart);
2126 $subdir .= ((!empty($subdir) && !preg_match(
'/\/$/', $subdir)) ?
'/' :
'').$objectref;
2128 $subdir =
get_exdir($object->id, 0, 0, 1, $object, $modulepart);
2130 if (empty($subdir)) {
2131 $subdir =
'errorgettingsubdirofobject';
2134 $filepath = $dir_output.$subdir.
"/";
2136 $filepdf = $filepath.$objectref.
".pdf";
2137 $relativepath = $subdir.
'/'.$objectref.
'.pdf';
2140 $fileimage = $filepdf.
'_preview.png';
2141 $relativepathimage = $relativepath.
'_preview.png';
2143 $pdfexists = file_exists($filepdf);
2148 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2149 if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) {
2150 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2159 if ($pdfexists && !$error) {
2160 $heightforphotref = 80;
2161 if (!empty($conf->dol_optimize_smallscreen)) {
2162 $heightforphotref = 60;
2165 if (file_exists($fileimage)) {
2166 $phototoshow =
'<div class="photoref">';
2167 $phototoshow .=
'<img height="'.$heightforphotref.
'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2168 $phototoshow .=
'</div>';
2171 } elseif (!$phototoshow) {
2172 $phototoshow .= $form->showphoto($modulepart, $object, 0, 0, 0,
'photowithmargin photoref',
'small', 1, 0, $maxvisiblephotos);
2176 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
2177 $morehtmlleft .= $phototoshow;
2178 $morehtmlleft .=
'</div>';
2182 if (empty($phototoshow)) {
2183 if ($object->element ==
'action') {
2185 $cssclass =
'photorefcenter';
2186 $nophoto =
img_picto(
'No photo',
'title_agenda');
2189 $cssclass =
'photorefcenter';
2190 $picto = $object->picto;
2191 $prefix =
'object_';
2192 if ($object->element ==
'project' && !$object->public) {
2195 if (strpos($picto,
'fontawesome_') !==
false) {
2198 $nophoto =
img_picto(
'No photo', $prefix.$picto);
2200 $morehtmlleft .=
'<!-- No photo to show -->';
2201 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2202 $morehtmlleft .= $nophoto;
2203 $morehtmlleft .=
'</div></div>';
2209 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object, 100,
'photoref valignmiddle').
'</div>';
2212 if ($object->element ==
'societe') {
2213 if (!empty($conf->use_javascript_ajax) && $user->rights->societe->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
2214 $morehtmlstatus .=
ajax_object_onoff($object,
'status',
'status',
'InActivity',
'ActivityCeased');
2216 $morehtmlstatus .= $object->getLibStatut(6);
2218 } elseif ($object->element ==
'product') {
2220 if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
2221 $morehtmlstatus .=
ajax_object_onoff($object,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
2223 $morehtmlstatus .=
'<span class="statusrefsell">'.$object->getLibStatut(6, 0).
'</span>';
2225 $morehtmlstatus .=
' ';
2227 if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
2228 $morehtmlstatus .=
ajax_object_onoff($object,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
2230 $morehtmlstatus .=
'<span class="statusrefbuy">'.$object->getLibStatut(6, 1).
'</span>';
2232 } elseif (in_array($object->element, array(
'facture',
'invoice',
'invoice_supplier',
'chargesociales',
'loan',
'tva',
'salary'))) {
2233 $tmptxt = $object->getLibStatut(6, $object->totalpaid);
2234 if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
2235 $tmptxt = $object->getLibStatut(5, $object->totalpaid);
2237 $morehtmlstatus .= $tmptxt;
2238 } elseif ($object->element ==
'contrat' || $object->element ==
'contract') {
2239 if ($object->statut == 0) {
2240 $morehtmlstatus .= $object->getLibStatut(5);
2242 $morehtmlstatus .= $object->getLibStatut(4);
2244 } elseif ($object->element ==
'facturerec') {
2245 if ($object->frequency == 0) {
2246 $morehtmlstatus .= $object->getLibStatut(2);
2248 $morehtmlstatus .= $object->getLibStatut(5);
2250 } elseif ($object->element ==
'project_task') {
2251 $object->fk_statut = 1;
2252 if ($object->progress > 0) {
2253 $object->fk_statut = 2;
2255 if ($object->progress >= 100) {
2256 $object->fk_statut = 3;
2258 $tmptxt = $object->getLibStatut(5);
2259 $morehtmlstatus .= $tmptxt;
2261 $tmptxt = $object->getLibStatut(6);
2262 if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) {
2263 $tmptxt = $object->getLibStatut(5);
2265 $morehtmlstatus .= $tmptxt;
2269 if (!empty($conf->accounting->enabled) && in_array($object->element, array(
'bank',
'paiementcharge',
'facture',
'invoice',
'invoice_supplier',
'expensereport',
'payment_various'))) {
2271 if (method_exists($object,
'getVentilExportCompta')) {
2272 $accounted = $object->getVentilExportCompta();
2273 $langs->load(
"accountancy");
2274 $morehtmlstatus .=
'</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? $langs->trans(
"Accounted") : $langs->trans(
"NotYetAccounted")).
'</span>';
2279 if (!empty($object->name_alias)) {
2280 $morehtmlref .=
'<div class="refidno">'.$object->name_alias.
'</div>';
2284 if (in_array($object->element, array(
'product',
'bank_account',
'project_task'))) {
2285 if (!empty($object->label)) {
2286 $morehtmlref .=
'<div class="refidno">'.$object->label.
'</div>';
2291 if (method_exists($object,
'getBannerAddress') && !in_array($object->element, array(
'product',
'bookmark',
'ecm_directories',
'ecm_files'))) {
2292 $moreaddress = $object->getBannerAddress(
'refaddress', $object);
2294 $morehtmlref .=
'<div class="refidno">';
2295 $morehtmlref .= $moreaddress;
2296 $morehtmlref .=
'</div>';
2299 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)) {
2300 $morehtmlref .=
'<div style="clear: both;"></div>';
2301 $morehtmlref .=
'<div class="refidno">';
2302 $morehtmlref .= $langs->trans(
"TechnicalID").
': '.$object->id;
2303 $morehtmlref .=
'</div>';
2306 $parameters=array(
'morehtmlref'=>$morehtmlref);
2307 $reshook = $hookmanager->executeHooks(
'formDolBanner', $parameters, $object, $action);
2310 } elseif (empty($reshook)) {
2311 $morehtmlref .= $hookmanager->resPrint;
2312 } elseif ($reshook > 0) {
2313 $morehtmlref = $hookmanager->resPrint;
2317 print
'<div class="'.($onlybanner ?
'arearefnobottom ' :
'arearef ').
'heightref valignmiddle centpercent">';
2318 print $form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
2320 print
'<div class="underrefbanner clearboth"></div>';
2336 if ($fieldrequired) {
2337 $ret .=
'<span class="fieldrequired">';
2339 $ret .=
'<label for="'.$fieldkey.
'">';
2340 $ret .= $langs->trans($langkey);
2342 if ($fieldrequired) {
2358 $ret =
' '.$bc[$var];
2360 $ret = preg_replace(
'/class=\"/',
'class="'.$moreclass.
' ', $ret);
2378 function dol_format_address($object, $withcountry = 0, $sep =
"\n", $outputlangs =
'', $mode = 0, $extralangcode =
'')
2380 global $conf, $langs, $hookmanager;
2383 $countriesusingstate = array(
'AU',
'CA',
'US',
'IN',
'GB',
'ES',
'UK',
'TR',
'CN');
2388 $ret .= ($extralangcode ? $object->array_languages[
'address'][$extralangcode] : (empty($object->address) ?
'' : $object->address));
2391 if (isset($object->country_code) && in_array($object->country_code, array(
'AU',
'CA',
'US',
'CN')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) {
2393 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2394 $ret .= (($ret && $town) ? $sep :
'').$town;
2396 if (!empty($object->state)) {
2397 $ret .= ($ret ? ($town ?
", " : $sep) :
'').$object->state;
2399 if (!empty($object->zip)) {
2400 $ret .= ($ret ? (($town || $object->state) ?
", " : $sep) :
'').$object->zip;
2402 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'GB',
'UK'))) {
2404 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2405 $ret .= ($ret ? $sep :
'').$town;
2406 if (!empty($object->state)) {
2407 $ret .= ($ret ?
", " :
'').$object->state;
2409 if (!empty($object->zip)) {
2410 $ret .= ($ret ? $sep :
'').$object->zip;
2412 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'ES',
'TR'))) {
2414 $ret .= ($ret ? $sep :
'').$object->zip;
2415 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2416 $ret .= ($town ? (($object->zip ?
' ' :
'').$town) :
'');
2417 if (!empty($object->state)) {
2418 $ret .=
"\n".$object->state;
2420 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'JP'))) {
2423 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2424 $ret .= ($ret ? $sep :
'').($object->state ? $object->state.
', ' :
'').$town.($object->zip ?
' ' :
'').$object->zip;
2425 } elseif (isset($object->country_code) && in_array($object->country_code, array(
'IT'))) {
2427 $ret .= ($ret ? $sep :
'').$object->zip;
2428 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2429 $ret .= ($town ? (($object->zip ?
' ' :
'').$town) :
'');
2430 $ret .= (empty($object->state_code) ?
'' : (
' '.$object->state_code));
2433 $town = ($extralangcode ? $object->array_languages[
'town'][$extralangcode] : (empty($object->town) ?
'' : $object->town));
2434 $ret .= !empty($object->zip) ? (($ret ? $sep :
'').$object->zip) :
'';
2435 $ret .= ($town ? (($object->zip ?
' ' : ($ret ? $sep :
'')).$town) :
'');
2436 if (!empty($object->state) && in_array($object->country_code, $countriesusingstate)) {
2437 $ret .= ($ret ?
", " :
'').$object->state;
2440 if (!is_object($outputlangs)) {
2441 $outputlangs = $langs;
2444 $langs->load(
"dict");
2445 $ret .= (empty($object->country_code) ?
'' : ($ret ? $sep :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$object->country_code)));
2448 $parameters = array(
'withcountry' => $withcountry,
'sep' => $sep,
'outputlangs' => $outputlangs,
'mode' => $mode,
'extralangcode' => $extralangcode);
2449 $reshook = $hookmanager->executeHooks(
'formatAddress', $parameters, $object);
2453 $ret .= $hookmanager->resPrint;
2471 if ((abs($ts) <= 0x7FFFFFFF)) {
2472 return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts);
2474 return 'Error date into a not supported range';
2499 function dol_print_date($time, $format =
'', $tzoutput =
'auto', $outputlangs =
'', $encodetooutput =
false)
2501 global $conf, $langs;
2508 if ($tzoutput ===
'auto') {
2509 $tzoutput = (empty($conf) ?
'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey :
'tzserver'));
2514 $offsettz = $offsetdst = 0;
2517 if (is_string($tzoutput)) {
2518 if ($tzoutput ==
'tzserver') {
2520 $offsettzstring = @date_default_timezone_get();
2523 } elseif ($tzoutput ==
'tzuser' || $tzoutput ==
'tzuserrel') {
2525 $offsettzstring = (empty($_SESSION[
'dol_tz_string']) ?
'UTC' : $_SESSION[
'dol_tz_string']);
2527 if (class_exists(
'DateTimeZone')) {
2528 $user_date_tz =
new DateTimeZone($offsettzstring);
2529 $user_dt =
new DateTime();
2530 $user_dt->setTimezone($user_date_tz);
2531 $user_dt->setTimestamp($tzoutput ==
'tzuser' ?
dol_now() : (
int) $time);
2532 $offsettz = $user_dt->getOffset();
2534 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
2535 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
2540 if (!is_object($outputlangs)) {
2541 $outputlangs = $langs;
2544 $format =
'daytextshort';
2549 $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array(
'day',
'dayhour'))) ? 1 : 0;
2550 $format = preg_replace(
'/inputnoreduce/',
'', $format);
2551 $formatwithoutreduce = preg_replace(
'/reduceformat/',
'', $format);
2552 if ($formatwithoutreduce != $format) {
2553 $format = $formatwithoutreduce;
2559 if ($format ==
'day') {
2560 $format = ($outputlangs->trans(
"FormatDateShort") !=
"FormatDateShort" ? $outputlangs->trans(
"FormatDateShort") : $conf->format_date_short);
2561 } elseif ($format ==
'hour') {
2562 $format = ($outputlangs->trans(
"FormatHourShort") !=
"FormatHourShort" ? $outputlangs->trans(
"FormatHourShort") : $conf->format_hour_short);
2563 } elseif ($format ==
'hourduration') {
2564 $format = ($outputlangs->trans(
"FormatHourShortDuration") !=
"FormatHourShortDuration" ? $outputlangs->trans(
"FormatHourShortDuration") : $conf->format_hour_short_duration);
2565 } elseif ($format ==
'daytext') {
2566 $format = ($outputlangs->trans(
"FormatDateText") !=
"FormatDateText" ? $outputlangs->trans(
"FormatDateText") : $conf->format_date_text);
2567 } elseif ($format ==
'daytextshort') {
2568 $format = ($outputlangs->trans(
"FormatDateTextShort") !=
"FormatDateTextShort" ? $outputlangs->trans(
"FormatDateTextShort") : $conf->format_date_text_short);
2569 } elseif ($format ==
'dayhour') {
2570 $format = ($outputlangs->trans(
"FormatDateHourShort") !=
"FormatDateHourShort" ? $outputlangs->trans(
"FormatDateHourShort") : $conf->format_date_hour_short);
2571 } elseif ($format ==
'dayhoursec') {
2572 $format = ($outputlangs->trans(
"FormatDateHourSecShort") !=
"FormatDateHourSecShort" ? $outputlangs->trans(
"FormatDateHourSecShort") : $conf->format_date_hour_sec_short);
2573 } elseif ($format ==
'dayhourtext') {
2574 $format = ($outputlangs->trans(
"FormatDateHourText") !=
"FormatDateHourText" ? $outputlangs->trans(
"FormatDateHourText") : $conf->format_date_hour_text);
2575 } elseif ($format ==
'dayhourtextshort') {
2576 $format = ($outputlangs->trans(
"FormatDateHourTextShort") !=
"FormatDateHourTextShort" ? $outputlangs->trans(
"FormatDateHourTextShort") : $conf->format_date_hour_text_short);
2577 } elseif ($format ==
'dayhourlog') {
2579 $format =
'%Y%m%d%H%M%S';
2580 } elseif ($format ==
'dayhourlogsmall') {
2582 $format =
'%Y%m%d%H%M';
2583 } elseif ($format ==
'dayhourldap') {
2584 $format =
'%Y%m%d%H%M%SZ';
2585 } elseif ($format ==
'dayhourxcard') {
2586 $format =
'%Y%m%dT%H%M%SZ';
2587 } elseif ($format ==
'dayxcard') {
2589 } elseif ($format ==
'dayrfc') {
2590 $format =
'%Y-%m-%d';
2591 } elseif ($format ==
'dayhourrfc') {
2592 $format =
'%Y-%m-%dT%H:%M:%SZ';
2593 } elseif ($format ==
'standard') {
2594 $format =
'%Y-%m-%d %H:%M:%S';
2597 if ($reduceformat) {
2598 $format = str_replace(
'%Y',
'%y', $format);
2599 $format = str_replace(
'yyyy',
'yy', $format);
2603 if (preg_match(
'/%b/i', $format)) {
2605 $format = str_replace(
'%b',
'__b__', $format);
2606 $format = str_replace(
'%B',
'__B__', $format);
2608 if (preg_match(
'/%a/i', $format)) {
2610 $format = str_replace(
'%a',
'__a__', $format);
2611 $format = str_replace(
'%A',
'__A__', $format);
2617 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)) {
2618 dol_print_error(
'',
"Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER[
"PHP_SELF"]);
2620 } elseif (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)) {
2622 dol_syslog(
"Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER[
"PHP_SELF"], LOG_WARNING);
2625 $syear = (!empty($reg[1]) ? $reg[1] :
'');
2626 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
2627 $sday = (!empty($reg[3]) ? $reg[3] :
'');
2628 $shour = (!empty($reg[4]) ? $reg[4] :
'');
2629 $smin = (!empty($reg[5]) ? $reg[5] :
'');
2630 $ssec = (!empty($reg[6]) ? $reg[6] :
'');
2632 $time =
dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear,
true);
2633 $ret = adodb_strftime($format, $time + $offsettz + $offsetdst, $to_gmt);
2636 if ($time < 100000000000) {
2637 $timetouse = $time + $offsettz + $offsetdst;
2639 $ret = adodb_strftime($format, $timetouse, $to_gmt);
2641 $ret =
'Bad value '.$time.
' for date';
2645 if (preg_match(
'/__b__/i', $format)) {
2646 $timetouse = $time + $offsettz + $offsetdst;
2649 $month = adodb_strftime(
'%m', $timetouse, $to_gmt);
2650 $month = sprintf(
"%02d", $month);
2651 if ($encodetooutput) {
2652 $monthtext = $outputlangs->transnoentities(
'Month'.$month);
2653 $monthtextshort = $outputlangs->transnoentities(
'MonthShort'.$month);
2655 $monthtext = $outputlangs->transnoentitiesnoconv(
'Month'.$month);
2656 $monthtextshort = $outputlangs->transnoentitiesnoconv(
'MonthShort'.$month);
2659 $ret = str_replace(
'__b__', $monthtextshort, $ret);
2660 $ret = str_replace(
'__B__', $monthtext, $ret);
2664 if (preg_match(
'/__a__/i', $format)) {
2666 $timetouse = $time + $offsettz + $offsetdst;
2668 $w = adodb_strftime(
'%w', $timetouse, $to_gmt);
2669 $dayweek = $outputlangs->transnoentitiesnoconv(
'Day'.$w);
2670 $ret = str_replace(
'__A__', $dayweek, $ret);
2671 $ret = str_replace(
'__a__',
dol_substr($dayweek, 0, 3), $ret);
2701 $datetimeobj =
new DateTime();
2702 $datetimeobj->setTimestamp($timestamp);
2703 if ($forcetimezone) {
2704 $datetimeobj->setTimezone(
new DateTimeZone($forcetimezone ==
'gmt' ?
'UTC' : $forcetimezone));
2707 'year'=>((
int) date_format($datetimeobj,
'Y')),
2708 'mon'=>((
int) date_format($datetimeobj,
'm')),
2709 'mday'=>((
int) date_format($datetimeobj,
'd')),
2710 'wday'=>((
int) date_format($datetimeobj,
'w')),
2711 'yday'=>((
int) date_format($datetimeobj,
'z')),
2712 'hours'=>((
int) date_format($datetimeobj,
'H')),
2713 'minutes'=>((
int) date_format($datetimeobj,
'i')),
2714 'seconds'=>((
int) date_format($datetimeobj,
's')),
2742 function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm =
'auto', $check = 1)
2747 if ($gm ===
'auto') {
2748 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
2753 if ($hour == -1 || empty($hour)) {
2756 if ($minute == -1 || empty($minute)) {
2759 if ($second == -1 || empty($second)) {
2765 if (!$month || !$day) {
2774 if ($hour < 0 || $hour > 24) {
2777 if ($minute < 0 || $minute > 60) {
2780 if ($second < 0 || $second > 60) {
2785 if (empty($gm) || ($gm ===
'server' || $gm ===
'tzserver')) {
2786 $default_timezone = @date_default_timezone_get();
2787 $localtz =
new DateTimeZone($default_timezone);
2788 } elseif ($gm ===
'user' || $gm ===
'tzuser' || $gm ===
'tzuserrel') {
2790 $default_timezone = (empty($_SESSION[
"dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION[
"dol_tz_string"]);
2792 $localtz =
new DateTimeZone($default_timezone);
2794 dol_syslog(
"Warning dol_tz_string contains an invalid value ".$_SESSION[
"dol_tz_string"], LOG_WARNING);
2795 $default_timezone = @date_default_timezone_get();
2797 } elseif (strrpos($gm,
"tz,") !==
false) {
2798 $timezone = str_replace(
"tz,",
"", $gm);
2800 $localtz =
new DateTimeZone($timezone);
2802 dol_syslog(
"Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
2806 if (empty($localtz)) {
2807 $localtz =
new DateTimeZone(
'UTC');
2811 $dt =
new DateTime(
'now', $localtz);
2812 $dt->setDate((
int) $year, (
int) $month, (
int) $day);
2813 $dt->setTime((
int) $hour, (
int) $minute, (
int) $second);
2814 $date = $dt->getTimestamp();
2834 if ($mode ===
'auto') {
2838 if ($mode ==
'gmt') {
2840 } elseif ($mode ==
'tzserver') {
2841 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
2843 $ret = (int) (
dol_now(
'gmt') + ($tzsecond * 3600));
2849 } elseif ($mode ==
'tzuser' || $mode ==
'tzuserrel') {
2852 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
2853 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
2854 $ret = (int) (
dol_now(
'gmt') + ($offsettz + $offsetdst));
2871 global $conf, $langs;
2874 if (!empty($conf->dol_optimize_smallscreen)) {
2879 if (empty($shortvalue) || $size < ($level * 10)) {
2881 $textunitshort = $langs->trans(
"b");
2882 $textunitlong = $langs->trans(
"Bytes");
2884 $ret = round($size / $level, 0);
2885 $textunitshort = $langs->trans(
"Kb");
2886 $textunitlong = $langs->trans(
"KiloBytes");
2889 if (empty($shortunit)) {
2890 $ret .=
' '.$textunitlong;
2892 $ret .=
' '.$textunitshort;
2915 $link =
'<a href="';
2916 if (!preg_match(
'/^http/i', $url)) {
2922 $link .=
' target="'.$target.
'"';
2925 if (!preg_match(
'/^http/i', $url)) {
2930 return '<div class="nospan float" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe').
' ' :
'').$link.
'</div>';
2945 function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0)
2947 global $conf, $user, $langs, $hookmanager;
2951 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpicto) {
2955 if (empty($email)) {
2959 if (!empty($addlink)) {
2960 $newemail =
'<a style="text-overflow: ellipsis;" href="';
2961 if (!preg_match(
'/^mailto:/i', $email)) {
2962 $newemail .=
'mailto:';
2964 $newemail .= $email;
2967 $newemail .=
'</a>';
2969 $langs->load(
"errors");
2970 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
2973 if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
2976 if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) {
2977 $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>';
2980 $newemail =
'<div>'.$newemail.
' '.$link.
'</div>';
2985 $langs->load(
"errors");
2986 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
2991 $rep = ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto)).
' ' :
'').$newemail;
2994 $parameters = array(
'cid' => $cid,
'socid' => $socid,
'addlink' => $addlink,
'picto' => $withpicto);
2996 $reshook = $hookmanager->executeHooks(
'printEmail', $parameters, $email);
3000 $rep .= $hookmanager->resPrint;
3015 $socialnetworks = array();
3017 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
3018 $cachekey =
'socialnetworks_' . $conf->entity;
3020 if (!is_null($dataretrieved)) {
3021 $socialnetworks = $dataretrieved;
3023 $sql =
"SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX.
"c_socialnetworks";
3024 $sql .=
" WHERE entity=".$conf->entity;
3025 $resql = $db->query($sql);
3027 while ($obj = $db->fetch_object(
$resql)) {
3028 $socialnetworks[$obj->code] = array(
3029 'rowid' => $obj->rowid,
3030 'label' => $obj->label,
3032 'icon' => $obj->icon,
3033 'active' => $obj->active,
3040 return $socialnetworks;
3055 global $conf, $user, $langs;
3059 if (empty($value)) {
3063 if (!empty($type)) {
3064 $htmllink =
'<div class="divsocialnetwork inline-block valignmiddle">';
3066 $htmllink .=
'<span class="fa paddingright '.($dictsocialnetworks[$type][
'icon'] ? $dictsocialnetworks[$type][
'icon'] :
'fa-link').
'"></span>';
3067 if ($type ==
'skype') {
3069 $htmllink .=
' ';
3070 $htmllink .=
'<a href="skype:';
3072 $htmllink .=
'?call" alt="'.$langs->trans(
"Call").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Call").
' '.$value).
'">';
3073 $htmllink .=
'<img src="'.DOL_URL_ROOT.
'/theme/common/skype_callbutton.png" border="0">';
3074 $htmllink .=
'</a><a href="skype:';
3076 $htmllink .=
'?chat" alt="'.$langs->trans(
"Chat").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Chat").
' '.$value).
'">';
3077 $htmllink .=
'<img class="paddingleft" src="'.DOL_URL_ROOT.
'/theme/common/skype_chatbutton.png" border="0">';
3078 $htmllink .=
'</a>';
3079 if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
3080 $addlink =
'AC_SKYPE';
3082 if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) {
3083 $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>';
3085 $htmllink .= ($link ?
' '.$link :
'');
3088 if (!empty($dictsocialnetworks[$type][
'url'])) {
3089 $tmpvirginurl = preg_replace(
'/\/?{socialid}/',
'', $dictsocialnetworks[$type][
'url']);
3090 if ($tmpvirginurl) {
3091 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3092 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3094 $tmpvirginurl3 = preg_replace(
'/^https:\/\//i',
'https://www.', $tmpvirginurl);
3095 if ($tmpvirginurl3) {
3096 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3097 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3100 $tmpvirginurl2 = preg_replace(
'/^https?:\/\//i',
'', $tmpvirginurl);
3101 if ($tmpvirginurl2) {
3102 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3103 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3106 $link = str_replace(
'{socialid}', $value, $dictsocialnetworks[$type][
'url']);
3107 if (preg_match(
'/^https?:\/\//i', $link)) {
3108 $htmllink .=
' <a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3110 $htmllink .=
' <a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3116 $htmllink .=
'</div>';
3118 $langs->load(
"errors");
3119 $htmllink .=
img_warning($langs->trans(
"ErrorBadSocialNetworkValue", $value));
3134 function dol_print_profids($profID, $profIDtype, $countrycode =
'', $addcpButton = 1, $separ =
' ')
3138 if (empty($profID) || empty($profIDtype)) {
3141 if (empty($countrycode)) $countrycode = $mysoc->country_code;
3142 $newProfID = $profID;
3143 $id = substr($profIDtype, -1);
3145 if (strtoupper($countrycode) ==
'FR') {
3147 if ($id == 1 &&
dol_strlen($newProfID) == 9) $newProfID = substr($newProfID, 0, 3).$separ.substr($newProfID, 3, 3).$separ.substr($newProfID, 6, 3);
3148 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);
3149 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);
3152 else $ret = $newProfID;
3170 function dol_print_phone($phone, $countrycode =
'', $cid = 0, $socid = 0, $addlink =
'', $separ =
" ", $withpicto =
'', $titlealt =
'', $adddivfloat = 0)
3172 global $conf, $user, $langs, $mysoc, $hookmanager;
3175 $phone = preg_replace(
"/[\s.-]/",
"", trim($phone));
3176 if (empty($phone)) {
3179 if (!empty($conf->global->MAIN_PHONE_SEPAR)) {
3180 $separ = $conf->global->MAIN_PHONE_SEPAR;
3182 if (empty($countrycode) && is_object($mysoc)) {
3183 $countrycode = $mysoc->country_code;
3187 if ($conf->dol_optimize_smallscreen) {
3192 if (strtoupper($countrycode) ==
"FR") {
3195 $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);
3197 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
3199 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
3201 $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);
3203 $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);
3205 $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);
3207 } elseif (strtoupper($countrycode) ==
"CA") {
3209 $newphone = ($separ !=
'' ?
'(' :
'').substr($newphone, 0, 3).($separ !=
'' ?
')' :
'').$separ.substr($newphone, 3, 3).($separ !=
'' ?
'-' :
'').substr($newphone, 6, 4);
3211 } elseif (strtoupper($countrycode) ==
"PT") {
3213 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3215 } elseif (strtoupper($countrycode) ==
"SR") {
3217 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
3219 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
3221 } elseif (strtoupper($countrycode) ==
"DE") {
3223 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
3225 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
3227 } elseif (strtoupper($countrycode) ==
"ES") {
3229 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3231 } elseif (strtoupper($countrycode) ==
"BF") {
3233 $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);
3235 } elseif (strtoupper($countrycode) ==
"RO") {
3237 $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);
3239 } elseif (strtoupper($countrycode) ==
"TR") {
3241 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
3243 } elseif (strtoupper($countrycode) ==
"US") {
3245 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
3247 } elseif (strtoupper($countrycode) ==
"MX") {
3249 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
3251 $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);
3253 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
3255 } elseif (strtoupper($countrycode) ==
"ML") {
3257 $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);
3259 } elseif (strtoupper($countrycode) ==
"TH") {
3261 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
3263 $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);
3265 } elseif (strtoupper($countrycode) ==
"MU") {
3268 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
3270 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
3272 } elseif (strtoupper($countrycode) ==
"ZA") {
3274 $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);
3276 } elseif (strtoupper($countrycode) ==
"SY") {
3278 $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);
3280 $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);
3282 } elseif (strtoupper($countrycode) ==
"AE") {
3284 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
3286 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3288 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
3290 } elseif (strtoupper($countrycode) ==
"DZ") {
3292 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3294 } elseif (strtoupper($countrycode) ==
"BE") {
3296 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
3298 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3300 } elseif (strtoupper($countrycode) ==
"PF") {
3302 $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);
3304 } elseif (strtoupper($countrycode) ==
"CO") {
3306 $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);
3308 } elseif (strtoupper($countrycode) ==
"JO") {
3310 $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);
3312 } elseif (strtoupper($countrycode) ==
"JM") {
3314 $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
3316 } elseif (strtoupper($countrycode) ==
"MG") {
3318 $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);
3320 } elseif (strtoupper($countrycode) ==
"GB") {
3322 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
3324 } elseif (strtoupper($countrycode) ==
"CH") {
3326 $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);
3328 $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);
3330 } elseif (strtoupper($countrycode) ==
"TN") {
3332 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3334 } elseif (strtoupper($countrycode) ==
"GF") {
3336 $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);
3338 } elseif (strtoupper($countrycode) ==
"GP") {
3340 $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);
3342 } elseif (strtoupper($countrycode) ==
"MQ") {
3344 $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);
3346 } elseif (strtoupper($countrycode) ==
"IT") {
3348 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
3350 $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);
3352 } elseif (strtoupper($countrycode) ==
"AU") {
3356 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
3359 if (!empty($addlink)) {
3360 if ($conf->browser->layout ==
'phone' || (!empty($conf->clicktodial->enabled) && !empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) {
3361 $newphoneform = $newphone;
3362 $newphone =
'<a href="tel:'.$phone.
'"';
3363 $newphone .=
'>'.$newphoneform.
'</a>';
3364 } elseif (!empty($conf->clicktodial->enabled) && $addlink ==
'AC_TEL') {
3365 if (empty($user->clicktodial_loaded)) {
3366 $user->fetch_clicktodial();
3370 $urlmask =
'ErrorClickToDialModuleNotConfigured';
3371 if (!empty($conf->global->CLICKTODIAL_URL)) {
3372 $urlmask = $conf->global->CLICKTODIAL_URL;
3374 if (!empty($user->clicktodial_url)) {
3375 $urlmask = $user->clicktodial_url;
3378 $clicktodial_poste = (!empty($user->clicktodial_poste) ?urlencode($user->clicktodial_poste) :
'');
3379 $clicktodial_login = (!empty($user->clicktodial_login) ?urlencode($user->clicktodial_login) :
'');
3380 $clicktodial_password = (!empty($user->clicktodial_password) ?urlencode($user->clicktodial_password) :
'');
3382 $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
3384 $substitarray = array(
'__PHONEFROM__'=>$clicktodial_poste,
3385 '__PHONETO__'=>urlencode($phone),
3386 '__LOGIN__'=>$clicktodial_login,
3387 '__PASS__'=>$clicktodial_password);
3389 $newphonesav = $newphone;
3390 if (empty($conf->global->CLICKTODIAL_DO_NOT_USE_AJAX_CALL)) {
3392 $newphone =
'<a href="'.$url.
'" class="cssforclicktodial"';
3393 $newphone .=
'>'.$newphonesav.
'</a>';
3396 $newphone =
'<a href="'.$url.
'"';
3397 if (!empty($conf->global->CLICKTODIAL_FORCENEWTARGET)) {
3398 $newphone .=
' target="_blank" rel="noopener noreferrer"';
3400 $newphone .=
'>'.$newphonesav.
'</a>';
3405 if (
isModEnabled(
'agenda') && $user->rights->agenda->myactions->create) {
3408 if ($addlink ==
'AC_FAX') {
3411 if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE)) {
3412 $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>';
3415 $newphone =
'<div>'.$newphone.
' '.$link.
'</div>';
3420 if (empty($titlealt)) {
3421 $titlealt = ($withpicto ==
'fax' ? $langs->trans(
"Fax") : $langs->trans(
"Phone"));
3426 $parameters = array(
'countrycode' => $countrycode,
'cid' => $cid,
'socid' => $socid,
'titlealt' => $titlealt,
'picto' => $withpicto);
3427 $reshook = $hookmanager->executeHooks(
'printPhone', $parameters, $phone);
3428 $rep .= $hookmanager->resPrint;
3430 if (empty($reshook)) {
3433 if ($withpicto ==
'fax') {
3434 $picto =
'phoning_fax';
3435 } elseif ($withpicto ==
'phone') {
3437 } elseif ($withpicto ==
'mobile') {
3438 $picto =
'phoning_mobile';
3444 $rep .=
'<div class="nospan float" style="margin-right: 10px">';
3446 $rep .=
'<span style="margin-right: 10px;">';
3448 $rep .= ($withpicto ?
img_picto($titlealt,
'object_'.$picto.
'.png').
' ' :
'').$newphone;
3468 global $conf, $langs;
3479 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/common/flags/'.$countrycode.
'.png')) {
3480 $ret .=
' '.img_picto($countrycode.
' '.$langs->trans(
"AccordingToGeoIPDatabase"), DOL_URL_ROOT.
'/theme/common/flags/'.$countrycode.
'.png',
'', 1);
3482 $ret .=
' ('.$countrycode.
')';
3502 if (empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
3503 if (empty($_SERVER[
'HTTP_CLIENT_IP']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_CLIENT_IP'])) {
3504 if (empty($_SERVER[
"HTTP_CF_CONNECTING_IP"])) {
3505 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
3507 $ip = $_SERVER[
"HTTP_CF_CONNECTING_IP"];
3510 $ip = $_SERVER[
'HTTP_CLIENT_IP'];
3513 $ip = $_SERVER[
'HTTP_X_FORWARDED_FOR'];
3529 if (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on') {
3531 } 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') {
3549 if (!empty($conf->geoipmaxmind->enabled)) {
3553 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
3554 $geoip =
new DolGeoIP(
'country', $datafile);
3556 $countrycode = $geoip->getCountryCodeFromIP($ip);
3559 return $countrycode;
3571 global $conf, $langs, $user;
3575 if (!empty($conf->geoipmaxmind->enabled)) {
3580 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
3581 $geoip =
new DolGeoIP(
'country', $datafile);
3582 $countrycode = $geoip->getCountryCodeFromIP($ip);
3583 $ret = $countrycode;
3602 global $conf, $user, $langs, $hookmanager;
3608 $parameters = array(
'element' => $element,
'id' => $id);
3609 $reshook = $hookmanager->executeHooks(
'printAddress', $parameters, $address);
3610 $out .= $hookmanager->resPrint;
3612 if (empty($reshook)) {
3613 if (empty($charfornl)) {
3614 $out .= nl2br($address);
3616 $out .= preg_replace(
'/[\r\n]+/', $charfornl, $address);
3620 $showgmap = $showomap = 0;
3621 if (($element ==
'thirdparty' || $element ==
'societe') && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) {
3624 if ($element ==
'contact' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) {
3627 if ($element ==
'member' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) {
3630 if (($element ==
'thirdparty' || $element ==
'societe') && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) {
3633 if ($element ==
'contact' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) {
3636 if ($element ==
'member' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) {
3640 $url =
dol_buildpath(
'/google/gmaps.php?mode='.$element.
'&id='.$id, 1);
3641 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
3644 $url =
dol_buildpath(
'/openstreetmap/maps.php?mode='.$element.
'&id='.$id, 1);
3645 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
3666 function isValidEmail($address, $acceptsupervisorkey = 0, $acceptuserkey = 0)
3668 if ($acceptsupervisorkey && $address ==
'__SUPERVISOREMAIL__') {
3671 if ($acceptuserkey && $address ==
'__USER_EMAIL__') {
3674 if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
3691 if (function_exists(
'idn_to_ascii') && function_exists(
'checkdnsrr')) {
3692 if (!checkdnsrr(idn_to_ascii($domain),
'MX')) {
3695 if (function_exists(
'getmxrr')) {
3698 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
3699 if (count($mxhosts) > 1) {
3702 if (count($mxhosts) == 1 && !empty($mxhosts[0])) {
3734 if (function_exists(
'mb_strlen')) {
3735 return mb_strlen($string, $stringencoding);
3737 return strlen($string);
3751 function dol_substr($string, $start, $length, $stringencoding =
'', $trunconbytes = 0)
3755 if (empty($stringencoding)) {
3756 $stringencoding = $langs->charset_output;
3760 if (empty($trunconbytes)) {
3761 if (function_exists(
'mb_substr')) {
3762 $ret = mb_substr($string, $start, $length, $stringencoding);
3764 $ret = substr($string, $start, $length);
3767 if (function_exists(
'mb_strcut')) {
3768 $ret = mb_strcut($string, $start, $length, $stringencoding);
3770 $ret = substr($string, $start, $length);
3790 function dol_trunc($string, $size = 40, $trunc =
'right', $stringencoding =
'UTF-8', $nodot = 0, $display = 0)
3794 if (empty($size) || !empty($conf->global->MAIN_DISABLE_TRUNC)) {
3798 if (empty($stringencoding)) {
3799 $stringencoding =
'UTF-8';
3802 if ($conf->dol_optimize_smallscreen == 1 && $display == 1) {
3803 $size = round($size / 3);
3807 if ($trunc ==
'right') {
3809 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
3811 return dol_substr($newstring, 0, $size, $stringencoding).($nodot ?
'' :
'…');
3816 } elseif ($trunc ==
'middle') {
3818 if (
dol_strlen($newstring, $stringencoding) > 2 &&
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
3819 $size1 = round($size / 2);
3820 $size2 = round($size / 2);
3821 return dol_substr($newstring, 0, $size1, $stringencoding).
'…'.
dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
3825 } elseif ($trunc ==
'left') {
3827 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
3829 return '…'.dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
3833 } elseif ($trunc ==
'wrap') {
3835 if (
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
3841 return 'BadParam3CallingDolTrunc';
3865 function img_picto($titlealt, $picto, $moreatt =
'', $pictoisfullpath =
false, $srconly = 0, $notitle = 0, $alt =
'', $morecss =
'', $marginleftonlyshort = 2)
3867 global $conf, $langs;
3870 $url = DOL_URL_ROOT;
3871 $theme = isset($conf->theme) ? $conf->theme : null;
3872 $path =
'theme/'.$theme;
3874 if ($pictoisfullpath) {
3876 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
3879 $fullpathpicto = $picto;
3881 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
3882 $morecss .= ($morecss ?
' ' :
'').$reg[1];
3883 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
3886 $pictowithouttext = preg_replace(
'/(\.png|\.gif|\.svg)$/',
'', $picto);
3887 $pictowithouttext = str_replace(
'object_',
'', $pictowithouttext);
3889 if (strpos($pictowithouttext,
'fontawesome_') !==
false || preg_match(
'/^fa-/', $pictowithouttext)) {
3891 $pictowithouttext = str_replace(
'fa-',
'', $pictowithouttext);
3892 $pictowithouttextarray = explode(
'_', $pictowithouttext);
3893 $marginleftonlyshort = 0;
3895 if (!empty($pictowithouttextarray[1])) {
3896 $fakey =
'fa-'.$pictowithouttextarray[1];
3897 $fa = empty($pictowithouttextarray[2]) ?
'fa' : $pictowithouttextarray[2];
3898 $facolor = empty($pictowithouttextarray[3]) ?
'' : $pictowithouttextarray[3];
3899 $fasize = empty($pictowithouttextarray[4]) ?
'' : $pictowithouttextarray[4];
3901 $fakey =
'fa-'.$pictowithouttext;
3911 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
3912 $morecss .= ($morecss ?
' ' :
'').$reg[1];
3913 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
3915 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
3916 $morestyle = $reg[1];
3917 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
3919 $moreatt = trim($moreatt);
3921 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
3922 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
3926 $enabledisablehtml .=
'</span>';
3928 return $enabledisablehtml;
3931 if (empty($srconly) && in_array($pictowithouttext, array(
3932 '1downarrow',
'1uparrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected',
3933 'accountancy',
'accounting_account',
'account',
'accountline',
'action',
'add',
'address',
'angle-double-down',
'angle-double-up',
'asset',
3934 'bank_account',
'barcode',
'bank',
'bell',
'bill',
'billa',
'billr',
'billd',
'bookmark',
'bom',
'briefcase-medical',
'bug',
'building',
3935 'card',
'calendarlist',
'calendar',
'calendarmonth',
'calendarweek',
'calendarday',
'calendarperuser',
'calendarpertype',
3936 'cash-register',
'category',
'chart',
'check',
'clock',
'close_title',
'cog',
'collab',
'company',
'contact',
'country',
'contract',
'conversation',
'cron',
'cubes',
3937 'currency',
'multicurrency',
3938 'delete',
'dolly',
'dollyrevert',
'donation',
'download',
'dynamicprice',
3939 'edit',
'ellipsis-h',
'email',
'entity',
'envelope',
'eraser',
'establishment',
'expensereport',
'external-link-alt',
'external-link-square-alt',
3940 'filter',
'file-code',
'file-export',
'file-import',
'file-upload',
'autofill',
'folder',
'folder-open',
'folder-plus',
3941 'generate',
'globe',
'globe-americas',
'graph',
'grip',
'grip_title',
'group',
3943 'images',
'incoterm',
'info',
'intervention',
'inventory',
'intracommreport',
'knowledgemanagement',
3944 'label',
'language',
'line',
'link',
'list',
'list-alt',
'listlight',
'loan',
'lot',
'long-arrow-alt-right',
3945 'margin',
'map-marker-alt',
'member',
'meeting',
'money-bill-alt',
'movement',
'mrp',
'note',
'next',
3946 'off',
'on',
'order',
3947 'paiment',
'paragraph',
'play',
'pdf',
'phone',
'phoning',
'phoning_mobile',
'phoning_fax',
'playdisabled',
'previous',
'poll',
'pos',
'printer',
'product',
'propal',
'puce',
3948 'stock',
'resize',
'service',
'stats',
'trip',
3949 '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',
3950 'github',
'google',
'jabber',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'youtube',
'google-plus-g',
'whatsapp',
3951 'chevron-left',
'chevron-right',
'chevron-down',
'chevron-top',
'commercial',
'companies',
3952 'generic',
'home',
'hrm',
'members',
'products',
'invoicing',
3953 'partnership',
'payment',
'payment_vat',
'pencil-ruler',
'preview',
'project',
'projectpub',
'projecttask',
'question',
'refresh',
'region',
3954 'salary',
'shipment',
'state',
'supplier_invoice',
'supplier_invoicea',
'supplier_invoicer',
'supplier_invoiced',
3955 'technic',
'ticket',
3957 'recent',
'reception',
'recruitmentcandidature',
'recruitmentjobposition',
'resource',
'recurring',
3958 'shapes',
'square',
'stop-circle',
'supplier',
'supplier_proposal',
'supplier_order',
'supplier_invoice',
3959 'timespent',
'title_setup',
'title_accountancy',
'title_bank',
'title_hrm',
'title_agenda',
3960 'uncheck',
'user-cog',
'user-injured',
'user-md',
'vat',
'website',
'workstation',
'webhook',
'world',
'private',
3961 'conferenceorbooth',
'eventorganization'
3963 $fakey = $pictowithouttext;
3967 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'))) {
3970 if (in_array($pictowithouttext, array(
'black-tie',
'github',
'google',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'stripe',
'stripe-s',
'youtube',
'google-plus-g',
'whatsapp'))) {
3974 $arrayconvpictotofa = array(
3975 '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',
3976 'bank_account'=>
'university',
3977 'bill'=>
'file-invoice-dollar',
'billa'=>
'file-excel',
'billr'=>
'file-invoice-dollar',
'billd'=>
'file-medical',
3978 'supplier_invoice'=>
'file-invoice-dollar',
'supplier_invoicea'=>
'file-excel',
'supplier_invoicer'=>
'file-invoice-dollar',
'supplier_invoiced'=>
'file-medical',
3980 'card'=>
'address-card',
'chart'=>
'chart-line',
'company'=>
'building',
'contact'=>
'address-book',
'contract'=>
'suitcase',
'collab'=>
'people-arrows',
'conversation'=>
'comments',
'country'=>
'globe-americas',
'cron'=>
'business-time',
3981 'donation'=>
'file-alt',
'dynamicprice'=>
'hand-holding-usd',
3982 'setup'=>
'cog',
'companies'=>
'building',
'products'=>
'cube',
'commercial'=>
'suitcase',
'invoicing'=>
'coins',
3983 'accounting'=>
'search-dollar',
'category'=>
'tag',
'dollyrevert'=>
'dolly',
3984 'generate'=>
'plus-square',
'hrm'=>
'user-tie',
'incoterm'=>
'truck-loading',
3985 'margin'=>
'calculator',
'members'=>
'user-friends',
'ticket'=>
'ticket-alt',
'globe'=>
'external-link-alt',
'lot'=>
'barcode',
3986 'email'=>
'at',
'establishment'=>
'building',
'edit'=>
'pencil-alt',
'entity'=>
'globe',
3987 'graph'=>
'chart-line',
'grip_title'=>
'arrows-alt',
'grip'=>
'arrows-alt',
'help'=>
'question-circle',
3988 'generic'=>
'file',
'holiday'=>
'umbrella-beach',
3989 'info'=>
'info-circle',
'inventory'=>
'boxes',
'intracommreport'=>
'globe-europe',
'knowledgemanagement'=>
'ticket-alt',
'label'=>
'layer-group',
'line'=>
'bars',
'loan'=>
'money-bill-alt',
3990 'member'=>
'user-alt',
'meeting'=>
'chalkboard-teacher',
'mrp'=>
'cubes',
'next'=>
'arrow-alt-circle-right',
3991 'trip'=>
'wallet',
'expensereport'=>
'wallet',
'group'=>
'users',
'movement'=>
'people-carry',
3992 'sign-out'=>
'sign-out-alt',
3993 'switch_off'=>
'toggle-off',
'switch_on'=>
'toggle-on',
'switch_on_red'=>
'toggle-on',
'check'=>
'check',
'bookmark'=>
'star',
3994 'bank'=>
'university',
'close_title'=>
'times',
'delete'=>
'trash',
'filter'=>
'filter',
3995 'list-alt'=>
'list-alt',
'calendarlist'=>
'bars',
'calendar'=>
'calendar-alt',
'calendarmonth'=>
'calendar-alt',
'calendarweek'=>
'calendar-week',
'calendarday'=>
'calendar-day',
'calendarperuser'=>
'table',
3996 'intervention'=>
'ambulance',
'invoice'=>
'file-invoice-dollar',
'currency'=>
'dollar-sign',
'multicurrency'=>
'dollar-sign',
'order'=>
'file-invoice',
3997 'error'=>
'exclamation-triangle',
'warning'=>
'exclamation-triangle',
3999 'playdisabled'=>
'play',
'pdf'=>
'file-pdf',
'poll'=>
'check-double',
'pos'=>
'cash-register',
'preview'=>
'binoculars',
'project'=>
'project-diagram',
'projectpub'=>
'project-diagram',
'projecttask'=>
'tasks',
'propal'=>
'file-signature',
4000 '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',
4001 'recent' =>
'question',
'reception'=>
'dolly',
'recruitmentjobposition'=>
'id-card-alt',
'recruitmentcandidature'=>
'id-badge',
4002 'resize'=>
'crop',
'supplier_order'=>
'dol-order_supplier',
'supplier_proposal'=>
'file-signature',
4003 'refresh'=>
'redo',
'region'=>
'map-marked',
'resource'=>
'laptop-house',
'recurring'=>
'history',
4004 'service'=>
'concierge-bell',
4005 'state'=>
'map-marked-alt',
'security'=>
'key',
'salary'=>
'wallet',
'shipment'=>
'dolly',
'stock'=>
'box-open',
'stats' =>
'chart-bar',
'split'=>
'code-branch',
'stripe'=>
'stripe-s',
4006 'supplier'=>
'building',
'technic'=>
'cogs',
4007 'timespent'=>
'clock',
'title_setup'=>
'tools',
'title_accountancy'=>
'money-check-alt',
'title_bank'=>
'university',
'title_hrm'=>
'umbrella-beach',
4008 'title_agenda'=>
'calendar-alt',
4009 'uncheck'=>
'times',
'uparrow'=>
'share',
'vat'=>
'money-check-alt',
'vcard'=>
'address-card',
4010 'jabber'=>
'comment-o',
4011 'website'=>
'globe-americas',
'workstation'=>
'pallet',
'webhook'=>
'bullseye',
'world'=>
'globe',
'private'=>
'user-lock',
4012 'conferenceorbooth'=>
'chalkboard-teacher',
'eventorganization'=>
'project-diagram'
4014 if ($pictowithouttext ==
'off') {
4015 $fakey =
'fa-square';
4017 } elseif ($pictowithouttext ==
'on') {
4018 $fakey =
'fa-check-square';
4020 } elseif ($pictowithouttext ==
'listlight') {
4021 $fakey =
'fa-download';
4022 $marginleftonlyshort = 1;
4023 } elseif ($pictowithouttext ==
'printer') {
4024 $fakey =
'fa-print';
4026 } elseif ($pictowithouttext ==
'note') {
4027 $fakey =
'fa-sticky-note';
4028 $marginleftonlyshort = 1;
4029 } elseif (in_array($pictowithouttext, array(
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'))) {
4030 $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');
4031 $fakey =
'fa-'.$convertarray[$pictowithouttext];
4032 if (preg_match(
'/selected/', $pictowithouttext)) {
4035 $marginleftonlyshort = 1;
4036 } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) {
4037 $fakey =
'fa-'.$arrayconvpictotofa[$pictowithouttext];
4039 $fakey =
'fa-'.$pictowithouttext;
4042 if (in_array($pictowithouttext, array(
'dollyrevert',
'member',
'members',
'contract',
'group',
'resource',
'shipment'))) {
4043 $morecss .=
' em092';
4045 if (in_array($pictowithouttext, array(
'conferenceorbooth',
'collab',
'eventorganization',
'holiday',
'info',
'project',
'workstation'))) {
4046 $morecss .=
' em088';
4048 if (in_array($pictowithouttext, array(
'asset',
'intervention',
'payment',
'loan',
'partnership',
'stock',
'technic'))) {
4049 $morecss .=
' em080';
4053 $arrayconvpictotomarginleftonly = array(
4054 'bank',
'check',
'delete',
'generic',
'grip',
'grip_title',
'jabber',
4055 'grip_title',
'grip',
'listlight',
'note',
'on',
'off',
'playdisabled',
'printer',
'resize',
'sign-out',
'stats',
'switch_on',
'switch_on_red',
'switch_off',
4056 'uparrow',
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'
4058 if (!isset($arrayconvpictotomarginleftonly[$pictowithouttext])) {
4059 $marginleftonlyshort = 0;
4063 $arrayconvpictotomorcess = array(
4064 'action'=>
'infobox-action',
'account'=>
'infobox-bank_account',
'accounting_account'=>
'infobox-bank_account',
'accountline'=>
'infobox-bank_account',
'accountancy'=>
'infobox-bank_account',
'asset'=>
'infobox-bank_account',
4065 'bank_account'=>
'bg-infobox-bank_account',
4066 'bill'=>
'infobox-commande',
'billa'=>
'infobox-commande',
'billr'=>
'infobox-commande',
'billd'=>
'infobox-commande',
4067 'margin'=>
'infobox-bank_account',
'conferenceorbooth'=>
'infobox-project',
4068 'cash-register'=>
'infobox-bank_account',
'contract'=>
'infobox-contrat',
'check'=>
'font-status4',
'collab'=>
'infobox-action',
'conversation'=>
'infobox-contrat',
4069 'donation'=>
'infobox-commande',
'dolly'=>
'infobox-commande',
'dollyrevert'=>
'flip infobox-order_supplier',
4070 'ecm'=>
'infobox-action',
'eventorganization'=>
'infobox-project',
4071 'hrm'=>
'infobox-adherent',
'group'=>
'infobox-adherent',
'intervention'=>
'infobox-contrat',
4072 'incoterm'=>
'infobox-supplier_proposal',
4073 'currency'=>
'infobox-bank_account',
'multicurrency'=>
'infobox-bank_account',
4074 'members'=>
'infobox-adherent',
'member'=>
'infobox-adherent',
'money-bill-alt'=>
'infobox-bank_account',
4075 'order'=>
'infobox-commande',
4076 'user'=>
'infobox-adherent',
'users'=>
'infobox-adherent',
4077 'error'=>
'pictoerror',
'warning'=>
'pictowarning',
'switch_on'=>
'font-status4',
'switch_on_red'=>
'font-status8',
4078 'holiday'=>
'infobox-holiday',
'info'=>
'opacityhigh',
'invoice'=>
'infobox-commande',
4079 'knowledgemanagement'=>
'infobox-contrat rotate90',
'loan'=>
'infobox-bank_account',
4080 'payment'=>
'infobox-bank_account',
'payment_vat'=>
'infobox-bank_account',
'poll'=>
'infobox-adherent',
'pos'=>
'infobox-bank_account',
'project'=>
'infobox-project',
'projecttask'=>
'infobox-project',
4081 'propal'=>
'infobox-propal',
'private'=>
'infobox-project',
4082 'reception'=>
'flip',
'recruitmentjobposition'=>
'infobox-adherent',
'recruitmentcandidature'=>
'infobox-adherent',
4083 'resource'=>
'infobox-action',
4084 'salary'=>
'infobox-bank_account',
'shipment'=>
'infobox-commande',
'supplier_invoice'=>
'infobox-order_supplier',
'supplier_invoicea'=>
'infobox-order_supplier',
'supplier_invoiced'=>
'infobox-order_supplier',
4085 'supplier'=>
'infobox-order_supplier',
'supplier_order'=>
'infobox-order_supplier',
'supplier_proposal'=>
'infobox-supplier_proposal',
4086 'ticket'=>
'infobox-contrat',
'title_accountancy'=>
'infobox-bank_account',
'title_hrm'=>
'infobox-holiday',
'expensereport'=>
'infobox-expensereport',
'trip'=>
'infobox-expensereport',
'title_agenda'=>
'infobox-action',
4087 'vat'=>
'infobox-bank_account',
4089 'list-alt'=>
'imgforviewmode',
'calendar'=>
'imgforviewmode',
'calendarweek'=>
'imgforviewmode',
'calendarmonth'=>
'imgforviewmode',
'calendarday'=>
'imgforviewmode',
'calendarperuser'=>
'imgforviewmode'
4091 if (!empty($arrayconvpictotomorcess[$pictowithouttext])) {
4092 $morecss .= ($morecss ?
' ' :
'').$arrayconvpictotomorcess[$pictowithouttext];
4096 $arrayconvpictotocolor = array(
4097 'address'=>
'#6c6aa8',
'building'=>
'#6c6aa8',
'bom'=>
'#a69944',
4098 'cog'=>
'#999',
'companies'=>
'#6c6aa8',
'company'=>
'#6c6aa8',
'contact'=>
'#6c6aa8',
'cron'=>
'#555',
4099 'dynamicprice'=>
'#a69944',
4100 'edit'=>
'#444',
'note'=>
'#999',
'error'=>
'',
'help'=>
'#bbb',
'listlight'=>
'#999',
'language'=>
'#555',
4103 'map-marker-alt'=>
'#aaa',
'mrp'=>
'#a69944',
'product'=>
'#a69944',
'service'=>
'#a69944',
'inventory'=>
'#a69944',
'stock'=>
'#a69944',
'movement'=>
'#a69944',
4104 'other'=>
'#ddd',
'world'=>
'#986c6a',
4105 'partnership'=>
'#6c6aa8',
'playdisabled'=>
'#ccc',
'printer'=>
'#444',
'projectpub'=>
'#986c6a',
'reception'=>
'#a69944',
'resize'=>
'#444',
'rss'=>
'#cba',
4107 'security'=>
'#999',
'square'=>
'#888',
'stop-circle'=>
'#888',
'stats'=>
'#444',
'switch_off'=>
'#999',
'technic'=>
'#999',
'timespent'=>
'#555',
4108 'uncheck'=>
'#800',
'uparrow'=>
'#555',
'user-cog'=>
'#999',
'country'=>
'#aaa',
'globe-americas'=>
'#aaa',
'region'=>
'#aaa',
'state'=>
'#aaa',
4109 'website'=>
'#304',
'workstation'=>
'#a69944'
4111 if (isset($arrayconvpictotocolor[$pictowithouttext])) {
4112 $facolor = $arrayconvpictotocolor[$pictowithouttext];
4119 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4120 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4121 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4123 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
4124 $morestyle = $reg[1];
4125 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
4127 $moreatt = trim($moreatt);
4129 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
4130 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
4134 $enabledisablehtml .=
'</span>';
4136 return $enabledisablehtml;
4139 if (!empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) {
4140 $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.
'/theme/'.$theme;
4141 } elseif (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) {
4142 $path = $conf->global->MAIN_OVERWRITE_THEME_RES.
'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES;
4143 } elseif (!empty($conf->modules_parts[
'theme']) && array_key_exists($theme, $conf->modules_parts[
'theme'])) {
4144 $path = $theme.
'/theme/'.$theme;
4149 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
4155 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
4160 foreach ($conf->file->dol_document_root as $type => $dirroot) {
4161 if ($type ==
'main') {
4165 if (file_exists($dirroot.
'/'.$path.
'/img/'.$picto)) {
4166 $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type];
4172 $fullpathpicto = $url.
'/'.$path.
'/img/'.$picto;
4176 return $fullpathpicto;
4179 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 :
'').
'"').
'>';
4195 function img_object($titlealt, $picto, $moreatt =
'', $pictoisfullpath =
false, $srconly = 0, $notitle = 0)
4197 if (strpos($picto,
'^') === 0) {
4198 return img_picto($titlealt, str_replace(
'^',
'', $picto), $moreatt, $pictoisfullpath, $srconly, $notitle);
4200 return img_picto($titlealt,
'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
4215 function img_weather($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $morecss =
'')
4219 if (is_numeric($picto)) {
4222 return '<i class="fa fa-weather-level'.$picto.
'"></i>';
4223 } elseif (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
4227 $path = DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/weather/'.$picto;
4229 return img_picto($titlealt, $path, $moreatt, 1, 0, 0,
'', $morecss);
4243 function img_picto_common($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $notitle = 0)
4247 if (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
4251 if ($pictoisfullpath) {
4254 $path = DOL_URL_ROOT.
'/theme/common/'.$picto;
4256 if (!empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) {
4257 $themepath = DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/img/'.$picto;
4259 if (file_exists($themepath)) {
4265 return img_picto($titlealt, $path, $moreatt, 1, 0, $notitle);
4284 if (empty($titlealt) || $titlealt ==
'default') {
4285 if ($numaction ==
'-1' || $numaction ==
'ST_NO') {
4287 $titlealt = $langs->transnoentitiesnoconv(
'ChangeDoNotContact');
4288 } elseif ($numaction ==
'0' || $numaction ==
'ST_NEVER') {
4290 $titlealt = $langs->transnoentitiesnoconv(
'ChangeNeverContacted');
4291 } elseif ($numaction ==
'1' || $numaction ==
'ST_TODO') {
4293 $titlealt = $langs->transnoentitiesnoconv(
'ChangeToContact');
4294 } elseif ($numaction ==
'2' || $numaction ==
'ST_PEND') {
4296 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactInProcess');
4297 } elseif ($numaction ==
'3' || $numaction ==
'ST_DONE') {
4299 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactDone');
4301 $titlealt = $langs->transnoentitiesnoconv(
'ChangeStatus '.$numaction);
4305 if (!is_numeric($numaction)) {
4309 return img_picto($titlealt, !empty($picto) ? $picto :
'stcomm'.$numaction.
'.png');
4319 function img_pdf($titlealt =
'default', $size = 3)
4323 if ($titlealt ==
'default') {
4324 $titlealt = $langs->trans(
'Show');
4327 return img_picto($titlealt,
'pdf'.$size.
'.png');
4341 if ($titlealt ==
'default') {
4342 $titlealt = $langs->trans(
'Add');
4345 return img_picto($titlealt,
'edit_add.png', $other);
4358 if ($titlealt ==
'default') {
4359 $titlealt = $langs->trans(
'Remove');
4362 return img_picto($titlealt,
'edit_remove.png', $other);
4373 function img_edit($titlealt =
'default', $float = 0, $other =
'')
4377 if ($titlealt ==
'default') {
4378 $titlealt = $langs->trans(
'Modify');
4381 return img_picto($titlealt,
'edit.png', ($float ?
'style="float: '.($langs->tab_translate[
"DIRECTION"] ==
'rtl' ?
'left' :
'right').
'"' :
"").($other ?
' '.$other :
''));
4392 function img_view($titlealt =
'default', $float = 0, $other =
'class="valignmiddle"')
4396 if ($titlealt ==
'default') {
4397 $titlealt = $langs->trans(
'View');
4400 $moreatt = ($float ?
'style="float: right" ' :
'').$other;
4402 return img_picto($titlealt,
'view.png', $moreatt);
4413 function img_delete($titlealt =
'default', $other =
'class="pictodelete"', $morecss =
'')
4417 if ($titlealt ==
'default') {
4418 $titlealt = $langs->trans(
'Delete');
4421 return img_picto($titlealt,
'delete.png', $other,
false, 0, 0,
'', $morecss);
4434 if ($titlealt ==
"default") {
4435 $titlealt = $langs->trans(
"Print");
4437 return img_picto($titlealt,
'printer.png', $other);
4447 function img_split($titlealt =
'default', $other =
'class="pictosplit"')
4451 if ($titlealt ==
'default') {
4452 $titlealt = $langs->trans(
'Split');
4455 return img_picto($titlealt,
'split.png', $other);
4465 function img_help($usehelpcursor = 1, $usealttitle = 1)
4470 if (is_string($usealttitle)) {
4473 $usealttitle = $langs->trans(
'Info');
4477 return img_picto($usealttitle,
'info.png',
'style="vertical-align: middle;'.($usehelpcursor == 1 ?
' cursor: help' : ($usehelpcursor == 2 ?
' cursor: pointer' :
'')).
'"');
4490 if ($titlealt ==
'default') {
4491 $titlealt = $langs->trans(
'Informations');
4494 return img_picto($titlealt,
'info.png',
'style="vertical-align: middle;"');
4505 function img_warning($titlealt =
'default', $moreatt =
'', $morecss =
'pictowarning')
4509 if ($titlealt ==
'default') {
4510 $titlealt = $langs->trans(
'Warning');
4514 return img_picto($titlealt,
'warning.png',
'class="'.$morecss.
'"'.($moreatt ? ($moreatt ==
'1' ?
' style="float: right"' :
' '.$moreatt) :
''));
4527 if ($titlealt ==
'default') {
4528 $titlealt = $langs->trans(
'Error');
4531 return img_picto($titlealt,
'error.png');
4541 function img_next($titlealt =
'default', $moreatt =
'')
4545 if ($titlealt ==
'default') {
4546 $titlealt = $langs->trans(
'Next');
4550 return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
4564 if ($titlealt ==
'default') {
4565 $titlealt = $langs->trans(
'Previous');
4569 return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
4580 function img_down($titlealt =
'default', $selected = 0, $moreclass =
'')
4584 if ($titlealt ==
'default') {
4585 $titlealt = $langs->trans(
'Down');
4588 return img_picto($titlealt, ($selected ?
'1downarrow_selected.png' :
'1downarrow.png'),
'class="imgdown'.($moreclass ?
" ".$moreclass :
"").
'"');
4599 function img_up($titlealt =
'default', $selected = 0, $moreclass =
'')
4603 if ($titlealt ==
'default') {
4604 $titlealt = $langs->trans(
'Up');
4607 return img_picto($titlealt, ($selected ?
'1uparrow_selected.png' :
'1uparrow.png'),
'class="imgup'.($moreclass ?
" ".$moreclass :
"").
'"');
4618 function img_left($titlealt =
'default', $selected = 0, $moreatt =
'')
4622 if ($titlealt ==
'default') {
4623 $titlealt = $langs->trans(
'Left');
4626 return img_picto($titlealt, ($selected ?
'1leftarrow_selected.png' :
'1leftarrow.png'), $moreatt);
4637 function img_right($titlealt =
'default', $selected = 0, $moreatt =
'')
4641 if ($titlealt ==
'default') {
4642 $titlealt = $langs->trans(
'Right');
4645 return img_picto($titlealt, ($selected ?
'1rightarrow_selected.png' :
'1rightarrow.png'), $moreatt);
4659 if ($titlealt ==
'default') {
4660 $titlealt = $langs->trans(
'Active');
4664 return img_picto($titlealt,
'tick.png');
4679 if (is_null($morecss)) {
4683 if ($brand ==
'visa' || $brand ==
'Visa') {
4685 } elseif ($brand ==
'mastercard' || $brand ==
'MasterCard') {
4686 $brand =
'cc-mastercard';
4687 } elseif ($brand ==
'amex' || $brand ==
'American Express') {
4689 } elseif ($brand ==
'discover' || $brand ==
'Discover') {
4690 $brand =
'cc-discover';
4691 } elseif ($brand ==
'jcb' || $brand ==
'JCB') {
4693 } elseif ($brand ==
'diners' || $brand ==
'Diners club') {
4694 $brand =
'cc-diners-club';
4695 } elseif (!in_array($brand, array(
'cc-visa',
'cc-mastercard',
'cc-amex',
'cc-discover',
'cc-jcb',
'cc-diners-club'))) {
4696 $brand =
'credit-card';
4699 return '<span class="fa fa-'.$brand.
' fa-fw'.($morecss ?
' '.$morecss :
'').
'"></span>';
4710 function img_mime($file, $titlealt =
'', $morecss =
'')
4712 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
4718 if (empty($titlealt)) {
4719 $titlealt =
'Mime type: '.$mimetype;
4723 return '<i class="fa fa-'.$mimefa.
' paddingright'.($morecss ?
' '.$morecss :
'').
'"'.($titlealt ?
' title="'.$titlealt.
'"' :
'').
'></i>';
4736 global $conf, $langs;
4738 if ($titlealt ==
'default') {
4739 $titlealt = $langs->trans(
'Search');
4742 $img =
img_picto($titlealt,
'search.png', $other,
false, 1);
4744 $input =
'<input type="image" class="liste_titre" name="button_search" src="'.$img.
'" ';
4745 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
4759 global $conf, $langs;
4761 if ($titlealt ==
'default') {
4762 $titlealt = $langs->trans(
'Search');
4765 $img =
img_picto($titlealt,
'searchclear.png', $other,
false, 1);
4767 $input =
'<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.
'" ';
4768 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
4784 function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin =
'1', $morecss =
'hideonsmartphone', $textfordropdown =
'')
4786 global $conf, $langs;
4788 if ($infoonimgalt) {
4789 $result =
img_picto($text,
'info',
'class="'.($morecss ?
' '.$morecss :
'').
'"');
4791 if (empty($conf->use_javascript_ajax)) {
4792 $textfordropdown =
'';
4795 $class = (empty($admin) ?
'undefined' : ($admin ==
'1' ?
'info' : $admin));
4796 $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>');
4798 if ($textfordropdown) {
4799 $tmpresult =
'<span class="'.$class.
'text opacitymedium cursorpointer">'.$langs->trans($textfordropdown).
' '.
img_picto($langs->trans($textfordropdown),
'1downarrow').
'</span>';
4800 $tmpresult .=
'<script type="text/javascript">
4801 jQuery(document).ready(function() {
4802 jQuery(".'.$class.
'text").click(function() {
4803 console.log("toggle text");
4804 jQuery(".'.$class.
'").toggle();
4809 $result = $tmpresult.$result;
4830 global $conf, $langs, $argv;
4831 global $dolibarr_main_prod;
4838 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
4840 $langs->load(
"main");
4844 $langs->loadLangs(array(
'main',
'errors'));
4846 if ($_SERVER[
'DOCUMENT_ROOT']) {
4847 $out .= $langs->trans(
"DolibarrHasDetectedError").
".<br>\n";
4849 $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";
4851 $out .= $langs->trans(
"InformationToHelpDiagnose").
":<br>\n";
4853 $out .=
"<b>".$langs->trans(
"Date").
":</b> ".
dol_print_date(time(),
'dayhourlog').
"<br>\n";
4854 $out .=
"<b>".$langs->trans(
"Dolibarr").
":</b> ".DOL_VERSION.
" - https://www.dolibarr.org<br>\n";
4855 if (isset($conf->global->MAIN_FEATURES_LEVEL)) {
4856 $out .=
"<b>".$langs->trans(
"LevelOfFeature").
":</b> ".
getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
"<br>\n";
4858 if (function_exists(
"phpversion")) {
4859 $out .=
"<b>".$langs->trans(
"PHP").
":</b> ".phpversion().
"<br>\n";
4861 $out .=
"<b>".$langs->trans(
"Server").
":</b> ".(isset($_SERVER[
"SERVER_SOFTWARE"]) ?
dol_htmlentities($_SERVER[
"SERVER_SOFTWARE"], ENT_COMPAT) :
'').
"<br>\n";
4862 if (function_exists(
"php_uname")) {
4863 $out .=
"<b>".$langs->trans(
"OS").
":</b> ".php_uname().
"<br>\n";
4865 $out .=
"<b>".$langs->trans(
"UserAgent").
":</b> ".(isset($_SERVER[
"HTTP_USER_AGENT"]) ?
dol_htmlentities($_SERVER[
"HTTP_USER_AGENT"], ENT_COMPAT) :
'').
"<br>\n";
4867 $out .=
"<b>".$langs->trans(
"RequestedUrl").
":</b> ".
dol_htmlentities($_SERVER[
"REQUEST_URI"], ENT_COMPAT).
"<br>\n";
4868 $out .=
"<b>".$langs->trans(
"Referer").
":</b> ".(isset($_SERVER[
"HTTP_REFERER"]) ?
dol_htmlentities($_SERVER[
"HTTP_REFERER"], ENT_COMPAT) :
'').
"<br>\n";
4869 $out .=
"<b>".$langs->trans(
"MenuManager").
":</b> ".(isset($conf->standard_menu) ?
dol_htmlentities($conf->standard_menu, ENT_COMPAT) :
'').
"<br>\n";
4871 $syslog .=
"url=".dol_escape_htmltag($_SERVER[
"REQUEST_URI"]);
4872 $syslog .=
", query_string=".dol_escape_htmltag($_SERVER[
"QUERY_STRING"]);
4875 $out .=
'> '.$langs->transnoentities(
"ErrorInternalErrorDetected").
":\n".$argv[0].
"\n";
4876 $syslog .=
"pid=".dol_getmypid();
4879 if (!empty($conf->modules)) {
4880 $out .=
"<b>".$langs->trans(
"Modules").
":</b> ".join(
', ', $conf->modules).
"<br>\n";
4883 if (is_object($db)) {
4884 if ($_SERVER[
'DOCUMENT_ROOT']) {
4885 $out .=
"<b>".$langs->trans(
"DatabaseTypeManager").
":</b> ".$db->type.
"<br>\n";
4886 $out .=
"<b>".$langs->trans(
"RequestLastAccessInError").
":</b> ".($db->lastqueryerror() ?
dol_escape_htmltag($db->lastqueryerror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
4887 $out .=
"<b>".$langs->trans(
"ReturnCodeLastAccessInError").
":</b> ".($db->lasterrno() ?
dol_escape_htmltag($db->lasterrno()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
4888 $out .=
"<b>".$langs->trans(
"InformationLastAccessInError").
":</b> ".($db->lasterror() ?
dol_escape_htmltag($db->lasterror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
4893 $out .=
'> '.$langs->transnoentities(
"DatabaseTypeManager").
":\n".$db->type.
"\n";
4894 $out .=
'> '.$langs->transnoentities(
"RequestLastAccessInError").
":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
4895 $out .=
'> '.$langs->transnoentities(
"ReturnCodeLastAccessInError").
":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
4896 $out .=
'> '.$langs->transnoentities(
"InformationLastAccessInError").
":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
4898 $syslog .=
", sql=".$db->lastquery();
4899 $syslog .=
", db_error=".$db->lasterror();
4902 if ($error || $errors) {
4903 $langs->load(
"errors");
4906 if (is_array($error) && is_array($errors)) {
4907 $errors = array_merge($error, $errors);
4908 } elseif (is_array($error)) {
4910 } elseif (is_array($errors)) {
4911 $errors = array_merge(array($error), $errors);
4913 $errors = array_merge(array($error));
4916 foreach ($errors as $msg) {
4920 if ($_SERVER[
'DOCUMENT_ROOT']) {
4924 $out .=
'> '.$langs->transnoentities(
"Message").
":\n".$msg.
"\n";
4926 $syslog .=
", msg=".$msg;
4929 if (empty($dolibarr_main_prod) && $_SERVER[
'DOCUMENT_ROOT'] && function_exists(
'xdebug_print_function_stack') && function_exists(
'xdebug_call_file')) {
4930 xdebug_print_function_stack();
4931 $out .=
'<b>XDebug informations:</b>'.
"<br>\n";
4932 $out .=
'File: '.xdebug_call_file().
"<br>\n";
4933 $out .=
'Line: '.xdebug_call_line().
"<br>\n";
4934 $out .=
'Function: '.xdebug_call_function().
"<br>\n";
4939 if (!headers_sent()) {
4940 http_response_code(500);
4943 if (empty($dolibarr_main_prod)) {
4946 if (empty($langs->defaultlang)) {
4947 $langs->setDefaultLang();
4949 $langs->loadLangs(array(
"main",
"errors"));
4951 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";
4952 print $langs->trans(
"DolibarrHasDetectedError").
'. ';
4953 print $langs->trans(
"YouCanSetOptionDolibarrMainProdToZero");
4954 define(
"MAIN_CORE_ERROR", 1);
4970 function dol_print_error_email($prefixcode, $errormessage =
'', $errormessages = array(), $morecss =
'error', $email =
'')
4972 global $langs, $conf;
4974 if (empty($email)) {
4975 $email = $conf->global->MAIN_INFO_SOCIETE_MAIL;
4978 $langs->load(
"errors");
4981 print
'<br><div class="center login_main_message"><div class="'.$morecss.
'">';
4982 print $langs->trans(
"ErrorContactEMail", $email, $prefixcode.dol_print_date($now,
'%Y%m%d%H%M%S'));
4983 if ($errormessage) {
4984 print
'<br><br>'.$errormessage;
4986 if (is_array($errormessages) && count($errormessages)) {
4987 foreach ($errormessages as $mesgtoshow) {
4988 print
'<br><br>'.$mesgtoshow;
4991 print
'</div></div>';
5010 function print_liste_field_titre($name, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $tooltip =
"", $forcenowrapcolumntitle = 0)
5012 print
getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip, $forcenowrapcolumntitle);
5033 function getTitleFieldOfList($name, $thead = 0, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $disablesortlink = 0, $tooltip =
'', $forcenowrapcolumntitle = 0)
5035 global $conf, $langs,
$form;
5038 if ($moreattrib ==
'class="right"') {
5039 $prefix .=
'right ';
5042 $sortorder = strtoupper($sortorder);
5051 $tmpsortfield = explode(
',', $sortfield);
5052 $sortfield1 = trim($tmpsortfield[0]);
5053 $tmpfield = explode(
',', $field);
5054 $field1 = trim($tmpfield[0]);
5056 if (empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && empty($forcenowrapcolumntitle)) {
5057 $prefix =
'wrapcolumntitle '.$prefix;
5063 $liste_titre =
'liste_titre';
5064 if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace(
"/^[^\.]+\./",
"", $field1))) {
5065 $liste_titre =
'liste_titre_sel';
5068 $tagstart =
'<'.$tag.
' class="'.$prefix.$liste_titre.
'" '.$moreattrib;
5070 $tagstart .= ($name && empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && empty($forcenowrapcolumntitle) && !
dol_textishtml($name)) ?
' title="'.
dol_escape_htmltag($langs->trans($name)).
'"' :
'';
5073 if (empty($thead) && $field && empty($disablesortlink)) {
5074 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
5075 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
5076 $options = preg_replace(
'/&+/i',
'&', $options);
5077 if (!preg_match(
'/^&/', $options)) {
5078 $options =
'&'.$options;
5081 $sortordertouseinlink =
'';
5082 if ($field1 != $sortfield1) {
5083 if (preg_match(
'/^DESC/i', $sortorder)) {
5084 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
5086 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
5089 if (preg_match(
'/^ASC/i', $sortorder)) {
5090 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
5092 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
5095 $sortordertouseinlink = preg_replace(
'/,$/',
'', $sortordertouseinlink);
5096 $out .=
'<a class="reposition" href="'.$file.
'?sortfield='.$field.
'&sortorder='.$sortordertouseinlink.
'&begin='.$begin.$options.
'"';
5102 $tmptooltip = explode(
':', $tooltip);
5103 $out .= $form->textwithpicto($langs->trans($name), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.str_replace(
'.',
'_', $field).
'_'.$tmptooltip[1]));
5105 $out .= $langs->trans($name);
5108 if (empty($thead) && $field && empty($disablesortlink)) {
5112 if (empty($thead) && $field) {
5113 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
5114 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
5115 $options = preg_replace(
'/&+/i',
'&', $options);
5116 if (!preg_match(
'/^&/', $options)) {
5117 $options =
'&'.$options;
5120 if (!$sortorder || $field1 != $sortfield1) {
5124 if (preg_match(
'/^DESC/', $sortorder)) {
5127 $sortimg .=
'<span class="nowrap">'.img_up(
"Z-A", 0,
'paddingright').
'</span>';
5129 if (preg_match(
'/^ASC/', $sortorder)) {
5132 $sortimg .=
'<span class="nowrap">'.img_down(
"A-Z", 0,
'paddingright').
'</span>';
5137 $tagend =
'</'.$tag.
'>';
5139 $out = $tagstart.$sortimg.$out.$tagend;
5154 dol_syslog(__FUNCTION__.
" is deprecated", LOG_WARNING);
5156 print
'<div class="titre">'.$title.
'</div>';
5188 function load_fiche_titre($titre, $morehtmlright =
'', $picto =
'generic', $pictoisfullpath = 0, $id =
'', $morecssontable =
'', $morehtmlcenter =
'')
5194 if ($picto ==
'setup') {
5199 $return .=
'<table '.($id ?
'id="'.$id.
'" ' :
'').
'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ?
' '.$morecssontable :
'').
'">';
5200 $return .=
'<tr class="titre">';
5202 $return .=
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).
'</td>';
5204 $return .=
'<td class="nobordernopadding valignmiddle col-title">';
5205 $return .=
'<div class="titre inline-block">'.$titre.
'</div>';
5208 $return .=
'<td class="nobordernopadding center valignmiddle">'.$morehtmlcenter.
'</td>';
5211 $return .=
'<td class="nobordernopadding titre_right wordbreakimp right valignmiddle">'.$morehtmlright.
'</td>';
5213 $return .=
'</tr></table>'.
"\n";
5241 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 =
'')
5243 global $conf, $langs;
5246 $savtotalnboflines = $totalnboflines;
5247 $totalnboflines = abs((
int) $totalnboflines);
5249 if ($picto ==
'setup') {
5250 $picto =
'title_setup.png';
5252 if (($conf->browser->name ==
'ie') && $picto ==
'generic') {
5253 $picto =
'title.gif';
5256 $limit = $conf->liste_limit;
5258 if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
5266 print
"<!-- Begin title -->\n";
5267 print
'<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ?
' '.$morecss :
'').
'"><tr>';
5271 if ($picto && $titre) {
5272 print
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath).
'</td>';
5274 print
'<td class="nobordernopadding valignmiddle col-title">';
5275 print
'<div class="titre inline-block">'.$titre;
5276 if (!empty($titre) && $savtotalnboflines >= 0 && (
string) $savtotalnboflines !=
'') {
5277 print
'<span class="opacitymedium colorblack paddingleft">('.$totalnboflines.
')</span>';
5279 print
'</div></td>';
5282 if ($morehtmlcenter) {
5283 print
'<td class="nobordernopadding center valignmiddle">'.$morehtmlcenter.
'</td>';
5287 print
'<td class="nobordernopadding valignmiddle right">';
5288 print
'<input type="hidden" name="pageplusoneold" value="'.((int) $page + 1).
'">';
5290 $options .=
"&sortfield=".urlencode($sortfield);
5293 $options .=
"&sortorder=".urlencode($sortorder);
5297 if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
5298 if ($totalnboflines) {
5300 $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 0);
5303 $nbpages = ceil($totalnboflines / $limit);
5307 $cpt = ($page - $maxnbofpage);
5313 if (empty($pagenavastextinput)) {
5314 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page=0'.$options.
'">1</a></li>';
5316 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
5317 } elseif ($cpt == 2) {
5318 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page=1'.$options.
'">2</a></li>';
5324 if ($pagenavastextinput) {
5325 if ($cpt == $page) {
5326 $pagelist .=
'<li class="pagination"><input type="text" class="width25 center pageplusone" name="pageplusone" value="'.($page + 1).
'"></li>';
5330 if ($cpt == $page) {
5331 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
'</span></li>';
5333 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.$cpt.$options.
'">'.($cpt + 1).
'</a></li>';
5337 }
while ($cpt < $nbpages && $cpt <= ($page + $maxnbofpage));
5339 if (empty($pagenavastextinput)) {
5340 if ($cpt < $nbpages) {
5341 if ($cpt < $nbpages - 2) {
5342 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
5343 } elseif ($cpt == $nbpages - 2) {
5344 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.($nbpages - 2).$options.
'">'.($nbpages - 1).
'</a></li>';
5346 $pagelist .=
'<li class="pagination"><a href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
5350 $pagelist .=
'<li class="pagination paginationlastpage"><a href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
5353 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
"</li>";
5357 if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
5358 print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow);
5362 if ($pagenavastextinput) {
5368 print
'</tr></table>'.
"\n";
5369 print
"<!-- End title -->\n\n";
5387 function print_fleche_navigation($page, $file, $options =
'', $nextpage = 0, $betweenarrows =
'', $afterarrows =
'', $limit = -1, $totalnboflines = 0, $hideselectlimit = 0, $beforearrows =
'')
5389 global $conf, $langs;
5391 print
'<div class="pagination"><ul>';
5392 if ($beforearrows) {
5393 print
'<li class="paginationbeforearrows">';
5394 print $beforearrows;
5397 if ((
int) $limit > 0 && empty($hideselectlimit)) {
5398 $pagesizechoices =
'10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000';
5399 $pagesizechoices .=
',5000:5000,10000:10000,20000:20000';
5402 if (!empty($conf->global->MAIN_PAGESIZE_CHOICES)) {
5403 $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES;
5406 print
'<li class="pagination">';
5407 print
'<select class="flat selectlimit" name="limit" title="'.dol_escape_htmltag($langs->trans(
"MaxNbOfRecordPerPage")).
'">';
5408 $tmpchoice = explode(
',', $pagesizechoices);
5409 $tmpkey = $limit.
':'.$limit;
5410 if (!in_array($tmpkey, $tmpchoice)) {
5411 $tmpchoice[] = $tmpkey;
5413 $tmpkey = $conf->liste_limit.
':'.$conf->liste_limit;
5414 if (!in_array($tmpkey, $tmpchoice)) {
5415 $tmpchoice[] = $tmpkey;
5417 asort($tmpchoice, SORT_NUMERIC);
5418 foreach ($tmpchoice as $val) {
5420 $tmp = explode(
':', $val);
5423 if ($key !=
'' && $val !=
'') {
5424 if ((
int) $key == (
int) $limit) {
5425 $selected =
' selected="selected"';
5427 print
'<option name="'.$key.
'"'.$selected.
'>'.
dol_escape_htmltag($val).
'</option>'.
"\n";
5431 if ($conf->use_javascript_ajax) {
5432 print
'<!-- JS CODE TO ENABLE select limit to launch submit of page -->
5434 jQuery(document).ready(function () {
5435 jQuery(".selectlimit").change(function() {
5436 console.log("Change limit. Send submit");
5437 $(this).parents(\'form:first\').submit();
5446 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>';
5448 if ($betweenarrows) {
5449 print
'<!--<div class="betweenarrows nowraponall inline-block">-->';
5450 print $betweenarrows;
5451 print
'<!--</div>-->';
5453 if ($nextpage > 0) {
5454 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>';
5457 print
'<li class="paginationafterarrows">';
5461 print
'</ul></div>'.
"\n";
5476 function vatrate($rate, $addpercent =
false, $info_bits = 0, $usestarfornpr = 0, $html = 0)
5480 if (preg_match(
'/%/', $rate)) {
5481 $rate = str_replace(
'%',
'', $rate);
5485 if (preg_match(
'/\((.*)\)/', $rate, $reg)) {
5486 $morelabel =
' ('.$reg[1].
')';
5487 $rate = preg_replace(
'/\s*'.preg_quote($morelabel,
'/').
'/',
'', $rate);
5488 $morelabel =
' '.($html ?
'<span class="opacitymedium">' :
'').
'('.$reg[1].
')'.($html ?
'</span>' :
'');
5490 if (preg_match(
'/\*/', $rate)) {
5491 $rate = str_replace(
'*',
'', $rate);
5496 if (!preg_match(
'/\//', $rate)) {
5497 $ret =
price($rate, 0,
'', 0, 0).($addpercent ?
'%' :
'');
5500 $ret = $rate.($addpercent ?
'%' :
'');
5502 if (($info_bits & 1) && $usestarfornpr >= 0) {
5525 function price($amount,
$form = 0, $outlangs =
'', $trunc = 1, $rounding = -1, $forcerounding = -1, $currency_code =
'')
5527 global $langs, $conf;
5530 if (empty($amount)) {
5533 $amount = (is_numeric($amount) ? $amount : 0);
5534 if ($rounding < 0) {
5535 $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
5537 $nbdecimal = $rounding;
5539 if ($outlangs ===
'none') {
5549 if (!is_object($outlangs)) {
5553 if ($outlangs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
5554 $dec = $outlangs->transnoentitiesnoconv(
"SeparatorDecimal");
5556 if ($outlangs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
5557 $thousand = $outlangs->transnoentitiesnoconv(
"SeparatorThousand");
5559 if ($thousand ==
'None') {
5561 } elseif ($thousand ==
'Space') {
5568 $amount = str_replace(
',',
'.', $amount);
5570 $datas = explode(
'.', $amount);
5571 $decpart = isset($datas[1]) ? $datas[1] :
'';
5572 $decpart = preg_replace(
'/0+$/i',
'', $decpart);
5581 if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN) {
5582 $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_SHOWN;
5583 if (preg_match(
'/\.\.\./i', $conf->global->MAIN_MAX_DECIMALS_SHOWN)) {
5590 if ($forcerounding >= 0) {
5591 $nbdecimal = $forcerounding;
5595 $output = number_format($amount, $nbdecimal, $dec, $thousand);
5597 $output = preg_replace(
'/\s/',
' ', $output);
5598 $output = preg_replace(
'/\'/',
''', $output);
5601 $cursymbolbefore = $cursymbolafter =
'';
5602 if ($currency_code && is_object($outlangs)) {
5603 if ($currency_code ==
'auto') {
5604 $currency_code = $conf->currency;
5607 $listofcurrenciesbefore = array(
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD');
5608 $listoflanguagesbefore = array(
'nl_NL');
5609 if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) {
5610 $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
5612 $tmpcur = $outlangs->getCurrencySymbol($currency_code);
5613 $cursymbolafter .= ($tmpcur == $currency_code ?
' '.$tmpcur : $tmpcur);
5616 $output = $cursymbolbefore.$output.$end.($cursymbolafter ?
' ' :
'').$cursymbolafter;
5647 global $langs, $conf;
5654 if (is_null($langs)) {
5658 if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
5659 $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
5661 if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
5662 $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
5665 if ($thousand ==
'None') {
5667 } elseif ($thousand ==
'Space') {
5675 if (!is_numeric($amount)) {
5676 $amount = preg_replace(
'/[a-zA-Z\/\\\*\(\)<>\_]/',
'', $amount);
5679 if ($option == 2 && $thousand ==
'.' && preg_match(
'/\.(\d\d\d)$/', (
string) $amount)) {
5680 $amount = str_replace($thousand,
'', $amount);
5686 if (is_numeric($amount)) {
5688 $temps = sprintf(
"%0.10F", $amount - intval($amount));
5689 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
5691 $amount = number_format($amount, $nbofdec, $dec, $thousand);
5696 if ($thousand !=
',' && $thousand !=
'.') {
5697 $amount = str_replace(
',',
'.', $amount);
5700 $amount = str_replace(
' ',
'', $amount);
5701 $amount = str_replace($thousand,
'', $amount);
5702 $amount = str_replace($dec,
'.', $amount);
5704 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
5710 $nbofdectoround =
'';
5711 if ($rounding ==
'MU') {
5712 $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT;
5713 } elseif ($rounding ==
'MT') {
5714 $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT;
5715 } elseif ($rounding ==
'MS') {
5716 $nbofdectoround = isset($conf->global->MAIN_MAX_DECIMALS_STOCK) ? $conf->global->MAIN_MAX_DECIMALS_STOCK : 5;
5717 } elseif ($rounding ==
'CU') {
5718 $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_UNIT, 8);
5719 } elseif ($rounding ==
'CT') {
5720 $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_TOT, 8);
5721 } elseif (is_numeric($rounding)) {
5722 $nbofdectoround = (int) $rounding;
5727 $amount = round(is_string($amount) ? (
float) $amount : $amount, $nbofdectoround);
5729 return 'ErrorBadParameterProvidedToFunction';
5735 if (is_numeric($amount)) {
5737 $temps = sprintf(
"%0.10F", $amount - intval($amount));
5738 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
5740 $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand);
5746 if ($thousand !=
',' && $thousand !=
'.') {
5747 $amount = str_replace(
',',
'.', $amount);
5750 $amount = str_replace(
' ',
'', $amount);
5751 $amount = str_replace($thousand,
'', $amount);
5752 $amount = str_replace($dec,
'.', $amount);
5754 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
5772 function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput =
'no', $use_short_label = 0)
5774 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
5776 if (($forceunitoutput ==
'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
5777 $dimension = $dimension * 1000000;
5779 } elseif (($forceunitoutput ==
'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) {
5780 $dimension = $dimension * 1000;
5782 } elseif (($forceunitoutput ==
'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) {
5783 $dimension = $dimension / 1000000;
5785 } elseif (($forceunitoutput ==
'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) {
5786 $dimension = $dimension / 1000;
5802 $ret =
price($dimension, 0, $outputlangs, 0, 0, $round);
5803 $ret .=
' '.measuringUnitString(0, $type, $unit, $use_short_label, $outputlangs);
5821 function get_localtax($vatrate, $local, $thirdparty_buyer =
"", $thirdparty_seller =
"", $vatnpr = 0)
5823 global $db, $conf, $mysoc;
5825 if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) {
5826 $thirdparty_seller = $mysoc;
5829 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);
5831 $vatratecleaned = $vatrate;
5833 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
5834 $vatratecleaned = trim($reg[1]);
5835 $vatratecode = $reg[2];
5844 if ($mysoc->country_code ==
'ES') {
5846 if (!$mysoc->localtax1_assuj || (
string) $vatratecleaned ==
"0") {
5849 if ($thirdparty_seller->id == $mysoc->id) {
5850 if (!$thirdparty_buyer->localtax1_assuj) {
5854 if (!$thirdparty_seller->localtax1_assuj) {
5862 if (!$mysoc->localtax2_assuj) {
5865 if ($thirdparty_seller->id == $mysoc->id) {
5866 if (!$thirdparty_buyer->localtax2_assuj) {
5870 if (!$thirdparty_seller->localtax2_assuj) {
5876 if ($local == 1 && !$thirdparty_seller->localtax1_assuj) {
5879 if ($local == 2 && !$thirdparty_seller->localtax2_assuj) {
5885 if (in_array($mysoc->country_code, array(
'ES'))) {
5886 $conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY = 1;
5890 if (!empty($conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY)) {
5892 if ($thirdparty_seller != $mysoc) {
5894 return $thirdparty_seller->localtax1_value;
5898 return $conf->global->MAIN_INFO_VALUE_LOCALTAX1;
5903 if ($thirdparty_seller != $mysoc) {
5906 return $thirdparty_seller->localtax2_value;
5909 if (in_array($mysoc->country_code, array(
'ES'))) {
5910 return $thirdparty_buyer->localtax2_value;
5912 return $conf->global->MAIN_INFO_VALUE_LOCALTAX2;
5919 $sql =
"SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
5920 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
5921 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdparty_seller->country_code).
"'";
5922 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
5923 if (!empty($vatratecode)) {
5924 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
5926 $sql .=
" AND t.recuperableonly = '".$db->escape($vatnpr).
"'";
5929 $resql = $db->query($sql);
5932 $obj = $db->fetch_object(
$resql);
5935 return $obj->localtax1;
5936 } elseif ($local == 2) {
5937 return $obj->localtax2;
5958 $valors = explode(
":", $tax);
5960 if (count($valors) > 1) {
5976 $sql =
"SELECT t.localtax1, t.localtax2 ";
5977 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t inner join ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid=t.fk_pays";
5978 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.active = 1 AND t.taux=(";
5979 $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";
5980 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND tt.active = 1";
5983 $resql = $db->query($sql);
5985 $obj = $db->fetch_object(
$resql);
5987 return $obj->localtax1;
5988 } elseif ($local == 2) {
5989 return $obj->localtax2;
6008 function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid = 1)
6012 dol_syslog(
"getTaxesFromId vat id or rate = ".$vatrate);
6015 $sql =
"SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy,";
6016 $sql .=
" t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
6017 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
6018 if ($firstparamisid) {
6019 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
6021 $vatratecleaned = $vatrate;
6024 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
6025 $vatratecleaned = $reg[1];
6026 $vatratecode = $reg[2];
6029 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
6032 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($seller->country_code).
"'";
6033 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
6035 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
6039 $resql = $db->query($sql);
6041 $obj = $db->fetch_object(
$resql);
6044 'rowid'=>$obj->rowid,
6047 'localtax1'=>$obj->localtax1,
6048 'localtax1_type'=>$obj->localtax1_type,
6049 'localtax2'=>$obj->localtax2,
6050 'localtax2_type'=>$obj->localtax2_type,
6052 'accountancy_code_sell'=>$obj->accountancy_code_sell,
6053 'accountancy_code_buy'=>$obj->accountancy_code_buy
6085 dol_syslog(
"getLocalTaxesFromRate vatrate=".$vatrate.
" local=".$local);
6088 $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";
6089 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
6090 if ($firstparamisid) {
6091 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
6093 $vatratecleaned = $vatrate;
6096 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
6097 $vatratecleaned = $reg[1];
6098 $vatratecode = $reg[2];
6101 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
6102 if ($mysoc->country_code ==
'ES') {
6103 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($buyer->country_code).
"'";
6105 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(empty($seller->country_code) ? $mysoc->country_code : $seller->country_code).
"'";
6107 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
6109 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
6113 $resql = $db->query($sql);
6115 $obj = $db->fetch_object(
$resql);
6118 $vateratestring = $obj->rate.($obj->code ?
' ('.$obj->code.
')' :
'');
6121 return array($obj->localtax1_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
6122 } elseif ($local == 2) {
6123 return array($obj->localtax2_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
6125 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);
6145 global $db, $conf, $mysoc;
6147 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
6155 $result = $product->fetch($idprod);
6157 if ($mysoc->country_code == $thirdpartytouse->country_code) {
6158 if ($idprodfournprice > 0) {
6159 $product->get_buyprice($idprodfournprice, 0, 0, 0);
6160 $ret = $product->vatrate_supplier;
6161 if ($product->default_vat_code) {
6162 $ret .=
' ('.$product->default_vat_code.
')';
6165 $ret = $product->tva_tx;
6166 if ($product->default_vat_code) {
6167 $ret .=
' ('.$product->default_vat_code.
')';
6178 if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
6180 $sql =
"SELECT t.taux as vat_rate, t.code as default_vat_code";
6181 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
6182 $sql .=
" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdpartytouse->country_code).
"'";
6183 $sql .=
" ORDER BY t.taux DESC, t.code ASC, t.recuperableonly ASC";
6184 $sql .= $db->plimit(1);
6186 $resql = $db->query($sql);
6188 $obj = $db->fetch_object(
$resql);
6190 $ret = $obj->vat_rate;
6191 if ($obj->default_vat_code) {
6192 $ret .=
' ('.$obj->default_vat_code.
')';
6200 $ret = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
6204 dol_syslog(
"get_product_vat_for_country: ret=".$ret);
6221 if (!class_exists(
'Product')) {
6222 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
6231 $result = $product->fetch($idprod);
6233 if ($mysoc->country_code == $thirdpartytouse->country_code) {
6247 $sql =
"SELECT taux as vat_rate, localtax1, localtax2";
6248 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
6249 $sql .=
" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdpartytouse->country_code).
"'";
6250 $sql .=
" ORDER BY t.taux DESC, t.recuperableonly ASC";
6251 $sql .= $db->plimit(1);
6253 $resql = $db->query($sql);
6255 $obj = $db->fetch_object(
$resql);
6258 $ret = $obj->localtax1;
6259 } elseif ($local == 2) {
6260 $ret = $obj->localtax2;
6268 dol_syslog(
"get_product_localtax_for_country: ret=".$ret);
6292 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
6295 $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;
6297 $seller_country_code = $thirdparty_seller->country_code;
6298 $seller_in_cee =
isInEEC($thirdparty_seller);
6300 $buyer_country_code = $thirdparty_buyer->country_code;
6301 $buyer_in_cee =
isInEEC($thirdparty_buyer);
6303 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 :
''));
6307 if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
6308 if ($seller_in_cee && $buyer_in_cee) {
6309 $isacompany = $thirdparty_buyer->
isACompany();
6310 if ($isacompany && !empty($conf->global->MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL)) {
6311 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
6325 if (!$seller_use_vat) {
6333 if (($seller_country_code == $buyer_country_code)
6334 || (in_array($seller_country_code, array(
'FR',
'MC')) && in_array($buyer_country_code, array(
'FR',
'MC')))) {
6344 if (($seller_in_cee && $buyer_in_cee)) {
6345 $isacompany = $thirdparty_buyer->
isACompany();
6346 if ($isacompany && !empty($conf->global->MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL)) {
6347 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
6364 if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC) && empty($buyer_in_cee)) {
6365 $isacompany = $thirdparty_buyer->
isACompany();
6393 if ($idprodfournprice > 0) {
6394 if (!class_exists(
'ProductFournisseur')) {
6395 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
6398 $prodprice->fetch_product_fournisseur_price($idprodfournprice);
6399 return $prodprice->fourn_tva_npr;
6400 } elseif ($idprod > 0) {
6401 if (!class_exists(
'Product')) {
6402 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
6405 $prod->fetch($idprod);
6406 return $prod->tva_npr;
6429 if (!is_object($thirdparty_seller)) {
6432 if (!is_object($thirdparty_buyer)) {
6437 if ($mysoc->country_code ==
'ES') {
6438 if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) {
6443 if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) {
6446 if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj ==
'localtax1off') {
6450 } elseif ($local == 2) {
6452 if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) {
6455 if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj ==
'localtax2off') {
6460 if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
6475 function yn($yesno, $case = 1, $color = 0)
6479 $result =
'unknown';
6481 if ($yesno == 1 || strtolower($yesno) ==
'yes' || strtolower($yesno) ==
'true') {
6482 $result = $langs->trans(
'yes');
6483 if ($case == 1 || $case == 3) {
6484 $result = $langs->trans(
"Yes");
6487 $result =
'<input type="checkbox" value="1" checked disabled>';
6490 $result =
'<input type="checkbox" value="1" checked disabled> '.$result;
6494 } elseif ($yesno == 0 || strtolower($yesno) ==
'no' || strtolower($yesno) ==
'false') {
6495 $result = $langs->trans(
"no");
6496 if ($case == 1 || $case == 3) {
6497 $result = $langs->trans(
"No");
6500 $result =
'<input type="checkbox" value="0" disabled>';
6503 $result =
'<input type="checkbox" value="0" disabled> '.$result;
6509 $classname =
'error';
6513 return '<span class="'.$classname.
'">'.$result.
'</span>';
6533 function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart =
'')
6537 if (empty($modulepart) && !empty($object->module)) {
6538 $modulepart = $object->module;
6543 $arrayforoldpath = array(
'cheque',
'category',
'holiday',
'supplier_invoice',
'invoice_supplier',
'mailing',
'supplier_payment');
6544 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
6545 $arrayforoldpath[] =
'product';
6547 if (!empty($level) && in_array($modulepart, $arrayforoldpath)) {
6549 if (empty($alpha)) {
6550 $num = preg_replace(
'/([^0-9])/i',
'', $num);
6552 $num = preg_replace(
'/^.*\-/i',
'', $num);
6554 $num = substr(
"000".$num, -$level);
6556 $path = substr($num, 0, 1);
6559 $path = substr($num, 1, 1).
'/'.substr($num, 0, 1);
6562 $path = substr($num, 2, 1).
'/'.substr($num, 1, 1).
'/'.substr($num, 0, 1);
6572 if (empty($withoutslash) && !empty($path)) {
6591 dol_syslog(
"functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
6594 if (@is_dir($dir_osencoded)) {
6602 if (!empty($dataroot)) {
6604 $dir = str_replace($dataroot.
'/',
'', $dir);
6605 $ccdir = $dataroot.
'/';
6608 $cdir = explode(
"/", $dir);
6609 $num = count($cdir);
6610 for ($i = 0; $i < $num; $i++) {
6612 $ccdir .=
'/'.$cdir[$i];
6614 $ccdir .= $cdir[$i];
6616 if (preg_match(
"/^.:$/", $ccdir, $regs)) {
6624 if (!@is_dir($ccdir_osencoded)) {
6625 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG);
6628 $dirmaskdec = octdec((
string) $newmask);
6629 if (empty($newmask)) {
6630 $dirmaskdec = empty($conf->global->MAIN_UMASK) ? octdec(
'0755') : octdec($conf->global->MAIN_UMASK);
6632 $dirmaskdec |= octdec(
'0111');
6633 if (!@mkdir($ccdir_osencoded, $dirmaskdec)) {
6635 dol_syslog(
"functions.lib::dol_mkdir: Fails to create directory '".$ccdir.
"' or directory already exists.", LOG_WARNING);
6638 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' created", LOG_DEBUG);
6647 return ($nberr ? -$nberr : $nbcreated);
6658 return '<span class="fieldrequired">*</span>';
6678 function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
'UTF-8', $strip_tags = 0, $removedoublespaces = 1)
6680 if ($removelinefeed == 2) {
6681 $stringtoclean = preg_replace(
'/<br[^>]*>(\n|\r)+/ims',
'<br>', $stringtoclean);
6683 $temp = preg_replace(
'/<br[^>]*>/i',
"\n", $stringtoclean);
6688 $temp = str_replace(
'< ',
'__ltspace__', $temp);
6691 $temp = strip_tags($temp);
6694 $pattern =
"/<[^<>]+>/";
6701 $tempbis = str_replace(
'<>',
'', $temp);
6702 $tempbis = preg_replace($pattern,
'', $tempbis);
6704 }
while ($tempbis != $temp);
6709 $temp = preg_replace(
'/<+([a-z]+)/i',
'\1', $temp);
6715 if ($removelinefeed == 1) {
6716 $temp = str_replace(array(
"\r\n",
"\r",
"\n"),
" ", $temp);
6720 if ($removedoublespaces) {
6721 while (strpos($temp,
" ")) {
6722 $temp = str_replace(
" ",
" ", $temp);
6726 $temp = str_replace(
'__ltspace__',
'< ', $temp);
6746 $allowed_tags = array(
6747 "html",
"head",
"meta",
"body",
"article",
"a",
"abbr",
"b",
"blockquote",
"br",
"cite",
"div",
"dl",
"dd",
"dt",
"em",
"font",
"img",
"ins",
"hr",
"i",
"li",
"link",
6748 "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",
6752 $allowed_tags[] =
"iframe";
6755 $allowed_tags_string = join(
"><", $allowed_tags);
6756 $allowed_tags_string =
'<'.$allowed_tags_string.
'>';
6758 $stringtoclean = str_replace(
'<!DOCTYPE html>',
'__!DOCTYPE_HTML__', $stringtoclean);
6763 $stringtoclean = preg_replace(
'/<!--([^>]*)-->/',
'<comment>\1</comment>', $stringtoclean);
6765 $stringtoclean = preg_replace(
'/:/i',
':', $stringtoclean);
6766 $stringtoclean = preg_replace(
'/:|�+58|:/i',
'', $stringtoclean);
6767 $stringtoclean = preg_replace(
'/javascript\s*:/i',
'', $stringtoclean);
6769 $temp = strip_tags($stringtoclean, $allowed_tags_string);
6771 if ($cleanalsosomestyles) {
6772 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/i',
'', $temp);
6774 if ($removeclassattribute) {
6775 $temp = preg_replace(
'/(<[^>]+)\s+class=((["\']).*?\\3|\\w*)/i',
'\\1', $temp);
6780 if ($cleanalsojavascript) {
6781 $temp = preg_replace(
'/javascript\s*:/i',
'', $temp);
6784 $temp = str_replace(
'__!DOCTYPE_HTML__',
'<!DOCTYPE html>', $temp);
6786 $temp = preg_replace(
'/<comment>([^>]*)<\/comment>/',
'<!--\1-->', $temp);
6804 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"))
6806 if (class_exists(
'DOMDocument') && !empty($stringtoclean)) {
6807 $stringtoclean =
'<?xml encoding="UTF-8"><html><body>'.$stringtoclean.
'</body></html>';
6809 $dom =
new DOMDocument(null,
'UTF-8');
6810 $dom->loadHTML($stringtoclean, LIBXML_ERR_NONE|LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD|LIBXML_NONET|LIBXML_NOWARNING|LIBXML_NOXMLDECL);
6812 if (is_object($dom)) {
6813 for ($els = $dom->getElementsByTagname(
'*'), $i = $els->length - 1; $i >= 0; $i--) {
6814 for ($attrs = $els->item($i)->attributes, $ii = $attrs->length - 1; $ii >= 0; $ii--) {
6816 if (! empty($attrs->item($ii)->name)) {
6818 if (! in_array($attrs->item($ii)->name, $allowed_attributes)) {
6819 $els->item($i)->removeAttribute($attrs->item($ii)->name);
6820 } elseif (in_array($attrs->item($ii)->name, array(
'style'))) {
6821 $valuetoclean = $attrs->item($ii)->value;
6823 if (isset($valuetoclean)) {
6825 $oldvaluetoclean = $valuetoclean;
6826 $valuetoclean = preg_replace(
'/\/\*.*\*\//m',
'', $valuetoclean);
6827 $valuetoclean = preg_replace(
'/position\s*:\s*[a-z]+/mi',
'', $valuetoclean);
6828 if ($els->item($i)->tagName ==
'a') {
6829 $valuetoclean = preg_replace(
'/display\s*://m',
'', $valuetoclean);
6830 $valuetoclean = preg_replace(
'/z-index\s*://m',
'', $valuetoclean);
6831 $valuetoclean = preg_replace(
'/\s+(top|left|right|bottom)\s*://m',
'', $valuetoclean);
6833 }
while ($oldvaluetoclean != $valuetoclean);
6836 $attrs->item($ii)->value = $valuetoclean;
6843 $return = $dom->saveHTML();
6846 $return = preg_replace(
'/^'.preg_quote(
'<?xml encoding="UTF-8">',
'/').
'/',
'', $return);
6847 $return = preg_replace(
'/^'.preg_quote(
'<html><body>',
'/').
'/',
'', $return);
6848 $return = preg_replace(
'/'.preg_quote(
'</body></html>',
'/').
'$/',
'', $return);
6849 return trim($return);
6851 return $stringtoclean;
6868 $temp = $stringtoclean;
6869 foreach ($disallowed_tags as $tagtoremove) {
6870 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'>/',
'', $temp);
6871 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'\s+[^>]*>/',
'', $temp);
6874 if ($cleanalsosomestyles) {
6875 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/',
'', $temp);
6893 if ($nboflines == 1) {
6895 $firstline = preg_replace(
'/<br[^>]*>.*$/s',
'', $text);
6896 $firstline = preg_replace(
'/<div[^>]*>.*$/s',
'', $firstline);
6898 $firstline = preg_replace(
'/[\n\r].*/',
'', $text);
6900 return $firstline.((strlen($firstline) != strlen($text)) ?
'...' :
'');
6904 $text = preg_replace(
'/\n/',
'', $text);
6906 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
6908 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
6911 $text = strtr($text, $repTable);
6912 if ($charset ==
'UTF-8') {
6913 $pattern =
'/(<br[^>]*>)/Uu';
6916 $pattern =
'/(<br[^>]*>)/U';
6918 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
6923 while (($i < $nba) && ($i < ($nboflines * 2))) {
6925 $firstline .= $a[$i];
6926 } elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) {
6927 $firstline .= ($ishtml ?
"<br>\n" :
"\n");
6932 return $firstline.(($i < $nba) ?
'...' :
'');
6947 function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml =
false)
6950 return nl2br($stringtoencode, $forxml);
6952 $ret = preg_replace(
'/(\r\n|\r|\n)/i', ($forxml ?
'<br />' :
'<br>'), $stringtoencode);
6975 function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom =
'UTF-8', $removelasteolbr = 1)
6977 $newstring = $stringtoencode;
6979 $newstring = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
'<br>', $newstring);
6980 if ($removelasteolbr) {
6981 $newstring = preg_replace(
'/<br>$/i',
'', $newstring);
6983 $newstring = strtr($newstring, array(
'&'=>
'__and__',
'<'=>
'__lt__',
'>'=>
'__gt__',
'"'=>
'__dquot__'));
6985 $newstring = strtr($newstring, array(
'__and__'=>
'&',
'__lt__'=>
'<',
'__gt__'=>
'>',
'__dquot__'=>
'"'));
6987 if ($removelasteolbr) {
6988 $newstring = preg_replace(
'/(\r\n|\r|\n)$/i',
'', $newstring);
7007 $ret = preg_replace(
'/'.
"\r\n".
'<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"<br>", $ret);
7008 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\r\n".
'/i',
"\r\n", $ret);
7009 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\n".
'/i',
"\n", $ret);
7010 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"\n", $ret);
7022 $ret = preg_replace(
'/ $/i',
"", $stringtodecode);
7023 $ret = preg_replace(
'/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'.
"\n".
'|'.
"\r".
')+$/i',
"", $ret);
7039 if ($keepsomeentities) {
7040 $newstring = strtr($newstring, array(
'&'=>
'__andamp__',
'<'=>
'__andlt__',
'>'=>
'__andgt__',
'"'=>
'__dquot__'));
7042 $newstring = html_entity_decode((
string) $newstring, (
int) $b, (
string) $c);
7043 if ($keepsomeentities) {
7044 $newstring = strtr($newstring, array(
'__andamp__'=>
'&',
'__andlt__'=>
'<',
'__andgt__'=>
'>',
'__dquot__'=>
'"'));
7059 function dol_htmlentities($string, $flags = ENT_QUOTES|ENT_SUBSTITUTE, $encoding =
'UTF-8', $double_encode =
false)
7061 return htmlentities($string, $flags, $encoding, $double_encode);
7078 for ($scursor = 0; $scursor < $len; $scursor++) {
7079 $ordchar = ord($s[$scursor]);
7081 if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) {
7084 } elseif ($ordchar > 126 && $ordchar < 160) {
7088 $out .= $s[$scursor];
7110 $arraystring = explode(
"\n", $s);
7111 $nb = count($arraystring);
7128 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7130 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
7133 $text = strtr($text, $repTable);
7134 if ($charset ==
'UTF-8') {
7135 $pattern =
'/(<br[^>]*>)/Uu';
7138 $pattern =
'/(<br[^>]*>)/U';
7140 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
7142 $nblines = (int) floor((count($a) + 1) / 2);
7145 foreach ($a as $line) {
7148 $line_dec = html_entity_decode($line);
7150 $line_dec = wordwrap($line_dec, $maxlinesize,
'\n',
true);
7151 $nblines += substr_count($line_dec,
'\n');
7172 if (preg_match(
'/<html/i', $msg)) {
7174 } elseif (preg_match(
'/<body/i', $msg)) {
7176 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
7178 } elseif (preg_match(
'/<(b|em|i|u)>/i', $msg)) {
7180 } elseif (preg_match(
'/<br/i', $msg)) {
7186 $msg = preg_replace(
'/https?:\/\/[^"\'\s]+/i',
'', $msg);
7187 if (preg_match(
'/<html/i', $msg)) {
7189 } elseif (preg_match(
'/<body/i', $msg)) {
7191 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
7193 } elseif (preg_match(
'/<(b|em|i|u)>/i', $msg)) {
7195 } elseif (preg_match(
'/<br\/>/i', $msg)) {
7197 } elseif (preg_match(
'/<(br|div|font|li|p|span|strong|table)>/i', $msg)) {
7199 } elseif (preg_match(
'/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/?>/i', $msg)) {
7201 } elseif (preg_match(
'/<img\s+[^<>]*src[^<>]*>/i', $msg)) {
7203 } elseif (preg_match(
'/<a\s+[^<>]*href[^<>]*>/i', $msg)) {
7205 } elseif (preg_match(
'/<h[0-9]>/i', $msg)) {
7207 } elseif (preg_match(
'/&[A-Z0-9]{1,6};/i', $msg)) {
7210 } elseif (preg_match(
'/&#[0-9]{2,3};/i', $msg)) {
7234 if (!empty($invert)) {
7242 $ret .= (!empty($text1) && !empty($text2)) ? ((
dol_textishtml($text1) ||
dol_textishtml($text2)) ? ($forxml ?
"<br >\n" :
"<br>\n") :
"\n") :
"";
7261 global $db, $conf, $mysoc, $user, $extrafields;
7263 $substitutionarray = array();
7265 if (empty($exclude) || !in_array(
'user', $exclude)) {
7268 $signature = $user->signature;
7269 $substitutionarray = array_merge($substitutionarray, array(
7270 '__USER_SIGNATURE__' => (
string) (($signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ?
dol_trunc(
dol_string_nohtmltag($signature), 30) : $signature) :
'')
7273 if (is_object($user)) {
7274 $substitutionarray = array_merge($substitutionarray, array(
7275 '__USER_ID__' => (
string) $user->id,
7276 '__USER_LOGIN__' => (
string) $user->login,
7277 '__USER_EMAIL__' => (
string) $user->email,
7280 '__USER_PHONEMOBILE__' => (
string)
dol_print_phone($user->personal_mobile),
7281 '__USER_FAX__' => (
string) $user->office_fax,
7282 '__USER_LASTNAME__' => (
string) $user->lastname,
7283 '__USER_FIRSTNAME__' => (
string) $user->firstname,
7284 '__USER_FULLNAME__' => (
string) $user->getFullName($outputlangs),
7285 '__USER_SUPERVISOR_ID__' => (string) ($user->fk_user ? $user->fk_user :
'0'),
7286 '__USER_JOB__' => (string) $user->job,
7291 if ((empty($exclude) || !in_array(
'mycompany', $exclude)) && is_object($mysoc)) {
7292 $substitutionarray = array_merge($substitutionarray, array(
7293 '__MYCOMPANY_NAME__' => $mysoc->name,
7294 '__MYCOMPANY_EMAIL__' => $mysoc->email,
7297 '__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
7298 '__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
7299 '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
7300 '__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
7301 '__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
7302 '__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
7303 '__MYCOMPANY_CAPITAL__' => $mysoc->capital,
7304 '__MYCOMPANY_FULLADDRESS__' => (method_exists($mysoc,
'getFullAddress') ? $mysoc->getFullAddress(1,
', ') :
''),
7305 '__MYCOMPANY_ADDRESS__' => $mysoc->address,
7306 '__MYCOMPANY_ZIP__' => $mysoc->zip,
7307 '__MYCOMPANY_TOWN__' => $mysoc->town,
7308 '__MYCOMPANY_COUNTRY__' => $mysoc->country,
7309 '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id,
7310 '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code,
7311 '__MYCOMPANY_CURRENCY_CODE__' => $conf->currency
7315 if (($onlykey || is_object($object)) && (empty($exclude) || !in_array(
'object', $exclude))) {
7317 $substitutionarray[
'__ID__'] =
'__ID__';
7318 $substitutionarray[
'__REF__'] =
'__REF__';
7319 $substitutionarray[
'__NEWREF__'] =
'__NEWREF__';
7320 $substitutionarray[
'__REF_CLIENT__'] =
'__REF_CLIENT__';
7321 $substitutionarray[
'__REF_SUPPLIER__'] =
'__REF_SUPPLIER__';
7322 $substitutionarray[
'__NOTE_PUBLIC__'] =
'__NOTE_PUBLIC__';
7323 $substitutionarray[
'__NOTE_PRIVATE__'] =
'__NOTE_PRIVATE__';
7324 $substitutionarray[
'__EXTRAFIELD_XXX__'] =
'__EXTRAFIELD_XXX__';
7326 if (!empty($conf->societe->enabled)) {
7327 $substitutionarray[
'__THIRDPARTY_ID__'] =
'__THIRDPARTY_ID__';
7328 $substitutionarray[
'__THIRDPARTY_NAME__'] =
'__THIRDPARTY_NAME__';
7329 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
'__THIRDPARTY_NAME_ALIAS__';
7330 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
'__THIRDPARTY_CODE_CLIENT__';
7331 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
'__THIRDPARTY_CODE_FOURNISSEUR__';
7332 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
'__THIRDPARTY_EMAIL__';
7333 $substitutionarray[
'__THIRDPARTY_PHONE__'] =
'__THIRDPARTY_PHONE__';
7334 $substitutionarray[
'__THIRDPARTY_FAX__'] =
'__THIRDPARTY_FAX__';
7335 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
'__THIRDPARTY_ADDRESS__';
7336 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
'__THIRDPARTY_ZIP__';
7337 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
'__THIRDPARTY_TOWN__';
7338 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
'__THIRDPARTY_IDPROF1__';
7339 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
'__THIRDPARTY_IDPROF2__';
7340 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
'__THIRDPARTY_IDPROF3__';
7341 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
'__THIRDPARTY_IDPROF4__';
7342 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
'__THIRDPARTY_IDPROF5__';
7343 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
'__THIRDPARTY_IDPROF6__';
7344 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
'__THIRDPARTY_TVAINTRA__';
7345 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] =
'__THIRDPARTY_NOTE_PUBLIC__';
7346 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] =
'__THIRDPARTY_NOTE_PRIVATE__';
7348 if (!empty($conf->adherent->enabled) && (!is_object($object) || $object->element ==
'adherent')) {
7349 $substitutionarray[
'__MEMBER_ID__'] =
'__MEMBER_ID__';
7350 $substitutionarray[
'__MEMBER_CIVILITY__'] =
'__MEMBER_CIVILITY__';
7351 $substitutionarray[
'__MEMBER_FIRSTNAME__'] =
'__MEMBER_FIRSTNAME__';
7352 $substitutionarray[
'__MEMBER_LASTNAME__'] =
'__MEMBER_LASTNAME__';
7353 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'Login and pass of the external user account';
7358 if (!empty($conf->ticket->enabled) && (!is_object($object) || $object->element ==
'ticket')) {
7359 $substitutionarray[
'__TICKET_TRACKID__'] =
'__TICKET_TRACKID__';
7360 $substitutionarray[
'__TICKET_SUBJECT__'] =
'__TICKET_SUBJECT__';
7361 $substitutionarray[
'__TICKET_TYPE__'] =
'__TICKET_TYPE__';
7362 $substitutionarray[
'__TICKET_SEVERITY__'] =
'__TICKET_SEVERITY__';
7363 $substitutionarray[
'__TICKET_CATEGORY__'] =
'__TICKET_CATEGORY__';
7364 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
'__TICKET_ANALYTIC_CODE__';
7365 $substitutionarray[
'__TICKET_MESSAGE__'] =
'__TICKET_MESSAGE__';
7366 $substitutionarray[
'__TICKET_PROGRESSION__'] =
'__TICKET_PROGRESSION__';
7367 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
'__TICKET_USER_ASSIGN__';
7370 if (!empty($conf->recruitment->enabled) && (!is_object($object) || $object->element ==
'recruitmentcandidature')) {
7371 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
'__CANDIDATE_FULLNAME__';
7372 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] =
'__CANDIDATE_FIRSTNAME__';
7373 $substitutionarray[
'__CANDIDATE_LASTNAME__'] =
'__CANDIDATE_LASTNAME__';
7375 if (!empty($conf->project->enabled)) {
7376 $substitutionarray[
'__PROJECT_ID__'] =
'__PROJECT_ID__';
7377 $substitutionarray[
'__PROJECT_REF__'] =
'__PROJECT_REF__';
7378 $substitutionarray[
'__PROJECT_NAME__'] =
'__PROJECT_NAME__';
7382 if (!empty($conf->contrat->enabled) && (!is_object($object) || $object->element ==
'contract')) {
7383 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
'Highest date planned for a service start';
7384 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
'Highest date and hour planned for service start';
7385 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
'Lowest data for planned expiration of service';
7386 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
'Lowest date and hour for planned expiration of service';
7388 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'UrlToPayOnlineIfApplicable';
7389 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'TextAndUrlToPayOnlineIfApplicable';
7390 $substitutionarray[
'__SECUREKEYPAYMENT__'] =
'Security key (if key is not unique per record)';
7391 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
'Security key for payment on a member subscription (one key per member)';
7392 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
'Security key for payment on an order';
7393 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
'Security key for payment on an invoice';
7394 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
'Security key for payment on a service of a contract';
7396 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'Direct download url of a proposal';
7397 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'Direct download url of an order';
7398 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'Direct download url of an invoice';
7399 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'Direct download url of a contract';
7400 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'Direct download url of a supplier proposal';
7402 if (!empty($conf->expedition->enabled) && (!is_object($object) || $object->element ==
'shipping')) {
7403 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
'Shipping tracking number';
7404 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
'Shipping tracking url';
7406 if (!empty($conf->reception->enabled) && (!is_object($object) || $object->element ==
'reception')) {
7407 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
'Shippin tracking number of shipment';
7408 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
'Shipping tracking url';
7411 $substitutionarray[
'__ID__'] = $object->id;
7412 $substitutionarray[
'__REF__'] = $object->ref;
7413 $substitutionarray[
'__NEWREF__'] = $object->newref;
7414 $substitutionarray[
'__REF_CLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null));
7415 $substitutionarray[
'__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null);
7416 $substitutionarray[
'__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null);
7417 $substitutionarray[
'__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null);
7418 $substitutionarray[
'__DATE_DELIVERY__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
'day', 0, $outputlangs) :
'');
7419 $substitutionarray[
'__DATE_DELIVERY_DAY__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%d") :
'');
7420 $substitutionarray[
'__DATE_DELIVERY_DAY_TEXT__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%A") :
'');
7421 $substitutionarray[
'__DATE_DELIVERY_MON__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%m") :
'');
7422 $substitutionarray[
'__DATE_DELIVERY_MON_TEXT__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%b") :
'');
7423 $substitutionarray[
'__DATE_DELIVERY_YEAR__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%Y") :
'');
7424 $substitutionarray[
'__DATE_DELIVERY_HH__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%H") :
'');
7425 $substitutionarray[
'__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%M") :
'');
7426 $substitutionarray[
'__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
"%S") :
'');
7429 $substitutionarray[
'__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null));
7430 $substitutionarray[
'__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null);
7431 $substitutionarray[
'__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ?
dol_print_date($object->date_livraison,
'day', 0, $outputlangs) :
'');
7432 $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 :
'')) :
'');
7434 if (is_object($object) && ($object->element ==
'adherent' || $object->element ==
'member') && $object->id > 0) {
7435 $birthday = (empty($object->birth) ?
'' :
dol_print_date($object->birth,
'day'));
7437 $substitutionarray[
'__MEMBER_ID__'] = (isset($object->id) ? $object->id :
'');
7438 if (method_exists($object,
'getCivilityLabel')) {
7439 $substitutionarray[
'__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
7441 $substitutionarray[
'__MEMBER_FIRSTNAME__'] = (isset($object->firstname) ? $object->firstname :
'');
7442 $substitutionarray[
'__MEMBER_LASTNAME__'] = (isset($object->lastname) ? $object->lastname :
'');
7443 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'';
7444 if (method_exists($object,
'getFullName')) {
7445 $substitutionarray[
'__MEMBER_FULLNAME__'] = $object->getFullName($outputlangs);
7447 $substitutionarray[
'__MEMBER_COMPANY__'] = (isset($object->societe) ? $object->societe :
'');
7448 $substitutionarray[
'__MEMBER_ADDRESS__'] = (isset($object->address) ? $object->address :
'');
7449 $substitutionarray[
'__MEMBER_ZIP__'] = (isset($object->zip) ? $object->zip :
'');
7450 $substitutionarray[
'__MEMBER_TOWN__'] = (isset($object->town) ? $object->town :
'');
7451 $substitutionarray[
'__MEMBER_COUNTRY__'] = (isset($object->country) ? $object->country :
'');
7452 $substitutionarray[
'__MEMBER_EMAIL__'] = (isset($object->email) ? $object->email :
'');
7453 $substitutionarray[
'__MEMBER_BIRTH__'] = (isset($birthday) ? $birthday :
'');
7454 $substitutionarray[
'__MEMBER_PHOTO__'] = (isset($object->photo) ? $object->photo :
'');
7455 $substitutionarray[
'__MEMBER_LOGIN__'] = (isset($object->login) ? $object->login :
'');
7456 $substitutionarray[
'__MEMBER_PASSWORD__'] = (isset($object->pass) ? $object->pass :
'');
7457 $substitutionarray[
'__MEMBER_PHONE__'] = (isset($object->phone) ?
dol_print_phone($object->phone) :
'');
7458 $substitutionarray[
'__MEMBER_PHONEPRO__'] = (isset($object->phone_perso) ?
dol_print_phone($object->phone_perso) :
'');
7459 $substitutionarray[
'__MEMBER_PHONEMOBILE__'] = (isset($object->phone_mobile) ?
dol_print_phone($object->phone_mobile) :
'');
7460 $substitutionarray[
'__MEMBER_TYPE__'] = (isset($object->type) ? $object->type :
'');
7461 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE__'] =
dol_print_date($object->first_subscription_date,
'dayrfc');
7462 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = (isset($object->first_subscription_date_start) ?
dol_print_date($object->first_subscription_date_start,
'dayrfc') :
'');
7463 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = (isset($object->first_subscription_date_end) ?
dol_print_date($object->first_subscription_date_end,
'dayrfc') :
'');
7464 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE__'] =
dol_print_date($object->last_subscription_date,
'dayrfc');
7465 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] =
dol_print_date($object->last_subscription_date_start,
'dayrfc');
7466 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] =
dol_print_date($object->last_subscription_date_end,
'dayrfc');
7469 if (is_object($object) && $object->element ==
'societe') {
7470 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object($object) ? $object->id :
'');
7471 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object($object) ? $object->name :
'');
7472 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object($object) ? $object->name_alias :
'');
7473 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object($object) ? $object->code_client :
'');
7474 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object) ? $object->code_fournisseur :
'');
7475 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object($object) ? $object->email :
'');
7476 $substitutionarray[
'__THIRDPARTY_PHONE__'] = (is_object($object) ?
dol_print_phone($object->phone) :
'');
7477 $substitutionarray[
'__THIRDPARTY_FAX__'] = (is_object($object) ?
dol_print_phone($object->fax) :
'');
7478 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object($object) ? $object->address :
'');
7479 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object($object) ? $object->zip :
'');
7480 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object($object) ? $object->town :
'');
7481 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object($object) ? $object->country_id :
'');
7482 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object) ? $object->country_code :
'');
7483 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object($object) ? $object->idprof1 :
'');
7484 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object($object) ? $object->idprof2 :
'');
7485 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object($object) ? $object->idprof3 :
'');
7486 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object($object) ? $object->idprof4 :
'');
7487 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object($object) ? $object->idprof5 :
'');
7488 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object($object) ? $object->idprof6 :
'');
7489 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object($object) ? $object->tva_intra :
'');
7490 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object) ?
dol_htmlentitiesbr($object->note_public) :
'');
7491 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object) ?
dol_htmlentitiesbr($object->note_private) :
'');
7492 } elseif (is_object($object->thirdparty)) {
7493 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->id :
'');
7494 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object($object->thirdparty) ? $object->thirdparty->name :
'');
7495 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty) ? $object->thirdparty->name_alias :
'');
7496 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_client :
'');
7497 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_fournisseur :
'');
7498 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty) ? $object->thirdparty->email :
'');
7499 $substitutionarray[
'__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty) ?
dol_print_phone($object->thirdparty->phone) :
'');
7500 $substitutionarray[
'__THIRDPARTY_FAX__'] = (is_object($object->thirdparty) ?
dol_print_phone($object->thirdparty->fax) :
'');
7501 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty) ? $object->thirdparty->address :
'');
7502 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty) ? $object->thirdparty->zip :
'');
7503 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty) ? $object->thirdparty->town :
'');
7504 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_id :
'');
7505 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_code :
'');
7506 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof1 :
'');
7507 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof2 :
'');
7508 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof3 :
'');
7509 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof4 :
'');
7510 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof5 :
'');
7511 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof6 :
'');
7512 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty) ? $object->thirdparty->tva_intra :
'');
7513 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object->thirdparty) ?
dol_htmlentitiesbr($object->thirdparty->note_public) :
'');
7514 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object->thirdparty) ?
dol_htmlentitiesbr($object->thirdparty->note_private) :
'');
7517 if (is_object($object) && $object->element ==
'recruitmentcandidature') {
7518 $substitutionarray[
'__CANDIDATE_FULLNAME__'] = $object->getFullName($outputlangs);
7519 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname :
'';
7520 $substitutionarray[
'__CANDIDATE_LASTNAME__'] = isset($object->lastname) ? $object->lastname :
'';
7523 if (is_object($object->project)) {
7524 $substitutionarray[
'__PROJECT_ID__'] = (is_object($object->project) ? $object->project->id :
'');
7525 $substitutionarray[
'__PROJECT_REF__'] = (is_object($object->project) ? $object->project->ref :
'');
7526 $substitutionarray[
'__PROJECT_NAME__'] = (is_object($object->project) ? $object->project->title :
'');
7528 if (is_object($object->projet)) {
7529 $substitutionarray[
'__PROJECT_ID__'] = (is_object($object->projet) ? $object->projet->id :
'');
7530 $substitutionarray[
'__PROJECT_REF__'] = (is_object($object->projet) ? $object->projet->ref :
'');
7531 $substitutionarray[
'__PROJECT_NAME__'] = (is_object($object->projet) ? $object->projet->title :
'');
7534 if (is_object($object) && $object->element ==
'shipping') {
7535 $substitutionarray[
'__SHIPPINGTRACKNUM__'] = $object->tracking_number;
7536 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] = $object->tracking_url;
7538 if (is_object($object) && $object->element ==
'reception') {
7539 $substitutionarray[
'__RECEPTIONTRACKNUM__'] = $object->tracking_number;
7540 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] = $object->tracking_url;
7543 if (is_object($object) && $object->element ==
'contrat' && $object->id > 0 && is_array($object->lines)) {
7544 $dateplannedstart =
'';
7545 $datenextexpiration =
'';
7546 foreach ($object->lines as $line) {
7547 if ($line->date_ouverture_prevue > $dateplannedstart) {
7548 $dateplannedstart = $line->date_ouverture_prevue;
7550 if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) {
7551 $datenextexpiration = $line->date_fin_prevue;
7554 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
dol_print_date($dateplannedstart,
'dayrfc');
7555 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
dol_print_date($dateplannedstart,
'standard');
7556 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
dol_print_date($datenextexpiration,
'dayrfc');
7557 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
dol_print_date($datenextexpiration,
'standard');
7560 if (is_object($object) && $object->element ==
'ticket') {
7561 $substitutionarray[
'__TICKET_TRACKID__'] = $object->track_id;
7562 $substitutionarray[
'__REF__'] = $object->ref;
7563 $substitutionarray[
'__TICKET_SUBJECT__'] = $object->subject;
7564 $substitutionarray[
'__TICKET_TYPE__'] = $object->type_code;
7565 $substitutionarray[
'__TICKET_SEVERITY__'] = $object->severity_code;
7566 $substitutionarray[
'__TICKET_CATEGORY__'] = $object->category_code;
7567 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] = $object->category_code;
7568 $substitutionarray[
'__TICKET_MESSAGE__'] = $object->message;
7569 $substitutionarray[
'__TICKET_PROGRESSION__'] = $object->progress;
7570 $userstat =
new User($db);
7571 if ($object->fk_user_assign > 0) {
7572 $userstat->fetch($object->fk_user_assign);
7573 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
7576 if ($object->fk_user_create > 0) {
7577 $userstat->fetch($object->fk_user_create);
7578 $substitutionarray[
'__USER_CREATE__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
7583 if ($object->table_element && $object->id > 0) {
7584 if (!is_object($extrafields)) {
7587 $extrafields->fetch_name_optionals_label($object->table_element,
true);
7589 if ($object->fetch_optionals() > 0) {
7590 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label']) > 0) {
7591 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $label) {
7592 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = $object->array_options[
'options_'.$key];
7593 if ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'date') {
7594 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_date($object->array_options[
'options_'.$key],
'day');
7595 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] =
dol_print_date($object->array_options[
'options_'.$key],
'day',
'tzserver', $outputlangs);
7596 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] =
dol_print_date($object->array_options[
'options_'.$key],
'dayrfc');
7597 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'datetime') {
7598 $datetime = $object->array_options[
'options_'.$key];
7599 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
7600 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
7601 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_DAY_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'day',
'tzserver', $outputlangs) :
'');
7602 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
7603 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'phone') {
7604 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_phone($object->array_options[
'options_'.$key]);
7605 } elseif ($extrafields->attributes[$object->table_element][
'type'][$key] ==
'price') {
7606 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = $object->array_options[
'options_'.$key];
7607 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATED__'] =
price($object->array_options[
'options_'.$key]);
7616 if (empty($substitutionarray[
'__REF__'])) {
7620 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
7621 $outputlangs->loadLangs(array(
'paypal',
'other'));
7622 $typeforonlinepayment =
'free';
7623 if (is_object($object) && $object->element ==
'commande') {
7624 $typeforonlinepayment =
'order';
7626 if (is_object($object) && $object->element ==
'facture') {
7627 $typeforonlinepayment =
'invoice';
7629 if (is_object($object) && $object->element ==
'member') {
7630 $typeforonlinepayment =
'member';
7632 if (is_object($object) && $object->element ==
'contrat') {
7633 $typeforonlinepayment =
'contract';
7635 $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray[
'__REF__']);
7639 if ($object->id > 0) {
7640 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ?str_replace(
'\n',
"\n", $outputlangs->trans(
"PredefinedMailContentLink", $paymenturl)) :
'');
7641 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] = $paymenturl;
7643 if (is_object($object) && $object->element ==
'propal') {
7644 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
7645 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'proposal', $object->ref);
7647 if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'propal') {
7648 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
7650 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'';
7652 if (!empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'commande') {
7653 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element);
7655 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'';
7657 if (!empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'facture') {
7658 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element);
7660 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'';
7662 if (!empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'contrat') {
7663 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] = $object->getLastMainDocLink($object->element);
7665 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'';
7667 if (!empty($conf->global->SUPPLIER_PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element ==
'supplier_proposal') {
7668 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
7670 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'';
7673 if (is_object($object) && $object->element ==
'propal') {
7674 $substitutionarray[
'__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/comm/propal/card.php?id=".$object->id;
7676 if (is_object($object) && $object->element ==
'commande') {
7677 $substitutionarray[
'__URL_ORDER__'] = DOL_MAIN_URL_ROOT.
"/commande/card.php?id=".$object->id;
7679 if (is_object($object) && $object->element ==
'facture') {
7680 $substitutionarray[
'__URL_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/compta/facture/card.php?id=".$object->id;
7682 if (is_object($object) && $object->element ==
'contrat') {
7683 $substitutionarray[
'__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT.
"/contrat/card.php?id=".$object->id;
7685 if (is_object($object) && $object->element ==
'supplier_proposal') {
7686 $substitutionarray[
'__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/supplier_proposal/card.php?id=".$object->id;
7688 if (is_object($object) && $object->element ==
'shipping') {
7689 $substitutionarray[
'__URL_SHIPMENT__'] = DOL_MAIN_URL_ROOT.
"/expedition/card.php?id=".$object->id;
7693 if (is_object($object) && $object->element ==
'action') {
7694 $substitutionarray[
'__EVENT_LABEL__'] = $object->label;
7695 $substitutionarray[
'__EVENT_DATE__'] =
dol_print_date($object->datep,
'%A %d %b %Y');
7696 $substitutionarray[
'__EVENT_TIME__'] =
dol_print_date($object->datep,
'%H:%M:%S');
7700 if (empty($exclude) || !in_array(
'objectamount', $exclude)) {
7701 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functionsnumtoword.lib.php';
7703 $substitutionarray[
'__DATE_YMD__'] = is_object($object) ? (isset($object->date) ?
dol_print_date($object->date,
'day', 0, $outputlangs) : null) :
'';
7704 $substitutionarray[
'__DATE_DUE_YMD__'] = is_object($object) ? (isset($object->date_lim_reglement) ?
dol_print_date($object->date_lim_reglement,
'day', 0, $outputlangs) : null) :
'';
7706 $already_payed_all = 0;
7707 if (is_object($object) && ($object instanceof
Facture)) {
7708 $already_payed_all = $object->sumpayed + $object->sumdeposit + $object->sumcreditnote;
7711 $substitutionarray[
'__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht :
'';
7713 $substitutionarray[
'__AMOUNT__'] = is_object($object) ? $object->total_ttc :
'';
7714 $substitutionarray[
'__AMOUNT_TEXT__'] = is_object($object) ?
dol_convertToWord($object->total_ttc, $outputlangs,
'',
true) :
'';
7715 $substitutionarray[
'__AMOUNT_TEXTCURRENCY__'] = is_object($object) ?
dol_convertToWord($object->total_ttc, $outputlangs, $conf->currency,
true) :
'';
7717 $substitutionarray[
'__AMOUNT_REMAIN__'] = is_object($object) ? $object->total_ttc - $already_payed_all :
'';
7719 $substitutionarray[
'__AMOUNT_VAT__'] = is_object($object) ? (isset($object->total_vat) ? $object->total_vat : $object->total_tva) :
'';
7720 $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)) :
'';
7721 $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)) :
'';
7723 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
7724 $substitutionarray[
'__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 :
'';
7726 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
7727 $substitutionarray[
'__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 :
'';
7731 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object) ? ($object->total_ht ?
price($object->total_ht, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) :
'';
7732 $substitutionarray[
'__AMOUNT_FORMATED__'] = is_object($object) ? ($object->total_ttc ?
price($object->total_ttc, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) :
'';
7733 $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) :
'';
7734 $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)) :
'';
7735 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
7736 $substitutionarray[
'__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? ($object->total_localtax1 ?
price($object->total_localtax1, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) :
'';
7738 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
7739 $substitutionarray[
'__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? ($object->total_localtax2 ?
price($object->total_localtax2, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) :
'';
7742 $substitutionarray[
'__AMOUNT_MULTICURRENCY__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ? $object->multicurrency_total_ttc :
'';
7743 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXT__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ?
dol_convertToWord($object->multicurrency_total_ttc, $outputlangs,
'',
true) :
'';
7744 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXTCURRENCY__'] = (is_object($object) && isset($object->multicurrency_total_ttc)) ?
dol_convertToWord($object->multicurrency_total_ttc, $outputlangs, $object->multicurrency_code,
true) :
'';
7748 if ($onlykey != 2) {
7749 $substitutionarray[
'__TOTAL_TTC__'] = is_object($object) ? $object->total_ttc :
'';
7750 $substitutionarray[
'__TOTAL_HT__'] = is_object($object) ? $object->total_ht :
'';
7751 $substitutionarray[
'__TOTAL_VAT__'] = is_object($object) ? (isset($object->total_vat) ? $object->total_vat : $object->total_tva) :
'';
7756 if (empty($exclude) || !in_array(
'date', $exclude)) {
7757 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
7765 $daytext = $outputlangs->trans(
'Day'.$tmp[
'wday']);
7767 $substitutionarray = array_merge($substitutionarray, array(
7768 '__DAY__' => (
string) $tmp[
'mday'],
7769 '__DAY_TEXT__' => $daytext,
7770 '__DAY_TEXT_SHORT__' =>
dol_trunc($daytext, 3,
'right',
'UTF-8', 1),
7771 '__DAY_TEXT_MIN__' =>
dol_trunc($daytext, 1,
'right',
'UTF-8', 1),
7772 '__MONTH__' => (
string) $tmp[
'mon'],
7773 '__MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp[
'mon'])),
7774 '__MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp[
'mon'])),
7775 '__MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp[
'mon'])),
7776 '__YEAR__' => (
string) $tmp[
'year'],
7777 '__PREVIOUS_DAY__' => (string) $tmp2[
'day'],
7778 '__PREVIOUS_MONTH__' => (
string) $tmp3[
'month'],
7779 '__PREVIOUS_YEAR__' => (string) ($tmp[
'year'] - 1),
7780 '__NEXT_DAY__' => (string) $tmp4[
'day'],
7781 '__NEXT_MONTH__' => (
string) $tmp5[
'month'],
7782 '__NEXT_YEAR__' => (string) ($tmp[
'year'] + 1),
7786 if (!empty($conf->multicompany->enabled)) {
7787 $substitutionarray = array_merge($substitutionarray, array(
'__ENTITY_ID__' => $conf->entity));
7789 if (empty($exclude) || !in_array(
'system', $exclude)) {
7790 $substitutionarray[
'__DOL_MAIN_URL_ROOT__'] = DOL_MAIN_URL_ROOT;
7791 $substitutionarray[
'__(AnyTranslationKey)__'] = $outputlangs->trans(
'TranslationOfKey');
7792 $substitutionarray[
'__(AnyTranslationKey|langfile)__'] = $outputlangs->trans(
'TranslationOfKey').
' (load also language file before)';
7793 $substitutionarray[
'__[AnyConstantKey]__'] = $outputlangs->trans(
'ValueOfConstantKey');
7796 return $substitutionarray;
7815 function make_substitutions($text, $substitutionarray, $outputlangs = null, $converttextinhtmlifnecessary = 0)
7817 global $conf, $langs;
7819 if (!is_array($substitutionarray)) {
7820 return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
7823 if (empty($outputlangs)) {
7824 $outputlangs = $langs;
7834 if (is_object($outputlangs)) {
7836 while (preg_match(
'/__\(([^\)]+)\)__/', $text, $reg)) {
7838 $tmp = explode(
'|', $reg[1]);
7839 if (!empty($tmp[1])) {
7840 $outputlangs->load($tmp[1]);
7843 $value = $outputlangs->transnoentitiesnoconv($reg[1]);
7845 if (empty($converttextinhtmlifnecessary)) {
7847 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
7851 var_dump(
"valueishtml=".$valueishtml);
7861 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $value, $text);
7869 while (preg_match(
'/__\[([^\]]+)\]__/', $text, $reg)) {
7870 $keyfound = $reg[1];
7872 $value =
'*****forbidden*****';
7874 $value = empty($conf->global->$keyfound) ?
'' : $conf->global->$keyfound;
7877 if (empty($converttextinhtmlifnecessary)) {
7879 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
7892 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $value, $text);
7897 foreach ($substitutionarray as $key => $value) {
7898 if (!isset($value)) {
7902 if ($key ==
'__USER_SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) {
7906 if (empty($converttextinhtmlifnecessary)) {
7907 $text = str_replace(
"$key",
"$value", $text);
7919 $text = str_replace(
"$key",
"$value", $text);
7940 global $conf, $user;
7942 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
7947 $dirsubstitutions = array_merge(array(), (array) $conf->modules_parts[
'substitutions']);
7949 foreach ($dirsubstitutions as $reldir) {
7957 $substitfiles =
dol_dir_list($dir,
'files', 0,
'functions_');
7958 foreach ($substitfiles as $substitfile) {
7960 if (preg_match(
'/functions_(.*)\.lib\.php/i', $substitfile[
'name'], $reg)) {
7963 dol_syslog(
"Library ".$substitfile[
'name'].
" found into ".$dir);
7965 require_once $dir.$substitfile[
'name'];
7967 $function_name = $module.
"_".$callfunc;
7968 if (function_exists($function_name)) {
7969 $function_name($substitutionarray, $outputlangs, $object, $parameters);
7974 if (!empty($conf->global->ODT_ENABLE_ALL_TAGS_IN_SUBSTITUTIONS)) {
7977 foreach ($substitutionarray as $key => $value) {
7978 $tags .=
'{'.$key.
'} => '.$value.
"\n";
7980 $substitutionarray = array_merge($substitutionarray, array(
'__ALL_TAGS__' => $tags));
7995 print
get_date_range($date_start, $date_end, $format, $outputlangs);
8008 function get_date_range($date_start, $date_end, $format =
'', $outputlangs =
'', $withparenthesis = 1)
8014 if (!is_object($outputlangs)) {
8015 $outputlangs = $langs;
8018 if ($date_start && $date_end) {
8019 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFromTo',
dol_print_date($date_start, $format,
false, $outputlangs),
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
8021 if ($date_start && !$date_end) {
8022 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($date_start, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
8024 if (!$date_start && $date_end) {
8025 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
8045 if ($nameorder < 0) {
8046 $nameorder = (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0);
8048 if ($nameorder == 1) {
8050 if ($firstname && $lastname) {
8054 } elseif ($nameorder == 2 || $nameorder == 3) {
8056 if (empty($ret) && $nameorder == 3) {
8061 if (empty($ret) && $nameorder == 5) {
8064 if ($nameorder == 0) {
8065 if ($firstname && $lastname) {
8088 if (!is_array($mesgs)) {
8091 $_SESSION[
'dol_events'][$style][] = $mesgs;
8095 foreach ($mesgs as $mesg) {
8097 $_SESSION[
'dol_events'][$style][] = $mesg;
8116 if (empty($mesg) && empty($mesgs)) {
8117 dol_syslog(
"Try to add a message in stack with empty message", LOG_WARNING);
8124 if (empty($messagekey) || empty($_COOKIE[
"DOLHIDEMESSAGE".$messagekey])) {
8125 if (!in_array((
string) $style, array(
'mesgs',
'warnings',
'errors'))) {
8126 dol_print_error(
'',
'Bad parameter style='.$style.
' for setEventMessages');
8128 if (empty($mesgs)) {
8131 if (!empty($mesg) && !in_array($mesg, $mesgs)) {
8152 if (isset($_SESSION[
'dol_events'][
'mesgs'])) {
8153 if (empty($disabledoutputofmessages)) {
8156 unset($_SESSION[
'dol_events'][
'mesgs']);
8159 if (isset($_SESSION[
'dol_events'][
'errors'])) {
8160 if (empty($disabledoutputofmessages)) {
8163 unset($_SESSION[
'dol_events'][
'errors']);
8167 if (isset($_SESSION[
'dol_events'][
'warnings'])) {
8168 if (empty($disabledoutputofmessages)) {
8171 unset($_SESSION[
'dol_events'][
'warnings']);
8191 global $conf, $langs;
8196 $divstart = $divend =
'';
8199 if ((empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && !preg_match(
'/<div class=".*">/i', $out)) {
8200 $divstart =
'<div class="'.$style.
' clearboth">';
8204 if ((is_array($mesgarray) && count($mesgarray)) || $mesgstring) {
8205 $langs->load(
"errors");
8207 if (is_array($mesgarray) && count($mesgarray)) {
8208 foreach ($mesgarray as $message) {
8210 $out .= $langs->trans($message);
8211 if ($ret < count($mesgarray)) {
8218 $out .= $langs->trans($mesgstring);
8224 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && empty($keepembedded)) {
8226 $(document).ready(function() {
8227 var block = '.(!empty($conf->global->MAIN_USE_JQUERY_BLOCKUI) ?
"true" :
"false").
'
8231 /* jnotify(message, preset of message type, keepmessage) */
8233 "'.($style ==
"ok" ? 3000 : $style).
'",
8234 '.($style ==
"ok" ?
"false" :
"true").
',
8235 { remove: function (){} } );
8278 if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) {
8284 if (is_array($mesgarray)) {
8285 foreach ($mesgarray as $val) {
8286 if ($val && preg_match(
'/class="error"/i', $val)) {
8290 if ($val && preg_match(
'/class="warning"/i', $val)) {
8295 } elseif ($mesgstring && preg_match(
'/class="error"/i', $mesgstring)) {
8297 } elseif ($mesgstring && preg_match(
'/class="warning"/i', $mesgstring)) {
8300 if ($style ==
'error') {
8303 if ($style ==
'warning') {
8307 if ($iserror || $iswarning) {
8309 $mesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $mesgstring);
8310 $mesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $mesgstring);
8311 $mesgstring = preg_replace(
'/<\/div>/',
'', $mesgstring);
8313 if (is_array($mesgarray)) {
8314 $newmesgarray = array();
8315 foreach ($mesgarray as $val) {
8316 if (is_string($val)) {
8317 $tmpmesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $val);
8318 $tmpmesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $tmpmesgstring);
8319 $tmpmesgstring = preg_replace(
'/<\/div>/',
'', $tmpmesgstring);
8320 $newmesgarray[] = $tmpmesgstring;
8322 dol_syslog(
"Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING);
8325 $mesgarray = $newmesgarray;
8327 print
get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ?
'error' :
'warning'), $keepembedded);
8362 function dol_sort_array(&$array, $index, $order =
'asc', $natsort = 0, $case_sensitive = 0, $keepindex = 0)
8365 $order = strtolower($order);
8367 if (is_array($array)) {
8368 $sizearray = count($array);
8369 if ($sizearray > 0) {
8371 foreach (array_keys($array) as $key) {
8372 if (is_object($array[$key])) {
8373 $temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index;
8375 $temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index];
8380 if ($order ==
'asc') {
8386 if ($case_sensitive) {
8391 if ($order !=
'asc') {
8392 $temp = array_reverse($temp,
true);
8398 foreach (array_keys($temp) as $key) {
8399 (is_numeric($key) && empty($keepindex)) ? $sorted[] = $array[$key] : $sorted[$key] = $array[$key];
8417 $str = (string) $str;
8421 for ($i = 0; $i < $strLength; $i++) {
8422 if (ord($str[$i]) < 0x80) {
8424 } elseif ((ord($str[$i]) & 0xE0) == 0xC0) {
8426 } elseif ((ord($str[$i]) & 0xF0) == 0xE0) {
8428 } elseif ((ord($str[$i]) & 0xF8) == 0xF0) {
8430 } elseif ((ord($str[$i]) & 0xFC) == 0xF8) {
8432 } elseif ((ord($str[$i]) & 0xFE) == 0xFC) {
8437 for ($j = 0; $j < $n; $j++) {
8438 if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) {
8454 if (function_exists(
'mb_check_encoding')) {
8456 if (!mb_check_encoding($str,
'ASCII')) {
8460 if (preg_match(
'/[^\x00-\x7f]/', $str)) {
8480 $tmp = ini_get(
"unicode.filesystem_encoding");
8481 if (empty($tmp) && !empty($_SERVER[
"WINDIR"])) {
8482 $tmp =
'iso-8859-1';
8487 if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING)) {
8488 $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING;
8491 if ($tmp ==
'iso-8859-1') {
8492 return utf8_decode($str);
8512 function dol_getIdFromCode($db, $key, $tablename, $fieldkey =
'code', $fieldid =
'id', $entityfilter = 0, $filters =
'')
8514 global $cache_codes;
8522 if (isset($cache_codes[$tablename][$key][$fieldid])) {
8523 return $cache_codes[$tablename][$key][$fieldid];
8526 dol_syslog(
'dol_getIdFromCode (value for field '.$fieldid.
' from key '.$key.
' not found into cache)', LOG_DEBUG);
8528 $sql =
"SELECT ".$fieldid.
" as valuetoget";
8529 $sql .=
" FROM ".MAIN_DB_PREFIX.$tablename;
8530 $sql .=
" WHERE ".$fieldkey.
" = '".$db->escape($key).
"'";
8531 if (!empty($entityfilter)) {
8532 $sql .=
" AND entity IN (".getEntity($tablename).
")";
8538 $resql = $db->query($sql);
8540 $obj = $db->fetch_object(
$resql);
8542 $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget;
8544 $cache_codes[$tablename][$key][$fieldid] =
'';
8547 return $cache_codes[$tablename][$key][$fieldid];
8561 global $user, $conf, $langs;
8567 if (isset($strToEvaluate) && $strToEvaluate !==
'') {
8571 $rep =
dol_eval($strToEvaluate, 1, 1,
'1');
8572 $rights = $rep && (!is_string($rep) || strpos($rep,
'Bad string syntax to evaluate') ===
false);
8588 function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring =
'1')
8591 global $db, $langs, $user, $conf, $website, $websitepage;
8592 global $action, $mainmenu, $leftmenu;
8601 if ($onlysimplestring ==
'1') {
8605 if (preg_match(
'/[^a-z0-9\s'.preg_quote(
'^$_+-.*>&|=!?():"\',/@',
'/').
']/i', $s)) {
8607 return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s;
8609 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s);
8615 } elseif ($onlysimplestring ==
'2') {
8617 if (preg_match(
'/[^a-z0-9\s'.preg_quote(
'^$_+-.*>&|=!?():"\',/@;[]',
'/').
']/i', $s)) {
8619 return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s;
8621 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s);
8626 if (strpos($s,
'::') !==
false) {
8628 return 'Bad string syntax to evaluate (double : char is forbidden): '.$s;
8630 dol_syslog(
'Bad string syntax to evaluate (double : char is forbidden): '.$s);
8634 if (strpos($s,
'`') !==
false) {
8636 return 'Bad string syntax to evaluate (backtick char is forbidden): '.$s;
8638 dol_syslog(
'Bad string syntax to evaluate (backtick char is forbidden): '.$s);
8642 if (preg_match(
'/[^0-9]+\.[^0-9]+/', $s)) {
8644 return 'Bad string syntax to evaluate (dot char is forbidden): '.$s;
8646 dol_syslog(
'Bad string syntax to evaluate (dot char is forbidden): '.$s);
8652 $forbiddenphpstrings = array(
'$$');
8653 $forbiddenphpstrings = array_merge($forbiddenphpstrings, array(
'_ENV',
'_SESSION',
'_COOKIE',
'_GET',
'_POST',
'_REQUEST'));
8655 $forbiddenphpfunctions = array(
"exec",
"passthru",
"shell_exec",
"system",
"proc_open",
"popen",
"eval",
"dol_eval",
"executeCLI",
'verifCond');
8656 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"fopen",
"file_put_contents",
"fputs",
"fputscsv",
"fwrite",
"fpassthru",
"require",
"include",
"mkdir",
"rmdir",
"symlink",
"touch",
"unlink",
"umask"));
8657 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"function",
"call_user_func"));
8659 $forbiddenphpregex =
'global\s+\$|\b('.implode(
'|', $forbiddenphpfunctions).
')\b';
8662 $oldstringtoclean = $s;
8663 $s = str_ireplace($forbiddenphpstrings,
'__forbiddenstring__', $s);
8664 $s = preg_replace(
'/'.$forbiddenphpregex.
'/i',
'__forbiddenstring__', $s);
8666 }
while ($oldstringtoclean != $s);
8668 if (strpos($s,
'__forbiddenstring__') !==
false) {
8669 dol_syslog(
'Bad string syntax to evaluate: '.$s, LOG_WARNING);
8671 return 'Bad string syntax to evaluate: '.$s;
8673 dol_syslog(
'Bad string syntax to evaluate: '.$s);
8681 return @eval(
'return '.$s.
';');
8683 return eval(
'return '.$s.
';');
8702 return (trim($element) !=
'');
8715 if (empty($codelang)) {
8719 if ($codelang ==
'auto') {
8720 return '<span class="fa fa-language"></span>';
8723 $langtocountryflag = array(
8725 'ca_ES' =>
'catalonia',
8729 'sw_SW' =>
'unknown',
8739 if (isset($langtocountryflag[$codelang])) {
8740 $flagImage = $langtocountryflag[$codelang];
8742 $tmparray = explode(
'_', $codelang);
8743 $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
8746 return img_picto_common($codelang,
'flags/'.strtolower($flagImage).
'.png', $moreatt, 0, $notitlealt);
8760 if (empty($countrycode)) {
8764 if (strtoupper($countrycode) ==
'MQ') {
8767 if (strtoupper($countrycode) ==
'SE') {
8770 if (strtoupper($countrycode) ==
'CH') {
8771 if ($mysoc->country_code ==
'FR') {
8774 if ($mysoc->country_code ==
'DE') {
8777 if ($mysoc->country_code ==
'IT') {
8959 $buildprimarykeytotest = strtolower($countrycode).
'-'.strtoupper($countrycode);
8960 if (in_array($buildprimarykeytotest, $locales)) {
8961 return strtolower($countrycode).
'_'.strtoupper($countrycode);
8964 if (function_exists(
'locale_get_primary_language') && function_exists(
'locale_get_region')) {
8965 foreach ($locales as $locale) {
8966 $locale_language = locale_get_primary_language($locale);
8967 $locale_region = locale_get_region($locale);
8968 if (strtoupper($countrycode) == $locale_region) {
8970 return strtolower($locale_language).
'_'.strtoupper($locale_region);
8974 dol_syslog(
"Warning Exention php-intl is not available", LOG_WARNING);
9011 global $hookmanager, $db;
9013 if (isset($conf->modules_parts[
'tabs'][$type]) && is_array($conf->modules_parts[
'tabs'][$type])) {
9014 foreach ($conf->modules_parts[
'tabs'][$type] as $value) {
9015 $values = explode(
':', $value);
9018 if ($mode ==
'add' && !preg_match(
'/^\-/', $values[1])) {
9019 if (count($values) == 6) {
9023 if ($values[0] != $type) {
9030 $langs->load($values[3]);
9032 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
9033 $substitutionarray = array();
9037 $labeltemp = explode(
',', $values[2]);
9038 $label = $langs->trans($labeltemp[0]);
9039 if (!empty($labeltemp[1]) && is_object($object) && !empty($object->id)) {
9041 $classtoload = $labeltemp[1];
9042 if (class_exists($classtoload)) {
9043 $obj =
new $classtoload($db);
9044 $function = $labeltemp[3];
9045 if ($obj && $function && method_exists($obj, $function)) {
9046 $nbrec = $obj->$function($object->id, $obj);
9047 $label .=
'<span class="badge marginleftonlyshort">'.$nbrec.
'</span>';
9053 $head[$h][0] =
dol_buildpath(preg_replace(
'/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id :
''), $values[5]), 1);
9054 $head[$h][1] = $label;
9055 $head[$h][2] = str_replace(
'+',
'', $values[1]);
9058 } elseif (count($values) == 5) {
9059 dol_syslog(
'Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
9061 if ($values[0] != $type) {
9065 $langs->load($values[3]);
9067 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
9068 $substitutionarray = array();
9072 $label = $langs->trans($values[2]);
9075 $head[$h][0] =
dol_buildpath(preg_replace(
'/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id :
''), $values[4]), 1);
9076 $head[$h][1] = $label;
9077 $head[$h][2] = str_replace(
'+',
'', $values[1]);
9080 } elseif ($mode ==
'remove' && preg_match(
'/^\-/', $values[1])) {
9081 if ($values[0] != $type) {
9084 $tabname = str_replace(
'-',
'', $values[1]);
9085 foreach ($head as $key => $val) {
9086 $condition = (!empty($values[3]) ?
verifCond($values[3]) : 1);
9088 if ($head[$key][2] == $tabname && $condition) {
9098 if (!empty($hookmanager)) {
9099 $parameters = array(
'object' => $object,
'mode' => $mode,
'head' => &$head);
9100 $reshook = $hookmanager->executeHooks(
'completeTabsHead', $parameters);
9102 $head = $hookmanager->resArray;
9104 $head = array_merge($head, $hookmanager->resArray);
9123 global $conf, $hookmanager, $user, $debugbar;
9125 global $micro_start_time;
9127 if ($zone ==
'private') {
9128 print
"\n".
'<!-- Common footer for private page -->'.
"\n";
9130 print
"\n".
'<!-- Common footer for public page -->'.
"\n";
9134 print
"\n<!-- A div to store page_y POST parameter -->\n";
9135 print
'<div id="page_y" style="display: none;">'.(GETPOST(
'page_y') ?
GETPOST(
'page_y') :
'').
'</div>'.
"\n";
9137 $parameters = array();
9138 $reshook = $hookmanager->executeHooks(
'printCommonFooter', $parameters);
9139 if (empty($reshook)) {
9140 if (!empty($conf->global->MAIN_HTML_FOOTER)) {
9141 print $conf->global->MAIN_HTML_FOOTER.
"\n";
9145 if (!empty($conf->use_javascript_ajax)) {
9146 print
'<script>'.
"\n";
9147 print
'jQuery(document).ready(function() {'.
"\n";
9149 if ($zone ==
'private' && empty($conf->dol_use_jmobile)) {
9151 print
'/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'.
"\n";
9152 print
'jQuery("li.menuhider").click(function(event) {';
9153 print
' if (!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'.
"\n";
9154 print
' console.log("We click on .menuhider");'.
"\n";
9155 print
' $("body").toggleClass("sidebar-collapse")'.
"\n";
9160 if ($action ==
'create' || $action ==
'edit' || (empty($action) && (preg_match(
'/new\.php/', $_SERVER[
"PHP_SELF"])))) {
9161 print
'/* JS CODE TO ENABLE to manage focus and mandatory form fields */'.
"\n";
9162 $relativepathstring = $_SERVER[
"PHP_SELF"];
9164 if (constant(
'DOL_URL_ROOT')) {
9165 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
9167 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
9168 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
9170 if (!empty($user->default_values[$relativepathstring][
'focus'])) {
9171 foreach ($user->default_values[$relativepathstring][
'focus'] as $defkey => $defval) {
9173 if ($defkey !=
'_noquery_') {
9174 $tmpqueryarraytohave = explode(
'&', $defkey);
9176 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
9177 $tmpquerytohaveparam = explode(
'=', $tmpquerytohave);
9179 if (!
GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] !=
GETPOST($tmpquerytohaveparam[0]))) {
9192 foreach ($defval as $paramkey => $paramval) {
9194 print
'jQuery("input[name=\''.$paramkey.
'\']
").focus();'."\n
";
9195 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").focus();'."\n
";
9196 print 'jQuery("select[name=\
''.$paramkey.
'\']
").focus();'."\n
"; // Not really usefull, but we keep it in case of.
9201 if (!empty($user->default_values[$relativepathstring]['mandatory'])) {
9202 foreach ($user->default_values[$relativepathstring]['mandatory'] as $defkey => $defval) {
9204 if ($defkey != '_noquery_') {
9205 $tmpqueryarraytohave = explode('&', $defkey);
9207 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
9208 $tmpquerytohaveparam = explode('=', $tmpquerytohave);
9209 //print "console.log(
'".$tmpquerytohaveparam[0]." ".$tmpquerytohaveparam[1]." ".GETPOST($tmpquerytohaveparam[0])."');
";
9210 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] != GETPOST($tmpquerytohaveparam[0]))) {
9217 //var_dump($defkey.'-'.$qualified);
9223 foreach ($defval as $paramkey => $paramval) {
9224 // Add property 'required' on input
9225 print 'jQuery("input[name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
9226 print 'jQuery("textarea[name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
9227 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
";
9228 print 'jQuery("select[name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
9229 print 'jQuery("select[name=\
''.$paramkey.
'\'] option[value=\
'-1\']").prop(\'value\', \'\');'.
"\n";
9230 print
'jQuery("select[name=\''.$paramkey.
'\'] option[value=\
'0\']").prop(\'value\', \'\');'.
"\n";
9233 print
'jQuery(":input[name=\'' . $paramkey .
'\']
").closest("tr
").find("td:first
").addClass("fieldrequired
");' . "\n
";
9243 if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO']) || !empty($conf->global->MAIN_SHOW_TUNING_INFO)) {
9246 print 'window.console && console.log("';
9247 if (!empty($conf->global->MEMCACHED_SERVER)) {
9248 print 'MEMCACHED_SERVER=
'.$conf->global->MEMCACHED_SERVER.' -
';
9250 print 'MAIN_OPTIMIZE_SPEED=
'.(isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off
');
9251 if (!empty($micro_start_time)) { // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable.
9252 $micro_end_time = microtime(true);
9253 print ' - Build time:
'.ceil(1000 * ($micro_end_time - $micro_start_time)).' ms
';
9256 if (function_exists("memory_get_usage")) {
9257 print ' - Mem:
'.memory_get_usage(); // Do not use true here, it seems it takes the peak amount
9259 if (function_exists("memory_get_peak_usage")) {
9260 print ' - Real mem peak:
'.memory_get_peak_usage(true);
9262 if (function_exists("zend_loader_file_encoded")) {
9263 print ' - Zend encoded file:
'.(zend_loader_file_encoded() ? 'yes
' : 'no
');
9268 print "\n
".'</script>'."\n
";
9271 // TODO Add a hook here
9272 if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) {
9273 $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID);
9274 foreach ($tmptagarray as $tmptag) {
9276 print "<!-- JS CODE TO ENABLE
for google analtics tag -->\n
";
9278 <!-- Global site tag (gtag.js) - Google Analytics -->
9279 <script async src=\
"https://www.googletagmanager.com/gtag/js?id=".trim($tmptag).
"\"></script>
9281 window.dataLayer = window.dataLayer || [];
9282 function gtag(){dataLayer.push(arguments);}
9283 gtag('js', new Date());
9285 gtag('config', '".trim($tmptag).
"');
9293 if (defined(
'XDEBUGCOVERAGE')) {
9294 print_r(xdebug_get_code_coverage());
9298 if (!empty($user->rights->debugbar->read) && is_object($debugbar)) {
9299 $debugbar[
'time']->stopMeasure(
'pageaftermaster');
9300 print
'<!-- Output debugbar data -->'.
"\n";
9301 $renderer = $debugbar->getRenderer();
9302 print $debugbar->getRenderer()->render();
9303 } elseif (count($conf->logbuffer)) {
9305 print
"<!-- Start of log output\n";
9307 foreach ($conf->logbuffer as $logline) {
9308 print $logline.
"<br>\n";
9311 print
"End of log output -->\n";
9327 if ($a = explode($delimiter, $string)) {
9329 foreach ($a as $s) {
9331 if ($pos = strpos($s, $kv)) {
9332 $ka[trim(substr($s, 0, $pos))] = trim(substr($s, $pos + strlen($kv)));
9352 print
"\n".
'<!-- Set focus onto a specific field -->'.
"\n";
9353 print
'<script>jQuery(document).ready(function() { jQuery("'.dol_escape_js($selector).
'").focus(); });</script>'.
"\n";
9366 if (!function_exists(
'getmypid')) {
9367 return mt_rand(1, 32768);
9395 $value = trim($value);
9398 $value = preg_replace(
'/\*/',
'%', $value);
9401 $value = preg_replace(
'/([<>=]+)\s+([0-9'.preg_quote($langs->trans(
"DecimalSeparator"),
'/').
'\-])/',
'\1\2', $value);
9404 $value = preg_replace(
'/\s*\|\s*/',
'|', $value);
9406 $crits = explode(
' ', $value);
9408 if (!is_array($fields)) {
9409 $fields = array($fields);
9413 foreach ($crits as $crit) {
9414 $crit = trim($crit);
9418 foreach ($fields as $field) {
9421 $newcrit = preg_replace(
'/([<>=]+)/',
'', $crit);
9424 preg_match(
'/([<>=]+)/', $crit, $reg);
9425 if (!empty($reg[1])) {
9426 $operator = $reg[1];
9428 if ($newcrit !=
'') {
9430 if (is_numeric($numnewcrit)) {
9431 $newres .= ($i2 > 0 ?
' OR ' :
'').$field.
' '.$operator.
' '.((
float) $numnewcrit);
9433 $newres .= ($i2 > 0 ?
' OR ' :
'').
'1 = 2';
9437 } elseif ($mode == 2 || $mode == -2) {
9438 $crit = preg_replace(
'/[^0-9,]/',
'', $crit);
9439 $newres .= ($i2 > 0 ?
' OR ' :
'').$field.
" ".($mode == -2 ?
'NOT ' :
'');
9440 $newres .= $crit ?
"IN (".$db->sanitize($db->escape($crit)).
")" :
"IN (0)";
9442 $newres .=
' OR '.$field.
' IS NULL';
9445 } elseif ($mode == 3 || $mode == -3) {
9446 $tmparray = explode(
',', $crit);
9447 if (count($tmparray)) {
9449 foreach ($tmparray as $val) {
9452 $listofcodes .= ($listofcodes ?
',' :
'');
9453 $listofcodes .=
"'".$db->escape($val).
"'";
9456 $newres .= ($i2 > 0 ?
' OR ' :
'').$field.
" ".($mode == -3 ?
'NOT ' :
'').
"IN (".$db->sanitize($listofcodes, 1).
")";
9460 $newres .=
' OR '.$field.
' IS NULL';
9462 } elseif ($mode == 4) {
9463 $tmparray = explode(
',', $crit);
9464 if (count($tmparray)) {
9466 foreach ($tmparray as $val) {
9469 $newres .= ($i2 > 0 ?
" OR (" :
"(").$field.
" LIKE '".$db->escape($val).
",%'";
9470 $newres .=
' OR '.$field.
" = '".$db->escape($val).
"'";
9471 $newres .=
' OR '.$field.
" LIKE '%,".$db->escape($val).
"'";
9472 $newres .=
' OR '.$field.
" LIKE '%,".$db->escape($val).
",%'";
9480 $tmpcrits = explode(
'|', $crit);
9482 foreach ($tmpcrits as $tmpcrit) {
9483 if ($tmpcrit !==
'0' && empty($tmpcrit)) {
9487 $newres .= (($i2 > 0 || $i3 > 0) ?
' OR ' :
'');
9489 if (preg_match(
'/\.(id|rowid)$/', $field)) {
9490 $newres .= $field.
" = ".(is_numeric(trim($tmpcrit)) ? ((
float) trim($tmpcrit)) :
'0');
9492 $tmpcrit = trim($tmpcrit);
9493 $tmpcrit2 = $tmpcrit;
9496 if (preg_match(
'/^!/', $tmpcrit)) {
9497 $newres .= $field.
" NOT LIKE '";
9498 $tmpcrit2 = preg_replace(
'/^!/',
'', $tmpcrit2);
9499 }
else $newres .= $field.
" LIKE '";
9501 if (preg_match(
'/^[\^\$]/', $tmpcrit)) {
9503 $tmpcrit2 = preg_replace(
'/^[\^\$]/',
'', $tmpcrit2);
9505 if (preg_match(
'/[\^\$]$/', $tmpcrit)) {
9507 $tmpcrit2 = preg_replace(
'/[\^\$]$/',
'', $tmpcrit2);
9509 $newres .= $tmpbefore;
9510 $newres .= $db->escape($tmpcrit2);
9511 $newres .= $tmpafter;
9513 if ($tmpcrit2 ==
'') {
9514 $newres .=
" OR ".$field.
" IS NULL";
9525 $res = $res.($res ?
' AND ' :
'').($i2 > 1 ?
'(' :
'').$newres.($i2 > 1 ?
')' :
'');
9529 $res = ($nofirstand ?
"" :
" AND ").
"(".$res.
")";
9542 global $conf, $langs;
9545 $url = $object->getLastMainDocLink($object->element);
9547 $out .=
img_picto($langs->trans(
"PublicDownloadLinkDesc"),
'globe').
' <span class="opacitymedium">'.$langs->trans(
"DirectDownloadLink").
'</span><br>';
9549 $out .=
'<div class="urllink"><input type="text" id="directdownloadlink" class="quatrevingtpercent" value="'.$url.
'"></div>';
9552 $out .=
'<div class="urllink">'.$langs->trans(
"FileNotShared").
'</div>';
9568 $dirName = dirname($file);
9569 if ($dirName ==
'.') {
9573 $fileName = preg_replace(
'/(\.gif|\.jpeg|\.jpg|\.png|\.bmp|\.webp)$/i',
'', $file);
9574 $fileName = basename($fileName);
9576 if (empty($extImgTarget)) {
9577 $extImgTarget = (preg_match(
'/\.jpg$/i', $file) ?
'.jpg' :
'');
9579 if (empty($extImgTarget)) {
9580 $extImgTarget = (preg_match(
'/\.jpeg$/i', $file) ?
'.jpeg' :
'');
9582 if (empty($extImgTarget)) {
9583 $extImgTarget = (preg_match(
'/\.gif$/i', $file) ?
'.gif' :
'');
9585 if (empty($extImgTarget)) {
9586 $extImgTarget = (preg_match(
'/\.png$/i', $file) ?
'.png' :
'');
9588 if (empty($extImgTarget)) {
9589 $extImgTarget = (preg_match(
'/\.bmp$/i', $file) ?
'.bmp' :
'');
9591 if (empty($extImgTarget)) {
9592 $extImgTarget = (preg_match(
'/\.webp$/i', $file) ?
'.webp' :
'');
9595 if (!$extImgTarget) {
9601 $subdir =
'thumbs/';
9604 return ($dirName ? $dirName.
'/' :
'').$subdir.$fileName.$extName.$extImgTarget;
9619 global $conf, $langs;
9621 if (empty($conf->use_javascript_ajax)) {
9627 if ($alldata == 1) {
9628 if ($isAllowedForPreview) {
9629 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));
9636 if ($isAllowedForPreview) {
9637 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')).
'\')
';
9652 function ajax_autoselect($htmlname, $addlink = '', $textonlink = 'Link')
9656 jQuery(document).ready(
function () {
9657 jQuery(
"'.((strpos($htmlname, '.') === 0 ? '' : '#').$htmlname).'").click(
function() { jQuery(
this).select(); } );
9661 if ($textonlink === 'image
') {
9662 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.img_picto('', 'globe
').'</a>
';
9664 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.$langs->trans("Link").'</a>
';
9677 function dolIsAllowedForPreview($file)
9681 // Check .noexe extension in filename
9682 if (preg_match('/\.noexe$/i
', $file)) {
9687 $mime_preview = array('bmp
', 'jpeg
', 'png
', 'gif
', 'tiff
', 'pdf
', 'plain
', 'css
', 'webp
');
9688 if (!empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) {
9689 $mime_preview[] = 'svg+xml
';
9691 //$mime_preview[]='vnd.oasis.opendocument.presentation
';
9692 //$mime_preview[]='archive
';
9693 $num_mime = array_search(dol_mimetype($file, '', 1), $mime_preview);
9694 if ($num_mime !== false) {
9698 // By default, not allowed for preview
9712 function dol_mimetype($file, $default = 'application/octet-stream
', $mode = 0)
9715 $imgmime = 'other.png
';
9719 $tmpfile = preg_replace('/\.noexe$/
', '', $file);
9722 if (preg_match('/\.txt$/i
', $tmpfile)) {
9723 $mime = 'text/plain
';
9724 $imgmime = 'text.png
';
9725 $famime = 'file-text-o
';
9727 if (preg_match('/\.rtx$/i
', $tmpfile)) {
9728 $mime = 'text/richtext
';
9729 $imgmime = 'text.png
';
9730 $famime = 'file-text-o
';
9732 if (preg_match('/\.csv$/i
', $tmpfile)) {
9734 $imgmime = 'text.png
';
9735 $famime = 'file-text-o
';
9737 if (preg_match('/\.tsv$/i
', $tmpfile)) {
9738 $mime = 'text/tab-separated-values
';
9739 $imgmime = 'text.png
';
9740 $famime = 'file-text-o
';
9742 if (preg_match('/\.(cf|
conf|log)$/i
', $tmpfile)) {
9743 $mime = 'text/plain
';
9744 $imgmime = 'text.png
';
9745 $famime = 'file-text-o
';
9747 if (preg_match('/\.ini$/i
', $tmpfile)) {
9748 $mime = 'text/plain
';
9749 $imgmime = 'text.png
';
9751 $famime = 'file-text-o
';
9753 if (preg_match('/\.md$/i
', $tmpfile)) {
9754 $mime = 'text/plain
';
9755 $imgmime = 'text.png
';
9757 $famime = 'file-text-o
';
9759 if (preg_match('/\.css$/i
', $tmpfile)) {
9761 $imgmime = 'css.png
';
9763 $famime = 'file-text-o
';
9765 if (preg_match('/\.lang$/i
', $tmpfile)) {
9766 $mime = 'text/plain
';
9767 $imgmime = 'text.png
';
9769 $famime = 'file-text-o
';
9771 // Certificate files
9772 if (preg_match('/\.(crt|cer|key|pub)$/i
', $tmpfile)) {
9773 $mime = 'text/plain
';
9774 $imgmime = 'text.png
';
9775 $famime = 'file-text-o
';
9777 // XML based (HTML/XML/XAML)
9778 if (preg_match('/\.(html|htm|shtml)$/i
', $tmpfile)) {
9779 $mime = 'text/html
';
9780 $imgmime = 'html.png
';
9782 $famime = 'file-text-o
';
9784 if (preg_match('/\.(xml|xhtml)$/i
', $tmpfile)) {
9786 $imgmime = 'other.png
';
9788 $famime = 'file-text-o
';
9790 if (preg_match('/\.xaml$/i
', $tmpfile)) {
9792 $imgmime = 'other.png
';
9794 $famime = 'file-text-o
';
9797 if (preg_match('/\.bas$/i
', $tmpfile)) {
9798 $mime = 'text/plain
';
9799 $imgmime = 'text.png
';
9801 $famime = 'file-
code-o
';
9803 if (preg_match('/\.(c)$/i
', $tmpfile)) {
9804 $mime = 'text/plain
';
9805 $imgmime = 'text.png
';
9807 $famime = 'file-
code-o
';
9809 if (preg_match('/\.(cpp)$/i
', $tmpfile)) {
9810 $mime = 'text/plain
';
9811 $imgmime = 'text.png
';
9813 $famime = 'file-
code-o
';
9815 if (preg_match('/\.cs$/i
', $tmpfile)) {
9816 $mime = 'text/plain
';
9817 $imgmime = 'text.png
';
9819 $famime = 'file-
code-o
';
9821 if (preg_match('/\.(h)$/i
', $tmpfile)) {
9822 $mime = 'text/plain
';
9823 $imgmime = 'text.png
';
9825 $famime = 'file-
code-o
';
9827 if (preg_match('/\.(java|jsp)$/i
', $tmpfile)) {
9828 $mime = 'text/plain
';
9829 $imgmime = 'text.png
';
9831 $famime = 'file-
code-o
';
9833 if (preg_match('/\.php([0-9]{1})?$/i
', $tmpfile)) {
9834 $mime = 'text/plain
';
9835 $imgmime = 'php.png
';
9837 $famime = 'file-
code-o
';
9839 if (preg_match('/\.phtml$/i
', $tmpfile)) {
9840 $mime = 'text/plain
';
9841 $imgmime = 'php.png
';
9843 $famime = 'file-
code-o
';
9845 if (preg_match('/\.(pl|pm)$/i
', $tmpfile)) {
9846 $mime = 'text/plain
';
9847 $imgmime = 'pl.png
';
9849 $famime = 'file-
code-o
';
9851 if (preg_match('/\.sql$/i
', $tmpfile)) {
9852 $mime = 'text/plain
';
9853 $imgmime = 'text.png
';
9855 $famime = 'file-
code-o
';
9857 if (preg_match('/\.js$/i
', $tmpfile)) {
9858 $mime = 'text/x-javascript
';
9859 $imgmime = 'jscript.png
';
9861 $famime = 'file-
code-o
';
9864 if (preg_match('/\.odp$/i
', $tmpfile)) {
9865 $mime = 'application/vnd.oasis.opendocument.presentation
';
9866 $imgmime = 'ooffice.png
';
9867 $famime = 'file-powerpoint-o
';
9869 if (preg_match('/\.ods$/i
', $tmpfile)) {
9870 $mime = 'application/vnd.oasis.opendocument.spreadsheet
';
9871 $imgmime = 'ooffice.png
';
9872 $famime = 'file-excel-o
';
9874 if (preg_match('/\.odt$/i
', $tmpfile)) {
9875 $mime = 'application/vnd.oasis.opendocument.text
';
9876 $imgmime = 'ooffice.png
';
9877 $famime = 'file-word-o
';
9880 if (preg_match('/\.mdb$/i
', $tmpfile)) {
9881 $mime = 'application/msaccess
';
9882 $imgmime = 'mdb.png
';
9885 if (preg_match('/\.doc(x|m)?$/i
', $tmpfile)) {
9886 $mime = 'application/msword
';
9887 $imgmime = 'doc.png
';
9888 $famime = 'file-word-o
';
9890 if (preg_match('/\.dot(x|m)?$/i
', $tmpfile)) {
9891 $mime = 'application/msword
';
9892 $imgmime = 'doc.png
';
9893 $famime = 'file-word-o
';
9895 if (preg_match('/\.xlt(x)?$/i
', $tmpfile)) {
9896 $mime = 'application/vnd.ms-excel
';
9897 $imgmime = 'xls.png
';
9898 $famime = 'file-excel-o
';
9900 if (preg_match('/\.xla(m)?$/i
', $tmpfile)) {
9901 $mime = 'application/vnd.ms-excel
';
9902 $imgmime = 'xls.png
';
9903 $famime = 'file-excel-o
';
9905 if (preg_match('/\.xls$/i
', $tmpfile)) {
9906 $mime = 'application/vnd.ms-excel
';
9907 $imgmime = 'xls.png
';
9908 $famime = 'file-excel-o
';
9910 if (preg_match('/\.xls(b|m|x)$/i
', $tmpfile)) {
9911 $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
';
9912 $imgmime = 'xls.png
';
9913 $famime = 'file-excel-o
';
9915 if (preg_match('/\.pps(m|x)?$/i
', $tmpfile)) {
9916 $mime = 'application/vnd.ms-powerpoint
';
9917 $imgmime = 'ppt.png
';
9918 $famime = 'file-powerpoint-o
';
9920 if (preg_match('/\.ppt(m|x)?$/i
', $tmpfile)) {
9921 $mime = 'application/x-mspowerpoint
';
9922 $imgmime = 'ppt.png
';
9923 $famime = 'file-powerpoint-o
';
9926 if (preg_match('/\.pdf$/i
', $tmpfile)) {
9927 $mime = 'application/pdf
';
9928 $imgmime = 'pdf.png
';
9929 $famime = 'file-pdf-o
';
9932 if (preg_match('/\.bat$/i
', $tmpfile)) {
9933 $mime = 'text/x-bat
';
9934 $imgmime = 'script.png
';
9936 $famime = 'file-
code-o
';
9938 if (preg_match('/\.sh$/i
', $tmpfile)) {
9939 $mime = 'text/x-sh
';
9940 $imgmime = 'script.png
';
9942 $famime = 'file-
code-o
';
9944 if (preg_match('/\.ksh$/i
', $tmpfile)) {
9945 $mime = 'text/x-ksh
';
9946 $imgmime = 'script.png
';
9948 $famime = 'file-
code-o
';
9950 if (preg_match('/\.bash$/i
', $tmpfile)) {
9951 $mime = 'text/x-bash
';
9952 $imgmime = 'script.png
';
9954 $famime = 'file-
code-o
';
9957 if (preg_match('/\.ico$/i
', $tmpfile)) {
9958 $mime = 'image/x-icon
';
9959 $imgmime = 'image.png
';
9960 $famime = 'file-image-o
';
9962 if (preg_match('/\.(jpg|jpeg)$/i
', $tmpfile)) {
9963 $mime = 'image/jpeg
';
9964 $imgmime = 'image.png
';
9965 $famime = 'file-image-o
';
9967 if (preg_match('/\.png$/i
', $tmpfile)) {
9968 $mime = 'image/png
';
9969 $imgmime = 'image.png
';
9970 $famime = 'file-image-o
';
9972 if (preg_match('/\.gif$/i
', $tmpfile)) {
9973 $mime = 'image/gif
';
9974 $imgmime = 'image.png
';
9975 $famime = 'file-image-o
';
9977 if (preg_match('/\.bmp$/i
', $tmpfile)) {
9978 $mime = 'image/bmp
';
9979 $imgmime = 'image.png
';
9980 $famime = 'file-image-o
';
9982 if (preg_match('/\.(tif|tiff)$/i
', $tmpfile)) {
9983 $mime = 'image/tiff
';
9984 $imgmime = 'image.png
';
9985 $famime = 'file-image-o
';
9987 if (preg_match('/\.svg$/i
', $tmpfile)) {
9988 $mime = 'image/svg+xml
';
9989 $imgmime = 'image.png
';
9990 $famime = 'file-image-o
';
9992 if (preg_match('/\.webp$/i
', $tmpfile)) {
9993 $mime = 'image/webp
';
9994 $imgmime = 'image.png
';
9995 $famime = 'file-image-o
';
9998 if (preg_match('/\.vcs$/i
', $tmpfile)) {
9999 $mime = 'text/calendar
';
10000 $imgmime = 'other.png
';
10001 $famime = 'file-text-o
';
10003 if (preg_match('/\.ics$/i
', $tmpfile)) {
10004 $mime = 'text/calendar
';
10005 $imgmime = 'other.png
';
10006 $famime = 'file-text-o
';
10009 if (preg_match('/\.torrent$/i
', $tmpfile)) {
10010 $mime = 'application/x-bittorrent
';
10011 $imgmime = 'other.png
';
10012 $famime = 'file-o
';
10015 if (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i
', $tmpfile)) {
10017 $imgmime = 'audio.png
';
10018 $famime = 'file-audio-o
';
10021 if (preg_match('/\.mp4$/i
', $tmpfile)) {
10022 $mime = 'video/mp4
';
10023 $imgmime = 'video.png
';
10024 $famime = 'file-video-o
';
10026 if (preg_match('/\.ogv$/i
', $tmpfile)) {
10027 $mime = 'video/ogg
';
10028 $imgmime = 'video.png
';
10029 $famime = 'file-video-o
';
10031 if (preg_match('/\.webm$/i
', $tmpfile)) {
10032 $mime = 'video/webm
';
10033 $imgmime = 'video.png
';
10034 $famime = 'file-video-o
';
10036 if (preg_match('/\.avi$/i
', $tmpfile)) {
10037 $mime = 'video/x-msvideo
';
10038 $imgmime = 'video.png
';
10039 $famime = 'file-video-o
';
10041 if (preg_match('/\.divx$/i
', $tmpfile)) {
10042 $mime = 'video/divx
';
10043 $imgmime = 'video.png
';
10044 $famime = 'file-video-o
';
10046 if (preg_match('/\.xvid$/i
', $tmpfile)) {
10047 $mime = 'video/xvid
';
10048 $imgmime = 'video.png
';
10049 $famime = 'file-video-o
';
10051 if (preg_match('/\.(wmv|mpg|mpeg)$/i
', $tmpfile)) {
10053 $imgmime = 'video.png
';
10054 $famime = 'file-video-o
';
10057 if (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh|zst)$/i
', $tmpfile)) {
10059 $imgmime = 'archive.png
';
10060 $famime = 'file-archive-o
';
10061 } // application/xxx where zzz is zip, ...
10063 if (preg_match('/\.(exe|com)$/i
', $tmpfile)) {
10064 $mime = 'application/octet-stream
';
10065 $imgmime = 'other.png
';
10066 $famime = 'file-o
';
10069 if (preg_match('/\.(dll|lib|o|so|a)$/i
', $tmpfile)) {
10071 $imgmime = 'library.png
';
10072 $famime = 'file-o
';
10075 if (preg_match('/\.err$/i
', $tmpfile)) {
10077 $imgmime = 'error.png
';
10078 $famime = 'file-text-o
';
10083 $tmp = explode('/
', $mime);
10084 return (!empty($tmp[1]) ? $tmp[1] : $tmp[0]);
10109 function getDictionaryValue($tablename, $field, $id, $checkentity = false, $rowidfield = 'rowid')
10113 $tablename = preg_replace('/^
'.preg_quote(MAIN_DB_PREFIX, '/
').'/
', '', $tablename); // Clean name of table for backward compatibility.
10115 $dictvalues = (isset($conf->cache['dictvalues_
'.$tablename]) ? $conf->cache['dictvalues_
'.$tablename] : null);
10117 if (is_null($dictvalues)) {
10118 $dictvalues = array();
10120 $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
10121 if ($checkentity) {
10122 $sql .=
' AND entity IN (0,'.getEntity($tablename).
')';
10125 $resql = $db->query($sql);
10127 while ($obj = $db->fetch_object(
$resql)) {
10128 $dictvalues[$obj->{$rowidfield}] = $obj;
10134 $conf->cache[
'dictvalues_'.$tablename] = $dictvalues;
10137 if (!empty($dictvalues[$id])) {
10139 $tmp = $dictvalues[$id];
10140 return (property_exists($tmp, $field) ? $tmp->$field :
'');
10155 $stringcolor = str_replace(
'#',
'', $stringcolor);
10157 if (!empty($stringcolor)) {
10159 $tmp = explode(
',', $stringcolor);
10160 if (count($tmp) > 1) {
10165 $hexr = $stringcolor[0].$stringcolor[1];
10166 $hexg = $stringcolor[2].$stringcolor[3];
10167 $hexb = $stringcolor[4].$stringcolor[5];
10168 $r = hexdec($hexr);
10169 $g = hexdec($hexg);
10170 $b = hexdec($hexb);
10172 $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0;
10173 if ($bright > 0.6) {
10194 if (empty($menuentry[
'enabled'])) {
10197 if ($type_user && $menuentry[
'module']) {
10198 $tmploops = explode(
'|', $menuentry[
'module']);
10200 foreach ($tmploops as $tmploop) {
10201 if (in_array($tmploop, $listofmodulesforexternal)) {
10210 if (!$menuentry[
'perms'] && $type_user) {
10213 if (!$menuentry[
'perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) {
10216 if (!$menuentry[
'perms']) {
10231 return (ceil($n) % $x === 0) ? ceil($n) : round(($n + $x / 2) / $x) * $x;
10245 function dolGetBadge($label, $html =
'', $type =
'primary', $mode =
'', $url =
'', $params = array())
10248 'class'=>
'badge '.(!empty($mode) ?
' badge-'.$mode :
'').(!empty($type) ?
' badge-'.$type :
'').(empty($params[
'css']) ?
'' :
' '.$params[
'css'])
10251 if (empty($html)) {
10255 if (!empty($url)) {
10256 $attr[
'href'] = $url;
10259 if ($mode ===
'dot') {
10260 $attr[
'class'] .=
' classfortooltip';
10261 $attr[
'title'] = $html;
10262 $attr[
'aria-label'] = $label;
10267 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
10268 foreach ($params[
'attr'] as $key => $value) {
10269 if ($key ==
'class') {
10270 $attr[
'class'] .=
' '.$value;
10271 } elseif ($key ==
'classOverride') {
10272 $attr[
'class'] = $value;
10274 $attr[$key] = $value;
10282 $attr = array_map(
'dol_escape_htmltag', $attr);
10284 $TCompiledAttr = array();
10285 foreach ($attr as $key => $value) {
10286 $TCompiledAttr[] = $key.
'="'.$value.
'"';
10289 $compiledAttributes = !empty($TCompiledAttr) ?implode(
' ', $TCompiledAttr) :
'';
10291 $tag = !empty($url) ?
'a' :
'span';
10293 return '<'.$tag.
' '.$compiledAttributes.
'>'.$html.
'</'.$tag.
'>';
10309 function dolGetStatus($statusLabel =
'', $statusLabelShort =
'', $html =
'', $statusType =
'status0', $displayMode = 0, $url =
'', $params = array())
10314 $dolGetBadgeParams = array();
10316 if (!empty($params[
'badgeParams'])) {
10317 $dolGetBadgeParams = $params[
'badgeParams'];
10321 if ($displayMode == 0) {
10322 $return = !empty($html) ? $html : (empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort));
10323 } elseif ($displayMode == 1) {
10324 $return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
10325 } elseif (!empty($conf->global->MAIN_STATUS_USES_IMAGES)) {
10328 $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ?
'<span class="hideonsmartphone">' :
'').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ?
'</span>' :
'');
10329 $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>' :
'');
10332 if (!empty($conf->dol_optimize_smallscreen)) {
10333 if ($displayMode == 0) {
10335 } elseif ($displayMode == 4) {
10337 } elseif ($displayMode == 6) {
10343 $statusImg = array(
10344 'status0' =>
'statut0',
10345 'status1' =>
'statut1',
10346 'status2' =>
'statut2',
10347 'status3' =>
'statut3',
10348 'status4' =>
'statut4',
10349 'status5' =>
'statut5',
10350 'status6' =>
'statut6',
10351 'status7' =>
'statut7',
10352 'status8' =>
'statut8',
10353 'status9' =>
'statut9'
10356 if (!empty($statusImg[$statusType])) {
10357 $htmlImg =
img_picto($statusLabel, $statusImg[$statusType]);
10359 $htmlImg =
img_picto($statusLabel, $statusType);
10362 if ($displayMode === 2) {
10363 $return = $htmlImg.
' '.$htmlLabelShort;
10364 } elseif ($displayMode === 3) {
10365 $return = $htmlImg;
10366 } elseif ($displayMode === 4) {
10367 $return = $htmlImg.
' '.$htmlLabel;
10368 } elseif ($displayMode === 5) {
10369 $return = $htmlLabelShort.
' '.$htmlImg;
10371 $return = $htmlLabel.
' '.$htmlImg;
10373 } elseif (empty($conf->global->MAIN_STATUS_USES_IMAGES) && !empty($displayMode)) {
10375 $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
10377 $dolGetBadgeParams[
'attr'][
'class'] =
'badge-status';
10378 $dolGetBadgeParams[
'attr'][
'title'] = empty($params[
'tooltip']) ? $statusLabel : ($params[
'tooltip'] !=
'no' ? $params[
'tooltip'] :
'');
10380 if ($displayMode == 3) {
10381 $return =
dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)),
'', $statusType,
'dot', $url, $dolGetBadgeParams);
10382 } elseif ($displayMode === 5) {
10383 $return =
dolGetBadge($statusLabelShort, $html, $statusType,
'', $url, $dolGetBadgeParams);
10385 $return =
dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), $html, $statusType,
'', $url, $dolGetBadgeParams);
10421 function dolGetButtonAction($label, $html =
'', $actionType =
'default', $url =
'', $id =
'', $userRight = 1, $params = array())
10423 global $hookmanager, $action, $object, $langs;
10425 $class =
'butAction';
10426 if ($actionType ==
'danger' || $actionType ==
'delete') {
10427 $class =
'butActionDelete';
10428 if (!empty($url) && strpos($url,
'token=') ===
false) $url .=
'&token='.newToken();
10433 'href' => empty($url) ?
'' : $url,
10437 if (empty($html)) {
10439 $attr[
'title'] =
'';
10441 $attr[
'aria-label'] = $label;
10444 if (empty($userRight)) {
10445 $attr[
'class'] =
'butActionRefused';
10446 $attr[
'href'] =
'';
10455 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
10456 foreach ($params[
'attr'] as $key => $value) {
10457 if ($key ==
'class') {
10458 $attr[
'class'] .=
' '.$value;
10459 } elseif ($key ==
'classOverride') {
10460 $attr[
'class'] = $value;
10462 $attr[$key] = $value;
10468 if (!empty($attr[
'title']) && !empty($attr[
'class']) && strpos($attr[
'class'],
'classfortooltip') ===
false) {
10469 $attr[
'class'].=
' classfortooltip';
10473 if ($userRight && !empty($params[
'confirm'])) {
10474 if (!is_array($params[
'confirm'])) {
10475 $params[
'confirm'] = array();
10478 if (empty($params[
'confirm'][
'url'])) {
10479 $params[
'confirm'][
'url'] = $url . (strpos($url,
'?') > 0 ?
'&' :
'?') .
'confirm=yes';
10483 $attr[
'data-confirm-url'] = $params[
'confirm'][
'url'];
10484 $attr[
'data-confirm-title'] = !empty($params[
'confirm'][
'title']) ? $params[
'confirm'][
'title'] : $langs->trans(
'ConfirmBtnCommonTitle', $label);
10485 $attr[
'data-confirm-content'] = !empty($params[
'confirm'][
'content']) ? $params[
'confirm'][
'content'] : $langs->trans(
'ConfirmBtnCommonContent', $label);
10486 $attr[
'data-confirm-content'] = preg_replace(
"/\r|\n/",
"", $attr[
'data-confirm-content']);
10487 $attr[
'data-confirm-action-btn-label'] = !empty($params[
'confirm'][
'action-btn-label']) ? $params[
'confirm'][
'action-btn-label'] : $langs->trans(
'Confirm');
10488 $attr[
'data-confirm-cancel-btn-label'] = !empty($params[
'confirm'][
'cancel-btn-label']) ? $params[
'confirm'][
'cancel-btn-label'] : $langs->trans(
'CloseDialog');
10489 $attr[
'data-confirm-modal'] = !empty($params[
'confirm'][
'modal']) ? $params[
'confirm'][
'modal'] :
true;
10491 $attr[
'class'].=
' butActionConfirm';
10494 if (isset($attr[
'href']) && empty($attr[
'href'])) {
10495 unset($attr[
'href']);
10499 $attr = array_map(
'dol_escape_htmltag', $attr);
10501 $TCompiledAttr = array();
10502 foreach ($attr as $key => $value) {
10503 $TCompiledAttr[] = $key.
'="'.$value.
'"';
10506 $compiledAttributes = empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr);
10508 $tag = !empty($attr[
'href']) ?
'a' :
'span';
10511 $parameters = array(
10512 'TCompiledAttr' => $TCompiledAttr,
10513 'compiledAttributes' => $compiledAttributes,
10518 'actionType' => $actionType,
10521 'userRight' => $userRight,
10522 'params' => $params
10525 $reshook = $hookmanager->executeHooks(
'dolGetButtonAction', $parameters, $object, $action);
10526 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
10528 if (empty($reshook)) {
10529 return '<' . $tag .
' ' . $compiledAttributes .
'>' . $html .
'</' . $tag .
'>';
10531 return $hookmanager->resPrint;
10543 return '<span class="button-title-separator '.$moreClass.
'" ></span>';
10555 if (!empty($fieldValidationErrorMsg)) {
10556 $out.=
'<span class="field-error-icon classfortooltip" title="'.dol_escape_htmltag($fieldValidationErrorMsg, 1).
'" role="alert" >';
10557 $out.=
'<span class="fa fa-exclamation-circle" aria-hidden="true" ></span>';
10576 function dolGetButtonTitle($label, $helpText =
'', $iconClass =
'fa fa-file', $url =
'', $id =
'', $status = 1, $params = array())
10578 global $langs, $conf, $user;
10581 if (!empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (!$user->admin) && $status <= 0) {
10585 $class =
'btnTitle';
10586 if (in_array($iconClass, array(
'fa fa-plus-circle',
'fa fa-plus-circle size15x',
'fa fa-comment-dots'))) {
10587 $class .=
' btnTitlePlus';
10589 $useclassfortooltip = 1;
10591 if (!empty($params[
'morecss'])) {
10592 $class .=
' '.$params[
'morecss'];
10597 'href' => empty($url) ?
'' : $url
10600 if (!empty($helpText)) {
10602 } elseif (empty($attr[
'title']) && $label) {
10603 $attr[
'title'] = $label;
10604 $useclassfortooltip = 0;
10607 if ($status == 2) {
10608 $attr[
'class'] .=
' btnTitleSelected';
10609 } elseif ($status <= 0) {
10610 $attr[
'class'] .=
' refused';
10612 $attr[
'href'] =
'';
10614 if ($status == -1) {
10615 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"FeatureDisabled"));
10616 } elseif ($status == 0) {
10617 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions"));
10621 if (!empty($attr[
'title']) && $useclassfortooltip) {
10622 $attr[
'class'] .=
' classfortooltip';
10630 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
10631 foreach ($params[
'attr'] as $key => $value) {
10632 if ($key ==
'class') {
10633 $attr[
'class'] .=
' '.$value;
10634 } elseif ($key ==
'classOverride') {
10635 $attr[
'class'] = $value;
10637 $attr[$key] = $value;
10642 if (isset($attr[
'href']) && empty($attr[
'href'])) {
10643 unset($attr[
'href']);
10649 $attr = array_map(
'dol_escape_htmltag', $attr);
10651 $TCompiledAttr = array();
10652 foreach ($attr as $key => $value) {
10653 $TCompiledAttr[] = $key.
'="'.$value.
'"';
10656 $compiledAttributes = (empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr));
10658 $tag = (empty($attr[
'href']) ?
'span' :
'a');
10660 $button =
'<'.$tag.
' '.$compiledAttributes.
'>';
10661 $button .=
'<span class="'.$iconClass.
' valignmiddle btnTitle-icon"></span>';
10662 if (!empty($params[
'forcenohideoftext'])) {
10663 $button .=
'<span class="valignmiddle text-plus-circle btnTitle-label'.(empty($params[
'forcenohideoftext']) ?
' hideonsmartphone' :
'').
'">'.$label.
'</span>';
10665 $button .=
'</'.$tag.
'>';
10681 $classfile = $classname = $classpath =
'';
10684 $module = $element_type;
10685 $element = $element_type;
10686 $subelement = $element_type;
10689 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $element_type, $regs)) {
10690 $element = $subelement = $regs[1];
10691 $module = $regs[2];
10695 if (preg_match(
'/^([^_]+)_([^_]+)/i', $element, $regs)) {
10696 $module = $element = $regs[1];
10697 $subelement = $regs[2];
10701 if ($element_type ==
"action") {
10702 $classpath =
'comm/action/class';
10703 $subelement =
'Actioncomm';
10704 $module =
'agenda';
10708 if ($element_type ==
'facture' || $element_type ==
'invoice') {
10709 $classpath =
'compta/facture/class';
10710 $module =
'facture';
10711 $subelement =
'facture';
10713 if ($element_type ==
'commande' || $element_type ==
'order') {
10714 $classpath =
'commande/class';
10715 $module =
'commande';
10716 $subelement =
'commande';
10718 if ($element_type ==
'propal') {
10719 $classpath =
'comm/propal/class';
10721 if ($element_type ==
'supplier_proposal') {
10722 $classpath =
'supplier_proposal/class';
10724 if ($element_type ==
'shipping') {
10725 $classpath =
'expedition/class';
10726 $subelement =
'expedition';
10727 $module =
'expedition_bon';
10729 if ($element_type ==
'delivery') {
10730 $classpath =
'delivery/class';
10731 $subelement =
'delivery';
10732 $module =
'delivery_note';
10734 if ($element_type ==
'contract') {
10735 $classpath =
'contrat/class';
10736 $module =
'contrat';
10737 $subelement =
'contrat';
10739 if ($element_type ==
'member') {
10740 $classpath =
'adherents/class';
10741 $module =
'adherent';
10742 $subelement =
'adherent';
10744 if ($element_type ==
'cabinetmed_cons') {
10745 $classpath =
'cabinetmed/class';
10746 $module =
'cabinetmed';
10747 $subelement =
'cabinetmedcons';
10749 if ($element_type ==
'fichinter') {
10750 $classpath =
'fichinter/class';
10751 $module =
'ficheinter';
10752 $subelement =
'fichinter';
10754 if ($element_type ==
'dolresource' || $element_type ==
'resource') {
10755 $classpath =
'resource/class';
10756 $module =
'resource';
10757 $subelement =
'dolresource';
10759 if ($element_type ==
'propaldet') {
10760 $classpath =
'comm/propal/class';
10761 $module =
'propal';
10762 $subelement =
'propaleligne';
10764 if ($element_type ==
'order_supplier') {
10765 $classpath =
'fourn/class';
10766 $module =
'fournisseur';
10767 $subelement =
'commandefournisseur';
10768 $classfile =
'fournisseur.commande';
10770 if ($element_type ==
'invoice_supplier') {
10771 $classpath =
'fourn/class';
10772 $module =
'fournisseur';
10773 $subelement =
'facturefournisseur';
10774 $classfile =
'fournisseur.facture';
10776 if ($element_type ==
"service") {
10777 $classpath =
'product/class';
10778 $subelement =
'product';
10781 if (empty($classfile)) {
10782 $classfile = strtolower($subelement);
10784 if (empty($classname)) {
10785 $classname = ucfirst($subelement);
10787 if (empty($classpath)) {
10788 $classpath = $module.
'/class';
10791 $element_properties = array(
10792 'module' => $module,
10793 'classpath' => $classpath,
10794 'element' => $element,
10795 'subelement' => $subelement,
10796 'classfile' => $classfile,
10797 'classname' => $classname
10799 return $element_properties;
10816 if (is_array($element_prop) && $conf->{$element_prop[
'module']}->enabled) {
10817 dol_include_once(
'/'.$element_prop[
'classpath'].
'/'.$element_prop[
'classfile'].
'.class.php');
10819 $objecttmp =
new $element_prop[
'classname']($db);
10820 $ret = $objecttmp->fetch($element_id, $element_ref);
10836 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)) {
10851 return empty($_SESSION[
'newtoken']) ?
'' : $_SESSION[
'newtoken'];
10862 return isset($_SESSION[
'token']) ? $_SESSION[
'token'] :
'';
10881 print
'<div class="div-table-responsive-no-min">';
10882 print
'<table class="noborder centpercent">';
10883 print
'<tr class="liste_titre">';
10885 print $emptyRows < 1 ? '<th>
' : '<th colspan=
"'.($emptyRows + 1).'">
';
10887 print $langs->trans($header);
10889 // extra space between the first header and the number
10890 if ($number > -1) {
10894 if (!empty($link)) {
10895 if (!empty($arguments)) {
10896 print '<a href=
"'.DOL_URL_ROOT.'/'.$link.'?'.$arguments.'">
';
10898 print '<a href=
"'.DOL_URL_ROOT.'/'.$link.'">
';
10902 if ($number > -1) {
10903 print '<span
class=
"badge">
'.$number.'</span>
';
10906 if (!empty($link)) {
10912 if ($number < 0 && !empty($link)) {
10913 print '<th
class=
"right">
';
10915 if (!empty($arguments)) {
10916 print '<a
class=
"commonlink" href=
"'.DOL_URL_ROOT.'/'.$link.'?'.$arguments.'">
';
10918 print '<a
class=
"commonlink" href=
"'.DOL_URL_ROOT.'/'.$link.'">
';
10921 print $langs->trans("FullList");
10937 function finishSimpleTable($addLineBreak = false)
10942 if ($addLineBreak) {
10958 function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord = "None", $extraRightColumn = false)
10963 print '<tr
class=
"oddeven">
';
10964 print '<td colspan=
"'.$tableColumnCount.'" class=
"opacitymedium">
'.$langs->trans($noneWord).'</td>
';
10969 if ($nbofloop === 0) {
10970 // don't show a summary line
10975 $colspan = $tableColumnCount;
10976 } elseif ($num > $nbofloop) {
10977 $colspan = $tableColumnCount;
10979 $colspan = $tableColumnCount - 1;
10982 if ($extraRightColumn) {
10986 print
'<tr class="liste_total">';
10988 if ($nbofloop > 0 && $num > $nbofloop) {
10989 print
'<td colspan="'.$colspan.
'" class="right">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
'</td>';
10991 print
'<td colspan="'.$colspan.
'" class="right"> '.$langs->trans(
"Total").
'</td>';
10992 print
'<td class="right" width="100">'.price($total).
'</td>';
10995 if ($extraRightColumn) {
11014 if ($method == -1) {
11016 if (!empty($conf->global->MAIN_FORCE_READFILE_WITH_FREAD)) {
11019 if (!empty($conf->global->MAIN_FORCE_READFILE_WITH_STREAM_COPY)) {
11025 while (ob_get_level()) {
11030 if ($method == 0) {
11031 readfile($fullpath_original_file_osencoded);
11032 } elseif ($method == 1) {
11034 $handle = fopen($fullpath_original_file_osencoded,
"rb");
11035 while (!feof($handle)) {
11036 print fread($handle, 8192);
11039 } elseif ($method == 2) {
11041 $handle1 = fopen($fullpath_original_file_osencoded,
"rb");
11042 $handle2 = fopen(
"php://output",
"wb");
11043 stream_copy_to_stream($handle1, $handle2);
11068 if ($texttoshow ===
'none') {
11069 $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>';
11070 } elseif ($texttoshow) {
11071 $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>';
11073 $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>';
11088 $result = json_decode($stringtodecode);
11089 if ($result === null) {
11090 $result = unserialize($stringtodecode);
11117 $tmp = $sqlfilters;
11118 $i = 0; $nb = strlen($tmp);
11121 if ($tmp[$i] ==
'(') {
11124 if ($tmp[$i] ==
')') {
11127 if ($counter < 0) {
11128 $error =
"Bad sqlfilters=".$sqlfilters;
11157 if (empty($matches[1])) {
11160 $tmp = explode(
':', $matches[1], 3);
11162 if (count($tmp) < 3) {
11166 $operand = preg_replace(
'/[^a-z0-9\._]/i',
'', trim($tmp[0]));
11168 $operator = strtoupper(preg_replace(
'/[^a-z<>=]/i',
'', trim($tmp[1])));
11169 if ($operator ==
'NOTLIKE') {
11170 $operator =
'NOT LIKE';
11173 $tmpescaped = trim($tmp[2]);
11175 if ($operator ==
'IN') {
11176 $tmpescaped =
"(".$db->sanitize($tmpescaped, 1).
")";
11177 } elseif (preg_match(
'/^\'(.*)\'$/', $tmpescaped, $regbis)) {
11178 $tmpescaped =
"'".$db->escape($regbis[1]).
"'";
11180 $tmpescaped = $db->sanitize($db->escape($tmpescaped));
11183 return $db->escape($operand).
' '.$db->escape($operator).
" ".$tmpescaped;
dol_convert_file($fileinput, $ext= 'png', $fileoutput= '', $page= '')
Convert an image file or a PDF into another image format.
dol_nboflines_bis($text, $maxlinesize=0, $charset= 'UTF-8')
Return nb of lines of a formated text with and (WARNING: string must not have mixed and br sepa...
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolIsAllowedForPreview($file)
Return if a file is qualified for preview.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
dol_sanitizePathName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a path name.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
dol_htmloutput_events($disabledoutputofmessages=0)
Print formated messages to output (Used to show messages on html output).
dol_getcache($memoryid)
Read a memory area shared by all users, all sessions on server.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow= '')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
dol_substr($string, $start, $length, $stringencoding= '', $trunconbytes=0)
Make a substring.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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...
getUserRemoteIP()
Return the IP of remote user.
dol_get_prev_month($month, $year)
Return previous month.
isACompany()
Return if third party is a company (Business) or an end user (Consumer)
dol_mkdir($dir, $dataroot= '', $newmask= '')
Creation of a directory (this can create recursive subdir)
dol_print_url($url, $target= '_blank', $max=32, $withpicto=0)
Show Url link.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs= '', $mode=0, $extralangcode= '')
Return a formated address (part address/zip/town/state) according to country rules.
conf($dolibarr_main_document_root)
Load conf file (file must exists)
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
dol_setcache($memoryid, $data, $expire=0)
Save data into a memory area shared by all users, all sessions on server.
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
getArrayOfSocialNetworks()
Get array of social network dictionary.
setEntity($currentobject)
Set entity id to use when to create an object.
printCommonFooter($zone= 'private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0)
Clean a string to keep only desirable HTML tags.
img_weather($titlealt, $picto, $moreatt= '', $pictoisfullpath=0, $morecss= '')
Show weather picto.
img_credit_card($brand, $morecss=null)
Return image of a credit card according to its brand name.
dol_escape_json($stringtoescape)
Returns text escaped for inclusion into javascript code.
dol_shutdown()
Function called at end of web php process.
dol_html_entity_decode($a, $b, $c= 'UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
Class to manage products or services.
dol_fiche_head($links=array(), $active= '0', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tab header of a card.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_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.
dol_now($mode= 'auto')
Return date for now.
picto_required()
Return picto saying a field is required.
img_view($titlealt= 'default', $float=0, $other= 'class="valignmiddle"')
Show logo view card.
get_date_range($date_start, $date_end, $format= '', $outputlangs= '', $withparenthesis=1)
Format output for start and end date.
Class to manage Dolibarr users.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
get_htmloutput_errors($mesgstring= '', $mesgarray=array(), $keepembedded=0)
Get formated error messages to output (Used to show messages on html output).
getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
Get tax (VAT) main information from Id.
dol_strtoupper($string, $encoding="UTF-8")
Convert a string to upper.
isASecretKey($keyname)
Return if string has a name dedicated to store a secret.
dol_print_phone($phone, $countrycode= '', $cid=0, $socid=0, $addlink= '', $separ=" ", $withpicto= '', $titlealt= '', $adddivfloat=0)
Format phone numbers according to country.
jsonOrUnserialize($stringtodecode)
Decode an encode string.
setEventMessage($mesgs, $style= 'mesgs')
Set event message in dol_events session object.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
dol_getmypid()
Return getmypid() or random PID when function is disabled Some web hosts disable this php function fo...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
dolGetButtonAction($label, $html= '', $actionType= 'default', $url= '', $id= '', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
num2Alpha($n)
Return a numeric value into an Excel like column number.
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_string_nospecial($str, $newstr= '_', $badcharstoreplace= '', $badcharstoremove= '')
Clean a string from all punctuation characters to use it as a ref or login.
dol_is_dir($folder)
Test if filename is a directory.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Fonction qui renvoie si tva doit etre tva percue recuperable.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
$conf db name
Only used if Module[ID]Name translation string is not found.
dol_sanitizeUrl($stringtoclean, $type=1)
Clean a string to use it as an URL (into a href or src attribute)
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...
checkVal($out= '', $check= 'alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_get_prev_day($day, $month, $year)
Return previous day.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error_email($prefixcode, $errormessage= '', $errormessages=array(), $morecss= 'error', $email= '')
Show a public email and error code to contact if technical error.
dol_validElement($element)
Return if var element is ok.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0, $filters= '')
Return an id or code from a code or id.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate, from a $thirdparty_buyer to a $thirdparty_seller Note: This function applies same rules than get_default_tva.
img_left($titlealt= 'default', $selected=0, $moreatt= '')
Show left arrow logo.
img_mime($file, $titlealt= '', $morecss= '')
Show MIME img of a file.
ajax_autoselect($htmlname, $addlink= '', $textonlink= 'Link')
Make content of an input box selected when we click into input field.
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...
img_action($titlealt, $numaction, $picto= '')
Show logo action.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled= '', $morecss= 'button bordertransp', $backtopagejsfields= '')
Return HTML code to output a button to open a dialog popup box.
dol_string_nounprintableascii($str, $removetabcrlf=1)
Clean a string from all non printable ASCII chars (0x00-0x1F and 0x7F).
img_search($titlealt= 'default', $other= '')
Show search logo.
dol_print_ip($ip, $mode=0)
Return an IP formated to be shown on screen.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
dol_nboflines($s, $maxchar=0)
Return nb of lines of a clear text.
getImageFileNameForSize($file, $extName, $extImgTarget= '')
Return the filename of file to get the thumbs.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
verifCond($strToEvaluate)
Verify if condition in string is ok or not.
img_error($titlealt= 'default')
Show error logo.
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring= '1')
Replace eval function to add more security.
showDirectDownloadLink($object)
Return string with full Url.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput= 'no', $use_short_label=0)
Output a dimension with best unit.
isValidMXRecord($domain)
Return if the domain name has a valid MX record.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
img_down($titlealt= 'default', $selected=0, $moreclass= '')
Show down arrow logo.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetworks=array())
Show social network link.
img_pdf($titlealt= 'default', $size=3)
Show pdf logo.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags=array('textarea'), $cleanalsosomestyles=0)
Clean a string from some undesirable HTML tags.
get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
Function that return localtax of a product line (according to seller, buyer and product vat rate) Si ...
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
get_htmloutput_mesg($mesgstring= '', $mesgarray= '', $style= 'ok', $keepembedded=0)
Get formated messages to output (Used to show messages on html output).
dol_convertToWord($num, $langs, $currency= '', $centimes=false)
Function to return a number into a text.
dolGetCountryCodeFromIp($ip)
Return a country code from IP.
getServerTimeZoneInt($refgmtdate= 'now')
Return server timezone int.
print *****$script_file(".$version.") pid code
! Closing after partial payment: discount_vat, badcustomer or badsupplier, bankcharge, other ! Closing when no payment: replaced, abandoned
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= 'hideonsmartphone', $textfordropdown= '')
Show information for admin users or standard users.
dol_mimetype($file, $default= 'application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
img_up($titlealt= 'default', $selected=0, $moreclass= '')
Show top arrow logo.
dolCheckFilters($sqlfilters, &$error= '')
Return if a $sqlfilters parameter is valid and will pass the preg_replace_callback() to replace Gener...
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal)
Function to test if an entry is enabled or not.
img_searchclear($titlealt= 'default', $other= '')
Show search logo.
dol_size($size, $type= '')
Optimize a size for some browsers (phone, smarphone, ...)
img_printer($titlealt="default", $other= '')
Show printer logo.
dol_get_next_month($month, $year)
Return next month.
dol_fiche_end($notab=0)
Show tab footer of a card.
img_picto_common($titlealt, $picto, $moreatt= '', $pictoisfullpath=0, $notitle=0)
Show picto (generic function)
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_ucfirst($string, $encoding="UTF-8")
Convert first character of the first word of a string to upper.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_get_next_day($day, $month, $year)
Return next day.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
readfileLowMemory($fullpath_original_file_osencoded, $method=-1)
Return a file on output using a low memory.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array. ...
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
getBrowserInfo($user_agent)
Return information about user browser.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
Class to manage translations.
isValidVATID($company)
Check if VAT numero is valid (check done on syntax only, no database or remote access) ...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
dol_user_country()
Return country code for current user.
utf8_check($str)
Check if a string is in UTF8.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
img_right($titlealt= 'default', $selected=0, $moreatt= '')
Show right arrow logo.
img_next($titlealt= 'default', $moreatt= '')
Show next logo.
dolExplodeIntoArray($string, $delimiter= ';', $kv= '=')
Split a string with 2 keys into key array.
getElementProperties($element_type)
Get an array with properties of an element.
img_edit_add($titlealt= 'default', $other= '')
Show logo +.
print_fiche_titre($title, $mesg= '', $picto= 'generic', $pictoisfullpath=0, $id= '')
Show a title with picto.
if(!empty($_SERVER['MAIN_SHOW_TUNING_INFO'])) realCharForNumericEntities($matches)
Return the real char for a numeric entities.
img_edit_remove($titlealt= 'default', $other= '')
Show logo -.
img_allow($allow, $titlealt= 'default')
Show tick logo if allowed.
dolGetFirstLineOfText($text, $nboflines=1, $charset= 'UTF-8')
Return first line of text.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_ucwords($string, $encoding="UTF-8")
Convert first character of all the words of a string to upper.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_htmloutput_mesg($mesgstring= '', $mesgarray=array(), $style= 'ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
div float
Buy price without taxes.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_previous($titlealt= 'default', $moreatt= '')
Show previous logo.
dol_string_is_good_iso($s, $clean=0)
Check if a string is a correct iso string If not, it will we considered not HTML encoded even if it i...
print_fleche_navigation($page, $file, $options= '', $nextpage=0, $betweenarrows= '', $afterarrows= '', $limit=-1, $totalnboflines=0, $hideselectlimit=0, $beforearrows= '')
Function to show navigation arrows into lists.
isAFileWithExecutableContent($filename)
Return if a file can contains executable content.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
isHTTPS()
Return if we are using a HTTPS connexion Check HTTPS (no way to be modified by user but may be empty ...
startSimpleTable($header, $link="", $arguments="", $emptyRows=0, $number=-1)
Start a table with headers and a optinal clickable number (don't forget to use "finishSimpleTable()" ...
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
dolGetBadge($label, $html= '', $type= 'primary', $mode= '', $url= '', $params=array())
Function dolGetBadge.
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
img_info($titlealt= 'default')
Show info logo.
get_localtax_by_third($local)
Get values of localtaxes (1 or 2) for company country for the common vat with the highest value...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto= 'UTF-8')
This function is called to decode a HTML string (it decodes entities and br tags) ...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
print_titre($title)
Show a title.
dolForgeCriteriaCallback($matches)
Function to forge a SQL criteria from a Generic filter string.
isModEnabled($module)
Is Dolibarr module enabled.
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length. ...
print_date_range($date_start, $date_end, $format= '', $outputlangs= '')
Format output for start and end date.
dolGetStatus($statusLabel= '', $statusLabelShort= '', $html= '', $statusType= 'status0', $displayMode=0, $url= '', $params=array())
Output the badge of a status.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
Class to manage invoices.
fieldLabel($langkey, $fieldkey, $fieldrequired=0)
Show a string with the label tag dedicated to the HTML edit field.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
dol_htmloutput_errors($mesgstring= '', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
getFieldErrorIcon($fieldValidationErrorMsg)
get field error icon
fetchObjectByElement($element_id, $element_type, $element_ref= '')
Fetch an object from its id and element_type Inclusion of classes is automatic.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode= 'add')
Complete or removed entries into a head array (used to build tabs).
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array(), $morecss= '')
On/off button to change status of an object This is called when MAIN_DIRECT_STATUS_UPDATE is set and ...
colorIsLight($stringcolor)
Return true if the color is light.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
img_split($titlealt= 'default', $other= 'class="pictosplit"')
Show split logo.
picto_from_langcode($codelang, $moreatt= '', $notitlealt=0)
Return img flag of country for a language code or country code.
currentToken()
Return the value of token currently saved into session with name 'token'.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param= '')
Return URL we can use for advanced preview links.
dol_print_address($address, $htmlid, $element, $id, $noprint=0, $charfornl= '')
Format address string.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
sanitizeVal($out= '', $check= 'alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
dol_print_profids($profID, $profIDtype, $countrycode= '', $addcpButton=1, $separ= ' ')
Format profIDs according to country.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
Class to manage predefined suppliers products.
ascii_check($str)
Check if a string is in ASCII.
isValidPhone($phone)
Return true if phone number syntax is ok TODO Decide what to do with this.
dol_strtolower($string, $encoding="UTF-8")
Convert a string to lower.
roundUpToNextMultiple($n, $x=5)
Round to next multiple.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_strftime($fmt, $ts=false, $is_gmt=false)
Format a string.
dol_bc($var, $moreclass= '')
Return string to add class property on html element with pair/impair.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
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...
Classe to manage GeoIP Usage: $geoip=new GeoIP('country',$datfile); $geoip->getCountryCodeFromIP($ip)...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid