53if (!function_exists(
'utf8_encode')) {
61 function utf8_encode($elements)
63 return mb_convert_encoding($elements,
'UTF-8',
'ISO-8859-1');
67if (!function_exists(
'utf8_decode')) {
75 function utf8_decode($elements)
77 return mb_convert_encoding($elements,
'ISO-8859-1',
'UTF-8');
80if (!function_exists(
'str_starts_with')) {
89 function str_starts_with($haystack, $needle)
91 return (
string) $needle !==
'' && strncmp($haystack, $needle, strlen($needle)) === 0;
94if (!function_exists(
'str_ends_with')) {
103 function str_ends_with($haystack, $needle)
105 return $needle !==
'' && substr($haystack, -strlen($needle)) === (string) $needle;
108if (!function_exists(
'str_contains')) {
117 function str_contains($haystack, $needle)
119 return $needle !==
'' && mb_strpos($haystack, $needle) !==
false;
139 if (!is_object(
$object) && empty($module)) {
142 if (empty($module) && !empty(
$object->element)) {
147 if ($module ==
'fichinter') {
148 $module =
'ficheinter';
149 } elseif ($module ==
'invoice_supplier') {
150 $module =
'supplier_invoice';
151 } elseif ($module ==
'order_supplier') {
152 $module =
'supplier_order';
156 if ($mode ==
'output' || $mode ==
'outputrel' || $mode ==
'version') {
157 if (isset(
$conf->$module) && property_exists(
$conf->$module,
'multidir_output')) {
159 if ($mode !=
'outputrel') {
162 if ($forobject &&
$object->id > 0) {
166 } elseif (isset(
$conf->$module) && property_exists(
$conf->$module,
'dir_output')) {
168 if ($mode !=
'outputrel') {
169 $s =
$conf->$module->dir_output;
171 if ($forobject &&
$object->id > 0) {
176 return 'error-diroutput-not-defined-for-this-object='.$module;
178 } elseif ($mode ==
'temp') {
179 if (isset(
$conf->$module) && property_exists(
$conf->$module,
'multidir_temp')) {
181 } elseif (isset(
$conf->$module) && property_exists(
$conf->$module,
'dir_temp')) {
182 return $conf->$module->dir_temp;
184 return 'error-dirtemp-not-defined-for-this-object='.$module;
187 return 'error-bad-value-for-mode';
231 return (
string) (isset(
$conf->global->$key) ?
$conf->global->$key : $default);
246 return (
int) (isset(
$conf->global->$key) ?
$conf->global->$key : $default);
261 return (
float) (isset(
$conf->global->$key) ?
$conf->global->$key : $default);
275 return (
bool) (
$conf->global->$key ?? $default);
289 if (empty($tmpuser)) {
294 return (
string) (isset($tmpuser->conf->$key) ? $tmpuser->conf->$key : $default);
307 if (empty($tmpuser)) {
312 return (
int) (isset($tmpuser->conf->$key) ? $tmpuser->conf->$key : $default);
329 'adherent' =>
'member',
330 'member_type' =>
'adherent_type',
332 'contrat' =>
'contract',
333 'entrepot' =>
'stock',
334 'projet' =>
'project',
335 'categorie' =>
'category',
336 'commande' =>
'order',
337 'expedition' =>
'shipping',
338 'facture' =>
'invoice',
339 'fichinter' =>
'intervention',
340 'ficheinter' =>
'intervention',
341 'propale' =>
'propal',
342 'socpeople' =>
'contact',
343 'fournisseur' =>
'supplier',
345 'actioncomm' =>
'agenda',
346 'product_price' =>
'productprice',
347 'product_fournisseur_price' =>
'productsupplierprice',
357function isModEnabled($module)
367 $arrayconv[
'supplier_order'] =
'fournisseur';
368 $arrayconv[
'supplier_invoice'] =
'fournisseur';
373 if ($module ==
'delivery_note') {
377 $module =
'shipping';
381 $module_alt = $module;
382 if (!empty($arrayconv[$module])) {
383 $module_alt = $arrayconv[$module];
385 $module_bis = $module;
386 if (!empty($arrayconvbis[$module])) {
387 $module_bis = $arrayconvbis[$module];
390 return !empty(
$conf->modules[$module]) || !empty(
$conf->modules[$module_alt]) || !empty(
$conf->modules[$module_bis]);
402 if ($timestamp ===
'') {
403 dol_syslog(
'Using empty string for a timestamp is deprecated, prefer use of null when calling page '.$_SERVER[
"PHP_SELF"] .
getCallerInfoString(), LOG_NOTICE);
406 if (is_null($timestamp) || !is_numeric($timestamp)) {
426 require_once DOL_DOCUMENT_ROOT.
"/core/db/".$type.
'.class.php';
428 $class =
'DoliDB'.ucfirst($type);
429 $db =
new $class($type, $host, $user, $pass, $name, $port);
450function getEntity($element, $shared = 1, $currentobject =
null)
454 if (!is_object($hookmanager)) {
455 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
462 $element =
'project';
465 $element =
'contract';
467 case 'order_supplier':
468 $element =
'supplier_order';
470 case 'invoice_supplier':
471 $element =
'supplier_invoice';
475 if (is_object($mc)) {
476 $out = $mc->getEntity($element, $shared, $currentobject);
479 $addzero = array(
'user',
'usergroup',
'cronjob',
'c_email_templates',
'email_template',
'default_values',
'overwrite_trans');
481 $addzero[] =
'c_holiday_types';
483 if (in_array($element, $addzero)) {
486 $out .= ((int)
$conf->entity);
491 'element' => $element,
494 'currentobject' => $currentobject,
497 $reshook = $hookmanager->executeHooks(
'hookGetEntity', $parameters, $currentobject, $action);
499 if (is_numeric($reshook)) {
500 if ($reshook == 0 && !empty($hookmanager->resPrint)) {
501 $out .=
','.$hookmanager->resPrint;
502 } elseif ($reshook == 1) {
503 $out = $hookmanager->resPrint;
520 if (is_object($mc) && method_exists($mc,
'setEntity')) {
521 return $mc->setEntity($currentobject);
523 return ((is_object($currentobject) && $currentobject->id > 0 && $currentobject->entity > 0) ? $currentobject->entity :
$conf->entity);
535 return preg_match(
'/(_pass|password|_pw|_key|securekey|serverkey|secret\d?|p12key|exportkey|_PW_[a-z]+|token)$/i', $keyname);
547 for ($r =
""; $n >= 0; $n = intval($n / 26) - 1) {
548 $r = chr($n % 26 + 0x41) . $r;
572 include_once DOL_DOCUMENT_ROOT.
'/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php';
579 $user_agent = substr($user_agent, 0, 512);
581 $detectmobile =
new Mobile_Detect(
null, $user_agent);
582 $tablet = $detectmobile->isTablet();
584 if ($detectmobile->isMobile()) {
588 if ($detectmobile->is(
'AndroidOS')) {
589 $os = $phone =
'android';
590 } elseif ($detectmobile->is(
'BlackBerryOS')) {
591 $os = $phone =
'blackberry';
592 } elseif ($detectmobile->is(
'iOS')) {
595 } elseif ($detectmobile->is(
'PalmOS')) {
596 $os = $phone =
'palm';
597 } elseif ($detectmobile->is(
'SymbianOS')) {
599 } elseif ($detectmobile->is(
'webOS')) {
601 } elseif ($detectmobile->is(
'MaemoOS')) {
603 } elseif ($detectmobile->is(
'WindowsMobileOS') || $detectmobile->is(
'WindowsPhoneOS')) {
609 if (preg_match(
'/linux/i', $user_agent)) {
611 } elseif (preg_match(
'/macintosh/i', $user_agent)) {
613 } elseif (preg_match(
'/windows/i', $user_agent)) {
619 if (preg_match(
'/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
621 $version = empty($reg[2]) ?
'' : $reg[2];
622 } elseif (preg_match(
'/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
624 $version = empty($reg[2]) ?
'' : $reg[2];
625 } elseif (preg_match(
'/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) {
627 $version = empty($reg[2]) ?
'' : $reg[2];
628 } elseif (preg_match(
'/chrome/i', $user_agent, $reg)) {
631 } elseif (preg_match(
'/iceweasel/i', $user_agent)) {
633 } elseif (preg_match(
'/epiphany/i', $user_agent)) {
635 } elseif (preg_match(
'/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
637 $version = empty($reg[2]) ?
'' : $reg[2];
638 } elseif (preg_match(
'/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
641 $version = empty($reg[2]) ?
'' : $reg[2];
642 } elseif (preg_match(
'/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
644 $version = end($reg);
645 } elseif (preg_match(
'/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
648 $version = end($reg);
649 } elseif (preg_match(
'/l[iy]n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) {
651 $name =
'textbrowser';
652 $version = empty($reg[3]) ?
'' : $reg[3];
653 } elseif (preg_match(
'/w3m\/([\d\.]+)/i', $user_agent, $reg)) {
655 $name =
'textbrowser';
656 $version = empty($reg[1]) ?
'' : $reg[1];
668 'browsername' => $name,
669 'browserversion' => $version,
671 'browserua' => $user_agent,
686 $disconnectdone =
false;
688 if (is_object($db) && !empty($db->connected)) {
689 $depth = $db->transaction_opened;
690 $disconnectdone = $db->close();
692 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));
704function GETPOSTISSET($paramname)
708 $relativepathstring = $_SERVER[
"PHP_SELF"];
710 if (constant(
'DOL_URL_ROOT')) {
711 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
713 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
714 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
720 if (!empty($_GET[
'restore_lastsearch_values'])) {
721 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
722 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
723 if (is_array($tmp)) {
724 foreach ($tmp as $key => $val) {
725 if ($key == $paramname) {
733 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
735 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
737 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
739 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
743 $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname]));
760 if (empty($method)) {
761 $val = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
762 } elseif ($method == 1) {
763 $val = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
764 } elseif ($method == 2) {
765 $val = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
766 } elseif ($method == 3) {
767 $val = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
769 $val =
'BadFirstParameterForGETPOST';
772 return is_array($val);
805function GETPOST($paramname, $check =
'alphanohtml', $method = 0, $filter =
null, $options =
null, $noreplace = 0)
807 global $mysoc, $user,
$conf;
809 if (empty($paramname)) {
810 return 'BadFirstParameterForGETPOST';
813 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);
818 if (empty($method)) {
819 $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
820 } elseif ($method == 1) {
821 $out = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
822 } elseif ($method == 2) {
823 $out = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
824 } elseif ($method == 3) {
825 $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
827 return 'BadThirdParameterForGETPOST';
830 $relativepathstring =
'';
832 if (empty($method) || $method == 3 || $method == 4) {
833 $relativepathstring = (empty($_SERVER[
"PHP_SELF"]) ?
'' : $_SERVER[
"PHP_SELF"]);
835 if (constant(
'DOL_URL_ROOT')) {
836 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
838 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
839 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
845 if (!empty($_GET[
'restore_lastsearch_values'])) {
846 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
847 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
848 if (is_array($tmp)) {
849 foreach ($tmp as $key => $val) {
850 if ($key == $paramname) {
858 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
859 $out = $_SESSION[
'lastsearch_contextpage_'.$relativepathstring];
860 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
861 $out = $_SESSION[
'lastsearch_limit_'.$relativepathstring];
862 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
863 $out = $_SESSION[
'lastsearch_page_'.$relativepathstring];
864 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
865 $out = $_SESSION[
'lastsearch_mode_'.$relativepathstring];
867 } elseif (!isset($_GET[
'sortfield'])) {
870 if (!empty($_GET[
'action']) && $_GET[
'action'] ==
'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
873 '@phan-var-force CommonObject $object';
874 if (is_object(
$object) && isset(
$object->fields[$paramname][
'default'])) {
876 $out =
$object->fields[$paramname][
'default'];
880 if (!empty($_GET[
'action']) && (preg_match(
'/^create/', $_GET[
'action']) || preg_match(
'/^presend/', $_GET[
'action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
882 if (!empty($user->default_values)) {
883 if (isset($user->default_values[$relativepathstring][
'createform'])) {
884 foreach ($user->default_values[$relativepathstring][
'createform'] as $defkey => $defval) {
886 if ($defkey !=
'_noquery_') {
887 $tmpqueryarraytohave = explode(
'&', $defkey);
890 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
891 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
904 if (isset($user->default_values[$relativepathstring][
'createform'][$defkey][$paramname])) {
905 $out = $user->default_values[$relativepathstring][
'createform'][$defkey][$paramname];
912 } elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
914 if (!empty($user->default_values)) {
917 if ($paramname ==
'sortfield' || $paramname ==
'sortorder') {
919 if (isset($user->default_values[$relativepathstring][
'sortorder'])) {
921 foreach ($user->default_values[$relativepathstring][
'sortorder'] as $defkey => $defval) {
923 if ($defkey !=
'_noquery_') {
924 $tmpqueryarraytohave = explode(
'&', $defkey);
927 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
928 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
941 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
942 foreach ($user->default_values[$relativepathstring][
'sortorder'][$defkey] as $key => $val) {
946 if ($paramname ==
'sortfield') {
949 if ($paramname ==
'sortorder') {
957 } elseif (isset($user->default_values[$relativepathstring][
'filters'])) {
958 foreach ($user->default_values[$relativepathstring][
'filters'] as $defkey => $defval) {
959 if (!empty($_GET[
'disabledefaultvalues'])) {
963 if ($defkey !=
'_noquery_') {
964 $tmpqueryarraytohave = explode(
'&', $defkey);
967 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
968 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
980 if ($qualified && isset($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname])) {
982 if (isset($_POST[
'search_all']) || isset($_GET[
'search_all'])) {
985 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
986 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
989 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
990 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
1005 '@phan-var-force string $paramname';
1006 if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
1011 while (preg_match(
'/__([A-Z0-9]+(?:_[A-Z0-9]+){0,3})__/i', $out, $reg) && ($loopnb < $maxloop)) {
1015 if ($reg[1] ==
'DAY') {
1017 $newout = $tmp[
'mday'];
1018 } elseif ($reg[1] ==
'MONTH') {
1020 $newout = $tmp[
'mon'];
1021 } elseif ($reg[1] ==
'YEAR') {
1023 $newout = $tmp[
'year'];
1024 } elseif ($reg[1] ==
'PREVIOUS_DAY') {
1027 $newout = $tmp2[
'day'];
1028 } elseif ($reg[1] ==
'PREVIOUS_MONTH') {
1031 $newout = $tmp2[
'month'];
1032 } elseif ($reg[1] ==
'PREVIOUS_YEAR') {
1034 $newout = ($tmp[
'year'] - 1);
1035 } elseif ($reg[1] ==
'NEXT_DAY') {
1038 $newout = $tmp2[
'day'];
1039 } elseif ($reg[1] ==
'NEXT_MONTH') {
1042 $newout = $tmp2[
'month'];
1043 } elseif ($reg[1] ==
'NEXT_YEAR') {
1045 $newout = ($tmp[
'year'] + 1);
1046 } elseif ($reg[1] ==
'MYCOMPANY_COUNTRY_ID' || $reg[1] ==
'MYCOUNTRY_ID' || $reg[1] ==
'MYCOUNTRYID') {
1047 $newout = $mysoc->country_id;
1048 } elseif ($reg[1] ==
'USER_ID' || $reg[1] ==
'USERID') {
1049 $newout = $user->id;
1050 } elseif ($reg[1] ==
'USER_SUPERVISOR_ID' || $reg[1] ==
'SUPERVISOR_ID' || $reg[1] ==
'SUPERVISORID') {
1051 $newout = $user->fk_user;
1052 } elseif ($reg[1] ==
'ENTITY_ID' || $reg[1] ==
'ENTITYID') {
1053 $newout =
$conf->entity;
1054 } elseif ($reg[1] ==
'ID') {
1060 $out = preg_replace(
'/__'.preg_quote($reg[1],
'/').
'__/', $newout, $out);
1065 if (preg_match(
'/^array/', $check)) {
1066 if (!is_array($out) || empty($out)) {
1069 $tmparray = explode(
':', $check);
1070 if (!empty($tmparray[1])) {
1071 $tmpcheck = $tmparray[1];
1073 $tmpcheck =
'alphanohtml';
1075 foreach ($out as $outkey => $outval) {
1076 $out[$outkey] =
sanitizeVal($outval, $tmpcheck, $filter, $options);
1082 if (strpos($paramname,
'search_') === 0) {
1083 $out = preg_replace(
'/([<>])([-+]?\d)/',
'\1 \2', $out);
1087 $out =
sanitizeVal($out, $check, $filter, $options);
1094 if (preg_match(
'/^backto/i', $paramname)) {
1095 $out = str_replace(
'\\',
'/', $out);
1096 $out = str_replace(array(
':',
';',
'@',
"\t",
' '),
'', $out);
1098 $oldstringtoclean = $out;
1099 $out = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $out);
1100 $out = preg_replace(array(
'/^[^\?]*%/'),
'', $out);
1101 $out = preg_replace(array(
'/^[a-z]*\/\s*\/+/i'),
'', $out);
1102 }
while ($oldstringtoclean != $out);
1107 if (empty($method) || $method == 3 || $method == 4) {
1108 if (preg_match(
'/^search_/', $paramname) || in_array($paramname, array(
'sortorder',
'sortfield'))) {
1115 if ($out !=
'' && isset($user)) {
1116 $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out;
1135 return (
int)
GETPOST($paramname,
'int', $method,
null,
null, 0);
1167function GETPOSTDATE($prefix, $hourTime =
'', $gm =
'auto')
1170 if ($hourTime ===
'getpost') {
1174 } elseif (preg_match(
'/^(\d\d):(\d\d):(\d\d)$/', $hourTime, $m)) {
1175 $hour = intval($m[1]);
1176 $minute = intval($m[2]);
1177 $second = intval($m[3]);
1179 $hour = $minute = $second = 0;
1182 $hour = (int) min($hour, 23);
1183 $minute = (int) min($minute, 59);
1184 $second = (int) min($second, 59);
1200function checkVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1202 return sanitizeVal($out, $check, $filter, $options);
1214function sanitizeVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1223 if (!is_numeric($out)) {
1228 if (is_array($out)) {
1229 $out = implode(
',', $out);
1231 if (preg_match(
'/[^0-9,-]+/i', $out)) {
1236 $out = filter_var($out, FILTER_SANITIZE_STRING);
1239 $out = filter_var($out, FILTER_SANITIZE_EMAIL);
1242 if (!is_array($out)) {
1244 if (preg_match(
'/[^a-z]+/i', $out)) {
1250 if (!is_array($out)) {
1252 if (preg_match(
'/[^a-z0-9_\-\.]+/i', $out)) {
1258 if (!is_array($out)) {
1260 if (preg_match(
'/[^a-z0-9_\-\.@]+/i', $out)) {
1266 if (!is_array($out)) {
1268 if (preg_match(
'/[^a-z0-9_\-\.,]+/i', $out)) {
1275 if (!is_array($out)) {
1278 $oldstringtoclean = $out;
1282 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1289 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1290 }
while ($oldstringtoclean != $out);
1294 case 'alphawithlgt':
1295 if (!is_array($out)) {
1298 $oldstringtoclean = $out;
1302 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1309 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1310 }
while ($oldstringtoclean != $out);
1316 case 'restricthtmlnolink':
1317 case 'restricthtml':
1318 case 'restricthtmlallowclass':
1319 case 'restricthtmlallowlinkscript':
1320 case 'restricthtmlallowunvalid':
1325 if (empty($filter)) {
1326 return 'BadParameterForGETPOST - Param 3 of sanitizeVal()';
1328 if (is_null($options)) {
1331 $out = filter_var($out, $filter, $options);
1335 dol_syslog(
"Error, you call sanitizeVal() with a bad value for the check type. Data will be sanitized with alphanohtml.", LOG_ERR);
1336 $out =
GETPOST($out,
'alphanohtml');
1344if (!function_exists(
'dol_getprefix')) {
1355 function dol_getprefix($mode =
'')
1358 if ($mode ==
'email') {
1364 } elseif (isset($_SERVER[
"SERVER_NAME"])) {
1365 return $_SERVER[
"SERVER_NAME"];
1370 if (!empty(
$conf->file->instance_unique_id)) {
1371 return sha1(
'dolibarr'.
$conf->file->instance_unique_id);
1375 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1379 global $dolibarr_main_instance_unique_id, $dolibarr_main_cookie_cryptkey;
1380 $tmp_instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ?
'' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
1383 if (!empty($tmp_instance_unique_id)) {
1384 return sha1(
'dolibarr'.$tmp_instance_unique_id);
1388 if (isset($_SERVER[
"SERVER_NAME"]) && isset($_SERVER[
"DOCUMENT_ROOT"])) {
1389 return sha1($_SERVER[
"SERVER_NAME"].$_SERVER[
"DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1391 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1408 global
$conf, $langs, $user, $mysoc;
1412 if (!file_exists($fullpath)) {
1413 dol_syslog(
'functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_WARNING);
1417 if (!empty($classname) && !class_exists($classname)) {
1418 return include $fullpath;
1420 return include_once $fullpath;
1438function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
1442 $path = preg_replace(
'/^\//',
'', $path);
1445 $res = DOL_DOCUMENT_ROOT.
'/'.$path;
1446 if (is_array(
$conf->file->dol_document_root)) {
1447 foreach (
$conf->file->dol_document_root as $key => $dirroot) {
1448 if ($key ==
'main') {
1452 if (@file_exists($dirroot.
'/'.$path)) {
1453 $res = $dirroot.
'/'.$path;
1458 if ($returnemptyifnotfound) {
1460 if ($returnemptyifnotfound == 1 || !file_exists($res)) {
1472 $res = DOL_URL_ROOT.
'/'.$path;
1475 $res = DOL_MAIN_URL_ROOT.
'/'.$path;
1478 $res = DOL_URL_ROOT.
'/'.$path;
1481 foreach (
$conf->file->dol_document_root as $key => $dirroot) {
1482 if ($key ==
'main') {
1487 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$conf->file->dol_main_url_root));
1488 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1491 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
'/'.$path;
1496 preg_match(
'/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);
1497 if (!empty($regs[1])) {
1500 if (@file_exists($dirroot.
'/'.$regs[1])) {
1502 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : DOL_URL_ROOT).
$conf->file->dol_url_root[$key].
'/'.$path;
1503 } elseif ($type == 2) {
1504 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : DOL_MAIN_URL_ROOT).
$conf->file->dol_url_root[$key].
'/'.$path;
1505 } elseif ($type == 3) {
1509 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$conf->file->dol_main_url_root));
1510 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1513 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
$conf->file->dol_url_root[$key].
'/'.$path;
1537 if (empty($properties)) {
1538 return get_object_vars($obj);
1541 $existingProperties = [];
1542 $realProperties = get_object_vars($obj);
1545 foreach ($properties as $property) {
1546 if (array_key_exists($property, $realProperties)) {
1548 $existingProperties[$property] = $obj->{$property};
1549 } elseif (property_exists($obj, $property)) {
1551 $existingProperties[$property] = $obj->{$property};
1555 return $existingProperties;
1584 $myclone = unserialize(serialize(
$object));
1586 if (!empty($tmpsavdb)) {
1589 } elseif ($native == 2) {
1592 $tmparray = get_object_vars(
$object);
1594 if (is_array($tmparray)) {
1595 foreach ($tmparray as $propertykey => $propertyval) {
1596 if (is_scalar($propertyval) || is_array($propertyval)) {
1597 $myclone->$propertykey = $propertyval;
1617function dol_size($size, $type =
'')
1620 if (empty(
$conf->dol_optimize_smallscreen)) {
1623 if ($type ==
'width' && $size > 250) {
1648 $filesystem_forbidden_chars = array(
'<',
'>',
'/',
'\\',
'?',
'*',
'|',
'"',
':',
'°',
'$',
';',
'`');
1650 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1651 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1652 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1653 $tmp = str_replace(
'..',
'', $tmp);
1674 $filesystem_forbidden_chars = array(
'<',
'>',
'?',
'*',
'|',
'"',
'°',
'$',
';',
'`');
1681 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1682 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1683 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1684 $tmp = str_replace(
'..',
'', $tmp);
1699 $stringtoclean = preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $stringtoclean);
1701 $stringtoclean = preg_replace(
'/<!--[^>]*-->/',
'', $stringtoclean);
1703 $stringtoclean = str_replace(
'\\',
'/', $stringtoclean);
1707 $stringtoclean = str_replace(array(
':',
';',
'@'),
'', $stringtoclean);
1711 $oldstringtoclean = $stringtoclean;
1714 $stringtoclean = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $stringtoclean);
1715 }
while ($oldstringtoclean != $stringtoclean);
1719 $stringtoclean = preg_replace(array(
'/^[a-z]*\/\/+/i'),
'', $stringtoclean);
1722 return $stringtoclean;
1734 $oldstringtoclean = $stringtoclean;
1735 $stringtoclean = str_ireplace(array(
'"',
':',
'[',
']',
"\n",
"\r",
'\\',
'\/'),
'', $stringtoclean);
1736 }
while ($oldstringtoclean != $stringtoclean);
1738 return $stringtoclean;
1751 return preg_replace(
'/[^\w]+/',
'', $str);
1765 if (is_null($str)) {
1770 if (extension_loaded(
'intl') &&
getDolGlobalString(
'MAIN_UNACCENT_USE_TRANSLITERATOR')) {
1771 $transliterator = Transliterator::createFromRules(
':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', Transliterator::FORWARD);
1772 return $transliterator->transliterate($str);
1775 $string = rawurlencode($str);
1776 $replacements = array(
1777 '%C3%80' =>
'A',
'%C3%81' =>
'A',
'%C3%82' =>
'A',
'%C3%83' =>
'A',
'%C3%84' =>
'A',
'%C3%85' =>
'A',
1779 '%C3%88' =>
'E',
'%C3%89' =>
'E',
'%C3%8A' =>
'E',
'%C3%8B' =>
'E',
1780 '%C3%8C' =>
'I',
'%C3%8D' =>
'I',
'%C3%8E' =>
'I',
'%C3%8F' =>
'I',
1782 '%C3%92' =>
'O',
'%C3%93' =>
'O',
'%C3%94' =>
'O',
'%C3%95' =>
'O',
'%C3%96' =>
'O',
1784 '%C3%99' =>
'U',
'%C3%9A' =>
'U',
'%C3%9B' =>
'U',
'%C3%9C' =>
'U',
1785 '%C3%9D' =>
'Y',
'%C5%B8' =>
'y',
1786 '%C3%A0' =>
'a',
'%C3%A1' =>
'a',
'%C3%A2' =>
'a',
'%C3%A3' =>
'a',
'%C3%A4' =>
'a',
'%C3%A5' =>
'a',
1788 '%C3%A8' =>
'e',
'%C3%A9' =>
'e',
'%C3%AA' =>
'e',
'%C3%AB' =>
'e',
1789 '%C3%AC' =>
'i',
'%C3%AD' =>
'i',
'%C3%AE' =>
'i',
'%C3%AF' =>
'i',
1791 '%C3%B2' =>
'o',
'%C3%B3' =>
'o',
'%C3%B4' =>
'o',
'%C3%B5' =>
'o',
'%C3%B6' =>
'o',
1793 '%C3%B9' =>
'u',
'%C3%BA' =>
'u',
'%C3%BB' =>
'u',
'%C3%BC' =>
'u',
1794 '%C3%BD' =>
'y',
'%C3%BF' =>
'y'
1796 $string = strtr($string, $replacements);
1797 return rawurldecode($string);
1802 "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
1803 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
1804 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
1805 \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
1806 \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
1807 \xF9\xFA\xFB\xFC\xFD\xFF",
1815 $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"));
1833function dol_string_nospecial($str, $newstr =
'_', $badcharstoreplace =
'', $badcharstoremove =
'', $keepspaces = 0)
1835 $forbidden_chars_to_replace = array(
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
",",
";",
"=",
'°',
'$',
';');
1836 if (empty($keepspaces)) {
1837 $forbidden_chars_to_replace[] =
" ";
1839 $forbidden_chars_to_remove = array();
1842 if (is_array($badcharstoreplace)) {
1843 $forbidden_chars_to_replace = $badcharstoreplace;
1845 if (is_array($badcharstoremove)) {
1846 $forbidden_chars_to_remove = $badcharstoremove;
1850 return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove,
"", $str));
1869 if ($removetabcrlf) {
1870 return preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $str);
1872 return preg_replace(
'/[\x00-\x08\x11-\x12\x14-\x1F\x7F]/u',
'', $str);
1884function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0)
1886 if (is_null($stringtoescape)) {
1891 $substitjs = array(
"'" =>
"\\'",
"\r" =>
'\\r');
1893 if (empty($noescapebackslashn)) {
1894 $substitjs[
"\n"] =
'\\n';
1895 $substitjs[
'\\'] =
'\\\\';
1898 $substitjs[
"'"] =
"\\'";
1899 $substitjs[
'"'] =
"\\'";
1900 } elseif ($mode == 1) {
1901 $substitjs[
"'"] =
"\\'";
1902 } elseif ($mode == 2) {
1903 $substitjs[
'"'] =
'\\"';
1904 } elseif ($mode == 3) {
1905 $substitjs[
"'"] =
"\\'";
1906 $substitjs[
'"'] =
"\\\"";
1908 return strtr($stringtoescape, $substitjs);
1922 return rawurlencode($stringtoescape);
1933 return str_replace(
'"',
'\"', $stringtoescape);
1945 if (is_null($stringtoescape)) {
1949 if ($stringforquotes == 2) {
1950 return str_replace(
'"',
"'", $stringtoescape);
1951 } elseif ($stringforquotes == 1) {
1957 $stringtoescape = str_replace(
'\\',
'', $stringtoescape);
1958 return str_replace(
"'",
"\'", str_replace(
'"',
"'", $stringtoescape));
1961 return 'Bad parameter for stringforquotes in dol_escape_php';
1972 return preg_replace(
'/[^a-z0-9_]/i',
'', $stringtoescape);
1983 return $stringtoescape;
2035 return dol_escape_htmltag(
dol_string_onlythesehtmltags(
dol_htmlentitiesbr($s), 1, 0, 0, 0, array(
'br',
'b',
'font',
'span')), 1, -1,
'', 0, 1);
2060 return htmlspecialchars($s, ENT_COMPAT,
'UTF-8');
2080function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags =
'', $escapeonlyhtmltags = 0, $cleanalsojavascript = 0)
2082 if ($noescapetags ==
'common') {
2083 $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';
2085 $noescapetags .=
',header,footer,nav,section,menu,menuitem';
2087 if ($cleanalsojavascript) {
2092 if ($escapeonlyhtmltags) {
2093 $tmp = htmlspecialchars_decode((
string) $stringtoescape, ENT_COMPAT);
2095 $tmp = html_entity_decode((
string) $stringtoescape, ENT_COMPAT,
'UTF-8');
2096 $tmp = str_ireplace(
''',
'__SIMPLEQUOTE', $tmp);
2099 $tmp = strtr($tmp, array(
"<b>" =>
'',
'</b>' =>
'',
'<strong>' =>
'',
'</strong>' =>
''));
2102 $tmp = strtr($tmp, array(
"\r" =>
'\\r',
"\n" =>
'\\n'));
2103 } elseif ($keepn == -1) {
2104 $tmp = strtr($tmp, array(
"\r" =>
'',
"\n" =>
''));
2107 if ($escapeonlyhtmltags) {
2108 return htmlspecialchars($tmp, ENT_COMPAT,
'UTF-8');
2111 $tmparrayoftags = array();
2112 if ($noescapetags) {
2113 $tmparrayoftags = explode(
',', $noescapetags);
2115 if (count($tmparrayoftags)) {
2117 $tmp = str_ireplace(
'__DOUBLEQUOTE',
'', $tmp);
2119 foreach ($tmparrayoftags as $tagtoreplace) {
2120 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'>/',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2121 $tmp = str_ireplace(
'</'.$tagtoreplace.
'>',
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2122 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
' \/>/',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2128 if (preg_match(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+([^>]+)>/', $tmp, $reg)) {
2129 $tmpattributes = str_ireplace(array(
'[',
']'),
'_', $reg[1]);
2130 $tmpattributes = str_ireplace(
'href="http:',
'__HREFHTTPA', $tmpattributes);
2131 $tmpattributes = str_ireplace(
'href="https:',
'__HREFHTTPSA', $tmpattributes);
2132 $tmpattributes = str_ireplace(
'src="http:',
'__SRCHTTPIMG', $tmpattributes);
2133 $tmpattributes = str_ireplace(
'src="https:',
'__SRCHTTPSIMG', $tmpattributes);
2134 $tmpattributes = str_ireplace(
'"',
'__DOUBLEQUOTE', $tmpattributes);
2135 $tmpattributes = preg_replace(
'/[^a-z0-9_\/\?\;\s=&\.\-@:\.#\+]/i',
'', $tmpattributes);
2137 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+'.preg_quote($reg[1],
'/').
'>/',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'['.$tmpattributes.
']__', $tmp);
2139 if (preg_match(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+([^>]+)\s+\/>/', $tmp, $reg)) {
2140 $tmpattributes = str_ireplace(array(
'[',
']'),
'_', $reg[1]);
2141 $tmpattributes = str_ireplace(
'"',
'__DOUBLEQUOTE', $tmpattributes);
2142 $tmpattributes = preg_replace(
'/[^a-z0-9_\/\?\;\s=&\.\-@:\.#\+]/i',
'', $tmpattributes);
2144 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+'.preg_quote($reg[1],
'/').
'\s+\/>/',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'['.$tmpattributes.
']__', $tmp);
2147 $diff = strcmp($tmpold, $tmp);
2152 $result = htmlentities($tmp, ENT_COMPAT,
'UTF-8');
2156 if (count($tmparrayoftags)) {
2157 foreach ($tmparrayoftags as $tagtoreplace) {
2158 $result = str_ireplace(
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
'>', $result);
2159 $result = preg_replace(
'/__BEGINTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1>', $result);
2160 $result = str_ireplace(
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__',
'</'.$tagtoreplace.
'>', $result);
2161 $result = str_ireplace(
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
' />', $result);
2162 $result = preg_replace(
'/__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1 />', $result);
2165 $result = str_ireplace(
'__HREFHTTPA',
'href="http:', $result);
2166 $result = str_ireplace(
'__HREFHTTPSA',
'href="https:', $result);
2167 $result = str_ireplace(
'__SRCHTTPIMG',
'src="http:', $result);
2168 $result = str_ireplace(
'__SRCHTTPSIMG',
'src="https:', $result);
2169 $result = str_ireplace(
'__DOUBLEQUOTE',
'"', $result);
2172 $result = str_ireplace(
'__SIMPLEQUOTE',
''', $result);
2189 if (function_exists(
'mb_strtolower')) {
2190 return mb_strtolower($string, $encoding);
2192 return strtolower($string);
2206 if (function_exists(
'mb_strtoupper')) {
2207 return mb_strtoupper($string, $encoding);
2209 return strtoupper($string);
2223 if (function_exists(
'mb_substr')) {
2224 return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1,
null, $encoding);
2226 return ucfirst($string);
2240 if (function_exists(
'mb_convert_case')) {
2241 return mb_convert_case($string, MB_CASE_TITLE, $encoding);
2243 return ucwords($string);
2255 $backtrace = debug_backtrace();
2257 if (count($backtrace) >= 2) {
2258 $trace = $backtrace[1];
2259 if (isset($trace[
'file'], $trace[
'line'])) {
2260 $msg =
" From {$trace['file']}:{$trace['line']}.";
2288function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
'', $restricttologhandler =
'', $logcontext =
null)
2290 global
$conf, $user, $debugbar;
2293 if (!isModEnabled(
'syslog')) {
2298 if (defined(
'USEEXTERNALSERVER') && !defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
2299 global $website, $websitekey;
2300 if (is_object($website) && !empty($website->ref)) {
2301 $suffixinfilename .=
'_website_'.$website->ref;
2302 } elseif (!empty($websitekey)) {
2303 $suffixinfilename .=
'_website_'.$websitekey;
2308 if (defined(
'USESUFFIXINLOG')) {
2309 $suffixinfilename .= constant(
'USESUFFIXINLOG');
2313 foreach (
$conf->loghandlers as $loghandlerinstance) {
2314 $loghandlerinstance->setIdent($ident);
2318 if (!empty($message)) {
2320 $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');
2321 if (!array_key_exists($level, $logLevels)) {
2322 throw new Exception(
'Incorrect log level');
2329 $message = preg_replace(
'/password=\'[^\']*\'/',
'password=\'hidden\'', $message);
2333 if ((!empty($_REQUEST[
'logtohtml']) &&
getDolGlobalString(
'MAIN_ENABLE_LOG_TO_HTML'))
2334 || (is_object($user) && $user->hasRight(
'debugbar',
'read') && is_object($debugbar))) {
2335 $ospid = sprintf(
"%7s",
dol_trunc((
string) getmypid(), 7,
'right',
'UTF-8', 1));
2336 $osuser =
" ".sprintf(
"%6s",
dol_trunc(function_exists(
'posix_getuid') ? posix_getuid() :
'', 6,
'right',
'UTF-8', 1));
2338 $conf->logbuffer[] =
dol_print_date(time(),
"%Y-%m-%d %H:%M:%S").
" ".sprintf(
"%-7s", $logLevels[$level]).
" ".$ospid.
" ".$osuser.
" ".$message;
2344 print
"\n\n<!-- Log start\n";
2346 print
"Log end -->\n";
2350 'message' => $message,
2351 'script' => (isset($_SERVER[
'PHP_SELF']) ? basename($_SERVER[
'PHP_SELF'],
'.php') : false),
2353 'user' => ((is_object($user) && $user->id) ? $user->login : false),
2355 'osuser' => function_exists(
'posix_getuid') ? posix_getuid() : false,
2356 'ospid' => getmypid()
2360 if (!empty($remoteip)) {
2361 $data[
'ip'] = $remoteip;
2363 if (!empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) && $_SERVER[
'HTTP_X_FORWARDED_FOR'] != $remoteip) {
2364 $data[
'ip'] = $_SERVER[
'HTTP_X_FORWARDED_FOR'].
' -> '.$data[
'ip'];
2365 } elseif (!empty($_SERVER[
'HTTP_CLIENT_IP']) && $_SERVER[
'HTTP_CLIENT_IP'] != $remoteip) {
2366 $data[
'ip'] = $_SERVER[
'HTTP_CLIENT_IP'].
' -> '.$data[
'ip'];
2368 } elseif (!empty($_SERVER[
'SERVER_ADDR'])) {
2370 $data[
'ip'] = $_SERVER[
'SERVER_ADDR'];
2371 } elseif (!empty($_SERVER[
'COMPUTERNAME'])) {
2373 $data[
'ip'] = $_SERVER[
'COMPUTERNAME'];
2375 $data[
'ip'] =
'???';
2378 if (!empty($_SERVER[
'USERNAME'])) {
2380 $data[
'osuser'] = $_SERVER[
'USERNAME'];
2381 } elseif (!empty($_SERVER[
'LOGNAME'])) {
2383 $data[
'osuser'] = $_SERVER[
'LOGNAME'];
2387 foreach (
$conf->loghandlers as $loghandlerinstance) {
2388 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
2391 $loghandlerinstance->export($data, $suffixinfilename);
2397 foreach (
$conf->loghandlers as $loghandlerinstance) {
2398 $loghandlerinstance->setIdent($ident);
2418 $form =
new Form($db);
2420 $templatenameforexport = $website->name_template;
2421 if (empty($templatenameforexport)) {
2422 $templatenameforexport =
'website_'.$website->ref;
2426 $out .=
'<input type="button" class="cursorpointer button bordertransp" id="open-dialog-' . $name .
'" value="'.dol_escape_htmltag($buttonstring).
'"/>';
2429 $out .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">';
2430 $out .=
'jQuery(document).ready(function () {';
2431 $out .=
' jQuery("#open-dialog-' . $name .
'").click(function () {';
2432 $out .=
' var dialogHtml = \'';
2434 $dialogcontent =
' <div id="custom-dialog-' . $name .
'">';
2435 $dialogcontent .=
' <div style="margin-top: 20px;">';
2436 $dialogcontent .=
' <label for="export-site-' . $name .
'"><strong>'.$langs->trans(
"ExportSiteLabel").
'...</label><br>';
2437 $dialogcontent .=
' <button class="button smallpaddingimp" id="export-site-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"DownloadZip")) .
'</button>';
2438 $dialogcontent .=
' </div>';
2439 $dialogcontent .=
' <br>';
2440 $dialogcontent .=
' <div style="margin-top: 20px;">';
2441 $dialogcontent .=
' <strong>'.$langs->trans(
"ExportSiteGitLabel").
' '.$form->textwithpicto(
'', $langs->trans(
"SourceFiles"), 1,
'help',
'', 0, 3,
'').
'</strong><br>';
2442 $dialogcontent .=
' <form action="'.dol_escape_htmltag($overwriteGitUrl).
'" method="POST">';
2443 $dialogcontent .=
' <input type="hidden" name="action" value="overwritesite">';
2444 $dialogcontent .=
' <input type="hidden" name="token" value="'.newToken().
'">';
2445 $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>';
2446 $dialogcontent .=
' <button type="submit" class="button smallpaddingimp" id="overwrite-git-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"ExportIntoGIT")) .
'</button>';
2447 $dialogcontent .=
' </form>';
2448 $dialogcontent .=
' </div>';
2449 $dialogcontent .=
' </div>';
2456 // Add the content of the dialog to the body of the page
2457 $out .= ' var $dialog = jQuery(
"#custom-dialog-' . $name . '");
';
2458 $out .= ' if ($dialog.length > 0) {
2461 jQuery(
"body").append(dialogHtml);
';
2463 // Configuration of popup
2464 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog({
';
2465 $out .= ' autoOpen:
false,
';
2466 $out .= ' modal:
true,
';
2467 $out .= ' height: 290,
';
2468 $out .= ' width:
"40%",
';
2469 $out .= ' title:
"' . dol_escape_js($label) . '",
';
2472 // Simulate a click on the original "submit" input to export the site.
2473 $out .= ' jQuery(
"#export-site-' . $name . '").click(
function () {
';
2474 $out .= ' console.log(
"Clic on exportsite.");
';
2475 $out .= ' var target = jQuery(
"input[name=\'' . dol_escape_js($exportSiteName) . '\']");
';
2476 $out .= ' console.log(
"element founded:", target.length > 0);
';
2477 $out .= ' if (target.length > 0) { target.click(); }
';
2478 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"close");
';
2482 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"open");
';
2483 $out .= ' return false;
';
2486 $out .= '</script>
';
2508function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '
', $morecss = 'classlink
button bordertransp
', $jsonopen = '', $backtopagejsfields = '', $accesskey = '')
2512 if (strpos($url, '?
') > 0) {
2513 $url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2515 $url .= '?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2520 $backtopagejsfieldsid = '';
2521 $backtopagejsfieldslabel = '';
2522 if ($backtopagejsfields) {
2523 $tmpbacktopagejsfields = explode(':
', $backtopagejsfields);
2524 if (empty($tmpbacktopagejsfields[1])) { // If the part 'keyforpopupid:
' is missing, we add $name for it.
2525 $backtopagejsfields = $name.":".$backtopagejsfields;
2526 $tmp2backtopagejsfields = explode(',
', $tmpbacktopagejsfields[0]);
2528 $tmp2backtopagejsfields = explode(',
', $tmpbacktopagejsfields[1]);
2530 $backtopagejsfieldsid = empty($tmp2backtopagejsfields[0]) ? '' : $tmp2backtopagejsfields[0];
2531 $backtopagejsfieldslabel = empty($tmp2backtopagejsfields[1]) ? '' : $tmp2backtopagejsfields[1];
2532 $url .= '&backtopagejsfields=
'.urlencode($backtopagejsfields);
2535 //print '<input
type=
"submit" class=
"button bordertransp"'.$disabled.' value=
"'.dol_escape_htmltag($langs->trans("MediaFiles
")).'" name=
"file_manager">
';
2536 $out .= '<!-- a link
for button to open url into a dialog popup with backtopagejsfields =
'.$backtopagejsfields.' -->
';
2537 $out .= '<a
'.($accesskey ? ' accesskey=
"'.$accesskey.'"' : '').' class=
"cursorpointer reposition button_'.$name.($morecss ? ' '.$morecss : '').'"'.$disabled.' title=
"'.dol_escape_htmltag($label).'"';
2538 if (empty($conf->use_javascript_ajax)) {
2539 $out .= ' href=
"'.DOL_URL_ROOT.$url.'" target=
"_blank"';
2540 } elseif ($jsonopen) {
2541 $out .= ' href=
"#" onclick=
"'.$jsonopen.'"';
2543 $out .= ' href=
"#"';
2545 $out .= '>
'.$buttonstring.'</a>
';
2547 if (!empty($conf->use_javascript_ajax)) {
2548 // Add code to open url using the popup. Add also hidden field to retrieve the returned variables
2549 $out .= '<!-- code to open popup and variables to retrieve returned variables -->
';
2550 $out .= '<div
id=
"idfordialog'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for dialog
' : '').'</div>
';
2551 $out .= '<div
id=
"varforreturndialogid'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for returned
id' : '').'</div>
';
2552 $out .= '<div
id=
"varforreturndialoglabel'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for returned label
' : '').'</div>
';
2554 $out .= '<!-- Add js code to open dialog popup on dialog -->
';
2555 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript">
2556 jQuery(document).ready(
function () {
2557 jQuery(
".button_'.$name.'").click(
function () {
2558 console.log(\
'Open popup with jQuery(...).dialog() on URL '.
dol_escape_js(DOL_URL_ROOT.$url).
'\');
2559 var $tmpdialog = $(\
'#idfordialog'.$name.
'\');
2560 $tmpdialog.html(\
'<iframe class="iframedialog" id="iframedialog'.$name.
'" style="border: 0px;" src="'.DOL_URL_ROOT.$url.
'" width="100%" height="98%"></iframe>\');
2564 height: (window.innerHeight - 150),
2567 open: function (event, ui) {
2568 console.log(
"open popup name='.$name.', backtopagejsfields='.$backtopagejsfields.'");
2570 close:
function (event, ui) {
2571 var returnedid = jQuery(
"#varforreturndialogid'.$name.'").text();
2572 var returnedlabel = jQuery(
"#varforreturndialoglabel'.$name.'").text();
2573 console.log(
"popup has been closed. returnedid (js var defined into parent page)="+returnedid+
" returnedlabel="+returnedlabel);
2574 if (returnedid !=
"" && returnedid !=
"div for returned id") {
2575 jQuery(
"#'.(empty($backtopagejsfieldsid) ? "none
" : $backtopagejsfieldsid).'").val(returnedid);
2577 if (returnedlabel !=
"" && returnedlabel !=
"div for returned label") {
2578 jQuery(
"#'.(empty($backtopagejsfieldslabel) ? "none
" : $backtopagejsfieldslabel).'").val(returnedlabel);
2583 $tmpdialog.dialog(\
'open\');
2608function dol_fiche_head($links = array(), $active =
'0', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
2610 print
dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow, $moretabssuffix);
2629function dol_get_fiche_head($links = array(), $active =
'', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'', $dragdropfile = 0)
2631 global
$conf, $langs, $hookmanager;
2635 if (!empty(
$conf->dol_optimize_smallscreen)) {
2639 $out =
"\n".
'<!-- dol_fiche_head - dol_get_fiche_head -->';
2641 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2642 $out .=
'<div class="tabs'.($picto ?
'' :
' nopaddingleft').
'" data-role="controlgroup" data-type="horizontal">'.
"\n";
2646 if ($morehtmlright) {
2647 $out .=
'<div class="inline-block floatright tabsElem">'.$morehtmlright.
'</div>';
2671 if (is_array($links) && !empty($links)) {
2672 $keys = array_keys($links);
2674 $maxkey = max($keys);
2680 if (empty($limittoshow)) {
2683 if (!empty(
$conf->dol_optimize_smallscreen)) {
2691 for ($i = 0; $i <= $maxkey; $i++) {
2692 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2694 if ($i >= $limittoshow) {
2700 for ($i = 0; $i <= $maxkey; $i++) {
2701 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2707 if ($i < $limittoshow || $isactive) {
2709 $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])).
' -->';
2711 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2712 if (!empty($links[$i][0])) {
2713 $out .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2715 $out .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2717 } elseif (!empty($links[$i][1])) {
2719 $out .=
'<div class="tab tab'.($isactive ?
'active' :
'unactive').
'" style="margin: 0 !important">';
2721 if (!empty($links[$i][0])) {
2722 $titletoshow = preg_replace(
'/<.*$/',
'', $links[$i][1]);
2723 $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).
'">';
2726 if ($displaytab == 0 && $picto) {
2727 $out .=
img_picto($title, $picto,
'', $pictoisfullpath, 0, 0,
'',
'imgTabTitle paddingright marginrightonlyshort');
2730 $out .= $links[$i][1];
2731 if (!empty($links[$i][0])) {
2732 $out .=
'</a>'.
"\n";
2734 $out .= empty($links[$i][4]) ?
'' : $links[$i][4];
2743 $outmore .=
'<div class="popuptabset wordwrap">';
2745 $outmore .=
'<div class="popuptab wordwrap" style="display:inherit;">';
2746 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2747 if (!empty($links[$i][0])) {
2748 $outmore .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2750 $outmore .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2752 } elseif (!empty($links[$i][1])) {
2753 $outmore .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="wordwrap inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
2754 $outmore .= preg_replace(
'/([a-z])\|([a-z])/i',
'\\1 | \\2', $links[$i][1]);
2755 $outmore .=
'</a>'.
"\n";
2757 $outmore .=
'</div>';
2762 $displaytab = $i + 1;
2765 $outmore .=
'</div>';
2769 $left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
2770 $right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
2771 $widthofpopup = 200;
2773 $tabsname = $moretabssuffix;
2774 if (empty($tabsname)) {
2775 $tabsname = str_replace(
"@",
"", $picto);
2777 $out .=
'<div id="moretabs'.$tabsname.
'" class="inline-block tabsElem valignmiddle">';
2779 $out .=
'<div class="tab valignmiddle"><a href="#" class="tab moretab inline-block tabunactive valignmiddle"><span class="hideonsmartphone">'.$langs->trans(
"More").
'</span>... ('.$nbintab.
')</a></div>';
2781 $out .=
'<div id="moretabsList'.$tabsname.
'" style="width: '.$widthofpopup.
'px; position: absolute; '.$left.
': -999em; text-align: '.$left.
'; margin:0px; padding:2px; z-index:10;">';
2784 $out .=
'<div></div>';
2787 $out .=
'<script nonce="'.getNonce().
'">';
2788 $out .=
"$('#moretabs".$tabsname.
"').mouseenter( function() {
2789 var x = this.offsetLeft, y = this.offsetTop;
2790 console.log('mouseenter ".$left.
" x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
2791 if ((window.innerWidth - x) < ".($widthofpopup + 10).
") {
2792 $('#moretabsList".$tabsname.
"').css('".$right.
"','8px');
2794 $('#moretabsList".$tabsname.
"').css('".$left.
"','auto');
2797 $out .=
"$('#moretabs".$tabsname.
"').mouseleave( function() { console.log('mouseleave ".$left.
"'); $('#moretabsList".$tabsname.
"').css('".$left.
"','-999em');});";
2798 $out .=
"</script>";
2801 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2805 if (!$notab || $notab == -1 || $notab == -2 || $notab == -3 || $notab == -4) {
2806 $out .=
"\n".
'<div id="dragDropAreaTabBar" class="tabBar'.($notab == -1 ?
'' : ($notab == -2 ?
' tabBarNoTop' : ((($notab == -3 || $notab == -4) ?
' noborderbottom' :
'').($notab == -4 ?
'' :
' tabBarWithBottom'))));
2809 if (!empty($dragdropfile)) {
2810 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2813 $parameters = array(
'tabname' => $active,
'out' => $out);
2814 $reshook = $hookmanager->executeHooks(
'printTabsHead', $parameters);
2816 $out = $hookmanager->resPrint;
2842 if (!$notab || $notab == -1) {
2843 return "\n</div>\n";
2868function dol_banner_tab(
$object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $onlybanner = 0, $morehtmlright =
'')
2870 global
$conf, $form, $user, $langs, $hookmanager, $action;
2874 $maxvisiblephotos = 1;
2878 $showbarcode = !isModEnabled(
'barcode') ? 0 : (empty(
$object->barcode) ? 0 : 1);
2879 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2882 $modulepart =
'unknown';
2884 if (in_array(
$object->element, [
'societe',
'contact',
'product',
'ticket',
'bom'])) {
2885 $modulepart =
$object->element;
2886 } elseif (
$object->element ==
'member') {
2887 $modulepart =
'memberphoto';
2888 } elseif (
$object->element ==
'user') {
2889 $modulepart =
'userphoto';
2892 if (class_exists(
"Imagick")) {
2893 if (
$object->element ==
'expensereport' ||
$object->element ==
'propal' ||
$object->element ==
'commande' ||
$object->element ==
'facture' ||
$object->element ==
'supplier_proposal') {
2894 $modulepart =
$object->element;
2895 } elseif (
$object->element ==
'fichinter' ||
$object->element ==
'intervention') {
2896 $modulepart =
'ficheinter';
2897 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
2898 $modulepart =
'contract';
2899 } elseif (
$object->element ==
'order_supplier') {
2900 $modulepart =
'supplier_order';
2901 } elseif (
$object->element ==
'invoice_supplier') {
2902 $modulepart =
'supplier_invoice';
2906 if (
$object->element ==
'product') {
2908 '@phan-var-force Product $object';
2910 $cssclass =
'photowithmargin photoref';
2911 $showimage =
$object->is_photo_available(
$conf->product->multidir_output[$entity]);
2913 if (
$conf->browser->layout ==
'phone') {
2914 $maxvisiblephotos = 1;
2917 $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>';
2921 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2923 $nophoto =
'/public/theme/common/nophoto.png';
2924 $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>';
2927 } elseif (
$object->element ==
'category') {
2929 '@phan-var-force Categorie $object';
2931 $cssclass =
'photowithmargin photoref';
2932 $showimage =
$object->isAnyPhotoAvailable(
$conf->categorie->multidir_output[$entity]);
2934 if (
$conf->browser->layout ==
'phone') {
2935 $maxvisiblephotos = 1;
2938 $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>';
2942 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2944 $nophoto =
'/public/theme/common/nophoto.png';
2945 $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>';
2948 } elseif (
$object->element ==
'bom') {
2950 '@phan-var-force Bom $object';
2952 $cssclass =
'photowithmargin photoref';
2953 $showimage =
$object->is_photo_available(
$conf->bom->multidir_output[$entity]);
2955 if (
$conf->browser->layout ==
'phone') {
2956 $maxvisiblephotos = 1;
2959 $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>';
2963 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2965 $nophoto =
'/public/theme/common/nophoto.png';
2966 $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>';
2969 } elseif (
$object->element ==
'ticket') {
2971 $cssclass =
'photoref';
2973 '@phan-var-force Ticket $object';
2974 $showimage =
$object->is_photo_available(
$conf->ticket->multidir_output[$entity].
'/'.
$object->ref);
2976 if (
$conf->browser->layout ==
'phone') {
2977 $maxvisiblephotos = 1;
2981 $showphoto =
$object->show_photos(
'ticket',
$conf->ticket->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0);
2983 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$showphoto.
'</div>';
2991 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2993 $nophoto =
img_picto(
'No photo',
'object_ticket');
2994 $morehtmlleft .=
'<!-- No photo to show -->';
2995 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2996 $morehtmlleft .= $nophoto;
2997 $morehtmlleft .=
'</div></div>';
3002 if ($modulepart !=
'unknown' || method_exists(
$object,
'getDataToShowPhoto')) {
3005 if (in_array($modulepart, array(
'propal',
'commande',
'facture',
'ficheinter',
'contract',
'supplier_order',
'supplier_proposal',
'supplier_invoice',
'expensereport')) && class_exists(
"Imagick")) {
3007 $dir_output = (empty(
$conf->$modulepart->multidir_output[$entity]) ?
$conf->$modulepart->dir_output :
$conf->$modulepart->multidir_output[$entity]).
"/";
3008 if (in_array($modulepart, array(
'invoice_supplier',
'supplier_invoice'))) {
3010 $subdir .= ((!empty($subdir) && !preg_match(
'/\/$/', $subdir)) ?
'/' :
'').$objectref;
3014 if (empty($subdir)) {
3015 $subdir =
'errorgettingsubdirofobject';
3018 $filepath = $dir_output.$subdir.
"/";
3020 $filepdf = $filepath.$objectref.
".pdf";
3021 $relativepath = $subdir.
'/'.$objectref.
'.pdf';
3024 $fileimage = $filepdf.
'_preview.png';
3025 $relativepathimage = $relativepath.
'_preview.png';
3027 $pdfexists = file_exists($filepdf);
3032 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
3034 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
3043 if ($pdfexists && !$error) {
3044 $heightforphotref = 80;
3045 if (!empty(
$conf->dol_optimize_smallscreen)) {
3046 $heightforphotref = 60;
3049 if (file_exists($fileimage)) {
3050 $phototoshow =
'<div class="photoref">';
3051 $phototoshow .=
'<img height="'.$heightforphotref.
'" class="photo photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
3052 $phototoshow .=
'</div>';
3055 } elseif (!$phototoshow) {
3056 $phototoshow .= $form->showphoto($modulepart,
$object, 0, 0, 0,
'photowithmargin photoref',
'small', 1, 0, $maxvisiblephotos);
3060 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
3061 $morehtmlleft .= $phototoshow;
3062 $morehtmlleft .=
'</div>';
3066 if (empty($phototoshow)) {
3067 if (
$object->element ==
'action') {
3069 $cssclass =
'photorefcenter';
3070 $nophoto =
img_picto(
'No photo',
'title_agenda');
3073 $cssclass =
'photorefcenter';
3075 $prefix =
'object_';
3079 if (strpos($picto,
'fontawesome_') !==
false) {
3082 $nophoto =
img_picto(
'No photo', $prefix.$picto);
3084 $morehtmlleft .=
'<!-- No photo to show -->';
3085 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
3086 $morehtmlleft .= $nophoto;
3087 $morehtmlleft .=
'</div></div>';
3094 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode(
$object, 100,
'photoref valignmiddle').
'</div>';
3097 if (
$object->element ==
'societe') {
3098 if (!empty(
$conf->use_javascript_ajax) && $user->hasRight(
'societe',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3101 $morehtmlstatus .=
$object->getLibStatut(6);
3103 } elseif (
$object->element ==
'product') {
3105 if (!empty(
$conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3106 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
3108 $morehtmlstatus .=
'<span class="statusrefsell">'.$object->getLibStatut(6, 0).
'</span>';
3110 $morehtmlstatus .=
' ';
3112 if (!empty(
$conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3113 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
3115 $morehtmlstatus .=
'<span class="statusrefbuy">'.$object->getLibStatut(6, 1).
'</span>';
3117 } elseif (in_array(
$object->element, array(
'salary'))) {
3119 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3122 $morehtmlstatus .= $tmptxt;
3123 } elseif (in_array(
$object->element, array(
'facture',
'invoice',
'invoice_supplier'))) {
3124 $totalallpayments =
$object->getSommePaiement(0);
3125 $totalallpayments +=
$object->getSumCreditNotesUsed(0);
3126 $totalallpayments +=
$object->getSumDepositsUsed(0);
3127 $tmptxt =
$object->getLibStatut(6, $totalallpayments);
3128 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3129 $tmptxt =
$object->getLibStatut(5, $totalallpayments);
3131 $morehtmlstatus .= $tmptxt;
3132 } elseif (in_array(
$object->element, array(
'chargesociales',
'loan',
'tva'))) {
3134 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3137 $morehtmlstatus .= $tmptxt;
3138 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
3140 $morehtmlstatus .=
$object->getLibStatut(5);
3142 $morehtmlstatus .=
$object->getLibStatut(4);
3144 } elseif (
$object->element ==
'facturerec') {
3145 '@phan-var-force FactureRec $object';
3146 if (
$object->frequency == 0) {
3147 $morehtmlstatus .=
$object->getLibStatut(2);
3149 $morehtmlstatus .=
$object->getLibStatut(5);
3151 } elseif (
$object->element ==
'project_task') {
3158 if (
$object->progress >= 100) {
3162 $tmptxt =
$object->getLibStatut(5);
3163 $morehtmlstatus .= $tmptxt;
3164 } elseif (method_exists(
$object,
'getLibStatut')) {
3165 $tmptxt =
$object->getLibStatut(6);
3166 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3167 $tmptxt =
$object->getLibStatut(5);
3169 $morehtmlstatus .= $tmptxt;
3173 if (isModEnabled(
'accounting') && in_array(
$object->element, array(
'bank',
'paiementcharge',
'facture',
'invoice',
'invoice_supplier',
'expensereport',
'payment_various'))) {
3175 if (method_exists(
$object,
'getVentilExportCompta')) {
3176 $accounted =
$object->getVentilExportCompta();
3177 $langs->load(
"accountancy");
3178 $morehtmlstatus .=
'</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? $langs->trans(
"Accounted") : $langs->trans(
"NotYetAccounted")).
'</span>';
3183 if (!empty(
$object->name_alias)) {
3184 '@phan-var-force Societe $object';
3185 $morehtmlref .=
'<div class="refidno opacitymedium">'.dol_escape_htmltag(
$object->name_alias).
'</div>';
3189 if (in_array(
$object->element, array(
'product',
'bank_account',
'project_task'))) {
3191 $morehtmlref .=
'<div class="refidno opacitymedium">'.$object->label.
'</div>';
3195 if (method_exists(
$object,
'getBannerAddress') && !in_array(
$object->element, array(
'product',
'bookmark',
'ecm_directories',
'ecm_files'))) {
3198 $morehtmlref .=
'<div class="refidno refaddress">';
3199 $morehtmlref .= $moreaddress;
3200 $morehtmlref .=
'</div>';
3204 $morehtmlref .=
'<div style="clear: both;"></div>';
3205 $morehtmlref .=
'<div class="refidno opacitymedium">';
3206 $morehtmlref .= $langs->trans(
"TechnicalID").
': '.((int)
$object->id);
3207 $morehtmlref .=
'</div>';
3210 $parameters = array(
'morehtmlref' => &$morehtmlref,
'moreparam' => &$moreparam,
'morehtmlleft' => &$morehtmlleft,
'morehtmlstatus' => &$morehtmlstatus,
'morehtmlright' => &$morehtmlright);
3211 $reshook = $hookmanager->executeHooks(
'formDolBanner', $parameters,
$object, $action);
3214 } elseif (empty($reshook)) {
3215 $morehtmlref .= $hookmanager->resPrint;
3216 } elseif ($reshook > 0) {
3217 $morehtmlref = $hookmanager->resPrint;
3225 print
'<div class="'.($onlybanner ?
'arearefnobottom ' :
'arearef ').
'heightref valignmiddle centpercent">';
3226 print $form->showrefnav(
$object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
3228 print
'<div class="underrefbanner clearboth"></div>';
3240function fieldLabel($langkey, $fieldkey, $fieldrequired = 0)
3244 if ($fieldrequired) {
3245 $ret .=
'<span class="fieldrequired">';
3247 $ret .=
'<label for="'.$fieldkey.
'">';
3248 $ret .= $langs->trans($langkey);
3250 if ($fieldrequired) {
3271 global $langs, $hookmanager;
3274 $countriesusingstate = array(
'AU',
'CA',
'US',
'IN',
'GB',
'ES',
'UK',
'TR',
'CN');
3279 $ret .= ($extralangcode ?
$object->array_languages[
'address'][$extralangcode] : (empty(
$object->address) ?
'' : preg_replace(
'/(\r\n|\r|\n)+/', $sep,
$object->address)));
3282 if (isset(
$object->country_code) && in_array(
$object->country_code, array(
'AU',
'CA',
'US',
'CN')) ||
getDolGlobalString(
'MAIN_FORCE_STATE_INTO_ADDRESS')) {
3284 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3285 $ret .= (($ret && $town) ? $sep :
'').$town;
3288 $ret .= ($ret ? ($town ?
", " : $sep) :
'').
$object->state;
3291 $ret .= ($ret ? (($town ||
$object->state) ?
", " : $sep) :
'').
$object->zip;
3293 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'GB',
'UK'))) {
3295 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3296 $ret .= ($ret ? $sep :
'').$town;
3298 $ret .= ($ret ?
", " :
'').
$object->state;
3301 $ret .= ($ret ? $sep :
'').
$object->zip;
3303 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'ES',
'TR'))) {
3305 $ret .= ($ret ? $sep :
'').
$object->zip;
3306 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3307 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3309 $ret .= $sep.$object->state;
3311 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'JP'))) {
3314 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3316 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'IT'))) {
3318 $ret .= ($ret ? $sep :
'').
$object->zip;
3319 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3320 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3321 $ret .= (empty(
$object->state_code) ?
'' : (
' '.$object->state_code));
3324 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3325 $ret .= !empty(
$object->zip) ? (($ret ? $sep :
'').
$object->zip) :
'';
3326 $ret .= ($town ? ((
$object->zip ?
' ' : ($ret ? $sep :
'')).$town) :
'');
3327 if (!empty(
$object->state) && in_array(
$object->country_code, $countriesusingstate)) {
3328 $ret .= ($ret ?
", " :
'').
$object->state;
3332 if (!is_object($outputlangs)) {
3333 $outputlangs = $langs;
3336 $langs->load(
"dict");
3337 $ret .= (empty(
$object->country_code) ?
'' : ($ret ? $sep :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$object->country_code)));
3340 $parameters = array(
'withcountry' => $withcountry,
'sep' => $sep,
'outputlangs' => $outputlangs,
'mode' => $mode,
'extralangcode' => $extralangcode);
3341 $reshook = $hookmanager->executeHooks(
'formatAddress', $parameters,
$object);
3345 $ret .= $hookmanager->resPrint;
3362function dol_strftime($fmt, $ts =
false, $is_gmt =
false)
3364 if ((abs($ts) <= 0x7FFFFFFF)) {
3367 return 'Error date outside supported range';
3392function dol_print_date($time, $format =
'', $tzoutput =
'auto', $outputlangs =
null, $encodetooutput =
false)
3394 global
$conf, $langs;
3401 if ($tzoutput ===
'auto') {
3402 $tzoutput = (empty(
$conf) ?
'tzserver' : (isset(
$conf->tzuserinputkey) ?
$conf->tzuserinputkey :
'tzserver'));
3407 $offsettz = $offsetdst = 0;
3410 if (is_string($tzoutput)) {
3411 if ($tzoutput ==
'tzserver') {
3413 $offsettzstring = @date_default_timezone_get();
3418 } elseif ($tzoutput ==
'tzuser' || $tzoutput ==
'tzuserrel') {
3420 $offsettzstring = (empty($_SESSION[
'dol_tz_string']) ?
'UTC' : $_SESSION[
'dol_tz_string']);
3422 if (class_exists(
'DateTimeZone')) {
3423 $user_date_tz =
new DateTimeZone($offsettzstring);
3424 $user_dt =
new DateTime();
3425 $user_dt->setTimezone($user_date_tz);
3426 $user_dt->setTimestamp($tzoutput ==
'tzuser' ?
dol_now() : (int) $time);
3427 $offsettz = $user_dt->getOffset();
3429 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3430 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3435 if (!is_object($outputlangs)) {
3436 $outputlangs = $langs;
3439 $format =
'daytextshort';
3444 $reduceformat = (!empty(
$conf->dol_optimize_smallscreen) && in_array($format, array(
'day',
'dayhour',
'dayhoursec'))) ? 1 : 0;
3445 $format = preg_replace(
'/inputnoreduce/',
'', $format);
3446 $formatwithoutreduce = preg_replace(
'/reduceformat/',
'', $format);
3447 if ($formatwithoutreduce != $format) {
3448 $format = $formatwithoutreduce;
3454 if ($format ==
'day') {
3455 $format = ($outputlangs->trans(
"FormatDateShort") !=
"FormatDateShort" ? $outputlangs->trans(
"FormatDateShort") :
$conf->format_date_short);
3456 } elseif ($format ==
'hour') {
3457 $format = ($outputlangs->trans(
"FormatHourShort") !=
"FormatHourShort" ? $outputlangs->trans(
"FormatHourShort") :
$conf->format_hour_short);
3458 } elseif ($format ==
'hourduration') {
3459 $format = ($outputlangs->trans(
"FormatHourShortDuration") !=
"FormatHourShortDuration" ? $outputlangs->trans(
"FormatHourShortDuration") :
$conf->format_hour_short_duration);
3460 } elseif ($format ==
'daytext') {
3461 $format = ($outputlangs->trans(
"FormatDateText") !=
"FormatDateText" ? $outputlangs->trans(
"FormatDateText") :
$conf->format_date_text);
3462 } elseif ($format ==
'daytextshort') {
3463 $format = ($outputlangs->trans(
"FormatDateTextShort") !=
"FormatDateTextShort" ? $outputlangs->trans(
"FormatDateTextShort") :
$conf->format_date_text_short);
3464 } elseif ($format ==
'dayhour') {
3465 $format = ($outputlangs->trans(
"FormatDateHourShort") !=
"FormatDateHourShort" ? $outputlangs->trans(
"FormatDateHourShort") :
$conf->format_date_hour_short);
3466 } elseif ($format ==
'dayhoursec') {
3467 $format = ($outputlangs->trans(
"FormatDateHourSecShort") !=
"FormatDateHourSecShort" ? $outputlangs->trans(
"FormatDateHourSecShort") :
$conf->format_date_hour_sec_short);
3468 } elseif ($format ==
'dayhourtext') {
3469 $format = ($outputlangs->trans(
"FormatDateHourText") !=
"FormatDateHourText" ? $outputlangs->trans(
"FormatDateHourText") :
$conf->format_date_hour_text);
3470 } elseif ($format ==
'dayhourtextshort') {
3471 $format = ($outputlangs->trans(
"FormatDateHourTextShort") !=
"FormatDateHourTextShort" ? $outputlangs->trans(
"FormatDateHourTextShort") :
$conf->format_date_hour_text_short);
3472 } elseif ($format ==
'dayhourlog') {
3474 $format =
'%Y%m%d%H%M%S';
3475 } elseif ($format ==
'dayhourlogsmall') {
3477 $format =
'%y%m%d%H%M';
3478 } elseif ($format ==
'dayhourldap') {
3479 $format =
'%Y%m%d%H%M%SZ';
3480 } elseif ($format ==
'dayhourxcard') {
3481 $format =
'%Y%m%dT%H%M%SZ';
3482 } elseif ($format ==
'dayxcard') {
3484 } elseif ($format ==
'dayrfc') {
3485 $format =
'%Y-%m-%d';
3486 } elseif ($format ==
'dayhourrfc') {
3487 $format =
'%Y-%m-%dT%H:%M:%SZ';
3488 } elseif ($format ==
'standard') {
3489 $format =
'%Y-%m-%d %H:%M:%S';
3492 if ($reduceformat) {
3493 $format = str_replace(
'%Y',
'%y', $format);
3494 $format = str_replace(
'yyyy',
'yy', $format);
3498 if (preg_match(
'/%b/i', $format)) {
3500 $format = str_replace(
'%b',
'__b__', $format);
3501 $format = str_replace(
'%B',
'__B__', $format);
3503 if (preg_match(
'/%a/i', $format)) {
3505 $format = str_replace(
'%a',
'__a__', $format);
3506 $format = str_replace(
'%A',
'__A__', $format);
3511 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)) {
3512 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"]));
3514 } elseif (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', (
string) $time, $reg)) {
3516 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);
3519 $syear = (!empty($reg[1]) ? $reg[1] :
'');
3520 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
3521 $sday = (!empty($reg[3]) ? $reg[3] :
'');
3522 $shour = (!empty($reg[4]) ? $reg[4] :
'');
3523 $smin = (!empty($reg[5]) ? $reg[5] :
'');
3524 $ssec = (!empty($reg[6]) ? $reg[6] :
'');
3526 $time =
dol_mktime((
int) $shour, (
int) $smin, (
int) $ssec, (
int) $smonth, (
int) $sday, (
int) $syear,
true);
3529 $tzo =
new DateTimeZone(
'UTC');
3531 $tzo =
new DateTimeZone(date_default_timezone_get());
3533 $dtts =
new DateTime();
3534 $dtts->setTimestamp($time);
3535 $dtts->setTimezone($tzo);
3536 $newformat = str_replace(
3537 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3538 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3541 $ret = $dtts->format($newformat);
3543 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3544 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3549 if ($time < 100000000000) {
3550 $timetouse = $time + $offsettz + $offsetdst;
3553 $tzo =
new DateTimeZone(
'UTC');
3555 $tzo =
new DateTimeZone(date_default_timezone_get());
3557 $dtts =
new DateTime();
3558 $dtts->setTimestamp($timetouse);
3559 $dtts->setTimezone($tzo);
3560 $newformat = str_replace(
3561 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'%w',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3562 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'w',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3565 $ret = $dtts->format($newformat);
3567 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3568 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3573 $ret =
'Bad value '.$time.
' for date';
3577 if (preg_match(
'/__b__/i', $format)) {
3578 $timetouse = $time + $offsettz + $offsetdst;
3581 $tzo =
new DateTimeZone(
'UTC');
3583 $tzo =
new DateTimeZone(date_default_timezone_get());
3585 $dtts =
new DateTime();
3586 $dtts->setTimestamp($timetouse);
3587 $dtts->setTimezone($tzo);
3588 $month = (int) $dtts->format(
"m");
3589 $month = sprintf(
"%02d", $month);
3590 if ($encodetooutput) {
3591 $monthtext = $outputlangs->transnoentities(
'Month'.$month);
3592 $monthtextshort = $outputlangs->transnoentities(
'MonthShort'.$month);
3594 $monthtext = $outputlangs->transnoentitiesnoconv(
'Month'.$month);
3595 $monthtextshort = $outputlangs->transnoentitiesnoconv(
'MonthShort'.$month);
3598 $ret = str_replace(
'__b__', $monthtextshort, $ret);
3599 $ret = str_replace(
'__B__', $monthtext, $ret);
3603 if (preg_match(
'/__a__/i', $format)) {
3605 $timetouse = $time + $offsettz + $offsetdst;
3608 $tzo =
new DateTimeZone(
'UTC');
3610 $tzo =
new DateTimeZone(date_default_timezone_get());
3612 $dtts =
new DateTime();
3613 $dtts->setTimestamp($timetouse);
3614 $dtts->setTimezone($tzo);
3615 $w = $dtts->format(
"w");
3616 $dayweek = $outputlangs->transnoentitiesnoconv(
'Day'.$w);
3618 $ret = str_replace(
'__A__', $dayweek, $ret);
3619 $ret = str_replace(
'__a__',
dol_substr($dayweek, 0, 3), $ret);
3646function dol_getdate($timestamp, $fast =
false, $forcetimezone =
'')
3648 if ($timestamp ===
'') {
3652 $datetimeobj =
new DateTime();
3653 $datetimeobj->setTimestamp($timestamp);
3654 if ($forcetimezone) {
3655 $datetimeobj->setTimezone(
new DateTimeZone($forcetimezone ==
'gmt' ?
'UTC' : $forcetimezone));
3658 'year' => ((
int) date_format($datetimeobj,
'Y')),
3659 'mon' => ((
int) date_format($datetimeobj,
'm')),
3660 'mday' => ((
int) date_format($datetimeobj,
'd')),
3661 'wday' => ((
int) date_format($datetimeobj,
'w')),
3662 'yday' => ((
int) date_format($datetimeobj,
'z')),
3663 'hours' => ((
int) date_format($datetimeobj,
'H')),
3664 'minutes' => ((
int) date_format($datetimeobj,
'i')),
3665 'seconds' => ((
int) date_format($datetimeobj,
's')),
3693function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm =
'auto', $check = 1)
3698 if ($gm ===
'auto') {
3699 $gm = (empty(
$conf) ?
'tzserver' :
$conf->tzuserinputkey);
3704 if ($hour == -1 || empty($hour)) {
3707 if ($minute == -1 || empty($minute)) {
3710 if ($second == -1 || empty($second)) {
3716 if (!$month || !$day) {
3725 if ($hour < 0 || $hour > 24) {
3728 if ($minute < 0 || $minute > 60) {
3731 if ($second < 0 || $second > 60) {
3736 if (empty($gm) || ($gm ===
'server' || $gm ===
'tzserver')) {
3737 $default_timezone = @date_default_timezone_get();
3738 $localtz =
new DateTimeZone($default_timezone);
3739 } elseif ($gm ===
'user' || $gm ===
'tzuser' || $gm ===
'tzuserrel') {
3741 $default_timezone = (empty($_SESSION[
"dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION[
"dol_tz_string"]);
3743 $localtz =
new DateTimeZone($default_timezone);
3745 dol_syslog(
"Warning dol_tz_string contains an invalid value ".json_encode($_SESSION[
"dol_tz_string"] ??
null), LOG_WARNING);
3746 $default_timezone = @date_default_timezone_get();
3748 } elseif (strrpos($gm,
"tz,") !==
false) {
3749 $timezone = str_replace(
"tz,",
"", $gm);
3751 $localtz =
new DateTimeZone($timezone);
3753 dol_syslog(
"Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
3757 if (empty($localtz)) {
3758 $localtz =
new DateTimeZone(
'UTC');
3762 $dt =
new DateTime(
'now', $localtz);
3763 $dt->setDate((
int) $year, (
int) $month, (
int) $day);
3764 $dt->setTime((
int) $hour, (
int) $minute, (
int) $second);
3765 $date = $dt->getTimestamp();
3781function dol_now($mode =
'auto')
3785 if ($mode ===
'auto') {
3789 if ($mode ==
'gmt') {
3791 } elseif ($mode ==
'tzserver') {
3792 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
3794 $ret = (int) (
dol_now(
'gmt') + ($tzsecond * 3600));
3800 } elseif ($mode ==
'tzuser' || $mode ==
'tzuserrel') {
3803 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3804 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3805 $ret = (int) (
dol_now(
'gmt') + ($offsettz + $offsetdst));
3822 global
$conf, $langs;
3825 if (!empty(
$conf->dol_optimize_smallscreen)) {
3830 if (empty($shortvalue) || $size < ($level * 10)) {
3832 $textunitshort = $langs->trans(
"b");
3833 $textunitlong = $langs->trans(
"Bytes");
3835 $ret = round($size / $level, 0);
3836 $textunitshort = $langs->trans(
"Kb");
3837 $textunitlong = $langs->trans(
"KiloBytes");
3840 if (empty($shortunit)) {
3841 $ret .=
' '.$textunitlong;
3843 $ret .=
' '.$textunitshort;
3859function dol_print_url($url, $target =
'_blank', $max = 32, $withpicto = 0, $morecss =
'')
3867 $linkstart =
'<a href="';
3868 if (!preg_match(
'/^http/i', $url)) {
3869 $linkstart .=
'http://';
3874 $linkstart .=
' target="'.$target.
'"';
3876 $linkstart .=
' title="'.$langs->trans(
"URL").
': '.$url.
'"';
3880 if (!preg_match(
'/^http/i', $url)) {
3887 if ($morecss ==
'float') {
3888 return '<div class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe',
'class="paddingrightonly"') :
'').$link.
'</div>';
3890 return $linkstart.
'<span class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto(
'',
'globe',
'class="paddingrightonly"') :
'').$link.
'</span>'.$linkend;
3907function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0, $morecss =
'paddingrightonly')
3909 global $user, $langs, $hookmanager;
3920 if (empty($email)) {
3924 if ($addlink == 1) {
3925 $newemail =
'<a class="'.($morecss ? $morecss :
'').
'" style="text-overflow: ellipsis;" href="';
3926 if (!preg_match(
'/^mailto:/i', $email)) {
3927 $newemail .=
'mailto:';
3929 $newemail .= $email;
3930 $newemail .=
'" target="_blank">';
3932 $newemail .= ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'');
3937 $newemail .= $email;
3939 $newemail .=
'</a>';
3941 $langs->load(
"errors");
3942 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email),
'',
'paddingrightonly');
3945 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
3947 $linktoaddaction =
'';
3949 $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>';
3951 if ($linktoaddaction) {
3952 $newemail =
'<div>'.$newemail.
' '.$linktoaddaction.
'</div>';
3955 } elseif ($addlink ===
'thirdparty') {
3956 $tmpnewemail =
'<a class="'.($morecss ? $morecss :
'').
'" style="text-overflow: ellipsis;" href="'.DOL_URL_ROOT.
'/societe/card.php?socid='.$socid.
'&action=presend&mode=init#formmailbeforetitle">';
3957 $tmpnewemail .= ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'');
3958 if ($withpicto == 1) {
3959 $tmpnewemail .= $newemail;
3961 $tmpnewemail .=
'</a>';
3963 $newemail = $tmpnewemail;
3965 $newemail = ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'').$newemail;
3968 $langs->load(
"errors");
3969 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
3979 $parameters = array(
'cid' => $cid,
'socid' => $socid,
'addlink' => $addlink,
'picto' => $withpicto);
3981 $reshook = $hookmanager->executeHooks(
'printEmail', $parameters, $email);
3985 $rep .= $hookmanager->resPrint;
4000 $socialnetworks = array();
4002 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
4003 $cachekey =
'socialnetworks_' .
$conf->entity;
4005 if (!is_null($dataretrieved)) {
4006 $socialnetworks = $dataretrieved;
4008 $sql =
"SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX.
"c_socialnetworks";
4009 $sql .=
" WHERE entity=".$conf->entity;
4010 $resql = $db->query($sql);
4012 while ($obj = $db->fetch_object($resql)) {
4013 $socialnetworks[$obj->code] = array(
4014 'rowid' => $obj->rowid,
4015 'label' => $obj->label,
4017 'icon' => $obj->icon,
4018 'active' => $obj->active,
4024 return $socialnetworks;
4039 global $hookmanager, $langs, $user;
4043 if (empty($value)) {
4047 if (!empty($type)) {
4048 $htmllink =
'<div class="divsocialnetwork inline-block valignmiddle">';
4050 $htmllink .=
'<span class="fab pictofixedwidth '.($dictsocialnetworks[$type][
'icon'] ? $dictsocialnetworks[$type][
'icon'] :
'fa-link').
'"></span>';
4051 if ($type ==
'skype') {
4053 $htmllink .=
' <a href="skype:';
4055 $htmllink .=
'?call" alt="'.$langs->trans(
"Call").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Call").
' '.$value).
'">';
4056 $htmllink .=
'<img src="'.DOL_URL_ROOT.
'/theme/common/skype_callbutton.png" border="0">';
4057 $htmllink .=
'</a><a href="skype:';
4059 $htmllink .=
'?chat" alt="'.$langs->trans(
"Chat").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Chat").
' '.$value).
'">';
4060 $htmllink .=
'<img class="paddingleft" src="'.DOL_URL_ROOT.
'/theme/common/skype_chatbutton.png" border="0">';
4061 $htmllink .=
'</a>';
4062 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
4063 $addlink =
'AC_SKYPE';
4066 $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>';
4068 $htmllink .= ($link ?
' '.$link :
'');
4071 $networkconstname =
'MAIN_INFO_SOCIETE_'.strtoupper($type).
'_URL';
4074 if (preg_match(
'/^https?:\/\//i', $link)) {
4075 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
4077 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
4079 } elseif (!empty($dictsocialnetworks[$type][
'url'])) {
4080 $tmpvirginurl = preg_replace(
'/\/?{socialid}/',
'', $dictsocialnetworks[$type][
'url']);
4081 if ($tmpvirginurl) {
4082 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
4083 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
4085 $tmpvirginurl3 = preg_replace(
'/^https:\/\//i',
'https://www.', $tmpvirginurl);
4086 if ($tmpvirginurl3) {
4087 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
4088 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
4091 $tmpvirginurl2 = preg_replace(
'/^https?:\/\//i',
'', $tmpvirginurl);
4092 if ($tmpvirginurl2) {
4093 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
4094 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
4097 $link = str_replace(
'{socialid}', $value, $dictsocialnetworks[$type][
'url']);
4098 if (preg_match(
'/^https?:\/\//i', $link)) {
4099 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
4101 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
4107 $htmllink .=
'</div>';
4109 $langs->load(
"errors");
4110 $htmllink .=
img_warning($langs->trans(
"ErrorBadSocialNetworkValue", $value));
4114 $parameters = array(
4119 'dictsocialnetworks' => $dictsocialnetworks,
4122 $reshook = $hookmanager->executeHooks(
'printSocialNetworks', $parameters);
4126 $htmllink .= $hookmanager->resPrint;
4141function dol_print_profids($profID, $profIDtype, $countrycode =
'', $addcpButton = 1)
4145 if (empty($profID) || empty($profIDtype)) {
4148 if (empty($countrycode)) {
4149 $countrycode = $mysoc->country_code;
4151 $newProfID = $profID;
4152 $id = substr($profIDtype, -1);
4154 if (strtoupper($countrycode) ==
'FR') {
4160 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3);
4164 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3).
' '.substr($newProfID, 9, 5);
4168 $newProfID = substr($newProfID, 0, 2).
'.'.substr($newProfID, 2, 3);
4170 if ($profIDtype ===
'VAT' &&
dol_strlen($newProfID) == 13) {
4172 $newProfID = substr($newProfID, 0, 4).
' '.substr($newProfID, 4, 3).
' '.substr($newProfID, 7, 3).
' '.substr($newProfID, 10, 3);
4175 if (!empty($addcpButton)) {
4198function dol_print_phone($phone, $countrycode =
'', $cid = 0, $socid = 0, $addlink =
'', $separ =
" ", $withpicto =
'', $titlealt =
'', $adddivfloat = 0, $morecss =
'paddingright')
4200 global
$conf, $user, $langs, $mysoc, $hookmanager;
4203 $phone = is_null($phone) ?
'' : preg_replace(
"/[\s.-]/",
"", trim($phone));
4204 if (empty($phone)) {
4210 if (empty($countrycode) && is_object($mysoc)) {
4211 $countrycode = $mysoc->country_code;
4215 if (!empty(
$conf->dol_optimize_smallscreen) && $separ !=
'hidenum') {
4220 $newphonewa = $phone;
4221 if (strtoupper($countrycode) ==
"FR") {
4224 $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);
4226 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
4228 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
4230 $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);
4232 $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);
4234 $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);
4236 } elseif (strtoupper($countrycode) ==
"CA") {
4238 $newphone = ($separ !=
'' ?
'(' :
'').substr($newphone, 0, 3).($separ !=
'' ?
')' :
'').$separ.substr($newphone, 3, 3).($separ !=
'' ?
'-' :
'').substr($newphone, 6, 4);
4240 } elseif (strtoupper($countrycode) ==
"PT") {
4242 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4244 } elseif (strtoupper($countrycode) ==
"SR") {
4246 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
4248 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
4250 } elseif (strtoupper($countrycode) ==
"DE") {
4252 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
4254 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
4256 } elseif (strtoupper($countrycode) ==
"ES") {
4258 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4260 } elseif (strtoupper($countrycode) ==
"BF") {
4262 $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);
4264 } elseif (strtoupper($countrycode) ==
"RO") {
4266 $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);
4268 } elseif (strtoupper($countrycode) ==
"TR") {
4270 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4272 } elseif (strtoupper($countrycode) ==
"US") {
4274 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4276 } elseif (strtoupper($countrycode) ==
"MX") {
4278 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4280 $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);
4282 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4284 } elseif (strtoupper($countrycode) ==
"ML") {
4286 $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);
4288 } elseif (strtoupper($countrycode) ==
"TH") {
4290 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4292 $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);
4294 } elseif (strtoupper($countrycode) ==
"MU") {
4297 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
4299 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4301 } elseif (strtoupper($countrycode) ==
"ZA") {
4303 $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);
4305 } elseif (strtoupper($countrycode) ==
"SY") {
4307 $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);
4309 $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);
4311 } elseif (strtoupper($countrycode) ==
"AE") {
4313 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4315 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4317 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
4319 } elseif (strtoupper($countrycode) ==
"DZ") {
4321 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4323 } elseif (strtoupper($countrycode) ==
"BE") {
4325 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4327 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4329 } elseif (strtoupper($countrycode) ==
"PF") {
4331 $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);
4333 } elseif (strtoupper($countrycode) ==
"CO") {
4335 $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);
4337 } elseif (strtoupper($countrycode) ==
"JO") {
4339 $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);
4341 } elseif (strtoupper($countrycode) ==
"JM") {
4343 $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4345 } elseif (strtoupper($countrycode) ==
"MG") {
4347 $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);
4349 } elseif (strtoupper($countrycode) ==
"GB") {
4351 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4353 } elseif (strtoupper($countrycode) ==
"CH") {
4355 $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);
4357 $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);
4359 } elseif (strtoupper($countrycode) ==
"TN") {
4361 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4363 } elseif (strtoupper($countrycode) ==
"GF") {
4365 $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);
4367 } elseif (strtoupper($countrycode) ==
"GP") {
4369 $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);
4371 } elseif (strtoupper($countrycode) ==
"MQ") {
4373 $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);
4375 } elseif (strtoupper($countrycode) ==
"IT") {
4377 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4379 $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);
4381 } elseif (strtoupper($countrycode) ==
"AU") {
4385 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
4387 } elseif (strtoupper($countrycode) ==
"LU") {
4390 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
4392 $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);
4394 $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);
4396 $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);
4398 } elseif (strtoupper($countrycode) ==
"PE") {
4401 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4);
4403 $newphonewa =
'+51'.$newphone;
4404 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 10, 3);
4406 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 8, 4);
4408 $newphonewa = $newphone;
4409 $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);
4413 $newphoneastart = $newphoneaend =
'';
4414 if (!empty($addlink)) {
4415 if ($addlink ==
'tel' ||
$conf->browser->layout ==
'phone' || (isModEnabled(
'clicktodial') &&
getDolGlobalString(
'CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS'))) {
4416 $newphoneastart =
'<a href="tel:'.urlencode($phone).
'">';
4417 $newphoneaend .=
'</a>';
4418 } elseif (isModEnabled(
'clicktodial') && $addlink ==
'AC_TEL') {
4419 if (empty($user->clicktodial_loaded)) {
4420 $user->fetch_clicktodial();
4424 $urlmask =
getDolGlobalString(
'CLICKTODIAL_URL',
'ErrorClickToDialModuleNotConfigured');
4425 if (!empty($user->clicktodial_url)) {
4426 $urlmask = $user->clicktodial_url;
4429 $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) :
'');
4430 $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) :
'');
4431 $clicktodial_password = (!empty($user->clicktodial_password) ? urlencode($user->clicktodial_password) :
'');
4433 $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
4435 $substitarray = array(
'__PHONEFROM__' => $clicktodial_poste,
4436 '__PHONETO__' => urlencode($phone),
4437 '__LOGIN__' => $clicktodial_login,
4438 '__PASS__' => $clicktodial_password);
4442 $newphoneastart =
'<a href="'.$url.
'" class="cssforclicktodial">';
4443 $newphoneaend =
'</a>';
4446 $newphoneastart =
'<a href="'.$url.
'"';
4448 $newphoneastart .=
' target="_blank" rel="noopener noreferrer"';
4450 $newphoneastart .=
'>';
4451 $newphoneaend .=
'</a>';
4456 if (isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
4458 $addlinktoagenda =
'';
4459 if ($addlink ==
'AC_FAX') {
4463 $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>';
4465 if ($addlinktoagenda) {
4466 $newphone =
'<span>'.$newphone.
' '.$addlinktoagenda.
'</span>';
4471 if (
getDolGlobalString(
'CONTACT_PHONEMOBILE_SHOW_LINK_TO_WHATSAPP') && $withpicto ==
'mobile') {
4473 $newphone .=
' <a href="https://wa.me/'.$newphonewa.
'" target="_blank"';
4474 $newphone .=
'><span class="paddingright fab fa-whatsapp" style="color:#25D366;" title="WhatsApp"></span></a>';
4477 if (empty($titlealt)) {
4478 $titlealt = ($withpicto ==
'fax' ? $langs->trans(
"Fax") : $langs->trans(
"Phone"));
4483 $parameters = array(
'countrycode' => $countrycode,
'cid' => $cid,
'socid' => $socid,
'titlealt' => $titlealt,
'picto' => $withpicto);
4484 $reshook = $hookmanager->executeHooks(
'printPhone', $parameters, $phone);
4485 $rep .= $hookmanager->resPrint;
4487 if (empty($reshook)) {
4490 if ($withpicto ==
'fax') {
4491 $picto =
'phoning_fax';
4492 } elseif ($withpicto ==
'phone') {
4494 } elseif ($withpicto ==
'mobile') {
4495 $picto =
'phoning_mobile';
4500 if ($adddivfloat == 1) {
4501 $rep .=
'<div class="nospan float'.($morecss ?
' '.$morecss :
'').
'">';
4502 } elseif (empty($adddivfloat)) {
4503 $rep .=
'<span'.($morecss ?
' class="'.$morecss.
'"' :
'').
'>';
4506 $rep .= $newphoneastart;
4507 $rep .= ($withpicto ?
img_picto($titlealt,
'object_'.$picto.
'.png') :
'');
4508 if ($separ !=
'hidenum') {
4509 $rep .= ($withpicto ?
' ' :
'').$newphone;
4511 $rep .= $newphoneaend;
4513 if ($adddivfloat == 1) {
4515 } elseif (empty($adddivfloat)) {
4543 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/common/flags/'.$countrycode.
'.png')) {
4544 $ret .=
' '.img_picto($countrycode.
' '.$langs->trans(
"AccordingToGeoIPDatabase"), DOL_URL_ROOT.
'/theme/common/flags/'.$countrycode.
'.png',
'', 1);
4546 $ret .=
' ('.$countrycode.
')';
4566 if (empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
4567 if (empty($_SERVER[
'HTTP_CLIENT_IP']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_CLIENT_IP'])) {
4568 if (empty($_SERVER[
"HTTP_CF_CONNECTING_IP"])) {
4569 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
4571 $ip = $_SERVER[
"HTTP_CF_CONNECTING_IP"];
4574 $ip = $_SERVER[
'HTTP_CLIENT_IP'];
4577 $ip = $_SERVER[
'HTTP_X_FORWARDED_FOR'];
4593 if (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on') {
4595 } 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') {
4613 if (isModEnabled(
'geoipmaxmind')) {
4617 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4618 $geoip =
new DolGeoIP(
'country', $datafile);
4620 $countrycode = $geoip->getCountryCodeFromIP($ip);
4623 return $countrycode;
4635 global
$conf, $langs, $user;
4639 if (isModEnabled(
'geoipmaxmind')) {
4644 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4645 $geoip =
new DolGeoIP(
'country', $datafile);
4646 $countrycode = $geoip->getCountryCodeFromIP($ip);
4647 $ret = $countrycode;
4666 global
$conf, $user, $langs, $hookmanager;
4672 $parameters = array(
'element' => $element,
'id' =>
$id);
4673 $reshook = $hookmanager->executeHooks(
'printAddress', $parameters, $address);
4674 $out .= $hookmanager->resPrint;
4676 if (empty($reshook)) {
4677 if (empty($charfornl)) {
4678 $out .= nl2br($address);
4680 $out .= preg_replace(
'/[\r\n]+/', $charfornl, $address);
4684 $showgmap = $showomap = 0;
4685 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS')) {
4688 if ($element ==
'contact' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_CONTACTS')) {
4691 if ($element ==
'member' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_MEMBERS')) {
4694 if ($element ==
'user' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_USERS')) {
4697 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS')) {
4700 if ($element ==
'contact' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_CONTACTS')) {
4703 if ($element ==
'member' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_MEMBERS')) {
4706 if ($element ==
'user' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_USERS')) {
4711 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4714 $url =
dol_buildpath(
'/openstreetmap/maps.php?mode='.$element.
'&id='.
$id, 1);
4715 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4737function isValidEmail($address, $acceptsupervisorkey = 0, $acceptuserkey = 0)
4739 if ($acceptsupervisorkey && $address ==
'__SUPERVISOREMAIL__') {
4742 if ($acceptuserkey && $address ==
'__USER_EMAIL__') {
4745 if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
4763 if (function_exists(
'idn_to_ascii') && function_exists(
'checkdnsrr')) {
4764 if (!checkdnsrr(idn_to_ascii($domain),
'MX')) {
4767 if (function_exists(
'getmxrr')) {
4770 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
4771 if (count($mxhosts) > 1) {
4774 if (count($mxhosts) == 1 && !in_array((
string) $mxhosts[0], array(
'',
'.'))) {
4811 $tmparray = explode(
' ', $s);
4812 foreach ($tmparray as $tmps) {
4827function dol_strlen($string, $stringencoding =
'UTF-8')
4829 if (is_null($string)) {
4833 if (function_exists(
'mb_strlen')) {
4834 return mb_strlen($string, $stringencoding);
4836 return strlen($string);
4850function dol_substr($string, $start, $length =
null, $stringencoding =
'', $trunconbytes = 0)
4854 if (empty($stringencoding)) {
4855 $stringencoding = (empty($langs) ?
'UTF-8' : $langs->charset_output);
4859 if (empty($trunconbytes)) {
4860 if (function_exists(
'mb_substr')) {
4861 $ret = mb_substr($string, $start, $length, $stringencoding);
4863 $ret = substr($string, $start, $length);
4866 if (function_exists(
'mb_strcut')) {
4867 $ret = mb_strcut($string, $start, $length, $stringencoding);
4869 $ret = substr($string, $start, $length);
4889function dol_trunc($string, $size = 40, $trunc =
'right', $stringencoding =
'UTF-8', $nodot = 0, $display = 0)
4897 if (empty($stringencoding)) {
4898 $stringencoding =
'UTF-8';
4901 if (!empty(
$conf->dol_optimize_smallscreen) &&
$conf->dol_optimize_smallscreen == 1 && $display == 1) {
4902 $size = round($size / 3);
4906 if ($trunc ==
'right') {
4908 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
4910 return dol_substr($newstring, 0, $size, $stringencoding).($nodot ?
'' :
'…');
4915 } elseif ($trunc ==
'middle') {
4917 if (
dol_strlen($newstring, $stringencoding) > 2 &&
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4918 $size1 = (int) round($size / 2);
4919 $size2 = (int) round($size / 2);
4920 return dol_substr($newstring, 0, $size1, $stringencoding).
'…'.
dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
4924 } elseif ($trunc ==
'left') {
4926 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
4928 return '…'.dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
4932 } elseif ($trunc ==
'wrap') {
4934 if (
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4940 return 'BadParam3CallingDolTrunc';
4954 $type2picto = array(
4955 'varchar' =>
'font',
4958 'int' =>
'sort-numeric-down',
4959 'double' =>
'sort-numeric-down',
4960 'price' =>
'currency',
4961 'pricecy' =>
'multicurrency',
4962 'password' =>
'key',
4963 'boolean' =>
'check-square',
4964 'date' =>
'calendar',
4965 'datetime' =>
'calendar',
4966 'duration' =>
'hourglass',
4972 'sellist' =>
'list',
4973 'stars' =>
'fontawesome_star_fas',
4974 'radio' =>
'check-circle',
4975 'checkbox' =>
'list',
4976 'chkbxlst' =>
'list',
4978 'icon' =>
"question",
4979 'point' =>
"country",
4980 'multipts' =>
'country',
4981 'linestrg' =>
"country",
4982 'polygon' =>
"country",
4983 'separate' =>
'minus'
4986 if (!empty($type2picto[$key])) {
4987 return img_picto(
'', $type2picto[$key],
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
4990 return img_picto(
'',
'generic',
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
5015function img_picto($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0, $alt =
'', $morecss =
'', $marginleftonlyshort = 2)
5020 $url = DOL_URL_ROOT;
5021 $theme = isset(
$conf->theme) ?
$conf->theme :
null;
5022 $path =
'theme/'.$theme;
5023 if (empty($picto)) {
5028 if ($pictoisfullpath) {
5030 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
5033 $fullpathpicto = $picto;
5035 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5036 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5037 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5042 $pictowithouttext = preg_replace(
'/(\.png|\.gif|\.svg)$/',
'', $picto);
5043 $pictowithouttext = str_replace(
'object_',
'', $pictowithouttext);
5044 $pictowithouttext = str_replace(
'_nocolor',
'', $pictowithouttext);
5047 $pictoconvertkey = array(
'facture' =>
'bill',
'shipping' =>
'shipment',
'fichinter' =>
'intervention',
'agenda' =>
'calendar',
'invoice_supplier' =>
'supplier_invoice',
'order_supplier' =>
'supplier_order');
5048 if (in_array($pictowithouttext, array_keys($pictoconvertkey))) {
5049 $pictowithouttext = $pictoconvertkey[$pictowithouttext];
5052 if (strpos($pictowithouttext,
'fontawesome_') === 0 || strpos($pictowithouttext,
'fa-') === 0) {
5054 $pictowithouttext = str_replace(
'fontawesome_',
'', $pictowithouttext);
5055 $pictowithouttext = str_replace(
'fa-',
'', $pictowithouttext);
5058 if ($pictowithouttext ==
'file-o') {
5059 $pictowithouttext =
'file';
5062 $pictowithouttextarray = explode(
'_', $pictowithouttext);
5063 $marginleftonlyshort = 0;
5065 if (!empty($pictowithouttextarray[1])) {
5067 $fakey =
'fa-'.$pictowithouttextarray[0];
5068 $faprefix = empty($pictowithouttextarray[1]) ?
'fas' : $pictowithouttextarray[1];
5069 $facolor = empty($pictowithouttextarray[2]) ?
'' : $pictowithouttextarray[2];
5070 $fasize = empty($pictowithouttextarray[3]) ?
'' : $pictowithouttextarray[3];
5072 $fakey =
'fa-'.$pictowithouttext;
5082 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5083 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5084 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5086 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
5087 $morestyle = $reg[1];
5088 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
5090 $moreatt = trim($moreatt);
5092 $enabledisablehtml =
'<span class="'.$faprefix.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
5093 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
5097 $enabledisablehtml .=
'</span>';
5099 return $enabledisablehtml;
5102 if (empty($srconly) && in_array($pictowithouttext, array(
5103 '1downarrow',
'1uparrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected',
5104 'accountancy',
'accounting_account',
'account',
'accountline',
'action',
'add',
'address',
'ai',
'angle-double-down',
'angle-double-up',
'asset',
5105 'back',
'bank_account',
'barcode',
'bank',
'bell',
'bill',
'billa',
'billr',
'billd',
'birthday-cake',
'bom',
'bookcal',
'bookmark',
'briefcase-medical',
'bug',
'building',
5106 'card',
'calendarlist',
'calendar',
'calendarmonth',
'calendarweek',
'calendarday',
'calendarperuser',
'calendarpertype',
'hourglass',
5107 'cash-register',
'category',
'chart',
'check',
'clock',
'clone',
'close_title',
'code',
'cog',
'collab',
'company',
'contact',
'country',
'contract',
'conversation',
'cron',
'cross',
'cubes',
5108 'check-circle',
'check-square',
'circle',
'stop-circle',
'currency',
'multicurrency',
5109 'chevron-left',
'chevron-right',
'chevron-down',
'chevron-top',
5110 'chevron-double-left',
'chevron-double-right',
'chevron-double-down',
'chevron-double-top',
5111 'commercial',
'companies',
5112 'delete',
'dolly',
'dollyrevert',
'donation',
'download',
'dynamicprice',
5113 'edit',
'ellipsis-h',
'email',
'entity',
'envelope',
'eraser',
'establishment',
'expensereport',
'external-link-alt',
'external-link-square-alt',
'eye',
5114 'filter',
'file',
'file-o',
'file-code',
'file-export',
'file-import',
'file-upload',
'autofill',
'folder',
'folder-open',
'folder-plus',
'font',
5115 'gears',
'generate',
'generic',
'globe',
'globe-americas',
'graph',
'grip',
'grip_title',
'group',
5116 'hands-helping',
'help',
'holiday',
5117 'id-card',
'images',
'incoterm',
'info',
'intervention',
'inventory',
'intracommreport',
'jobprofile',
5118 'key',
'knowledgemanagement',
5119 'label',
'language',
'layout',
'line',
'link',
'list',
'list-alt',
'listlight',
'loan',
'lock',
'lot',
'long-arrow-alt-right',
5120 'margin',
'map-marker-alt',
'member',
'meeting',
'minus',
'money-bill-alt',
'movement',
'mrp',
'note',
'next',
5121 'off',
'on',
'order',
5122 'paiment',
'paragraph',
'play',
'pdf',
'phone',
'phoning',
'phoning_mobile',
'phoning_fax',
'playdisabled',
'previous',
'poll',
'pos',
'printer',
'product',
'propal',
'proposal',
'puce',
5123 'stock',
'resize',
'service',
'stats',
5124 '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',
5125 'github',
'google',
'jabber',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'youtube',
'google-plus-g',
'whatsapp',
5126 'generic',
'home',
'hrm',
'members',
'products',
'invoicing',
5127 'partnership',
'payment',
'payment_vat',
'pencil-ruler',
'pictoconfirm',
'preview',
'project',
'projectpub',
'projecttask',
'question',
'refresh',
'region',
5128 'salary',
'shipment',
'state',
'supplier_invoice',
'supplier_invoicea',
'supplier_invoicer',
'supplier_invoiced',
5129 'technic',
'ticket',
5131 'recent',
'reception',
'recruitmentcandidature',
'recruitmentjobposition',
'replacement',
'resource',
'recurring',
'rss',
5132 'shapes',
'skill',
'square',
'sort-numeric-down',
'status',
'stop-circle',
'supplier',
'supplier_proposal',
'supplier_order',
'supplier_invoice',
5133 'terminal',
'tick',
'timespent',
'title_setup',
'title_accountancy',
'title_bank',
'title_hrm',
'title_agenda',
'trip',
5134 'uncheck',
'undo',
'url',
'user-cog',
'user-injured',
'user-md',
'vat',
'website',
'workstation',
'webhook',
'world',
'private',
5135 'conferenceorbooth',
'eventorganization',
5136 'stamp',
'signature',
5139 $fakey = $pictowithouttext;
5143 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'))) {
5146 if (in_array($pictowithouttext, array(
'black-tie',
'github',
'google',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'stripe',
'stripe-s',
'youtube',
'google-plus-g',
'whatsapp'))) {
5150 $arrayconvpictotofa = array(
5151 'account' =>
'university',
'accounting_account' =>
'clipboard-list',
'accountline' =>
'receipt',
'accountancy' =>
'search-dollar',
'action' =>
'calendar-alt',
'add' =>
'plus-circle',
'address' =>
'address-book',
'ai' =>
'magic',
5152 'asset' =>
'money-check-alt',
'autofill' =>
'fill',
5153 'back' =>
'arrow-left',
'bank_account' =>
'university',
5154 'bill' =>
'file-invoice-dollar',
'billa' =>
'file-excel',
'billr' =>
'file-invoice-dollar',
'billd' =>
'file-medical',
5155 'bookcal' =>
'calendar-check',
5156 'supplier_invoice' =>
'file-invoice-dollar',
'supplier_invoicea' =>
'file-excel',
'supplier_invoicer' =>
'file-invoice-dollar',
'supplier_invoiced' =>
'file-medical',
5158 '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',
5159 'chevron-double-left' =>
'angle-double-left',
'chevron-double-right' =>
'angle-double-right',
'chevron-double-down' =>
'angle-double-down',
'chevron-double-top' =>
'angle-double-up',
5160 'donation' =>
'file-alt',
'dynamicprice' =>
'hand-holding-usd',
5161 'setup' =>
'cog',
'companies' =>
'building',
'products' =>
'cube',
'commercial' =>
'suitcase',
'invoicing' =>
'coins',
5162 'accounting' =>
'search-dollar',
'category' =>
'tag',
'dollyrevert' =>
'dolly',
5163 'file-o' =>
'file',
'generate' =>
'plus-square',
'hrm' =>
'user-tie',
'incoterm' =>
'truck-loading',
5164 'margin' =>
'calculator',
'members' =>
'user-friends',
'ticket' =>
'ticket-alt',
'globe' =>
'external-link-alt',
'lot' =>
'barcode',
5165 'email' =>
'at',
'establishment' =>
'building',
'edit' =>
'pencil-alt',
'entity' =>
'globe',
5166 'graph' =>
'chart-line',
'grip_title' =>
'arrows-alt',
'grip' =>
'arrows-alt',
'help' =>
'question-circle',
5167 'generic' =>
'file',
'holiday' =>
'umbrella-beach',
5168 'info' =>
'info-circle',
'inventory' =>
'boxes',
'intracommreport' =>
'globe-europe',
'jobprofile' =>
'cogs',
5169 'knowledgemanagement' =>
'ticket-alt',
'label' =>
'layer-group',
'layout' =>
'columns',
'line' =>
'bars',
'loan' =>
'money-bill-alt',
5170 'member' =>
'user-alt',
'meeting' =>
'chalkboard-teacher',
'mrp' =>
'cubes',
'next' =>
'arrow-alt-circle-right',
5171 'trip' =>
'wallet',
'expensereport' =>
'wallet',
'group' =>
'users',
'movement' =>
'people-carry',
5172 'sign-out' =>
'sign-out-alt',
5173 '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',
5174 'bank' =>
'university',
'close_title' =>
'times',
'delete' =>
'trash',
'filter' =>
'filter',
5175 'list-alt' =>
'list-alt',
'calendarlist' =>
'bars',
'calendar' =>
'calendar-alt',
'calendarmonth' =>
'calendar-alt',
'calendarweek' =>
'calendar-week',
'calendarday' =>
'calendar-day',
'calendarperuser' =>
'table',
5176 'intervention' =>
'ambulance',
'invoice' =>
'file-invoice-dollar',
'order' =>
'file-invoice',
5177 'error' =>
'exclamation-triangle',
'warning' =>
'exclamation-triangle',
5178 'other' =>
'square',
5179 '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',
5180 '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',
5181 'recent' =>
'check-square',
'reception' =>
'dolly',
'recruitmentjobposition' =>
'id-card-alt',
'recruitmentcandidature' =>
'id-badge',
5182 'resize' =>
'crop',
'supplier_order' =>
'dol-order_supplier',
'supplier_proposal' =>
'file-signature',
5183 'refresh' =>
'redo',
'region' =>
'map-marked',
'replacement' =>
'exchange-alt',
'resource' =>
'laptop-house',
'recurring' =>
'history',
5184 'service' =>
'concierge-bell',
5185 'skill' =>
'shapes',
'state' =>
'map-marked-alt',
'security' =>
'key',
'salary' =>
'wallet',
'shipment' =>
'dolly',
'stock' =>
'box-open',
'stats' =>
'chart-bar',
'split' =>
'code-branch',
5186 'status' =>
'stop-circle',
5187 'stripe' =>
'stripe-s',
'supplier' =>
'building',
5188 'technic' =>
'cogs',
'tick' =>
'check',
'timespent' =>
'clock',
'title_setup' =>
'tools',
'title_accountancy' =>
'money-check-alt',
'title_bank' =>
'university',
'title_hrm' =>
'umbrella-beach',
5189 'title_agenda' =>
'calendar-alt',
5190 'uncheck' =>
'times',
'uparrow' =>
'share',
'url' =>
'external-link-alt',
'vat' =>
'money-check-alt',
'vcard' =>
'arrow-alt-circle-down',
5191 'jabber' =>
'comment-o',
5192 'website' =>
'globe-americas',
'workstation' =>
'pallet',
'webhook' =>
'bullseye',
'world' =>
'globe',
'private' =>
'user-lock',
5193 'conferenceorbooth' =>
'chalkboard-teacher',
'eventorganization' =>
'project-diagram',
5194 'webportal' =>
'door-open'
5196 if (
$conf->currency ==
'EUR') {
5197 $arrayconvpictotofa[
'currency'] =
'euro-sign';
5198 $arrayconvpictotofa[
'multicurrency'] =
'dollar-sign';
5200 $arrayconvpictotofa[
'currency'] =
'dollar-sign';
5201 $arrayconvpictotofa[
'multicurrency'] =
'euro-sign';
5203 if ($pictowithouttext ==
'off') {
5204 $fakey =
'fa-square';
5206 } elseif ($pictowithouttext ==
'on') {
5207 $fakey =
'fa-check-square';
5209 } elseif ($pictowithouttext ==
'listlight') {
5210 $fakey =
'fa-download';
5211 $marginleftonlyshort = 1;
5212 } elseif ($pictowithouttext ==
'printer') {
5213 $fakey =
'fa-print';
5215 } elseif ($pictowithouttext ==
'note') {
5216 $fakey =
'fa-sticky-note';
5217 $marginleftonlyshort = 1;
5218 } elseif (in_array($pictowithouttext, array(
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'))) {
5219 $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');
5220 $fakey =
'fa-'.$convertarray[$pictowithouttext];
5221 if (preg_match(
'/selected/', $pictowithouttext)) {
5224 $marginleftonlyshort = 1;
5225 } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) {
5226 $fakey =
'fa-'.$arrayconvpictotofa[$pictowithouttext];
5228 $fakey =
'fa-'.$pictowithouttext;
5231 if (in_array($pictowithouttext, array(
'dollyrevert',
'member',
'members',
'contract',
'group',
'resource',
'shipment',
'reception'))) {
5232 $morecss .=
' em092';
5234 if (in_array($pictowithouttext, array(
'conferenceorbooth',
'collab',
'eventorganization',
'holiday',
'info',
'project',
'workstation'))) {
5235 $morecss .=
' em088';
5237 if (in_array($pictowithouttext, array(
'asset',
'intervention',
'payment',
'loan',
'partnership',
'stock',
'technic'))) {
5238 $morecss .=
' em080';
5242 $arrayconvpictotomarginleftonly = array(
5243 'bank',
'check',
'delete',
'generic',
'grip',
'grip_title',
'jabber',
5244 'grip_title',
'grip',
'listlight',
'note',
'on',
'off',
'playdisabled',
'printer',
'resize',
'sign-out',
'stats',
'switch_on',
'switch_on_grey',
'switch_on_red',
'switch_off',
5245 'uparrow',
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'
5247 if (!array_key_exists($pictowithouttext, $arrayconvpictotomarginleftonly)) {
5248 $marginleftonlyshort = 0;
5252 $arrayconvpictotomorcess = array(
5253 'action' =>
'infobox-action',
'account' =>
'infobox-bank_account',
'accounting_account' =>
'infobox-bank_account',
'accountline' =>
'infobox-bank_account',
'accountancy' =>
'infobox-bank_account',
'asset' =>
'infobox-bank_account',
5254 'bank_account' =>
'infobox-bank_account',
5255 'bill' =>
'infobox-commande',
'billa' =>
'infobox-commande',
'billr' =>
'infobox-commande',
'billd' =>
'infobox-commande',
5256 'bookcal' =>
'infobox-action',
5257 'margin' =>
'infobox-bank_account',
'conferenceorbooth' =>
'infobox-project',
5258 'cash-register' =>
'infobox-bank_account',
'contract' =>
'infobox-contrat',
'check' =>
'font-status4',
'collab' =>
'infobox-action',
'conversation' =>
'infobox-contrat',
5259 'donation' =>
'infobox-commande',
'dolly' =>
'infobox-commande',
'dollyrevert' =>
'flip infobox-order_supplier',
5260 'ecm' =>
'infobox-action',
'eventorganization' =>
'infobox-project',
5261 'hrm' =>
'infobox-adherent',
'group' =>
'infobox-adherent',
'intervention' =>
'infobox-contrat',
5262 'incoterm' =>
'infobox-supplier_proposal',
5263 'currency' =>
'infobox-bank_account',
'multicurrency' =>
'infobox-bank_account',
5264 'members' =>
'infobox-adherent',
'member' =>
'infobox-adherent',
'money-bill-alt' =>
'infobox-bank_account',
5265 'order' =>
'infobox-commande',
5266 'user' =>
'infobox-adherent',
'users' =>
'infobox-adherent',
5267 'error' =>
'pictoerror',
'warning' =>
'pictowarning',
'switch_on' =>
'font-status4',
'switch_on_warning' =>
'font-status4 warning',
'switch_on_red' =>
'font-status8',
5268 'holiday' =>
'infobox-holiday',
'info' =>
'opacityhigh',
'invoice' =>
'infobox-commande',
5269 'knowledgemanagement' =>
'infobox-contrat rotate90',
'loan' =>
'infobox-bank_account',
5270 'payment' =>
'infobox-bank_account',
'payment_vat' =>
'infobox-bank_account',
'poll' =>
'infobox-adherent',
'pos' =>
'infobox-bank_account',
'project' =>
'infobox-project',
'projecttask' =>
'infobox-project',
5271 'propal' =>
'infobox-propal',
'proposal' =>
'infobox-propal',
'private' =>
'infobox-project',
5272 'reception' =>
'flip infobox-order_supplier',
'recruitmentjobposition' =>
'infobox-adherent',
'recruitmentcandidature' =>
'infobox-adherent',
5273 'resource' =>
'infobox-action',
5274 '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',
5275 'supplier' =>
'infobox-order_supplier',
'supplier_order' =>
'infobox-order_supplier',
'supplier_proposal' =>
'infobox-supplier_proposal',
5276 'ticket' =>
'infobox-contrat',
'title_accountancy' =>
'infobox-bank_account',
'title_hrm' =>
'infobox-holiday',
'expensereport' =>
'infobox-expensereport',
'trip' =>
'infobox-expensereport',
'title_agenda' =>
'infobox-action',
5277 'vat' =>
'infobox-bank_account',
5279 'list-alt' =>
'imgforviewmode',
'calendar' =>
'imgforviewmode',
'calendarweek' =>
'imgforviewmode',
'calendarmonth' =>
'imgforviewmode',
'calendarday' =>
'imgforviewmode',
'calendarperuser' =>
'imgforviewmode'
5281 if (!empty($arrayconvpictotomorcess[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5282 $morecss .= ($morecss ?
' ' :
'').$arrayconvpictotomorcess[$pictowithouttext];
5286 $arrayconvpictotocolor = array(
5287 'address' =>
'#6c6aa8',
'building' =>
'#6c6aa8',
'bom' =>
'#a69944',
5288 'clone' =>
'#999',
'cog' =>
'#999',
'companies' =>
'#6c6aa8',
'company' =>
'#6c6aa8',
'contact' =>
'#6c6aa8',
'cron' =>
'#555',
5289 'dynamicprice' =>
'#a69944',
5290 'edit' =>
'#444',
'note' =>
'#999',
'error' =>
'',
'help' =>
'#bbb',
'listlight' =>
'#999',
'language' =>
'#555',
5292 'lock' =>
'#ddd',
'lot' =>
'#a69944',
5293 'map-marker-alt' =>
'#aaa',
'mrp' =>
'#a69944',
'product' =>
'#a69944',
'service' =>
'#a69944',
'inventory' =>
'#a69944',
'stock' =>
'#a69944',
'movement' =>
'#a69944',
5294 'other' =>
'#ddd',
'world' =>
'#986c6a',
5295 'partnership' =>
'#6c6aa8',
'playdisabled' =>
'#ccc',
'printer' =>
'#444',
'projectpub' =>
'#986c6a',
'resize' =>
'#444',
'rss' =>
'#cba',
5297 'security' =>
'#999',
'square' =>
'#888',
'stop-circle' =>
'#888',
'stats' =>
'#444',
'switch_off' =>
'#999',
5298 'technic' =>
'#999',
'tick' =>
'#282',
'timespent' =>
'#555',
5299 'uncheck' =>
'#800',
'uparrow' =>
'#555',
'user-cog' =>
'#999',
'country' =>
'#aaa',
'globe-americas' =>
'#aaa',
'region' =>
'#aaa',
'state' =>
'#aaa',
5300 'website' =>
'#304',
'workstation' =>
'#a69944'
5302 if (isset($arrayconvpictotocolor[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5303 $facolor = $arrayconvpictotocolor[$pictowithouttext];
5310 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5311 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5312 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5314 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
5315 $morestyle = $reg[1];
5316 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
5318 $moreatt = trim($moreatt);
5320 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
5321 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
5325 $enabledisablehtml .=
'</span>';
5327 return $enabledisablehtml;
5334 } elseif (!empty(
$conf->modules_parts[
'theme']) && array_key_exists($theme,
$conf->modules_parts[
'theme'])) {
5335 $path = $theme.
'/theme/'.$theme;
5340 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
5346 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
5351 foreach (
$conf->file->dol_document_root as $type => $dirroot) {
5352 if ($type ==
'main') {
5356 if (file_exists($dirroot.
'/'.$path.
'/img/'.$picto)) {
5357 $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type];
5363 $fullpathpicto = $url.
'/'.$path.
'/img/'.$picto;
5367 return $fullpathpicto;
5371 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 :
'').
'"').
'>';
5387function img_object($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0)
5389 if (strpos($picto,
'^') === 0) {
5390 return img_picto($titlealt, str_replace(
'^',
'', $picto), $moreatt, $pictoisfullpath, $srconly, $notitle);
5392 return img_picto($titlealt,
'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
5407function img_weather($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $morecss =
'')
5411 if (is_numeric($picto)) {
5414 return '<i class="fa fa-weather-level'.$picto.
'"></i>';
5415 } elseif (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5419 $path = DOL_URL_ROOT.
'/theme/'.
$conf->theme.
'/img/weather/'.$picto;
5421 return img_picto($titlealt, $path, $moreatt, 1, 0, 0,
'', $morecss);
5435function img_picto_common($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $notitle = 0)
5439 if (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5443 if ($pictoisfullpath) {
5446 $path = DOL_URL_ROOT.
'/theme/common/'.$picto;
5449 $themepath = DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/img/'.$picto;
5451 if (file_exists($themepath)) {
5457 return img_picto($titlealt, $path, $moreatt, 1, 0, $notitle);
5473function img_action($titlealt, $numaction, $picto =
'', $moreatt =
'')
5477 if (empty($titlealt) || $titlealt ==
'default') {
5478 if ($numaction ==
'-1' || $numaction ==
'ST_NO') {
5480 $titlealt = $langs->transnoentitiesnoconv(
'ChangeDoNotContact');
5481 } elseif ($numaction ==
'0' || $numaction ==
'ST_NEVER') {
5483 $titlealt = $langs->transnoentitiesnoconv(
'ChangeNeverContacted');
5484 } elseif ($numaction ==
'1' || $numaction ==
'ST_TODO') {
5486 $titlealt = $langs->transnoentitiesnoconv(
'ChangeToContact');
5487 } elseif ($numaction ==
'2' || $numaction ==
'ST_PEND') {
5489 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactInProcess');
5490 } elseif ($numaction ==
'3' || $numaction ==
'ST_DONE') {
5492 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactDone');
5494 $titlealt = $langs->transnoentitiesnoconv(
'ChangeStatus '.$numaction);
5498 if (!is_numeric($numaction)) {
5502 return img_picto($titlealt, (empty($picto) ?
'stcomm'.$numaction.
'.png' : $picto), $moreatt);
5512function img_pdf($titlealt =
'default', $size = 3)
5516 if ($titlealt ==
'default') {
5517 $titlealt = $langs->trans(
'Show');
5520 return img_picto($titlealt,
'pdf'.$size.
'.png');
5530function img_edit_add($titlealt =
'default', $other =
'')
5534 if ($titlealt ==
'default') {
5535 $titlealt = $langs->trans(
'Add');
5538 return img_picto($titlealt,
'edit_add.png', $other);
5551 if ($titlealt ==
'default') {
5552 $titlealt = $langs->trans(
'Remove');
5555 return img_picto($titlealt,
'edit_remove.png', $other);
5566function img_edit($titlealt =
'default', $float = 0, $other =
'')
5570 if ($titlealt ==
'default') {
5571 $titlealt = $langs->trans(
'Modify');
5574 return img_picto($titlealt,
'edit.png', ($float ?
'style="float: '.($langs->tab_translate[
"DIRECTION"] ==
'rtl' ?
'left' :
'right').
'"' :
"").($other ?
' '.$other :
''));
5585function img_view($titlealt =
'default', $float = 0, $other =
'class="valignmiddle"')
5589 if ($titlealt ==
'default') {
5590 $titlealt = $langs->trans(
'View');
5593 $moreatt = ($float ?
'style="float: right" ' :
'').$other;
5595 return img_picto($titlealt,
'eye', $moreatt);
5606function img_delete($titlealt =
'default', $other =
'class="pictodelete"', $morecss =
'')
5610 if ($titlealt ==
'default') {
5611 $titlealt = $langs->trans(
'Delete');
5614 return img_picto($titlealt,
'delete.png', $other, 0, 0, 0,
'', $morecss);
5624function img_printer($titlealt =
"default", $other =
'')
5627 if ($titlealt ==
"default") {
5628 $titlealt = $langs->trans(
"Print");
5630 return img_picto($titlealt,
'printer.png', $other);
5640function img_split($titlealt =
'default', $other =
'class="pictosplit"')
5644 if ($titlealt ==
'default') {
5645 $titlealt = $langs->trans(
'Split');
5648 return img_picto($titlealt,
'split.png', $other);
5658function img_help($usehelpcursor = 1, $usealttitle = 1)
5663 if (is_string($usealttitle)) {
5666 $usealttitle = $langs->trans(
'Info');
5670 return img_picto($usealttitle,
'info.png',
'style="vertical-align: middle;'.($usehelpcursor == 1 ?
' cursor: help' : ($usehelpcursor == 2 ?
' cursor: pointer' :
'')).
'"');
5679function img_info($titlealt =
'default')
5683 if ($titlealt ==
'default') {
5684 $titlealt = $langs->trans(
'Informations');
5687 return img_picto($titlealt,
'info.png',
'style="vertical-align: middle;"');
5698function img_warning($titlealt =
'default', $moreatt =
'', $morecss =
'pictowarning')
5702 if ($titlealt ==
'default') {
5703 $titlealt = $langs->trans(
'Warning');
5707 return img_picto($titlealt,
'warning.png',
'class="'.$morecss.
'"'.($moreatt ? ($moreatt ==
'1' ?
' style="float: right"' :
' '.$moreatt) :
''));
5716function img_error($titlealt =
'default')
5720 if ($titlealt ==
'default') {
5721 $titlealt = $langs->trans(
'Error');
5724 return img_picto($titlealt,
'error.png');
5734function img_next($titlealt =
'default', $moreatt =
'')
5738 if ($titlealt ==
'default') {
5739 $titlealt = $langs->trans(
'Next');
5743 return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
5753function img_previous($titlealt =
'default', $moreatt =
'')
5757 if ($titlealt ==
'default') {
5758 $titlealt = $langs->trans(
'Previous');
5762 return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
5773function img_down($titlealt =
'default', $selected = 0, $moreclass =
'')
5777 if ($titlealt ==
'default') {
5778 $titlealt = $langs->trans(
'Down');
5781 return img_picto($titlealt, ($selected ?
'1downarrow_selected.png' :
'1downarrow.png'),
'class="imgdown'.($moreclass ?
" ".$moreclass :
"").
'"');
5792function img_up($titlealt =
'default', $selected = 0, $moreclass =
'')
5796 if ($titlealt ==
'default') {
5797 $titlealt = $langs->trans(
'Up');
5800 return img_picto($titlealt, ($selected ?
'1uparrow_selected.png' :
'1uparrow.png'),
'class="imgup'.($moreclass ?
" ".$moreclass :
"").
'"');
5811function img_left($titlealt =
'default', $selected = 0, $moreatt =
'')
5815 if ($titlealt ==
'default') {
5816 $titlealt = $langs->trans(
'Left');
5819 return img_picto($titlealt, ($selected ?
'1leftarrow_selected.png' :
'1leftarrow.png'), $moreatt);
5830function img_right($titlealt =
'default', $selected = 0, $moreatt =
'')
5834 if ($titlealt ==
'default') {
5835 $titlealt = $langs->trans(
'Right');
5838 return img_picto($titlealt, ($selected ?
'1rightarrow_selected.png' :
'1rightarrow.png'), $moreatt);
5848function img_allow($allow, $titlealt =
'default')
5852 if ($titlealt ==
'default') {
5853 $titlealt = $langs->trans(
'Active');
5857 return img_picto($titlealt,
'tick.png');
5872 if (is_null($morecss)) {
5876 if ($brand ==
'visa' || $brand ==
'Visa') {
5878 } elseif ($brand ==
'mastercard' || $brand ==
'MasterCard') {
5879 $brand =
'cc-mastercard';
5880 } elseif ($brand ==
'amex' || $brand ==
'American Express') {
5882 } elseif ($brand ==
'discover' || $brand ==
'Discover') {
5883 $brand =
'cc-discover';
5884 } elseif ($brand ==
'jcb' || $brand ==
'JCB') {
5886 } elseif ($brand ==
'diners' || $brand ==
'Diners club') {
5887 $brand =
'cc-diners-club';
5888 } elseif (!in_array($brand, array(
'cc-visa',
'cc-mastercard',
'cc-amex',
'cc-discover',
'cc-jcb',
'cc-diners-club'))) {
5889 $brand =
'credit-card';
5892 return '<span class="fa fa-'.$brand.
' fa-fw'.($morecss ?
' '.$morecss :
'').
'"></span>';
5903function img_mime($file, $titlealt =
'', $morecss =
'')
5905 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
5911 if (empty($titlealt)) {
5912 $titlealt =
'Mime type: '.$mimetype;
5916 return '<i class="fa fa-'.$mimefa.
' paddingright'.($morecss ?
' '.$morecss :
'').
'"'.($titlealt ?
' title="'.$titlealt.
'"' :
'').
'></i>';
5927function img_search($titlealt =
'default', $other =
'')
5931 if ($titlealt ==
'default') {
5932 $titlealt = $langs->trans(
'Search');
5935 $img =
img_picto($titlealt,
'search.png', $other, 0, 1);
5937 $input =
'<input type="image" class="liste_titre" name="button_search" src="'.$img.
'" ';
5938 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
5954 if ($titlealt ==
'default') {
5955 $titlealt = $langs->trans(
'Search');
5958 $img =
img_picto($titlealt,
'searchclear.png', $other, 0, 1);
5960 $input =
'<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.
'" ';
5961 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
5978function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin =
'1', $morecss =
'hideonsmartphone', $textfordropdown =
'', $picto =
'')
5980 global
$conf, $langs;
5982 if ($infoonimgalt) {
5983 $result =
img_picto($text,
'info',
'class="'.($morecss ?
' '.$morecss :
'').
'"');
5985 if (empty(
$conf->use_javascript_ajax)) {
5986 $textfordropdown =
'';
5989 $class = (empty($admin) ?
'undefined' : ($admin ==
'1' ?
'info' : $admin));
5990 $fa =
'info-circle';
5991 if ($picto ==
'warning') {
5992 $fa =
'exclamation-triangle';
5994 $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> ';
5996 $result .= ($nodiv ?
'' :
'</div>');
5998 if ($textfordropdown) {
5999 $tmpresult =
'<span class="'.$class.
'text opacitymedium cursorpointer">'.$langs->trans($textfordropdown).
' '.
img_picto($langs->trans($textfordropdown),
'1downarrow').
'</span>';
6000 $tmpresult .=
'<script nonce="'.getNonce().
'" type="text/javascript">
6001 jQuery(document).ready(function() {
6002 jQuery(".'.$class.
'text").click(function() {
6003 console.log("toggle text");
6004 jQuery(".'.$class.
'").toggle();
6009 $result = $tmpresult.$result;
6030 global
$conf, $langs, $user, $argv;
6031 global $dolibarr_main_prod;
6038 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
6040 $langs->load(
"main");
6044 $langs->loadLangs(array(
'main',
'errors'));
6046 if ($_SERVER[
'DOCUMENT_ROOT']) {
6047 $out .= $langs->trans(
"DolibarrHasDetectedError").
".<br>\n";
6049 $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";
6051 $out .= $langs->trans(
"InformationToHelpDiagnose").
":<br>\n";
6053 $out .=
"<b>".$langs->trans(
"Date").
":</b> ".
dol_print_date(time(),
'dayhourlog').
"<br>\n";
6054 $out .=
"<b>".$langs->trans(
"Dolibarr").
":</b> ".DOL_VERSION.
" - https://www.dolibarr.org<br>\n";
6055 if (isset(
$conf->global->MAIN_FEATURES_LEVEL)) {
6056 $out .=
"<b>".$langs->trans(
"LevelOfFeature").
":</b> ".
getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
"<br>\n";
6058 if ($user instanceof
User) {
6059 $out .=
"<b>".$langs->trans(
"Login").
":</b> ".$user->login.
"<br>\n";
6061 if (function_exists(
"phpversion")) {
6062 $out .=
"<b>".$langs->trans(
"PHP").
":</b> ".phpversion().
"<br>\n";
6064 $out .=
"<b>".$langs->trans(
"Server").
":</b> ".(isset($_SERVER[
"SERVER_SOFTWARE"]) ?
dol_htmlentities($_SERVER[
"SERVER_SOFTWARE"], ENT_COMPAT) :
'').
"<br>\n";
6065 if (function_exists(
"php_uname")) {
6066 $out .=
"<b>".$langs->trans(
"OS").
":</b> ".php_uname().
"<br>\n";
6068 $out .=
"<b>".$langs->trans(
"UserAgent").
":</b> ".(isset($_SERVER[
"HTTP_USER_AGENT"]) ?
dol_htmlentities($_SERVER[
"HTTP_USER_AGENT"], ENT_COMPAT) :
'').
"<br>\n";
6070 $out .=
"<b>".$langs->trans(
"RequestedUrl").
":</b> ".
dol_htmlentities($_SERVER[
"REQUEST_URI"], ENT_COMPAT).
"<br>\n";
6071 $out .=
"<b>".$langs->trans(
"Referer").
":</b> ".(isset($_SERVER[
"HTTP_REFERER"]) ?
dol_htmlentities($_SERVER[
"HTTP_REFERER"], ENT_COMPAT) :
'').
"<br>\n";
6072 $out .=
"<b>".$langs->trans(
"MenuManager").
":</b> ".(isset(
$conf->standard_menu) ?
dol_htmlentities(
$conf->standard_menu, ENT_COMPAT) :
'').
"<br>\n";
6074 $syslog .=
"url=".dol_escape_htmltag($_SERVER[
"REQUEST_URI"]);
6075 $syslog .=
", query_string=".dol_escape_htmltag($_SERVER[
"QUERY_STRING"]);
6077 $out .=
'> '.$langs->transnoentities(
"ErrorInternalErrorDetected").
":\n".$argv[0].
"\n";
6078 $syslog .=
"pid=".dol_getmypid();
6081 if (!empty(
$conf->modules)) {
6082 $out .=
"<b>".$langs->trans(
"Modules").
":</b> ".implode(
', ',
$conf->modules).
"<br>\n";
6085 if (is_object($db)) {
6086 if ($_SERVER[
'DOCUMENT_ROOT']) {
6087 $out .=
"<b>".$langs->trans(
"DatabaseTypeManager").
":</b> ".$db->type.
"<br>\n";
6088 $lastqueryerror = $db->lastqueryerror();
6090 $lastqueryerror =
"SQL error string is not a valid UTF8 string. We can't show it.";
6092 $out .=
"<b>".$langs->trans(
"RequestLastAccessInError").
":</b> ".($lastqueryerror ?
dol_escape_htmltag($lastqueryerror) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6093 $out .=
"<b>".$langs->trans(
"ReturnCodeLastAccessInError").
":</b> ".($db->lasterrno() ?
dol_escape_htmltag($db->lasterrno()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6094 $out .=
"<b>".$langs->trans(
"InformationLastAccessInError").
":</b> ".($db->lasterror() ?
dol_escape_htmltag($db->lasterror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6098 $out .=
'> '.$langs->transnoentities(
"DatabaseTypeManager").
":\n".$db->type.
"\n";
6099 $out .=
'> '.$langs->transnoentities(
"RequestLastAccessInError").
":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6100 $out .=
'> '.$langs->transnoentities(
"ReturnCodeLastAccessInError").
":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6101 $out .=
'> '.$langs->transnoentities(
"InformationLastAccessInError").
":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6103 $syslog .=
", sql=".$db->lastquery();
6104 $syslog .=
", db_error=".$db->lasterror();
6107 if ($error || $errors) {
6109 if (is_array($error) && is_array($errors)) {
6110 $errors = array_merge($error, $errors);
6111 } elseif (is_array($error)) {
6113 } elseif (is_array($errors) && !empty($error)) {
6114 $errors = array_merge(array($error), $errors);
6115 } elseif (!empty($error)) {
6116 $errors = array_merge(array($error), array($errors));
6119 $langs->load(
"errors");
6121 foreach ($errors as $msg) {
6125 if ($_SERVER[
'DOCUMENT_ROOT']) {
6128 $out .=
'> '.$langs->transnoentities(
"Message").
":\n".$msg.
"\n";
6130 $syslog .=
", msg=".$msg;
6133 if (empty($dolibarr_main_prod) && $_SERVER[
'DOCUMENT_ROOT'] && function_exists(
'xdebug_print_function_stack') && function_exists(
'xdebug_call_file')) {
6134 xdebug_print_function_stack();
6135 $out .=
'<b>XDebug information:</b>'.
"<br>\n";
6136 $out .=
'File: '.xdebug_call_file().
"<br>\n";
6137 $out .=
'Line: '.xdebug_call_line().
"<br>\n";
6138 $out .=
'Function: '.xdebug_call_function().
"<br>\n";
6143 if (!headers_sent()) {
6144 if (function_exists(
'top_httphead')) {
6148 http_response_code(202);
6151 if (empty($dolibarr_main_prod)) {
6154 if (empty($langs->defaultlang)) {
6155 $langs->setDefaultLang();
6157 $langs->loadLangs(array(
"main",
"errors"));
6159 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";
6160 print $langs->trans(
"DolibarrHasDetectedError").
'. ';
6161 print $langs->trans(
"YouCanSetOptionDolibarrMainProdToZero");
6162 if (!defined(
"MAIN_CORE_ERROR")) {
6163 define(
"MAIN_CORE_ERROR", 1);
6180function dol_print_error_email($prefixcode, $errormessage =
'', $errormessages = array(), $morecss =
'error', $email =
'')
6184 if (empty($email)) {
6188 $langs->load(
"errors");
6191 print
'<br><div class="center login_main_message"><div class="'.$morecss.
'">';
6192 print $langs->trans(
"ErrorContactEMail", $email, $prefixcode.
'-'.
dol_print_date($now,
'%Y%m%d%H%M%S'));
6193 if ($errormessage) {
6194 print
'<br><br>'.$errormessage;
6196 if (is_array($errormessages) && count($errormessages)) {
6197 foreach ($errormessages as $mesgtoshow) {
6198 print
'<br><br>'.$mesgtoshow;
6201 print
'</div></div>';
6220function print_liste_field_titre($name, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $tooltip =
"", $forcenowrapcolumntitle = 0)
6222 print
getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip, $forcenowrapcolumntitle);
6243function getTitleFieldOfList($name, $thead = 0, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $disablesortlink = 0, $tooltip =
'', $forcenowrapcolumntitle = 0)
6245 global $langs, $form;
6248 if ($moreattrib ==
'class="right"') {
6249 $prefix .=
'right ';
6252 $sortorder = strtoupper($sortorder);
6261 $tmpsortfield = explode(
',', $sortfield);
6262 $sortfield1 = trim($tmpsortfield[0]);
6263 $tmpfield = explode(
',', $field);
6264 $field1 = trim($tmpfield[0]);
6266 if (!
getDolGlobalString(
'MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE') && empty($forcenowrapcolumntitle)) {
6267 $prefix =
'wrapcolumntitle '.$prefix;
6273 $liste_titre =
'liste_titre';
6274 if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace(
"/^[^\.]+\./",
"", $field1))) {
6275 $liste_titre =
'liste_titre_sel';
6278 $tagstart =
'<'.$tag.
' class="'.$prefix.$liste_titre.
'" '.$moreattrib;
6283 if (empty($thead) && $field && empty($disablesortlink)) {
6284 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6285 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6286 $options = preg_replace(
'/&+/i',
'&', $options);
6287 if (!preg_match(
'/^&/', $options)) {
6288 $options =
'&'.$options;
6291 $sortordertouseinlink =
'';
6292 if ($field1 != $sortfield1) {
6293 if (preg_match(
'/^DESC/i', $sortorder)) {
6294 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6296 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6299 if (preg_match(
'/^ASC/i', $sortorder)) {
6300 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6302 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6305 $sortordertouseinlink = preg_replace(
'/,$/',
'', $sortordertouseinlink);
6306 $out .=
'<a class="reposition" href="'.$file.
'?sortfield='.$field.
'&sortorder='.$sortordertouseinlink.
'&begin='.$begin.$options.
'"';
6312 if (preg_match(
'/:\w+$/', $tooltip)) {
6313 $tmptooltip = explode(
':', $tooltip);
6315 $tmptooltip = array($tooltip);
6317 $out .= $form->textwithpicto($langs->trans($name), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.str_replace(
'.',
'_', $field).
'_'.$tmptooltip[1]));
6319 $out .= $langs->trans($name);
6322 if (empty($thead) && $field && empty($disablesortlink)) {
6326 if (empty($thead) && $field) {
6327 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6328 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6329 $options = preg_replace(
'/&+/i',
'&', $options);
6330 if (!preg_match(
'/^&/', $options)) {
6331 $options =
'&'.$options;
6334 if (!$sortorder || ($field1 != $sortfield1)) {
6338 if (preg_match(
'/^DESC/', $sortorder)) {
6341 $sortimg .=
'<span class="nowrap">'.img_up(
"Z-A", 0,
'paddingright').
'</span>';