48include_once DOL_DOCUMENT_ROOT.
'/core/lib/json.lib.php';
51if (!function_exists(
'utf8_encode')) {
59 function utf8_encode($elements)
61 return mb_convert_encoding($elements,
'UTF-8',
'ISO-8859-1');
65if (!function_exists(
'utf8_decode')) {
73 function utf8_decode($elements)
75 return mb_convert_encoding($elements,
'ISO-8859-1',
'UTF-8');
78if (!function_exists(
'str_starts_with')) {
87 function str_starts_with($haystack, $needle)
89 return (
string) $needle !==
'' && strncmp($haystack, $needle, strlen($needle)) === 0;
92if (!function_exists(
'str_ends_with')) {
101 function str_ends_with($haystack, $needle)
103 return $needle !==
'' && substr($haystack, -strlen($needle)) === (string) $needle;
106if (!function_exists(
'str_contains')) {
115 function str_contains($haystack, $needle)
117 return $needle !==
'' && mb_strpos($haystack, $needle) !==
false;
137 if (!is_object(
$object) && empty($module)) {
140 if (empty($module) && !empty(
$object->element)) {
145 if ($module ==
'fichinter') {
146 $module =
'ficheinter';
147 } elseif ($module ==
'invoice_supplier') {
148 $module =
'supplier_invoice';
149 } elseif ($module ==
'order_supplier') {
150 $module =
'supplier_order';
154 if ($mode ==
'output' || $mode ==
'outputrel' || $mode ==
'version') {
155 if (isset($conf->$module) && property_exists($conf->$module,
'multidir_output')) {
157 if ($mode !=
'outputrel') {
158 $s = $conf->$module->multidir_output[(empty(
$object->entity) ? $conf->entity :
$object->entity)];
160 if ($forobject &&
$object->id > 0) {
165 return 'error-diroutput-not-defined-for-this-object='.$module;
167 } elseif ($mode ==
'temp') {
168 if (isset($conf->$module) && property_exists($conf->$module,
'multidir_temp')) {
169 return $conf->$module->multidir_temp[(empty(
$object->entity) ? $conf->entity :
$object->entity)];
171 return 'error-dirtemp-not-defined-for-this-object='.$module;
174 return 'error-bad-value-for-mode';
218 return (
string) (isset($conf->global->$key) ? $conf->global->$key : $default);
233 return (
int) (isset($conf->global->$key) ? $conf->global->$key : $default);
247 if (empty($tmpuser)) {
252 return (
string) (isset($tmpuser->conf->$key) ? $tmpuser->conf->$key : $default);
265 if (empty($tmpuser)) {
270 return (
int) (isset($tmpuser->conf->$key) ? $tmpuser->conf->$key: $default);
287 'adherent' =>
'member',
288 'member_type' =>
'adherent_type',
290 'contrat' =>
'contract',
291 'entrepot' =>
'stock',
292 'projet' =>
'project',
293 'categorie' =>
'category',
294 'commande' =>
'order',
295 'expedition' =>
'shipping',
296 'facture' =>
'invoice',
297 'fichinter' =>
'intervention',
298 'ficheinter' =>
'intervention',
299 'propale' =>
'propal',
300 'socpeople' =>
'contact',
301 'fournisseur' =>
'supplier',
303 'actioncomm' =>
'agenda',
304 'product_price' =>
'productprice',
305 'product_fournisseur_price' =>
'productsupplierprice',
315function isModEnabled($module)
325 $arrayconv[
'supplier_order'] =
'fournisseur';
326 $arrayconv[
'supplier_invoice'] =
'fournisseur';
331 if ($module ==
'delivery_note') {
335 $module =
'shipping';
339 $module_alt = $module;
340 if (!empty($arrayconv[$module])) {
341 $module_alt = $arrayconv[$module];
343 $module_bis = $module;
344 if (!empty($arrayconvbis[$module])) {
345 $module_bis = $arrayconvbis[$module];
348 return !empty($conf->modules[$module]) || !empty($conf->modules[$module_alt]) || !empty($conf->modules[$module_bis]);
360 if ($timestamp ===
'') {
361 dol_syslog(
'Using empty string for a timestamp is deprecated, prefer use of null when calling page '.$_SERVER[
"PHP_SELF"], LOG_NOTICE);
364 if (is_null($timestamp) || !is_numeric($timestamp)) {
384 require_once DOL_DOCUMENT_ROOT.
"/core/db/".$type.
'.class.php';
386 $class =
'DoliDB'.ucfirst($type);
387 $db =
new $class($type, $host, $user, $pass, $name, $port);
408function getEntity($element, $shared = 1, $currentobject =
null)
410 global $conf, $mc, $hookmanager,
$object, $action, $db;
412 if (!is_object($hookmanager)) {
413 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
420 $element =
'project';
423 $element =
'contract';
425 case 'order_supplier':
426 $element =
'supplier_order';
428 case 'invoice_supplier':
429 $element =
'supplier_invoice';
433 if (is_object($mc)) {
434 $out = $mc->getEntity($element, $shared, $currentobject);
437 $addzero = array(
'user',
'usergroup',
'cronjob',
'c_email_templates',
'email_template',
'default_values',
'overwrite_trans');
439 $addzero[] =
'c_holiday_types';
441 if (in_array($element, $addzero)) {
444 $out .= ((int) $conf->entity);
449 'element' => $element,
452 'currentobject' => $currentobject,
455 $reshook = $hookmanager->executeHooks(
'hookGetEntity', $parameters, $currentobject, $action);
457 if (is_numeric($reshook)) {
458 if ($reshook == 0 && !empty($hookmanager->resPrint)) {
459 $out .=
','.$hookmanager->resPrint;
460 } elseif ($reshook == 1) {
461 $out = $hookmanager->resPrint;
478 if (is_object($mc) && method_exists($mc,
'setEntity')) {
479 return $mc->setEntity($currentobject);
481 return ((is_object($currentobject) && $currentobject->id > 0 && $currentobject->entity > 0) ? $currentobject->entity : $conf->entity);
493 return preg_match(
'/(_pass|password|_pw|_key|securekey|serverkey|secret\d?|p12key|exportkey|_PW_[a-z]+|token)$/i', $keyname);
505 for ($r =
""; $n >= 0; $n = intval($n / 26) - 1) {
506 $r = chr($n % 26 + 0x41) . $r;
530 include_once DOL_DOCUMENT_ROOT.
'/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php';
537 $user_agent = substr($user_agent, 0, 512);
539 $detectmobile =
new Mobile_Detect(
null, $user_agent);
540 $tablet = $detectmobile->isTablet();
542 if ($detectmobile->isMobile()) {
546 if ($detectmobile->is(
'AndroidOS')) {
547 $os = $phone =
'android';
548 } elseif ($detectmobile->is(
'BlackBerryOS')) {
549 $os = $phone =
'blackberry';
550 } elseif ($detectmobile->is(
'iOS')) {
553 } elseif ($detectmobile->is(
'PalmOS')) {
554 $os = $phone =
'palm';
555 } elseif ($detectmobile->is(
'SymbianOS')) {
557 } elseif ($detectmobile->is(
'webOS')) {
559 } elseif ($detectmobile->is(
'MaemoOS')) {
561 } elseif ($detectmobile->is(
'WindowsMobileOS') || $detectmobile->is(
'WindowsPhoneOS')) {
567 if (preg_match(
'/linux/i', $user_agent)) {
569 } elseif (preg_match(
'/macintosh/i', $user_agent)) {
571 } elseif (preg_match(
'/windows/i', $user_agent)) {
577 if (preg_match(
'/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
579 $version = empty($reg[2]) ?
'' : $reg[2];
580 } elseif (preg_match(
'/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
582 $version = empty($reg[2]) ?
'' : $reg[2];
583 } elseif (preg_match(
'/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) {
585 $version = empty($reg[2]) ?
'' : $reg[2];
586 } elseif (preg_match(
'/chrome/i', $user_agent, $reg)) {
589 } elseif (preg_match(
'/iceweasel/i', $user_agent)) {
591 } elseif (preg_match(
'/epiphany/i', $user_agent)) {
593 } elseif (preg_match(
'/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
595 $version = empty($reg[2]) ?
'' : $reg[2];
596 } elseif (preg_match(
'/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) {
599 $version = empty($reg[2]) ?
'' : $reg[2];
600 } elseif (preg_match(
'/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
602 $version = end($reg);
603 } elseif (preg_match(
'/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) {
606 $version = end($reg);
607 } elseif (preg_match(
'/l[iy]n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) {
609 $name =
'textbrowser';
610 $version = empty($reg[3]) ?
'' : $reg[3];
611 } elseif (preg_match(
'/w3m\/([\d\.]+)/i', $user_agent, $reg)) {
613 $name =
'textbrowser';
614 $version = empty($reg[1]) ?
'' : $reg[1];
626 'browsername' => $name,
627 'browserversion' => $version,
629 'browserua' => $user_agent,
644 $disconnectdone =
false;
646 if (is_object($db) && !empty($db->connected)) {
647 $depth = $db->transaction_opened;
648 $disconnectdone = $db->close();
650 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));
662function GETPOSTISSET($paramname)
666 $relativepathstring = $_SERVER[
"PHP_SELF"];
668 if (constant(
'DOL_URL_ROOT')) {
669 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
671 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
672 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
678 if (!empty($_GET[
'restore_lastsearch_values'])) {
679 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
680 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
681 if (is_array($tmp)) {
682 foreach ($tmp as $key => $val) {
683 if ($key == $paramname) {
691 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
693 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
695 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
697 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
701 $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname]));
718 if (empty($method)) {
719 $val = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
720 } elseif ($method == 1) {
721 $val = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
722 } elseif ($method == 2) {
723 $val = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
724 } elseif ($method == 3) {
725 $val = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
727 $val =
'BadFirstParameterForGETPOST';
730 return is_array($val);
762function GETPOST($paramname, $check =
'alphanohtml', $method = 0, $filter =
null, $options =
null, $noreplace = 0)
764 global $mysoc, $user, $conf;
766 if (empty($paramname)) {
767 return 'BadFirstParameterForGETPOST';
770 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);
775 if (empty($method)) {
776 $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] :
'');
777 } elseif ($method == 1) {
778 $out = isset($_GET[$paramname]) ? $_GET[$paramname] :
'';
779 } elseif ($method == 2) {
780 $out = isset($_POST[$paramname]) ? $_POST[$paramname] :
'';
781 } elseif ($method == 3) {
782 $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] :
'');
784 return 'BadThirdParameterForGETPOST';
787 $relativepathstring =
'';
789 if (empty($method) || $method == 3 || $method == 4) {
790 $relativepathstring = (empty($_SERVER[
"PHP_SELF"]) ?
'' : $_SERVER[
"PHP_SELF"]);
792 if (constant(
'DOL_URL_ROOT')) {
793 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
795 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
796 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
802 if (!empty($_GET[
'restore_lastsearch_values'])) {
803 if (!empty($_SESSION[
'lastsearch_values_'.$relativepathstring])) {
804 $tmp = json_decode($_SESSION[
'lastsearch_values_'.$relativepathstring],
true);
805 if (is_array($tmp)) {
806 foreach ($tmp as $key => $val) {
807 if ($key == $paramname) {
815 if ($paramname ==
'contextpage' && !empty($_SESSION[
'lastsearch_contextpage_'.$relativepathstring])) {
816 $out = $_SESSION[
'lastsearch_contextpage_'.$relativepathstring];
817 } elseif ($paramname ==
'limit' && !empty($_SESSION[
'lastsearch_limit_'.$relativepathstring])) {
818 $out = $_SESSION[
'lastsearch_limit_'.$relativepathstring];
819 } elseif ($paramname ==
'page' && !empty($_SESSION[
'lastsearch_page_'.$relativepathstring])) {
820 $out = $_SESSION[
'lastsearch_page_'.$relativepathstring];
821 } elseif ($paramname ==
'mode' && !empty($_SESSION[
'lastsearch_mode_'.$relativepathstring])) {
822 $out = $_SESSION[
'lastsearch_mode_'.$relativepathstring];
824 } elseif (!isset($_GET[
'sortfield'])) {
827 if (!empty($_GET[
'action']) && $_GET[
'action'] ==
'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
830 '@phan-var-force CommonObject $object';
831 if (is_object(
$object) && isset(
$object->fields[$paramname][
'default'])) {
833 $out =
$object->fields[$paramname][
'default'];
837 if (!empty($_GET[
'action']) && (preg_match(
'/^create/', $_GET[
'action']) || preg_match(
'/^presend/', $_GET[
'action'])) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
839 if (!empty($user->default_values)) {
840 if (isset($user->default_values[$relativepathstring][
'createform'])) {
841 foreach ($user->default_values[$relativepathstring][
'createform'] as $defkey => $defval) {
843 if ($defkey !=
'_noquery_') {
844 $tmpqueryarraytohave = explode(
'&', $defkey);
847 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
848 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
861 if (isset($user->default_values[$relativepathstring][
'createform'][$defkey][$paramname])) {
862 $out = $user->default_values[$relativepathstring][
'createform'][$defkey][$paramname];
869 } elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
871 if (!empty($user->default_values)) {
874 if ($paramname ==
'sortfield' || $paramname ==
'sortorder') {
876 if (isset($user->default_values[$relativepathstring][
'sortorder'])) {
878 foreach ($user->default_values[$relativepathstring][
'sortorder'] as $defkey => $defval) {
880 if ($defkey !=
'_noquery_') {
881 $tmpqueryarraytohave = explode(
'&', $defkey);
884 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
885 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
898 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
899 foreach ($user->default_values[$relativepathstring][
'sortorder'][$defkey] as $key => $val) {
903 if ($paramname ==
'sortfield') {
906 if ($paramname ==
'sortorder') {
914 } elseif (isset($user->default_values[$relativepathstring][
'filters'])) {
915 foreach ($user->default_values[$relativepathstring][
'filters'] as $defkey => $defval) {
916 if (!empty($_GET[
'disabledefaultvalues'])) {
920 if ($defkey !=
'_noquery_') {
921 $tmpqueryarraytohave = explode(
'&', $defkey);
924 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
925 if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
937 if ($qualified && isset($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname])) {
939 if (isset($_POST[
'sall']) || isset($_POST[
'search_all']) || isset($_GET[
'sall']) || isset($_GET[
'search_all'])) {
942 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
943 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
946 $forbidden_chars_to_replace = array(
" ",
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
";",
"=");
947 $out =
dol_string_nospecial($user->default_values[$relativepathstring][
'filters'][$defkey][$paramname],
'', $forbidden_chars_to_replace);
962 '@phan-var-force string $paramname';
963 if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
967 while (preg_match(
'/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) {
971 if ($reg[1] ==
'DAY') {
973 $newout = $tmp[
'mday'];
974 } elseif ($reg[1] ==
'MONTH') {
976 $newout = $tmp[
'mon'];
977 } elseif ($reg[1] ==
'YEAR') {
979 $newout = $tmp[
'year'];
980 } elseif ($reg[1] ==
'PREVIOUS_DAY') {
983 $newout = $tmp2[
'day'];
984 } elseif ($reg[1] ==
'PREVIOUS_MONTH') {
987 $newout = $tmp2[
'month'];
988 } elseif ($reg[1] ==
'PREVIOUS_YEAR') {
990 $newout = ($tmp[
'year'] - 1);
991 } elseif ($reg[1] ==
'NEXT_DAY') {
994 $newout = $tmp2[
'day'];
995 } elseif ($reg[1] ==
'NEXT_MONTH') {
998 $newout = $tmp2[
'month'];
999 } elseif ($reg[1] ==
'NEXT_YEAR') {
1001 $newout = ($tmp[
'year'] + 1);
1002 } elseif ($reg[1] ==
'MYCOMPANY_COUNTRY_ID' || $reg[1] ==
'MYCOUNTRY_ID' || $reg[1] ==
'MYCOUNTRYID') {
1003 $newout = $mysoc->country_id;
1004 } elseif ($reg[1] ==
'USER_ID' || $reg[1] ==
'USERID') {
1005 $newout = $user->id;
1006 } elseif ($reg[1] ==
'USER_SUPERVISOR_ID' || $reg[1] ==
'SUPERVISOR_ID' || $reg[1] ==
'SUPERVISORID') {
1007 $newout = $user->fk_user;
1008 } elseif ($reg[1] ==
'ENTITY_ID' || $reg[1] ==
'ENTITYID') {
1009 $newout = $conf->entity;
1010 } elseif ($reg[1] ==
'ID') {
1016 $out = preg_replace(
'/__'.preg_quote($reg[1],
'/').
'__/', $newout, $out);
1021 if (preg_match(
'/^array/', $check)) {
1022 if (!is_array($out) || empty($out)) {
1025 $tmparray = explode(
':', $check);
1026 if (!empty($tmparray[1])) {
1027 $tmpcheck = $tmparray[1];
1029 $tmpcheck =
'alphanohtml';
1031 foreach ($out as $outkey => $outval) {
1032 $out[$outkey] =
sanitizeVal($outval, $tmpcheck, $filter, $options);
1038 if (strpos($paramname,
'search_') === 0) {
1039 $out = preg_replace(
'/([<>])([-+]?\d)/',
'\1 \2', $out);
1043 $out =
sanitizeVal($out, $check, $filter, $options);
1048 if (preg_match(
'/backtopage/', $paramname) || $paramname ==
'backtolist' || $paramname ==
'backtourl') {
1049 $out = str_replace(
'\\',
'/', $out);
1050 $out = str_replace(array(
':',
';',
'@',
"\t",
' '),
'', $out);
1052 $oldstringtoclean = $out;
1053 $out = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $out);
1054 $out = preg_replace(array(
'/^[^\?]*%/'),
'', $out);
1055 $out = preg_replace(array(
'/^[a-z]*\/\s*\/+/i'),
'', $out);
1056 }
while ($oldstringtoclean != $out);
1061 if (empty($method) || $method == 3 || $method == 4) {
1062 if (preg_match(
'/^search_/', $paramname) || in_array($paramname, array(
'sortorder',
'sortfield'))) {
1069 if ($out !=
'' && isset($user)) {
1070 $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out;
1089 return (
int)
GETPOST($paramname,
'int', $method,
null,
null, 0);
1118function checkVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1120 return sanitizeVal($out, $check, $filter, $options);
1132function sanitizeVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1140 if (!is_numeric($out)) {
1145 if (is_array($out)) {
1146 $out = implode(
',', $out);
1148 if (preg_match(
'/[^0-9,-]+/i', $out)) {
1153 $out = filter_var($out, FILTER_SANITIZE_STRING);
1156 $out = filter_var($out, FILTER_SANITIZE_EMAIL);
1159 if (!is_array($out)) {
1161 if (preg_match(
'/[^a-z]+/i', $out)) {
1167 if (!is_array($out)) {
1169 if (preg_match(
'/[^a-z0-9_\-\.]+/i', $out)) {
1175 if (!is_array($out)) {
1177 if (preg_match(
'/[^a-z0-9_\-\.@]+/i', $out)) {
1183 if (!is_array($out)) {
1185 if (preg_match(
'/[^a-z0-9_\-\.,]+/i', $out)) {
1192 if (!is_array($out)) {
1195 $oldstringtoclean = $out;
1199 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1206 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1207 }
while ($oldstringtoclean != $out);
1211 case 'alphawithlgt':
1212 if (!is_array($out)) {
1215 $oldstringtoclean = $out;
1219 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1226 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1227 }
while ($oldstringtoclean != $out);
1233 case 'restricthtmlnolink':
1234 case 'restricthtml':
1235 case 'restricthtmlallowclass':
1236 case 'restricthtmlallowunvalid':
1241 if (empty($filter)) {
1242 return 'BadParameterForGETPOST - Param 3 of sanitizeVal()';
1244 if (is_null($options)) {
1247 $out = filter_var($out, $filter, $options);
1251 dol_syslog(
"Error, you call sanitizeVal() with a bad value for the check type. Data will be sanitized with alphanohtml.", LOG_ERR);
1252 $out =
GETPOST($out,
'alphanohtml');
1260if (!function_exists(
'dol_getprefix')) {
1271 function dol_getprefix($mode =
'')
1274 if ($mode ==
'email') {
1279 return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
1280 } elseif (isset($_SERVER[
"SERVER_NAME"])) {
1281 return $_SERVER[
"SERVER_NAME"];
1286 if (!empty($conf->file->instance_unique_id)) {
1287 return sha1(
'dolibarr'.$conf->file->instance_unique_id);
1291 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1295 global $dolibarr_main_instance_unique_id, $dolibarr_main_cookie_cryptkey;
1296 $tmp_instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ?
'' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
1299 if (!empty($tmp_instance_unique_id)) {
1300 return sha1(
'dolibarr'.$tmp_instance_unique_id);
1304 if (isset($_SERVER[
"SERVER_NAME"]) && isset($_SERVER[
"DOCUMENT_ROOT"])) {
1305 return sha1($_SERVER[
"SERVER_NAME"].$_SERVER[
"DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1307 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1324 global $conf, $langs, $user, $mysoc;
1328 if (!file_exists($fullpath)) {
1329 dol_syslog(
'functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_WARNING);
1333 if (!empty($classname) && !class_exists($classname)) {
1334 return include $fullpath;
1336 return include_once $fullpath;
1354function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
1358 $path = preg_replace(
'/^\//',
'', $path);
1361 $res = DOL_DOCUMENT_ROOT.
'/'.$path;
1362 if (is_array($conf->file->dol_document_root)) {
1363 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1364 if ($key ==
'main') {
1368 if (@file_exists($dirroot.
'/'.$path)) {
1369 $res = $dirroot.
'/'.$path;
1374 if ($returnemptyifnotfound) {
1376 if ($returnemptyifnotfound == 1 || !file_exists($res)) {
1388 $res = DOL_URL_ROOT.
'/'.$path;
1391 $res = DOL_MAIN_URL_ROOT.
'/'.$path;
1394 $res = DOL_URL_ROOT.
'/'.$path;
1397 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1398 if ($key ==
'main') {
1403 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($conf->file->dol_main_url_root));
1404 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1407 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
'/'.$path;
1412 preg_match(
'/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);
1413 if (!empty($regs[1])) {
1416 if (@file_exists($dirroot.
'/'.$regs[1])) {
1418 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1419 } elseif ($type == 2) {
1420 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1421 } elseif ($type == 3) {
1425 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($conf->file->dol_main_url_root));
1426 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1429 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).$conf->file->dol_url_root[$key].
'/'.$path;
1453 if (empty($properties)) {
1454 return get_object_vars($obj);
1457 $existingProperties = [];
1458 $realProperties = get_object_vars($obj);
1461 foreach ($properties as $property) {
1462 if (array_key_exists($property, $realProperties)) {
1464 $existingProperties[$property] = $obj->{$property};
1465 } elseif (property_exists($obj, $property)) {
1467 $existingProperties[$property] = $obj->{$property};
1471 return $existingProperties;
1499 $myclone = unserialize(serialize(
$object));
1501 if (!empty($tmpsavdb)) {
1504 } elseif ($native == 2) {
1507 $tmparray = get_object_vars(
$object);
1509 if (is_array($tmparray)) {
1510 foreach ($tmparray as $propertykey => $propertyval) {
1511 if (is_scalar($propertyval) || is_array($propertyval)) {
1512 $myclone->$propertykey = $propertyval;
1532function dol_size($size, $type =
'')
1535 if (empty($conf->dol_optimize_smallscreen)) {
1538 if ($type ==
'width' && $size > 250) {
1563 $filesystem_forbidden_chars = array(
'<',
'>',
'/',
'\\',
'?',
'*',
'|',
'"',
':',
'°',
'$',
';',
'`');
1565 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1566 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1567 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1568 $tmp = str_replace(
'..',
'', $tmp);
1589 $filesystem_forbidden_chars = array(
'<',
'>',
'?',
'*',
'|',
'"',
'°',
'$',
';',
'`');
1591 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1592 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1593 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1594 $tmp = str_replace(
'..',
'', $tmp);
1609 $stringtoclean = preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $stringtoclean);
1611 $stringtoclean = preg_replace(
'/<!--[^>]*-->/',
'', $stringtoclean);
1613 $stringtoclean = str_replace(
'\\',
'/', $stringtoclean);
1617 $stringtoclean = str_replace(array(
':',
';',
'@'),
'', $stringtoclean);
1621 $oldstringtoclean = $stringtoclean;
1624 $stringtoclean = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $stringtoclean);
1625 }
while ($oldstringtoclean != $stringtoclean);
1629 $stringtoclean = preg_replace(array(
'/^[a-z]*\/\/+/i'),
'', $stringtoclean);
1632 return $stringtoclean;
1644 $oldstringtoclean = $stringtoclean;
1645 $stringtoclean = str_ireplace(array(
'"',
':',
'[',
']',
"\n",
"\r",
'\\',
'\/'),
'', $stringtoclean);
1646 }
while ($oldstringtoclean != $stringtoclean);
1648 return $stringtoclean;
1663 if (is_null($str)) {
1668 if (extension_loaded(
'intl') &&
getDolGlobalString(
'MAIN_UNACCENT_USE_TRANSLITERATOR')) {
1669 $transliterator = Transliterator::createFromRules(
':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', Transliterator::FORWARD);
1670 return $transliterator->transliterate($str);
1673 $string = rawurlencode($str);
1674 $replacements = array(
1675 '%C3%80' =>
'A',
'%C3%81' =>
'A',
'%C3%82' =>
'A',
'%C3%83' =>
'A',
'%C3%84' =>
'A',
'%C3%85' =>
'A',
1677 '%C3%88' =>
'E',
'%C3%89' =>
'E',
'%C3%8A' =>
'E',
'%C3%8B' =>
'E',
1678 '%C3%8C' =>
'I',
'%C3%8D' =>
'I',
'%C3%8E' =>
'I',
'%C3%8F' =>
'I',
1680 '%C3%92' =>
'O',
'%C3%93' =>
'O',
'%C3%94' =>
'O',
'%C3%95' =>
'O',
'%C3%96' =>
'O',
1682 '%C3%99' =>
'U',
'%C3%9A' =>
'U',
'%C3%9B' =>
'U',
'%C3%9C' =>
'U',
1683 '%C3%9D' =>
'Y',
'%C5%B8' =>
'y',
1684 '%C3%A0' =>
'a',
'%C3%A1' =>
'a',
'%C3%A2' =>
'a',
'%C3%A3' =>
'a',
'%C3%A4' =>
'a',
'%C3%A5' =>
'a',
1686 '%C3%A8' =>
'e',
'%C3%A9' =>
'e',
'%C3%AA' =>
'e',
'%C3%AB' =>
'e',
1687 '%C3%AC' =>
'i',
'%C3%AD' =>
'i',
'%C3%AE' =>
'i',
'%C3%AF' =>
'i',
1689 '%C3%B2' =>
'o',
'%C3%B3' =>
'o',
'%C3%B4' =>
'o',
'%C3%B5' =>
'o',
'%C3%B6' =>
'o',
1691 '%C3%B9' =>
'u',
'%C3%BA' =>
'u',
'%C3%BB' =>
'u',
'%C3%BC' =>
'u',
1692 '%C3%BD' =>
'y',
'%C3%BF' =>
'y'
1694 $string = strtr($string, $replacements);
1695 return rawurldecode($string);
1700 "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
1701 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
1702 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
1703 \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
1704 \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
1705 \xF9\xFA\xFB\xFC\xFD\xFF",
1713 $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"));
1731function dol_string_nospecial($str, $newstr =
'_', $badcharstoreplace =
'', $badcharstoremove =
'', $keepspaces = 0)
1733 $forbidden_chars_to_replace = array(
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
",",
";",
"=",
'°',
'$',
';');
1734 if (empty($keepspaces)) {
1735 $forbidden_chars_to_replace[] =
" ";
1737 $forbidden_chars_to_remove = array();
1740 if (is_array($badcharstoreplace)) {
1741 $forbidden_chars_to_replace = $badcharstoreplace;
1743 if (is_array($badcharstoremove)) {
1744 $forbidden_chars_to_remove = $badcharstoremove;
1748 return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove,
"", $str));
1767 if ($removetabcrlf) {
1768 return preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $str);
1770 return preg_replace(
'/[\x00-\x08\x11-\x12\x14-\x1F\x7F]/u',
'', $str);
1782function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0)
1784 if (is_null($stringtoescape)) {
1789 $substitjs = array(
"'" =>
"\\'",
"\r" =>
'\\r');
1791 if (empty($noescapebackslashn)) {
1792 $substitjs[
"\n"] =
'\\n';
1793 $substitjs[
'\\'] =
'\\\\';
1796 $substitjs[
"'"] =
"\\'";
1797 $substitjs[
'"'] =
"\\'";
1798 } elseif ($mode == 1) {
1799 $substitjs[
"'"] =
"\\'";
1800 } elseif ($mode == 2) {
1801 $substitjs[
'"'] =
'\\"';
1802 } elseif ($mode == 3) {
1803 $substitjs[
"'"] =
"\\'";
1804 $substitjs[
'"'] =
"\\\"";
1806 return strtr($stringtoescape, $substitjs);
1820 return rawurlencode($stringtoescape);
1831 return str_replace(
'"',
'\"', $stringtoescape);
1843 if (is_null($stringtoescape)) {
1847 if ($stringforquotes == 2) {
1848 return str_replace(
'"',
"'", $stringtoescape);
1849 } elseif ($stringforquotes == 1) {
1855 $stringtoescape = str_replace(
'\\',
'', $stringtoescape);
1856 return str_replace(
"'",
"\'", str_replace(
'"',
"'", $stringtoescape));
1859 return 'Bad parameter for stringforquotes in dol_escape_php';
1870 return preg_replace(
'/[^a-z0-9_]/i',
'', $stringtoescape);
1881 return $stringtoescape;
1921 return dol_escape_htmltag(
dol_string_onlythesehtmltags(
dol_htmlentitiesbr($s), 1, 0, 0, 0, array(
'br',
'b',
'font',
'span')), 1, -1,
'', 0, 1);
1945 return htmlspecialchars($s, ENT_COMPAT,
'UTF-8');
1965function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags =
'', $escapeonlyhtmltags = 0, $cleanalsojavascript = 0)
1967 if ($noescapetags ==
'common') {
1968 $noescapetags =
'html,body,a,b,em,hr,i,u,ul,li,br,div,img,font,p,span,strong,table,tr,td,th,tbody,h1,h2,h3,h4,h5,h6,h7,h8,h9';
1970 $noescapetags .=
',header,footer,nav,section,menu,menuitem';
1972 if ($cleanalsojavascript) {
1977 if ($escapeonlyhtmltags) {
1978 $tmp = htmlspecialchars_decode((
string) $stringtoescape, ENT_COMPAT);
1980 $tmp = html_entity_decode((
string) $stringtoescape, ENT_COMPAT,
'UTF-8');
1981 $tmp = str_ireplace(
''',
'__SIMPLEQUOTE', $tmp);
1984 $tmp = strtr($tmp, array(
"<b>" =>
'',
'</b>' =>
'',
'<strong>' =>
'',
'</strong>' =>
''));
1987 $tmp = strtr($tmp, array(
"\r" =>
'\\r',
"\n" =>
'\\n'));
1988 } elseif ($keepn == -1) {
1989 $tmp = strtr($tmp, array(
"\r" =>
'',
"\n" =>
''));
1992 if ($escapeonlyhtmltags) {
1993 return htmlspecialchars($tmp, ENT_COMPAT,
'UTF-8');
1996 $tmparrayoftags = array();
1997 if ($noescapetags) {
1998 $tmparrayoftags = explode(
',', $noescapetags);
2000 if (count($tmparrayoftags)) {
2002 $tmp = str_ireplace(
'__DOUBLEQUOTE',
'', $tmp);
2004 foreach ($tmparrayoftags as $tagtoreplace) {
2005 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'>/',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2006 $tmp = str_ireplace(
'</'.$tagtoreplace.
'>',
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2007 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
' \/>/',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2013 if (preg_match(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+([^>]+)>/', $tmp, $reg)) {
2014 $tmpattributes = str_ireplace(array(
'[',
']'),
'_', $reg[1]);
2015 $tmpattributes = str_ireplace(
'href="http:',
'__HREFHTTPA', $tmpattributes);
2016 $tmpattributes = str_ireplace(
'href="https:',
'__HREFHTTPSA', $tmpattributes);
2017 $tmpattributes = str_ireplace(
'src="http:',
'__SRCHTTPIMG', $tmpattributes);
2018 $tmpattributes = str_ireplace(
'src="https:',
'__SRCHTTPSIMG', $tmpattributes);
2019 $tmpattributes = str_ireplace(
'"',
'__DOUBLEQUOTE', $tmpattributes);
2020 $tmpattributes = preg_replace(
'/[^a-z0-9_\/\?\;\s=&\.\-@:\.#\+]/i',
'', $tmpattributes);
2022 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+'.preg_quote($reg[1],
'/').
'>/',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'['.$tmpattributes.
']__', $tmp);
2024 if (preg_match(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+([^>]+)\s+\/>/', $tmp, $reg)) {
2025 $tmpattributes = str_ireplace(array(
'[',
']'),
'_', $reg[1]);
2026 $tmpattributes = str_ireplace(
'"',
'__DOUBLEQUOTE', $tmpattributes);
2027 $tmpattributes = preg_replace(
'/[^a-z0-9_\/\?\;\s=&\.\-@:\.#\+]/i',
'', $tmpattributes);
2029 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'\s+'.preg_quote($reg[1],
'/').
'\s+\/>/',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'['.$tmpattributes.
']__', $tmp);
2032 $diff = strcmp($tmpold, $tmp);
2037 $result = htmlentities($tmp, ENT_COMPAT,
'UTF-8');
2041 if (count($tmparrayoftags)) {
2042 foreach ($tmparrayoftags as $tagtoreplace) {
2043 $result = str_ireplace(
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
'>', $result);
2044 $result = preg_replace(
'/__BEGINTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1>', $result);
2045 $result = str_ireplace(
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__',
'</'.$tagtoreplace.
'>', $result);
2046 $result = str_ireplace(
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
' />', $result);
2047 $result = preg_replace(
'/__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1 />', $result);
2050 $result = str_ireplace(
'__HREFHTTPA',
'href="http:', $result);
2051 $result = str_ireplace(
'__HREFHTTPSA',
'href="https:', $result);
2052 $result = str_ireplace(
'__SRCHTTPIMG',
'src="http:', $result);
2053 $result = str_ireplace(
'__SRCHTTPSIMG',
'src="https:', $result);
2054 $result = str_ireplace(
'__DOUBLEQUOTE',
'"', $result);
2057 $result = str_ireplace(
'__SIMPLEQUOTE',
''', $result);
2074 if (function_exists(
'mb_strtolower')) {
2075 return mb_strtolower($string, $encoding);
2077 return strtolower($string);
2091 if (function_exists(
'mb_strtoupper')) {
2092 return mb_strtoupper($string, $encoding);
2094 return strtoupper($string);
2108 if (function_exists(
'mb_substr')) {
2109 return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1,
null, $encoding);
2111 return ucfirst($string);
2125 if (function_exists(
'mb_convert_case')) {
2126 return mb_convert_case($string, MB_CASE_TITLE, $encoding);
2128 return ucwords($string);
2154function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
'', $restricttologhandler =
'', $logcontext =
null)
2156 global $conf, $user, $debugbar;
2159 if (!isModEnabled(
'syslog')) {
2164 if (defined(
'USEEXTERNALSERVER') && !defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
2165 global $website, $websitekey;
2166 if (is_object($website) && !empty($website->ref)) {
2167 $suffixinfilename .=
'_website_'.$website->ref;
2168 } elseif (!empty($websitekey)) {
2169 $suffixinfilename .=
'_website_'.$websitekey;
2174 if (defined(
'USESUFFIXINLOG')) {
2175 $suffixinfilename .= constant(
'USESUFFIXINLOG');
2179 foreach ($conf->loghandlers as $loghandlerinstance) {
2180 $loghandlerinstance->setIdent($ident);
2184 if (!empty($message)) {
2187 $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');
2189 if (!array_key_exists($level, $logLevels)) {
2190 dol_syslog(
'Error Bad Log Level '.$level, LOG_ERR);
2191 $level = $logLevels[LOG_ERR];
2198 $message = preg_replace(
'/password=\'[^\']*\'/',
'password=\'hidden\'', $message);
2202 if ((!empty($_REQUEST[
'logtohtml']) &&
getDolGlobalString(
'MAIN_ENABLE_LOG_TO_HTML'))
2203 || (is_object($user) && $user->hasRight(
'debugbar',
'read') && is_object($debugbar))) {
2204 $ospid = sprintf(
"%7s",
dol_trunc(getmypid(), 7,
'right',
'UTF-8', 1));
2205 $osuser =
" ".sprintf(
"%6s",
dol_trunc(function_exists(
'posix_getuid') ? posix_getuid() :
'', 6,
'right',
'UTF-8', 1));
2207 $conf->logbuffer[] =
dol_print_date(time(),
"%Y-%m-%d %H:%M:%S").
" ".sprintf(
"%-7s", $logLevels[$level]).
" ".$ospid.
" ".$osuser.
" ".$message;
2213 print
"\n\n<!-- Log start\n";
2215 print
"Log end -->\n";
2219 'message' => $message,
2220 'script' => (isset($_SERVER[
'PHP_SELF']) ? basename($_SERVER[
'PHP_SELF'],
'.php') : false),
2222 'user' => ((is_object($user) && $user->id) ? $user->login : false),
2224 'osuser' => function_exists(
'posix_getuid') ? posix_getuid() : false,
2225 'ospid' => getmypid()
2229 if (!empty($remoteip)) {
2230 $data[
'ip'] = $remoteip;
2232 if (!empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) && $_SERVER[
'HTTP_X_FORWARDED_FOR'] != $remoteip) {
2233 $data[
'ip'] = $_SERVER[
'HTTP_X_FORWARDED_FOR'].
' -> '.$data[
'ip'];
2234 } elseif (!empty($_SERVER[
'HTTP_CLIENT_IP']) && $_SERVER[
'HTTP_CLIENT_IP'] != $remoteip) {
2235 $data[
'ip'] = $_SERVER[
'HTTP_CLIENT_IP'].
' -> '.$data[
'ip'];
2237 } elseif (!empty($_SERVER[
'SERVER_ADDR'])) {
2239 $data[
'ip'] = $_SERVER[
'SERVER_ADDR'];
2240 } elseif (!empty($_SERVER[
'COMPUTERNAME'])) {
2242 $data[
'ip'] = $_SERVER[
'COMPUTERNAME'];
2244 $data[
'ip'] =
'???';
2247 if (!empty($_SERVER[
'USERNAME'])) {
2249 $data[
'osuser'] = $_SERVER[
'USERNAME'];
2250 } elseif (!empty($_SERVER[
'LOGNAME'])) {
2252 $data[
'osuser'] = $_SERVER[
'LOGNAME'];
2256 foreach ($conf->loghandlers as $loghandlerinstance) {
2257 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
2260 $loghandlerinstance->export($data, $suffixinfilename);
2266 foreach ($conf->loghandlers as $loghandlerinstance) {
2267 $loghandlerinstance->setIdent($ident);
2287 $form =
new Form($db);
2289 $templatenameforexport = $website->name_template;
2290 if (empty($templatenameforexport)) {
2291 $templatenameforexport =
'website_'.$website->ref;
2295 $out .=
'<input type="button" class="cursorpointer button bordertransp" id="open-dialog-' . $name .
'" value="'.dol_escape_htmltag($buttonstring).
'"/>';
2298 $out .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">';
2299 $out .=
'jQuery(document).ready(function () {';
2300 $out .=
' jQuery("#open-dialog-' . $name .
'").click(function () {';
2301 $out .=
' var dialogHtml = \'';
2303 $dialogcontent =
' <div id="custom-dialog-' . $name .
'">';
2304 $dialogcontent .=
' <div style="margin-top: 20px;">';
2305 $dialogcontent .=
' <label for="export-site-' . $name .
'"><strong>'.$langs->trans(
"ExportSiteLabel").
'...</label><br>';
2306 $dialogcontent .=
' <button class="button smallpaddingimp" id="export-site-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"DownloadZip")) .
'</button>';
2307 $dialogcontent .=
' </div>';
2308 $dialogcontent .=
' <br>';
2309 $dialogcontent .=
' <div style="margin-top: 20px;">';
2310 $dialogcontent .=
' <strong>'.$langs->trans(
"ExportSiteGitLabel").
' '.$form->textwithpicto(
'', $langs->trans(
"SourceFiles"), 1,
'help',
'', 0, 3,
'').
'</strong><br>';
2311 $dialogcontent .=
' <form action="'.dol_escape_htmltag($overwriteGitUrl).
'" method="POST">';
2312 $dialogcontent .=
' <input type="hidden" name="action" value="overwritesite">';
2313 $dialogcontent .=
' <input type="hidden" name="token" value="'.newToken().
'">';
2314 $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>';
2315 $dialogcontent .=
' <button type="submit" class="button smallpaddingimp" id="overwrite-git-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"ExportIntoGIT")) .
'</button>';
2316 $dialogcontent .=
' </form>';
2317 $dialogcontent .=
' </div>';
2318 $dialogcontent .=
' </div>';
2325 // Add the content of the dialog to the body of the page
2326 $out .= ' var $dialog = jQuery(
"#custom-dialog-' . $name . '");
';
2327 $out .= ' if ($dialog.length > 0) {
2330 jQuery(
"body").append(dialogHtml);
';
2332 // Configuration of popup
2333 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog({
';
2334 $out .= ' autoOpen:
false,
';
2335 $out .= ' modal:
true,
';
2336 $out .= ' height: 290,
';
2337 $out .= ' width:
"40%",
';
2338 $out .= ' title:
"' . dol_escape_js($label) . '",
';
2341 // Simulate a click on the original "submit" input to export the site.
2342 $out .= ' jQuery(
"#export-site-' . $name . '").click(
function () {
';
2343 $out .= ' console.log(
"Clic on exportsite.");
';
2344 $out .= ' var target = jQuery(
"input[name=\'' . dol_escape_js($exportSiteName) . '\']");
';
2345 $out .= ' console.log(
"element founded:", target.length > 0);
';
2346 $out .= ' if (target.length > 0) { target.click(); }
';
2347 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"close");
';
2351 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"open");
';
2352 $out .= ' return false;
';
2355 $out .= '</script>
';
2377function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '
', $morecss = 'classlink
button bordertransp
', $jsonopen = '', $backtopagejsfields = '', $accesskey = '')
2381 if (strpos($url, '?
') > 0) {
2382 $url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2384 $url .= '?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2389 $backtopagejsfieldsid = '';
2390 $backtopagejsfieldslabel = '';
2391 if ($backtopagejsfields) {
2392 $tmpbacktopagejsfields = explode(':
', $backtopagejsfields);
2393 if (empty($tmpbacktopagejsfields[1])) { // If the part 'keyforpopupid:
' is missing, we add $name for it.
2394 $backtopagejsfields = $name.":".$backtopagejsfields;
2395 $tmp2backtopagejsfields = explode(',
', $tmpbacktopagejsfields[0]);
2397 $tmp2backtopagejsfields = explode(',
', $tmpbacktopagejsfields[1]);
2399 $backtopagejsfieldsid = empty($tmp2backtopagejsfields[0]) ? '' : $tmp2backtopagejsfields[0];
2400 $backtopagejsfieldslabel = empty($tmp2backtopagejsfields[1]) ? '' : $tmp2backtopagejsfields[1];
2401 $url .= '&backtopagejsfields=
'.urlencode($backtopagejsfields);
2404 //print '<input
type=
"submit" class=
"button bordertransp"'.$disabled.' value=
"'.dol_escape_htmltag($langs->trans("MediaFiles
")).'" name=
"file_manager">
';
2405 $out .= '<!-- a link
for button to open url into a dialog popup with backtopagejsfields =
'.$backtopagejsfields.' -->
';
2406 $out .= '<a
'.($accesskey ? ' accesskey=
"'.$accesskey.'"' : '').' class=
"cursorpointer reposition button_'.$name.($morecss ? ' '.$morecss : '').'"'.$disabled.' title=
"'.dol_escape_htmltag($label).'"';
2407 if (empty($conf->use_javascript_ajax)) {
2408 $out .= ' href=
"'.DOL_URL_ROOT.$url.'" target=
"_blank"';
2409 } elseif ($jsonopen) {
2410 $out .= ' href=
"#" onclick=
"'.$jsonopen.'"';
2412 $out .= ' href=
"#"';
2414 $out .= '>
'.$buttonstring.'</a>
';
2416 if (!empty($conf->use_javascript_ajax)) {
2417 // Add code to open url using the popup. Add also hidden field to retrieve the returned variables
2418 $out .= '<!-- code to open popup and variables to retrieve returned variables -->
';
2419 $out .= '<div
id=
"idfordialog'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for dialog
' : '').'</div>
';
2420 $out .= '<div
id=
"varforreturndialogid'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for returned
id' : '').'</div>
';
2421 $out .= '<div
id=
"varforreturndialoglabel'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for returned label
' : '').'</div>
';
2423 $out .= '<!-- Add js code to open dialog popup on dialog -->
';
2424 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript">
2425 jQuery(document).ready(
function () {
2426 jQuery(
".button_'.$name.'").click(
function () {
2427 console.log(\
'Open popup with jQuery(...).dialog() on URL '.
dol_escape_js(DOL_URL_ROOT.$url).
'\');
2428 var $tmpdialog = $(\
'#idfordialog'.$name.
'\');
2429 $tmpdialog.html(\
'<iframe class="iframedialog" id="iframedialog'.$name.
'" style="border: 0px;" src="'.DOL_URL_ROOT.$url.
'" width="100%" height="98%"></iframe>\');
2433 height: (window.innerHeight - 150),
2436 open: function (event, ui) {
2437 console.log(
"open popup name='.$name.', backtopagejsfields='.$backtopagejsfields.'");
2439 close:
function (event, ui) {
2440 var returnedid = jQuery(
"#varforreturndialogid'.$name.'").text();
2441 var returnedlabel = jQuery(
"#varforreturndialoglabel'.$name.'").text();
2442 console.log(
"popup has been closed. returnedid (js var defined into parent page)="+returnedid+
" returnedlabel="+returnedlabel);
2443 if (returnedid !=
"" && returnedid !=
"div for returned id") {
2444 jQuery(
"#'.(empty($backtopagejsfieldsid) ? "none
" : $backtopagejsfieldsid).'").val(returnedid);
2446 if (returnedlabel !=
"" && returnedlabel !=
"div for returned label") {
2447 jQuery(
"#'.(empty($backtopagejsfieldslabel) ? "none
" : $backtopagejsfieldslabel).'").val(returnedlabel);
2452 $tmpdialog.dialog(\
'open\');
2477function dol_fiche_head($links = array(), $active =
'0', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
2479 print
dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow, $moretabssuffix);
2498function dol_get_fiche_head($links = array(), $active =
'', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'', $dragdropfile = 0)
2500 global $conf, $langs, $hookmanager;
2504 if (!empty($conf->dol_optimize_smallscreen)) {
2508 $out =
"\n".
'<!-- dol_fiche_head - dol_get_fiche_head -->';
2510 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2511 $out .=
'<div class="tabs'.($picto ?
'' :
' nopaddingleft').
'" data-role="controlgroup" data-type="horizontal">'.
"\n";
2515 if ($morehtmlright) {
2516 $out .=
'<div class="inline-block floatright tabsElem">'.$morehtmlright.
'</div>';
2520 if (!empty($title) && $showtitle && !
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER')) {
2522 $out .=
'<a class="tabTitle">';
2524 $noprefix = $pictoisfullpath;
2525 if (strpos($picto,
'fontawesome_') !==
false) {
2528 $out .=
img_picto($title, ($noprefix ?
'' :
'object_').$picto,
'', $pictoisfullpath, 0, 0,
'',
'imgTabTitle').
' ';
2530 $out .=
'<span class="tabTitleText">'.dol_escape_htmltag(
dol_trunc($title, $limittitle)).
'</span>';
2538 if (is_array($links) && !empty($links)) {
2539 $keys = array_keys($links);
2541 $maxkey = max($keys);
2547 if (empty($limittoshow)) {
2548 $limittoshow = (!
getDolGlobalString(
'MAIN_MAXTABS_IN_CARD') ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD);
2550 if (!empty($conf->dol_optimize_smallscreen)) {
2558 for ($i = 0; $i <= $maxkey; $i++) {
2559 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2561 if ($i >= $limittoshow) {
2567 for ($i = 0; $i <= $maxkey; $i++) {
2568 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2574 if ($i < $limittoshow || $isactive) {
2576 $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])).
' -->';
2578 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2579 if (!empty($links[$i][0])) {
2580 $out .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2582 $out .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2584 } elseif (!empty($links[$i][1])) {
2586 $out .=
'<div class="tab tab'.($isactive ?
'active' :
'unactive').
'" style="margin: 0 !important">';
2587 if (!empty($links[$i][0])) {
2588 $titletoshow = preg_replace(
'/<.*$/',
'', $links[$i][1]);
2589 $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).
'">';
2591 $out .= $links[$i][1];
2592 if (!empty($links[$i][0])) {
2593 $out .=
'</a>'.
"\n";
2595 $out .= empty($links[$i][4]) ?
'' : $links[$i][4];
2604 $outmore .=
'<div class="popuptabset wordwrap">';
2606 $outmore .=
'<div class="popuptab wordwrap" style="display:inherit;">';
2607 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2608 if (!empty($links[$i][0])) {
2609 $outmore .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2611 $outmore .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2613 } elseif (!empty($links[$i][1])) {
2614 $outmore .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="wordwrap inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
2615 $outmore .= preg_replace(
'/([a-z])\|([a-z])/i',
'\\1 | \\2', $links[$i][1]);
2616 $outmore .=
'</a>'.
"\n";
2618 $outmore .=
'</div>';
2625 $outmore .=
'</div>';
2629 $left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
2630 $right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
2631 $widthofpopup = 200;
2633 $tabsname = $moretabssuffix;
2634 if (empty($tabsname)) {
2635 $tabsname = str_replace(
"@",
"", $picto);
2637 $out .=
'<div id="moretabs'.$tabsname.
'" class="inline-block tabsElem valignmiddle">';
2639 $out .=
'<div class="tab valignmiddle"><a href="#" class="tab moretab inline-block tabunactive valignmiddle"><span class="hideonsmartphone">'.$langs->trans(
"More").
'</span>... ('.$nbintab.
')</a></div>';
2641 $out .=
'<div id="moretabsList'.$tabsname.
'" style="width: '.$widthofpopup.
'px; position: absolute; '.$left.
': -999em; text-align: '.$left.
'; margin:0px; padding:2px; z-index:10;">';
2644 $out .=
'<div></div>';
2647 $out .=
'<script nonce="'.getNonce().
'">';
2648 $out .=
"$('#moretabs".$tabsname.
"').mouseenter( function() {
2649 var x = this.offsetLeft, y = this.offsetTop;
2650 console.log('mouseenter ".$left.
" x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
2651 if ((window.innerWidth - x) < ".($widthofpopup + 10).
") {
2652 $('#moretabsList".$tabsname.
"').css('".$right.
"','8px');
2654 $('#moretabsList".$tabsname.
"').css('".$left.
"','auto');
2657 $out .=
"$('#moretabs".$tabsname.
"').mouseleave( function() { console.log('mouseleave ".$left.
"'); $('#moretabsList".$tabsname.
"').css('".$left.
"','-999em');});";
2658 $out .=
"</script>";
2661 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2665 if (!$notab || $notab == -1 || $notab == -2 || $notab == -3) {
2666 $out .=
"\n".
'<div id="dragDropAreaTabBar" class="tabBar'.($notab == -1 ?
'' : ($notab == -2 ?
' tabBarNoTop' : (($notab == -3 ?
' noborderbottom' :
'').
' tabBarWithBottom')));
2669 if (!empty($dragdropfile)) {
2670 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2673 $parameters = array(
'tabname' => $active,
'out' => $out);
2674 $reshook = $hookmanager->executeHooks(
'printTabsHead', $parameters);
2676 $out = $hookmanager->resPrint;
2702 if (!$notab || $notab == -1) {
2703 return "\n</div>\n";
2728function dol_banner_tab(
$object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $onlybanner = 0, $morehtmlright =
'')
2730 global $conf, $form, $user, $langs, $hookmanager, $action;
2734 $maxvisiblephotos = 1;
2736 $entity = (empty(
$object->entity) ? $conf->entity :
$object->entity);
2738 $showbarcode = !isModEnabled(
'barcode') ? 0 : (empty(
$object->barcode) ? 0 : 1);
2739 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2742 $modulepart =
'unknown';
2744 if (in_array(
$object->element, [
'societe',
'contact',
'product',
'ticket',
'bom'])) {
2745 $modulepart =
$object->element;
2746 } elseif (
$object->element ==
'member') {
2747 $modulepart =
'memberphoto';
2748 } elseif (
$object->element ==
'user') {
2749 $modulepart =
'userphoto';
2752 if (class_exists(
"Imagick")) {
2753 if (
$object->element ==
'expensereport' ||
$object->element ==
'propal' ||
$object->element ==
'commande' ||
$object->element ==
'facture' ||
$object->element ==
'supplier_proposal') {
2754 $modulepart =
$object->element;
2755 } elseif (
$object->element ==
'fichinter' ||
$object->element ==
'intervention') {
2756 $modulepart =
'ficheinter';
2757 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
2758 $modulepart =
'contract';
2759 } elseif (
$object->element ==
'order_supplier') {
2760 $modulepart =
'supplier_order';
2761 } elseif (
$object->element ==
'invoice_supplier') {
2762 $modulepart =
'supplier_invoice';
2766 if (
$object->element ==
'product') {
2768 '@phan-var-force Product $object';
2770 $cssclass =
'photowithmargin photoref';
2771 $showimage =
$object->is_photo_available($conf->product->multidir_output[$entity]);
2773 if ($conf->browser->layout ==
'phone') {
2774 $maxvisiblephotos = 1;
2777 $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>';
2781 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2783 $nophoto =
'/public/theme/common/nophoto.png';
2784 $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>';
2787 } elseif (
$object->element ==
'category') {
2789 '@phan-var-force Categorie $object';
2791 $cssclass =
'photowithmargin photoref';
2792 $showimage =
$object->isAnyPhotoAvailable($conf->categorie->multidir_output[$entity]);
2794 if ($conf->browser->layout ==
'phone') {
2795 $maxvisiblephotos = 1;
2798 $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>';
2802 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2804 $nophoto =
'/public/theme/common/nophoto.png';
2805 $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>';
2808 } elseif (
$object->element ==
'bom') {
2810 '@phan-var-force Bom $object';
2812 $cssclass =
'photowithmargin photoref';
2813 $showimage =
$object->is_photo_available($conf->bom->multidir_output[$entity]);
2815 if ($conf->browser->layout ==
'phone') {
2816 $maxvisiblephotos = 1;
2819 $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>';
2823 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2825 $nophoto =
'/public/theme/common/nophoto.png';
2826 $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>';
2829 } elseif (
$object->element ==
'ticket') {
2831 $cssclass =
'photoref';
2833 '@phan-var-force Ticket $object';
2834 $showimage =
$object->is_photo_available($conf->ticket->multidir_output[$entity].
'/'.
$object->ref);
2836 if ($conf->browser->layout ==
'phone') {
2837 $maxvisiblephotos = 1;
2841 $showphoto =
$object->show_photos(
'ticket', $conf->ticket->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0);
2843 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$showphoto.
'</div>';
2851 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2853 $nophoto =
img_picto(
'No photo',
'object_ticket');
2854 $morehtmlleft .=
'<!-- No photo to show -->';
2855 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2856 $morehtmlleft .= $nophoto;
2857 $morehtmlleft .=
'</div></div>';
2862 if ($modulepart !=
'unknown' || method_exists(
$object,
'getDataToShowPhoto')) {
2865 if (in_array($modulepart, array(
'propal',
'commande',
'facture',
'ficheinter',
'contract',
'supplier_order',
'supplier_proposal',
'supplier_invoice',
'expensereport')) && class_exists(
"Imagick")) {
2867 $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]).
"/";
2868 if (in_array($modulepart, array(
'invoice_supplier',
'supplier_invoice'))) {
2870 $subdir .= ((!empty($subdir) && !preg_match(
'/\/$/', $subdir)) ?
'/' :
'').$objectref;
2874 if (empty($subdir)) {
2875 $subdir =
'errorgettingsubdirofobject';
2878 $filepath = $dir_output.$subdir.
"/";
2880 $filepdf = $filepath.$objectref.
".pdf";
2881 $relativepath = $subdir.
'/'.$objectref.
'.pdf';
2884 $fileimage = $filepdf.
'_preview.png';
2885 $relativepathimage = $relativepath.
'_preview.png';
2887 $pdfexists = file_exists($filepdf);
2892 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2894 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2903 if ($pdfexists && !$error) {
2904 $heightforphotref = 80;
2905 if (!empty($conf->dol_optimize_smallscreen)) {
2906 $heightforphotref = 60;
2909 if (file_exists($fileimage)) {
2910 $phototoshow =
'<div class="photoref">';
2911 $phototoshow .=
'<img height="'.$heightforphotref.
'" class="photo photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2912 $phototoshow .=
'</div>';
2915 } elseif (!$phototoshow) {
2916 $phototoshow .= $form->showphoto($modulepart,
$object, 0, 0, 0,
'photowithmargin photoref',
'small', 1, 0, $maxvisiblephotos);
2920 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
2921 $morehtmlleft .= $phototoshow;
2922 $morehtmlleft .=
'</div>';
2926 if (empty($phototoshow)) {
2927 if (
$object->element ==
'action') {
2929 $cssclass =
'photorefcenter';
2930 $nophoto =
img_picto(
'No photo',
'title_agenda');
2933 $cssclass =
'photorefcenter';
2935 $prefix =
'object_';
2939 if (strpos($picto,
'fontawesome_') !==
false) {
2942 $nophoto =
img_picto(
'No photo', $prefix.$picto);
2944 $morehtmlleft .=
'<!-- No photo to show -->';
2945 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2946 $morehtmlleft .= $nophoto;
2947 $morehtmlleft .=
'</div></div>';
2954 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode(
$object, 100,
'photoref valignmiddle').
'</div>';
2957 if (
$object->element ==
'societe') {
2958 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'societe',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
2961 $morehtmlstatus .=
$object->getLibStatut(6);
2963 } elseif (
$object->element ==
'product') {
2965 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
2966 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
2968 $morehtmlstatus .=
'<span class="statusrefsell">'.$object->getLibStatut(6, 0).
'</span>';
2970 $morehtmlstatus .=
' ';
2972 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
2973 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
2975 $morehtmlstatus .=
'<span class="statusrefbuy">'.$object->getLibStatut(6, 1).
'</span>';
2977 } elseif (in_array(
$object->element, array(
'salary'))) {
2979 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
2982 $morehtmlstatus .= $tmptxt;
2983 } elseif (in_array(
$object->element, array(
'facture',
'invoice',
'invoice_supplier'))) {
2984 $totalallpayments =
$object->getSommePaiement(0);
2985 $totalallpayments +=
$object->getSumCreditNotesUsed(0);
2986 $totalallpayments +=
$object->getSumDepositsUsed(0);
2987 $tmptxt =
$object->getLibStatut(6, $totalallpayments);
2988 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
2989 $tmptxt =
$object->getLibStatut(5, $totalallpayments);
2991 $morehtmlstatus .= $tmptxt;
2992 } elseif (in_array(
$object->element, array(
'chargesociales',
'loan',
'tva'))) {
2994 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
2997 $morehtmlstatus .= $tmptxt;
2998 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
3000 $morehtmlstatus .=
$object->getLibStatut(5);
3002 $morehtmlstatus .=
$object->getLibStatut(4);
3004 } elseif (
$object->element ==
'facturerec') {
3005 '@phan-var-force FactureRec $object';
3006 if (
$object->frequency == 0) {
3007 $morehtmlstatus .=
$object->getLibStatut(2);
3009 $morehtmlstatus .=
$object->getLibStatut(5);
3011 } elseif (
$object->element ==
'project_task') {
3016 if (
$object->progress >= 100) {
3019 $tmptxt =
$object->getLibStatut(5);
3020 $morehtmlstatus .= $tmptxt;
3021 } elseif (method_exists(
$object,
'getLibStatut')) {
3022 $tmptxt =
$object->getLibStatut(6);
3023 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3024 $tmptxt =
$object->getLibStatut(5);
3026 $morehtmlstatus .= $tmptxt;
3030 if (isModEnabled(
'accounting') && in_array(
$object->element, array(
'bank',
'paiementcharge',
'facture',
'invoice',
'invoice_supplier',
'expensereport',
'payment_various'))) {
3032 if (method_exists(
$object,
'getVentilExportCompta')) {
3033 $accounted =
$object->getVentilExportCompta();
3034 $langs->load(
"accountancy");
3035 $morehtmlstatus .=
'</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? $langs->trans(
"Accounted") : $langs->trans(
"NotYetAccounted")).
'</span>';
3040 if (!empty(
$object->name_alias)) {
3041 '@phan-var-force Societe $object';
3042 $morehtmlref .=
'<div class="refidno opacitymedium">'.dol_escape_htmltag(
$object->name_alias).
'</div>';
3046 if (in_array(
$object->element, array(
'product',
'bank_account',
'project_task'))) {
3048 $morehtmlref .=
'<div class="refidno opacitymedium">'.$object->label.
'</div>';
3052 if (method_exists(
$object,
'getBannerAddress') && !in_array(
$object->element, array(
'product',
'bookmark',
'ecm_directories',
'ecm_files'))) {
3055 $morehtmlref .=
'<div class="refidno refaddress">';
3056 $morehtmlref .= $moreaddress;
3057 $morehtmlref .=
'</div>';
3061 $morehtmlref .=
'<div style="clear: both;"></div>';
3062 $morehtmlref .=
'<div class="refidno opacitymedium">';
3063 $morehtmlref .= $langs->trans(
"TechnicalID").
': '.((int)
$object->id);
3064 $morehtmlref .=
'</div>';
3067 $parameters = array(
'morehtmlref' => &$morehtmlref,
'moreparam' => &$moreparam,
'morehtmlleft' => &$morehtmlleft,
'morehtmlstatus' => &$morehtmlstatus,
'morehtmlright' => &$morehtmlright);
3068 $reshook = $hookmanager->executeHooks(
'formDolBanner', $parameters,
$object, $action);
3071 } elseif (empty($reshook)) {
3072 $morehtmlref .= $hookmanager->resPrint;
3073 } elseif ($reshook > 0) {
3074 $morehtmlref = $hookmanager->resPrint;
3082 print
'<div class="'.($onlybanner ?
'arearefnobottom ' :
'arearef ').
'heightref valignmiddle centpercent">';
3083 print $form->showrefnav(
$object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
3085 print
'<div class="underrefbanner clearboth"></div>';
3097function fieldLabel($langkey, $fieldkey, $fieldrequired = 0)
3101 if ($fieldrequired) {
3102 $ret .=
'<span class="fieldrequired">';
3104 $ret .=
'<label for="'.$fieldkey.
'">';
3105 $ret .= $langs->trans($langkey);
3107 if ($fieldrequired) {
3120function dol_bc($var, $moreclass =
'')
3123 $ret =
' '.$bc[$var];
3125 $ret = preg_replace(
'/class=\"/',
'class="'.$moreclass.
' ', $ret);
3145 global $langs, $hookmanager;
3148 $countriesusingstate = array(
'AU',
'CA',
'US',
'IN',
'GB',
'ES',
'UK',
'TR',
'CN');
3153 $ret .= ($extralangcode ?
$object->array_languages[
'address'][$extralangcode] : (empty(
$object->address) ?
'' : preg_replace(
'/(\r\n|\r|\n)+/', $sep,
$object->address)));
3156 if (isset(
$object->country_code) && in_array(
$object->country_code, array(
'AU',
'CA',
'US',
'CN')) ||
getDolGlobalString(
'MAIN_FORCE_STATE_INTO_ADDRESS')) {
3158 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3159 $ret .= (($ret && $town) ? $sep :
'').$town;
3162 $ret .= ($ret ? ($town ?
", " : $sep) :
'').
$object->state;
3165 $ret .= ($ret ? (($town ||
$object->state) ?
", " : $sep) :
'').
$object->zip;
3167 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'GB',
'UK'))) {
3169 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3170 $ret .= ($ret ? $sep :
'').$town;
3172 $ret .= ($ret ?
", " :
'').
$object->state;
3175 $ret .= ($ret ? $sep :
'').
$object->zip;
3177 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'ES',
'TR'))) {
3179 $ret .= ($ret ? $sep :
'').
$object->zip;
3180 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3181 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3183 $ret .= $sep.$object->state;
3185 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'JP'))) {
3188 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3190 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'IT'))) {
3192 $ret .= ($ret ? $sep :
'').
$object->zip;
3193 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3194 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3195 $ret .= (empty(
$object->state_code) ?
'' : (
' '.$object->state_code));
3198 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3199 $ret .= !empty(
$object->zip) ? (($ret ? $sep :
'').
$object->zip) :
'';
3200 $ret .= ($town ? ((
$object->zip ?
' ' : ($ret ? $sep :
'')).$town) :
'');
3201 if (!empty(
$object->state) && in_array(
$object->country_code, $countriesusingstate)) {
3202 $ret .= ($ret ?
", " :
'').
$object->state;
3206 if (!is_object($outputlangs)) {
3207 $outputlangs = $langs;
3210 $langs->load(
"dict");
3211 $ret .= (empty(
$object->country_code) ?
'' : ($ret ? $sep :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$object->country_code)));
3214 $parameters = array(
'withcountry' => $withcountry,
'sep' => $sep,
'outputlangs' => $outputlangs,
'mode' => $mode,
'extralangcode' => $extralangcode);
3215 $reshook = $hookmanager->executeHooks(
'formatAddress', $parameters,
$object);
3219 $ret .= $hookmanager->resPrint;
3236function dol_strftime($fmt, $ts =
false, $is_gmt =
false)
3238 if ((abs($ts) <= 0x7FFFFFFF)) {
3241 return 'Error date outside supported range';
3266function dol_print_date($time, $format =
'', $tzoutput =
'auto', $outputlangs =
null, $encodetooutput =
false)
3268 global $conf, $langs;
3275 if ($tzoutput ===
'auto') {
3276 $tzoutput = (empty($conf) ?
'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey :
'tzserver'));
3281 $offsettz = $offsetdst = 0;
3284 if (is_string($tzoutput)) {
3285 if ($tzoutput ==
'tzserver') {
3287 $offsettzstring = @date_default_timezone_get();
3292 } elseif ($tzoutput ==
'tzuser' || $tzoutput ==
'tzuserrel') {
3294 $offsettzstring = (empty($_SESSION[
'dol_tz_string']) ?
'UTC' : $_SESSION[
'dol_tz_string']);
3296 if (class_exists(
'DateTimeZone')) {
3297 $user_date_tz =
new DateTimeZone($offsettzstring);
3298 $user_dt =
new DateTime();
3299 $user_dt->setTimezone($user_date_tz);
3300 $user_dt->setTimestamp($tzoutput ==
'tzuser' ?
dol_now() : (int) $time);
3301 $offsettz = $user_dt->getOffset();
3303 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3304 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3309 if (!is_object($outputlangs)) {
3310 $outputlangs = $langs;
3313 $format =
'daytextshort';
3318 $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array(
'day',
'dayhour',
'dayhoursec'))) ? 1 : 0;
3319 $format = preg_replace(
'/inputnoreduce/',
'', $format);
3320 $formatwithoutreduce = preg_replace(
'/reduceformat/',
'', $format);
3321 if ($formatwithoutreduce != $format) {
3322 $format = $formatwithoutreduce;
3328 if ($format ==
'day') {
3329 $format = ($outputlangs->trans(
"FormatDateShort") !=
"FormatDateShort" ? $outputlangs->trans(
"FormatDateShort") : $conf->format_date_short);
3330 } elseif ($format ==
'hour') {
3331 $format = ($outputlangs->trans(
"FormatHourShort") !=
"FormatHourShort" ? $outputlangs->trans(
"FormatHourShort") : $conf->format_hour_short);
3332 } elseif ($format ==
'hourduration') {
3333 $format = ($outputlangs->trans(
"FormatHourShortDuration") !=
"FormatHourShortDuration" ? $outputlangs->trans(
"FormatHourShortDuration") : $conf->format_hour_short_duration);
3334 } elseif ($format ==
'daytext') {
3335 $format = ($outputlangs->trans(
"FormatDateText") !=
"FormatDateText" ? $outputlangs->trans(
"FormatDateText") : $conf->format_date_text);
3336 } elseif ($format ==
'daytextshort') {
3337 $format = ($outputlangs->trans(
"FormatDateTextShort") !=
"FormatDateTextShort" ? $outputlangs->trans(
"FormatDateTextShort") : $conf->format_date_text_short);
3338 } elseif ($format ==
'dayhour') {
3339 $format = ($outputlangs->trans(
"FormatDateHourShort") !=
"FormatDateHourShort" ? $outputlangs->trans(
"FormatDateHourShort") : $conf->format_date_hour_short);
3340 } elseif ($format ==
'dayhoursec') {
3341 $format = ($outputlangs->trans(
"FormatDateHourSecShort") !=
"FormatDateHourSecShort" ? $outputlangs->trans(
"FormatDateHourSecShort") : $conf->format_date_hour_sec_short);
3342 } elseif ($format ==
'dayhourtext') {
3343 $format = ($outputlangs->trans(
"FormatDateHourText") !=
"FormatDateHourText" ? $outputlangs->trans(
"FormatDateHourText") : $conf->format_date_hour_text);
3344 } elseif ($format ==
'dayhourtextshort') {
3345 $format = ($outputlangs->trans(
"FormatDateHourTextShort") !=
"FormatDateHourTextShort" ? $outputlangs->trans(
"FormatDateHourTextShort") : $conf->format_date_hour_text_short);
3346 } elseif ($format ==
'dayhourlog') {
3348 $format =
'%Y%m%d%H%M%S';
3349 } elseif ($format ==
'dayhourlogsmall') {
3351 $format =
'%y%m%d%H%M';
3352 } elseif ($format ==
'dayhourldap') {
3353 $format =
'%Y%m%d%H%M%SZ';
3354 } elseif ($format ==
'dayhourxcard') {
3355 $format =
'%Y%m%dT%H%M%SZ';
3356 } elseif ($format ==
'dayxcard') {
3358 } elseif ($format ==
'dayrfc') {
3359 $format =
'%Y-%m-%d';
3360 } elseif ($format ==
'dayhourrfc') {
3361 $format =
'%Y-%m-%dT%H:%M:%SZ';
3362 } elseif ($format ==
'standard') {
3363 $format =
'%Y-%m-%d %H:%M:%S';
3366 if ($reduceformat) {
3367 $format = str_replace(
'%Y',
'%y', $format);
3368 $format = str_replace(
'yyyy',
'yy', $format);
3372 if (preg_match(
'/%b/i', $format)) {
3374 $format = str_replace(
'%b',
'__b__', $format);
3375 $format = str_replace(
'%B',
'__B__', $format);
3377 if (preg_match(
'/%a/i', $format)) {
3379 $format = str_replace(
'%a',
'__a__', $format);
3380 $format = str_replace(
'%A',
'__A__', $format);
3385 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)) {
3386 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"]));
3388 } elseif (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', (
string) $time, $reg)) {
3390 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);
3393 $syear = (!empty($reg[1]) ? $reg[1] :
'');
3394 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
3395 $sday = (!empty($reg[3]) ? $reg[3] :
'');
3396 $shour = (!empty($reg[4]) ? $reg[4] :
'');
3397 $smin = (!empty($reg[5]) ? $reg[5] :
'');
3398 $ssec = (!empty($reg[6]) ? $reg[6] :
'');
3400 $time =
dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear,
true);
3403 $tzo =
new DateTimeZone(
'UTC');
3405 $tzo =
new DateTimeZone(date_default_timezone_get());
3407 $dtts =
new DateTime();
3408 $dtts->setTimestamp($time);
3409 $dtts->setTimezone($tzo);
3410 $newformat = str_replace(
3411 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3412 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3415 $ret = $dtts->format($newformat);
3417 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3418 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3423 if ($time < 100000000000) {
3424 $timetouse = $time + $offsettz + $offsetdst;
3427 $tzo =
new DateTimeZone(
'UTC');
3429 $tzo =
new DateTimeZone(date_default_timezone_get());
3431 $dtts =
new DateTime();
3432 $dtts->setTimestamp($timetouse);
3433 $dtts->setTimezone($tzo);
3434 $newformat = str_replace(
3435 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'%w',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3436 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'w',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3439 $ret = $dtts->format($newformat);
3441 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3442 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3447 $ret =
'Bad value '.$time.
' for date';
3451 if (preg_match(
'/__b__/i', $format)) {
3452 $timetouse = $time + $offsettz + $offsetdst;
3455 $tzo =
new DateTimeZone(
'UTC');
3457 $tzo =
new DateTimeZone(date_default_timezone_get());
3459 $dtts =
new DateTime();
3460 $dtts->setTimestamp($timetouse);
3461 $dtts->setTimezone($tzo);
3462 $month = (int) $dtts->format(
"m");
3463 $month = sprintf(
"%02d", $month);
3464 if ($encodetooutput) {
3465 $monthtext = $outputlangs->transnoentities(
'Month'.$month);
3466 $monthtextshort = $outputlangs->transnoentities(
'MonthShort'.$month);
3468 $monthtext = $outputlangs->transnoentitiesnoconv(
'Month'.$month);
3469 $monthtextshort = $outputlangs->transnoentitiesnoconv(
'MonthShort'.$month);
3472 $ret = str_replace(
'__b__', $monthtextshort, $ret);
3473 $ret = str_replace(
'__B__', $monthtext, $ret);
3477 if (preg_match(
'/__a__/i', $format)) {
3479 $timetouse = $time + $offsettz + $offsetdst;
3482 $tzo =
new DateTimeZone(
'UTC');
3484 $tzo =
new DateTimeZone(date_default_timezone_get());
3486 $dtts =
new DateTime();
3487 $dtts->setTimestamp($timetouse);
3488 $dtts->setTimezone($tzo);
3489 $w = $dtts->format(
"w");
3490 $dayweek = $outputlangs->transnoentitiesnoconv(
'Day'.$w);
3492 $ret = str_replace(
'__A__', $dayweek, $ret);
3493 $ret = str_replace(
'__a__',
dol_substr($dayweek, 0, 3), $ret);
3520function dol_getdate($timestamp, $fast =
false, $forcetimezone =
'')
3522 if ($timestamp ===
'') {
3526 $datetimeobj =
new DateTime();
3527 $datetimeobj->setTimestamp($timestamp);
3528 if ($forcetimezone) {
3529 $datetimeobj->setTimezone(
new DateTimeZone($forcetimezone ==
'gmt' ?
'UTC' : $forcetimezone));
3532 'year' => ((
int) date_format($datetimeobj,
'Y')),
3533 'mon' => ((
int) date_format($datetimeobj,
'm')),
3534 'mday' => ((
int) date_format($datetimeobj,
'd')),
3535 'wday' => ((
int) date_format($datetimeobj,
'w')),
3536 'yday' => ((
int) date_format($datetimeobj,
'z')),
3537 'hours' => ((
int) date_format($datetimeobj,
'H')),
3538 'minutes' => ((
int) date_format($datetimeobj,
'i')),
3539 'seconds' => ((
int) date_format($datetimeobj,
's')),
3567function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm =
'auto', $check = 1)
3572 if ($gm ===
'auto') {
3573 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
3578 if ($hour == -1 || empty($hour)) {
3581 if ($minute == -1 || empty($minute)) {
3584 if ($second == -1 || empty($second)) {
3590 if (!$month || !$day) {
3599 if ($hour < 0 || $hour > 24) {
3602 if ($minute < 0 || $minute > 60) {
3605 if ($second < 0 || $second > 60) {
3610 if (empty($gm) || ($gm ===
'server' || $gm ===
'tzserver')) {
3611 $default_timezone = @date_default_timezone_get();
3612 $localtz =
new DateTimeZone($default_timezone);
3613 } elseif ($gm ===
'user' || $gm ===
'tzuser' || $gm ===
'tzuserrel') {
3615 $default_timezone = (empty($_SESSION[
"dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION[
"dol_tz_string"]);
3617 $localtz =
new DateTimeZone($default_timezone);
3619 dol_syslog(
"Warning dol_tz_string contains an invalid value ".json_encode($_SESSION[
"dol_tz_string"] ??
null), LOG_WARNING);
3620 $default_timezone = @date_default_timezone_get();
3622 } elseif (strrpos($gm,
"tz,") !==
false) {
3623 $timezone = str_replace(
"tz,",
"", $gm);
3625 $localtz =
new DateTimeZone($timezone);
3627 dol_syslog(
"Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
3631 if (empty($localtz)) {
3632 $localtz =
new DateTimeZone(
'UTC');
3636 $dt =
new DateTime(
'now', $localtz);
3637 $dt->setDate((
int) $year, (
int) $month, (
int) $day);
3638 $dt->setTime((
int) $hour, (
int) $minute, (
int) $second);
3639 $date = $dt->getTimestamp();
3655function dol_now($mode =
'auto')
3659 if ($mode ===
'auto') {
3663 if ($mode ==
'gmt') {
3665 } elseif ($mode ==
'tzserver') {
3666 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
3668 $ret = (int) (
dol_now(
'gmt') + ($tzsecond * 3600));
3674 } elseif ($mode ==
'tzuser' || $mode ==
'tzuserrel') {
3677 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3678 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3679 $ret = (int) (
dol_now(
'gmt') + ($offsettz + $offsetdst));
3696 global $conf, $langs;
3699 if (!empty($conf->dol_optimize_smallscreen)) {
3704 if (empty($shortvalue) || $size < ($level * 10)) {
3706 $textunitshort = $langs->trans(
"b");
3707 $textunitlong = $langs->trans(
"Bytes");
3709 $ret = round($size / $level, 0);
3710 $textunitshort = $langs->trans(
"Kb");
3711 $textunitlong = $langs->trans(
"KiloBytes");
3714 if (empty($shortunit)) {
3715 $ret .=
' '.$textunitlong;
3717 $ret .=
' '.$textunitshort;
3733function dol_print_url($url, $target =
'_blank', $max = 32, $withpicto = 0, $morecss =
'')
3741 $linkstart =
'<a href="';
3742 if (!preg_match(
'/^http/i', $url)) {
3743 $linkstart .=
'http://';
3748 $linkstart .=
' target="'.$target.
'"';
3750 $linkstart .=
' title="'.$langs->trans(
"URL").
': '.$url.
'"';
3754 if (!preg_match(
'/^http/i', $url)) {
3761 if ($morecss ==
'float') {
3762 return '<div class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe',
'class="paddingrightonly"') :
'').$link.
'</div>';
3764 return $linkstart.
'<span class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto(
'',
'globe',
'class="paddingrightonly"') :
'').$link.
'</span>'.$linkend;
3780function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0)
3782 global $user, $langs, $hookmanager;
3793 if (empty($email)) {
3797 if (!empty($addlink)) {
3798 $newemail =
'<a class="paddingrightonly" style="text-overflow: ellipsis;" href="';
3799 if (!preg_match(
'/^mailto:/i', $email)) {
3800 $newemail .=
'mailto:';
3802 $newemail .= $email;
3805 $newemail .= ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'');
3808 $newemail .=
'</a>';
3810 $langs->load(
"errors");
3811 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email),
'',
'paddingrightonly');
3814 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
3816 $linktoaddaction =
'';
3818 $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>';
3820 if ($linktoaddaction) {
3821 $newemail =
'<div>'.$newemail.
' '.$linktoaddaction.
'</div>';
3825 $newemail = ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'').$newemail;
3828 $langs->load(
"errors");
3829 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
3839 $parameters = array(
'cid' => $cid,
'socid' => $socid,
'addlink' => $addlink,
'picto' => $withpicto);
3841 $reshook = $hookmanager->executeHooks(
'printEmail', $parameters, $email);
3845 $rep .= $hookmanager->resPrint;
3860 $socialnetworks = array();
3862 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
3863 $cachekey =
'socialnetworks_' . $conf->entity;
3865 if (!is_null($dataretrieved)) {
3866 $socialnetworks = $dataretrieved;
3868 $sql =
"SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX.
"c_socialnetworks";
3869 $sql .=
" WHERE entity=".$conf->entity;
3870 $resql = $db->query($sql);
3872 while ($obj = $db->fetch_object($resql)) {
3873 $socialnetworks[$obj->code] = array(
3874 'rowid' => $obj->rowid,
3875 'label' => $obj->label,
3877 'icon' => $obj->icon,
3878 'active' => $obj->active,
3884 return $socialnetworks;
3899 global $user, $langs;
3903 if (empty($value)) {
3907 if (!empty($type)) {
3908 $htmllink =
'<div class="divsocialnetwork inline-block valignmiddle">';
3910 $htmllink .=
'<span class="fab pictofixedwidth '.($dictsocialnetworks[$type][
'icon'] ? $dictsocialnetworks[$type][
'icon'] :
'fa-link').
'"></span>';
3911 if ($type ==
'skype') {
3913 $htmllink .=
' <a href="skype:';
3915 $htmllink .=
'?call" alt="'.$langs->trans(
"Call").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Call").
' '.$value).
'">';
3916 $htmllink .=
'<img src="'.DOL_URL_ROOT.
'/theme/common/skype_callbutton.png" border="0">';
3917 $htmllink .=
'</a><a href="skype:';
3919 $htmllink .=
'?chat" alt="'.$langs->trans(
"Chat").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Chat").
' '.$value).
'">';
3920 $htmllink .=
'<img class="paddingleft" src="'.DOL_URL_ROOT.
'/theme/common/skype_chatbutton.png" border="0">';
3921 $htmllink .=
'</a>';
3922 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
3923 $addlink =
'AC_SKYPE';
3926 $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>';
3928 $htmllink .= ($link ?
' '.$link :
'');
3931 $networkconstname =
'MAIN_INFO_SOCIETE_'.strtoupper($type).
'_URL';
3934 if (preg_match(
'/^https?:\/\//i', $link)) {
3935 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3937 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3939 } elseif (!empty($dictsocialnetworks[$type][
'url'])) {
3940 $tmpvirginurl = preg_replace(
'/\/?{socialid}/',
'', $dictsocialnetworks[$type][
'url']);
3941 if ($tmpvirginurl) {
3942 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3943 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3945 $tmpvirginurl3 = preg_replace(
'/^https:\/\//i',
'https://www.', $tmpvirginurl);
3946 if ($tmpvirginurl3) {
3947 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3948 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3951 $tmpvirginurl2 = preg_replace(
'/^https?:\/\//i',
'', $tmpvirginurl);
3952 if ($tmpvirginurl2) {
3953 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3954 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3957 $link = str_replace(
'{socialid}', $value, $dictsocialnetworks[$type][
'url']);
3958 if (preg_match(
'/^https?:\/\//i', $link)) {
3959 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3961 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3967 $htmllink .=
'</div>';
3969 $langs->load(
"errors");
3970 $htmllink .=
img_warning($langs->trans(
"ErrorBadSocialNetworkValue", $value));
3984function dol_print_profids($profID, $profIDtype, $countrycode =
'', $addcpButton = 1)
3988 if (empty($profID) || empty($profIDtype)) {
3991 if (empty($countrycode)) {
3992 $countrycode = $mysoc->country_code;
3994 $newProfID = $profID;
3995 $id = substr($profIDtype, -1);
3997 if (strtoupper($countrycode) ==
'FR') {
4001 if ($id == 1 &&
dol_strlen($newProfID) == 9) {
4003 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3);
4005 if ($id == 2 &&
dol_strlen($newProfID) == 14) {
4007 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3).
' '.substr($newProfID, 9, 5);
4009 if ($id == 3 &&
dol_strlen($newProfID) == 5) {
4011 $newProfID = substr($newProfID, 0, 2).
'.'.substr($newProfID, 2, 3);
4013 if ($profIDtype ===
'VAT' &&
dol_strlen($newProfID) == 13) {
4015 $newProfID = substr($newProfID, 0, 4).
' '.substr($newProfID, 4, 3).
' '.substr($newProfID, 7, 3).
' '.substr($newProfID, 10, 3);
4018 if (!empty($addcpButton)) {
4041function dol_print_phone($phone, $countrycode =
'', $cid = 0, $socid = 0, $addlink =
'', $separ =
" ", $withpicto =
'', $titlealt =
'', $adddivfloat = 0, $morecss =
'')
4043 global $conf, $user, $langs, $mysoc, $hookmanager;
4046 $phone = is_null($phone) ?
'' : preg_replace(
"/[\s.-]/",
"", trim($phone));
4047 if (empty($phone)) {
4053 if (empty($countrycode) && is_object($mysoc)) {
4054 $countrycode = $mysoc->country_code;
4058 if (!empty($conf->dol_optimize_smallscreen) && $separ !=
'hidenum') {
4063 $newphonewa = $phone;
4064 if (strtoupper($countrycode) ==
"FR") {
4067 $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);
4069 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
4071 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
4073 $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);
4075 $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);
4077 $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);
4079 } elseif (strtoupper($countrycode) ==
"CA") {
4081 $newphone = ($separ !=
'' ?
'(' :
'').substr($newphone, 0, 3).($separ !=
'' ?
')' :
'').$separ.substr($newphone, 3, 3).($separ !=
'' ?
'-' :
'').substr($newphone, 6, 4);
4083 } elseif (strtoupper($countrycode) ==
"PT") {
4085 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4087 } elseif (strtoupper($countrycode) ==
"SR") {
4089 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
4091 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
4093 } elseif (strtoupper($countrycode) ==
"DE") {
4095 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
4097 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
4099 } elseif (strtoupper($countrycode) ==
"ES") {
4101 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4103 } elseif (strtoupper($countrycode) ==
"BF") {
4105 $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);
4107 } elseif (strtoupper($countrycode) ==
"RO") {
4109 $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);
4111 } elseif (strtoupper($countrycode) ==
"TR") {
4113 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4115 } elseif (strtoupper($countrycode) ==
"US") {
4117 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4119 } elseif (strtoupper($countrycode) ==
"MX") {
4121 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4123 $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);
4125 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4127 } elseif (strtoupper($countrycode) ==
"ML") {
4129 $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);
4131 } elseif (strtoupper($countrycode) ==
"TH") {
4133 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4135 $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);
4137 } elseif (strtoupper($countrycode) ==
"MU") {
4140 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
4142 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4144 } elseif (strtoupper($countrycode) ==
"ZA") {
4146 $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);
4148 } elseif (strtoupper($countrycode) ==
"SY") {
4150 $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);
4152 $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);
4154 } elseif (strtoupper($countrycode) ==
"AE") {
4156 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4158 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4160 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
4162 } elseif (strtoupper($countrycode) ==
"DZ") {
4164 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4166 } elseif (strtoupper($countrycode) ==
"BE") {
4168 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4170 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4172 } elseif (strtoupper($countrycode) ==
"PF") {
4174 $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);
4176 } elseif (strtoupper($countrycode) ==
"CO") {
4178 $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);
4180 } elseif (strtoupper($countrycode) ==
"JO") {
4182 $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);
4184 } elseif (strtoupper($countrycode) ==
"JM") {
4186 $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4188 } elseif (strtoupper($countrycode) ==
"MG") {
4190 $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);
4192 } elseif (strtoupper($countrycode) ==
"GB") {
4194 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4196 } elseif (strtoupper($countrycode) ==
"CH") {
4198 $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);
4200 $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);
4202 } elseif (strtoupper($countrycode) ==
"TN") {
4204 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4206 } elseif (strtoupper($countrycode) ==
"GF") {
4208 $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);
4210 } elseif (strtoupper($countrycode) ==
"GP") {
4212 $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);
4214 } elseif (strtoupper($countrycode) ==
"MQ") {
4216 $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);
4218 } elseif (strtoupper($countrycode) ==
"IT") {
4220 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4222 $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);
4224 } elseif (strtoupper($countrycode) ==
"AU") {
4228 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
4230 } elseif (strtoupper($countrycode) ==
"LU") {
4233 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
4235 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 1);
4237 $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);
4239 $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);
4241 } elseif (strtoupper($countrycode) ==
"PE") {
4244 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4);
4246 $newphonewa =
'+51'.$newphone;
4247 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 10, 3);
4249 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 8, 4);
4251 $newphonewa = $newphone;
4252 $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);
4256 $newphoneastart = $newphoneaend =
'';
4257 if (!empty($addlink)) {
4258 if ($addlink ==
'tel' || $conf->browser->layout ==
'phone' || (isModEnabled(
'clicktodial') &&
getDolGlobalString(
'CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS'))) {
4259 $newphoneastart =
'<a href="tel:'.urlencode($phone).
'">';
4260 $newphoneaend .=
'</a>';
4261 } elseif (isModEnabled(
'clicktodial') && $addlink ==
'AC_TEL') {
4262 if (empty($user->clicktodial_loaded)) {
4263 $user->fetch_clicktodial();
4267 $urlmask =
getDolGlobalString(
'CLICKTODIAL_URL',
'ErrorClickToDialModuleNotConfigured');
4268 if (!empty($user->clicktodial_url)) {
4269 $urlmask = $user->clicktodial_url;
4272 $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) :
'');
4273 $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) :
'');
4274 $clicktodial_password = (!empty($user->clicktodial_password) ? urlencode($user->clicktodial_password) :
'');
4276 $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
4278 $substitarray = array(
'__PHONEFROM__' => $clicktodial_poste,
4279 '__PHONETO__' => urlencode($phone),
4280 '__LOGIN__' => $clicktodial_login,
4281 '__PASS__' => $clicktodial_password);
4285 $newphoneastart =
'<a href="'.$url.
'" class="cssforclicktodial">';
4286 $newphoneaend =
'</a>';
4289 $newphoneastart =
'<a href="'.$url.
'"';
4291 $newphoneastart .=
' target="_blank" rel="noopener noreferrer"';
4293 $newphoneastart .=
'>';
4294 $newphoneaend .=
'</a>';
4299 if (isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
4301 $addlinktoagenda =
'';
4302 if ($addlink ==
'AC_FAX') {
4306 $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>';
4308 if ($addlinktoagenda) {
4309 $newphone =
'<span>'.$newphone.
' '.$addlinktoagenda.
'</span>';
4314 if (
getDolGlobalString(
'CONTACT_PHONEMOBILE_SHOW_LINK_TO_WHATSAPP') && $withpicto ==
'mobile') {
4316 $newphone .=
' <a href="https://wa.me/'.$newphonewa.
'" target="_blank"';
4317 $newphone .=
'><span class="paddingright fab fa-whatsapp" style="color:#25D366;" title="WhatsApp"></span></a>';
4320 if (empty($titlealt)) {
4321 $titlealt = ($withpicto ==
'fax' ? $langs->trans(
"Fax") : $langs->trans(
"Phone"));
4326 $parameters = array(
'countrycode' => $countrycode,
'cid' => $cid,
'socid' => $socid,
'titlealt' => $titlealt,
'picto' => $withpicto);
4327 $reshook = $hookmanager->executeHooks(
'printPhone', $parameters, $phone);
4328 $rep .= $hookmanager->resPrint;
4330 if (empty($reshook)) {
4333 if ($withpicto ==
'fax') {
4334 $picto =
'phoning_fax';
4335 } elseif ($withpicto ==
'phone') {
4337 } elseif ($withpicto ==
'mobile') {
4338 $picto =
'phoning_mobile';
4343 if ($adddivfloat == 1) {
4344 $rep .=
'<div class="nospan float'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">';
4345 } elseif (empty($adddivfloat)) {
4346 $rep .=
'<span'.($morecss ?
' class="'.$morecss.
'"' :
'').
' style="margin-right: 10px;">';
4349 $rep .= $newphoneastart;
4350 $rep .= ($withpicto ?
img_picto($titlealt,
'object_'.$picto.
'.png') :
'');
4351 if ($separ !=
'hidenum') {
4352 $rep .= ($withpicto ?
' ' :
'').$newphone;
4354 $rep .= $newphoneaend;
4356 if ($adddivfloat == 1) {
4358 } elseif (empty($adddivfloat)) {
4386 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/common/flags/'.$countrycode.
'.png')) {
4387 $ret .=
' '.img_picto($countrycode.
' '.$langs->trans(
"AccordingToGeoIPDatabase"), DOL_URL_ROOT.
'/theme/common/flags/'.$countrycode.
'.png',
'', 1);
4389 $ret .=
' ('.$countrycode.
')';
4409 if (empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
4410 if (empty($_SERVER[
'HTTP_CLIENT_IP']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_CLIENT_IP'])) {
4411 if (empty($_SERVER[
"HTTP_CF_CONNECTING_IP"])) {
4412 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
4414 $ip = $_SERVER[
"HTTP_CF_CONNECTING_IP"];
4417 $ip = $_SERVER[
'HTTP_CLIENT_IP'];
4420 $ip = $_SERVER[
'HTTP_X_FORWARDED_FOR'];
4436 if (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on') {
4438 } 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') {
4456 if (!empty($conf->geoipmaxmind->enabled)) {
4460 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4461 $geoip =
new DolGeoIP(
'country', $datafile);
4463 $countrycode = $geoip->getCountryCodeFromIP($ip);
4466 return $countrycode;
4478 global $conf, $langs, $user;
4482 if (!empty($conf->geoipmaxmind->enabled)) {
4487 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4488 $geoip =
new DolGeoIP(
'country', $datafile);
4489 $countrycode = $geoip->getCountryCodeFromIP($ip);
4490 $ret = $countrycode;
4507function dol_print_address($address, $htmlid, $element, $id, $noprint = 0, $charfornl =
'')
4509 global $conf, $user, $langs, $hookmanager;
4515 $parameters = array(
'element' => $element,
'id' => $id);
4516 $reshook = $hookmanager->executeHooks(
'printAddress', $parameters, $address);
4517 $out .= $hookmanager->resPrint;
4519 if (empty($reshook)) {
4520 if (empty($charfornl)) {
4521 $out .= nl2br($address);
4523 $out .= preg_replace(
'/[\r\n]+/', $charfornl, $address);
4527 $showgmap = $showomap = 0;
4528 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS')) {
4531 if ($element ==
'contact' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_CONTACTS')) {
4534 if ($element ==
'member' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_MEMBERS')) {
4537 if ($element ==
'user' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_USERS')) {
4540 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS')) {
4543 if ($element ==
'contact' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_CONTACTS')) {
4546 if ($element ==
'member' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_MEMBERS')) {
4549 if ($element ==
'user' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_USERS')) {
4553 $url =
dol_buildpath(
'/google/gmaps.php?mode='.$element.
'&id='.$id, 1);
4554 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4557 $url =
dol_buildpath(
'/openstreetmap/maps.php?mode='.$element.
'&id='.$id, 1);
4558 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4579function isValidEmail($address, $acceptsupervisorkey = 0, $acceptuserkey = 0)
4581 if ($acceptsupervisorkey && $address ==
'__SUPERVISOREMAIL__') {
4584 if ($acceptuserkey && $address ==
'__USER_EMAIL__') {
4587 if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
4605 if (function_exists(
'idn_to_ascii') && function_exists(
'checkdnsrr')) {
4606 if (!checkdnsrr(idn_to_ascii($domain),
'MX')) {
4609 if (function_exists(
'getmxrr')) {
4612 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
4613 if (count($mxhosts) > 1) {
4616 if (count($mxhosts) == 1 && !in_array((
string) $mxhosts[0], array(
'',
'.'))) {
4653 $tmparray = explode(
' ', $s);
4654 foreach ($tmparray as $tmps) {
4669function dol_strlen($string, $stringencoding =
'UTF-8')
4671 if (is_null($string)) {
4675 if (function_exists(
'mb_strlen')) {
4676 return mb_strlen($string, $stringencoding);
4678 return strlen($string);
4692function dol_substr($string, $start, $length =
null, $stringencoding =
'', $trunconbytes = 0)
4696 if (empty($stringencoding)) {
4697 $stringencoding = (empty($langs) ?
'UTF-8' : $langs->charset_output);
4701 if (empty($trunconbytes)) {
4702 if (function_exists(
'mb_substr')) {
4703 $ret = mb_substr($string, $start, $length, $stringencoding);
4705 $ret = substr($string, $start, $length);
4708 if (function_exists(
'mb_strcut')) {
4709 $ret = mb_strcut($string, $start, $length, $stringencoding);
4711 $ret = substr($string, $start, $length);
4731function dol_trunc($string, $size = 40, $trunc =
'right', $stringencoding =
'UTF-8', $nodot = 0, $display = 0)
4739 if (empty($stringencoding)) {
4740 $stringencoding =
'UTF-8';
4743 if (!empty($conf->dol_optimize_smallscreen) && $conf->dol_optimize_smallscreen == 1 && $display == 1) {
4744 $size = round($size / 3);
4748 if ($trunc ==
'right') {
4750 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
4752 return dol_substr($newstring, 0, $size, $stringencoding).($nodot ?
'' :
'…');
4757 } elseif ($trunc ==
'middle') {
4759 if (
dol_strlen($newstring, $stringencoding) > 2 &&
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4760 $size1 = round($size / 2);
4761 $size2 = round($size / 2);
4762 return dol_substr($newstring, 0, $size1, $stringencoding).
'…'.
dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
4766 } elseif ($trunc ==
'left') {
4768 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
4770 return '…'.dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
4774 } elseif ($trunc ==
'wrap') {
4776 if (
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4782 return 'BadParam3CallingDolTrunc';
4796 $type2picto = array(
4797 'varchar' =>
'font',
4800 'int' =>
'sort-numeric-down',
4801 'double' =>
'sort-numeric-down',
4802 'price' =>
'currency',
4803 'pricecy' =>
'multicurrency',
4804 'password' =>
'key',
4805 'boolean' =>
'check-square',
4806 'date' =>
'calendar',
4807 'datetime' =>
'calendar',
4813 'sellist' =>
'list',
4814 'radio' =>
'check-circle',
4815 'checkbox' =>
'list',
4816 'chkbxlst' =>
'list',
4818 'icon' =>
"question",
4819 'point' =>
"country",
4820 'multipts' =>
'country',
4821 'linestrg' =>
"country",
4822 'polygon' =>
"country",
4823 'separate' =>
'minus'
4826 if (!empty($type2picto[$key])) {
4827 return img_picto(
'', $type2picto[$key],
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
4830 return img_picto(
'',
'generic',
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
4855function img_picto($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0, $alt =
'', $morecss =
'', $marginleftonlyshort = 2)
4860 $url = DOL_URL_ROOT;
4861 $theme = isset($conf->theme) ? $conf->theme :
null;
4862 $path =
'theme/'.$theme;
4863 if (empty($picto)) {
4868 if ($pictoisfullpath) {
4870 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
4873 $fullpathpicto = $picto;
4875 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4876 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4877 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4880 $pictowithouttext = preg_replace(
'/(\.png|\.gif|\.svg)$/',
'', (is_null($picto) ?
'' : $picto));
4881 $pictowithouttext = str_replace(
'object_',
'', $pictowithouttext);
4882 $pictowithouttext = str_replace(
'_nocolor',
'', $pictowithouttext);
4884 if (strpos($pictowithouttext,
'fontawesome_') === 0 || strpos($pictowithouttext,
'fa-') === 0) {
4886 $pictowithouttext = str_replace(
'fontawesome_',
'', $pictowithouttext);
4887 $pictowithouttext = str_replace(
'fa-',
'', $pictowithouttext);
4890 if ($pictowithouttext ==
'file-o') {
4891 $pictowithouttext =
'file';
4894 $pictowithouttextarray = explode(
'_', $pictowithouttext);
4895 $marginleftonlyshort = 0;
4897 if (!empty($pictowithouttextarray[1])) {
4899 $fakey =
'fa-'.$pictowithouttextarray[0];
4900 $faprefix = empty($pictowithouttextarray[1]) ?
'fas' : $pictowithouttextarray[1];
4901 $facolor = empty($pictowithouttextarray[2]) ?
'' : $pictowithouttextarray[2];
4902 $fasize = empty($pictowithouttextarray[3]) ?
'' : $pictowithouttextarray[3];
4904 $fakey =
'fa-'.$pictowithouttext;
4914 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4915 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4916 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4918 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
4919 $morestyle = $reg[1];
4920 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
4922 $moreatt = trim($moreatt);
4924 $enabledisablehtml =
'<span class="'.$faprefix.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
4925 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
4929 $enabledisablehtml .=
'</span>';
4931 return $enabledisablehtml;
4934 if (empty($srconly) && in_array($pictowithouttext, array(
4935 '1downarrow',
'1uparrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected',
4936 'accountancy',
'accounting_account',
'account',
'accountline',
'action',
'add',
'address',
'ai',
'angle-double-down',
'angle-double-up',
'asset',
4937 'bank_account',
'barcode',
'bank',
'bell',
'bill',
'billa',
'billr',
'billd',
'birthday-cake',
'bom',
'bookcal',
'bookmark',
'briefcase-medical',
'bug',
'building',
4938 'card',
'calendarlist',
'calendar',
'calendarmonth',
'calendarweek',
'calendarday',
'calendarperuser',
'calendarpertype',
4939 'cash-register',
'category',
'chart',
'check',
'clock',
'clone',
'close_title',
'code',
'cog',
'collab',
'company',
'contact',
'country',
'contract',
'conversation',
'cron',
'cross',
'cubes',
4940 'check-circle',
'check-square',
'circle',
'stop-circle',
'currency',
'multicurrency',
4941 'chevron-left',
'chevron-right',
'chevron-down',
'chevron-top',
4942 'chevron-double-left',
'chevron-double-right',
'chevron-double-down',
'chevron-double-top',
4943 'commercial',
'companies',
4944 'delete',
'dolly',
'dollyrevert',
'donation',
'download',
'dynamicprice',
4945 'edit',
'ellipsis-h',
'email',
'entity',
'envelope',
'eraser',
'establishment',
'expensereport',
'external-link-alt',
'external-link-square-alt',
'eye',
4946 'filter',
'file',
'file-o',
'file-code',
'file-export',
'file-import',
'file-upload',
'autofill',
'folder',
'folder-open',
'folder-plus',
'font',
4947 'gears',
'generate',
'generic',
'globe',
'globe-americas',
'graph',
'grip',
'grip_title',
'group',
4948 'hands-helping',
'help',
'holiday',
4949 'id-card',
'images',
'incoterm',
'info',
'intervention',
'inventory',
'intracommreport',
'jobprofile',
4950 'key',
'knowledgemanagement',
4951 'label',
'language',
'layout',
'line',
'link',
'list',
'list-alt',
'listlight',
'loan',
'lock',
'lot',
'long-arrow-alt-right',
4952 'margin',
'map-marker-alt',
'member',
'meeting',
'minus',
'money-bill-alt',
'movement',
'mrp',
'note',
'next',
4953 'off',
'on',
'order',
4954 'paiment',
'paragraph',
'play',
'pdf',
'phone',
'phoning',
'phoning_mobile',
'phoning_fax',
'playdisabled',
'previous',
'poll',
'pos',
'printer',
'product',
'propal',
'proposal',
'puce',
4955 'stock',
'resize',
'service',
'stats',
4956 'security',
'setup',
'share-alt',
'sign-out',
'split',
'stripe',
'stripe-s',
'switch_off',
'switch_on',
'switch_on_warning',
'switch_on_red',
'tools',
'unlink',
'uparrow',
'user',
'user-tie',
'vcard',
'wrench',
4957 'github',
'google',
'jabber',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'youtube',
'google-plus-g',
'whatsapp',
4958 'generic',
'home',
'hrm',
'members',
'products',
'invoicing',
4959 'partnership',
'payment',
'payment_vat',
'pencil-ruler',
'pictoconfirm',
'preview',
'project',
'projectpub',
'projecttask',
'question',
'refresh',
'region',
4960 'salary',
'shipment',
'state',
'supplier_invoice',
'supplier_invoicea',
'supplier_invoicer',
'supplier_invoiced',
4961 'technic',
'ticket',
4963 'recent',
'reception',
'recruitmentcandidature',
'recruitmentjobposition',
'replacement',
'resource',
'recurring',
'rss',
4964 'shapes',
'skill',
'square',
'sort-numeric-down',
'status',
'stop-circle',
'supplier',
'supplier_proposal',
'supplier_order',
'supplier_invoice',
4965 'terminal',
'tick',
'timespent',
'title_setup',
'title_accountancy',
'title_bank',
'title_hrm',
'title_agenda',
'trip',
4966 'uncheck',
'url',
'user-cog',
'user-injured',
'user-md',
'vat',
'website',
'workstation',
'webhook',
'world',
'private',
4967 'conferenceorbooth',
'eventorganization',
4968 'stamp',
'signature',
4971 $fakey = $pictowithouttext;
4975 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'))) {
4978 if (in_array($pictowithouttext, array(
'black-tie',
'github',
'google',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'stripe',
'stripe-s',
'youtube',
'google-plus-g',
'whatsapp'))) {
4982 $arrayconvpictotofa = array(
4983 'account' =>
'university',
'accounting_account' =>
'clipboard-list',
'accountline' =>
'receipt',
'accountancy' =>
'search-dollar',
'action' =>
'calendar-alt',
'add' =>
'plus-circle',
'address' =>
'address-book',
'ai' =>
'magic',
4984 'asset' =>
'money-check-alt',
'autofill' =>
'fill',
4985 'bank_account' =>
'university',
4986 'bill' =>
'file-invoice-dollar',
'billa' =>
'file-excel',
'billr' =>
'file-invoice-dollar',
'billd' =>
'file-medical',
4987 'bookcal' =>
'calendar-check',
4988 'supplier_invoice' =>
'file-invoice-dollar',
'supplier_invoicea' =>
'file-excel',
'supplier_invoicer' =>
'file-invoice-dollar',
'supplier_invoiced' =>
'file-medical',
4990 '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',
4991 'chevron-double-left' =>
'angle-double-left',
'chevron-double-right' =>
'angle-double-right',
'chevron-double-down' =>
'angle-double-down',
'chevron-double-top' =>
'angle-double-up',
4992 'donation' =>
'file-alt',
'dynamicprice' =>
'hand-holding-usd',
4993 'setup' =>
'cog',
'companies' =>
'building',
'products' =>
'cube',
'commercial' =>
'suitcase',
'invoicing' =>
'coins',
4994 'accounting' =>
'search-dollar',
'category' =>
'tag',
'dollyrevert' =>
'dolly',
4995 'file-o' =>
'file',
'generate' =>
'plus-square',
'hrm' =>
'user-tie',
'incoterm' =>
'truck-loading',
4996 'margin' =>
'calculator',
'members' =>
'user-friends',
'ticket' =>
'ticket-alt',
'globe' =>
'external-link-alt',
'lot' =>
'barcode',
4997 'email' =>
'at',
'establishment' =>
'building',
'edit' =>
'pencil-alt',
'entity' =>
'globe',
4998 'graph' =>
'chart-line',
'grip_title' =>
'arrows-alt',
'grip' =>
'arrows-alt',
'help' =>
'question-circle',
4999 'generic' =>
'file',
'holiday' =>
'umbrella-beach',
5000 'info' =>
'info-circle',
'inventory' =>
'boxes',
'intracommreport' =>
'globe-europe',
'jobprofile' =>
'cogs',
5001 'knowledgemanagement' =>
'ticket-alt',
'label' =>
'layer-group',
'layout' =>
'columns',
'line' =>
'bars',
'loan' =>
'money-bill-alt',
5002 'member' =>
'user-alt',
'meeting' =>
'chalkboard-teacher',
'mrp' =>
'cubes',
'next' =>
'arrow-alt-circle-right',
5003 'trip' =>
'wallet',
'expensereport' =>
'wallet',
'group' =>
'users',
'movement' =>
'people-carry',
5004 'sign-out' =>
'sign-out-alt',
5005 'switch_off' =>
'toggle-off',
'switch_on' =>
'toggle-on',
'switch_on_warning' =>
'toggle-on',
'switch_on_red' =>
'toggle-on',
'check' =>
'check',
'bookmark' =>
'star',
5006 'bank' =>
'university',
'close_title' =>
'times',
'delete' =>
'trash',
'filter' =>
'filter',
5007 'list-alt' =>
'list-alt',
'calendarlist' =>
'bars',
'calendar' =>
'calendar-alt',
'calendarmonth' =>
'calendar-alt',
'calendarweek' =>
'calendar-week',
'calendarday' =>
'calendar-day',
'calendarperuser' =>
'table',
5008 'intervention' =>
'ambulance',
'invoice' =>
'file-invoice-dollar',
'order' =>
'file-invoice',
5009 'error' =>
'exclamation-triangle',
'warning' =>
'exclamation-triangle',
5010 'other' =>
'square',
5011 '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',
5012 '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',
5013 'recent' =>
'check-square',
'reception' =>
'dolly',
'recruitmentjobposition' =>
'id-card-alt',
'recruitmentcandidature' =>
'id-badge',
5014 'resize' =>
'crop',
'supplier_order' =>
'dol-order_supplier',
'supplier_proposal' =>
'file-signature',
5015 'refresh' =>
'redo',
'region' =>
'map-marked',
'replacement' =>
'exchange-alt',
'resource' =>
'laptop-house',
'recurring' =>
'history',
5016 'service' =>
'concierge-bell',
5017 'skill' =>
'shapes',
'state' =>
'map-marked-alt',
'security' =>
'key',
'salary' =>
'wallet',
'shipment' =>
'dolly',
'stock' =>
'box-open',
'stats' =>
'chart-bar',
'split' =>
'code-branch',
5018 'status' =>
'stop-circle',
5019 'stripe' =>
'stripe-s',
'supplier' =>
'building',
5020 'technic' =>
'cogs',
'tick' =>
'check',
'timespent' =>
'clock',
'title_setup' =>
'tools',
'title_accountancy' =>
'money-check-alt',
'title_bank' =>
'university',
'title_hrm' =>
'umbrella-beach',
5021 'title_agenda' =>
'calendar-alt',
5022 'uncheck' =>
'times',
'uparrow' =>
'share',
'url' =>
'external-link-alt',
'vat' =>
'money-check-alt',
'vcard' =>
'arrow-alt-circle-down',
5023 'jabber' =>
'comment-o',
5024 'website' =>
'globe-americas',
'workstation' =>
'pallet',
'webhook' =>
'bullseye',
'world' =>
'globe',
'private' =>
'user-lock',
5025 'conferenceorbooth' =>
'chalkboard-teacher',
'eventorganization' =>
'project-diagram',
5026 'webportal' =>
'door-open'
5028 if ($conf->currency ==
'EUR') {
5029 $arrayconvpictotofa[
'currency'] =
'euro-sign';
5030 $arrayconvpictotofa[
'multicurrency'] =
'dollar-sign';
5032 $arrayconvpictotofa[
'currency'] =
'dollar-sign';
5033 $arrayconvpictotofa[
'multicurrency'] =
'euro-sign';
5035 if ($pictowithouttext ==
'off') {
5036 $fakey =
'fa-square';
5038 } elseif ($pictowithouttext ==
'on') {
5039 $fakey =
'fa-check-square';
5041 } elseif ($pictowithouttext ==
'listlight') {
5042 $fakey =
'fa-download';
5043 $marginleftonlyshort = 1;
5044 } elseif ($pictowithouttext ==
'printer') {
5045 $fakey =
'fa-print';
5047 } elseif ($pictowithouttext ==
'note') {
5048 $fakey =
'fa-sticky-note';
5049 $marginleftonlyshort = 1;
5050 } elseif (in_array($pictowithouttext, array(
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'))) {
5051 $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');
5052 $fakey =
'fa-'.$convertarray[$pictowithouttext];
5053 if (preg_match(
'/selected/', $pictowithouttext)) {
5056 $marginleftonlyshort = 1;
5057 } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) {
5058 $fakey =
'fa-'.$arrayconvpictotofa[$pictowithouttext];
5060 $fakey =
'fa-'.$pictowithouttext;
5063 if (in_array($pictowithouttext, array(
'dollyrevert',
'member',
'members',
'contract',
'group',
'resource',
'shipment',
'reception'))) {
5064 $morecss .=
' em092';
5066 if (in_array($pictowithouttext, array(
'conferenceorbooth',
'collab',
'eventorganization',
'holiday',
'info',
'project',
'workstation'))) {
5067 $morecss .=
' em088';
5069 if (in_array($pictowithouttext, array(
'asset',
'intervention',
'payment',
'loan',
'partnership',
'stock',
'technic'))) {
5070 $morecss .=
' em080';
5074 $arrayconvpictotomarginleftonly = array(
5075 'bank',
'check',
'delete',
'generic',
'grip',
'grip_title',
'jabber',
5076 'grip_title',
'grip',
'listlight',
'note',
'on',
'off',
'playdisabled',
'printer',
'resize',
'sign-out',
'stats',
'switch_on',
'switch_on_red',
'switch_off',
5077 'uparrow',
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'
5079 if (!isset($arrayconvpictotomarginleftonly[$pictowithouttext])) {
5080 $marginleftonlyshort = 0;
5084 $arrayconvpictotomorcess = array(
5085 'action' =>
'infobox-action',
'account' =>
'infobox-bank_account',
'accounting_account' =>
'infobox-bank_account',
'accountline' =>
'infobox-bank_account',
'accountancy' =>
'infobox-bank_account',
'asset' =>
'infobox-bank_account',
5086 'bank_account' =>
'infobox-bank_account',
5087 'bill' =>
'infobox-commande',
'billa' =>
'infobox-commande',
'billr' =>
'infobox-commande',
'billd' =>
'infobox-commande',
5088 'bookcal' =>
'infobox-action',
5089 'margin' =>
'infobox-bank_account',
'conferenceorbooth' =>
'infobox-project',
5090 'cash-register' =>
'infobox-bank_account',
'contract' =>
'infobox-contrat',
'check' =>
'font-status4',
'collab' =>
'infobox-action',
'conversation' =>
'infobox-contrat',
5091 'donation' =>
'infobox-commande',
'dolly' =>
'infobox-commande',
'dollyrevert' =>
'flip infobox-order_supplier',
5092 'ecm' =>
'infobox-action',
'eventorganization' =>
'infobox-project',
5093 'hrm' =>
'infobox-adherent',
'group' =>
'infobox-adherent',
'intervention' =>
'infobox-contrat',
5094 'incoterm' =>
'infobox-supplier_proposal',
5095 'currency' =>
'infobox-bank_account',
'multicurrency' =>
'infobox-bank_account',
5096 'members' =>
'infobox-adherent',
'member' =>
'infobox-adherent',
'money-bill-alt' =>
'infobox-bank_account',
5097 'order' =>
'infobox-commande',
5098 'user' =>
'infobox-adherent',
'users' =>
'infobox-adherent',
5099 'error' =>
'pictoerror',
'warning' =>
'pictowarning',
'switch_on' =>
'font-status4',
'switch_on_warning' =>
'font-status4 warning',
'switch_on_red' =>
'font-status8',
5100 'holiday' =>
'infobox-holiday',
'info' =>
'opacityhigh',
'invoice' =>
'infobox-commande',
5101 'knowledgemanagement' =>
'infobox-contrat rotate90',
'loan' =>
'infobox-bank_account',
5102 'payment' =>
'infobox-bank_account',
'payment_vat' =>
'infobox-bank_account',
'poll' =>
'infobox-adherent',
'pos' =>
'infobox-bank_account',
'project' =>
'infobox-project',
'projecttask' =>
'infobox-project',
5103 'propal' =>
'infobox-propal',
'proposal' =>
'infobox-propal',
'private' =>
'infobox-project',
5104 'reception' =>
'flip infobox-order_supplier',
'recruitmentjobposition' =>
'infobox-adherent',
'recruitmentcandidature' =>
'infobox-adherent',
5105 'resource' =>
'infobox-action',
5106 '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',
5107 'supplier' =>
'infobox-order_supplier',
'supplier_order' =>
'infobox-order_supplier',
'supplier_proposal' =>
'infobox-supplier_proposal',
5108 'ticket' =>
'infobox-contrat',
'title_accountancy' =>
'infobox-bank_account',
'title_hrm' =>
'infobox-holiday',
'expensereport' =>
'infobox-expensereport',
'trip' =>
'infobox-expensereport',
'title_agenda' =>
'infobox-action',
5109 'vat' =>
'infobox-bank_account',
5111 'list-alt' =>
'imgforviewmode',
'calendar' =>
'imgforviewmode',
'calendarweek' =>
'imgforviewmode',
'calendarmonth' =>
'imgforviewmode',
'calendarday' =>
'imgforviewmode',
'calendarperuser' =>
'imgforviewmode'
5113 if (!empty($arrayconvpictotomorcess[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5114 $morecss .= ($morecss ?
' ' :
'').$arrayconvpictotomorcess[$pictowithouttext];
5118 $arrayconvpictotocolor = array(
5119 'address' =>
'#6c6aa8',
'building' =>
'#6c6aa8',
'bom' =>
'#a69944',
5120 'clone' =>
'#999',
'cog' =>
'#999',
'companies' =>
'#6c6aa8',
'company' =>
'#6c6aa8',
'contact' =>
'#6c6aa8',
'cron' =>
'#555',
5121 'dynamicprice' =>
'#a69944',
5122 'edit' =>
'#444',
'note' =>
'#999',
'error' =>
'',
'help' =>
'#bbb',
'listlight' =>
'#999',
'language' =>
'#555',
5124 'lock' =>
'#ddd',
'lot' =>
'#a69944',
5125 'map-marker-alt' =>
'#aaa',
'mrp' =>
'#a69944',
'product' =>
'#a69944',
'service' =>
'#a69944',
'inventory' =>
'#a69944',
'stock' =>
'#a69944',
'movement' =>
'#a69944',
5126 'other' =>
'#ddd',
'world' =>
'#986c6a',
5127 'partnership' =>
'#6c6aa8',
'playdisabled' =>
'#ccc',
'printer' =>
'#444',
'projectpub' =>
'#986c6a',
'resize' =>
'#444',
'rss' =>
'#cba',
5129 'security' =>
'#999',
'square' =>
'#888',
'stop-circle' =>
'#888',
'stats' =>
'#444',
'switch_off' =>
'#999',
5130 'technic' =>
'#999',
'tick' =>
'#282',
'timespent' =>
'#555',
5131 'uncheck' =>
'#800',
'uparrow' =>
'#555',
'user-cog' =>
'#999',
'country' =>
'#aaa',
'globe-americas' =>
'#aaa',
'region' =>
'#aaa',
'state' =>
'#aaa',
5132 'website' =>
'#304',
'workstation' =>
'#a69944'
5134 if (isset($arrayconvpictotocolor[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5135 $facolor = $arrayconvpictotocolor[$pictowithouttext];
5142 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5143 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5144 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5146 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
5147 $morestyle = $reg[1];
5148 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
5150 $moreatt = trim($moreatt);
5152 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
5153 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
5157 $enabledisablehtml .=
'</span>';
5159 return $enabledisablehtml;
5166 } elseif (!empty($conf->modules_parts[
'theme']) && array_key_exists($theme, $conf->modules_parts[
'theme'])) {
5167 $path = $theme.
'/theme/'.$theme;
5172 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
5178 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
5183 foreach ($conf->file->dol_document_root as $type => $dirroot) {
5184 if ($type ==
'main') {
5188 if (file_exists($dirroot.
'/'.$path.
'/img/'.$picto)) {
5189 $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type];
5195 $fullpathpicto = $url.
'/'.$path.
'/img/'.$picto;
5199 return $fullpathpicto;
5203 return '<img src="'.$fullpathpicto.
'"'.($notitle ?
'' :
' alt="'.dol_escape_htmltag($alt).
'"').(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt.($morecss ?
' class="'.$morecss.
'"' :
'') :
' class="inline-block'.($morecss ?
' '.$morecss :
'').
'"').
'>';
5219function img_object($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0)
5221 if (strpos($picto,
'^') === 0) {
5222 return img_picto($titlealt, str_replace(
'^',
'', $picto), $moreatt, $pictoisfullpath, $srconly, $notitle);
5224 return img_picto($titlealt,
'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
5239function img_weather($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $morecss =
'')
5243 if (is_numeric($picto)) {
5246 return '<i class="fa fa-weather-level'.$picto.
'"></i>';
5247 } elseif (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5251 $path = DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/weather/'.$picto;
5253 return img_picto($titlealt, $path, $moreatt, 1, 0, 0,
'', $morecss);
5267function img_picto_common($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $notitle = 0)
5271 if (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5275 if ($pictoisfullpath) {
5278 $path = DOL_URL_ROOT.
'/theme/common/'.$picto;
5281 $themepath = DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/img/'.$picto;
5283 if (file_exists($themepath)) {
5289 return img_picto($titlealt, $path, $moreatt, 1, 0, $notitle);
5305function img_action($titlealt, $numaction, $picto =
'', $moreatt =
'')
5309 if (empty($titlealt) || $titlealt ==
'default') {
5310 if ($numaction ==
'-1' || $numaction ==
'ST_NO') {
5312 $titlealt = $langs->transnoentitiesnoconv(
'ChangeDoNotContact');
5313 } elseif ($numaction ==
'0' || $numaction ==
'ST_NEVER') {
5315 $titlealt = $langs->transnoentitiesnoconv(
'ChangeNeverContacted');
5316 } elseif ($numaction ==
'1' || $numaction ==
'ST_TODO') {
5318 $titlealt = $langs->transnoentitiesnoconv(
'ChangeToContact');
5319 } elseif ($numaction ==
'2' || $numaction ==
'ST_PEND') {
5321 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactInProcess');
5322 } elseif ($numaction ==
'3' || $numaction ==
'ST_DONE') {
5324 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactDone');
5326 $titlealt = $langs->transnoentitiesnoconv(
'ChangeStatus '.$numaction);
5330 if (!is_numeric($numaction)) {
5334 return img_picto($titlealt, (empty($picto) ?
'stcomm'.$numaction.
'.png' : $picto), $moreatt);
5344function img_pdf($titlealt =
'default', $size = 3)
5348 if ($titlealt ==
'default') {
5349 $titlealt = $langs->trans(
'Show');
5352 return img_picto($titlealt,
'pdf'.$size.
'.png');
5362function img_edit_add($titlealt =
'default', $other =
'')
5366 if ($titlealt ==
'default') {
5367 $titlealt = $langs->trans(
'Add');
5370 return img_picto($titlealt,
'edit_add.png', $other);
5383 if ($titlealt ==
'default') {
5384 $titlealt = $langs->trans(
'Remove');
5387 return img_picto($titlealt,
'edit_remove.png', $other);
5398function img_edit($titlealt =
'default', $float = 0, $other =
'')
5402 if ($titlealt ==
'default') {
5403 $titlealt = $langs->trans(
'Modify');
5406 return img_picto($titlealt,
'edit.png', ($float ?
'style="float: '.($langs->tab_translate[
"DIRECTION"] ==
'rtl' ?
'left' :
'right').
'"' :
"").($other ?
' '.$other :
''));
5417function img_view($titlealt =
'default', $float = 0, $other =
'class="valignmiddle"')
5421 if ($titlealt ==
'default') {
5422 $titlealt = $langs->trans(
'View');
5425 $moreatt = ($float ?
'style="float: right" ' :
'').$other;
5427 return img_picto($titlealt,
'eye', $moreatt);
5438function img_delete($titlealt =
'default', $other =
'class="pictodelete"', $morecss =
'')
5442 if ($titlealt ==
'default') {
5443 $titlealt = $langs->trans(
'Delete');
5446 return img_picto($titlealt,
'delete.png', $other, 0, 0, 0,
'', $morecss);
5456function img_printer($titlealt =
"default", $other =
'')
5459 if ($titlealt ==
"default") {
5460 $titlealt = $langs->trans(
"Print");
5462 return img_picto($titlealt,
'printer.png', $other);
5472function img_split($titlealt =
'default', $other =
'class="pictosplit"')
5476 if ($titlealt ==
'default') {
5477 $titlealt = $langs->trans(
'Split');
5480 return img_picto($titlealt,
'split.png', $other);
5490function img_help($usehelpcursor = 1, $usealttitle = 1)
5495 if (is_string($usealttitle)) {
5498 $usealttitle = $langs->trans(
'Info');
5502 return img_picto($usealttitle,
'info.png',
'style="vertical-align: middle;'.($usehelpcursor == 1 ?
' cursor: help' : ($usehelpcursor == 2 ?
' cursor: pointer' :
'')).
'"');
5511function img_info($titlealt =
'default')
5515 if ($titlealt ==
'default') {
5516 $titlealt = $langs->trans(
'Informations');
5519 return img_picto($titlealt,
'info.png',
'style="vertical-align: middle;"');
5530function img_warning($titlealt =
'default', $moreatt =
'', $morecss =
'pictowarning')
5534 if ($titlealt ==
'default') {
5535 $titlealt = $langs->trans(
'Warning');
5539 return img_picto($titlealt,
'warning.png',
'class="'.$morecss.
'"'.($moreatt ? ($moreatt ==
'1' ?
' style="float: right"' :
' '.$moreatt) :
''));
5548function img_error($titlealt =
'default')
5552 if ($titlealt ==
'default') {
5553 $titlealt = $langs->trans(
'Error');
5556 return img_picto($titlealt,
'error.png');
5566function img_next($titlealt =
'default', $moreatt =
'')
5570 if ($titlealt ==
'default') {
5571 $titlealt = $langs->trans(
'Next');
5575 return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
5585function img_previous($titlealt =
'default', $moreatt =
'')
5589 if ($titlealt ==
'default') {
5590 $titlealt = $langs->trans(
'Previous');
5594 return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
5605function img_down($titlealt =
'default', $selected = 0, $moreclass =
'')
5609 if ($titlealt ==
'default') {
5610 $titlealt = $langs->trans(
'Down');
5613 return img_picto($titlealt, ($selected ?
'1downarrow_selected.png' :
'1downarrow.png'),
'class="imgdown'.($moreclass ?
" ".$moreclass :
"").
'"');
5624function img_up($titlealt =
'default', $selected = 0, $moreclass =
'')
5628 if ($titlealt ==
'default') {
5629 $titlealt = $langs->trans(
'Up');
5632 return img_picto($titlealt, ($selected ?
'1uparrow_selected.png' :
'1uparrow.png'),
'class="imgup'.($moreclass ?
" ".$moreclass :
"").
'"');
5643function img_left($titlealt =
'default', $selected = 0, $moreatt =
'')
5647 if ($titlealt ==
'default') {
5648 $titlealt = $langs->trans(
'Left');
5651 return img_picto($titlealt, ($selected ?
'1leftarrow_selected.png' :
'1leftarrow.png'), $moreatt);
5662function img_right($titlealt =
'default', $selected = 0, $moreatt =
'')
5666 if ($titlealt ==
'default') {
5667 $titlealt = $langs->trans(
'Right');
5670 return img_picto($titlealt, ($selected ?
'1rightarrow_selected.png' :
'1rightarrow.png'), $moreatt);
5680function img_allow($allow, $titlealt =
'default')
5684 if ($titlealt ==
'default') {
5685 $titlealt = $langs->trans(
'Active');
5689 return img_picto($titlealt,
'tick.png');
5704 if (is_null($morecss)) {
5708 if ($brand ==
'visa' || $brand ==
'Visa') {
5710 } elseif ($brand ==
'mastercard' || $brand ==
'MasterCard') {
5711 $brand =
'cc-mastercard';
5712 } elseif ($brand ==
'amex' || $brand ==
'American Express') {
5714 } elseif ($brand ==
'discover' || $brand ==
'Discover') {
5715 $brand =
'cc-discover';
5716 } elseif ($brand ==
'jcb' || $brand ==
'JCB') {
5718 } elseif ($brand ==
'diners' || $brand ==
'Diners club') {
5719 $brand =
'cc-diners-club';
5720 } elseif (!in_array($brand, array(
'cc-visa',
'cc-mastercard',
'cc-amex',
'cc-discover',
'cc-jcb',
'cc-diners-club'))) {
5721 $brand =
'credit-card';
5724 return '<span class="fa fa-'.$brand.
' fa-fw'.($morecss ?
' '.$morecss :
'').
'"></span>';
5735function img_mime($file, $titlealt =
'', $morecss =
'')
5737 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
5743 if (empty($titlealt)) {
5744 $titlealt =
'Mime type: '.$mimetype;
5748 return '<i class="fa fa-'.$mimefa.
' paddingright'.($morecss ?
' '.$morecss :
'').
'"'.($titlealt ?
' title="'.$titlealt.
'"' :
'').
'></i>';
5759function img_search($titlealt =
'default', $other =
'')
5763 if ($titlealt ==
'default') {
5764 $titlealt = $langs->trans(
'Search');
5767 $img =
img_picto($titlealt,
'search.png', $other, 0, 1);
5769 $input =
'<input type="image" class="liste_titre" name="button_search" src="'.$img.
'" ';
5770 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
5786 if ($titlealt ==
'default') {
5787 $titlealt = $langs->trans(
'Search');
5790 $img =
img_picto($titlealt,
'searchclear.png', $other, 0, 1);
5792 $input =
'<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.
'" ';
5793 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
5810function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin =
'1', $morecss =
'hideonsmartphone', $textfordropdown =
'', $picto =
'')
5812 global $conf, $langs;
5814 if ($infoonimgalt) {
5815 $result =
img_picto($text,
'info',
'class="'.($morecss ?
' '.$morecss :
'').
'"');
5817 if (empty($conf->use_javascript_ajax)) {
5818 $textfordropdown =
'';
5821 $class = (empty($admin) ?
'undefined' : ($admin ==
'1' ?
'info' : $admin));
5822 $fa =
'info-circle';
5823 if ($picto ==
'warning') {
5824 $fa =
'exclamation-triangle';
5826 $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> ';
5828 $result .= ($nodiv ?
'' :
'</div>');
5830 if ($textfordropdown) {
5831 $tmpresult =
'<span class="'.$class.
'text opacitymedium cursorpointer">'.$langs->trans($textfordropdown).
' '.
img_picto($langs->trans($textfordropdown),
'1downarrow').
'</span>';
5832 $tmpresult .=
'<script nonce="'.getNonce().
'" type="text/javascript">
5833 jQuery(document).ready(function() {
5834 jQuery(".'.$class.
'text").click(function() {
5835 console.log("toggle text");
5836 jQuery(".'.$class.
'").toggle();
5841 $result = $tmpresult.$result;
5862 global $conf, $langs, $user, $argv;
5863 global $dolibarr_main_prod;
5870 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
5872 $langs->load(
"main");
5876 $langs->loadLangs(array(
'main',
'errors'));
5878 if ($_SERVER[
'DOCUMENT_ROOT']) {
5879 $out .= $langs->trans(
"DolibarrHasDetectedError").
".<br>\n";
5881 $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";
5883 $out .= $langs->trans(
"InformationToHelpDiagnose").
":<br>\n";
5885 $out .=
"<b>".$langs->trans(
"Date").
":</b> ".
dol_print_date(time(),
'dayhourlog').
"<br>\n";
5886 $out .=
"<b>".$langs->trans(
"Dolibarr").
":</b> ".DOL_VERSION.
" - https://www.dolibarr.org<br>\n";
5887 if (isset($conf->global->MAIN_FEATURES_LEVEL)) {
5888 $out .=
"<b>".$langs->trans(
"LevelOfFeature").
":</b> ".
getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
"<br>\n";
5890 if ($user instanceof
User) {
5891 $out .=
"<b>".$langs->trans(
"Login").
":</b> ".$user->login.
"<br>\n";
5893 if (function_exists(
"phpversion")) {
5894 $out .=
"<b>".$langs->trans(
"PHP").
":</b> ".phpversion().
"<br>\n";
5896 $out .=
"<b>".$langs->trans(
"Server").
":</b> ".(isset($_SERVER[
"SERVER_SOFTWARE"]) ?
dol_htmlentities($_SERVER[
"SERVER_SOFTWARE"], ENT_COMPAT) :
'').
"<br>\n";
5897 if (function_exists(
"php_uname")) {
5898 $out .=
"<b>".$langs->trans(
"OS").
":</b> ".php_uname().
"<br>\n";
5900 $out .=
"<b>".$langs->trans(
"UserAgent").
":</b> ".(isset($_SERVER[
"HTTP_USER_AGENT"]) ?
dol_htmlentities($_SERVER[
"HTTP_USER_AGENT"], ENT_COMPAT) :
'').
"<br>\n";
5902 $out .=
"<b>".$langs->trans(
"RequestedUrl").
":</b> ".
dol_htmlentities($_SERVER[
"REQUEST_URI"], ENT_COMPAT).
"<br>\n";
5903 $out .=
"<b>".$langs->trans(
"Referer").
":</b> ".(isset($_SERVER[
"HTTP_REFERER"]) ?
dol_htmlentities($_SERVER[
"HTTP_REFERER"], ENT_COMPAT) :
'').
"<br>\n";
5904 $out .=
"<b>".$langs->trans(
"MenuManager").
":</b> ".(isset($conf->standard_menu) ?
dol_htmlentities($conf->standard_menu, ENT_COMPAT) :
'').
"<br>\n";
5906 $syslog .=
"url=".dol_escape_htmltag($_SERVER[
"REQUEST_URI"]);
5907 $syslog .=
", query_string=".dol_escape_htmltag($_SERVER[
"QUERY_STRING"]);
5909 $out .=
'> '.$langs->transnoentities(
"ErrorInternalErrorDetected").
":\n".$argv[0].
"\n";
5910 $syslog .=
"pid=".dol_getmypid();
5913 if (!empty($conf->modules)) {
5914 $out .=
"<b>".$langs->trans(
"Modules").
":</b> ".implode(
', ', $conf->modules).
"<br>\n";
5917 if (is_object($db)) {
5918 if ($_SERVER[
'DOCUMENT_ROOT']) {
5919 $out .=
"<b>".$langs->trans(
"DatabaseTypeManager").
":</b> ".$db->type.
"<br>\n";
5920 $lastqueryerror = $db->lastqueryerror();
5922 $lastqueryerror =
"SQL error string is not a valid UTF8 string. We can't show it.";
5924 $out .=
"<b>".$langs->trans(
"RequestLastAccessInError").
":</b> ".($lastqueryerror ?
dol_escape_htmltag($lastqueryerror) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5925 $out .=
"<b>".$langs->trans(
"ReturnCodeLastAccessInError").
":</b> ".($db->lasterrno() ?
dol_escape_htmltag($db->lasterrno()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5926 $out .=
"<b>".$langs->trans(
"InformationLastAccessInError").
":</b> ".($db->lasterror() ?
dol_escape_htmltag($db->lasterror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5930 $out .=
'> '.$langs->transnoentities(
"DatabaseTypeManager").
":\n".$db->type.
"\n";
5931 $out .=
'> '.$langs->transnoentities(
"RequestLastAccessInError").
":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5932 $out .=
'> '.$langs->transnoentities(
"ReturnCodeLastAccessInError").
":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5933 $out .=
'> '.$langs->transnoentities(
"InformationLastAccessInError").
":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5935 $syslog .=
", sql=".$db->lastquery();
5936 $syslog .=
", db_error=".$db->lasterror();
5939 if ($error || $errors) {
5941 if (is_array($error) && is_array($errors)) {
5942 $errors = array_merge($error, $errors);
5943 } elseif (is_array($error)) {
5945 } elseif (is_array($errors) && !empty($error)) {
5946 $errors = array_merge(array($error), $errors);
5947 } elseif (!empty($error)) {
5948 $errors = array_merge(array($error), array($errors));
5951 $langs->load(
"errors");
5953 foreach ($errors as $msg) {
5957 if ($_SERVER[
'DOCUMENT_ROOT']) {
5960 $out .=
'> '.$langs->transnoentities(
"Message").
":\n".$msg.
"\n";
5962 $syslog .=
", msg=".$msg;
5965 if (empty($dolibarr_main_prod) && $_SERVER[
'DOCUMENT_ROOT'] && function_exists(
'xdebug_print_function_stack') && function_exists(
'xdebug_call_file')) {
5966 xdebug_print_function_stack();
5967 $out .=
'<b>XDebug information:</b>'.
"<br>\n";
5968 $out .=
'File: '.xdebug_call_file().
"<br>\n";
5969 $out .=
'Line: '.xdebug_call_line().
"<br>\n";
5970 $out .=
'Function: '.xdebug_call_function().
"<br>\n";
5975 if (!headers_sent()) {
5976 if (function_exists(
'top_httphead')) {
5980 http_response_code(202);
5983 if (empty($dolibarr_main_prod)) {
5986 if (empty($langs->defaultlang)) {
5987 $langs->setDefaultLang();
5989 $langs->loadLangs(array(
"main",
"errors"));
5991 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";
5992 print $langs->trans(
"DolibarrHasDetectedError").
'. ';
5993 print $langs->trans(
"YouCanSetOptionDolibarrMainProdToZero");
5994 if (!defined(
"MAIN_CORE_ERROR")) {
5995 define(
"MAIN_CORE_ERROR", 1);
6012function dol_print_error_email($prefixcode, $errormessage =
'', $errormessages = array(), $morecss =
'error', $email =
'')
6016 if (empty($email)) {
6020 $langs->load(
"errors");
6023 print
'<br><div class="center login_main_message"><div class="'.$morecss.
'">';
6024 print $langs->trans(
"ErrorContactEMail", $email, $prefixcode.
'-'.
dol_print_date($now,
'%Y%m%d%H%M%S'));
6025 if ($errormessage) {
6026 print
'<br><br>'.$errormessage;
6028 if (is_array($errormessages) && count($errormessages)) {
6029 foreach ($errormessages as $mesgtoshow) {
6030 print
'<br><br>'.$mesgtoshow;
6033 print
'</div></div>';
6052function print_liste_field_titre($name, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $tooltip =
"", $forcenowrapcolumntitle = 0)
6054 print
getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip, $forcenowrapcolumntitle);
6075function getTitleFieldOfList($name, $thead = 0, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $disablesortlink = 0, $tooltip =
'', $forcenowrapcolumntitle = 0)
6077 global $langs, $form;
6080 if ($moreattrib ==
'class="right"') {
6081 $prefix .=
'right ';
6084 $sortorder = strtoupper($sortorder);
6093 $tmpsortfield = explode(
',', $sortfield);
6094 $sortfield1 = trim($tmpsortfield[0]);
6095 $tmpfield = explode(
',', $field);
6096 $field1 = trim($tmpfield[0]);
6098 if (!
getDolGlobalString(
'MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE') && empty($forcenowrapcolumntitle)) {
6099 $prefix =
'wrapcolumntitle '.$prefix;
6105 $liste_titre =
'liste_titre';
6106 if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace(
"/^[^\.]+\./",
"", $field1))) {
6107 $liste_titre =
'liste_titre_sel';
6110 $tagstart =
'<'.$tag.
' class="'.$prefix.$liste_titre.
'" '.$moreattrib;
6115 if (empty($thead) && $field && empty($disablesortlink)) {
6116 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6117 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6118 $options = preg_replace(
'/&+/i',
'&', $options);
6119 if (!preg_match(
'/^&/', $options)) {
6120 $options =
'&'.$options;
6123 $sortordertouseinlink =
'';
6124 if ($field1 != $sortfield1) {
6125 if (preg_match(
'/^DESC/i', $sortorder)) {
6126 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6128 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6131 if (preg_match(
'/^ASC/i', $sortorder)) {
6132 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6134 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6137 $sortordertouseinlink = preg_replace(
'/,$/',
'', $sortordertouseinlink);
6138 $out .=
'<a class="reposition" href="'.$file.
'?sortfield='.$field.
'&sortorder='.$sortordertouseinlink.
'&begin='.$begin.$options.
'"';
6144 if (preg_match(
'/:\w+$/', $tooltip)) {
6145 $tmptooltip = explode(
':', $tooltip);
6147 $tmptooltip = array($tooltip);
6149 $out .= $form->textwithpicto($langs->trans($name), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.str_replace(
'.',
'_', $field).
'_'.$tmptooltip[1]));
6151 $out .= $langs->trans($name);
6154 if (empty($thead) && $field && empty($disablesortlink)) {
6158 if (empty($thead) && $field) {
6159 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6160 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6161 $options = preg_replace(
'/&+/i',
'&', $options);
6162 if (!preg_match(
'/^&/', $options)) {
6163 $options =
'&'.$options;
6166 if (!$sortorder || ($field1 != $sortfield1)) {
6170 if (preg_match(
'/^DESC/', $sortorder)) {
6173 $sortimg .=
'<span class="nowrap">'.img_up(
"Z-A", 0,
'paddingright').
'</span>';
6175 if (preg_match(
'/^ASC/', $sortorder)) {
6178 $sortimg .=
'<span class="nowrap">'.img_down(
"A-Z", 0,
'paddingright').
'</span>';
6183 $tagend =
'</'.$tag.
'>';
6185 $out = $tagstart.$sortimg.$out.$tagend;
6200 dol_syslog(__FUNCTION__.
" is deprecated", LOG_WARNING);
6202 print
'<div class="titre">'.$title.
'</div>';
6216function print_fiche_titre($title, $mesg =
'', $picto =
'generic', $pictoisfullpath = 0, $id =
'')
6234function load_fiche_titre($title, $morehtmlright =
'', $picto =
'generic', $pictoisfullpath = 0, $id =
'', $morecssontable =
'', $morehtmlcenter =
'')
6238 if ($picto ==
'setup') {
6243 $return .=
'<table '.($id ?
'id="'.$id.
'" ' :
'').
'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ?
' '.$morecssontable :
'').
'">';
6244 $return .=
'<tr class="titre">';
6246 $return .=
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).
'</td>';
6248 $return .=
'<td class="nobordernopadding valignmiddle col-title">';
6249 $return .=
'<div class="titre inline-block">';
6251 $return .=
'</div>';
6254 $return .=
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
6257 $return .=
'<td class="nobordernopadding titre_right wordbreakimp right valignmiddle col-right">'.$morehtmlright.
'</td>';
6259 $return .=
'</tr></table>'.
"\n";
6287function print_barre_liste($title, $page, $file, $options =
'', $sortfield =
'', $sortorder =
'', $morehtmlcenter =
'', $num = -1, $totalnboflines =
'', $picto =
'generic', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limit = -1, $hideselectlimit = 0, $hidenavigation = 0, $pagenavastextinput = 0, $morehtmlrightbeforearrow =
'')
6292 $savtotalnboflines = $totalnboflines;
6293 if (is_numeric($totalnboflines)) {
6294 $totalnboflines = abs($totalnboflines);
6297 $page = (int) $page;
6299 if ($picto ==
'setup') {
6300 $picto =
'title_setup.png';
6302 if (($conf->browser->name ==
'ie') && $picto ==
'generic') {
6303 $picto =
'title.gif';
6306 $limit = $conf->liste_limit;
6309 if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
6317 print
"<!-- Begin title -->\n";
6318 print
'<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ?
' '.$morecss :
'').
'"><tr>';
6322 if ($picto && $title) {
6323 print
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath).
'</td>';
6326 print
'<td class="nobordernopadding valignmiddle col-title">';
6327 print
'<div class="titre inline-block">';
6329 if (!empty($title) && $savtotalnboflines >= 0 && (
string) $savtotalnboflines !=
'') {
6330 print
'<span class="opacitymedium colorblack paddingleft totalnboflines">('.$totalnboflines.
')</span>';
6332 print
'</div></td>';
6335 if ($morehtmlcenter && empty($conf->dol_optimize_smallscreen)) {
6336 print
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
6340 print
'<td class="nobordernopadding valignmiddle right col-right">';
6341 print
'<input type="hidden" name="pageplusoneold" value="'.((int) $page + 1).
'">';
6343 $options .=
"&sortfield=".urlencode($sortfield);
6346 $options .=
"&sortorder=".urlencode($sortorder);
6350 if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
6351 if ($totalnboflines) {
6353 $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 0);
6356 $nbpages = ceil($totalnboflines / $limit);
6360 $cpt = ($page - $maxnbofpage);
6366 if (empty($pagenavastextinput)) {
6367 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page=0'.$options.
'">1</a></li>';
6369 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
6370 } elseif ($cpt == 2) {
6371 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page=1'.$options.
'">2</a></li>';
6377 if ($pagenavastextinput) {
6378 if ($cpt == $page) {
6379 $pagelist .=
'<li class="pagination pageplusone valignmiddle"><input type="text" class="'.($totalnboflines > 100 ?
'width40' :
'width25').
' center pageplusone" name="pageplusone" value="'.($page + 1).
'"></li>';
6383 if ($cpt == $page) {
6384 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
'</span></li>';
6386 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.$cpt.$options.
'">'.($cpt + 1).
'</a></li>';
6390 }
while ($cpt < $nbpages && $cpt <= ($page + $maxnbofpage));
6392 if (empty($pagenavastextinput)) {
6393 if ($cpt < $nbpages) {
6394 if ($cpt < $nbpages - 2) {
6395 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
6396 } elseif ($cpt == $nbpages - 2) {
6397 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.($nbpages - 2).$options.
'">'.($nbpages - 1).
'</a></li>';
6399 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
6403 $pagelist .=
'<li class="pagination paginationlastpage"><a class="reposition" href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
6406 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
"</li>";
6410 if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
6411 print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow, $hidenavigation);
6415 if ($pagenavastextinput) {
6422 print
'</table>'.
"\n";
6425 if ($morehtmlcenter && !empty($conf->dol_optimize_smallscreen)) {
6426 print
'<div class="nobordernopadding marginbottomonly center valignmiddle col-center centpercent">'.$morehtmlcenter.
'</div>';
6429 print
"<!-- End title -->\n\n";
6448function print_fleche_navigation($page, $file, $options =
'', $nextpage = 0, $betweenarrows =
'', $afterarrows =
'', $limit = -1, $totalnboflines = 0, $hideselectlimit = 0, $beforearrows =
'', $hidenavigation = 0)
6450 global $conf, $langs;
6452 print
'<div class="pagination"><ul>';
6453 if ($beforearrows) {
6454 print
'<li class="paginationbeforearrows">';
6455 print $beforearrows;
6459 if (empty($hidenavigation)) {
6460 if ((
int) $limit > 0 && empty($hideselectlimit)) {
6461 $pagesizechoices =
'10:10,15:15,20:20,25:25,50:50,100:100,250:250,500:500,1000:1000';
6462 $pagesizechoices .=
',5000:5000,10000:10000';
6471 print
'<li class="pagination">';
6472 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.
'">';
6473 print
'<datalist id="limitlist">';
6475 print
'<li class="paginationcombolimit valignmiddle">';
6476 print
'<select id="limit" class="flat selectlimit nopadding maxwidth75 center" name="limit" title="'.dol_escape_htmltag($langs->trans(
"MaxNbOfRecordPerPage")).
'">';
6478 $tmpchoice = explode(
',', $pagesizechoices);
6479 $tmpkey = $limit.
':'.$limit;
6480 if (!in_array($tmpkey, $tmpchoice)) {
6481 $tmpchoice[] = $tmpkey;
6483 $tmpkey = $conf->liste_limit.
':'.$conf->liste_limit;
6484 if (!in_array($tmpkey, $tmpchoice)) {
6485 $tmpchoice[] = $tmpkey;
6487 asort($tmpchoice, SORT_NUMERIC);
6488 foreach ($tmpchoice as $val) {
6490 $tmp = explode(
':', $val);
6493 if ($key !=
'' && $val !=
'') {
6494 if ((
int) $key == (
int) $limit) {
6495 $selected =
' selected="selected"';
6497 print
'<option name="'.$key.
'"'.$selected.
'>'.
dol_escape_htmltag($val).
'</option>'.
"\n";
6501 print
'</datalist>';
6504 print
ajax_combobox(
"limit", array(), 0, 0,
'resolve', -1,
'limit');
6508 if ($conf->use_javascript_ajax) {
6509 print
'<!-- JS CODE TO ENABLE select limit to launch submit of page -->
6511 jQuery(document).ready(function () {
6512 jQuery(".selectlimit").change(function() {
6513 console.log("Change limit. Send submit");
6514 $(this).parents(\'form:first\').submit();
6523 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>';
6525 if ($betweenarrows) {
6526 print
'<!--<div class="betweenarrows nowraponall inline-block">-->';
6527 print $betweenarrows;
6528 print
'<!--</div>-->';
6530 if ($nextpage > 0) {
6531 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>';
6534 print
'<li class="paginationafterarrows">';
6539 print
'</ul></div>'.
"\n";
6554function vatrate($rate, $addpercent =
false, $info_bits = 0, $usestarfornpr = 0, $html = 0)
6558 if (preg_match(
'/%/', $rate)) {
6559 $rate = str_replace(
'%',
'', $rate);
6563 if (preg_match(
'/\((.*)\)/', $rate, $reg)) {
6564 $morelabel =
' ('.$reg[1].
')';
6565 $rate = preg_replace(
'/\s*'.preg_quote($morelabel,
'/').
'/',
'', $rate);
6566 $morelabel =
' '.($html ?
'<span class="opacitymedium">' :
'').
'('.$reg[1].
')'.($html ?
'</span>' :
'');
6568 if (preg_match(
'/\*/', $rate)) {
6569 $rate = str_replace(
'*',
'', $rate);
6574 if (!preg_match(
'/\//', $rate)) {
6575 $ret =
price($rate, 0,
'', 0, 0).($addpercent ?
'%' :
'');
6578 $ret = $rate.($addpercent ?
'%' :
'');
6580 if (($info_bits & 1) && $usestarfornpr >= 0) {
6603function price($amount, $form = 0, $outlangs =
'', $trunc = 1, $rounding = -1, $forcerounding = -1, $currency_code =
'')
6605 global $langs, $conf;
6608 if (empty($amount)) {
6611 $amount = (is_numeric($amount) ? $amount : 0);
6612 if ($rounding == -1) {
6615 $nbdecimal = $rounding;
6617 if ($outlangs ===
'none') {
6627 if (!($outlangs instanceof
Translate)) {
6631 if ($outlangs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
6632 $dec = $outlangs->transnoentitiesnoconv(
"SeparatorDecimal");
6634 if ($outlangs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
6635 $thousand = $outlangs->transnoentitiesnoconv(
"SeparatorThousand");
6637 if ($thousand ==
'None') {
6639 } elseif ($thousand ==
'Space') {
6646 $amount = str_replace(
',',
'.', $amount);
6648 $data = explode(
'.', $amount);
6649 $decpart = isset($data[1]) ? $data[1] :
'';
6650 $decpart = preg_replace(
'/0+$/i',
'', $decpart);
6660 $nbdecimalmaxshown = (int) str_replace(
'...',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN'));
6661 if ($trunc && $nbdecimal > $nbdecimalmaxshown) {
6662 $nbdecimal = $nbdecimalmaxshown;
6670 if ((
string) $forcerounding !=
'-1') {
6671 if ($forcerounding ===
'MU') {
6673 } elseif ($forcerounding ===
'MT') {
6675 } elseif ($forcerounding >= 0) {
6676 $nbdecimal = $forcerounding;
6681 $output = number_format((
float) $amount, $nbdecimal, $dec, $thousand);
6683 $output = preg_replace(
'/\s/',
' ', $output);
6684 $output = preg_replace(
'/\'/',
''', $output);
6687 $cursymbolbefore = $cursymbolafter =
'';
6688 if ($currency_code && is_object($outlangs)) {
6689 if ($currency_code ==
'auto') {
6690 $currency_code = $conf->currency;
6693 $listofcurrenciesbefore = array(
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD',
'CRC',
'ZAR');
6694 $listoflanguagesbefore = array(
'nl_NL');
6695 if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) {
6696 $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
6698 $tmpcur = $outlangs->getCurrencySymbol($currency_code);
6699 $cursymbolafter .= ($tmpcur == $currency_code ?
' '.$tmpcur : $tmpcur);
6702 $output = $cursymbolbefore.$output.$end.($cursymbolafter ?
' ' :
'').$cursymbolafter;
6731function price2num($amount, $rounding =
'', $option = 0)
6733 global $langs, $conf;
6736 if (is_null($amount)) {
6745 if (is_null($langs)) {
6749 if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
6750 $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
6752 if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
6753 $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
6756 if ($thousand ==
'None') {
6758 } elseif ($thousand ==
'Space') {
6766 if (!is_numeric($amount)) {
6767 $amount = preg_replace(
'/[a-zA-Z\/\\\*\(\)<>\_]/',
'', $amount);
6770 if ($option == 2 && $thousand ==
'.' && preg_match(
'/\.(\d\d\d)$/', (
string) $amount)) {
6771 $amount = str_replace($thousand,
'', $amount);
6777 if (is_numeric($amount)) {
6779 $temps = sprintf(
"%10.10F", $amount - intval($amount));
6780 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
6782 $amount = number_format($amount, $nbofdec, $dec, $thousand);
6787 if ($thousand !=
',' && $thousand !=
'.') {
6788 $amount = str_replace(
',',
'.', $amount);
6791 $amount = str_replace(
' ',
'', $amount);
6792 $amount = str_replace($thousand,
'', $amount);
6793 $amount = str_replace($dec,
'.', $amount);
6795 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
6801 $nbofdectoround =
'';
6802 if ($rounding ==
'MU') {
6804 } elseif ($rounding ==
'MT') {
6806 } elseif ($rounding ==
'MS') {
6807 $nbofdectoround = isset($conf->global->MAIN_MAX_DECIMALS_STOCK) ? $conf->global->MAIN_MAX_DECIMALS_STOCK : 5;
6808 } elseif ($rounding ==
'CU') {
6810 } elseif ($rounding ==
'CT') {
6812 } elseif (is_numeric($rounding)) {
6813 $nbofdectoround = (int) $rounding;
6818 $amount = round(is_string($amount) ? (
float) $amount : $amount, $nbofdectoround);
6820 return 'ErrorBadParameterProvidedToFunction';
6826 if (is_numeric($amount)) {
6828 $temps = sprintf(
"%10.10F", $amount - intval($amount));
6829 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
6831 $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand);
6837 if ($thousand !=
',' && $thousand !=
'.') {
6838 $amount = str_replace(
',',
'.', $amount);
6841 $amount = str_replace(
' ',
'', $amount);
6842 $amount = str_replace($thousand,
'', $amount);
6843 $amount = str_replace($dec,
'.', $amount);
6845 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
6863function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput =
'no', $use_short_label = 0)
6865 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
6867 if (($forceunitoutput ==
'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
6868 $dimension *= 1000000;
6870 } elseif (($forceunitoutput ==
'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) {
6873 } elseif (($forceunitoutput ==
'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) {
6874 $dimension /= 1000000;
6876 } elseif (($forceunitoutput ==
'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) {
6893 $ret =
price($dimension, 0, $outputlangs, 0, 0, $round);
6895 $ret .=
' '.measuringUnitString(0, $type, $unit, $use_short_label, $outputlangs);
6913function get_localtax($vatrate, $local, $thirdparty_buyer =
null, $thirdparty_seller =
null, $vatnpr = 0)
6915 global $db, $conf, $mysoc;
6917 if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) {
6918 $thirdparty_seller = $mysoc;
6921 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);
6923 $vatratecleaned = $vatrate;
6925 if (preg_match(
'/^(.*)\s*\((.*)\)$/', (
string) $vatrate, $reg)) {
6926 $vatratecleaned = trim($reg[1]);
6927 $vatratecode = $reg[2];
6936 if ($mysoc->country_code ==
'ES') {
6938 if (!$mysoc->localtax1_assuj || (
string) $vatratecleaned ==
"0") {
6941 if ($thirdparty_seller->id == $mysoc->id) {
6942 if (!$thirdparty_buyer->localtax1_assuj) {
6946 if (!$thirdparty_seller->localtax1_assuj) {
6954 if (!$mysoc->localtax2_assuj) {
6957 if ($thirdparty_seller->id == $mysoc->id) {
6958 if (!$thirdparty_buyer->localtax2_assuj) {
6962 if (!$thirdparty_seller->localtax2_assuj) {
6968 if ($local == 1 && !$thirdparty_seller->localtax1_assuj) {
6971 if ($local == 2 && !$thirdparty_seller->localtax2_assuj) {
6977 if (in_array($mysoc->country_code, array(
'ES'))) {
6978 $conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY = 1;
6984 if ($thirdparty_seller != $mysoc) {
6986 return $thirdparty_seller->localtax1_value;
6990 return $conf->global->MAIN_INFO_VALUE_LOCALTAX1;
6995 if ($thirdparty_seller != $mysoc) {
6998 return $thirdparty_seller->localtax2_value;
7001 if (in_array($mysoc->country_code, array(
'ES'))) {
7002 return $thirdparty_buyer->localtax2_value;
7004 return $conf->global->MAIN_INFO_VALUE_LOCALTAX2;
7011 $sql =
"SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
7012 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7013 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdparty_seller->country_code).
"'";
7014 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7015 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7016 if (!empty($vatratecode)) {
7017 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
7019 $sql .=
" AND t.recuperableonly = '".$db->escape($vatnpr).
"'";
7022 $resql = $db->query($sql);
7025 $obj = $db->fetch_object($resql);
7028 return $obj->localtax1;
7029 } elseif ($local == 2) {
7030 return $obj->localtax2;
7051 $valors = explode(
":", $tax);
7053 if (count($valors) > 1) {
7070 $sql =
" SELECT t.localtax".$local.
" as localtax";
7071 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t INNER JOIN ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid = t.fk_pays";
7072 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.active = 1 AND t.entity IN (".
getEntity(
'c_tva').
") AND t.taux = (";
7073 $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";
7074 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.entity IN (".
getEntity(
'c_tva').
") AND tt.active = 1)";
7075 $sql .=
" AND t.localtax".$local.
"_type <> '0'";
7076 $sql .=
" ORDER BY t.rowid DESC";
7078 $resql = $db->query($sql);
7080 $obj = $db->fetch_object($resql);
7082 return $obj->localtax;
7103function getTaxesFromId($vatrate, $buyer =
null, $seller =
null, $firstparamisid = 1)
7107 dol_syslog(
"getTaxesFromId vat id or rate = ".$vatrate);
7110 $sql =
"SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy,";
7111 $sql .=
" t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
7112 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
7113 if ($firstparamisid) {
7114 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
7116 $vatratecleaned = $vatrate;
7119 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
7120 $vatratecleaned = $reg[1];
7121 $vatratecode = $reg[2];
7124 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
7127 $sql .=
" WHERE t.fk_pays = c.rowid";
7129 $sql .=
" AND c.code = '".$db->escape($buyer->country_code).
"'";
7131 $sql .=
" AND c.code = '".$db->escape($seller->country_code).
"'";
7133 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7134 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7136 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
7140 $resql = $db->query($sql);
7142 $obj = $db->fetch_object($resql);
7145 'rowid' => $obj->rowid,
7146 'code' => $obj->code,
7147 'rate' => $obj->rate,
7148 'localtax1' => $obj->localtax1,
7149 'localtax1_type' => $obj->localtax1_type,
7150 'localtax2' => $obj->localtax2,
7151 'localtax2_type' => $obj->localtax2_type,
7153 'accountancy_code_sell' => $obj->accountancy_code_sell,
7154 'accountancy_code_buy' => $obj->accountancy_code_buy
7186 dol_syslog(
"getLocalTaxesFromRate vatrate=".$vatrate.
" local=".$local);
7189 $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";
7190 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
7191 if ($firstparamisid) {
7192 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
7194 $vatratecleaned = $vatrate;
7197 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
7198 $vatratecleaned = $reg[1];
7199 $vatratecode = $reg[2];
7202 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
7203 if (!empty($mysoc) && $mysoc->country_code ==
'ES') {
7204 $countrycodetouse = ((empty($buyer) || empty($buyer->country_code)) ? $mysoc->country_code : $buyer->country_code);
7205 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
7207 $countrycodetouse = ((empty($seller) || empty($seller->country_code)) ? $mysoc->country_code : $seller->country_code);
7208 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
7210 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7212 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
7216 $resql = $db->query($sql);
7218 $obj = $db->fetch_object($resql);
7221 $vateratestring = $obj->rate.($obj->code ?
' ('.$obj->code.
')' :
'');
7224 return array($obj->localtax1_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
7225 } elseif ($local == 2) {
7226 return array($obj->localtax2_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
7228 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);
7250 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
7258 $product->fetch($idprod);
7260 if (($mysoc->country_code == $thirdpartytouse->country_code)
7261 || (in_array($mysoc->country_code, array(
'FR',
'MC')) && in_array($thirdpartytouse->country_code, array(
'FR',
'MC')))
7262 || (in_array($mysoc->country_code, array(
'MQ',
'GP')) && in_array($thirdpartytouse->country_code, array(
'MQ',
'GP')))
7265 if ($idprodfournprice > 0) {
7266 $result = $product->get_buyprice($idprodfournprice, 0, 0, 0);
7268 $ret = $product->vatrate_supplier;
7269 if ($product->default_vat_code_supplier) {
7270 $ret .=
' ('.$product->default_vat_code_supplier.
')';
7276 $ret = $product->tva_tx;
7277 if ($product->default_vat_code) {
7278 $ret .=
' ('.$product->default_vat_code.
')';
7291 $sql =
"SELECT t.taux as vat_rate, t.code as default_vat_code";
7292 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7293 $sql .=
" WHERE t.active = 1 AND t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdpartytouse->country_code).
"'";
7294 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7295 $sql .=
" ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC";
7296 $sql .= $db->plimit(1);
7298 $resql = $db->query($sql);
7300 $obj = $db->fetch_object($resql);
7302 $ret = $obj->vat_rate;
7303 if ($obj->default_vat_code) {
7304 $ret .=
' ('.$obj->default_vat_code.
')';
7328 dol_syslog(
"get_product_vat_for_country: ret=".$ret);
7345 if (!class_exists(
'Product')) {
7346 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
7355 $result = $product->fetch($idprod);
7357 if ($mysoc->country_code == $thirdpartytouse->country_code) {
7371 $sql =
"SELECT taux as vat_rate, localtax1, localtax2";
7372 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7373 $sql .=
" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdpartytouse->country_code).
"'";
7374 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7375 $sql .=
" ORDER BY t.taux DESC, t.recuperableonly ASC";
7376 $sql .= $db->plimit(1);
7378 $resql = $db->query($sql);
7380 $obj = $db->fetch_object($resql);
7383 $ret = $obj->localtax1;
7384 } elseif ($local == 2) {
7385 $ret = $obj->localtax2;
7393 dol_syslog(
"get_product_localtax_for_country: ret=".$ret);
7417 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
7420 $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;
7422 $seller_country_code = $thirdparty_seller->country_code;
7423 $seller_in_cee =
isInEEC($thirdparty_seller);
7425 $buyer_country_code = $thirdparty_buyer->country_code;
7426 $buyer_in_cee =
isInEEC($thirdparty_buyer);
7428 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(
'SERVICES_ARE_ECOMMERCE_200238EC') ? $conf->global->SERVICES_ARE_ECOMMERCE_200238EC :
''));
7433 if ($seller_in_cee && $buyer_in_cee) {
7434 $isacompany = $thirdparty_buyer->isACompany();
7435 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
7436 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
7450 if (!$seller_use_vat) {
7456 if (($seller_country_code == $buyer_country_code)
7457 || (in_array($seller_country_code, array(
'FR',
'MC')) && in_array($buyer_country_code, array(
'FR',
'MC')))
7458 || (in_array($seller_country_code, array(
'MQ',
'GP')) && in_array($buyer_country_code, array(
'MQ',
'GP')))
7463 if ($seller_country_code ==
'IN' &&
getDolGlobalString(
'MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA')) {
7467 if (preg_match(
'/C+S-(\d+)/', $tmpvat, $reg) && $thirdparty_seller->state_id != $thirdparty_buyer->state_id) {
7469 $tmpvat = str_replace(
"C+S",
"I", $tmpvat);
7470 } elseif (preg_match(
'/I-(\d+)/', $tmpvat, $reg) && $thirdparty_seller->state_id == $thirdparty_buyer->state_id) {
7472 $tmpvat = str_replace(
"I",
"C+S", $tmpvat);
7484 if (($seller_in_cee && $buyer_in_cee)) {
7485 $isacompany = $thirdparty_buyer->isACompany();
7486 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
7487 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
7504 if (
getDolGlobalString(
'MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC') && empty($buyer_in_cee)) {
7505 $isacompany = $thirdparty_buyer->isACompany();
7533 if ($idprodfournprice > 0) {
7534 if (!class_exists(
'ProductFournisseur')) {
7535 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
7538 $prodprice->fetch_product_fournisseur_price($idprodfournprice);
7539 return $prodprice->fourn_tva_npr;
7540 } elseif ($idprod > 0) {
7541 if (!class_exists(
'Product')) {
7542 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
7545 $prod->fetch($idprod);
7546 return $prod->tva_npr;
7569 if (!is_object($thirdparty_seller)) {
7572 if (!is_object($thirdparty_buyer)) {
7577 if ($mysoc->country_code ==
'ES') {
7578 if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) {
7583 if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) {
7586 if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj ==
'localtax1off') {
7590 } elseif ($local == 2) {
7592 if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) {
7595 if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj ==
'localtax2off') {
7600 if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
7615function yn($yesno, $case = 1, $color = 0)
7619 $result =
'unknown';
7621 if ($yesno == 1 || (isset($yesno) && (strtolower($yesno) ==
'yes' || strtolower($yesno) ==
'true'))) {
7622 $result = $langs->trans(
'yes');
7623 if ($case == 1 || $case == 3) {
7624 $result = $langs->trans(
"Yes");
7627 $result =
'<input type="checkbox" value="1" checked disabled>';
7630 $result =
'<input type="checkbox" value="1" checked disabled> '.$result;
7637 } elseif ($yesno == 0 || strtolower($yesno) ==
'no' || strtolower($yesno) ==
'false') {
7638 $result = $langs->trans(
"no");
7639 if ($case == 1 || $case == 3) {
7640 $result = $langs->trans(
"No");
7643 $result =
'<input type="checkbox" value="0" disabled>';
7646 $result =
'<input type="checkbox" value="0" disabled> '.$result;
7649 $result =
img_picto(
'uncheck',
'uncheck');
7655 $classname =
'error';
7659 return '<span class="'.$classname.
'">'.$result.
'</span>';
7682function get_exdir($num, $level, $alpha, $withoutslash,
$object, $modulepart =
'')
7684 if (empty($modulepart) && is_object(
$object)) {
7685 if (!empty(
$object->module)) {
7686 $modulepart =
$object->module;
7687 } elseif (!empty(
$object->element)) {
7688 $modulepart =
$object->element;
7695 $arrayforoldpath = array(
'cheque' => 2,
'category' => 2,
'holiday' => 2,
'supplier_invoice' => 2,
'invoice_supplier' => 2,
'mailing' => 2,
'supplier_payment' => 2);
7697 $arrayforoldpath[
'product'] = 2;
7700 if (empty($level) && array_key_exists($modulepart, $arrayforoldpath)) {
7701 $level = $arrayforoldpath[$modulepart];
7704 if (!empty($level) && array_key_exists($modulepart, $arrayforoldpath)) {
7706 if (empty($num) && is_object(
$object)) {
7709 if (empty($alpha)) {
7710 $num = preg_replace(
'/([^0-9])/i',
'', $num);
7712 $num = preg_replace(
'/^.*\-/i',
'', $num);
7714 $num = substr(
"000".$num, -$level);
7716 $path = substr($num, 0, 1);
7719 $path = substr($num, 1, 1).
'/'.substr($num, 0, 1);
7722 $path = substr($num, 2, 1).
'/'.substr($num, 1, 1).
'/'.substr($num, 0, 1);
7732 if (empty($withoutslash) && !empty($path)) {
7747function dol_mkdir($dir, $dataroot =
'', $newmask =
'')
7751 dol_syslog(
"functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
7754 if (@is_dir($dir_osencoded)) {
7762 if (!empty($dataroot)) {
7764 $dir = str_replace($dataroot.
'/',
'', $dir);
7765 $ccdir = $dataroot.
'/';
7768 $cdir = explode(
"/", $dir);
7769 $num = count($cdir);
7770 for ($i = 0; $i < $num; $i++) {
7772 $ccdir .=
'/'.$cdir[$i];
7774 $ccdir .= $cdir[$i];
7777 if (preg_match(
"/^.:$/", $ccdir, $regs)) {
7785 if (!@is_dir($ccdir_osencoded)) {
7786 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG);
7789 $dirmaskdec = octdec((
string) $newmask);
7790 if (empty($newmask)) {
7791 $dirmaskdec = !
getDolGlobalString(
'MAIN_UMASK') ? octdec(
'0755') : octdec($conf->global->MAIN_UMASK);
7793 $dirmaskdec |= octdec(
'0111');
7794 if (!@mkdir($ccdir_osencoded, $dirmaskdec)) {
7796 dol_syslog(
"functions.lib::dol_mkdir: Fails to create directory '".$ccdir.
"' or directory already exists.", LOG_WARNING);
7799 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' created", LOG_DEBUG);
7808 return ($nberr ? -$nberr : $nbcreated);
7819function dolChmod($filepath, $newmask =
'')
7823 if (!empty($newmask)) {
7824 @chmod($filepath, octdec($newmask));
7826 @chmod($filepath, octdec($conf->global->MAIN_UMASK));
7838 return '<span class="fieldrequired">*</span>';
7858function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
'UTF-8', $strip_tags = 0, $removedoublespaces = 1)
7860 if (is_null($stringtoclean)) {
7864 if ($removelinefeed == 2) {
7865 $stringtoclean = preg_replace(
'/<br[^>]*>(\n|\r)+/ims',
'<br>', $stringtoclean);
7867 $temp = preg_replace(
'/<br[^>]*>/i',
"\n", $stringtoclean);
7872 $temp = str_replace(
'< ',
'__ltspace__', $temp);
7873 $temp = str_replace(
'<:',
'__lttwopoints__', $temp);
7876 $temp = strip_tags($temp);
7879 $pattern =
"/<[^<>]+>/";
7886 $tempbis = str_replace(
'<>',
'', $temp);
7887 $tempbis = preg_replace($pattern,
'', $tempbis);
7889 }
while ($tempbis != $temp);
7894 $temp = preg_replace(
'/<+([a-z]+)/i',
'\1', $temp);
7900 if ($removelinefeed == 1) {
7901 $temp = str_replace(array(
"\r\n",
"\r",
"\n"),
" ", $temp);
7905 if ($removedoublespaces) {
7906 while (strpos($temp,
" ")) {
7907 $temp = str_replace(
" ",
" ", $temp);
7911 $temp = str_replace(
'__ltspace__',
'< ', $temp);
7912 $temp = str_replace(
'__lttwopoints__',
'<:', $temp);
7932function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $removeclassattribute = 1, $cleanalsojavascript = 0, $allowiframe = 0, $allowed_tags = array(), $allowlink = 0)
7934 if (empty($allowed_tags)) {
7935 $allowed_tags = array(
7936 "html",
"head",
"meta",
"body",
"article",
"a",
"abbr",
"b",
"blockquote",
"br",
"cite",
"div",
"dl",
"dd",
"dt",
"em",
"font",
"img",
"ins",
"hr",
"i",
"li",
7937 "ol",
"p",
"q",
"s",
"span",
"strike",
"strong",
"title",
"table",
"tr",
"th",
"td",
"u",
"ul",
"sup",
"sub",
"blockquote",
"pre",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
7938 "header",
"footer",
"nav",
"section",
"menu",
"menuitem"
7941 $allowed_tags[] =
"comment";
7943 if (!in_array(
'iframe', $allowed_tags)) {
7944 $allowed_tags[] =
"iframe";
7948 if (!in_array(
'link', $allowed_tags)) {
7949 $allowed_tags[] =
"link";
7953 $allowed_tags_string = implode(
"><", $allowed_tags);
7954 $allowed_tags_string =
'<'.$allowed_tags_string.
'>';
7956 $stringtoclean = str_replace(
'<!DOCTYPE html>',
'__!DOCTYPE_HTML__', $stringtoclean);
7961 $stringtoclean = preg_replace(
'/<!--([^>]*)-->/',
'<comment>\1</comment>', $stringtoclean);
7963 $stringtoclean = preg_replace(
'/:/i',
':', $stringtoclean);
7964 $stringtoclean = preg_replace(
'/:|�+58|:/i',
'', $stringtoclean);
7967 $temp = strip_tags($stringtoclean, $allowed_tags_string);
7969 if ($cleanalsosomestyles) {
7970 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/i',
'', $temp);
7972 if ($removeclassattribute) {
7973 $temp = preg_replace(
'/(<[^>]+)\s+class=((["\']).*?\\3|\\w*)/i',
'\\1', $temp);
7978 if ($cleanalsojavascript) {
7979 $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);
7982 $temp = str_replace(
'__!DOCTYPE_HTML__',
'<!DOCTYPE html>', $temp);
7984 $temp = preg_replace(
'/<comment>([^>]*)<\/comment>/',
'<!--\1-->', $temp);
8005 if (is_null($allowed_attributes)) {
8006 $allowed_attributes = array(
8007 "allow",
"allowfullscreen",
"alt",
"class",
"contenteditable",
"data-html",
"frameborder",
"height",
"href",
"id",
"name",
"src",
"style",
"target",
"title",
"width",
8009 "header",
"footer",
"nav",
"section",
"menu",
"menuitem"
8013 if (class_exists(
'DOMDocument') && !empty($stringtoclean)) {
8014 $stringtoclean =
'<?xml encoding="UTF-8"><html><body>'.$stringtoclean.
'</body></html>';
8017 $dom =
new DOMDocument(
'',
'UTF-8');
8019 $savwarning = error_reporting();
8020 error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);
8021 $dom->loadHTML($stringtoclean, LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOXMLDECL);
8022 error_reporting($savwarning);
8024 if ($dom instanceof DOMDocument) {
8025 for ($els = $dom->getElementsByTagname(
'*'), $i = $els->length - 1; $i >= 0; $i--) {
8026 $el = $els->item($i);
8027 if (!$el instanceof DOMElement) {
8030 $attrs = $el->attributes;
8031 for ($ii = $attrs->length - 1; $ii >= 0; $ii--) {
8033 if (!empty($attrs->item($ii)->name)) {
8034 if (! in_array($attrs->item($ii)->name, $allowed_attributes)) {
8036 $els->item($i)->removeAttribute($attrs->item($ii)->name);
8037 } elseif (in_array($attrs->item($ii)->name, array(
'style'))) {
8039 $valuetoclean = $attrs->item($ii)->value;
8041 if (isset($valuetoclean)) {
8043 $oldvaluetoclean = $valuetoclean;
8044 $valuetoclean = preg_replace(
'/\/\*.*\*\//m',
'', $valuetoclean);
8045 $valuetoclean = preg_replace(
'/position\s*:\s*[a-z]+/mi',
'', $valuetoclean);
8046 if ($els->item($i)->tagName ==
'a') {
8047 $valuetoclean = preg_replace(
'/display\s*:/mi',
'', $valuetoclean);
8048 $valuetoclean = preg_replace(
'/z-index\s*:/mi',
'', $valuetoclean);
8049 $valuetoclean = preg_replace(
'/\s+(top|left|right|bottom)\s*:/mi',
'', $valuetoclean);
8053 $valuetoclean = preg_replace(
'/(logout|passwordforgotten)\.php/mi',
'', $valuetoclean);
8054 $valuetoclean = preg_replace(
'/action=/mi',
'', $valuetoclean);
8055 }
while ($oldvaluetoclean != $valuetoclean);
8058 $attrs->item($ii)->value = $valuetoclean;
8065 $return = $dom->saveHTML();
8068 $return = preg_replace(
'/^'.preg_quote(
'<?xml encoding="UTF-8">',
'/').
'/',
'', $return);
8069 $return = preg_replace(
'/^'.preg_quote(
'<html><body>',
'/').
'/',
'', $return);
8070 $return = preg_replace(
'/'.preg_quote(
'</body></html>',
'/').
'$/',
'', $return);
8071 return trim($return);
8073 return $stringtoclean;
8090 $temp = $stringtoclean;
8091 foreach ($disallowed_tags as $tagtoremove) {
8092 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'>/',
'', $temp);
8093 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'\s+[^>]*>/',
'', $temp);
8096 if ($cleanalsosomestyles) {
8097 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/',
'', $temp);
8115 if ($nboflines == 1) {
8117 $firstline = preg_replace(
'/<br[^>]*>.*$/s',
'', $text);
8118 $firstline = preg_replace(
'/<div[^>]*>.*$/s',
'', $firstline);
8121 $firstline = preg_replace(
'/[\n\r].*/',
'', $text);
8126 return $firstline.(isset($firstline) && isset($text) && (strlen($firstline) != strlen($text)) ?
'...' :
'');
8130 $text = preg_replace(
'/\n/',
'', $text);
8132 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8134 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8137 $text = strtr($text, $repTable);
8138 if ($charset ==
'UTF-8') {
8139 $pattern =
'/(<br[^>]*>)/Uu';
8142 $pattern =
'/(<br[^>]*>)/U';
8144 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
8149 $lastaddediscontent = 1;
8150 while ($countline < $nboflines && isset($a[$i])) {
8151 if (preg_match(
'/<br[^>]*>/', $a[$i])) {
8152 if (array_key_exists($i + 1, $a) && !empty($a[$i + 1])) {
8153 $firstline .= ($ishtml ?
"<br>\n" :
"\n");
8155 if (!$lastaddediscontent) {
8158 $lastaddediscontent = 0;
8161 $firstline .= $a[$i];
8162 $lastaddediscontent = 1;
8168 $adddots = (isset($a[$i]) && (!preg_match(
'/<br[^>]*>/', $a[$i]) || (array_key_exists($i + 1, $a) && !empty($a[$i + 1]))));
8170 $ret = $firstline.($adddots ?
'...' :
'');
8188function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml =
false)
8190 if (is_null($stringtoencode)) {
8195 return nl2br($stringtoencode, $forxml);
8197 $ret = preg_replace(
'/(\r\n|\r|\n)/i', ($forxml ?
'<br />' :
'<br>'), $stringtoencode);
8211function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check =
'restricthtml')
8213 if (empty($nouseofiframesandbox) &&
getDolGlobalString(
'MAIN_SECURITY_USE_SANDBOX_FOR_HTMLWITHNOJS')) {
8218 return $stringtoencode;
8220 $out = $stringtoencode;
8224 $oldstringtoclean = $out;
8226 if (!empty($out) &&
getDolGlobalString(
'MAIN_RESTRICTHTML_ONLY_VALID_HTML') && $check !=
'restricthtmlallowunvalid') {
8228 libxml_use_internal_errors(
false);
8229 if (LIBXML_VERSION < 20900) {
8233 libxml_disable_entity_loader(
true);
8236 $dom =
new DOMDocument();
8242 $out =
'<?xml encoding="UTF-8"><div class="tricktoremove">'.$out.
'</div>';
8244 $out =
'<?xml encoding="UTF-8"><div class="tricktoremove">'.dol_nl2br($out).
'</div>';
8247 $dom->loadHTML($out, LIBXML_HTML_NODEFDTD | LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOERROR | LIBXML_NOXMLDECL);
8248 $out = trim($dom->saveHTML());
8251 $out = preg_replace(
'/^<\?xml encoding="UTF-8"><div class="tricktoremove">/',
'', $out);
8252 $out = preg_replace(
'/<\/div>$/',
'', $out);
8256 $out =
'InvalidHTMLStringCantBeCleaned '.$e->getMessage();
8260 if (!empty($out) &&
getDolGlobalString(
'MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY') && $check !=
'restricthtmlallowunvalid') {
8263 if (extension_loaded(
'tidy') && class_exists(
"tidy")) {
8269 'quote-marks' =>
false,
8270 'doctype' =>
'strict',
8271 'show-body-only' =>
true,
8272 "indent-attributes" =>
false,
8273 "vertical-space" =>
false,
8285 $out = $tidy->repairString($out, $config,
'utf8');
8292 $out =
'InvalidHTMLStringCantBeCleaned '.$e->getMessage();
8297 $out = preg_replace(
'/[\x{200B}-\x{200D}\x{FEFF}]/u',
' ', $out);
8300 $out = preg_replace(
'/&(tab|newline);/i',
' ', $out);
8304 $out = preg_replace(
'/'/i',
''', $out);
8309 $out = preg_replace_callback(
8310 '/&#(x?[0-9][0-9a-f]+;?)/i',
8315 static function ($m) {
8322 $out = preg_replace(
'/&#x?[0-9]+/i',
'', $out);
8325 if ($check ==
'restricthtmlallowclass' || $check ==
'restricthtmlallowunvalid') {
8337 $out = preg_replace(
'/'/i',
"'", $out);
8341 $out = preg_replace(
'/on(mouse|drag|key|load|touch|pointer|select|transition)[a-z]*\s*=/i',
'', $out);
8342 $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);
8343 $out = preg_replace(
'/on(dblclick|drop|durationchange|emptied|end|ended|error|focus|focusin|focusout|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i',
'', $out);
8344 $out = preg_replace(
'/on(lostpointercapture|offline|online|pagehide|pageshow)[a-z]*\s*=/i',
'', $out);
8345 $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);
8346 $out = preg_replace(
'/on(timeupdate|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i',
'', $out);
8348 $out = preg_replace(
'/on(repeat|begin|finish|beforeinput)[a-z]*\s*=/i',
'', $out);
8349 }
while ($oldstringtoclean != $out);
8356 $tmpout = preg_replace(
'/<img src="data:/mi',
'<__IMG_SRC_DATA__ src="data:', $out);
8357 preg_match_all(
'/(<img|url\(|<link)/i', $tmpout, $reg);
8358 $nblinks = count($reg[0]);
8359 if ($nblinks >
getDolGlobalInt(
"MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 1000)) {
8360 $out =
'ErrorTooManyLinksIntoHTMLString';
8363 if (
getDolGlobalInt(
'MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 2 || $check ==
'restricthtmlnolink') {
8365 $out =
'ErrorHTMLLinksNotAllowed';
8367 } elseif (
getDolGlobalInt(
'MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 1) {
8370 $pattern =
'/src=["\']?(http[^"\']+)|url\(["\']?(http[^\)]+)/';
8373 if (preg_match_all($pattern, $out, $matches)) {
8375 $urls = $matches[1];
8378 foreach ($urls as $url) {
8380 echo
"Found url = ".$url .
"\n";
8383 $out =
'ErrorHTMLExternalLinksNotAllowed';
8412function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom =
'UTF-8', $removelasteolbr = 1)
8414 if (is_null($stringtoencode)) {
8418 $newstring = $stringtoencode;
8420 $newstring = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
'<br>', $newstring);
8421 if ($removelasteolbr) {
8422 $newstring = preg_replace(
'/<br>$/i',
'', $newstring);
8424 $newstring = preg_replace(
'/[\x{200B}-\x{200D}\x{FEFF}]/u',
' ', $newstring);
8425 $newstring = strtr($newstring, array(
'&' =>
'__and__',
'<' =>
'__lt__',
'>' =>
'__gt__',
'"' =>
'__dquot__'));
8427 $newstring = strtr($newstring, array(
'__and__' =>
'&',
'__lt__' =>
'<',
'__gt__' =>
'>',
'__dquot__' =>
'"'));
8429 if ($removelasteolbr) {
8430 $newstring = preg_replace(
'/(\r\n|\r|\n)$/i',
'', $newstring);
8449 $ret = preg_replace(
'/'.
"\r\n".
'<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"<br>", $ret);
8450 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\r\n".
'/i',
"\r\n", $ret);
8451 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\n".
'/i',
"\n", $ret);
8452 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"\n", $ret);
8464 $ret = preg_replace(
'/ $/i',
"", $stringtodecode);
8465 $ret = preg_replace(
'/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'.
"\n".
'|'.
"\r".
')+$/i',
"", $ret);
8481 if ($keepsomeentities) {
8482 $newstring = strtr($newstring, array(
'&' =>
'__andamp__',
'<' =>
'__andlt__',
'>' =>
'__andgt__',
'"' =>
'__dquot__'));
8484 $newstring = html_entity_decode((
string) $newstring, (
int) $b, (
string) $c);
8485 if ($keepsomeentities) {
8486 $newstring = strtr($newstring, array(
'__andamp__' =>
'&',
'__andlt__' =>
'<',
'__andgt__' =>
'>',
'__dquot__' =>
'"'));
8502function dol_htmlentities($string, $flags = ENT_QUOTES | ENT_SUBSTITUTE, $encoding =
'UTF-8', $double_encode =
false)
8504 return htmlentities($string, $flags, $encoding, $double_encode);
8523 for ($scursor = 0; $scursor < $len; $scursor++) {
8524 $ordchar = ord($s[$scursor]);
8526 if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) {
8529 } elseif ($ordchar > 126 && $ordchar < 160) {
8533 $out .= $s[$scursor];
8555 $arraystring = explode(
"\n", $s);
8556 $nb = count($arraystring);
8573 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8575 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8578 $text = strtr($text, $repTable);
8579 if ($charset ==
'UTF-8') {
8580 $pattern =
'/(<br[^>]*>)/Uu';
8583 $pattern =
'/(<br[^>]*>)/U';
8585 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
8587 $nblines = (int) floor((count($a) + 1) / 2);
8590 foreach ($a as $line) {
8593 $line_dec = html_entity_decode($line);
8595 $line_dec = wordwrap($line_dec, $maxlinesize,
'\n',
true);
8596 $nblines += substr_count($line_dec,
'\n');
8616 if (is_null($msg)) {
8621 if (preg_match(
'/<html/i', $msg)) {
8623 } elseif (preg_match(
'/<body/i', $msg)) {
8625 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
8627 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
8629 } elseif (preg_match(
'/<br/i', $msg)) {
8635 $msg = preg_replace(
'/https?:\/\/[^"\'\s]+/i',
'', $msg);
8636 if (preg_match(
'/<html/i', $msg)) {
8638 } elseif (preg_match(
'/<body/i', $msg)) {
8640 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
8642 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
8644 } elseif (preg_match(
'/<(br|hr)\/>/i', $msg)) {
8646 } elseif (preg_match(
'/<(br|hr|div|font|li|p|span|strong|table)>/i', $msg)) {
8648 } elseif (preg_match(
'/<(br|hr|div|font|li|p|span|strong|table)\s+[^<>\/]*\/?>/i', $msg)) {
8650 } elseif (preg_match(
'/<img\s+[^<>]*src[^<>]*>/i', $msg)) {
8652 } elseif (preg_match(
'/<a\s+[^<>]*href[^<>]*>/i', $msg)) {
8654 } elseif (preg_match(
'/<h[0-9]>/i', $msg)) {
8656 } elseif (preg_match(
'/&[A-Z0-9]{1,6};/i', $msg)) {
8659 } elseif (preg_match(
'/&#[0-9]{2,3};/i', $msg)) {
8681function dol_concatdesc($text1, $text2, $forxml =
false, $invert =
false)
8683 if (!empty($invert)) {
8691 $ret .= (!empty($text1) && !empty($text2)) ? ((
dol_textishtml($text1) ||
dol_textishtml($text2)) ? ($forxml ?
"<br >\n" :
"<br>\n") :
"\n") :
"";
8713 global $db, $conf, $mysoc, $user, $extrafields;
8715 $substitutionarray = array();
8717 if ((empty($exclude) || !in_array(
'user', $exclude)) && (empty($include) || in_array(
'user', $include))) {
8721 $emailsendersignature = $user->signature;
8722 $usersignature = $user->signature;
8723 $substitutionarray = array_merge($substitutionarray, array(
8724 '__SENDEREMAIL_SIGNATURE__' => (
string) ((!
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? ($onlykey == 2 ?
dol_trunc(
'SignatureFromTheSelectedSenderProfile', 30) : $emailsendersignature) :
''),
8728 if (is_object($user) && ($user instanceof
User)) {
8729 $substitutionarray = array_merge($substitutionarray, array(
8730 '__USER_ID__' => (
string) $user->id,
8731 '__USER_LOGIN__' => (
string) $user->login,
8732 '__USER_EMAIL__' => (
string) $user->email,
8733 '__USER_PHONE__' => (
string)
dol_print_phone($user->office_phone,
'', 0, 0,
'',
" ",
'',
'', -1),
8734 '__USER_PHONEPRO__' => (
string)
dol_print_phone($user->user_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
8735 '__USER_PHONEMOBILE__' => (
string)
dol_print_phone($user->personal_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
8736 '__USER_FAX__' => (
string) $user->office_fax,
8737 '__USER_LASTNAME__' => (
string) $user->lastname,
8738 '__USER_FIRSTNAME__' => (
string) $user->firstname,
8739 '__USER_FULLNAME__' => (
string) $user->getFullName($outputlangs),
8740 '__USER_SUPERVISOR_ID__' => (
string) ($user->fk_user ? $user->fk_user :
'0'),
8741 '__USER_JOB__' => (string) $user->job,
8743 '__USER_VCARD_URL__' => (string) $user->getOnlineVirtualCardUrl(
'',
'external')
8747 if ((empty($exclude) || !in_array(
'mycompany', $exclude)) && is_object($mysoc) && (empty($include) || in_array(
'mycompany', $include))) {
8748 $substitutionarray = array_merge($substitutionarray, array(
8749 '__MYCOMPANY_NAME__' => $mysoc->name,
8750 '__MYCOMPANY_EMAIL__' => $mysoc->email,
8751 '__MYCOMPANY_PHONE__' =>
dol_print_phone($mysoc->phone,
'', 0, 0,
'',
" ",
'',
'', -1),
8752 '__MYCOMPANY_FAX__' =>
dol_print_phone($mysoc->fax,
'', 0, 0,
'',
" ",
'',
'', -1),
8753 '__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
8754 '__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
8755 '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
8756 '__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
8757 '__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
8758 '__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
8759 '__MYCOMPANY_PROFID7__' => $mysoc->idprof7,
8760 '__MYCOMPANY_PROFID8__' => $mysoc->idprof8,
8761 '__MYCOMPANY_PROFID9__' => $mysoc->idprof9,
8762 '__MYCOMPANY_PROFID10__' => $mysoc->idprof10,
8763 '__MYCOMPANY_CAPITAL__' => $mysoc->capital,
8764 '__MYCOMPANY_FULLADDRESS__' => (method_exists($mysoc,
'getFullAddress') ? $mysoc->getFullAddress(1,
', ') :
''),
8765 '__MYCOMPANY_ADDRESS__' => $mysoc->address,
8766 '__MYCOMPANY_ZIP__' => $mysoc->zip,
8767 '__MYCOMPANY_TOWN__' => $mysoc->town,
8768 '__MYCOMPANY_COUNTRY__' => $mysoc->country,
8769 '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id,
8770 '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code,
8771 '__MYCOMPANY_CURRENCY_CODE__' => $conf->currency
8775 if (($onlykey || is_object(
$object)) && (empty($exclude) || !in_array(
'object', $exclude)) && (empty($include) || in_array(
'object', $include))) {
8777 $substitutionarray[
'__ID__'] =
'__ID__';
8778 $substitutionarray[
'__REF__'] =
'__REF__';
8779 $substitutionarray[
'__NEWREF__'] =
'__NEWREF__';
8780 $substitutionarray[
'__LABEL__'] =
'__LABEL__';
8781 $substitutionarray[
'__REF_CLIENT__'] =
'__REF_CLIENT__';
8782 $substitutionarray[
'__REF_SUPPLIER__'] =
'__REF_SUPPLIER__';
8783 $substitutionarray[
'__NOTE_PUBLIC__'] =
'__NOTE_PUBLIC__';
8784 $substitutionarray[
'__NOTE_PRIVATE__'] =
'__NOTE_PRIVATE__';
8785 $substitutionarray[
'__EXTRAFIELD_XXX__'] =
'__EXTRAFIELD_XXX__';
8787 if (isModEnabled(
"societe")) {
8788 $substitutionarray[
'__THIRDPARTY_ID__'] =
'__THIRDPARTY_ID__';
8789 $substitutionarray[
'__THIRDPARTY_NAME__'] =
'__THIRDPARTY_NAME__';
8790 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
'__THIRDPARTY_NAME_ALIAS__';
8791 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
'__THIRDPARTY_CODE_CLIENT__';
8792 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
'__THIRDPARTY_CODE_FOURNISSEUR__';
8793 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
'__THIRDPARTY_EMAIL__';
8795 $substitutionarray[
'__THIRDPARTY_PHONE__'] =
'__THIRDPARTY_PHONE__';
8796 $substitutionarray[
'__THIRDPARTY_FAX__'] =
'__THIRDPARTY_FAX__';
8797 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
'__THIRDPARTY_ADDRESS__';
8798 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
'__THIRDPARTY_ZIP__';
8799 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
'__THIRDPARTY_TOWN__';
8800 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
'__THIRDPARTY_IDPROF1__';
8801 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
'__THIRDPARTY_IDPROF2__';
8802 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
'__THIRDPARTY_IDPROF3__';
8803 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
'__THIRDPARTY_IDPROF4__';
8804 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
'__THIRDPARTY_IDPROF5__';
8805 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
'__THIRDPARTY_IDPROF6__';
8806 $substitutionarray[
'__THIRDPARTY_IDPROF7__'] =
'__THIRDPARTY_IDPROF7__';
8807 $substitutionarray[
'__THIRDPARTY_IDPROF8__'] =
'__THIRDPARTY_IDPROF8__';
8808 $substitutionarray[
'__THIRDPARTY_IDPROF9__'] =
'__THIRDPARTY_IDPROF9__';
8809 $substitutionarray[
'__THIRDPARTY_IDPROF10__'] =
'__THIRDPARTY_IDPROF10__';
8810 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
'__THIRDPARTY_TVAINTRA__';
8811 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] =
'__THIRDPARTY_NOTE_PUBLIC__';
8812 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] =
'__THIRDPARTY_NOTE_PRIVATE__';
8814 if (isModEnabled(
'member') && (!is_object(
$object) ||
$object->element ==
'adherent') && (empty($exclude) || !in_array(
'member', $exclude)) && (empty($include) || in_array(
'member', $include))) {
8815 $substitutionarray[
'__MEMBER_ID__'] =
'__MEMBER_ID__';
8816 $substitutionarray[
'__MEMBER_CIVILITY__'] =
'__MEMBER_CIVILITY__';
8817 $substitutionarray[
'__MEMBER_FIRSTNAME__'] =
'__MEMBER_FIRSTNAME__';
8818 $substitutionarray[
'__MEMBER_LASTNAME__'] =
'__MEMBER_LASTNAME__';
8819 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'Login and pass of the external user account';
8824 if (isModEnabled(
'ticket') && (!is_object(
$object) ||
$object->element ==
'ticket') && (empty($exclude) || !in_array(
'ticket', $exclude)) && (empty($include) || in_array(
'ticket', $include))) {
8825 $substitutionarray[
'__TICKET_TRACKID__'] =
'__TICKET_TRACKID__';
8826 $substitutionarray[
'__TICKET_SUBJECT__'] =
'__TICKET_SUBJECT__';
8827 $substitutionarray[
'__TICKET_TYPE__'] =
'__TICKET_TYPE__';
8828 $substitutionarray[
'__TICKET_SEVERITY__'] =
'__TICKET_SEVERITY__';
8829 $substitutionarray[
'__TICKET_CATEGORY__'] =
'__TICKET_CATEGORY__';
8830 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
'__TICKET_ANALYTIC_CODE__';
8831 $substitutionarray[
'__TICKET_MESSAGE__'] =
'__TICKET_MESSAGE__';
8832 $substitutionarray[
'__TICKET_PROGRESSION__'] =
'__TICKET_PROGRESSION__';
8833 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
'__TICKET_USER_ASSIGN__';
8836 if (isModEnabled(
'recruitment') && (!is_object(
$object) ||
$object->element ==
'recruitmentcandidature') && (empty($exclude) || !in_array(
'recruitment', $exclude)) && (empty($include) || in_array(
'recruitment', $include))) {
8837 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
'__CANDIDATE_FULLNAME__';
8838 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] =
'__CANDIDATE_FIRSTNAME__';
8839 $substitutionarray[
'__CANDIDATE_LASTNAME__'] =
'__CANDIDATE_LASTNAME__';
8841 if (isModEnabled(
'project') && (empty($exclude) || !in_array(
'project', $exclude)) && (empty($include) || in_array(
'project', $include))) {
8842 $substitutionarray[
'__PROJECT_ID__'] =
'__PROJECT_ID__';
8843 $substitutionarray[
'__PROJECT_REF__'] =
'__PROJECT_REF__';
8844 $substitutionarray[
'__PROJECT_NAME__'] =
'__PROJECT_NAME__';
8848 if (isModEnabled(
'contract') && (!is_object(
$object) ||
$object->element ==
'contract') && (empty($exclude) || !in_array(
'contract', $exclude)) && (empty($include) || in_array(
'contract', $include))) {
8849 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
'Highest date planned for a service start';
8850 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
'Highest date and hour planned for service start';
8851 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
'Lowest data for planned expiration of service';
8852 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
'Lowest date and hour for planned expiration of service';
8854 if (isModEnabled(
"propal") && (!is_object(
$object) ||
$object->element ==
'propal') && (empty($exclude) || !in_array(
'propal', $exclude)) && (empty($include) || in_array(
'propal', $include))) {
8855 $substitutionarray[
'__ONLINE_SIGN_URL__'] =
'ToOfferALinkForOnlineSignature';
8857 if (isModEnabled(
"intervention") && (!is_object(
$object) ||
$object->element ==
'fichinter') && (empty($exclude) || !in_array(
'intervention', $exclude)) && (empty($include) || in_array(
'intervention', $include))) {
8858 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] =
'ToOfferALinkForOnlineSignature';
8860 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'UrlToPayOnlineIfApplicable';
8861 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'TextAndUrlToPayOnlineIfApplicable';
8862 $substitutionarray[
'__SECUREKEYPAYMENT__'] =
'Security key (if key is not unique per record)';
8863 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
'Security key for payment on a member subscription (one key per member)';
8864 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
'Security key for payment on an order';
8865 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
'Security key for payment on an invoice';
8866 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
'Security key for payment on a service of a contract';
8868 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'Direct download url of a proposal';
8869 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'Direct download url of an order';
8870 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'Direct download url of an invoice';
8871 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'Direct download url of a contract';
8872 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'Direct download url of a supplier proposal';
8874 if (isModEnabled(
"shipping") && (!is_object(
$object) ||
$object->element ==
'shipping')) {
8875 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
'Shipping tracking number';
8876 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
'Shipping tracking url';
8877 $substitutionarray[
'__SHIPPINGMETHOD__'] =
'Shipping method';
8879 if (isModEnabled(
"reception") && (!is_object(
$object) ||
$object->element ==
'reception')) {
8880 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
'Shipping tracking number of shipment';
8881 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
'Shipping tracking url';
8884 '@phan-var-force Adherent|Delivery $object';
8885 $substitutionarray[
'__ID__'] =
$object->id;
8886 $substitutionarray[
'__REF__'] =
$object->ref;
8887 $substitutionarray[
'__NEWREF__'] =
$object->newref;
8889 $substitutionarray[
'__REF_CLIENT__'] = (isset(
$object->ref_client) ?
$object->ref_client : (isset(
$object->ref_customer) ?
$object->ref_customer :
null));
8890 $substitutionarray[
'__REF_SUPPLIER__'] = (isset(
$object->ref_supplier) ?
$object->ref_supplier :
null);
8891 $substitutionarray[
'__NOTE_PUBLIC__'] = (isset(
$object->note_public) ?
$object->note_public :
null);
8892 $substitutionarray[
'__NOTE_PRIVATE__'] = (isset(
$object->note_private) ?
$object->note_private :
null);
8893 $substitutionarray[
'__DATE_CREATION__'] = (isset(
$object->date_creation) ?
dol_print_date(
$object->date_creation,
'day', 0, $outputlangs) :
'');
8894 $substitutionarray[
'__DATE_MODIFICATION__'] = (isset(
$object->date_modification) ?
dol_print_date(
$object->date_modification,
'day', 0, $outputlangs) :
'');
8895 $substitutionarray[
'__DATE_VALIDATION__'] = (isset(
$object->date_validation) ?
dol_print_date(
$object->date_validation,
'day', 0, $outputlangs) :
'');
8896 $substitutionarray[
'__DATE_DELIVERY__'] = (isset(
$object->date_delivery) ?
dol_print_date(
$object->date_delivery,
'day', 0, $outputlangs) :
'');
8898 $substitutionarray[
'__DATE_DELIVERY_DAY_TEXT__'] = (isset(
$object->date_delivery) ?
dol_print_date(
$object->date_delivery,
"%A") :
'');
8900 $substitutionarray[
'__DATE_DELIVERY_MON_TEXT__'] = (isset(
$object->date_delivery) ?
dol_print_date(
$object->date_delivery,
"%b") :
'');
8907 $substitutionarray[
'__REFCLIENT__'] = (isset(
$object->ref_client) ?
$object->ref_client : (isset(
$object->ref_customer) ?
$object->ref_customer :
null));
8908 $substitutionarray[
'__REFSUPPLIER__'] = (isset(
$object->ref_supplier) ?
$object->ref_supplier :
null);
8909 $substitutionarray[
'__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset(
$object->delivery_date) ?
dol_print_date(
$object->delivery_date,
'day', 0, $outputlangs) :
'');
8910 $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 :
'')) :
'');
8914 '@phan-var-force Adherent $object';
8917 $substitutionarray[
'__MEMBER_ID__'] = (isset(
$object->id) ?
$object->id :
'');
8918 if (method_exists(
$object,
'getCivilityLabel')) {
8919 $substitutionarray[
'__MEMBER_CIVILITY__'] =
$object->getCivilityLabel();
8921 $substitutionarray[
'__MEMBER_FIRSTNAME__'] = (isset(
$object->firstname) ?
$object->firstname :
'');
8922 $substitutionarray[
'__MEMBER_LASTNAME__'] = (isset(
$object->lastname) ?
$object->lastname :
'');
8923 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'';
8924 if (method_exists(
$object,
'getFullName')) {
8925 $substitutionarray[
'__MEMBER_FULLNAME__'] =
$object->getFullName($outputlangs);
8927 $substitutionarray[
'__MEMBER_COMPANY__'] = (isset(
$object->societe) ?
$object->societe :
'');
8928 $substitutionarray[
'__MEMBER_ADDRESS__'] = (isset(
$object->address) ?
$object->address :
'');
8929 $substitutionarray[
'__MEMBER_ZIP__'] = (isset(
$object->zip) ?
$object->zip :
'');
8930 $substitutionarray[
'__MEMBER_TOWN__'] = (isset(
$object->town) ?
$object->town :
'');
8931 $substitutionarray[
'__MEMBER_COUNTRY__'] = (isset(
$object->country) ?
$object->country :
'');
8932 $substitutionarray[
'__MEMBER_EMAIL__'] = (isset(
$object->email) ?
$object->email :
'');
8933 $substitutionarray[
'__MEMBER_BIRTH__'] = (isset($birthday) ? $birthday :
'');
8934 $substitutionarray[
'__MEMBER_PHOTO__'] = (isset(
$object->photo) ?
$object->photo :
'');
8935 $substitutionarray[
'__MEMBER_LOGIN__'] = (isset(
$object->login) ?
$object->login :
'');
8936 $substitutionarray[
'__MEMBER_PASSWORD__'] = (isset(
$object->pass) ?
$object->pass :
'');
8940 $substitutionarray[
'__MEMBER_TYPE__'] = (isset(
$object->type) ?
$object->type :
'');
8941 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE__'] =
dol_print_date(
$object->first_subscription_date,
'day');
8943 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_RFC__'] =
dol_print_date(
$object->first_subscription_date,
'dayrfc');
8944 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = (isset(
$object->first_subscription_date_start) ?
dol_print_date(
$object->first_subscription_date_start,
'day') :
'');
8945 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START_RFC__'] = (isset(
$object->first_subscription_date_start) ?
dol_print_date(
$object->first_subscription_date_start,
'dayrfc') :
'');
8946 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = (isset(
$object->first_subscription_date_end) ?
dol_print_date(
$object->first_subscription_date_end,
'day') :
'');
8947 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END_RFC__'] = (isset(
$object->first_subscription_date_end) ?
dol_print_date(
$object->first_subscription_date_end,
'dayrfc') :
'');
8948 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE__'] =
dol_print_date(
$object->last_subscription_date,
'day');
8949 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_RFC__'] =
dol_print_date(
$object->last_subscription_date,
'dayrfc');
8950 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] =
dol_print_date(
$object->last_subscription_date_start,
'day');
8951 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START_RFC__'] =
dol_print_date(
$object->last_subscription_date_start,
'dayrfc');
8952 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] =
dol_print_date(
$object->last_subscription_date_end,
'day');
8953 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END_RFC__'] =
dol_print_date(
$object->last_subscription_date_end,
'dayrfc');
8957 '@phan-var-force Societe $object';
8958 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object(
$object) ?
$object->id :
'');
8959 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object(
$object) ?
$object->name :
'');
8960 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object(
$object) ?
$object->name_alias :
'');
8961 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object(
$object) ?
$object->code_client :
'');
8962 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object(
$object) ?
$object->code_fournisseur :
'');
8963 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object(
$object) ?
$object->email :
'');
8964 $substitutionarray[
'__THIRDPARTY_EMAIL_URLENCODED__'] = urlencode(is_object(
$object) ?
$object->email :
'');
8967 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object(
$object) ?
$object->address :
'');
8968 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object(
$object) ?
$object->zip :
'');
8969 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object(
$object) ?
$object->town :
'');
8970 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object(
$object) ?
$object->country_id :
'');
8971 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object(
$object) ?
$object->country_code :
'');
8972 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object(
$object) ?
$object->idprof1 :
'');
8973 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object(
$object) ?
$object->idprof2 :
'');
8974 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object(
$object) ?
$object->idprof3 :
'');
8975 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object(
$object) ?
$object->idprof4 :
'');
8976 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object(
$object) ?
$object->idprof5 :
'');
8977 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object(
$object) ?
$object->idprof6 :
'');
8978 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object(
$object) ?
$object->tva_intra :
'');
8981 } elseif (is_object(
$object->thirdparty)) {
8982 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->id :
'');
8983 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->name :
'');
8984 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->name_alias :
'');
8985 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->code_client :
'');
8986 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->code_fournisseur :
'');
8987 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->email :
'');
8988 $substitutionarray[
'__THIRDPARTY_EMAIL_URLENCODED__'] = urlencode(is_object(
$object->thirdparty) ?
$object->thirdparty->email :
'');
8991 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->address :
'');
8992 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->zip :
'');
8993 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->town :
'');
8994 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->country_id :
'');
8995 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->country_code :
'');
8996 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof1 :
'');
8997 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof2 :
'');
8998 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof3 :
'');
8999 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof4 :
'');
9000 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof5 :
'');
9001 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof6 :
'');
9002 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->tva_intra :
'');
9007 if (is_object(
$object) &&
$object->element ==
'recruitmentcandidature') {
9008 '@phan-var-force RecruitmentCandidature $object';
9009 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
$object->getFullName($outputlangs);
9010 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] = isset(
$object->firstname) ?
$object->firstname :
'';
9011 $substitutionarray[
'__CANDIDATE_LASTNAME__'] = isset(
$object->lastname) ?
$object->lastname :
'';
9013 if (is_object(
$object) &&
$object->element ==
'conferenceorboothattendee') {
9014 '@phan-var-force ConferenceOrBoothAttendee $object';
9015 $substitutionarray[
'__ATTENDEE_FULLNAME__'] =
$object->getFullName($outputlangs);
9016 $substitutionarray[
'__ATTENDEE_FIRSTNAME__'] = isset(
$object->firstname) ?
$object->firstname :
'';
9017 $substitutionarray[
'__ATTENDEE_LASTNAME__'] = isset(
$object->lastname) ?
$object->lastname :
'';
9021 '@phan-var-force Project $object';
9022 $substitutionarray[
'__PROJECT_ID__'] =
$object->id;
9023 $substitutionarray[
'__PROJECT_REF__'] =
$object->ref;
9024 $substitutionarray[
'__PROJECT_NAME__'] =
$object->title;
9025 } elseif (is_object(
$object)) {
9027 if (!empty(
$object->project)) {
9029 } elseif (!empty(
$object->projet)) {
9032 if (!is_null($project) && is_object($project)) {
9033 $substitutionarray[
'__PROJECT_ID__'] = $project->id;
9034 $substitutionarray[
'__PROJECT_REF__'] = $project->ref;
9035 $substitutionarray[
'__PROJECT_NAME__'] = $project->title;
9040 $project_id =
$object->fk_project;
9041 } elseif (!empty(
$object->fk_projet) &&
$object->fk_projet > 0) {
9042 $project_id =
$object->fk_project;
9044 if ($project_id > 0) {
9046 $substitutionarray[
'__PROJECT_ID__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9047 $substitutionarray[
'__PROJECT_REF__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9048 $substitutionarray[
'__PROJECT_NAME__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9054 '@phan-var-force Facture $object';
9055 $substitutionarray[
'__INVOICE_SITUATION_NUMBER__'] = isset(
$object->situation_counter) ?
$object->situation_counter :
'';
9058 '@phan-var-force Expedition $object';
9059 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
$object->tracking_number;
9060 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
$object->tracking_url;
9061 $substitutionarray[
'__SHIPPINGMETHOD__'] =
$object->shipping_method;
9064 '@phan-var-force Reception $object';
9065 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
$object->tracking_number;
9066 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
$object->tracking_url;
9070 '@phan-var-force Contrat $object';
9071 $dateplannedstart =
'';
9072 $datenextexpiration =
'';
9073 foreach (
$object->lines as $line) {
9074 if ($line->date_start > $dateplannedstart) {
9075 $dateplannedstart = $line->date_start;
9077 if ($line->statut == 4 && $line->date_end && (!$datenextexpiration || $line->date_end < $datenextexpiration)) {
9078 $datenextexpiration = $line->date_end;
9081 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
dol_print_date($dateplannedstart,
'day');
9082 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE_RFC__'] =
dol_print_date($dateplannedstart,
'dayrfc');
9083 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
dol_print_date($dateplannedstart,
'standard');
9085 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
dol_print_date($datenextexpiration,
'day');
9086 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE_RFC__'] =
dol_print_date($datenextexpiration,
'dayrfc');
9087 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
dol_print_date($datenextexpiration,
'standard');
9091 '@phan-var-force Ticket $object';
9092 $substitutionarray[
'__TICKET_TRACKID__'] =
$object->track_id;
9093 $substitutionarray[
'__TICKET_SUBJECT__'] =
$object->subject;
9094 $substitutionarray[
'__TICKET_TYPE__'] =
$object->type_code;
9095 $substitutionarray[
'__TICKET_SEVERITY__'] =
$object->severity_code;
9096 $substitutionarray[
'__TICKET_CATEGORY__'] =
$object->category_code;
9097 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
$object->category_code;
9098 $substitutionarray[
'__TICKET_MESSAGE__'] =
$object->message;
9099 $substitutionarray[
'__TICKET_PROGRESSION__'] =
$object->progress;
9100 $userstat =
new User($db);
9101 if (
$object->fk_user_assign > 0) {
9102 $userstat->fetch(
$object->fk_user_assign);
9103 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
9106 if (
$object->fk_user_create > 0) {
9107 $userstat->fetch(
$object->fk_user_create);
9108 $substitutionarray[
'__USER_CREATE__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
9114 if (!is_object($extrafields)) {
9117 $extrafields->fetch_name_optionals_label(
$object->table_element,
true);
9119 if (
$object->fetch_optionals() > 0) {
9120 if (is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label']) > 0) {
9121 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $label) {
9122 if ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'date') {
9123 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'day');
9124 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'day',
'tzserver', $outputlangs);
9125 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'dayrfc');
9126 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'datetime') {
9127 $datetime =
$object->array_options[
'options_'.$key];
9128 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
9129 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
9130 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_DAY_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'day',
'tzserver', $outputlangs) :
'');
9131 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
9132 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'phone') {
9133 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_phone(
$object->array_options[
'options_'.$key]);
9134 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'price') {
9135 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
$object->array_options[
'options_'.$key];
9136 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATED__'] =
price(
$object->array_options[
'options_'.$key]);
9137 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATTED__'] =
price(
$object->array_options[
'options_'.$key]);
9138 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separator') {
9139 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = !empty(
$object->array_options[
'options_'.$key]) ?
$object->array_options[
'options_'.$key] :
'';
9147 if (empty($substitutionarray[
'__REF__'])) {
9151 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
9152 $outputlangs->loadLangs(array(
'paypal',
'other'));
9155 $typeforonlinepayment =
'free';
9157 $typeforonlinepayment =
'order';
9160 $typeforonlinepayment =
'invoice';
9163 $typeforonlinepayment =
'member';
9164 if (!empty(
$object->last_subscription_amount)) {
9165 $amounttouse =
$object->last_subscription_amount;
9169 $typeforonlinepayment =
'contract';
9172 $typeforonlinepayment =
'ficheinter';
9175 $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray[
'__REF__'], $amounttouse);
9180 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ? str_replace(
'\n',
"\n", $outputlangs->trans(
"PredefinedMailContentLink", $paymenturl)) :
'');
9181 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] = $paymenturl;
9184 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
$object->getLastMainDocLink(
$object->element);
9186 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'';
9189 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
$object->getLastMainDocLink(
$object->element);
9191 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'';
9194 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
$object->getLastMainDocLink(
$object->element);
9196 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'';
9199 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
$object->getLastMainDocLink(
$object->element);
9201 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'';
9204 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] =
$object->getLastMainDocLink(
$object->element);
9206 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] =
'';
9209 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
$object->getLastMainDocLink(
$object->element);
9211 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'';
9215 '@phan-var-force Propal $object';
9216 $substitutionarray[
'__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/comm/propal/card.php?id=".
$object->id;
9217 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9218 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'proposal',
$object->ref, 1,
$object);
9221 '@phan-var-force Commande $object';
9222 $substitutionarray[
'__URL_ORDER__'] = DOL_MAIN_URL_ROOT.
"/commande/card.php?id=".
$object->id;
9225 '@phan-var-force Facture $object';
9226 $substitutionarray[
'__URL_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/compta/facture/card.php?id=".
$object->id;
9229 '@phan-var-force Contrat $object';
9230 $substitutionarray[
'__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT.
"/contrat/card.php?id=".
$object->id;
9231 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9232 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'contract',
$object->ref, 1,
$object);
9235 '@phan-var-force Fichinter $object';
9236 $substitutionarray[
'__URL_FICHINTER__'] = DOL_MAIN_URL_ROOT.
"/fichinter/card.php?id=".
$object->id;
9237 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9238 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0,
'fichinter',
$object->ref, 1,
$object);
9240 if (is_object(
$object) &&
$object->element ==
'supplier_proposal') {
9241 '@phan-var-force SupplierProposal $object';
9242 $substitutionarray[
'__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/supplier_proposal/card.php?id=".
$object->id;
9244 if (is_object(
$object) &&
$object->element ==
'invoice_supplier') {
9245 '@phan-var-force FactureFournisseur $object';
9246 $substitutionarray[
'__URL_SUPPLIER_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/fourn/facture/card.php?id=".
$object->id;
9249 '@phan-var-force Expedition $object';
9250 $substitutionarray[
'__URL_SHIPMENT__'] = DOL_MAIN_URL_ROOT.
"/expedition/card.php?id=".
$object->id;
9255 '@phan-var-force ActionComm $object';
9256 $substitutionarray[
'__EVENT_LABEL__'] =
$object->label;
9257 $substitutionarray[
'__EVENT_TYPE__'] = $outputlangs->trans(
"Action".
$object->type_code);
9259 $substitutionarray[
'__EVENT_TIME__'] =
dol_print_date(
$object->datep,
'hour',
'auto', $outputlangs);
9263 if ((empty($exclude) || !in_array(
'objectamount', $exclude)) && (empty($include) || in_array(
'objectamount', $include))) {
9264 '@phan-var-force Facture|FactureRec $object';
9265 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functionsnumtoword.lib.php';
9268 $substitutionarray[
'__DATE_DUE_YMD__'] = is_object(
$object) ? (isset(
$object->date_lim_reglement) ?
dol_print_date(
$object->date_lim_reglement,
'day', 0, $outputlangs) : null) :
'';
9270 $substitutionarray[
'__DATE_DUE_YMD_TEXT__'] = is_object(
$object) ? (isset(
$object->date_lim_reglement) ?
dol_print_date(
$object->date_lim_reglement,
'daytext', 0, $outputlangs) : null) :
'';
9272 $already_payed_all = 0;
9277 $substitutionarray[
'__AMOUNT_EXCL_TAX__'] = is_object(
$object) ?
$object->total_ht :
'';
9279 $substitutionarray[
'__AMOUNT_EXCL_TAX_TEXTCURRENCY__'] = is_object(
$object) ?
dol_convertToWord(
$object->total_ht, $outputlangs, $conf->currency,
true) :
'';
9281 $substitutionarray[
'__AMOUNT__'] = is_object(
$object) ?
$object->total_ttc :
'';
9285 $substitutionarray[
'__AMOUNT_REMAIN__'] = is_object(
$object) ?
price2num(
$object->total_ttc - $already_payed_all,
'MT') :
'';
9287 $substitutionarray[
'__AMOUNT_VAT__'] = is_object(
$object) ? (isset(
$object->total_vat) ?
$object->total_vat :
$object->total_tva) :
'';
9291 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
9292 $substitutionarray[
'__AMOUNT_TAX2__'] = is_object(
$object) ?
$object->total_localtax1 :
'';
9294 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
9295 $substitutionarray[
'__AMOUNT_TAX3__'] = is_object(
$object) ?
$object->total_localtax2 :
'';
9299 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATTED__'] = is_object(
$object) ? (
$object->total_ht ?
price(
$object->total_ht, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) :
'';
9300 $substitutionarray[
'__AMOUNT_FORMATTED__'] = is_object(
$object) ? (
$object->total_ttc ?
price(
$object->total_ttc, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) :
'';
9301 $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) :
'';
9302 $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)) :
'';
9303 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
9304 $substitutionarray[
'__AMOUNT_TAX2_FORMATTED__'] = is_object(
$object) ? (
$object->total_localtax1 ?
price(
$object->total_localtax1, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) :
'';
9306 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
9307 $substitutionarray[
'__AMOUNT_TAX3_FORMATTED__'] = is_object(
$object) ? (
$object->total_localtax2 ?
price(
$object->total_localtax2, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) :
'';
9310 if ($onlykey != 2) {
9311 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATED__'] = $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATTED__'];
9312 $substitutionarray[
'__AMOUNT_FORMATED__'] = $substitutionarray[
'__AMOUNT_FORMATTED__'];
9313 $substitutionarray[
'__AMOUNT_REMAIN_FORMATED__'] = $substitutionarray[
'__AMOUNT_REMAIN_FORMATTED__'];
9314 $substitutionarray[
'__AMOUNT_VAT_FORMATED__'] = $substitutionarray[
'__AMOUNT_VAT_FORMATTED__'];
9315 if ($mysoc instanceof
Societe && $mysoc->useLocalTax(1)) {
9316 $substitutionarray[
'__AMOUNT_TAX2_FORMATED__'] = $substitutionarray[
'__AMOUNT_TAX2_FORMATTED__'];
9318 if ($mysoc instanceof
Societe && $mysoc->useLocalTax(2)) {
9319 $substitutionarray[
'__AMOUNT_TAX3_FORMATED__'] = $substitutionarray[
'__AMOUNT_TAX3_FORMATTED__'];
9323 $substitutionarray[
'__AMOUNT_MULTICURRENCY__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
$object->multicurrency_total_ttc :
'';
9324 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXT__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
dol_convertToWord(
$object->multicurrency_total_ttc, $outputlangs,
'',
true) :
'';
9325 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXTCURRENCY__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
dol_convertToWord(
$object->multicurrency_total_ttc, $outputlangs,
$object->multicurrency_code,
true) :
'';
9329 if ($onlykey != 2) {
9330 $substitutionarray[
'__TOTAL_TTC__'] = is_object(
$object) ?
$object->total_ttc :
'';
9331 $substitutionarray[
'__TOTAL_HT__'] = is_object(
$object) ?
$object->total_ht :
'';
9337 if ((empty($exclude) || !in_array(
'date', $exclude)) && (empty($include) || in_array(
'date', $include))) {
9338 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
9348 $daytext = $outputlangs->trans(
'Day'.$tmp[
'wday']);
9350 $substitutionarray = array_merge($substitutionarray, array(
9351 '__NOW_TMS__' => (
string) $now,
9352 '__NOW_TMS_YMD__' =>
dol_print_date($now,
'day',
'auto', $outputlangs),
9353 '__DAY__' => (
string) $tmp[
'mday'],
9354 '__DAY_TEXT__' => $daytext,
9355 '__DAY_TEXT_SHORT__' =>
dol_trunc($daytext, 3,
'right',
'UTF-8', 1),
9356 '__DAY_TEXT_MIN__' =>
dol_trunc($daytext, 1,
'right',
'UTF-8', 1),
9357 '__MONTH__' => (
string) $tmp[
'mon'],
9358 '__MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp[
'mon'])),
9359 '__MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp[
'mon'])),
9360 '__MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp[
'mon'])),
9361 '__YEAR__' => (
string) $tmp[
'year'],
9362 '__PREVIOUS_DAY__' => (
string) $tmp2[
'day'],
9363 '__PREVIOUS_MONTH__' => (
string) $tmp3[
'month'],
9364 '__PREVIOUS_YEAR__' => (
string) ($tmp[
'year'] - 1),
9365 '__NEXT_DAY__' => (
string) $tmp4[
'day'],
9366 '__NEXT_MONTH__' => (
string) $tmp5[
'month'],
9367 '__NEXT_MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp5[
'month'])),
9368 '__NEXT_MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp5[
'month'])),
9369 '__NEXT_MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp5[
'month'])),
9370 '__NEXT_YEAR__' => (
string) ($tmp[
'year'] + 1),
9374 if (isModEnabled(
'multicompany')) {
9375 $substitutionarray = array_merge($substitutionarray, array(
'__ENTITY_ID__' => $conf->entity));
9377 if ((empty($exclude) || !in_array(
'system', $exclude)) && (empty($include) || in_array(
'user', $include))) {
9378 $substitutionarray[
'__DOL_MAIN_URL_ROOT__'] = DOL_MAIN_URL_ROOT;
9379 $substitutionarray[
'__(AnyTranslationKey)__'] = $outputlangs->trans(
'TranslationOfKey');
9380 $substitutionarray[
'__(AnyTranslationKey|langfile)__'] = $outputlangs->trans(
'TranslationOfKey').
' (load also language file before)';
9381 $substitutionarray[
'__[AnyConstantKey]__'] = $outputlangs->trans(
'ValueOfConstantKey');
9386 return $substitutionarray;
9405function make_substitutions($text, $substitutionarray, $outputlangs =
null, $converttextinhtmlifnecessary = 0)
9407 global $conf, $db, $langs;
9409 if (!is_array($substitutionarray)) {
9410 return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
9413 if (empty($outputlangs)) {
9414 $outputlangs = $langs;
9424 if (is_object($outputlangs)) {
9426 while (preg_match(
'/__\(([^\)]+)\)__/', $text, $reg)) {
9428 $tmp = explode(
'|', $reg[1]);
9429 if (!empty($tmp[1])) {
9430 $outputlangs->load($tmp[1]);
9433 $value = $outputlangs->transnoentitiesnoconv($reg[1]);
9435 if (empty($converttextinhtmlifnecessary)) {
9437 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
9451 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $value, $text);
9459 while (preg_match(
'/__\[([^\]]+)\]__/', $text, $reg)) {
9460 $keyfound = $reg[1];
9462 $value =
'*****forbidden*****';
9464 $value = empty($conf->global->$keyfound) ?
'' : $conf->global->$keyfound;
9467 if (empty($converttextinhtmlifnecessary)) {
9469 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
9482 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $value, $text);
9487 foreach ($substitutionarray as $key => $value) {
9488 if (!isset($value)) {
9492 if (($key ==
'__USER_SIGNATURE__' || $key ==
'__SENDEREMAIL_SIGNATURE__') && (
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN'))) {
9496 if (empty($converttextinhtmlifnecessary)) {
9497 $text = str_replace(
"$key",
"$value", $text);
9509 $text = str_replace(
"$key",
"$value", $text);
9525 $memory_object_list = array();
9526 foreach ($substitutionarray as $key => $value) {
9527 $lazy_load_arr = array();
9528 if (preg_match(
'/(__[A-Z\_]+__)@lazyload$/', $key, $lazy_load_arr)) {
9529 if (isset($lazy_load_arr[1]) && !empty($lazy_load_arr[1])) {
9530 $key_to_substitute = $lazy_load_arr[1];
9531 if (preg_match(
'/' . preg_quote($key_to_substitute,
'/') .
'/', $text)) {
9532 $param_arr = explode(
':', $value);
9534 if (count($param_arr) == 4) {
9535 $path = $param_arr[0];
9536 $class = $param_arr[1];
9537 $method = $param_arr[2];
9538 $id = (int) $param_arr[3];
9541 if (!isset($memory_object_list[$class])) {
9543 require_once DOL_DOCUMENT_ROOT . $path;
9544 if (class_exists($class)) {
9545 $memory_object_list[$class] = array(
9553 if (isset($memory_object_list[$class]) && isset($memory_object_list[$class][
'list'])) {
9554 if (method_exists($class, $method)) {
9555 if (!isset($memory_object_list[$class][
'list'][$id])) {
9556 $tmpobj =
new $class($db);
9558 $valuetouseforsubstitution = $tmpobj->$method($id, $key_to_substitute);
9559 $memory_object_list[$class][
'list'][$id] = $tmpobj;
9562 $tmpobj = $memory_object_list[$class][
'list'][$id];
9564 $valuetouseforsubstitution = $tmpobj->$method($id, $key_to_substitute,
true);
9567 $text = str_replace(
"$key_to_substitute",
"$valuetouseforsubstitution", $text);
9593 global $conf, $user;
9595 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
9600 $dirsubstitutions = array_merge(array(), (array) $conf->modules_parts[
'substitutions']);
9602 foreach ($dirsubstitutions as $reldir) {
9610 $substitfiles =
dol_dir_list($dir,
'files', 0,
'functions_');
9611 foreach ($substitfiles as $substitfile) {
9613 if (preg_match(
'/functions_(.*)\.lib\.php/i', $substitfile[
'name'], $reg)) {
9616 dol_syslog(
"Library ".$substitfile[
'name'].
" found into ".$dir);
9618 require_once $dir.$substitfile[
'name'];
9620 $function_name = $module.
"_".$callfunc;
9621 if (function_exists($function_name)) {
9622 $function_name($substitutionarray, $outputlangs,
$object, $parameters);
9630 foreach ($substitutionarray as $key => $value) {
9631 $tags .=
'{'.$key.
'} => '.$value.
"\n";
9633 $substitutionarray = array_merge($substitutionarray, array(
'__ALL_TAGS__' => $tags));
9646function print_date_range($date_start, $date_end, $format =
'', $outputlangs =
null)
9648 print
get_date_range($date_start, $date_end, $format, $outputlangs);
9661function get_date_range($date_start, $date_end, $format =
'', $outputlangs =
null, $withparenthesis = 1)
9667 if (!is_object($outputlangs)) {
9668 $outputlangs = $langs;
9671 if ($date_start && $date_end) {
9672 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFromTo',
dol_print_date($date_start, $format,
false, $outputlangs),
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
9674 if ($date_start && !$date_end) {
9675 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($date_start, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
9677 if (!$date_start && $date_end) {
9678 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
9698 if ($nameorder < 0) {
9701 if ($nameorder == 1) {
9703 if ($firstname && $lastname) {
9707 } elseif ($nameorder == 2 || $nameorder == 3) {
9709 if (empty($ret) && $nameorder == 3) {
9714 if (empty($ret) && $nameorder == 5) {
9717 if ($nameorder == 0) {
9718 if ($firstname && $lastname) {
9742 if (!is_array($mesgs)) {
9743 $mesgs = trim((
string) $mesgs);
9746 if (!empty($noduplicate) && isset($_SESSION[
'dol_events'][$style]) && in_array($mesgs, $_SESSION[
'dol_events'][$style])) {
9749 $_SESSION[
'dol_events'][$style][] = $mesgs;
9753 foreach ($mesgs as $mesg) {
9754 $mesg = trim((
string) $mesg);
9756 if (!empty($noduplicate) && isset($_SESSION[
'dol_events'][$style]) && in_array($mesg, $_SESSION[
'dol_events'][$style])) {
9759 $_SESSION[
'dol_events'][$style][] = $mesg;
9777function setEventMessages($mesg, $mesgs, $style =
'mesgs', $messagekey =
'', $noduplicate = 0)
9779 if (empty($mesg) && empty($mesgs)) {
9780 dol_syslog(
"Try to add a message in stack, but value to add is empty message", LOG_WARNING);
9787 if (empty($messagekey) || empty($_COOKIE[
"DOLHIDEMESSAGE".$messagekey])) {
9788 if (!in_array((
string) $style, array(
'mesgs',
'warnings',
'errors'))) {
9789 dol_print_error(
null,
'Bad parameter style='.$style.
' for setEventMessages');
9791 if (empty($mesgs)) {
9794 if (!empty($mesg) && !in_array($mesg, $mesgs)) {
9815 if (isset($_SESSION[
'dol_events'][
'mesgs'])) {
9816 if (empty($disabledoutputofmessages)) {
9819 unset($_SESSION[
'dol_events'][
'mesgs']);
9822 if (isset($_SESSION[
'dol_events'][
'errors'])) {
9823 if (empty($disabledoutputofmessages)) {
9826 unset($_SESSION[
'dol_events'][
'errors']);
9830 if (isset($_SESSION[
'dol_events'][
'warnings'])) {
9831 if (empty($disabledoutputofmessages)) {
9834 unset($_SESSION[
'dol_events'][
'warnings']);
9852function get_htmloutput_mesg($mesgstring =
'', $mesgarray = [], $style =
'ok', $keepembedded = 0)
9854 global $conf, $langs;
9859 $divstart = $divend =
'';
9862 if ((empty($conf->use_javascript_ajax) ||
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') || $keepembedded) && !preg_match(
'/<div class=".*">/i', $out)) {
9863 $divstart =
'<div class="'.$style.
' clearboth">';
9867 if ((is_array($mesgarray) && count($mesgarray)) || $mesgstring) {
9868 $langs->load(
"errors");
9870 if (is_array($mesgarray) && count($mesgarray)) {
9871 foreach ($mesgarray as $message) {
9873 $out .= $langs->trans($message);
9874 if ($ret < count($mesgarray)) {
9881 $out .= $langs->trans($mesgstring);
9887 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') && empty($keepembedded)) {
9888 $return =
'<script nonce="'.getNonce().
'">
9889 $(document).ready(function() {
9894 /* jnotify(message, preset of message type, keepmessage) */
9896 "'.($style ==
"ok" ? 3000 : $style).
'",
9897 '.($style ==
"ok" ?
"false" :
"true").
',
9898 { remove: function (){} } );
9939function dol_htmloutput_mesg($mesgstring =
'', $mesgarray = array(), $style =
'ok', $keepembedded = 0)
9941 if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) {
9947 if (is_array($mesgarray)) {
9948 foreach ($mesgarray as $val) {
9949 if ($val && preg_match(
'/class="error"/i', $val)) {
9953 if ($val && preg_match(
'/class="warning"/i', $val)) {
9958 } elseif ($mesgstring && preg_match(
'/class="error"/i', $mesgstring)) {
9960 } elseif ($mesgstring && preg_match(
'/class="warning"/i', $mesgstring)) {
9963 if ($style ==
'error') {
9966 if ($style ==
'warning') {
9970 if ($iserror || $iswarning) {
9972 $mesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $mesgstring);
9973 $mesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $mesgstring);
9974 $mesgstring = preg_replace(
'/<\/div>/',
'', $mesgstring);
9976 if (is_array($mesgarray)) {
9977 $newmesgarray = array();
9978 foreach ($mesgarray as $val) {
9979 if (is_string($val)) {
9980 $tmpmesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $val);
9981 $tmpmesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $tmpmesgstring);
9982 $tmpmesgstring = preg_replace(
'/<\/div>/',
'', $tmpmesgstring);
9983 $newmesgarray[] = $tmpmesgstring;
9985 dol_syslog(
"Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING);
9988 $mesgarray = $newmesgarray;
9990 print
get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ?
'error' :
'warning'), $keepembedded);
10025function dol_sort_array(&$array, $index, $order =
'asc', $natsort = 0, $case_sensitive = 0, $keepindex = 0)
10028 $order = strtolower($order);
10030 if (is_array($array)) {
10031 $sizearray = count($array);
10032 if ($sizearray > 0) {
10034 foreach (array_keys($array) as $key) {
10035 if (is_object($array[$key])) {
10036 $temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index;
10039 $temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index];
10041 if ($natsort == -1) {
10042 $temp[$key] =
'___'.$temp[$key];
10046 if (empty($natsort) || $natsort == -1) {
10047 if ($order ==
'asc') {
10053 if ($case_sensitive) {
10056 natcasesort($temp);
10058 if ($order !=
'asc') {
10059 $temp = array_reverse($temp,
true);
10065 foreach (array_keys($temp) as $key) {
10066 (is_numeric($key) && empty($keepindex)) ? $sorted[] = $array[$key] : $sorted[$key] = $array[$key];
10085 $str = (string) $str;
10088 $strLength = strlen($str);
10089 for ($i = 0; $i < $strLength; $i++) {
10090 if (ord($str[$i]) < 0x80) {
10092 } elseif ((ord($str[$i]) & 0xE0) == 0xC0) {
10094 } elseif ((ord($str[$i]) & 0xF0) == 0xE0) {
10096 } elseif ((ord($str[$i]) & 0xF8) == 0xF0) {
10098 } elseif ((ord($str[$i]) & 0xFC) == 0xF8) {
10100 } elseif ((ord($str[$i]) & 0xFE) == 0xFC) {
10105 for ($j = 0; $j < $n; $j++) {
10106 if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) {
10127 return preg_match(
'//u', $str) ? true :
false;
10139 if (function_exists(
'mb_check_encoding')) {
10141 if (!mb_check_encoding($str,
'ASCII')) {
10145 if (preg_match(
'/[^\x00-\x7f]/', $str)) {
10163 $tmp = ini_get(
"unicode.filesystem_encoding");
10164 if (empty($tmp) && !empty($_SERVER[
"WINDIR"])) {
10165 $tmp =
'iso-8859-1';
10174 if ($tmp ==
'iso-8859-1') {
10175 return mb_convert_encoding($str,
'ISO-8859-1',
'UTF-8');
10195function dol_getIdFromCode($db, $key, $tablename, $fieldkey =
'code', $fieldid =
'id', $entityfilter = 0, $filters =
'')
10205 if (isset($conf->cache[
'codeid'][$tablename][$key][$fieldid])) {
10206 return $conf->cache[
'codeid'][$tablename][$key][$fieldid];
10209 dol_syslog(
'dol_getIdFromCode (value for field '.$fieldid.
' from key '.$key.
' not found into cache)', LOG_DEBUG);
10211 $sql =
"SELECT ".$fieldid.
" as valuetoget";
10212 $sql .=
" FROM ".MAIN_DB_PREFIX.$tablename;
10213 $sql .=
" WHERE ".$fieldkey.
" = '".$db->escape($key).
"'";
10214 if (!empty($entityfilter)) {
10215 $sql .=
" AND entity IN (".getEntity($tablename).
")";
10221 $resql = $db->query($sql);
10223 $obj = $db->fetch_object($resql);
10225 $conf->cache[
'codeid'][$tablename][$key][$fieldid] = $obj->valuetoget;
10227 $conf->cache[
'codeid'][$tablename][$key][$fieldid] =
'';
10231 return $conf->cache[
'codeid'][$tablename][$key][$fieldid];
10248 if ($matchrule == 1) {
10249 if ($var ==
'mainmenu') {
10251 return (preg_match(
'/^'.$regextext.
'/', $mainmenu));
10252 } elseif ($var ==
'leftmenu') {
10254 return (preg_match(
'/^'.$regextext.
'/', $leftmenu));
10256 return 'This variable is not accessible with dol_eval';
10259 return 'This value for matchrule is not implemented';
10273function verifCond($strToEvaluate, $onlysimplestring =
'1')
10277 if (isset($strToEvaluate) && $strToEvaluate !==
'') {
10280 $rep =
dol_eval($strToEvaluate, 1, 1, $onlysimplestring);
10281 $rights = (bool) $rep && (!is_string($rep) || strpos($rep,
'Bad string syntax to evaluate') ===
false);
10301function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring =
'1')
10305 global $db, $langs, $user, $website, $websitepage;
10306 global $action, $mainmenu, $leftmenu;
10308 global $objectoffield;
10314 $isObBufferActive =
false;
10315 if (!in_array($onlysimplestring, array(
'0',
'1',
'2'))) {
10316 return "Bad call of dol_eval. Parameter onlysimplestring must be '0' (deprecated), '1' or '2'";
10321 if ($onlysimplestring ==
'1' || $onlysimplestring ==
'2') {
10327 $specialcharsallowed =
'^$_+-.*>&|=!?():"\',/@';
10328 if ($onlysimplestring ==
'2') {
10329 $specialcharsallowed .=
'[]';
10332 $specialcharsallowed .=
getDolGlobalString(
'MAIN_ALLOW_UNSECURED_SPECIAL_CHARS_IN_DOL_EVAL');
10334 if (preg_match(
'/[^a-z0-9\s'.preg_quote($specialcharsallowed,
'/').
']/i', $s)) {
10335 if ($returnvalue) {
10336 return 'Bad string syntax to evaluate (found chars that are not chars for a simple clean eval string): '.$s;
10338 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for a simple clean eval string): '.$s, LOG_WARNING);
10344 if (preg_match(
'/\$[\w]*\s*\(/', $s)) {
10345 if ($returnvalue) {
10346 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;
10348 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);
10356 while ($scheck && $savescheck != $scheck) {
10357 $savescheck = $scheck;
10358 $scheck = preg_replace(
'/->[a-zA-Z0-9_]+\(/',
'->__METHOD__', $scheck);
10359 $scheck = preg_replace(
'/^\(/',
'__PARENTHESIS__ ', $scheck);
10360 $scheck = preg_replace(
'/\s\(/',
'__PARENTHESIS__ ', $scheck);
10361 $scheck = preg_replace(
'/^!?[a-zA-Z0-9_]+\(/',
'__FUNCTION__', $scheck);
10362 $scheck = preg_replace(
'/\s!?[a-zA-Z0-9_]+\(/',
'__FUNCTION__', $scheck);
10363 $scheck = preg_replace(
'/(\^|\')\(/',
'__REGEXSTART__', $scheck);
10366 if (strpos($scheck,
'(') !==
false) {
10367 if ($returnvalue) {
10368 return 'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found call of a function or method without using the direct name of the function): '.$s;
10370 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);
10379 if (is_array($s) || $s ===
'Array') {
10380 if ($returnvalue) {
10381 return 'Bad string syntax to evaluate (value is Array): '.var_export($s,
true);
10383 dol_syslog(
'Bad string syntax to evaluate (value is Array): '.var_export($s,
true), LOG_WARNING);
10387 if (strpos($s,
'::') !==
false) {
10388 if ($returnvalue) {
10389 return 'Bad string syntax to evaluate (double : char is forbidden): '.$s;
10391 dol_syslog(
'Bad string syntax to evaluate (double : char is forbidden): '.$s, LOG_WARNING);
10395 if (strpos($s,
'`') !==
false) {
10396 if ($returnvalue) {
10397 return 'Bad string syntax to evaluate (backtick char is forbidden): '.$s;
10399 dol_syslog(
'Bad string syntax to evaluate (backtick char is forbidden): '.$s, LOG_WARNING);
10403 if (preg_match(
'/[^0-9]+\.[^0-9]+/', $s)) {
10404 if ($returnvalue) {
10405 return 'Bad string syntax to evaluate (dot char is forbidden): '.$s;
10407 dol_syslog(
'Bad string syntax to evaluate (dot char is forbidden): '.$s, LOG_WARNING);
10413 $forbiddenphpstrings = array(
'$$',
'$_',
'}[');
10414 $forbiddenphpstrings = array_merge($forbiddenphpstrings, array(
'_ENV',
'_SESSION',
'_COOKIE',
'_GET',
'_POST',
'_REQUEST',
'ReflectionFunction'));
10416 $forbiddenphpfunctions = array();
10418 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"base64".
"_".
"decode",
"rawurl".
"decode",
"url".
"decode",
"str".
"_rot13",
"hex".
"2bin"));
10419 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"fopen",
"file_put_contents",
"fputs",
"fputscsv",
"fwrite",
"fpassthru",
"require",
"include",
"mkdir",
"rmdir",
"symlink",
"touch",
"unlink",
"umask"));
10420 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"override_function",
"session_id",
"session_create_id",
"session_regenerate_id"));
10421 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"get_defined_functions",
"get_defined_vars",
"get_defined_constants",
"get_declared_classes"));
10422 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"function",
"call_user_func"));
10423 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"require",
"include",
"require_once",
"include_once"));
10424 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"exec",
"passthru",
"shell_exec",
"system",
"proc_open",
"popen"));
10425 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_eval",
"executeCLI",
"verifCond"));
10426 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"eval",
"create_function",
"assert",
"mb_ereg_replace"));
10427 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_compress_dir",
"dol_decode",
"dol_delete_file",
"dol_delete_dir",
"dol_delete_dir_recursive",
"dol_copy",
"archiveOrBackupFile"));
10429 $forbiddenphpmethods = array(
'invoke',
'invokeArgs');
10431 $forbiddenphpregex =
'global\s+\$|\b('.implode(
'|', $forbiddenphpfunctions).
')\b';
10433 $forbiddenphpmethodsregex =
'->('.implode(
'|', $forbiddenphpmethods).
')';
10436 $oldstringtoclean = $s;
10437 $s = str_ireplace($forbiddenphpstrings,
'__forbiddenstring__', $s);
10438 $s = preg_replace(
'/'.$forbiddenphpregex.
'/i',
'__forbiddenstring__', $s);
10439 $s = preg_replace(
'/'.$forbiddenphpmethodsregex.
'/i',
'__forbiddenstring__', $s);
10441 }
while ($oldstringtoclean != $s);
10444 if (strpos($s,
'__forbiddenstring__') !==
false) {
10445 dol_syslog(
'Bad string syntax to evaluate: '.$s, LOG_WARNING);
10446 if ($returnvalue) {
10447 return 'Bad string syntax to evaluate: '.$s;
10449 dol_syslog(
'Bad string syntax to evaluate: '.$s);
10455 if ($returnvalue) {
10458 $isObBufferActive =
true;
10459 $tmps = @eval(
'return '.$s.
';');
10460 $tmpo = ob_get_clean();
10461 $isObBufferActive =
false;
10463 print
'Bad string syntax to evaluate. Some data were output when it should not when evaluating: '.$s;
10468 $isObBufferActive =
true;
10469 $tmps = eval(
'return '.$s.
';');
10470 $tmpo = ob_get_clean();
10471 $isObBufferActive =
false;
10473 print
'Bad string syntax to evaluate. Some data were output when it should not when evaluating: '.$s;
10478 dol_syslog(
'Do not use anymore dol_eval with param returnvalue=0', LOG_WARNING);
10486 }
catch (Error $e) {
10487 if ($isObBufferActive) {
10489 $tmpo = ob_get_clean();
10490 $isObBufferActive =
false;
10492 $error =
'dol_eval try/catch error : ';
10493 $error .= $e->getMessage();
10495 if ($returnvalue) {
10496 return 'Exception during evaluation: '.$s;
10512 return (trim($element) !=
'');
10525 if (empty($codelang)) {
10529 if ($codelang ==
'auto') {
10530 return '<span class="fa fa-language"></span>';
10533 $langtocountryflag = array(
10535 'ca_ES' =>
'catalonia',
10539 'sw_SW' =>
'unknown',
10549 if (isset($langtocountryflag[$codelang])) {
10550 $flagImage = $langtocountryflag[$codelang];
10552 $tmparray = explode(
'_', $codelang);
10553 $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
10558 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
10559 $morecss = $reg[1];
10564 return '<span class="flag-sprite '.strtolower($flagImage).($morecss ?
' '.$morecss :
'').
'"'.($moreatt ?
' '.$moreatt :
'').(!$notitlealt ?
' title="'.$codelang.
'"' :
'').
'></span>';
10578 if (empty($countrycode)) {
10582 if (strtoupper($countrycode) ==
'MQ') {
10585 if (strtoupper($countrycode) ==
'SE') {
10588 if (strtoupper($countrycode) ==
'CH') {
10589 if ($mysoc->country_code ==
'FR') {
10592 if ($mysoc->country_code ==
'DE') {
10595 if ($mysoc->country_code ==
'IT') {
10777 $buildprimarykeytotest = strtolower($countrycode).
'-'.strtoupper($countrycode);
10778 if (in_array($buildprimarykeytotest, $locales)) {
10779 return strtolower($countrycode).
'_'.strtoupper($countrycode);
10782 if (function_exists(
'locale_get_primary_language') && function_exists(
'locale_get_region')) {
10783 foreach ($locales as $locale) {
10784 $locale_language = locale_get_primary_language($locale);
10785 $locale_region = locale_get_region($locale);
10786 if (strtoupper($countrycode) == $locale_region) {
10788 return strtolower($locale_language).
'_'.strtoupper($locale_region);
10792 dol_syslog(
"Warning Extension php-intl is not available", LOG_WARNING);
10830 global $hookmanager, $db;
10832 if (isset($conf->modules_parts[
'tabs'][$type]) && is_array($conf->modules_parts[
'tabs'][$type])) {
10833 foreach ($conf->modules_parts[
'tabs'][$type] as $value) {
10834 $values = explode(
':', $value);
10837 if ($mode ==
'add' && !preg_match(
'/^\-/', $values[1])) {
10842 $posstart = strpos($str,
'(');
10843 if ($posstart > 0) {
10844 $posend = strpos($str,
')');
10845 if ($posstart > 0) {
10846 $res1 = substr($str, $posstart + 1, $posend - $posstart - 1);
10847 if (is_numeric($res1)) {
10848 $postab = (int) $res1;
10849 $values[1] =
'+' . substr($str, $posend + 1);
10853 if (count($values) == 6) {
10857 if ($values[0] != $type) {
10863 if ($filterorigmodule) {
10864 if (strpos($values[3],
'@')) {
10865 if ($filterorigmodule !=
'external') {
10869 if ($filterorigmodule !=
'core') {
10874 $langs->load($values[3]);
10876 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
10878 $substitutionarray = array();
10883 $labeltemp = explode(
',', $values[2]);
10884 $label = $langs->trans($labeltemp[0]);
10886 if (!empty($labeltemp[1]) && is_object(
$object) && !empty(
$object->id)) {
10888 $classtoload = $labeltemp[1];
10889 if (class_exists($classtoload)) {
10890 $obj =
new $classtoload($db);
10891 $function = $labeltemp[3];
10892 if ($obj && $function && method_exists($obj, $function)) {
10894 $nbrec = $obj->$function(
$object->id, $obj);
10895 if (!empty($nbrec)) {
10896 $label .=
'<span class="badge marginleftonlyshort">'.$nbrec.
'</span>';
10904 $newtab[1] = $label;
10905 $newtab[2] = str_replace(
'+',
'', $values[1]);
10910 } elseif (count($values) == 5) {
10911 dol_syslog(
'Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
10913 if ($values[0] != $type) {
10917 if ($filterorigmodule) {
10918 if (strpos($values[3],
'@')) {
10919 if ($filterorigmodule !=
'external') {
10923 if ($filterorigmodule !=
'core') {
10928 $langs->load($values[3]);
10930 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
10931 $substitutionarray = array();
10935 $label = $langs->trans($values[2]);
10939 $newtab[1] = $label;
10940 $newtab[2] = str_replace(
'+',
'', $values[1]);
10944 $head = array_merge(array_slice($head, 0, $postab), array($newtab), array_slice($head, $postab));
10945 } elseif ($mode ==
'remove' && preg_match(
'/^\-/', $values[1])) {
10946 if ($values[0] != $type) {
10949 $tabname = str_replace(
'-',
'', $values[1]);
10950 foreach ($head as $key => $val) {
10951 $condition = (!empty($values[3]) ?
verifCond($values[3],
'2') : 1);
10953 if ($head[$key][2] == $tabname && $condition) {
10954 unset($head[$key]);
10963 if (!empty($hookmanager)) {
10964 $parameters = array(
'object' =>
$object,
'mode' => $mode,
'head' => &$head,
'filterorigmodule' => $filterorigmodule);
10965 $reshook = $hookmanager->executeHooks(
'completeTabsHead', $parameters,
$object);
10966 if ($reshook > 0) {
10967 $head = $hookmanager->resArray;
10969 $head = array_merge($head, $hookmanager->resArray);
10988 global $conf, $hookmanager, $user, $langs;
10991 global $micro_start_time;
10993 if ($zone ==
'private') {
10994 print
"\n".
'<!-- Common footer for private page -->'.
"\n";
10996 print
"\n".
'<!-- Common footer for public page -->'.
"\n";
11000 print
"\n<!-- A div to store page_y POST parameter -->\n";
11001 print
'<div id="page_y" style="display: none;">'.(GETPOST(
'page_y') ?
GETPOST(
'page_y') :
'').
'</div>'.
"\n";
11003 $parameters = array();
11004 $reshook = $hookmanager->executeHooks(
'printCommonFooter', $parameters);
11005 if (empty($reshook)) {
11011 if (!empty($conf->use_javascript_ajax)) {
11012 print
"\n<!-- A script section to add menuhider handler on backoffice, manage focus and mandatory fields, tuning info, ... -->\n";
11013 print
'<script>'.
"\n";
11014 print
'jQuery(document).ready(function() {'.
"\n";
11016 if ($zone ==
'private' && empty($conf->dol_use_jmobile)) {
11018 print
'/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'.
"\n";
11019 print
'jQuery("li.menuhider").click(function(event) {';
11020 print
' if (!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'.
"\n";
11021 print
' console.log("We click on .menuhider");'.
"\n";
11022 print
' $("body").toggleClass("sidebar-collapse")'.
"\n";
11027 if ($action ==
'create' || $action ==
'edit' || (empty($action) && (preg_match(
'/new\.php/', $_SERVER[
"PHP_SELF"]))) || ((empty($action) || $action ==
'addline') && (preg_match(
'/card\.php/', $_SERVER[
"PHP_SELF"])))) {
11028 print
'/* JS CODE TO ENABLE to manage focus and mandatory form fields */'.
"\n";
11029 $relativepathstring = $_SERVER[
"PHP_SELF"];
11031 if (constant(
'DOL_URL_ROOT')) {
11032 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
11034 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
11035 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
11038 if (!empty($user->default_values[$relativepathstring][
'focus'])) {
11039 foreach ($user->default_values[$relativepathstring][
'focus'] as $defkey => $defval) {
11041 if ($defkey !=
'_noquery_') {
11042 $tmpqueryarraytohave = explode(
'&', $defkey);
11044 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
11045 $tmpquerytohaveparam = explode(
'=', $tmpquerytohave);
11047 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] !=
GETPOST($tmpquerytohaveparam[0]))) {
11051 if (!$foundintru) {
11060 print
'console.log("set the focus by executing jQuery(...).focus();")'.
"\n";
11061 foreach ($defval as $paramkey => $paramval) {
11063 print
'jQuery("input[name=\''.$paramkey.
'\']
").focus();'."\n
";
11064 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").focus();'."\n
"; // TODO KO with ckeditor
11065 print 'jQuery("select[
name=\
''.$paramkey.
'\']
").focus();'."\n
"; // Not really useful, but we keep it in case of.
11070 if (!empty($user->default_values[$relativepathstring]['mandatory'])) {
11071 foreach ($user->default_values[$relativepathstring]['mandatory'] as $defkey => $defval) {
11073 if ($defkey != '_noquery_') {
11074 $tmpqueryarraytohave = explode('&', $defkey);
11076 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
11077 $tmpquerytohaveparam = explode('=', $tmpquerytohave);
11078 //print "console.log(
'".$tmpquerytohaveparam[0]." ".$tmpquerytohaveparam[1]." ".GETPOST($tmpquerytohaveparam[0])."');
";
11079 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] != GETPOST($tmpquerytohaveparam[0]))) {
11083 if (!$foundintru) {
11086 //var_dump($defkey.'-'.$qualified);
11092 print 'console.log("set the js code to manage fields that are
set as mandatory
");'."\n
";
11094 foreach ($defval as $paramkey => $paramval) {
11095 // Solution 1: Add handler on submit to check if mandatory fields are empty
11096 print 'var form = $(\'#'.dol_escape_js($paramkey).'\').closest("form
");'."\n
";
11097 print "form.on(
'submit',
function(event) {
11098 var submitter =
event.originalEvent.submitter;
11100 var buttonName = $(submitter).attr(
'name');
11101 if (buttonName ==
'cancel') {
11102 console.log(
'We click on cancel button so we accept submit with no need to check mandatory fields');
11107 console.log(
'We did not click on cancel button but on something else, we check that field #".dol_escape_js($paramkey)." is not empty');
11109 var tmpvalue = jQuery(
'#".dol_escape_js($paramkey)."').val();
11110 let tmptypefield = jQuery(
'#".dol_escape_js($paramkey)."').prop(
'nodeName').toLowerCase();
11112 if (tmptypefield ==
'textarea') {
11114 var tmpeditor = CKEDITOR.instances[
'".dol_escape_js($paramkey)."'];
11116 tmpvalue = tmpeditor.getData();
11117 console.log(
'For textarea tmpvalue is '+tmpvalue);
11121 let tmpvalueisempty =
false;
11122 if (tmpvalue ===
null || tmpvalue === undefined || tmpvalue ===
'') {
11123 tmpvalueisempty =
true;
11125 if (tmpvalue ===
'0' && tmptypefield ==
'select') {
11126 tmpvalueisempty =
true;
11128 if (tmpvalueisempty) {
11129 console.log(
'field has type '+tmptypefield+
' and is empty, we cancel the submit');
11130 event.preventDefault();
11131 event.stopPropagation();
11132 alert(
'".dol_escape_js($langs->trans("ErrorFieldRequired", $paramkey).' (
'.$langs->trans("CustomMandatoryFieldRule").')
')."');
11135 console.log(
'field has type '+tmptypefield+
' and is defined to '+tmpvalue);
11140 // Solution 2: Add property 'required' on input
11141 // so browser will check value and try to focus on it when submitting the form.
11142 //print 'setTimeout(function() {'; // If we want to wait that ckeditor beuatifier has finished its job.
11143 //print 'jQuery("input[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
11144 //print 'jQuery("textarea[
id=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
11145 //print 'jQuery("select[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";*/
11146 //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
";
11147 //print 'jQuery("select[
name=\
''.$paramkey.
'\'] option[value=\
'-1\']").prop(\'value\', \'\');'.
"\n";
11153 print
'jQuery(\':input[name="' .
dol_escape_js($paramkey) .
'"]\').closest("tr").find("td:first").addClass("fieldrequired");'.
"\n";
11158 print
'jQuery("input[name=\'cancel\']").click(function() {
11159 console.log("We click on cancel button so removed all required attribute");
11160 jQuery("input, textarea, select").each(function(){this.removeAttribute(\'required\');});
11170 if (!empty($_SERVER[
'MAIN_SHOW_TUNING_INFO']) ||
getDolGlobalString(
'MAIN_SHOW_TUNING_INFO')) {
11172 print
"/* JS CODE TO ENABLE to add memory info */\n";
11173 print
'window.console && console.log("';
11178 if (!empty($micro_start_time)) {
11179 $micro_end_time = microtime(
true);
11180 print
' - Build time: '.ceil(1000 * ($micro_end_time - $micro_start_time)).
' ms';
11183 if (function_exists(
"memory_get_usage")) {
11184 print
' - Mem: '.memory_get_usage();
11186 if (function_exists(
"memory_get_peak_usage")) {
11187 print
' - Real mem peak: '.memory_get_peak_usage(
true);
11189 if (function_exists(
"zend_loader_file_encoded")) {
11190 print
' - Zend encoded file: '.(zend_loader_file_encoded() ?
'yes' :
'no');
11195 print
"\n".
'</script>'.
"\n";
11201 foreach ($tmptagarray as $tmptag) {
11203 print
"<!-- JS CODE TO ENABLE for google analtics tag -->\n";
11205 <!-- Global site tag (gtag.js) - Google Analytics -->
11206 <script nonce="'.getNonce().
'" async src="https://www.googletagmanager.com/gtag/js?id='.trim($tmptag).
'"></script>
11208 window.dataLayer = window.dataLayer || [];
11209 function gtag(){dataLayer.push(arguments);}
11210 gtag(\'js\', new Date());
11212 gtag(\'config\', \''.trim($tmptag).
'\');
11219 // Add Xdebug coverage of code
11220 if (defined('XDEBUGCOVERAGE
')) {
11221 print_r(xdebug_get_code_coverage());
11224 // Add DebugBar data
11225 if ($user->hasRight('debugbar
', 'read
') && $debugbar instanceof DebugBar\DebugBar) {
11226 if (isset($debugbar['time
'])) {
11227 // @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
11228 $debugbar['time
']->stopMeasure('pageaftermaster
');
11230 print '<!-- Output debugbar data -->
'."\n";
11231 $renderer = $debugbar->getJavascriptRenderer();
11232 print $renderer->render();
11233 } elseif (count($conf->logbuffer)) { // If there is some logs in buffer to show
11235 print "<!-- Start of log output\n";
11236 //print '<div
class=
"hidden">
'."\n";
11237 foreach ($conf->logbuffer as $logline) {
11238 print $logline."<br>\n";
11240 //print '</div>
'."\n";
11241 print "End of log output -->\n";
11255function dolExplodeIntoArray($string, $delimiter = ';
', $kv = '=
')
11257 if (is_null($string)) {
11261 if (preg_match('/^\[.*\]$/sm
', $delimiter) || preg_match('/^\(.*\)$/sm
', $delimiter)) {
11262 // This is a regex string
11263 $newdelimiter = $delimiter;
11265 // This is a simple string
11266 // @phan-suppress-next-line PhanPluginSuspiciousParamPositionInternal
11267 $newdelimiter = preg_quote($delimiter, '/
');
11270 if ($a = preg_split('/
'.$newdelimiter.'/
', $string)) {
11272 foreach ($a as $s) { // each part
11274 if ($pos = strpos($s, $kv)) { // key/value delimiter
11275 $ka[trim(substr($s, 0, $pos))] = trim(substr($s, $pos + strlen($kv)));
11276 } else { // key delimiter not found
11294function dol_set_focus($selector)
11296 print "\n".'<!-- Set focus onto a specific field -->
'."\n";
11297 print '<script nonce=
"'.getNonce().'">jQuery(document).ready(
function() { jQuery(
"'.dol_escape_js($selector).'").focus(); });</script>
'."\n";
11308function dol_getmypid()
11310 if (!function_exists('getmypid
')) {
11311 return mt_rand(99900000, 99965535);
11313 return getmypid(); // May be a number on 64 bits (depending on OS)
11339function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
11341 global $db, $langs;
11343 $value = trim($value);
11346 $value = preg_replace('/\*/
', '%
', $value); // Replace * with %
11349 $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
11352 $value = preg_replace('/\s*\|\s*/
', '|
', $value);
11354 $crits = explode(' ', $value);
11356 if (!is_array($fields)) {
11357 $fields = array($fields);
11360 $i1 = 0; // count the nb of and criteria added (all fields / criteria)
11361 foreach ($crits as $crit) { // Loop on each AND criteria
11362 $crit = trim($crit);
11363 $i2 = 0; // count the nb of valid criteria added for this this first criteria
11365 foreach ($fields as $field) {
11367 $tmpcrits = explode('|
', $crit);
11368 $i3 = 0; // count the nb of valid criteria added for this current field
11369 foreach ($tmpcrits as $tmpcrit) {
11370 if ($tmpcrit !== '0
' && empty($tmpcrit)) {
11373 $tmpcrit = trim($tmpcrit);
11375 $newres .= (($i2 > 0 || $i3 > 0) ? ' OR
' : '');
11378 $newcrit = preg_replace('/([!<>=]+)/
', '', $tmpcrit);
11381 preg_match('/([!<>=]+)/
', $tmpcrit, $reg);
11382 if (!empty($reg[1])) {
11383 $operator = $reg[1];
11385 if ($newcrit != '') {
11386 $numnewcrit = price2num($newcrit);
11387 if (is_numeric($numnewcrit)) {
11388 $newres .= $field.' '.$operator.' '.((float) $numnewcrit); // should be a numeric
11390 $newres .= '1 = 2
'; // force false, we received a corrupted data
11392 $i3++; // a criteria was added to string
11395 $i2++; // a criteria for 1 more field was added to string
11396 } elseif ($mode == 2 || $mode == -2) {
11397 $crit = preg_replace('/[^0-9,]/
', '', $crit); // ID are always integer
11398 $newres .= ($i2 > 0 ? ' OR
' : '').$field." ".($mode == -2 ? 'NOT
' : '');
11399 $newres .= $crit ? "IN (".$db->sanitize($db->escape($crit)).")" : "IN (0)";
11401 $newres .= ' OR
'.$field.' IS NULL
';
11403 $i2++; // a criteria for 1 more field was added to string
11404 } elseif ($mode == 3 || $mode == -3) {
11405 $tmparray = explode(',
', $crit);
11406 if (count($tmparray)) {
11408 foreach ($tmparray as $val) {
11411 $listofcodes .= ($listofcodes ? ',
' : '');
11412 $listofcodes .= "'".$db->escape($val)."'";
11415 $newres .= ($i2 > 0 ? ' OR
' : '').$field." ".($mode == -3 ? 'NOT
' : '')."IN (".$db->sanitize($listofcodes, 1).")";
11416 $i2++; // a criteria for 1 more field was added to string
11419 $newres .= ' OR
'.$field.' IS NULL
';
11421 } elseif ($mode == 4) {
11422 $tmparray = explode(',
', $crit);
11423 if (count($tmparray)) {
11425 foreach ($tmparray as $val) {
11428 $newres .= ($i2 > 0 ? " OR (" : "(").$field." LIKE '".$db->escape($val).",%
'";
11429 $newres .= ' OR
'.$field." = '".$db->escape($val)."'";
11430 $newres .= ' OR
'.$field." LIKE '%,
".$db->escape($val)."'";
11431 $newres .= ' OR
'.$field." LIKE '%,
".$db->escape($val).",%
'";
11433 $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)
11437 } else { // $mode=0
11438 $tmpcrits = explode('|
', $crit);
11439 $i3 = 0; // count the nb of valid criteria added for the current couple criteria/field
11440 foreach ($tmpcrits as $tmpcrit) { // loop on each OR criteria
11441 if ($tmpcrit !== '0
' && empty($tmpcrit)) {
11444 $tmpcrit = trim($tmpcrit);
11446 if ($tmpcrit == '^$
' || strpos($crit, '!
') === 0) { // If we search empty, we must combined different OR fields with AND
11447 $newres .= (($i2 > 0 || $i3 > 0) ? ' AND
' : '');
11449 $newres .= (($i2 > 0 || $i3 > 0) ? ' OR
' : '');
11452 if (preg_match('/\.(
id|
rowid)$/
', $field)) { // Special case for rowid that is sometimes a ref so used as a search field
11453 $newres .= $field." = ".(is_numeric($tmpcrit) ? ((float) $tmpcrit) : '0
');
11455 $tmpcrit2 = $tmpcrit;
11460 if (preg_match('/^!/
', $tmpcrit)) {
11461 $tmps .= $field." NOT LIKE "; // ! as exclude character
11462 $tmpcrit2 = preg_replace('/^!/
', '', $tmpcrit2);
11464 $tmps .= $field." LIKE ";
11468 if (preg_match('/^[\^\$]/', $tmpcrit)) {
11470 $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
11472 if (preg_match('/[\^\$]$/', $tmpcrit)) {
11474 $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
11477 if ($tmpcrit2 == '' || preg_match('/^!/', $tmpcrit)) {
11481 $newres .= $tmpbefore;
11482 $newres .= $db->escape($tmpcrit2);
11483 $newres .= $tmpafter;
11485 if ($tmpcrit2 == '' || preg_match('/^!/
', $tmpcrit)) {
11486 $newres .= " OR ".$field." IS NULL)";
11493 $i2++; // a criteria for 1 more field was added to string
11498 $res = $res.($res ? ' AND
' : '').($i2 > 1 ? '(
' : '').$newres.($i2 > 1 ? ')
' : '');
11502 $res = ($nofirstand ? "" : " AND ")."(".$res.")";
11513function showDirectDownloadLink($object)
11515 global $conf, $langs;
11518 $url = $object->getLastMainDocLink($object->element);
11520 $out .= img_picto($langs->trans("PublicDownloadLinkDesc"), 'globe
').' <span
class=
"opacitymedium">
'.$langs->trans("DirectDownloadLink").'</span><br>
';
11522 $out .= '<div
class=
"urllink"><input
type=
"text" id=
"directdownloadlink" class=
"quatrevingtpercent" value=
"'.$url.'"></div>
';
11523 $out .= ajax_autoselect("directdownloadlink", 0);
11525 $out .= '<div
class=
"urllink">
'.$langs->trans("FileNotShared").'</div>
';
11539function getImageFileNameForSize($file, $extName, $extImgTarget = '
')
11541 $dirName = dirname($file);
11542 if ($dirName == '.
') {
11546 $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp|\.webp)$/i
', '', $file); // We remove extension, whatever is its case
11547 $fileName = basename($fileName);
11549 if (empty($extImgTarget)) {
11550 $extImgTarget = (preg_match('/\.jpg$/i
', $file) ? '.jpg
' : '');
11552 if (empty($extImgTarget)) {
11553 $extImgTarget = (preg_match('/\.jpeg$/i
', $file) ? '.jpeg
' : '');
11555 if (empty($extImgTarget)) {
11556 $extImgTarget = (preg_match('/\.gif$/i
', $file) ? '.gif
' : '');
11558 if (empty($extImgTarget)) {
11559 $extImgTarget = (preg_match('/\.png$/i
', $file) ? '.png
' : '');
11561 if (empty($extImgTarget)) {
11562 $extImgTarget = (preg_match('/\.bmp$/i
', $file) ? '.bmp
' : '');
11564 if (empty($extImgTarget)) {
11565 $extImgTarget = (preg_match('/\.webp$/i
', $file) ? '.webp
' : '');
11568 if (!$extImgTarget) {
11574 $subdir = 'thumbs/
';
11577 return ($dirName ? $dirName.'/
' : '').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb
11590function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param = '
')
11592 global $conf, $langs;
11594 if (empty($conf->use_javascript_ajax)) {
11598 $isAllowedForPreview = dolIsAllowedForPreview($relativepath);
11600 if ($alldata == 1) {
11601 if ($isAllowedForPreview) {
11602 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));
11608 // old behavior, return a string
11609 if ($isAllowedForPreview) {
11610 $tmpurl = DOL_URL_ROOT.'/document.php?modulepart=
'.urlencode($modulepart).'&attachment=0&file=
'.urlencode($relativepath).($param ? '&
'.$param : '');
11611 $title = $langs->transnoentities("Preview");
11612 //$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().
11613 //$tmpurl = 'file=
'.urlencode("'-alert(document.domain)-
'_small.jpg"); // An example of tmpurl that should be blocked by the dol_escape_uri()
11615 // 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,
11616 // 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.
11633function ajax_autoselect($htmlname, $addlink = '
', $textonlink = 'Link')
11636 $out = '<script nonce=
"'.getNonce().'">
11637 jQuery(document).ready(
function () {
11638 jQuery(
"'.((strpos($htmlname, '.') === 0 ? '' : '#').$htmlname).'").click(
function() { jQuery(
this).select(); } );
11642 if ($textonlink === 'image
') {
11643 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.img_picto('', 'globe
').'</a>
';
11645 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.$langs->trans("Link").'</a>
';
11658function dolIsAllowedForPreview($file)
11660 // Check .noexe extension in filename
11661 if (preg_match('/\.noexe$/i
', $file)) {
11665 // Check mime types
11666 $mime_preview = array('bmp
', 'jpeg
', 'png
', 'gif
', 'tiff
', 'pdf
', 'plain
', 'css
', 'webp
');
11667 if (getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES
')) {
11668 $mime_preview[] = 'svg+xml
';
11670 //$mime_preview[]='vnd.oasis.opendocument.presentation
';
11671 //$mime_preview[]='archive
';
11672 $num_mime = array_search(dol_mimetype($file, '', 1), $mime_preview);
11673 if ($num_mime !== false) {
11677 // By default, not allowed for preview
11691function dol_mimetype($file, $default = 'application/octet-stream
', $mode = 0)
11694 $imgmime = 'other.png
';
11695 $famime = 'file-o
';
11698 $tmpfile = preg_replace('/\.noexe$/
', '', $file);
11700 // Plain text files
11701 if (preg_match('/\.txt$/i
', $tmpfile)) {
11702 $mime = 'text/plain
';
11703 $imgmime = 'text.png
';
11704 $famime = 'file-alt
';
11705 } elseif (preg_match('/\.rtx$/i
', $tmpfile)) {
11706 $mime = 'text/richtext
';
11707 $imgmime = 'text.png
';
11708 $famime = 'file-alt
';
11709 } elseif (preg_match('/\.csv$/i
', $tmpfile)) {
11710 $mime = 'text/csv
';
11711 $imgmime = 'text.png
';
11712 $famime = 'file-csv
';
11713 } elseif (preg_match('/\.tsv$/i
', $tmpfile)) {
11714 $mime = 'text/tab-separated-values
';
11715 $imgmime = 'text.png
';
11716 $famime = 'file-alt
';
11717 } elseif (preg_match('/\.(cf|
conf|log)$/i
', $tmpfile)) {
11718 $mime = 'text/plain
';
11719 $imgmime = 'text.png
';
11720 $famime = 'file-alt
';
11721 } elseif (preg_match('/\.ini$/i
', $tmpfile)) {
11722 $mime = 'text/plain
';
11723 $imgmime = 'text.png
';
11725 $famime = 'file-alt
';
11726 } elseif (preg_match('/\.md$/i
', $tmpfile)) {
11727 $mime = 'text/plain
';
11728 $imgmime = 'text.png
';
11730 $famime = 'file-alt
';
11731 } elseif (preg_match('/\.css$/i
', $tmpfile)) {
11732 $mime = 'text/css
';
11733 $imgmime = 'css.png
';
11735 $famime = 'file-alt
';
11736 } elseif (preg_match('/\.lang$/i
', $tmpfile)) {
11737 $mime = 'text/plain
';
11738 $imgmime = 'text.png
';
11740 $famime = 'file-alt
';
11741 } elseif (preg_match('/\.(crt|cer|key|pub)$/i
', $tmpfile)) { // Certificate files
11742 $mime = 'text/plain
';
11743 $imgmime = 'text.png
';
11744 $famime = 'file-alt
';
11745 } elseif (preg_match('/\.(html|htm|shtml)$/i
', $tmpfile)) { // XML based (HTML/XML/XAML)
11746 $mime = 'text/html
';
11747 $imgmime = 'html.png
';
11749 $famime = 'file-alt
';
11750 } elseif (preg_match('/\.(xml|xhtml)$/i
', $tmpfile)) {
11751 $mime = 'text/xml
';
11752 $imgmime = 'other.png
';
11754 $famime = 'file-alt
';
11755 } elseif (preg_match('/\.xaml$/i
', $tmpfile)) {
11756 $mime = 'text/xml
';
11757 $imgmime = 'other.png
';
11759 $famime = 'file-alt
';
11760 } elseif (preg_match('/\.bas$/i
', $tmpfile)) { // Languages
11761 $mime = 'text/plain
';
11762 $imgmime = 'text.png
';
11764 $famime = 'file-code
';
11765 } elseif (preg_match('/\.(c)$/i
', $tmpfile)) {
11766 $mime = 'text/plain
';
11767 $imgmime = 'text.png
';
11769 $famime = 'file-code
';
11770 } elseif (preg_match('/\.(cpp)$/i
', $tmpfile)) {
11771 $mime = 'text/plain
';
11772 $imgmime = 'text.png
';
11774 $famime = 'file-code
';
11775 } elseif (preg_match('/\.cs$/i
', $tmpfile)) {
11776 $mime = 'text/plain
';
11777 $imgmime = 'text.png
';
11779 $famime = 'file-code
';
11780 } elseif (preg_match('/\.(h)$/i
', $tmpfile)) {
11781 $mime = 'text/plain
';
11782 $imgmime = 'text.png
';
11784 $famime = 'file-code
';
11785 } elseif (preg_match('/\.(java|jsp)$/i
', $tmpfile)) {
11786 $mime = 'text/plain
';
11787 $imgmime = 'text.png
';
11789 $famime = 'file-code
';
11790 } elseif (preg_match('/\.php([0-9]{1})?$/i
', $tmpfile)) {
11791 $mime = 'text/plain
';
11792 $imgmime = 'php.png
';
11794 $famime = 'file-code
';
11795 } elseif (preg_match('/\.phtml$/i
', $tmpfile)) {
11796 $mime = 'text/plain
';
11797 $imgmime = 'php.png
';
11799 $famime = 'file-code
';
11800 } elseif (preg_match('/\.(pl|pm)$/i
', $tmpfile)) {
11801 $mime = 'text/plain
';
11802 $imgmime = 'pl.png
';
11804 $famime = 'file-code
';
11805 } elseif (preg_match('/\.sql$/i
', $tmpfile)) {
11806 $mime = 'text/plain
';
11807 $imgmime = 'text.png
';
11809 $famime = 'file-code
';
11810 } elseif (preg_match('/\.js$/i
', $tmpfile)) {
11811 $mime = 'text/x-javascript
';
11812 $imgmime = 'jscript.png
';
11814 $famime = 'file-code
';
11815 } elseif (preg_match('/\.odp$/i
', $tmpfile)) { // Open office
11816 $mime = 'application/vnd.oasis.opendocument.presentation
';
11817 $imgmime = 'ooffice.png
';
11818 $famime = 'file-powerpoint
';
11819 } elseif (preg_match('/\.ods$/i
', $tmpfile)) {
11820 $mime = 'application/vnd.oasis.opendocument.spreadsheet
';
11821 $imgmime = 'ooffice.png
';
11822 $famime = 'file-excel
';
11823 } elseif (preg_match('/\.odt$/i
', $tmpfile)) {
11824 $mime = 'application/vnd.oasis.opendocument.text
';
11825 $imgmime = 'ooffice.png
';
11826 $famime = 'file-word
';
11827 } elseif (preg_match('/\.mdb$/i
', $tmpfile)) { // MS Office
11828 $mime = 'application/msaccess
';
11829 $imgmime = 'mdb.png
';
11831 } elseif (preg_match('/\.doc[xm]?$/i
', $tmpfile)) {
11832 $mime = 'application/msword
';
11833 $imgmime = 'doc.png
';
11834 $famime = 'file-word
';
11835 } elseif (preg_match('/\.dot[xm]?$/i
', $tmpfile)) {
11836 $mime = 'application/msword
';
11837 $imgmime = 'doc.png
';
11838 $famime = 'file-word
';
11839 } elseif (preg_match('/\.xlt(x)?$/i
', $tmpfile)) {
11840 $mime = 'application/vnd.ms-excel
';
11841 $imgmime = 'xls.png
';
11842 $famime = 'file-excel
';
11843 } elseif (preg_match('/\.xla(m)?$/i
', $tmpfile)) {
11844 $mime = 'application/vnd.ms-excel
';
11845 $imgmime = 'xls.png
';
11846 $famime = 'file-excel
';
11847 } elseif (preg_match('/\.xls$/i
', $tmpfile)) {
11848 $mime = 'application/vnd.ms-excel
';
11849 $imgmime = 'xls.png
';
11850 $famime = 'file-excel
';
11851 } elseif (preg_match('/\.xls[bmx]$/i
', $tmpfile)) {
11852 $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
';
11853 $imgmime = 'xls.png
';
11854 $famime = 'file-excel
';
11855 } elseif (preg_match('/\.pps[mx]?$/i
', $tmpfile)) {
11856 $mime = 'application/vnd.ms-powerpoint
';
11857 $imgmime = 'ppt.png
';
11858 $famime = 'file-powerpoint
';
11859 } elseif (preg_match('/\.ppt[mx]?$/i
', $tmpfile)) {
11860 $mime = 'application/x-mspowerpoint
';
11861 $imgmime = 'ppt.png
';
11862 $famime = 'file-powerpoint
';
11863 } elseif (preg_match('/\.pdf$/i
', $tmpfile)) { // Other
11864 $mime = 'application/pdf
';
11865 $imgmime = 'pdf.png
';
11866 $famime = 'file-pdf
';
11867 } elseif (preg_match('/\.bat$/i
', $tmpfile)) { // Scripts
11868 $mime = 'text/x-bat
';
11869 $imgmime = 'script.png
';
11871 $famime = 'file-code
';
11872 } elseif (preg_match('/\.sh$/i
', $tmpfile)) {
11873 $mime = 'text/x-sh
';
11874 $imgmime = 'script.png
';
11876 $famime = 'file-code
';
11877 } elseif (preg_match('/\.ksh$/i
', $tmpfile)) {
11878 $mime = 'text/x-ksh
';
11879 $imgmime = 'script.png
';
11881 $famime = 'file-code
';
11882 } elseif (preg_match('/\.bash$/i
', $tmpfile)) {
11883 $mime = 'text/x-bash
';
11884 $imgmime = 'script.png
';
11886 $famime = 'file-code
';
11887 } elseif (preg_match('/\.ico$/i
', $tmpfile)) { // Images
11888 $mime = 'image/x-
icon';
11889 $imgmime = 'image.png
';
11890 $famime = 'file-image
';
11891 } elseif (preg_match('/\.(jpg|jpeg)$/i
', $tmpfile)) {
11892 $mime = 'image/jpeg
';
11893 $imgmime = 'image.png
';
11894 $famime = 'file-image
';
11895 } elseif (preg_match('/\.png$/i
', $tmpfile)) {
11896 $mime = 'image/png
';
11897 $imgmime = 'image.png
';
11898 $famime = 'file-image
';
11899 } elseif (preg_match('/\.gif$/i
', $tmpfile)) {
11900 $mime = 'image/gif
';
11901 $imgmime = 'image.png
';
11902 $famime = 'file-image
';
11903 } elseif (preg_match('/\.bmp$/i
', $tmpfile)) {
11904 $mime = 'image/bmp
';
11905 $imgmime = 'image.png
';
11906 $famime = 'file-image
';
11907 } elseif (preg_match('/\.(tif|tiff)$/i
', $tmpfile)) {
11908 $mime = 'image/tiff
';
11909 $imgmime = 'image.png
';
11910 $famime = 'file-image
';
11911 } elseif (preg_match('/\.svg$/i
', $tmpfile)) {
11912 $mime = 'image/svg+xml
';
11913 $imgmime = 'image.png
';
11914 $famime = 'file-image
';
11915 } elseif (preg_match('/\.webp$/i
', $tmpfile)) {
11916 $mime = 'image/webp
';
11917 $imgmime = 'image.png
';
11918 $famime = 'file-image
';
11919 } elseif (preg_match('/\.vcs$/i
', $tmpfile)) { // Calendar
11920 $mime = 'text/calendar
';
11921 $imgmime = 'other.png
';
11922 $famime = 'file-alt
';
11923 } elseif (preg_match('/\.ics$/i
', $tmpfile)) {
11924 $mime = 'text/calendar
';
11925 $imgmime = 'other.png
';
11926 $famime = 'file-alt
';
11927 } elseif (preg_match('/\.torrent$/i
', $tmpfile)) { // Other
11928 $mime = 'application/x-bittorrent
';
11929 $imgmime = 'other.png
';
11930 $famime = 'file-o
';
11931 } elseif (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i
', $tmpfile)) { // Audio
11933 $imgmime = 'audio.png
';
11934 $famime = 'file-audio
';
11935 } elseif (preg_match('/\.mp4$/i
', $tmpfile)) { // Video
11936 $mime = 'video/mp4
';
11937 $imgmime = 'video.png
';
11938 $famime = 'file-video
';
11939 } elseif (preg_match('/\.ogv$/i
', $tmpfile)) {
11940 $mime = 'video/ogg
';
11941 $imgmime = 'video.png
';
11942 $famime = 'file-video
';
11943 } elseif (preg_match('/\.webm$/i
', $tmpfile)) {
11944 $mime = 'video/webm
';
11945 $imgmime = 'video.png
';
11946 $famime = 'file-video
';
11947 } elseif (preg_match('/\.avi$/i
', $tmpfile)) {
11948 $mime = 'video/x-msvideo
';
11949 $imgmime = 'video.png
';
11950 $famime = 'file-video
';
11951 } elseif (preg_match('/\.divx$/i
', $tmpfile)) {
11952 $mime = 'video/divx
';
11953 $imgmime = 'video.png
';
11954 $famime = 'file-video
';
11955 } elseif (preg_match('/\.xvid$/i
', $tmpfile)) {
11956 $mime = 'video/xvid
';
11957 $imgmime = 'video.png
';
11958 $famime = 'file-video
';
11959 } elseif (preg_match('/\.(wmv|mpg|mpeg)$/i
', $tmpfile)) {
11961 $imgmime = 'video.png
';
11962 $famime = 'file-video
';
11963 } elseif (preg_match('/\.(zip|rar|gz|tgz|xz|z|cab|bz2|7z|tar|lzh|zst)$/i
', $tmpfile)) { // Archive
11964 // application/xxx where zzz is zip, ...
11966 $imgmime = 'archive.png
';
11967 $famime = 'file-archive
';
11968 } elseif (preg_match('/\.(exe|com)$/i
', $tmpfile)) { // Exe
11969 $mime = 'application/octet-stream
';
11970 $imgmime = 'other.png
';
11971 $famime = 'file-o
';
11972 } elseif (preg_match('/\.(dll|lib|o|so|a)$/i
', $tmpfile)) { // Lib
11974 $imgmime = 'library.png
';
11975 $famime = 'file-o
';
11976 } elseif (preg_match('/\.err$/i
', $tmpfile)) { // phpcs:ignore
11978 $imgmime = 'error.png
';
11979 $famime = 'file-alt
';
11982 // Return mimetype string
11983 switch ((int) $mode) {
11985 $tmp = explode('/
', $mime);
11986 return (!empty($tmp[1]) ? $tmp[1] : $tmp[0]);
12008function getDictionaryValue($tablename, $field, $id, $checkentity = false, $rowidfield = '
rowid')
12012 $tablename = preg_replace('/^
'.preg_quote(MAIN_DB_PREFIX, '/
').'/
', '', $tablename); // Clean name of table for backward compatibility.
12014 $dictvalues = (isset($conf->cache['dictvalues_
'.$tablename]) ? $conf->cache['dictvalues_
'.$tablename] : null);
12016 if (is_null($dictvalues)) {
12017 $dictvalues = array();
12019 $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
12020 if ($checkentity) {
12021 $sql .=
' AND entity IN (0,'.getEntity($tablename).
')';
12024 $resql = $db->query($sql);
12026 while ($obj = $db->fetch_object($resql)) {
12027 $dictvalues[$obj->$rowidfield] = $obj;
12033 $conf->cache[
'dictvalues_'.$tablename] = $dictvalues;
12036 if (!empty($dictvalues[$id])) {
12038 $tmp = $dictvalues[$id];
12039 return (property_exists($tmp, $field) ? $tmp->$field :
'');
12054 $stringcolor = str_replace(
'#',
'', $stringcolor);
12056 if (!empty($stringcolor)) {
12058 $tmp = explode(
',', $stringcolor);
12059 if (count($tmp) > 1) {
12064 $hexr = $stringcolor[0].$stringcolor[1];
12065 $hexg = $stringcolor[2].$stringcolor[3];
12066 $hexb = $stringcolor[4].$stringcolor[5];
12067 $r = hexdec($hexr);
12068 $g = hexdec($hexg);
12069 $b = hexdec($hexb);
12071 $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0;
12072 if ($bright > 0.6) {
12093 if (empty($menuentry[
'enabled'])) {
12096 if ($type_user && $menuentry[
'module']) {
12097 $tmploops = explode(
'|', $menuentry[
'module']);
12099 foreach ($tmploops as $tmploop) {
12100 if (in_array($tmploop, $listofmodulesforexternal)) {
12109 if (!$menuentry[
'perms'] && $type_user) {
12115 if (!$menuentry[
'perms']) {
12130 $result = (ceil($n) % $x === 0) ? ceil($n) : (round(($n + $x / 2) / $x) * $x);
12131 return (
int) $result;
12145function dolGetBadge($label, $html =
'', $type =
'primary', $mode =
'', $url =
'', $params = array())
12147 $csstouse =
'badge';
12148 $csstouse .= (!empty($mode) ?
' badge-'.$mode :
'');
12149 $csstouse .= (!empty($type) ?
' badge-'.$type :
'');
12150 $csstouse .= (empty($params[
'css']) ?
'' :
' '.$params[
'css']);
12153 'class' => $csstouse
12156 if (empty($html)) {
12160 if (!empty($url)) {
12161 $attr[
'href'] = $url;
12164 if ($mode ===
'dot') {
12165 $attr[
'class'] .=
' classfortooltip';
12166 $attr[
'title'] = $html;
12167 $attr[
'aria-label'] = $label;
12172 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
12173 foreach ($params[
'attr'] as $key => $value) {
12174 if ($key ==
'class') {
12175 $attr[
'class'] .=
' '.$value;
12176 } elseif ($key ==
'classOverride') {
12177 $attr[
'class'] = $value;
12179 $attr[$key] = $value;
12187 $attr = array_map(
'dol_escape_htmltag', $attr);
12189 $TCompiledAttr = array();
12190 foreach ($attr as $key => $value) {
12191 $TCompiledAttr[] = $key.
'="'.$value.
'"';
12194 $compiledAttributes = !empty($TCompiledAttr) ? implode(
' ', $TCompiledAttr) :
'';
12196 $tag = !empty($url) ?
'a' :
'span';
12198 return '<'.$tag.
' '.$compiledAttributes.
'>'.$html.
'</'.$tag.
'>';
12214function dolGetStatus($statusLabel =
'', $statusLabelShort =
'', $html =
'', $statusType =
'status0', $displayMode = 0, $url =
'', $params = array())
12219 $dolGetBadgeParams = array();
12221 if (!empty($params[
'badgeParams'])) {
12222 $dolGetBadgeParams = $params[
'badgeParams'];
12226 if ($displayMode == 0) {
12227 $return = !empty($html) ? $html : (empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort));
12228 } elseif ($displayMode == 1) {
12229 $return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
12233 $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ?
'<span class="hideonsmartphone">' :
'').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ?
'</span>' :
'');
12234 $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>' :
'');
12237 if (!empty($conf->dol_optimize_smallscreen)) {
12238 if ($displayMode == 0) {
12240 } elseif ($displayMode == 4) {
12242 } elseif ($displayMode == 6) {
12248 $statusImg = array(
12249 'status0' =>
'statut0',
12250 'status1' =>
'statut1',
12251 'status2' =>
'statut2',
12252 'status3' =>
'statut3',
12253 'status4' =>
'statut4',
12254 'status5' =>
'statut5',
12255 'status6' =>
'statut6',
12256 'status7' =>
'statut7',
12257 'status8' =>
'statut8',
12258 'status9' =>
'statut9'
12261 if (!empty($statusImg[$statusType])) {
12262 $htmlImg =
img_picto($statusLabel, $statusImg[$statusType]);
12264 $htmlImg =
img_picto($statusLabel, $statusType);
12267 if ($displayMode === 2) {
12268 $return = $htmlImg.
' '.$htmlLabelShort;
12269 } elseif ($displayMode === 3) {
12270 $return = $htmlImg;
12271 } elseif ($displayMode === 4) {
12272 $return = $htmlImg.
' '.$htmlLabel;
12273 } elseif ($displayMode === 5) {
12274 $return = $htmlLabelShort.
' '.$htmlImg;
12276 $return = $htmlLabel.
' '.$htmlImg;
12280 $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
12282 $dolGetBadgeParams[
'attr'][
'class'] =
'badge-status';
12283 if (empty($dolGetBadgeParams[
'attr'][
'title'])) {
12284 $dolGetBadgeParams[
'attr'][
'title'] = empty($params[
'tooltip']) ? $statusLabel : ($params[
'tooltip'] !=
'no' ? $params[
'tooltip'] :
'');
12286 $dolGetBadgeParams[
'attr'][
'class'] .=
' classfortooltip';
12288 $dolGetBadgeParams[
'attr'][
'title'] =
dol_htmlentitiesbr($dolGetBadgeParams[
'attr'][
'title'], 1);
12291 if ($displayMode == 3) {
12292 $return = dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)),
'', $statusType,
'dot', $url, $dolGetBadgeParams);
12293 } elseif ($displayMode === 5) {
12294 $return = dolGetBadge($statusLabelShort, $html, $statusType,
'', $url, $dolGetBadgeParams);
12296 $return = dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), $html, $statusType,
'', $url, $dolGetBadgeParams);
12341function dolGetButtonAction($label, $text =
'', $actionType =
'default', $url =
'', $id =
'', $userRight = 1, $params = array())
12343 global $hookmanager, $action,
$object, $langs;
12346 if (is_array($url)) {
12348 foreach ($url as $key => $subbutton) {
12349 if (isset($subbutton[
'enabled']) && empty($subbutton[
'enabled'])) {
12356 if (isset($params[
"areDropdownButtons"]) && $params[
"areDropdownButtons"] ===
false) {
12357 foreach ($url as $button) {
12358 if (!empty($button[
'lang'])) {
12359 $langs->load($button[
'lang']);
12361 $label = $langs->trans($button[
'label']);
12362 $text = $button[
'text'] ??
'';
12363 $actionType = $button[
'actionType'] ??
'';
12364 $tmpUrl = DOL_URL_ROOT.$button[
'url'].(empty($params[
'backtopage']) ?
'' :
'&backtopage='.urlencode($params[
'backtopage']));
12365 $id = $button[
'id'] ??
'';
12366 $userRight = $button[
'perm'] ?? 1;
12367 $button[
'params'] = $button[
'params'] ?? [];
12369 $out .=
dolGetButtonAction($label, $text, $actionType, $tmpUrl, $id, $userRight, $button[
'params']);
12374 if (count($url) > 1) {
12375 $out .=
'<div class="dropdown inline-block dropdown-holder">';
12376 $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>';
12377 $out .=
'<div class="dropdown-content">';
12378 foreach ($url as $subbutton) {
12379 if (!empty($subbutton[
'lang'])) {
12380 $langs->load($subbutton[
'lang']);
12383 if (!empty($subbutton[
'urlraw'])) {
12384 $tmpurl = $subbutton[
'urlraw'];
12386 $tmpurl = !empty($subbutton[
'urlroot']) ? $subbutton[
'urlroot'] : $subbutton[
'url'];
12390 $subbuttonparam = array();
12391 if (!empty($subbutton[
'attr'])) {
12392 $subbuttonparam[
'attr'] = $subbutton[
'attr'];
12394 $subbuttonparam[
'isDropDown'] = (empty($params[
'isDropDown']) ? ($subbutton[
'isDropDown']??
false) : $params[
'isDropDown']);
12396 $out .=
dolGetButtonAction(
'', $langs->trans($subbutton[
'label']),
'default', $tmpurl, $subbutton[
'id'] ??
'', $subbutton[
'perm'], $subbuttonparam);
12401 foreach ($url as $subbutton) {
12402 if (!empty($subbutton[
'lang'])) {
12403 $langs->load($subbutton[
'lang']);
12406 if (!empty($subbutton[
'urlraw'])) {
12407 $tmpurl = $subbutton[
'urlraw'];
12409 $tmpurl = !empty($subbutton[
'urlroot']) ? $subbutton[
'urlroot'] : $subbutton[
'url'];
12413 $out .=
dolGetButtonAction(
'', $langs->trans($subbutton[
'label']),
'default', $tmpurl,
'', $subbutton[
'perm'], $params);
12422 if (!empty($params[
'isDropdown']) || !empty($params[
'isDropDown'])) {
12423 $class =
"dropdown-item";
12425 $class =
'butAction';
12426 if ($actionType ==
'danger' || $actionType ==
'delete') {
12427 $class =
'butActionDelete';
12428 if (!empty($url) && strpos($url,
'token=') ===
false) {
12429 $url .=
'&token='.newToken();
12435 'href' => empty($url) ?
'' : $url,
12439 if (empty($text)) {
12441 $attr[
'title'] =
'';
12443 $attr[
'title'] = $label;
12444 $attr[
'aria-label'] = $label;
12447 if (empty($userRight)) {
12448 $attr[
'class'] =
'butActionRefused';
12449 $attr[
'href'] =
'';
12450 $attr[
'title'] = (($label && $text && $label != $text) ? $label :
'');
12451 $attr[
'title'] = ($attr[
'title'] ? $attr[
'title'].
'<br>' :
'').$langs->trans(
'NotEnoughPermissions');
12459 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
12460 foreach ($params[
'attr'] as $key => $value) {
12461 if ($key ==
'class') {
12462 $attr[
'class'] .=
' '.$value;
12463 } elseif ($key ==
'classOverride') {
12464 $attr[
'class'] = $value;
12466 $attr[$key] = $value;
12472 if (!empty($attr[
'title']) && !empty($attr[
'class']) && strpos($attr[
'class'],
'classfortooltip') ===
false) {
12473 $attr[
'class'] .=
' classfortooltip';
12477 if ($userRight && !empty($params[
'confirm'])) {
12478 if (!is_array($params[
'confirm'])) {
12479 $params[
'confirm'] = array();
12482 if (empty($params[
'confirm'][
'url'])) {
12483 $params[
'confirm'][
'url'] = $url . (strpos($url,
'?') > 0 ?
'&' :
'?') .
'confirm=yes';
12487 $attr[
'data-confirm-url'] = $params[
'confirm'][
'url'];
12488 $attr[
'data-confirm-title'] = !empty($params[
'confirm'][
'title']) ? $params[
'confirm'][
'title'] : $langs->trans(
'ConfirmBtnCommonTitle', $label);
12489 $attr[
'data-confirm-content'] = !empty($params[
'confirm'][
'content']) ? $params[
'confirm'][
'content'] : $langs->trans(
'ConfirmBtnCommonContent', $label);
12490 $attr[
'data-confirm-content'] = preg_replace(
"/\r|\n/",
"", $attr[
'data-confirm-content']);
12491 $attr[
'data-confirm-action-btn-label'] = !empty($params[
'confirm'][
'action-btn-label']) ? $params[
'confirm'][
'action-btn-label'] : $langs->trans(
'Confirm');
12492 $attr[
'data-confirm-cancel-btn-label'] = !empty($params[
'confirm'][
'cancel-btn-label']) ? $params[
'confirm'][
'cancel-btn-label'] : $langs->trans(
'CloseDialog');
12493 $attr[
'data-confirm-modal'] = !empty($params[
'confirm'][
'modal']) ? $params[
'confirm'][
'modal'] :
true;
12495 $attr[
'class'] .=
' butActionConfirm';
12498 if (isset($attr[
'href']) && empty($attr[
'href'])) {
12499 unset($attr[
'href']);
12503 $attr = array_map(
'dol_escape_htmltag', $attr);
12505 $TCompiledAttr = array();
12506 foreach ($attr as $key => $value) {
12507 $TCompiledAttr[] = $key.
'= "'.$value.
'"';
12510 $compiledAttributes = empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr);
12512 $tag = !empty($attr[
'href']) ?
'a' :
'span';
12515 $parameters = array(
12516 'TCompiledAttr' => $TCompiledAttr,
12517 'compiledAttributes' => $compiledAttributes,
12522 'actionType' => $actionType,
12525 'userRight' => $userRight,
12526 'params' => $params
12529 $reshook = $hookmanager->executeHooks(
'dolGetButtonAction', $parameters,
$object, $action);
12530 if ($reshook < 0) {
12534 if (empty($reshook)) {
12536 return '<' . $tag .
' ' . $compiledAttributes .
'>' . $text .
'</' . $tag .
'>';
12538 return '<' . $tag .
' ' . $compiledAttributes .
'>' .
dol_escape_htmltag($text) .
'</' . $tag .
'>';
12541 return $hookmanager->resPrint;
12560 $parsedUrl = parse_url($url);
12561 if ((isset($parsedUrl[
'scheme']) && in_array($parsedUrl[
'scheme'], [
'javascript',
'mailto',
'tel'])) || strpos($url,
'#') === 0) {
12565 if (!empty($parsedUrl[
'query'])) {
12567 parse_str($parsedUrl[
'query'], $urlQuery);
12568 if (!isset($urlQuery[
'backtopage']) && isset($params[
'backtopage'])) {
12569 $url.=
'&backtopage='.urlencode($params[
'backtopage']);
12573 if (!isset($parsedUrl[
'scheme']) && $addDolUrlRoot) {
12574 $url = DOL_URL_ROOT.$url;
12589 return '<span class="button-title-separator '.$moreClass.
'" ></span>';
12601 if (!empty($fieldValidationErrorMsg)) {
12602 $out .=
'<span class="field-error-icon classfortooltip" title="'.dol_escape_htmltag($fieldValidationErrorMsg, 1).
'" role="alert" >';
12603 $out .=
'<span class="fa fa-exclamation-circle" aria-hidden="true" ></span>';
12622function dolGetButtonTitle($label, $helpText =
'', $iconClass =
'fa fa-file', $url =
'', $id =
'', $status = 1, $params = array())
12624 global $langs, $conf, $user;
12627 if (
getDolGlobalString(
'MAIN_BUTTON_HIDE_UNAUTHORIZED') && (!$user->admin) && $status <= 0) {
12631 $class =
'btnTitle';
12632 if (in_array($iconClass, array(
'fa fa-plus-circle',
'fa fa-plus-circle size15x',
'fa fa-comment-dots',
'fa fa-paper-plane'))) {
12633 $class .=
' btnTitlePlus';
12635 $useclassfortooltip = 1;
12637 if (!empty($params[
'morecss'])) {
12638 $class .=
' '.$params[
'morecss'];
12643 'href' => empty($url) ?
'' : $url
12646 if (!empty($helpText)) {
12648 } elseif (empty($attr[
'title']) && $label) {
12649 $attr[
'title'] = $label;
12650 $useclassfortooltip = 0;
12653 if ($status == 2) {
12654 $attr[
'class'] .=
' btnTitleSelected';
12655 } elseif ($status <= 0) {
12656 $attr[
'class'] .=
' refused';
12658 $attr[
'href'] =
'';
12660 if ($status == -1) {
12661 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"FeatureDisabled"));
12662 } elseif ($status == 0) {
12663 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions"));
12667 if (!empty($attr[
'title']) && $useclassfortooltip) {
12668 $attr[
'class'] .=
' classfortooltip';
12676 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
12677 foreach ($params[
'attr'] as $key => $value) {
12678 if ($key ==
'class') {
12679 $attr[
'class'] .=
' '.$value;
12680 } elseif ($key ==
'classOverride') {
12681 $attr[
'class'] = $value;
12683 $attr[$key] = $value;
12688 if (isset($attr[
'href']) && empty($attr[
'href'])) {
12689 unset($attr[
'href']);
12695 $attr = array_map(
'dol_escape_htmltag', $attr);
12697 $TCompiledAttr = array();
12698 foreach ($attr as $key => $value) {
12699 $TCompiledAttr[] = $key.
'="'.$value.
'"';
12702 $compiledAttributes = (empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr));
12704 $tag = (empty($attr[
'href']) ?
'span' :
'a');
12706 $button =
'<'.$tag.
' '.$compiledAttributes.
'>';
12707 $button .=
'<span class="'.$iconClass.
' valignmiddle btnTitle-icon"></span>';
12708 if (!empty($params[
'forcenohideoftext'])) {
12709 $button .=
'<span class="valignmiddle text-plus-circle btnTitle-label'.(empty($params[
'forcenohideoftext']) ?
' hideonsmartphone' :
'').
'">'.$label.
'</span>';
12711 $button .=
'</'.$tag.
'>';
12727 global $conf, $db, $hookmanager;
12733 $classfile = $classname = $classpath = $subdir = $dir_output =
'';
12736 $module = $elementType;
12737 $element = $elementType;
12738 $subelement = $elementType;
12739 $table_element = $elementType;
12742 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $elementType, $regs)) {
12743 $element = $subelement = $regs[1];
12744 $module = $regs[2];
12749 if (preg_match(
'/^([^_]+)_([^_]+)/i', $element, $regs)) {
12750 $module = $element = $regs[1];
12751 $subelement = $regs[2];
12755 if (substr($elementType, -3) ==
'det') {
12756 $module = preg_replace(
'/det$/',
'', $element);
12757 $subelement = preg_replace(
'/det$/',
'', $subelement);
12758 $classpath = $module.
'/class';
12759 $classfile = $module;
12760 $classname = preg_replace(
'/det$/',
'Line', $element);
12761 if (in_array($module, array(
'expedition',
'propale',
'facture',
'contrat',
'fichinter',
'commandefournisseur'))) {
12762 $classname = preg_replace(
'/det$/',
'Ligne', $element);
12766 if ($elementType ==
"action" || $elementType ==
"actioncomm") {
12767 $classpath =
'comm/action/class';
12768 $subelement =
'Actioncomm';
12769 $module =
'agenda';
12770 $table_element =
'actioncomm';
12771 } elseif ($elementType ==
'cronjob') {
12772 $classpath =
'cron/class';
12774 $table_element =
'cron';
12775 } elseif ($elementType ==
'adherent_type') {
12776 $classpath =
'adherents/class';
12777 $classfile =
'adherent_type';
12778 $module =
'adherent';
12779 $subelement =
'adherent_type';
12780 $classname =
'AdherentType';
12781 $table_element =
'adherent_type';
12782 } elseif ($elementType ==
'bank_account') {
12783 $classpath =
'compta/bank/class';
12785 $classfile =
'account';
12786 $classname =
'Account';
12787 } elseif ($elementType ==
'category') {
12788 $classpath =
'categories/class';
12789 $module =
'categorie';
12790 $subelement =
'categorie';
12791 $table_element =
'categorie';
12792 } elseif ($elementType ==
'contact') {
12793 $classpath =
'contact/class';
12794 $classfile =
'contact';
12795 $module =
'societe';
12796 $subelement =
'contact';
12797 $table_element =
'socpeople';
12798 } elseif ($elementType ==
'inventory') {
12799 $module =
'product';
12800 $classpath =
'product/inventory/class';
12801 } elseif ($elementType ==
'stock' || $elementType ==
'entrepot') {
12803 $classpath =
'product/stock/class';
12804 $classfile =
'entrepot';
12805 $classname =
'Entrepot';
12806 $table_element =
'entrepot';
12807 } elseif ($elementType ==
'project') {
12808 $classpath =
'projet/class';
12809 $module =
'projet';
12810 $table_element =
'projet';
12811 } elseif ($elementType ==
'project_task') {
12812 $classpath =
'projet/class';
12813 $module =
'projet';
12814 $subelement =
'task';
12815 $table_element =
'projet_task';
12816 } elseif ($elementType ==
'facture' || $elementType ==
'invoice') {
12817 $classpath =
'compta/facture/class';
12818 $module =
'facture';
12819 $subelement =
'facture';
12820 $table_element =
'facture';
12821 } elseif ($elementType ==
'facturerec') {
12822 $classpath =
'compta/facture/class';
12823 $module =
'facture';
12824 $classname =
'FactureRec';
12825 } elseif ($elementType ==
'commande' || $elementType ==
'order') {
12826 $classpath =
'commande/class';
12827 $module =
'commande';
12828 $subelement =
'commande';
12829 $table_element =
'commande';
12830 } elseif ($elementType ==
'propal') {
12831 $classpath =
'comm/propal/class';
12832 $table_element =
'propal';
12833 } elseif ($elementType ==
'shipping') {
12834 $classpath =
'expedition/class';
12835 $classfile =
'expedition';
12836 $classname =
'Expedition';
12837 $module =
'expedition';
12838 $table_element =
'expedition';
12839 } elseif ($elementType ==
'delivery_note') {
12840 $classpath =
'delivery/class';
12841 $subelement =
'delivery';
12842 $module =
'expedition';
12843 } elseif ($elementType ==
'delivery') {
12844 $classpath =
'delivery/class';
12845 $subelement =
'delivery';
12846 $module =
'expedition';
12847 } elseif ($elementType ==
'supplier_proposal') {
12848 $classpath =
'supplier_proposal/class';
12849 $module =
'supplier_proposal';
12850 $element =
'supplierproposal';
12851 $classfile =
'supplier_proposal';
12852 $subelement =
'supplierproposal';
12853 } elseif ($elementType ==
'contract') {
12854 $classpath =
'contrat/class';
12855 $module =
'contrat';
12856 $subelement =
'contrat';
12857 $table_element =
'contract';
12858 } elseif ($elementType ==
'mailing') {
12859 $classpath =
'comm/mailing/class';
12860 $module =
'mailing';
12861 $classfile =
'mailing';
12862 $classname =
'Mailing';
12864 } elseif ($elementType ==
'member') {
12865 $classpath =
'adherents/class';
12866 $module =
'adherent';
12867 $subelement =
'adherent';
12868 $table_element =
'adherent';
12869 } elseif ($elementType ==
'usergroup') {
12870 $classpath =
'user/class';
12872 } elseif ($elementType ==
'mo') {
12873 $classpath =
'mrp/class';
12878 $table_element =
'mrp_mo';
12879 } elseif ($elementType ==
'cabinetmed_cons') {
12880 $classpath =
'cabinetmed/class';
12881 $module =
'cabinetmed';
12882 $subelement =
'cabinetmedcons';
12883 $table_element =
'cabinetmedcons';
12884 } elseif ($elementType ==
'fichinter') {
12885 $classpath =
'fichinter/class';
12886 $module =
'ficheinter';
12887 $subelement =
'fichinter';
12888 $table_element =
'fichinter';
12889 } elseif ($elementType ==
'dolresource' || $elementType ==
'resource') {
12890 $classpath =
'resource/class';
12891 $module =
'resource';
12892 $subelement =
'dolresource';
12893 $table_element =
'resource';
12894 } elseif ($elementType ==
'propaldet') {
12895 $classpath =
'comm/propal/class';
12896 $module =
'propal';
12897 $subelement =
'propaleligne';
12898 } elseif ($elementType ==
'opensurvey_sondage') {
12899 $classpath =
'opensurvey/class';
12900 $module =
'opensurvey';
12901 $subelement =
'opensurveysondage';
12902 } elseif ($elementType ==
'order_supplier') {
12903 $classpath =
'fourn/class';
12904 $module =
'fournisseur';
12905 $classfile =
'fournisseur.commande';
12906 $element =
'order_supplier';
12908 $classname =
'CommandeFournisseur';
12909 $table_element =
'commande_fournisseur';
12910 } elseif ($elementType ==
'commande_fournisseurdet') {
12911 $classpath =
'fourn/class';
12912 $module =
'fournisseur';
12913 $classfile =
'fournisseur.commande';
12914 $element =
'commande_fournisseurdet';
12916 $classname =
'CommandeFournisseurLigne';
12917 $table_element =
'commande_fournisseurdet';
12918 } elseif ($elementType ==
'invoice_supplier') {
12919 $classpath =
'fourn/class';
12920 $module =
'fournisseur';
12921 $classfile =
'fournisseur.facture';
12922 $element =
'invoice_supplier';
12924 $classname =
'FactureFournisseur';
12925 $table_element =
'facture_fourn';
12926 } elseif ($elementType ==
"service") {
12927 $classpath =
'product/class';
12928 $subelement =
'product';
12929 $table_element =
'product';
12930 } elseif ($elementType ==
'salary') {
12931 $classpath =
'salaries/class';
12932 $module =
'salaries';
12933 } elseif ($elementType ==
'payment_salary') {
12934 $classpath =
'salaries/class';
12935 $classfile =
'paymentsalary';
12936 $classname =
'PaymentSalary';
12937 $module =
'salaries';
12938 } elseif ($elementType ==
'productlot') {
12939 $module =
'productbatch';
12940 $classpath =
'product/stock/class';
12941 $classfile =
'productlot';
12942 $classname =
'Productlot';
12943 $element =
'productlot';
12945 $table_element =
'product_lot';
12946 } elseif ($elementType ==
'societeaccount') {
12947 $classpath =
'societe/class';
12948 $classfile =
'societeaccount';
12949 $classname =
'SocieteAccount';
12950 $module =
'societe';
12951 } elseif ($elementType ==
'websitepage') {
12952 $classpath =
'website/class';
12953 $classfile =
'websitepage';
12954 $classname =
'Websitepage';
12955 $module =
'website';
12956 $subelement =
'websitepage';
12957 $table_element =
'website_page';
12958 } elseif ($elementType ==
'fiscalyear') {
12959 $classpath =
'core/class';
12960 $module =
'accounting';
12961 $subelement =
'fiscalyear';
12962 } elseif ($elementType ==
'chargesociales') {
12963 $classpath =
'compta/sociales/class';
12965 $table_element =
'chargesociales';
12966 } elseif ($elementType ==
'tva') {
12967 $classpath =
'compta/tva/class';
12970 $table_element =
'tva';
12971 } elseif ($elementType ==
'emailsenderprofile') {
12973 $classpath =
'core/class';
12974 $classfile =
'emailsenderprofile';
12975 $classname =
'EmailSenderProfile';
12976 $table_element =
'c_email_senderprofile';
12978 } elseif ($elementType ==
'conferenceorboothattendee') {
12979 $classpath =
'eventorganization/class';
12980 $classfile =
'conferenceorboothattendee';
12981 $classname =
'ConferenceOrBoothAttendee';
12982 $module =
'eventorganization';
12983 } elseif ($elementType ==
'conferenceorbooth') {
12984 $classpath =
'eventorganization/class';
12985 $classfile =
'conferenceorbooth';
12986 $classname =
'ConferenceOrBooth';
12987 $module =
'eventorganization';
12988 } elseif ($elementType ==
'ccountry') {
12990 $classpath =
'core/class';
12991 $classfile =
'ccountry';
12992 $classname =
'Ccountry';
12993 $table_element =
'c_country';
12997 if (empty($classfile)) {
12998 $classfile = strtolower($subelement);
13000 if (empty($classname)) {
13001 $classname = ucfirst($subelement);
13003 if (empty($classpath)) {
13004 $classpath = $module.
'/class';
13010 if ($module && isset($conf->$module)) {
13011 if (!empty($conf->$module->multidir_output[$conf->entity])) {
13012 $dir_output = $conf->$module->multidir_output[$conf->entity];
13013 } elseif (!empty($conf->$module->output[$conf->entity])) {
13014 $dir_output = $conf->$module->output[$conf->entity];
13015 } elseif (!empty($conf->$module->dir_output)) {
13016 $dir_output = $conf->$module->dir_output;
13021 if ($element ==
'order_supplier') {
13022 $dir_output = $conf->fournisseur->commande->dir_output;
13023 } elseif ($element ==
'invoice_supplier') {
13024 $dir_output = $conf->fournisseur->facture->dir_output;
13026 $dir_output .= $subdir;
13028 $elementProperties = array(
13029 'module' => $module,
13030 'element' => $element,
13031 'table_element' => $table_element,
13032 'subelement' => $subelement,
13033 'classpath' => $classpath,
13034 'classfile' => $classfile,
13035 'classname' => $classname,
13036 'dir_output' => $dir_output
13041 if (!is_object($hookmanager)) {
13042 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
13045 $hookmanager->initHooks(array(
'elementproperties'));
13049 $parameters = array(
13050 'elementType' => $elementType,
13051 'elementProperties' => $elementProperties
13054 $reshook = $hookmanager->executeHooks(
'getElementProperties', $parameters);
13057 $elementProperties = $hookmanager->resArray;
13058 } elseif (!empty($hookmanager->resArray) && is_array($hookmanager->resArray)) {
13059 $elementProperties = array_replace($elementProperties, $hookmanager->resArray);
13063 if (($key = array_search(
'elementproperties', $hookmanager->contextarray)) !==
false) {
13064 unset($hookmanager->contextarray[$key]);
13067 return $elementProperties;
13082function fetchObjectByElement($element_id, $element_type, $element_ref =
'', $useCache = 0, $maxCacheByType = 10)
13090 if ($element_prop[
'module'] ==
'product' || $element_prop[
'module'] ==
'service') {
13095 $ismodenabled = (isModEnabled(
'product') || isModEnabled(
'service'));
13096 } elseif ($element_prop[
'module'] ==
'societeaccount') {
13097 $ismodenabled = isModEnabled(
'website') || isModEnabled(
'webportal');
13099 $ismodenabled = isModEnabled($element_prop[
'module']);
13104 if (is_array($element_prop) && (empty($element_prop[
'module']) || $ismodenabled)) {
13105 if ($useCache === 1
13106 && !empty($conf->cache[
'fetchObjectByElement'][$element_type])
13107 && !empty($conf->cache[
'fetchObjectByElement'][$element_type][$element_id])
13108 && is_object($conf->cache[
'fetchObjectByElement'][$element_type][$element_id])
13110 return $conf->cache[
'fetchObjectByElement'][$element_type][$element_id];
13113 dol_include_once(
'/'.$element_prop[
'classpath'].
'/'.$element_prop[
'classfile'].
'.class.php');
13115 if (class_exists($element_prop[
'classname'])) {
13116 $className = $element_prop[
'classname'];
13117 $objecttmp =
new $className($db);
13118 '@phan-var-force CommonObject $objecttmp';
13120 if ($element_id > 0 || !empty($element_ref)) {
13121 $ret = $objecttmp->fetch($element_id, $element_ref);
13123 if (empty($objecttmp->module)) {
13124 $objecttmp->module = $element_prop[
'module'];
13127 if ($useCache > 0) {
13128 if (!isset($conf->cache[
'fetchObjectByElement'][$element_type])) {
13129 $conf->cache[
'fetchObjectByElement'][$element_type] = [];
13133 if (! empty($conf->cache[
'fetchObjectByElement'][$element_type]) && is_array($conf->cache[
'fetchObjectByElement'][$element_type]) && count($conf->cache[
'fetchObjectByElement'][$element_type]) >= $maxCacheByType) {
13134 array_shift($conf->cache[
'fetchObjectByElement'][$element_type]);
13137 $conf->cache[
'fetchObjectByElement'][$element_type][$element_id] = $objecttmp;
13161 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)) {
13177 return empty($_SESSION[
'newtoken']) ?
'' : $_SESSION[
'newtoken'];
13189 return isset($_SESSION[
'token']) ? $_SESSION[
'token'] :
'';
13201 if (empty($conf->cache[
'nonce'])) {
13205 return $conf->cache[
'nonce'];
13222function startSimpleTable($header, $link =
"", $arguments =
"", $emptyColumns = 0, $number = -1, $pictofulllist =
'')
13226 print
'<div class="div-table-responsive-no-min">';
13227 print
'<table class="noborder centpercent">';
13228 print
'<tr class="liste_titre">';
13230 print ($emptyColumns < 1) ?
'<th>' :
'<th colspan="'.($emptyColumns + 1).
'">';
13232 print
'<span class="valignmiddle">'.$langs->trans($header).
'</span>';
13234 if (!empty($link)) {
13235 if (!empty($arguments)) {
13236 print
'<a href="'.DOL_URL_ROOT.
'/'.$link.
'?'.$arguments.
'">';
13238 print
'<a href="'.DOL_URL_ROOT.
'/'.$link.
'">';
13242 if ($number > -1) {
13243 print
'<span class="badge marginleftonlyshort">'.$number.
'</span>';
13244 } elseif (!empty($link)) {
13245 print
'<span class="badge marginleftonlyshort">...</span>';
13248 if (!empty($link)) {
13254 if ($number < 0 && !empty($link)) {
13255 print
'<th class="right">';
13275 if ($addLineBreak) {
13291function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord =
"None", $extraRightColumn =
false)
13296 print
'<tr class="oddeven">';
13297 print
'<td colspan="'.$tableColumnCount.
'"><span class="opacitymedium">'.$langs->trans($noneWord).
'</span></td>';
13302 if ($nbofloop === 0) {
13308 $colspan = $tableColumnCount;
13309 } elseif ($num > $nbofloop) {
13310 $colspan = $tableColumnCount;
13312 $colspan = $tableColumnCount - 1;
13315 if ($extraRightColumn) {
13319 print
'<tr class="liste_total">';
13321 if ($nbofloop > 0 && $num > $nbofloop) {
13322 print
'<td colspan="'.$colspan.
'" class="right">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
'</td>';
13324 print
'<td colspan="'.$colspan.
'" class="right"> '.$langs->trans(
"Total").
'</td>';
13325 print
'<td class="right centpercent">'.price($total).
'</td>';
13328 if ($extraRightColumn) {
13345 if ($method == -1) {
13356 while (ob_get_level()) {
13361 if ($method == 0) {
13362 readfile($fullpath_original_file_osencoded);
13363 } elseif ($method == 1) {
13365 $handle = fopen($fullpath_original_file_osencoded,
"rb");
13366 while (!feof($handle)) {
13367 print fread($handle, 8192);
13370 } elseif ($method == 2) {
13372 $handle1 = fopen($fullpath_original_file_osencoded,
"rb");
13373 $handle2 = fopen(
"php://output",
"wb");
13374 stream_copy_to_stream($handle1, $handle2);
13399 if ($texttoshow ===
'none') {
13400 $result =
'<span class="clipboardCP'.($showonlyonhover ?
' clipboardCPShowOnHover' :
'').
'"><'.$tag.
' class="clipboardCPValue hidewithsize">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'><span class="clipboardCPValueToPrint"></span><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText"></span></span>';
13401 } elseif ($texttoshow) {
13402 $result =
'<span class="clipboardCP'.($showonlyonhover ?
' clipboardCPShowOnHover' :
'').
'"><'.$tag.
' class="clipboardCPValue hidewithsize">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'><span class="clipboardCPValueToPrint">'.
dol_escape_htmltag($texttoshow, 1, 1).
'</span><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText"></span></span>';
13404 $result =
'<span class="clipboardCP'.($showonlyonhover ?
' clipboardCPShowOnHover' :
'').
'"><'.$tag.
' class="clipboardCPValue">'.
dol_escape_htmltag($valuetocopy, 1, 1).
'</'.$tag.
'><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText"></span></span>';
13419 $result = json_decode($stringtodecode);
13420 if ($result ===
null) {
13421 $result = unserialize($stringtodecode);
13448 if (is_null($filter) || !is_string($filter) || $filter ===
'') {
13451 if (!preg_match(
'/^\(.*\)$/', $filter)) {
13452 $filter =
'(' . $filter .
')';
13455 $regexstring =
'\(([a-zA-Z0-9_\.]+:[<>!=insotlke]+:[^\(\)]+)\)';
13456 $firstandlastparenthesis = 0;
13458 if (!
dolCheckFilters($filter, $errorstr, $firstandlastparenthesis)) {
13462 return 'Filter syntax error - '.$errorstr;
13467 $t = preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeDummyCriteriaCallback', $filter);
13468 $t = str_replace(array(
'and',
'or',
'AND',
'OR',
' '),
'', $t);
13471 if (preg_match(
'/[^\(\)]/', $t)) {
13472 $tmperrorstr =
'Bad syntax of the search string';
13473 $errorstr =
'Bad syntax of the search string: '.$filter;
13477 dol_syslog(
"forgeSQLFromUniversalSearchCriteria Filter error - ".$errorstr, LOG_WARNING);
13478 return 'Filter error - '.$tmperrorstr;
13482 $ret = ($noand ?
"" :
" AND ").($nopar ?
"" :
'(').preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeCriteriaCallback', $filter).($nopar ?
"" :
')');
13484 if (is_object($db)) {
13485 $ret = str_replace(
'__NOW__', $db->idate(
dol_now()), $ret);
13487 if (is_object($user)) {
13488 $ret = str_replace(
'__USER_ID__', (
string) $user->id, $ret);
13503 $arrayofandtags = array();
13507 $parenthesislevel = 0;
13512 if ($parenthesislevel >= 1) {
13513 $sqlfilters = preg_replace(
'/^\(/',
'', preg_replace(
'/\)$/',
'', $sqlfilters));
13518 $countparenthesis = 0;
13519 while ($i < $nbofchars) {
13522 if ($char ==
'(') {
13523 $countparenthesis++;
13524 } elseif ($char ==
')') {
13525 $countparenthesis--;
13528 if ($countparenthesis == 0) {
13529 $char2 =
dol_substr($sqlfilters, $i + 1, 1);
13530 $char3 =
dol_substr($sqlfilters, $i + 2, 1);
13531 if ($char ==
'A' && $char2 ==
'N' && $char3 ==
'D') {
13534 if (!preg_match(
'/^\(.*\)$/', $s)) {
13537 $arrayofandtags[] = $s;
13550 if (!preg_match(
'/^\(.*\)$/', $s)) {
13553 $arrayofandtags[] = $s;
13556 return $arrayofandtags;
13568function dolCheckFilters($sqlfilters, &$error =
'', &$parenthesislevel = 0)
13572 $tmp = $sqlfilters;
13576 $parenthesislevel = 0;
13584 if ($char ==
'(') {
13585 if ($i == $parenthesislevel && $parenthesislevel == $counter) {
13587 $parenthesislevel++;
13590 } elseif ($char ==
')') {
13591 $nbcharremaining = ($nb - $i - 1);
13592 if ($nbcharremaining >= $counter) {
13593 $parenthesislevel = min($parenthesislevel, $counter - 1);
13595 if ($parenthesislevel > $counter && $nbcharremaining >= $counter) {
13596 $parenthesislevel = $counter;
13601 if ($counter < 0) {
13602 $error =
"Wrong balance of parenthesis in sqlfilters=".$sqlfilters;
13603 $parenthesislevel = 0;
13611 if ($counter > 0) {
13612 $error =
"Wrong balance of parenthesis in sqlfilters=".$sqlfilters;
13613 $parenthesislevel = 0;
13631 if (empty($matches[1])) {
13634 $tmp = explode(
':', $matches[1]);
13635 if (count($tmp) < 3) {
13655 if (empty($matches[1])) {
13658 $tmp = explode(
':', $matches[1], 3);
13659 if (count($tmp) < 3) {
13663 $operand = preg_replace(
'/[^a-z0-9\._]/i',
'', trim($tmp[0]));
13665 $operator = strtoupper(preg_replace(
'/[^a-z<>!=]/i',
'', trim($tmp[1])));
13668 'NOTLIKE' =>
'NOT LIKE',
13669 'ISNOT' =>
'IS NOT',
13670 'NOTIN' =>
'NOT IN',
13674 if (array_key_exists($operator, $realOperator)) {
13675 $operator = $realOperator[$operator];
13678 $tmpescaped = $tmp[2];
13684 if ($operator ==
'IN' || $operator ==
'NOT IN') {
13686 $tmpescaped2 =
'(';
13688 $tmpelemarray = explode(
',', $tmpescaped);
13689 foreach ($tmpelemarray as $tmpkey => $tmpelem) {
13691 if (preg_match(
'/^\'(.*)\'$/', $tmpelem, $reg)) {
13692 $tmpelemarray[$tmpkey] =
"'".$db->escape($db->sanitize($reg[1], 1, 1, 1)).
"'";
13694 $tmpelemarray[$tmpkey] = $db->escape($db->sanitize($tmpelem, 1, 1, 1));
13697 $tmpescaped2 .= implode(
',', $tmpelemarray);
13698 $tmpescaped2 .=
')';
13700 $tmpescaped = $tmpescaped2;
13701 } elseif ($operator ==
'LIKE' || $operator ==
'NOT LIKE') {
13702 if (preg_match(
'/^\'([^\']*)\'$/', $tmpescaped, $regbis)) {
13703 $tmpescaped = $regbis[1];
13706 $tmpescaped =
"'".$db->escape($tmpescaped).
"'";
13707 } elseif (preg_match(
'/^\'(.*)\'$/', $tmpescaped, $regbis)) {
13710 $tmpescaped =
"'".$db->escape($regbis[1]).
"'";
13712 if (strtoupper($tmpescaped) ==
'NULL') {
13713 $tmpescaped =
'NULL';
13714 } elseif (is_int($tmpescaped)) {
13715 $tmpescaped = (int) $tmpescaped;
13717 $tmpescaped = (float) $tmpescaped;
13721 return '('.$db->escape($operand).
' '.strtoupper($operator).
' '.$tmpescaped.
')';
13738 $out =
'<!-- timeline icon -->'.
"\n";
13739 $iconClass =
'fa fa-comments';
13744 if ($histo[$key][
'percent'] == -1) {
13745 $colorClass =
'timeline-icon-not-applicble';
13746 $pictoTitle = $langs->trans(
'StatusNotApplicable');
13747 } elseif ($histo[$key][
'percent'] == 0) {
13748 $colorClass =
'timeline-icon-todo';
13749 $pictoTitle = $langs->trans(
'StatusActionToDo').
' (0%)';
13750 } elseif ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100) {
13751 $colorClass =
'timeline-icon-in-progress';
13752 $pictoTitle = $langs->trans(
'StatusActionInProcess').
' ('.$histo[$key][
'percent'].
'%)';
13753 } elseif ($histo[$key][
'percent'] >= 100) {
13754 $colorClass =
'timeline-icon-done';
13755 $pictoTitle = $langs->trans(
'StatusActionDone').
' (100%)';
13758 if ($actionstatic->code ==
'AC_TICKET_CREATE') {
13759 $iconClass =
'fa fa-ticket';
13760 } elseif ($actionstatic->code ==
'AC_TICKET_MODIFY') {
13761 $iconClass =
'fa fa-pencilxxx';
13762 } elseif (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
13763 $iconClass =
'fa fa-comments';
13764 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
13765 $iconClass =
'fa fa-mask';
13767 if ($actionstatic->type_picto) {
13768 $img_picto =
img_picto(
'', $actionstatic->type_picto);
13770 if ($actionstatic->type_code ==
'AC_RDV') {
13771 $iconClass =
'fa fa-handshake';
13772 } elseif ($actionstatic->type_code ==
'AC_TEL') {
13773 $iconClass =
'fa fa-phone';
13774 } elseif ($actionstatic->type_code ==
'AC_FAX') {
13775 $iconClass =
'fa fa-fax';
13776 } elseif ($actionstatic->type_code ==
'AC_EMAIL') {
13777 $iconClass =
'fa fa-envelope';
13778 } elseif ($actionstatic->type_code ==
'AC_INT') {
13779 $iconClass =
'fa fa-shipping-fast';
13780 } elseif ($actionstatic->type_code ==
'AC_OTH_AUTO') {
13781 $iconClass =
'fa fa-robot';
13782 } elseif (!preg_match(
'/_AUTO/', $actionstatic->type_code)) {
13783 $iconClass =
'fa fa-robot';
13788 $out .=
'<i class="'.$iconClass.
' '.$colorClass.
'" title="'.$pictoTitle.
'">'.$img_picto.
'</i>'.
"\n";
13802 $documents = array();
13804 $sql =
'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.filepath, ecm.filename';
13805 $sql .=
' FROM '.MAIN_DB_PREFIX.
'ecm_files ecm';
13806 $sql .=
" WHERE ecm.filepath = 'agenda/".((int)
$object->id).
"'";
13808 $sql .=
' ORDER BY ecm.position ASC';
13810 $resql = $db->query($sql);
13812 if ($db->num_rows($resql)) {
13813 while ($obj = $db->fetch_object($resql)) {
13814 $documents[$obj->id] = $obj;
13840function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon =
null, $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC')
13842 global $user, $conf;
13845 global $param, $massactionbutton;
13847 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
13850 if (!is_object($filterobj) && !is_object($objcon)) {
13855 '@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';
13860 $sortfield_list = explode(
',', $sortfield);
13861 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
13862 $sortfield_new_list = array();
13863 foreach ($sortfield_list as $sortfield_value) {
13864 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
13866 $sortfield_new = implode(
',', $sortfield_new_list);
13871 if (isModEnabled(
'agenda')) {
13873 if (is_object($objcon) && $objcon->id > 0) {
13874 $sql =
"SELECT DISTINCT a.id, a.label as label,";
13876 $sql =
"SELECT a.id, a.label as label,";
13878 $sql .=
" a.datep as dp,";
13879 $sql .=
" a.note as message,";
13880 $sql .=
" a.datep2 as dp2,";
13881 $sql .=
" a.percent as percent, 'action' as type,";
13882 $sql .=
" a.fk_element, a.elementtype,";
13883 $sql .=
" a.fk_contact,";
13884 $sql .=
" a.email_from as msg_from,";
13885 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
13886 $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";
13887 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
13888 $sql .=
", sp.lastname, sp.firstname";
13889 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
13890 $sql .=
", m.lastname, m.firstname";
13891 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
13893 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
13895 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
13897 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
13899 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
13902 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
13903 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
13904 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
13906 $force_filter_contact = $filterobj instanceof
User;
13908 if (is_object($objcon) && $objcon->id > 0) {
13909 $force_filter_contact =
true;
13910 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as r ON a.id = r.fk_actioncomm";
13911 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id);
13914 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
13915 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
13916 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
13917 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
13918 $sql .=
" ON er.resource_type = 'dolresource'";
13919 $sql .=
" AND er.element_id = a.id";
13920 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
13921 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
13922 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
13923 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
13924 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
13925 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
13926 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
13927 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
13928 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
13929 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
13930 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
13931 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
13932 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
13935 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
13936 if (!$force_filter_contact) {
13937 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
13938 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
13939 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
13940 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
13941 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
13942 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
13943 if ($filterobj->id) {
13944 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
13946 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
13947 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
13948 if ($filterobj->id) {
13949 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
13951 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
13952 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
13953 if ($filterobj->id) {
13954 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
13956 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
13957 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
13958 if ($filterobj->id) {
13959 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
13961 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
13962 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
13963 if ($filterobj->id) {
13964 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
13966 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
13967 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
13968 if ($filterobj->id) {
13969 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
13973 $sql .=
" AND u.rowid = ". ((int) $filterobj->id);
13977 if (!empty($actioncode)) {
13979 if ($actioncode ==
'AC_NON_AUTO') {
13980 $sql .=
" AND c.type != 'systemauto'";
13981 } elseif ($actioncode ==
'AC_ALL_AUTO') {
13982 $sql .=
" AND c.type = 'systemauto'";
13984 if ($actioncode ==
'AC_OTH') {
13985 $sql .=
" AND c.type != 'systemauto'";
13986 } elseif ($actioncode ==
'AC_OTH_AUTO') {
13987 $sql .=
" AND c.type = 'systemauto'";
13991 if ($actioncode ==
'AC_NON_AUTO') {
13992 $sql .=
" AND c.type != 'systemauto'";
13993 } elseif ($actioncode ==
'AC_ALL_AUTO') {
13994 $sql .=
" AND c.type = 'systemauto'";
13996 $sql .=
" AND c.code = '".$db->escape($actioncode).
"'";
14000 if ($donetodo ==
'todo') {
14001 $sql .=
" AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now).
"'))";
14002 } elseif ($donetodo ==
'done') {
14003 $sql .=
" AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now).
"'))";
14005 if (is_array($filters) && $filters[
'search_agenda_label']) {
14006 $sql .=
natural_search(
'a.label', $filters[
'search_agenda_label']);
14011 if (isModEnabled(
'mailing') && !empty($objcon->email)
14012 && (empty($actioncode) || $actioncode ==
'AC_OTH_AUTO' || $actioncode ==
'AC_EMAILING')) {
14013 $langs->load(
"mails");
14015 $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";
14016 $sql2 .=
", null as fk_element, '' as elementtype, null as contact_id";
14017 $sql2 .=
", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
14018 $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";
14019 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
14020 $sql2 .=
", '' as lastname, '' as firstname";
14021 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
14022 $sql2 .=
", '' as lastname, '' as firstname";
14023 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
14024 $sql2 .=
", '' as ref";
14025 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
14026 $sql2 .=
", '' as ref";
14027 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
14028 $sql2 .=
", '' as ref";
14030 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"user as u";
14031 $sql2 .=
" WHERE mc.email = '".$db->escape($objcon->email).
"'";
14032 $sql2 .=
" AND mc.statut = 1";
14033 $sql2 .=
" AND u.rowid = m.fk_user_valid";
14034 $sql2 .=
" AND mc.fk_mailing=m.rowid";
14037 if ($sql || $sql2) {
14038 if (!empty($sql) && !empty($sql2)) {
14039 $sql = $sql.
" UNION ".$sql2;
14040 } elseif (empty($sql) && !empty($sql2)) {
14049 $sql .= $db->order($sortfield_new, $sortorder);
14051 $sql .= $db->plimit($limit + 1, $offset);
14054 dol_syslog(
"function.lib::show_actions_messaging", LOG_DEBUG);
14055 $resql = $db->query($sql);
14058 $num = $db->num_rows($resql);
14060 $imaxinloop = ($limit ? min($num, $limit) : $num);
14061 while ($i < $imaxinloop) {
14062 $obj = $db->fetch_object($resql);
14064 if ($obj->type ==
'action') {
14066 $contactaction->id = $obj->id;
14067 $result = $contactaction->fetchResources();
14070 setEventMessage(
"actions.lib::show_actions_messaging Error fetch resource",
'errors');
14076 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->dp > $now)) {
14077 $tododone =
'todo';
14080 $histo[$numaction] = array(
14081 'type' => $obj->type,
14082 'tododone' => $tododone,
14084 'datestart' => $db->jdate($obj->dp),
14085 'dateend' => $db->jdate($obj->dp2),
14086 'note' => $obj->label,
14088 'percent' => $obj->percent,
14090 'userid' => $obj->user_id,
14091 'login' => $obj->user_login,
14092 'userfirstname' => $obj->user_firstname,
14093 'userlastname' => $obj->user_lastname,
14094 'userphoto' => $obj->user_photo,
14095 'msg_from' => $obj->msg_from,
14097 'contact_id' => $obj->fk_contact,
14098 'socpeopleassigned' => $contactaction->socpeopleassigned,
14099 'lastname' => (empty($obj->lastname) ?
'' : $obj->lastname),
14100 'firstname' => (empty($obj->firstname) ?
'' : $obj->firstname),
14101 'fk_element' => $obj->fk_element,
14102 'elementtype' => $obj->elementtype,
14104 'acode' => $obj->acode,
14105 'alabel' => $obj->alabel,
14106 'libelle' => $obj->alabel,
14107 'apicto' => $obj->apicto
14110 $histo[$numaction] = array(
14111 'type' => $obj->type,
14112 'tododone' =>
'done',
14114 'datestart' => $db->jdate($obj->dp),
14115 'dateend' => $db->jdate($obj->dp2),
14116 'note' => $obj->label,
14118 'percent' => $obj->percent,
14119 'acode' => $obj->acode,
14121 'userid' => $obj->user_id,
14122 'login' => $obj->user_login,
14123 'userfirstname' => $obj->user_firstname,
14124 'userlastname' => $obj->user_lastname,
14125 'userphoto' => $obj->user_photo
14140 if (!isModEnabled(
'agenda')) {
14141 $langs->loadLangs(array(
"admin",
"errors"));
14142 $out =
info_admin($langs->trans(
"WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv(
"Module2400Name")), 0, 0,
'warning');
14145 if (isModEnabled(
'agenda') || (isModEnabled(
'mailing') && !empty($objcon->email))) {
14146 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
14148 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
14149 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
14150 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
14151 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
14156 $userstatic =
new User($db);
14157 $contactstatic =
new Contact($db);
14158 $userGetNomUrlCache = array();
14159 $contactGetNomUrlCache = array();
14161 $out .=
'<div class="filters-container" >';
14162 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
14163 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
14165 if ($objcon && get_class($objcon) ==
'Contact' &&
14166 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
14167 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
14169 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
14171 if (($filterobj && get_class($filterobj) ==
'Societe')) {
14172 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
14174 $out .=
'<input type="hidden" name="userid" value="'.$filterobj->id.
'" />';
14179 $out .=
'<div class="div-table-responsive-no-min">';
14180 $out .=
'<table class="noborder borderbottom centpercent">';
14182 $out .=
'<tr class="liste_titre">';
14186 $out .=
'<th class="liste_titre width50 middle">';
14187 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
14188 $out .= $searchpicto;
14192 $out .=
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
14194 $out .=
'<th class="liste_titre"><strong class="hideonsmartphone">'.$langs->trans(
"Search").
' : </strong></th>';
14196 $out .=
'<th class="liste_titre"></th>';
14198 $out .=
'<th class="liste_titre">';
14199 $out .=
'<span class="fas fa-square inline-block fawidth30" style=" color: #ddd;" title="'.$langs->trans(
"ActionType").
'"></span>';
14201 $out .= $formactions->select_type_actions($actioncode,
"actioncode",
'', !
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 1 : -1, 0, 0, 1,
'minwidth200imp');
14203 $out .=
'<th class="liste_titre maxwidth100onsmartphone">';
14204 $out .=
'<input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'" placeholder="'.$langs->trans(
"Label").
'">';
14209 $out .=
'<th class="liste_titre width50 middle">';
14210 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
14211 $out .= $searchpicto;
14218 $out .=
'</table>';
14225 $out .=
'<ul class="timeline">';
14229 if ($filterobj instanceof
Societe) {
14230 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
14232 if ($filterobj instanceof
User) {
14233 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
14235 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
14236 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
14237 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
14239 if ($filterobj instanceof
Societe) {
14242 if ($filterobj instanceof
User) {
14248 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
14250 $arraylist = $caction->liste_array(1,
'code',
'', (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 1 : 0),
'', 1);
14252 $actualCycleDate =
false;
14255 foreach ($histo as $key => $value) {
14256 $actionstatic->fetch($histo[$key][
'id']);
14258 $actionstatic->type_picto = $histo[$key][
'apicto'];
14259 $actionstatic->type_code = $histo[$key][
'acode'];
14261 $labeltype = $actionstatic->type_code;
14262 if (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labeltype])) {
14263 $labeltype =
'AC_OTH';
14265 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
14266 $labeltype = $langs->trans(
"Message");
14268 if (!empty($arraylist[$labeltype])) {
14269 $labeltype = $arraylist[$labeltype];
14271 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
14272 $labeltype .=
' - '.$arraylist[$actionstatic->code];
14276 $url = DOL_URL_ROOT.
'/comm/action/card.php?id='.$histo[$key][
'id'];
14278 $tmpa =
dol_getdate($histo[$key][
'datestart'],
false);
14280 if (isset($tmpa[
'year']) && isset($tmpa[
'yday']) && $actualCycleDate !== $tmpa[
'year'].
'-'.$tmpa[
'yday']) {
14281 $actualCycleDate = $tmpa[
'year'].
'-'.$tmpa[
'yday'];
14282 $out .=
'<!-- timeline time label -->';
14283 $out .=
'<li class="time-label">';
14284 $out .=
'<span class="timeline-badge-date">';
14285 $out .=
dol_print_date($histo[$key][
'datestart'],
'daytext',
'tzuserrel', $langs);
14288 $out .=
'<!-- /.timeline-label -->';
14292 $out .=
'<!-- timeline item -->'.
"\n";
14293 $out .=
'<li class="timeline-code-'.strtolower($actionstatic->code).
'">';
14296 $typeicon = $actionstatic->getTypePicto(
'pictofixedwidth timeline-icon-not-applicble', $labeltype);
14301 $out .=
'<div class="timeline-item">'.
"\n";
14303 $out .=
'<span class="time timeline-header-action2">';
14305 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
14306 $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").
' ';
14307 $out .= $histo[$key][
'id'];
14310 $out .= $actionstatic->getNomUrl(1, -1,
'valignmiddle').
' ';
14313 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
14314 (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
14315 $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).
'">';
14317 $out .=
img_picto($langs->trans(
"Modify"),
'edit',
'class="edita"');
14324 $out .=
'<span class="time"><i class="fa fa-clock-o valignmiddle"></i> <span class="valignmiddle">';
14325 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
14326 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
14327 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
14328 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
14329 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
14330 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
14332 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
14336 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
14339 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
14342 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
14345 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
14351 $out .=
"</span></span>\n";
14354 $out .=
'<h3 class="timeline-header">';
14357 $out .=
'<div class="messaging-author inline-block tdoverflowmax150 valignmiddle marginrightonly">';
14358 if ($histo[$key][
'userid'] > 0) {
14359 if (!isset($userGetNomUrlCache[$histo[$key][
'userid']])) {
14360 $userstatic->fetch($histo[$key][
'userid']);
14361 $userGetNomUrlCache[$histo[$key][
'userid']] = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
14363 $out .= $userGetNomUrlCache[$histo[$key][
'userid']];
14364 } elseif (!empty($histo[$key][
'msg_from']) && $actionstatic->code ==
'TICKET_MSG') {
14365 if (!isset($contactGetNomUrlCache[$histo[$key][
'msg_from']])) {
14366 if ($contactstatic->fetch(0,
null,
'', $histo[$key][
'msg_from']) > 0) {
14367 $contactGetNomUrlCache[$histo[$key][
'msg_from']] = $contactstatic->getNomUrl(-1,
'', 16);
14369 $contactGetNomUrlCache[$histo[$key][
'msg_from']] = $histo[$key][
'msg_from'];
14372 $out .= $contactGetNomUrlCache[$histo[$key][
'msg_from']];
14377 $out .=
' <div class="messaging-title inline-block">';
14379 if (empty($conf->dol_optimize_smallscreen) && $actionstatic->type_code !=
'AC_OTH_AUTO') {
14380 $out .= $labeltype.
' - ';
14384 if (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
14385 $out .= $langs->trans(
'TicketNewMessage');
14386 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
14387 $out .= $langs->trans(
'TicketNewMessage').
' <em>('.$langs->trans(
'Private').
')</em>';
14388 } elseif (isset($histo[$key][
'type'])) {
14389 if ($histo[$key][
'type'] ==
'action') {
14390 $transcode = $langs->transnoentitiesnoconv(
"Action".$histo[$key][
'acode']);
14391 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode : $histo[$key][
'alabel']);
14392 $libelle = $histo[$key][
'note'];
14393 $actionstatic->id = $histo[$key][
'id'];
14395 } elseif ($histo[$key][
'type'] ==
'mailing') {
14396 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
14397 $transcode = $langs->transnoentitiesnoconv(
"Action".$histo[$key][
'acode']);
14398 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
14401 $libelle .= $histo[$key][
'note'];
14406 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
14407 if (isset($conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']]) && isset($conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
14408 $link = $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
14410 if (!isset($conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']])) {
14411 $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']] = array();
14413 $link =
dolGetElementUrl($histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
14414 $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
14417 $out .=
' - '.$link;
14426 if (!empty($histo[$key][
'message'] && $histo[$key][
'message'] != $libelle)
14427 && $actionstatic->code !=
'AC_TICKET_CREATE'
14428 && $actionstatic->code !=
'AC_TICKET_MODIFY'
14430 $out .=
'<div class="timeline-body wordbreak small">';
14431 $truncateLines =
getDolGlobalInt(
'MAIN_TRUNCATE_TIMELINE_MESSAGE', 3);
14433 if ($truncateLines > 0 && strlen($histo[$key][
'message']) > strlen($truncatedText)) {
14434 $out .=
'<div class="readmore-block --closed" >';
14435 $out .=
' <div class="readmore-block__excerpt">';
14437 $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>';
14439 $out .=
' <div class="readmore-block__full-text" >';
14441 $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>';
14455 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
14457 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $Tab) {
14458 if (empty($conf->cache[
'contact'][$histo[$key][
'contact_id']])) {
14460 $contact->fetch($cid);
14461 $conf->cache[
'contact'][$histo[$key][
'contact_id']] = $contact;
14463 $contact = $conf->cache[
'contact'][$histo[$key][
'contact_id']];
14467 $contactList .= !empty($contactList) ?
', ' :
'';
14468 $contactList .= $contact->getNomUrl(1);
14469 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
14470 if (!empty($contact->phone_pro)) {
14471 $contactList .=
'('.dol_print_phone($contact->phone_pro).
')';
14477 $footer .= $langs->trans(
'ActionOnContact').
' : '.$contactList;
14478 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
14479 if (empty($conf->cache[
'contact'][$histo[$key][
'contact_id']])) {
14481 $result = $contact->fetch($histo[$key][
'contact_id']);
14482 $conf->cache[
'contact'][$histo[$key][
'contact_id']] = $contact;
14484 $contact = $conf->cache[
'contact'][$histo[$key][
'contact_id']];
14485 $result = ($contact instanceof
Contact) ? $contact->id : 0;
14489 $footer .= $contact->getNomUrl(1);
14490 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
14491 if (!empty($contact->phone_pro)) {
14492 $footer .=
'('.dol_print_phone($contact->phone_pro).
')';
14499 if (!empty($documents)) {
14500 $footer .=
'<div class="timeline-documents-container">';
14501 foreach ($documents as $doc) {
14502 $footer .=
'<span id="document_'.$doc->id.
'" class="timeline-documents" ';
14503 $footer .=
' data-id="'.$doc->id.
'" ';
14504 $footer .=
' data-path="'.$doc->filepath.
'"';
14505 $footer .=
' data-filename="'.dol_escape_htmltag($doc->filename).
'" ';
14508 $filePath = DOL_DATA_ROOT.
'/'.$doc->filepath.
'/'.$doc->filename;
14510 $file = $actionstatic->id.
'/'.$doc->filename;
14511 $thumb = $actionstatic->id.
'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename,
'.')).
'_mini'.substr($doc->filename, strrpos($doc->filename,
'.'));
14512 $doclink =
dol_buildpath(
'document.php', 1).
'?modulepart=actions&attachment=0&file='.urlencode($file).
'&entity='.$conf->entity;
14513 $viewlink =
dol_buildpath(
'viewimage.php', 1).
'?modulepart=actions&file='.urlencode($thumb).
'&entity='.$conf->entity;
14515 $mimeAttr =
' mime="'.$mime.
'" ';
14517 if (in_array($mime, array(
'image/png',
'image/jpeg',
'application/pdf'))) {
14518 $class .=
' documentpreview';
14521 $footer .=
'<a href="'.$doclink.
'" class="btn-link '.$class.
'" target="_blank" rel="noopener noreferrer" '.$mimeAttr.
' >';
14522 $footer .=
img_mime($filePath).
' '.$doc->filename;
14525 $footer .=
'</span>';
14527 $footer .=
'</div>';
14530 if (!empty($footer)) {
14531 $out .=
'<div class="timeline-footer">'.$footer.
'</div>';
14534 $out .=
'</div>'.
"\n";
14537 $out .=
'<!-- END timeline item -->';
14543 jQuery(document).ready(function () {
14544 $(document).on("click", "[data-read-more-action]", function(e){
14545 let readMoreBloc = $(this).closest(".readmore-block");
14546 if(readMoreBloc.length > 0){
14547 e.preventDefault();
14548 if($(this).attr("data-read-more-action") == "close"){
14549 readMoreBloc.addClass("--closed").removeClass("--open");
14550 $("html, body").animate({
14551 scrollTop: readMoreBloc.offset().top - 200
14554 readMoreBloc.addClass("--open").removeClass("--closed");
14562 if (empty($histo)) {
14563 $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
14584function GETPOSTDATE($prefix, $hourTime =
'', $gm =
'auto')
14587 if ($hourTime ===
'getpost') {
14591 } elseif (preg_match(
'/^(\d\d):(\d\d):(\d\d)$/', $hourTime, $m)) {
14592 $hour = intval($m[1]);
14593 $minute = intval($m[2]);
14594 $second = intval($m[3]);
14596 $hour = $minute = $second = 0;
14599 $hour = min($hour, 23);
14600 $minute = min($minute, 59);
14601 $second = min($second, 59);
14616function buildParamDate($prefix, $timestamp =
null, $hourTime =
'', $gm =
'auto')
14618 if ($timestamp ===
null) {
14619 $timestamp =
GETPOSTDATE($prefix, $hourTime, $gm);
14626 if ($hourTime ===
'getpost' || ($timestamp !==
null &&
dol_print_date($timestamp,
'%H:%M:%S') !==
'00:00:00')) {
14627 $TParam = array_merge($TParam, array(
14634 return '&' . http_build_query($TParam);
14656function recordNotFound($message =
'', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params =
null)
14658 global $conf, $db, $langs, $hookmanager;
14661 if (!is_object($langs)) {
14662 include_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
14664 $langs->setDefaultLang();
14667 $langs->load(
"errors");
14669 if ($printheader) {
14670 if (function_exists(
"llxHeader")) {
14672 } elseif (function_exists(
"llxHeaderVierge")) {
14677 print
'<div class="error">';
14678 if (empty($message)) {
14679 print $langs->trans(
"ErrorRecordNotFound");
14681 print $langs->trans($message);
14686 if (empty($showonlymessage)) {
14687 if (empty($hookmanager)) {
14688 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
14691 $hookmanager->initHooks(array(
'main'));
14694 $parameters = array(
'message' => $message,
'params' => $params);
14695 $reshook = $hookmanager->executeHooks(
'getErrorRecordNotFound', $parameters,
$object, $action);
14696 print $hookmanager->resPrint;
14699 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()
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....
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
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.
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.
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0, $morecss='')
Format phone numbers according to country.
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.
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_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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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_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.
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0, $beforearrows='', $hidenavigation=0)
Function to show navigation arrows into lists.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
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.
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.
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.
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
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
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.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0)
Clean a string to keep only desirable HTML tags.
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.
dolPrintHTMLForAttribute($s)
Return a string ready to be output on an HTML attribute (alt, title, data-html, .....
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_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
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_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)
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...
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.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
dol_bc($var, $moreclass='')
Return string to add class property on html element with pair/impair.
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).
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.
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.
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.
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_escape_json($stringtoescape)
Returns text escaped for inclusion into javascript code.
dolForgeCriteriaCallback($matches)
Function to forge a SQL criteria from a Dolibarr filter syntax string.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getUserRemoteIP()
Return the IP of remote user.
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.
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.
dolPrintLabel($s)
Return a string label (so on 1 line only and that should not contains any HTML) ready to be output on...
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.
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 ...
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
table table fiche title col title div col center btnTitle icon
Automatically calls the icon named with the corresponding "object_" prefix.
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.
dol_setcache($memoryid, $data, $expire=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid)
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.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e rowid