48include_once DOL_DOCUMENT_ROOT.
'/core/lib/json.lib.php';
51if (!function_exists(
'utf8_encode')) {
59 function utf8_encode($elements)
61 return mb_convert_encoding($elements,
'UTF-8',
'ISO-8859-1');
65if (!function_exists(
'utf8_decode')) {
73 function utf8_decode($elements)
75 return mb_convert_encoding($elements,
'ISO-8859-1',
'UTF-8');
78if (!function_exists(
'str_starts_with')) {
87 function str_starts_with($haystack, $needle)
89 return (
string) $needle !==
'' && strncmp($haystack, $needle, strlen($needle)) === 0;
92if (!function_exists(
'str_ends_with')) {
101 function str_ends_with($haystack, $needle)
103 return $needle !==
'' && substr($haystack, -strlen($needle)) === (string) $needle;
106if (!function_exists(
'str_contains')) {
115 function str_contains($haystack, $needle)
117 return $needle !==
'' && mb_strpos($haystack, $needle) !==
false;
137 if (!is_object(
$object) && empty($module)) {
140 if (empty($module) && !empty(
$object->element)) {
145 if ($module ==
'fichinter') {
146 $module =
'ficheinter';
147 } elseif ($module ==
'invoice_supplier') {
148 $module =
'supplier_invoice';
149 } elseif ($module ==
'order_supplier') {
150 $module =
'supplier_order';
154 if ($mode ==
'output' || $mode ==
'outputrel' || $mode ==
'version') {
155 if (isset($conf->$module) && property_exists($conf->$module,
'multidir_output')) {
157 if ($mode !=
'outputrel') {
158 $s = $conf->$module->multidir_output[(empty(
$object->entity) ? $conf->entity :
$object->entity)];
160 if ($forobject &&
$object->id > 0) {
165 return 'error-diroutput-not-defined-for-this-object='.$module;
167 } elseif ($mode ==
'temp') {
168 if (isset($conf->$module) && property_exists($conf->$module,
'multidir_temp')) {
169 return $conf->$module->multidir_temp[(empty(
$object->entity) ? $conf->entity :
$object->entity)];
171 return 'error-dirtemp-not-defined-for-this-object='.$module;
174 return 'error-bad-value-for-mode';
218 return (
string) (isset($conf->global->$key) ? $conf->global->$key : $default);
233 return (
int) (isset($conf->global->$key) ? $conf->global->$key : $default);
247 if (empty($tmpuser)) {
252 return (
string) (isset($tmpuser->conf->$key) ? $tmpuser->conf->$key : $default);
265 if (empty($tmpuser)) {
270 return (
int) (isset($tmpuser->conf->$key) ? $tmpuser->conf->$key: $default);
287 'adherent' =>
'member',
288 'member_type' =>
'adherent_type',
290 'contrat' =>
'contract',
291 'entrepot' =>
'stock',
292 'projet' =>
'project',
293 'categorie' =>
'category',
294 'commande' =>
'order',
295 'expedition' =>
'shipping',
296 'facture' =>
'invoice',
297 'fichinter' =>
'intervention',
298 'ficheinter' =>
'intervention',
299 'propale' =>
'propal',
300 'socpeople' =>
'contact',
301 'fournisseur' =>
'supplier',
303 'actioncomm' =>
'agenda',
304 'product_price' =>
'productprice',
305 'product_fournisseur_price' =>
'productsupplierprice',
315function isModEnabled($module)
325 $arrayconv[
'supplier_order'] =
'fournisseur';
326 $arrayconv[
'supplier_invoice'] =
'fournisseur';
331 if ($module ==
'delivery_note') {
335 $module =
'shipping';
339 $module_alt = $module;
340 if (!empty($arrayconv[$module])) {
341 $module_alt = $arrayconv[$module];
343 $module_bis = $module;
344 if (!empty($arrayconvbis[$module])) {
345 $module_bis = $arrayconvbis[$module];
348 return !empty($conf->modules[$module]) || !empty($conf->modules[$module_alt]) || !empty($conf->modules[$module_bis]);
360 if ($timestamp ===
'') {
361 dol_syslog(
'Using empty string for a timestamp is deprecated, prefer use of null when calling page '.$_SERVER[
"PHP_SELF"], LOG_NOTICE);
364 if (is_null($timestamp) || !is_numeric($timestamp)) {
384 require_once DOL_DOCUMENT_ROOT.
"/core/db/".$type.
'.class.php';
386 $class =
'DoliDB'.ucfirst($type);
387 $db =
new $class($type, $host, $user, $pass, $name, $port);
408function getEntity($element, $shared = 1, $currentobject =
null)
410 global $conf, $mc, $hookmanager,
$object, $action, $db;
412 if (!is_object($hookmanager)) {
413 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
420 $element =
'project';
423 $element =
'contract';
425 case 'order_supplier':
426 $element =
'supplier_order';
428 case 'invoice_supplier':
429 $element =
'supplier_invoice';
433 if (is_object($mc)) {
434 $out = $mc->getEntity($element, $shared, $currentobject);
437 $addzero = array(
'user',
'usergroup',
'cronjob',
'c_email_templates',
'c_holiday_types',
'email_template',
'default_values',
'overwrite_trans');
438 if (in_array($element, $addzero)) {
441 $out .= ((int) $conf->entity);
446 'element' => $element,
449 'currentobject' => $currentobject,
452 $reshook = $hookmanager->executeHooks(
'hookGetEntity', $parameters, $currentobject, $action);
454 if (is_numeric($reshook)) {
455 if ($reshook == 0 && !empty($hookmanager->resPrint)) {
456 $out .=
','.$hookmanager->resPrint;
457 } elseif ($reshook == 1) {
458 $out = $hookmanager->resPrint;
475 if (is_object($mc) && method_exists($mc,
'setEntity')) {
476 return $mc->setEntity($currentobject);
478 return ((is_object($currentobject) && $currentobject->id > 0 && $currentobject->entity > 0) ? $currentobject->entity : $conf->entity);
490 return preg_match(
'/(_pass|password|_pw|_key|securekey|serverkey|secret\d?|p12key|exportkey|_PW_[a-z]+|token)$/i', $keyname);
502 for ($r =
""; $n >= 0; $n = intval($n / 26) - 1) {
503 $r = chr($n % 26 + 0x41) . $r;
527 include_once DOL_DOCUMENT_ROOT.
'/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php';
534 $user_agent = substr($user_agent, 0, 512);
536 $detectmobile =
new Mobile_Detect(
null, $user_agent);
537 $tablet = $detectmobile->isTablet();
539 if ($detectmobile->isMobile()) {
543 if ($detectmobile->is(
'AndroidOS')) {
544 $os = $phone =
'android';
545 } elseif ($detectmobile->is(
'BlackBerryOS')) {
546 $os = $phone =
'blackberry';
547 } elseif ($detectmobile->is(
'iOS')) {
550 } elseif ($detectmobile->is(
'PalmOS')) {
551 $os = $phone =
'palm';
552 } elseif ($detectmobile->is(
'SymbianOS')) {
554 } elseif ($detectmobile->is(
'webOS')) {
556 } elseif ($detectmobile->is(
'MaemoOS')) {
558 } elseif ($detectmobile->is(
'WindowsMobileOS') || $detectmobile->is(
'WindowsPhoneOS')) {
564 if (preg_match(
'/linux/i', $user_agent)) {
566 } elseif (preg_match(
'/macintosh/i', $user_agent)) {
568 } elseif (preg_match(
'/windows/i', $user_agent)) {
574 if (preg_match(
'/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
576 $version = empty($reg[2]) ?
'' : $reg[2];
577 } elseif (preg_match(
'/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
579 $version = empty($reg[2]) ?
'' : $reg[2];
580 } elseif (preg_match(
'/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) {
582 $version = empty($reg[2]) ?
'' : $reg[2];
583 } elseif (preg_match(
'/chrome/i', $user_agent, $reg)) {
586 } elseif (preg_match(
'/iceweasel/i', $user_agent)) {
588 } elseif (preg_match(
'/epiphany/i', $user_agent)) {
590 } elseif (preg_match(
'/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
592 $version = empty($reg[2]) ?
'' : $reg[2];
593 } elseif (preg_match(
'/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
596 $version = empty($reg[2]) ?
'' : $reg[2];
597 } elseif (preg_match(
'/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
599 $version = end($reg);
600 } elseif (preg_match(
'/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
603 $version = end($reg);
604 } elseif (preg_match(
'/l[iy]n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) {
607 $version = empty($reg[3]) ?
'' : $reg[3];
619 'browsername' => $name,
620 'browserversion' => $version,
622 'browserua' => $user_agent,
637 $disconnectdone =
false;
639 if (is_object($db) && !empty($db->connected)) {
640 $depth = $db->transaction_opened;
641 $disconnectdone = $db->close();
643 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));
655function GETPOSTISSET($paramname)
659 $relativepathstring = $_SERVER[
"PHP_SELF"];
661 if (constant(
'DOL_URL_ROOT')) {
662 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
664 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
665 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
671 if (!empty($_GET[
'restore_lastsearch_values'])) {
672 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
673 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
674 if (is_array($tmp)) {
675 foreach ($tmp as $key => $val) {
676 if ($key == $paramname) {
684 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
686 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
688 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
690 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
694 $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname]));
711 if (empty($method)) {
712 $val = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
713 } elseif ($method == 1) {
714 $val = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
715 } elseif ($method == 2) {
716 $val = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
717 } elseif ($method == 3) {
718 $val = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
720 $val =
'BadFirstParameterForGETPOST';
723 return is_array($val);
755function GETPOST($paramname, $check =
'alphanohtml', $method = 0, $filter =
null, $options =
null, $noreplace = 0)
757 global $mysoc, $user, $conf;
759 if (empty($paramname)) {
760 return 'BadFirstParameterForGETPOST';
763 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);
768 if (empty($method)) {
769 $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
770 } elseif ($method == 1) {
771 $out = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
772 } elseif ($method == 2) {
773 $out = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
774 } elseif ($method == 3) {
775 $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
777 return 'BadThirdParameterForGETPOST';
780 $relativepathstring =
'';
782 if (empty($method) || $method == 3 || $method == 4) {
783 $relativepathstring = (empty($_SERVER[
"PHP_SELF"]) ?
'' : $_SERVER[
"PHP_SELF"]);
785 if (constant(
'DOL_URL_ROOT')) {
786 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
788 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
789 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
795 if (!empty($_GET[
'restore_lastsearch_values'])) {
796 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
797 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
798 if (is_array($tmp)) {
799 foreach ($tmp as $key => $val) {
800 if ($key == $paramname) {
808 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
809 $out = $_SESSION[
'lastsearch_contextpage_'.$relativepathstring];
810 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
811 $out = $_SESSION[
'lastsearch_limit_'.$relativepathstring];
812 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
813 $out = $_SESSION[
'lastsearch_page_'.$relativepathstring];
814 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
815 $out = $_SESSION[
'lastsearch_mode_'.$relativepathstring];
817 } elseif (!isset($_GET[
'sortfield'])) {
820 if (!empty($_GET[
'action']) && $_GET[
'action'] ==
'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
823 '@phan-var-force CommonObject $object';
824 if (is_object(
$object) && isset(
$object->fields[$paramname][
'default'])) {
826 $out =
$object->fields[$paramname][
'default'];
830 if (!empty($_GET[
'action']) && (preg_match(
'/^create/', $_GET[
'action']) || preg_match(
'/^presend/', $_GET[
'action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
832 if (!empty($user->default_values)) {
833 if (isset($user->default_values[$relativepathstring][
'createform'])) {
834 foreach ($user->default_values[$relativepathstring][
'createform'] as $defkey => $defval) {
836 if ($defkey !=
'_noquery_') {
837 $tmpqueryarraytohave = explode(
'&', $defkey);
840 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
841 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
854 if (isset($user->default_values[$relativepathstring][
'createform'][$defkey][$paramname])) {
855 $out = $user->default_values[$relativepathstring][
'createform'][$defkey][$paramname];
862 } elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
864 if (!empty($user->default_values)) {
867 if ($paramname ==
'sortfield' || $paramname ==
'sortorder') {
869 if (isset($user->default_values[$relativepathstring][
'sortorder'])) {
871 foreach ($user->default_values[$relativepathstring][
'sortorder'] as $defkey => $defval) {
873 if ($defkey !=
'_noquery_') {
874 $tmpqueryarraytohave = explode(
'&', $defkey);
877 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
878 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
891 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
892 foreach ($user->default_values[$relativepathstring][
'sortorder'][$defkey] as $key => $val) {
896 if ($paramname ==
'sortfield') {
899 if ($paramname ==
'sortorder') {
907 } elseif (isset($user->default_values[$relativepathstring][
'filters'])) {
908 foreach ($user->default_values[$relativepathstring][
'filters'] as $defkey => $defval) {
909 if (!empty($_GET[
'disabledefaultvalues'])) {
913 if ($defkey !=
'_noquery_') {
914 $tmpqueryarraytohave = explode(
'&', $defkey);
917 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
918 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
930 if ($qualified && isset($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname])) {
932 if (isset($_POST[
'sall']) || isset($_POST[
'search_all']) || isset($_GET[
'sall']) || isset($_GET[
'search_all'])) {
935 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
936 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
939 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
940 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
955 '@phan-var-force string $paramname';
956 if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
960 while (preg_match(
'/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) {
964 if ($reg[1] ==
'DAY') {
966 $newout = $tmp[
'mday'];
967 } elseif ($reg[1] ==
'MONTH') {
969 $newout = $tmp[
'mon'];
970 } elseif ($reg[1] ==
'YEAR') {
972 $newout = $tmp[
'year'];
973 } elseif ($reg[1] ==
'PREVIOUS_DAY') {
976 $newout = $tmp2[
'day'];
977 } elseif ($reg[1] ==
'PREVIOUS_MONTH') {
980 $newout = $tmp2[
'month'];
981 } elseif ($reg[1] ==
'PREVIOUS_YEAR') {
983 $newout = ($tmp[
'year'] - 1);
984 } elseif ($reg[1] ==
'NEXT_DAY') {
987 $newout = $tmp2[
'day'];
988 } elseif ($reg[1] ==
'NEXT_MONTH') {
991 $newout = $tmp2[
'month'];
992 } elseif ($reg[1] ==
'NEXT_YEAR') {
994 $newout = ($tmp[
'year'] + 1);
995 } elseif ($reg[1] ==
'MYCOMPANY_COUNTRY_ID' || $reg[1] ==
'MYCOUNTRY_ID' || $reg[1] ==
'MYCOUNTRYID') {
996 $newout = $mysoc->country_id;
997 } elseif ($reg[1] ==
'USER_ID' || $reg[1] ==
'USERID') {
999 } elseif ($reg[1] ==
'USER_SUPERVISOR_ID' || $reg[1] ==
'SUPERVISOR_ID' || $reg[1] ==
'SUPERVISORID') {
1000 $newout = $user->fk_user;
1001 } elseif ($reg[1] ==
'ENTITY_ID' || $reg[1] ==
'ENTITYID') {
1002 $newout = $conf->entity;
1003 } elseif ($reg[1] ==
'ID') {
1009 $out = preg_replace(
'/__'.preg_quote($reg[1],
'/').
'__/', $newout, $out);
1014 if (preg_match(
'/^array/', $check)) {
1015 if (!is_array($out) || empty($out)) {
1018 $tmparray = explode(
':', $check);
1019 if (!empty($tmparray[1])) {
1020 $tmpcheck = $tmparray[1];
1022 $tmpcheck =
'alphanohtml';
1024 foreach ($out as $outkey => $outval) {
1025 $out[$outkey] =
sanitizeVal($outval, $tmpcheck, $filter, $options);
1031 if (strpos($paramname,
'search_') === 0) {
1032 $out = preg_replace(
'/([<>])([-+]?\d)/',
'\1 \2', $out);
1036 $out =
sanitizeVal($out, $check, $filter, $options);
1041 if ($paramname ==
'backtopage' || $paramname ==
'backtolist' || $paramname ==
'backtourl') {
1042 $out = str_replace(
'\\',
'/', $out);
1043 $out = str_replace(array(
':',
';',
'@',
"\t",
' '),
'', $out);
1045 $oldstringtoclean = $out;
1046 $out = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $out);
1047 $out = preg_replace(array(
'/^[^\?]*%/'),
'', $out);
1048 $out = preg_replace(array(
'/^[a-z]*\/\s*\/+/i'),
'', $out);
1049 }
while ($oldstringtoclean != $out);
1054 if (empty($method) || $method == 3 || $method == 4) {
1055 if (preg_match(
'/^search_/', $paramname) || in_array($paramname, array(
'sortorder',
'sortfield'))) {
1062 if ($out !=
'' && isset($user)) {
1063 $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out;
1082 return (
int)
GETPOST($paramname,
'int', $method,
null,
null, 0);
1111function checkVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1113 return sanitizeVal($out, $check, $filter, $options);
1125function sanitizeVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1133 if (!is_numeric($out)) {
1138 if (is_array($out)) {
1139 $out = implode(
',', $out);
1141 if (preg_match(
'/[^0-9,-]+/i', $out)) {
1146 $out = filter_var($out, FILTER_SANITIZE_STRING);
1149 $out = filter_var($out, FILTER_SANITIZE_EMAIL);
1152 if (!is_array($out)) {
1154 if (preg_match(
'/[^a-z]+/i', $out)) {
1160 if (!is_array($out)) {
1162 if (preg_match(
'/[^a-z0-9_\-\.]+/i', $out)) {
1168 if (!is_array($out)) {
1170 if (preg_match(
'/[^a-z0-9_\-\.@]+/i', $out)) {
1176 if (!is_array($out)) {
1178 if (preg_match(
'/[^a-z0-9_\-\.,]+/i', $out)) {
1185 if (!is_array($out)) {
1188 $oldstringtoclean = $out;
1192 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1199 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1200 }
while ($oldstringtoclean != $out);
1204 case 'alphawithlgt':
1205 if (!is_array($out)) {
1208 $oldstringtoclean = $out;
1212 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1219 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1220 }
while ($oldstringtoclean != $out);
1226 case 'restricthtmlnolink':
1227 case 'restricthtml':
1228 case 'restricthtmlallowclass':
1229 case 'restricthtmlallowunvalid':
1234 if (empty($filter)) {
1235 return 'BadParameterForGETPOST - Param 3 of sanitizeVal()';
1237 if (is_null($options)) {
1240 $out = filter_var($out, $filter, $options);
1244 dol_syslog(
"Error, you call sanitizeVal() with a bad value for the check type. Data will be sanitized with alphanohtml.", LOG_ERR);
1245 $out =
GETPOST($out,
'alphanohtml');
1253if (!function_exists(
'dol_getprefix')) {
1264 function dol_getprefix($mode =
'')
1267 if ($mode ==
'email') {
1272 return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
1273 } elseif (isset($_SERVER[
"SERVER_NAME"])) {
1274 return $_SERVER[
"SERVER_NAME"];
1279 if (!empty($conf->file->instance_unique_id)) {
1280 return sha1(
'dolibarr'.$conf->file->instance_unique_id);
1284 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1288 global $dolibarr_main_instance_unique_id, $dolibarr_main_cookie_cryptkey;
1289 $tmp_instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ?
'' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
1292 if (!empty($tmp_instance_unique_id)) {
1293 return sha1(
'dolibarr'.$tmp_instance_unique_id);
1297 if (isset($_SERVER[
"SERVER_NAME"]) && isset($_SERVER[
"DOCUMENT_ROOT"])) {
1298 return sha1($_SERVER[
"SERVER_NAME"].$_SERVER[
"DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1300 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1317 global $conf, $langs, $user, $mysoc;
1321 if (!file_exists($fullpath)) {
1322 dol_syslog(
'functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_WARNING);
1326 if (!empty($classname) && !class_exists($classname)) {
1327 return include $fullpath;
1329 return include_once $fullpath;
1347function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
1351 $path = preg_replace(
'/^\//',
'', $path);
1354 $res = DOL_DOCUMENT_ROOT.
'/'.$path;
1355 if (is_array($conf->file->dol_document_root)) {
1356 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1357 if ($key ==
'main') {
1361 if (@file_exists($dirroot.
'/'.$path)) {
1362 $res = $dirroot.
'/'.$path;
1367 if ($returnemptyifnotfound) {
1369 if ($returnemptyifnotfound == 1 || !file_exists($res)) {
1381 $res = DOL_URL_ROOT.
'/'.$path;
1384 $res = DOL_MAIN_URL_ROOT.
'/'.$path;
1387 $res = DOL_URL_ROOT.
'/'.$path;
1390 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1391 if ($key ==
'main') {
1396 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($conf->file->dol_main_url_root));
1397 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1400 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
'/'.$path;
1405 preg_match(
'/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);
1406 if (!empty($regs[1])) {
1409 if (@file_exists($dirroot.
'/'.$regs[1])) {
1411 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1412 } elseif ($type == 2) {
1413 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1414 } elseif ($type == 3) {
1418 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($conf->file->dol_main_url_root));
1419 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1422 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).$conf->file->dol_url_root[$key].
'/'.$path;
1446 if (empty($properties)) {
1447 return get_object_vars($obj);
1450 $existingProperties = [];
1451 $realProperties = get_object_vars($obj);
1454 foreach ($properties as $property) {
1455 if (array_key_exists($property, $realProperties)) {
1457 $existingProperties[$property] = $obj->{$property};
1458 } elseif (property_exists($obj, $property)) {
1460 $existingProperties[$property] = $obj->{$property};
1464 return $existingProperties;
1492 $myclone = unserialize(serialize(
$object));
1494 if (!empty($tmpsavdb)) {
1497 } elseif ($native == 2) {
1500 $tmparray = get_object_vars(
$object);
1502 if (is_array($tmparray)) {
1503 foreach ($tmparray as $propertykey => $propertyval) {
1504 if (is_scalar($propertyval) || is_array($propertyval)) {
1505 $myclone->$propertykey = $propertyval;
1525function dol_size($size, $type =
'')
1528 if (empty($conf->dol_optimize_smallscreen)) {
1531 if ($type ==
'width' && $size > 250) {
1556 $filesystem_forbidden_chars = array(
'<',
'>',
'/',
'\\',
'?',
'*',
'|',
'"',
':',
'°',
'$',
';',
'`');
1558 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1559 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1560 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1561 $tmp = str_replace(
'..',
'', $tmp);
1582 $filesystem_forbidden_chars = array(
'<',
'>',
'?',
'*',
'|',
'"',
'°',
'$',
';',
'`');
1584 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1585 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1586 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1587 $tmp = str_replace(
'..',
'', $tmp);
1602 $stringtoclean = preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $stringtoclean);
1604 $stringtoclean = preg_replace(
'/<!--[^>]*-->/',
'', $stringtoclean);
1606 $stringtoclean = str_replace(
'\\',
'/', $stringtoclean);
1610 $stringtoclean = str_replace(array(
':',
';',
'@'),
'', $stringtoclean);
1614 $oldstringtoclean = $stringtoclean;
1617 $stringtoclean = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $stringtoclean);
1618 }
while ($oldstringtoclean != $stringtoclean);
1622 $stringtoclean = preg_replace(array(
'/^[a-z]*\/\/+/i'),
'', $stringtoclean);
1625 return $stringtoclean;
1637 $oldstringtoclean = $stringtoclean;
1638 $stringtoclean = str_ireplace(array(
'"',
':',
'[',
']',
"\n",
"\r",
'\\',
'\/'),
'', $stringtoclean);
1639 }
while ($oldstringtoclean != $stringtoclean);
1641 return $stringtoclean;
1656 if (is_null($str)) {
1661 if (extension_loaded(
'intl') &&
getDolGlobalString(
'MAIN_UNACCENT_USE_TRANSLITERATOR')) {
1662 $transliterator = Transliterator::createFromRules(
':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', Transliterator::FORWARD);
1663 return $transliterator->transliterate($str);
1666 $string = rawurlencode($str);
1667 $replacements = array(
1668 '%C3%80' =>
'A',
'%C3%81' =>
'A',
'%C3%82' =>
'A',
'%C3%83' =>
'A',
'%C3%84' =>
'A',
'%C3%85' =>
'A',
1670 '%C3%88' =>
'E',
'%C3%89' =>
'E',
'%C3%8A' =>
'E',
'%C3%8B' =>
'E',
1671 '%C3%8C' =>
'I',
'%C3%8D' =>
'I',
'%C3%8E' =>
'I',
'%C3%8F' =>
'I',
1673 '%C3%92' =>
'O',
'%C3%93' =>
'O',
'%C3%94' =>
'O',
'%C3%95' =>
'O',
'%C3%96' =>
'O',
1675 '%C3%99' =>
'U',
'%C3%9A' =>
'U',
'%C3%9B' =>
'U',
'%C3%9C' =>
'U',
1676 '%C3%9D' =>
'Y',
'%C5%B8' =>
'y',
1677 '%C3%A0' =>
'a',
'%C3%A1' =>
'a',
'%C3%A2' =>
'a',
'%C3%A3' =>
'a',
'%C3%A4' =>
'a',
'%C3%A5' =>
'a',
1679 '%C3%A8' =>
'e',
'%C3%A9' =>
'e',
'%C3%AA' =>
'e',
'%C3%AB' =>
'e',
1680 '%C3%AC' =>
'i',
'%C3%AD' =>
'i',
'%C3%AE' =>
'i',
'%C3%AF' =>
'i',
1682 '%C3%B2' =>
'o',
'%C3%B3' =>
'o',
'%C3%B4' =>
'o',
'%C3%B5' =>
'o',
'%C3%B6' =>
'o',
1684 '%C3%B9' =>
'u',
'%C3%BA' =>
'u',
'%C3%BB' =>
'u',
'%C3%BC' =>
'u',
1685 '%C3%BD' =>
'y',
'%C3%BF' =>
'y'
1687 $string = strtr($string, $replacements);
1688 return rawurldecode($string);
1693 "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
1694 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
1695 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
1696 \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
1697 \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
1698 \xF9\xFA\xFB\xFC\xFD\xFF",
1706 $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"));
1724function dol_string_nospecial($str, $newstr =
'_', $badcharstoreplace =
'', $badcharstoremove =
'', $keepspaces = 0)
1726 $forbidden_chars_to_replace = array(
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
",",
";",
"=",
'°',
'$',
';');
1727 if (empty($keepspaces)) {
1728 $forbidden_chars_to_replace[] =
" ";
1730 $forbidden_chars_to_remove = array();
1733 if (is_array($badcharstoreplace)) {
1734 $forbidden_chars_to_replace = $badcharstoreplace;
1736 if (is_array($badcharstoremove)) {
1737 $forbidden_chars_to_remove = $badcharstoremove;
1741 return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove,
"", $str));
1760 if ($removetabcrlf) {
1761 return preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $str);
1763 return preg_replace(
'/[\x00-\x08\x11-\x12\x14-\x1F\x7F]/u',
'', $str);
1775function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0)
1777 if (is_null($stringtoescape)) {
1782 $substitjs = array(
"'" =>
"\\'",
"\r" =>
'\\r');
1784 if (empty($noescapebackslashn)) {
1785 $substitjs[
"\n"] =
'\\n';
1786 $substitjs[
'\\'] =
'\\\\';
1789 $substitjs[
"'"] =
"\\'";
1790 $substitjs[
'"'] =
"\\'";
1791 } elseif ($mode == 1) {
1792 $substitjs[
"'"] =
"\\'";
1793 } elseif ($mode == 2) {
1794 $substitjs[
'"'] =
'\\"';
1795 } elseif ($mode == 3) {
1796 $substitjs[
"'"] =
"\\'";
1797 $substitjs[
'"'] =
"\\\"";
1799 return strtr($stringtoescape, $substitjs);
1810 return str_replace(
'"',
'\"', $stringtoescape);
1822 if (is_null($stringtoescape)) {
1826 if ($stringforquotes == 2) {
1827 return str_replace(
'"',
"'", $stringtoescape);
1828 } elseif ($stringforquotes == 1) {
1834 $stringtoescape = str_replace(
'\\',
'', $stringtoescape);
1835 return str_replace(
"'",
"\'", str_replace(
'"',
"'", $stringtoescape));
1838 return 'Bad parameter for stringforquotes in dol_escape_php';
1849 return $stringtoescape;
1889 return dol_escape_htmltag(
dol_string_onlythesehtmltags(
dol_htmlentitiesbr($s), 1, 0, 0, 0, array(
'br',
'b',
'font',
'span')), 1, -1,
'', 0, 1);
1913 return htmlspecialchars($s, ENT_COMPAT,
'UTF-8');
1933function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags =
'', $escapeonlyhtmltags = 0, $cleanalsojavascript = 0)
1935 if ($noescapetags ==
'common') {
1936 $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';
1938 $noescapetags .=
',header,footer,nav,section,menu,menuitem';
1940 if ($cleanalsojavascript) {
1945 if ($escapeonlyhtmltags) {
1946 $tmp = htmlspecialchars_decode((
string) $stringtoescape, ENT_COMPAT);
1948 $tmp = html_entity_decode((
string) $stringtoescape, ENT_COMPAT,
'UTF-8');
1949 $tmp = str_ireplace(
''',
'__SIMPLEQUOTE', $tmp);
1952 $tmp = strtr($tmp, array(
"<b>" =>
'',
'</b>' =>
'',
'<strong>' =>
'',
'</strong>' =>
''));
1955 $tmp = strtr($tmp, array(
"\r" =>
'\\r',
"\n" =>
'\\n'));
1956 } elseif ($keepn == -1) {
1957 $tmp = strtr($tmp, array(
"\r" =>
'',
"\n" =>
''));
1960 if ($escapeonlyhtmltags) {
1961 return htmlspecialchars($tmp, ENT_COMPAT,
'UTF-8');
1964 $tmparrayoftags = array();
1965 if ($noescapetags) {
1966 $tmparrayoftags = explode(
',', $noescapetags);
1968 if (count($tmparrayoftags)) {
1970 $tmp = str_ireplace(
'__DOUBLEQUOTE',
'', $tmp);
1972 foreach ($tmparrayoftags as $tagtoreplace) {
1973 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'>/',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1974 $tmp = str_ireplace(
'</'.$tagtoreplace.
'>',
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1975 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
' \/>/',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
1981 if (preg_match(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+([^>]+)>/', $tmp, $reg)) {
1982 $tmpattributes = str_ireplace(array(
'[',
']'),
'_', $reg[1]);
1983 $tmpattributes = str_ireplace(
'href="http:',
'__HREFHTTPA', $tmpattributes);
1984 $tmpattributes = str_ireplace(
'href="https:',
'__HREFHTTPSA', $tmpattributes);
1985 $tmpattributes = str_ireplace(
'src="http:',
'__SRCHTTPIMG', $tmpattributes);
1986 $tmpattributes = str_ireplace(
'src="https:',
'__SRCHTTPSIMG', $tmpattributes);
1987 $tmpattributes = str_ireplace(
'"',
'__DOUBLEQUOTE', $tmpattributes);
1988 $tmpattributes = preg_replace(
'/[^a-z0-9_\/\?\;\s=&\.\-@:\.#\+]/i',
'', $tmpattributes);
1990 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+'.preg_quote($reg[1],
'/').
'>/',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'['.$tmpattributes.
']__', $tmp);
1992 if (preg_match(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+([^>]+)\s+\/>/', $tmp, $reg)) {
1993 $tmpattributes = str_ireplace(array(
'[',
']'),
'_', $reg[1]);
1994 $tmpattributes = str_ireplace(
'"',
'__DOUBLEQUOTE', $tmpattributes);
1995 $tmpattributes = preg_replace(
'/[^a-z0-9_\/\?\;\s=&\.\-@:\.#\+]/i',
'', $tmpattributes);
1997 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+'.preg_quote($reg[1],
'/').
'\s+\/>/',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'['.$tmpattributes.
']__', $tmp);
2000 $diff = strcmp($tmpold, $tmp);
2005 $result = htmlentities($tmp, ENT_COMPAT,
'UTF-8');
2009 if (count($tmparrayoftags)) {
2010 foreach ($tmparrayoftags as $tagtoreplace) {
2011 $result = str_ireplace(
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
'>', $result);
2012 $result = preg_replace(
'/__BEGINTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1>', $result);
2013 $result = str_ireplace(
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__',
'</'.$tagtoreplace.
'>', $result);
2014 $result = str_ireplace(
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
' />', $result);
2015 $result = preg_replace(
'/__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1 />', $result);
2018 $result = str_ireplace(
'__HREFHTTPA',
'href="http:', $result);
2019 $result = str_ireplace(
'__HREFHTTPSA',
'href="https:', $result);
2020 $result = str_ireplace(
'__SRCHTTPIMG',
'src="http:', $result);
2021 $result = str_ireplace(
'__SRCHTTPSIMG',
'src="https:', $result);
2022 $result = str_ireplace(
'__DOUBLEQUOTE',
'"', $result);
2025 $result = str_ireplace(
'__SIMPLEQUOTE',
''', $result);
2042 if (function_exists(
'mb_strtolower')) {
2043 return mb_strtolower($string, $encoding);
2045 return strtolower($string);
2059 if (function_exists(
'mb_strtoupper')) {
2060 return mb_strtoupper($string, $encoding);
2062 return strtoupper($string);
2076 if (function_exists(
'mb_substr')) {
2077 return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1,
null, $encoding);
2079 return ucfirst($string);
2093 if (function_exists(
'mb_convert_case')) {
2094 return mb_convert_case($string, MB_CASE_TITLE, $encoding);
2096 return ucwords($string);
2122function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
'', $restricttologhandler =
'', $logcontext =
null)
2124 global $conf, $user, $debugbar;
2127 if (!isModEnabled(
'syslog')) {
2132 if (defined(
'USEEXTERNALSERVER') && !defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
2133 global $website, $websitekey;
2134 if (is_object($website) && !empty($website->ref)) {
2135 $suffixinfilename .=
'_website_'.$website->ref;
2136 } elseif (!empty($websitekey)) {
2137 $suffixinfilename .=
'_website_'.$websitekey;
2142 if (defined(
'USESUFFIXINLOG')) {
2143 $suffixinfilename .= constant(
'USESUFFIXINLOG');
2147 foreach ($conf->loghandlers as $loghandlerinstance) {
2148 $loghandlerinstance->setIdent($ident);
2152 if (!empty($message)) {
2155 $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');
2156 if (!array_key_exists($level, $logLevels)) {
2157 throw new Exception(
'Incorrect log level');
2164 $message = preg_replace(
'/password=\'[^\']*\'/',
'password=\'hidden\'', $message);
2168 if ((!empty($_REQUEST[
'logtohtml']) &&
getDolGlobalString(
'MAIN_ENABLE_LOG_TO_HTML'))
2169 || (is_object($user) && $user->hasRight(
'debugbar',
'read') && is_object($debugbar))) {
2170 $ospid = sprintf(
"%7s",
dol_trunc(getmypid(), 7,
'right',
'UTF-8', 1));
2171 $osuser =
" ".sprintf(
"%6s",
dol_trunc(function_exists(
'posix_getuid') ? posix_getuid() :
'', 6,
'right',
'UTF-8', 1));
2173 $conf->logbuffer[] =
dol_print_date(time(),
"%Y-%m-%d %H:%M:%S").
" ".sprintf(
"%-7s", $logLevels[$level]).
" ".$ospid.
" ".$osuser.
" ".$message;
2179 print
"\n\n<!-- Log start\n";
2181 print
"Log end -->\n";
2185 'message' => $message,
2186 'script' => (isset($_SERVER[
'PHP_SELF']) ? basename($_SERVER[
'PHP_SELF'],
'.php') : false),
2188 'user' => ((is_object($user) && $user->id) ? $user->login : false),
2190 'osuser' => function_exists(
'posix_getuid') ? posix_getuid() : false,
2191 'ospid' => getmypid()
2195 if (!empty($remoteip)) {
2196 $data[
'ip'] = $remoteip;
2198 if (!empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) && $_SERVER[
'HTTP_X_FORWARDED_FOR'] != $remoteip) {
2199 $data[
'ip'] = $_SERVER[
'HTTP_X_FORWARDED_FOR'].
' -> '.$data[
'ip'];
2200 } elseif (!empty($_SERVER[
'HTTP_CLIENT_IP']) && $_SERVER[
'HTTP_CLIENT_IP'] != $remoteip) {
2201 $data[
'ip'] = $_SERVER[
'HTTP_CLIENT_IP'].
' -> '.$data[
'ip'];
2203 } elseif (!empty($_SERVER[
'SERVER_ADDR'])) {
2205 $data[
'ip'] = $_SERVER[
'SERVER_ADDR'];
2206 } elseif (!empty($_SERVER[
'COMPUTERNAME'])) {
2208 $data[
'ip'] = $_SERVER[
'COMPUTERNAME'];
2210 $data[
'ip'] =
'???';
2213 if (!empty($_SERVER[
'USERNAME'])) {
2215 $data[
'osuser'] = $_SERVER[
'USERNAME'];
2216 } elseif (!empty($_SERVER[
'LOGNAME'])) {
2218 $data[
'osuser'] = $_SERVER[
'LOGNAME'];
2222 foreach ($conf->loghandlers as $loghandlerinstance) {
2223 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
2226 $loghandlerinstance->export($data, $suffixinfilename);
2232 foreach ($conf->loghandlers as $loghandlerinstance) {
2233 $loghandlerinstance->setIdent($ident);
2253 $form =
new Form($db);
2255 $templatenameforexport = $website->name_template;
2256 if (empty($templatenameforexport)) {
2257 $templatenameforexport =
'website_'.$website->ref;
2261 $out .=
'<input type="button" class="cursorpointer button bordertransp" id="open-dialog-' . $name .
'" value="'.dol_escape_htmltag($buttonstring).
'"/>';
2264 $out .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">';
2265 $out .=
'jQuery(document).ready(function () {';
2266 $out .=
' jQuery("#open-dialog-' . $name .
'").click(function () {';
2267 $out .=
' var dialogHtml = \'';
2269 $dialogcontent =
' <div id="custom-dialog-' . $name .
'">';
2270 $dialogcontent .=
' <div style="margin-top: 20px;">';
2271 $dialogcontent .=
' <label for="export-site-' . $name .
'"><strong>'.$langs->trans(
"ExportSiteLabel").
'...</label><br>';
2272 $dialogcontent .=
' <button class="button smallpaddingimp" id="export-site-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"DownloadZip")) .
'</button>';
2273 $dialogcontent .=
' </div>';
2274 $dialogcontent .=
' <br>';
2275 $dialogcontent .=
' <div style="margin-top: 20px;">';
2276 $dialogcontent .=
' <strong>'.$langs->trans(
"ExportSiteGitLabel").
' '.$form->textwithpicto(
'', $langs->trans(
"SourceFiles"), 1,
'help',
'', 0, 3,
'').
'</strong><br>';
2277 $dialogcontent .=
' <form action="'.dol_escape_htmltag($overwriteGitUrl).
'" method="POST">';
2278 $dialogcontent .=
' <input type="hidden" name="action" value="overwritesite">';
2279 $dialogcontent .=
' <input type="hidden" name="token" value="'.newToken().
'">';
2280 $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>';
2281 $dialogcontent .=
' <button type="submit" class="button smallpaddingimp" id="overwrite-git-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"ExportIntoGIT")) .
'</button>';
2282 $dialogcontent .=
' </form>';
2283 $dialogcontent .=
' </div>';
2284 $dialogcontent .=
' </div>';
2291 // Add the content of the dialog to the body of the page
2292 $out .= ' var $dialog = jQuery(
"#custom-dialog-' . $name . '");
';
2293 $out .= ' if ($dialog.length > 0) {
2296 jQuery(
"body").append(dialogHtml);
';
2298 // Configuration of popup
2299 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog({
';
2300 $out .= ' autoOpen:
false,
';
2301 $out .= ' modal:
true,
';
2302 $out .= ' height: 290,
';
2303 $out .= ' width:
"40%",
';
2304 $out .= ' title:
"' . dol_escape_js($label) . '",
';
2307 // Simulate a click on the original "submit" input to export the site.
2308 $out .= ' jQuery(
"#export-site-' . $name . '").click(
function () {
';
2309 $out .= ' console.log(
"Clic on exportsite.");
';
2310 $out .= ' var target = jQuery(
"input[name=\'' . dol_escape_js($exportSiteName) . '\']");
';
2311 $out .= ' console.log(
"element founded:", target.length > 0);
';
2312 $out .= ' if (target.length > 0) { target.click(); }
';
2313 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"close");
';
2317 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"open");
';
2318 $out .= ' return false;
';
2321 $out .= '</script>
';
2343function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '
', $morecss = 'classlink
button bordertransp
', $jsonopen = '', $backtopagejsfields = '', $accesskey = '')
2347 if (strpos($url, '?
') > 0) {
2348 $url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2350 $url .= '?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2355 $backtopagejsfieldsid = '';
2356 $backtopagejsfieldslabel = '';
2357 if ($backtopagejsfields) {
2358 $tmpbacktopagejsfields = explode(':
', $backtopagejsfields);
2359 if (empty($tmpbacktopagejsfields[1])) { // If the part 'keyforpopupid:
' is missing, we add $name for it.
2360 $backtopagejsfields = $name.":".$backtopagejsfields;
2361 $tmp2backtopagejsfields = explode(',
', $tmpbacktopagejsfields[0]);
2363 $tmp2backtopagejsfields = explode(',
', $tmpbacktopagejsfields[1]);
2365 $backtopagejsfieldsid = empty($tmp2backtopagejsfields[0]) ? '' : $tmp2backtopagejsfields[0];
2366 $backtopagejsfieldslabel = empty($tmp2backtopagejsfields[1]) ? '' : $tmp2backtopagejsfields[1];
2367 $url .= '&backtopagejsfields=
'.urlencode($backtopagejsfields);
2370 //print '<input
type=
"submit" class=
"button bordertransp"'.$disabled.' value=
"'.dol_escape_htmltag($langs->trans("MediaFiles
")).'" name=
"file_manager">
';
2371 $out .= '<!-- a link
for button to open url into a dialog popup with backtopagejsfields =
'.$backtopagejsfields.' -->
';
2372 $out .= '<a
'.($accesskey ? ' accesskey=
"'.$accesskey.'"' : '').' class=
"cursorpointer reposition button_'.$name.($morecss ? ' '.$morecss : '').'"'.$disabled.' title=
"'.dol_escape_htmltag($label).'"';
2373 if (empty($conf->use_javascript_ajax)) {
2374 $out .= ' href=
"'.DOL_URL_ROOT.$url.'" target=
"_blank"';
2375 } elseif ($jsonopen) {
2376 $out .= ' href=
"#" onclick=
"'.$jsonopen.'"';
2378 $out .= ' href=
"#"';
2380 $out .= '>
'.$buttonstring.'</a>
';
2382 if (!empty($conf->use_javascript_ajax)) {
2383 // Add code to open url using the popup. Add also hidden field to retrieve the returned variables
2384 $out .= '<!-- code to open popup and variables to retrieve returned variables -->
';
2385 $out .= '<div
id=
"idfordialog'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for dialog
' : '').'</div>
';
2386 $out .= '<div
id=
"varforreturndialogid'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for returned
id' : '').'</div>
';
2387 $out .= '<div
id=
"varforreturndialoglabel'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for returned label
' : '').'</div>
';
2389 $out .= '<!-- Add js code to open dialog popup on dialog -->
';
2390 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript">
2391 jQuery(document).ready(
function () {
2392 jQuery(
".button_'.$name.'").click(
function () {
2393 console.log(\
'Open popup with jQuery(...).dialog() on URL '.
dol_escape_js(DOL_URL_ROOT.$url).
'\');
2394 var $tmpdialog = $(\
'#idfordialog'.$name.
'\');
2395 $tmpdialog.html(\
'<iframe class="iframedialog" id="iframedialog'.$name.
'" style="border: 0px;" src="'.DOL_URL_ROOT.$url.
'" width="100%" height="98%"></iframe>\');
2399 height: (window.innerHeight - 150),
2402 open: function (event, ui) {
2403 console.log(
"open popup name='.$name.', backtopagejsfields='.$backtopagejsfields.'");
2405 close:
function (event, ui) {
2406 var returnedid = jQuery(
"#varforreturndialogid'.$name.'").text();
2407 var returnedlabel = jQuery(
"#varforreturndialoglabel'.$name.'").text();
2408 console.log(
"popup has been closed. returnedid (js var defined into parent page)="+returnedid+
" returnedlabel="+returnedlabel);
2409 if (returnedid !=
"" && returnedid !=
"div for returned id") {
2410 jQuery(
"#'.(empty($backtopagejsfieldsid) ? "none
" : $backtopagejsfieldsid).'").val(returnedid);
2412 if (returnedlabel !=
"" && returnedlabel !=
"div for returned label") {
2413 jQuery(
"#'.(empty($backtopagejsfieldslabel) ? "none
" : $backtopagejsfieldslabel).'").val(returnedlabel);
2418 $tmpdialog.dialog(\
'open\');
2443function dol_fiche_head($links = array(), $active =
'0', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
2445 print
dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow, $moretabssuffix);
2464function dol_get_fiche_head($links = array(), $active =
'', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'', $dragdropfile = 0)
2466 global $conf, $langs, $hookmanager;
2470 if (!empty($conf->dol_optimize_smallscreen)) {
2474 $out =
"\n".
'<!-- dol_fiche_head - dol_get_fiche_head -->';
2476 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2477 $out .=
'<div class="tabs'.($picto ?
'' :
' nopaddingleft').
'" data-role="controlgroup" data-type="horizontal">'.
"\n";
2481 if ($morehtmlright) {
2482 $out .=
'<div class="inline-block floatright tabsElem">'.$morehtmlright.
'</div>';
2486 if (!empty($title) && $showtitle && !
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER')) {
2488 $out .=
'<a class="tabTitle">';
2490 $noprefix = $pictoisfullpath;
2491 if (strpos($picto,
'fontawesome_') !==
false) {
2494 $out .=
img_picto($title, ($noprefix ?
'' :
'object_').$picto,
'', $pictoisfullpath, 0, 0,
'',
'imgTabTitle').
' ';
2496 $out .=
'<span class="tabTitleText">'.dol_escape_htmltag(
dol_trunc($title, $limittitle)).
'</span>';
2504 if (is_array($links) && !empty($links)) {
2505 $keys = array_keys($links);
2507 $maxkey = max($keys);
2513 if (empty($limittoshow)) {
2514 $limittoshow = (!
getDolGlobalString(
'MAIN_MAXTABS_IN_CARD') ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD);
2516 if (!empty($conf->dol_optimize_smallscreen)) {
2524 for ($i = 0; $i <= $maxkey; $i++) {
2525 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2527 if ($i >= $limittoshow) {
2533 for ($i = 0; $i <= $maxkey; $i++) {
2534 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2540 if ($i < $limittoshow || $isactive) {
2542 $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])).
' -->';
2544 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2545 if (!empty($links[$i][0])) {
2546 $out .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2548 $out .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2550 } elseif (!empty($links[$i][1])) {
2552 $out .=
'<div class="tab tab'.($isactive ?
'active' :
'unactive').
'" style="margin: 0 !important">';
2553 if (!empty($links[$i][0])) {
2554 $titletoshow = preg_replace(
'/<.*$/',
'', $links[$i][1]);
2555 $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).
'">';
2557 $out .= $links[$i][1];
2558 if (!empty($links[$i][0])) {
2559 $out .=
'</a>'.
"\n";
2561 $out .= empty($links[$i][4]) ?
'' : $links[$i][4];
2570 $outmore .=
'<div class="popuptabset wordwrap">';
2572 $outmore .=
'<div class="popuptab wordwrap" style="display:inherit;">';
2573 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2574 if (!empty($links[$i][0])) {
2575 $outmore .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2577 $outmore .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2579 } elseif (!empty($links[$i][1])) {
2580 $outmore .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="wordwrap inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
2581 $outmore .= preg_replace(
'/([a-z])\|([a-z])/i',
'\\1 | \\2', $links[$i][1]);
2582 $outmore .=
'</a>'.
"\n";
2584 $outmore .=
'</div>';
2591 $outmore .=
'</div>';
2595 $left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
2596 $right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
2597 $widthofpopup = 200;
2599 $tabsname = $moretabssuffix;
2600 if (empty($tabsname)) {
2601 $tabsname = str_replace(
"@",
"", $picto);
2603 $out .=
'<div id="moretabs'.$tabsname.
'" class="inline-block tabsElem valignmiddle">';
2605 $out .=
'<div class="tab valignmiddle"><a href="#" class="tab moretab inline-block tabunactive valignmiddle"><span class="hideonsmartphone">'.$langs->trans(
"More").
'</span>... ('.$nbintab.
')</a></div>';
2607 $out .=
'<div id="moretabsList'.$tabsname.
'" style="width: '.$widthofpopup.
'px; position: absolute; '.$left.
': -999em; text-align: '.$left.
'; margin:0px; padding:2px; z-index:10;">';
2610 $out .=
'<div></div>';
2613 $out .=
'<script nonce="'.getNonce().
'">';
2614 $out .=
"$('#moretabs".$tabsname.
"').mouseenter( function() {
2615 var x = this.offsetLeft, y = this.offsetTop;
2616 console.log('mouseenter ".$left.
" x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
2617 if ((window.innerWidth - x) < ".($widthofpopup + 10).
") {
2618 $('#moretabsList".$tabsname.
"').css('".$right.
"','8px');
2620 $('#moretabsList".$tabsname.
"').css('".$left.
"','auto');
2623 $out .=
"$('#moretabs".$tabsname.
"').mouseleave( function() { console.log('mouseleave ".$left.
"'); $('#moretabsList".$tabsname.
"').css('".$left.
"','-999em');});";
2624 $out .=
"</script>";
2627 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2631 if (!$notab || $notab == -1 || $notab == -2 || $notab == -3) {
2632 $out .=
"\n".
'<div id="dragDropAreaTabBar" class="tabBar'.($notab == -1 ?
'' : ($notab == -2 ?
' tabBarNoTop' : (($notab == -3 ?
' noborderbottom' :
'').
' tabBarWithBottom')));
2635 if (!empty($dragdropfile)) {
2636 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2639 $parameters = array(
'tabname' => $active,
'out' => $out);
2640 $reshook = $hookmanager->executeHooks(
'printTabsHead', $parameters);
2642 $out = $hookmanager->resPrint;
2668 if (!$notab || $notab == -1) {
2669 return "\n</div>\n";
2694function dol_banner_tab(
$object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $onlybanner = 0, $morehtmlright =
'')
2696 global $conf, $form, $user, $langs, $hookmanager, $action;
2700 $maxvisiblephotos = 1;
2702 $entity = (empty(
$object->entity) ? $conf->entity :
$object->entity);
2704 $showbarcode = !isModEnabled(
'barcode') ? 0 : (empty(
$object->barcode) ? 0 : 1);
2705 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2708 $modulepart =
'unknown';
2710 if (in_array(
$object->element, [
'societe',
'contact',
'product',
'ticket',
'bom'])) {
2711 $modulepart =
$object->element;
2712 } elseif (
$object->element ==
'member') {
2713 $modulepart =
'memberphoto';
2714 } elseif (
$object->element ==
'user') {
2715 $modulepart =
'userphoto';
2718 if (class_exists(
"Imagick")) {
2719 if (
$object->element ==
'expensereport' ||
$object->element ==
'propal' ||
$object->element ==
'commande' ||
$object->element ==
'facture' ||
$object->element ==
'supplier_proposal') {
2720 $modulepart =
$object->element;
2721 } elseif (
$object->element ==
'fichinter' ||
$object->element ==
'intervention') {
2722 $modulepart =
'ficheinter';
2723 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
2724 $modulepart =
'contract';
2725 } elseif (
$object->element ==
'order_supplier') {
2726 $modulepart =
'supplier_order';
2727 } elseif (
$object->element ==
'invoice_supplier') {
2728 $modulepart =
'supplier_invoice';
2732 if (
$object->element ==
'product') {
2734 '@phan-var-force Product $object';
2736 $cssclass =
'photowithmargin photoref';
2737 $showimage =
$object->is_photo_available($conf->product->multidir_output[$entity]);
2739 if ($conf->browser->layout ==
'phone') {
2740 $maxvisiblephotos = 1;
2743 $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>';
2747 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2749 $nophoto =
'/public/theme/common/nophoto.png';
2750 $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>';
2753 } elseif (
$object->element ==
'category') {
2755 '@phan-var-force Categorie $object';
2757 $cssclass =
'photowithmargin photoref';
2758 $showimage =
$object->isAnyPhotoAvailable($conf->categorie->multidir_output[$entity]);
2760 if ($conf->browser->layout ==
'phone') {
2761 $maxvisiblephotos = 1;
2764 $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>';
2768 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2770 $nophoto =
'/public/theme/common/nophoto.png';
2771 $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>';
2774 } elseif (
$object->element ==
'bom') {
2776 '@phan-var-force Bom $object';
2778 $cssclass =
'photowithmargin photoref';
2779 $showimage =
$object->is_photo_available($conf->bom->multidir_output[$entity]);
2781 if ($conf->browser->layout ==
'phone') {
2782 $maxvisiblephotos = 1;
2785 $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>';
2789 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2791 $nophoto =
'/public/theme/common/nophoto.png';
2792 $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>';
2795 } elseif (
$object->element ==
'ticket') {
2797 $cssclass =
'photoref';
2799 '@phan-var-force Ticket $object';
2800 $showimage =
$object->is_photo_available($conf->ticket->multidir_output[$entity].
'/'.
$object->ref);
2802 if ($conf->browser->layout ==
'phone') {
2803 $maxvisiblephotos = 1;
2807 $showphoto =
$object->show_photos(
'ticket', $conf->ticket->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0);
2809 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$showphoto.
'</div>';
2817 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2819 $nophoto =
img_picto(
'No photo',
'object_ticket');
2820 $morehtmlleft .=
'<!-- No photo to show -->';
2821 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2822 $morehtmlleft .= $nophoto;
2823 $morehtmlleft .=
'</div></div>';
2828 if ($modulepart !=
'unknown' || method_exists(
$object,
'getDataToShowPhoto')) {
2831 if (in_array($modulepart, array(
'propal',
'commande',
'facture',
'ficheinter',
'contract',
'supplier_order',
'supplier_proposal',
'supplier_invoice',
'expensereport')) && class_exists(
"Imagick")) {
2833 $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]).
"/";
2834 if (in_array($modulepart, array(
'invoice_supplier',
'supplier_invoice'))) {
2836 $subdir .= ((!empty($subdir) && !preg_match(
'/\/$/', $subdir)) ?
'/' :
'').$objectref;
2840 if (empty($subdir)) {
2841 $subdir =
'errorgettingsubdirofobject';
2844 $filepath = $dir_output.$subdir.
"/";
2846 $filepdf = $filepath.$objectref.
".pdf";
2847 $relativepath = $subdir.
'/'.$objectref.
'.pdf';
2850 $fileimage = $filepdf.
'_preview.png';
2851 $relativepathimage = $relativepath.
'_preview.png';
2853 $pdfexists = file_exists($filepdf);
2858 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2860 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2869 if ($pdfexists && !$error) {
2870 $heightforphotref = 80;
2871 if (!empty($conf->dol_optimize_smallscreen)) {
2872 $heightforphotref = 60;
2875 if (file_exists($fileimage)) {
2876 $phototoshow =
'<div class="photoref">';
2877 $phototoshow .=
'<img height="'.$heightforphotref.
'" class="photo photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2878 $phototoshow .=
'</div>';
2881 } elseif (!$phototoshow) {
2882 $phototoshow .= $form->showphoto($modulepart,
$object, 0, 0, 0,
'photowithmargin photoref',
'small', 1, 0, $maxvisiblephotos);
2886 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
2887 $morehtmlleft .= $phototoshow;
2888 $morehtmlleft .=
'</div>';
2892 if (empty($phototoshow)) {
2893 if (
$object->element ==
'action') {
2895 $cssclass =
'photorefcenter';
2896 $nophoto =
img_picto(
'No photo',
'title_agenda');
2899 $cssclass =
'photorefcenter';
2901 $prefix =
'object_';
2905 if (strpos($picto,
'fontawesome_') !==
false) {
2908 $nophoto =
img_picto(
'No photo', $prefix.$picto);
2910 $morehtmlleft .=
'<!-- No photo to show -->';
2911 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2912 $morehtmlleft .= $nophoto;
2913 $morehtmlleft .=
'</div></div>';
2920 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode(
$object, 100,
'photoref valignmiddle').
'</div>';
2923 if (
$object->element ==
'societe') {
2924 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'societe',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
2927 $morehtmlstatus .=
$object->getLibStatut(6);
2929 } elseif (
$object->element ==
'product') {
2931 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
2932 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
2934 $morehtmlstatus .=
'<span class="statusrefsell">'.$object->getLibStatut(6, 0).
'</span>';
2936 $morehtmlstatus .=
' ';
2938 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
2939 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
2941 $morehtmlstatus .=
'<span class="statusrefbuy">'.$object->getLibStatut(6, 1).
'</span>';
2943 } elseif (in_array(
$object->element, array(
'salary'))) {
2945 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
2948 $morehtmlstatus .= $tmptxt;
2949 } elseif (in_array(
$object->element, array(
'facture',
'invoice',
'invoice_supplier',
'chargesociales',
'loan',
'tva'))) {
2951 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
2954 $morehtmlstatus .= $tmptxt;
2955 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
2957 $morehtmlstatus .=
$object->getLibStatut(5);
2959 $morehtmlstatus .=
$object->getLibStatut(4);
2961 } elseif (
$object->element ==
'facturerec') {
2962 '@phan-var-force FactureRec $object';
2963 if (
$object->frequency == 0) {
2964 $morehtmlstatus .=
$object->getLibStatut(2);
2966 $morehtmlstatus .=
$object->getLibStatut(5);
2968 } elseif (
$object->element ==
'project_task') {
2973 if (
$object->progress >= 100) {
2976 $tmptxt =
$object->getLibStatut(5);
2977 $morehtmlstatus .= $tmptxt;
2978 } elseif (method_exists(
$object,
'getLibStatut')) {
2979 $tmptxt =
$object->getLibStatut(6);
2980 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
2981 $tmptxt =
$object->getLibStatut(5);
2983 $morehtmlstatus .= $tmptxt;
2987 if (isModEnabled(
'accounting') && in_array(
$object->element, array(
'bank',
'paiementcharge',
'facture',
'invoice',
'invoice_supplier',
'expensereport',
'payment_various'))) {
2989 if (method_exists(
$object,
'getVentilExportCompta')) {
2990 $accounted =
$object->getVentilExportCompta();
2991 $langs->load(
"accountancy");
2992 $morehtmlstatus .=
'</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? $langs->trans(
"Accounted") : $langs->trans(
"NotYetAccounted")).
'</span>';
2997 if (!empty(
$object->name_alias)) {
2998 '@phan-var-force Societe $object';
2999 $morehtmlref .=
'<div class="refidno opacitymedium">'.dol_escape_htmltag(
$object->name_alias).
'</div>';
3003 if (in_array(
$object->element, array(
'product',
'bank_account',
'project_task'))) {
3005 $morehtmlref .=
'<div class="refidno opacitymedium">'.$object->label.
'</div>';
3009 if (method_exists(
$object,
'getBannerAddress') && !in_array(
$object->element, array(
'product',
'bookmark',
'ecm_directories',
'ecm_files'))) {
3012 $morehtmlref .=
'<div class="refidno refaddress">';
3013 $morehtmlref .= $moreaddress;
3014 $morehtmlref .=
'</div>';
3018 $morehtmlref .=
'<div style="clear: both;"></div>';
3019 $morehtmlref .=
'<div class="refidno opacitymedium">';
3020 $morehtmlref .= $langs->trans(
"TechnicalID").
': '.((int)
$object->id);
3021 $morehtmlref .=
'</div>';
3024 $parameters = array(
'morehtmlref' => &$morehtmlref,
'moreparam' => &$moreparam,
'morehtmlleft' => &$morehtmlleft,
'morehtmlstatus' => &$morehtmlstatus,
'morehtmlright' => &$morehtmlright);
3025 $reshook = $hookmanager->executeHooks(
'formDolBanner', $parameters,
$object, $action);
3028 } elseif (empty($reshook)) {
3029 $morehtmlref .= $hookmanager->resPrint;
3030 } elseif ($reshook > 0) {
3031 $morehtmlref = $hookmanager->resPrint;
3039 print
'<div class="'.($onlybanner ?
'arearefnobottom ' :
'arearef ').
'heightref valignmiddle centpercent">';
3040 print $form->showrefnav(
$object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
3042 print
'<div class="underrefbanner clearboth"></div>';
3054function fieldLabel($langkey, $fieldkey, $fieldrequired = 0)
3058 if ($fieldrequired) {
3059 $ret .=
'<span class="fieldrequired">';
3061 $ret .=
'<label for="'.$fieldkey.
'">';
3062 $ret .= $langs->trans($langkey);
3064 if ($fieldrequired) {
3077function dol_bc($var, $moreclass =
'')
3080 $ret =
' '.$bc[$var];
3082 $ret = preg_replace(
'/class=\"/',
'class="'.$moreclass.
' ', $ret);
3102 global $langs, $hookmanager;
3105 $countriesusingstate = array(
'AU',
'CA',
'US',
'IN',
'GB',
'ES',
'UK',
'TR',
'CN');
3110 $ret .= ($extralangcode ?
$object->array_languages[
'address'][$extralangcode] : (empty(
$object->address) ?
'' : preg_replace(
'/(\r\n|\r|\n)+/', $sep,
$object->address)));
3113 if (isset(
$object->country_code) && in_array(
$object->country_code, array(
'AU',
'CA',
'US',
'CN')) ||
getDolGlobalString(
'MAIN_FORCE_STATE_INTO_ADDRESS')) {
3115 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3116 $ret .= (($ret && $town) ? $sep :
'').$town;
3119 $ret .= ($ret ? ($town ?
", " : $sep) :
'').
$object->state;
3122 $ret .= ($ret ? (($town ||
$object->state) ?
", " : $sep) :
'').
$object->zip;
3124 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'GB',
'UK'))) {
3126 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3127 $ret .= ($ret ? $sep :
'').$town;
3129 $ret .= ($ret ?
", " :
'').
$object->state;
3132 $ret .= ($ret ? $sep :
'').
$object->zip;
3134 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'ES',
'TR'))) {
3136 $ret .= ($ret ? $sep :
'').
$object->zip;
3137 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3138 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3140 $ret .= $sep.$object->state;
3142 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'JP'))) {
3145 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3147 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'IT'))) {
3149 $ret .= ($ret ? $sep :
'').
$object->zip;
3150 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3151 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3152 $ret .= (empty(
$object->state_code) ?
'' : (
' '.$object->state_code));
3155 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3156 $ret .= !empty(
$object->zip) ? (($ret ? $sep :
'').
$object->zip) :
'';
3157 $ret .= ($town ? ((
$object->zip ?
' ' : ($ret ? $sep :
'')).$town) :
'');
3158 if (!empty(
$object->state) && in_array(
$object->country_code, $countriesusingstate)) {
3159 $ret .= ($ret ?
", " :
'').
$object->state;
3163 if (!is_object($outputlangs)) {
3164 $outputlangs = $langs;
3167 $langs->load(
"dict");
3168 $ret .= (empty(
$object->country_code) ?
'' : ($ret ? $sep :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$object->country_code)));
3171 $parameters = array(
'withcountry' => $withcountry,
'sep' => $sep,
'outputlangs' => $outputlangs,
'mode' => $mode,
'extralangcode' => $extralangcode);
3172 $reshook = $hookmanager->executeHooks(
'formatAddress', $parameters,
$object);
3176 $ret .= $hookmanager->resPrint;
3193function dol_strftime($fmt, $ts =
false, $is_gmt =
false)
3195 if ((abs($ts) <= 0x7FFFFFFF)) {
3198 return 'Error date outside supported range';
3223function dol_print_date($time, $format =
'', $tzoutput =
'auto', $outputlangs =
null, $encodetooutput =
false)
3225 global $conf, $langs;
3232 if ($tzoutput ===
'auto') {
3233 $tzoutput = (empty($conf) ?
'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey :
'tzserver'));
3238 $offsettz = $offsetdst = 0;
3241 if (is_string($tzoutput)) {
3242 if ($tzoutput ==
'tzserver') {
3244 $offsettzstring = @date_default_timezone_get();
3249 } elseif ($tzoutput ==
'tzuser' || $tzoutput ==
'tzuserrel') {
3251 $offsettzstring = (empty($_SESSION[
'dol_tz_string']) ?
'UTC' : $_SESSION[
'dol_tz_string']);
3253 if (class_exists(
'DateTimeZone')) {
3254 $user_date_tz =
new DateTimeZone($offsettzstring);
3255 $user_dt =
new DateTime();
3256 $user_dt->setTimezone($user_date_tz);
3257 $user_dt->setTimestamp($tzoutput ==
'tzuser' ?
dol_now() : (int) $time);
3258 $offsettz = $user_dt->getOffset();
3260 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3261 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3266 if (!is_object($outputlangs)) {
3267 $outputlangs = $langs;
3270 $format =
'daytextshort';
3275 $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array(
'day',
'dayhour',
'dayhoursec'))) ? 1 : 0;
3276 $format = preg_replace(
'/inputnoreduce/',
'', $format);
3277 $formatwithoutreduce = preg_replace(
'/reduceformat/',
'', $format);
3278 if ($formatwithoutreduce != $format) {
3279 $format = $formatwithoutreduce;
3285 if ($format ==
'day') {
3286 $format = ($outputlangs->trans(
"FormatDateShort") !=
"FormatDateShort" ? $outputlangs->trans(
"FormatDateShort") : $conf->format_date_short);
3287 } elseif ($format ==
'hour') {
3288 $format = ($outputlangs->trans(
"FormatHourShort") !=
"FormatHourShort" ? $outputlangs->trans(
"FormatHourShort") : $conf->format_hour_short);
3289 } elseif ($format ==
'hourduration') {
3290 $format = ($outputlangs->trans(
"FormatHourShortDuration") !=
"FormatHourShortDuration" ? $outputlangs->trans(
"FormatHourShortDuration") : $conf->format_hour_short_duration);
3291 } elseif ($format ==
'daytext') {
3292 $format = ($outputlangs->trans(
"FormatDateText") !=
"FormatDateText" ? $outputlangs->trans(
"FormatDateText") : $conf->format_date_text);
3293 } elseif ($format ==
'daytextshort') {
3294 $format = ($outputlangs->trans(
"FormatDateTextShort") !=
"FormatDateTextShort" ? $outputlangs->trans(
"FormatDateTextShort") : $conf->format_date_text_short);
3295 } elseif ($format ==
'dayhour') {
3296 $format = ($outputlangs->trans(
"FormatDateHourShort") !=
"FormatDateHourShort" ? $outputlangs->trans(
"FormatDateHourShort") : $conf->format_date_hour_short);
3297 } elseif ($format ==
'dayhoursec') {
3298 $format = ($outputlangs->trans(
"FormatDateHourSecShort") !=
"FormatDateHourSecShort" ? $outputlangs->trans(
"FormatDateHourSecShort") : $conf->format_date_hour_sec_short);
3299 } elseif ($format ==
'dayhourtext') {
3300 $format = ($outputlangs->trans(
"FormatDateHourText") !=
"FormatDateHourText" ? $outputlangs->trans(
"FormatDateHourText") : $conf->format_date_hour_text);
3301 } elseif ($format ==
'dayhourtextshort') {
3302 $format = ($outputlangs->trans(
"FormatDateHourTextShort") !=
"FormatDateHourTextShort" ? $outputlangs->trans(
"FormatDateHourTextShort") : $conf->format_date_hour_text_short);
3303 } elseif ($format ==
'dayhourlog') {
3305 $format =
'%Y%m%d%H%M%S';
3306 } elseif ($format ==
'dayhourlogsmall') {
3308 $format =
'%y%m%d%H%M';
3309 } elseif ($format ==
'dayhourldap') {
3310 $format =
'%Y%m%d%H%M%SZ';
3311 } elseif ($format ==
'dayhourxcard') {
3312 $format =
'%Y%m%dT%H%M%SZ';
3313 } elseif ($format ==
'dayxcard') {
3315 } elseif ($format ==
'dayrfc') {
3316 $format =
'%Y-%m-%d';
3317 } elseif ($format ==
'dayhourrfc') {
3318 $format =
'%Y-%m-%dT%H:%M:%SZ';
3319 } elseif ($format ==
'standard') {
3320 $format =
'%Y-%m-%d %H:%M:%S';
3323 if ($reduceformat) {
3324 $format = str_replace(
'%Y',
'%y', $format);
3325 $format = str_replace(
'yyyy',
'yy', $format);
3329 if (preg_match(
'/%b/i', $format)) {
3331 $format = str_replace(
'%b',
'__b__', $format);
3332 $format = str_replace(
'%B',
'__B__', $format);
3334 if (preg_match(
'/%a/i', $format)) {
3336 $format = str_replace(
'%a',
'__a__', $format);
3337 $format = str_replace(
'%A',
'__A__', $format);
3342 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)) {
3343 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"]));
3345 } elseif (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', (
string) $time, $reg)) {
3347 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);
3350 $syear = (!empty($reg[1]) ? $reg[1] :
'');
3351 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
3352 $sday = (!empty($reg[3]) ? $reg[3] :
'');
3353 $shour = (!empty($reg[4]) ? $reg[4] :
'');
3354 $smin = (!empty($reg[5]) ? $reg[5] :
'');
3355 $ssec = (!empty($reg[6]) ? $reg[6] :
'');
3357 $time =
dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear,
true);
3360 $tzo =
new DateTimeZone(
'UTC');
3362 $tzo =
new DateTimeZone(date_default_timezone_get());
3364 $dtts =
new DateTime();
3365 $dtts->setTimestamp($time);
3366 $dtts->setTimezone($tzo);
3367 $newformat = str_replace(
3368 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3369 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3372 $ret = $dtts->format($newformat);
3374 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3375 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3380 if ($time < 100000000000) {
3381 $timetouse = $time + $offsettz + $offsetdst;
3384 $tzo =
new DateTimeZone(
'UTC');
3386 $tzo =
new DateTimeZone(date_default_timezone_get());
3388 $dtts =
new DateTime();
3389 $dtts->setTimestamp($timetouse);
3390 $dtts->setTimezone($tzo);
3391 $newformat = str_replace(
3392 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'%w',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3393 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'w',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3396 $ret = $dtts->format($newformat);
3398 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3399 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3404 $ret =
'Bad value '.$time.
' for date';
3408 if (preg_match(
'/__b__/i', $format)) {
3409 $timetouse = $time + $offsettz + $offsetdst;
3412 $tzo =
new DateTimeZone(
'UTC');
3414 $tzo =
new DateTimeZone(date_default_timezone_get());
3416 $dtts =
new DateTime();
3417 $dtts->setTimestamp($timetouse);
3418 $dtts->setTimezone($tzo);
3419 $month = (int) $dtts->format(
"m");
3420 $month = sprintf(
"%02d", $month);
3421 if ($encodetooutput) {
3422 $monthtext = $outputlangs->transnoentities(
'Month'.$month);
3423 $monthtextshort = $outputlangs->transnoentities(
'MonthShort'.$month);
3425 $monthtext = $outputlangs->transnoentitiesnoconv(
'Month'.$month);
3426 $monthtextshort = $outputlangs->transnoentitiesnoconv(
'MonthShort'.$month);
3429 $ret = str_replace(
'__b__', $monthtextshort, $ret);
3430 $ret = str_replace(
'__B__', $monthtext, $ret);
3434 if (preg_match(
'/__a__/i', $format)) {
3436 $timetouse = $time + $offsettz + $offsetdst;
3439 $tzo =
new DateTimeZone(
'UTC');
3441 $tzo =
new DateTimeZone(date_default_timezone_get());
3443 $dtts =
new DateTime();
3444 $dtts->setTimestamp($timetouse);
3445 $dtts->setTimezone($tzo);
3446 $w = $dtts->format(
"w");
3447 $dayweek = $outputlangs->transnoentitiesnoconv(
'Day'.$w);
3449 $ret = str_replace(
'__A__', $dayweek, $ret);
3450 $ret = str_replace(
'__a__',
dol_substr($dayweek, 0, 3), $ret);
3477function dol_getdate($timestamp, $fast =
false, $forcetimezone =
'')
3479 if ($timestamp ===
'') {
3483 $datetimeobj =
new DateTime();
3484 $datetimeobj->setTimestamp($timestamp);
3485 if ($forcetimezone) {
3486 $datetimeobj->setTimezone(
new DateTimeZone($forcetimezone ==
'gmt' ?
'UTC' : $forcetimezone));
3489 'year' => ((
int) date_format($datetimeobj,
'Y')),
3490 'mon' => ((
int) date_format($datetimeobj,
'm')),
3491 'mday' => ((
int) date_format($datetimeobj,
'd')),
3492 'wday' => ((
int) date_format($datetimeobj,
'w')),
3493 'yday' => ((
int) date_format($datetimeobj,
'z')),
3494 'hours' => ((
int) date_format($datetimeobj,
'H')),
3495 'minutes' => ((
int) date_format($datetimeobj,
'i')),
3496 'seconds' => ((
int) date_format($datetimeobj,
's')),
3524function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm =
'auto', $check = 1)
3529 if ($gm ===
'auto') {
3530 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
3535 if ($hour == -1 || empty($hour)) {
3538 if ($minute == -1 || empty($minute)) {
3541 if ($second == -1 || empty($second)) {
3547 if (!$month || !$day) {
3556 if ($hour < 0 || $hour > 24) {
3559 if ($minute < 0 || $minute > 60) {
3562 if ($second < 0 || $second > 60) {
3567 if (empty($gm) || ($gm ===
'server' || $gm ===
'tzserver')) {
3568 $default_timezone = @date_default_timezone_get();
3569 $localtz =
new DateTimeZone($default_timezone);
3570 } elseif ($gm ===
'user' || $gm ===
'tzuser' || $gm ===
'tzuserrel') {
3572 $default_timezone = (empty($_SESSION[
"dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION[
"dol_tz_string"]);
3574 $localtz =
new DateTimeZone($default_timezone);
3576 dol_syslog(
"Warning dol_tz_string contains an invalid value ".json_encode($_SESSION[
"dol_tz_string"] ??
null), LOG_WARNING);
3577 $default_timezone = @date_default_timezone_get();
3579 } elseif (strrpos($gm,
"tz,") !==
false) {
3580 $timezone = str_replace(
"tz,",
"", $gm);
3582 $localtz =
new DateTimeZone($timezone);
3584 dol_syslog(
"Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
3588 if (empty($localtz)) {
3589 $localtz =
new DateTimeZone(
'UTC');
3593 $dt =
new DateTime(
'now', $localtz);
3594 $dt->setDate((
int) $year, (
int) $month, (
int) $day);
3595 $dt->setTime((
int) $hour, (
int) $minute, (
int) $second);
3596 $date = $dt->getTimestamp();
3612function dol_now($mode =
'auto')
3616 if ($mode ===
'auto') {
3620 if ($mode ==
'gmt') {
3622 } elseif ($mode ==
'tzserver') {
3623 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
3625 $ret = (int) (
dol_now(
'gmt') + ($tzsecond * 3600));
3631 } elseif ($mode ==
'tzuser' || $mode ==
'tzuserrel') {
3634 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3635 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3636 $ret = (int) (
dol_now(
'gmt') + ($offsettz + $offsetdst));
3653 global $conf, $langs;
3656 if (!empty($conf->dol_optimize_smallscreen)) {
3661 if (empty($shortvalue) || $size < ($level * 10)) {
3663 $textunitshort = $langs->trans(
"b");
3664 $textunitlong = $langs->trans(
"Bytes");
3666 $ret = round($size / $level, 0);
3667 $textunitshort = $langs->trans(
"Kb");
3668 $textunitlong = $langs->trans(
"KiloBytes");
3671 if (empty($shortunit)) {
3672 $ret .=
' '.$textunitlong;
3674 $ret .=
' '.$textunitshort;
3690function dol_print_url($url, $target =
'_blank', $max = 32, $withpicto = 0, $morecss =
'')
3698 $linkstart =
'<a href="';
3699 if (!preg_match(
'/^http/i', $url)) {
3700 $linkstart .=
'http://';
3705 $linkstart .=
' target="'.$target.
'"';
3707 $linkstart .=
' title="'.$langs->trans(
"URL").
': '.$url.
'"';
3711 if (!preg_match(
'/^http/i', $url)) {
3718 if ($morecss ==
'float') {
3719 return '<div class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe',
'class="paddingrightonly"') :
'').$link.
'</div>';
3721 return $linkstart.
'<span class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto(
'',
'globe',
'class="paddingrightonly"') :
'').$link.
'</span>'.$linkend;
3737function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0)
3739 global $user, $langs, $hookmanager;
3750 if (empty($email)) {
3754 if (!empty($addlink)) {
3755 $newemail =
'<a class="paddingrightonly" style="text-overflow: ellipsis;" href="';
3756 if (!preg_match(
'/^mailto:/i', $email)) {
3757 $newemail .=
'mailto:';
3759 $newemail .= $email;
3762 $newemail .= ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'');
3765 $newemail .=
'</a>';
3767 $langs->load(
"errors");
3768 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email),
'',
'paddingrightonly');
3771 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
3773 $linktoaddaction =
'';
3775 $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>';
3777 if ($linktoaddaction) {
3778 $newemail =
'<div>'.$newemail.
' '.$linktoaddaction.
'</div>';
3782 $newemail = ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'').$newemail;
3785 $langs->load(
"errors");
3786 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
3796 $parameters = array(
'cid' => $cid,
'socid' => $socid,
'addlink' => $addlink,
'picto' => $withpicto);
3798 $reshook = $hookmanager->executeHooks(
'printEmail', $parameters, $email);
3802 $rep .= $hookmanager->resPrint;
3817 $socialnetworks = array();
3819 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
3820 $cachekey =
'socialnetworks_' . $conf->entity;
3822 if (!is_null($dataretrieved)) {
3823 $socialnetworks = $dataretrieved;
3825 $sql =
"SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX.
"c_socialnetworks";
3826 $sql .=
" WHERE entity=".$conf->entity;
3827 $resql = $db->query($sql);
3829 while ($obj = $db->fetch_object($resql)) {
3830 $socialnetworks[$obj->code] = array(
3831 'rowid' => $obj->rowid,
3832 'label' => $obj->label,
3834 'icon' => $obj->icon,
3835 'active' => $obj->active,
3841 return $socialnetworks;
3856 global $user, $langs;
3860 if (empty($value)) {
3864 if (!empty($type)) {
3865 $htmllink =
'<div class="divsocialnetwork inline-block valignmiddle">';
3867 $htmllink .=
'<span class="fab pictofixedwidth '.($dictsocialnetworks[$type][
'icon'] ? $dictsocialnetworks[$type][
'icon'] :
'fa-link').
'"></span>';
3868 if ($type ==
'skype') {
3870 $htmllink .=
' <a href="skype:';
3872 $htmllink .=
'?call" alt="'.$langs->trans(
"Call").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Call").
' '.$value).
'">';
3873 $htmllink .=
'<img src="'.DOL_URL_ROOT.
'/theme/common/skype_callbutton.png" border="0">';
3874 $htmllink .=
'</a><a href="skype:';
3876 $htmllink .=
'?chat" alt="'.$langs->trans(
"Chat").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Chat").
' '.$value).
'">';
3877 $htmllink .=
'<img class="paddingleft" src="'.DOL_URL_ROOT.
'/theme/common/skype_chatbutton.png" border="0">';
3878 $htmllink .=
'</a>';
3879 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
3880 $addlink =
'AC_SKYPE';
3883 $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>';
3885 $htmllink .= ($link ?
' '.$link :
'');
3888 $networkconstname =
'MAIN_INFO_SOCIETE_'.strtoupper($type).
'_URL';
3891 if (preg_match(
'/^https?:\/\//i', $link)) {
3892 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3894 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3896 } elseif (!empty($dictsocialnetworks[$type][
'url'])) {
3897 $tmpvirginurl = preg_replace(
'/\/?{socialid}/',
'', $dictsocialnetworks[$type][
'url']);
3898 if ($tmpvirginurl) {
3899 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3900 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3902 $tmpvirginurl3 = preg_replace(
'/^https:\/\//i',
'https://www.', $tmpvirginurl);
3903 if ($tmpvirginurl3) {
3904 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3905 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3908 $tmpvirginurl2 = preg_replace(
'/^https?:\/\//i',
'', $tmpvirginurl);
3909 if ($tmpvirginurl2) {
3910 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3911 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3914 $link = str_replace(
'{socialid}', $value, $dictsocialnetworks[$type][
'url']);
3915 if (preg_match(
'/^https?:\/\//i', $link)) {
3916 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3918 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3924 $htmllink .=
'</div>';
3926 $langs->load(
"errors");
3927 $htmllink .=
img_warning($langs->trans(
"ErrorBadSocialNetworkValue", $value));
3941function dol_print_profids($profID, $profIDtype, $countrycode =
'', $addcpButton = 1)
3945 if (empty($profID) || empty($profIDtype)) {
3948 if (empty($countrycode)) {
3949 $countrycode = $mysoc->country_code;
3951 $newProfID = $profID;
3952 $id = substr($profIDtype, -1);
3954 if (strtoupper($countrycode) ==
'FR') {
3958 if ($id == 1 &&
dol_strlen($newProfID) == 9) {
3960 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3);
3962 if ($id == 2 &&
dol_strlen($newProfID) == 14) {
3964 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3).
' '.substr($newProfID, 9, 5);
3966 if ($id == 3 &&
dol_strlen($newProfID) == 5) {
3968 $newProfID = substr($newProfID, 0, 2).
'.'.substr($newProfID, 2, 3);
3970 if ($profIDtype ===
'VAT' &&
dol_strlen($newProfID) == 13) {
3972 $newProfID = substr($newProfID, 0, 4).
' '.substr($newProfID, 4, 3).
' '.substr($newProfID, 7, 3).
' '.substr($newProfID, 10, 3);
3975 if (!empty($addcpButton)) {
3998function dol_print_phone($phone, $countrycode =
'', $cid = 0, $socid = 0, $addlink =
'', $separ =
" ", $withpicto =
'', $titlealt =
'', $adddivfloat = 0, $morecss =
'')
4000 global $conf, $user, $langs, $mysoc, $hookmanager;
4003 $phone = is_null($phone) ?
'' : preg_replace(
"/[\s.-]/",
"", trim($phone));
4004 if (empty($phone)) {
4010 if (empty($countrycode) && is_object($mysoc)) {
4011 $countrycode = $mysoc->country_code;
4015 if (!empty($conf->dol_optimize_smallscreen) && $separ !=
'hidenum') {
4020 $newphonewa = $phone;
4021 if (strtoupper($countrycode) ==
"FR") {
4024 $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);
4026 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
4028 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
4030 $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);
4032 $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);
4034 $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);
4036 } elseif (strtoupper($countrycode) ==
"CA") {
4038 $newphone = ($separ !=
'' ?
'(' :
'').substr($newphone, 0, 3).($separ !=
'' ?
')' :
'').$separ.substr($newphone, 3, 3).($separ !=
'' ?
'-' :
'').substr($newphone, 6, 4);
4040 } elseif (strtoupper($countrycode) ==
"PT") {
4042 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4044 } elseif (strtoupper($countrycode) ==
"SR") {
4046 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
4048 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
4050 } elseif (strtoupper($countrycode) ==
"DE") {
4052 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
4054 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
4056 } elseif (strtoupper($countrycode) ==
"ES") {
4058 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4060 } elseif (strtoupper($countrycode) ==
"BF") {
4062 $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);
4064 } elseif (strtoupper($countrycode) ==
"RO") {
4066 $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);
4068 } elseif (strtoupper($countrycode) ==
"TR") {
4070 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4072 } elseif (strtoupper($countrycode) ==
"US") {
4074 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4076 } elseif (strtoupper($countrycode) ==
"MX") {
4078 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4080 $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);
4082 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4084 } elseif (strtoupper($countrycode) ==
"ML") {
4086 $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);
4088 } elseif (strtoupper($countrycode) ==
"TH") {
4090 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4092 $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);
4094 } elseif (strtoupper($countrycode) ==
"MU") {
4097 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
4099 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4101 } elseif (strtoupper($countrycode) ==
"ZA") {
4103 $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);
4105 } elseif (strtoupper($countrycode) ==
"SY") {
4107 $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);
4109 $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);
4111 } elseif (strtoupper($countrycode) ==
"AE") {
4113 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4115 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4117 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
4119 } elseif (strtoupper($countrycode) ==
"DZ") {
4121 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4123 } elseif (strtoupper($countrycode) ==
"BE") {
4125 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4127 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4129 } elseif (strtoupper($countrycode) ==
"PF") {
4131 $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);
4133 } elseif (strtoupper($countrycode) ==
"CO") {
4135 $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);
4137 } elseif (strtoupper($countrycode) ==
"JO") {
4139 $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);
4141 } elseif (strtoupper($countrycode) ==
"JM") {
4143 $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4145 } elseif (strtoupper($countrycode) ==
"MG") {
4147 $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);
4149 } elseif (strtoupper($countrycode) ==
"GB") {
4151 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4153 } elseif (strtoupper($countrycode) ==
"CH") {
4155 $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);
4157 $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);
4159 } elseif (strtoupper($countrycode) ==
"TN") {
4161 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4163 } elseif (strtoupper($countrycode) ==
"GF") {
4165 $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);
4167 } elseif (strtoupper($countrycode) ==
"GP") {
4169 $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);
4171 } elseif (strtoupper($countrycode) ==
"MQ") {
4173 $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);
4175 } elseif (strtoupper($countrycode) ==
"IT") {
4177 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4179 $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);
4181 } elseif (strtoupper($countrycode) ==
"AU") {
4185 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
4187 } elseif (strtoupper($countrycode) ==
"LU") {
4190 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
4192 $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);
4194 $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);
4196 $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);
4198 } elseif (strtoupper($countrycode) ==
"PE") {
4201 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4);
4203 $newphonewa =
'+51'.$newphone;
4204 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 10, 3);
4206 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 8, 4);
4208 $newphonewa = $newphone;
4209 $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);
4213 $newphoneastart = $newphoneaend =
'';
4214 if (!empty($addlink)) {
4215 if ($addlink ==
'tel' || $conf->browser->layout ==
'phone' || (isModEnabled(
'clicktodial') &&
getDolGlobalString(
'CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS'))) {
4216 $newphoneastart =
'<a href="tel:'.urlencode($phone).
'">';
4217 $newphoneaend .=
'</a>';
4218 } elseif (isModEnabled(
'clicktodial') && $addlink ==
'AC_TEL') {
4219 if (empty($user->clicktodial_loaded)) {
4220 $user->fetch_clicktodial();
4224 $urlmask =
getDolGlobalString(
'CLICKTODIAL_URL',
'ErrorClickToDialModuleNotConfigured');
4225 if (!empty($user->clicktodial_url)) {
4226 $urlmask = $user->clicktodial_url;
4229 $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) :
'');
4230 $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) :
'');
4231 $clicktodial_password = (!empty($user->clicktodial_password) ? urlencode($user->clicktodial_password) :
'');
4233 $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
4235 $substitarray = array(
'__PHONEFROM__' => $clicktodial_poste,
4236 '__PHONETO__' => urlencode($phone),
4237 '__LOGIN__' => $clicktodial_login,
4238 '__PASS__' => $clicktodial_password);
4242 $newphoneastart =
'<a href="'.$url.
'" class="cssforclicktodial">';
4243 $newphoneaend =
'</a>';
4246 $newphoneastart =
'<a href="'.$url.
'"';
4248 $newphoneastart .=
' target="_blank" rel="noopener noreferrer"';
4250 $newphoneastart .=
'>';
4251 $newphoneaend .=
'</a>';
4256 if (isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
4258 $addlinktoagenda =
'';
4259 if ($addlink ==
'AC_FAX') {
4263 $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>';
4265 if ($addlinktoagenda) {
4266 $newphone =
'<span>'.$newphone.
' '.$addlinktoagenda.
'</span>';
4271 if (
getDolGlobalString(
'CONTACT_PHONEMOBILE_SHOW_LINK_TO_WHATSAPP') && $withpicto ==
'mobile') {
4273 $newphone .=
' <a href="https://wa.me/'.$newphonewa.
'" target="_blank"';
4274 $newphone .=
'><span class="paddingright fab fa-whatsapp" style="color:#25D366;" title="WhatsApp"></span></a>';
4277 if (empty($titlealt)) {
4278 $titlealt = ($withpicto ==
'fax' ? $langs->trans(
"Fax") : $langs->trans(
"Phone"));
4283 $parameters = array(
'countrycode' => $countrycode,
'cid' => $cid,
'socid' => $socid,
'titlealt' => $titlealt,
'picto' => $withpicto);
4284 $reshook = $hookmanager->executeHooks(
'printPhone', $parameters, $phone);
4285 $rep .= $hookmanager->resPrint;
4287 if (empty($reshook)) {
4290 if ($withpicto ==
'fax') {
4291 $picto =
'phoning_fax';
4292 } elseif ($withpicto ==
'phone') {
4294 } elseif ($withpicto ==
'mobile') {
4295 $picto =
'phoning_mobile';
4300 if ($adddivfloat == 1) {
4301 $rep .=
'<div class="nospan float'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">';
4302 } elseif (empty($adddivfloat)) {
4303 $rep .=
'<span'.($morecss ?
' class="'.$morecss.
'"' :
'').
' style="margin-right: 10px;">';
4306 $rep .= $newphoneastart;
4307 $rep .= ($withpicto ?
img_picto($titlealt,
'object_'.$picto.
'.png') :
'');
4308 if ($separ !=
'hidenum') {
4309 $rep .= ($withpicto ?
' ' :
'').$newphone;
4311 $rep .= $newphoneaend;
4313 if ($adddivfloat == 1) {
4315 } elseif (empty($adddivfloat)) {
4343 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/common/flags/'.$countrycode.
'.png')) {
4344 $ret .=
' '.img_picto($countrycode.
' '.$langs->trans(
"AccordingToGeoIPDatabase"), DOL_URL_ROOT.
'/theme/common/flags/'.$countrycode.
'.png',
'', 1);
4346 $ret .=
' ('.$countrycode.
')';
4366 if (empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
4367 if (empty($_SERVER[
'HTTP_CLIENT_IP']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_CLIENT_IP'])) {
4368 if (empty($_SERVER[
"HTTP_CF_CONNECTING_IP"])) {
4369 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
4371 $ip = $_SERVER[
"HTTP_CF_CONNECTING_IP"];
4374 $ip = $_SERVER[
'HTTP_CLIENT_IP'];
4377 $ip = $_SERVER[
'HTTP_X_FORWARDED_FOR'];
4393 if (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on') {
4395 } 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') {
4413 if (!empty($conf->geoipmaxmind->enabled)) {
4417 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4418 $geoip =
new DolGeoIP(
'country', $datafile);
4420 $countrycode = $geoip->getCountryCodeFromIP($ip);
4423 return $countrycode;
4435 global $conf, $langs, $user;
4439 if (!empty($conf->geoipmaxmind->enabled)) {
4444 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4445 $geoip =
new DolGeoIP(
'country', $datafile);
4446 $countrycode = $geoip->getCountryCodeFromIP($ip);
4447 $ret = $countrycode;
4464function dol_print_address($address, $htmlid, $element, $id, $noprint = 0, $charfornl =
'')
4466 global $conf, $user, $langs, $hookmanager;
4472 $parameters = array(
'element' => $element,
'id' => $id);
4473 $reshook = $hookmanager->executeHooks(
'printAddress', $parameters, $address);
4474 $out .= $hookmanager->resPrint;
4476 if (empty($reshook)) {
4477 if (empty($charfornl)) {
4478 $out .= nl2br($address);
4480 $out .= preg_replace(
'/[\r\n]+/', $charfornl, $address);
4484 $showgmap = $showomap = 0;
4485 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS')) {
4488 if ($element ==
'contact' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_CONTACTS')) {
4491 if ($element ==
'member' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_MEMBERS')) {
4494 if ($element ==
'user' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_USERS')) {
4497 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS')) {
4500 if ($element ==
'contact' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_CONTACTS')) {
4503 if ($element ==
'member' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_MEMBERS')) {
4506 if ($element ==
'user' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_USERS')) {
4510 $url =
dol_buildpath(
'/google/gmaps.php?mode='.$element.
'&id='.$id, 1);
4511 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4514 $url =
dol_buildpath(
'/openstreetmap/maps.php?mode='.$element.
'&id='.$id, 1);
4515 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4536function isValidEmail($address, $acceptsupervisorkey = 0, $acceptuserkey = 0)
4538 if ($acceptsupervisorkey && $address ==
'__SUPERVISOREMAIL__') {
4541 if ($acceptuserkey && $address ==
'__USER_EMAIL__') {
4544 if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
4562 if (function_exists(
'idn_to_ascii') && function_exists(
'checkdnsrr')) {
4563 if (!checkdnsrr(idn_to_ascii($domain),
'MX')) {
4566 if (function_exists(
'getmxrr')) {
4569 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
4570 if (count($mxhosts) > 1) {
4573 if (count($mxhosts) == 1 && !in_array((
string) $mxhosts[0], array(
'',
'.'))) {
4610 $tmparray = explode(
' ', $s);
4611 foreach ($tmparray as $tmps) {
4626function dol_strlen($string, $stringencoding =
'UTF-8')
4628 if (is_null($string)) {
4632 if (function_exists(
'mb_strlen')) {
4633 return mb_strlen($string, $stringencoding);
4635 return strlen($string);
4649function dol_substr($string, $start, $length =
null, $stringencoding =
'', $trunconbytes = 0)
4653 if (empty($stringencoding)) {
4654 $stringencoding = (empty($langs) ?
'UTF-8' : $langs->charset_output);
4658 if (empty($trunconbytes)) {
4659 if (function_exists(
'mb_substr')) {
4660 $ret = mb_substr($string, $start, $length, $stringencoding);
4662 $ret = substr($string, $start, $length);
4665 if (function_exists(
'mb_strcut')) {
4666 $ret = mb_strcut($string, $start, $length, $stringencoding);
4668 $ret = substr($string, $start, $length);
4688function dol_trunc($string, $size = 40, $trunc =
'right', $stringencoding =
'UTF-8', $nodot = 0, $display = 0)
4696 if (empty($stringencoding)) {
4697 $stringencoding =
'UTF-8';
4700 if (!empty($conf->dol_optimize_smallscreen) && $conf->dol_optimize_smallscreen == 1 && $display == 1) {
4701 $size = round($size / 3);
4705 if ($trunc ==
'right') {
4707 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
4709 return dol_substr($newstring, 0, $size, $stringencoding).($nodot ?
'' :
'…');
4714 } elseif ($trunc ==
'middle') {
4716 if (
dol_strlen($newstring, $stringencoding) > 2 &&
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4717 $size1 = round($size / 2);
4718 $size2 = round($size / 2);
4719 return dol_substr($newstring, 0, $size1, $stringencoding).
'…'.
dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
4723 } elseif ($trunc ==
'left') {
4725 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
4727 return '…'.dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
4731 } elseif ($trunc ==
'wrap') {
4733 if (
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4739 return 'BadParam3CallingDolTrunc';
4753 $type2picto = array(
4754 'varchar' =>
'font',
4757 'int' =>
'sort-numeric-down',
4758 'double' =>
'sort-numeric-down',
4759 'price' =>
'currency',
4760 'pricecy' =>
'multicurrency',
4761 'password' =>
'key',
4762 'boolean' =>
'check-square',
4763 'date' =>
'calendar',
4764 'datetime' =>
'calendar',
4770 'sellist' =>
'list',
4771 'radio' =>
'check-circle',
4772 'checkbox' =>
'list',
4773 'chkbxlst' =>
'list',
4775 'icon' =>
"question",
4776 'point' =>
"country",
4777 'multipts' =>
'country',
4778 'linestrg' =>
"country",
4779 'polygon' =>
"country",
4780 'separate' =>
'minus'
4783 if (!empty($type2picto[$key])) {
4784 return img_picto(
'', $type2picto[$key],
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
4787 return img_picto(
'',
'generic',
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
4812function img_picto($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0, $alt =
'', $morecss =
'', $marginleftonlyshort = 2)
4817 $url = DOL_URL_ROOT;
4818 $theme = isset($conf->theme) ? $conf->theme :
null;
4819 $path =
'theme/'.$theme;
4820 if (empty($picto)) {
4825 if ($pictoisfullpath) {
4827 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
4830 $fullpathpicto = $picto;
4832 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4833 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4834 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4837 $pictowithouttext = preg_replace(
'/(\.png|\.gif|\.svg)$/',
'', (is_null($picto) ?
'' : $picto));
4838 $pictowithouttext = str_replace(
'object_',
'', $pictowithouttext);
4839 $pictowithouttext = str_replace(
'_nocolor',
'', $pictowithouttext);
4841 if (strpos($pictowithouttext,
'fontawesome_') === 0 || strpos($pictowithouttext,
'fa-') === 0) {
4843 $pictowithouttext = str_replace(
'fontawesome_',
'', $pictowithouttext);
4844 $pictowithouttext = str_replace(
'fa-',
'', $pictowithouttext);
4847 if ($pictowithouttext ==
'file-o') {
4848 $pictowithouttext =
'file';
4851 $pictowithouttextarray = explode(
'_', $pictowithouttext);
4852 $marginleftonlyshort = 0;
4854 if (!empty($pictowithouttextarray[1])) {
4856 $fakey =
'fa-'.$pictowithouttextarray[0];
4857 $faprefix = empty($pictowithouttextarray[1]) ?
'fas' : $pictowithouttextarray[1];
4858 $facolor = empty($pictowithouttextarray[2]) ?
'' : $pictowithouttextarray[2];
4859 $fasize = empty($pictowithouttextarray[3]) ?
'' : $pictowithouttextarray[3];
4861 $fakey =
'fa-'.$pictowithouttext;
4871 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4872 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4873 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4875 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
4876 $morestyle = $reg[1];
4877 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
4879 $moreatt = trim($moreatt);
4881 $enabledisablehtml =
'<span class="'.$faprefix.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
4882 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
4886 $enabledisablehtml .=
'</span>';
4888 return $enabledisablehtml;
4891 if (empty($srconly) && in_array($pictowithouttext, array(
4892 '1downarrow',
'1uparrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected',
4893 'accountancy',
'accounting_account',
'account',
'accountline',
'action',
'add',
'address',
'ai',
'angle-double-down',
'angle-double-up',
'asset',
4894 'bank_account',
'barcode',
'bank',
'bell',
'bill',
'billa',
'billr',
'billd',
'birthday-cake',
'bom',
'bookcal',
'bookmark',
'briefcase-medical',
'bug',
'building',
4895 'card',
'calendarlist',
'calendar',
'calendarmonth',
'calendarweek',
'calendarday',
'calendarperuser',
'calendarpertype',
4896 'cash-register',
'category',
'chart',
'check',
'clock',
'clone',
'close_title',
'code',
'cog',
'collab',
'company',
'contact',
'country',
'contract',
'conversation',
'cron',
'cross',
'cubes',
4897 'check-circle',
'check-square',
'circle',
'stop-circle',
'currency',
'multicurrency',
4898 'chevron-left',
'chevron-right',
'chevron-down',
'chevron-top',
4899 'chevron-double-left',
'chevron-double-right',
'chevron-double-down',
'chevron-double-top',
4900 'commercial',
'companies',
4901 'delete',
'dolly',
'dollyrevert',
'donation',
'download',
'dynamicprice',
4902 'edit',
'ellipsis-h',
'email',
'entity',
'envelope',
'eraser',
'establishment',
'expensereport',
'external-link-alt',
'external-link-square-alt',
'eye',
4903 'filter',
'file',
'file-o',
'file-code',
'file-export',
'file-import',
'file-upload',
'autofill',
'folder',
'folder-open',
'folder-plus',
'font',
4904 'gears',
'generate',
'generic',
'globe',
'globe-americas',
'graph',
'grip',
'grip_title',
'group',
4905 'hands-helping',
'help',
'holiday',
4906 'id-card',
'images',
'incoterm',
'info',
'intervention',
'inventory',
'intracommreport',
'jobprofile',
4907 'key',
'knowledgemanagement',
4908 'label',
'language',
'layout',
'line',
'link',
'list',
'list-alt',
'listlight',
'loan',
'lock',
'lot',
'long-arrow-alt-right',
4909 'margin',
'map-marker-alt',
'member',
'meeting',
'minus',
'money-bill-alt',
'movement',
'mrp',
'note',
'next',
4910 'off',
'on',
'order',
4911 'paiment',
'paragraph',
'play',
'pdf',
'phone',
'phoning',
'phoning_mobile',
'phoning_fax',
'playdisabled',
'previous',
'poll',
'pos',
'printer',
'product',
'propal',
'proposal',
'puce',
4912 'stock',
'resize',
'service',
'stats',
4913 'security',
'setup',
'share-alt',
'sign-out',
'split',
'stripe',
'stripe-s',
'switch_off',
'switch_on',
'switch_on_warning',
'switch_on_red',
'tools',
'unlink',
'uparrow',
'user',
'user-tie',
'vcard',
'wrench',
4914 'github',
'google',
'jabber',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'youtube',
'google-plus-g',
'whatsapp',
4915 'generic',
'home',
'hrm',
'members',
'products',
'invoicing',
4916 'partnership',
'payment',
'payment_vat',
'pencil-ruler',
'pictoconfirm',
'preview',
'project',
'projectpub',
'projecttask',
'question',
'refresh',
'region',
4917 'salary',
'shipment',
'state',
'supplier_invoice',
'supplier_invoicea',
'supplier_invoicer',
'supplier_invoiced',
4918 'technic',
'ticket',
4920 'recent',
'reception',
'recruitmentcandidature',
'recruitmentjobposition',
'replacement',
'resource',
'recurring',
'rss',
4921 'shapes',
'skill',
'square',
'sort-numeric-down',
'status',
'stop-circle',
'supplier',
'supplier_proposal',
'supplier_order',
'supplier_invoice',
4922 'terminal',
'tick',
'timespent',
'title_setup',
'title_accountancy',
'title_bank',
'title_hrm',
'title_agenda',
'trip',
4923 'uncheck',
'url',
'user-cog',
'user-injured',
'user-md',
'vat',
'website',
'workstation',
'webhook',
'world',
'private',
4924 'conferenceorbooth',
'eventorganization',
4925 'stamp',
'signature',
4928 $fakey = $pictowithouttext;
4932 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'))) {
4935 if (in_array($pictowithouttext, array(
'black-tie',
'github',
'google',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'stripe',
'stripe-s',
'youtube',
'google-plus-g',
'whatsapp'))) {
4939 $arrayconvpictotofa = array(
4940 'account' =>
'university',
'accounting_account' =>
'clipboard-list',
'accountline' =>
'receipt',
'accountancy' =>
'search-dollar',
'action' =>
'calendar-alt',
'add' =>
'plus-circle',
'address' =>
'address-book',
'ai' =>
'magic',
4941 'asset' =>
'money-check-alt',
'autofill' =>
'fill',
4942 'bank_account' =>
'university',
4943 'bill' =>
'file-invoice-dollar',
'billa' =>
'file-excel',
'billr' =>
'file-invoice-dollar',
'billd' =>
'file-medical',
4944 'bookcal' =>
'calendar-check',
4945 'supplier_invoice' =>
'file-invoice-dollar',
'supplier_invoicea' =>
'file-excel',
'supplier_invoicer' =>
'file-invoice-dollar',
'supplier_invoiced' =>
'file-medical',
4947 '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',
4948 'chevron-double-left' =>
'angle-double-left',
'chevron-double-right' =>
'angle-double-right',
'chevron-double-down' =>
'angle-double-down',
'chevron-double-top' =>
'angle-double-up',
4949 'donation' =>
'file-alt',
'dynamicprice' =>
'hand-holding-usd',
4950 'setup' =>
'cog',
'companies' =>
'building',
'products' =>
'cube',
'commercial' =>
'suitcase',
'invoicing' =>
'coins',
4951 'accounting' =>
'search-dollar',
'category' =>
'tag',
'dollyrevert' =>
'dolly',
4952 'file-o' =>
'file',
'generate' =>
'plus-square',
'hrm' =>
'user-tie',
'incoterm' =>
'truck-loading',
4953 'margin' =>
'calculator',
'members' =>
'user-friends',
'ticket' =>
'ticket-alt',
'globe' =>
'external-link-alt',
'lot' =>
'barcode',
4954 'email' =>
'at',
'establishment' =>
'building',
'edit' =>
'pencil-alt',
'entity' =>
'globe',
4955 'graph' =>
'chart-line',
'grip_title' =>
'arrows-alt',
'grip' =>
'arrows-alt',
'help' =>
'question-circle',
4956 'generic' =>
'file',
'holiday' =>
'umbrella-beach',
4957 'info' =>
'info-circle',
'inventory' =>
'boxes',
'intracommreport' =>
'globe-europe',
'jobprofile' =>
'cogs',
4958 'knowledgemanagement' =>
'ticket-alt',
'label' =>
'layer-group',
'layout' =>
'columns',
'line' =>
'bars',
'loan' =>
'money-bill-alt',
4959 'member' =>
'user-alt',
'meeting' =>
'chalkboard-teacher',
'mrp' =>
'cubes',
'next' =>
'arrow-alt-circle-right',
4960 'trip' =>
'wallet',
'expensereport' =>
'wallet',
'group' =>
'users',
'movement' =>
'people-carry',
4961 'sign-out' =>
'sign-out-alt',
4962 'switch_off' =>
'toggle-off',
'switch_on' =>
'toggle-on',
'switch_on_warning' =>
'toggle-on',
'switch_on_red' =>
'toggle-on',
'check' =>
'check',
'bookmark' =>
'star',
4963 'bank' =>
'university',
'close_title' =>
'times',
'delete' =>
'trash',
'filter' =>
'filter',
4964 'list-alt' =>
'list-alt',
'calendarlist' =>
'bars',
'calendar' =>
'calendar-alt',
'calendarmonth' =>
'calendar-alt',
'calendarweek' =>
'calendar-week',
'calendarday' =>
'calendar-day',
'calendarperuser' =>
'table',
4965 'intervention' =>
'ambulance',
'invoice' =>
'file-invoice-dollar',
'order' =>
'file-invoice',
4966 'error' =>
'exclamation-triangle',
'warning' =>
'exclamation-triangle',
4967 'other' =>
'square',
4968 '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',
4969 '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',
4970 'recent' =>
'check-square',
'reception' =>
'dolly',
'recruitmentjobposition' =>
'id-card-alt',
'recruitmentcandidature' =>
'id-badge',
4971 'resize' =>
'crop',
'supplier_order' =>
'dol-order_supplier',
'supplier_proposal' =>
'file-signature',
4972 'refresh' =>
'redo',
'region' =>
'map-marked',
'replacement' =>
'exchange-alt',
'resource' =>
'laptop-house',
'recurring' =>
'history',
4973 'service' =>
'concierge-bell',
4974 'skill' =>
'shapes',
'state' =>
'map-marked-alt',
'security' =>
'key',
'salary' =>
'wallet',
'shipment' =>
'dolly',
'stock' =>
'box-open',
'stats' =>
'chart-bar',
'split' =>
'code-branch',
4975 'status' =>
'stop-circle',
4976 'stripe' =>
'stripe-s',
'supplier' =>
'building',
4977 'technic' =>
'cogs',
'tick' =>
'check',
'timespent' =>
'clock',
'title_setup' =>
'tools',
'title_accountancy' =>
'money-check-alt',
'title_bank' =>
'university',
'title_hrm' =>
'umbrella-beach',
4978 'title_agenda' =>
'calendar-alt',
4979 'uncheck' =>
'times',
'uparrow' =>
'share',
'url' =>
'external-link-alt',
'vat' =>
'money-check-alt',
'vcard' =>
'arrow-alt-circle-down',
4980 'jabber' =>
'comment-o',
4981 'website' =>
'globe-americas',
'workstation' =>
'pallet',
'webhook' =>
'bullseye',
'world' =>
'globe',
'private' =>
'user-lock',
4982 'conferenceorbooth' =>
'chalkboard-teacher',
'eventorganization' =>
'project-diagram',
4983 'webportal' =>
'door-open'
4985 if ($conf->currency ==
'EUR') {
4986 $arrayconvpictotofa[
'currency'] =
'euro-sign';
4987 $arrayconvpictotofa[
'multicurrency'] =
'dollar-sign';
4989 $arrayconvpictotofa[
'currency'] =
'dollar-sign';
4990 $arrayconvpictotofa[
'multicurrency'] =
'euro-sign';
4992 if ($pictowithouttext ==
'off') {
4993 $fakey =
'fa-square';
4995 } elseif ($pictowithouttext ==
'on') {
4996 $fakey =
'fa-check-square';
4998 } elseif ($pictowithouttext ==
'listlight') {
4999 $fakey =
'fa-download';
5000 $marginleftonlyshort = 1;
5001 } elseif ($pictowithouttext ==
'printer') {
5002 $fakey =
'fa-print';
5004 } elseif ($pictowithouttext ==
'note') {
5005 $fakey =
'fa-sticky-note';
5006 $marginleftonlyshort = 1;
5007 } elseif (in_array($pictowithouttext, array(
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'))) {
5008 $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');
5009 $fakey =
'fa-'.$convertarray[$pictowithouttext];
5010 if (preg_match(
'/selected/', $pictowithouttext)) {
5013 $marginleftonlyshort = 1;
5014 } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) {
5015 $fakey =
'fa-'.$arrayconvpictotofa[$pictowithouttext];
5017 $fakey =
'fa-'.$pictowithouttext;
5020 if (in_array($pictowithouttext, array(
'dollyrevert',
'member',
'members',
'contract',
'group',
'resource',
'shipment',
'reception'))) {
5021 $morecss .=
' em092';
5023 if (in_array($pictowithouttext, array(
'conferenceorbooth',
'collab',
'eventorganization',
'holiday',
'info',
'project',
'workstation'))) {
5024 $morecss .=
' em088';
5026 if (in_array($pictowithouttext, array(
'asset',
'intervention',
'payment',
'loan',
'partnership',
'stock',
'technic'))) {
5027 $morecss .=
' em080';
5031 $arrayconvpictotomarginleftonly = array(
5032 'bank',
'check',
'delete',
'generic',
'grip',
'grip_title',
'jabber',
5033 'grip_title',
'grip',
'listlight',
'note',
'on',
'off',
'playdisabled',
'printer',
'resize',
'sign-out',
'stats',
'switch_on',
'switch_on_red',
'switch_off',
5034 'uparrow',
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'
5036 if (!isset($arrayconvpictotomarginleftonly[$pictowithouttext])) {
5037 $marginleftonlyshort = 0;
5041 $arrayconvpictotomorcess = array(
5042 'action' =>
'infobox-action',
'account' =>
'infobox-bank_account',
'accounting_account' =>
'infobox-bank_account',
'accountline' =>
'infobox-bank_account',
'accountancy' =>
'infobox-bank_account',
'asset' =>
'infobox-bank_account',
5043 'bank_account' =>
'infobox-bank_account',
5044 'bill' =>
'infobox-commande',
'billa' =>
'infobox-commande',
'billr' =>
'infobox-commande',
'billd' =>
'infobox-commande',
5045 'bookcal' =>
'infobox-action',
5046 'margin' =>
'infobox-bank_account',
'conferenceorbooth' =>
'infobox-project',
5047 'cash-register' =>
'infobox-bank_account',
'contract' =>
'infobox-contrat',
'check' =>
'font-status4',
'collab' =>
'infobox-action',
'conversation' =>
'infobox-contrat',
5048 'donation' =>
'infobox-commande',
'dolly' =>
'infobox-commande',
'dollyrevert' =>
'flip infobox-order_supplier',
5049 'ecm' =>
'infobox-action',
'eventorganization' =>
'infobox-project',
5050 'hrm' =>
'infobox-adherent',
'group' =>
'infobox-adherent',
'intervention' =>
'infobox-contrat',
5051 'incoterm' =>
'infobox-supplier_proposal',
5052 'currency' =>
'infobox-bank_account',
'multicurrency' =>
'infobox-bank_account',
5053 'members' =>
'infobox-adherent',
'member' =>
'infobox-adherent',
'money-bill-alt' =>
'infobox-bank_account',
5054 'order' =>
'infobox-commande',
5055 'user' =>
'infobox-adherent',
'users' =>
'infobox-adherent',
5056 'error' =>
'pictoerror',
'warning' =>
'pictowarning',
'switch_on' =>
'font-status4',
'switch_on_warning' =>
'font-status4 warning',
'switch_on_red' =>
'font-status8',
5057 'holiday' =>
'infobox-holiday',
'info' =>
'opacityhigh',
'invoice' =>
'infobox-commande',
5058 'knowledgemanagement' =>
'infobox-contrat rotate90',
'loan' =>
'infobox-bank_account',
5059 'payment' =>
'infobox-bank_account',
'payment_vat' =>
'infobox-bank_account',
'poll' =>
'infobox-adherent',
'pos' =>
'infobox-bank_account',
'project' =>
'infobox-project',
'projecttask' =>
'infobox-project',
5060 'propal' =>
'infobox-propal',
'proposal' =>
'infobox-propal',
'private' =>
'infobox-project',
5061 'reception' =>
'flip infobox-order_supplier',
'recruitmentjobposition' =>
'infobox-adherent',
'recruitmentcandidature' =>
'infobox-adherent',
5062 'resource' =>
'infobox-action',
5063 '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',
5064 'supplier' =>
'infobox-order_supplier',
'supplier_order' =>
'infobox-order_supplier',
'supplier_proposal' =>
'infobox-supplier_proposal',
5065 'ticket' =>
'infobox-contrat',
'title_accountancy' =>
'infobox-bank_account',
'title_hrm' =>
'infobox-holiday',
'expensereport' =>
'infobox-expensereport',
'trip' =>
'infobox-expensereport',
'title_agenda' =>
'infobox-action',
5066 'vat' =>
'infobox-bank_account',
5068 'list-alt' =>
'imgforviewmode',
'calendar' =>
'imgforviewmode',
'calendarweek' =>
'imgforviewmode',
'calendarmonth' =>
'imgforviewmode',
'calendarday' =>
'imgforviewmode',
'calendarperuser' =>
'imgforviewmode'
5070 if (!empty($arrayconvpictotomorcess[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5071 $morecss .= ($morecss ?
' ' :
'').$arrayconvpictotomorcess[$pictowithouttext];
5075 $arrayconvpictotocolor = array(
5076 'address' =>
'#6c6aa8',
'building' =>
'#6c6aa8',
'bom' =>
'#a69944',
5077 'clone' =>
'#999',
'cog' =>
'#999',
'companies' =>
'#6c6aa8',
'company' =>
'#6c6aa8',
'contact' =>
'#6c6aa8',
'cron' =>
'#555',
5078 'dynamicprice' =>
'#a69944',
5079 'edit' =>
'#444',
'note' =>
'#999',
'error' =>
'',
'help' =>
'#bbb',
'listlight' =>
'#999',
'language' =>
'#555',
5081 'lock' =>
'#ddd',
'lot' =>
'#a69944',
5082 'map-marker-alt' =>
'#aaa',
'mrp' =>
'#a69944',
'product' =>
'#a69944',
'service' =>
'#a69944',
'inventory' =>
'#a69944',
'stock' =>
'#a69944',
'movement' =>
'#a69944',
5083 'other' =>
'#ddd',
'world' =>
'#986c6a',
5084 'partnership' =>
'#6c6aa8',
'playdisabled' =>
'#ccc',
'printer' =>
'#444',
'projectpub' =>
'#986c6a',
'resize' =>
'#444',
'rss' =>
'#cba',
5086 'security' =>
'#999',
'square' =>
'#888',
'stop-circle' =>
'#888',
'stats' =>
'#444',
'switch_off' =>
'#999',
5087 'technic' =>
'#999',
'tick' =>
'#282',
'timespent' =>
'#555',
5088 'uncheck' =>
'#800',
'uparrow' =>
'#555',
'user-cog' =>
'#999',
'country' =>
'#aaa',
'globe-americas' =>
'#aaa',
'region' =>
'#aaa',
'state' =>
'#aaa',
5089 'website' =>
'#304',
'workstation' =>
'#a69944'
5091 if (isset($arrayconvpictotocolor[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5092 $facolor = $arrayconvpictotocolor[$pictowithouttext];
5099 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5100 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5101 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5103 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
5104 $morestyle = $reg[1];
5105 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
5107 $moreatt = trim($moreatt);
5109 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
5110 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
5114 $enabledisablehtml .=
'</span>';
5116 return $enabledisablehtml;
5123 } elseif (!empty($conf->modules_parts[
'theme']) && array_key_exists($theme, $conf->modules_parts[
'theme'])) {
5124 $path = $theme.
'/theme/'.$theme;
5129 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
5135 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
5140 foreach ($conf->file->dol_document_root as $type => $dirroot) {
5141 if ($type ==
'main') {
5145 if (file_exists($dirroot.
'/'.$path.
'/img/'.$picto)) {
5146 $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type];
5152 $fullpathpicto = $url.
'/'.$path.
'/img/'.$picto;
5156 return $fullpathpicto;
5160 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 :
'').
'"').
'>';
5176function img_object($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0)
5178 if (strpos($picto,
'^') === 0) {
5179 return img_picto($titlealt, str_replace(
'^',
'', $picto), $moreatt, $pictoisfullpath, $srconly, $notitle);
5181 return img_picto($titlealt,
'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
5196function img_weather($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $morecss =
'')
5200 if (is_numeric($picto)) {
5203 return '<i class="fa fa-weather-level'.$picto.
'"></i>';
5204 } elseif (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5208 $path = DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/weather/'.$picto;
5210 return img_picto($titlealt, $path, $moreatt, 1, 0, 0,
'', $morecss);
5224function img_picto_common($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $notitle = 0)
5228 if (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5232 if ($pictoisfullpath) {
5235 $path = DOL_URL_ROOT.
'/theme/common/'.$picto;
5238 $themepath = DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/img/'.$picto;
5240 if (file_exists($themepath)) {
5246 return img_picto($titlealt, $path, $moreatt, 1, 0, $notitle);
5262function img_action($titlealt, $numaction, $picto =
'', $moreatt =
'')
5266 if (empty($titlealt) || $titlealt ==
'default') {
5267 if ($numaction ==
'-1' || $numaction ==
'ST_NO') {
5269 $titlealt = $langs->transnoentitiesnoconv(
'ChangeDoNotContact');
5270 } elseif ($numaction ==
'0' || $numaction ==
'ST_NEVER') {
5272 $titlealt = $langs->transnoentitiesnoconv(
'ChangeNeverContacted');
5273 } elseif ($numaction ==
'1' || $numaction ==
'ST_TODO') {
5275 $titlealt = $langs->transnoentitiesnoconv(
'ChangeToContact');
5276 } elseif ($numaction ==
'2' || $numaction ==
'ST_PEND') {
5278 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactInProcess');
5279 } elseif ($numaction ==
'3' || $numaction ==
'ST_DONE') {
5281 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactDone');
5283 $titlealt = $langs->transnoentitiesnoconv(
'ChangeStatus '.$numaction);
5287 if (!is_numeric($numaction)) {
5291 return img_picto($titlealt, (empty($picto) ?
'stcomm'.$numaction.
'.png' : $picto), $moreatt);
5301function img_pdf($titlealt =
'default', $size = 3)
5305 if ($titlealt ==
'default') {
5306 $titlealt = $langs->trans(
'Show');
5309 return img_picto($titlealt,
'pdf'.$size.
'.png');
5319function img_edit_add($titlealt =
'default', $other =
'')
5323 if ($titlealt ==
'default') {
5324 $titlealt = $langs->trans(
'Add');
5327 return img_picto($titlealt,
'edit_add.png', $other);
5340 if ($titlealt ==
'default') {
5341 $titlealt = $langs->trans(
'Remove');
5344 return img_picto($titlealt,
'edit_remove.png', $other);
5355function img_edit($titlealt =
'default', $float = 0, $other =
'')
5359 if ($titlealt ==
'default') {
5360 $titlealt = $langs->trans(
'Modify');
5363 return img_picto($titlealt,
'edit.png', ($float ?
'style="float: '.($langs->tab_translate[
"DIRECTION"] ==
'rtl' ?
'left' :
'right').
'"' :
"").($other ?
' '.$other :
''));
5374function img_view($titlealt =
'default', $float = 0, $other =
'class="valignmiddle"')
5378 if ($titlealt ==
'default') {
5379 $titlealt = $langs->trans(
'View');
5382 $moreatt = ($float ?
'style="float: right" ' :
'').$other;
5384 return img_picto($titlealt,
'eye', $moreatt);
5395function img_delete($titlealt =
'default', $other =
'class="pictodelete"', $morecss =
'')
5399 if ($titlealt ==
'default') {
5400 $titlealt = $langs->trans(
'Delete');
5403 return img_picto($titlealt,
'delete.png', $other, 0, 0, 0,
'', $morecss);
5413function img_printer($titlealt =
"default", $other =
'')
5416 if ($titlealt ==
"default") {
5417 $titlealt = $langs->trans(
"Print");
5419 return img_picto($titlealt,
'printer.png', $other);
5429function img_split($titlealt =
'default', $other =
'class="pictosplit"')
5433 if ($titlealt ==
'default') {
5434 $titlealt = $langs->trans(
'Split');
5437 return img_picto($titlealt,
'split.png', $other);
5447function img_help($usehelpcursor = 1, $usealttitle = 1)
5452 if (is_string($usealttitle)) {
5455 $usealttitle = $langs->trans(
'Info');
5459 return img_picto($usealttitle,
'info.png',
'style="vertical-align: middle;'.($usehelpcursor == 1 ?
' cursor: help' : ($usehelpcursor == 2 ?
' cursor: pointer' :
'')).
'"');
5468function img_info($titlealt =
'default')
5472 if ($titlealt ==
'default') {
5473 $titlealt = $langs->trans(
'Informations');
5476 return img_picto($titlealt,
'info.png',
'style="vertical-align: middle;"');
5487function img_warning($titlealt =
'default', $moreatt =
'', $morecss =
'pictowarning')
5491 if ($titlealt ==
'default') {
5492 $titlealt = $langs->trans(
'Warning');
5496 return img_picto($titlealt,
'warning.png',
'class="'.$morecss.
'"'.($moreatt ? ($moreatt ==
'1' ?
' style="float: right"' :
' '.$moreatt) :
''));
5505function img_error($titlealt =
'default')
5509 if ($titlealt ==
'default') {
5510 $titlealt = $langs->trans(
'Error');
5513 return img_picto($titlealt,
'error.png');
5523function img_next($titlealt =
'default', $moreatt =
'')
5527 if ($titlealt ==
'default') {
5528 $titlealt = $langs->trans(
'Next');
5532 return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
5542function img_previous($titlealt =
'default', $moreatt =
'')
5546 if ($titlealt ==
'default') {
5547 $titlealt = $langs->trans(
'Previous');
5551 return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
5562function img_down($titlealt =
'default', $selected = 0, $moreclass =
'')
5566 if ($titlealt ==
'default') {
5567 $titlealt = $langs->trans(
'Down');
5570 return img_picto($titlealt, ($selected ?
'1downarrow_selected.png' :
'1downarrow.png'),
'class="imgdown'.($moreclass ?
" ".$moreclass :
"").
'"');
5581function img_up($titlealt =
'default', $selected = 0, $moreclass =
'')
5585 if ($titlealt ==
'default') {
5586 $titlealt = $langs->trans(
'Up');
5589 return img_picto($titlealt, ($selected ?
'1uparrow_selected.png' :
'1uparrow.png'),
'class="imgup'.($moreclass ?
" ".$moreclass :
"").
'"');
5600function img_left($titlealt =
'default', $selected = 0, $moreatt =
'')
5604 if ($titlealt ==
'default') {
5605 $titlealt = $langs->trans(
'Left');
5608 return img_picto($titlealt, ($selected ?
'1leftarrow_selected.png' :
'1leftarrow.png'), $moreatt);
5619function img_right($titlealt =
'default', $selected = 0, $moreatt =
'')
5623 if ($titlealt ==
'default') {
5624 $titlealt = $langs->trans(
'Right');
5627 return img_picto($titlealt, ($selected ?
'1rightarrow_selected.png' :
'1rightarrow.png'), $moreatt);
5637function img_allow($allow, $titlealt =
'default')
5641 if ($titlealt ==
'default') {
5642 $titlealt = $langs->trans(
'Active');
5646 return img_picto($titlealt,
'tick.png');
5661 if (is_null($morecss)) {
5665 if ($brand ==
'visa' || $brand ==
'Visa') {
5667 } elseif ($brand ==
'mastercard' || $brand ==
'MasterCard') {
5668 $brand =
'cc-mastercard';
5669 } elseif ($brand ==
'amex' || $brand ==
'American Express') {
5671 } elseif ($brand ==
'discover' || $brand ==
'Discover') {
5672 $brand =
'cc-discover';
5673 } elseif ($brand ==
'jcb' || $brand ==
'JCB') {
5675 } elseif ($brand ==
'diners' || $brand ==
'Diners club') {
5676 $brand =
'cc-diners-club';
5677 } elseif (!in_array($brand, array(
'cc-visa',
'cc-mastercard',
'cc-amex',
'cc-discover',
'cc-jcb',
'cc-diners-club'))) {
5678 $brand =
'credit-card';
5681 return '<span class="fa fa-'.$brand.
' fa-fw'.($morecss ?
' '.$morecss :
'').
'"></span>';
5692function img_mime($file, $titlealt =
'', $morecss =
'')
5694 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
5700 if (empty($titlealt)) {
5701 $titlealt =
'Mime type: '.$mimetype;
5705 return '<i class="fa fa-'.$mimefa.
' paddingright'.($morecss ?
' '.$morecss :
'').
'"'.($titlealt ?
' title="'.$titlealt.
'"' :
'').
'></i>';
5716function img_search($titlealt =
'default', $other =
'')
5720 if ($titlealt ==
'default') {
5721 $titlealt = $langs->trans(
'Search');
5724 $img =
img_picto($titlealt,
'search.png', $other, 0, 1);
5726 $input =
'<input type="image" class="liste_titre" name="button_search" src="'.$img.
'" ';
5727 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
5743 if ($titlealt ==
'default') {
5744 $titlealt = $langs->trans(
'Search');
5747 $img =
img_picto($titlealt,
'searchclear.png', $other, 0, 1);
5749 $input =
'<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.
'" ';
5750 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
5767function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin =
'1', $morecss =
'hideonsmartphone', $textfordropdown =
'', $picto =
'')
5769 global $conf, $langs;
5771 if ($infoonimgalt) {
5772 $result =
img_picto($text,
'info',
'class="'.($morecss ?
' '.$morecss :
'').
'"');
5774 if (empty($conf->use_javascript_ajax)) {
5775 $textfordropdown =
'';
5778 $class = (empty($admin) ?
'undefined' : ($admin ==
'1' ?
'info' : $admin));
5779 $fa =
'info-circle';
5780 if ($picto ==
'warning') {
5781 $fa =
'exclamation-triangle';
5783 $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> ';
5785 $result .= ($nodiv ?
'' :
'</div>');
5787 if ($textfordropdown) {
5788 $tmpresult =
'<span class="'.$class.
'text opacitymedium cursorpointer">'.$langs->trans($textfordropdown).
' '.
img_picto($langs->trans($textfordropdown),
'1downarrow').
'</span>';
5789 $tmpresult .=
'<script nonce="'.getNonce().
'" type="text/javascript">
5790 jQuery(document).ready(function() {
5791 jQuery(".'.$class.
'text").click(function() {
5792 console.log("toggle text");
5793 jQuery(".'.$class.
'").toggle();
5798 $result = $tmpresult.$result;
5819 global $conf, $langs, $user, $argv;
5820 global $dolibarr_main_prod;
5827 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
5829 $langs->load(
"main");
5833 $langs->loadLangs(array(
'main',
'errors'));
5835 if ($_SERVER[
'DOCUMENT_ROOT']) {
5836 $out .= $langs->trans(
"DolibarrHasDetectedError").
".<br>\n";
5838 $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";
5840 $out .= $langs->trans(
"InformationToHelpDiagnose").
":<br>\n";
5842 $out .=
"<b>".$langs->trans(
"Date").
":</b> ".
dol_print_date(time(),
'dayhourlog').
"<br>\n";
5843 $out .=
"<b>".$langs->trans(
"Dolibarr").
":</b> ".DOL_VERSION.
" - https://www.dolibarr.org<br>\n";
5844 if (isset($conf->global->MAIN_FEATURES_LEVEL)) {
5845 $out .=
"<b>".$langs->trans(
"LevelOfFeature").
":</b> ".
getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
"<br>\n";
5847 if ($user instanceof
User) {
5848 $out .=
"<b>".$langs->trans(
"Login").
":</b> ".$user->login.
"<br>\n";
5850 if (function_exists(
"phpversion")) {
5851 $out .=
"<b>".$langs->trans(
"PHP").
":</b> ".phpversion().
"<br>\n";
5853 $out .=
"<b>".$langs->trans(
"Server").
":</b> ".(isset($_SERVER[
"SERVER_SOFTWARE"]) ?
dol_htmlentities($_SERVER[
"SERVER_SOFTWARE"], ENT_COMPAT) :
'').
"<br>\n";
5854 if (function_exists(
"php_uname")) {
5855 $out .=
"<b>".$langs->trans(
"OS").
":</b> ".php_uname().
"<br>\n";
5857 $out .=
"<b>".$langs->trans(
"UserAgent").
":</b> ".(isset($_SERVER[
"HTTP_USER_AGENT"]) ?
dol_htmlentities($_SERVER[
"HTTP_USER_AGENT"], ENT_COMPAT) :
'').
"<br>\n";
5859 $out .=
"<b>".$langs->trans(
"RequestedUrl").
":</b> ".
dol_htmlentities($_SERVER[
"REQUEST_URI"], ENT_COMPAT).
"<br>\n";
5860 $out .=
"<b>".$langs->trans(
"Referer").
":</b> ".(isset($_SERVER[
"HTTP_REFERER"]) ?
dol_htmlentities($_SERVER[
"HTTP_REFERER"], ENT_COMPAT) :
'').
"<br>\n";
5861 $out .=
"<b>".$langs->trans(
"MenuManager").
":</b> ".(isset($conf->standard_menu) ?
dol_htmlentities($conf->standard_menu, ENT_COMPAT) :
'').
"<br>\n";
5863 $syslog .=
"url=".dol_escape_htmltag($_SERVER[
"REQUEST_URI"]);
5864 $syslog .=
", query_string=".dol_escape_htmltag($_SERVER[
"QUERY_STRING"]);
5866 $out .=
'> '.$langs->transnoentities(
"ErrorInternalErrorDetected").
":\n".$argv[0].
"\n";
5867 $syslog .=
"pid=".dol_getmypid();
5870 if (!empty($conf->modules)) {
5871 $out .=
"<b>".$langs->trans(
"Modules").
":</b> ".implode(
', ', $conf->modules).
"<br>\n";
5874 if (is_object($db)) {
5875 if ($_SERVER[
'DOCUMENT_ROOT']) {
5876 $out .=
"<b>".$langs->trans(
"DatabaseTypeManager").
":</b> ".$db->type.
"<br>\n";
5877 $lastqueryerror = $db->lastqueryerror();
5879 $lastqueryerror =
"SQL error string is not a valid UTF8 string. We can't show it.";
5881 $out .=
"<b>".$langs->trans(
"RequestLastAccessInError").
":</b> ".($lastqueryerror ?
dol_escape_htmltag($lastqueryerror) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5882 $out .=
"<b>".$langs->trans(
"ReturnCodeLastAccessInError").
":</b> ".($db->lasterrno() ?
dol_escape_htmltag($db->lasterrno()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5883 $out .=
"<b>".$langs->trans(
"InformationLastAccessInError").
":</b> ".($db->lasterror() ?
dol_escape_htmltag($db->lasterror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5887 $out .=
'> '.$langs->transnoentities(
"DatabaseTypeManager").
":\n".$db->type.
"\n";
5888 $out .=
'> '.$langs->transnoentities(
"RequestLastAccessInError").
":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5889 $out .=
'> '.$langs->transnoentities(
"ReturnCodeLastAccessInError").
":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5890 $out .=
'> '.$langs->transnoentities(
"InformationLastAccessInError").
":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5892 $syslog .=
", sql=".$db->lastquery();
5893 $syslog .=
", db_error=".$db->lasterror();
5896 if ($error || $errors) {
5898 if (is_array($error) && is_array($errors)) {
5899 $errors = array_merge($error, $errors);
5900 } elseif (is_array($error)) {
5902 } elseif (is_array($errors) && !empty($error)) {
5903 $errors = array_merge(array($error), $errors);
5904 } elseif (!empty($error)) {
5905 $errors = array_merge(array($error), array($errors));
5908 $langs->load(
"errors");
5910 foreach ($errors as $msg) {
5914 if ($_SERVER[
'DOCUMENT_ROOT']) {
5917 $out .=
'> '.$langs->transnoentities(
"Message").
":\n".$msg.
"\n";
5919 $syslog .=
", msg=".$msg;
5922 if (empty($dolibarr_main_prod) && $_SERVER[
'DOCUMENT_ROOT'] && function_exists(
'xdebug_print_function_stack') && function_exists(
'xdebug_call_file')) {
5923 xdebug_print_function_stack();
5924 $out .=
'<b>XDebug information:</b>'.
"<br>\n";
5925 $out .=
'File: '.xdebug_call_file().
"<br>\n";
5926 $out .=
'Line: '.xdebug_call_line().
"<br>\n";
5927 $out .=
'Function: '.xdebug_call_function().
"<br>\n";
5932 if (!headers_sent()) {
5933 if (function_exists(
'top_httphead')) {
5937 http_response_code(202);
5940 if (empty($dolibarr_main_prod)) {
5943 if (empty($langs->defaultlang)) {
5944 $langs->setDefaultLang();
5946 $langs->loadLangs(array(
"main",
"errors"));
5948 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";
5949 print $langs->trans(
"DolibarrHasDetectedError").
'. ';
5950 print $langs->trans(
"YouCanSetOptionDolibarrMainProdToZero");
5951 if (!defined(
"MAIN_CORE_ERROR")) {
5952 define(
"MAIN_CORE_ERROR", 1);
5969function dol_print_error_email($prefixcode, $errormessage =
'', $errormessages = array(), $morecss =
'error', $email =
'')
5973 if (empty($email)) {
5977 $langs->load(
"errors");
5980 print
'<br><div class="center login_main_message"><div class="'.$morecss.
'">';
5981 print $langs->trans(
"ErrorContactEMail", $email, $prefixcode.
'-'.
dol_print_date($now,
'%Y%m%d%H%M%S'));
5982 if ($errormessage) {
5983 print
'<br><br>'.$errormessage;
5985 if (is_array($errormessages) && count($errormessages)) {
5986 foreach ($errormessages as $mesgtoshow) {
5987 print
'<br><br>'.$mesgtoshow;
5990 print
'</div></div>';
6009function print_liste_field_titre($name, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $tooltip =
"", $forcenowrapcolumntitle = 0)
6011 print
getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip, $forcenowrapcolumntitle);
6032function getTitleFieldOfList($name, $thead = 0, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $disablesortlink = 0, $tooltip =
'', $forcenowrapcolumntitle = 0)
6034 global $langs, $form;
6037 if ($moreattrib ==
'class="right"') {
6038 $prefix .=
'right ';
6041 $sortorder = strtoupper($sortorder);
6050 $tmpsortfield = explode(
',', $sortfield);
6051 $sortfield1 = trim($tmpsortfield[0]);
6052 $tmpfield = explode(
',', $field);
6053 $field1 = trim($tmpfield[0]);
6055 if (!
getDolGlobalString(
'MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE') && empty($forcenowrapcolumntitle)) {
6056 $prefix =
'wrapcolumntitle '.$prefix;
6062 $liste_titre =
'liste_titre';
6063 if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace(
"/^[^\.]+\./",
"", $field1))) {
6064 $liste_titre =
'liste_titre_sel';
6067 $tagstart =
'<'.$tag.
' class="'.$prefix.$liste_titre.
'" '.$moreattrib;
6072 if (empty($thead) && $field && empty($disablesortlink)) {
6073 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6074 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6075 $options = preg_replace(
'/&+/i',
'&', $options);
6076 if (!preg_match(
'/^&/', $options)) {
6077 $options =
'&'.$options;
6080 $sortordertouseinlink =
'';
6081 if ($field1 != $sortfield1) {
6082 if (preg_match(
'/^DESC/i', $sortorder)) {
6083 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6085 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6088 if (preg_match(
'/^ASC/i', $sortorder)) {
6089 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6091 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6094 $sortordertouseinlink = preg_replace(
'/,$/',
'', $sortordertouseinlink);
6095 $out .=
'<a class="reposition" href="'.$file.
'?sortfield='.$field.
'&sortorder='.$sortordertouseinlink.
'&begin='.$begin.$options.
'"';
6101 if (preg_match(
'/:\w+$/', $tooltip)) {
6102 $tmptooltip = explode(
':', $tooltip);
6104 $tmptooltip = array($tooltip);
6106 $out .= $form->textwithpicto($langs->trans($name), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.str_replace(
'.',
'_', $field).
'_'.$tmptooltip[1]));
6108 $out .= $langs->trans($name);
6111 if (empty($thead) && $field && empty($disablesortlink)) {
6115 if (empty($thead) && $field) {
6116 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6117 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6118 $options = preg_replace(
'/&+/i',
'&', $options);
6119 if (!preg_match(
'/^&/', $options)) {
6120 $options =
'&'.$options;
6123 if (!$sortorder || ($field1 != $sortfield1)) {
6127 if (preg_match(
'/^DESC/', $sortorder)) {
6130 $sortimg .=
'<span class="nowrap">'.img_up(
"Z-A", 0,
'paddingright').
'</span>';
6132 if (preg_match(
'/^ASC/', $sortorder)) {
6135 $sortimg .=
'<span class="nowrap">'.img_down(
"A-Z", 0,
'paddingright').
'</span>';
6140 $tagend =
'</'.$tag.
'>';
6142 $out = $tagstart.$sortimg.$out.$tagend;
6157 dol_syslog(__FUNCTION__.
" is deprecated", LOG_WARNING);
6159 print
'<div class="titre">'.$title.
'</div>';
6173function print_fiche_titre($title, $mesg =
'', $picto =
'generic', $pictoisfullpath = 0, $id =
'')
6191function load_fiche_titre($title, $morehtmlright =
'', $picto =
'generic', $pictoisfullpath = 0, $id =
'', $morecssontable =
'', $morehtmlcenter =
'')
6195 if ($picto ==
'setup') {
6200 $return .=
'<table '.($id ?
'id="'.$id.
'" ' :
'').
'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ?
' '.$morecssontable :
'').
'">';
6201 $return .=
'<tr class="titre">';
6203 $return .=
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).
'</td>';
6205 $return .=
'<td class="nobordernopadding valignmiddle col-title">';
6206 $return .=
'<div class="titre inline-block">';
6208 $return .=
'</div>';
6211 $return .=
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
6214 $return .=
'<td class="nobordernopadding titre_right wordbreakimp right valignmiddle col-right">'.$morehtmlright.
'</td>';
6216 $return .=
'</tr></table>'.
"\n";
6244function print_barre_liste($title, $page, $file, $options =
'', $sortfield =
'', $sortorder =
'', $morehtmlcenter =
'', $num = -1, $totalnboflines =
'', $picto =
'generic', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limit = -1, $hideselectlimit = 0, $hidenavigation = 0, $pagenavastextinput = 0, $morehtmlrightbeforearrow =
'')
6249 $savtotalnboflines = $totalnboflines;
6250 if (is_numeric($totalnboflines)) {
6251 $totalnboflines = abs($totalnboflines);
6254 $page = (int) $page;
6256 if ($picto ==
'setup') {
6257 $picto =
'title_setup.png';
6259 if (($conf->browser->name ==
'ie') && $picto ==
'generic') {
6260 $picto =
'title.gif';
6263 $limit = $conf->liste_limit;
6266 if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
6274 print
"<!-- Begin title -->\n";
6275 print
'<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ?
' '.$morecss :
'').
'"><tr>';
6279 if ($picto && $title) {
6280 print
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath).
'</td>';
6283 print
'<td class="nobordernopadding valignmiddle col-title">';
6284 print
'<div class="titre inline-block">';
6286 if (!empty($title) && $savtotalnboflines >= 0 && (
string) $savtotalnboflines !=
'') {
6287 print
'<span class="opacitymedium colorblack paddingleft totalnboflines">('.$totalnboflines.
')</span>';
6289 print
'</div></td>';
6292 if ($morehtmlcenter && empty($conf->dol_optimize_smallscreen)) {
6293 print
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
6297 print
'<td class="nobordernopadding valignmiddle right col-right">';
6298 print
'<input type="hidden" name="pageplusoneold" value="'.((int) $page + 1).
'">';
6300 $options .=
"&sortfield=".urlencode($sortfield);
6303 $options .=
"&sortorder=".urlencode($sortorder);
6307 if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
6308 if ($totalnboflines) {
6310 $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 0);
6313 $nbpages = ceil($totalnboflines / $limit);
6317 $cpt = ($page - $maxnbofpage);
6323 if (empty($pagenavastextinput)) {
6324 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page=0'.$options.
'">1</a></li>';
6326 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
6327 } elseif ($cpt == 2) {
6328 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page=1'.$options.
'">2</a></li>';
6334 if ($pagenavastextinput) {
6335 if ($cpt == $page) {
6336 $pagelist .=
'<li class="pagination pageplusone"><input type="text" class="'.($totalnboflines > 100 ?
'width40' :
'width25').
' center pageplusone" name="pageplusone" value="'.($page + 1).
'"></li>';
6340 if ($cpt == $page) {
6341 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
'</span></li>';
6343 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.$cpt.$options.
'">'.($cpt + 1).
'</a></li>';
6347 }
while ($cpt < $nbpages && $cpt <= ($page + $maxnbofpage));
6349 if (empty($pagenavastextinput)) {
6350 if ($cpt < $nbpages) {
6351 if ($cpt < $nbpages - 2) {
6352 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
6353 } elseif ($cpt == $nbpages - 2) {
6354 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.($nbpages - 2).$options.
'">'.($nbpages - 1).
'</a></li>';
6356 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
6360 $pagelist .=
'<li class="pagination paginationlastpage"><a class="reposition" href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
6363 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
"</li>";
6367 if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
6368 print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow, $hidenavigation);
6372 if ($pagenavastextinput) {
6379 print
'</table>'.
"\n";
6382 if ($morehtmlcenter && !empty($conf->dol_optimize_smallscreen)) {
6383 print
'<div class="nobordernopadding marginbottomonly center valignmiddle col-center centpercent">'.$morehtmlcenter.
'</div>';
6386 print
"<!-- End title -->\n\n";
6405function print_fleche_navigation($page, $file, $options =
'', $nextpage = 0, $betweenarrows =
'', $afterarrows =
'', $limit = -1, $totalnboflines = 0, $hideselectlimit = 0, $beforearrows =
'', $hidenavigation = 0)
6407 global $conf, $langs;
6409 print
'<div class="pagination"><ul>';
6410 if ($beforearrows) {
6411 print
'<li class="paginationbeforearrows">';
6412 print $beforearrows;
6416 if (empty($hidenavigation)) {
6417 if ((
int) $limit > 0 && empty($hideselectlimit)) {
6418 $pagesizechoices =
'10:10,15:15,20:20,25:25,50:50,100:100,250:250,500:500,1000:1000';
6419 $pagesizechoices .=
',5000:5000,10000:10000';
6428 print
'<li class="pagination">';
6429 print
'<input onfocus="this.value=null;" onchange="this.blur();" class="flat selectlimit nopadding maxwidth75 right pageplusone" id="limit" name="limit" list="limitlist" title="'.dol_escape_htmltag($langs->trans(
"MaxNbOfRecordPerPage")).
'" value="'.$limit.
'">';
6430 print
'<datalist id="limitlist">';
6432 print
'<li class="paginationcombolimit valignmiddle">';
6433 print
'<select id="limit" class="flat selectlimit nopadding maxwidth75 center" name="limit" title="'.dol_escape_htmltag($langs->trans(
"MaxNbOfRecordPerPage")).
'">';