51if (!function_exists(
'utf8_encode')) {
59 function utf8_encode($elements)
61 return mb_convert_encoding($elements,
'UTF-8',
'ISO-8859-1');
65if (!function_exists(
'utf8_decode')) {
73 function utf8_decode($elements)
75 return mb_convert_encoding($elements,
'ISO-8859-1',
'UTF-8');
78if (!function_exists(
'str_starts_with')) {
87 function str_starts_with($haystack, $needle)
89 return (
string) $needle !==
'' && strncmp($haystack, $needle, strlen($needle)) === 0;
92if (!function_exists(
'str_ends_with')) {
101 function str_ends_with($haystack, $needle)
103 return $needle !==
'' && substr($haystack, -strlen($needle)) === (string) $needle;
106if (!function_exists(
'str_contains')) {
115 function str_contains($haystack, $needle)
117 return $needle !==
'' && mb_strpos($haystack, $needle) !==
false;
137 if (!is_object(
$object) && empty($module)) {
140 if (empty($module) && !empty(
$object->element)) {
145 if ($module ==
'fichinter') {
146 $module =
'ficheinter';
147 } elseif ($module ==
'invoice_supplier') {
148 $module =
'supplier_invoice';
149 } elseif ($module ==
'order_supplier') {
150 $module =
'supplier_order';
154 if ($mode ==
'output' || $mode ==
'outputrel' || $mode ==
'version') {
155 if (isset($conf->$module) && property_exists($conf->$module,
'multidir_output')) {
157 if ($mode !=
'outputrel') {
158 $s = $conf->$module->multidir_output[(empty(
$object->entity) ? $conf->entity :
$object->entity)];
160 if ($forobject &&
$object->id > 0) {
165 return 'error-diroutput-not-defined-for-this-object='.$module;
167 } elseif ($mode ==
'temp') {
168 if (isset($conf->$module) && property_exists($conf->$module,
'multidir_temp')) {
169 return $conf->$module->multidir_temp[(empty(
$object->entity) ? $conf->entity :
$object->entity)];
171 return 'error-dirtemp-not-defined-for-this-object='.$module;
174 return 'error-bad-value-for-mode';
218 return (
string) (isset($conf->global->$key) ? $conf->global->$key : $default);
233 return (
int) (isset($conf->global->$key) ? $conf->global->$key : $default);
247 return (
bool) ($conf->global->$key ?? $default);
261 if (empty($tmpuser)) {
266 return (
string) (isset($tmpuser->conf->$key) ? $tmpuser->conf->$key : $default);
279 if (empty($tmpuser)) {
284 return (
int) (isset($tmpuser->conf->$key) ? $tmpuser->conf->$key : $default);
301 'adherent' =>
'member',
302 'member_type' =>
'adherent_type',
304 'contrat' =>
'contract',
305 'entrepot' =>
'stock',
306 'projet' =>
'project',
307 'categorie' =>
'category',
308 'commande' =>
'order',
309 'expedition' =>
'shipping',
310 'facture' =>
'invoice',
311 'fichinter' =>
'intervention',
312 'ficheinter' =>
'intervention',
313 'propale' =>
'propal',
314 'socpeople' =>
'contact',
315 'fournisseur' =>
'supplier',
317 'actioncomm' =>
'agenda',
318 'product_price' =>
'productprice',
319 'product_fournisseur_price' =>
'productsupplierprice',
329function isModEnabled($module)
339 $arrayconv[
'supplier_order'] =
'fournisseur';
340 $arrayconv[
'supplier_invoice'] =
'fournisseur';
345 if ($module ==
'delivery_note') {
349 $module =
'shipping';
353 $module_alt = $module;
354 if (!empty($arrayconv[$module])) {
355 $module_alt = $arrayconv[$module];
357 $module_bis = $module;
358 if (!empty($arrayconvbis[$module])) {
359 $module_bis = $arrayconvbis[$module];
362 return !empty($conf->modules[$module]) || !empty($conf->modules[$module_alt]) || !empty($conf->modules[$module_bis]);
374 if ($timestamp ===
'') {
375 dol_syslog(
'Using empty string for a timestamp is deprecated, prefer use of null when calling page '.$_SERVER[
"PHP_SELF"], LOG_NOTICE);
378 if (is_null($timestamp) || !is_numeric($timestamp)) {
398 require_once DOL_DOCUMENT_ROOT.
"/core/db/".$type.
'.class.php';
400 $class =
'DoliDB'.ucfirst($type);
401 $db =
new $class($type, $host, $user, $pass, $name, $port);
422function getEntity($element, $shared = 1, $currentobject =
null)
424 global $conf, $mc, $hookmanager,
$object, $action, $db;
426 if (!is_object($hookmanager)) {
427 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
434 $element =
'project';
437 $element =
'contract';
439 case 'order_supplier':
440 $element =
'supplier_order';
442 case 'invoice_supplier':
443 $element =
'supplier_invoice';
447 if (is_object($mc)) {
448 $out = $mc->getEntity($element, $shared, $currentobject);
451 $addzero = array(
'user',
'usergroup',
'cronjob',
'c_email_templates',
'c_holiday_types',
'email_template',
'default_values',
'overwrite_trans');
452 if (in_array($element, $addzero)) {
455 $out .= ((int) $conf->entity);
460 'element' => $element,
463 'currentobject' => $currentobject,
466 $reshook = $hookmanager->executeHooks(
'hookGetEntity', $parameters, $currentobject, $action);
468 if (is_numeric($reshook)) {
469 if ($reshook == 0 && !empty($hookmanager->resPrint)) {
470 $out .=
','.$hookmanager->resPrint;
471 } elseif ($reshook == 1) {
472 $out = $hookmanager->resPrint;
489 if (is_object($mc) && method_exists($mc,
'setEntity')) {
490 return $mc->setEntity($currentobject);
492 return ((is_object($currentobject) && $currentobject->id > 0 && $currentobject->entity > 0) ? $currentobject->entity : $conf->entity);
504 return preg_match(
'/(_pass|password|_pw|_key|securekey|serverkey|secret\d?|p12key|exportkey|_PW_[a-z]+|token)$/i', $keyname);
516 for ($r =
""; $n >= 0; $n = intval($n / 26) - 1) {
517 $r = chr($n % 26 + 0x41) . $r;
541 include_once DOL_DOCUMENT_ROOT.
'/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php';
548 $user_agent = substr($user_agent, 0, 512);
550 $detectmobile =
new Mobile_Detect(
null, $user_agent);
551 $tablet = $detectmobile->isTablet();
553 if ($detectmobile->isMobile()) {
557 if ($detectmobile->is(
'AndroidOS')) {
558 $os = $phone =
'android';
559 } elseif ($detectmobile->is(
'BlackBerryOS')) {
560 $os = $phone =
'blackberry';
561 } elseif ($detectmobile->is(
'iOS')) {
564 } elseif ($detectmobile->is(
'PalmOS')) {
565 $os = $phone =
'palm';
566 } elseif ($detectmobile->is(
'SymbianOS')) {
568 } elseif ($detectmobile->is(
'webOS')) {
570 } elseif ($detectmobile->is(
'MaemoOS')) {
572 } elseif ($detectmobile->is(
'WindowsMobileOS') || $detectmobile->is(
'WindowsPhoneOS')) {
578 if (preg_match(
'/linux/i', $user_agent)) {
580 } elseif (preg_match(
'/macintosh/i', $user_agent)) {
582 } elseif (preg_match(
'/windows/i', $user_agent)) {
588 if (preg_match(
'/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
590 $version = empty($reg[2]) ?
'' : $reg[2];
591 } elseif (preg_match(
'/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
593 $version = empty($reg[2]) ?
'' : $reg[2];
594 } elseif (preg_match(
'/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) {
596 $version = empty($reg[2]) ?
'' : $reg[2];
597 } elseif (preg_match(
'/chrome/i', $user_agent, $reg)) {
600 } elseif (preg_match(
'/iceweasel/i', $user_agent)) {
602 } elseif (preg_match(
'/epiphany/i', $user_agent)) {
604 } elseif (preg_match(
'/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
606 $version = empty($reg[2]) ?
'' : $reg[2];
607 } elseif (preg_match(
'/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
610 $version = empty($reg[2]) ?
'' : $reg[2];
611 } elseif (preg_match(
'/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
613 $version = end($reg);
614 } elseif (preg_match(
'/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
617 $version = end($reg);
618 } elseif (preg_match(
'/l[iy]n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) {
621 $version = empty($reg[3]) ?
'' : $reg[3];
633 'browsername' => $name,
634 'browserversion' => $version,
636 'browserua' => $user_agent,
651 $disconnectdone =
false;
653 if (is_object($db) && !empty($db->connected)) {
654 $depth = $db->transaction_opened;
655 $disconnectdone = $db->close();
657 dol_syslog(
"--- End access to ".(empty($_SERVER[
"PHP_SELF"]) ?
'unknown' : $_SERVER[
"PHP_SELF"]).(($disconnectdone && $depth) ?
' (Warn: db disconnection forced, transaction depth was '.$depth.
')' :
''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO));
669function GETPOSTISSET($paramname)
673 $relativepathstring = $_SERVER[
"PHP_SELF"];
675 if (constant(
'DOL_URL_ROOT')) {
676 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
678 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
679 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
685 if (!empty($_GET[
'restore_lastsearch_values'])) {
686 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
687 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
688 if (is_array($tmp)) {
689 foreach ($tmp as $key => $val) {
690 if ($key == $paramname) {
698 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
700 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
702 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
704 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
708 $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname]));
725 if (empty($method)) {
726 $val = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
727 } elseif ($method == 1) {
728 $val = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
729 } elseif ($method == 2) {
730 $val = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
731 } elseif ($method == 3) {
732 $val = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
734 $val =
'BadFirstParameterForGETPOST';
737 return is_array($val);
770function GETPOST($paramname, $check =
'alphanohtml', $method = 0, $filter =
null, $options =
null, $noreplace = 0)
772 global $mysoc, $user, $conf;
774 if (empty($paramname)) {
775 return 'BadFirstParameterForGETPOST';
778 dol_syslog(
"Deprecated use of GETPOST, called with 1st param = ".$paramname.
" and a 2nd param that is '', when calling page ".$_SERVER[
"PHP_SELF"], LOG_WARNING);
783 if (empty($method)) {
784 $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
785 } elseif ($method == 1) {
786 $out = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
787 } elseif ($method == 2) {
788 $out = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
789 } elseif ($method == 3) {
790 $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
792 return 'BadThirdParameterForGETPOST';
795 $relativepathstring =
'';
797 if (empty($method) || $method == 3 || $method == 4) {
798 $relativepathstring = (empty($_SERVER[
"PHP_SELF"]) ?
'' : $_SERVER[
"PHP_SELF"]);
800 if (constant(
'DOL_URL_ROOT')) {
801 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
803 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
804 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
810 if (!empty($_GET[
'restore_lastsearch_values'])) {
811 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
812 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
813 if (is_array($tmp)) {
814 foreach ($tmp as $key => $val) {
815 if ($key == $paramname) {
823 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
824 $out = $_SESSION[
'lastsearch_contextpage_'.$relativepathstring];
825 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
826 $out = $_SESSION[
'lastsearch_limit_'.$relativepathstring];
827 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
828 $out = $_SESSION[
'lastsearch_page_'.$relativepathstring];
829 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
830 $out = $_SESSION[
'lastsearch_mode_'.$relativepathstring];
832 } elseif (!isset($_GET[
'sortfield'])) {
835 if (!empty($_GET[
'action']) && $_GET[
'action'] ==
'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
838 '@phan-var-force CommonObject $object';
839 if (is_object(
$object) && isset(
$object->fields[$paramname][
'default'])) {
841 $out =
$object->fields[$paramname][
'default'];
845 if (!empty($_GET[
'action']) && (preg_match(
'/^create/', $_GET[
'action']) || preg_match(
'/^presend/', $_GET[
'action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
847 if (!empty($user->default_values)) {
848 if (isset($user->default_values[$relativepathstring][
'createform'])) {
849 foreach ($user->default_values[$relativepathstring][
'createform'] as $defkey => $defval) {
851 if ($defkey !=
'_noquery_') {
852 $tmpqueryarraytohave = explode(
'&', $defkey);
855 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
856 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
869 if (isset($user->default_values[$relativepathstring][
'createform'][$defkey][$paramname])) {
870 $out = $user->default_values[$relativepathstring][
'createform'][$defkey][$paramname];
877 } elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
879 if (!empty($user->default_values)) {
882 if ($paramname ==
'sortfield' || $paramname ==
'sortorder') {
884 if (isset($user->default_values[$relativepathstring][
'sortorder'])) {
886 foreach ($user->default_values[$relativepathstring][
'sortorder'] as $defkey => $defval) {
888 if ($defkey !=
'_noquery_') {
889 $tmpqueryarraytohave = explode(
'&', $defkey);
892 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
893 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
906 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
907 foreach ($user->default_values[$relativepathstring][
'sortorder'][$defkey] as $key => $val) {
911 if ($paramname ==
'sortfield') {
914 if ($paramname ==
'sortorder') {
922 } elseif (isset($user->default_values[$relativepathstring][
'filters'])) {
923 foreach ($user->default_values[$relativepathstring][
'filters'] as $defkey => $defval) {
924 if (!empty($_GET[
'disabledefaultvalues'])) {
928 if ($defkey !=
'_noquery_') {
929 $tmpqueryarraytohave = explode(
'&', $defkey);
932 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
933 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
945 if ($qualified && isset($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname])) {
947 if (isset($_POST[
'sall']) || isset($_POST[
'search_all']) || isset($_GET[
'sall']) || isset($_GET[
'search_all'])) {
950 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
951 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
954 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
955 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
970 '@phan-var-force string $paramname';
971 if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
975 while (preg_match(
'/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) {
979 if ($reg[1] ==
'DAY') {
981 $newout = $tmp[
'mday'];
982 } elseif ($reg[1] ==
'MONTH') {
984 $newout = $tmp[
'mon'];
985 } elseif ($reg[1] ==
'YEAR') {
987 $newout = $tmp[
'year'];
988 } elseif ($reg[1] ==
'PREVIOUS_DAY') {
991 $newout = $tmp2[
'day'];
992 } elseif ($reg[1] ==
'PREVIOUS_MONTH') {
995 $newout = $tmp2[
'month'];
996 } elseif ($reg[1] ==
'PREVIOUS_YEAR') {
998 $newout = ($tmp[
'year'] - 1);
999 } elseif ($reg[1] ==
'NEXT_DAY') {
1002 $newout = $tmp2[
'day'];
1003 } elseif ($reg[1] ==
'NEXT_MONTH') {
1006 $newout = $tmp2[
'month'];
1007 } elseif ($reg[1] ==
'NEXT_YEAR') {
1009 $newout = ($tmp[
'year'] + 1);
1010 } elseif ($reg[1] ==
'MYCOMPANY_COUNTRY_ID' || $reg[1] ==
'MYCOUNTRY_ID' || $reg[1] ==
'MYCOUNTRYID') {
1011 $newout = $mysoc->country_id;
1012 } elseif ($reg[1] ==
'USER_ID' || $reg[1] ==
'USERID') {
1013 $newout = $user->id;
1014 } elseif ($reg[1] ==
'USER_SUPERVISOR_ID' || $reg[1] ==
'SUPERVISOR_ID' || $reg[1] ==
'SUPERVISORID') {
1015 $newout = $user->fk_user;
1016 } elseif ($reg[1] ==
'ENTITY_ID' || $reg[1] ==
'ENTITYID') {
1017 $newout = $conf->entity;
1018 } elseif ($reg[1] ==
'ID') {
1024 $out = preg_replace(
'/__'.preg_quote($reg[1],
'/').
'__/', $newout, $out);
1029 if (preg_match(
'/^array/', $check)) {
1030 if (!is_array($out) || empty($out)) {
1033 $tmparray = explode(
':', $check);
1034 if (!empty($tmparray[1])) {
1035 $tmpcheck = $tmparray[1];
1037 $tmpcheck =
'alphanohtml';
1039 foreach ($out as $outkey => $outval) {
1040 $out[$outkey] =
sanitizeVal($outval, $tmpcheck, $filter, $options);
1046 if (strpos($paramname,
'search_') === 0) {
1047 $out = preg_replace(
'/([<>])([-+]?\d)/',
'\1 \2', $out);
1051 $out =
sanitizeVal($out, $check, $filter, $options);
1056 if ($paramname ==
'backtopage' || $paramname ==
'backtolist' || $paramname ==
'backtourl') {
1057 $out = str_replace(
'\\',
'/', $out);
1058 $out = str_replace(array(
':',
';',
'@',
"\t",
' '),
'', $out);
1060 $oldstringtoclean = $out;
1061 $out = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $out);
1062 $out = preg_replace(array(
'/^[^\?]*%/'),
'', $out);
1063 $out = preg_replace(array(
'/^[a-z]*\/\s*\/+/i'),
'', $out);
1064 }
while ($oldstringtoclean != $out);
1069 if (empty($method) || $method == 3 || $method == 4) {
1070 if (preg_match(
'/^search_/', $paramname) || in_array($paramname, array(
'sortorder',
'sortfield'))) {
1077 if ($out !=
'' && isset($user)) {
1078 $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out;
1097 return (
int)
GETPOST($paramname,
'int', $method,
null,
null, 0);
1126function GETPOSTDATE($prefix, $hourTime =
'', $gm =
'auto')
1129 if ($hourTime ===
'getpost') {
1133 } elseif (preg_match(
'/^(\d\d):(\d\d):(\d\d)$/', $hourTime, $m)) {
1134 $hour = intval($m[1]);
1135 $minute = intval($m[2]);
1136 $second = intval($m[3]);
1138 $hour = $minute = $second = 0;
1141 $hour = min($hour, 23);
1142 $minute = min($minute, 59);
1143 $second = min($second, 59);
1158function checkVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1160 return sanitizeVal($out, $check, $filter, $options);
1172function sanitizeVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1181 if (!is_numeric($out)) {
1186 if (is_array($out)) {
1187 $out = implode(
',', $out);
1189 if (preg_match(
'/[^0-9,-]+/i', $out)) {
1194 $out = filter_var($out, FILTER_SANITIZE_STRING);
1197 $out = filter_var($out, FILTER_SANITIZE_EMAIL);
1200 if (!is_array($out)) {
1202 if (preg_match(
'/[^a-z]+/i', $out)) {
1208 if (!is_array($out)) {
1210 if (preg_match(
'/[^a-z0-9_\-\.]+/i', $out)) {
1216 if (!is_array($out)) {
1218 if (preg_match(
'/[^a-z0-9_\-\.@]+/i', $out)) {
1224 if (!is_array($out)) {
1226 if (preg_match(
'/[^a-z0-9_\-\.,]+/i', $out)) {
1233 if (!is_array($out)) {
1236 $oldstringtoclean = $out;
1240 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1247 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1248 }
while ($oldstringtoclean != $out);
1252 case 'alphawithlgt':
1253 if (!is_array($out)) {
1256 $oldstringtoclean = $out;
1260 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1267 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1268 }
while ($oldstringtoclean != $out);
1274 case 'restricthtmlnolink':
1275 case 'restricthtml':
1276 case 'restricthtmlallowclass':
1277 case 'restricthtmlallowlinkscript':
1278 case 'restricthtmlallowunvalid':
1283 if (empty($filter)) {
1284 return 'BadParameterForGETPOST - Param 3 of sanitizeVal()';
1286 if (is_null($options)) {
1289 $out = filter_var($out, $filter, $options);
1293 dol_syslog(
"Error, you call sanitizeVal() with a bad value for the check type. Data will be sanitized with alphanohtml.", LOG_ERR);
1294 $out =
GETPOST($out,
'alphanohtml');
1302if (!function_exists(
'dol_getprefix')) {
1313 function dol_getprefix($mode =
'')
1316 if ($mode ==
'email') {
1321 return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
1322 } elseif (isset($_SERVER[
"SERVER_NAME"])) {
1323 return $_SERVER[
"SERVER_NAME"];
1328 if (!empty($conf->file->instance_unique_id)) {
1329 return sha1(
'dolibarr'.$conf->file->instance_unique_id);
1333 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1337 global $dolibarr_main_instance_unique_id, $dolibarr_main_cookie_cryptkey;
1338 $tmp_instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ?
'' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
1341 if (!empty($tmp_instance_unique_id)) {
1342 return sha1(
'dolibarr'.$tmp_instance_unique_id);
1346 if (isset($_SERVER[
"SERVER_NAME"]) && isset($_SERVER[
"DOCUMENT_ROOT"])) {
1347 return sha1($_SERVER[
"SERVER_NAME"].$_SERVER[
"DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1349 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1366 global $conf, $langs, $user, $mysoc;
1370 if (!file_exists($fullpath)) {
1371 dol_syslog(
'functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_WARNING);
1375 if (!empty($classname) && !class_exists($classname)) {
1376 return include $fullpath;
1378 return include_once $fullpath;
1393function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
1397 $path = preg_replace(
'/^\//',
'', $path);
1400 $res = DOL_DOCUMENT_ROOT.
'/'.$path;
1401 if (is_array($conf->file->dol_document_root)) {
1402 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1403 if ($key ==
'main') {
1407 if (@file_exists($dirroot.
'/'.$path)) {
1408 $res = $dirroot.
'/'.$path;
1413 if ($returnemptyifnotfound) {
1415 if ($returnemptyifnotfound == 1 || !file_exists($res)) {
1427 $res = DOL_URL_ROOT.
'/'.$path;
1430 $res = DOL_MAIN_URL_ROOT.
'/'.$path;
1433 $res = DOL_URL_ROOT.
'/'.$path;
1436 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1437 if ($key ==
'main') {
1442 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($conf->file->dol_main_url_root));
1443 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1446 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
'/'.$path;
1451 preg_match(
'/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);
1452 if (!empty($regs[1])) {
1455 if (@file_exists($dirroot.
'/'.$regs[1])) {
1457 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1460 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1466 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($conf->file->dol_main_url_root));
1467 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1470 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).$conf->file->dol_url_root[$key].
'/'.$path;
1494 if (empty($properties)) {
1495 return get_object_vars($obj);
1498 $existingProperties = [];
1499 $realProperties = get_object_vars($obj);
1502 foreach ($properties as $property) {
1503 if (array_key_exists($property, $realProperties)) {
1505 $existingProperties[$property] = $obj->{$property};
1506 } elseif (property_exists($obj, $property)) {
1508 $existingProperties[$property] = $obj->{$property};
1512 return $existingProperties;
1540 $myclone = unserialize(serialize(
$object));
1542 if (!empty($tmpsavdb)) {
1545 } elseif ($native == 2) {
1548 $tmparray = get_object_vars(
$object);
1550 if (is_array($tmparray)) {
1551 foreach ($tmparray as $propertykey => $propertyval) {
1552 if (is_scalar($propertyval) || is_array($propertyval)) {
1553 $myclone->$propertykey = $propertyval;
1573function dol_size($size, $type =
'')
1576 if (empty($conf->dol_optimize_smallscreen)) {
1579 if ($type ==
'width' && $size > 250) {
1604 $filesystem_forbidden_chars = array(
'<',
'>',
'/',
'\\',
'?',
'*',
'|',
'"',
':',
'°',
'$',
';',
'`');
1606 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1607 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1608 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1609 $tmp = str_replace(
'..',
'', $tmp);
1630 $filesystem_forbidden_chars = array(
'<',
'>',
'?',
'*',
'|',
'"',
'°',
'$',
';',
'`');
1632 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1633 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1634 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1635 $tmp = str_replace(
'..',
'', $tmp);
1650 $stringtoclean = preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $stringtoclean);
1652 $stringtoclean = preg_replace(
'/<!--[^>]*-->/',
'', $stringtoclean);
1654 $stringtoclean = str_replace(
'\\',
'/', $stringtoclean);
1658 $stringtoclean = str_replace(array(
':',
';',
'@'),
'', $stringtoclean);
1662 $oldstringtoclean = $stringtoclean;
1665 $stringtoclean = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $stringtoclean);
1666 }
while ($oldstringtoclean != $stringtoclean);
1670 $stringtoclean = preg_replace(array(
'/^[a-z]*\/\/+/i'),
'', $stringtoclean);
1673 return $stringtoclean;
1685 $oldstringtoclean = $stringtoclean;
1686 $stringtoclean = str_ireplace(array(
'"',
':',
'[',
']',
"\n",
"\r",
'\\',
'\/'),
'', $stringtoclean);
1687 }
while ($oldstringtoclean != $stringtoclean);
1689 return $stringtoclean;
1702 return preg_replace(
'/[^\w]+/',
'', $str);
1716 if (is_null($str)) {
1721 if (extension_loaded(
'intl') &&
getDolGlobalString(
'MAIN_UNACCENT_USE_TRANSLITERATOR')) {
1722 $transliterator = Transliterator::createFromRules(
':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', Transliterator::FORWARD);
1723 return $transliterator->transliterate($str);
1726 $string = rawurlencode($str);
1727 $replacements = array(
1728 '%C3%80' =>
'A',
'%C3%81' =>
'A',
'%C3%82' =>
'A',
'%C3%83' =>
'A',
'%C3%84' =>
'A',
'%C3%85' =>
'A',
1730 '%C3%88' =>
'E',
'%C3%89' =>
'E',
'%C3%8A' =>
'E',
'%C3%8B' =>
'E',
1731 '%C3%8C' =>
'I',
'%C3%8D' =>
'I',
'%C3%8E' =>
'I',
'%C3%8F' =>
'I',
1733 '%C3%92' =>
'O',
'%C3%93' =>
'O',
'%C3%94' =>
'O',
'%C3%95' =>
'O',
'%C3%96' =>
'O',
1735 '%C3%99' =>
'U',
'%C3%9A' =>
'U',
'%C3%9B' =>
'U',
'%C3%9C' =>
'U',
1736 '%C3%9D' =>
'Y',
'%C5%B8' =>
'y',
1737 '%C3%A0' =>
'a',
'%C3%A1' =>
'a',
'%C3%A2' =>
'a',
'%C3%A3' =>
'a',
'%C3%A4' =>
'a',
'%C3%A5' =>
'a',
1739 '%C3%A8' =>
'e',
'%C3%A9' =>
'e',
'%C3%AA' =>
'e',
'%C3%AB' =>
'e',
1740 '%C3%AC' =>
'i',
'%C3%AD' =>
'i',
'%C3%AE' =>
'i',
'%C3%AF' =>
'i',
1742 '%C3%B2' =>
'o',
'%C3%B3' =>
'o',
'%C3%B4' =>
'o',
'%C3%B5' =>
'o',
'%C3%B6' =>
'o',
1744 '%C3%B9' =>
'u',
'%C3%BA' =>
'u',
'%C3%BB' =>
'u',
'%C3%BC' =>
'u',
1745 '%C3%BD' =>
'y',
'%C3%BF' =>
'y'
1747 $string = strtr($string, $replacements);
1748 return rawurldecode($string);
1753 "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
1754 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
1755 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
1756 \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
1757 \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
1758 \xF9\xFA\xFB\xFC\xFD\xFF",
1766 $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"));
1784function dol_string_nospecial($str, $newstr =
'_', $badcharstoreplace =
'', $badcharstoremove =
'', $keepspaces = 0)
1786 $forbidden_chars_to_replace = array(
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
",",
";",
"=",
'°',
'$',
';');
1787 if (empty($keepspaces)) {
1788 $forbidden_chars_to_replace[] =
" ";
1790 $forbidden_chars_to_remove = array();
1793 if (is_array($badcharstoreplace)) {
1794 $forbidden_chars_to_replace = $badcharstoreplace;
1796 if (is_array($badcharstoremove)) {
1797 $forbidden_chars_to_remove = $badcharstoremove;
1801 return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove,
"", $str));
1820 if ($removetabcrlf) {
1821 return preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $str);
1823 return preg_replace(
'/[\x00-\x08\x11-\x12\x14-\x1F\x7F]/u',
'', $str);
1835function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0)
1837 if (is_null($stringtoescape)) {
1842 $substitjs = array(
"'" =>
"\\'",
"\r" =>
'\\r');
1844 if (empty($noescapebackslashn)) {
1845 $substitjs[
"\n"] =
'\\n';
1846 $substitjs[
'\\'] =
'\\\\';
1849 $substitjs[
"'"] =
"\\'";
1850 $substitjs[
'"'] =
"\\'";
1851 } elseif ($mode == 1) {
1852 $substitjs[
"'"] =
"\\'";
1853 } elseif ($mode == 2) {
1854 $substitjs[
'"'] =
'\\"';
1855 } elseif ($mode == 3) {
1856 $substitjs[
"'"] =
"\\'";
1857 $substitjs[
'"'] =
"\\\"";
1859 return strtr($stringtoescape, $substitjs);
1870 return str_replace(
'"',
'\"', $stringtoescape);
1882 if (is_null($stringtoescape)) {
1886 if ($stringforquotes == 2) {
1887 return str_replace(
'"',
"'", $stringtoescape);
1888 } elseif ($stringforquotes == 1) {
1894 $stringtoescape = str_replace(
'\\',
'', $stringtoescape);
1895 return str_replace(
"'",
"\'", str_replace(
'"',
"'", $stringtoescape));
1898 return 'Bad parameter for stringforquotes in dol_escape_php';
1909 return preg_replace(
'/[^a-z0-9_]/i',
'', $stringtoescape);
1920 return $stringtoescape;
1972 return dol_escape_htmltag(
dol_string_onlythesehtmltags(
dol_htmlentitiesbr($s), 1, 0, 0, 0, array(
'br',
'b',
'font',
'span')), 1, -1,
'', 0, 1);
1997 return htmlspecialchars($s, ENT_COMPAT,
'UTF-8');
2017function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags =
'', $escapeonlyhtmltags = 0, $cleanalsojavascript = 0)
2019 if ($noescapetags ==
'common') {
2020 $noescapetags =
'html,body,a,b,em,hr,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody,h1,h2,h3,h4,h5,h6,h7,h8,h9';
2022 $noescapetags .=
',header,footer,nav,section,menu,menuitem';
2024 if ($cleanalsojavascript) {
2029 if ($escapeonlyhtmltags) {
2030 $tmp = htmlspecialchars_decode((
string) $stringtoescape, ENT_COMPAT);
2032 $tmp = html_entity_decode((
string) $stringtoescape, ENT_COMPAT,
'UTF-8');
2033 $tmp = str_ireplace(
''',
'__SIMPLEQUOTE', $tmp);
2036 $tmp = strtr($tmp, array(
"<b>" =>
'',
'</b>' =>
'',
'<strong>' =>
'',
'</strong>' =>
''));
2039 $tmp = strtr($tmp, array(
"\r" =>
'\\r',
"\n" =>
'\\n'));
2040 } elseif ($keepn == -1) {
2041 $tmp = strtr($tmp, array(
"\r" =>
'',
"\n" =>
''));
2044 if ($escapeonlyhtmltags) {
2045 return htmlspecialchars($tmp, ENT_COMPAT,
'UTF-8');
2048 $tmparrayoftags = array();
2049 if ($noescapetags) {
2050 $tmparrayoftags = explode(
',', $noescapetags);
2052 if (count($tmparrayoftags)) {
2054 $tmp = str_ireplace(
'__DOUBLEQUOTE',
'', $tmp);
2056 foreach ($tmparrayoftags as $tagtoreplace) {
2057 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'>/',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2058 $tmp = str_ireplace(
'</'.$tagtoreplace.
'>',
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2059 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
' \/>/',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2065 if (preg_match(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+([^>]+)>/', $tmp, $reg)) {
2066 $tmpattributes = str_ireplace(array(
'[',
']'),
'_', $reg[1]);
2067 $tmpattributes = str_ireplace(
'href="http:',
'__HREFHTTPA', $tmpattributes);
2068 $tmpattributes = str_ireplace(
'href="https:',
'__HREFHTTPSA', $tmpattributes);
2069 $tmpattributes = str_ireplace(
'src="http:',
'__SRCHTTPIMG', $tmpattributes);
2070 $tmpattributes = str_ireplace(
'src="https:',
'__SRCHTTPSIMG', $tmpattributes);
2071 $tmpattributes = str_ireplace(
'"',
'__DOUBLEQUOTE', $tmpattributes);
2072 $tmpattributes = preg_replace(
'/[^a-z0-9_\/\?\;\s=&\.\-@:\.#\+]/i',
'', $tmpattributes);
2074 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+'.preg_quote($reg[1],
'/').
'>/',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'['.$tmpattributes.
']__', $tmp);
2076 if (preg_match(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+([^>]+)\s+\/>/', $tmp, $reg)) {
2077 $tmpattributes = str_ireplace(array(
'[',
']'),
'_', $reg[1]);
2078 $tmpattributes = str_ireplace(
'"',
'__DOUBLEQUOTE', $tmpattributes);
2079 $tmpattributes = preg_replace(
'/[^a-z0-9_\/\?\;\s=&\.\-@:\.#\+]/i',
'', $tmpattributes);
2081 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+'.preg_quote($reg[1],
'/').
'\s+\/>/',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'['.$tmpattributes.
']__', $tmp);
2084 $diff = strcmp($tmpold, $tmp);
2089 $result = htmlentities($tmp, ENT_COMPAT,
'UTF-8');
2093 if (count($tmparrayoftags)) {
2094 foreach ($tmparrayoftags as $tagtoreplace) {
2095 $result = str_ireplace(
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
'>', $result);
2096 $result = preg_replace(
'/__BEGINTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1>', $result);
2097 $result = str_ireplace(
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__',
'</'.$tagtoreplace.
'>', $result);
2098 $result = str_ireplace(
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
' />', $result);
2099 $result = preg_replace(
'/__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1 />', $result);
2102 $result = str_ireplace(
'__HREFHTTPA',
'href="http:', $result);
2103 $result = str_ireplace(
'__HREFHTTPSA',
'href="https:', $result);
2104 $result = str_ireplace(
'__SRCHTTPIMG',
'src="http:', $result);
2105 $result = str_ireplace(
'__SRCHTTPSIMG',
'src="https:', $result);
2106 $result = str_ireplace(
'__DOUBLEQUOTE',
'"', $result);
2109 $result = str_ireplace(
'__SIMPLEQUOTE',
''', $result);
2126 if (function_exists(
'mb_strtolower')) {
2127 return mb_strtolower($string, $encoding);
2129 return strtolower($string);
2143 if (function_exists(
'mb_strtoupper')) {
2144 return mb_strtoupper($string, $encoding);
2146 return strtoupper($string);
2160 if (function_exists(
'mb_substr')) {
2161 return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1,
null, $encoding);
2163 return ucfirst($string);
2177 if (function_exists(
'mb_convert_case')) {
2178 return mb_convert_case($string, MB_CASE_TITLE, $encoding);
2180 return ucwords($string);
2206function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
'', $restricttologhandler =
'', $logcontext =
null)
2208 global $conf, $user, $debugbar;
2211 if (!isModEnabled(
'syslog')) {
2216 if (defined(
'USEEXTERNALSERVER') && !defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
2217 global $website, $websitekey;
2218 if (is_object($website) && !empty($website->ref)) {
2219 $suffixinfilename .=
'_website_'.$website->ref;
2220 } elseif (!empty($websitekey)) {
2221 $suffixinfilename .=
'_website_'.$websitekey;
2226 if (defined(
'USESUFFIXINLOG')) {
2227 $suffixinfilename .= constant(
'USESUFFIXINLOG');
2231 foreach ($conf->loghandlers as $loghandlerinstance) {
2232 $loghandlerinstance->setIdent($ident);
2236 if (!empty($message)) {
2238 $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');
2239 if (!array_key_exists($level, $logLevels)) {
2240 throw new Exception(
'Incorrect log level');
2247 $message = preg_replace(
'/password=\'[^\']*\'/',
'password=\'hidden\'', $message);
2251 if ((!empty($_REQUEST[
'logtohtml']) &&
getDolGlobalString(
'MAIN_ENABLE_LOG_TO_HTML'))
2252 || (is_object($user) && $user->hasRight(
'debugbar',
'read') && is_object($debugbar))) {
2253 $ospid = sprintf(
"%7s",
dol_trunc((
string) getmypid(), 7,
'right',
'UTF-8', 1));
2254 $osuser =
" ".sprintf(
"%6s",
dol_trunc(function_exists(
'posix_getuid') ? posix_getuid() :
'', 6,
'right',
'UTF-8', 1));
2256 $conf->logbuffer[] =
dol_print_date(time(),
"%Y-%m-%d %H:%M:%S").
" ".sprintf(
"%-7s", $logLevels[$level]).
" ".$ospid.
" ".$osuser.
" ".$message;
2262 print
"\n\n<!-- Log start\n";
2264 print
"Log end -->\n";
2268 'message' => $message,
2269 'script' => (isset($_SERVER[
'PHP_SELF']) ? basename($_SERVER[
'PHP_SELF'],
'.php') : false),
2271 'user' => ((is_object($user) && $user->id) ? $user->login : false),
2273 'osuser' => function_exists(
'posix_getuid') ? posix_getuid() : false,
2274 'ospid' => getmypid()
2278 if (!empty($remoteip)) {
2279 $data[
'ip'] = $remoteip;
2281 if (!empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) && $_SERVER[
'HTTP_X_FORWARDED_FOR'] != $remoteip) {
2282 $data[
'ip'] = $_SERVER[
'HTTP_X_FORWARDED_FOR'].
' -> '.$data[
'ip'];
2283 } elseif (!empty($_SERVER[
'HTTP_CLIENT_IP']) && $_SERVER[
'HTTP_CLIENT_IP'] != $remoteip) {
2284 $data[
'ip'] = $_SERVER[
'HTTP_CLIENT_IP'].
' -> '.$data[
'ip'];
2286 } elseif (!empty($_SERVER[
'SERVER_ADDR'])) {
2288 $data[
'ip'] = $_SERVER[
'SERVER_ADDR'];
2289 } elseif (!empty($_SERVER[
'COMPUTERNAME'])) {
2291 $data[
'ip'] = $_SERVER[
'COMPUTERNAME'];
2293 $data[
'ip'] =
'???';
2296 if (!empty($_SERVER[
'USERNAME'])) {
2298 $data[
'osuser'] = $_SERVER[
'USERNAME'];
2299 } elseif (!empty($_SERVER[
'LOGNAME'])) {
2301 $data[
'osuser'] = $_SERVER[
'LOGNAME'];
2305 foreach ($conf->loghandlers as $loghandlerinstance) {
2306 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
2309 $loghandlerinstance->export($data, $suffixinfilename);
2315 foreach ($conf->loghandlers as $loghandlerinstance) {
2316 $loghandlerinstance->setIdent($ident);
2336 $form =
new Form($db);
2338 $templatenameforexport = $website->name_template;
2339 if (empty($templatenameforexport)) {
2340 $templatenameforexport =
'website_'.$website->ref;
2344 $out .=
'<input type="button" class="cursorpointer button bordertransp" id="open-dialog-' . $name .
'" value="'.dol_escape_htmltag($buttonstring).
'"/>';
2347 $out .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">';
2348 $out .=
'jQuery(document).ready(function () {';
2349 $out .=
' jQuery("#open-dialog-' . $name .
'").click(function () {';
2350 $out .=
' var dialogHtml = \'';
2352 $dialogcontent =
' <div id="custom-dialog-' . $name .
'">';
2353 $dialogcontent .=
' <div style="margin-top: 20px;">';
2354 $dialogcontent .=
' <label for="export-site-' . $name .
'"><strong>'.$langs->trans(
"ExportSiteLabel").
'...</label><br>';
2355 $dialogcontent .=
' <button class="button smallpaddingimp" id="export-site-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"DownloadZip")) .
'</button>';
2356 $dialogcontent .=
' </div>';
2357 $dialogcontent .=
' <br>';
2358 $dialogcontent .=
' <div style="margin-top: 20px;">';
2359 $dialogcontent .=
' <strong>'.$langs->trans(
"ExportSiteGitLabel").
' '.$form->textwithpicto(
'', $langs->trans(
"SourceFiles"), 1,
'help',
'', 0, 3,
'').
'</strong><br>';
2360 $dialogcontent .=
' <form action="'.dol_escape_htmltag($overwriteGitUrl).
'" method="POST">';
2361 $dialogcontent .=
' <input type="hidden" name="action" value="overwritesite">';
2362 $dialogcontent .=
' <input type="hidden" name="token" value="'.newToken().
'">';
2363 $dialogcontent .=
' <input type="text" autofocus name="export_path" id="export-path-'.$name.
'" placeholder="'.$langs->trans(
'ExportPath').
'" style="width:400px " value="'.
dol_escape_htmltag($templatenameforexport).
'"/><br>';
2364 $dialogcontent .=
' <button type="submit" class="button smallpaddingimp" id="overwrite-git-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"ExportIntoGIT")) .
'</button>';
2365 $dialogcontent .=
' </form>';
2366 $dialogcontent .=
' </div>';
2367 $dialogcontent .=
' </div>';
2374 // Add the content of the dialog to the body of the page
2375 $out .= ' var $dialog = jQuery(
"#custom-dialog-' . $name . '");
';
2376 $out .= ' if ($dialog.length > 0) {
2379 jQuery(
"body").append(dialogHtml);
';
2381 // Configuration of popup
2382 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog({
';
2383 $out .= ' autoOpen:
false,
';
2384 $out .= ' modal:
true,
';
2385 $out .= ' height: 290,
';
2386 $out .= ' width:
"40%",
';
2387 $out .= ' title:
"' . dol_escape_js($label) . '",
';
2390 // Simulate a click on the original "submit" input to export the site.
2391 $out .= ' jQuery(
"#export-site-' . $name . '").click(
function () {
';
2392 $out .= ' console.log(
"Clic on exportsite.");
';
2393 $out .= ' var target = jQuery(
"input[name=\'' . dol_escape_js($exportSiteName) . '\']");
';
2394 $out .= ' console.log(
"element founded:", target.length > 0);
';
2395 $out .= ' if (target.length > 0) { target.click(); }
';
2396 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"close");
';
2400 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"open");
';
2401 $out .= ' return false;
';
2404 $out .= '</script>
';
2426function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '
', $morecss = 'classlink
button bordertransp
', $jsonopen = '', $backtopagejsfields = '', $accesskey = '')
2430 if (strpos($url, '?
') > 0) {
2431 $url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2433 $url .= '?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2438 $backtopagejsfieldsid = '';
2439 $backtopagejsfieldslabel = '';
2440 if ($backtopagejsfields) {
2441 $tmpbacktopagejsfields = explode(':
', $backtopagejsfields);
2442 if (empty($tmpbacktopagejsfields[1])) { // If the part 'keyforpopupid:
' is missing, we add $name for it.
2443 $backtopagejsfields = $name.":".$backtopagejsfields;
2444 $tmp2backtopagejsfields = explode(',
', $tmpbacktopagejsfields[0]);
2446 $tmp2backtopagejsfields = explode(',
', $tmpbacktopagejsfields[1]);
2448 $backtopagejsfieldsid = empty($tmp2backtopagejsfields[0]) ? '' : $tmp2backtopagejsfields[0];
2449 $backtopagejsfieldslabel = empty($tmp2backtopagejsfields[1]) ? '' : $tmp2backtopagejsfields[1];
2450 $url .= '&backtopagejsfields=
'.urlencode($backtopagejsfields);
2453 //print '<input
type=
"submit" class=
"button bordertransp"'.$disabled.' value=
"'.dol_escape_htmltag($langs->trans("MediaFiles
")).'" name=
"file_manager">
';
2454 $out .= '<!-- a link
for button to open url into a dialog popup with backtopagejsfields =
'.$backtopagejsfields.' -->
';
2455 $out .= '<a
'.($accesskey ? ' accesskey=
"'.$accesskey.'"' : '').' class=
"cursorpointer reposition button_'.$name.($morecss ? ' '.$morecss : '').'"'.$disabled.' title=
"'.dol_escape_htmltag($label).'"';
2456 if (empty($conf->use_javascript_ajax)) {
2457 $out .= ' href=
"'.DOL_URL_ROOT.$url.'" target=
"_blank"';
2458 } elseif ($jsonopen) {
2459 $out .= ' href=
"#" onclick=
"'.$jsonopen.'"';
2461 $out .= ' href=
"#"';
2463 $out .= '>
'.$buttonstring.'</a>
';
2465 if (!empty($conf->use_javascript_ajax)) {
2466 // Add code to open url using the popup. Add also hidden field to retrieve the returned variables
2467 $out .= '<!-- code to open popup and variables to retrieve returned variables -->
';
2468 $out .= '<div
id=
"idfordialog'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for dialog
' : '').'</div>
';
2469 $out .= '<div
id=
"varforreturndialogid'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for returned
id' : '').'</div>
';
2470 $out .= '<div
id=
"varforreturndialoglabel'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for returned label
' : '').'</div>
';
2472 $out .= '<!-- Add js code to open dialog popup on dialog -->
';
2473 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript">
2474 jQuery(document).ready(
function () {
2475 jQuery(
".button_'.$name.'").click(
function () {
2476 console.log(\
'Open popup with jQuery(...).dialog() on URL '.
dol_escape_js(DOL_URL_ROOT.$url).
'\');
2477 var $tmpdialog = $(\
'#idfordialog'.$name.
'\');
2478 $tmpdialog.html(\
'<iframe class="iframedialog" id="iframedialog'.$name.
'" style="border: 0px;" src="'.DOL_URL_ROOT.$url.
'" width="100%" height="98%"></iframe>\');
2482 height: (window.innerHeight - 150),
2485 open: function (event, ui) {
2486 console.log(
"open popup name='.$name.', backtopagejsfields='.$backtopagejsfields.'");
2488 close:
function (event, ui) {
2489 var returnedid = jQuery(
"#varforreturndialogid'.$name.'").text();
2490 var returnedlabel = jQuery(
"#varforreturndialoglabel'.$name.'").text();
2491 console.log(
"popup has been closed. returnedid (js var defined into parent page)="+returnedid+
" returnedlabel="+returnedlabel);
2492 if (returnedid !=
"" && returnedid !=
"div for returned id") {
2493 jQuery(
"#'.(empty($backtopagejsfieldsid) ? "none
" : $backtopagejsfieldsid).'").val(returnedid);
2495 if (returnedlabel !=
"" && returnedlabel !=
"div for returned label") {
2496 jQuery(
"#'.(empty($backtopagejsfieldslabel) ? "none
" : $backtopagejsfieldslabel).'").val(returnedlabel);
2501 $tmpdialog.dialog(\
'open\');
2526function dol_fiche_head($links = array(), $active =
'0', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
2528 print
dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow, $moretabssuffix);
2547function dol_get_fiche_head($links = array(), $active =
'', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'', $dragdropfile = 0)
2549 global $conf, $langs, $hookmanager;
2553 if (!empty($conf->dol_optimize_smallscreen)) {
2557 $out =
"\n".
'<!-- dol_fiche_head - dol_get_fiche_head -->';
2559 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2560 $out .=
'<div class="tabs'.($picto ?
'' :
' nopaddingleft').
'" data-role="controlgroup" data-type="horizontal">'.
"\n";
2564 if ($morehtmlright) {
2565 $out .=
'<div class="inline-block floatright tabsElem">'.$morehtmlright.
'</div>';
2589 if (is_array($links) && !empty($links)) {
2590 $keys = array_keys($links);
2592 $maxkey = max($keys);
2598 if (empty($limittoshow)) {
2599 $limittoshow = (!
getDolGlobalString(
'MAIN_MAXTABS_IN_CARD') ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD);
2601 if (!empty($conf->dol_optimize_smallscreen)) {
2609 for ($i = 0; $i <= $maxkey; $i++) {
2610 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2612 if ($i >= $limittoshow) {
2618 for ($i = 0; $i <= $maxkey; $i++) {
2619 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2625 if ($i < $limittoshow || $isactive) {
2627 $out .=
'<div class="inline-block tabsElem'.($isactive ?
' tabsElemActive' :
'').((!$isactive &&
getDolGlobalString(
'MAIN_HIDE_INACTIVETAB_ON_PRINT')) ?
' hideonprint' :
'').
'"><!-- id tab = '.(empty($links[$i][2]) ?
'' :
dol_escape_htmltag($links[$i][2])).
' -->';
2629 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2630 if (!empty($links[$i][0])) {
2631 $out .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2633 $out .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2635 } elseif (!empty($links[$i][1])) {
2637 $out .=
'<div class="tab tab'.($isactive ?
'active' :
'unactive').
'" style="margin: 0 !important">';
2639 if (!empty($links[$i][0])) {
2640 $titletoshow = preg_replace(
'/<.*$/',
'', $links[$i][1]);
2641 $out .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="tab inline-block valignmiddle'.($morecss ?
' '.$morecss :
'').(!empty($links[$i][5]) ?
' '.$links[$i][5] :
'').
'" href="'.$links[$i][0].
'" title="'.
dol_escape_htmltag($titletoshow).
'">';
2644 if ($displaytab == 0) {
2645 $out .=
img_picto($title, $picto,
'', $pictoisfullpath, 0, 0,
'',
'imgTabTitle paddingright marginrightonlyshort');
2648 $out .= $links[$i][1];
2649 if (!empty($links[$i][0])) {
2650 $out .=
'</a>'.
"\n";
2652 $out .= empty($links[$i][4]) ?
'' : $links[$i][4];
2661 $outmore .=
'<div class="popuptabset wordwrap">';
2663 $outmore .=
'<div class="popuptab wordwrap" style="display:inherit;">';
2664 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2665 if (!empty($links[$i][0])) {
2666 $outmore .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2668 $outmore .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2670 } elseif (!empty($links[$i][1])) {
2671 $outmore .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="wordwrap inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
2672 $outmore .= preg_replace(
'/([a-z])\|([a-z])/i',
'\\1 | \\2', $links[$i][1]);
2673 $outmore .=
'</a>'.
"\n";
2675 $outmore .=
'</div>';
2680 $displaytab = $i + 1;
2683 $outmore .=
'</div>';
2687 $left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
2688 $right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
2689 $widthofpopup = 200;
2691 $tabsname = $moretabssuffix;
2692 if (empty($tabsname)) {
2693 $tabsname = str_replace(
"@",
"", $picto);
2695 $out .=
'<div id="moretabs'.$tabsname.
'" class="inline-block tabsElem valignmiddle">';
2697 $out .=
'<div class="tab valignmiddle"><a href="#" class="tab moretab inline-block tabunactive valignmiddle"><span class="hideonsmartphone">'.$langs->trans(
"More").
'</span>... ('.$nbintab.
')</a></div>';
2699 $out .=
'<div id="moretabsList'.$tabsname.
'" style="width: '.$widthofpopup.
'px; position: absolute; '.$left.
': -999em; text-align: '.$left.
'; margin:0px; padding:2px; z-index:10;">';
2702 $out .=
'<div></div>';
2705 $out .=
'<script nonce="'.getNonce().
'">';
2706 $out .=
"$('#moretabs".$tabsname.
"').mouseenter( function() {
2707 var x = this.offsetLeft, y = this.offsetTop;
2708 console.log('mouseenter ".$left.
" x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
2709 if ((window.innerWidth - x) < ".($widthofpopup + 10).
") {
2710 $('#moretabsList".$tabsname.
"').css('".$right.
"','8px');
2712 $('#moretabsList".$tabsname.
"').css('".$left.
"','auto');
2715 $out .=
"$('#moretabs".$tabsname.
"').mouseleave( function() { console.log('mouseleave ".$left.
"'); $('#moretabsList".$tabsname.
"').css('".$left.
"','-999em');});";
2716 $out .=
"</script>";
2719 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2723 if (!$notab || $notab == -1 || $notab == -2 || $notab == -3) {
2724 $out .=
"\n".
'<div id="dragDropAreaTabBar" class="tabBar'.($notab == -1 ?
'' : ($notab == -2 ?
' tabBarNoTop' : (($notab == -3 ?
' noborderbottom' :
'').
' tabBarWithBottom')));
2727 if (!empty($dragdropfile)) {
2728 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2731 $parameters = array(
'tabname' => $active,
'out' => $out);
2732 $reshook = $hookmanager->executeHooks(
'printTabsHead', $parameters);
2734 $out = $hookmanager->resPrint;
2760 if (!$notab || $notab == -1) {
2761 return "\n</div>\n";
2786function dol_banner_tab(
$object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $onlybanner = 0, $morehtmlright =
'')
2788 global $conf, $form, $user, $langs, $hookmanager, $action;
2792 $maxvisiblephotos = 1;
2794 $entity = (empty(
$object->entity) ? $conf->entity :
$object->entity);
2796 $showbarcode = !isModEnabled(
'barcode') ? 0 : (empty(
$object->barcode) ? 0 : 1);
2797 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2800 $modulepart =
'unknown';
2802 if (in_array(
$object->element, [
'societe',
'contact',
'product',
'ticket',
'bom'])) {
2803 $modulepart =
$object->element;
2804 } elseif (
$object->element ==
'member') {
2805 $modulepart =
'memberphoto';
2806 } elseif (
$object->element ==
'user') {
2807 $modulepart =
'userphoto';
2810 if (class_exists(
"Imagick")) {
2811 if (
$object->element ==
'expensereport' ||
$object->element ==
'propal' ||
$object->element ==
'commande' ||
$object->element ==
'facture' ||
$object->element ==
'supplier_proposal') {
2812 $modulepart =
$object->element;
2813 } elseif (
$object->element ==
'fichinter' ||
$object->element ==
'intervention') {
2814 $modulepart =
'ficheinter';
2815 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
2816 $modulepart =
'contract';
2817 } elseif (
$object->element ==
'order_supplier') {
2818 $modulepart =
'supplier_order';
2819 } elseif (
$object->element ==
'invoice_supplier') {
2820 $modulepart =
'supplier_invoice';
2824 if (
$object->element ==
'product') {
2826 '@phan-var-force Product $object';
2828 $cssclass =
'photowithmargin photoref';
2829 $showimage =
$object->is_photo_available($conf->product->multidir_output[$entity]);
2831 if ($conf->browser->layout ==
'phone') {
2832 $maxvisiblephotos = 1;
2835 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos(
'product', $conf->product->multidir_output[$entity], 1, $maxvisiblephotos, 0, 0, 0, 0, $width, 0,
'').
'</div>';
2839 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2841 $nophoto =
'/public/theme/common/nophoto.png';
2842 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" title="'.
dol_escape_htmltag($langs->trans(
"UploadAnImageToSeeAPhotoHere", $langs->transnoentitiesnoconv(
"Documents"))).
'" alt="No photo"'.($width ?
' style="width: '.$width.
'px"' :
'').
' src="'.DOL_URL_ROOT.$nophoto.
'"></div>';
2845 } elseif (
$object->element ==
'category') {
2847 '@phan-var-force Categorie $object';
2849 $cssclass =
'photowithmargin photoref';
2850 $showimage =
$object->isAnyPhotoAvailable($conf->categorie->multidir_output[$entity]);
2852 if ($conf->browser->layout ==
'phone') {
2853 $maxvisiblephotos = 1;
2856 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos(
'category', $conf->categorie->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, 0, $width, 0,
'').
'</div>';
2860 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2862 $nophoto =
'/public/theme/common/nophoto.png';
2863 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" title="'.
dol_escape_htmltag($langs->trans(
"UploadAnImageToSeeAPhotoHere", $langs->transnoentitiesnoconv(
"Documents"))).
'" alt="No photo"'.($width ?
' style="width: '.$width.
'px"' :
'').
' src="'.DOL_URL_ROOT.$nophoto.
'"></div>';
2866 } elseif (
$object->element ==
'bom') {
2868 '@phan-var-force Bom $object';
2870 $cssclass =
'photowithmargin photoref';
2871 $showimage =
$object->is_photo_available($conf->bom->multidir_output[$entity]);
2873 if ($conf->browser->layout ==
'phone') {
2874 $maxvisiblephotos = 1;
2877 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos(
'bom', $conf->bom->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, 0, $width, 0,
'').
'</div>';
2881 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2883 $nophoto =
'/public/theme/common/nophoto.png';
2884 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" title="'.
dol_escape_htmltag($langs->trans(
"UploadAnImageToSeeAPhotoHere", $langs->transnoentitiesnoconv(
"Documents"))).
'" alt="No photo"'.($width ?
' style="width: '.$width.
'px"' :
'').
' src="'.DOL_URL_ROOT.$nophoto.
'"></div>';
2887 } elseif (
$object->element ==
'ticket') {
2889 $cssclass =
'photoref';
2891 '@phan-var-force Ticket $object';
2892 $showimage =
$object->is_photo_available($conf->ticket->multidir_output[$entity].
'/'.
$object->ref);
2894 if ($conf->browser->layout ==
'phone') {
2895 $maxvisiblephotos = 1;
2899 $showphoto =
$object->show_photos(
'ticket', $conf->ticket->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0);
2901 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$showphoto.
'</div>';
2909 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2911 $nophoto =
img_picto(
'No photo',
'object_ticket');
2912 $morehtmlleft .=
'<!-- No photo to show -->';
2913 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2914 $morehtmlleft .= $nophoto;
2915 $morehtmlleft .=
'</div></div>';
2920 if ($modulepart !=
'unknown' || method_exists(
$object,
'getDataToShowPhoto')) {
2923 if (in_array($modulepart, array(
'propal',
'commande',
'facture',
'ficheinter',
'contract',
'supplier_order',
'supplier_proposal',
'supplier_invoice',
'expensereport')) && class_exists(
"Imagick")) {
2925 $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]).
"/";
2926 if (in_array($modulepart, array(
'invoice_supplier',
'supplier_invoice'))) {
2928 $subdir .= ((!empty($subdir) && !preg_match(
'/\/$/', $subdir)) ?
'/' :
'').$objectref;
2932 if (empty($subdir)) {
2933 $subdir =
'errorgettingsubdirofobject';
2936 $filepath = $dir_output.$subdir.
"/";
2938 $filepdf = $filepath.$objectref.
".pdf";
2939 $relativepath = $subdir.
'/'.$objectref.
'.pdf';
2942 $fileimage = $filepdf.
'_preview.png';
2943 $relativepathimage = $relativepath.
'_preview.png';
2945 $pdfexists = file_exists($filepdf);
2950 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2952 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2961 if ($pdfexists && !$error) {
2962 $heightforphotref = 80;
2963 if (!empty($conf->dol_optimize_smallscreen)) {
2964 $heightforphotref = 60;
2967 if (file_exists($fileimage)) {
2968 $phototoshow =
'<div class="photoref">';
2969 $phototoshow .=
'<img height="'.$heightforphotref.
'" class="photo photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2970 $phototoshow .=
'</div>';
2973 } elseif (!$phototoshow) {
2974 $phototoshow .= $form->showphoto($modulepart,
$object, 0, 0, 0,
'photowithmargin photoref',
'small', 1, 0, $maxvisiblephotos);
2978 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
2979 $morehtmlleft .= $phototoshow;
2980 $morehtmlleft .=
'</div>';
2984 if (empty($phototoshow)) {
2985 if (
$object->element ==
'action') {
2987 $cssclass =
'photorefcenter';
2988 $nophoto =
img_picto(
'No photo',
'title_agenda');
2991 $cssclass =
'photorefcenter';
2993 $prefix =
'object_';
2997 if (strpos($picto,
'fontawesome_') !==
false) {
3000 $nophoto =
img_picto(
'No photo', $prefix.$picto);
3002 $morehtmlleft .=
'<!-- No photo to show -->';
3003 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
3004 $morehtmlleft .= $nophoto;
3005 $morehtmlleft .=
'</div></div>';
3012 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode(
$object, 100,
'photoref valignmiddle').
'</div>';
3015 if (
$object->element ==
'societe') {
3016 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'societe',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3019 $morehtmlstatus .=
$object->getLibStatut(6);
3021 } elseif (
$object->element ==
'product') {
3023 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3024 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
3026 $morehtmlstatus .=
'<span class="statusrefsell">'.$object->getLibStatut(6, 0).
'</span>';
3028 $morehtmlstatus .=
' ';
3030 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3031 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
3033 $morehtmlstatus .=
'<span class="statusrefbuy">'.$object->getLibStatut(6, 1).
'</span>';
3035 } elseif (in_array(
$object->element, array(
'salary'))) {
3037 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3040 $morehtmlstatus .= $tmptxt;
3041 } elseif (in_array(
$object->element, array(
'facture',
'invoice',
'invoice_supplier',
'chargesociales',
'loan',
'tva'))) {
3043 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3046 $morehtmlstatus .= $tmptxt;
3047 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
3049 $morehtmlstatus .=
$object->getLibStatut(5);
3051 $morehtmlstatus .=
$object->getLibStatut(4);
3053 } elseif (
$object->element ==
'facturerec') {
3054 '@phan-var-force FactureRec $object';
3055 if (
$object->frequency == 0) {
3056 $morehtmlstatus .=
$object->getLibStatut(2);
3058 $morehtmlstatus .=
$object->getLibStatut(5);
3060 } elseif (
$object->element ==
'project_task') {
3067 if (
$object->progress >= 100) {
3071 $tmptxt =
$object->getLibStatut(5);
3072 $morehtmlstatus .= $tmptxt;
3073 } elseif (method_exists(
$object,
'getLibStatut')) {
3074 $tmptxt =
$object->getLibStatut(6);
3075 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3076 $tmptxt =
$object->getLibStatut(5);
3078 $morehtmlstatus .= $tmptxt;
3082 if (isModEnabled(
'accounting') && in_array(
$object->element, array(
'bank',
'paiementcharge',
'facture',
'invoice',
'invoice_supplier',
'expensereport',
'payment_various'))) {
3084 if (method_exists(
$object,
'getVentilExportCompta')) {
3085 $accounted =
$object->getVentilExportCompta();
3086 $langs->load(
"accountancy");
3087 $morehtmlstatus .=
'</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? $langs->trans(
"Accounted") : $langs->trans(
"NotYetAccounted")).
'</span>';
3092 if (!empty(
$object->name_alias)) {
3093 '@phan-var-force Societe $object';
3094 $morehtmlref .=
'<div class="refidno opacitymedium">'.dol_escape_htmltag(
$object->name_alias).
'</div>';
3098 if (in_array(
$object->element, array(
'product',
'bank_account',
'project_task'))) {
3100 $morehtmlref .=
'<div class="refidno opacitymedium">'.$object->label.
'</div>';
3104 if (method_exists(
$object,
'getBannerAddress') && !in_array(
$object->element, array(
'product',
'bookmark',
'ecm_directories',
'ecm_files'))) {
3107 $morehtmlref .=
'<div class="refidno refaddress">';
3108 $morehtmlref .= $moreaddress;
3109 $morehtmlref .=
'</div>';
3113 $morehtmlref .=
'<div style="clear: both;"></div>';
3114 $morehtmlref .=
'<div class="refidno opacitymedium">';
3115 $morehtmlref .= $langs->trans(
"TechnicalID").
': '.((int)
$object->id);
3116 $morehtmlref .=
'</div>';
3119 $parameters = array(
'morehtmlref' => &$morehtmlref,
'moreparam' => &$moreparam,
'morehtmlleft' => &$morehtmlleft,
'morehtmlstatus' => &$morehtmlstatus,
'morehtmlright' => &$morehtmlright);
3120 $reshook = $hookmanager->executeHooks(
'formDolBanner', $parameters,
$object, $action);
3123 } elseif (empty($reshook)) {
3124 $morehtmlref .= $hookmanager->resPrint;
3125 } elseif ($reshook > 0) {
3126 $morehtmlref = $hookmanager->resPrint;
3134 print
'<div class="'.($onlybanner ?
'arearefnobottom ' :
'arearef ').
'heightref valignmiddle centpercent">';
3135 print $form->showrefnav(
$object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
3137 print
'<div class="underrefbanner clearboth"></div>';
3149function fieldLabel($langkey, $fieldkey, $fieldrequired = 0)
3153 if ($fieldrequired) {
3154 $ret .=
'<span class="fieldrequired">';
3156 $ret .=
'<label for="'.$fieldkey.
'">';
3157 $ret .= $langs->trans($langkey);
3159 if ($fieldrequired) {
3172function dol_bc($var, $moreclass =
'')
3175 $ret =
' '.$bc[$var];
3177 $ret = preg_replace(
'/class=\"/',
'class="'.$moreclass.
' ', $ret);
3197 global $langs, $hookmanager;
3200 $countriesusingstate = array(
'AU',
'CA',
'US',
'IN',
'GB',
'ES',
'UK',
'TR',
'CN');
3205 $ret .= ($extralangcode ?
$object->array_languages[
'address'][$extralangcode] : (empty(
$object->address) ?
'' : preg_replace(
'/(\r\n|\r|\n)+/', $sep,
$object->address)));
3208 if (isset(
$object->country_code) && in_array(
$object->country_code, array(
'AU',
'CA',
'US',
'CN')) ||
getDolGlobalString(
'MAIN_FORCE_STATE_INTO_ADDRESS')) {
3210 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3211 $ret .= (($ret && $town) ? $sep :
'').$town;
3214 $ret .= ($ret ? ($town ?
", " : $sep) :
'').
$object->state;
3217 $ret .= ($ret ? (($town ||
$object->state) ?
", " : $sep) :
'').
$object->zip;
3219 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'GB',
'UK'))) {
3221 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3222 $ret .= ($ret ? $sep :
'').$town;
3224 $ret .= ($ret ?
", " :
'').
$object->state;
3227 $ret .= ($ret ? $sep :
'').
$object->zip;
3229 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'ES',
'TR'))) {
3231 $ret .= ($ret ? $sep :
'').
$object->zip;
3232 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3233 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3235 $ret .= $sep.$object->state;
3237 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'JP'))) {
3240 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3242 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'IT'))) {
3244 $ret .= ($ret ? $sep :
'').
$object->zip;
3245 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3246 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3247 $ret .= (empty(
$object->state_code) ?
'' : (
' '.$object->state_code));
3250 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3251 $ret .= !empty(
$object->zip) ? (($ret ? $sep :
'').
$object->zip) :
'';
3252 $ret .= ($town ? ((
$object->zip ?
' ' : ($ret ? $sep :
'')).$town) :
'');
3253 if (!empty(
$object->state) && in_array(
$object->country_code, $countriesusingstate)) {
3254 $ret .= ($ret ?
", " :
'').
$object->state;
3258 if (!is_object($outputlangs)) {
3259 $outputlangs = $langs;
3262 $langs->load(
"dict");
3263 $ret .= (empty(
$object->country_code) ?
'' : ($ret ? $sep :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$object->country_code)));
3266 $parameters = array(
'withcountry' => $withcountry,
'sep' => $sep,
'outputlangs' => $outputlangs,
'mode' => $mode,
'extralangcode' => $extralangcode);
3267 $reshook = $hookmanager->executeHooks(
'formatAddress', $parameters,
$object);
3271 $ret .= $hookmanager->resPrint;
3288function dol_strftime($fmt, $ts =
false, $is_gmt =
false)
3290 if ((abs($ts) <= 0x7FFFFFFF)) {
3293 return 'Error date outside supported range';
3318function dol_print_date($time, $format =
'', $tzoutput =
'auto', $outputlangs =
null, $encodetooutput =
false)
3320 global $conf, $langs;
3327 if ($tzoutput ===
'auto') {
3328 $tzoutput = (empty($conf) ?
'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey :
'tzserver'));
3333 $offsettz = $offsetdst = 0;
3336 if (is_string($tzoutput)) {
3337 if ($tzoutput ==
'tzserver') {
3339 $offsettzstring = @date_default_timezone_get();
3344 } elseif ($tzoutput ==
'tzuser' || $tzoutput ==
'tzuserrel') {
3346 $offsettzstring = (empty($_SESSION[
'dol_tz_string']) ?
'UTC' : $_SESSION[
'dol_tz_string']);
3348 if (class_exists(
'DateTimeZone')) {
3349 $user_date_tz =
new DateTimeZone($offsettzstring);
3350 $user_dt =
new DateTime();
3351 $user_dt->setTimezone($user_date_tz);
3352 $user_dt->setTimestamp($tzoutput ==
'tzuser' ?
dol_now() : (int) $time);
3353 $offsettz = $user_dt->getOffset();
3355 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3356 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3361 if (!is_object($outputlangs)) {
3362 $outputlangs = $langs;
3365 $format =
'daytextshort';
3370 $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array(
'day',
'dayhour',
'dayhoursec'))) ? 1 : 0;
3371 $format = preg_replace(
'/inputnoreduce/',
'', $format);
3372 $formatwithoutreduce = preg_replace(
'/reduceformat/',
'', $format);
3373 if ($formatwithoutreduce != $format) {
3374 $format = $formatwithoutreduce;
3380 if ($format ==
'day') {
3381 $format = ($outputlangs->trans(
"FormatDateShort") !=
"FormatDateShort" ? $outputlangs->trans(
"FormatDateShort") : $conf->format_date_short);
3382 } elseif ($format ==
'hour') {
3383 $format = ($outputlangs->trans(
"FormatHourShort") !=
"FormatHourShort" ? $outputlangs->trans(
"FormatHourShort") : $conf->format_hour_short);
3384 } elseif ($format ==
'hourduration') {
3385 $format = ($outputlangs->trans(
"FormatHourShortDuration") !=
"FormatHourShortDuration" ? $outputlangs->trans(
"FormatHourShortDuration") : $conf->format_hour_short_duration);
3386 } elseif ($format ==
'daytext') {
3387 $format = ($outputlangs->trans(
"FormatDateText") !=
"FormatDateText" ? $outputlangs->trans(
"FormatDateText") : $conf->format_date_text);
3388 } elseif ($format ==
'daytextshort') {
3389 $format = ($outputlangs->trans(
"FormatDateTextShort") !=
"FormatDateTextShort" ? $outputlangs->trans(
"FormatDateTextShort") : $conf->format_date_text_short);
3390 } elseif ($format ==
'dayhour') {
3391 $format = ($outputlangs->trans(
"FormatDateHourShort") !=
"FormatDateHourShort" ? $outputlangs->trans(
"FormatDateHourShort") : $conf->format_date_hour_short);
3392 } elseif ($format ==
'dayhoursec') {
3393 $format = ($outputlangs->trans(
"FormatDateHourSecShort") !=
"FormatDateHourSecShort" ? $outputlangs->trans(
"FormatDateHourSecShort") : $conf->format_date_hour_sec_short);
3394 } elseif ($format ==
'dayhourtext') {
3395 $format = ($outputlangs->trans(
"FormatDateHourText") !=
"FormatDateHourText" ? $outputlangs->trans(
"FormatDateHourText") : $conf->format_date_hour_text);
3396 } elseif ($format ==
'dayhourtextshort') {
3397 $format = ($outputlangs->trans(
"FormatDateHourTextShort") !=
"FormatDateHourTextShort" ? $outputlangs->trans(
"FormatDateHourTextShort") : $conf->format_date_hour_text_short);
3398 } elseif ($format ==
'dayhourlog') {
3400 $format =
'%Y%m%d%H%M%S';
3401 } elseif ($format ==
'dayhourlogsmall') {
3403 $format =
'%y%m%d%H%M';
3404 } elseif ($format ==
'dayhourldap') {
3405 $format =
'%Y%m%d%H%M%SZ';
3406 } elseif ($format ==
'dayhourxcard') {
3407 $format =
'%Y%m%dT%H%M%SZ';
3408 } elseif ($format ==
'dayxcard') {
3410 } elseif ($format ==
'dayrfc') {
3411 $format =
'%Y-%m-%d';
3412 } elseif ($format ==
'dayhourrfc') {
3413 $format =
'%Y-%m-%dT%H:%M:%SZ';
3414 } elseif ($format ==
'standard') {
3415 $format =
'%Y-%m-%d %H:%M:%S';
3418 if ($reduceformat) {
3419 $format = str_replace(
'%Y',
'%y', $format);
3420 $format = str_replace(
'yyyy',
'yy', $format);
3424 if (preg_match(
'/%b/i', $format)) {
3426 $format = str_replace(
'%b',
'__b__', $format);
3427 $format = str_replace(
'%B',
'__B__', $format);
3429 if (preg_match(
'/%a/i', $format)) {
3431 $format = str_replace(
'%a',
'__a__', $format);
3432 $format = str_replace(
'%A',
'__A__', $format);
3437 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', (
string) $time, $reg)) {
3438 dol_print_error(
null,
"Functions.lib::dol_print_date function called with a bad value from page ".(empty($_SERVER[
"PHP_SELF"]) ?
'unknown' : $_SERVER[
"PHP_SELF"]));
3440 } elseif (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', (
string) $time, $reg)) {
3442 dol_syslog(
"Functions.lib::dol_print_date function called with a bad value from page ".(empty($_SERVER[
"PHP_SELF"]) ?
'unknown' : $_SERVER[
"PHP_SELF"]), LOG_WARNING);
3445 $syear = (!empty($reg[1]) ? $reg[1] :
'');
3446 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
3447 $sday = (!empty($reg[3]) ? $reg[3] :
'');
3448 $shour = (!empty($reg[4]) ? $reg[4] :
'');
3449 $smin = (!empty($reg[5]) ? $reg[5] :
'');
3450 $ssec = (!empty($reg[6]) ? $reg[6] :
'');
3452 $time =
dol_mktime((
int) $shour, (
int) $smin, (
int) $ssec, (
int) $smonth, (
int) $sday, (
int) $syear,
true);
3455 $tzo =
new DateTimeZone(
'UTC');
3457 $tzo =
new DateTimeZone(date_default_timezone_get());
3459 $dtts =
new DateTime();
3460 $dtts->setTimestamp($time);
3461 $dtts->setTimezone($tzo);
3462 $newformat = str_replace(
3463 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3464 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3467 $ret = $dtts->format($newformat);
3469 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3470 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3475 if ($time < 100000000000) {
3476 $timetouse = $time + $offsettz + $offsetdst;
3479 $tzo =
new DateTimeZone(
'UTC');
3481 $tzo =
new DateTimeZone(date_default_timezone_get());
3483 $dtts =
new DateTime();
3484 $dtts->setTimestamp($timetouse);
3485 $dtts->setTimezone($tzo);
3486 $newformat = str_replace(
3487 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'%w',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3488 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'w',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3491 $ret = $dtts->format($newformat);
3493 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3494 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3499 $ret =
'Bad value '.$time.
' for date';
3503 if (preg_match(
'/__b__/i', $format)) {
3504 $timetouse = $time + $offsettz + $offsetdst;
3507 $tzo =
new DateTimeZone(
'UTC');
3509 $tzo =
new DateTimeZone(date_default_timezone_get());
3511 $dtts =
new DateTime();
3512 $dtts->setTimestamp($timetouse);
3513 $dtts->setTimezone($tzo);
3514 $month = (int) $dtts->format(
"m");
3515 $month = sprintf(
"%02d", $month);
3516 if ($encodetooutput) {
3517 $monthtext = $outputlangs->transnoentities(
'Month'.$month);
3518 $monthtextshort = $outputlangs->transnoentities(
'MonthShort'.$month);
3520 $monthtext = $outputlangs->transnoentitiesnoconv(
'Month'.$month);
3521 $monthtextshort = $outputlangs->transnoentitiesnoconv(
'MonthShort'.$month);
3524 $ret = str_replace(
'__b__', $monthtextshort, $ret);
3525 $ret = str_replace(
'__B__', $monthtext, $ret);
3529 if (preg_match(
'/__a__/i', $format)) {
3531 $timetouse = $time + $offsettz + $offsetdst;
3534 $tzo =
new DateTimeZone(
'UTC');
3536 $tzo =
new DateTimeZone(date_default_timezone_get());
3538 $dtts =
new DateTime();
3539 $dtts->setTimestamp($timetouse);
3540 $dtts->setTimezone($tzo);
3541 $w = $dtts->format(
"w");
3542 $dayweek = $outputlangs->transnoentitiesnoconv(
'Day'.$w);
3544 $ret = str_replace(
'__A__', $dayweek, $ret);
3545 $ret = str_replace(
'__a__',
dol_substr($dayweek, 0, 3), $ret);
3572function dol_getdate($timestamp, $fast =
false, $forcetimezone =
'')
3574 if ($timestamp ===
'') {
3578 $datetimeobj =
new DateTime();
3579 $datetimeobj->setTimestamp($timestamp);
3580 if ($forcetimezone) {
3581 $datetimeobj->setTimezone(
new DateTimeZone($forcetimezone ==
'gmt' ?
'UTC' : $forcetimezone));
3584 'year' => ((
int) date_format($datetimeobj,
'Y')),
3585 'mon' => ((
int) date_format($datetimeobj,
'm')),
3586 'mday' => ((
int) date_format($datetimeobj,
'd')),
3587 'wday' => ((
int) date_format($datetimeobj,
'w')),
3588 'yday' => ((
int) date_format($datetimeobj,
'z')),
3589 'hours' => ((
int) date_format($datetimeobj,
'H')),
3590 'minutes' => ((
int) date_format($datetimeobj,
'i')),
3591 'seconds' => ((
int) date_format($datetimeobj,
's')),
3619function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm =
'auto', $check = 1)
3624 if ($gm ===
'auto') {
3625 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
3630 if ($hour == -1 || empty($hour)) {
3633 if ($minute == -1 || empty($minute)) {
3636 if ($second == -1 || empty($second)) {
3642 if (!$month || !$day) {
3651 if ($hour < 0 || $hour > 24) {
3654 if ($minute < 0 || $minute > 60) {
3657 if ($second < 0 || $second > 60) {
3662 if (empty($gm) || ($gm ===
'server' || $gm ===
'tzserver')) {
3663 $default_timezone = @date_default_timezone_get();
3664 $localtz =
new DateTimeZone($default_timezone);
3665 } elseif ($gm ===
'user' || $gm ===
'tzuser' || $gm ===
'tzuserrel') {
3667 $default_timezone = (empty($_SESSION[
"dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION[
"dol_tz_string"]);
3669 $localtz =
new DateTimeZone($default_timezone);
3671 dol_syslog(
"Warning dol_tz_string contains an invalid value ".json_encode($_SESSION[
"dol_tz_string"] ??
null), LOG_WARNING);
3672 $default_timezone = @date_default_timezone_get();
3674 } elseif (strrpos($gm,
"tz,") !==
false) {
3675 $timezone = str_replace(
"tz,",
"", $gm);
3677 $localtz =
new DateTimeZone($timezone);
3679 dol_syslog(
"Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
3683 if (empty($localtz)) {
3684 $localtz =
new DateTimeZone(
'UTC');
3688 $dt =
new DateTime(
'now', $localtz);
3689 $dt->setDate((
int) $year, (
int) $month, (
int) $day);
3690 $dt->setTime((
int) $hour, (
int) $minute, (
int) $second);
3691 $date = $dt->getTimestamp();
3707function dol_now($mode =
'auto')
3711 if ($mode ===
'auto') {
3715 if ($mode ==
'gmt') {
3717 } elseif ($mode ==
'tzserver') {
3718 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
3720 $ret = (int) (
dol_now(
'gmt') + ($tzsecond * 3600));
3726 } elseif ($mode ==
'tzuser' || $mode ==
'tzuserrel') {
3729 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3730 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3731 $ret = (int) (
dol_now(
'gmt') + ($offsettz + $offsetdst));
3748 global $conf, $langs;
3751 if (!empty($conf->dol_optimize_smallscreen)) {
3756 if (empty($shortvalue) || $size < ($level * 10)) {
3758 $textunitshort = $langs->trans(
"b");
3759 $textunitlong = $langs->trans(
"Bytes");
3761 $ret = round($size / $level, 0);
3762 $textunitshort = $langs->trans(
"Kb");
3763 $textunitlong = $langs->trans(
"KiloBytes");
3766 if (empty($shortunit)) {
3767 $ret .=
' '.$textunitlong;
3769 $ret .=
' '.$textunitshort;
3785function dol_print_url($url, $target =
'_blank', $max = 32, $withpicto = 0, $morecss =
'')
3793 $linkstart =
'<a href="';
3794 if (!preg_match(
'/^http/i', $url)) {
3795 $linkstart .=
'http://';
3800 $linkstart .=
' target="'.$target.
'"';
3802 $linkstart .=
' title="'.$langs->trans(
"URL").
': '.$url.
'"';
3806 if (!preg_match(
'/^http/i', $url)) {
3813 if ($morecss ==
'float') {
3814 return '<div class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe',
'class="paddingrightonly"') :
'').$link.
'</div>';
3816 return $linkstart.
'<span class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto(
'',
'globe',
'class="paddingrightonly"') :
'').$link.
'</span>'.$linkend;
3833function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0, $morecss =
'paddingrightonly')
3835 global $user, $langs, $hookmanager;
3846 if (empty($email)) {
3850 if ($addlink == 1) {
3851 $newemail =
'<a class="'.($morecss ? $morecss :
'').
'" style="text-overflow: ellipsis;" href="';
3852 if (!preg_match(
'/^mailto:/i', $email)) {
3853 $newemail .=
'mailto:';
3855 $newemail .= $email;
3858 $newemail .= ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'');
3863 $newemail .= $email;
3865 $newemail .=
'</a>';
3867 $langs->load(
"errors");
3868 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email),
'',
'paddingrightonly');
3871 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
3873 $linktoaddaction =
'';
3875 $linktoaddaction =
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&backtopage=1&actioncode='.urlencode($type).
'&contactid='.((int) $cid).
'&socid='.((int) $socid).
'">'.
img_object($langs->trans(
"AddAction"),
"calendar").
'</a>';
3877 if ($linktoaddaction) {
3878 $newemail =
'<div>'.$newemail.
' '.$linktoaddaction.
'</div>';
3881 } elseif ($addlink ===
'thirdparty') {
3882 $tmpnewemail =
'<a class="'.($morecss ? $morecss :
'').
'" style="text-overflow: ellipsis;" href="'.DOL_URL_ROOT.
'/societe/card.php?socid='.$socid.
'&action=presend&mode=init#formmailbeforetitle">';
3883 $tmpnewemail .= ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'');
3884 if ($withpicto == 1) {
3885 $tmpnewemail .= $newemail;
3887 $tmpnewemail .=
'</a>';
3889 $newemail = $tmpnewemail;
3891 $newemail = ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'').$newemail;
3894 $langs->load(
"errors");
3895 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
3905 $parameters = array(
'cid' => $cid,
'socid' => $socid,
'addlink' => $addlink,
'picto' => $withpicto);
3907 $reshook = $hookmanager->executeHooks(
'printEmail', $parameters, $email);
3911 $rep .= $hookmanager->resPrint;
3926 $socialnetworks = array();
3928 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
3929 $cachekey =
'socialnetworks_' . $conf->entity;
3931 if (!is_null($dataretrieved)) {
3932 $socialnetworks = $dataretrieved;
3934 $sql =
"SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX.
"c_socialnetworks";
3935 $sql .=
" WHERE entity=".$conf->entity;
3936 $resql = $db->query($sql);
3938 while ($obj = $db->fetch_object($resql)) {
3939 $socialnetworks[$obj->code] = array(
3940 'rowid' => $obj->rowid,
3941 'label' => $obj->label,
3943 'icon' => $obj->icon,
3944 'active' => $obj->active,
3950 return $socialnetworks;
3965 global $hookmanager, $langs, $user;
3969 if (empty($value)) {
3973 if (!empty($type)) {
3974 $htmllink =
'<div class="divsocialnetwork inline-block valignmiddle">';
3976 $htmllink .=
'<span class="fab pictofixedwidth '.($dictsocialnetworks[$type][
'icon'] ? $dictsocialnetworks[$type][
'icon'] :
'fa-link').
'"></span>';
3977 if ($type ==
'skype') {
3979 $htmllink .=
' <a href="skype:';
3981 $htmllink .=
'?call" alt="'.$langs->trans(
"Call").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Call").
' '.$value).
'">';
3982 $htmllink .=
'<img src="'.DOL_URL_ROOT.
'/theme/common/skype_callbutton.png" border="0">';
3983 $htmllink .=
'</a><a href="skype:';
3985 $htmllink .=
'?chat" alt="'.$langs->trans(
"Chat").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Chat").
' '.$value).
'">';
3986 $htmllink .=
'<img class="paddingleft" src="'.DOL_URL_ROOT.
'/theme/common/skype_chatbutton.png" border="0">';
3987 $htmllink .=
'</a>';
3988 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
3989 $addlink =
'AC_SKYPE';
3992 $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>';
3994 $htmllink .= ($link ?
' '.$link :
'');
3997 $networkconstname =
'MAIN_INFO_SOCIETE_'.strtoupper($type).
'_URL';
4000 if (preg_match(
'/^https?:\/\//i', $link)) {
4001 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
4003 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
4005 } elseif (!empty($dictsocialnetworks[$type][
'url'])) {
4006 $tmpvirginurl = preg_replace(
'/\/?{socialid}/',
'', $dictsocialnetworks[$type][
'url']);
4007 if ($tmpvirginurl) {
4008 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
4009 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
4011 $tmpvirginurl3 = preg_replace(
'/^https:\/\//i',
'https://www.', $tmpvirginurl);
4012 if ($tmpvirginurl3) {
4013 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
4014 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
4017 $tmpvirginurl2 = preg_replace(
'/^https?:\/\//i',
'', $tmpvirginurl);
4018 if ($tmpvirginurl2) {
4019 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
4020 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
4023 $link = str_replace(
'{socialid}', $value, $dictsocialnetworks[$type][
'url']);
4024 if (preg_match(
'/^https?:\/\//i', $link)) {
4025 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
4027 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
4033 $htmllink .=
'</div>';
4035 $langs->load(
"errors");
4036 $htmllink .=
img_warning($langs->trans(
"ErrorBadSocialNetworkValue", $value));
4040 $parameters = array(
4045 'dictsocialnetworks' => $dictsocialnetworks,
4048 $reshook = $hookmanager->executeHooks(
'printSocialNetworks', $parameters);
4052 $htmllink .= $hookmanager->resPrint;
4067function dol_print_profids($profID, $profIDtype, $countrycode =
'', $addcpButton = 1)
4071 if (empty($profID) || empty($profIDtype)) {
4074 if (empty($countrycode)) {
4075 $countrycode = $mysoc->country_code;
4077 $newProfID = $profID;
4078 $id = substr($profIDtype, -1);
4080 if (strtoupper($countrycode) ==
'FR') {
4086 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3);
4090 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3).
' '.substr($newProfID, 9, 5);
4094 $newProfID = substr($newProfID, 0, 2).
'.'.substr($newProfID, 2, 3);
4096 if ($profIDtype ===
'VAT' &&
dol_strlen($newProfID) == 13) {
4098 $newProfID = substr($newProfID, 0, 4).
' '.substr($newProfID, 4, 3).
' '.substr($newProfID, 7, 3).
' '.substr($newProfID, 10, 3);
4101 if (!empty($addcpButton)) {
4124function dol_print_phone($phone, $countrycode =
'', $cid = 0, $socid = 0, $addlink =
'', $separ =
" ", $withpicto =
'', $titlealt =
'', $adddivfloat = 0, $morecss =
'paddingright')
4126 global $conf, $user, $langs, $mysoc, $hookmanager;
4129 $phone = is_null($phone) ?
'' : preg_replace(
"/[\s.-]/",
"", trim($phone));
4130 if (empty($phone)) {
4136 if (empty($countrycode) && is_object($mysoc)) {
4137 $countrycode = $mysoc->country_code;
4141 if (!empty($conf->dol_optimize_smallscreen) && $separ !=
'hidenum') {
4146 $newphonewa = $phone;
4147 if (strtoupper($countrycode) ==
"FR") {
4150 $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);
4152 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
4154 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
4156 $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);
4158 $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);
4160 $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);
4162 } elseif (strtoupper($countrycode) ==
"CA") {
4164 $newphone = ($separ !=
'' ?
'(' :
'').substr($newphone, 0, 3).($separ !=
'' ?
')' :
'').$separ.substr($newphone, 3, 3).($separ !=
'' ?
'-' :
'').substr($newphone, 6, 4);
4166 } elseif (strtoupper($countrycode) ==
"PT") {
4168 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4170 } elseif (strtoupper($countrycode) ==
"SR") {
4172 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
4174 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
4176 } elseif (strtoupper($countrycode) ==
"DE") {
4178 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
4180 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
4182 } elseif (strtoupper($countrycode) ==
"ES") {
4184 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4186 } elseif (strtoupper($countrycode) ==
"BF") {
4188 $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);
4190 } elseif (strtoupper($countrycode) ==
"RO") {
4192 $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);
4194 } elseif (strtoupper($countrycode) ==
"TR") {
4196 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4198 } elseif (strtoupper($countrycode) ==
"US") {
4200 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4202 } elseif (strtoupper($countrycode) ==
"MX") {
4204 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4206 $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);
4208 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4210 } elseif (strtoupper($countrycode) ==
"ML") {
4212 $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);
4214 } elseif (strtoupper($countrycode) ==
"TH") {
4216 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4218 $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);
4220 } elseif (strtoupper($countrycode) ==
"MU") {
4223 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
4225 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4227 } elseif (strtoupper($countrycode) ==
"ZA") {
4229 $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);
4231 } elseif (strtoupper($countrycode) ==
"SY") {
4233 $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);
4235 $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);
4237 } elseif (strtoupper($countrycode) ==
"AE") {
4239 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4241 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4243 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
4245 } elseif (strtoupper($countrycode) ==
"DZ") {
4247 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4249 } elseif (strtoupper($countrycode) ==
"BE") {
4251 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4253 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4255 } elseif (strtoupper($countrycode) ==
"PF") {
4257 $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);
4259 } elseif (strtoupper($countrycode) ==
"CO") {
4261 $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);
4263 } elseif (strtoupper($countrycode) ==
"JO") {
4265 $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);
4267 } elseif (strtoupper($countrycode) ==
"JM") {
4269 $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4271 } elseif (strtoupper($countrycode) ==
"MG") {
4273 $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);
4275 } elseif (strtoupper($countrycode) ==
"GB") {
4277 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4279 } elseif (strtoupper($countrycode) ==
"CH") {
4281 $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);
4283 $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);
4285 } elseif (strtoupper($countrycode) ==
"TN") {
4287 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4289 } elseif (strtoupper($countrycode) ==
"GF") {
4291 $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);
4293 } elseif (strtoupper($countrycode) ==
"GP") {
4295 $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);
4297 } elseif (strtoupper($countrycode) ==
"MQ") {
4299 $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);
4301 } elseif (strtoupper($countrycode) ==
"IT") {
4303 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4305 $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);
4307 } elseif (strtoupper($countrycode) ==
"AU") {
4311 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
4313 } elseif (strtoupper($countrycode) ==
"LU") {
4316 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
4318 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 1);
4320 $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);
4322 $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);
4324 } elseif (strtoupper($countrycode) ==
"PE") {
4327 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4);
4329 $newphonewa =
'+51'.$newphone;
4330 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 10, 3);
4332 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 8, 4);
4334 $newphonewa = $newphone;
4335 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 10, 3).$separ.substr($newphone, 14, 3);
4339 $newphoneastart = $newphoneaend =
'';
4340 if (!empty($addlink)) {
4341 if ($addlink ==
'tel' || $conf->browser->layout ==
'phone' || (isModEnabled(
'clicktodial') &&
getDolGlobalString(
'CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS'))) {
4342 $newphoneastart =
'<a href="tel:'.urlencode($phone).
'">';
4343 $newphoneaend .=
'</a>';
4344 } elseif (isModEnabled(
'clicktodial') && $addlink ==
'AC_TEL') {
4345 if (empty($user->clicktodial_loaded)) {
4346 $user->fetch_clicktodial();
4350 $urlmask =
getDolGlobalString(
'CLICKTODIAL_URL',
'ErrorClickToDialModuleNotConfigured');
4351 if (!empty($user->clicktodial_url)) {
4352 $urlmask = $user->clicktodial_url;
4355 $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) :
'');
4356 $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) :
'');
4357 $clicktodial_password = (!empty($user->clicktodial_password) ? urlencode($user->clicktodial_password) :
'');
4359 $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
4361 $substitarray = array(
'__PHONEFROM__' => $clicktodial_poste,
4362 '__PHONETO__' => urlencode($phone),
4363 '__LOGIN__' => $clicktodial_login,
4364 '__PASS__' => $clicktodial_password);
4368 $newphoneastart =
'<a href="'.$url.
'" class="cssforclicktodial">';
4369 $newphoneaend =
'</a>';
4372 $newphoneastart =
'<a href="'.$url.
'"';
4374 $newphoneastart .=
' target="_blank" rel="noopener noreferrer"';
4376 $newphoneastart .=
'>';
4377 $newphoneaend .=
'</a>';
4382 if (isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
4384 $addlinktoagenda =
'';
4385 if ($addlink ==
'AC_FAX') {
4389 $addlinktoagenda =
'<a href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&backtopage='. urlencode($_SERVER[
'REQUEST_URI']) .
'&actioncode='.$type.($cid ?
'&contactid='.$cid :
'').($socid ?
'&socid='.$socid :
'').
'">'.
img_object($langs->trans(
"AddAction"),
"calendar").
'</a>';
4391 if ($addlinktoagenda) {
4392 $newphone =
'<span>'.$newphone.
' '.$addlinktoagenda.
'</span>';
4397 if (
getDolGlobalString(
'CONTACT_PHONEMOBILE_SHOW_LINK_TO_WHATSAPP') && $withpicto ==
'mobile') {
4399 $newphone .=
' <a href="https://wa.me/'.$newphonewa.
'" target="_blank"';
4400 $newphone .=
'><span class="paddingright fab fa-whatsapp" style="color:#25D366;" title="WhatsApp"></span></a>';
4403 if (empty($titlealt)) {
4404 $titlealt = ($withpicto ==
'fax' ? $langs->trans(
"Fax") : $langs->trans(
"Phone"));
4409 $parameters = array(
'countrycode' => $countrycode,
'cid' => $cid,
'socid' => $socid,
'titlealt' => $titlealt,
'picto' => $withpicto);
4410 $reshook = $hookmanager->executeHooks(
'printPhone', $parameters, $phone);
4411 $rep .= $hookmanager->resPrint;
4413 if (empty($reshook)) {
4416 if ($withpicto ==
'fax') {
4417 $picto =
'phoning_fax';
4418 } elseif ($withpicto ==
'phone') {
4420 } elseif ($withpicto ==
'mobile') {
4421 $picto =
'phoning_mobile';
4426 if ($adddivfloat == 1) {
4427 $rep .=
'<div class="nospan float'.($morecss ?
' '.$morecss :
'').
'">';
4428 } elseif (empty($adddivfloat)) {
4429 $rep .=
'<span'.($morecss ?
' class="'.$morecss.
'"' :
'').
'>';
4432 $rep .= $newphoneastart;
4433 $rep .= ($withpicto ?
img_picto($titlealt,
'object_'.$picto.
'.png') :
'');
4434 if ($separ !=
'hidenum') {
4435 $rep .= ($withpicto ?
' ' :
'').$newphone;
4437 $rep .= $newphoneaend;
4439 if ($adddivfloat == 1) {
4441 } elseif (empty($adddivfloat)) {
4469 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/common/flags/'.$countrycode.
'.png')) {
4470 $ret .=
' '.img_picto($countrycode.
' '.$langs->trans(
"AccordingToGeoIPDatabase"), DOL_URL_ROOT.
'/theme/common/flags/'.$countrycode.
'.png',
'', 1);
4472 $ret .=
' ('.$countrycode.
')';
4492 if (empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
4493 if (empty($_SERVER[
'HTTP_CLIENT_IP']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_CLIENT_IP'])) {
4494 if (empty($_SERVER[
"HTTP_CF_CONNECTING_IP"])) {
4495 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
4497 $ip = $_SERVER[
"HTTP_CF_CONNECTING_IP"];
4500 $ip = $_SERVER[
'HTTP_CLIENT_IP'];
4503 $ip = $_SERVER[
'HTTP_X_FORWARDED_FOR'];
4519 if (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on') {
4521 } 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') {
4539 if (!empty($conf->geoipmaxmind->enabled)) {
4543 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4544 $geoip =
new DolGeoIP(
'country', $datafile);
4546 $countrycode = $geoip->getCountryCodeFromIP($ip);
4549 return $countrycode;
4561 global $conf, $langs, $user;
4565 if (!empty($conf->geoipmaxmind->enabled)) {
4570 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4571 $geoip =
new DolGeoIP(
'country', $datafile);
4572 $countrycode = $geoip->getCountryCodeFromIP($ip);
4573 $ret = $countrycode;
4592 global $conf, $user, $langs, $hookmanager;
4598 $parameters = array(
'element' => $element,
'id' =>
$id);
4599 $reshook = $hookmanager->executeHooks(
'printAddress', $parameters, $address);
4600 $out .= $hookmanager->resPrint;
4602 if (empty($reshook)) {
4603 if (empty($charfornl)) {
4604 $out .= nl2br($address);
4606 $out .= preg_replace(
'/[\r\n]+/', $charfornl, $address);
4610 $showgmap = $showomap = 0;
4611 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS')) {
4614 if ($element ==
'contact' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_CONTACTS')) {
4617 if ($element ==
'member' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_MEMBERS')) {
4620 if ($element ==
'user' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_USERS')) {
4623 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS')) {
4626 if ($element ==
'contact' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_CONTACTS')) {
4629 if ($element ==
'member' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_MEMBERS')) {
4632 if ($element ==
'user' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_USERS')) {
4637 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4640 $url =
dol_buildpath(
'/openstreetmap/maps.php?mode='.$element.
'&id='.
$id, 1);
4641 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4663function isValidEmail($address, $acceptsupervisorkey = 0, $acceptuserkey = 0)
4665 if ($acceptsupervisorkey && $address ==
'__SUPERVISOREMAIL__') {
4668 if ($acceptuserkey && $address ==
'__USER_EMAIL__') {
4671 if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
4689 if (function_exists(
'idn_to_ascii') && function_exists(
'checkdnsrr')) {
4690 if (!checkdnsrr(idn_to_ascii($domain),
'MX')) {
4693 if (function_exists(
'getmxrr')) {
4696 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
4697 if (count($mxhosts) > 1) {
4700 if (count($mxhosts) == 1 && !in_array((
string) $mxhosts[0], array(
'',
'.'))) {
4737 $tmparray = explode(
' ', $s);
4738 foreach ($tmparray as $tmps) {
4753function dol_strlen($string, $stringencoding =
'UTF-8')
4755 if (is_null($string)) {
4759 if (function_exists(
'mb_strlen')) {
4760 return mb_strlen($string, $stringencoding);
4762 return strlen($string);
4776function dol_substr($string, $start, $length =
null, $stringencoding =
'', $trunconbytes = 0)
4780 if (empty($stringencoding)) {
4781 $stringencoding = (empty($langs) ?
'UTF-8' : $langs->charset_output);
4785 if (empty($trunconbytes)) {
4786 if (function_exists(
'mb_substr')) {
4787 $ret = mb_substr($string, $start, $length, $stringencoding);
4789 $ret = substr($string, $start, $length);
4792 if (function_exists(
'mb_strcut')) {
4793 $ret = mb_strcut($string, $start, $length, $stringencoding);
4795 $ret = substr($string, $start, $length);
4815function dol_trunc($string, $size = 40, $trunc =
'right', $stringencoding =
'UTF-8', $nodot = 0, $display = 0)
4823 if (empty($stringencoding)) {
4824 $stringencoding =
'UTF-8';
4827 if (!empty($conf->dol_optimize_smallscreen) && $conf->dol_optimize_smallscreen == 1 && $display == 1) {
4828 $size = round($size / 3);
4832 if ($trunc ==
'right') {
4834 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
4836 return dol_substr($newstring, 0, $size, $stringencoding).($nodot ?
'' :
'…');
4841 } elseif ($trunc ==
'middle') {
4843 if (
dol_strlen($newstring, $stringencoding) > 2 &&
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4844 $size1 = round($size / 2);
4845 $size2 = round($size / 2);
4846 return dol_substr($newstring, 0, $size1, $stringencoding).
'…'.
dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
4850 } elseif ($trunc ==
'left') {
4852 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
4854 return '…'.dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
4858 } elseif ($trunc ==
'wrap') {
4860 if (
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4866 return 'BadParam3CallingDolTrunc';
4880 $type2picto = array(
4881 'varchar' =>
'font',
4884 'int' =>
'sort-numeric-down',
4885 'double' =>
'sort-numeric-down',
4886 'price' =>
'currency',
4887 'pricecy' =>
'multicurrency',
4888 'password' =>
'key',
4889 'boolean' =>
'check-square',
4890 'date' =>
'calendar',
4891 'datetime' =>
'calendar',
4897 'sellist' =>
'list',
4898 'radio' =>
'check-circle',
4899 'checkbox' =>
'list',
4900 'chkbxlst' =>
'list',
4902 'icon' =>
"question",
4903 'point' =>
"country",
4904 'multipts' =>
'country',
4905 'linestrg' =>
"country",
4906 'polygon' =>
"country",
4907 'separate' =>
'minus'
4910 if (!empty($type2picto[$key])) {
4911 return img_picto(
'', $type2picto[$key],
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
4914 return img_picto(
'',
'generic',
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
4939function img_picto($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0, $alt =
'', $morecss =
'', $marginleftonlyshort = 2)
4944 $url = DOL_URL_ROOT;
4945 $theme = isset($conf->theme) ? $conf->theme :
null;
4946 $path =
'theme/'.$theme;
4947 if (empty($picto)) {
4952 if ($pictoisfullpath) {
4954 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
4957 $fullpathpicto = $picto;
4959 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4960 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4961 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4966 $pictowithouttext = preg_replace(
'/(\.png|\.gif|\.svg)$/',
'', $picto);
4967 $pictowithouttext = str_replace(
'object_',
'', $pictowithouttext);
4968 $pictowithouttext = str_replace(
'_nocolor',
'', $pictowithouttext);
4971 $pictoconvertkey = array(
'facture' =>
'bill',
'shipping' =>
'shipment',
'fichinter' =>
'intervention',
'agenda' =>
'calendar',
'invoice_supplier' =>
'supplier_invoice',
'order_supplier' =>
'supplier_order');
4972 if (in_array($pictowithouttext, array_keys($pictoconvertkey))) {
4973 $pictowithouttext = $pictoconvertkey[$pictowithouttext];
4976 if (strpos($pictowithouttext,
'fontawesome_') === 0 || strpos($pictowithouttext,
'fa-') === 0) {
4978 $pictowithouttext = str_replace(
'fontawesome_',
'', $pictowithouttext);
4979 $pictowithouttext = str_replace(
'fa-',
'', $pictowithouttext);
4982 if ($pictowithouttext ==
'file-o') {
4983 $pictowithouttext =
'file';
4986 $pictowithouttextarray = explode(
'_', $pictowithouttext);
4987 $marginleftonlyshort = 0;
4989 if (!empty($pictowithouttextarray[1])) {
4991 $fakey =
'fa-'.$pictowithouttextarray[0];
4992 $faprefix = empty($pictowithouttextarray[1]) ?
'fas' : $pictowithouttextarray[1];
4993 $facolor = empty($pictowithouttextarray[2]) ?
'' : $pictowithouttextarray[2];
4994 $fasize = empty($pictowithouttextarray[3]) ?
'' : $pictowithouttextarray[3];
4996 $fakey =
'fa-'.$pictowithouttext;
5006 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5007 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5008 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5010 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
5011 $morestyle = $reg[1];
5012 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
5014 $moreatt = trim($moreatt);
5016 $enabledisablehtml =
'<span class="'.$faprefix.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
5017 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
5021 $enabledisablehtml .=
'</span>';
5023 return $enabledisablehtml;
5026 if (empty($srconly) && in_array($pictowithouttext, array(
5027 '1downarrow',
'1uparrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected',
5028 'accountancy',
'accounting_account',
'account',
'accountline',
'action',
'add',
'address',
'ai',
'angle-double-down',
'angle-double-up',
'asset',
5029 'bank_account',
'barcode',
'bank',
'bell',
'bill',
'billa',
'billr',
'billd',
'birthday-cake',
'bom',
'bookcal',
'bookmark',
'briefcase-medical',
'bug',
'building',
5030 'card',
'calendarlist',
'calendar',
'calendarmonth',
'calendarweek',
'calendarday',
'calendarperuser',
'calendarpertype',
5031 'cash-register',
'category',
'chart',
'check',
'clock',
'clone',
'close_title',
'code',
'cog',
'collab',
'company',
'contact',
'country',
'contract',
'conversation',
'cron',
'cross',
'cubes',
5032 'check-circle',
'check-square',
'circle',
'stop-circle',
'currency',
'multicurrency',
5033 'chevron-left',
'chevron-right',
'chevron-down',
'chevron-top',
5034 'chevron-double-left',
'chevron-double-right',
'chevron-double-down',
'chevron-double-top',
5035 'commercial',
'companies',
5036 'delete',
'dolly',
'dollyrevert',
'donation',
'download',
'dynamicprice',
5037 'edit',
'ellipsis-h',
'email',
'entity',
'envelope',
'eraser',
'establishment',
'expensereport',
'external-link-alt',
'external-link-square-alt',
'eye',
5038 'filter',
'file',
'file-o',
'file-code',
'file-export',
'file-import',
'file-upload',
'autofill',
'folder',
'folder-open',
'folder-plus',
'font',
5039 'gears',
'generate',
'generic',
'globe',
'globe-americas',
'graph',
'grip',
'grip_title',
'group',
5040 'hands-helping',
'help',
'holiday',
5041 'id-card',
'images',
'incoterm',
'info',
'intervention',
'inventory',
'intracommreport',
'jobprofile',
5042 'key',
'knowledgemanagement',
5043 'label',
'language',
'layout',
'line',
'link',
'list',
'list-alt',
'listlight',
'loan',
'lock',
'lot',
'long-arrow-alt-right',
5044 'margin',
'map-marker-alt',
'member',
'meeting',
'minus',
'money-bill-alt',
'movement',
'mrp',
'note',
'next',
5045 'off',
'on',
'order',
5046 'paiment',
'paragraph',
'play',
'pdf',
'phone',
'phoning',
'phoning_mobile',
'phoning_fax',
'playdisabled',
'previous',
'poll',
'pos',
'printer',
'product',
'propal',
'proposal',
'puce',
5047 'stock',
'resize',
'service',
'stats',
5048 'security',
'setup',
'share-alt',
'sign-out',
'split',
'stripe',
'stripe-s',
'switch_off',
'switch_on',
'switch_on_grey',
'switch_on_warning',
'switch_on_red',
'tools',
'unlink',
'uparrow',
'user',
'user-tie',
'vcard',
'wrench',
5049 'github',
'google',
'jabber',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'youtube',
'google-plus-g',
'whatsapp',
5050 'generic',
'home',
'hrm',
'members',
'products',
'invoicing',
5051 'partnership',
'payment',
'payment_vat',
'pencil-ruler',
'pictoconfirm',
'preview',
'project',
'projectpub',
'projecttask',
'question',
'refresh',
'region',
5052 'salary',
'shipment',
'state',
'supplier_invoice',
'supplier_invoicea',
'supplier_invoicer',
'supplier_invoiced',
5053 'technic',
'ticket',
5055 'recent',
'reception',
'recruitmentcandidature',
'recruitmentjobposition',
'replacement',
'resource',
'recurring',
'rss',
5056 'shapes',
'skill',
'square',
'sort-numeric-down',
'status',
'stop-circle',
'supplier',
'supplier_proposal',
'supplier_order',
'supplier_invoice',
5057 'terminal',
'tick',
'timespent',
'title_setup',
'title_accountancy',
'title_bank',
'title_hrm',
'title_agenda',
'trip',
5058 'uncheck',
'undo',
'url',
'user-cog',
'user-injured',
'user-md',
'vat',
'website',
'workstation',
'webhook',
'world',
'private',
5059 'conferenceorbooth',
'eventorganization',
5060 'stamp',
'signature',
5063 $fakey = $pictowithouttext;
5067 if (in_array($pictowithouttext, array(
'card',
'bell',
'clock',
'establishment',
'file',
'file-o',
'generic',
'minus-square',
'object_generic',
'pdf',
'plus-square',
'timespent',
'note',
'off',
'on',
'object_bookmark',
'bookmark',
'vcard'))) {
5070 if (in_array($pictowithouttext, array(
'black-tie',
'github',
'google',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'stripe',
'stripe-s',
'youtube',
'google-plus-g',
'whatsapp'))) {
5074 $arrayconvpictotofa = array(
5075 'account' =>
'university',
'accounting_account' =>
'clipboard-list',
'accountline' =>
'receipt',
'accountancy' =>
'search-dollar',
'action' =>
'calendar-alt',
'add' =>
'plus-circle',
'address' =>
'address-book',
'ai' =>
'magic',
5076 'asset' =>
'money-check-alt',
'autofill' =>
'fill',
5077 'bank_account' =>
'university',
5078 'bill' =>
'file-invoice-dollar',
'billa' =>
'file-excel',
'billr' =>
'file-invoice-dollar',
'billd' =>
'file-medical',
5079 'bookcal' =>
'calendar-check',
5080 'supplier_invoice' =>
'file-invoice-dollar',
'supplier_invoicea' =>
'file-excel',
'supplier_invoicer' =>
'file-invoice-dollar',
'supplier_invoiced' =>
'file-medical',
5082 'card' =>
'address-card',
'chart' =>
'chart-line',
'company' =>
'building',
'contact' =>
'address-book',
'contract' =>
'suitcase',
'collab' =>
'people-arrows',
'conversation' =>
'comments',
'country' =>
'globe-americas',
'cron' =>
'business-time',
'cross' =>
'times',
5083 'chevron-double-left' =>
'angle-double-left',
'chevron-double-right' =>
'angle-double-right',
'chevron-double-down' =>
'angle-double-down',
'chevron-double-top' =>
'angle-double-up',
5084 'donation' =>
'file-alt',
'dynamicprice' =>
'hand-holding-usd',
5085 'setup' =>
'cog',
'companies' =>
'building',
'products' =>
'cube',
'commercial' =>
'suitcase',
'invoicing' =>
'coins',
5086 'accounting' =>
'search-dollar',
'category' =>
'tag',
'dollyrevert' =>
'dolly',
5087 'file-o' =>
'file',
'generate' =>
'plus-square',
'hrm' =>
'user-tie',
'incoterm' =>
'truck-loading',
5088 'margin' =>
'calculator',
'members' =>
'user-friends',
'ticket' =>
'ticket-alt',
'globe' =>
'external-link-alt',
'lot' =>
'barcode',
5089 'email' =>
'at',
'establishment' =>
'building',
'edit' =>
'pencil-alt',
'entity' =>
'globe',
5090 'graph' =>
'chart-line',
'grip_title' =>
'arrows-alt',
'grip' =>
'arrows-alt',
'help' =>
'question-circle',
5091 'generic' =>
'file',
'holiday' =>
'umbrella-beach',
5092 'info' =>
'info-circle',
'inventory' =>
'boxes',
'intracommreport' =>
'globe-europe',
'jobprofile' =>
'cogs',
5093 'knowledgemanagement' =>
'ticket-alt',
'label' =>
'layer-group',
'layout' =>
'columns',
'line' =>
'bars',
'loan' =>
'money-bill-alt',
5094 'member' =>
'user-alt',
'meeting' =>
'chalkboard-teacher',
'mrp' =>
'cubes',
'next' =>
'arrow-alt-circle-right',
5095 'trip' =>
'wallet',
'expensereport' =>
'wallet',
'group' =>
'users',
'movement' =>
'people-carry',
5096 'sign-out' =>
'sign-out-alt',
5097 'switch_off' =>
'toggle-off',
'switch_on' =>
'toggle-on',
'switch_on_grey' =>
'toggle-on',
'switch_on_warning' =>
'toggle-on',
'switch_on_red' =>
'toggle-on',
'check' =>
'check',
'bookmark' =>
'star',
5098 'bank' =>
'university',
'close_title' =>
'times',
'delete' =>
'trash',
'filter' =>
'filter',
5099 'list-alt' =>
'list-alt',
'calendarlist' =>
'bars',
'calendar' =>
'calendar-alt',
'calendarmonth' =>
'calendar-alt',
'calendarweek' =>
'calendar-week',
'calendarday' =>
'calendar-day',
'calendarperuser' =>
'table',
5100 'intervention' =>
'ambulance',
'invoice' =>
'file-invoice-dollar',
'order' =>
'file-invoice',
5101 'error' =>
'exclamation-triangle',
'warning' =>
'exclamation-triangle',
5102 'other' =>
'square',
5103 'playdisabled' =>
'play',
'pdf' =>
'file-pdf',
'poll' =>
'check-double',
'pos' =>
'cash-register',
'preview' =>
'binoculars',
'project' =>
'project-diagram',
'projectpub' =>
'project-diagram',
'projecttask' =>
'tasks',
'propal' =>
'file-signature',
'proposal' =>
'file-signature',
5104 'partnership' =>
'handshake',
'payment' =>
'money-check-alt',
'payment_vat' =>
'money-check-alt',
'pictoconfirm' =>
'check-square',
'phoning' =>
'phone',
'phoning_mobile' =>
'mobile-alt',
'phoning_fax' =>
'fax',
'previous' =>
'arrow-alt-circle-left',
'printer' =>
'print',
'product' =>
'cube',
'puce' =>
'angle-right',
5105 'recent' =>
'check-square',
'reception' =>
'dolly',
'recruitmentjobposition' =>
'id-card-alt',
'recruitmentcandidature' =>
'id-badge',
5106 'resize' =>
'crop',
'supplier_order' =>
'dol-order_supplier',
'supplier_proposal' =>
'file-signature',
5107 'refresh' =>
'redo',
'region' =>
'map-marked',
'replacement' =>
'exchange-alt',
'resource' =>
'laptop-house',
'recurring' =>
'history',
5108 'service' =>
'concierge-bell',
5109 'skill' =>
'shapes',
'state' =>
'map-marked-alt',
'security' =>
'key',
'salary' =>
'wallet',
'shipment' =>
'dolly',
'stock' =>
'box-open',
'stats' =>
'chart-bar',
'split' =>
'code-branch',
5110 'status' =>
'stop-circle',
5111 'stripe' =>
'stripe-s',
'supplier' =>
'building',
5112 'technic' =>
'cogs',
'tick' =>
'check',
'timespent' =>
'clock',
'title_setup' =>
'tools',
'title_accountancy' =>
'money-check-alt',
'title_bank' =>
'university',
'title_hrm' =>
'umbrella-beach',
5113 'title_agenda' =>
'calendar-alt',
5114 'uncheck' =>
'times',
'uparrow' =>
'share',
'url' =>
'external-link-alt',
'vat' =>
'money-check-alt',
'vcard' =>
'arrow-alt-circle-down',
5115 'jabber' =>
'comment-o',
5116 'website' =>
'globe-americas',
'workstation' =>
'pallet',
'webhook' =>
'bullseye',
'world' =>
'globe',
'private' =>
'user-lock',
5117 'conferenceorbooth' =>
'chalkboard-teacher',
'eventorganization' =>
'project-diagram',
5118 'webportal' =>
'door-open'
5120 if ($conf->currency ==
'EUR') {
5121 $arrayconvpictotofa[
'currency'] =
'euro-sign';
5122 $arrayconvpictotofa[
'multicurrency'] =
'dollar-sign';
5124 $arrayconvpictotofa[
'currency'] =
'dollar-sign';
5125 $arrayconvpictotofa[
'multicurrency'] =
'euro-sign';
5127 if ($pictowithouttext ==
'off') {
5128 $fakey =
'fa-square';
5130 } elseif ($pictowithouttext ==
'on') {
5131 $fakey =
'fa-check-square';
5133 } elseif ($pictowithouttext ==
'listlight') {
5134 $fakey =
'fa-download';
5135 $marginleftonlyshort = 1;
5136 } elseif ($pictowithouttext ==
'printer') {
5137 $fakey =
'fa-print';
5139 } elseif ($pictowithouttext ==
'note') {
5140 $fakey =
'fa-sticky-note';
5141 $marginleftonlyshort = 1;
5142 } elseif (in_array($pictowithouttext, array(
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'))) {
5143 $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');
5144 $fakey =
'fa-'.$convertarray[$pictowithouttext];
5145 if (preg_match(
'/selected/', $pictowithouttext)) {
5148 $marginleftonlyshort = 1;
5149 } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) {
5150 $fakey =
'fa-'.$arrayconvpictotofa[$pictowithouttext];
5152 $fakey =
'fa-'.$pictowithouttext;
5155 if (in_array($pictowithouttext, array(
'dollyrevert',
'member',
'members',
'contract',
'group',
'resource',
'shipment',
'reception'))) {
5156 $morecss .=
' em092';
5158 if (in_array($pictowithouttext, array(
'conferenceorbooth',
'collab',
'eventorganization',
'holiday',
'info',
'project',
'workstation'))) {
5159 $morecss .=
' em088';
5161 if (in_array($pictowithouttext, array(
'asset',
'intervention',
'payment',
'loan',
'partnership',
'stock',
'technic'))) {
5162 $morecss .=
' em080';
5166 $arrayconvpictotomarginleftonly = array(
5167 'bank',
'check',
'delete',
'generic',
'grip',
'grip_title',
'jabber',
5168 'grip_title',
'grip',
'listlight',
'note',
'on',
'off',
'playdisabled',
'printer',
'resize',
'sign-out',
'stats',
'switch_on',
'switch_on_grey',
'switch_on_red',
'switch_off',
5169 'uparrow',
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'
5171 if (!array_key_exists($pictowithouttext, $arrayconvpictotomarginleftonly)) {
5172 $marginleftonlyshort = 0;
5176 $arrayconvpictotomorcess = array(
5177 'action' =>
'infobox-action',
'account' =>
'infobox-bank_account',
'accounting_account' =>
'infobox-bank_account',
'accountline' =>
'infobox-bank_account',
'accountancy' =>
'infobox-bank_account',
'asset' =>
'infobox-bank_account',
5178 'bank_account' =>
'infobox-bank_account',
5179 'bill' =>
'infobox-commande',
'billa' =>
'infobox-commande',
'billr' =>
'infobox-commande',
'billd' =>
'infobox-commande',
5180 'bookcal' =>
'infobox-action',
5181 'margin' =>
'infobox-bank_account',
'conferenceorbooth' =>
'infobox-project',
5182 'cash-register' =>
'infobox-bank_account',
'contract' =>
'infobox-contrat',
'check' =>
'font-status4',
'collab' =>
'infobox-action',
'conversation' =>
'infobox-contrat',
5183 'donation' =>
'infobox-commande',
'dolly' =>
'infobox-commande',
'dollyrevert' =>
'flip infobox-order_supplier',
5184 'ecm' =>
'infobox-action',
'eventorganization' =>
'infobox-project',
5185 'hrm' =>
'infobox-adherent',
'group' =>
'infobox-adherent',
'intervention' =>
'infobox-contrat',
5186 'incoterm' =>
'infobox-supplier_proposal',
5187 'currency' =>
'infobox-bank_account',
'multicurrency' =>
'infobox-bank_account',
5188 'members' =>
'infobox-adherent',
'member' =>
'infobox-adherent',
'money-bill-alt' =>
'infobox-bank_account',
5189 'order' =>
'infobox-commande',
5190 'user' =>
'infobox-adherent',
'users' =>
'infobox-adherent',
5191 'error' =>
'pictoerror',
'warning' =>
'pictowarning',
'switch_on' =>
'font-status4',
'switch_on_warning' =>
'font-status4 warning',
'switch_on_red' =>
'font-status8',
5192 'holiday' =>
'infobox-holiday',
'info' =>
'opacityhigh',
'invoice' =>
'infobox-commande',
5193 'knowledgemanagement' =>
'infobox-contrat rotate90',
'loan' =>
'infobox-bank_account',
5194 'payment' =>
'infobox-bank_account',
'payment_vat' =>
'infobox-bank_account',
'poll' =>
'infobox-adherent',
'pos' =>
'infobox-bank_account',
'project' =>
'infobox-project',
'projecttask' =>
'infobox-project',
5195 'propal' =>
'infobox-propal',
'proposal' =>
'infobox-propal',
'private' =>
'infobox-project',
5196 'reception' =>
'flip infobox-order_supplier',
'recruitmentjobposition' =>
'infobox-adherent',
'recruitmentcandidature' =>
'infobox-adherent',
5197 'resource' =>
'infobox-action',
5198 'salary' =>
'infobox-bank_account',
'shapes' =>
'infobox-adherent',
'shipment' =>
'infobox-commande',
'stripe' =>
'infobox-bank_account',
'supplier_invoice' =>
'infobox-order_supplier',
'supplier_invoicea' =>
'infobox-order_supplier',
'supplier_invoiced' =>
'infobox-order_supplier',
5199 'supplier' =>
'infobox-order_supplier',
'supplier_order' =>
'infobox-order_supplier',
'supplier_proposal' =>
'infobox-supplier_proposal',
5200 'ticket' =>
'infobox-contrat',
'title_accountancy' =>
'infobox-bank_account',
'title_hrm' =>
'infobox-holiday',
'expensereport' =>
'infobox-expensereport',
'trip' =>
'infobox-expensereport',
'title_agenda' =>
'infobox-action',
5201 'vat' =>
'infobox-bank_account',
5203 'list-alt' =>
'imgforviewmode',
'calendar' =>
'imgforviewmode',
'calendarweek' =>
'imgforviewmode',
'calendarmonth' =>
'imgforviewmode',
'calendarday' =>
'imgforviewmode',
'calendarperuser' =>
'imgforviewmode'
5205 if (!empty($arrayconvpictotomorcess[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5206 $morecss .= ($morecss ?
' ' :
'').$arrayconvpictotomorcess[$pictowithouttext];
5210 $arrayconvpictotocolor = array(
5211 'address' =>
'#6c6aa8',
'building' =>
'#6c6aa8',
'bom' =>
'#a69944',
5212 'clone' =>
'#999',
'cog' =>
'#999',
'companies' =>
'#6c6aa8',
'company' =>
'#6c6aa8',
'contact' =>
'#6c6aa8',
'cron' =>
'#555',
5213 'dynamicprice' =>
'#a69944',
5214 'edit' =>
'#444',
'note' =>
'#999',
'error' =>
'',
'help' =>
'#bbb',
'listlight' =>
'#999',
'language' =>
'#555',
5216 'lock' =>
'#ddd',
'lot' =>
'#a69944',
5217 'map-marker-alt' =>
'#aaa',
'mrp' =>
'#a69944',
'product' =>
'#a69944',
'service' =>
'#a69944',
'inventory' =>
'#a69944',
'stock' =>
'#a69944',
'movement' =>
'#a69944',
5218 'other' =>
'#ddd',
'world' =>
'#986c6a',
5219 'partnership' =>
'#6c6aa8',
'playdisabled' =>
'#ccc',
'printer' =>
'#444',
'projectpub' =>
'#986c6a',
'resize' =>
'#444',
'rss' =>
'#cba',
5221 'security' =>
'#999',
'square' =>
'#888',
'stop-circle' =>
'#888',
'stats' =>
'#444',
'switch_off' =>
'#999',
5222 'technic' =>
'#999',
'tick' =>
'#282',
'timespent' =>
'#555',
5223 'uncheck' =>
'#800',
'uparrow' =>
'#555',
'user-cog' =>
'#999',
'country' =>
'#aaa',
'globe-americas' =>
'#aaa',
'region' =>
'#aaa',
'state' =>
'#aaa',
5224 'website' =>
'#304',
'workstation' =>
'#a69944'
5226 if (isset($arrayconvpictotocolor[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5227 $facolor = $arrayconvpictotocolor[$pictowithouttext];
5234 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5235 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5236 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5238 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
5239 $morestyle = $reg[1];
5240 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
5242 $moreatt = trim($moreatt);
5244 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
5245 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
5249 $enabledisablehtml .=
'</span>';
5251 return $enabledisablehtml;
5258 } elseif (!empty($conf->modules_parts[
'theme']) && array_key_exists($theme, $conf->modules_parts[
'theme'])) {
5259 $path = $theme.
'/theme/'.$theme;
5264 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
5270 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
5275 foreach ($conf->file->dol_document_root as $type => $dirroot) {
5276 if ($type ==
'main') {
5280 if (file_exists($dirroot.
'/'.$path.
'/img/'.$picto)) {
5281 $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type];
5287 $fullpathpicto = $url.
'/'.$path.
'/img/'.$picto;
5291 return $fullpathpicto;
5295 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 :
'').
'"').
'>';
5311function img_object($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0)
5313 if (strpos($picto,
'^') === 0) {
5314 return img_picto($titlealt, str_replace(
'^',
'', $picto), $moreatt, $pictoisfullpath, $srconly, $notitle);
5316 return img_picto($titlealt,
'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
5331function img_weather($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $morecss =
'')
5335 if (is_numeric($picto)) {
5338 return '<i class="fa fa-weather-level'.$picto.
'"></i>';
5339 } elseif (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5343 $path = DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/weather/'.$picto;
5345 return img_picto($titlealt, $path, $moreatt, 1, 0, 0,
'', $morecss);
5359function img_picto_common($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $notitle = 0)
5363 if (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5367 if ($pictoisfullpath) {
5370 $path = DOL_URL_ROOT.
'/theme/common/'.$picto;
5373 $themepath = DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/img/'.$picto;
5375 if (file_exists($themepath)) {
5381 return img_picto($titlealt, $path, $moreatt, 1, 0, $notitle);
5397function img_action($titlealt, $numaction, $picto =
'', $moreatt =
'')
5401 if (empty($titlealt) || $titlealt ==
'default') {
5402 if ($numaction ==
'-1' || $numaction ==
'ST_NO') {
5404 $titlealt = $langs->transnoentitiesnoconv(
'ChangeDoNotContact');
5405 } elseif ($numaction ==
'0' || $numaction ==
'ST_NEVER') {
5407 $titlealt = $langs->transnoentitiesnoconv(
'ChangeNeverContacted');
5408 } elseif ($numaction ==
'1' || $numaction ==
'ST_TODO') {
5410 $titlealt = $langs->transnoentitiesnoconv(
'ChangeToContact');
5411 } elseif ($numaction ==
'2' || $numaction ==
'ST_PEND') {
5413 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactInProcess');
5414 } elseif ($numaction ==
'3' || $numaction ==
'ST_DONE') {
5416 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactDone');
5418 $titlealt = $langs->transnoentitiesnoconv(
'ChangeStatus '.$numaction);
5422 if (!is_numeric($numaction)) {
5426 return img_picto($titlealt, (empty($picto) ?
'stcomm'.$numaction.
'.png' : $picto), $moreatt);
5436function img_pdf($titlealt =
'default', $size = 3)
5440 if ($titlealt ==
'default') {
5441 $titlealt = $langs->trans(
'Show');
5444 return img_picto($titlealt,
'pdf'.$size.
'.png');
5454function img_edit_add($titlealt =
'default', $other =
'')
5458 if ($titlealt ==
'default') {
5459 $titlealt = $langs->trans(
'Add');
5462 return img_picto($titlealt,
'edit_add.png', $other);
5475 if ($titlealt ==
'default') {
5476 $titlealt = $langs->trans(
'Remove');
5479 return img_picto($titlealt,
'edit_remove.png', $other);
5490function img_edit($titlealt =
'default', $float = 0, $other =
'')
5494 if ($titlealt ==
'default') {
5495 $titlealt = $langs->trans(
'Modify');
5498 return img_picto($titlealt,
'edit.png', ($float ?
'style="float: '.($langs->tab_translate[
"DIRECTION"] ==
'rtl' ?
'left' :
'right').
'"' :
"").($other ?
' '.$other :
''));
5509function img_view($titlealt =
'default', $float = 0, $other =
'class="valignmiddle"')
5513 if ($titlealt ==
'default') {
5514 $titlealt = $langs->trans(
'View');
5517 $moreatt = ($float ?
'style="float: right" ' :
'').$other;
5519 return img_picto($titlealt,
'eye', $moreatt);
5530function img_delete($titlealt =
'default', $other =
'class="pictodelete"', $morecss =
'')
5534 if ($titlealt ==
'default') {
5535 $titlealt = $langs->trans(
'Delete');
5538 return img_picto($titlealt,
'delete.png', $other, 0, 0, 0,
'', $morecss);
5548function img_printer($titlealt =
"default", $other =
'')
5551 if ($titlealt ==
"default") {
5552 $titlealt = $langs->trans(
"Print");
5554 return img_picto($titlealt,
'printer.png', $other);
5564function img_split($titlealt =
'default', $other =
'class="pictosplit"')
5568 if ($titlealt ==
'default') {
5569 $titlealt = $langs->trans(
'Split');
5572 return img_picto($titlealt,
'split.png', $other);
5582function img_help($usehelpcursor = 1, $usealttitle = 1)
5587 if (is_string($usealttitle)) {
5590 $usealttitle = $langs->trans(
'Info');
5594 return img_picto($usealttitle,
'info.png',
'style="vertical-align: middle;'.($usehelpcursor == 1 ?
' cursor: help' : ($usehelpcursor == 2 ?
' cursor: pointer' :
'')).
'"');
5603function img_info($titlealt =
'default')
5607 if ($titlealt ==
'default') {
5608 $titlealt = $langs->trans(
'Informations');
5611 return img_picto($titlealt,
'info.png',
'style="vertical-align: middle;"');
5622function img_warning($titlealt =
'default', $moreatt =
'', $morecss =
'pictowarning')
5626 if ($titlealt ==
'default') {
5627 $titlealt = $langs->trans(
'Warning');
5631 return img_picto($titlealt,
'warning.png',
'class="'.$morecss.
'"'.($moreatt ? ($moreatt ==
'1' ?
' style="float: right"' :
' '.$moreatt) :
''));
5640function img_error($titlealt =
'default')
5644 if ($titlealt ==
'default') {
5645 $titlealt = $langs->trans(
'Error');
5648 return img_picto($titlealt,
'error.png');
5658function img_next($titlealt =
'default', $moreatt =
'')
5662 if ($titlealt ==
'default') {
5663 $titlealt = $langs->trans(
'Next');
5667 return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
5677function img_previous($titlealt =
'default', $moreatt =
'')
5681 if ($titlealt ==
'default') {
5682 $titlealt = $langs->trans(
'Previous');
5686 return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
5697function img_down($titlealt =
'default', $selected = 0, $moreclass =
'')
5701 if ($titlealt ==
'default') {
5702 $titlealt = $langs->trans(
'Down');
5705 return img_picto($titlealt, ($selected ?
'1downarrow_selected.png' :
'1downarrow.png'),
'class="imgdown'.($moreclass ?
" ".$moreclass :
"").
'"');
5716function img_up($titlealt =
'default', $selected = 0, $moreclass =
'')
5720 if ($titlealt ==
'default') {
5721 $titlealt = $langs->trans(
'Up');
5724 return img_picto($titlealt, ($selected ?
'1uparrow_selected.png' :
'1uparrow.png'),
'class="imgup'.($moreclass ?
" ".$moreclass :
"").
'"');
5735function img_left($titlealt =
'default', $selected = 0, $moreatt =
'')
5739 if ($titlealt ==
'default') {
5740 $titlealt = $langs->trans(
'Left');
5743 return img_picto($titlealt, ($selected ?
'1leftarrow_selected.png' :
'1leftarrow.png'), $moreatt);
5754function img_right($titlealt =
'default', $selected = 0, $moreatt =
'')
5758 if ($titlealt ==
'default') {
5759 $titlealt = $langs->trans(
'Right');
5762 return img_picto($titlealt, ($selected ?
'1rightarrow_selected.png' :
'1rightarrow.png'), $moreatt);
5772function img_allow($allow, $titlealt =
'default')
5776 if ($titlealt ==
'default') {
5777 $titlealt = $langs->trans(
'Active');
5781 return img_picto($titlealt,
'tick.png');
5796 if (is_null($morecss)) {
5800 if ($brand ==
'visa' || $brand ==
'Visa') {
5802 } elseif ($brand ==
'mastercard' || $brand ==
'MasterCard') {
5803 $brand =
'cc-mastercard';
5804 } elseif ($brand ==
'amex' || $brand ==
'American Express') {
5806 } elseif ($brand ==
'discover' || $brand ==
'Discover') {
5807 $brand =
'cc-discover';
5808 } elseif ($brand ==
'jcb' || $brand ==
'JCB') {
5810 } elseif ($brand ==
'diners' || $brand ==
'Diners club') {
5811 $brand =
'cc-diners-club';
5812 } elseif (!in_array($brand, array(
'cc-visa',
'cc-mastercard',
'cc-amex',
'cc-discover',
'cc-jcb',
'cc-diners-club'))) {
5813 $brand =
'credit-card';
5816 return '<span class="fa fa-'.$brand.
' fa-fw'.($morecss ?
' '.$morecss :
'').
'"></span>';
5827function img_mime($file, $titlealt =
'', $morecss =
'')
5829 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
5835 if (empty($titlealt)) {
5836 $titlealt =
'Mime type: '.$mimetype;
5840 return '<i class="fa fa-'.$mimefa.
' paddingright'.($morecss ?
' '.$morecss :
'').
'"'.($titlealt ?
' title="'.$titlealt.
'"' :
'').
'></i>';
5851function img_search($titlealt =
'default', $other =
'')
5855 if ($titlealt ==
'default') {
5856 $titlealt = $langs->trans(
'Search');
5859 $img =
img_picto($titlealt,
'search.png', $other, 0, 1);
5861 $input =
'<input type="image" class="liste_titre" name="button_search" src="'.$img.
'" ';
5862 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
5878 if ($titlealt ==
'default') {
5879 $titlealt = $langs->trans(
'Search');
5882 $img =
img_picto($titlealt,
'searchclear.png', $other, 0, 1);
5884 $input =
'<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.
'" ';
5885 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
5902function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin =
'1', $morecss =
'hideonsmartphone', $textfordropdown =
'', $picto =
'')
5904 global $conf, $langs;
5906 if ($infoonimgalt) {
5907 $result =
img_picto($text,
'info',
'class="'.($morecss ?
' '.$morecss :
'').
'"');
5909 if (empty($conf->use_javascript_ajax)) {
5910 $textfordropdown =
'';
5913 $class = (empty($admin) ?
'undefined' : ($admin ==
'1' ?
'info' : $admin));
5914 $fa =
'info-circle';
5915 if ($picto ==
'warning') {
5916 $fa =
'exclamation-triangle';
5918 $result = ($nodiv ?
'' :
'<div class="wordbreak '.$class.($morecss ?
' '.$morecss :
'').($textfordropdown ?
' hidden' :
'').
'">').
'<span class="fa fa-'.$fa.
'" title="'.
dol_escape_htmltag($admin ? $langs->trans(
'InfoAdmin') : $langs->trans(
'Note')).
'"></span> ';
5920 $result .= ($nodiv ?
'' :
'</div>');
5922 if ($textfordropdown) {
5923 $tmpresult =
'<span class="'.$class.
'text opacitymedium cursorpointer">'.$langs->trans($textfordropdown).
' '.
img_picto($langs->trans($textfordropdown),
'1downarrow').
'</span>';
5924 $tmpresult .=
'<script nonce="'.getNonce().
'" type="text/javascript">
5925 jQuery(document).ready(function() {
5926 jQuery(".'.$class.
'text").click(function() {
5927 console.log("toggle text");
5928 jQuery(".'.$class.
'").toggle();
5933 $result = $tmpresult.$result;
5954 global $conf, $langs, $user, $argv;
5955 global $dolibarr_main_prod;
5962 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
5964 $langs->load(
"main");
5968 $langs->loadLangs(array(
'main',
'errors'));
5970 if ($_SERVER[
'DOCUMENT_ROOT']) {
5971 $out .= $langs->trans(
"DolibarrHasDetectedError").
".<br>\n";
5973 $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";
5975 $out .= $langs->trans(
"InformationToHelpDiagnose").
":<br>\n";
5977 $out .=
"<b>".$langs->trans(
"Date").
":</b> ".
dol_print_date(time(),
'dayhourlog').
"<br>\n";
5978 $out .=
"<b>".$langs->trans(
"Dolibarr").
":</b> ".DOL_VERSION.
" - https://www.dolibarr.org<br>\n";
5979 if (isset($conf->global->MAIN_FEATURES_LEVEL)) {
5980 $out .=
"<b>".$langs->trans(
"LevelOfFeature").
":</b> ".
getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
"<br>\n";
5982 if ($user instanceof
User) {
5983 $out .=
"<b>".$langs->trans(
"Login").
":</b> ".$user->login.
"<br>\n";
5985 if (function_exists(
"phpversion")) {
5986 $out .=
"<b>".$langs->trans(
"PHP").
":</b> ".phpversion().
"<br>\n";
5988 $out .=
"<b>".$langs->trans(
"Server").
":</b> ".(isset($_SERVER[
"SERVER_SOFTWARE"]) ?
dol_htmlentities($_SERVER[
"SERVER_SOFTWARE"], ENT_COMPAT) :
'').
"<br>\n";
5989 if (function_exists(
"php_uname")) {
5990 $out .=
"<b>".$langs->trans(
"OS").
":</b> ".php_uname().
"<br>\n";
5992 $out .=
"<b>".$langs->trans(
"UserAgent").
":</b> ".(isset($_SERVER[
"HTTP_USER_AGENT"]) ?
dol_htmlentities($_SERVER[
"HTTP_USER_AGENT"], ENT_COMPAT) :
'').
"<br>\n";
5994 $out .=
"<b>".$langs->trans(
"RequestedUrl").
":</b> ".
dol_htmlentities($_SERVER[
"REQUEST_URI"], ENT_COMPAT).
"<br>\n";
5995 $out .=
"<b>".$langs->trans(
"Referer").
":</b> ".(isset($_SERVER[
"HTTP_REFERER"]) ?
dol_htmlentities($_SERVER[
"HTTP_REFERER"], ENT_COMPAT) :
'').
"<br>\n";
5996 $out .=
"<b>".$langs->trans(
"MenuManager").
":</b> ".(isset($conf->standard_menu) ?
dol_htmlentities($conf->standard_menu, ENT_COMPAT) :
'').
"<br>\n";
5998 $syslog .=
"url=".dol_escape_htmltag($_SERVER[
"REQUEST_URI"]);
5999 $syslog .=
", query_string=".dol_escape_htmltag($_SERVER[
"QUERY_STRING"]);
6001 $out .=
'> '.$langs->transnoentities(
"ErrorInternalErrorDetected").
":\n".$argv[0].
"\n";
6002 $syslog .=
"pid=".dol_getmypid();
6005 if (!empty($conf->modules)) {
6006 $out .=
"<b>".$langs->trans(
"Modules").
":</b> ".implode(
', ', $conf->modules).
"<br>\n";
6009 if (is_object($db)) {
6010 if ($_SERVER[
'DOCUMENT_ROOT']) {
6011 $out .=
"<b>".$langs->trans(
"DatabaseTypeManager").
":</b> ".$db->type.
"<br>\n";
6012 $lastqueryerror = $db->lastqueryerror();
6014 $lastqueryerror =
"SQL error string is not a valid UTF8 string. We can't show it.";
6016 $out .=
"<b>".$langs->trans(
"RequestLastAccessInError").
":</b> ".($lastqueryerror ?
dol_escape_htmltag($lastqueryerror) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6017 $out .=
"<b>".$langs->trans(
"ReturnCodeLastAccessInError").
":</b> ".($db->lasterrno() ?
dol_escape_htmltag($db->lasterrno()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6018 $out .=
"<b>".$langs->trans(
"InformationLastAccessInError").
":</b> ".($db->lasterror() ?
dol_escape_htmltag($db->lasterror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6022 $out .=
'> '.$langs->transnoentities(
"DatabaseTypeManager").
":\n".$db->type.
"\n";
6023 $out .=
'> '.$langs->transnoentities(
"RequestLastAccessInError").
":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6024 $out .=
'> '.$langs->transnoentities(
"ReturnCodeLastAccessInError").
":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6025 $out .=
'> '.$langs->transnoentities(
"InformationLastAccessInError").
":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6027 $syslog .=
", sql=".$db->lastquery();
6028 $syslog .=
", db_error=".$db->lasterror();
6031 if ($error || $errors) {
6033 if (is_array($error) && is_array($errors)) {
6034 $errors = array_merge($error, $errors);
6035 } elseif (is_array($error)) {
6037 } elseif (is_array($errors) && !empty($error)) {
6038 $errors = array_merge(array($error), $errors);
6039 } elseif (!empty($error)) {
6040 $errors = array_merge(array($error), array($errors));
6043 $langs->load(
"errors");
6045 foreach ($errors as $msg) {
6049 if ($_SERVER[
'DOCUMENT_ROOT']) {
6052 $out .=
'> '.$langs->transnoentities(
"Message").
":\n".$msg.
"\n";
6054 $syslog .=
", msg=".$msg;
6057 if (empty($dolibarr_main_prod) && $_SERVER[
'DOCUMENT_ROOT'] && function_exists(
'xdebug_print_function_stack') && function_exists(
'xdebug_call_file')) {
6058 xdebug_print_function_stack();
6059 $out .=
'<b>XDebug information:</b>'.
"<br>\n";
6060 $out .=
'File: '.xdebug_call_file().
"<br>\n";
6061 $out .=
'Line: '.xdebug_call_line().
"<br>\n";
6062 $out .=
'Function: '.xdebug_call_function().
"<br>\n";
6067 if (!headers_sent()) {
6068 if (function_exists(
'top_httphead')) {
6072 http_response_code(202);
6075 if (empty($dolibarr_main_prod)) {
6078 if (empty($langs->defaultlang)) {
6079 $langs->setDefaultLang();
6081 $langs->loadLangs(array(
"main",
"errors"));
6083 print
'This website or feature is currently temporarily 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";
6084 print $langs->trans(
"DolibarrHasDetectedError").
'. ';
6085 print $langs->trans(
"YouCanSetOptionDolibarrMainProdToZero");
6086 if (!defined(
"MAIN_CORE_ERROR")) {
6087 define(
"MAIN_CORE_ERROR", 1);
6104function dol_print_error_email($prefixcode, $errormessage =
'', $errormessages = array(), $morecss =
'error', $email =
'')
6108 if (empty($email)) {
6112 $langs->load(
"errors");
6115 print
'<br><div class="center login_main_message"><div class="'.$morecss.
'">';
6116 print $langs->trans(
"ErrorContactEMail", $email, $prefixcode.
'-'.
dol_print_date($now,
'%Y%m%d%H%M%S'));
6117 if ($errormessage) {
6118 print
'<br><br>'.$errormessage;
6120 if (is_array($errormessages) && count($errormessages)) {
6121 foreach ($errormessages as $mesgtoshow) {
6122 print
'<br><br>'.$mesgtoshow;
6125 print
'</div></div>';
6144function print_liste_field_titre($name, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $tooltip =
"", $forcenowrapcolumntitle = 0)
6146 print
getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip, $forcenowrapcolumntitle);
6167function getTitleFieldOfList($name, $thead = 0, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $disablesortlink = 0, $tooltip =
'', $forcenowrapcolumntitle = 0)
6169 global $langs, $form;
6172 if ($moreattrib ==
'class="right"') {
6173 $prefix .=
'right ';
6176 $sortorder = strtoupper($sortorder);
6185 $tmpsortfield = explode(
',', $sortfield);
6186 $sortfield1 = trim($tmpsortfield[0]);
6187 $tmpfield = explode(
',', $field);
6188 $field1 = trim($tmpfield[0]);
6190 if (!
getDolGlobalString(
'MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE') && empty($forcenowrapcolumntitle)) {
6191 $prefix =
'wrapcolumntitle '.$prefix;
6197 $liste_titre =
'liste_titre';
6198 if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace(
"/^[^\.]+\./",
"", $field1))) {
6199 $liste_titre =
'liste_titre_sel';
6202 $tagstart =
'<'.$tag.
' class="'.$prefix.$liste_titre.
'" '.$moreattrib;
6207 if (empty($thead) && $field && empty($disablesortlink)) {
6208 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6209 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6210 $options = preg_replace(
'/&+/i',
'&', $options);
6211 if (!preg_match(
'/^&/', $options)) {
6212 $options =
'&'.$options;
6215 $sortordertouseinlink =
'';
6216 if ($field1 != $sortfield1) {
6217 if (preg_match(
'/^DESC/i', $sortorder)) {
6218 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6220 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6223 if (preg_match(
'/^ASC/i', $sortorder)) {
6224 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6226 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6229 $sortordertouseinlink = preg_replace(
'/,$/',
'', $sortordertouseinlink);
6230 $out .=
'<a class="reposition" href="'.$file.
'?sortfield='.$field.
'&sortorder='.$sortordertouseinlink.
'&begin='.$begin.$options.
'"';
6236 if (preg_match(
'/:\w+$/', $tooltip)) {
6237 $tmptooltip = explode(
':', $tooltip);
6239 $tmptooltip = array($tooltip);
6241 $out .= $form->textwithpicto($langs->trans($name), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.str_replace(
'.',
'_', $field).
'_'.$tmptooltip[1]));
6243 $out .= $langs->trans($name);
6246 if (empty($thead) && $field && empty($disablesortlink)) {
6250 if (empty($thead) && $field) {
6251 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6252 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6253 $options = preg_replace(
'/&+/i',
'&', $options);
6254 if (!preg_match(
'/^&/', $options)) {
6255 $options =
'&'.$options;
6258 if (!$sortorder || ($field1 != $sortfield1)) {
6262 if (preg_match(
'/^DESC/', $sortorder)) {
6265 $sortimg .=
'<span class="nowrap">'.img_up(
"Z-A", 0,
'paddingright').
'</span>';
6267 if (preg_match(
'/^ASC/', $sortorder)) {
6270 $sortimg .=
'<span class="nowrap">'.img_down(
"A-Z", 0,
'paddingright').
'</span>';
6275 $tagend =
'</'.$tag.
'>';
6277 $out = $tagstart.$sortimg.$out.$tagend;
6292 dol_syslog(__FUNCTION__.
" is deprecated", LOG_WARNING);
6294 print
'<div class="titre">'.$title.
'</div>';
6308function print_fiche_titre($title, $mesg =
'', $picto =
'generic', $pictoisfullpath = 0,
$id =
'')
6326function load_fiche_titre($title, $morehtmlright =
'', $picto =
'generic', $pictoisfullpath = 0,
$id =
'', $morecssontable =
'', $morehtmlcenter =
'')
6330 if ($picto ==
'setup') {
6335 $return .=
'<table '.($id ?
'id="'.$id.
'" ' :
'').
'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ?
' '.$morecssontable :
'').
'">';
6336 $return .=
'<tr class="titre">';
6338 $return .=
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).
'</td>';
6340 $return .=
'<td class="nobordernopadding valignmiddle col-title">';
6341 $return .=
'<div class="titre inline-block">';
6343 $return .=
'</div>';
6346 $return .=
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
6349 $return .=
'<td class="nobordernopadding titre_right wordbreakimp right valignmiddle col-right">'.$morehtmlright.
'</td>';
6351 $return .=
'</tr></table>'.
"\n";
6379function print_barre_liste($title, $page, $file, $options =
'', $sortfield =
'', $sortorder =
'', $morehtmlcenter =
'', $num = -1, $totalnboflines =
'', $picto =
'generic', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limit = -1, $hideselectlimit = 0, $hidenavigation = 0, $pagenavastextinput = 0, $morehtmlrightbeforearrow =
'')
6381 global $conf, $langs;
6384 $savtotalnboflines = $totalnboflines;
6385 if (is_numeric($totalnboflines)) {
6386 $totalnboflines = abs($totalnboflines);
6389 $page = (int) $page;
6391 if ($picto ==
'setup') {
6392 $picto =
'title_setup.png';
6394 if (($conf->browser->name ==
'ie') && $picto ==
'generic') {
6395 $picto =
'title.gif';
6398 $limit = $conf->liste_limit;
6401 if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
6409 print
"<!-- Begin print_barre_liste -->\n";
6410 print
'<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ?
' '.$morecss :
'').
'"><tr>';
6414 if ($picto && $title) {
6415 print
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath).
'</td>';
6418 print
'<td class="nobordernopadding valignmiddle col-title">';
6419 print
'<div class="titre inline-block">';
6420 print
'<span class="inline-block valignmiddle">'.dolPrintLabel($title).
'</span>';
6421 if (!empty($title) && $savtotalnboflines >= 0 && (
string) $savtotalnboflines !=
'') {
6422 print
'<span class="opacitymedium colorblack marginleftonly totalnboflines valignmiddle" title="'.$langs->trans(
"NbRecordQualified").
'">('.$totalnboflines.
')</span>';
6424 print
'</div></td>';
6427 if ($morehtmlcenter && empty($conf->dol_optimize_smallscreen)) {
6428 print
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
6432 print
'<td class="nobordernopadding valignmiddle right col-right">';
6433 print
'<input type="hidden" name="pageplusoneold" value="'.((int) $page + 1).
'">';
6435 $options .=
"&sortfield=".urlencode($sortfield);
6438 $options .=
"&sortorder=".urlencode($sortorder);
6442 if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
6443 if ($totalnboflines) {
6445 $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 0);
6448 $nbpages = ceil($totalnboflines / $limit);
6452 $cpt = ($page - $maxnbofpage);