53if (!function_exists(
'utf8_encode')) {
61 function utf8_encode($elements)
63 return mb_convert_encoding($elements,
'UTF-8',
'ISO-8859-1');
67if (!function_exists(
'utf8_decode')) {
75 function utf8_decode($elements)
77 return mb_convert_encoding($elements,
'ISO-8859-1',
'UTF-8');
80if (!function_exists(
'str_starts_with')) {
89 function str_starts_with($haystack, $needle)
91 return (
string) $needle !==
'' && strncmp($haystack, $needle, strlen($needle)) === 0;
94if (!function_exists(
'str_ends_with')) {
103 function str_ends_with($haystack, $needle)
105 return $needle !==
'' && substr($haystack, -strlen($needle)) === (string) $needle;
108if (!function_exists(
'str_contains')) {
117 function str_contains($haystack, $needle)
119 return $needle !==
'' && mb_strpos($haystack, $needle) !==
false;
139 if (!is_object(
$object) && empty($module)) {
142 if (empty($module) && !empty(
$object->element)) {
147 if ($module ==
'fichinter') {
148 $module =
'ficheinter';
149 } elseif ($module ==
'invoice_supplier') {
150 $module =
'supplier_invoice';
151 } elseif ($module ==
'order_supplier') {
152 $module =
'supplier_order';
156 if ($mode ==
'output' || $mode ==
'outputrel' || $mode ==
'version') {
157 if (isset(
$conf->$module) && property_exists(
$conf->$module,
'multidir_output')) {
159 if ($mode !=
'outputrel') {
162 if ($forobject &&
$object->id > 0) {
166 } elseif (isset(
$conf->$module) && property_exists(
$conf->$module,
'dir_output')) {
168 if ($mode !=
'outputrel') {
169 $s =
$conf->$module->dir_output;
171 if ($forobject &&
$object->id > 0) {
176 return 'error-diroutput-not-defined-for-this-object='.$module;
178 } elseif ($mode ==
'temp') {
179 if (isset(
$conf->$module) && property_exists(
$conf->$module,
'multidir_temp')) {
181 } elseif (isset(
$conf->$module) && property_exists(
$conf->$module,
'dir_temp')) {
182 return $conf->$module->dir_temp;
184 return 'error-dirtemp-not-defined-for-this-object='.$module;
187 return 'error-bad-value-for-mode';
231 return (
string) (isset(
$conf->global->$key) ?
$conf->global->$key : $default);
246 return (
int) (isset(
$conf->global->$key) ?
$conf->global->$key : $default);
261 return (
float) (isset(
$conf->global->$key) ?
$conf->global->$key : $default);
275 return (
bool) (
$conf->global->$key ?? $default);
289 if (empty($tmpuser)) {
294 return (
string) (isset($tmpuser->conf->$key) ? $tmpuser->conf->$key : $default);
307 if (empty($tmpuser)) {
312 return (
int) (isset($tmpuser->conf->$key) ? $tmpuser->conf->$key : $default);
329 'adherent' =>
'member',
330 'member_type' =>
'adherent_type',
332 'contrat' =>
'contract',
333 'entrepot' =>
'stock',
334 'projet' =>
'project',
335 'categorie' =>
'category',
336 'commande' =>
'order',
337 'expedition' =>
'shipping',
338 'facture' =>
'invoice',
339 'fichinter' =>
'intervention',
340 'ficheinter' =>
'intervention',
341 'propale' =>
'propal',
342 'socpeople' =>
'contact',
343 'fournisseur' =>
'supplier',
345 'actioncomm' =>
'agenda',
346 'product_price' =>
'productprice',
347 'product_fournisseur_price' =>
'productsupplierprice',
357function isModEnabled($module)
367 $arrayconv[
'supplier_order'] =
'fournisseur';
368 $arrayconv[
'supplier_invoice'] =
'fournisseur';
373 if ($module ==
'delivery_note') {
377 $module =
'shipping';
381 $module_alt = $module;
382 if (!empty($arrayconv[$module])) {
383 $module_alt = $arrayconv[$module];
385 $module_bis = $module;
386 if (!empty($arrayconvbis[$module])) {
387 $module_bis = $arrayconvbis[$module];
390 return !empty(
$conf->modules[$module]) || !empty(
$conf->modules[$module_alt]) || !empty(
$conf->modules[$module_bis]);
402 if ($timestamp ===
'') {
403 dol_syslog(
'Using empty string for a timestamp is deprecated, prefer use of null when calling page '.$_SERVER[
"PHP_SELF"] .
getCallerInfoString(), LOG_NOTICE);
406 if (is_null($timestamp) || !is_numeric($timestamp)) {
426 require_once DOL_DOCUMENT_ROOT.
"/core/db/".$type.
'.class.php';
428 $class =
'DoliDB'.ucfirst($type);
429 $db =
new $class($type, $host, $user, $pass, $name, $port);
450function getEntity($element, $shared = 1, $currentobject =
null)
454 if (!is_object($hookmanager)) {
455 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
462 $element =
'project';
465 $element =
'contract';
467 case 'order_supplier':
468 $element =
'supplier_order';
470 case 'invoice_supplier':
471 $element =
'supplier_invoice';
475 if (is_object($mc)) {
476 $out = $mc->getEntity($element, $shared, $currentobject);
479 $addzero = array(
'user',
'usergroup',
'cronjob',
'c_email_templates',
'email_template',
'default_values',
'overwrite_trans');
481 $addzero[] =
'c_holiday_types';
483 if (in_array($element, $addzero)) {
486 $out .= ((int)
$conf->entity);
491 'element' => $element,
494 'currentobject' => $currentobject,
497 $reshook = $hookmanager->executeHooks(
'hookGetEntity', $parameters, $currentobject, $action);
499 if (is_numeric($reshook)) {
500 if ($reshook == 0 && !empty($hookmanager->resPrint)) {
501 $out .=
','.$hookmanager->resPrint;
502 } elseif ($reshook == 1) {
503 $out = $hookmanager->resPrint;
520 if (is_object($mc) && method_exists($mc,
'setEntity')) {
521 return $mc->setEntity($currentobject);
523 return ((is_object($currentobject) && $currentobject->id > 0 && $currentobject->entity > 0) ? $currentobject->entity :
$conf->entity);
535 return preg_match(
'/(_pass|password|_pw|_key|securekey|serverkey|secret\d?|p12key|exportkey|_PW_[a-z]+|token)$/i', $keyname);
547 for ($r =
""; $n >= 0; $n = intval($n / 26) - 1) {
548 $r = chr($n % 26 + 0x41) . $r;
572 include_once DOL_DOCUMENT_ROOT.
'/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php';
579 $user_agent = substr($user_agent, 0, 512);
581 $detectmobile =
new Mobile_Detect(
null, $user_agent);
582 $tablet = $detectmobile->isTablet();
584 if ($detectmobile->isMobile()) {
588 if ($detectmobile->is(
'AndroidOS')) {
589 $os = $phone =
'android';
590 } elseif ($detectmobile->is(
'BlackBerryOS')) {
591 $os = $phone =
'blackberry';
592 } elseif ($detectmobile->is(
'iOS')) {
595 } elseif ($detectmobile->is(
'PalmOS')) {
596 $os = $phone =
'palm';
597 } elseif ($detectmobile->is(
'SymbianOS')) {
599 } elseif ($detectmobile->is(
'webOS')) {
601 } elseif ($detectmobile->is(
'MaemoOS')) {
603 } elseif ($detectmobile->is(
'WindowsMobileOS') || $detectmobile->is(
'WindowsPhoneOS')) {
609 if (preg_match(
'/linux/i', $user_agent)) {
611 } elseif (preg_match(
'/macintosh/i', $user_agent)) {
613 } elseif (preg_match(
'/windows/i', $user_agent)) {
619 if (preg_match(
'/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
621 $version = empty($reg[2]) ?
'' : $reg[2];
622 } elseif (preg_match(
'/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
624 $version = empty($reg[2]) ?
'' : $reg[2];
625 } elseif (preg_match(
'/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) {
627 $version = empty($reg[2]) ?
'' : $reg[2];
628 } elseif (preg_match(
'/chrome/i', $user_agent, $reg)) {
631 } elseif (preg_match(
'/iceweasel/i', $user_agent)) {
633 } elseif (preg_match(
'/epiphany/i', $user_agent)) {
635 } elseif (preg_match(
'/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
637 $version = empty($reg[2]) ?
'' : $reg[2];
638 } elseif (preg_match(
'/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
641 $version = empty($reg[2]) ?
'' : $reg[2];
642 } elseif (preg_match(
'/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
644 $version = end($reg);
645 } elseif (preg_match(
'/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
648 $version = end($reg);
649 } elseif (preg_match(
'/l[iy]n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) {
651 $name =
'textbrowser';
652 $version = empty($reg[3]) ?
'' : $reg[3];
653 } elseif (preg_match(
'/w3m\/([\d\.]+)/i', $user_agent, $reg)) {
655 $name =
'textbrowser';
656 $version = empty($reg[1]) ?
'' : $reg[1];
668 'browsername' => $name,
669 'browserversion' => $version,
671 'browserua' => $user_agent,
686 $disconnectdone =
false;
688 if (is_object($db) && !empty($db->connected)) {
689 $depth = $db->transaction_opened;
690 $disconnectdone = $db->close();
692 dol_syslog(
"--- End access to ".(empty($_SERVER[
"PHP_SELF"]) ?
'unknown' : $_SERVER[
"PHP_SELF"]).(($disconnectdone && $depth) ?
' (Warn: db disconnection forced, transaction depth was '.$depth.
')' :
''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO));
704function GETPOSTISSET($paramname)
708 $relativepathstring = $_SERVER[
"PHP_SELF"];
710 if (constant(
'DOL_URL_ROOT')) {
711 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
713 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
714 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
720 if (!empty($_GET[
'restore_lastsearch_values'])) {
721 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
722 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
723 if (is_array($tmp)) {
724 foreach ($tmp as $key => $val) {
725 if ($key == $paramname) {
733 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
735 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
737 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
739 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
743 $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname]));
760 if (empty($method)) {
761 $val = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
762 } elseif ($method == 1) {
763 $val = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
764 } elseif ($method == 2) {
765 $val = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
766 } elseif ($method == 3) {
767 $val = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
769 $val =
'BadFirstParameterForGETPOST';
772 return is_array($val);
804function GETPOST($paramname, $check =
'alphanohtml', $method = 0, $filter =
null, $options =
null, $noreplace = 0)
806 global $mysoc, $user,
$conf;
808 if (empty($paramname)) {
809 return 'BadFirstParameterForGETPOST';
812 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);
817 if (empty($method)) {
818 $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
819 } elseif ($method == 1) {
820 $out = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
821 } elseif ($method == 2) {
822 $out = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
823 } elseif ($method == 3) {
824 $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
826 return 'BadThirdParameterForGETPOST';
829 $relativepathstring =
'';
831 if (empty($method) || $method == 3 || $method == 4) {
832 $relativepathstring = (empty($_SERVER[
"PHP_SELF"]) ?
'' : $_SERVER[
"PHP_SELF"]);
834 if (constant(
'DOL_URL_ROOT')) {
835 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
837 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
838 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
844 if (!empty($_GET[
'restore_lastsearch_values'])) {
845 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
846 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
847 if (is_array($tmp)) {
848 foreach ($tmp as $key => $val) {
849 if ($key == $paramname) {
857 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
858 $out = $_SESSION[
'lastsearch_contextpage_'.$relativepathstring];
859 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
860 $out = $_SESSION[
'lastsearch_limit_'.$relativepathstring];
861 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
862 $out = $_SESSION[
'lastsearch_page_'.$relativepathstring];
863 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
864 $out = $_SESSION[
'lastsearch_mode_'.$relativepathstring];
866 } elseif (!isset($_GET[
'sortfield'])) {
869 if (!empty($_GET[
'action']) && $_GET[
'action'] ==
'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
872 '@phan-var-force CommonObject $object';
873 if (is_object(
$object) && isset(
$object->fields[$paramname][
'default'])) {
875 $out =
$object->fields[$paramname][
'default'];
879 if (!empty($_GET[
'action']) && (preg_match(
'/^create/', $_GET[
'action']) || preg_match(
'/^presend/', $_GET[
'action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
881 if (!empty($user->default_values)) {
882 if (isset($user->default_values[$relativepathstring][
'createform'])) {
883 foreach ($user->default_values[$relativepathstring][
'createform'] as $defkey => $defval) {
885 if ($defkey !=
'_noquery_') {
886 $tmpqueryarraytohave = explode(
'&', $defkey);
889 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
890 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
903 if (isset($user->default_values[$relativepathstring][
'createform'][$defkey][$paramname])) {
904 $out = $user->default_values[$relativepathstring][
'createform'][$defkey][$paramname];
911 } elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
913 if (!empty($user->default_values)) {
916 if ($paramname ==
'sortfield' || $paramname ==
'sortorder') {
918 if (isset($user->default_values[$relativepathstring][
'sortorder'])) {
920 foreach ($user->default_values[$relativepathstring][
'sortorder'] as $defkey => $defval) {
922 if ($defkey !=
'_noquery_') {
923 $tmpqueryarraytohave = explode(
'&', $defkey);
926 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
927 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
940 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
941 foreach ($user->default_values[$relativepathstring][
'sortorder'][$defkey] as $key => $val) {
945 if ($paramname ==
'sortfield') {
948 if ($paramname ==
'sortorder') {
956 } elseif (isset($user->default_values[$relativepathstring][
'filters'])) {
957 foreach ($user->default_values[$relativepathstring][
'filters'] as $defkey => $defval) {
958 if (!empty($_GET[
'disabledefaultvalues'])) {
962 if ($defkey !=
'_noquery_') {
963 $tmpqueryarraytohave = explode(
'&', $defkey);
966 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
967 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
979 if ($qualified && isset($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname])) {
981 if (isset($_POST[
'search_all']) || isset($_GET[
'search_all'])) {
984 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
985 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
988 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
989 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
1004 '@phan-var-force string $paramname';
1005 if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
1007 $regreplace = array();
1011 while (preg_match(
'/__([A-Z0-9]+(?:_[A-Z0-9]+){0,3})__/i', $out, $reg) && ($loopnb < $maxloop)) {
1015 if ($reg[1] ==
'DAY') {
1017 $newout = $tmp[
'mday'];
1018 } elseif ($reg[1] ==
'MONTH') {
1020 $newout = $tmp[
'mon'];
1021 } elseif ($reg[1] ==
'YEAR') {
1023 $newout = $tmp[
'year'];
1024 } elseif ($reg[1] ==
'PREVIOUS_DAY') {
1027 $newout = $tmp2[
'day'];
1028 } elseif ($reg[1] ==
'PREVIOUS_MONTH') {
1031 $newout = $tmp2[
'month'];
1032 } elseif ($reg[1] ==
'PREVIOUS_YEAR') {
1034 $newout = ($tmp[
'year'] - 1);
1035 } elseif ($reg[1] ==
'NEXT_DAY') {
1038 $newout = $tmp2[
'day'];
1039 } elseif ($reg[1] ==
'NEXT_MONTH') {
1042 $newout = $tmp2[
'month'];
1043 } elseif ($reg[1] ==
'NEXT_YEAR') {
1045 $newout = ($tmp[
'year'] + 1);
1046 } elseif ($reg[1] ==
'MYCOMPANY_COUNTRY_ID' || $reg[1] ==
'MYCOUNTRY_ID' || $reg[1] ==
'MYCOUNTRYID') {
1047 $newout = $mysoc->country_id;
1048 } elseif ($reg[1] ==
'USER_ID' || $reg[1] ==
'USERID') {
1049 $newout = $user->id;
1050 } elseif ($reg[1] ==
'USER_SUPERVISOR_ID' || $reg[1] ==
'SUPERVISOR_ID' || $reg[1] ==
'SUPERVISORID') {
1051 $newout = $user->fk_user;
1052 } elseif ($reg[1] ==
'ENTITY_ID' || $reg[1] ==
'ENTITYID') {
1053 $newout =
$conf->entity;
1054 } elseif ($reg[1] ==
'ID') {
1057 $newout =
'REGREPLACE_'.$loopnb;
1058 $regreplace[$loopnb] = $reg[0];
1061 $out = preg_replace(
'/__'.preg_quote($reg[1],
'/').
'__/', $newout, $out);
1063 if (!empty($regreplace)) {
1064 foreach ($regreplace as $key => $value) {
1065 $out = preg_replace(
'/REGREPLACE_'.$key.
'/', $value, $out);
1071 if (preg_match(
'/^array/', $check)) {
1072 if (!is_array($out) || empty($out)) {
1075 $tmparray = explode(
':', $check);
1076 if (!empty($tmparray[1])) {
1077 $tmpcheck = $tmparray[1];
1079 $tmpcheck =
'alphanohtml';
1081 foreach ($out as $outkey => $outval) {
1082 $out[$outkey] =
sanitizeVal($outval, $tmpcheck, $filter, $options);
1088 if (strpos($paramname,
'search_') === 0) {
1089 $out = preg_replace(
'/([<>])([-+]?\d)/',
'\1 \2', $out);
1093 $out =
sanitizeVal($out, $check, $filter, $options);
1100 if (preg_match(
'/^backto/i', $paramname)) {
1101 $out = str_replace(
'\\',
'/', $out);
1102 $out = str_replace(array(
':',
';',
'@',
"\t",
' '),
'', $out);
1104 $oldstringtoclean = $out;
1105 $out = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $out);
1106 $out = preg_replace(array(
'/^[^\?]*%/'),
'', $out);
1107 $out = preg_replace(array(
'/^[a-z]*\/\s*\/+/i'),
'', $out);
1108 }
while ($oldstringtoclean != $out);
1113 if (empty($method) || $method == 3 || $method == 4) {
1114 if (preg_match(
'/^search_/', $paramname) || in_array($paramname, array(
'sortorder',
'sortfield'))) {
1121 if ($out !=
'' && isset($user)) {
1122 $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out;
1141 return (
int)
GETPOST($paramname,
'int', $method,
null,
null, 0);
1171function GETPOSTDATE($prefix, $hourTime =
'', $gm =
'auto')
1174 if ($hourTime ===
'getpost') {
1178 } elseif (preg_match(
'/^(\d\d):(\d\d):(\d\d)$/', $hourTime, $m)) {
1179 $hour = intval($m[1]);
1180 $minute = intval($m[2]);
1181 $second = intval($m[3]);
1183 $hour = $minute = $second = 0;
1186 $hour = (int) min($hour, 23);
1187 $minute = (int) min($minute, 59);
1188 $second = (int) min($second, 59);
1204function checkVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1206 return sanitizeVal($out, $check, $filter, $options);
1218function sanitizeVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1227 if (!is_numeric($out)) {
1232 if (is_array($out)) {
1233 $out = implode(
',', $out);
1235 if (preg_match(
'/[^0-9,-]+/i', $out)) {
1240 $out = filter_var($out, FILTER_SANITIZE_STRING);
1243 $out = filter_var($out, FILTER_SANITIZE_EMAIL);
1246 if (!is_array($out)) {
1248 if (preg_match(
'/[^a-z]+/i', $out)) {
1254 if (!is_array($out)) {
1256 if (preg_match(
'/[^a-z0-9_\-\.]+/i', $out)) {
1262 if (!is_array($out)) {
1264 if (preg_match(
'/[^a-z0-9_\-\.@]+/i', $out)) {
1270 if (!is_array($out)) {
1272 if (preg_match(
'/[^a-z0-9_\-\.,]+/i', $out)) {
1279 if (!is_array($out)) {
1282 $oldstringtoclean = $out;
1286 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1293 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1294 }
while ($oldstringtoclean != $out);
1298 case 'alphawithlgt':
1299 if (!is_array($out)) {
1302 $oldstringtoclean = $out;
1306 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1313 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1314 }
while ($oldstringtoclean != $out);
1320 case 'restricthtmlnolink':
1321 case 'restricthtml':
1322 case 'restricthtmlallowclass':
1323 case 'restricthtmlallowiframe':
1324 case 'restricthtmlallowlinkscript':
1325 case 'restricthtmlallowunvalid':
1330 if (empty($filter)) {
1331 return 'BadParameterForGETPOST - Param 3 of sanitizeVal()';
1333 if (is_null($options)) {
1336 $out = filter_var($out, $filter, $options);
1340 dol_syslog(
"Error, you call sanitizeVal() with a bad value for the check type. Data will be sanitized with alphanohtml.", LOG_ERR);
1341 $out =
GETPOST($out,
'alphanohtml');
1349if (!function_exists(
'dol_getprefix')) {
1360 function dol_getprefix($mode =
'')
1363 if ($mode ==
'email') {
1369 } elseif (isset($_SERVER[
"SERVER_NAME"])) {
1370 return $_SERVER[
"SERVER_NAME"];
1375 if (!empty(
$conf->file->instance_unique_id)) {
1376 return sha1(
'dolibarr'.
$conf->file->instance_unique_id);
1380 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1384 global $dolibarr_main_instance_unique_id, $dolibarr_main_cookie_cryptkey;
1385 $tmp_instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ?
'' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
1388 if (!empty($tmp_instance_unique_id)) {
1389 return sha1(
'dolibarr'.$tmp_instance_unique_id);
1393 if (isset($_SERVER[
"SERVER_NAME"]) && isset($_SERVER[
"DOCUMENT_ROOT"])) {
1394 return sha1($_SERVER[
"SERVER_NAME"].$_SERVER[
"DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1396 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1413 global
$conf, $langs, $user, $mysoc;
1417 if (!file_exists($fullpath)) {
1418 dol_syslog(
'functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_WARNING);
1422 if (!empty($classname) && !class_exists($classname)) {
1423 return include $fullpath;
1425 return include_once $fullpath;
1443function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
1447 $path = preg_replace(
'/^\//',
'', $path);
1450 $res = DOL_DOCUMENT_ROOT.
'/'.$path;
1451 if (is_array(
$conf->file->dol_document_root)) {
1452 foreach (
$conf->file->dol_document_root as $key => $dirroot) {
1453 if ($key ==
'main') {
1457 if (@file_exists($dirroot.
'/'.$path)) {
1458 $res = $dirroot.
'/'.$path;
1463 if ($returnemptyifnotfound) {
1465 if ($returnemptyifnotfound == 1 || !file_exists($res)) {
1477 $res = DOL_URL_ROOT.
'/'.$path;
1480 $res = DOL_MAIN_URL_ROOT.
'/'.$path;
1483 $res = DOL_URL_ROOT.
'/'.$path;
1486 foreach (
$conf->file->dol_document_root as $key => $dirroot) {
1487 if ($key ==
'main') {
1492 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$conf->file->dol_main_url_root));
1493 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1496 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
'/'.$path;
1501 preg_match(
'/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);
1502 if (!empty($regs[1])) {
1505 if (@file_exists($dirroot.
'/'.$regs[1])) {
1507 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : DOL_URL_ROOT).
$conf->file->dol_url_root[$key].
'/'.$path;
1508 } elseif ($type == 2) {
1509 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : DOL_MAIN_URL_ROOT).
$conf->file->dol_url_root[$key].
'/'.$path;
1510 } elseif ($type == 3) {
1514 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$conf->file->dol_main_url_root));
1515 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1518 $res = (preg_match(
'/^http/i',
$conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
$conf->file->dol_url_root[$key].
'/'.$path;
1542 if (empty($properties)) {
1543 return get_object_vars($obj);
1546 $existingProperties = [];
1547 $realProperties = get_object_vars($obj);
1550 foreach ($properties as $property) {
1551 if (array_key_exists($property, $realProperties)) {
1553 $existingProperties[$property] = $obj->{$property};
1554 } elseif (property_exists($obj, $property)) {
1556 $existingProperties[$property] = $obj->{$property};
1560 return $existingProperties;
1589 $myclone = unserialize(serialize(
$object));
1591 if (!empty($tmpsavdb)) {
1594 } elseif ($native == 2) {
1597 $tmparray = get_object_vars(
$object);
1599 if (is_array($tmparray)) {
1600 foreach ($tmparray as $propertykey => $propertyval) {
1601 if (is_scalar($propertyval) || is_array($propertyval)) {
1602 $myclone->$propertykey = $propertyval;
1622function dol_size($size, $type =
'')
1625 if (empty(
$conf->dol_optimize_smallscreen)) {
1628 if ($type ==
'width' && $size > 250) {
1654 $filesystem_forbidden_chars = array(
'<',
'>',
'/',
'\\',
'?',
'*',
'|',
'"',
':',
'°',
'$',
';',
'`');
1655 if ($includequotes) {
1656 $filesystem_forbidden_chars[] =
"'";
1659 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1660 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1661 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1662 $tmp = str_replace(
'..',
'', $tmp);
1684 $filesystem_forbidden_chars = array(
'<',
'>',
'?',
'*',
'|',
'"',
'°',
'$',
';',
'`');
1691 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1692 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1693 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1694 $tmp = str_replace(
'..',
'', $tmp);
1709 $stringtoclean = preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $stringtoclean);
1711 $stringtoclean = preg_replace(
'/<!--[^>]*-->/',
'', $stringtoclean);
1713 $stringtoclean = str_replace(
'\\',
'/', $stringtoclean);
1717 $stringtoclean = str_replace(array(
':',
';',
'@'),
'', $stringtoclean);
1721 $oldstringtoclean = $stringtoclean;
1724 $stringtoclean = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $stringtoclean);
1725 }
while ($oldstringtoclean != $stringtoclean);
1729 $stringtoclean = preg_replace(array(
'/^[a-z]*\/\/+/i'),
'', $stringtoclean);
1732 return $stringtoclean;
1744 $oldstringtoclean = $stringtoclean;
1745 $stringtoclean = str_ireplace(array(
'"',
':',
'[',
']',
"\n",
"\r",
'\\',
'\/'),
'', $stringtoclean);
1746 }
while ($oldstringtoclean != $stringtoclean);
1748 return $stringtoclean;
1761 return preg_replace(
'/[^\w]+/',
'', $str);
1775 if (is_null($str)) {
1780 if (extension_loaded(
'intl') &&
getDolGlobalString(
'MAIN_UNACCENT_USE_TRANSLITERATOR')) {
1781 $transliterator = Transliterator::createFromRules(
':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', Transliterator::FORWARD);
1782 return $transliterator->transliterate($str);
1785 $string = rawurlencode($str);
1786 $replacements = array(
1787 '%C3%80' =>
'A',
'%C3%81' =>
'A',
'%C3%82' =>
'A',
'%C3%83' =>
'A',
'%C3%84' =>
'A',
'%C3%85' =>
'A',
1789 '%C3%88' =>
'E',
'%C3%89' =>
'E',
'%C3%8A' =>
'E',
'%C3%8B' =>
'E',
1790 '%C3%8C' =>
'I',
'%C3%8D' =>
'I',
'%C3%8E' =>
'I',
'%C3%8F' =>
'I',
1792 '%C3%92' =>
'O',
'%C3%93' =>
'O',
'%C3%94' =>
'O',
'%C3%95' =>
'O',
'%C3%96' =>
'O',
1794 '%C3%99' =>
'U',
'%C3%9A' =>
'U',
'%C3%9B' =>
'U',
'%C3%9C' =>
'U',
1795 '%C3%9D' =>
'Y',
'%C5%B8' =>
'y',
1796 '%C3%A0' =>
'a',
'%C3%A1' =>
'a',
'%C3%A2' =>
'a',
'%C3%A3' =>
'a',
'%C3%A4' =>
'a',
'%C3%A5' =>
'a',
1798 '%C3%A8' =>
'e',
'%C3%A9' =>
'e',
'%C3%AA' =>
'e',
'%C3%AB' =>
'e',
1799 '%C3%AC' =>
'i',
'%C3%AD' =>
'i',
'%C3%AE' =>
'i',
'%C3%AF' =>
'i',
1801 '%C3%B2' =>
'o',
'%C3%B3' =>
'o',
'%C3%B4' =>
'o',
'%C3%B5' =>
'o',
'%C3%B6' =>
'o',
1803 '%C3%B9' =>
'u',
'%C3%BA' =>
'u',
'%C3%BB' =>
'u',
'%C3%BC' =>
'u',
1804 '%C3%BD' =>
'y',
'%C3%BF' =>
'y'
1806 $string = strtr($string, $replacements);
1807 return rawurldecode($string);
1812 "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
1813 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
1814 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
1815 \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
1816 \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
1817 \xF9\xFA\xFB\xFC\xFD\xFF",
1825 $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"));
1843function dol_string_nospecial($str, $newstr =
'_', $badcharstoreplace =
'', $badcharstoremove =
'', $keepspaces = 0)
1845 $forbidden_chars_to_replace = array(
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
",",
";",
"=",
'°',
'$',
';');
1846 if (empty($keepspaces)) {
1847 $forbidden_chars_to_replace[] =
" ";
1849 $forbidden_chars_to_remove = array();
1852 if (is_array($badcharstoreplace)) {
1853 $forbidden_chars_to_replace = $badcharstoreplace;
1855 if (is_array($badcharstoremove)) {
1856 $forbidden_chars_to_remove = $badcharstoremove;
1860 return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove,
"", $str));
1879 if ($removetabcrlf) {
1880 return preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $str);
1882 return preg_replace(
'/[\x00-\x08\x11-\x12\x14-\x1F\x7F]/u',
'', $str);
1897 if (function_exists(
'iconv')) {
1898 $slug = iconv(
'UTF-8',
'ASCII//TRANSLIT//IGNORE', $slug);
1902 $slug = strtolower($slug);
1905 $slug = preg_replace(
'/[^a-z0-9]+/',
'-', $slug);
1908 $slug = trim($slug,
'-');
1921function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0)
1923 if (is_null($stringtoescape)) {
1928 $substitjs = array(
"'" =>
"\\'",
"\r" =>
'\\r');
1930 if (empty($noescapebackslashn)) {
1931 $substitjs[
"\n"] =
'\\n';
1932 $substitjs[
'\\'] =
'\\\\';
1935 $substitjs[
"'"] =
"\\'";
1936 $substitjs[
'"'] =
"\\'";
1937 } elseif ($mode == 1) {
1938 $substitjs[
"'"] =
"\\'";
1939 } elseif ($mode == 2) {
1940 $substitjs[
'"'] =
'\\"';
1941 } elseif ($mode == 3) {
1942 $substitjs[
"'"] =
"\\'";
1943 $substitjs[
'"'] =
"\\\"";
1945 return strtr($stringtoescape, $substitjs);
1959 return rawurlencode($stringtoescape);
1970 return str_replace(
'"',
'\"', $stringtoescape);
1982 if (is_null($stringtoescape)) {
1986 if ($stringforquotes == 2) {
1987 return str_replace(
'"',
"'", $stringtoescape);
1988 } elseif ($stringforquotes == 1) {
1994 $stringtoescape = str_replace(
'\\',
'', $stringtoescape);
1995 return str_replace(
"'",
"\'", str_replace(
'"',
"'", $stringtoescape));
1998 return 'Bad parameter for stringforquotes in dol_escape_php';
2009 return preg_replace(
'/[^a-z0-9_]/i',
'', $stringtoescape);
2020 return $stringtoescape;
2075 $allowedtags = array(
'br',
'b',
'font',
'hr',
'span');
2076 if (!empty($allowothertags) && is_array($allowothertags)) {
2077 $allowedtags = array_merge($allowedtags, $allowothertags);
2081 if ($escapeonlyhtmltags) {
2082 return dol_escape_htmltag(
dol_string_onlythesehtmltags($s, 1, 0, 0, 0, $allowedtags), 1, -1,
'', 1, 1);
2084 return dol_escape_htmltag(
dol_string_onlythesehtmltags(
dol_htmlentitiesbr($s), 1, 0, 0, 0, $allowedtags), 1, -1,
'', 0, 1);
2100 $escapeonlyhtmltags = 1;
2101 return dol_escape_htmltag(
dol_string_onlythesehtmltags($s, 1, 1, 1, 0, array()), 0, 0,
'', $escapeonlyhtmltags, 1);
2126 return htmlspecialchars($s, ENT_COMPAT,
'UTF-8');
2146function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags =
'', $escapeonlyhtmltags = 0, $cleanalsojavascript = 0)
2148 if ($noescapetags ==
'common') {
2149 $noescapetags =
'html,body,a,b,em,hr,i,u,ul,ol,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody,h1,h2,h3,h4,h5,h6,h7,h8,h9';
2151 $noescapetags .=
',header,footer,nav,section,menu,menuitem';
2153 if ($cleanalsojavascript) {
2158 if ($escapeonlyhtmltags) {
2159 $tmp = htmlspecialchars_decode((
string) $stringtoescape, ENT_COMPAT);
2166 $tmp = (string) $stringtoescape;
2169 $tmp = str_ireplace(
'<',
'__DONOTDECODELT', $tmp);
2170 $tmp = str_ireplace(
'>',
'__DONOTDECODEGT', $tmp);
2171 $tmp = str_ireplace(
'&',
'__DONOTDECODEAMP', $tmp);
2172 $tmp = str_ireplace(
'"',
'__DONOTDECODEQUOT', $tmp);
2173 $tmp = str_ireplace(
'&apos',
'__DONOTDECODEAPOS', $tmp);
2174 $tmp = str_ireplace(
''',
'__DONOTDECODE39', $tmp);
2176 $tmp = html_entity_decode((
string) $tmp, ENT_COMPAT,
'UTF-8');
2179 $tmp = str_ireplace(
'__DONOTDECODELT',
'<', $tmp);
2180 $tmp = str_ireplace(
'__DONOTDECODEGT',
'>', $tmp);
2181 $tmp = str_ireplace(
'__DONOTDECODEAMP',
'&', $tmp);
2182 $tmp = str_ireplace(
'__DONOTDECODEQUOT',
'"', $tmp);
2183 $tmp = str_ireplace(
'__DONOTDECODEAPOS',
'&apos', $tmp);
2184 $tmp = str_ireplace(
'__DONOTDECODE39',
''', $tmp);
2186 $tmp = str_ireplace(
''',
'__SIMPLEQUOTE__', $tmp);
2189 $tmp = strtr($tmp, array(
"<b>" =>
'',
'</b>' =>
'',
'<strong>' =>
'',
'</strong>' =>
''));
2192 $tmp = strtr($tmp, array(
"\r" =>
'\\r',
"\n" =>
'\\n'));
2193 } elseif ($keepn == -1) {
2194 $tmp = strtr($tmp, array(
"\r" =>
'',
"\n" =>
''));
2197 if ($escapeonlyhtmltags) {
2198 $tmp = htmlspecialchars($tmp, ENT_COMPAT,
'UTF-8');
2202 $tmparrayoftags = array();
2203 if ($noescapetags) {
2204 $tmparrayoftags = explode(
',', $noescapetags);
2207 if (count($tmparrayoftags)) {
2212 $tmp = str_ireplace(array(
'__DOUBLEQUOTE',
'__BEGINTAGTOREPLACE',
'__ENDTAGTOREPLACE',
'__BEGINENDTAGTOREPLACE'),
'', $tmp);
2214 foreach ($tmparrayoftags as $tagtoreplace) {
2216 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'>/',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2217 $tmp = str_ireplace(
'</'.$tagtoreplace.
'>',
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2218 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
' \/>/',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2224 if (preg_match(
'/<'.preg_quote($tagtoreplace,
'/').
'(\s+)([^>]+)>/', $tmp, $reg)) {
2226 $tmpattributes = str_ireplace(array(
'[',
']'),
'_', $reg[2]);
2227 $tmpattributes = str_ireplace(
'"',
'__DOUBLEQUOTE__', $tmpattributes);
2228 $tmpattributes = preg_replace(
'/[^a-z0-9_%,\/\?\;\s=&\.\-@:\.#\+]/i',
'', $tmpattributes);
2230 $tmp = str_replace(
'<'.$tagtoreplace.$reg[1].$reg[2].
'>',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'['.$tmpattributes.
']__', $tmp);
2233 $diff = strcmp($tmpold, $tmp);
2237 $tmp = str_ireplace(
'"',
'__DOUBLEQUOTENOSEMICOLON__', $tmp);
2238 $tmp = str_ireplace(
'<',
'__LESSTHAN__', $tmp);
2239 $tmp = str_ireplace(
'>',
'__GREATERTHAN__', $tmp);
2243 $result = htmlentities($tmp, ENT_COMPAT,
'UTF-8');
2247 if (count($tmparrayoftags)) {
2249 foreach ($tmparrayoftags as $tagtoreplace) {
2250 $result = str_ireplace(
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
'>', $result);
2251 $result = preg_replace(
'/__BEGINTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1>', $result);
2252 $result = str_ireplace(
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__',
'</'.$tagtoreplace.
'>', $result);
2253 $result = str_ireplace(
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
' />', $result);
2254 $result = preg_replace(
'/__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1 />', $result);
2257 $result = str_ireplace(
'__DOUBLEQUOTE__',
'"', $result);
2259 $result = str_ireplace(
'__DOUBLEQUOTENOSEMICOLON__',
'"', $result);
2260 $result = str_ireplace(
'__LESSTHAN__',
'<', $result);
2261 $result = str_ireplace(
'__GREATERTHAN__',
'>', $result);
2264 $result = str_ireplace(
'__SIMPLEQUOTE__',
''', $result);
2281 if (function_exists(
'mb_strtolower')) {
2282 return mb_strtolower($string, $encoding);
2284 return strtolower($string);
2298 if (function_exists(
'mb_strtoupper')) {
2299 return mb_strtoupper($string, $encoding);
2301 return strtoupper($string);
2315 if (function_exists(
'mb_substr')) {
2316 return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1,
null, $encoding);
2318 return ucfirst($string);
2332 if (function_exists(
'mb_convert_case')) {
2333 return mb_convert_case($string, MB_CASE_TITLE, $encoding);
2335 return ucwords($string);
2347 $backtrace = debug_backtrace();
2349 if (count($backtrace) >= 1) {
2351 if (count($backtrace) == 1) {
2354 $trace = $backtrace[$pos];
2355 if (isset($trace[
'file'], $trace[
'line'])) {
2356 $msg =
" From {$trace['file']}:{$trace['line']}.";
2384function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
'', $restricttologhandler =
'', $logcontext =
null)
2386 global
$conf, $user, $debugbar;
2389 if (!isModEnabled(
'syslog')) {
2394 if (defined(
'USEEXTERNALSERVER') && !defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
2395 global $website, $websitekey;
2396 if (is_object($website) && !empty($website->ref)) {
2397 $suffixinfilename .=
'_website_'.$website->ref;
2398 } elseif (!empty($websitekey)) {
2399 $suffixinfilename .=
'_website_'.$websitekey;
2404 if (defined(
'USESUFFIXINLOG')) {
2405 $suffixinfilename .= constant(
'USESUFFIXINLOG');
2409 foreach (
$conf->loghandlers as $loghandlerinstance) {
2410 $loghandlerinstance->setIdent($ident);
2414 if (!empty($message)) {
2417 $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');
2419 if (!array_key_exists($level, $logLevels)) {
2420 dol_syslog(
'Error Bad Log Level '.$level, LOG_ERR);
2421 $level = $logLevels[LOG_ERR];
2428 $message = preg_replace(
'/password=\'[^\']*\'/',
'password=\'hidden\'', $message);
2432 if ((!empty($_REQUEST[
'logtohtml']) &&
getDolGlobalString(
'MAIN_ENABLE_LOG_TO_HTML'))
2433 || (is_object($user) && $user->hasRight(
'debugbar',
'read') && is_object($debugbar))) {
2434 $ospid = sprintf(
"%7s",
dol_trunc((
string) getmypid(), 7,
'right',
'UTF-8', 1));
2435 $osuser =
" ".sprintf(
"%6s",
dol_trunc(function_exists(
'posix_getuid') ? posix_getuid() :
'', 6,
'right',
'UTF-8', 1));
2437 $conf->logbuffer[] =
dol_print_date(time(),
"%Y-%m-%d %H:%M:%S").
" ".sprintf(
"%-7s", $logLevels[$level]).
" ".$ospid.
" ".$osuser.
" ".$message;
2443 print
"\n\n<!-- Log start\n";
2445 print
"Log end -->\n";
2449 'message' => $message,
2450 'script' => (isset($_SERVER[
'PHP_SELF']) ? basename($_SERVER[
'PHP_SELF'],
'.php') : false),
2452 'user' => ((is_object($user) && $user->id) ? $user->login : false),
2454 'osuser' => function_exists(
'posix_getuid') ? posix_getuid() : false,
2455 'ospid' => getmypid()
2460 if (!empty($remoteip)) {
2461 $data[
'ip'] = $remoteip;
2465 if (!empty($_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
2466 $tmpips = explode(
',', $_SERVER[
'HTTP_X_FORWARDED_FOR']);
2470 foreach ($tmpips as $tmpip) {
2471 $tmpip = trim($tmpip);
2472 if (strtolower($tmpip) == strtolower($remoteip)) {
2475 if (empty($data[
'ip'])) {
2476 $data[
'ip'] = $tmpip;
2479 $data[
'ip'] .= (($j == 1) ?
' [via ' :
',').$tmpip;
2482 if (!$foundremoteip) {
2484 $data[
'ip'] .= (($j == 1) ?
' [via ' :
',').$remoteip;
2486 $data[
'ip'] .= (($j > 0) ?
']' :
'');
2487 } elseif (!empty($_SERVER[
'HTTP_CLIENT_IP']) ) {
2488 $tmpips = explode(
',', $_SERVER[
'HTTP_CLIENT_IP']);
2492 foreach ($tmpips as $tmpip) {
2493 $tmpip = trim($tmpip);
2494 if (strtolower($tmpip) == strtolower($remoteip)) {
2497 if (empty($data[
'ip'])) {
2498 $data[
'ip'] = $tmpip;
2501 $data[
'ip'] .= (($j == 1) ?
' [via ' :
',').$tmpip;
2504 if (!$foundremoteip) {
2506 $data[
'ip'] .= (($j == 1) ?
' [via ' :
',').$remoteip;
2508 $data[
'ip'] .= (($j > 0) ?
']' :
'');
2510 } elseif (!empty($_SERVER[
'SERVER_ADDR'])) {
2512 $data[
'ip'] = $_SERVER[
'SERVER_ADDR'];
2513 } elseif (!empty($_SERVER[
'COMPUTERNAME'])) {
2515 $data[
'ip'] = $_SERVER[
'COMPUTERNAME'];
2517 $data[
'ip'] =
'???';
2520 if (!empty($_SERVER[
'USERNAME'])) {
2522 $data[
'osuser'] = $_SERVER[
'USERNAME'];
2523 } elseif (!empty($_SERVER[
'LOGNAME'])) {
2525 $data[
'osuser'] = $_SERVER[
'LOGNAME'];
2529 foreach (
$conf->loghandlers as $loghandlerinstance) {
2530 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
2533 $loghandlerinstance->export($data, $suffixinfilename);
2539 foreach (
$conf->loghandlers as $loghandlerinstance) {
2540 $loghandlerinstance->setIdent($ident);
2560 $form =
new Form($db);
2562 $templatenameforexport = $website->name_template;
2563 if (empty($templatenameforexport)) {
2564 $templatenameforexport =
'website_'.$website->ref;
2568 $out .=
'<input type="button" class="cursorpointer button bordertransp" id="open-dialog-' . $name .
'" value="'.dol_escape_htmltag($buttonstring).
'"/>';
2571 $out .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">';
2572 $out .=
'jQuery(document).ready(function () {';
2573 $out .=
' jQuery("#open-dialog-' . $name .
'").click(function () {';
2574 $out .=
' var dialogHtml = \'';
2576 $dialogcontent =
' <div id="custom-dialog-' . $name .
'">';
2577 $dialogcontent .=
' <div style="margin-top: 20px;">';
2578 $dialogcontent .=
' <label for="export-site-' . $name .
'"><strong>'.$langs->trans(
"ExportSiteLabel").
'...</label><br>';
2579 $dialogcontent .=
' <button class="button smallpaddingimp" id="export-site-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"DownloadZip")) .
'</button>';
2580 $dialogcontent .=
' </div>';
2581 $dialogcontent .=
' <br>';
2582 $dialogcontent .=
' <div style="margin-top: 20px;">';
2583 $dialogcontent .=
' <strong>'.$langs->trans(
"ExportSiteGitLabel").
' '.$form->textwithpicto(
'', $langs->trans(
"SourceFiles"), 1,
'help',
'', 0, 3,
'').
'</strong><br>';
2584 $dialogcontent .=
' <form action="'.dol_escape_htmltag($overwriteGitUrl).
'" method="POST">';
2585 $dialogcontent .=
' <input type="hidden" name="action" value="overwritesite">';
2586 $dialogcontent .=
' <input type="hidden" name="token" value="'.newToken().
'">';
2587 $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>';
2588 $dialogcontent .=
' <button type="submit" class="button smallpaddingimp" id="overwrite-git-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"ExportIntoGIT")) .
'</button>';
2589 $dialogcontent .=
' </form>';
2590 $dialogcontent .=
' </div>';
2591 $dialogcontent .=
' </div>';
2598 // Add the content of the dialog to the body of the page
2599 $out .= ' var $dialog = jQuery(
"#custom-dialog-' . $name . '");
';
2600 $out .= ' if ($dialog.length > 0) {
2603 jQuery(
"body").append(dialogHtml);
';
2605 // Configuration of popup
2606 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog({
';
2607 $out .= ' autoOpen:
false,
';
2608 $out .= ' modal:
true,
';
2609 $out .= ' height: 290,
';
2610 $out .= ' width:
"40%",
';
2611 $out .= ' title:
"' . dol_escape_js($label) . '",
';
2614 // Simulate a click on the original "submit" input to export the site.
2615 $out .= ' jQuery(
"#export-site-' . $name . '").click(
function () {
';
2616 $out .= ' console.log(
"Clic on exportsite.");
';
2617 $out .= ' var target = jQuery(
"input[name=\'' . dol_escape_js($exportSiteName) . '\']");
';
2618 $out .= ' console.log(
"element founded:", target.length > 0);
';
2619 $out .= ' if (target.length > 0) { target.click(); }
';
2620 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"close");
';
2624 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"open");
';
2625 $out .= ' return false;
';
2628 $out .= '</script>
';
2650function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '
', $morecss = 'classlink
button bordertransp
', $jsonopen = '', $backtopagejsfields = '', $accesskey = '')
2654 if (strpos($url, '?
') > 0) {
2655 $url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2657 $url .= '?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2662 $backtopagejsfieldsid = '';
2663 $backtopagejsfieldslabel = '';
2664 if ($backtopagejsfields) {
2665 $tmpbacktopagejsfields = explode(':
', $backtopagejsfields);
2666 if (empty($tmpbacktopagejsfields[1])) { // If the part 'keyforpopupid:
' is missing, we add $name for it.
2667 $backtopagejsfields = $name.":".$backtopagejsfields;
2668 $tmp2backtopagejsfields = explode(',
', $tmpbacktopagejsfields[0]);
2670 $tmp2backtopagejsfields = explode(',
', $tmpbacktopagejsfields[1]);
2672 $backtopagejsfieldsid = empty($tmp2backtopagejsfields[0]) ? '' : $tmp2backtopagejsfields[0];
2673 $backtopagejsfieldslabel = empty($tmp2backtopagejsfields[1]) ? '' : $tmp2backtopagejsfields[1];
2674 $url .= '&backtopagejsfields=
'.urlencode($backtopagejsfields);
2677 //print '<input
type=
"submit" class=
"button bordertransp"'.$disabled.' value=
"'.dol_escape_htmltag($langs->trans("MediaFiles
")).'" name=
"file_manager">
';
2678 $out .= '<!-- a link
for button to open url into a dialog popup with backtopagejsfields =
'.$backtopagejsfields.' -->
';
2679 $out .= '<a
'.($accesskey ? ' accesskey=
"'.$accesskey.'"' : '').' class=
"cursorpointer reposition button_'.$name.($morecss ? ' '.$morecss : '').'"'.$disabled.' title=
"'.dol_escape_htmltag($label).'"';
2680 if (empty($conf->use_javascript_ajax)) {
2681 $out .= ' href=
"'.DOL_URL_ROOT.$url.'" target=
"_blank"';
2682 } elseif ($jsonopen) {
2683 $out .= ' href=
"#" onclick=
"'.$jsonopen.'"';
2685 $out .= ' href=
"#"';
2687 $out .= '>
'.$buttonstring.'</a>
';
2689 if (!empty($conf->use_javascript_ajax)) {
2690 // Add code to open url using the popup. Add also hidden field to retrieve the returned variables
2691 $out .= '<!-- code to open popup and variables to retrieve returned variables -->
';
2692 $out .= '<div
id=
"idfordialog'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for dialog
' : '').'</div>
';
2693 $out .= '<div
id=
"varforreturndialogid'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for returned
id' : '').'</div>
';
2694 $out .= '<div
id=
"varforreturndialoglabel'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for returned label
' : '').'</div>
';
2696 $out .= '<!-- Add js code to open dialog popup on dialog -->
';
2697 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript">
2698 jQuery(document).ready(
function () {
2699 jQuery(
".button_'.$name.'").click(
function () {
2700 console.log(\
'Open popup with jQuery(...).dialog() on URL '.
dol_escape_js(DOL_URL_ROOT.$url).
'\');
2701 var $tmpdialog = $(\
'#idfordialog'.$name.
'\');
2702 $tmpdialog.html(\
'<iframe class="iframedialog" id="iframedialog'.$name.
'" style="border: 0px;" src="'.DOL_URL_ROOT.$url.
'" width="100%" height="98%"></iframe>\');
2706 height: (window.innerHeight - 150),
2709 open: function (event, ui) {
2710 console.log(
"open popup name='.$name.', backtopagejsfields='.$backtopagejsfields.'");
2712 close:
function (event, ui) {
2713 var returnedid = jQuery(
"#varforreturndialogid'.$name.'").text();
2714 var returnedlabel = jQuery(
"#varforreturndialoglabel'.$name.'").text();
2715 console.log(
"popup has been closed. returnedid (js var defined into parent page)="+returnedid+
" returnedlabel="+returnedlabel);
2716 if (returnedid !=
"" && returnedid !=
"div for returned id") {
2717 jQuery(
"#'.(empty($backtopagejsfieldsid) ? "none
" : $backtopagejsfieldsid).'").val(returnedid);
2719 if (returnedlabel !=
"" && returnedlabel !=
"div for returned label") {
2720 jQuery(
"#'.(empty($backtopagejsfieldslabel) ? "none
" : $backtopagejsfieldslabel).'").val(returnedlabel);
2725 $tmpdialog.dialog(\
'open\');
2750function dol_fiche_head($links = array(), $active =
'0', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
2752 print
dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow, $moretabssuffix);
2771function dol_get_fiche_head($links = array(), $active =
'', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'', $dragdropfile = 0)
2773 global
$conf, $langs, $hookmanager;
2777 if (!empty(
$conf->dol_optimize_smallscreen)) {
2781 $out =
"\n".
'<!-- dol_fiche_head - dol_get_fiche_head -->';
2783 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2784 $out .=
'<div class="tabs'.($picto ?
'' :
' nopaddingleft').
'" data-role="controlgroup" data-type="horizontal">'.
"\n";
2788 if ($morehtmlright) {
2789 $out .=
'<div class="inline-block floatright tabsElem">'.$morehtmlright.
'</div>';
2796 if (is_array($links) && !empty($links)) {
2797 $keys = array_keys($links);
2799 $maxkey = max($keys);
2805 if (empty($limittoshow)) {
2808 if (!empty(
$conf->dol_optimize_smallscreen)) {
2816 for ($i = 0; $i <= $maxkey; $i++) {
2817 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2819 if ($i >= $limittoshow) {
2825 for ($i = 0; $i <= $maxkey; $i++) {
2826 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2832 if ($i < $limittoshow || $isactive) {
2834 $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])).
' -->';
2836 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2837 if (!empty($links[$i][0])) {
2838 $out .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2840 $out .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2842 } elseif (!empty($links[$i][1])) {
2844 $out .=
'<div class="tab tab'.($isactive ?
'active' :
'unactive').
'" style="margin: 0 !important">';
2846 if (!empty($links[$i][0])) {
2847 $titletoshow = preg_replace(
'/<.*$/',
'', $links[$i][1]);
2848 $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).
'">';
2851 if ($displaytab == 0 && $picto) {
2852 $out .=
img_picto($title, $picto,
'', $pictoisfullpath, 0, 0,
'',
'imgTabTitle paddingright marginrightonlyshort');
2855 $out .= $links[$i][1];
2856 if (!empty($links[$i][0])) {
2857 $out .=
'</a>'.
"\n";
2859 $out .= empty($links[$i][4]) ?
'' : $links[$i][4];
2868 $outmore .=
'<div class="popuptabset wordwrap">';
2870 $outmore .=
'<div class="popuptab wordwrap" style="display:inherit;">';
2871 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2872 if (!empty($links[$i][0])) {
2873 $outmore .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2875 $outmore .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2877 } elseif (!empty($links[$i][1])) {
2878 $outmore .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="wordwrap inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
2879 $outmore .= preg_replace(
'/([a-z])\|([a-z])/i',
'\\1 | \\2', $links[$i][1]);
2880 $outmore .=
'</a>'.
"\n";
2882 $outmore .=
'</div>';
2887 $displaytab = $i + 1;
2890 $outmore .=
'</div>';
2894 $left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
2895 $right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
2896 $widthofpopup = 200;
2898 $tabsname = $moretabssuffix;
2899 if (empty($tabsname)) {
2900 $tabsname = str_replace(
"@",
"", $picto);
2902 $out .=
'<div id="moretabs'.$tabsname.
'" class="inline-block tabsElem valignmiddle">';
2904 $out .=
'<div class="tab valignmiddle"><a href="#" class="tab moretab inline-block tabunactive valignmiddle"><span class="hideonsmartphone">'.$langs->trans(
"More").
'</span>... ('.$nbintab.
')</a></div>';
2906 $out .=
'<div id="moretabsList'.$tabsname.
'" style="width: '.$widthofpopup.
'px; position: absolute; '.$left.
': -999em; text-align: '.$left.
'; margin:0px; padding:2px; z-index:10;">';
2909 $out .=
'<div></div>';
2912 $out .=
'<script nonce="'.getNonce().
'">';
2913 $out .=
"$('#moretabs".$tabsname.
"').mouseenter( function() {
2914 var x = this.offsetLeft, y = this.offsetTop;
2915 console.log('mouseenter ".$left.
" x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
2916 if ((window.innerWidth - x) < ".($widthofpopup + 10).
") {
2917 $('#moretabsList".$tabsname.
"').css('".$right.
"','8px');
2919 $('#moretabsList".$tabsname.
"').css('".$left.
"','auto');
2922 $out .=
"$('#moretabs".$tabsname.
"').mouseleave( function() { console.log('mouseleave ".$left.
"'); $('#moretabsList".$tabsname.
"').css('".$left.
"','-999em');});";
2923 $out .=
"</script>";
2926 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2930 if (!$notab || $notab == -1 || $notab == -2 || $notab == -3 || $notab == -4) {
2931 $out .=
"\n".
'<div id="dragDropAreaTabBar" class="tabBar'.($notab == -1 ?
'' : ($notab == -2 ?
' tabBarNoTop' : ((($notab == -3 || $notab == -4) ?
' noborderbottom' :
'').($notab == -4 ?
'' :
' tabBarWithBottom'))));
2934 if (!empty($dragdropfile)) {
2935 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2938 $parameters = array(
'tabname' => $active,
'out' => $out);
2939 $reshook = $hookmanager->executeHooks(
'printTabsHead', $parameters);
2941 $out = $hookmanager->resPrint;
2967 if (!$notab || $notab == -1) {
2968 return "\n</div>\n";
2993function dol_banner_tab(
$object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $onlybanner = 0, $morehtmlright =
'')
2995 global
$conf, $form, $user, $langs, $hookmanager, $action;
2999 $maxvisiblephotos = 1;
3003 $showbarcode = !isModEnabled(
'barcode') ? 0 : (empty(
$object->barcode) ? 0 : 1);
3004 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
3007 $modulepart =
'unknown';
3009 if (in_array(
$object->element, [
'societe',
'contact',
'product',
'ticket',
'bom'])) {
3010 $modulepart =
$object->element;
3011 } elseif (
$object->element ==
'member') {
3012 $modulepart =
'memberphoto';
3013 } elseif (
$object->element ==
'user') {
3014 $modulepart =
'userphoto';
3017 if (class_exists(
"Imagick")) {
3018 if (
$object->element ==
'expensereport' ||
$object->element ==
'propal' ||
$object->element ==
'commande' ||
$object->element ==
'facture' ||
$object->element ==
'supplier_proposal') {
3019 $modulepart =
$object->element;
3020 } elseif (
$object->element ==
'fichinter' ||
$object->element ==
'intervention') {
3021 $modulepart =
'ficheinter';
3022 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
3023 $modulepart =
'contract';
3024 } elseif (
$object->element ==
'order_supplier') {
3025 $modulepart =
'supplier_order';
3026 } elseif (
$object->element ==
'invoice_supplier') {
3027 $modulepart =
'supplier_invoice';
3031 if (
$object->element ==
'product') {
3033 '@phan-var-force Product $object';
3035 $cssclass =
'photowithmargin photoref';
3036 $showimage =
$object->is_photo_available(
$conf->product->multidir_output[$entity]);
3038 if (
$conf->browser->layout ==
'phone') {
3039 $maxvisiblephotos = 1;
3042 $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>';
3046 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
3048 $nophoto =
'/public/theme/common/nophoto.png';
3049 $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>';
3052 } elseif (
$object->element ==
'category') {
3054 '@phan-var-force Categorie $object';
3056 $cssclass =
'photowithmargin photoref';
3057 $showimage =
$object->isAnyPhotoAvailable(
$conf->categorie->multidir_output[$entity]);
3059 if (
$conf->browser->layout ==
'phone') {
3060 $maxvisiblephotos = 1;
3063 $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>';
3067 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
3069 $nophoto =
'/public/theme/common/nophoto.png';
3070 $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>';
3073 } elseif (
$object->element ==
'bom') {
3075 '@phan-var-force Bom $object';
3077 $cssclass =
'photowithmargin photoref';
3078 $showimage =
$object->is_photo_available(
$conf->bom->multidir_output[$entity]);
3080 if (
$conf->browser->layout ==
'phone') {
3081 $maxvisiblephotos = 1;
3084 $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>';
3088 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
3090 $nophoto =
'/public/theme/common/nophoto.png';
3091 $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>';
3094 } elseif (
$object->element ==
'ticket') {
3096 $cssclass =
'photoref';
3098 '@phan-var-force Ticket $object';
3099 $showimage =
$object->is_photo_available(
$conf->ticket->multidir_output[$entity].
'/'.
$object->ref);
3101 if (
$conf->browser->layout ==
'phone') {
3102 $maxvisiblephotos = 1;
3106 $showphoto =
$object->show_photos(
'ticket',
$conf->ticket->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0);
3108 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$showphoto.
'</div>';
3116 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
3118 $nophoto =
img_picto(
'No photo',
'object_ticket');
3119 $morehtmlleft .=
'<!-- No photo to show -->';
3120 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
3121 $morehtmlleft .= $nophoto;
3122 $morehtmlleft .=
'</div></div>';
3127 if ($modulepart !=
'unknown' || method_exists(
$object,
'getDataToShowPhoto')) {
3130 if (in_array($modulepart, array(
'propal',
'commande',
'facture',
'ficheinter',
'contract',
'supplier_order',
'supplier_proposal',
'supplier_invoice',
'expensereport')) && class_exists(
"Imagick")) {
3132 $dir_output = (empty(
$conf->$modulepart->multidir_output[$entity]) ?
$conf->$modulepart->dir_output :
$conf->$modulepart->multidir_output[$entity]).
"/";
3133 if (in_array($modulepart, array(
'invoice_supplier',
'supplier_invoice'))) {
3135 $subdir .= ((!empty($subdir) && !preg_match(
'/\/$/', $subdir)) ?
'/' :
'').$objectref;
3139 if (empty($subdir)) {
3140 $subdir =
'errorgettingsubdirofobject';
3143 $filepath = $dir_output.$subdir.
"/";
3145 $filepdf = $filepath.$objectref.
".pdf";
3146 $relativepath = $subdir.
'/'.$objectref.
'.pdf';
3149 $fileimage = $filepdf.
'_preview.png';
3150 $relativepathimage = $relativepath.
'_preview.png';
3152 $pdfexists = file_exists($filepdf);
3157 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
3159 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
3168 if ($pdfexists && !$error) {
3169 $heightforphotref = 80;
3170 if (!empty(
$conf->dol_optimize_smallscreen)) {
3171 $heightforphotref = 60;
3174 if (file_exists($fileimage)) {
3175 $phototoshow =
'<div class="photoref">';
3176 $phototoshow .=
'<img height="'.$heightforphotref.
'" class="photo photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
3177 $phototoshow .=
'</div>';
3180 } elseif (!$phototoshow) {
3181 $phototoshow .= $form->showphoto($modulepart,
$object, 0, 0, 0,
'photowithmargin photoref',
'small', 1, 0, $maxvisiblephotos);
3185 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
3186 $morehtmlleft .= $phototoshow;
3187 $morehtmlleft .=
'</div>';
3191 if (empty($phototoshow)) {
3192 if (
$object->element ==
'action') {
3194 $cssclass =
'photorefcenter';
3195 $nophoto =
img_picto(
'No photo',
'title_agenda');
3198 $cssclass =
'photorefcenter';
3200 $prefix =
'object_';
3204 if (strpos($picto,
'fontawesome_') !==
false) {
3207 $nophoto =
img_picto(
'No photo', $prefix.$picto);
3209 $morehtmlleft .=
'<!-- No photo to show -->';
3210 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
3211 $morehtmlleft .= $nophoto;
3212 $morehtmlleft .=
'</div></div>';
3219 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode(
$object, 100,
'photoref valignmiddle').
'</div>';
3222 if (
$object->element ==
'societe') {
3223 if (!empty(
$conf->use_javascript_ajax) && $user->hasRight(
'societe',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3226 $morehtmlstatus .=
$object->getLibStatut(6);
3228 } elseif (
$object->element ==
'product') {
3230 if (!empty(
$conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3231 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
3233 $morehtmlstatus .=
'<span class="statusrefsell">'.$object->getLibStatut(6, 0).
'</span>';
3235 $morehtmlstatus .=
' ';
3237 if (!empty(
$conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
3238 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
3240 $morehtmlstatus .=
'<span class="statusrefbuy">'.$object->getLibStatut(6, 1).
'</span>';
3242 } elseif (in_array(
$object->element, array(
'salary'))) {
3244 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3247 $morehtmlstatus .= $tmptxt;
3248 } elseif (in_array(
$object->element, array(
'facture',
'invoice',
'invoice_supplier'))) {
3249 $totalallpayments =
$object->getSommePaiement(0);
3250 $totalallpayments +=
$object->getSumCreditNotesUsed(0);
3251 $totalallpayments +=
$object->getSumDepositsUsed(0);
3252 $tmptxt =
$object->getLibStatut(6, $totalallpayments);
3253 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3254 $tmptxt =
$object->getLibStatut(5, $totalallpayments);
3256 $morehtmlstatus .= $tmptxt;
3257 } elseif (in_array(
$object->element, array(
'chargesociales',
'loan',
'tva'))) {
3259 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3262 $morehtmlstatus .= $tmptxt;
3263 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
3265 $morehtmlstatus .=
$object->getLibStatut(5);
3267 $morehtmlstatus .=
$object->getLibStatut(4);
3269 } elseif (
$object->element ==
'facturerec') {
3270 '@phan-var-force FactureRec $object';
3271 if (
$object->frequency == 0) {
3272 $morehtmlstatus .=
$object->getLibStatut(2);
3274 $morehtmlstatus .=
$object->getLibStatut(5);
3276 } elseif (
$object->element ==
'project_task') {
3283 if (
$object->progress >= 100) {
3287 $tmptxt =
$object->getLibStatut(5);
3288 $morehtmlstatus .= $tmptxt;
3289 } elseif (method_exists(
$object,
'getLibStatut')) {
3290 $tmptxt =
$object->getLibStatut(6);
3291 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3292 $tmptxt =
$object->getLibStatut(5);
3294 $morehtmlstatus .= $tmptxt;
3298 if (isModEnabled(
'accounting') && in_array(
$object->element, array(
'bank',
'paiementcharge',
'facture',
'invoice',
'invoice_supplier',
'expensereport',
'payment_various'))) {
3300 if (method_exists(
$object,
'getVentilExportCompta')) {
3301 $accounted =
$object->getVentilExportCompta();
3302 $langs->load(
"accountancy");
3303 $morehtmlstatus .=
'</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? $langs->trans(
"Accounted") : $langs->trans(
"NotYetAccounted")).
'</span>';
3308 if (!empty(
$object->name_alias)) {
3309 '@phan-var-force Societe $object';
3310 $morehtmlref .=
'<div class="refidno opacitymedium">'.dol_escape_htmltag(
$object->name_alias).
'</div>';
3314 if (in_array(
$object->element, array(
'product',
'bank_account',
'project_task'))) {
3316 $morehtmlref .=
'<div class="refidno opacitymedium">'.$object->label.
'</div>';
3320 if (method_exists(
$object,
'getBannerAddress') && !in_array(
$object->element, array(
'product',
'bookmark',
'ecm_directories',
'ecm_files'))) {
3323 $morehtmlref .=
'<div class="refidno refaddress">';
3324 $morehtmlref .= $moreaddress;
3325 $morehtmlref .=
'</div>';
3329 $morehtmlref .=
'<div style="clear: both;"></div>';
3330 $morehtmlref .=
'<div class="refidno opacitymedium">';
3331 $morehtmlref .= $langs->trans(
"TechnicalID").
': '.((int)
$object->id);
3332 $morehtmlref .=
'</div>';
3335 $parameters = array(
'morehtmlref' => &$morehtmlref,
'moreparam' => &$moreparam,
'morehtmlleft' => &$morehtmlleft,
'morehtmlstatus' => &$morehtmlstatus,
'morehtmlright' => &$morehtmlright);
3336 $reshook = $hookmanager->executeHooks(
'formDolBanner', $parameters,
$object, $action);
3339 } elseif (empty($reshook)) {
3340 $morehtmlref .= $hookmanager->resPrint;
3341 } elseif ($reshook > 0) {
3342 $morehtmlref = $hookmanager->resPrint;
3350 print
'<div class="'.($onlybanner ?
'arearefnobottom ' :
'arearef ').
'heightref valignmiddle centpercent">';
3351 print $form->showrefnav(
$object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
3353 print
'<div class="underrefbanner clearboth"></div>';
3365function fieldLabel($langkey, $fieldkey, $fieldrequired = 0)
3369 if ($fieldrequired) {
3370 $ret .=
'<span class="fieldrequired">';
3372 $ret .=
'<label for="'.$fieldkey.
'">';
3373 $ret .= $langs->trans($langkey);
3375 if ($fieldrequired) {
3396 global $langs, $hookmanager;
3399 $countriesusingstate = array(
'AU',
'CA',
'US',
'IN',
'GB',
'ES',
'UK',
'TR',
'CN');
3404 $ret .= ($extralangcode ?
$object->array_languages[
'address'][$extralangcode] : (empty(
$object->address) ?
'' : preg_replace(
'/(\r\n|\r|\n)+/', $sep,
$object->address)));
3407 if (isset(
$object->country_code) && in_array(
$object->country_code, array(
'AU',
'CA',
'US',
'CN')) ||
getDolGlobalString(
'MAIN_FORCE_STATE_INTO_ADDRESS')) {
3409 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3410 $ret .= (($ret && $town) ? $sep :
'').$town;
3413 $ret .= ($ret ? ($town ?
", " : $sep) :
'').
$object->state;
3416 $ret .= ($ret ? (($town ||
$object->state) ?
", " : $sep) :
'').
$object->zip;
3418 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'GB',
'UK'))) {
3420 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3421 $ret .= ($ret ? $sep :
'').$town;
3423 $ret .= ($ret ?
", " :
'').
$object->state;
3426 $ret .= ($ret ? $sep :
'').
$object->zip;
3428 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'ES',
'TR'))) {
3430 $ret .= ($ret ? $sep :
'').
$object->zip;
3431 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3432 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3434 $ret .= $sep.$object->state;
3436 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'JP'))) {
3439 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3441 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'IT'))) {
3443 $ret .= ($ret ? $sep :
'').
$object->zip;
3444 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3445 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3446 $ret .= (empty(
$object->state_code) ?
'' : (
' '.$object->state_code));
3449 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3450 $ret .= !empty(
$object->zip) ? (($ret ? $sep :
'').
$object->zip) :
'';
3451 $ret .= ($town ? ((
$object->zip ?
' ' : ($ret ? $sep :
'')).$town) :
'');
3452 if (!empty(
$object->state) && in_array(
$object->country_code, $countriesusingstate)) {
3453 $ret .= ($ret ?
", " :
'').
$object->state;
3457 if (!is_object($outputlangs)) {
3458 $outputlangs = $langs;
3461 $langs->load(
"dict");
3462 $ret .= (empty(
$object->country_code) ?
'' : ($ret ? $sep :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$object->country_code)));
3465 $parameters = array(
'withcountry' => $withcountry,
'sep' => $sep,
'outputlangs' => $outputlangs,
'mode' => $mode,
'extralangcode' => $extralangcode);
3466 $reshook = $hookmanager->executeHooks(
'formatAddress', $parameters,
$object);
3470 $ret .= $hookmanager->resPrint;
3487function dol_strftime($fmt, $ts =
false, $is_gmt =
false)
3489 if ((abs($ts) <= 0x7FFFFFFF)) {
3492 return 'Error date outside supported range';
3517function dol_print_date($time, $format =
'', $tzoutput =
'auto', $outputlangs =
null, $encodetooutput =
false)
3519 global
$conf, $langs;
3526 if ($tzoutput ===
'auto') {
3527 $tzoutput = (empty(
$conf) ?
'tzserver' : (isset(
$conf->tzuserinputkey) ?
$conf->tzuserinputkey :
'tzserver'));
3532 $offsettz = $offsetdst = 0;
3535 if (is_string($tzoutput)) {
3536 if ($tzoutput ==
'tzserver') {
3538 $offsettzstring = @date_default_timezone_get();
3543 } elseif ($tzoutput ==
'tzuser' || $tzoutput ==
'tzuserrel') {
3545 $offsettzstring = (empty($_SESSION[
'dol_tz_string']) ?
'UTC' : $_SESSION[
'dol_tz_string']);
3547 if (class_exists(
'DateTimeZone')) {
3548 $user_date_tz =
new DateTimeZone($offsettzstring);
3549 $user_dt =
new DateTime();
3550 $user_dt->setTimezone($user_date_tz);
3551 $user_dt->setTimestamp($tzoutput ==
'tzuser' ?
dol_now() : (int) $time);
3552 $offsettz = $user_dt->getOffset();
3554 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3555 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3560 if (!is_object($outputlangs)) {
3561 $outputlangs = $langs;
3564 $format =
'daytextshort';
3569 $reduceformat = (!empty(
$conf->dol_optimize_smallscreen) && in_array($format, array(
'day',
'dayhour',
'dayhoursec'))) ? 1 : 0;
3570 $format = preg_replace(
'/inputnoreduce/',
'', $format);
3571 $formatwithoutreduce = preg_replace(
'/reduceformat/',
'', $format);
3572 if ($formatwithoutreduce != $format) {
3573 $format = $formatwithoutreduce;
3579 if ($format ==
'day') {
3580 $format = ($outputlangs->trans(
"FormatDateShort") !=
"FormatDateShort" ? $outputlangs->trans(
"FormatDateShort") :
$conf->format_date_short);
3581 } elseif ($format ==
'hour') {
3582 $format = ($outputlangs->trans(
"FormatHourShort") !=
"FormatHourShort" ? $outputlangs->trans(
"FormatHourShort") :
$conf->format_hour_short);
3583 } elseif ($format ==
'hourduration') {
3584 $format = ($outputlangs->trans(
"FormatHourShortDuration") !=
"FormatHourShortDuration" ? $outputlangs->trans(
"FormatHourShortDuration") :
$conf->format_hour_short_duration);
3585 } elseif ($format ==
'daytext') {
3586 $format = ($outputlangs->trans(
"FormatDateText") !=
"FormatDateText" ? $outputlangs->trans(
"FormatDateText") :
$conf->format_date_text);
3587 } elseif ($format ==
'daytextshort') {
3588 $format = ($outputlangs->trans(
"FormatDateTextShort") !=
"FormatDateTextShort" ? $outputlangs->trans(
"FormatDateTextShort") :
$conf->format_date_text_short);
3589 } elseif ($format ==
'dayhour') {
3590 $format = ($outputlangs->trans(
"FormatDateHourShort") !=
"FormatDateHourShort" ? $outputlangs->trans(
"FormatDateHourShort") :
$conf->format_date_hour_short);
3591 } elseif ($format ==
'dayhoursec') {
3592 $format = ($outputlangs->trans(
"FormatDateHourSecShort") !=
"FormatDateHourSecShort" ? $outputlangs->trans(
"FormatDateHourSecShort") :
$conf->format_date_hour_sec_short);
3593 } elseif ($format ==
'dayhourtext') {
3594 $format = ($outputlangs->trans(
"FormatDateHourText") !=
"FormatDateHourText" ? $outputlangs->trans(
"FormatDateHourText") :
$conf->format_date_hour_text);
3595 } elseif ($format ==
'dayhourtextshort') {
3596 $format = ($outputlangs->trans(
"FormatDateHourTextShort") !=
"FormatDateHourTextShort" ? $outputlangs->trans(
"FormatDateHourTextShort") :
$conf->format_date_hour_text_short);
3597 } elseif ($format ==
'dayhourlog') {
3599 $format =
'%Y%m%d%H%M%S';
3600 } elseif ($format ==
'dayhourlogsmall') {
3602 $format =
'%y%m%d%H%M';
3603 } elseif ($format ==
'dayhourldap') {
3604 $format =
'%Y%m%d%H%M%SZ';
3605 } elseif ($format ==
'dayhourxcard') {
3606 $format =
'%Y%m%dT%H%M%SZ';
3607 } elseif ($format ==
'dayxcard') {
3609 } elseif ($format ==
'dayrfc') {
3610 $format =
'%Y-%m-%d';
3611 } elseif ($format ==
'dayhourrfc') {
3612 $format =
'%Y-%m-%dT%H:%M:%SZ';
3613 } elseif ($format ==
'standard') {
3614 $format =
'%Y-%m-%d %H:%M:%S';
3617 if ($reduceformat) {
3618 $format = str_replace(
'%Y',
'%y', $format);
3619 $format = str_replace(
'yyyy',
'yy', $format);
3623 if (preg_match(
'/%b/i', $format)) {
3625 $format = str_replace(
'%b',
'__b__', $format);
3626 $format = str_replace(
'%B',
'__B__', $format);
3628 if (preg_match(
'/%a/i', $format)) {
3630 $format = str_replace(
'%a',
'__a__', $format);
3631 $format = str_replace(
'%A',
'__A__', $format);
3636 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)) {
3637 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"]));
3639 } elseif (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', (
string) $time, $reg)) {
3641 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);
3644 $syear = (!empty($reg[1]) ? $reg[1] :
'');
3645 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
3646 $sday = (!empty($reg[3]) ? $reg[3] :
'');
3647 $shour = (!empty($reg[4]) ? $reg[4] :
'');
3648 $smin = (!empty($reg[5]) ? $reg[5] :
'');
3649 $ssec = (!empty($reg[6]) ? $reg[6] :
'');
3651 $time =
dol_mktime((
int) $shour, (
int) $smin, (
int) $ssec, (
int) $smonth, (
int) $sday, (
int) $syear,
true);
3654 $tzo =
new DateTimeZone(
'UTC');
3656 $tzo =
new DateTimeZone(date_default_timezone_get());
3658 $dtts =
new DateTime();
3659 $dtts->setTimestamp($time);
3660 $dtts->setTimezone($tzo);
3661 $newformat = str_replace(
3662 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3663 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3666 $ret = $dtts->format($newformat);
3668 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3669 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3674 if ($time < 100000000000) {
3675 $timetouse = $time + $offsettz + $offsetdst;
3678 $tzo =
new DateTimeZone(
'UTC');
3680 $tzo =
new DateTimeZone(date_default_timezone_get());
3682 $dtts =
new DateTime();
3683 $dtts->setTimestamp($timetouse);
3684 $dtts->setTimezone($tzo);
3685 $newformat = str_replace(
3686 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'%w',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3687 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'w',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3690 $ret = $dtts->format($newformat);
3692 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3693 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3698 $ret =
'Bad value '.$time.
' for date';
3702 if (preg_match(
'/__b__/i', $format)) {
3703 $timetouse = $time + $offsettz + $offsetdst;
3706 $tzo =
new DateTimeZone(
'UTC');
3708 $tzo =
new DateTimeZone(date_default_timezone_get());
3710 $dtts =
new DateTime();
3711 $dtts->setTimestamp($timetouse);
3712 $dtts->setTimezone($tzo);
3713 $month = (int) $dtts->format(
"m");
3714 $month = sprintf(
"%02d", $month);
3715 if ($encodetooutput) {
3716 $monthtext = $outputlangs->transnoentities(
'Month'.$month);
3717 $monthtextshort = $outputlangs->transnoentities(
'MonthShort'.$month);
3719 $monthtext = $outputlangs->transnoentitiesnoconv(
'Month'.$month);
3720 $monthtextshort = $outputlangs->transnoentitiesnoconv(
'MonthShort'.$month);
3723 $ret = str_replace(
'__b__', $monthtextshort, $ret);
3724 $ret = str_replace(
'__B__', $monthtext, $ret);
3728 if (preg_match(
'/__a__/i', $format)) {
3730 $timetouse = $time + $offsettz + $offsetdst;
3733 $tzo =
new DateTimeZone(
'UTC');
3735 $tzo =
new DateTimeZone(date_default_timezone_get());
3737 $dtts =
new DateTime();
3738 $dtts->setTimestamp($timetouse);
3739 $dtts->setTimezone($tzo);
3740 $w = $dtts->format(
"w");
3741 $dayweek = $outputlangs->transnoentitiesnoconv(
'Day'.$w);
3743 $ret = str_replace(
'__A__', $dayweek, $ret);
3744 $ret = str_replace(
'__a__',
dol_substr($dayweek, 0, 3), $ret);
3771function dol_getdate($timestamp, $fast =
false, $forcetimezone =
'')
3773 if ($timestamp ===
'') {
3777 $datetimeobj =
new DateTime();
3778 $datetimeobj->setTimestamp($timestamp);
3779 if ($forcetimezone) {
3780 $datetimeobj->setTimezone(
new DateTimeZone($forcetimezone ==
'gmt' ?
'UTC' : $forcetimezone));
3783 'year' => ((
int) date_format($datetimeobj,
'Y')),
3784 'mon' => ((
int) date_format($datetimeobj,
'm')),
3785 'mday' => ((
int) date_format($datetimeobj,
'd')),
3786 'wday' => ((
int) date_format($datetimeobj,
'w')),
3787 'yday' => ((
int) date_format($datetimeobj,
'z')),
3788 'hours' => ((
int) date_format($datetimeobj,
'H')),
3789 'minutes' => ((
int) date_format($datetimeobj,
'i')),
3790 'seconds' => ((
int) date_format($datetimeobj,
's')),
3818function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm =
'auto', $check = 1)
3823 if ($gm ===
'auto') {
3824 $gm = (empty(
$conf) ?
'tzserver' :
$conf->tzuserinputkey);
3829 if ($hour == -1 || empty($hour)) {
3832 if ($minute == -1 || empty($minute)) {
3835 if ($second == -1 || empty($second)) {
3841 if (!$month || !$day) {
3850 if ($hour < 0 || $hour > 24) {
3853 if ($minute < 0 || $minute > 60) {
3856 if ($second < 0 || $second > 60) {
3861 if (empty($gm) || ($gm ===
'server' || $gm ===
'tzserver')) {
3862 $default_timezone = @date_default_timezone_get();
3863 $localtz =
new DateTimeZone($default_timezone);
3864 } elseif ($gm ===
'user' || $gm ===
'tzuser' || $gm ===
'tzuserrel') {
3866 $default_timezone = (empty($_SESSION[
"dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION[
"dol_tz_string"]);
3868 $localtz =
new DateTimeZone($default_timezone);
3870 dol_syslog(
"Warning dol_tz_string contains an invalid value ".json_encode($_SESSION[
"dol_tz_string"] ??
null), LOG_WARNING);
3871 $default_timezone = @date_default_timezone_get();
3873 } elseif (strrpos($gm,
"tz,") !==
false) {
3874 $timezone = str_replace(
"tz,",
"", $gm);
3876 $localtz =
new DateTimeZone($timezone);
3878 dol_syslog(
"Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
3882 if (empty($localtz)) {
3883 $localtz =
new DateTimeZone(
'UTC');
3887 $dt =
new DateTime(
'now', $localtz);
3888 $dt->setDate((
int) $year, (
int) $month, (
int) $day);
3889 $dt->setTime((
int) $hour, (
int) $minute, (
int) $second);
3890 $date = $dt->getTimestamp();
3906function dol_now($mode =
'auto')
3910 if ($mode ===
'auto') {
3914 if ($mode ==
'gmt') {
3916 } elseif ($mode ==
'tzserver') {
3917 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
3919 $ret = (int) (
dol_now(
'gmt') + ($tzsecond * 3600));
3925 } elseif ($mode ==
'tzuser' || $mode ==
'tzuserrel') {
3928 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3929 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3930 $ret = (int) (
dol_now(
'gmt') + ($offsettz + $offsetdst));
3947 global
$conf, $langs;
3950 if (!empty(
$conf->dol_optimize_smallscreen)) {
3955 if (empty($shortvalue) || $size < ($level * 10)) {
3957 $textunitshort = $langs->trans(
"b");
3958 $textunitlong = $langs->trans(
"Bytes");
3960 $ret = round($size / $level, 0);
3961 $textunitshort = $langs->trans(
"Kb");
3962 $textunitlong = $langs->trans(
"KiloBytes");
3965 if (empty($shortunit)) {
3966 $ret .=
' '.$textunitlong;
3968 $ret .=
' '.$textunitshort;
3984function dol_print_url($url, $target =
'_blank', $max = 32, $withpicto = 0, $morecss =
'')
3992 $linkstart =
'<a href="';
3993 if (!preg_match(
'/^http/i', $url)) {
3994 $linkstart .=
'http://';
3999 $linkstart .=
' target="'.$target.
'"';
4001 $linkstart .=
' title="'.$langs->trans(
"URL").
': '.$url.
'"';
4005 if (!preg_match(
'/^http/i', $url)) {
4012 if ($morecss ==
'float') {
4013 return '<div class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe',
'class="paddingrightonly"') :
'').$link.
'</div>';
4015 return $linkstart.
'<span class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto(
'',
'globe',
'class="paddingrightonly"') :
'').$link.
'</span>'.$linkend;
4032function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0, $morecss =
'paddingrightonly')
4034 global $user, $langs, $hookmanager;
4045 if (empty($email)) {
4049 if ($addlink == 1) {
4050 $newemail =
'<a class="'.($morecss ? $morecss :
'').
'" style="text-overflow: ellipsis;" href="';
4051 if (!preg_match(
'/^mailto:/i', $email)) {
4052 $newemail .=
'mailto:';
4054 $newemail .= $email;
4055 $newemail .=
'" target="_blank">';
4057 $newemail .= ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'');
4062 $newemail .= $email;
4064 $newemail .=
'</a>';
4066 $langs->load(
"errors");
4067 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email),
'',
'paddingrightonly');
4070 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
4072 $linktoaddaction =
'';
4074 $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>';
4076 if ($linktoaddaction) {
4077 $newemail =
'<div>'.$newemail.
' '.$linktoaddaction.
'</div>';
4080 } elseif ($addlink ===
'thirdparty') {
4081 $tmpnewemail =
'<a class="'.($morecss ? $morecss :
'').
'" style="text-overflow: ellipsis;" href="'.DOL_URL_ROOT.
'/societe/card.php?socid='.$socid.
'&action=presend&mode=init#formmailbeforetitle">';
4082 $tmpnewemail .= ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'');
4083 if ($withpicto == 1) {
4084 $tmpnewemail .= $newemail;
4086 $tmpnewemail .=
'</a>';
4088 $newemail = $tmpnewemail;
4090 $newemail = ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'').$newemail;
4093 $langs->load(
"errors");
4094 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
4104 $parameters = array(
'cid' => $cid,
'socid' => $socid,
'addlink' => $addlink,
'picto' => $withpicto);
4106 $reshook = $hookmanager->executeHooks(
'printEmail', $parameters, $email);
4110 $rep .= $hookmanager->resPrint;
4125 $socialnetworks = array();
4127 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
4128 $cachekey =
'socialnetworks_' .
$conf->entity;
4130 if (!is_null($dataretrieved)) {
4131 $socialnetworks = $dataretrieved;
4133 $sql =
"SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX.
"c_socialnetworks";
4134 $sql .=
" WHERE entity=".$conf->entity;
4135 $resql = $db->query($sql);
4137 while ($obj = $db->fetch_object($resql)) {
4138 $socialnetworks[$obj->code] = array(
4139 'rowid' => $obj->rowid,
4140 'label' => $obj->label,
4142 'icon' => $obj->icon,
4143 'active' => $obj->active,
4149 return $socialnetworks;
4164 global $hookmanager, $langs, $user;
4168 if (empty($value)) {
4172 if (!empty($type)) {
4173 $htmllink =
'<div class="divsocialnetwork inline-block valignmiddle">';
4175 $htmllink .=
'<span class="fab pictofixedwidth '.($dictsocialnetworks[$type][
'icon'] ? $dictsocialnetworks[$type][
'icon'] :
'fa-link').
'"></span>';
4176 if ($type ==
'skype') {
4178 $htmllink .=
' <a href="skype:';
4180 $htmllink .=
'?call" alt="'.$langs->trans(
"Call").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Call").
' '.$value).
'">';
4181 $htmllink .=
'<img src="'.DOL_URL_ROOT.
'/theme/common/skype_callbutton.png" border="0">';
4182 $htmllink .=
'</a><a href="skype:';
4184 $htmllink .=
'?chat" alt="'.$langs->trans(
"Chat").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Chat").
' '.$value).
'">';
4185 $htmllink .=
'<img class="paddingleft" src="'.DOL_URL_ROOT.
'/theme/common/skype_chatbutton.png" border="0">';
4186 $htmllink .=
'</a>';
4187 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
4188 $addlink =
'AC_SKYPE';
4191 $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>';
4193 $htmllink .= ($link ?
' '.$link :
'');
4196 $networkconstname =
'MAIN_INFO_SOCIETE_'.strtoupper($type).
'_URL';
4199 if (preg_match(
'/^https?:\/\//i', $link)) {
4200 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
4202 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
4204 } elseif (!empty($dictsocialnetworks[$type][
'url'])) {
4205 $tmpvirginurl = preg_replace(
'/\/?{socialid}/',
'', $dictsocialnetworks[$type][
'url']);
4206 if ($tmpvirginurl) {
4207 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
4208 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
4210 $tmpvirginurl3 = preg_replace(
'/^https:\/\//i',
'https://www.', $tmpvirginurl);
4211 if ($tmpvirginurl3) {
4212 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
4213 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
4216 $tmpvirginurl2 = preg_replace(
'/^https?:\/\//i',
'', $tmpvirginurl);
4217 if ($tmpvirginurl2) {
4218 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
4219 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
4222 $link = str_replace(
'{socialid}', $value, $dictsocialnetworks[$type][
'url']);
4223 if (preg_match(
'/^https?:\/\//i', $link)) {
4224 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
4226 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
4232 $htmllink .=
'</div>';
4234 $langs->load(
"errors");
4235 $htmllink .=
img_warning($langs->trans(
"ErrorBadSocialNetworkValue", $value));
4239 $parameters = array(
4244 'dictsocialnetworks' => $dictsocialnetworks,
4247 $reshook = $hookmanager->executeHooks(
'printSocialNetworks', $parameters);
4251 $htmllink .= $hookmanager->resPrint;
4266function dol_print_profids($profID, $profIDtype, $countrycode =
'', $addcpButton = 1)
4270 if (empty($profID) || empty($profIDtype)) {
4273 if (empty($countrycode)) {
4274 $countrycode = $mysoc->country_code;
4276 $newProfID = $profID;
4277 $id = substr($profIDtype, -1);
4279 if (strtoupper($countrycode) ==
'FR') {
4285 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3);
4289 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3).
' '.substr($newProfID, 9, 5);
4293 $newProfID = substr($newProfID, 0, 2).
'.'.substr($newProfID, 2, 3);
4295 if ($profIDtype ===
'VAT' &&
dol_strlen($newProfID) == 13) {
4297 $newProfID = substr($newProfID, 0, 4).
' '.substr($newProfID, 4, 3).
' '.substr($newProfID, 7, 3).
' '.substr($newProfID, 10, 3);
4300 if (!empty($addcpButton)) {
4323function dol_print_phone($phone, $countrycode =
'', $cid = 0, $socid = 0, $addlink =
'', $separ =
" ", $withpicto =
'', $titlealt =
'', $adddivfloat = 0, $morecss =
'paddingright')
4325 global
$conf, $user, $langs, $mysoc, $hookmanager;
4328 $phone = is_null($phone) ?
'' : preg_replace(
"/[\s.-]/",
"", trim($phone));
4329 if (empty($phone)) {
4335 if (empty($countrycode) && is_object($mysoc)) {
4336 $countrycode = $mysoc->country_code;
4340 if (!empty(
$conf->dol_optimize_smallscreen) && $separ !=
'hidenum') {
4345 $newphonewa = $phone;
4346 if (strtoupper($countrycode) ==
"FR") {
4349 $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);
4351 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
4353 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
4355 $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);
4357 $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);
4359 $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);
4361 } elseif (strtoupper($countrycode) ==
"CA") {
4363 $newphone = ($separ !=
'' ?
'(' :
'').substr($newphone, 0, 3).($separ !=
'' ?
')' :
'').$separ.substr($newphone, 3, 3).($separ !=
'' ?
'-' :
'').substr($newphone, 6, 4);
4365 } elseif (strtoupper($countrycode) ==
"PT") {
4367 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4369 } elseif (strtoupper($countrycode) ==
"SR") {
4371 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
4373 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
4375 } elseif (strtoupper($countrycode) ==
"DE") {
4377 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
4379 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
4381 } elseif (strtoupper($countrycode) ==
"ES") {
4383 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4385 } elseif (strtoupper($countrycode) ==
"BF") {
4387 $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);
4389 } elseif (strtoupper($countrycode) ==
"RO") {
4391 $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);
4393 } elseif (strtoupper($countrycode) ==
"TR") {
4395 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4397 } elseif (strtoupper($countrycode) ==
"US") {
4399 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4401 } elseif (strtoupper($countrycode) ==
"MX") {
4403 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4405 $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);
4407 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4409 } elseif (strtoupper($countrycode) ==
"ML") {
4411 $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);
4413 } elseif (strtoupper($countrycode) ==
"TH") {
4415 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4417 $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);
4419 } elseif (strtoupper($countrycode) ==
"MU") {
4422 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
4424 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4426 } elseif (strtoupper($countrycode) ==
"ZA") {
4428 $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);
4430 } elseif (strtoupper($countrycode) ==
"SY") {
4432 $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);
4434 $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);
4436 } elseif (strtoupper($countrycode) ==
"AE") {
4438 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4440 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4442 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
4444 } elseif (strtoupper($countrycode) ==
"DZ") {
4446 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4448 } elseif (strtoupper($countrycode) ==
"BE") {
4450 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4452 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4454 } elseif (strtoupper($countrycode) ==
"PF") {
4456 $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);
4458 } elseif (strtoupper($countrycode) ==
"CO") {
4460 $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);
4462 } elseif (strtoupper($countrycode) ==
"JO") {
4464 $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);
4466 } elseif (strtoupper($countrycode) ==
"JM") {
4468 $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4470 } elseif (strtoupper($countrycode) ==
"MG") {
4472 $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);
4474 } elseif (strtoupper($countrycode) ==
"GB") {
4476 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4478 } elseif (strtoupper($countrycode) ==
"CH") {
4480 $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);
4482 $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);
4484 } elseif (strtoupper($countrycode) ==
"TN") {
4486 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4488 } elseif (strtoupper($countrycode) ==
"GF") {
4490 $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);
4492 } elseif (strtoupper($countrycode) ==
"GP") {
4494 $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);
4496 } elseif (strtoupper($countrycode) ==
"MQ") {
4498 $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);
4500 } elseif (strtoupper($countrycode) ==
"IT") {
4502 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4504 $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);
4506 } elseif (strtoupper($countrycode) ==
"AU") {
4510 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
4512 } elseif (strtoupper($countrycode) ==
"LU") {
4515 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
4517 $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);
4519 $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);
4521 $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);
4523 } elseif (strtoupper($countrycode) ==
"PE") {
4526 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4);
4528 $newphonewa =
'+51'.$newphone;
4529 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 10, 3);
4531 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 8, 4);
4533 $newphonewa = $newphone;
4534 $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);
4536 } elseif (strtoupper($countrycode) ==
"IN") {
4538 if ($withpicto ==
'phone') {
4539 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 4).$separ.substr($newphone, 9, 4);
4541 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 5).$separ.substr($newphone, 8, 5);
4546 $newphoneastart = $newphoneaend =
'';
4547 if (!empty($addlink)) {
4548 if ($addlink ==
'tel' ||
$conf->browser->layout ==
'phone' || (isModEnabled(
'clicktodial') &&
getDolGlobalString(
'CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS'))) {
4549 $newphoneastart =
'<a href="tel:'.urlencode($phone).
'">';
4550 $newphoneaend .=
'</a>';
4551 } elseif (isModEnabled(
'clicktodial') && $addlink ==
'AC_TEL') {
4552 if (empty($user->clicktodial_loaded)) {
4553 $user->fetch_clicktodial();
4557 $urlmask =
getDolGlobalString(
'CLICKTODIAL_URL',
'ErrorClickToDialModuleNotConfigured');
4558 if (!empty($user->clicktodial_url)) {
4559 $urlmask = $user->clicktodial_url;
4562 $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) :
'');
4563 $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) :
'');
4564 $clicktodial_password = (!empty($user->clicktodial_password) ? urlencode($user->clicktodial_password) :
'');
4566 $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
4568 $substitarray = array(
'__PHONEFROM__' => $clicktodial_poste,
4569 '__PHONETO__' => urlencode($phone),
4570 '__LOGIN__' => $clicktodial_login,
4571 '__PASS__' => $clicktodial_password);
4575 $newphoneastart =
'<a href="'.$url.
'" class="cssforclicktodial">';
4576 $newphoneaend =
'</a>';
4579 $newphoneastart =
'<a href="'.$url.
'"';
4581 $newphoneastart .=
' target="_blank" rel="noopener noreferrer"';
4583 $newphoneastart .=
'>';
4584 $newphoneaend .=
'</a>';
4589 if (isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
4591 $addlinktoagenda =
'';
4592 if ($addlink ==
'AC_FAX') {
4596 $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>';
4598 if ($addlinktoagenda) {
4599 $newphone =
'<span>'.$newphone.
' '.$addlinktoagenda.
'</span>';
4604 if (
getDolGlobalString(
'CONTACT_PHONEMOBILE_SHOW_LINK_TO_WHATSAPP') && $withpicto ==
'mobile') {
4606 $newphone .=
' <a href="https://wa.me/'.$newphonewa.
'" target="_blank"';
4607 $newphone .=
'><span class="paddingright fab fa-whatsapp" style="color:#25D366;" title="WhatsApp"></span></a>';
4610 if (empty($titlealt)) {
4611 $titlealt = ($withpicto ==
'fax' ? $langs->trans(
"Fax") : $langs->trans(
"Phone"));
4616 $parameters = array(
'countrycode' => $countrycode,
'cid' => $cid,
'socid' => $socid,
'titlealt' => $titlealt,
'picto' => $withpicto);
4617 $reshook = $hookmanager->executeHooks(
'printPhone', $parameters, $phone);
4618 $rep .= $hookmanager->resPrint;
4620 if (empty($reshook)) {
4623 if ($withpicto ==
'fax') {
4624 $picto =
'phoning_fax';
4625 } elseif ($withpicto ==
'phone') {
4627 } elseif ($withpicto ==
'mobile') {
4628 $picto =
'phoning_mobile';
4633 if ($adddivfloat == 1) {
4634 $rep .=
'<div class="nospan float'.($morecss ?
' '.$morecss :
'').
'">';
4635 } elseif (empty($adddivfloat)) {
4636 $rep .=
'<span'.($morecss ?
' class="'.$morecss.
'"' :
'').
'>';
4639 $rep .= $newphoneastart;
4640 $rep .= ($withpicto ?
img_picto($titlealt,
'object_'.$picto.
'.png') :
'');
4641 if ($separ !=
'hidenum') {
4642 $rep .= ($withpicto ?
' ' :
'').$newphone;
4644 $rep .= $newphoneaend;
4646 if ($adddivfloat == 1) {
4648 } elseif (empty($adddivfloat)) {
4676 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/common/flags/'.$countrycode.
'.png')) {
4677 $ret .=
' '.img_picto($countrycode.
' '.$langs->trans(
"AccordingToGeoIPDatabase"), DOL_URL_ROOT.
'/theme/common/flags/'.$countrycode.
'.png',
'', 1);
4679 $ret .=
' ('.$countrycode.
')';
4704 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
4711 if (empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) || preg_match(
'/[^0-9\.\:,\[\]\s]/', $_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
4712 if (empty($_SERVER[
'HTTP_CLIENT_IP']) || preg_match(
'/[^0-9\.\:,\[\]\s]/', $_SERVER[
'HTTP_CLIENT_IP'])) {
4713 if (empty($_SERVER[
"HTTP_CF_CONNECTING_IP"])) {
4714 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
4716 $ip = $_SERVER[
"HTTP_CF_CONNECTING_IP"];
4719 $ip = preg_replace(
'/,.*$/',
'', $_SERVER[
'HTTP_CLIENT_IP']);
4722 $ip = preg_replace(
'/,.*$/',
'', $_SERVER[
'HTTP_X_FORWARDED_FOR']);
4738 if (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on') {
4740 } 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') {
4758 if (isModEnabled(
'geoipmaxmind')) {
4762 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4763 $geoip =
new DolGeoIP(
'country', $datafile);
4765 $countrycode = $geoip->getCountryCodeFromIP($ip);
4768 return $countrycode;
4780 global
$conf, $langs, $user;
4784 if (isModEnabled(
'geoipmaxmind')) {
4789 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4790 $geoip =
new DolGeoIP(
'country', $datafile);
4791 $countrycode = $geoip->getCountryCodeFromIP($ip);
4792 $ret = $countrycode;
4811 global
$conf, $user, $langs, $hookmanager;
4817 $parameters = array(
'element' => $element,
'id' =>
$id);
4818 $reshook = $hookmanager->executeHooks(
'printAddress', $parameters, $address);
4819 $out .= $hookmanager->resPrint;
4821 if (empty($reshook)) {
4822 if (empty($charfornl)) {
4823 $out .= nl2br($address);
4825 $out .= preg_replace(
'/[\r\n]+/', $charfornl, $address);
4829 $showgmap = $showomap = 0;
4830 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS')) {
4833 if ($element ==
'contact' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_CONTACTS')) {
4836 if ($element ==
'member' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_MEMBERS')) {
4839 if ($element ==
'user' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_USERS')) {
4842 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS')) {
4845 if ($element ==
'contact' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_CONTACTS')) {
4848 if ($element ==
'member' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_MEMBERS')) {
4851 if ($element ==
'user' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_USERS')) {
4856 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4859 $url =
dol_buildpath(
'/openstreetmap/maps.php?mode='.$element.
'&id='.
$id, 1);
4860 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4882function isValidEmail($address, $acceptsupervisorkey = 0, $acceptuserkey = 0)
4884 if ($acceptsupervisorkey && $address ==
'__SUPERVISOREMAIL__') {
4887 if ($acceptuserkey && $address ==
'__USER_EMAIL__') {
4890 if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
4908 if (function_exists(
'idn_to_ascii') && function_exists(
'checkdnsrr')) {
4909 if (!checkdnsrr(idn_to_ascii($domain),
'MX')) {
4912 if (function_exists(
'getmxrr')) {
4915 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
4916 if (count($mxhosts) > 1) {
4919 if (count($mxhosts) == 1 && !in_array((
string) $mxhosts[0], array(
'',
'.'))) {
4956 $tmparray = explode(
' ', $s);
4957 foreach ($tmparray as $tmps) {
4972function dol_strlen($string, $stringencoding =
'UTF-8')
4974 if (is_null($string)) {
4978 if (function_exists(
'mb_strlen')) {
4979 return mb_strlen($string, $stringencoding);
4981 return strlen($string);
4995function dol_substr($string, $start, $length =
null, $stringencoding =
'', $trunconbytes = 0)
4999 if (empty($stringencoding)) {
5000 $stringencoding = (empty($langs) ?
'UTF-8' : $langs->charset_output);
5004 if (empty($trunconbytes)) {
5005 if (function_exists(
'mb_substr')) {
5006 $ret = mb_substr($string, $start, $length, $stringencoding);
5008 $ret = substr($string, $start, $length);
5011 if (function_exists(
'mb_strcut')) {
5012 $ret = mb_strcut($string, $start, $length, $stringencoding);
5014 $ret = substr($string, $start, $length);
5034function dol_trunc($string, $size = 40, $trunc =
'right', $stringencoding =
'UTF-8', $nodot = 0, $display = 0)
5042 if (empty($stringencoding)) {
5043 $stringencoding =
'UTF-8';
5046 if (!empty(
$conf->dol_optimize_smallscreen) &&
$conf->dol_optimize_smallscreen == 1 && $display == 1) {
5047 $size = round($size / 3);
5051 if ($trunc ==
'right') {
5053 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
5055 return dol_substr($newstring, 0, $size, $stringencoding).($nodot ?
'' :
'…');
5060 } elseif ($trunc ==
'middle') {
5062 if (
dol_strlen($newstring, $stringencoding) > 2 &&
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
5063 $size1 = (int) round($size / 2);
5064 $size2 = (int) round($size / 2);
5065 return dol_substr($newstring, 0, $size1, $stringencoding).
'…'.
dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
5069 } elseif ($trunc ==
'left') {
5071 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
5073 return '…'.dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
5077 } elseif ($trunc ==
'wrap') {
5079 if (
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
5085 return 'BadParam3CallingDolTrunc';
5099 $type2picto = array(
5100 'varchar' =>
'font',
5103 'int' =>
'sort-numeric-down',
5104 'double' =>
'sort-numeric-down',
5105 'price' =>
'currency',
5106 'pricecy' =>
'multicurrency',
5107 'password' =>
'key',
5108 'boolean' =>
'check-square',
5109 'date' =>
'calendar',
5110 'datetime' =>
'calendar',
5111 'duration' =>
'hourglass',
5117 'sellist' =>
'list',
5118 'stars' =>
'fontawesome_star_fas',
5119 'radio' =>
'check-circle',
5120 'checkbox' =>
'list',
5121 'chkbxlst' =>
'list',
5123 'icon' =>
"question",
5124 'point' =>
"country",
5125 'multipts' =>
'country',
5126 'linestrg' =>
"country",
5127 'polygon' =>
"country",
5128 'separate' =>
'minus'
5131 if (!empty($type2picto[$key])) {
5132 return img_picto(
'', $type2picto[$key],
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
5135 return img_picto(
'',
'generic',
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
5161function img_picto($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0, $alt =
'', $morecss =
'', $marginleftonlyshort = 2, $allowothertags = array())
5166 $url = DOL_URL_ROOT;
5167 $theme = isset(
$conf->theme) ?
$conf->theme :
null;
5168 $path =
'theme/'.$theme;
5169 if (empty($picto)) {
5174 if ($pictoisfullpath) {
5176 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
5179 $fullpathpicto = $picto;
5181 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5182 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5183 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5188 $pictowithouttext = preg_replace(
'/(\.png|\.gif|\.svg)$/',
'', $picto);
5189 $pictowithouttext = str_replace(
'object_',
'', $pictowithouttext);
5190 $pictowithouttext = str_replace(
'_nocolor',
'', $pictowithouttext);
5193 $pictoconvertkey = array(
'facture' =>
'bill',
'shipping' =>
'shipment',
'fichinter' =>
'intervention',
'agenda' =>
'calendar',
'invoice_supplier' =>
'supplier_invoice',
'order_supplier' =>
'supplier_order');
5194 if (in_array($pictowithouttext, array_keys($pictoconvertkey))) {
5195 $pictowithouttext = $pictoconvertkey[$pictowithouttext];
5198 if (strpos($pictowithouttext,
'fontawesome_') === 0 || strpos($pictowithouttext,
'fa-') === 0) {
5200 $pictowithouttext = str_replace(
'fontawesome_',
'', $pictowithouttext);
5201 $pictowithouttext = str_replace(
'fa-',
'', $pictowithouttext);
5204 if ($pictowithouttext ==
'file-o') {
5205 $pictowithouttext =
'file';
5208 $pictowithouttextarray = explode(
'_', $pictowithouttext);
5209 $marginleftonlyshort = 0;
5211 if (!empty($pictowithouttextarray[1])) {
5213 $fakey =
'fa-'.$pictowithouttextarray[0];
5214 $faprefix = empty($pictowithouttextarray[1]) ?
'fas' : $pictowithouttextarray[1];
5215 $facolor = empty($pictowithouttextarray[2]) ?
'' : $pictowithouttextarray[2];
5216 $fasize = empty($pictowithouttextarray[3]) ?
'' : $pictowithouttextarray[3];
5218 $fakey =
'fa-'.$pictowithouttext;
5228 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5229 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5230 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5232 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
5233 $morestyle = $reg[1];
5234 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
5236 $moreatt = trim($moreatt);
5238 $enabledisablehtml =
'<span class="'.$faprefix.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
5239 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
5240 $enabledisablehtml .=
'</span>';
5242 return $enabledisablehtml;
5245 if (empty($srconly) && in_array($pictowithouttext, array(
5246 '1downarrow',
'1uparrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected',
5247 'accountancy',
'accounting_account',
'account',
'accountline',
'action',
'add',
'address',
'ai',
'angle-double-down',
'angle-double-up',
'asset',
5248 'back',
'bank_account',
'barcode',
'bank',
'bell',
'bill',
'billa',
'billr',
'billd',
'birthday-cake',
'bom',
'bookcal',
'bookmark',
'briefcase-medical',
'bug',
'building',
5249 'card',
'calendarlist',
'calendar',
'calendarmonth',
'calendarweek',
'calendarday',
'calendarperuser',
'calendarpertype',
'hourglass',
5250 'cash-register',
'category',
'chart',
'check',
'clock',
'clone',
'close_title',
'code',
'cog',
'collab',
'company',
'contact',
'country',
'contract',
'conversation',
'cron',
'cross',
'cubes',
5251 'check-circle',
'check-square',
'circle',
'stop-circle',
'currency',
'multicurrency',
5252 'chevron-left',
'chevron-right',
'chevron-down',
'chevron-top',
5253 'chevron-double-left',
'chevron-double-right',
'chevron-double-down',
'chevron-double-top',
5254 'commercial',
'companies',
5255 'delete',
'dolly',
'dollyrevert',
'donation',
'download',
'dynamicprice',
5256 'edit',
'ellipsis-h',
'email',
'entity',
'envelope',
'eraser',
'establishment',
'expensereport',
'external-link-alt',
'external-link-square-alt',
'eye',
5257 'filter',
'file',
'file-o',
'file-code',
'file-export',
'file-import',
'file-upload',
'autofill',
'folder',
'folder-open',
'folder-plus',
'font',
5258 'gears',
'generate',
'generic',
'globe',
'globe-americas',
'graph',
'grip',
'grip_title',
'group',
5259 'hands-helping',
'help',
'holiday',
5260 'id-card',
'images',
'incoterm',
'info',
'intervention',
'inventory',
'intracommreport',
'jobprofile',
5261 'key',
'knowledgemanagement',
5262 'label',
'language',
'layout',
'line',
'link',
'list',
'list-alt',
'listlight',
'loan',
'lock',
'lot',
'long-arrow-alt-right',
5263 'margin',
'map-marker-alt',
'member',
'meeting',
'minus',
'money-bill-alt',
'movement',
'mrp',
'note',
'next',
5264 'off',
'on',
'order',
5265 'paiment',
'paragraph',
'play',
'pdf',
'phone',
'phoning',
'phoning_mobile',
'phoning_fax',
'playdisabled',
'previous',
'poll',
'pos',
'printer',
'product',
'propal',
'proposal',
'puce',
5266 'stock',
'resize',
'service',
'stats',
5267 'security',
'setup',
'share-alt',
'sign-out',
'split',
'stripe',
'stripe-s',
'switch_off',
'switch_on',
'switch_on_grey',
'switch_on_warning',
'switch_on_red',
'tools',
'unlink',
'uparrow',
'user',
'user-tie',
'vcard',
'wrench',
5268 'discord',
'facebook',
'flickr',
'instagram',
'linkedin',
'github',
'google',
'jabber',
'meetup',
'microsoft',
'skype',
'slack',
'twitter',
'pinterest',
'reddit',
'snapchat',
'tumblr',
'youtube',
'viadeo',
'google-plus-g',
'whatsapp',
5269 'generic',
'home',
'hrm',
'members',
'products',
'invoicing',
5270 'partnership',
'payment',
'payment_vat',
'pencil-ruler',
'pictoconfirm',
'preview',
'project',
'projectpub',
'projecttask',
'question',
'refresh',
'region',
5271 'salary',
'shipment',
'state',
'supplier_invoice',
'supplier_invoicea',
'supplier_invoicer',
'supplier_invoiced',
5272 'technic',
'ticket',
5274 'recent',
'reception',
'recruitmentcandidature',
'recruitmentjobposition',
'replacement',
'resource',
'recurring',
'rss',
5275 'shapes',
'skill',
'square',
'sort-numeric-down',
'status',
'stop-circle',
'supplier',
'supplier_proposal',
'supplier_order',
'supplier_invoice',
5276 'terminal',
'tick',
'timespent',
'title_setup',
'title_accountancy',
'title_bank',
'title_hrm',
'title_agenda',
'trip',
5277 'uncheck',
'undo',
'url',
'user-cog',
'user-injured',
'user-md',
'vat',
'website',
'workstation',
'webhook',
'world',
'private',
5278 'conferenceorbooth',
'eventorganization',
5279 'stamp',
'signature',
5282 $fakey = $pictowithouttext;
5286 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'))) {
5289 if (in_array($pictowithouttext, array(
'black-tie',
'discord',
'facebook',
'flickr',
'github',
'google',
'google-plus-g',
'instagram',
'linkedin',
'meetup',
'microsoft',
'pinterest',
'skype',
'slack',
'twitter',
'reddit',
'snapchat',
'stripe',
'stripe-s',
'tumblr',
'viadeo',
'whatsapp',
'youtube'))) {
5293 $arrayconvpictotofa = array(
5294 'account' =>
'university',
'accounting_account' =>
'clipboard-list',
'accountline' =>
'receipt',
'accountancy' =>
'search-dollar',
'action' =>
'calendar-alt',
'add' =>
'plus-circle',
'address' =>
'address-book',
'ai' =>
'magic',
5295 'asset' =>
'money-check-alt',
'autofill' =>
'fill',
5296 'back' =>
'arrow-left',
'bank_account' =>
'university',
5297 'bill' =>
'file-invoice-dollar',
'billa' =>
'file-excel',
'billr' =>
'file-invoice-dollar',
'billd' =>
'file-medical',
5298 'bookcal' =>
'calendar-check',
5299 'supplier_invoice' =>
'file-invoice-dollar',
'supplier_invoicea' =>
'file-excel',
'supplier_invoicer' =>
'file-invoice-dollar',
'supplier_invoiced' =>
'file-medical',
5301 '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',
5302 'chevron-double-left' =>
'angle-double-left',
'chevron-double-right' =>
'angle-double-right',
'chevron-double-down' =>
'angle-double-down',
'chevron-double-top' =>
'angle-double-up',
5303 'donation' =>
'file-alt',
'dynamicprice' =>
'hand-holding-usd',
5304 'setup' =>
'cog',
'companies' =>
'building',
'products' =>
'cube',
'commercial' =>
'suitcase',
'invoicing' =>
'coins',
5305 'accounting' =>
'search-dollar',
'category' =>
'tag',
'dollyrevert' =>
'dolly',
5306 'file-o' =>
'file',
'generate' =>
'plus-square',
'hrm' =>
'user-tie',
'incoterm' =>
'truck-loading',
5307 'margin' =>
'calculator',
'members' =>
'user-friends',
'ticket' =>
'ticket-alt',
'globe' =>
'external-link-alt',
'lot' =>
'barcode',
5308 'email' =>
'at',
'establishment' =>
'building',
'edit' =>
'pencil-alt',
'entity' =>
'globe',
5309 'graph' =>
'chart-line',
'grip_title' =>
'arrows-alt',
'grip' =>
'arrows-alt',
'help' =>
'question-circle',
5310 'generic' =>
'file',
'holiday' =>
'umbrella-beach',
5311 'info' =>
'info-circle',
'inventory' =>
'boxes',
'intracommreport' =>
'globe-europe',
'jobprofile' =>
'cogs',
5312 'knowledgemanagement' =>
'ticket-alt',
'label' =>
'layer-group',
'layout' =>
'columns',
'line' =>
'bars',
'loan' =>
'money-bill-alt',
5313 'member' =>
'user-alt',
'meeting' =>
'chalkboard-teacher',
'mrp' =>
'cubes',
'next' =>
'arrow-alt-circle-right',
5314 'trip' =>
'wallet',
'expensereport' =>
'wallet',
'group' =>
'users',
'movement' =>
'people-carry',
5315 'sign-out' =>
'sign-out-alt',
5316 'switch_off' =>
'toggle-off',
'switch_on' =>
'toggle-on',
'switch_on_grey' =>
'toggle-on',
'switch_on_warning' =>
'toggle-on',
'switch_on_red' =>
'toggle-on',
'check' =>
'check',
'bookmark' =>
'star',
5317 'bank' =>
'university',
'close_title' =>
'times',
'delete' =>
'trash',
'filter' =>
'filter',
5318 'list-alt' =>
'list-alt',
'calendarlist' =>
'bars',
'calendar' =>
'calendar-alt',
'calendarmonth' =>
'calendar-alt',
'calendarweek' =>
'calendar-week',
'calendarday' =>
'calendar-day',
'calendarperuser' =>
'table',
5319 'intervention' =>
'ambulance',
'invoice' =>
'file-invoice-dollar',
'order' =>
'file-invoice',
5320 'error' =>
'exclamation-triangle',
'warning' =>
'exclamation-triangle',
5321 'other' =>
'square',
5322 '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',
5323 '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',
5324 'recent' =>
'check-square',
'reception' =>
'dolly',
'recruitmentjobposition' =>
'id-card-alt',
'recruitmentcandidature' =>
'id-badge',
5325 'resize' =>
'crop',
'supplier_order' =>
'dol-order_supplier',
'supplier_proposal' =>
'file-signature',
5326 'refresh' =>
'redo',
'region' =>
'map-marked',
'replacement' =>
'exchange-alt',
'resource' =>
'laptop-house',
'recurring' =>
'history',
5327 'service' =>
'concierge-bell',
5328 'skill' =>
'shapes',
'state' =>
'map-marked-alt',
'security' =>
'key',
'salary' =>
'wallet',
'shipment' =>
'dolly',
'stock' =>
'box-open',
'stats' =>
'chart-bar',
'split' =>
'code-branch',
5329 'status' =>
'stop-circle',
5330 'stripe' =>
'stripe-s',
'supplier' =>
'building',
5331 'technic' =>
'cogs',
'tick' =>
'check',
'timespent' =>
'clock',
'title_setup' =>
'tools',
'title_accountancy' =>
'money-check-alt',
'title_bank' =>
'university',
'title_hrm' =>
'umbrella-beach',
5332 'title_agenda' =>
'calendar-alt',
5333 'uncheck' =>
'times',
'uparrow' =>
'share',
'url' =>
'external-link-alt',
'vat' =>
'money-check-alt',
'vcard' =>
'arrow-alt-circle-down',
5334 'jabber' =>
'comment-o',
5335 'website' =>
'globe-americas',
'workstation' =>
'pallet',
'webhook' =>
'bullseye',
'world' =>
'globe',
'private' =>
'user-lock',
5336 'conferenceorbooth' =>
'chalkboard-teacher',
'eventorganization' =>
'project-diagram',
5337 'webportal' =>
'door-open'
5339 if (
$conf->currency ==
'EUR') {
5340 $arrayconvpictotofa[
'currency'] =
'euro-sign';
5341 $arrayconvpictotofa[
'multicurrency'] =
'dollar-sign';
5343 $arrayconvpictotofa[
'currency'] =
'dollar-sign';
5344 $arrayconvpictotofa[
'multicurrency'] =
'euro-sign';
5346 if ($pictowithouttext ==
'off') {
5347 $fakey =
'fa-square';
5349 } elseif ($pictowithouttext ==
'on') {
5350 $fakey =
'fa-check-square';
5352 } elseif ($pictowithouttext ==
'listlight') {
5353 $fakey =
'fa-download';
5354 $marginleftonlyshort = 1;
5355 } elseif ($pictowithouttext ==
'printer') {
5356 $fakey =
'fa-print';
5358 } elseif ($pictowithouttext ==
'note') {
5359 $fakey =
'fa-sticky-note';
5360 $marginleftonlyshort = 1;
5361 } elseif (in_array($pictowithouttext, array(
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'))) {
5362 $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');
5363 $fakey =
'fa-'.$convertarray[$pictowithouttext];
5364 if (preg_match(
'/selected/', $pictowithouttext)) {
5367 $marginleftonlyshort = 1;
5368 } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) {
5369 $fakey =
'fa-'.$arrayconvpictotofa[$pictowithouttext];
5371 $fakey =
'fa-'.$pictowithouttext;
5374 if (in_array($pictowithouttext, array(
'dollyrevert',
'member',
'members',
'contract',
'group',
'resource',
'shipment',
'reception'))) {
5375 $morecss .=
' em092';
5377 if (in_array($pictowithouttext, array(
'conferenceorbooth',
'collab',
'eventorganization',
'holiday',
'info',
'project',
'workstation'))) {
5378 $morecss .=
' em088';
5380 if (in_array($pictowithouttext, array(
'asset',
'intervention',
'payment',
'loan',
'partnership',
'stock',
'technic'))) {
5381 $morecss .=
' em080';
5385 $arrayconvpictotomarginleftonly = array(
5386 'bank',
'check',
'delete',
'generic',
'grip',
'grip_title',
'jabber',
5387 'grip_title',
'grip',
'listlight',
'note',
'on',
'off',
'playdisabled',
'printer',
'resize',
'sign-out',
'stats',
'switch_on',
'switch_on_grey',
'switch_on_red',
'switch_off',
5388 'uparrow',
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'
5390 if (!array_key_exists($pictowithouttext, $arrayconvpictotomarginleftonly)) {
5391 $marginleftonlyshort = 0;
5395 $arrayconvpictotomorcess = array(
5396 'action' =>
'infobox-action',
'account' =>
'infobox-bank_account',
'accounting_account' =>
'infobox-bank_account',
'accountline' =>
'infobox-bank_account',
'accountancy' =>
'infobox-bank_account',
'asset' =>
'infobox-bank_account',
5397 'bank_account' =>
'infobox-bank_account',
5398 'bill' =>
'infobox-commande',
'billa' =>
'infobox-commande',
'billr' =>
'infobox-commande',
'billd' =>
'infobox-commande',
5399 'bookcal' =>
'infobox-action',
5400 'margin' =>
'infobox-bank_account',
'conferenceorbooth' =>
'infobox-project',
5401 'cash-register' =>
'infobox-bank_account',
'contract' =>
'infobox-contrat',
'check' =>
'font-status4',
'collab' =>
'infobox-action',
'conversation' =>
'infobox-contrat',
5402 'donation' =>
'infobox-commande',
'dolly' =>
'infobox-commande',
'dollyrevert' =>
'flip infobox-order_supplier',
5403 'ecm' =>
'infobox-action',
'eventorganization' =>
'infobox-project',
5404 'hrm' =>
'infobox-adherent',
'group' =>
'infobox-adherent',
'intervention' =>
'infobox-contrat',
5405 'incoterm' =>
'infobox-supplier_proposal',
5406 'currency' =>
'infobox-bank_account',
'multicurrency' =>
'infobox-bank_account',
5407 'members' =>
'infobox-adherent',
'member' =>
'infobox-adherent',
'money-bill-alt' =>
'infobox-bank_account',
5408 'order' =>
'infobox-commande',
5409 'user' =>
'infobox-adherent',
'users' =>
'infobox-adherent',
5410 'error' =>
'pictoerror',
'warning' =>
'pictowarning',
'switch_on' =>
'font-status4',
'switch_on_warning' =>
'font-status4 warning',
'switch_on_red' =>
'font-status8',
5411 'holiday' =>
'infobox-holiday',
'info' =>
'opacityhigh',
'invoice' =>
'infobox-commande',
5412 'knowledgemanagement' =>
'infobox-contrat rotate90',
'loan' =>
'infobox-bank_account',
5413 'payment' =>
'infobox-bank_account',
'payment_vat' =>
'infobox-bank_account',
'poll' =>
'infobox-adherent',
'pos' =>
'infobox-bank_account',
'project' =>
'infobox-project',
'projecttask' =>
'infobox-project',
5414 'propal' =>
'infobox-propal',
'proposal' =>
'infobox-propal',
'private' =>
'infobox-project',
5415 'reception' =>
'flip infobox-order_supplier',
'recruitmentjobposition' =>
'infobox-adherent',
'recruitmentcandidature' =>
'infobox-adherent',
5416 'resource' =>
'infobox-action',
5417 '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',
5418 'supplier' =>
'infobox-order_supplier',
'supplier_order' =>
'infobox-order_supplier',
'supplier_proposal' =>
'infobox-supplier_proposal',
5419 'ticket' =>
'infobox-contrat',
'title_accountancy' =>
'infobox-bank_account',
'title_hrm' =>
'infobox-holiday',
'expensereport' =>
'infobox-expensereport',
'trip' =>
'infobox-expensereport',
'title_agenda' =>
'infobox-action',
5420 'vat' =>
'infobox-bank_account',
5422 'list-alt' =>
'imgforviewmode',
'calendar' =>
'imgforviewmode',
'calendarweek' =>
'imgforviewmode',
'calendarmonth' =>
'imgforviewmode',
'calendarday' =>
'imgforviewmode',
'calendarperuser' =>
'imgforviewmode'
5424 if (!empty($arrayconvpictotomorcess[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5425 $morecss .= ($morecss ?
' ' :
'').$arrayconvpictotomorcess[$pictowithouttext];
5429 $arrayconvpictotocolor = array(
5430 'address' =>
'#6c6aa8',
'building' =>
'#6c6aa8',
'bom' =>
'#a69944',
5431 'clone' =>
'#999',
'cog' =>
'#999',
'companies' =>
'#6c6aa8',
'company' =>
'#6c6aa8',
'contact' =>
'#6c6aa8',
'cron' =>
'#555',
5432 'dynamicprice' =>
'#a69944',
5433 'edit' =>
'#444',
'note' =>
'#999',
'error' =>
'',
'help' =>
'#bbb',
'listlight' =>
'#999',
'language' =>
'#555',
5435 'lock' =>
'#ddd',
'lot' =>
'#a69944',
5436 'map-marker-alt' =>
'#aaa',
'mrp' =>
'#a69944',
'product' =>
'#a69944',
'service' =>
'#a69944',
'inventory' =>
'#a69944',
'stock' =>
'#a69944',
'movement' =>
'#a69944',
5437 'other' =>
'#ddd',
'world' =>
'#986c6a',
5438 'partnership' =>
'#6c6aa8',
'playdisabled' =>
'#ccc',
'printer' =>
'#444',
'projectpub' =>
'#986c6a',
'resize' =>
'#444',
'rss' =>
'#cba',
5440 'security' =>
'#999',
'square' =>
'#888',
'stop-circle' =>
'#888',
'stats' =>
'#444',
'switch_off' =>
'#999',
5441 'technic' =>
'#999',
'tick' =>
'#282',
'timespent' =>
'#555',
5442 'uncheck' =>
'#800',
'uparrow' =>
'#555',
'user-cog' =>
'#999',
'country' =>
'#aaa',
'globe-americas' =>
'#aaa',
'region' =>
'#aaa',
'state' =>
'#aaa',
5443 'website' =>
'#304',
'workstation' =>
'#a69944'
5445 if (isset($arrayconvpictotocolor[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5446 $facolor = $arrayconvpictotocolor[$pictowithouttext];
5453 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5454 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5455 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5457 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
5458 $morestyle = $reg[1];
5459 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
5461 $moreatt = trim($moreatt);
5463 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
5464 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
5465 $enabledisablehtml .=
'</span>';
5467 return $enabledisablehtml;
5474 } elseif (!empty(
$conf->modules_parts[
'theme']) && array_key_exists($theme,
$conf->modules_parts[
'theme'])) {
5475 $path = $theme.
'/theme/'.$theme;
5480 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
5486 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
5491 foreach (
$conf->file->dol_document_root as $type => $dirroot) {
5492 if ($type ==
'main') {
5496 if (file_exists($dirroot.
'/'.$path.
'/img/'.$picto)) {
5497 $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type];
5503 $fullpathpicto = $url.
'/'.$path.
'/img/'.$picto;
5507 return $fullpathpicto;
5511 return '<img src="'.$fullpathpicto.
'"'.($notitle ?
'' :
' alt="'.dolPrintHTMLForAttribute($alt, 0, $allowothertags).
'"').(($notitle || empty($titlealt)) ?
'' :
' title="'.
dolPrintHTMLForAttribute($titlealt, 0, $allowothertags).
'"').($moreatt ?
' '.$moreatt.($morecss ?
' class="'.$morecss.
'"' :
'') :
' class="inline-block'.($morecss ?
' '.$morecss :
'').
'"').
'>';
5528function img_object($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0, $allowothertags = array())
5530 if (strpos($picto,
'^') === 0) {
5531 return img_picto($titlealt, str_replace(
'^',
'', $picto), $moreatt, $pictoisfullpath, $srconly, $notitle,
'',
'', 2, $allowothertags);
5533 return img_picto($titlealt,
'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle,
'',
'', 2, $allowothertags);
5548function img_weather($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $morecss =
'')
5552 if (is_numeric($picto)) {
5555 return '<i class="fa fa-weather-level'.$picto.
'"></i>';
5556 } elseif (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5560 $path = DOL_URL_ROOT.
'/theme/'.
$conf->theme.
'/img/weather/'.$picto;
5562 return img_picto($titlealt, $path, $moreatt, 1, 0, 0,
'', $morecss);
5576function img_picto_common($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $notitle = 0)
5580 if (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5584 if ($pictoisfullpath) {
5587 $path = DOL_URL_ROOT.
'/theme/common/'.$picto;
5590 $themepath = DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/img/'.$picto;
5592 if (file_exists($themepath)) {
5598 return img_picto($titlealt, $path, $moreatt, 1, 0, $notitle);
5614function img_action($titlealt, $numaction, $picto =
'', $moreatt =
'')
5618 if (empty($titlealt) || $titlealt ==
'default') {
5619 if ($numaction ==
'-1' || $numaction ==
'ST_NO') {
5621 $titlealt = $langs->transnoentitiesnoconv(
'ChangeDoNotContact');
5622 } elseif ($numaction ==
'0' || $numaction ==
'ST_NEVER') {
5624 $titlealt = $langs->transnoentitiesnoconv(
'ChangeNeverContacted');
5625 } elseif ($numaction ==
'1' || $numaction ==
'ST_TODO') {
5627 $titlealt = $langs->transnoentitiesnoconv(
'ChangeToContact');
5628 } elseif ($numaction ==
'2' || $numaction ==
'ST_PEND') {
5630 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactInProcess');
5631 } elseif ($numaction ==
'3' || $numaction ==
'ST_DONE') {
5633 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactDone');
5635 $titlealt = $langs->transnoentitiesnoconv(
'ChangeStatus '.$numaction);
5639 if (!is_numeric($numaction)) {
5643 return img_picto($titlealt, (empty($picto) ?
'stcomm'.$numaction.
'.png' : $picto), $moreatt);
5653function img_pdf($titlealt =
'default', $size = 3)
5657 if ($titlealt ==
'default') {
5658 $titlealt = $langs->trans(
'Show');
5661 return img_picto($titlealt,
'pdf'.$size.
'.png');
5671function img_edit_add($titlealt =
'default', $other =
'')
5675 if ($titlealt ==
'default') {
5676 $titlealt = $langs->trans(
'Add');
5679 return img_picto($titlealt,
'edit_add.png', $other);
5692 if ($titlealt ==
'default') {
5693 $titlealt = $langs->trans(
'Remove');
5696 return img_picto($titlealt,
'edit_remove.png', $other);
5707function img_edit($titlealt =
'default', $float = 0, $other =
'')
5711 if ($titlealt ==
'default') {
5712 $titlealt = $langs->trans(
'Modify');
5715 return img_picto($titlealt,
'edit.png', ($float ?
'style="float: '.($langs->tab_translate[
"DIRECTION"] ==
'rtl' ?
'left' :
'right').
'"' :
"").($other ?
' '.$other :
''));
5726function img_view($titlealt =
'default', $float = 0, $other =
'class="valignmiddle"')
5730 if ($titlealt ==
'default') {
5731 $titlealt = $langs->trans(
'View');
5734 $moreatt = ($float ?
'style="float: right" ' :
'').$other;
5736 return img_picto($titlealt,
'eye', $moreatt);
5747function img_delete($titlealt =
'default', $other =
'class="pictodelete"', $morecss =
'')
5751 if ($titlealt ==
'default') {
5752 $titlealt = $langs->trans(
'Delete');
5755 return img_picto($titlealt,
'delete.png', $other, 0, 0, 0,
'', $morecss);
5765function img_printer($titlealt =
"default", $other =
'')
5768 if ($titlealt ==
"default") {
5769 $titlealt = $langs->trans(
"Print");
5771 return img_picto($titlealt,
'printer.png', $other);
5781function img_split($titlealt =
'default', $other =
'class="pictosplit"')
5785 if ($titlealt ==
'default') {
5786 $titlealt = $langs->trans(
'Split');
5789 return img_picto($titlealt,
'split.png', $other);
5799function img_help($usehelpcursor = 1, $usealttitle = 1)
5804 if (is_string($usealttitle)) {
5807 $usealttitle = $langs->trans(
'Info');
5811 return img_picto($usealttitle,
'info.png',
'style="vertical-align: middle;'.($usehelpcursor == 1 ?
' cursor: help' : ($usehelpcursor == 2 ?
' cursor: pointer' :
'')).
'"');
5820function img_info($titlealt =
'default')
5824 if ($titlealt ==
'default') {
5825 $titlealt = $langs->trans(
'Informations');
5828 return img_picto($titlealt,
'info.png',
'style="vertical-align: middle;"');
5839function img_warning($titlealt =
'default', $moreatt =
'', $morecss =
'pictowarning')
5843 if ($titlealt ==
'default') {
5844 $titlealt = $langs->trans(
'Warning');
5848 return img_picto($titlealt,
'warning.png',
'class="'.$morecss.
'"'.($moreatt ? ($moreatt ==
'1' ?
' style="float: right"' :
' '.$moreatt) :
''));
5857function img_error($titlealt =
'default')
5861 if ($titlealt ==
'default') {
5862 $titlealt = $langs->trans(
'Error');
5865 return img_picto($titlealt,
'error.png');
5875function img_next($titlealt =
'default', $moreatt =
'')
5879 if ($titlealt ==
'default') {
5880 $titlealt = $langs->trans(
'Next');
5884 return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
5894function img_previous($titlealt =
'default', $moreatt =
'')
5898 if ($titlealt ==
'default') {
5899 $titlealt = $langs->trans(
'Previous');
5903 return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
5914function img_down($titlealt =
'default', $selected = 0, $moreclass =
'')
5918 if ($titlealt ==
'default') {
5919 $titlealt = $langs->trans(
'Down');
5922 return img_picto($titlealt, ($selected ?
'1downarrow_selected.png' :
'1downarrow.png'),
'class="imgdown'.($moreclass ?
" ".$moreclass :
"").
'"');
5933function img_up($titlealt =
'default', $selected = 0, $moreclass =
'')
5937 if ($titlealt ==
'default') {
5938 $titlealt = $langs->trans(
'Up');
5941 return img_picto($titlealt, ($selected ?
'1uparrow_selected.png' :
'1uparrow.png'),
'class="imgup'.($moreclass ?
" ".$moreclass :
"").
'"');
5952function img_left($titlealt =
'default', $selected = 0, $moreatt =
'')
5956 if ($titlealt ==
'default') {
5957 $titlealt = $langs->trans(
'Left');
5960 return img_picto($titlealt, ($selected ?
'1leftarrow_selected.png' :
'1leftarrow.png'), $moreatt);
5971function img_right($titlealt =
'default', $selected = 0, $moreatt =
'')
5975 if ($titlealt ==
'default') {
5976 $titlealt = $langs->trans(
'Right');
5979 return img_picto($titlealt, ($selected ?
'1rightarrow_selected.png' :
'1rightarrow.png'), $moreatt);
5989function img_allow($allow, $titlealt =
'default')
5993 if ($titlealt ==
'default') {
5994 $titlealt = $langs->trans(
'Active');
5998 return img_picto($titlealt,
'tick.png');
6013 if (is_null($morecss)) {
6017 if ($brand ==
'visa' || $brand ==
'Visa') {
6019 } elseif ($brand ==
'mastercard' || $brand ==
'MasterCard') {
6020 $brand =
'cc-mastercard';
6021 } elseif ($brand ==
'amex' || $brand ==
'American Express') {
6023 } elseif ($brand ==
'discover' || $brand ==
'Discover') {
6024 $brand =
'cc-discover';
6025 } elseif ($brand ==
'jcb' || $brand ==
'JCB') {
6027 } elseif ($brand ==
'diners' || $brand ==
'Diners club') {
6028 $brand =
'cc-diners-club';
6029 } elseif (!in_array($brand, array(
'cc-visa',
'cc-mastercard',
'cc-amex',
'cc-discover',
'cc-jcb',
'cc-diners-club'))) {
6030 $brand =
'credit-card';
6033 return '<span class="fa fa-'.$brand.
' fa-fw'.($morecss ?
' '.$morecss :
'').
'"></span>';
6044function img_mime($file, $titlealt =
'', $morecss =
'')
6046 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
6052 if (empty($titlealt)) {
6053 $titlealt =
'Mime type: '.$mimetype;
6057 return '<i class="fa fa-'.$mimefa.
' paddingright'.($morecss ?
' '.$morecss :
'').
'"'.($titlealt ?
' title="'.$titlealt.
'"' :
'').
'></i>';
6068function img_search($titlealt =
'default', $other =
'')
6072 if ($titlealt ==
'default') {
6073 $titlealt = $langs->trans(
'Search');
6076 $img =
img_picto($titlealt,
'search.png', $other, 0, 1);
6078 $input =
'<input type="image" class="liste_titre" name="button_search" src="'.$img.
'" ';
6079 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
6095 if ($titlealt ==
'default') {
6096 $titlealt = $langs->trans(
'Search');
6099 $img =
img_picto($titlealt,
'searchclear.png', $other, 0, 1);
6101 $input =
'<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.
'" ';
6102 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
6119function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin =
'1', $morecss =
'hideonsmartphone', $textfordropdown =
'', $picto =
'')
6121 global
$conf, $langs;
6123 if ($infoonimgalt) {
6124 $result =
img_picto($text,
'info',
'class="'.($morecss ?
' '.$morecss :
'').
'"');
6126 if (empty(
$conf->use_javascript_ajax)) {
6127 $textfordropdown =
'';
6130 $class = (empty($admin) ?
'undefined' : ($admin ==
'1' ?
'info' : $admin));
6131 $fa =
'info-circle';
6132 if ($picto ==
'warning') {
6133 $fa =
'exclamation-triangle';
6135 $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> ';
6137 $result .= ($nodiv ?
'' :
'</div>');
6139 if ($textfordropdown) {
6140 $tmpresult =
'<span class="'.$class.
'text opacitymedium cursorpointer">'.$langs->trans($textfordropdown).
' '.
img_picto($langs->trans($textfordropdown),
'1downarrow').
'</span>';
6141 $tmpresult .=
'<script nonce="'.getNonce().
'" type="text/javascript">
6142 jQuery(document).ready(function() {
6143 jQuery(".'.$class.
'text").click(function() {
6144 console.log("toggle text");
6145 jQuery(".'.$class.
'").toggle();
6150 $result = $tmpresult.$result;
6171 global
$conf, $langs, $user, $argv;
6172 global $dolibarr_main_prod;
6179 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
6181 $langs->load(
"main");
6185 $langs->loadLangs(array(
'main',
'errors'));
6187 if ($_SERVER[
'DOCUMENT_ROOT']) {
6188 $out .= $langs->trans(
"DolibarrHasDetectedError").
".<br>\n";
6190 $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";
6192 $out .= $langs->trans(
"InformationToHelpDiagnose").
":<br>\n";
6194 $out .=
"<b>".$langs->trans(
"Date").
":</b> ".
dol_print_date(time(),
'dayhourlog').
"<br>\n";
6195 $out .=
"<b>".$langs->trans(
"Dolibarr").
":</b> ".DOL_VERSION.
" - https://www.dolibarr.org<br>\n";
6196 if (isset(
$conf->global->MAIN_FEATURES_LEVEL)) {
6197 $out .=
"<b>".$langs->trans(
"LevelOfFeature").
":</b> ".
getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
"<br>\n";
6199 if ($user instanceof
User) {
6200 $out .=
"<b>".$langs->trans(
"Login").
":</b> ".$user->login.
"<br>\n";
6202 if (function_exists(
"phpversion")) {
6203 $out .=
"<b>".$langs->trans(
"PHP").
":</b> ".phpversion().
"<br>\n";
6205 $out .=
"<b>".$langs->trans(
"Server").
":</b> ".(isset($_SERVER[
"SERVER_SOFTWARE"]) ?
dol_htmlentities($_SERVER[
"SERVER_SOFTWARE"], ENT_COMPAT) :
'').
"<br>\n";
6206 if (function_exists(
"php_uname")) {
6207 $out .=
"<b>".$langs->trans(
"OS").
":</b> ".php_uname().
"<br>\n";
6209 $out .=
"<b>".$langs->trans(
"UserAgent").
":</b> ".(isset($_SERVER[
"HTTP_USER_AGENT"]) ?
dol_htmlentities($_SERVER[
"HTTP_USER_AGENT"], ENT_COMPAT) :
'').
"<br>\n";
6211 $out .=
"<b>".$langs->trans(
"RequestedUrl").
":</b> ".
dol_htmlentities($_SERVER[
"REQUEST_URI"], ENT_COMPAT).
"<br>\n";
6212 $out .=
"<b>".$langs->trans(
"Referer").
":</b> ".(isset($_SERVER[
"HTTP_REFERER"]) ?
dol_htmlentities($_SERVER[
"HTTP_REFERER"], ENT_COMPAT) :
'').
"<br>\n";
6213 $out .=
"<b>".$langs->trans(
"MenuManager").
":</b> ".(isset(
$conf->standard_menu) ?
dol_htmlentities(
$conf->standard_menu, ENT_COMPAT) :
'').
"<br>\n";
6215 $syslog .=
"url=".dol_escape_htmltag($_SERVER[
"REQUEST_URI"]);
6216 $syslog .=
", query_string=".dol_escape_htmltag($_SERVER[
"QUERY_STRING"]);
6218 $out .=
'> '.$langs->transnoentities(
"ErrorInternalErrorDetected").
":\n".$argv[0].
"\n";
6219 $syslog .=
"pid=".dol_getmypid();
6222 if (!empty(
$conf->modules)) {
6223 $out .=
"<b>".$langs->trans(
"Modules").
":</b> ".implode(
', ',
$conf->modules).
"<br>\n";
6226 if (is_object($db)) {
6227 if ($_SERVER[
'DOCUMENT_ROOT']) {
6228 $out .=
"<b>".$langs->trans(
"DatabaseTypeManager").
":</b> ".$db->type.
"<br>\n";
6229 $lastqueryerror = $db->lastqueryerror();
6231 $lastqueryerror =
"SQL error string is not a valid UTF8 string. We can't show it.";
6233 $out .=
"<b>".$langs->trans(
"RequestLastAccessInError").
":</b> ".($lastqueryerror ?
dol_escape_htmltag($lastqueryerror) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6234 $out .=
"<b>".$langs->trans(
"ReturnCodeLastAccessInError").
":</b> ".($db->lasterrno() ?
dol_escape_htmltag($db->lasterrno()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6235 $out .=
"<b>".$langs->trans(
"InformationLastAccessInError").
":</b> ".($db->lasterror() ?
dol_escape_htmltag($db->lasterror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
6239 $out .=
'> '.$langs->transnoentities(
"DatabaseTypeManager").
":\n".$db->type.
"\n";
6240 $out .=
'> '.$langs->transnoentities(
"RequestLastAccessInError").
":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6241 $out .=
'> '.$langs->transnoentities(
"ReturnCodeLastAccessInError").
":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6242 $out .=
'> '.$langs->transnoentities(
"InformationLastAccessInError").
":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
6244 $syslog .=
", sql=".$db->lastquery();
6245 $syslog .=
", db_error=".$db->lasterror();
6248 if ($error || $errors) {
6250 if (is_array($error) && is_array($errors)) {
6251 $errors = array_merge($error, $errors);
6252 } elseif (is_array($error)) {
6254 } elseif (is_array($errors) && !empty($error)) {
6255 $errors = array_merge(array($error), $errors);
6256 } elseif (!empty($error)) {
6257 $errors = array_merge(array($error), array($errors));
6260 $langs->load(
"errors");
6262 foreach ($errors as $msg) {
6266 if ($_SERVER[
'DOCUMENT_ROOT']) {
6269 $out .=
'> '.$langs->transnoentities(
"Message").
":\n".$msg.
"\n";
6271 $syslog .=
", msg=".$msg;
6274 if (empty($dolibarr_main_prod) && $_SERVER[
'DOCUMENT_ROOT'] && function_exists(
'xdebug_print_function_stack') && function_exists(
'xdebug_call_file')) {
6275 xdebug_print_function_stack();
6276 $out .=
'<b>XDebug information:</b>'.
"<br>\n";
6277 $out .=
'File: '.xdebug_call_file().
"<br>\n";
6278 $out .=
'Line: '.xdebug_call_line().
"<br>\n";
6279 $out .=
'Function: '.xdebug_call_function().
"<br>\n";
6284 if (!headers_sent()) {
6285 if (function_exists(
'top_httphead')) {
6289 http_response_code(202);
6292 if (empty($dolibarr_main_prod)) {
6295 if (empty($langs->defaultlang)) {
6296 $langs->setDefaultLang();
6298 $langs->loadLangs(array(
"main",
"errors"));
6300 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";
6301 print $langs->trans(
"DolibarrHasDetectedError").
'. ';
6302 print $langs->trans(
"YouCanSetOptionDolibarrMainProdToZero");
6303 if (!defined(
"MAIN_CORE_ERROR")) {
6304 define(
"MAIN_CORE_ERROR", 1);
6321function dol_print_error_email($prefixcode, $errormessage =
'', $errormessages = array(), $morecss =
'error', $email =
'')
6325 if (empty($email)) {
6329 $langs->load(
"errors");
6332 print
'<br><div class="center login_main_message"><div class="'.$morecss.
'">';
6333 print $langs->trans(
"ErrorContactEMail", $email, $prefixcode.
'-'.
dol_print_date($now,
'%Y%m%d%H%M%S'));
6334 if ($errormessage) {
6335 print
'<br><br>'.$errormessage;
6337 if (is_array($errormessages) && count($errormessages)) {
6338 foreach ($errormessages as $mesgtoshow) {
6339 print
'<br><br>'.$mesgtoshow;
6342 print
'</div></div>';
6361function print_liste_field_titre($name, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $tooltip =
"", $forcenowrapcolumntitle = 0)
6363 print
getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip, $forcenowrapcolumntitle);
6384function getTitleFieldOfList($name, $thead = 0, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $disablesortlink = 0, $tooltip =
'', $forcenowrapcolumntitle = 0)
6386 global $langs, $form;
6389 if ($moreattrib ==
'class="right"') {
6390 $prefix .=
'right ';
6393 $sortorder = strtoupper($sortorder);
6402 $tmpsortfield = explode(
',', $sortfield);
6403 $sortfield1 = trim($tmpsortfield[0]);
6404 $tmpfield = explode(
',', $field);
6405 $field1 = trim($tmpfield[0]);
6407 if (!
getDolGlobalString(
'MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE') && empty($forcenowrapcolumntitle)) {
6408 $prefix =
'wrapcolumntitle '.$prefix;
6414 $liste_titre =
'liste_titre';
6415 if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace(
"/^[^\.]+\./",
"", $field1))) {
6416 $liste_titre =
'liste_titre_sel';
6419 $tagstart =
'<'.$tag.
' class="'.$prefix.$liste_titre.
'" '.$moreattrib;
6424 if (empty($thead) && $field && empty($disablesortlink)) {
6425 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6426 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6427 $options = preg_replace(
'/&+/i',
'&', $options);
6428 if (!preg_match(
'/^&/', $options)) {
6429 $options =
'&'.$options;
6432 $sortordertouseinlink =
'';
6433 if ($field1 != $sortfield1) {
6434 if (preg_match(
'/^DESC/i', $sortorder)) {
6435 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6437 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6440 if (preg_match(
'/^ASC/i', $sortorder)) {
6441 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6443 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6446 $sortordertouseinlink = preg_replace(
'/,$/',
'', $sortordertouseinlink);
6447 $out .=
'<a class="reposition" href="'.$file.
'?sortfield='.$field.
'&sortorder='.$sortordertouseinlink.
'&begin='.$begin.$options.
'"';
6453 if (preg_match(
'/:\w+$/', $tooltip)) {
6454 $tmptooltip = explode(
':', $tooltip);
6456 $tmptooltip = array($tooltip);
6458 $out .= $form->textwithpicto($langs->trans($name), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.str_replace(
'.',
'_', $field).
'_'.$tmptooltip[1]));
6460 $out .= $langs->trans($name);
6463 if (empty($thead) && $field && empty($disablesortlink)) {
6467 if (empty($thead) && $field) {
6468 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6469 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6470 $options = preg_replace(
'/&+/i',
'&', $options);
6471 if (!preg_match(
'/^&/', $options)) {
6472 $options =
'&'.$options;
6475 if (!$sortorder || ($field1 != $sortfield1)) {
6479 if (preg_match(
'/^DESC/', $sortorder)) {
6482 $sortimg .=
'<span class="nowrap">'.img_up(
"Z-A", 0,
'paddingright').
'</span>';
6484 if (preg_match(
'/^ASC/', $sortorder)) {
6487 $sortimg .=
'<span class="nowrap">'.img_down(
"A-Z", 0,
'paddingright').
'</span>';
6492 $tagend =
'</'.$tag.
'>';
6494 $out = $tagstart.$sortimg.$out.$tagend;
6509 dol_syslog(__FUNCTION__.
" is deprecated", LOG_WARNING);
6511 print
'<div class="titre">'.$title.
'</div>';
6525function print_fiche_titre($title, $mesg =
'', $picto =
'generic', $pictoisfullpath = 0,
$id =
'')
6543function load_fiche_titre($title, $morehtmlright =
'', $picto =
'generic', $pictoisfullpath = 0,
$id =
'', $morecssontable =
'', $morehtmlcenter =
'')
6547 if ($picto ==
'setup') {
6552 $return .=
'<table '.($id ?
'id="'.$id.
'" ' :
'').
'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ?
' '.$morecssontable :
'').
'">';
6553 $return .=
'<tr class="toptitle">';
6555 $return .=
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).
'</td>';
6557 $return .=
'<td class="nobordernopadding valignmiddle col-title">';
6558 $return .=
'<div class="titre inline-block">';
6559 $return .=
'<span class="inline-block valignmiddle">'.$title.
'</span>';
6560 $return .=
'</div>';
6563 $return .=
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
6566 $return .=
'<td class="nobordernopadding titre_right wordbreakimp right valignmiddle col-right">'.$morehtmlright.
'</td>';
6568 $return .=
'</tr></table>'.
"\n";
6596function print_barre_liste($title, $page, $file, $options =
'', $sortfield =
'', $sortorder =
'', $morehtmlcenter =
'', $num = -1, $totalnboflines =
'', $picto =
'generic', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limit = -1, $selectlimitsuffix = 0, $hidenavigation = 0, $pagenavastextinput = 0, $morehtmlrightbeforearrow =
'')
6598 global
$conf, $langs;
6601 $savtotalnboflines = $totalnboflines;
6602 if (is_numeric($totalnboflines)) {
6603 $totalnboflines = abs($totalnboflines);
6608 $tmparray = preg_split(
'/<br>/i', $title, 2);
6609 if (!empty($tmparray[1])) {
6610 $title = $tmparray[0];
6611 $subtitle = $tmparray[1];
6614 $page = (int) $page;
6616 if ($picto ==
'setup') {
6617 $picto =
'title_setup.png';
6619 if ((
$conf->browser->name ==
'ie') && $picto ==
'generic') {
6620 $picto =
'title.gif';
6623 $limit =
$conf->liste_limit;
6626 if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
6634 print
"<!-- Begin print_barre_liste -->\n";
6635 print
'<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ?
' '.$morecss :
'').
'">';
6636 print
'<tr class="toptitle">';
6640 if ($picto && $title) {
6641 print
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">';
6642 print
img_picto(
'', $picto,
'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath);
6646 print
'<td class="nobordernopadding valignmiddle col-title">';
6647 print
'<div class="titre inline-block">';
6648 print
'<span class="inline-block valignmiddle print-barre-liste">'.$title.
'</span>';
6649 if (!empty($title) && $savtotalnboflines >= 0 && (
string) $savtotalnboflines !=
'' && $totalnboflines > 0) {
6650 print
'<span class="opacitymedium colorblack marginleftonly totalnboflines valignmiddle" title="'.$langs->trans(
"NbRecordQualified").
'">('.$totalnboflines.
')</span>';
6653 if (!empty($subtitle)) {
6654 print
'<br><div class="subtitle inline-block hideonsmartphone">'.$subtitle.
'</div>';
6659 if ($morehtmlcenter && empty(
$conf->dol_optimize_smallscreen)) {
6660 print
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
6664 print
'<td class="nobordernopadding valignmiddle right col-right">';
6665 print
'<input type="hidden" name="pageplusoneold" value="'.((int) $page + 1).
'">';
6667 $options .=
"&sortfield=".urlencode($sortfield);
6670 $options .=
"&sortorder=".urlencode($sortorder);
6674 if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
6675 if ($totalnboflines) {
6677 $maxnbofpage = (empty(
$conf->dol_optimize_smallscreen) ? 4 : 0);
6680 $nbpages = ceil($totalnboflines / $limit);
6684 $cpt = ($page - $maxnbofpage);
6690 if (empty($pagenavastextinput)) {
6691 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page=0'.$options.
'">1</a></li>';
6693 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
6694 } elseif ($cpt == 2) {
6695 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page=1'.$options.
'">2</a></li>';
6701 if ($pagenavastextinput) {
6702 if ($cpt == $page) {
6703 $pagelist .=
'<li class="pagination pageplusone valignmiddle"><input type="text" class="'.($totalnboflines > 100 ?
'width40' :
'width25').
' center pageplusone" name="pageplusone" value="'.($page + 1).
'"></li>';
6707 if ($cpt == $page) {
6708 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
'</span></li>';
6710 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.$cpt.$options.
'">'.($cpt + 1).
'</a></li>';
6714 }
while ($cpt < $nbpages && $cpt <= ($page + $maxnbofpage));
6716 if (empty($pagenavastextinput)) {
6717 if ($cpt < $nbpages) {
6718 if ($cpt < $nbpages - 2) {
6719 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
6720 } elseif ($cpt == $nbpages - 2) {
6721 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.($nbpages - 2).$options.
'">'.($nbpages - 1).
'</a></li>';
6723 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
6727 $pagelist .=
'<li class="pagination paginationlastpage"><a class="reposition" href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
6730 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
"</li>";
6734 if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
6735 print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $selectlimitsuffix, $morehtmlrightbeforearrow, $hidenavigation);
6739 if ($pagenavastextinput) {
6746 print
'</table>'.
"\n";
6749 if ($morehtmlcenter && !empty(
$conf->dol_optimize_smallscreen)) {
6750 print
'<div class="nobordernopadding marginbottomonly center valignmiddle col-center centpercent">'.$morehtmlcenter.
'</div>';
6753 print
"<!-- End title -->\n\n";
6772function print_fleche_navigation($page, $file, $options =
'', $nextpage = 0, $betweenarrows =
'', $afterarrows =
'', $limit = -1, $totalnboflines = 0, $selectlimitsuffix =
'', $beforearrows =
'', $hidenavigation = 0)
6774 global
$conf, $langs;
6776 print
'<div class="pagination"><ul>';
6777 if ($beforearrows) {
6778 print
'<li class="paginationbeforearrows">';
6779 print $beforearrows;
6783 if (empty($hidenavigation)) {
6784 if ((
int) $limit > 0 && (empty($selectlimitsuffix) || !is_numeric($selectlimitsuffix))) {
6785 $pagesizechoices =
'10:10,15:15,20:20,25:25,50:50,100:100,250:250,500:500,1000:1000';
6786 $pagesizechoices .=
',5000:5000';
6796 print
'<li class="pagination">';
6797 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.
'">';
6798 print
'<datalist id="limitlist">';
6800 print
'<li class="paginationcombolimit valignmiddle">';
6801 print
'<select id="limit'.(is_numeric($selectlimitsuffix) ?
'' : $selectlimitsuffix).
'" name="limit" class="flat selectlimit nopadding maxwidth75 center'.(is_numeric($selectlimitsuffix) ?
'' :
' '.$selectlimitsuffix).
'" title="'.
dol_escape_htmltag($langs->trans(
"MaxNbOfRecordPerPage")).
'">';
6803 $tmpchoice = explode(
',', $pagesizechoices);
6804 $tmpkey = $limit.
':'.$limit;
6805 if (!in_array($tmpkey, $tmpchoice)) {
6806 $tmpchoice[$tmpkey] = $tmpkey;
6808 $tmpkey =
$conf->liste_limit.
':'.
$conf->liste_limit;
6809 if (!in_array($tmpkey, $tmpchoice)) {
6810 $tmpchoice[$tmpkey] = $tmpkey;
6812 asort($tmpchoice, SORT_NUMERIC);
6813 foreach ($tmpchoice as $val) {
6815 $tmp = explode(
':', $val);
6818 if ($key !=
'' && $val !=
'') {
6819 if ((
int) $key == (
int) $limit) {
6820 $selected =
' selected="selected"';
6822 print
'<option name="'.$key.
'"'.$selected.
'>'.
dol_escape_htmltag($val).
'</option>'.
"\n";
6826 print
'</datalist>';
6829 print
ajax_combobox(
"limit".(is_numeric($selectlimitsuffix) ?
'' : $selectlimitsuffix), array(), 0, 0,
'resolve',
'-1',
'limit');
6833 if (
$conf->use_javascript_ajax) {
6834 print
'<!-- JS CODE TO ENABLE select limit to launch submit of page -->
6836 jQuery(document).ready(function () {
6837 jQuery(".selectlimit").change(function() {
6838 console.log("We change limit so we submit the form");
6839 $(this).parents(\'form:first\').submit();
6848 print
'<li class="pagination paginationpage paginationpageleft"><a class="paginationprevious reposition" href="'.$file.
'?page='.($page - 1).$options.
'"><i class="fa fa-chevron-left" title="'.
dol_escape_htmltag($langs->trans(
"Previous")).
'"></i></a></li>';
6850 if ($betweenarrows) {
6851 print
'<!--<div class="betweenarrows nowraponall inline-block">-->';
6852 print $betweenarrows;
6853 print
'<!--</div>-->';
6855 if ($nextpage > 0) {
6856 print
'<li class="pagination paginationpage paginationpageright"><a class="paginationnext reposition" href="'.$file.
'?page='.($page + 1).$options.
'"><i class="fa fa-chevron-right" title="'.
dol_escape_htmltag($langs->trans(
"Next")).
'"></i></a></li>';
6859 print
'<li class="paginationafterarrows">';
6864 print
'</ul></div>'.
"\n";
6879function vatrate($rate, $addpercent =
false, $info_bits = 0, $usestarfornpr = 0, $html = 0)
6883 if (preg_match(
'/%/', $rate)) {
6884 $rate = str_replace(
'%',
'', $rate);
6888 if (preg_match(
'/\((.*)\)/', $rate, $reg)) {
6889 $morelabel =
' ('.$reg[1].
')';
6890 $rate = preg_replace(
'/\s*'.preg_quote($morelabel,
'/').
'/',
'', $rate);
6891 $morelabel =
' '.($html ?
'<span class="opacitymedium">' :
'').
'('.$reg[1].
')'.($html ?
'</span>' :
'');
6893 if (preg_match(
'/\*/', $rate)) {
6894 $rate = str_replace(
'*',
'', $rate);
6899 if (!preg_match(
'/\//', $rate)) {
6900 $ret =
price($rate, 0,
'', 0, 0).($addpercent ?
'%' :
'');
6903 $ret = $rate.($addpercent ?
'%' :
'');
6905 if (($info_bits & 1) && $usestarfornpr >= 0) {
6928function price($amount, $form = 0, $outlangs =
'', $trunc = 1, $rounding = -1, $forcerounding = -1, $currency_code =
'')
6930 global $langs,
$conf;
6933 if (empty($amount)) {
6936 $amount = (is_numeric($amount) ? $amount : 0);
6937 if ($rounding == -1) {
6940 $nbdecimal = $rounding;
6942 if ($outlangs ===
'none') {
6952 if (!($outlangs instanceof
Translate)) {
6956 if ($outlangs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
6957 $dec = $outlangs->transnoentitiesnoconv(
"SeparatorDecimal");
6959 if ($outlangs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
6960 $thousand = $outlangs->transnoentitiesnoconv(
"SeparatorThousand");
6962 if ($thousand ==
'None') {
6964 } elseif ($thousand ==
'Space') {
6971 $amount = str_replace(
',',
'.', $amount);
6973 $data = explode(
'.', $amount);
6974 $decpart = isset($data[1]) ? $data[1] :
'';
6975 $decpart = preg_replace(
'/0+$/i',
'', $decpart);
6985 $nbdecimalmaxshown = (int) str_replace(
'...',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN'));
6986 if ($trunc && $nbdecimal > $nbdecimalmaxshown) {
6987 $nbdecimal = $nbdecimalmaxshown;
6995 if ((
string) $forcerounding !=
'-1') {
6996 if ($forcerounding ===
'MU') {
6998 } elseif ($forcerounding ===
'MT') {
7000 } elseif ($forcerounding >= 0) {
7001 $nbdecimal = $forcerounding;
7006 $output = number_format((
float) $amount, $nbdecimal, $dec, $thousand);
7008 $output = preg_replace(
'/\s/',
' ', $output);
7009 $output = preg_replace(
'/\'/',
''', $output);
7012 $cursymbolbefore = $cursymbolafter =
'';
7013 if ($currency_code && is_object($outlangs)) {
7014 if ($currency_code ==
'auto') {
7015 $currency_code =
$conf->currency;
7018 $listofcurrenciesbefore = array(
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD',
'CRC',
'ZAR');
7019 $listoflanguagesbefore = array(
'nl_NL');
7020 if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) {
7021 $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
7023 $tmpcur = $outlangs->getCurrencySymbol($currency_code);
7024 $cursymbolafter .= ($tmpcur == $currency_code ?
' '.$tmpcur : $tmpcur);
7027 $output = $cursymbolbefore.$output.$end.($cursymbolafter ?
' ' :
'').$cursymbolafter;
7056function price2num($amount, $rounding =
'', $option = 0)
7058 global $langs,
$conf;
7061 if (is_null($amount)) {
7070 if (is_null($langs)) {
7074 if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
7075 $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
7077 if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
7078 $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
7081 if ($thousand ==
'None') {
7083 } elseif ($thousand ==
'Space') {
7091 if (!is_numeric($amount)) {
7092 $amount = preg_replace(
'/[a-zA-Z\/\\\*\(\)<>\_]/',
'', $amount);
7095 if ($option == 2 && $thousand ==
'.' && preg_match(
'/\.(\d\d\d)$/', (
string) $amount)) {
7096 $amount = str_replace($thousand,
'', $amount);
7102 if (is_numeric($amount)) {
7104 $temps = sprintf(
"%10.10F", $amount - intval($amount));
7105 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
7107 $amount = number_format($amount, $nbofdec, $dec, $thousand);
7112 if ($thousand !=
',' && $thousand !=
'.') {
7113 $amount = str_replace(
',',
'.', $amount);
7116 $amount = str_replace(
' ',
'', $amount);
7117 $amount = str_replace($thousand,
'', $amount);
7118 $amount = str_replace($dec,
'.', $amount);
7120 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
7126 $nbofdectoround =
'';
7127 if ($rounding ==
'MU') {
7129 } elseif ($rounding ==
'MT') {
7131 } elseif ($rounding ==
'MS') {
7132 $nbofdectoround = isset(
$conf->global->MAIN_MAX_DECIMALS_STOCK) ?
$conf->global->MAIN_MAX_DECIMALS_STOCK : 5;
7133 } elseif ($rounding ==
'CU') {
7135 } elseif ($rounding ==
'CT') {
7137 } elseif (is_numeric($rounding)) {
7138 $nbofdectoround = (int) $rounding;
7143 $amount = round(is_string($amount) ? (
float) $amount : $amount, $nbofdectoround);
7145 return 'ErrorBadParameterProvidedToFunction';
7151 if (is_numeric($amount)) {
7153 $temps = sprintf(
"%10.10F", $amount - intval($amount));
7154 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
7156 $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand);
7162 if ($thousand !=
',' && $thousand !=
'.') {
7163 $amount = str_replace(
',',
'.', $amount);
7166 $amount = str_replace(
' ',
'', $amount);
7167 $amount = str_replace($thousand,
'', $amount);
7168 $amount = str_replace($dec,
'.', $amount);
7170 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
7188function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput =
'no', $use_short_label = 0)
7190 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
7192 if (($forceunitoutput ==
'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
7193 $dimension *= 1000000;
7195 } elseif (($forceunitoutput ==
'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) {
7198 } elseif (($forceunitoutput ==
'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) {
7199 $dimension /= 1000000;
7201 } elseif (($forceunitoutput ==
'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) {
7218 $ret =
price($dimension, 0, $outputlangs, 0, 0, $round);
7220 $ret .=
' '.measuringUnitString(0, $type, (
string) $unit, $use_short_label, $outputlangs);
7238function get_localtax($vatrate, $local, $thirdparty_buyer =
null, $thirdparty_seller =
null, $vatnpr = 0)
7240 global $db,
$conf, $mysoc;
7242 if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) {
7243 $thirdparty_seller = $mysoc;
7246 dol_syslog(
"get_localtax tva=".$vatrate.
" local=".$local.
" thirdparty_buyer id=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->id :
'').
"/country_code=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code :
'').
" thirdparty_seller id=".$thirdparty_seller->id.
"/country_code=".$thirdparty_seller->country_code.
" thirdparty_seller localtax1_assuj=".$thirdparty_seller->localtax1_assuj.
" thirdparty_seller localtax2_assuj=".$thirdparty_seller->localtax2_assuj);
7248 $vatratecleaned = $vatrate;
7250 if (preg_match(
'/^(.*)\s*\((.*)\)$/', (
string) $vatrate, $reg)) {
7251 $vatratecleaned = trim($reg[1]);
7252 $vatratecode = $reg[2];
7261 if ($mysoc->country_code ==
'ES') {
7263 if (!$mysoc->localtax1_assuj || (
string) $vatratecleaned ==
"0") {
7266 if ($thirdparty_seller->id == $mysoc->id) {
7267 if (!$thirdparty_buyer->localtax1_assuj) {
7271 if (!$thirdparty_seller->localtax1_assuj) {
7279 if (!$mysoc->localtax2_assuj) {
7282 if ($thirdparty_seller->id == $mysoc->id) {
7283 if (!$thirdparty_buyer->localtax2_assuj) {
7287 if (!$thirdparty_seller->localtax2_assuj) {
7293 if ($local == 1 && !$thirdparty_seller->localtax1_assuj) {
7296 if ($local == 2 && !$thirdparty_seller->localtax2_assuj) {
7302 if (in_array($mysoc->country_code, array(
'ES'))) {
7303 $conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY = 1;
7309 if ($thirdparty_seller != $mysoc) {
7311 return $thirdparty_seller->localtax1_value;
7320 if ($thirdparty_seller != $mysoc) {
7323 return $thirdparty_seller->localtax2_value;
7326 if (in_array($mysoc->country_code, array(
'ES'))) {
7327 return $thirdparty_buyer->localtax2_value;
7336 $sql =
"SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
7337 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7338 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdparty_seller->country_code).
"'";
7339 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7340 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7341 if (!empty($vatratecode)) {
7342 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
7344 $sql .=
" AND t.recuperableonly = '".$db->escape($vatnpr).
"'";
7347 $resql = $db->query($sql);
7350 $obj = $db->fetch_object($resql);
7353 return $obj->localtax1;
7354 } elseif ($local == 2) {
7355 return $obj->localtax2;
7376 $valors = explode(
":", $tax);
7378 if (count($valors) > 1) {
7395 $sql =
" SELECT t.localtax".$local.
" as localtax";
7396 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t INNER JOIN ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid = t.fk_pays";
7397 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.active = 1 AND t.entity IN (".
getEntity(
'c_tva').
") AND t.taux = (";
7398 $sql .=
"SELECT MAX(tt.taux) FROM ".MAIN_DB_PREFIX.
"c_tva as tt INNER JOIN ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid = tt.fk_pays";
7399 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.entity IN (".
getEntity(
'c_tva').
") AND tt.active = 1)";
7400 $sql .=
" AND t.localtax".$local.
"_type <> '0'";
7401 $sql .=
" ORDER BY t.rowid DESC";
7403 $resql = $db->query($sql);
7405 $obj = $db->fetch_object($resql);
7407 return $obj->localtax;
7428function getTaxesFromId($vatrate, $buyer =
null, $seller =
null, $firstparamisid = 1)
7432 dol_syslog(
"getTaxesFromId vat id or rate = ".$vatrate);
7435 $sql =
"SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy,";
7436 $sql .=
" t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
7437 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
7438 if ($firstparamisid) {
7439 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
7441 $vatratecleaned = $vatrate;
7444 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
7445 $vatratecleaned = $reg[1];
7446 $vatratecode = $reg[2];
7449 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
7452 $sql .=
" WHERE t.fk_pays = c.rowid";
7454 $sql .=
" AND c.code = '".$db->escape($buyer->country_code).
"'";
7456 $sql .=
" AND c.code = '".$db->escape($seller->country_code).
"'";
7458 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7459 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7461 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
7465 $resql = $db->query($sql);
7467 $obj = $db->fetch_object($resql);
7470 'rowid' => $obj->rowid,
7471 'code' => $obj->code,
7472 'rate' => $obj->rate,
7473 'localtax1' => $obj->localtax1,
7474 'localtax1_type' => $obj->localtax1_type,
7475 'localtax2' => $obj->localtax2,
7476 'localtax2_type' => $obj->localtax2_type,
7478 'accountancy_code_sell' => $obj->accountancy_code_sell,
7479 'accountancy_code_buy' => $obj->accountancy_code_buy
7511 dol_syslog(
"getLocalTaxesFromRate vatrate=".$vatrate.
" local=".$local);
7514 $sql =
"SELECT t.taux as rate, t.code, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
7515 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
7516 if ($firstparamisid) {
7517 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
7519 $vatratecleaned = $vatrate;
7522 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
7523 $vatratecleaned = $reg[1];
7524 $vatratecode = $reg[2];
7527 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
7528 if (!empty($mysoc) && $mysoc->country_code ==
'ES') {
7529 $countrycodetouse = ((empty($buyer) || empty($buyer->country_code)) ? $mysoc->country_code : $buyer->country_code);
7530 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
7532 $countrycodetouse = ((empty($seller) || empty($seller->country_code)) ? $mysoc->country_code : $seller->country_code);
7533 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
7535 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7537 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
7541 $resql = $db->query($sql);
7543 $obj = $db->fetch_object($resql);
7546 $vateratestring = $obj->rate.($obj->code ?
' ('.$obj->code.
')' :
'');
7549 return array($obj->localtax1_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
7550 } elseif ($local == 2) {
7551 return array($obj->localtax2_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
7553 return array($obj->localtax1_type,
get_localtax($vateratestring, 1, $buyer, $seller), $obj->localtax2_type,
get_localtax($vateratestring, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
7575 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
7583 $product->fetch($idprod);
7585 if (($mysoc->country_code == $thirdpartytouse->country_code)
7586 || (in_array($mysoc->country_code, array(
'FR',
'MC')) && in_array($thirdpartytouse->country_code, array(
'FR',
'MC')))
7587 || (in_array($mysoc->country_code, array(
'MQ',
'GP')) && in_array($thirdpartytouse->country_code, array(
'MQ',
'GP')))
7590 if ($idprodfournprice > 0) {
7591 $result = $product->get_buyprice($idprodfournprice, 0, 0, 0);
7593 $ret = $product->vatrate_supplier;
7594 if ($product->default_vat_code_supplier) {
7595 $ret .=
' ('.$product->default_vat_code_supplier.
')';
7601 $ret = $product->tva_tx;
7602 if ($product->default_vat_code) {
7603 $ret .=
' ('.$product->default_vat_code.
')';
7616 $sql =
"SELECT t.taux as vat_rate, t.code as default_vat_code";
7617 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7618 $sql .=
" WHERE t.active = 1 AND t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdpartytouse->country_code).
"'";
7619 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7620 $sql .=
" ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC";
7621 $sql .= $db->plimit(1);
7623 $resql = $db->query($sql);
7625 $obj = $db->fetch_object($resql);
7627 $ret = $obj->vat_rate;
7628 if ($obj->default_vat_code) {
7629 $ret .=
' ('.$obj->default_vat_code.
')';
7653 dol_syslog(
"get_product_vat_for_country: ret=".$ret);
7670 if (!class_exists(
'Product')) {
7671 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
7680 $result = $product->fetch($idprod);
7682 if ($mysoc->country_code == $thirdpartytouse->country_code) {
7696 $sql =
"SELECT taux as vat_rate, localtax1, localtax2";
7697 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7698 $sql .=
" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdpartytouse->country_code).
"'";
7699 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7700 $sql .=
" ORDER BY t.taux DESC, t.recuperableonly ASC";
7701 $sql .= $db->plimit(1);
7703 $resql = $db->query($sql);
7705 $obj = $db->fetch_object($resql);
7708 $ret = $obj->localtax1;
7709 } elseif ($local == 2) {
7710 $ret = $obj->localtax2;
7718 dol_syslog(
"get_product_localtax_for_country: ret=".$ret);
7743 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
7746 $seller_use_vat = ((is_numeric($thirdparty_seller->tva_assuj) && !$thirdparty_seller->tva_assuj) || (!is_numeric($thirdparty_seller->tva_assuj) && $thirdparty_seller->tva_assuj ==
'franchise')) ? 0 : 1;
7748 $seller_country_code = $thirdparty_seller->country_code;
7749 $seller_in_cee =
isInEEC($thirdparty_seller);
7751 $buyer_country_code = $thirdparty_buyer->country_code;
7752 $buyer_in_cee =
isInEEC($thirdparty_buyer);
7754 dol_syslog(
"get_default_tva: seller use vat=".$seller_use_vat.
", seller country=".$seller_country_code.
", seller in cee=".((
string) (
int) $seller_in_cee).
", buyer vat number=".$thirdparty_buyer->tva_intra.
" buyer country=".$buyer_country_code.
", buyer in cee=".((
string) (
int) $buyer_in_cee).
", idprod=".$idprod.
", idprodfournprice=".$idprodfournprice.
", SERVICE_ARE_ECOMMERCE_200238EC=".(
getDolGlobalString(
'SERVICE_ARE_ECOMMERCE_200238EC') ?
$conf->global->SERVICE_ARE_ECOMMERCE_200238EC :
''));
7759 if ($seller_in_cee && $buyer_in_cee) {
7760 $isacompany = $thirdparty_buyer->isACompany();
7761 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
7762 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
7776 if (!$seller_use_vat) {
7782 if (!empty($thirdparty_buyer->state_id)) {
7783 $sql =
"SELECT d.rowid, t.taux as vat_default_rate, t.code as vat_default_code ";
7784 $sql .=
" FROM ".$db->prefix().
"c_tva as t";
7785 $sql .=
" INNER JOIN ".$db->prefix().
"c_departements as d ON t.fk_department_buyer = d.rowid";
7786 $sql .=
" WHERE d.rowid = ".((int) $thirdparty_buyer->state_id);
7787 $sql .=
" ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC";
7789 $res = $db->query($sql);
7791 if ($db->num_rows($res)) {
7792 $obj = $db->fetch_object($res);
7793 return $obj->vat_default_rate.
' ('.$obj->vat_default_code.
')';
7800 if (($seller_country_code == $buyer_country_code)
7801 || (in_array($seller_country_code, array(
'FR',
'MC')) && in_array($buyer_country_code, array(
'FR',
'MC')))
7802 || (in_array($seller_country_code, array(
'MQ',
'GP')) && in_array($buyer_country_code, array(
'MQ',
'GP')))
7807 if ($seller_country_code ==
'IN' &&
getDolGlobalString(
'MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA')) {
7811 if (preg_match(
'/C+S-(\d+)/', $tmpvat, $reg) && $thirdparty_seller->state_id != $thirdparty_buyer->state_id) {
7813 $tmpvat = str_replace(
"C+S",
"I", $tmpvat);
7814 } elseif (preg_match(
'/I-(\d+)/', $tmpvat, $reg) && $thirdparty_seller->state_id == $thirdparty_buyer->state_id) {
7816 $tmpvat = str_replace(
"I",
"C+S", $tmpvat);
7828 if (($seller_in_cee && $buyer_in_cee)) {
7829 $isacompany = $thirdparty_buyer->isACompany();
7830 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
7831 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
7848 if (
getDolGlobalString(
'MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC') && empty($buyer_in_cee)) {
7849 $isacompany = $thirdparty_buyer->isACompany();
7877 if ($idprodfournprice > 0) {
7878 if (!class_exists(
'ProductFournisseur')) {
7879 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
7882 $prodprice->fetch_product_fournisseur_price($idprodfournprice);
7883 return $prodprice->fourn_tva_npr;
7884 } elseif ($idprod > 0) {
7885 if (!class_exists(
'Product')) {
7886 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
7889 $prod->fetch($idprod);
7890 return $prod->tva_npr;
7913 if (!is_object($thirdparty_seller)) {
7916 if (!is_object($thirdparty_buyer)) {
7921 if ($mysoc->country_code ==
'ES') {
7922 if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) {
7927 if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) {
7930 if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj ==
'localtax1off') {
7934 } elseif ($local == 2) {
7936 if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) {
7939 if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj ==
'localtax2off') {
7944 if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
7959function yn($yesno, $format = 1, $color = 0)
7963 $result =
'unknown';
7965 if ($yesno == 1 || (isset($yesno) && (strtolower($yesno) ==
'yes' || strtolower($yesno) ==
'true'))) {
7966 $result = $langs->trans(
'yes');
7967 if ($format == 1 || $format == 3) {
7968 $result = $langs->trans(
"Yes");
7971 $result =
'<input type="checkbox" value="1" checked disabled>';
7974 $result =
'<input type="checkbox" value="1" checked disabled> '.$result;
7976 if ($format == 4 || !is_numeric($format)) {
7977 $result =
img_picto(is_numeric($format) ?
'' : $format,
'check');
7981 } elseif ($yesno == 0 || strtolower($yesno) ==
'no' || strtolower($yesno) ==
'false') {
7982 $result = $langs->trans(
"no");
7983 if ($format == 1 || $format == 3) {
7984 $result = $langs->trans(
"No");
7987 $result =
'<input type="checkbox" value="0" disabled>';
7990 $result =
'<input type="checkbox" value="0" disabled> '.$result;
7992 if ($format == 4 || !is_numeric($format)) {
7993 $result =
img_picto(is_numeric($format) ?
'' : $format,
'uncheck');
7999 $classname =
'error';
8003 return '<span class="'.$classname.
'">'.$result.
'</span>';
8026function get_exdir($num, $level, $alpha, $withoutslash,
$object, $modulepart =
'')
8028 if (empty($modulepart) && is_object(
$object)) {
8029 if (!empty(
$object->module)) {
8030 $modulepart =
$object->module;
8031 } elseif (!empty(
$object->element)) {
8032 $modulepart =
$object->element;
8039 $arrayforoldpath = array(
'cheque' => 2,
'category' => 2,
'holiday' => 2,
'supplier_invoice' => 2,
'invoice_supplier' => 2,
'mailing' => 2,
'supplier_payment' => 2);
8041 $arrayforoldpath[
'product'] = 2;
8044 if (empty($level) && array_key_exists($modulepart, $arrayforoldpath)) {
8045 $level = $arrayforoldpath[$modulepart];
8047 if (!empty($level) && array_key_exists($modulepart, $arrayforoldpath)) {
8049 if (empty($num) && is_object(
$object)) {
8052 if (empty($alpha)) {
8053 $num = preg_replace(
'/([^0-9])/i',
'', $num);
8055 $num = preg_replace(
'/^.*\-/i',
'', $num);
8057 $num = substr(
"000".$num, -$level);
8059 $path = substr($num, 0, 1);
8062 $path = substr($num, 1, 1).
'/'.substr($num, 0, 1);
8065 $path = substr($num, 2, 1).
'/'.substr($num, 1, 1).
'/'.substr($num, 0, 1);
8071 if (in_array($modulepart, array(
'societe',
'thirdparty')) &&
$object instanceOf
Societe) {
8079 if (empty($withoutslash) && !empty($path)) {
8094function dol_mkdir($dir, $dataroot =
'', $newmask =
'')
8096 dol_syslog(
"functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
8101 if (@is_dir($dir_osencoded)) {
8109 if (!empty($dataroot)) {
8111 $dir = str_replace($dataroot.
'/',
'', $dir);
8112 $ccdir = $dataroot.
'/';
8115 $cdir = explode(
"/", $dir);
8116 $num = count($cdir);
8117 for ($i = 0; $i < $num; $i++) {
8119 $ccdir .=
'/'.$cdir[$i];
8121 $ccdir .= $cdir[$i];
8124 if (preg_match(
"/^.:$/", $ccdir, $regs)) {
8132 if (!@is_dir($ccdir_osencoded)) {
8133 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' is not found (does not exists or is outside open_basedir PHP setting).", LOG_DEBUG);
8136 $dirmaskdec = octdec((
string) $newmask);
8137 if (empty($newmask)) {
8140 $dirmaskdec |= octdec(
'0111');
8141 if (!@mkdir($ccdir_osencoded, $dirmaskdec)) {
8143 dol_syslog(
"functions.lib::dol_mkdir: Fails to create directory '".$ccdir.
"' (no permission to write into parent or directory already exists).", LOG_WARNING);
8146 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' created", LOG_DEBUG);
8155 return ($nberr ? -$nberr : $nbcreated);
8166function dolChmod($filepath, $newmask =
'')
8170 if (!empty($newmask)) {
8171 @chmod($filepath, octdec($newmask));
8173 @chmod($filepath, octdec(
$conf->global->MAIN_UMASK));
8185 return '<span class="fieldrequired">*</span>';
8205function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
'UTF-8', $strip_tags = 0, $removedoublespaces = 1)
8207 if (is_null($stringtoclean)) {
8211 if ($removelinefeed == 2) {
8212 $stringtoclean = preg_replace(
'/<br[^>]*>(\n|\r)+/ims',
'<br>', $stringtoclean);
8214 $temp = preg_replace(
'/<br[^>]*>/i',
"\n", $stringtoclean);
8219 $temp = str_replace(
'< ',
'__ltspace__', $temp);
8220 $temp = str_replace(
'<:',
'__lttwopoints__', $temp);
8223 $temp = strip_tags($temp);
8226 $pattern =
"/<[^<>]+>/";
8233 $tempbis = str_replace(
'<>',
'', $temp);
8234 $tempbis = preg_replace($pattern,
'', $tempbis);
8236 }
while ($tempbis != $temp);
8241 $temp = preg_replace(
'/<+([a-z]+)/i',
'\1', $temp);
8247 if ($removelinefeed == 1) {
8248 $temp = str_replace(array(
"\r\n",
"\r",
"\n"),
" ", $temp);
8252 if ($removedoublespaces) {
8253 while (strpos($temp,
" ")) {
8254 $temp = str_replace(
" ",
" ", $temp);
8258 $temp = str_replace(
'__ltspace__',
'< ', $temp);
8259 $temp = str_replace(
'__lttwopoints__',
'<:', $temp);
8282function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $removeclassattribute = 1, $cleanalsojavascript = 0, $allowiframe = 0, $allowed_tags = array(), $allowlink = 0, $allowscript = 0, $allowstyle = 0, $allowphp = 0)
8284 if (empty($allowed_tags)) {
8285 $allowed_tags = array(
8286 "html",
"head",
"meta",
"body",
"article",
"a",
"abbr",
"b",
"blockquote",
"br",
"cite",
"div",
"dl",
"dd",
"dt",
"em",
"font",
"img",
"ins",
"hr",
"i",
"li",
8287 "ol",
"p",
"q",
"s",
"span",
"strike",
"strong",
"title",
"table",
"tr",
"th",
"td",
"u",
"ul",
"sup",
"sub",
"blockquote",
"pre",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
8288 "header",
"footer",
"nav",
"section",
"menu",
"menuitem"
8291 $allowed_tags[] =
"comment";
8293 if (!in_array(
'iframe', $allowed_tags)) {
8294 $allowed_tags[] =
"iframe";
8298 if (!in_array(
'link', $allowed_tags)) {
8299 $allowed_tags[] =
"link";
8303 if (!in_array(
'script', $allowed_tags)) {
8304 $allowed_tags[] =
"script";
8308 if (!in_array(
'style', $allowed_tags)) {
8309 $allowed_tags[] =
"style";
8313 $allowed_tags_string = implode(
"><", $allowed_tags);
8314 $allowed_tags_string =
'<'.$allowed_tags_string.
'>';
8316 $stringtoclean = str_replace(
'<!DOCTYPE html>',
'__!DOCTYPE_HTML__', $stringtoclean);
8321 $stringtoclean = preg_replace(
'/<!--([^>]*)-->/',
'<comment>\1</comment>', $stringtoclean);
8324 $allowed_tags[] =
"commentphp";
8325 $stringtoclean = preg_replace(
'/^<\?php([^"]+)\?>$/i',
'<commentphp>\1__</commentphp>', $stringtoclean);
8326 $stringtoclean = preg_replace(
'/"<\?php([^"]+)\?>"/i',
'"<commentphp>\1</commentphp>"', $stringtoclean);
8329 $stringtoclean = preg_replace(
'/:/i',
':', $stringtoclean);
8330 $stringtoclean = preg_replace(
'/:|�+58|:/i',
'', $stringtoclean);
8333 $temp = strip_tags($stringtoclean, $allowed_tags_string);
8335 if ($cleanalsosomestyles) {
8336 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/i',
'', $temp);
8338 if ($removeclassattribute) {
8339 $temp = preg_replace(
'/(<[^>]+)\s+class=((["\']).*?\\3|\\w*)/i',
'\\1', $temp);
8344 if ($cleanalsojavascript) {
8345 $temp = preg_replace(
'/j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t\s*:/i',
'', $temp);
8348 $temp = str_replace(
'__!DOCTYPE_HTML__',
'<!DOCTYPE html>', $temp);
8351 $temp = preg_replace(
'/<commentphp>(.*)<\/commentphp>/',
'<?php\1?>', $temp);
8354 $temp = preg_replace(
'/<comment>([^>]*)<\/comment>/',
'<!--\1-->', $temp);
8375 if (is_null($allowed_attributes)) {
8376 $allowed_attributes = array(
8377 "allow",
"allowfullscreen",
"alt",
"async",
"class",
"contenteditable",
"crossorigin",
"data-html",
"frameborder",
"height",
"href",
"id",
"name",
"property",
"rel",
"src",
"style",
"target",
"title",
"type",
"width",
8379 "header",
"footer",
"nav",
"section",
"menu",
"menuitem"
8383 if (!in_array(
"content", $allowed_attributes)) {
8384 $allowed_attributes[] =
"content";
8386 if (!in_array(
"http-equiv", $allowed_attributes)) {
8387 $allowed_attributes[] =
"http-equiv";
8390 if (class_exists(
'DOMDocument') && !empty($stringtoclean)) {
8391 $stringtoclean =
'<?xml encoding="UTF-8"><html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>'.$stringtoclean.
'</body></html>';
8394 $dom =
new DOMDocument(
'',
'UTF-8');
8396 $savwarning = error_reporting();
8397 error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);
8398 $dom->loadHTML($stringtoclean, LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOXMLDECL);
8399 error_reporting($savwarning);
8401 if ($dom instanceof DOMDocument) {
8402 for ($els = $dom->getElementsByTagname(
'*'), $i = $els->length - 1; $i >= 0; $i--) {
8403 $el = $els->item($i);
8404 if (!$el instanceof DOMElement) {
8407 $attrs = $el->attributes;
8408 for ($ii = $attrs->length - 1; $ii >= 0; $ii--) {
8410 if (!empty($attrs->item($ii)->name)) {
8411 if (! in_array($attrs->item($ii)->name, $allowed_attributes)) {
8413 $els->item($i)->removeAttribute($attrs->item($ii)->name);
8414 } elseif (in_array($attrs->item($ii)->name, array(
'style'))) {
8416 $valuetoclean = $attrs->item($ii)->value;
8418 if (isset($valuetoclean)) {
8420 $oldvaluetoclean = $valuetoclean;
8421 $valuetoclean = preg_replace(
'/\/\*.*\*\//m',
'', $valuetoclean);
8422 $valuetoclean = preg_replace(
'/position\s*:\s*[a-z]+/mi',
'', $valuetoclean);
8423 if ($els->item($i)->tagName ==
'a') {
8424 $valuetoclean = preg_replace(
'/display\s*:/mi',
'', $valuetoclean);
8425 $valuetoclean = preg_replace(
'/z-index\s*:/mi',
'', $valuetoclean);
8426 $valuetoclean = preg_replace(
'/\s+(top|left|right|bottom)\s*:/mi',
'', $valuetoclean);
8430 $valuetoclean = preg_replace(
'/(logout|passwordforgotten)\.php/mi',
'', $valuetoclean);
8431 $valuetoclean = preg_replace(
'/action=/mi',
'', $valuetoclean);
8432 }
while ($oldvaluetoclean != $valuetoclean);
8435 $attrs->item($ii)->value = $valuetoclean;
8442 $dom->encoding =
'UTF-8';
8444 $return = $dom->saveHTML();
8447 $return = preg_replace(
'/^'.preg_quote(
'<?xml encoding="UTF-8">',
'/').
'/',
'', $return);
8448 $return = preg_replace(
'/^'.preg_quote(
'<html><head><',
'/').
'[^<>]*'.preg_quote(
'></head><body>',
'/').
'/',
'', $return);
8449 $return = preg_replace(
'/'.preg_quote(
'</body></html>',
'/').
'$/',
'', trim($return));
8451 return trim($return);
8453 return $stringtoclean;
8470 $temp = $stringtoclean;
8471 foreach ($disallowed_tags as $tagtoremove) {
8472 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'>/',
'', $temp);
8473 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'\s+[^>]*>/',
'', $temp);
8476 if ($cleanalsosomestyles) {
8477 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/',
'', $temp);
8495 if ($nboflines == 1) {
8497 $firstline = preg_replace(
'/<br[^>]*>.*$/s',
'', $text);
8498 $firstline = preg_replace(
'/<div[^>]*>.*$/s',
'', $firstline);
8501 $firstline = preg_replace(
'/[\n\r].*/',
'', $text);
8506 return $firstline.(isset($firstline) && isset($text) && (strlen($firstline) != strlen($text)) ?
'...' :
'');
8510 $text = preg_replace(
'/\n/',
'', $text);
8512 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8514 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8517 $text = strtr($text, $repTable);
8518 if ($charset ==
'UTF-8') {
8519 $pattern =
'/(<br[^>]*>)/Uu';
8522 $pattern =
'/(<br[^>]*>)/U';
8524 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
8529 $lastaddediscontent = 1;
8530 while ($countline < $nboflines && isset($a[$i])) {
8531 if (preg_match(
'/<br[^>]*>/', $a[$i])) {
8532 if (array_key_exists($i + 1, $a) && !empty($a[$i + 1])) {
8533 $firstline .= ($ishtml ?
"<br>\n" :
"\n");
8535 if (!$lastaddediscontent) {
8538 $lastaddediscontent = 0;
8541 $firstline .= $a[$i];
8542 $lastaddediscontent = 1;
8548 $adddots = (isset($a[$i]) && (!preg_match(
'/<br[^>]*>/', $a[$i]) || (array_key_exists($i + 1, $a) && !empty($a[$i + 1]))));
8550 $ret = $firstline.($adddots ?
'...' :
'');
8568function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml =
false)
8570 if (is_null($stringtoencode)) {
8575 return nl2br($stringtoencode, $forxml);
8577 $ret = preg_replace(
'/(\r\n|\r|\n)/i', ($forxml ?
'<br />' :
'<br>'), $stringtoencode);
8591function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check =
'restricthtml')
8593 if (empty($nouseofiframesandbox) &&
getDolGlobalString(
'MAIN_SECURITY_USE_SANDBOX_FOR_HTMLWITHNOJS')) {
8598 return $stringtoencode;
8600 $out = $stringtoencode;
8604 $oldstringtoclean = $out;
8606 if (!empty($out) &&
getDolGlobalString(
'MAIN_RESTRICTHTML_ONLY_VALID_HTML') && $check !=
'restricthtmlallowunvalid') {
8608 libxml_use_internal_errors(
false);
8609 if (LIBXML_VERSION < 20900) {
8613 libxml_disable_entity_loader(
true);
8616 $dom =
new DOMDocument();
8622 $out =
'<?xml encoding="UTF-8"><html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body><div class="tricktoremove">'.$out.
'</div></body></html>';
8624 $out =
'<?xml encoding="UTF-8"><html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body><div class="tricktoremove">'.dol_nl2br($out).
'</div></body></html>';
8627 $dom->loadHTML($out, LIBXML_HTML_NODEFDTD | LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOERROR | LIBXML_NOXMLDECL);
8629 $dom->encoding =
'UTF-8';
8631 $out = trim($dom->saveHTML());
8634 $out = preg_replace(
'/^'.preg_quote(
'<?xml encoding="UTF-8">',
'/').
'/',
'', $out);
8635 $out = preg_replace(
'/^'.preg_quote(
'<html><head><',
'/').
'[^<>]+'.preg_quote(
'></head><body><div class="tricktoremove">',
'/').
'/',
'', $out);
8636 $out = preg_replace(
'/'.preg_quote(
'</div></body></html>',
'/').
'$/',
'', trim($out));
8643 $out =
'InvalidHTMLStringCantBeCleaned '.$e->getMessage();
8647 if (!empty($out) &&
getDolGlobalString(
'MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY') && !in_array($check, array(
'restricthtmlallowunvalid',
'restricthtmlallowlinkscript'))) {
8652 if (extension_loaded(
'tidy') && class_exists(
"tidy")) {
8659 'quote-marks' =>
false,
8660 'doctype' =>
'strict',
8661 'show-body-only' =>
true,
8662 "indent-attributes" =>
false,
8663 "vertical-space" =>
false,
8675 $out = $tidy->repairString($out, $config,
'utf8');
8682 $out =
'InvalidHTMLStringCantBeCleaned '.$e->getMessage();
8687 $out = preg_replace(
'/[\x{200B}-\x{200D}\x{FEFF}]/u',
' ', $out);
8690 $out = preg_replace(
'/&(tab|newline);/i',
' ', $out);
8694 $out = preg_replace(
'/'/i',
''', $out);
8699 if (function_exists(
'realCharForNumericEntities')) {
8700 $out = preg_replace_callback(
8701 '/&#(x?[0-9][0-9a-f]+;?)/i',
8706 static function ($m) {
8714 $out = preg_replace(
'/&#x?[0-9]+/i',
'', $out);
8717 if ($check ==
'restricthtmlallowlinkscript') {
8719 } elseif ($check ==
'restricthtmlallowclass' || $check ==
'restricthtmlallowunvalid') {
8721 } elseif ($check ==
'restricthtmlallowiframe') {
8733 $out = preg_replace(
'/'/i',
"'", $out);
8737 $out = preg_replace(
'/on(mouse|drag|key|load|touch|pointer|select|transition)[a-z]*\s*=/i',
'', $out);
8738 $out = preg_replace(
'/on(abort|after|animation|auxclick|before|blur|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i',
'', $out);
8739 $out = preg_replace(
'/on(dblclick|drop|durationchange|emptied|end|ended|error|focus(in|out)?|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i',
'', $out);
8740 $out = preg_replace(
'/on(lostpointercapture|offline|online|pagehide|pageshow)[a-z]*\s*=/i',
'', $out);
8741 $out = preg_replace(
'/on(paste|pause|play|playing|progress|ratechange|reset|resize|scroll|search|seeked|seeking|show|stalled|start|submit|suspend)[a-z]*\s*=/i',
'', $out);
8742 $out = preg_replace(
'/on(timeupdate|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i',
'', $out);
8744 $out = preg_replace(
'/on(repeat|begin|finish|beforeinput)[a-z]*\s*=/i',
'', $out);
8745 }
while ($oldstringtoclean != $out);
8752 $tmpout = preg_replace(
'/<img src="data:/mi',
'<__IMG_SRC_DATA__ src="data:', $out);
8753 preg_match_all(
'/(<img|url\(|<link)/i', $tmpout, $reg);
8754 $nblinks = count($reg[0]);
8755 if ($nblinks >
getDolGlobalInt(
"MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 1000)) {
8756 $out =
'ErrorTooManyLinksIntoHTMLString';
8759 if (
getDolGlobalInt(
'MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 2 || $check ==
'restricthtmlnolink') {
8761 $out =
'ErrorHTMLLinksNotAllowed';
8763 } elseif (
getDolGlobalInt(
'MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 1) {
8766 $pattern =
'/src=["\']?(http[^"\']+)|url\(["\']?(http[^\)]+)/';
8769 if (preg_match_all($pattern, $out, $matches)) {
8771 $urls = $matches[1];
8774 foreach ($urls as $url) {
8776 echo
"Found url = ".$url .
"\n";
8779 $out =
'ErrorHTMLExternalLinksNotAllowed';
8808function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom =
'UTF-8', $removelasteolbr = 1)
8810 if (is_null($stringtoencode)) {
8814 $newstring = $stringtoencode;
8816 $newstring = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
'<br>', $newstring);
8817 if ($removelasteolbr) {
8818 $newstring = preg_replace(
'/<br>$/i',
'', $newstring);
8820 $newstring = preg_replace(
'/[\x{200B}-\x{200D}\x{FEFF}]/u',
' ', $newstring);
8821 $newstring = strtr($newstring, array(
'&' =>
'__PROTECTand__',
'<' =>
'__PROTECTlt__',
'>' =>
'__PROTECTgt__',
'"' =>
'__PROTECTdquot__'));
8823 $newstring = strtr($newstring, array(
'__PROTECTand__' =>
'&',
'__PROTECTlt__' =>
'<',
'__PROTECTgt__' =>
'>',
'__PROTECTdquot__' =>
'"'));
8825 if ($removelasteolbr) {
8826 $newstring = preg_replace(
'/(\r\n|\r|\n)$/i',
'', $newstring);
8845 $ret = preg_replace(
'/'.
"\r\n".
'<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"<br>", $ret);
8846 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\r\n".
'/i',
"\r\n", $ret);
8847 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\n".
'/i',
"\n", $ret);
8848 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"\n", $ret);
8860 $ret = preg_replace(
'/ $/i',
"", $stringtodecode);
8861 $ret = preg_replace(
'/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'.
"\n".
'|'.
"\r".
')+$/i',
"", $ret);
8877 if ($keepsomeentities) {
8878 $newstring = strtr($newstring, array(
'&' =>
'__andamp__',
'<' =>
'__andlt__',
'>' =>
'__andgt__',
'"' =>
'__dquot__'));
8880 $newstring = html_entity_decode((
string) $newstring, (
int) $b, (
string)
$c);
8881 if ($keepsomeentities) {
8882 $newstring = strtr($newstring, array(
'__andamp__' =>
'&',
'__andlt__' =>
'<',
'__andgt__' =>
'>',
'__dquot__' =>
'"'));
8898function dol_htmlentities($string, $flags = ENT_QUOTES | ENT_SUBSTITUTE, $encoding =
'UTF-8', $double_encode =
false)
8900 return htmlentities($string, $flags, $encoding, $double_encode);
8919 for ($scursor = 0; $scursor < $len; $scursor++) {
8920 $ordchar = ord($s[$scursor]);
8922 if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) {
8925 } elseif ($ordchar > 126 && $ordchar < 160) {
8929 $out .= $s[$scursor];
8951 $arraystring = explode(
"\n", $s);
8952 $nb = count($arraystring);
8969 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8971 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8974 $text = strtr($text, $repTable);
8975 if ($charset ==
'UTF-8') {
8976 $pattern =
'/(<br[^>]*>)/Uu';
8979 $pattern =
'/(<br[^>]*>)/U';
8981 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
8983 $nblines = (int) floor((count($a) + 1) / 2);
8986 foreach ($a as $line) {
8989 $line_dec = html_entity_decode($line);
8991 $line_dec = wordwrap($line_dec, $maxlinesize,
'\n',
true);
8992 $nblines += substr_count($line_dec,
'\n');
9012 if (is_null($msg)) {
9017 if (preg_match(
'/<(html|link|script)/i', $msg)) {
9019 } elseif (preg_match(
'/<body/i', $msg)) {
9021 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
9023 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
9025 } elseif (preg_match(
'/<br/i', $msg)) {
9031 $msg = preg_replace(
'/https?:\/\/[^"\'\s]+/i',
'', $msg);
9032 if (preg_match(
'/<(html|link|script|body)/i', $msg)) {
9034 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
9036 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
9038 } elseif (preg_match(
'/<(br|hr)\/>/i', $msg)) {
9040 } elseif (preg_match(
'/<(br|hr|div|font|li|p|span|strong|table)>/i', $msg)) {
9042 } elseif (preg_match(
'/<(br|hr|div|font|li|p|span|strong|table)\s+[^<>\/]*\/?>/i', $msg)) {
9044 } elseif (preg_match(
'/<img\s+[^<>]*src[^<>]*>/i', $msg)) {
9046 } elseif (preg_match(
'/<a\s+[^<>]*href[^<>]*>/i', $msg)) {
9048 } elseif (preg_match(
'/<h[0-9]>/i', $msg)) {
9050 } elseif (preg_match(
'/&[A-Z0-9]{1,6};/i', $msg)) {
9053 } elseif (preg_match(
'/&#[0-9]{2,3};/i', $msg)) {
9075function dol_concatdesc($text1, $text2, $forxml =
false, $invert =
false)
9077 if (!empty($invert)) {
9085 $ret .= (!empty($text1) && !empty($text2)) ? ((
dol_textishtml($text1) ||
dol_textishtml($text2)) ? ($forxml ?
"<br >\n" :
"<br>\n") :
"\n") :
"";
9107 global $db,
$conf, $mysoc, $user, $extrafields;
9109 $substitutionarray = array();
9111 if ((empty($exclude) || !in_array(
'user', $exclude)) && (empty($include) || in_array(
'user', $include)) && $user instanceof
User) {
9115 $emailsendersignature = $user->signature;
9116 $usersignature = $user->signature;
9117 $substitutionarray = array_merge($substitutionarray, array(
9118 '__SENDEREMAIL_SIGNATURE__' => (
string) ((!
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? ($onlykey == 2 ?
dol_trunc(
'SignatureFromTheSelectedSenderProfile', 30) : $emailsendersignature) :
''),
9122 if (is_object($user) && ($user instanceof
User)) {
9123 $substitutionarray = array_merge($substitutionarray, array(
9124 '__USER_ID__' => (
string) $user->id,
9125 '__USER_LOGIN__' => (
string) $user->login,
9126 '__USER_EMAIL__' => (
string) $user->email,
9127 '__USER_PHONE__' => (
string)
dol_print_phone($user->office_phone,
'', 0, 0,
'',
" ",
'',
'', -1),
9128 '__USER_PHONEPRO__' => (
string)
dol_print_phone($user->user_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
9129 '__USER_PHONEMOBILE__' => (
string)
dol_print_phone($user->personal_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
9130 '__USER_FAX__' => (
string) $user->office_fax,
9131 '__USER_LASTNAME__' => (
string) $user->lastname,
9132 '__USER_FIRSTNAME__' => (
string) $user->firstname,
9133 '__USER_FULLNAME__' => (
string) $user->getFullName($outputlangs),
9134 '__USER_SUPERVISOR_ID__' => (
string) ($user->fk_user ? $user->fk_user :
'0'),
9135 '__USER_JOB__' => (string) $user->job,
9137 '__USER_VCARD_URL__' => (string) $user->getOnlineVirtualCardUrl(
'',
'external')
9141 if ((empty($exclude) || !in_array(
'mycompany', $exclude)) && is_object($mysoc) && (empty($include) || in_array(
'mycompany', $include))) {
9142 $substitutionarray = array_merge($substitutionarray, array(
9143 '__MYCOMPANY_NAME__' => $mysoc->name,
9144 '__MYCOMPANY_EMAIL__' => $mysoc->email,
9145 '__MYCOMPANY_PHONE__' =>
dol_print_phone($mysoc->phone,
'', 0, 0,
'',
" ",
'',
'', -1),
9146 '__MYCOMPANY_FAX__' =>
dol_print_phone($mysoc->fax,
'', 0, 0,
'',
" ",
'',
'', -1),
9147 '__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
9148 '__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
9149 '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
9150 '__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
9151 '__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
9152 '__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
9153 '__MYCOMPANY_PROFID7__' => $mysoc->idprof7,
9154 '__MYCOMPANY_PROFID8__' => $mysoc->idprof8,
9155 '__MYCOMPANY_PROFID9__' => $mysoc->idprof9,
9156 '__MYCOMPANY_PROFID10__' => $mysoc->idprof10,
9157 '__MYCOMPANY_CAPITAL__' => $mysoc->capital,
9158 '__MYCOMPANY_FULLADDRESS__' => (method_exists($mysoc,
'getFullAddress') ? $mysoc->getFullAddress(1,
', ') :
''),
9159 '__MYCOMPANY_ADDRESS__' => $mysoc->
address,
9160 '__MYCOMPANY_ZIP__' => $mysoc->zip,
9161 '__MYCOMPANY_TOWN__' => $mysoc->town,
9162 '__MYCOMPANY_STATE__' => $mysoc->state,
9163 '__MYCOMPANY_COUNTRY__' => $mysoc->country,
9164 '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id,
9165 '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code,
9166 '__MYCOMPANY_CURRENCY_CODE__' =>
$conf->currency
9170 if (($onlykey || is_object(
$object)) && (empty($exclude) || !in_array(
'object', $exclude)) && (empty($include) || in_array(
'object', $include))) {
9172 $substitutionarray[
'__ID__'] =
'__ID__';
9173 $substitutionarray[
'__REF__'] =
'__REF__';
9174 $substitutionarray[
'__NEWREF__'] =
'__NEWREF__';
9175 $substitutionarray[
'__LABEL__'] =
'__LABEL__';
9176 $substitutionarray[
'__REF_CLIENT__'] =
'__REF_CLIENT__';
9177 $substitutionarray[
'__REF_SUPPLIER__'] =
'__REF_SUPPLIER__';
9178 $substitutionarray[
'__NOTE_PUBLIC__'] =
'__NOTE_PUBLIC__';
9179 $substitutionarray[
'__NOTE_PRIVATE__'] =
'__NOTE_PRIVATE__';
9180 $substitutionarray[
'__EXTRAFIELD_XXX__'] =
'__EXTRAFIELD_XXX__';
9182 if (isModEnabled(
"societe")) {
9183 $substitutionarray[
'__THIRDPARTY_ID__'] =
'__THIRDPARTY_ID__';
9184 $substitutionarray[
'__THIRDPARTY_NAME__'] =
'__THIRDPARTY_NAME__';
9185 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
'__THIRDPARTY_NAME_ALIAS__';
9186 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
'__THIRDPARTY_CODE_CLIENT__';
9187 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
'__THIRDPARTY_CODE_FOURNISSEUR__';
9188 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
'__THIRDPARTY_EMAIL__';
9190 $substitutionarray[
'__THIRDPARTY_PHONE__'] =
'__THIRDPARTY_PHONE__';
9191 $substitutionarray[
'__THIRDPARTY_FAX__'] =
'__THIRDPARTY_FAX__';
9192 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
'__THIRDPARTY_ADDRESS__';
9193 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
'__THIRDPARTY_ZIP__';
9194 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
'__THIRDPARTY_TOWN__';
9195 $substitutionarray[
'__THIRDPARTY_STATE__'] =
'__THIRDPARTY_STATE__';
9196 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
'__THIRDPARTY_IDPROF1__';
9197 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
'__THIRDPARTY_IDPROF2__';
9198 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
'__THIRDPARTY_IDPROF3__';
9199 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
'__THIRDPARTY_IDPROF4__';
9200 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
'__THIRDPARTY_IDPROF5__';
9201 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
'__THIRDPARTY_IDPROF6__';
9202 $substitutionarray[
'__THIRDPARTY_IDPROF7__'] =
'__THIRDPARTY_IDPROF7__';
9203 $substitutionarray[
'__THIRDPARTY_IDPROF8__'] =
'__THIRDPARTY_IDPROF8__';
9204 $substitutionarray[
'__THIRDPARTY_IDPROF9__'] =
'__THIRDPARTY_IDPROF9__';
9205 $substitutionarray[
'__THIRDPARTY_IDPROF10__'] =
'__THIRDPARTY_IDPROF10__';
9206 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
'__THIRDPARTY_TVAINTRA__';
9207 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] =
'__THIRDPARTY_NOTE_PUBLIC__';
9208 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] =
'__THIRDPARTY_NOTE_PRIVATE__';
9210 if (isModEnabled(
'member') && (!is_object(
$object) ||
$object->element ==
'adherent') && (empty($exclude) || !in_array(
'member', $exclude)) && (empty($include) || in_array(
'member', $include))) {
9211 $substitutionarray[
'__MEMBER_ID__'] =
'__MEMBER_ID__';
9212 $substitutionarray[
'__MEMBER_TITLE__'] =
'__MEMBER_TITLE__';
9213 $substitutionarray[
'__MEMBER_FIRSTNAME__'] =
'__MEMBER_FIRSTNAME__';
9214 $substitutionarray[
'__MEMBER_LASTNAME__'] =
'__MEMBER_LASTNAME__';
9215 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'Login and pass of the external user account';
9220 if (isModEnabled(
'ticket') && (!is_object(
$object) ||
$object->element ==
'ticket') && (empty($exclude) || !in_array(
'ticket', $exclude)) && (empty($include) || in_array(
'ticket', $include))) {
9221 $substitutionarray[
'__TICKET_TRACKID__'] =
'__TICKET_TRACKID__';
9222 $substitutionarray[
'__TICKET_SUBJECT__'] =
'__TICKET_SUBJECT__';
9223 $substitutionarray[
'__TICKET_TYPE__'] =
'__TICKET_TYPE__';
9224 $substitutionarray[
'__TICKET_SEVERITY__'] =
'__TICKET_SEVERITY__';
9225 $substitutionarray[
'__TICKET_CATEGORY__'] =
'__TICKET_CATEGORY__';
9226 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
'__TICKET_ANALYTIC_CODE__';
9227 $substitutionarray[
'__TICKET_MESSAGE__'] =
'__TICKET_MESSAGE__';
9228 $substitutionarray[
'__TICKET_PROGRESSION__'] =
'__TICKET_PROGRESSION__';
9229 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
'__TICKET_USER_ASSIGN__';
9232 if (isModEnabled(
'recruitment') && (!is_object(
$object) ||
$object->element ==
'recruitmentcandidature') && (empty($exclude) || !in_array(
'recruitment', $exclude)) && (empty($include) || in_array(
'recruitment', $include))) {
9233 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
'__CANDIDATE_FULLNAME__';
9234 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] =
'__CANDIDATE_FIRSTNAME__';
9235 $substitutionarray[
'__CANDIDATE_LASTNAME__'] =
'__CANDIDATE_LASTNAME__';
9237 if (isModEnabled(
'project') && (empty($exclude) || !in_array(
'project', $exclude)) && (empty($include) || in_array(
'project', $include))) {
9238 $substitutionarray[
'__PROJECT_ID__'] =
'__PROJECT_ID__';
9239 $substitutionarray[
'__PROJECT_REF__'] =
'__PROJECT_REF__';
9240 $substitutionarray[
'__PROJECT_NAME__'] =
'__PROJECT_NAME__';
9244 if (isModEnabled(
'contract') && (!is_object(
$object) ||
$object->element ==
'contract') && (empty($exclude) || !in_array(
'contract', $exclude)) && (empty($include) || in_array(
'contract', $include))) {
9245 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
'Highest date planned for a service start';
9246 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
'Highest date and hour planned for service start';
9247 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
'Lowest data for planned expiration of service';
9248 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
'Lowest date and hour for planned expiration of service';
9250 if (isModEnabled(
"propal") && (!is_object(
$object) ||
$object->element ==
'propal') && (empty($exclude) || !in_array(
'propal', $exclude)) && (empty($include) || in_array(
'propal', $include))) {
9251 $substitutionarray[
'__ONLINE_SIGN_URL__'] =
'ToOfferALinkForOnlineSignature';
9253 if (isModEnabled(
"intervention") && (!is_object(
$object) ||
$object->element ==
'fichinter') && (empty($exclude) || !in_array(
'intervention', $exclude)) && (empty($include) || in_array(
'intervention', $include))) {
9254 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] =
'ToOfferALinkForOnlineSignature';
9256 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'UrlToPayOnlineIfApplicable';
9257 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'TextAndUrlToPayOnlineIfApplicable';
9258 $substitutionarray[
'__SECUREKEYPAYMENT__'] =
'Security key (if key is not unique per record)';
9259 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
'Security key for payment on a member subscription (one key per member)';
9260 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
'Security key for payment on an order';
9261 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
'Security key for payment on an invoice';
9262 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
'Security key for payment on a service of a contract';
9264 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'Direct download url of a proposal';
9265 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'Direct download url of an order';
9266 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'Direct download url of an invoice';
9267 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'Direct download url of a contract';
9268 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'Direct download url of a supplier proposal';
9270 if (isModEnabled(
"shipping") && (!is_object(
$object) ||
$object->element ==
'shipping')) {
9271 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
'Shipping tracking number';
9272 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
'Shipping tracking url';
9273 $substitutionarray[
'__SHIPPINGMETHOD__'] =
'Shipping method';
9275 if (isModEnabled(
"reception") && (!is_object(
$object) ||
$object->element ==
'reception')) {
9276 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
'Shipping tracking number of shipment';
9277 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
'Shipping tracking url';
9280 '@phan-var-force Adherent|Delivery $object';
9281 $substitutionarray[
'__ID__'] =
$object->id;
9282 $substitutionarray[
'__REF__'] =
$object->ref;
9283 $substitutionarray[
'__NEWREF__'] =
$object->newref;
9285 $substitutionarray[
'__REF_CLIENT__'] = (isset(
$object->ref_client) ?
$object->ref_client : (isset(
$object->ref_customer) ?
$object->ref_customer :
null));
9286 $substitutionarray[
'__REF_SUPPLIER__'] = (isset(
$object->ref_supplier) ?
$object->ref_supplier :
null);
9287 $substitutionarray[
'__NOTE_PUBLIC__'] = (isset(
$object->note_public) ?
$object->note_public :
null);
9288 $substitutionarray[
'__NOTE_PRIVATE__'] = (isset(
$object->note_private) ?
$object->note_private :
null);
9290 $substitutionarray[
'__DATE_CREATION__'] = (isset(
$object->date_creation) ?
dol_print_date(
$object->date_creation,
'day',
false, $outputlangs) :
'');
9291 $substitutionarray[
'__DATE_MODIFICATION__'] = (isset(
$object->date_modification) ?
dol_print_date(
$object->date_modification,
'day',
false, $outputlangs) :
'');
9292 $substitutionarray[
'__DATE_VALIDATION__'] = (isset(
$object->date_validation) ?
dol_print_date(
$object->date_validation,
'day',
false, $outputlangs) :
'');
9295 $date_delivery =
null;
9296 if (property_exists(
$object,
'date_delivery')) {
9297 $date_delivery =
$object->date_delivery;
9298 } elseif (property_exists(
$object,
'delivery_date')) {
9299 $date_delivery =
$object->delivery_date;
9301 $substitutionarray[
'__DATE_DELIVERY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
'day',
false, $outputlangs) :
'');
9302 $substitutionarray[
'__DATE_DELIVERY_DAY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%d") :
'');
9303 $substitutionarray[
'__DATE_DELIVERY_DAY_TEXT__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%A") :
'');
9304 $substitutionarray[
'__DATE_DELIVERY_MON__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%m") :
'');
9305 $substitutionarray[
'__DATE_DELIVERY_MON_TEXT__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%b") :
'');
9306 $substitutionarray[
'__DATE_DELIVERY_YEAR__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%Y") :
'');
9307 $substitutionarray[
'__DATE_DELIVERY_HH__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%H") :
'');
9308 $substitutionarray[
'__DATE_DELIVERY_MM__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%M") :
'');
9309 $substitutionarray[
'__DATE_DELIVERY_SS__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%S") :
'');
9312 $substitutionarray[
'__REFCLIENT__'] = (isset(
$object->ref_client) ?
$object->ref_client : (isset(
$object->ref_customer) ?
$object->ref_customer :
null));
9313 $substitutionarray[
'__REFSUPPLIER__'] = (isset(
$object->ref_supplier) ?
$object->ref_supplier :
null);
9315 $substitutionarray[
'__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
'day',
false, $outputlangs) :
'');
9316 $substitutionarray[
'__SUPPLIER_ORDER_DELAY_DELIVERY__'] = (isset(
$object->availability_code) ? ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code ? $outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) : $outputlangs->convToOutputCharset(isset(
$object->availability) ?
$object->availability :
'')) :
'');
9320 '@phan-var-force Adherent $object';
9323 $substitutionarray[
'__MEMBER_ID__'] = (isset(
$object->id) ?
$object->id :
'');
9324 if (method_exists(
$object,
'getCivilityLabel')) {
9325 $substitutionarray[
'__MEMBER_TITLE__'] =
$object->getCivilityLabel();
9327 $substitutionarray[
'__MEMBER_FIRSTNAME__'] = (isset(
$object->firstname) ?
$object->firstname :
'');
9328 $substitutionarray[
'__MEMBER_LASTNAME__'] = (isset(
$object->lastname) ?
$object->lastname :
'');
9329 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'';
9330 if (method_exists(
$object,
'getFullName')) {
9331 $substitutionarray[
'__MEMBER_FULLNAME__'] =
$object->getFullName($outputlangs);
9333 $substitutionarray[
'__MEMBER_COMPANY__'] = (isset(
$object->societe) ?
$object->societe :
'');
9334 $substitutionarray[
'__MEMBER_ADDRESS__'] = (isset(
$object->address) ?
$object->address :
'');
9335 $substitutionarray[
'__MEMBER_ZIP__'] = (isset(
$object->zip) ?
$object->zip :
'');
9336 $substitutionarray[
'__MEMBER_TOWN__'] = (isset(
$object->town) ?
$object->town :
'');
9337 $substitutionarray[
'__MEMBER_STATE__'] = (isset(
$object->state) ?
$object->state :
'');
9338 $substitutionarray[
'__MEMBER_COUNTRY__'] = (isset(
$object->country) ?
$object->country :
'');
9339 $substitutionarray[
'__MEMBER_EMAIL__'] = (isset(
$object->email) ?
$object->email :
'');
9340 $substitutionarray[
'__MEMBER_BIRTH__'] = (isset($birthday) ? $birthday :
'');
9341 $substitutionarray[
'__MEMBER_PHOTO__'] = (isset(
$object->photo) ?
$object->photo :
'');
9342 $substitutionarray[
'__MEMBER_LOGIN__'] = (isset(
$object->login) ?
$object->login :
'');
9343 $substitutionarray[
'__MEMBER_PASSWORD__'] = (isset(
$object->pass) ?
$object->pass :
'');
9347 $substitutionarray[
'__MEMBER_TYPE__'] = (isset(
$object->type) ?
$object->type :
'');
9348 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE__'] =
dol_print_date(
$object->first_subscription_date,
'day');
9350 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_RFC__'] =
dol_print_date(
$object->first_subscription_date,
'dayrfc');
9351 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = (isset(
$object->first_subscription_date_start) ?
dol_print_date(
$object->first_subscription_date_start,
'day') :
'');
9352 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START_RFC__'] = (isset(
$object->first_subscription_date_start) ?
dol_print_date(
$object->first_subscription_date_start,
'dayrfc') :
'');
9353 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = (isset(
$object->first_subscription_date_end) ?
dol_print_date(
$object->first_subscription_date_end,
'day') :
'');
9354 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END_RFC__'] = (isset(
$object->first_subscription_date_end) ?
dol_print_date(
$object->first_subscription_date_end,
'dayrfc') :
'');
9355 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE__'] =
dol_print_date(
$object->last_subscription_date,
'day');
9356 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_RFC__'] =
dol_print_date(
$object->last_subscription_date,
'dayrfc');
9357 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] =
dol_print_date(
$object->last_subscription_date_start,
'day');
9358 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START_RFC__'] =
dol_print_date(
$object->last_subscription_date_start,
'dayrfc');
9359 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] =
dol_print_date(
$object->last_subscription_date_end,
'day');
9360 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END_RFC__'] =
dol_print_date(
$object->last_subscription_date_end,
'dayrfc');
9364 '@phan-var-force Societe $object';
9365 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object(
$object) ?
$object->id :
'');
9366 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object(
$object) ?
$object->name :
'');
9367 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object(
$object) ?
$object->name_alias :
'');
9368 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object(
$object) ?
$object->code_client :
'');
9369 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object(
$object) ?
$object->code_fournisseur :
'');
9370 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object(
$object) ?
$object->email :
'');
9371 $substitutionarray[
'__THIRDPARTY_EMAIL_URLENCODED__'] = urlencode(is_object(
$object) ?
$object->email :
'');
9374 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object(
$object) ?
$object->address :
'');
9375 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object(
$object) ?
$object->zip :
'');
9376 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object(
$object) ?
$object->town :
'');
9377 $substitutionarray[
'__THIRDPARTY_STATE__'] = (is_object(
$object) ?
$object->state :
'');
9378 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object(
$object) ?
$object->country_id :
'');
9379 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object(
$object) ?
$object->country_code :
'');
9380 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object(
$object) ?
$object->idprof1 :
'');
9381 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object(
$object) ?
$object->idprof2 :
'');
9382 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object(
$object) ?
$object->idprof3 :
'');
9383 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object(
$object) ?
$object->idprof4 :
'');
9384 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object(
$object) ?
$object->idprof5 :
'');
9385 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object(
$object) ?
$object->idprof6 :
'');
9386 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object(
$object) ?
$object->tva_intra :
'');
9389 } elseif (is_object(
$object->thirdparty)) {
9390 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->id :
'');
9391 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->name :
'');
9392 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->name_alias :
'');
9393 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->code_client :
'');
9394 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->code_fournisseur :
'');
9395 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->email :
'');
9396 $substitutionarray[
'__THIRDPARTY_EMAIL_URLENCODED__'] = urlencode(is_object(
$object->thirdparty) ?
$object->thirdparty->email :
'');
9399 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->address :
'');
9400 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->zip :
'');
9401 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->town :
'');
9402 $substitutionarray[
'__THIRDPARTY_STATE__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->state :
'');
9403 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->country_id :
'');
9404 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->country_code :
'');
9405 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof1 :
'');
9406 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof2 :
'');
9407 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof3 :
'');
9408 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof4 :
'');
9409 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof5 :
'');
9410 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof6 :
'');
9411 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->tva_intra :
'');
9416 if (is_object(
$object) &&
$object->element ==
'recruitmentcandidature') {
9417 '@phan-var-force RecruitmentCandidature $object';
9418 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
$object->getFullName($outputlangs);
9419 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] = isset(
$object->firstname) ?
$object->firstname :
'';
9420 $substitutionarray[
'__CANDIDATE_LASTNAME__'] = isset(
$object->lastname) ?
$object->lastname :
'';
9422 if (is_object(
$object) &&
$object->element ==
'conferenceorboothattendee') {
9423 '@phan-var-force ConferenceOrBoothAttendee $object';
9424 $substitutionarray[
'__ATTENDEE_FULLNAME__'] =
$object->getFullName($outputlangs);
9425 $substitutionarray[
'__ATTENDEE_FIRSTNAME__'] = isset(
$object->firstname) ?
$object->firstname :
'';
9426 $substitutionarray[
'__ATTENDEE_LASTNAME__'] = isset(
$object->lastname) ?
$object->lastname :
'';
9430 '@phan-var-force Project $object';
9431 $substitutionarray[
'__PROJECT_ID__'] =
$object->id;
9432 $substitutionarray[
'__PROJECT_REF__'] =
$object->ref;
9433 $substitutionarray[
'__PROJECT_NAME__'] =
$object->title;
9434 } elseif (is_object(
$object)) {
9436 if (!empty(
$object->project)) {
9438 } elseif (!empty(
$object->projet)) {
9441 if (!is_null($project) && is_object($project)) {
9442 $substitutionarray[
'__PROJECT_ID__'] = $project->id;
9443 $substitutionarray[
'__PROJECT_REF__'] = $project->ref;
9444 $substitutionarray[
'__PROJECT_NAME__'] = $project->title;
9449 $project_id =
$object->fk_project;
9450 } elseif (!empty(
$object->fk_projet) &&
$object->fk_projet > 0) {
9451 $project_id =
$object->fk_project;
9453 if ($project_id > 0) {
9455 $substitutionarray[
'__PROJECT_ID__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9456 $substitutionarray[
'__PROJECT_REF__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9457 $substitutionarray[
'__PROJECT_NAME__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9463 '@phan-var-force Facture $object';
9464 $substitutionarray[
'__INVOICE_SITUATION_NUMBER__'] = isset(
$object->situation_counter) ?
$object->situation_counter :
'';
9467 '@phan-var-force Expedition $object';
9468 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
$object->tracking_number;
9469 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
$object->tracking_url;
9470 $substitutionarray[
'__SHIPPINGMETHOD__'] =
$object->shipping_method;
9473 '@phan-var-force Reception $object';
9474 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
$object->tracking_number;
9475 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
$object->tracking_url;
9479 '@phan-var-force Contrat $object';
9480 $dateplannedstart =
'';
9481 $datenextexpiration =
'';
9482 foreach (
$object->lines as $line) {
9483 if ($line->date_start > $dateplannedstart) {
9484 $dateplannedstart = $line->date_start;
9486 if ($line->statut == 4 && $line->date_end && (!$datenextexpiration || $line->date_end < $datenextexpiration)) {
9487 $datenextexpiration = $line->date_end;
9490 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
dol_print_date($dateplannedstart,
'day');
9491 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE_RFC__'] =
dol_print_date($dateplannedstart,
'dayrfc');
9492 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
dol_print_date($dateplannedstart,
'standard');
9494 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
dol_print_date($datenextexpiration,
'day');
9495 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE_RFC__'] =
dol_print_date($datenextexpiration,
'dayrfc');
9496 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
dol_print_date($datenextexpiration,
'standard');
9500 '@phan-var-force Ticket $object';
9501 $substitutionarray[
'__TICKET_TRACKID__'] =
$object->track_id;
9502 $substitutionarray[
'__TICKET_SUBJECT__'] =
$object->subject;
9503 $substitutionarray[
'__TICKET_TYPE__'] =
$object->type_code;
9504 $substitutionarray[
'__TICKET_SEVERITY__'] =
$object->severity_code;
9505 $substitutionarray[
'__TICKET_CATEGORY__'] =
$object->category_code;
9506 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
$object->category_code;
9507 $substitutionarray[
'__TICKET_MESSAGE__'] =
$object->message;
9508 $substitutionarray[
'__TICKET_PROGRESSION__'] =
$object->progress;
9509 $userstat =
new User($db);
9510 if (
$object->fk_user_assign > 0) {
9511 $userstat->fetch(
$object->fk_user_assign);
9512 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
9515 if (
$object->fk_user_create > 0) {
9516 $userstat->fetch(
$object->fk_user_create);
9517 $substitutionarray[
'__USER_CREATE__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
9523 if (!is_object($extrafields)) {
9526 $extrafields->fetch_name_optionals_label(
$object->table_element,
true);
9528 if (
$object->fetch_optionals() > 0) {
9529 if (is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label']) > 0) {
9530 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $label) {
9531 if ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'date') {
9532 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'day');
9533 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'day',
'tzserver', $outputlangs);
9534 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'dayrfc');
9535 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'datetime') {
9536 $datetime =
$object->array_options[
'options_'.$key];
9537 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
9538 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
9539 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_DAY_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'day',
'tzserver', $outputlangs) :
'');
9540 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
9541 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'phone') {
9542 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_phone(
$object->array_options[
'options_'.$key]);
9543 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'price') {
9544 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
$object->array_options[
'options_'.$key];
9545 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATED__'] =
price(
$object->array_options[
'options_'.$key]);
9546 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATTED__'] =
price(
$object->array_options[
'options_'.$key]);
9547 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separator') {
9548 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = !empty(
$object->array_options[
'options_'.$key]) ?
$object->array_options[
'options_'.$key] :
'';
9556 if (empty($substitutionarray[
'__REF__'])) {
9560 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
9561 $outputlangs->loadLangs(array(
'paypal',
'other'));
9564 $typeforonlinepayment =
'free';
9566 $typeforonlinepayment =
'order';
9569 $typeforonlinepayment =
'invoice';
9572 $typeforonlinepayment =
'member';
9573 if (!empty(
$object->last_subscription_amount)) {
9574 $amounttouse =
$object->last_subscription_amount;
9578 $typeforonlinepayment =
'contract';
9581 $typeforonlinepayment =
'ficheinter';
9584 $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray[
'__REF__'], $amounttouse);
9589 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ? str_replace(
'\n',
"\n", $outputlangs->trans(
"PredefinedMailContentLink", $paymenturl)) :
'');
9590 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] = $paymenturl;
9594 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
9599 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
$object->getLastMainDocLink(
$object->element);
9601 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'';
9604 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
$object->getLastMainDocLink(
$object->element);
9606 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'';
9609 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
$object->getLastMainDocLink(
$object->element);
9611 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'';
9614 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
$object->getLastMainDocLink(
$object->element);
9616 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'';
9619 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] =
$object->getLastMainDocLink(
$object->element);
9621 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] =
'';
9624 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
$object->getLastMainDocLink(
$object->element);
9626 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'';
9630 '@phan-var-force Propal $object';
9631 $substitutionarray[
'__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/comm/propal/card.php?id=".
$object->id;
9632 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9633 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'proposal',
$object->ref, 1,
$object);
9636 '@phan-var-force Commande $object';
9637 $substitutionarray[
'__URL_ORDER__'] = DOL_MAIN_URL_ROOT.
"/commande/card.php?id=".
$object->id;
9640 '@phan-var-force Facture $object';
9641 $substitutionarray[
'__URL_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/compta/facture/card.php?id=".
$object->id;
9644 '@phan-var-force Contrat $object';
9645 $substitutionarray[
'__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT.
"/contrat/card.php?id=".
$object->id;
9646 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9647 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'contract',
$object->ref, 1,
$object);
9650 '@phan-var-force Fichinter $object';
9651 $substitutionarray[
'__URL_FICHINTER__'] = DOL_MAIN_URL_ROOT.
"/fichinter/card.php?id=".
$object->id;
9652 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9653 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0,
'fichinter',
$object->ref, 1,
$object);
9655 if (is_object(
$object) &&
$object->element ==
'supplier_proposal') {
9656 '@phan-var-force SupplierProposal $object';
9657 $substitutionarray[
'__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/supplier_proposal/card.php?id=".
$object->id;
9659 if (is_object(
$object) &&
$object->element ==
'invoice_supplier') {
9660 '@phan-var-force FactureFournisseur $object';
9661 $substitutionarray[
'__URL_SUPPLIER_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/fourn/facture/card.php?id=".
$object->id;
9664 '@phan-var-force Expedition $object';
9665 $substitutionarray[
'__URL_SHIPMENT__'] = DOL_MAIN_URL_ROOT.
"/expedition/card.php?id=".
$object->id;
9670 '@phan-var-force ActionComm $object';
9671 $substitutionarray[
'__EVENT_LABEL__'] =
$object->label;
9672 $substitutionarray[
'__EVENT_TYPE__'] = $outputlangs->trans(
"Action".
$object->type_code);
9674 $substitutionarray[
'__EVENT_TIME__'] =
dol_print_date(
$object->datep,
'hour',
'auto', $outputlangs);
9678 if ((empty($exclude) || !in_array(
'objectamount', $exclude)) && (empty($include) || in_array(
'objectamount', $include))) {
9679 '@phan-var-force Facture|FactureRec $object';
9680 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functionsnumtoword.lib.php';
9683 $substitutionarray[
'__DATE_DUE_YMD__'] = is_object(
$object) ? (isset(
$object->date_lim_reglement) ?
dol_print_date(
$object->date_lim_reglement,
'day',
false, $outputlangs) : null) :
'';
9685 $substitutionarray[
'__DATE_DUE_YMD_TEXT__'] = is_object(
$object) ? (isset(
$object->date_lim_reglement) ?
dol_print_date(
$object->date_lim_reglement,
'daytext',
false, $outputlangs) : null) :
'';
9687 $already_payed_all = 0;
9692 $substitutionarray[
'__AMOUNT_EXCL_TAX__'] = is_object(
$object) ?
$object->total_ht :
'';
9696 $substitutionarray[
'__AMOUNT__'] = is_object(
$object) ?
$object->total_ttc :
'';
9700 $substitutionarray[
'__AMOUNT_REMAIN__'] = is_object(
$object) ?
price2num(
$object->total_ttc - $already_payed_all,
'MT') :
'';
9702 $substitutionarray[
'__AMOUNT_VAT__'] = is_object(
$object) ? (isset(
$object->total_vat) ?
$object->total_vat :
$object->total_tva) :
'';
9706 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
9707 $substitutionarray[
'__AMOUNT_TAX2__'] = is_object(
$object) ?
$object->total_localtax1 :
'';
9709 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
9710 $substitutionarray[
'__AMOUNT_TAX3__'] = is_object(
$object) ?
$object->total_localtax2 :
'';
9714 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATTED__'] = is_object(
$object) ? (
$object->total_ht ?
price(
$object->total_ht, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null) :
'';
9715 $substitutionarray[
'__AMOUNT_FORMATTED__'] = is_object(
$object) ? (
$object->total_ttc ?
price(
$object->total_ttc, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null) :
'';
9716 $substitutionarray[
'__AMOUNT_REMAIN_FORMATTED__'] = is_object(
$object) ? (
$object->total_ttc ?
price(
$object->total_ttc - $already_payed_all, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null) :
'';
9717 $substitutionarray[
'__AMOUNT_VAT_FORMATTED__'] = is_object(
$object) ? (isset(
$object->total_vat) ?
price(
$object->total_vat, 0, $outputlangs, 0, -1, -1,
$conf->currency) : (
$object->total_tva ?
price(
$object->total_tva, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null)) :
'';
9718 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
9719 $substitutionarray[
'__AMOUNT_TAX2_FORMATTED__'] = is_object(
$object) ? (
$object->total_localtax1 ?
price(
$object->total_localtax1, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null) :
'';
9721 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
9722 $substitutionarray[
'__AMOUNT_TAX3_FORMATTED__'] = is_object(
$object) ? (
$object->total_localtax2 ?
price(
$object->total_localtax2, 0, $outputlangs, 0, -1, -1,
$conf->currency) : null) :
'';
9725 if ($onlykey != 2) {
9726 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATED__'] = $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATTED__'];
9727 $substitutionarray[
'__AMOUNT_FORMATED__'] = $substitutionarray[
'__AMOUNT_FORMATTED__'];
9728 $substitutionarray[
'__AMOUNT_REMAIN_FORMATED__'] = $substitutionarray[
'__AMOUNT_REMAIN_FORMATTED__'];
9729 $substitutionarray[
'__AMOUNT_VAT_FORMATED__'] = $substitutionarray[
'__AMOUNT_VAT_FORMATTED__'];
9730 if ($mysoc instanceof
Societe && $mysoc->useLocalTax(1)) {
9731 $substitutionarray[
'__AMOUNT_TAX2_FORMATED__'] = $substitutionarray[
'__AMOUNT_TAX2_FORMATTED__'];
9733 if ($mysoc instanceof
Societe && $mysoc->useLocalTax(2)) {
9734 $substitutionarray[
'__AMOUNT_TAX3_FORMATED__'] = $substitutionarray[
'__AMOUNT_TAX3_FORMATTED__'];
9738 $substitutionarray[
'__AMOUNT_MULTICURRENCY__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
$object->multicurrency_total_ttc :
'';
9739 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXT__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
dol_convertToWord(
$object->multicurrency_total_ttc, $outputlangs,
'',
true) :
'';
9740 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXTCURRENCY__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
dol_convertToWord(
$object->multicurrency_total_ttc, $outputlangs,
$object->multicurrency_code,
true) :
'';
9741 $substitutionarray[
'__MULTICURRENCY_CODE__'] = (is_object(
$object) && isset(
$object->multicurrency_code)) ?
$object->multicurrency_code :
'';
9745 if ($onlykey != 2) {
9746 $substitutionarray[
'__TOTAL_TTC__'] = is_object(
$object) ?
$object->total_ttc :
'';
9747 $substitutionarray[
'__TOTAL_HT__'] = is_object(
$object) ?
$object->total_ht :
'';
9753 if ((empty($exclude) || !in_array(
'date', $exclude)) && (empty($include) || in_array(
'date', $include))) {
9754 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
9764 $daytext = $outputlangs->trans(
'Day'.$tmp[
'wday']);
9766 $substitutionarray = array_merge($substitutionarray, array(
9767 '__NOW_TMS__' => (
string) $now,
9768 '__NOW_TMS_YMD__' =>
dol_print_date($now,
'day',
'auto', $outputlangs),
9769 '__DAY__' => (
string) $tmp[
'mday'],
9770 '__DAY_TEXT__' => $daytext,
9771 '__DAY_TEXT_SHORT__' =>
dol_trunc($daytext, 3,
'right',
'UTF-8', 1),
9772 '__DAY_TEXT_MIN__' =>
dol_trunc($daytext, 1,
'right',
'UTF-8', 1),
9773 '__MONTH__' => (
string) $tmp[
'mon'],
9774 '__MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp[
'mon'])),
9775 '__MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp[
'mon'])),
9776 '__MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp[
'mon'])),
9777 '__YEAR__' => (
string) $tmp[
'year'],
9778 '__PREVIOUS_DAY__' => (
string) $tmp2[
'day'],
9779 '__PREVIOUS_MONTH__' => (
string) $tmp3[
'month'],
9780 '__PREVIOUS_YEAR__' => (
string) ($tmp[
'year'] - 1),
9781 '__NEXT_DAY__' => (
string) $tmp4[
'day'],
9782 '__NEXT_MONTH__' => (
string) $tmp5[
'month'],
9783 '__NEXT_MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp5[
'month'])),
9784 '__NEXT_MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp5[
'month'])),
9785 '__NEXT_MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp5[
'month'])),
9786 '__NEXT_YEAR__' => (
string) ($tmp[
'year'] + 1),
9790 if (isModEnabled(
'multicompany')) {
9791 $substitutionarray = array_merge($substitutionarray, array(
'__ENTITY_ID__' =>
$conf->entity));
9793 if ((empty($exclude) || !in_array(
'system', $exclude)) && (empty($include) || in_array(
'user', $include))) {
9794 $substitutionarray[
'__DOL_MAIN_URL_ROOT__'] = DOL_MAIN_URL_ROOT;
9795 $substitutionarray[
'__(AnyTranslationKey)__'] = $outputlangs->trans(
'TranslationOfKey');
9796 $substitutionarray[
'__(AnyTranslationKey|langfile)__'] = $outputlangs->trans(
'TranslationOfKey').
' (load also language file before)';
9797 $substitutionarray[
'__[AnyConstantKey]__'] = $outputlangs->trans(
'ValueOfConstantKey');
9802 return $substitutionarray;
9821function make_substitutions($text, $substitutionarray, $outputlangs =
null, $converttextinhtmlifnecessary = 0)
9823 global
$conf, $db, $langs;
9825 if (!is_array($substitutionarray)) {
9826 return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
9829 if (empty($outputlangs)) {
9830 $outputlangs = $langs;
9840 if (is_object($outputlangs)) {
9842 while (preg_match(
'/__\(([^\)]+)\)__/', $text, $reg)) {
9844 $tmp = explode(
'|', $reg[1]);
9845 if (!empty($tmp[1])) {
9846 $outputlangs->load($tmp[1]);
9849 $value = $outputlangs->transnoentitiesnoconv($reg[1]);
9851 if (empty($converttextinhtmlifnecessary)) {
9853 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
9867 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $value, $text);
9875 while (preg_match(
'/__\[([^\]]+)\]__/', $text, $reg)) {
9876 $keyfound = $reg[1];
9878 $value =
'*****forbidden*****';
9880 $value = empty(
$conf->global->$keyfound) ?
'' :
$conf->global->$keyfound;
9883 if (empty($converttextinhtmlifnecessary)) {
9885 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
9898 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $value, $text);
9903 foreach ($substitutionarray as $key => $value) {
9904 if (!isset($value)) {
9908 if (($key ==
'__USER_SIGNATURE__' || $key ==
'__SENDEREMAIL_SIGNATURE__') && (
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN'))) {
9912 if (empty($converttextinhtmlifnecessary)) {
9913 $text = str_replace(
"$key",
"$value", $text);
9925 $text = str_replace(
"$key",
"$value", $text);
9941 $memory_object_list = array();
9942 foreach ($substitutionarray as $key => $value) {
9943 $lazy_load_arr = array();
9944 if (preg_match(
'/(__[A-Z\_]+__)@lazyload$/', $key, $lazy_load_arr)) {
9945 if (isset($lazy_load_arr[1]) && !empty($lazy_load_arr[1])) {
9946 $key_to_substitute = $lazy_load_arr[1];
9947 if (preg_match(
'/' . preg_quote($key_to_substitute,
'/') .
'/', $text)) {
9948 $param_arr = explode(
':', $value);
9950 if (count($param_arr) == 4) {
9951 $path = $param_arr[0];
9952 $class = $param_arr[1];
9953 $method = $param_arr[2];
9954 $id = (int) $param_arr[3];
9957 if (!isset($memory_object_list[$class])) {
9959 require_once DOL_DOCUMENT_ROOT . $path;
9960 if (class_exists($class)) {
9961 $memory_object_list[$class] = array(
9969 if (isset($memory_object_list[$class]) && isset($memory_object_list[$class][
'list'])) {
9970 if (method_exists($class, $method)) {
9971 if (!isset($memory_object_list[$class][
'list'][
$id])) {
9972 $tmpobj =
new $class($db);
9974 $valuetouseforsubstitution = $tmpobj->$method(
$id, $key_to_substitute);
9975 $memory_object_list[$class][
'list'][
$id] = $tmpobj;
9978 $tmpobj = $memory_object_list[$class][
'list'][
$id];
9980 $valuetouseforsubstitution = $tmpobj->$method(
$id, $key_to_substitute,
true);
9983 $text = str_replace(
"$key_to_substitute",
"$valuetouseforsubstitution", $text);
10009 global
$conf, $user;
10011 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
10016 $dirsubstitutions = array_merge(array(), (array)
$conf->modules_parts[
'substitutions']);
10018 foreach ($dirsubstitutions as $reldir) {
10026 $substitfiles =
dol_dir_list($dir,
'files', 0,
'functions_');
10027 foreach ($substitfiles as $substitfile) {
10029 if (preg_match(
'/functions_(.*)\.lib\.php/i', $substitfile[
'name'], $reg)) {
10032 dol_syslog(
"Library ".$substitfile[
'name'].
" found into ".$dir);
10034 require_once $dir.$substitfile[
'name'];
10036 $function_name = $module.
"_".$callfunc;
10037 if (function_exists($function_name)) {
10038 $function_name($substitutionarray, $outputlangs,
$object, $parameters);
10046 foreach ($substitutionarray as $key => $value) {
10047 $tags .=
'{'.$key.
'} => '.$value.
"\n";
10049 $substitutionarray = array_merge($substitutionarray, array(
'__ALL_TAGS__' => $tags));
10062function print_date_range($date_start, $date_end, $format =
'', $outputlangs =
null)
10064 print
get_date_range($date_start, $date_end, $format, $outputlangs);
10077function get_date_range($date_start, $date_end, $format =
'', $outputlangs =
null, $withparenthesis = 1)
10083 if (!is_object($outputlangs)) {
10084 $outputlangs = $langs;
10087 if ($date_start && $date_end) {
10088 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFromTo',
dol_print_date($date_start, $format,
false, $outputlangs),
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
10090 if ($date_start && !$date_end) {
10091 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($date_start, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
10093 if (!$date_start && $date_end) {
10094 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
10114 if ($nameorder < 0) {
10117 if ($nameorder == 1) {
10118 $ret .= $firstname;
10119 if ($firstname && $lastname) {
10123 } elseif ($nameorder == 2 || $nameorder == 3) {
10124 $ret .= $firstname;
10125 if (empty($ret) && $nameorder == 3) {
10130 if (empty($ret) && $nameorder == 5) {
10131 $ret .= $firstname;
10133 if ($nameorder == 0) {
10134 if ($firstname && $lastname) {
10137 $ret .= $firstname;
10156function setEventMessage($mesgs, $style =
'mesgs', $noduplicate = 0, $attop = 0)
10159 if (!is_array($mesgs)) {
10160 $mesgs = trim((
string) $mesgs);
10163 if (!empty($noduplicate) && isset($_SESSION[
'dol_events'][$style]) && in_array($mesgs, $_SESSION[
'dol_events'][$style])) {
10167 array_unshift($_SESSION[
'dol_events'][$style], $mesgs);
10169 $_SESSION[
'dol_events'][$style][] = $mesgs;
10174 foreach ($mesgs as $mesg) {
10175 $mesg = trim((
string) $mesg);
10177 if (!empty($noduplicate) && isset($_SESSION[
'dol_events'][$style]) && in_array($mesg, $_SESSION[
'dol_events'][$style])) {
10181 array_unshift($_SESSION[
'dol_events'][$style], $mesgs);
10183 $_SESSION[
'dol_events'][$style][] = $mesg;
10203function setEventMessages($mesg, $mesgs, $style =
'mesgs', $messagekey =
'', $noduplicate = 0, $attop = 0)
10205 if (empty($mesg) && empty($mesgs)) {
10213 if (empty($messagekey) || empty($_COOKIE[
"DOLUSER_HIDEMESSAGE".$messagekey])) {
10214 if (!in_array((
string) $style, array(
'mesgs',
'warnings',
'errors'))) {
10215 dol_print_error(
null,
'Bad parameter style='.$style.
' for setEventMessages');
10217 if (empty($mesgs)) {
10220 if (!empty($mesg) && !in_array($mesg, $mesgs)) {
10241 if (isset($_SESSION[
'dol_events'][
'mesgs'])) {
10242 if (empty($disabledoutputofmessages)) {
10245 unset($_SESSION[
'dol_events'][
'mesgs']);
10248 if (isset($_SESSION[
'dol_events'][
'errors'])) {
10249 if (empty($disabledoutputofmessages)) {
10252 unset($_SESSION[
'dol_events'][
'errors']);
10256 if (isset($_SESSION[
'dol_events'][
'warnings'])) {
10257 if (empty($disabledoutputofmessages)) {
10260 unset($_SESSION[
'dol_events'][
'warnings']);
10278function get_htmloutput_mesg($mesgstring =
'', $mesgarray = [], $style =
'ok', $keepembedded = 0)
10280 global
$conf, $langs;
10285 $divstart = $divend =
'';
10288 if ((empty(
$conf->use_javascript_ajax) ||
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') || $keepembedded) && !preg_match(
'/<div class=".*">/i', $out)) {
10289 $divstart =
'<div class="'.$style.
' clearboth">';
10290 $divend =
'</div>';
10293 if ((is_array($mesgarray) && count($mesgarray)) || $mesgstring) {
10294 $langs->load(
"errors");
10296 if (is_array($mesgarray) && count($mesgarray)) {
10297 foreach ($mesgarray as $message) {
10299 $out .= $langs->trans($message);
10300 if ($ret < count($mesgarray)) {
10307 $out .= $langs->trans($mesgstring);
10313 if (!empty(
$conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') && empty($keepembedded)) {
10314 $return =
'<script nonce="'.getNonce().
'">
10315 $(document).ready(function() {
10320 /* jnotify(message, preset of message type, keepmessage) */
10322 "'.($style ==
"ok" ? 3000 : $style).
'",
10323 '.($style ==
"ok" ?
"false" :
"true").
',
10324 { remove: function (){} } );
10365function dol_htmloutput_mesg($mesgstring =
'', $mesgarray = array(), $style =
'ok', $keepembedded = 0)
10367 if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) {
10373 if (is_array($mesgarray)) {
10374 foreach ($mesgarray as $val) {
10375 if ($val && preg_match(
'/class="error"/i', $val)) {
10379 if ($val && preg_match(
'/class="warning"/i', $val)) {
10384 } elseif ($mesgstring && preg_match(
'/class="error"/i', $mesgstring)) {
10386 } elseif ($mesgstring && preg_match(
'/class="warning"/i', $mesgstring)) {
10389 if ($style ==
'error') {
10392 if ($style ==
'warning') {
10396 if ($iserror || $iswarning) {
10398 $mesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $mesgstring);
10399 $mesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $mesgstring);
10400 $mesgstring = preg_replace(
'/<\/div>/',
'', $mesgstring);
10402 if (is_array($mesgarray)) {
10403 $newmesgarray = array();
10404 foreach ($mesgarray as $val) {
10405 if (is_string($val)) {
10406 $tmpmesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $val);
10407 $tmpmesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $tmpmesgstring);
10408 $tmpmesgstring = preg_replace(
'/<\/div>/',
'', $tmpmesgstring);
10409 $newmesgarray[] = $tmpmesgstring;
10411 dol_syslog(
"Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING);
10414 $mesgarray = $newmesgarray;
10416 print
get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ?
'error' :
'warning'), $keepembedded);
10458function dol_sort_array(&$array, $index, $order =
'asc', $natsort = 0, $case_sensitive = 0, $keepindex = 0)
10461 $order = strtolower($order);
10463 if (is_array($array)) {
10464 $sizearray = count($array);
10465 if ($sizearray > 0) {
10467 foreach (array_keys($array) as $key) {
10468 if (is_object($array[$key])) {
10469 $temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index;
10472 $temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index];
10474 if ($natsort == -1) {
10475 $temp[$key] =
'___'.$temp[$key];
10479 if (empty($natsort) || $natsort == -1) {
10480 if ($order ==
'asc') {
10486 if ($case_sensitive) {
10489 natcasesort($temp);
10491 if ($order !=
'asc') {
10492 $temp = array_reverse($temp,
true);
10498 foreach (array_keys($temp) as $key) {
10499 (is_numeric($key) && empty($keepindex)) ? $sorted[] = $array[$key] : $sorted[$key] = $array[$key];
10518 $str = (string) $str;
10521 $strLength = strlen($str);
10522 for ($i = 0; $i < $strLength; $i++) {
10523 if (ord($str[$i]) < 0x80) {
10525 } elseif ((ord($str[$i]) & 0xE0) == 0xC0) {
10527 } elseif ((ord($str[$i]) & 0xF0) == 0xE0) {
10529 } elseif ((ord($str[$i]) & 0xF8) == 0xF0) {
10531 } elseif ((ord($str[$i]) & 0xFC) == 0xF8) {
10533 } elseif ((ord($str[$i]) & 0xFE) == 0xFC) {
10538 for ($j = 0; $j < $n; $j++) {
10539 if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) {
10560 return preg_match(
'//u', $str) ? true :
false;
10572 if (function_exists(
'mb_check_encoding')) {
10574 if (!mb_check_encoding($str,
'ASCII')) {
10578 if (preg_match(
'/[^\x00-\x7f]/', $str)) {
10596 $tmp = ini_get(
"unicode.filesystem_encoding");
10597 if (empty($tmp) && !empty($_SERVER[
"WINDIR"])) {
10598 $tmp =
'iso-8859-1';
10607 if ($tmp ==
'iso-8859-1') {
10608 return mb_convert_encoding($str,
'ISO-8859-1',
'UTF-8');
10629function dol_getIdFromCode($db, $key, $tablename, $fieldkey =
'code', $fieldid =
'id', $entityfilter = 0, $filters =
'', $useCache =
true)
10639 if ($useCache && isset(
$conf->cache[
'codeid'][$tablename][$key][$fieldid])) {
10640 return $conf->cache[
'codeid'][$tablename][$key][$fieldid];
10643 dol_syslog(
'dol_getIdFromCode (value for field '.$fieldid.
' from key '.$key.
' not found into cache)', LOG_DEBUG);
10645 $sql =
"SELECT ".$fieldid.
" as valuetoget";
10646 $sql .=
" FROM ".MAIN_DB_PREFIX.$tablename;
10647 if ($fieldkey ==
'id' || $fieldkey ==
'rowid') {
10648 $sql .=
" WHERE ".$fieldkey.
" = ".((int) $key);
10650 $sql .=
" WHERE ".$fieldkey.
" = '".$db->escape($key).
"'";
10652 if (!empty($entityfilter)) {
10653 $sql .=
" AND entity IN (".getEntity($tablename).
")";
10659 $resql = $db->query($sql);
10661 $obj = $db->fetch_object($resql);
10664 $valuetoget = $obj->valuetoget;
10665 $conf->cache[
'codeid'][$tablename][$key][$fieldid] = $valuetoget;
10667 $conf->cache[
'codeid'][$tablename][$key][$fieldid] =
'';
10671 return $valuetoget;
10688 if ($matchrule == 1) {
10689 if ($var ==
'mainmenu') {
10691 return (preg_match(
'/^'.$regextext.
'/', $mainmenu));
10692 } elseif ($var ==
'leftmenu') {
10694 return (preg_match(
'/^'.$regextext.
'/', $leftmenu));
10696 return 'This variable is not accessible with dol_eval';
10699 return 'This value for matchrule is not implemented';
10713function verifCond($strToEvaluate, $onlysimplestring =
'1')
10717 if (isset($strToEvaluate) && $strToEvaluate !==
'') {
10720 $rep =
dol_eval($strToEvaluate, 1, 1, $onlysimplestring);
10721 $rights = (bool) $rep && (!is_string($rep) || strpos($rep,
'Bad string syntax to evaluate') ===
false);
10741function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring =
'1')
10745 global $db, $langs, $user, $website, $websitepage;
10746 global $action, $mainmenu, $leftmenu;
10748 global $objectoffield;
10754 $isObBufferActive =
false;
10755 if (!in_array($onlysimplestring, array(
'0',
'1',
'2'))) {
10756 return "Bad call of dol_eval. Parameter onlysimplestring must be '0' (deprecated), '1' or '2'";
10761 if ($onlysimplestring ==
'1' || $onlysimplestring ==
'2') {
10767 $specialcharsallowed =
'^$_+-.*>&|=!?():"\',/@';
10768 if ($onlysimplestring ==
'2') {
10769 $specialcharsallowed .=
'<[]';
10772 $specialcharsallowed .=
getDolGlobalString(
'MAIN_ALLOW_UNSECURED_SPECIAL_CHARS_IN_DOL_EVAL');
10774 if (preg_match(
'/[^a-z0-9\s'.preg_quote($specialcharsallowed,
'/').
']/i', $s)) {
10775 if ($returnvalue) {
10776 return 'Bad string syntax to evaluate (found chars that are not chars for a simple one line clean eval string): '.$s;
10778 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for a simple one line clean eval string): '.$s, LOG_WARNING);
10784 if (preg_match(
'/<=?[^\s]/', $s)) {
10785 if ($returnvalue) {
10786 return 'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found a < or <= without space before and after): '.$s;
10788 dol_syslog(
'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found a < or <= without space before and after): '.$s, LOG_WARNING);
10794 if (preg_match(
'/\$[\w]*\s*\(/', $s)) {
10795 if ($returnvalue) {
10796 return 'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found a call using of "$abc(" or "$abc (" instead of using the direct name of the function): '.$s;
10798 dol_syslog(
'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found a call using of "$abc(" or "$abc (" instead of using the direct name of the function): '.$s, LOG_WARNING);
10807 while ($scheck && $savescheck != $scheck) {
10808 $savescheck = $scheck;
10809 $scheck = preg_replace(
'/->[a-zA-Z0-9_]+\(/',
'->__METHOD__', $scheck);
10810 $scheck = preg_replace(
'/::[a-zA-Z0-9_]+\(/',
'->__METHOD__', $scheck);
10811 $scheck = preg_replace(
'/^\(+/',
'__PARENTHESIS__ ', $scheck);
10812 $scheck = preg_replace(
'/\&\&\s+\(/',
'__ANDPARENTHESIS__ ', $scheck);
10813 $scheck = preg_replace(
'/\|\|\s+\(/',
'__ORPARENTHESIS__ ', $scheck);
10814 $scheck = preg_replace(
'/^!?[a-zA-Z0-9_]+\(/',
'__FUNCTION__', $scheck);
10815 $scheck = preg_replace(
'/\s!?[a-zA-Z0-9_]+\(/',
'__FUNCTION__', $scheck);
10816 $scheck = preg_replace(
'/^!\(/',
'__NOTANDPARENTHESIS__', $scheck);
10817 $scheck = preg_replace(
'/\s!\(/',
'__NOTANDPARENTHESIS__', $scheck);
10818 $scheck = preg_replace(
'/(\^|\')\(/',
'__REGEXSTART__', $scheck);
10823 if (strpos($scheck,
'(') !==
false) {
10824 if ($returnvalue) {
10825 return 'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found call of a function or method without using the direct name of the function): '.$s;
10827 dol_syslog(
'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found call of a function or method without using the direct name of the function): '.$s, LOG_WARNING);
10836 if (is_array($s) || $s ===
'Array') {
10837 if ($returnvalue) {
10838 return 'Bad string syntax to evaluate (value is Array): '.var_export($s,
true);
10840 dol_syslog(
'Bad string syntax to evaluate (value is Array): '.var_export($s,
true), LOG_WARNING);
10845 if (!
getDolGlobalString(
'MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL') && strpos($s,
'::') !==
false) {
10846 if ($returnvalue) {
10847 return 'Bad string syntax to evaluate (double : char is forbidden without setting MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL): '.$s;
10849 dol_syslog(
'Bad string syntax to evaluate (double : char is forbidden without setting MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL): '.$s, LOG_WARNING);
10854 if (strpos($s,
'`') !==
false) {
10855 if ($returnvalue) {
10856 return 'Bad string syntax to evaluate (backtick char is forbidden): '.$s;
10858 dol_syslog(
'Bad string syntax to evaluate (backtick char is forbidden): '.$s, LOG_WARNING);
10865 if (preg_match(
'/[^0-9]+\.[^0-9]+/', $s)) {
10866 if ($returnvalue) {
10867 return 'Bad string syntax to evaluate (dot char is forbidden): '.$s;
10869 dol_syslog(
'Bad string syntax to evaluate (dot char is forbidden): '.$s, LOG_WARNING);
10876 $forbiddenphpstrings = array(
'$$',
'$_',
'}[');
10877 $forbiddenphpstrings = array_merge($forbiddenphpstrings, array(
'_ENV',
'_SESSION',
'_COOKIE',
'_GET',
'_POST',
'_REQUEST',
'ReflectionFunction'));
10882 $forbiddenphpfunctions = array();
10884 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"base64".
"_".
"decode",
"rawurl".
"decode",
"url".
"decode",
"str".
"_rot13",
"hex".
"2bin"));
10886 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"override_function",
"session_id",
"session_create_id",
"session_regenerate_id"));
10887 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"get_defined_functions",
"get_defined_vars",
"get_defined_constants",
"get_declared_classes"));
10888 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"function",
"call_user_func",
"call_user_func_array"));
10890 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"array_all",
"array_any",
"array_diff_ukey",
"array_filter",
"array_find",
"array_find_key",
"array_map",
"array_reduce",
"array_intersect_uassoc",
"array_intersect_ukey",
"array_walk",
"array_walk_recursive"));
10891 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"usort",
"uasort",
"uksort",
"preg_replace_callback",
"preg_replace_callback_array",
"header_register_callback"));
10892 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"set_error_handler",
"set_exception_handler",
"libxml_set_external_entity_loader",
"register_shutdown_function",
"register_tick_function",
"unregister_tick_function"));
10893 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"spl_autoload_register",
"spl_autoload_unregister",
"iterator_apply",
"session_set_save_handler"));
10894 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"forward_static_call",
"forward_static_call_array",
"register_postsend_function"));
10896 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"ob_start"));
10898 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"require",
"include",
"require_once",
"include_once"));
10899 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"exec",
"passthru",
"shell_exec",
"system",
"proc_open",
"popen"));
10900 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_eval",
"executeCLI",
"verifCond"));
10901 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"eval",
"create_function",
"assert",
"mb_ereg_replace",
"mb_ereg_replace_callback"));
10902 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"readline_completion_function",
"readline_callback_handler_install"));
10903 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_compress_dir",
"dol_decode",
"dol_delete_file",
"dol_delete_dir",
"dol_delete_dir_recursive",
"dol_copy",
"archiveOrBackupFile"));
10904 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"fopen",
"file_put_contents",
"fputs",
"fputscsv",
"fwrite",
"fpassthru",
"mkdir",
"rmdir",
"symlink",
"touch",
"unlink",
"umask"));
10905 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"require",
"include"));
10907 $forbiddenphpmethods = array(
'invoke',
'invokeArgs');
10909 $forbiddenphpregex =
'global\s*\$';
10910 $forbiddenphpregex .=
'|';
10911 $forbiddenphpregex .=
'\b('.implode(
'|', $forbiddenphpfunctions).
')\b';
10913 $forbiddenphpmethodsregex =
'->('.implode(
'|', $forbiddenphpmethods).
')';
10916 $oldstringtoclean = $s;
10917 $s = str_ireplace($forbiddenphpstrings,
'__forbiddenstring__', $s);
10918 $s = preg_replace(
'/'.$forbiddenphpregex.
'/i',
'__forbiddenstring__', $s);
10919 $s = preg_replace(
'/'.$forbiddenphpmethodsregex.
'/i',
'__forbiddenstring__', $s);
10921 }
while ($oldstringtoclean != $s);
10924 if (strpos($s,
'__forbiddenstring__') !==
false) {
10925 dol_syslog(
'Bad string syntax to evaluate: '.$s, LOG_WARNING);
10926 if ($returnvalue) {
10927 return 'Bad string syntax to evaluate: '.$s;
10929 dol_syslog(
'Bad string syntax to evaluate: '.$s);
10935 if ($returnvalue) {
10937 $isObBufferActive =
true;
10938 $tmps = $hideerrors ? @eval(
'return ' . $s .
';') : eval(
'return ' . $s .
';');
10939 $tmpo = ob_get_clean();
10940 $isObBufferActive =
false;
10942 print
'Bad string syntax to evaluate. Some data were output when it should not when evaluating: ' . $s;
10946 dol_syslog(
'Do not use anymore dol_eval with param returnvalue=0', LOG_WARNING);
10954 }
catch (Error $e) {
10955 if ($isObBufferActive) {
10957 $tmpo = ob_get_clean();
10958 $isObBufferActive =
false;
10960 $error =
'dol_eval try/catch error : ';
10961 $error .= $e->getMessage();
10963 if ($returnvalue) {
10964 return 'Exception during evaluation: '.$s;
10980 return (trim($element) !=
'');
10993 if (empty($codelang)) {
10997 if ($codelang ==
'auto') {
10998 return '<span class="fa fa-language"></span>';
11001 $langtocountryflag = array(
11003 'ca_ES' =>
'catalonia',
11007 'sw_SW' =>
'unknown',
11017 if (isset($langtocountryflag[$codelang])) {
11018 $flagImage = $langtocountryflag[$codelang];
11020 $tmparray = explode(
'_', $codelang);
11021 $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
11026 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
11027 $morecss = $reg[1];
11032 return '<span class="flag-sprite '.strtolower($flagImage).($morecss ?
' '.$morecss :
'').
'"'.($moreatt ?
' '.$moreatt :
'').(!$notitlealt ?
' title="'.$codelang.
'"' :
'').
'></span>';
11046 if (empty($countrycode)) {
11050 if (strtoupper($countrycode) ==
'MQ') {
11053 if (strtoupper($countrycode) ==
'SE') {
11056 if (strtoupper($countrycode) ==
'CH') {
11057 if ($mysoc->country_code ==
'FR') {
11060 if ($mysoc->country_code ==
'DE') {
11063 if ($mysoc->country_code ==
'IT') {
11245 $buildprimarykeytotest = strtolower($countrycode).
'-'.strtoupper($countrycode);
11246 if (in_array($buildprimarykeytotest, $locales)) {
11247 return strtolower($countrycode).
'_'.strtoupper($countrycode);
11250 if (function_exists(
'locale_get_primary_language') && function_exists(
'locale_get_region')) {
11251 foreach ($locales as $locale) {
11252 $locale_language = locale_get_primary_language($locale);
11253 $locale_region = locale_get_region($locale);
11254 if (strtoupper($countrycode) == $locale_region) {
11256 return strtolower($locale_language).
'_'.strtoupper($locale_region);
11260 dol_syslog(
"Warning Extension php-intl is not available", LOG_WARNING);
11298 global $hookmanager, $db;
11300 if (isset(
$conf->modules_parts[
'tabs'][$type]) && is_array(
$conf->modules_parts[
'tabs'][$type])) {
11301 foreach (
$conf->modules_parts[
'tabs'][$type] as $value) {
11302 $values = explode(
':', $value);
11305 if ($mode ==
'add' && !preg_match(
'/^\-/', $values[1])) {
11310 $posstart = strpos($str,
'(');
11311 if ($posstart > 0) {
11312 $posend = strpos($str,
')');
11313 if ($posstart > 0) {
11314 $res1 = substr($str, $posstart + 1, $posend - $posstart - 1);
11315 if (is_numeric($res1)) {
11316 $postab = (int) $res1;
11317 $values[1] =
'+' . substr($str, $posend + 1);
11321 if (count($values) == 6) {
11325 if ($values[0] != $type) {
11331 if ($filterorigmodule) {
11332 if (strpos($values[3],
'@')) {
11333 if ($filterorigmodule !=
'external') {
11337 if ($filterorigmodule !=
'core') {
11342 $langs->load($values[3]);
11344 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
11346 $substitutionarray = array();
11351 $labeltemp = explode(
',', $values[2]);
11352 $label = $langs->trans($labeltemp[0]);
11354 if (!empty($labeltemp[1]) && is_object(
$object) && !empty(
$object->id)) {
11356 $classtoload = $labeltemp[1];
11357 if (class_exists($classtoload)) {
11358 $obj =
new $classtoload($db);
11359 $function = $labeltemp[3];
11360 if ($obj && $function && method_exists($obj, $function)) {
11362 $nbrec = $obj->$function(
$object->id, $obj);
11363 if (!empty($nbrec)) {
11364 $label .=
'<span class="badge marginleftonlyshort">'.$nbrec.
'</span>';
11372 $newtab[1] = $label;
11373 $newtab[2] = str_replace(
'+',
'', $values[1]);
11378 } elseif (count($values) == 5) {
11379 dol_syslog(
'Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
11381 if ($values[0] != $type) {
11385 if ($filterorigmodule) {
11386 if (strpos($values[3],
'@')) {
11387 if ($filterorigmodule !=
'external') {
11391 if ($filterorigmodule !=
'core') {
11396 $langs->load($values[3]);
11398 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
11399 $substitutionarray = array();
11403 $label = $langs->trans($values[2]);
11407 $newtab[1] = $label;
11408 $newtab[2] = str_replace(
'+',
'', $values[1]);
11412 $head = array_merge(array_slice($head, 0, $postab), array($newtab), array_slice($head, $postab));
11413 } elseif ($mode ==
'remove' && preg_match(
'/^\-/', $values[1])) {
11414 if ($values[0] != $type) {
11417 $tabname = str_replace(
'-',
'', $values[1]);
11418 foreach ($head as $key => $val) {
11419 $condition = (!empty($values[3]) ?
verifCond($values[3],
'2') : 1);
11421 if ($head[$key][2] == $tabname && $condition) {
11422 unset($head[$key]);
11431 if (!empty($hookmanager)) {
11432 $parameters = array(
'object' =>
$object,
'mode' => $mode,
'head' => &$head,
'filterorigmodule' => $filterorigmodule);
11433 $reshook = $hookmanager->executeHooks(
'completeTabsHead', $parameters,
$object);
11434 if ($reshook > 0) {
11435 $head = $hookmanager->resArray;
11437 $head = array_merge($head, $hookmanager->resArray);
11456 global
$conf, $hookmanager, $user, $langs;
11459 global $micro_start_time;
11461 if ($zone ==
'private') {
11462 print
"\n".
'<!-- Common footer for private page -->'.
"\n";
11464 print
"\n".
'<!-- Common footer for public page -->'.
"\n";
11468 print
"\n<!-- A div to store page_y POST parameter -->\n";
11469 print
'<div id="page_y" style="display: none;">'.(GETPOST(
'page_y') ?
GETPOST(
'page_y') :
'').
'</div>'.
"\n";
11471 $parameters = array();
11472 $reshook = $hookmanager->executeHooks(
'printCommonFooter', $parameters);
11473 if (empty($reshook)) {
11479 if (!empty(
$conf->use_javascript_ajax)) {
11480 print
"\n<!-- A script section to add menuhider handler on backoffice, manage focus and mandatory fields, tuning info, ... -->\n";
11481 print
'<script>'.
"\n";
11482 print
'jQuery(document).ready(function() {'.
"\n";
11484 if ($zone ==
'private' && empty(
$conf->dol_use_jmobile)) {
11486 print
'/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'.
"\n";
11487 print
'jQuery("li.menuhider").click(function(event) {';
11488 print
' if (!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'.
"\n";
11489 print
' console.log("We click on .menuhider");'.
"\n";
11490 print
' $("body").toggleClass("sidebar-collapse")'.
"\n";
11495 if ($action ==
'create' || $action ==
'add' || $action ==
'edit' || (empty($action) && (preg_match(
'/new\.php/', $_SERVER[
"PHP_SELF"]))) || ((empty($action) || $action ==
'addline') && (preg_match(
'/card\.php/', $_SERVER[
"PHP_SELF"])))) {
11496 print
'/* JS CODE TO ENABLE to manage focus and mandatory form fields */'.
"\n";
11497 $relativepathstring = $_SERVER[
"PHP_SELF"];
11499 if (constant(
'DOL_URL_ROOT')) {
11500 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
11502 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
11503 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
11506 if (!empty($user->default_values[$relativepathstring][
'focus'])) {
11507 foreach ($user->default_values[$relativepathstring][
'focus'] as $defkey => $defval) {
11509 if ($defkey !=
'_noquery_') {
11510 $tmpqueryarraytohave = explode(
'&', $defkey);
11512 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
11513 $tmpquerytohaveparam = explode(
'=', $tmpquerytohave);
11515 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] !=
GETPOST($tmpquerytohaveparam[0]))) {
11519 if (!$foundintru) {
11528 print
'console.log("set the focus by executing jQuery(...).focus();")'.
"\n";
11529 foreach ($defval as $paramkey => $paramval) {
11531 print
'jQuery("input[name=\''.$paramkey.
'\']
").focus();'."\n
";
11532 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").focus();'."\n
"; // TODO KO with ckeditor
11533 print 'jQuery("select[
name=\
''.$paramkey.
'\']
").focus();'."\n
"; // Not really useful, but we keep it in case of.
11538 if (!empty($user->default_values[$relativepathstring]['mandatory'])) {
11539 foreach ($user->default_values[$relativepathstring]['mandatory'] as $defkey => $defval) {
11541 if ($defkey != '_noquery_') {
11542 $tmpqueryarraytohave = explode('&', $defkey);
11544 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
11545 $tmpquerytohaveparam = explode('=', $tmpquerytohave);
11546 //print "console.log(
'".$tmpquerytohaveparam[0]." ".$tmpquerytohaveparam[1]." ".GETPOST($tmpquerytohaveparam[0])."');
";
11547 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] != GETPOST($tmpquerytohaveparam[0]))) {
11551 if (!$foundintru) {
11554 //var_dump($defkey.'-'.$qualified);
11560 print 'console.log("set the js code to manage fields that are
set as mandatory
");'."\n
";
11562 foreach ($defval as $paramkey => $paramval) {
11563 // Solution 1: Add handler on submit to check if mandatory fields are empty
11564 print 'var form = $(\'#'.dol_escape_js($paramkey).'\').closest("form
");'."\n
";
11565 print "form.on(
'submit',
function(event) {
11566 var submitter = $(
this).find(
':submit:focus').get(0);
11568 var buttonName = $(submitter).attr(
'name');
11569 if (buttonName ==
'cancel') {
11570 console.log(
'We click on cancel button so we accept submit with no need to check mandatory fields');
11575 console.log(
'We did not click on cancel button but on something else, we check that field #".dol_escape_js($paramkey)." is not empty');
11577 var tmpvalue = jQuery(
'#".dol_escape_js($paramkey)."').val();
11578 let tmptypefield = jQuery(
'#".dol_escape_js($paramkey)."').prop(
'nodeName').toLowerCase();
11580 if (tmptypefield ==
'textarea') {
11582 var tmpeditor = CKEDITOR.instances[
'".dol_escape_js($paramkey)."'];
11584 tmpvalue = tmpeditor.getData();
11585 console.log(
'For textarea tmpvalue is '+tmpvalue);
11589 let tmpvalueisempty =
false;
11590 if (tmpvalue ===
null || tmpvalue === undefined || tmpvalue ===
'' || tmpvalue === -1) {
11591 tmpvalueisempty =
true;
11593 if (tmpvalue ===
'0' && (tmptypefield ==
'select' || tmptypefield ==
'input')) {
11594 tmpvalueisempty =
true;
11596 if (tmpvalueisempty && (buttonName ==
'save')) {
11597 console.log(
'field has type '+tmptypefield+
' and is empty, we cancel the submit');
11598 event.preventDefault();
11599 event.stopPropagation();
11600 alert(
'".dol_escape_js($langs->trans("ErrorFieldRequired", $paramkey).' (
'.$langs->trans("CustomMandatoryFieldRule").')
')."');
11603 console.log(
'field has type '+tmptypefield+
' and is defined to '+tmpvalue);
11608 // Solution 2: Add property 'required' on input
11609 // so browser will check value and try to focus on it when submitting the form.
11610 //print 'setTimeout(function() {'; // If we want to wait that ckeditor beuatifier has finished its job.
11611 //print 'jQuery("input[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
11612 //print 'jQuery("textarea[
id=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
11613 //print 'jQuery("select[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";*/
11614 //print '// required on a select works only if key is "", so we add the required attributes but also we reset the key -1 or 0 to an empty string'."\n
";
11615 //print 'jQuery("select[
name=\
''.$paramkey.
'\'] option[value=\
'-1\']").prop(\'value\', \'\');'.
"\n";
11621 print
'jQuery(\':input[name="' .
dol_escape_js($paramkey) .
'"]\').closest("tr").find("td:first").addClass("fieldrequired");'.
"\n";
11626 print
'jQuery("input[name=\'cancel\']").click(function() {
11627 console.log("We click on cancel button so removed all required attribute");
11628 jQuery("input, textarea, select").each(function(){this.removeAttribute(\'required\');});
11638 if (!empty($_SERVER[
'MAIN_SHOW_TUNING_INFO']) ||
getDolGlobalString(
'MAIN_SHOW_TUNING_INFO')) {
11640 print
"/* JS CODE TO ENABLE to add memory info */\n";
11641 print
'window.console && console.log("';
11646 if (!empty($micro_start_time)) {
11647 $micro_end_time = microtime(
true);
11648 print
' - Build time: '.ceil(1000 * ($micro_end_time - $micro_start_time)).
' ms';
11651 if (function_exists(
"memory_get_usage")) {
11652 print
' - Mem: '.memory_get_usage();
11654 if (function_exists(
"memory_get_peak_usage")) {
11655 print
' - Real mem peak: '.memory_get_peak_usage(
true);
11657 if (function_exists(
"zend_loader_file_encoded")) {
11658 print
' - Zend encoded file: '.(zend_loader_file_encoded() ?
'yes' :
'no');
11663 print
"\n".
'</script>'.
"\n";
11669 foreach ($tmptagarray as $tmptag) {
11671 print
"<!-- JS CODE TO ENABLE for google analtics tag -->\n";
11673 <!-- Global site tag (gtag.js) - Google Analytics -->
11674 <script nonce="'.getNonce().
'" async src="https://www.googletagmanager.com/gtag/js?id='.trim($tmptag).
'"></script>
11676 window.dataLayer = window.dataLayer || [];
11677 function gtag(){dataLayer.push(arguments);}
11678 gtag(\'js\', new Date());
11680 gtag(\'config\', \''.trim($tmptag).
'\');
11687 // Add Xdebug coverage of code
11688 if (defined('XDEBUGCOVERAGE
')) {
11689 print_r(xdebug_get_code_coverage());
11692 // Add DebugBar data
11693 if ($user->hasRight('debugbar
', 'read
') && $debugbar instanceof DebugBar\DebugBar) {
11694 if (isset($debugbar['time
'])) {
11695 // @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
11696 $debugbar['time
']->stopMeasure('pageaftermaster
');
11698 print '<!-- Output debugbar data -->
'."\n";
11699 $renderer = $debugbar->getJavascriptRenderer();
11700 print $renderer->render();
11701 } elseif (count($conf->logbuffer)) { // If there is some logs in buffer to show
11703 print "<!-- Start of log output\n";
11704 //print '<div
class=
"hidden">
'."\n";
11705 foreach ($conf->logbuffer as $logline) {
11706 print $logline."<br>\n";
11708 //print '</div>
'."\n";
11709 print "End of log output -->\n";
11723function dolExplodeIntoArray($string, $delimiter = ';
', $kv = '=
')
11725 if (is_null($string)) {
11729 if (preg_match('/^\[.*\]$/sm
', $delimiter) || preg_match('/^\(.*\)$/sm
', $delimiter)) {
11730 // This is a regex string
11731 $newdelimiter = $delimiter;
11733 // This is a simple string
11734 // @phan-suppress-next-line PhanPluginSuspiciousParamPositionInternal
11735 $newdelimiter = preg_quote($delimiter, '/
');
11738 if ($a = preg_split('/
'.$newdelimiter.'/
', $string)) {
11740 foreach ($a as $s) { // each part
11742 if ($pos = strpos($s, $kv)) { // key/value delimiter
11743 $ka[trim(substr($s, 0, $pos))] = trim(substr($s, $pos + strlen($kv)));
11744 } else { // key delimiter not found
11762function dol_set_focus($selector)
11764 print "\n".'<!-- Set focus onto a specific field -->
'."\n";
11765 print '<script nonce=
"'.getNonce().'">jQuery(document).ready(
function() { jQuery(
"'.dol_escape_js($selector).'").focus(); });</script>
'."\n";
11776function dol_getmypid()
11778 if (!function_exists('getmypid
')) {
11779 return mt_rand(99900000, 99965535);
11781 return getmypid(); // May be a number on 64 bits (depending on OS)
11807function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
11809 global $db, $langs;
11811 $value = trim($value);
11814 $value = preg_replace('/\*/
', '%
', $value); // Replace * with %
11817 $value = preg_replace('/([!<>=]+)\s+([0-9
'.preg_quote($langs->trans("DecimalSeparator"), '/
').'\-])/
', '\1\2
', $value); // Clean string '< 10
' into '<10
' so we can then explode on space to get all tests to do
11820 $value = preg_replace('/\s*\|\s*/
', '|
', $value);
11822 // Split criteria on ' '.
11823 // For mode 3, the split is done later on the , only and not on the ' '.
11824 if ($mode != -3 && $mode != 3) {
11825 $crits = explode(' ', $value);
11827 $crits = array($value);
11831 if (!is_array($fields)) {
11832 $fields = array($fields);
11835 $i1 = 0; // count the nb of "and" criteria added (all fields / criteria)
11836 foreach ($crits as $crit) { // Loop on each AND criteria
11837 $crit = trim($crit);
11838 $i2 = 0; // count the nb of valid criteria added for this this first criteria
11840 foreach ($fields as $field) {
11842 $tmpcrits = explode('|
', $crit);
11843 $i3 = 0; // count the nb of valid criteria added for this current field
11844 foreach ($tmpcrits as $tmpcrit) {
11845 if ($tmpcrit !== '0
' && empty($tmpcrit)) {
11848 $tmpcrit = trim($tmpcrit);
11850 $newres .= (($i2 > 0 || $i3 > 0) ? ' OR
' : '');
11853 $newcrit = preg_replace('/([!<>=]+)/
', '', $tmpcrit);
11856 preg_match('/([!<>=]+)/
', $tmpcrit, $reg);
11857 if (!empty($reg[1])) {
11858 $operator = $reg[1];
11860 if ($newcrit != '') {
11861 $numnewcrit = price2num($newcrit);
11862 if (is_numeric($numnewcrit)) {
11863 $newres .= $field.' '.$operator.' '.((float) $numnewcrit); // should be a numeric
11865 $newres .= '1 = 2
'; // force false, we received a corrupted data
11867 $i3++; // a criteria was added to string
11870 $i2++; // a criteria for 1 more field was added to string
11871 } elseif ($mode == 2 || $mode == -2) {
11872 $crit = preg_replace('/[^0-9,]/
', '', $crit); // ID are always integer
11873 $newres .= ($i2 > 0 ? ' OR
' : '').$field." ".($mode == -2 ? 'NOT
' : '');
11874 $newres .= $crit ? "IN (".$db->sanitize($db->escape($crit)).")" : "IN (0)";
11876 $newres .= ' OR
'.$field.' IS NULL
';
11878 $i2++; // a criteria for 1 more field was added to string
11879 } elseif ($mode == 3 || $mode == -3) {
11880 $tmparray = explode(',
', $crit);
11881 if (count($tmparray)) {
11883 foreach ($tmparray as $val) {
11886 $listofcodes .= ($listofcodes ? ',
' : '');
11887 $listofcodes .= "'".$db->escape($val)."'";
11890 $newres .= ($i2 > 0 ? ' OR
' : '').$field." ".($mode == -3 ? 'NOT
' : '')."IN (".$db->sanitize($listofcodes, 1, 0, 1).")";
11891 $i2++; // a criteria for 1 more field was added to string
11894 $newres .= ' OR
'.$field.' IS NULL
';
11896 } elseif ($mode == 4) {
11897 $tmparray = explode(',
', $crit);
11898 if (count($tmparray)) {
11900 foreach ($tmparray as $val) {
11903 $newres .= ($i2 > 0 ? " OR (" : "(").$field." LIKE '".$db->escape($val).",%
'";
11904 $newres .= ' OR
'.$field." = '".$db->escape($val)."'";
11905 $newres .= ' OR
'.$field." LIKE '%,
".$db->escape($val)."'";
11906 $newres .= ' OR
'.$field." LIKE '%,
".$db->escape($val).",%
'";
11908 $i2++; // a criteria for 1 more field was added to string (we can add several criteria for the same field as it is a multiselect search criteria)
11912 } else { // $mode=0
11913 $tmpcrits = explode('|
', $crit);
11914 $i3 = 0; // count the nb of valid criteria added for the current couple criteria/field
11915 foreach ($tmpcrits as $tmpcrit) { // loop on each OR criteria
11916 if ($tmpcrit !== '0
' && empty($tmpcrit)) {
11919 $tmpcrit = trim($tmpcrit);
11921 if ($tmpcrit == '^$
' || strpos($crit, '!
') === 0) { // If we search empty, we must combined different OR fields with AND
11922 $newres .= (($i2 > 0 || $i3 > 0) ? ' AND
' : '');
11924 $newres .= (($i2 > 0 || $i3 > 0) ? ' OR
' : '');
11927 if (preg_match('/\.(
id|rowid)$/
', $field)) { // Special case for rowid that is sometimes a ref so used as a search field
11928 $newres .= $field." = ".(is_numeric($tmpcrit) ? ((float) $tmpcrit) : '0
');
11930 $tmpcrit2 = $tmpcrit;
11935 if (preg_match('/^!/
', $tmpcrit)) {
11936 $tmps .= $field." NOT LIKE "; // ! as exclude character
11937 $tmpcrit2 = preg_replace('/^!/
', '', $tmpcrit2);
11939 $tmps .= $field." LIKE ";
11943 if (preg_match('/^[\^\$]/', $tmpcrit)) {
11945 $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
11947 if (preg_match('/[\^\$]$/', $tmpcrit)) {
11949 $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
11952 if ($tmpcrit2 == '' || preg_match('/^!/', $tmpcrit)) {
11956 $newres .= $tmpbefore;
11957 $newres .= $db->escape($tmpcrit2);
11958 $newres .= $tmpafter;
11960 if ($tmpcrit2 == '' || preg_match('/^!/
', $tmpcrit)) {
11961 $newres .= " OR ".$field." IS NULL)";
11968 $i2++; // a criteria for 1 more field was added to string
11973 $res = $res.($res ? ' AND
' : '').($i2 > 1 ? '(
' : '').$newres.($i2 > 1 ? ')
' : '');
11977 $res = ($nofirstand ? "" : " AND ")."(".$res.")";
11988function showDirectDownloadLink($object)
11993 $url = $object->getLastMainDocLink($object->element);
11995 $out .= img_picto($langs->trans("PublicDownloadLinkDesc"), 'globe
').' <span
class=
"opacitymedium">
'.$langs->trans("DirectDownloadLink").'</span><br>
';
11997 $out .= '<div
class=
"urllink"><input
type=
"text" id=
"directdownloadlink" class=
"quatrevingtpercent" value=
"'.$url.'"></div>
';
11998 $out .= ajax_autoselect("directdownloadlink", '');
12000 $out .= '<div
class=
"urllink">
'.$langs->trans("FileNotShared").'</div>
';
12014function getImageFileNameForSize($file, $extName, $extImgTarget = '
')
12016 $dirName = dirname($file);
12017 if ($dirName == '.
') {
12021 if (!in_array($extName, array('', '_small
', '_mini
'))) {
12022 return 'Bad parameter extName
';
12025 $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp|\.webp)$/i
', '', $file); // We remove image extension, whatever is its case
12026 $fileName = basename($fileName);
12028 if (empty($extImgTarget)) {
12029 $extImgTarget = (preg_match('/\.jpg$/i
', $file) ? '.jpg
' : '');
12031 if (empty($extImgTarget)) {
12032 $extImgTarget = (preg_match('/\.jpeg$/i
', $file) ? '.jpeg
' : '');
12034 if (empty($extImgTarget)) {
12035 $extImgTarget = (preg_match('/\.gif$/i
', $file) ? '.gif
' : '');
12037 if (empty($extImgTarget)) {
12038 $extImgTarget = (preg_match('/\.png$/i
', $file) ? '.png
' : '');
12040 if (empty($extImgTarget)) {
12041 $extImgTarget = (preg_match('/\.bmp$/i
', $file) ? '.bmp
' : '');
12043 if (empty($extImgTarget)) {
12044 $extImgTarget = (preg_match('/\.webp$/i
', $file) ? '.webp
' : '');
12047 if (!$extImgTarget) {
12053 $subdir = 'thumbs/
';
12056 return ($dirName ? $dirName.'/
' : '').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb
12069function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param = '
')
12071 global $conf, $langs;
12073 if (empty($conf->use_javascript_ajax)) {
12077 $isAllowedForPreview = dolIsAllowedForPreview($relativepath);
12079 if ($alldata == 1) {
12080 if ($isAllowedForPreview) {
12081 return array('target
' => '_blank
', 'css
' => 'documentpreview
', 'url
' => DOL_URL_ROOT.'/document.php?modulepart=
'.urlencode($modulepart).'&attachment=0&file=
'.urlencode($relativepath).($param ? '&
'.$param : ''), 'mime
' => dol_mimetype($relativepath));
12087 // old behavior, return a string
12088 if ($isAllowedForPreview) {
12089 $tmpurl = DOL_URL_ROOT.'/document.php?modulepart=
'.urlencode($modulepart).'&attachment=0&file=
'.urlencode($relativepath).($param ? '&
'.$param : '');
12090 $title = $langs->transnoentities("Preview");
12091 //$title = '%27-alert(document.domain)-%27
'; // An example of js injection into a corrupted title string, that should be blocked by the dol_escape_uri().
12092 //$tmpurl = 'file=
'.urlencode("'-alert(document.domain)-
'_small.jpg"); // An example of tmpurl that should be blocked by the dol_escape_uri()
12094 // We need to do a dol_escape_uri() on the full string after the javascript: because such parts are the URI and when we click on such links, a RFC3986 decode is done,
12095 // by the browser, converting the %27 (like when having param file=abc%27def), or when having a corrupted title), into a ', BEFORE interpreting the content that can be a js code.
12109function getLabelSpecialCode($idcode)
12113 $arrayspecialines = array(1 => 'Transport
', 2 => 'EcoTax
', 3 => 'Option
');
12114 if ($idcode > 10) {
12115 return 'Module ID
'.$idcode;
12117 if (!empty($arrayspecialines[$idcode])) {
12118 return $langs->trans($arrayspecialines[$idcode]);
12131function ajax_autoselect($htmlname, $addlink = '
', $textonlink = 'Link')
12134 $out = '<script nonce=
"'.getNonce().'">
12135 jQuery(document).ready(
function () {
12136 jQuery(
"'.((strpos($htmlname, '.') === 0 ? '' : '#').$htmlname).'").click(
function() { jQuery(
this).select(); } );
12140 if ($textonlink === 'image
') {
12141 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.img_picto('', 'globe
').'</a>
';
12143 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.$langs->trans("Link").'</a>
';
12156function dolIsAllowedForPreview($file)
12158 // Check .noexe extension in filename
12159 if (preg_match('/\.noexe$/i
', $file)) {
12163 // Check mime types
12164 $mime_preview = array('bmp
', 'jpeg
', 'png
', 'gif
', 'tiff
', 'pdf
', 'plain
', 'css
', 'webp
');
12165 if (getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES
')) {
12166 $mime_preview[] = 'svg+xml
';
12168 //$mime_preview[]='vnd.oasis.opendocument.presentation
';
12169 //$mime_preview[]='archive
';
12170 $num_mime = array_search(dol_mimetype($file, '', 1), $mime_preview);
12171 if ($num_mime !== false) {
12175 // By default, not allowed for preview
12189function dol_mimetype($file, $default = 'application/octet-stream
', $mode = 0)
12192 $imgmime = 'other.png
';
12193 $famime = 'file-o
';
12196 $tmpfile = preg_replace('/\.noexe$/
', '', $file);
12198 // Plain text files
12199 if (preg_match('/\.txt$/i
', $tmpfile)) {
12200 $mime = 'text/plain
';
12201 $imgmime = 'text.png
';
12202 $famime = 'file-alt
';
12203 } elseif (preg_match('/\.rtx$/i
', $tmpfile)) {
12204 $mime = 'text/richtext
';
12205 $imgmime = 'text.png
';
12206 $famime = 'file-alt
';
12207 } elseif (preg_match('/\.csv$/i
', $tmpfile)) {
12208 $mime = 'text/csv
';
12209 $imgmime = 'text.png
';
12210 $famime = 'file-csv
';
12211 } elseif (preg_match('/\.tsv$/i
', $tmpfile)) {
12212 $mime = 'text/tab-separated-values
';
12213 $imgmime = 'text.png
';
12214 $famime = 'file-alt
';
12215 } elseif (preg_match('/\.(cf|
conf|log)$/i
', $tmpfile)) {
12216 $mime = 'text/plain
';
12217 $imgmime = 'text.png
';
12218 $famime = 'file-alt
';
12219 } elseif (preg_match('/\.ini$/i
', $tmpfile)) {
12220 $mime = 'text/plain
';
12221 $imgmime = 'text.png
';
12223 $famime = 'file-alt
';
12224 } elseif (preg_match('/\.md$/i
', $tmpfile)) {
12225 $mime = 'text/plain
';
12226 $imgmime = 'text.png
';
12228 $famime = 'file-alt
';
12229 } elseif (preg_match('/\.css$/i
', $tmpfile)) {
12230 $mime = 'text/css
';
12231 $imgmime = 'css.png
';
12233 $famime = 'file-alt
';
12234 } elseif (preg_match('/\.lang$/i
', $tmpfile)) {
12235 $mime = 'text/plain
';
12236 $imgmime = 'text.png
';
12238 $famime = 'file-alt
';
12239 } elseif (preg_match('/\.(crt|cer|key|pub)$/i
', $tmpfile)) { // Certificate files
12240 $mime = 'text/plain
';
12241 $imgmime = 'text.png
';
12242 $famime = 'file-alt
';
12243 } elseif (preg_match('/\.(html|htm|shtml)$/i
', $tmpfile)) { // XML based (HTML/XML/XAML)
12244 $mime = 'text/html
';
12245 $imgmime = 'html.png
';
12247 $famime = 'file-alt
';
12248 } elseif (preg_match('/\.(xml|xhtml)$/i
', $tmpfile)) {
12249 $mime = 'text/xml
';
12250 $imgmime = 'other.png
';
12252 $famime = 'file-alt
';
12253 } elseif (preg_match('/\.xaml$/i
', $tmpfile)) {
12254 $mime = 'text/xml
';
12255 $imgmime = 'other.png
';
12257 $famime = 'file-alt
';
12258 } elseif (preg_match('/\.bas$/i
', $tmpfile)) { // Languages
12259 $mime = 'text/plain
';
12260 $imgmime = 'text.png
';
12262 $famime = 'file-code
';
12263 } elseif (preg_match('/\.(c)$/i
', $tmpfile)) {
12264 $mime = 'text/plain
';
12265 $imgmime = 'text.png
';
12267 $famime = 'file-code
';
12268 } elseif (preg_match('/\.(cpp)$/i
', $tmpfile)) {
12269 $mime = 'text/plain
';
12270 $imgmime = 'text.png
';
12272 $famime = 'file-code
';
12273 } elseif (preg_match('/\.cs$/i
', $tmpfile)) {
12274 $mime = 'text/plain
';
12275 $imgmime = 'text.png
';
12277 $famime = 'file-code
';
12278 } elseif (preg_match('/\.(h)$/i
', $tmpfile)) {
12279 $mime = 'text/plain
';
12280 $imgmime = 'text.png
';
12282 $famime = 'file-code
';
12283 } elseif (preg_match('/\.(java|jsp)$/i
', $tmpfile)) {
12284 $mime = 'text/plain
';
12285 $imgmime = 'text.png
';
12287 $famime = 'file-code
';
12288 } elseif (preg_match('/\.php([0-9]{1})?$/i
', $tmpfile)) {
12289 $mime = 'text/plain
';
12290 $imgmime = 'php.png
';
12292 $famime = 'file-code
';
12293 } elseif (preg_match('/\.phtml$/i
', $tmpfile)) {
12294 $mime = 'text/plain
';
12295 $imgmime = 'php.png
';
12297 $famime = 'file-code
';
12298 } elseif (preg_match('/\.(pl|pm)$/i
', $tmpfile)) {
12299 $mime = 'text/plain
';
12300 $imgmime = 'pl.png
';
12302 $famime = 'file-code
';
12303 } elseif (preg_match('/\.sql$/i
', $tmpfile)) {
12304 $mime = 'text/plain
';
12305 $imgmime = 'text.png
';
12307 $famime = 'file-code
';
12308 } elseif (preg_match('/\.js$/i
', $tmpfile)) {
12309 $mime = 'text/x-javascript
';
12310 $imgmime = 'jscript.png
';
12312 $famime = 'file-code
';
12313 } elseif (preg_match('/\.odp$/i
', $tmpfile)) { // Open office
12314 $mime = 'application/vnd.oasis.opendocument.presentation
';
12315 $imgmime = 'ooffice.png
';
12316 $famime = 'file-powerpoint
';
12317 } elseif (preg_match('/\.ods$/i
', $tmpfile)) {
12318 $mime = 'application/vnd.oasis.opendocument.spreadsheet
';
12319 $imgmime = 'ooffice.png
';
12320 $famime = 'file-excel
';
12321 } elseif (preg_match('/\.odt$/i
', $tmpfile)) {
12322 $mime = 'application/vnd.oasis.opendocument.text
';
12323 $imgmime = 'ooffice.png
';
12324 $famime = 'file-word
';
12325 } elseif (preg_match('/\.mdb$/i
', $tmpfile)) { // MS Office
12326 $mime = 'application/msaccess
';
12327 $imgmime = 'mdb.png
';
12329 } elseif (preg_match('/\.doc[xm]?$/i
', $tmpfile)) {
12330 $mime = 'application/msword
';
12331 $imgmime = 'doc.png
';
12332 $famime = 'file-word
';
12333 } elseif (preg_match('/\.dot[xm]?$/i
', $tmpfile)) {
12334 $mime = 'application/msword
';
12335 $imgmime = 'doc.png
';
12336 $famime = 'file-word
';
12337 } elseif (preg_match('/\.xlt(x)?$/i
', $tmpfile)) {
12338 $mime = 'application/vnd.ms-excel
';
12339 $imgmime = 'xls.png
';
12340 $famime = 'file-excel
';
12341 } elseif (preg_match('/\.xla(m)?$/i
', $tmpfile)) {
12342 $mime = 'application/vnd.ms-excel
';
12343 $imgmime = 'xls.png
';
12344 $famime = 'file-excel
';
12345 } elseif (preg_match('/\.xls$/i
', $tmpfile)) {
12346 $mime = 'application/vnd.ms-excel
';
12347 $imgmime = 'xls.png
';
12348 $famime = 'file-excel
';
12349 } elseif (preg_match('/\.xls[bmx]$/i
', $tmpfile)) {
12350 $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
';
12351 $imgmime = 'xls.png
';
12352 $famime = 'file-excel
';
12353 } elseif (preg_match('/\.pps[mx]?$/i
', $tmpfile)) {
12354 $mime = 'application/vnd.ms-powerpoint
';
12355 $imgmime = 'ppt.png
';
12356 $famime = 'file-powerpoint
';
12357 } elseif (preg_match('/\.ppt[mx]?$/i
', $tmpfile)) {
12358 $mime = 'application/x-mspowerpoint
';
12359 $imgmime = 'ppt.png
';
12360 $famime = 'file-powerpoint
';
12361 } elseif (preg_match('/\.pdf$/i
', $tmpfile)) { // Other
12362 $mime = 'application/pdf
';
12363 $imgmime = 'pdf.png
';
12364 $famime = 'file-pdf
';
12365 } elseif (preg_match('/\.bat$/i
', $tmpfile)) { // Scripts
12366 $mime = 'text/x-bat
';
12367 $imgmime = 'script.png
';
12369 $famime = 'file-code
';
12370 } elseif (preg_match('/\.sh$/i
', $tmpfile)) {
12371 $mime = 'text/x-sh
';
12372 $imgmime = 'script.png
';
12374 $famime = 'file-code
';
12375 } elseif (preg_match('/\.ksh$/i
', $tmpfile)) {
12376 $mime = 'text/x-ksh
';
12377 $imgmime = 'script.png
';
12379 $famime = 'file-code
';
12380 } elseif (preg_match('/\.bash$/i
', $tmpfile)) {
12381 $mime = 'text/x-bash
';
12382 $imgmime = 'script.png
';
12384 $famime = 'file-code
';
12385 } elseif (preg_match('/\.ico$/i
', $tmpfile)) { // Images
12386 $mime = 'image/x-icon
';
12387 $imgmime = 'image.png
';
12388 $famime = 'file-image
';
12389 } elseif (preg_match('/\.(jpg|jpeg)$/i
', $tmpfile)) {
12390 $mime = 'image/jpeg
';
12391 $imgmime = 'image.png
';
12392 $famime = 'file-image
';
12393 } elseif (preg_match('/\.png$/i
', $tmpfile)) {
12394 $mime = 'image/png
';
12395 $imgmime = 'image.png
';
12396 $famime = 'file-image
';
12397 } elseif (preg_match('/\.gif$/i
', $tmpfile)) {
12398 $mime = 'image/gif
';
12399 $imgmime = 'image.png
';
12400 $famime = 'file-image
';
12401 } elseif (preg_match('/\.bmp$/i
', $tmpfile)) {
12402 $mime = 'image/bmp
';
12403 $imgmime = 'image.png
';
12404 $famime = 'file-image
';
12405 } elseif (preg_match('/\.(tif|tiff)$/i
', $tmpfile)) {
12406 $mime = 'image/tiff
';
12407 $imgmime = 'image.png
';
12408 $famime = 'file-image
';
12409 } elseif (preg_match('/\.svg$/i
', $tmpfile)) {
12410 $mime = 'image/svg+xml
';
12411 $imgmime = 'image.png
';
12412 $famime = 'file-image
';
12413 } elseif (preg_match('/\.webp$/i
', $tmpfile)) {
12414 $mime = 'image/webp
';
12415 $imgmime = 'image.png
';
12416 $famime = 'file-image
';
12417 } elseif (preg_match('/\.vcs$/i
', $tmpfile)) { // Calendar
12418 $mime = 'text/calendar
';
12419 $imgmime = 'other.png
';
12420 $famime = 'file-alt
';
12421 } elseif (preg_match('/\.ics$/i
', $tmpfile)) {
12422 $mime = 'text/calendar
';
12423 $imgmime = 'other.png
';
12424 $famime = 'file-alt
';
12425 } elseif (preg_match('/\.torrent$/i
', $tmpfile)) { // Other
12426 $mime = 'application/x-bittorrent
';
12427 $imgmime = 'other.png
';
12428 $famime = 'file-o
';
12429 } elseif (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i
', $tmpfile)) { // Audio
12431 $imgmime = 'audio.png
';
12432 $famime = 'file-audio
';
12433 } elseif (preg_match('/\.mp4$/i
', $tmpfile)) { // Video
12434 $mime = 'video/mp4
';
12435 $imgmime = 'video.png
';
12436 $famime = 'file-video
';
12437 } elseif (preg_match('/\.ogv$/i
', $tmpfile)) {
12438 $mime = 'video/ogg
';
12439 $imgmime = 'video.png
';
12440 $famime = 'file-video
';
12441 } elseif (preg_match('/\.webm$/i
', $tmpfile)) {
12442 $mime = 'video/webm
';
12443 $imgmime = 'video.png
';
12444 $famime = 'file-video
';
12445 } elseif (preg_match('/\.avi$/i
', $tmpfile)) {
12446 $mime = 'video/x-msvideo
';
12447 $imgmime = 'video.png
';
12448 $famime = 'file-video
';
12449 } elseif (preg_match('/\.divx$/i
', $tmpfile)) {
12450 $mime = 'video/divx
';
12451 $imgmime = 'video.png
';
12452 $famime = 'file-video
';
12453 } elseif (preg_match('/\.xvid$/i
', $tmpfile)) {
12454 $mime = 'video/xvid
';
12455 $imgmime = 'video.png
';
12456 $famime = 'file-video
';
12457 } elseif (preg_match('/\.(wmv|mpg|mpeg)$/i
', $tmpfile)) {
12459 $imgmime = 'video.png
';
12460 $famime = 'file-video
';
12461 } elseif (preg_match('/\.(zip|rar|gz|tgz|xz|z|cab|bz2|7z|tar|lzh|zst)$/i
', $tmpfile)) { // Archive
12462 // application/xxx where zzz is zip, ...
12464 $imgmime = 'archive.png
';
12465 $famime = 'file-archive
';
12466 } elseif (preg_match('/\.(exe|com)$/i
', $tmpfile)) { // Exe
12467 $mime = 'application/octet-stream
';
12468 $imgmime = 'other.png
';
12469 $famime = 'file-o
';
12470 } elseif (preg_match('/\.(dll|lib|o|so|a)$/i
', $tmpfile)) { // Lib
12472 $imgmime = 'library.png
';
12473 $famime = 'file-o
';
12474 } elseif (preg_match('/\.err$/i
', $tmpfile)) { // phpcs:ignore
12476 $imgmime = 'error.png
';
12477 $famime = 'file-alt
';
12480 if ($famime == 'file-o
') {
12481 // file-o seems to not work in fontawesome 5
12485 // Return mimetype string
12486 switch ((int) $mode) {
12488 $tmp = explode('/
', $mime);
12489 return (!empty($tmp[1]) ? $tmp[1] : $tmp[0]);
12511function getDictionaryValue($tablename, $field, $id, $checkentity = false, $rowidfield = 'rowid
')
12515 $tablename = preg_replace('/^
'.preg_quote(MAIN_DB_PREFIX, '/
').'/
', '', $tablename); // Clean name of table for backward compatibility.
12517 $dictvalues = (isset($conf->cache['dictvalues_
'.$tablename]) ? $conf->cache['dictvalues_
'.$tablename] : null);
12519 if (is_null($dictvalues)) {
12520 $dictvalues = array();
12522 $sql = "SELECT * FROM ".MAIN_DB_PREFIX.$tablename." WHERE 1 = 1"; // Here select * is allowed as it is generic code and we don't have list of fields
12523 if ($checkentity) {
12524 $sql .=
' AND entity IN (0,'.getEntity($tablename).
')';
12527 $resql = $db->query($sql);
12529 while ($obj = $db->fetch_object($resql)) {
12530 $dictvalues[$obj->$rowidfield] = $obj;
12536 $conf->cache[
'dictvalues_'.$tablename] = $dictvalues;
12539 if (!empty($dictvalues[
$id])) {
12541 $tmp = $dictvalues[
$id];
12542 return (property_exists($tmp, $field) ? $tmp->$field :
'');
12557 $stringcolor = str_replace(
'#',
'', $stringcolor);
12559 if (!empty($stringcolor)) {
12561 $tmp = explode(
',', $stringcolor);
12562 if (count($tmp) > 1) {
12567 $hexr = $stringcolor[0].$stringcolor[1];
12568 $hexg = $stringcolor[2].$stringcolor[3];
12569 $hexb = $stringcolor[4].$stringcolor[5];
12570 $r = hexdec($hexr);
12571 $g = hexdec($hexg);
12572 $b = hexdec($hexb);
12574 $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0;
12575 if ($bright > 0.6) {
12596 if (empty($menuentry[
'enabled'])) {
12599 if ($type_user && $menuentry[
'module']) {
12600 $tmploops = explode(
'|', $menuentry[
'module']);
12602 foreach ($tmploops as $tmploop) {
12603 if (in_array($tmploop, $listofmodulesforexternal)) {
12612 if (!$menuentry[
'perms'] && $type_user) {
12618 if (!$menuentry[
'perms']) {
12633 $result = (ceil($n) % $x === 0) ? ceil($n) : (round(($n + $x / 2) / $x) * $x);
12634 return (
int) $result;
12648function dolGetBadge($label, $html =
'', $type =
'primary', $mode =
'', $url =
'', $params = array())
12650 $csstouse =
'badge';
12651 $csstouse .= (!empty($mode) ?
' badge-'.$mode :
'');
12652 $csstouse .= (!empty($type) ?
' badge-'.$type :
'');
12653 $csstouse .= (empty($params[
'css']) ?
'' :
' '.$params[
'css']);
12656 'class' => $csstouse
12659 if (empty($html)) {
12663 if (!empty($url)) {
12664 $attr[
'href'] = $url;
12667 if ($mode ===
'dot') {
12668 $attr[
'class'] .=
' classfortooltip';
12669 $attr[
'title'] = $html;
12670 $attr[
'aria-label'] = $label;
12675 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
12676 foreach ($params[
'attr'] as $key => $value) {
12677 if ($key ==
'class') {
12678 $attr[
'class'] .=
' '.$value;
12679 } elseif ($key ==
'classOverride') {
12680 $attr[
'class'] = $value;
12682 $attr[$key] = $value;
12690 $attr = array_map(
'dolPrintHTMLForAttribute', $attr);
12692 $TCompiledAttr = array();
12693 foreach ($attr as $key => $value) {
12694 $TCompiledAttr[] = $key.
'="'.$value.
'"';
12697 $compiledAttributes = !empty($TCompiledAttr) ? implode(
' ', $TCompiledAttr) :
'';
12699 $tag = !empty($url) ?
'a' :
'span';
12701 return '<'.$tag.
' '.$compiledAttributes.
'>'.$html.
'</'.$tag.
'>';
12717function dolGetStatus($statusLabel =
'', $statusLabelShort =
'', $html =
'', $statusType =
'status0', $displayMode = 0, $url =
'', $params = array())
12722 $dolGetBadgeParams = array();
12724 if (!empty($params[
'badgeParams'])) {
12725 $dolGetBadgeParams = $params[
'badgeParams'];
12729 if ($displayMode == 0) {
12730 $return = !empty($html) ? $html : (empty(
$conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort));
12731 } elseif ($displayMode == 1) {
12732 $return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
12736 $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ?
'<span class="hideonsmartphone">' :
'').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ?
'</span>' :
'');
12737 $htmlLabelShort = (in_array($displayMode, array(1, 2, 5)) ?
'<span class="hideonsmartphone">' :
'').(!empty($html) ? $html : (!empty($statusLabelShort) ? $statusLabelShort : $statusLabel)).(in_array($displayMode, array(1, 2, 5)) ?
'</span>' :
'');
12740 if (!empty(
$conf->dol_optimize_smallscreen)) {
12741 if ($displayMode == 0) {
12743 } elseif ($displayMode == 4) {
12745 } elseif ($displayMode == 6) {
12751 $statusImg = array(
12752 'status0' =>
'statut0',
12753 'status1' =>
'statut1',
12754 'status2' =>
'statut2',
12755 'status3' =>
'statut3',
12756 'status4' =>
'statut4',
12757 'status5' =>
'statut5',
12758 'status6' =>
'statut6',
12759 'status7' =>
'statut7',
12760 'status8' =>
'statut8',
12761 'status9' =>
'statut9'
12764 if (!empty($statusImg[$statusType])) {
12765 $htmlImg =
img_picto($statusLabel, $statusImg[$statusType]);
12767 $htmlImg =
img_picto($statusLabel, $statusType);
12770 if ($displayMode === 2) {
12771 $return = $htmlImg.
' '.$htmlLabelShort;
12772 } elseif ($displayMode === 3) {
12773 $return = $htmlImg;
12774 } elseif ($displayMode === 4) {
12775 $return = $htmlImg.
' '.$htmlLabel;
12776 } elseif ($displayMode === 5) {
12777 $return = $htmlLabelShort.
' '.$htmlImg;
12779 $return = $htmlLabel.
' '.$htmlImg;
12783 $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
12785 $dolGetBadgeParams[
'attr'][
'class'] =
'badge-status';
12786 if (empty($dolGetBadgeParams[
'attr'][
'title'])) {
12787 $dolGetBadgeParams[
'attr'][
'title'] = empty($params[
'tooltip']) ? $statusLabel : ($params[
'tooltip'] !=
'no' ? $params[
'tooltip'] :
'');
12789 $dolGetBadgeParams[
'attr'][
'class'] .=
' classfortooltip';
12791 $dolGetBadgeParams[
'attr'][
'title'] =
dol_htmlentitiesbr($dolGetBadgeParams[
'attr'][
'title'], 1);
12794 if ($displayMode == 3) {
12795 $return =
dolGetBadge((empty(
$conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)),
'', $statusType,
'dot', $url, $dolGetBadgeParams);
12796 } elseif ($displayMode === 5) {
12797 $return =
dolGetBadge($statusLabelShort, $html, $statusType,
'', $url, $dolGetBadgeParams);
12799 $return =
dolGetBadge(((empty(
$conf->dol_optimize_smallscreen) && $displayMode != 2) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), $html, $statusType,
'', $url, $dolGetBadgeParams);
12845function dolGetButtonAction($label, $text =
'', $actionType =
'default', $url =
'',
$id =
'', $userRight = 1, $params = array())
12847 global $hookmanager, $action,
$object, $langs;
12850 if (is_array($url)) {
12852 foreach ($url as $key => $subbutton) {
12853 if (isset($subbutton[
'enabled']) && empty($subbutton[
'enabled'])) {
12860 if (array_key_exists(
'areDropdownButtons', $params) && $params[
"areDropdownButtons"] ===
false) {
12861 foreach ($url as $button) {
12862 if (!empty($button[
'lang'])) {
12863 $langs->load($button[
'lang']);
12865 $label = $langs->trans($button[
'label']);
12866 $text = $button[
'text'] ??
'';
12867 $actionType = $button[
'actionType'] ??
'';
12868 $tmpUrl = DOL_URL_ROOT.$button[
'url'].(empty($params[
'backtopage']) ?
'' :
'&backtopage='.urlencode($params[
'backtopage']));
12869 $id = $button[
'id'] ??
'';
12870 $userRight = $button[
'perm'] ?? 1;
12871 $button[
'params'] = $button[
'params'] ?? [];
12873 $out .=
dolGetButtonAction($label, $text, $actionType, $tmpUrl,
$id, $userRight, $button[
'params']);
12878 if (count($url) > 1) {
12879 $out .=
'<div class="dropdown inline-block dropdown-holder">';
12880 $out .=
'<a style="margin-right: auto;" class="dropdown-toggle classfortooltip butAction'.($userRight ?
'' :
'Refused').
'" title="'.
dol_escape_htmltag($label).
'" data-toggle="dropdown">'.($text ? $text : $label).
'</a>';
12881 $out .=
'<div class="dropdown-content">';
12882 foreach ($url as $subbutton) {
12883 if (!empty($subbutton[
'lang'])) {
12884 $langs->load($subbutton[
'lang']);
12887 if (!empty($subbutton[
'urlraw'])) {
12888 $tmpurl = $subbutton[
'urlraw'];
12890 $tmpurl = !empty($subbutton[
'urlroot']) ? $subbutton[
'urlroot'] : $subbutton[
'url'];
12894 $subbuttonparam = array();
12895 if (!empty($subbutton[
'attr'])) {
12896 $subbuttonparam[
'attr'] = $subbutton[
'attr'];
12898 $subbuttonparam[
'isDropDown'] = (empty($params[
'isDropDown']) ? ($subbutton[
'isDropDown'] ??
false) : $params[
'isDropDown']);
12900 $out .=
dolGetButtonAction(
'', $langs->trans($subbutton[
'label']),
'default', $tmpurl, $subbutton[
'id'] ??
'', $subbutton[
'perm'], $subbuttonparam);
12905 foreach ($url as $subbutton) {
12906 if (!empty($subbutton[
'lang'])) {
12907 $langs->load($subbutton[
'lang']);
12910 if (!empty($subbutton[
'urlraw'])) {
12911 $tmpurl = $subbutton[
'urlraw'];
12913 $tmpurl = !empty($subbutton[
'urlroot']) ? $subbutton[
'urlroot'] : $subbutton[
'url'];
12917 $out .=
dolGetButtonAction(
'', $langs->trans($subbutton[
'label']),
'default', $tmpurl,
'', $subbutton[
'perm'], $params);
12926 if (!empty($params[
'isDropdown']) || !empty($params[
'isDropDown'])) {
12927 $class =
"dropdown-item";
12929 $class =
'butAction';
12930 if ($actionType ==
'danger' || $actionType ==
'delete') {
12931 $class =
'butActionDelete';
12932 if (!empty($url) && strpos($url,
'token=') ===
false) {
12933 $url .=
'&token='.newToken();
12939 'href' => empty($url) ?
'' : $url,
12943 if (empty($text)) {
12945 $attr[
'title'] =
'';
12947 $attr[
'title'] = $label;
12948 $attr[
'aria-label'] = $label;
12951 if (empty($userRight) || $userRight < 0) {
12952 $attr[
'class'] =
'butActionRefused';
12953 $attr[
'href'] =
'';
12954 $attr[
'title'] = (($label && $text && $label != $text) ? $label :
'');
12955 $attr[
'title'] = ($attr[
'title'] ? $attr[
'title'] . (empty($userRight) ?
'<br>' :
'') :
'').(empty($userRight) ? $langs->trans(
'NotEnoughPermissions') :
'');
12963 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
12964 foreach ($params[
'attr'] as $key => $value) {
12965 if ($key ==
'class') {
12966 $attr[
'class'] .=
' '.$value;
12967 } elseif ($key ==
'classOverride') {
12968 $attr[
'class'] = $value;
12970 $attr[$key] = $value;
12976 if (!empty($attr[
'title']) && !empty($attr[
'class']) && strpos($attr[
'class'],
'classfortooltip') ===
false) {
12977 $attr[
'class'] .=
' classfortooltip';
12981 if ($userRight && !empty($params[
'confirm'])) {
12982 if (!is_array($params[
'confirm'])) {
12983 $params[
'confirm'] = array();
12986 if (empty($params[
'confirm'][
'url'])) {
12987 $params[
'confirm'][
'url'] = $url . (strpos($url,
'?') > 0 ?
'&' :
'?') .
'confirm=yes';
12991 $attr[
'data-confirm-url'] = $params[
'confirm'][
'url'];
12992 $attr[
'data-confirm-title'] = !empty($params[
'confirm'][
'title']) ? $params[
'confirm'][
'title'] : $langs->trans(
'ConfirmBtnCommonTitle', $label);
12993 $attr[
'data-confirm-content'] = !empty($params[
'confirm'][
'content']) ? $params[
'confirm'][
'content'] : $langs->trans(
'ConfirmBtnCommonContent', $label);
12994 $attr[
'data-confirm-content'] = preg_replace(
"/\r|\n/",
"", $attr[
'data-confirm-content']);
12995 $attr[
'data-confirm-action-btn-label'] = !empty($params[
'confirm'][
'action-btn-label']) ? $params[
'confirm'][
'action-btn-label'] : $langs->trans(
'Confirm');
12996 $attr[
'data-confirm-cancel-btn-label'] = !empty($params[
'confirm'][
'cancel-btn-label']) ? $params[
'confirm'][
'cancel-btn-label'] : $langs->trans(
'CloseDialog');
12997 $attr[
'data-confirm-modal'] = !empty($params[
'confirm'][
'modal']) ? $params[
'confirm'][
'modal'] :
true;
12999 $attr[
'class'] .=
' butActionConfirm';
13002 if (isset($attr[
'href']) && empty($attr[
'href'])) {
13003 unset($attr[
'href']);
13006 $TCompiledAttr = array();
13007 foreach ($attr as $key => $value) {
13008 if (!empty($params[
'use_unsecured_unescapedattr']) && is_array($params[
'use_unsecured_unescapedattr']) && in_array($key, $params[
'use_unsecured_unescapedattr'])) {
13011 } elseif ($key ==
'href') {
13017 $TCompiledAttr[] = $key.
'="'.$value.
'"';
13020 $compiledAttributes = empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr);
13022 $tag = !empty($attr[
'href']) ?
'a' :
'span';
13025 $parameters = array(
13026 'TCompiledAttr' => $TCompiledAttr,
13027 'compiledAttributes' => $compiledAttributes,
13032 'actionType' => $actionType,
13035 'userRight' => $userRight,
13036 'params' => $params
13039 $reshook = $hookmanager->executeHooks(
'dolGetButtonAction', $parameters,
$object, $action);
13040 if ($reshook < 0) {
13044 if (empty($reshook)) {
13046 return '<' . $tag .
' ' . $compiledAttributes .
'><span class="textbutton">' . $text .
'</span></' . $tag .
'>';
13048 return '<' . $tag .
' ' . $compiledAttributes .
'><span class="textbutton">' .
dol_escape_htmltag($text) .
'</span></' . $tag .
'>';
13051 return $hookmanager->resPrint;
13070 $parsedUrl = parse_url($url);
13071 if ((isset($parsedUrl[
'scheme']) && in_array($parsedUrl[
'scheme'], [
'javascript',
'mailto',
'tel'])) || strpos($url,
'#') === 0) {
13075 if (!empty($parsedUrl[
'query'])) {
13077 parse_str($parsedUrl[
'query'], $urlQuery);
13078 if (!isset($urlQuery[
'backtopage']) && isset($params[
'backtopage'])) {
13079 $url .=
'&backtopage='.urlencode($params[
'backtopage']);
13083 if (!isset($parsedUrl[
'scheme']) && $addDolUrlRoot) {
13084 $url = DOL_URL_ROOT.$url;
13099 return '<span class="button-title-separator '.$moreClass.
'" ></span>';
13111 if (!empty($fieldValidationErrorMsg)) {
13112 $out .=
'<span class="field-error-icon classfortooltip" title="'.dol_escape_htmltag($fieldValidationErrorMsg, 1).
'" role="alert" >';
13113 $out .=
'<span class="fa fa-exclamation-circle" aria-hidden="true" ></span>';
13132function dolGetButtonTitle($label, $helpText =
'', $iconClass =
'fa fa-file', $url =
'',
$id =
'', $status = 1, $params = array())
13134 global $langs, $user;
13137 if (
getDolGlobalString(
'MAIN_BUTTON_HIDE_UNAUTHORIZED') && (!$user->admin) && $status <= 0) {
13141 $class =
'btnTitle';
13142 if (in_array($iconClass, array(
'fa fa-plus-circle',
'fa fa-plus-circle size15x',
'fa fa-comment-dots',
'fa fa-paper-plane'))) {
13143 $class .=
' btnTitlePlus';
13145 $useclassfortooltip = 1;
13147 if (!empty($params[
'morecss'])) {
13148 $class .=
' '.$params[
'morecss'];
13153 'href' => empty($url) ?
'' : $url
13156 if (!empty($helpText)) {
13157 $attr[
'title'] = $helpText;
13158 } elseif ($label) {
13159 $attr[
'title'] = $label;
13160 $useclassfortooltip = 0;
13163 if ($status == 2) {
13164 $attr[
'class'] .=
' btnTitleSelected';
13165 } elseif ($status <= 0) {
13166 $attr[
'class'] .=
' refused';
13168 $attr[
'href'] =
'';
13170 if ($status == -1) {
13171 $attr[
'title'] = $langs->transnoentitiesnoconv(
"FeatureDisabled");
13172 } elseif ($status == 0) {
13173 $attr[
'title'] = $langs->transnoentitiesnoconv(
"NotEnoughPermissions");
13177 if (!empty($attr[
'title']) && $useclassfortooltip) {
13178 $attr[
'class'] .=
' classfortooltip';
13186 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
13187 foreach ($params[
'attr'] as $key => $value) {
13188 if ($key ==
'class') {
13189 $attr[
'class'] .=
' '.$value;
13190 } elseif ($key ==
'classOverride') {
13191 $attr[
'class'] = $value;
13193 $attr[$key] = $value;
13198 if (isset($attr[
'href']) && empty($attr[
'href'])) {
13199 unset($attr[
'href']);
13205 $TCompiledAttr = array();
13206 foreach ($attr as $key => $value) {
13210 $compiledAttributes = (empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr));
13212 $tag = (empty($attr[
'href']) ?
'span' :
'a');
13214 $button =
'<'.$tag.
' '.$compiledAttributes.
'>';
13215 $button .=
'<span class="'.$iconClass.
' valignmiddle btnTitle-icon"></span>';
13216 if (!empty($params[
'forcenohideoftext'])) {
13217 $button .=
'<span class="valignmiddle text-plus-circle btnTitle-label'.(empty($params[
'forcenohideoftext']) ?
' hideonsmartphone' :
'').
'">'.$label.
'</span>';
13219 $button .=
'</'.$tag.
'>';
13235 global
$conf, $db, $hookmanager;
13241 $classfile = $classname = $classpath = $subdir = $dir_output = $dir_temp = $parent_element =
'';
13244 $module = $elementType;
13245 $element = $elementType;
13246 $subelement = $elementType;
13247 $table_element = $elementType;
13250 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $elementType, $regs)) {
13251 $element = $subelement = $regs[1];
13252 $module = $regs[2];
13257 if (preg_match(
'/^([^_]+)_([^_]+)/i', $element, $regs)) {
13258 $module = $element = $regs[1];
13259 $subelement = $regs[2];
13263 if (substr($elementType, -3) ==
'det') {
13264 $module = preg_replace(
'/det$/',
'', $element);
13265 $subelement = preg_replace(
'/det$/',
'', $subelement);
13266 $classpath = $module.
'/class';
13267 $classfile = $module;
13268 $classname = preg_replace(
'/det$/',
'Line', $element);
13269 if (in_array($module, array(
'expedition',
'propale',
'facture',
'contrat',
'fichinter',
'commandefournisseur'))) {
13270 $classname = preg_replace(
'/det$/',
'Ligne', $element);
13274 if ($elementType ==
"action" || $elementType ==
"actioncomm") {
13275 $classpath =
'comm/action/class';
13276 $subelement =
'Actioncomm';
13277 $module =
'agenda';
13278 $table_element =
'actioncomm';
13279 } elseif ($elementType ==
'cronjob') {
13280 $classpath =
'cron/class';
13282 $table_element =
'cron';
13283 } elseif ($elementType ==
'adherent_type') {
13284 $classpath =
'adherents/class';
13285 $classfile =
'adherent_type';
13286 $module =
'adherent';
13287 $subelement =
'adherent_type';
13288 $classname =
'AdherentType';
13289 $table_element =
'adherent_type';
13290 } elseif ($elementType ==
'bank_account') {
13291 $classpath =
'compta/bank/class';
13293 $classfile =
'account';
13294 $classname =
'Account';
13295 } elseif ($elementType ==
'category') {
13296 $classpath =
'categories/class';
13297 $module =
'categorie';
13298 $subelement =
'categorie';
13299 $table_element =
'categorie';
13300 } elseif ($elementType ==
'contact') {
13301 $classpath =
'contact/class';
13302 $classfile =
'contact';
13303 $module =
'societe';
13304 $subelement =
'contact';
13305 $table_element =
'socpeople';
13306 } elseif ($elementType ==
'inventory') {
13307 $module =
'product';
13308 $classpath =
'product/inventory/class';
13309 } elseif ($elementType ==
'inventoryline') {
13310 $module =
'product';
13311 $classpath =
'product/inventory/class';
13312 $table_element =
'inventorydet';
13313 $parent_element =
'inventory';
13314 } elseif ($elementType ==
'stock' || $elementType ==
'entrepot') {
13316 $classpath =
'product/stock/class';
13317 $classfile =
'entrepot';
13318 $classname =
'Entrepot';
13319 $table_element =
'entrepot';
13320 } elseif ($elementType ==
'project') {
13321 $classpath =
'projet/class';
13322 $module =
'projet';
13323 $table_element =
'projet';
13324 } elseif ($elementType ==
'project_task') {
13325 $classpath =
'projet/class';
13326 $module =
'projet';
13327 $subelement =
'task';
13328 $table_element =
'projet_task';
13329 } elseif ($elementType ==
'facture' || $elementType ==
'invoice') {
13330 $classpath =
'compta/facture/class';
13331 $module =
'facture';
13332 $subelement =
'facture';
13333 $table_element =
'facture';
13334 } elseif ($elementType ==
'facturedet') {
13335 $classpath =
'compta/facture/class';
13336 $classfile =
'facture';
13337 $classname =
'FactureLigne';
13338 $module =
'facture';
13339 $table_element =
'facturedet';
13340 $parent_element =
'facture';
13341 } elseif ($elementType ==
'facturerec') {
13342 $classpath =
'compta/facture/class';
13343 $classfile =
'facture-rec';
13344 $module =
'facture';
13345 $classname =
'FactureRec';
13346 } elseif ($elementType ==
'commande' || $elementType ==
'order') {
13347 $classpath =
'commande/class';
13348 $module =
'commande';
13349 $subelement =
'commande';
13350 $table_element =
'commande';
13351 } elseif ($elementType ==
'commandedet') {
13352 $classpath =
'commande/class';
13353 $classfile =
'commande';
13354 $classname =
'OrderLine';
13355 $module =
'commande';
13356 $table_element =
'commandedet';
13357 $parent_element =
'commande';
13358 } elseif ($elementType ==
'propal') {
13359 $classpath =
'comm/propal/class';
13360 $table_element =
'propal';
13361 } elseif ($elementType ==
'propaldet') {
13362 $classpath =
'comm/propal/class';
13363 $classfile =
'propal';
13364 $subelement =
'propaleligne';
13365 $module =
'propal';
13366 $table_element =
'propaldet';
13367 $parent_element =
'propal';
13368 } elseif ($elementType ==
'shipping') {
13369 $classpath =
'expedition/class';
13370 $classfile =
'expedition';
13371 $classname =
'Expedition';
13372 $module =
'expedition';
13373 $table_element =
'expedition';
13374 } elseif ($elementType ==
'expeditiondet' || $elementType ==
'shippingdet') {
13375 $classpath =
'expedition/class';
13376 $classfile =
'expedition';
13377 $classname =
'ExpeditionLigne';
13378 $module =
'expedition';
13379 $table_element =
'expeditiondet';
13380 $parent_element =
'expedition';
13381 } elseif ($elementType ==
'delivery_note') {
13382 $classpath =
'delivery/class';
13383 $subelement =
'delivery';
13384 $module =
'expedition';
13385 } elseif ($elementType ==
'delivery') {
13386 $classpath =
'delivery/class';
13387 $subelement =
'delivery';
13388 $module =
'expedition';
13389 } elseif ($elementType ==
'deliverydet') {
13391 } elseif ($elementType ==
'supplier_proposal') {
13392 $classpath =
'supplier_proposal/class';
13393 $module =
'supplier_proposal';
13394 $element =
'supplierproposal';
13395 $classfile =
'supplier_proposal';
13396 $subelement =
'supplierproposal';
13397 } elseif ($elementType ==
'supplier_proposaldet') {
13398 $classpath =
'supplier_proposal/class';
13399 $module =
'supplier_proposal';
13400 $classfile =
'supplier_proposal';
13401 $table_element =
'supplier_proposaldet';
13402 $parent_element =
'supplier_proposal';
13403 } elseif ($elementType ==
'contract') {
13404 $classpath =
'contrat/class';
13405 $module =
'contrat';
13406 $subelement =
'contrat';
13407 $table_element =
'contract';
13408 } elseif ($elementType ==
'contratdet') {
13409 $classpath =
'contrat/class';
13410 $module =
'contrat';
13411 $table_element =
'contratdet';
13412 $parent_element =
'contrat';
13413 } elseif ($elementType ==
'mailing') {
13414 $classpath =
'comm/mailing/class';
13415 $module =
'mailing';
13416 $classfile =
'mailing';
13417 $classname =
'Mailing';
13419 } elseif ($elementType ==
'member' || $elementType ==
'adherent') {
13420 $classpath =
'adherents/class';
13421 $module =
'adherent';
13422 $subelement =
'adherent';
13423 $table_element =
'adherent';
13424 } elseif ($elementType ==
'usergroup') {
13425 $classpath =
'user/class';
13427 } elseif ($elementType ==
'mo') {
13428 $classpath =
'mrp/class';
13433 $table_element =
'mrp_mo';
13434 } elseif ($elementType ==
'mrp_production') {
13435 $classpath =
'mrp/class';
13437 $classname =
'MoLine';
13440 $table_element =
'mrp_production';
13441 $parent_element =
'mo';
13442 } elseif ($elementType ==
'cabinetmed_cons') {
13443 $classpath =
'cabinetmed/class';
13444 $module =
'cabinetmed';
13445 $subelement =
'cabinetmedcons';
13446 $table_element =
'cabinetmedcons';
13447 } elseif ($elementType ==
'fichinter') {
13448 $classpath =
'fichinter/class';
13449 $module =
'ficheinter';
13450 $subelement =
'fichinter';
13451 $table_element =
'fichinter';
13452 } elseif ($elementType ==
'dolresource' || $elementType ==
'resource') {
13453 $classpath =
'resource/class';
13454 $module =
'resource';
13455 $subelement =
'dolresource';
13456 $table_element =
'resource';
13457 } elseif ($elementType ==
'opensurvey_sondage') {
13458 $classpath =
'opensurvey/class';
13459 $module =
'opensurvey';
13460 $subelement =
'opensurveysondage';
13461 } elseif ($elementType ==
'order_supplier' || $elementType ==
'commande_fournisseur') {
13462 $classpath =
'fourn/class';
13463 $module =
'fournisseur';
13464 $classfile =
'fournisseur.commande';
13465 $element =
'order_supplier';
13467 $classname =
'CommandeFournisseur';
13468 $table_element =
'commande_fournisseur';
13469 } elseif ($elementType ==
'commande_fournisseurdet') {
13470 $classpath =
'fourn/class';
13471 $module =
'fournisseur';
13472 $classfile =
'fournisseur.commande';
13473 $element =
'commande_fournisseurdet';
13475 $classname =
'CommandeFournisseurLigne';
13476 $table_element =
'commande_fournisseurdet';
13477 $parent_element =
'commande_fournisseur';
13478 } elseif ($elementType ==
'invoice_supplier') {
13479 $classpath =
'fourn/class';
13480 $module =
'fournisseur';
13481 $classfile =
'fournisseur.facture';
13482 $element =
'invoice_supplier';
13484 $classname =
'FactureFournisseur';
13485 $table_element =
'facture_fourn';
13486 } elseif ($elementType ==
'facture_fourn_det') {
13487 $classpath =
'fourn/class';
13488 $module =
'fournisseur';
13489 $classfile =
'fournisseur.facture';
13490 $element =
'facture_fourn_det';
13492 $classname =
'SupplierInvoiceLine';
13493 $table_element =
'facture_fourn_det';
13494 $parent_element =
'invoice_supplier';
13495 } elseif ($elementType ==
"service") {
13496 $classpath =
'product/class';
13497 $subelement =
'product';
13498 $table_element =
'product';
13499 } elseif ($elementType ==
'salary') {
13500 $classpath =
'salaries/class';
13501 $module =
'salaries';
13502 } elseif ($elementType ==
'payment_salary') {
13503 $classpath =
'salaries/class';
13504 $classfile =
'paymentsalary';
13505 $classname =
'PaymentSalary';
13506 $module =
'salaries';
13507 } elseif ($elementType ==
'productlot') {
13508 $module =
'productbatch';
13509 $classpath =
'product/stock/class';
13510 $classfile =
'productlot';
13511 $classname =
'Productlot';
13512 $element =
'productlot';
13514 $table_element =
'product_lot';
13515 } elseif ($elementType ==
'societeaccount') {
13516 $classpath =
'societe/class';
13517 $classfile =
'societeaccount';
13518 $classname =
'SocieteAccount';
13519 $module =
'societe';
13520 } elseif ($elementType ==
'websitepage') {
13521 $classpath =
'website/class';
13522 $classfile =
'websitepage';
13523 $classname =
'Websitepage';
13524 $module =
'website';
13525 $subelement =
'websitepage';
13526 $table_element =
'website_page';
13527 } elseif ($elementType ==
'fiscalyear') {
13528 $classpath =
'core/class';
13529 $module =
'accounting';
13530 $subelement =
'fiscalyear';
13531 } elseif ($elementType ==
'chargesociales') {
13532 $classpath =
'compta/sociales/class';
13534 $table_element =
'chargesociales';
13535 } elseif ($elementType ==
'tva') {
13536 $classpath =
'compta/tva/class';
13539 $table_element =
'tva';
13540 } elseif ($elementType ==
'emailsenderprofile') {
13542 $classpath =
'core/class';
13543 $classfile =
'emailsenderprofile';
13544 $classname =
'EmailSenderProfile';
13545 $table_element =
'c_email_senderprofile';
13547 } elseif ($elementType ==
'conferenceorboothattendee') {
13548 $classpath =
'eventorganization/class';
13549 $classfile =
'conferenceorboothattendee';
13550 $classname =
'ConferenceOrBoothAttendee';
13551 $module =
'eventorganization';
13552 } elseif ($elementType ==
'conferenceorbooth') {
13553 $classpath =
'eventorganization/class';
13554 $classfile =
'conferenceorbooth';
13555 $classname =
'ConferenceOrBooth';
13556 $module =
'eventorganization';
13557 } elseif ($elementType ==
'ccountry') {
13559 $classpath =
'core/class';
13560 $classfile =
'ccountry';
13561 $classname =
'Ccountry';
13562 $table_element =
'c_country';
13564 } elseif ($elementType ==
'ecmfiles') {
13566 $classpath =
'ecm/class';
13567 $classfile =
'ecmfiles';
13568 $classname =
'Ecmfiles';
13569 $table_element =
'ecmfiles';
13571 } elseif ($elementType ==
'knowledgerecord') {
13573 $classpath =
'knowledgemanagement/class';
13574 $classfile =
'knowledgerecord';
13575 $classname =
'KnowledgeRecord';
13576 $table_element =
'knowledgemanagement_knowledgerecord';
13580 if (empty($classfile)) {
13581 $classfile = strtolower($subelement);
13583 if (empty($classname)) {
13584 $classname = ucfirst($subelement);
13586 if (empty($classpath)) {
13587 $classpath = $module.
'/class';
13593 if ($module && isset(
$conf->$module)) {
13594 if (!empty(
$conf->$module->multidir_output[
$conf->entity])) {
13595 $dir_output =
$conf->$module->multidir_output[
$conf->entity];
13596 } elseif (!empty(
$conf->$module->output[
$conf->entity])) {
13597 $dir_output =
$conf->$module->output[
$conf->entity];
13598 } elseif (!empty(
$conf->$module->dir_output)) {
13599 $dir_output =
$conf->$module->dir_output;
13601 if (!empty(
$conf->$module->multidir_temp[
$conf->entity])) {
13602 $dir_temp =
$conf->$module->multidir_temp[
$conf->entity];
13603 } elseif (!empty(
$conf->$module->temp[
$conf->entity])) {
13604 $dir_temp =
$conf->$module->temp[
$conf->entity];
13605 } elseif (!empty(
$conf->$module->dir_temp)) {
13606 $dir_temp =
$conf->$module->dir_temp;
13611 if ($element ==
'order_supplier') {
13612 $dir_output =
$conf->fournisseur->commande->dir_output;
13613 $dir_temp =
$conf->fournisseur->commande->dir_temp;
13614 } elseif ($element ==
'invoice_supplier') {
13615 $dir_output =
$conf->fournisseur->facture->dir_output;
13616 $dir_temp =
$conf->fournisseur->facture->dir_temp;
13618 $dir_output .= $subdir;
13619 $dir_temp .= $subdir;
13621 $elementProperties = array(
13622 'module' => $module,
13623 'element' => $element,
13624 'table_element' => $table_element,
13625 'subelement' => $subelement,
13626 'classpath' => $classpath,
13627 'classfile' => $classfile,
13628 'classname' => $classname,
13629 'dir_output' => $dir_output,
13630 'dir_temp' => $dir_temp,
13631 'parent_element' => $parent_element,
13636 if (!is_object($hookmanager)) {
13637 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
13640 $hookmanager->initHooks(array(
'elementproperties'));
13644 $parameters = array(
13645 'elementType' => $elementType,
13646 'elementProperties' => $elementProperties
13649 $reshook = $hookmanager->executeHooks(
'getElementProperties', $parameters);
13652 $elementProperties = $hookmanager->resArray;
13653 } elseif (!empty($hookmanager->resArray) && is_array($hookmanager->resArray)) {
13654 $elementProperties = array_replace($elementProperties, $hookmanager->resArray);
13658 if (($key = array_search(
'elementproperties', $hookmanager->contextarray)) !==
false) {
13659 unset($hookmanager->contextarray[$key]);
13662 return $elementProperties;
13677function fetchObjectByElement($element_id, $element_type, $element_ref =
'', $useCache = 0, $maxCacheByType = 10)
13685 if ($element_prop[
'module'] ==
'product' || $element_prop[
'module'] ==
'service') {
13690 $ismodenabled = (isModEnabled(
'product') || isModEnabled(
'service'));
13691 } elseif ($element_prop[
'module'] ==
'societeaccount') {
13692 $ismodenabled = isModEnabled(
'website') || isModEnabled(
'webportal');
13694 $ismodenabled = isModEnabled($element_prop[
'module']);
13699 if (is_array($element_prop) && (empty($element_prop[
'module']) || $ismodenabled)) {
13700 if ($useCache === 1
13701 && !empty(
$conf->cache[
'fetchObjectByElement'][$element_type])
13702 && !empty(
$conf->cache[
'fetchObjectByElement'][$element_type][$element_id])
13703 && is_object(
$conf->cache[
'fetchObjectByElement'][$element_type][$element_id])
13705 return $conf->cache[
'fetchObjectByElement'][$element_type][$element_id];
13708 dol_include_once(
'/'.$element_prop[
'classpath'].
'/'.$element_prop[
'classfile'].
'.class.php');
13710 if (class_exists($element_prop[
'classname'])) {
13711 $className = $element_prop[
'classname'];
13712 $objecttmp =
new $className($db);
13713 '@phan-var-force CommonObject $objecttmp';
13715 if ($element_id > 0 || !empty($element_ref)) {
13716 $ret = $objecttmp->fetch($element_id, $element_ref);
13718 if (empty($objecttmp->module)) {
13719 $objecttmp->module = $element_prop[
'module'];
13722 if ($useCache > 0) {
13723 if (!isset(
$conf->cache[
'fetchObjectByElement'][$element_type])) {
13724 $conf->cache[
'fetchObjectByElement'][$element_type] = [];
13728 if (! empty(
$conf->cache[
'fetchObjectByElement'][$element_type]) && is_array(
$conf->cache[
'fetchObjectByElement'][$element_type]) && count(
$conf->cache[
'fetchObjectByElement'][$element_type]) >= $maxCacheByType) {
13729 array_shift(
$conf->cache[
'fetchObjectByElement'][$element_type]);
13732 $conf->cache[
'fetchObjectByElement'][$element_type][$element_id] = $objecttmp;
13741 dol_syslog($element_prop[
'classname'].
' doesn\'t exists in /'.$element_prop[
'classpath'].
'/'.$element_prop[
'classfile'].
'.class.php');
13757 if (preg_match(
'/\.(htm|html|js|phar|php|php\d+|phtml|pht|pl|py|cgi|ksh|sh|shtml|bash|bat|cmd|wpk|exe|dmg)$/i', $filename)) {
13773 return empty($_SESSION[
'newtoken']) ?
'' : $_SESSION[
'newtoken'];
13785 return isset($_SESSION[
'token']) ? $_SESSION[
'token'] :
'';
13797 if (empty(
$conf->cache[
'nonce'])) {
13801 return $conf->cache[
'nonce'];
13818function startSimpleTable($header, $link =
"", $arguments =
"", $emptyColumns = 0, $number = -1, $pictofulllist =
'')
13822 print
'<div class="div-table-responsive-no-min">';
13823 print
'<table class="noborder centpercent">';
13824 print
'<tr class="liste_titre">';
13826 print ($emptyColumns < 1) ?
'<th>' :
'<th colspan="'.($emptyColumns + 1).
'">';
13828 print
'<span class="valignmiddle">'.$langs->trans($header).
'</span>';
13830 if (!empty($link)) {
13831 if (!empty($arguments)) {
13832 print
'<a href="'.DOL_URL_ROOT.
'/'.$link.
'?'.$arguments.
'">';
13834 print
'<a href="'.DOL_URL_ROOT.
'/'.$link.
'">';
13838 if ($number > -1) {
13839 print
'<span class="badge marginleftonlyshort">'.$number.
'</span>';
13840 } elseif (!empty($link)) {
13841 print
'<span class="badge marginleftonlyshort">...</span>';
13844 if (!empty($link)) {
13850 if ($number < 0 && !empty($link)) {
13851 print
'<th class="right">';
13871 if ($addLineBreak) {
13887function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord =
"None", $extraRightColumn =
false)
13892 print
'<tr class="oddeven">';
13893 print
'<td colspan="'.$tableColumnCount.
'"><span class="opacitymedium">'.$langs->trans($noneWord).
'</span></td>';
13898 if ($nbofloop === 0) {
13908 if ($num > $nbofloop) {
13909 $colspan = $tableColumnCount;
13911 $colspan = $tableColumnCount - 1;
13914 if ($extraRightColumn) {
13918 print
'<tr class="liste_total">';
13920 if ($nbofloop > 0 && $num > $nbofloop) {
13921 print
'<td colspan="'.$colspan.
'" class="right">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
'</td>';
13923 print
'<td colspan="'.$colspan.
'" class="right"> '.$langs->trans(
"Total").
'</td>';
13924 print
'<td class="right centpercent">'.price($total).
'</td>';
13927 if ($extraRightColumn) {
13944 if ($method == -1) {
13955 while (ob_get_level()) {
13960 if ($method == 0) {
13961 readfile($fullpath_original_file_osencoded);
13962 } elseif ($method == 1) {
13964 $handle = fopen($fullpath_original_file_osencoded,
"rb");
13965 while (!feof($handle)) {
13966 print fread($handle, 8192);
13969 } elseif ($method == 2) {
13971 $handle1 = fopen($fullpath_original_file_osencoded,
"rb");
13972 $handle2 = fopen(
"php://output",
"wb");
13973 stream_copy_to_stream($handle1, $handle2);
13994 $result =
'<span class="clipboardCP'.($showonlyonhover ?
' clipboardCPShowOnHover' :
'').
'">';
13995 if ($texttoshow ===
'none') {
13996 $result .=
'<'.$tag.
' class="clipboardCPValue hidewithsize">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'>';
13997 $result .=
'<span class="clipboardCPValueToPrint"></span>';
13998 } elseif ($texttoshow) {
13999 $result .=
'<'.$tag.
' class="clipboardCPValue hidewithsize">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'>';
14000 $result .=
'<span class="clipboardCPValueToPrint">'.dol_escape_htmltag($texttoshow, 1, 1).
'</span>';
14002 $result .=
'<'.$tag.
' class="clipboardCPValue">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'>';
14004 $result .=
'<span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft pictomodule" title="'.dolPrintHTML($langs->trans(
"ClickToCopyToClipboard")).
'"></span>';
14005 $result .=
img_picto(
'',
'tick',
'class="clipboardCPTick hidden paddingleft pictomodule"');
14006 $result .=
'<span class="clipboardCPText"></span>';
14007 $result .=
'</span>';
14021 $result = json_decode($stringtodecode);
14022 if ($result ===
null) {
14023 $result = unserialize($stringtodecode);
14050 if (is_null($filter) || !is_string($filter) || $filter ===
'') {
14053 if (!preg_match(
'/^\(.*\)$/', $filter)) {
14054 $filter =
'(' . $filter .
')';
14057 $regexstring =
'\(([a-zA-Z0-9_\.]+:[<>!=insotlke]+:[^\(\)]+)\)';
14058 $firstandlastparenthesis = 0;
14060 if (!
dolCheckFilters($filter, $errorstr, $firstandlastparenthesis)) {
14064 return 'Filter syntax error - '.$errorstr;
14069 $t = preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeDummyCriteriaCallback', $filter);
14070 $t = str_ireplace(array(
'and',
'or',
' '),
'', $t);
14073 if (preg_match(
'/[^\(\)]/', $t)) {
14074 $tmperrorstr =
'Bad syntax of the search string';
14075 $errorstr =
'Bad syntax of the search string: '.$filter;
14079 dol_syslog(
"forgeSQLFromUniversalSearchCriteria Filter error - ".$errorstr, LOG_WARNING);
14080 return 'Filter error - '.$tmperrorstr;
14084 $ret = ($noand ?
"" :
" AND ").($nopar ?
"" :
'(').preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeSQLCriteriaCallback', $filter).($nopar ?
"" :
')');
14086 if (is_object($db)) {
14087 $ret = str_replace(
'__NOW__',
"'".$db->idate(
dol_now()).
"'", $ret);
14089 if (is_object($user)) {
14090 $ret = str_replace(
'__USER_ID__', (
string) $user->id, $ret);
14105 $arrayofandtags = array();
14109 $parenthesislevel = 0;
14114 if ($parenthesislevel >= 1) {
14115 $sqlfilters = preg_replace(
'/^\(/',
'', preg_replace(
'/\)$/',
'', $sqlfilters));
14120 $countparenthesis = 0;
14121 while ($i < $nbofchars) {
14124 if ($char ==
'(') {
14125 $countparenthesis++;
14126 } elseif ($char ==
')') {
14127 $countparenthesis--;
14130 if ($countparenthesis == 0) {
14131 $char2 =
dol_substr($sqlfilters, $i + 1, 1);
14132 $char3 =
dol_substr($sqlfilters, $i + 2, 1);
14133 if ($char ==
'A' && $char2 ==
'N' && $char3 ==
'D') {
14136 if (!preg_match(
'/^\(.*\)$/', $s)) {
14139 $arrayofandtags[] = $s;
14152 if (!preg_match(
'/^\(.*\)$/', $s)) {
14155 $arrayofandtags[] = $s;
14158 return $arrayofandtags;
14170function dolCheckFilters($sqlfilters, &$error =
'', &$parenthesislevel = 0)
14174 $tmp = $sqlfilters;
14178 $parenthesislevel = 0;
14186 if ($char ==
'(') {
14187 if ($i == $parenthesislevel && $parenthesislevel == $counter) {
14189 $parenthesislevel++;
14192 } elseif ($char ==
')') {
14193 $nbcharremaining = ($nb - $i - 1);
14194 if ($nbcharremaining >= $counter) {
14195 $parenthesislevel = min($parenthesislevel, $counter - 1);
14197 if ($parenthesislevel > $counter && $nbcharremaining >= $counter) {
14198 $parenthesislevel = $counter;
14203 if ($counter < 0) {
14204 $error =
"Wrong balance of parenthesis in sqlfilters=".$sqlfilters;
14205 $parenthesislevel = 0;
14213 if ($counter > 0) {
14214 $error =
"Wrong balance of parenthesis in sqlfilters=".$sqlfilters;
14215 $parenthesislevel = 0;
14233 if (empty($matches[1])) {
14236 $tmp = explode(
':', $matches[1]);
14237 if (count($tmp) < 3) {
14257 if (empty($matches[1])) {
14260 $tmp = explode(
':', $matches[1], 3);
14261 if (count($tmp) < 3) {
14265 $operand = preg_replace(
'/[^a-z0-9\._]/i',
'', trim($tmp[0]));
14267 $operator = strtoupper(preg_replace(
'/[^a-z<>!=]/i',
'', trim($tmp[1])));
14270 'NOTLIKE' =>
'NOT LIKE',
14271 'ISNOT' =>
'IS NOT',
14272 'NOTIN' =>
'NOT IN',
14276 if (array_key_exists($operator, $realOperator)) {
14277 $operator = $realOperator[$operator];
14280 $tmpescaped = $tmp[2];
14286 if ($operator ==
'IN' || $operator ==
'NOT IN') {
14288 $tmpescaped2 =
'(';
14290 $tmpelemarray = explode(
',', $tmpescaped);
14291 foreach ($tmpelemarray as $tmpkey => $tmpelem) {
14293 $tmpelem = trim($tmpelem);
14294 if (preg_match(
'/^\'(.*)\'$/', $tmpelem, $reg)) {
14295 $tmpelemarray[$tmpkey] =
"'".$db->escape($db->sanitize($reg[1], 2, 1, 1, 1)).
"'";
14299 $tmpelemarray[$tmpkey] = $db->escape($db->sanitize($tmpelem, 1, 1, 1, 1));
14302 $tmpescaped2 .= implode(
',', $tmpelemarray);
14303 $tmpescaped2 .=
')';
14305 $tmpescaped = $tmpescaped2;
14306 } elseif ($operator ==
'LIKE' || $operator ==
'NOT LIKE') {
14307 if (preg_match(
'/^\'([^\']*)\'$/', $tmpescaped, $regbis)) {
14308 $tmpescaped = $regbis[1];
14311 $tmpescaped =
"'".$db->escape($tmpescaped).
"'";
14312 } elseif (preg_match(
'/^\'(.*)\'$/', $tmpescaped, $regbis)) {
14315 $tmpescaped =
"'".$db->escape($regbis[1]).
"'";
14317 if (strtoupper($tmpescaped) ==
'NULL') {
14318 $tmpescaped =
'NULL';
14319 } elseif (ctype_digit((
string) $tmpescaped)) {
14320 $tmpescaped = (int) $tmpescaped;
14321 } elseif (is_numeric((
string) $tmpescaped)) {
14322 $tmpescaped = (float) $tmpescaped;
14324 $tmpescaped = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpescaped);
14328 return '('.$db->escape($operand).
' '.strtoupper($operator).
' '.$tmpescaped.
')';
14345 $out =
'<!-- timeline icon -->'.
"\n";
14346 $iconClass =
'fa fa-comments';
14351 if ($histo[$key][
'percent'] == -1) {
14352 $colorClass =
'timeline-icon-not-applicble';
14353 $pictoTitle = $langs->trans(
'StatusNotApplicable');
14354 } elseif ($histo[$key][
'percent'] == 0) {
14355 $colorClass =
'timeline-icon-todo';
14356 $pictoTitle = $langs->trans(
'StatusActionToDo').
' (0%)';
14357 } elseif ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100) {
14358 $colorClass =
'timeline-icon-in-progress';
14359 $pictoTitle = $langs->trans(
'StatusActionInProcess').
' ('.$histo[$key][
'percent'].
'%)';
14360 } elseif ($histo[$key][
'percent'] >= 100) {
14361 $colorClass =
'timeline-icon-done';
14362 $pictoTitle = $langs->trans(
'StatusActionDone').
' (100%)';
14365 if ($actionstatic->code ==
'AC_TICKET_CREATE') {
14366 $iconClass =
'fa fa-ticket';
14367 } elseif ($actionstatic->code ==
'AC_TICKET_MODIFY') {
14368 $iconClass =
'fa fa-pencilxxx';
14369 } elseif (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
14370 $iconClass =
'fa fa-comments';
14371 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
14372 $iconClass =
'fa fa-mask';
14374 if ($actionstatic->type_picto) {
14375 $img_picto =
img_picto(
'', $actionstatic->type_picto);
14377 if ($actionstatic->type_code ==
'AC_RDV') {
14378 $iconClass =
'fa fa-handshake';
14379 } elseif ($actionstatic->type_code ==
'AC_TEL') {
14380 $iconClass =
'fa fa-phone';
14381 } elseif ($actionstatic->type_code ==
'AC_FAX') {
14382 $iconClass =
'fa fa-fax';
14383 } elseif ($actionstatic->type_code ==
'AC_EMAIL') {
14384 $iconClass =
'fa fa-envelope';
14385 } elseif ($actionstatic->type_code ==
'AC_INT') {
14386 $iconClass =
'fa fa-shipping-fast';
14387 } elseif ($actionstatic->type_code ==
'AC_OTH_AUTO') {
14388 $iconClass =
'fa fa-robot';
14389 } elseif (!preg_match(
'/_AUTO/', $actionstatic->type_code)) {
14390 $iconClass =
'fa fa-robot';
14395 $out .=
'<i class="'.$iconClass.
' '.$colorClass.
'" title="'.$pictoTitle.
'">'.$img_picto.
'</i>'.
"\n";
14409 $documents = array();
14411 $sql =
'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.filepath, ecm.filename';
14412 $sql .=
' FROM '.MAIN_DB_PREFIX.
'ecm_files ecm';
14413 $sql .=
" WHERE ecm.filepath = 'agenda/".((int)
$object->id).
"'";
14415 $sql .=
' ORDER BY ecm.position ASC';
14417 $resql = $db->query($sql);
14419 if ($db->num_rows($resql)) {
14420 while ($obj = $db->fetch_object($resql)) {
14421 $documents[$obj->id] = $obj;
14447function show_actions_messaging(
$conf, $langs, $db, $filterobj, $objcon =
null, $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC')
14449 global $user,
$conf;
14452 global $param, $massactionbutton;
14454 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
14457 if (!is_object($filterobj) && !is_object($objcon)) {
14462 '@phan-var-force array<int,array{type:string,tododone:string,id:string,datestart:int|string,dateend:int|string,note:string,message:string,percent:string,userid:string,login:string,userfirstname:string,userlastname:string,userphoto:string,msg_from?:string,contact_id?:string,socpeopleassigned?:int[],lastname?:string,firstname?:string,fk_element?:int,elementtype?:string,acode:string,alabel?:string,libelle?:string,apicto?:string}> $histo';
14467 $sortfield_list = explode(
',', $sortfield);
14468 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
14469 $sortfield_new_list = array();
14470 foreach ($sortfield_list as $sortfield_value) {
14471 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
14473 $sortfield_new = implode(
',', $sortfield_new_list);
14478 if (isModEnabled(
'agenda')) {
14480 if (is_object($objcon) && $objcon->id > 0) {
14481 $sql =
"SELECT DISTINCT a.id, a.label as label,";
14483 $sql =
"SELECT a.id, a.label as label,";
14485 $sql .=
" a.datep as dp,";
14486 $sql .=
" a.note as message,";
14487 $sql .=
" a.datep2 as dp2,";
14488 $sql .=
" a.percent as percent, 'action' as type,";
14489 $sql .=
" a.fk_element, a.elementtype,";
14490 $sql .=
" a.fk_contact,";
14491 $sql .=
" a.email_from as msg_from,";
14492 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
14493 $sql .=
" u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
14494 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
14495 $sql .=
", sp.lastname, sp.firstname";
14496 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
14497 $sql .=
", m.lastname, m.firstname";
14498 } elseif (is_object($filterobj) && in_array(get_class($filterobj), array(
'Commande',
'CommandeFournisseur',
'Product',
'Ticket',
'BOM',
'Contrat',
'Facture',
'FactureFournisseur'))) {
14501 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
14502 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
14503 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
14505 $force_filter_contact = $filterobj instanceof
User;
14507 if (is_object($objcon) && $objcon->id > 0) {
14508 $force_filter_contact =
true;
14509 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as r ON a.id = r.fk_actioncomm";
14510 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id);
14513 if ((is_object($filterobj) && get_class($filterobj) ==
'Societe') || (is_object($filterobj) && get_class($filterobj) ==
'Contact')) {
14514 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
14515 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
14516 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
14517 $sql .=
" ON er.resource_type = 'dolresource'";
14518 $sql .=
" AND er.element_id = a.id";
14519 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
14520 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
14521 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
14522 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
14523 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
14524 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
14525 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
14526 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
14527 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
14528 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
14529 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
14530 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
14531 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
14532 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Facture') {
14533 $sql .=
", ".MAIN_DB_PREFIX.
"facture as o";
14534 } elseif (is_object($filterobj) && get_class($filterobj) ==
'FactureFournisseur') {
14535 $sql .=
", ".MAIN_DB_PREFIX.
"facture_fourn as o";
14538 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
14539 if (!$force_filter_contact) {
14540 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
14541 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
14542 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
14543 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
14544 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
14545 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
14546 if ($filterobj->id) {
14547 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
14549 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Commande') {
14550 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order'";
14551 if ($filterobj->id) {
14552 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
14554 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
14555 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
14556 if ($filterobj->id) {
14557 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
14559 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
14560 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
14561 if ($filterobj->id) {
14562 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
14564 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
14565 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
14566 if ($filterobj->id) {
14567 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
14569 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
14570 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
14571 if ($filterobj->id) {
14572 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
14574 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
14575 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
14576 if ($filterobj->id) {
14577 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
14579 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contact' && $filterobj->id) {
14580 $sql .=
" AND a.fk_contact = sp.rowid";
14581 if ($filterobj->id) {
14582 $sql .=
" AND a.fk_contact = ".((int) $filterobj->id);
14584 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Facture') {
14585 $sql .=
" AND a.fk_element = o.rowid";
14586 if ($filterobj->id) {
14587 $sql .=
" AND a.fk_element = ".((int) $filterobj->id).
" AND a.elementtype = 'invoice'";
14589 } elseif (is_object($filterobj) && get_class($filterobj) ==
'FactureFournisseur') {
14590 $sql .=
" AND a.fk_element = o.rowid";
14591 if ($filterobj->id) {
14592 $sql .=
" AND a.fk_element = ".((int) $filterobj->id).
" AND a.elementtype = 'invoice_supplier'";
14596 $sql .=
" AND u.rowid = ". ((int) $filterobj->id);
14600 if (!empty($actioncode) && $actioncode !=
'-1') {
14602 if ($actioncode ==
'AC_NON_AUTO') {
14603 $sql .=
" AND c.type != 'systemauto'";
14604 } elseif ($actioncode ==
'AC_ALL_AUTO') {
14605 $sql .=
" AND c.type = 'systemauto'";
14607 if ($actioncode ==
'AC_OTH') {
14608 $sql .=
" AND c.type != 'systemauto'";
14609 } elseif ($actioncode ==
'AC_OTH_AUTO') {
14610 $sql .=
" AND c.type = 'systemauto'";
14614 if ($actioncode ==
'AC_NON_AUTO') {
14615 $sql .=
" AND c.type != 'systemauto'";
14616 } elseif ($actioncode ==
'AC_ALL_AUTO') {
14617 $sql .=
" AND c.type = 'systemauto'";
14619 $sql .=
" AND c.code = '".$db->escape($actioncode).
"'";
14623 if ($donetodo ==
'todo') {
14624 $sql .=
" AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now).
"'))";
14625 } elseif ($donetodo ==
'done') {
14626 $sql .=
" AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now).
"'))";
14628 if (is_array($filters) && $filters[
'search_agenda_label']) {
14629 $sql .=
natural_search(
'a.label', $filters[
'search_agenda_label']);
14634 if (isModEnabled(
'mailing') && !empty($objcon->email)
14635 && (empty($actioncode) || $actioncode ==
'AC_OTH_AUTO' || $actioncode ==
'AC_EMAILING')) {
14636 $langs->load(
"mails");
14638 $sql2 =
"SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type";
14639 $sql2 .=
", null as fk_element, '' as elementtype, null as contact_id";
14640 $sql2 .=
", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
14641 $sql2 .=
", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
14642 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
14643 $sql2 .=
", '' as lastname, '' as firstname";
14644 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
14645 $sql2 .=
", '' as lastname, '' as firstname";
14646 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
14647 $sql2 .=
", '' as ref";
14648 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
14649 $sql2 .=
", '' as ref";
14650 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
14651 $sql2 .=
", '' as ref";
14653 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"user as u";
14654 $sql2 .=
" WHERE mc.email = '".$db->escape($objcon->email).
"'";
14655 $sql2 .=
" AND mc.statut = 1";
14656 $sql2 .=
" AND u.rowid = m.fk_user_valid";
14657 $sql2 .=
" AND mc.fk_mailing=m.rowid";
14660 if ($sql || $sql2) {
14661 if (!empty($sql) && !empty($sql2)) {
14662 $sql = $sql.
" UNION ".$sql2;
14663 } elseif (empty($sql) && !empty($sql2)) {
14672 $sql .= $db->order($sortfield_new, $sortorder);
14674 $sql .= $db->plimit($limit + 1, $offset);
14677 dol_syslog(
"function.lib::show_actions_messaging", LOG_DEBUG);
14678 $resql = $db->query($sql);
14681 $num = $db->num_rows($resql);
14683 $imaxinloop = ($limit ? min($num, $limit) : $num);
14684 while ($i < $imaxinloop) {
14685 $obj = $db->fetch_object($resql);
14687 if ($obj->type ==
'action') {
14689 $contactaction->id = $obj->id;
14690 $result = $contactaction->fetchResources();
14693 setEventMessage(
"actions.lib::show_actions_messaging Error fetch resource",
'errors');
14699 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->dp > $now)) {
14700 $tododone =
'todo';
14703 $histo[$numaction] = array(
14704 'type' => $obj->type,
14705 'tododone' => $tododone,
14707 'datestart' => $db->jdate($obj->dp),
14708 'dateend' => $db->jdate($obj->dp2),
14709 'note' => $obj->label,
14711 'percent' => $obj->percent,
14713 'userid' => $obj->user_id,
14714 'login' => $obj->user_login,
14715 'userfirstname' => $obj->user_firstname,
14716 'userlastname' => $obj->user_lastname,
14717 'userphoto' => $obj->user_photo,
14718 'msg_from' => $obj->msg_from,
14720 'contact_id' => $obj->fk_contact,
14721 'socpeopleassigned' => $contactaction->socpeopleassigned,
14722 'lastname' => (empty($obj->lastname) ?
'' : $obj->lastname),
14723 'firstname' => (empty($obj->firstname) ?
'' : $obj->firstname),
14724 'fk_element' => $obj->fk_element,
14725 'elementtype' => $obj->elementtype,
14727 'acode' => $obj->acode,
14728 'alabel' => $obj->alabel,
14729 'libelle' => $obj->alabel,
14730 'apicto' => $obj->apicto
14733 $histo[$numaction] = array(
14734 'type' => $obj->type,
14735 'tododone' =>
'done',
14737 'datestart' => $db->jdate($obj->dp),
14738 'dateend' => $db->jdate($obj->dp2),
14739 'note' => $obj->label,
14741 'percent' => $obj->percent,
14742 'acode' => $obj->acode,
14744 'userid' => $obj->user_id,
14745 'login' => $obj->user_login,
14746 'userfirstname' => $obj->user_firstname,
14747 'userlastname' => $obj->user_lastname,
14748 'userphoto' => $obj->user_photo
14763 if (!isModEnabled(
'agenda')) {
14764 $langs->loadLangs(array(
"admin",
"errors"));
14765 $out =
info_admin($langs->trans(
"WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv(
"Module2400Name")), 0, 0,
'warning');
14768 if (isModEnabled(
'agenda') || (isModEnabled(
'mailing') && !empty($objcon->email))) {
14769 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
14771 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
14772 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
14773 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
14774 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
14779 $userstatic =
new User($db);
14780 $contactstatic =
new Contact($db);
14781 $userGetNomUrlCache = array();
14782 $contactGetNomUrlCache = array();
14784 $out .=
'<div class="filters-container" >';
14785 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
14786 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
14788 if ($objcon && get_class($objcon) ==
'Contact' &&
14789 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
14790 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
14792 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
14794 if (($filterobj && get_class($filterobj) ==
'Societe')) {
14795 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
14797 $out .=
'<input type="hidden" name="userid" value="'.$filterobj->id.
'" />';
14802 $out .=
'<div class="div-table-responsive-no-min">';
14803 $out .=
'<table class="noborder borderbottom centpercent">';
14805 $out .=
'<tr class="liste_titre">';
14809 $out .=
'<th class="liste_titre width50 middle">';
14810 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
14811 $out .= $searchpicto;
14816 $out .=
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep',
'', $param,
'', $sortfield, $sortorder,
'nowraponall nopaddingleftimp ').
"\n";
14818 $out .=
'<th class="liste_titre hideonsmartphone"><strong class="hideonsmartphone">'.$langs->trans(
"Search").
' : </strong></th>';
14820 $out .=
'<th class="liste_titre"></th>';
14823 $out .=
'<th class="liste_titre">';
14824 $out .=
'<span class="fas fa-square inline-block fawidth30 hideonsmartphone" style="color: #ddd;" title="'.$langs->trans(
"ActionType").
'"></span>';
14825 $out .= $formactions->select_type_actions($actioncode,
"actioncode",
'',
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? -1 : 1, 0, 0, 1,
'selecttype minwidth100', $langs->trans(
"Type"));
14828 $out .=
'<th class="liste_titre maxwidth100onsmartphone">';
14829 $out .=
'<input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'" placeholder="'.$langs->trans(
"Label").
'">';
14834 $out .=
'<th class="liste_titre width50 middle">';
14835 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
14836 $out .= $searchpicto;
14842 $out .=
'</table>';
14849 $out .=
'<ul class="timeline">';
14853 if ($filterobj instanceof
Societe) {
14854 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
14856 if ($filterobj instanceof
User) {
14857 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
14859 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
14860 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
14861 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
14863 if ($filterobj instanceof
Societe) {
14866 if ($filterobj instanceof
User) {
14872 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
14874 $arraylist = $caction->liste_array(1,
'code',
'', (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 1 : 0),
'', 1);
14876 $actualCycleDate =
false;
14879 foreach ($histo as $key => $value) {
14880 $actionstatic->fetch($histo[$key][
'id']);
14882 $actionstatic->type_picto = $histo[$key][
'apicto'];
14883 $actionstatic->type_code = $histo[$key][
'acode'];
14885 $labeltype = $actionstatic->type_code;
14886 if (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labeltype])) {
14887 $labeltype =
'AC_OTH';
14889 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
14890 $labeltype = $langs->trans(
"Message");
14892 if (!empty($arraylist[$labeltype])) {
14893 $labeltype = $arraylist[$labeltype];
14895 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
14896 $labeltype .=
' - '.$arraylist[$actionstatic->code];
14900 $url = DOL_URL_ROOT.
'/comm/action/card.php?id='.$histo[$key][
'id'];
14902 $tmpa =
dol_getdate($histo[$key][
'datestart'],
false);
14904 if (isset($tmpa[
'year']) && isset($tmpa[
'yday']) && $actualCycleDate !== $tmpa[
'year'].
'-'.$tmpa[
'yday']) {
14905 $actualCycleDate = $tmpa[
'year'].
'-'.$tmpa[
'yday'];
14906 $out .=
'<!-- timeline time label -->';
14907 $out .=
'<li class="time-label">';
14908 $out .=
'<span class="timeline-badge-date">';
14909 $out .=
dol_print_date($histo[$key][
'datestart'],
'daytext',
'tzuserrel', $langs);
14912 $out .=
'<!-- /.timeline-label -->';
14916 $out .=
'<!-- timeline item -->'.
"\n";
14917 $out .=
'<li class="timeline-code-'.(!empty($actionstatic->code) ? strtolower($actionstatic->code) :
"none").
'">';
14920 $typeicon = $actionstatic->getTypePicto(
'pictofixedwidth timeline-icon-not-applicble', $labeltype);
14925 $out .=
'<div class="timeline-item">'.
"\n";
14927 $out .=
'<span class="time timeline-header-action2">';
14929 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
14930 $out .=
'<a class="paddingleft paddingright timeline-btn2 editfielda" href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
14931 $out .= $histo[$key][
'id'];
14934 $out .= $actionstatic->getNomUrl(1, -1,
'valignmiddle').
' ';
14937 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
14938 (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
14939 $out .=
'<a class="paddingleft paddingright timeline-btn2 editfielda" href="'.DOL_MAIN_URL_ROOT.
'/comm/action/card.php?action=edit&token='.
newToken().
'&id='.$actionstatic->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?'.$param).
'">';
14941 $out .=
img_picto($langs->trans(
"Modify"),
'edit',
'class="edita"');
14948 $out .=
'<span class="time"><i class="fa fa-clock-o valignmiddle"></i> <span class="valignmiddle">';
14949 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
14950 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
14951 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
14952 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
14953 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
14954 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
14956 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
14960 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
14963 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
14966 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
14969 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
14975 $out .=
"</span></span>\n";
14978 $out .=
'<h3 class="timeline-header">';
14981 $out .=
'<div class="messaging-author inline-block tdoverflowmax150 valignmiddle marginrightonly">';
14982 if ($histo[$key][
'userid'] > 0) {
14983 if (!isset($userGetNomUrlCache[$histo[$key][
'userid']])) {
14984 $userstatic->fetch($histo[$key][
'userid']);
14985 $userGetNomUrlCache[$histo[$key][
'userid']] = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
14987 $out .= $userGetNomUrlCache[$histo[$key][
'userid']];
14988 } elseif (!empty($histo[$key][
'msg_from']) && $actionstatic->code ==
'TICKET_MSG') {
14989 if (!isset($contactGetNomUrlCache[$histo[$key][
'msg_from']])) {
14990 if ($contactstatic->fetch(0,
null,
'', $histo[$key][
'msg_from']) > 0) {
14991 $contactGetNomUrlCache[$histo[$key][
'msg_from']] = $contactstatic->getNomUrl(-1,
'', 16);
14993 $contactGetNomUrlCache[$histo[$key][
'msg_from']] = $histo[$key][
'msg_from'];
14996 $out .= $contactGetNomUrlCache[$histo[$key][
'msg_from']];
15001 $out .=
' <div class="messaging-title inline-block">';
15003 if (empty(
$conf->dol_optimize_smallscreen) && $actionstatic->type_code !=
'AC_OTH_AUTO') {
15004 $out .= $labeltype.
' - ';
15008 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
15009 $out .= $langs->trans(
'TicketNewMessage');
15010 } elseif (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
15011 $out .= $langs->trans(
'TicketNewMessage').
' <em>('.$langs->trans(
'Private').
')</em>';
15012 } elseif (isset($histo[$key][
'type'])) {
15013 if ($histo[$key][
'type'] ==
'action') {
15014 $transcode = $langs->transnoentitiesnoconv(
"Action".$histo[$key][
'acode']);
15015 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode : $histo[$key][
'alabel']);
15016 $libelle = $histo[$key][
'note'];
15017 $actionstatic->id = $histo[$key][
'id'];
15019 } elseif ($histo[$key][
'type'] ==
'mailing') {
15020 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
15021 $transcode = $langs->transnoentitiesnoconv(
"Action".$histo[$key][
'acode']);
15022 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
15025 $libelle .= $histo[$key][
'note'];
15030 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
15031 if (isset(
$conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']]) && isset(
$conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
15032 $link =
$conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
15034 if (!isset(
$conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']])) {
15035 $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']] = array();
15037 $link =
dolGetElementUrl($histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
15038 $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
15041 $out .=
' - '.$link;
15050 if (!empty($histo[$key][
'message'] && $histo[$key][
'message'] != $libelle)
15051 && $actionstatic->code !=
'AC_TICKET_CREATE'
15052 && $actionstatic->code !=
'AC_TICKET_MODIFY'
15054 $out .=
'<div class="timeline-body wordbreak small">';
15055 $truncateLines =
getDolGlobalInt(
'MAIN_TRUNCATE_TIMELINE_MESSAGE', 3);
15057 if ($truncateLines > 0 && strlen($histo[$key][
'message']) > strlen($truncatedText)) {
15058 $out .=
'<div class="readmore-block --closed" >';
15059 $out .=
' <div class="readmore-block__excerpt">';
15061 $out .=
' <br><a class="read-more-link" data-read-more-action="open" href="'.DOL_MAIN_URL_ROOT.
'/comm/action/card.php?id='.$actionstatic->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?'.$param).
'" >'.$langs->trans(
"ReadMore").
' <span class="fa fa-chevron-right" aria-hidden="true"></span></a>';
15063 $out .=
' <div class="readmore-block__full-text" >';
15065 $out .=
' <a class="read-less-link" data-read-more-action="close" href="#" ><span class="fa fa-chevron-up" aria-hidden="true"></span> '.$langs->trans(
"ReadLess").
'</a>';
15079 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
15081 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $Tab) {
15082 if (empty(
$conf->cache[
'contact'][$histo[$key][
'contact_id']])) {
15084 $contact->fetch($cid);
15085 $conf->cache[
'contact'][$histo[$key][
'contact_id']] = $contact;
15087 $contact =
$conf->cache[
'contact'][$histo[$key][
'contact_id']];
15091 $contactList .= !empty($contactList) ?
', ' :
'';
15092 $contactList .= $contact->getNomUrl(1);
15093 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
15094 if (!empty($contact->phone_pro)) {
15095 $contactList .=
'('.dol_print_phone($contact->phone_pro).
')';
15101 $footer .= $langs->trans(
'ActionOnContact').
' : '.$contactList;
15102 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
15103 if (empty(
$conf->cache[
'contact'][$histo[$key][
'contact_id']])) {
15105 $result = $contact->fetch($histo[$key][
'contact_id']);
15106 $conf->cache[
'contact'][$histo[$key][
'contact_id']] = $contact;
15108 $contact =
$conf->cache[
'contact'][$histo[$key][
'contact_id']];
15109 $result = ($contact instanceof
Contact) ? $contact->id : 0;
15113 $footer .= $contact->getNomUrl(1);
15114 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
15115 if (!empty($contact->phone_pro)) {
15116 $footer .=
'('.dol_print_phone($contact->phone_pro).
')';
15123 if (!empty($documents)) {
15124 $footer .=
'<div class="timeline-documents-container">';
15125 foreach ($documents as $doc) {
15126 $footer .=
'<span id="document_'.$doc->id.
'" class="timeline-documents" ';
15127 $footer .=
' data-id="'.$doc->id.
'" ';
15128 $footer .=
' data-path="'.$doc->filepath.
'"';
15129 $footer .=
' data-filename="'.dol_escape_htmltag($doc->filename).
'" ';
15132 $filePath = DOL_DATA_ROOT.
'/'.$doc->filepath.
'/'.$doc->filename;
15134 $file = $actionstatic->id.
'/'.$doc->filename;
15135 $thumb = $actionstatic->id.
'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename,
'.')).
'_mini'.substr($doc->filename, strrpos($doc->filename,
'.'));
15136 $doclink =
dol_buildpath(
'document.php', 1).
'?modulepart=actions&attachment=0&file='.urlencode($file).
'&entity='.
$conf->entity;
15137 $viewlink =
dol_buildpath(
'viewimage.php', 1).
'?modulepart=actions&file='.urlencode($thumb).
'&entity='.
$conf->entity;
15139 $mimeAttr =
' mime="'.$mime.
'" ';
15141 if (in_array($mime, array(
'image/png',
'image/jpeg',
'application/pdf'))) {
15142 $class .=
' documentpreview';
15145 $footer .=
'<a href="'.$doclink.
'" class="btn-link '.$class.
'" target="_blank" rel="noopener noreferrer" '.$mimeAttr.
' >';
15146 $footer .=
img_mime($filePath).
' '.$doc->filename;
15149 $footer .=
'</span>';
15151 $footer .=
'</div>';
15154 if (!empty($footer)) {
15155 $out .=
'<div class="timeline-footer">'.$footer.
'</div>';
15158 $out .=
'</div>'.
"\n";
15161 $out .=
'<!-- END timeline item -->';
15167 jQuery(document).ready(function () {
15168 $(document).on("click", "[data-read-more-action]", function(e){
15169 let readMoreBloc = $(this).closest(".readmore-block");
15170 if(readMoreBloc.length > 0){
15171 e.preventDefault();
15172 if($(this).attr("data-read-more-action") == "close"){
15173 readMoreBloc.addClass("--closed").removeClass("--open");
15174 $("html, body").animate({
15175 scrollTop: readMoreBloc.offset().top - 200
15178 readMoreBloc.addClass("--open").removeClass("--closed");
15186 if (empty($histo)) {
15187 $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
15210function buildParamDate($prefix, $timestamp =
null, $hourTime =
'', $gm =
'auto')
15212 if ($timestamp ===
null) {
15213 $timestamp =
GETPOSTDATE($prefix, $hourTime, $gm);
15220 if ($hourTime ===
'getpost' || ($timestamp !==
null &&
dol_print_date($timestamp,
'%H:%M:%S') !==
'00:00:00')) {
15221 $TParam = array_merge($TParam, array(
15228 return '&' . http_build_query($TParam);
15249function recordNotFound($message =
'', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params =
null)
15251 global
$conf, $db, $langs, $hookmanager;
15254 if (!is_object($langs)) {
15255 include_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
15257 $langs->setDefaultLang();
15260 $langs->load(
"errors");
15262 if ($printheader) {
15263 if (function_exists(
"llxHeader")) {
15265 } elseif (function_exists(
"llxHeaderVierge")) {
15270 print
'<div class="error">';
15271 if (empty($message)) {
15272 print $langs->trans(
"ErrorRecordNotFound");
15274 print $langs->trans($message);
15279 if (empty($showonlymessage)) {
15280 if (empty($hookmanager)) {
15281 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
15284 $hookmanager->initHooks(array(
'main'));
15287 $parameters = array(
'message' => $message,
'params' => $params);
15288 $reshook = $hookmanager->executeHooks(
'getErrorRecordNotFound', $parameters,
$object, $action);
15289 print $hookmanager->resPrint;
15292 if ($printfooter && function_exists(
"llxFooter")) {
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined( 'NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined( 'NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined( 'NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined( 'NOIPCHECK')) llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[])
Header function.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array(), $morecss='', $htmlname='', $forcenojs=0, $moreparam='')
On/off button to change a property status of an object This uses the ajax service objectonoff....
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage agenda events (actions)
Class to manage different types of events.
Class to manage GeoIP conversion Usage: $geoip=new GeoIP('country',$datfile); $geoip->getCountryCodeF...
Class to manage invoices.
Class to manage predefined suppliers products.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
dol_get_prev_month($month, $year)
Return previous month.
dol_get_next_day($day, $month, $year)
Return next day.
getServerTimeZoneInt($refgmtdate='now')
Return server timezone int.
dol_get_prev_day($day, $month, $year)
Return previous day.
dol_get_next_month($month, $year)
Return next month.
dol_convert_file($fileinput, $ext='png', $fileoutput='', $page='')
Convert an image file or a PDF into another image format.
dragAndDropFileUpload($htmlname)
Function to manage the drag and drop of a file.
dol_is_file($pathoffile)
Return if path is a file.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_is_dir($folder)
Test if filename is a directory.
dolGetElementUrl($objectid, $objecttype, $withpicto=0, $option='')
Return link url to an object.
isValidVATID($company)
Check if VAT numero is valid (check done on syntax only, no database or remote access)
dol_html_entity_decode($a, $b, $c='UTF-8', $keepsomeentities=0)
Replace html_entity_decode functions to manage errors.
dol_fiche_end($notab=0)
Show tab footer of a card.
verifCond($strToEvaluate, $onlysimplestring='1')
Verify if condition in string is ok or not.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
getDolGlobalFloat($key, $default=0)
Return a Dolibarr global constant float value.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formatted size.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
Function that return localtax of a product line (according to seller, buyer and product vat rate) If ...
img_weather($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $morecss='')
Show weather picto.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
dolCheckFilters($sqlfilters, &$error='', &$parenthesislevel=0)
Return if a $sqlfilters parameter has a valid balance of parenthesis.
finishSimpleTable($addLineBreak=false)
Add the correct HTML close tags for "startSimpleTable(...)" (use after the last table line)
show_actions_messaging($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC')
Show html area with actions in messaging format.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
setEntity($currentobject)
Set entity id to use when to create an object.
dolForgeExplodeAnd($sqlfilters)
Explode an universal search string with AND parts.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetworks=array())
Show social network link.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
dol_ucfirst($string, $encoding="UTF-8")
Convert first character of the first word of a string to upper.
img_right($titlealt='default', $selected=0, $moreatt='')
Show right arrow logo.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
dol_strtolower($string, $encoding="UTF-8")
Convert a string to lower.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto='UTF-8')
This function is called to decode a HTML string (it decodes entities and br tags)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_left($titlealt='default', $selected=0, $moreatt='')
Show left arrow logo.
dol_print_ip($ip, $mode=0)
Return an IP formatted to be shown on screen.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal)
Function to test if an entry is enabled or not.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs=null, $mode=0, $extralangcode='')
Return a formatted address (part address/zip/town/state) according to country rules.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0, $morecss='paddingright')
Format phone numbers according to country.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
isASecretKey($keyname)
Return if string has a name dedicated to store a secret.
dolPrintHTMLForTextArea($s, $allowiframe=0)
Return a string ready to be output on input textarea.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
getCallerInfoString()
Get caller info as a string that can be appended to a log message.
get_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Get formatted error messages to output (Used to show messages on html output).
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
roundUpToNextMultiple($n, $x=5)
Round to next multiple.
dol_user_country()
Return country code for current user.
dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes=null)
Clean a string from some undesirable HTML tags.
getMultidirTemp($object, $module='', $forobject=0)
Return the full path of the directory where a module (or an object of a module) stores its temporary ...
isHTTPS()
Return if we are using a HTTPS connection Check HTTPS (no way to be modified by user but may be empty...
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
picto_required()
Return picto saying a field is required.
isDolTms($timestamp)
isDolTms check if a timestamp is valid.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
GETPOSTDATE($prefix, $hourTime='', $gm='auto')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
dol_print_url($url, $target='_blank', $max=32, $withpicto=0, $morecss='')
Show Url link.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
printCommonFooter($zone='private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
checkVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
dolGetBadge($label, $html='', $type='primary', $mode='', $url='', $params=array())
Function dolGetBadge.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
Get tax (VAT) main information from Id.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dolPrintText($s)
Return a string label (possible on several lines and that should not contains any HTML) ready to be o...
utf8_valid($str)
Check if a string is in UTF8.
getPictoForType($key, $morecss='')
Return the picto for a data type.
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
img_allow($allow, $titlealt='default')
Show tick logo if allowed.
isValidMXRecord($domain)
Return if the domain name has a valid MX record.
dolButtonToOpenExportDialog($name, $label, $buttonstring, $exportSiteName, $overwriteGitUrl, $website)
Create a dialog with two buttons for export and overwrite of a website.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tab header of a card.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
get_localtax_by_third($local)
Get values of localtaxes (1 or 2) for company country for the common vat with the highest value.
dol_escape_php($stringtoescape, $stringforquotes=2)
Returns text escaped for inclusion into a php string, build with double quotes " or '.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getElementProperties($elementType)
Get an array with properties of an element.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
img_view($titlealt='default', $float=0, $other='class="valignmiddle"')
Show logo view card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolCompletUrlForDropdownButton(string $url, array $params, bool $addDolUrlRoot=true)
An function to complete dropdown url in dolGetButtonAction.
dol_get_object_properties($obj, $properties=[])
Get properties for an object - including magic properties when requested.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
dol_strftime($fmt, $ts=false, $is_gmt=false)
Format a string.
img_picto_common($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $notitle=0)
Show picto (generic function)
img_search($titlealt='default', $other='')
Show search logo.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags=array('textarea'), $cleanalsosomestyles=0)
Clean a string from some undesirable HTML tags.
isValidPhone($phone)
Return true if phone number syntax is ok TODO Decide what to do with this.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
fieldLabel($langkey, $fieldkey, $fieldrequired=0)
Show a string with the label tag dedicated to the HTML edit field.
getBrowserInfo($user_agent)
Return information about user browser.
dolGetFirstLetters($s, $nbofchar=1)
Return first letters of a strings.
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
dolPrintLabel($s, $escapeonlyhtmltags=0)
Return a string label (so on 1 line only and that should not contains any HTML) ready to be output on...
dol_strtoupper($string, $encoding="UTF-8")
Convert a string to upper.
getMultidirVersion($object, $module='', $forobject=0)
Return the full path of the directory where a module (or an object of a module) stores its versioned ...
dol_sanitizeUrl($stringtoclean, $type=1)
Clean a string to use it as an URL (into a href or src attribute)
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
img_printer($titlealt="default", $other='')
Show printer logo.
dol_htmloutput_events($disabledoutputofmessages=0)
Print formatted messages to output (Used to show messages on html output).
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
ascii_check($str)
Check if a string is in ASCII.
get_date_range($date_start, $date_end, $format='', $outputlangs=null, $withparenthesis=1)
Format output for start and end date.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
print_date_range($date_start, $date_end, $format='', $outputlangs=null)
Format output for start and end date.
getArrayOfSocialNetworks()
Get array of social network dictionary.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
num2Alpha($n)
Return a numeric value into an Excel like column number.
dol_size($size, $type='')
Optimize a size for some browsers (phone, smarphone...)
img_split($titlealt='default', $other='class="pictosplit"')
Show split logo.
img_pdf($titlealt='default', $size=3)
Show pdf logo.
dolGetCountryCodeFromIp($ip)
Return a country code from IP.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolPrintPassword($s)
Return a string ready to be output on an HTML attribute (alt, title, ...)
colorIsLight($stringcolor)
Return true if the color is light.
dol_escape_all($stringtoescape)
Returns text escaped for all protocols (so only alpha chars and numbers)
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
readfileLowMemory($fullpath_original_file_osencoded, $method=-1)
Return a file on output using a low memory.
dolForgeSQLCriteriaCallback($matches)
Function to forge a SQL criteria from a USF (Universal Filter Syntax) string.
if(!function_exists( 'utf8_encode')) if(!function_exists('utf8_decode')) if(!function_exists( 'str_starts_with')) if(!function_exists('str_ends_with')) if(!function_exists( 'str_contains')) getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files.
dol_shutdown()
Function called at end of web php process.
dol_print_address($address, $htmlid, $element, $id, $noprint=0, $charfornl='')
Format address string.
dol_print_error_email($prefixcode, $errormessage='', $errormessages=array(), $morecss='error', $email='')
Show a public email and error code to contact if technical error.
dol_escape_uri($stringtoescape)
Returns text escaped by RFC 3986 for inclusion into a clicable link.
dol_print_profids($profID, $profIDtype, $countrycode='', $addcpButton=1)
Format professional IDs according to their country.
fetchObjectByElement($element_id, $element_type, $element_ref='', $useCache=0, $maxCacheByType=10)
Fetch an object from its id and element_type Inclusion of classes is automatic.
print_titre($title)
Show a title.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_string_nounprintableascii($str, $removetabcrlf=1)
Clean a string from all non printable ASCII chars (0x00-0x1F and 0x7F).
getDolGlobalBool($key, $default=false)
Return a Dolibarr global constant boolean value.
img_error($titlealt='default')
Show error logo.
getTimelineIcon($actionstatic, &$histo, $key)
Get timeline icon.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
getUserRemoteIP($trusted=0)
Return the real IP of remote user.
buildParamDate($prefix, $timestamp=null, $hourTime='', $gm='auto')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_next($titlealt='default', $moreatt='')
Show next logo.
isAFileWithExecutableContent($filename)
Return if a file can contains executable content.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_string_is_good_iso($s, $clean=0)
Check if a string is a correct iso string If not, it will not be considered as HTML encoded even if i...
getNonce()
Return a random string to be used as a nonce value for js.
isStringVarMatching($var, $regextext, $matchrule=1)
Check if a variable with name $var startx with $text.
dolSlugify($stringtoslugify)
Returns text slugified (no special char, separator is "-".
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
get_htmloutput_mesg($mesgstring='', $mesgarray=[], $style='ok', $keepembedded=0)
Get formatted messages to output (Used to show messages on html output).
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
get_product_localtax_for_country($idprod, $local, $thirdpartytouse)
Return localtax vat rate of a product in a particular country or default country vat if product is un...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $selectlimitsuffix='', $beforearrows='', $hidenavigation=0)
Function to show navigation arrows into lists.
dol_nboflines($s, $maxchar=0)
Return nb of lines of a clear text.
dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox=0, $check='restricthtml')
Sanitize a HTML to remove js, dangerous content and external link.
jsonOrUnserialize($stringtodecode)
Decode an encode string.
addSummaryTableLine($tableColumnCount, $num, $nbofloop=0, $total=0, $noneWord="None", $extraRightColumn=false)
Add a summary line to the current open table ("None", "XMoreLines" or "Total xxx")
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
dol_escape_xml($stringtoescape)
Returns text escaped for inclusion into a XML string.
getActionCommEcmList($object)
getActionCommEcmList
dol_ucwords($string, $encoding="UTF-8")
Convert first character of all the words of a string to upper.
img_edit_add($titlealt='default', $other='')
Show logo +.
print_fiche_titre($title, $mesg='', $picto='generic', $pictoisfullpath=0, $id='')
Show a title with picto.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
get_product_vat_for_country($idprod, $thirdpartytouse, $idprodfournprice=0)
Return vat rate of a product in a particular country, or default country vat if product is unknown.
dolForgeDummyCriteriaCallback($matches)
Function to forge a SQL criteria from a Dolibarr filter syntax string.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0, $allowscript=0, $allowstyle=0, $allowphp=0)
Clean a string to keep only desirable HTML tags.
dol_escape_json($stringtoescape)
Returns text escaped for inclusion into javascript code.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
sanitizeVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
dol_validElement($element)
Return if var element is ok.
dol_sanitizeKeyCode($str)
Clean a string to use it as a key or code.
img_credit_card($brand, $morecss=null)
Return image of a credit card according to its brand name.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_searchclear($titlealt='default', $other='')
Show search logo.
utf8_check($str)
Check if a string is in UTF8.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formatted error messages to output (Used to show messages on html output).
startSimpleTable($header, $link="", $arguments="", $emptyColumns=0, $number=-1, $pictofulllist='')
Start a table with headers and a optional clickable number (don't forget to use "finishSimpleTable()"...
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
getFieldErrorIcon($fieldValidationErrorMsg)
get field error icon
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.
dolPrintHTMLForAttributeUrl($s)
Return a string ready to be output on a href attribute (this one need a special because we need conte...
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
img_edit_remove($titlealt='default', $other='')
Show logo -.
img_info($titlealt='default')
Show info logo.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
dol_sanitizeEmail($stringtoclean)
Clean a string to use it as an Email.
dol_nboflines_bis($text, $maxlinesize=0, $charset='UTF-8')
Return nb of lines of a formatted text with and (WARNING: string must not have mixed and br sep...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
const MODULE_MAPPING
This mapping defines the conversion to the current internal names from the alternative allowed names ...
dolBECalculateStructuredCommunication($invoice_number, $invoice_type)
Calculate Structured Communication / BE Bank payment reference number.
dol_convertToWord($num, $langs, $currency='', $centimes=false)
Function to return a number into a text.
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
div refaddress div address
conf($dolibarr_main_document_root)
Load conf file (file must exists)
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
realCharForNumericEntities($matches)
Return the real char for a numeric entities.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
dol_setcache($memoryid, $data, $expire=0, $filecache=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid, $filecache=0)
Read a memory area shared by all users, all sessions on server.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
dolGetRandomBytes($length)
Return a string of random bytes (hexa string) with length = $length for cryptographic purposes.