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)) {
965 $regreplace = array();
968 while (preg_match(
'/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) {
972 if ($reg[1] ==
'DAY') {
974 $newout = $tmp[
'mday'];
975 } elseif ($reg[1] ==
'MONTH') {
977 $newout = $tmp[
'mon'];
978 } elseif ($reg[1] ==
'YEAR') {
980 $newout = $tmp[
'year'];
981 } elseif ($reg[1] ==
'PREVIOUS_DAY') {
984 $newout = $tmp2[
'day'];
985 } elseif ($reg[1] ==
'PREVIOUS_MONTH') {
988 $newout = $tmp2[
'month'];
989 } elseif ($reg[1] ==
'PREVIOUS_YEAR') {
991 $newout = ($tmp[
'year'] - 1);
992 } elseif ($reg[1] ==
'NEXT_DAY') {
995 $newout = $tmp2[
'day'];
996 } elseif ($reg[1] ==
'NEXT_MONTH') {
999 $newout = $tmp2[
'month'];
1000 } elseif ($reg[1] ==
'NEXT_YEAR') {
1002 $newout = ($tmp[
'year'] + 1);
1003 } elseif ($reg[1] ==
'MYCOMPANY_COUNTRY_ID' || $reg[1] ==
'MYCOUNTRY_ID' || $reg[1] ==
'MYCOUNTRYID') {
1004 $newout = $mysoc->country_id;
1005 } elseif ($reg[1] ==
'USER_ID' || $reg[1] ==
'USERID') {
1006 $newout = $user->id;
1007 } elseif ($reg[1] ==
'USER_SUPERVISOR_ID' || $reg[1] ==
'SUPERVISOR_ID' || $reg[1] ==
'SUPERVISORID') {
1008 $newout = $user->fk_user;
1009 } elseif ($reg[1] ==
'ENTITY_ID' || $reg[1] ==
'ENTITYID') {
1010 $newout = $conf->entity;
1011 } elseif ($reg[1] ==
'ID') {
1014 $newout =
'REGREPLACE_'.$loopnb;
1015 $regreplace[$loopnb] = $reg[0];
1018 $out = preg_replace(
'/__'.preg_quote($reg[1],
'/').
'__/', $newout, $out);
1020 if (!empty($regreplace)) {
1021 foreach ($regreplace as $key => $value) {
1022 $out = preg_replace(
'/REGREPLACE_'.$key.
'/', $value, $out);
1028 if (preg_match(
'/^array/', $check)) {
1029 if (!is_array($out) || empty($out)) {
1032 $tmparray = explode(
':', $check);
1033 if (!empty($tmparray[1])) {
1034 $tmpcheck = $tmparray[1];
1036 $tmpcheck =
'alphanohtml';
1038 foreach ($out as $outkey => $outval) {
1039 $out[$outkey] =
sanitizeVal($outval, $tmpcheck, $filter, $options);
1045 if (strpos($paramname,
'search_') === 0) {
1046 $out = preg_replace(
'/([<>])([-+]?\d)/',
'\1 \2', $out);
1050 $out =
sanitizeVal($out, $check, $filter, $options);
1055 if (preg_match(
'/backtopage/', $paramname) || $paramname ==
'backtolist' || $paramname ==
'backtourl') {
1056 $out = str_replace(
'\\',
'/', $out);
1057 $out = str_replace(array(
':',
';',
'@',
"\t",
' '),
'', $out);
1059 $oldstringtoclean = $out;
1060 $out = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $out);
1061 $out = preg_replace(array(
'/^[^\?]*%/'),
'', $out);
1062 $out = preg_replace(array(
'/^[a-z]*\/\s*\/+/i'),
'', $out);
1063 }
while ($oldstringtoclean != $out);
1068 if (empty($method) || $method == 3 || $method == 4) {
1069 if (preg_match(
'/^search_/', $paramname) || in_array($paramname, array(
'sortorder',
'sortfield'))) {
1076 if ($out !=
'' && isset($user)) {
1077 $user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out;
1096 return (
int)
GETPOST($paramname,
'int', $method,
null,
null, 0);
1125function checkVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1127 return sanitizeVal($out, $check, $filter, $options);
1139function sanitizeVal($out =
'', $check =
'alphanohtml', $filter =
null, $options =
null)
1147 if (!is_numeric($out)) {
1152 if (is_array($out)) {
1153 $out = implode(
',', $out);
1155 if (preg_match(
'/[^0-9,-]+/i', $out)) {
1160 $out = filter_var($out, FILTER_SANITIZE_STRING);
1163 $out = filter_var($out, FILTER_SANITIZE_EMAIL);
1166 if (!is_array($out)) {
1168 if (preg_match(
'/[^a-z]+/i', $out)) {
1174 if (!is_array($out)) {
1176 if (preg_match(
'/[^a-z0-9_\-\.]+/i', $out)) {
1182 if (!is_array($out)) {
1184 if (preg_match(
'/[^a-z0-9_\-\.@]+/i', $out)) {
1190 if (!is_array($out)) {
1192 if (preg_match(
'/[^a-z0-9_\-\.,]+/i', $out)) {
1199 if (!is_array($out)) {
1202 $oldstringtoclean = $out;
1206 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1213 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1214 }
while ($oldstringtoclean != $out);
1218 case 'alphawithlgt':
1219 if (!is_array($out)) {
1222 $oldstringtoclean = $out;
1226 $out = preg_replace(
'/\\\([0-9xu])/',
'/\1', $out);
1233 $out = str_ireplace(array(
'../',
'..\\',
'&',
'&',
'&',
'"',
'"',
'"',
'"',
'"',
'/',
'/',
'/',
'\',
'\',
'\'),
'', $out);
1234 }
while ($oldstringtoclean != $out);
1240 case 'restricthtmlnolink':
1241 case 'restricthtml':
1242 case 'restricthtmlallowclass':
1243 case 'restricthtmlallowunvalid':
1248 if (empty($filter)) {
1249 return 'BadParameterForGETPOST - Param 3 of sanitizeVal()';
1251 if (is_null($options)) {
1254 $out = filter_var($out, $filter, $options);
1258 dol_syslog(
"Error, you call sanitizeVal() with a bad value for the check type. Data will be sanitized with alphanohtml.", LOG_ERR);
1259 $out =
GETPOST($out,
'alphanohtml');
1267if (!function_exists(
'dol_getprefix')) {
1278 function dol_getprefix($mode =
'')
1281 if ($mode ==
'email') {
1286 return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
1287 } elseif (isset($_SERVER[
"SERVER_NAME"])) {
1288 return $_SERVER[
"SERVER_NAME"];
1293 if (!empty($conf->file->instance_unique_id)) {
1294 return sha1(
'dolibarr'.$conf->file->instance_unique_id);
1298 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1302 global $dolibarr_main_instance_unique_id, $dolibarr_main_cookie_cryptkey;
1303 $tmp_instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ?
'' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id;
1306 if (!empty($tmp_instance_unique_id)) {
1307 return sha1(
'dolibarr'.$tmp_instance_unique_id);
1311 if (isset($_SERVER[
"SERVER_NAME"]) && isset($_SERVER[
"DOCUMENT_ROOT"])) {
1312 return sha1($_SERVER[
"SERVER_NAME"].$_SERVER[
"DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1314 return sha1(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
1331 global $conf, $langs, $user, $mysoc;
1335 if (!file_exists($fullpath)) {
1336 dol_syslog(
'functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_WARNING);
1340 if (!empty($classname) && !class_exists($classname)) {
1341 return include $fullpath;
1343 return include_once $fullpath;
1361function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
1365 $path = preg_replace(
'/^\//',
'', $path);
1368 $res = DOL_DOCUMENT_ROOT.
'/'.$path;
1369 if (is_array($conf->file->dol_document_root)) {
1370 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1371 if ($key ==
'main') {
1375 if (@file_exists($dirroot.
'/'.$path)) {
1376 $res = $dirroot.
'/'.$path;
1381 if ($returnemptyifnotfound) {
1383 if ($returnemptyifnotfound == 1 || !file_exists($res)) {
1395 $res = DOL_URL_ROOT.
'/'.$path;
1398 $res = DOL_MAIN_URL_ROOT.
'/'.$path;
1401 $res = DOL_URL_ROOT.
'/'.$path;
1404 foreach ($conf->file->dol_document_root as $key => $dirroot) {
1405 if ($key ==
'main') {
1410 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($conf->file->dol_main_url_root));
1411 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1414 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).
'/'.$path;
1419 preg_match(
'/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);
1420 if (!empty($regs[1])) {
1423 if (@file_exists($dirroot.
'/'.$regs[1])) {
1425 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1426 } elseif ($type == 2) {
1427 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].
'/'.$path;
1428 } elseif ($type == 3) {
1432 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($conf->file->dol_main_url_root));
1433 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1436 $res = (preg_match(
'/^http/i', $conf->file->dol_url_root[$key]) ?
'' : $urlwithroot).$conf->file->dol_url_root[$key].
'/'.$path;
1460 if (empty($properties)) {
1461 return get_object_vars($obj);
1464 $existingProperties = [];
1465 $realProperties = get_object_vars($obj);
1468 foreach ($properties as $property) {
1469 if (array_key_exists($property, $realProperties)) {
1471 $existingProperties[$property] = $obj->{$property};
1472 } elseif (property_exists($obj, $property)) {
1474 $existingProperties[$property] = $obj->{$property};
1478 return $existingProperties;
1506 $myclone = unserialize(serialize(
$object));
1508 if (!empty($tmpsavdb)) {
1511 } elseif ($native == 2) {
1514 $tmparray = get_object_vars(
$object);
1516 if (is_array($tmparray)) {
1517 foreach ($tmparray as $propertykey => $propertyval) {
1518 if (is_scalar($propertyval) || is_array($propertyval)) {
1519 $myclone->$propertykey = $propertyval;
1539function dol_size($size, $type =
'')
1542 if (empty($conf->dol_optimize_smallscreen)) {
1545 if ($type ==
'width' && $size > 250) {
1570 $filesystem_forbidden_chars = array(
'<',
'>',
'/',
'\\',
'?',
'*',
'|',
'"',
':',
'°',
'$',
';',
'`');
1572 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1573 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1574 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1575 $tmp = str_replace(
'..',
'', $tmp);
1596 $filesystem_forbidden_chars = array(
'<',
'>',
'?',
'*',
'|',
'"',
'°',
'$',
';',
'`');
1598 $tmp = preg_replace(
'/\-\-+/',
'_', $tmp);
1599 $tmp = preg_replace(
'/\s+\-([^\s])/',
' _$1', $tmp);
1600 $tmp = preg_replace(
'/\s+\-$/',
'', $tmp);
1601 $tmp = str_replace(
'..',
'', $tmp);
1616 $stringtoclean = preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $stringtoclean);
1618 $stringtoclean = preg_replace(
'/<!--[^>]*-->/',
'', $stringtoclean);
1620 $stringtoclean = str_replace(
'\\',
'/', $stringtoclean);
1624 $stringtoclean = str_replace(array(
':',
';',
'@'),
'', $stringtoclean);
1628 $oldstringtoclean = $stringtoclean;
1631 $stringtoclean = str_ireplace(array(
'javascript',
'vbscript',
'&colon',
'&#'),
'', $stringtoclean);
1632 }
while ($oldstringtoclean != $stringtoclean);
1636 $stringtoclean = preg_replace(array(
'/^[a-z]*\/\/+/i'),
'', $stringtoclean);
1639 return $stringtoclean;
1651 $oldstringtoclean = $stringtoclean;
1652 $stringtoclean = str_ireplace(array(
'"',
':',
'[',
']',
"\n",
"\r",
'\\',
'\/'),
'', $stringtoclean);
1653 }
while ($oldstringtoclean != $stringtoclean);
1655 return $stringtoclean;
1670 if (is_null($str)) {
1675 if (extension_loaded(
'intl') &&
getDolGlobalString(
'MAIN_UNACCENT_USE_TRANSLITERATOR')) {
1676 $transliterator = Transliterator::createFromRules(
':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', Transliterator::FORWARD);
1677 return $transliterator->transliterate($str);
1680 $string = rawurlencode($str);
1681 $replacements = array(
1682 '%C3%80' =>
'A',
'%C3%81' =>
'A',
'%C3%82' =>
'A',
'%C3%83' =>
'A',
'%C3%84' =>
'A',
'%C3%85' =>
'A',
1684 '%C3%88' =>
'E',
'%C3%89' =>
'E',
'%C3%8A' =>
'E',
'%C3%8B' =>
'E',
1685 '%C3%8C' =>
'I',
'%C3%8D' =>
'I',
'%C3%8E' =>
'I',
'%C3%8F' =>
'I',
1687 '%C3%92' =>
'O',
'%C3%93' =>
'O',
'%C3%94' =>
'O',
'%C3%95' =>
'O',
'%C3%96' =>
'O',
1689 '%C3%99' =>
'U',
'%C3%9A' =>
'U',
'%C3%9B' =>
'U',
'%C3%9C' =>
'U',
1690 '%C3%9D' =>
'Y',
'%C5%B8' =>
'y',
1691 '%C3%A0' =>
'a',
'%C3%A1' =>
'a',
'%C3%A2' =>
'a',
'%C3%A3' =>
'a',
'%C3%A4' =>
'a',
'%C3%A5' =>
'a',
1693 '%C3%A8' =>
'e',
'%C3%A9' =>
'e',
'%C3%AA' =>
'e',
'%C3%AB' =>
'e',
1694 '%C3%AC' =>
'i',
'%C3%AD' =>
'i',
'%C3%AE' =>
'i',
'%C3%AF' =>
'i',
1696 '%C3%B2' =>
'o',
'%C3%B3' =>
'o',
'%C3%B4' =>
'o',
'%C3%B5' =>
'o',
'%C3%B6' =>
'o',
1698 '%C3%B9' =>
'u',
'%C3%BA' =>
'u',
'%C3%BB' =>
'u',
'%C3%BC' =>
'u',
1699 '%C3%BD' =>
'y',
'%C3%BF' =>
'y'
1701 $string = strtr($string, $replacements);
1702 return rawurldecode($string);
1707 "\xC0\xC1\xC2\xC3\xC4\xC5\xC7
1708 \xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
1709 \xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD
1710 \xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB
1711 \xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
1712 \xF9\xFA\xFB\xFC\xFD\xFF",
1720 $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"));
1738function dol_string_nospecial($str, $newstr =
'_', $badcharstoreplace =
'', $badcharstoremove =
'', $keepspaces = 0)
1740 $forbidden_chars_to_replace = array(
"'",
"/",
"\\",
":",
"*",
"?",
"\"",
"<",
">",
"|",
"[",
"]",
",",
";",
"=",
'°',
'$',
';');
1741 if (empty($keepspaces)) {
1742 $forbidden_chars_to_replace[] =
" ";
1744 $forbidden_chars_to_remove = array();
1747 if (is_array($badcharstoreplace)) {
1748 $forbidden_chars_to_replace = $badcharstoreplace;
1750 if (is_array($badcharstoremove)) {
1751 $forbidden_chars_to_remove = $badcharstoremove;
1755 return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove,
"", $str));
1774 if ($removetabcrlf) {
1775 return preg_replace(
'/[\x00-\x1F\x7F]/u',
'', $str);
1777 return preg_replace(
'/[\x00-\x08\x11-\x12\x14-\x1F\x7F]/u',
'', $str);
1789function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0)
1791 if (is_null($stringtoescape)) {
1796 $substitjs = array(
"'" =>
"\\'",
"\r" =>
'\\r');
1798 if (empty($noescapebackslashn)) {
1799 $substitjs[
"\n"] =
'\\n';
1800 $substitjs[
'\\'] =
'\\\\';
1803 $substitjs[
"'"] =
"\\'";
1804 $substitjs[
'"'] =
"\\'";
1805 } elseif ($mode == 1) {
1806 $substitjs[
"'"] =
"\\'";
1807 } elseif ($mode == 2) {
1808 $substitjs[
'"'] =
'\\"';
1809 } elseif ($mode == 3) {
1810 $substitjs[
"'"] =
"\\'";
1811 $substitjs[
'"'] =
"\\\"";
1813 return strtr($stringtoescape, $substitjs);
1827 return rawurlencode($stringtoescape);
1838 return str_replace(
'"',
'\"', $stringtoescape);
1850 if (is_null($stringtoescape)) {
1854 if ($stringforquotes == 2) {
1855 return str_replace(
'"',
"'", $stringtoescape);
1856 } elseif ($stringforquotes == 1) {
1862 $stringtoescape = str_replace(
'\\',
'', $stringtoescape);
1863 return str_replace(
"'",
"\'", str_replace(
'"',
"'", $stringtoescape));
1866 return 'Bad parameter for stringforquotes in dol_escape_php';
1877 return preg_replace(
'/[^a-z0-9_]/i',
'', $stringtoescape);
1888 return $stringtoescape;
1928 return dol_escape_htmltag(
dol_string_onlythesehtmltags(
dol_htmlentitiesbr($s), 1, 0, 0, 0, array(
'br',
'b',
'font',
'span')), 1, -1,
'', 0, 1);
1952 return htmlspecialchars($s, ENT_COMPAT,
'UTF-8');
1972function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapetags =
'', $escapeonlyhtmltags = 0, $cleanalsojavascript = 0)
1974 if ($noescapetags ==
'common') {
1975 $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';
1977 $noescapetags .=
',header,footer,nav,section,menu,menuitem';
1979 if ($cleanalsojavascript) {
1984 if ($escapeonlyhtmltags) {
1985 $tmp = htmlspecialchars_decode((
string) $stringtoescape, ENT_COMPAT);
1987 $tmp = html_entity_decode((
string) $stringtoescape, ENT_COMPAT,
'UTF-8');
1988 $tmp = str_ireplace(
''',
'__SIMPLEQUOTE', $tmp);
1991 $tmp = strtr($tmp, array(
"<b>" =>
'',
'</b>' =>
'',
'<strong>' =>
'',
'</strong>' =>
''));
1994 $tmp = strtr($tmp, array(
"\r" =>
'\\r',
"\n" =>
'\\n'));
1995 } elseif ($keepn == -1) {
1996 $tmp = strtr($tmp, array(
"\r" =>
'',
"\n" =>
''));
1999 if ($escapeonlyhtmltags) {
2000 return htmlspecialchars($tmp, ENT_COMPAT,
'UTF-8');
2003 $tmparrayoftags = array();
2004 if ($noescapetags) {
2005 $tmparrayoftags = explode(
',', $noescapetags);
2007 if (count($tmparrayoftags)) {
2009 $tmp = str_ireplace(
'__DOUBLEQUOTE',
'', $tmp);
2011 foreach ($tmparrayoftags as $tagtoreplace) {
2012 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
'>/',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2013 $tmp = str_ireplace(
'</'.$tagtoreplace.
'>',
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2014 $tmp = preg_replace(
'/<'.preg_quote($tagtoreplace,
'/').
' \/>/',
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__', $tmp);
2020 if (preg_match(
'/<'.preg_quote($tagtoreplace,
'/').
'(\s+)([^>]+)>/', $tmp, $reg)) {
2022 $tmpattributes = str_ireplace(array(
'[',
']'),
'_', $reg[2]);
2023 $tmpattributes = str_ireplace(
'href="http:',
'__HREFHTTPA', $tmpattributes);
2024 $tmpattributes = str_ireplace(
'href="https:',
'__HREFHTTPSA', $tmpattributes);
2025 $tmpattributes = str_ireplace(
'src="http:',
'__SRCHTTPIMG', $tmpattributes);
2026 $tmpattributes = str_ireplace(
'src="https:',
'__SRCHTTPSIMG', $tmpattributes);
2027 $tmpattributes = str_ireplace(
'"',
'__DOUBLEQUOTE', $tmpattributes);
2028 $tmpattributes = preg_replace(
'/[^a-z0-9_%,\/\?\;\s=&\.\-@:\.#\+]/i',
'', $tmpattributes);
2034 $tmp = str_replace(
'<'.$tagtoreplace.$reg[1].$reg[2].
'>',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'['.$tmpattributes.
']__', $tmp);
2037 if (preg_match(
'/<'.preg_quote($tagtoreplace,
'/').
'(\s+)([^>]+)(\s+)\/>/', $tmp, $reg)) {
2039 $tmpattributes = str_ireplace(array(
'[',
']'),
'_', $reg[2]);
2040 $tmpattributes = str_ireplace(
'"',
'__DOUBLEQUOTE', $tmpattributes);
2041 $tmpattributes = preg_replace(
'/[^a-z0-9_%,\/\?\;\s=&\.\-@:\.#\+]/i',
'', $tmpattributes);
2044 $tmp = str_replace(
'<'.$tagtoreplace.$reg[1].$reg[2].$reg[3].
'/>',
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'['.$tmpattributes.
']__', $tmp);
2047 $diff = strcmp($tmpold, $tmp);
2052 $result = htmlentities($tmp, ENT_COMPAT,
'UTF-8');
2056 if (count($tmparrayoftags)) {
2057 foreach ($tmparrayoftags as $tagtoreplace) {
2058 $result = str_ireplace(
'__BEGINTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
'>', $result);
2059 $result = preg_replace(
'/__BEGINTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1>', $result);
2060 $result = str_ireplace(
'__ENDTAGTOREPLACE'.$tagtoreplace.
'__',
'</'.$tagtoreplace.
'>', $result);
2061 $result = str_ireplace(
'__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'__',
'<'.$tagtoreplace.
' />', $result);
2062 $result = preg_replace(
'/__BEGINENDTAGTOREPLACE'.$tagtoreplace.
'\[([^\]]*)\]__/',
'<'.$tagtoreplace.
' \1 />', $result);
2065 $result = str_ireplace(
'__HREFHTTPA',
'href="http:', $result);
2066 $result = str_ireplace(
'__HREFHTTPSA',
'href="https:', $result);
2067 $result = str_ireplace(
'__SRCHTTPIMG',
'src="http:', $result);
2068 $result = str_ireplace(
'__SRCHTTPSIMG',
'src="https:', $result);
2069 $result = str_ireplace(
'__DOUBLEQUOTE',
'"', $result);
2072 $result = str_ireplace(
'__SIMPLEQUOTE',
''', $result);
2089 if (function_exists(
'mb_strtolower')) {
2090 return mb_strtolower($string, $encoding);
2092 return strtolower($string);
2106 if (function_exists(
'mb_strtoupper')) {
2107 return mb_strtoupper($string, $encoding);
2109 return strtoupper($string);
2123 if (function_exists(
'mb_substr')) {
2124 return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1,
null, $encoding);
2126 return ucfirst($string);
2140 if (function_exists(
'mb_convert_case')) {
2141 return mb_convert_case($string, MB_CASE_TITLE, $encoding);
2143 return ucwords($string);
2169function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
'', $restricttologhandler =
'', $logcontext =
null)
2171 global $conf, $user, $debugbar;
2174 if (!isModEnabled(
'syslog')) {
2179 if (defined(
'USEEXTERNALSERVER') && !defined(
'USEDOLIBARRSERVER') && !defined(
'USEDOLIBARREDITOR')) {
2180 global $website, $websitekey;
2181 if (is_object($website) && !empty($website->ref)) {
2182 $suffixinfilename .=
'_website_'.$website->ref;
2183 } elseif (!empty($websitekey)) {
2184 $suffixinfilename .=
'_website_'.$websitekey;
2189 if (defined(
'USESUFFIXINLOG')) {
2190 $suffixinfilename .= constant(
'USESUFFIXINLOG');
2194 foreach ($conf->loghandlers as $loghandlerinstance) {
2195 $loghandlerinstance->setIdent($ident);
2199 if (!empty($message)) {
2202 $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');
2204 if (!array_key_exists($level, $logLevels)) {
2205 dol_syslog(
'Error Bad Log Level '.$level, LOG_ERR);
2206 $level = $logLevels[LOG_ERR];
2213 $message = preg_replace(
'/password=\'[^\']*\'/',
'password=\'hidden\'', $message);
2217 if ((!empty($_REQUEST[
'logtohtml']) &&
getDolGlobalString(
'MAIN_ENABLE_LOG_TO_HTML'))
2218 || (is_object($user) && $user->hasRight(
'debugbar',
'read') && is_object($debugbar))) {
2219 $ospid = sprintf(
"%7s",
dol_trunc(getmypid(), 7,
'right',
'UTF-8', 1));
2220 $osuser =
" ".sprintf(
"%6s",
dol_trunc(function_exists(
'posix_getuid') ? posix_getuid() :
'', 6,
'right',
'UTF-8', 1));
2222 $conf->logbuffer[] =
dol_print_date(time(),
"%Y-%m-%d %H:%M:%S").
" ".sprintf(
"%-7s", $logLevels[$level]).
" ".$ospid.
" ".$osuser.
" ".$message;
2228 print
"\n\n<!-- Log start\n";
2230 print
"Log end -->\n";
2234 'message' => $message,
2235 'script' => (isset($_SERVER[
'PHP_SELF']) ? basename($_SERVER[
'PHP_SELF'],
'.php') : false),
2237 'user' => ((is_object($user) && $user->id) ? $user->login : false),
2239 'osuser' => function_exists(
'posix_getuid') ? posix_getuid() : false,
2240 'ospid' => getmypid()
2244 if (!empty($remoteip)) {
2245 $data[
'ip'] = $remoteip;
2247 if (!empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) && $_SERVER[
'HTTP_X_FORWARDED_FOR'] != $remoteip) {
2248 $data[
'ip'] = $_SERVER[
'HTTP_X_FORWARDED_FOR'].
' -> '.$data[
'ip'];
2249 } elseif (!empty($_SERVER[
'HTTP_CLIENT_IP']) && $_SERVER[
'HTTP_CLIENT_IP'] != $remoteip) {
2250 $data[
'ip'] = $_SERVER[
'HTTP_CLIENT_IP'].
' -> '.$data[
'ip'];
2252 } elseif (!empty($_SERVER[
'SERVER_ADDR'])) {
2254 $data[
'ip'] = $_SERVER[
'SERVER_ADDR'];
2255 } elseif (!empty($_SERVER[
'COMPUTERNAME'])) {
2257 $data[
'ip'] = $_SERVER[
'COMPUTERNAME'];
2259 $data[
'ip'] =
'???';
2262 if (!empty($_SERVER[
'USERNAME'])) {
2264 $data[
'osuser'] = $_SERVER[
'USERNAME'];
2265 } elseif (!empty($_SERVER[
'LOGNAME'])) {
2267 $data[
'osuser'] = $_SERVER[
'LOGNAME'];
2271 foreach ($conf->loghandlers as $loghandlerinstance) {
2272 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
2275 $loghandlerinstance->export($data, $suffixinfilename);
2281 foreach ($conf->loghandlers as $loghandlerinstance) {
2282 $loghandlerinstance->setIdent($ident);
2302 $form =
new Form($db);
2304 $templatenameforexport = $website->name_template;
2305 if (empty($templatenameforexport)) {
2306 $templatenameforexport =
'website_'.$website->ref;
2310 $out .=
'<input type="button" class="cursorpointer button bordertransp" id="open-dialog-' . $name .
'" value="'.dol_escape_htmltag($buttonstring).
'"/>';
2313 $out .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">';
2314 $out .=
'jQuery(document).ready(function () {';
2315 $out .=
' jQuery("#open-dialog-' . $name .
'").click(function () {';
2316 $out .=
' var dialogHtml = \'';
2318 $dialogcontent =
' <div id="custom-dialog-' . $name .
'">';
2319 $dialogcontent .=
' <div style="margin-top: 20px;">';
2320 $dialogcontent .=
' <label for="export-site-' . $name .
'"><strong>'.$langs->trans(
"ExportSiteLabel").
'...</label><br>';
2321 $dialogcontent .=
' <button class="button smallpaddingimp" id="export-site-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"DownloadZip")) .
'</button>';
2322 $dialogcontent .=
' </div>';
2323 $dialogcontent .=
' <br>';
2324 $dialogcontent .=
' <div style="margin-top: 20px;">';
2325 $dialogcontent .=
' <strong>'.$langs->trans(
"ExportSiteGitLabel").
' '.$form->textwithpicto(
'', $langs->trans(
"SourceFiles"), 1,
'help',
'', 0, 3,
'').
'</strong><br>';
2326 $dialogcontent .=
' <form action="'.dol_escape_htmltag($overwriteGitUrl).
'" method="POST">';
2327 $dialogcontent .=
' <input type="hidden" name="action" value="overwritesite">';
2328 $dialogcontent .=
' <input type="hidden" name="token" value="'.newToken().
'">';
2329 $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>';
2330 $dialogcontent .=
' <button type="submit" class="button smallpaddingimp" id="overwrite-git-' . $name .
'">' .
dol_escape_htmltag($langs->trans(
"ExportIntoGIT")) .
'</button>';
2331 $dialogcontent .=
' </form>';
2332 $dialogcontent .=
' </div>';
2333 $dialogcontent .=
' </div>';
2340 // Add the content of the dialog to the body of the page
2341 $out .= ' var $dialog = jQuery(
"#custom-dialog-' . $name . '");
';
2342 $out .= ' if ($dialog.length > 0) {
2345 jQuery(
"body").append(dialogHtml);
';
2347 // Configuration of popup
2348 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog({
';
2349 $out .= ' autoOpen:
false,
';
2350 $out .= ' modal:
true,
';
2351 $out .= ' height: 290,
';
2352 $out .= ' width:
"40%",
';
2353 $out .= ' title:
"' . dol_escape_js($label) . '",
';
2356 // Simulate a click on the original "submit" input to export the site.
2357 $out .= ' jQuery(
"#export-site-' . $name . '").click(
function () {
';
2358 $out .= ' console.log(
"Clic on exportsite.");
';
2359 $out .= ' var target = jQuery(
"input[name=\'' . dol_escape_js($exportSiteName) . '\']");
';
2360 $out .= ' console.log(
"element founded:", target.length > 0);
';
2361 $out .= ' if (target.length > 0) { target.click(); }
';
2362 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"close");
';
2366 $out .= ' jQuery(
"#custom-dialog-' . $name . '").dialog(
"open");
';
2367 $out .= ' return false;
';
2370 $out .= '</script>
';
2392function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '
', $morecss = 'classlink
button bordertransp
', $jsonopen = '', $backtopagejsfields = '', $accesskey = '')
2396 if (strpos($url, '?
') > 0) {
2397 $url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2399 $url .= '?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=
'.urlencode($name);
2404 $backtopagejsfieldsid = '';
2405 $backtopagejsfieldslabel = '';
2406 if ($backtopagejsfields) {
2407 $tmpbacktopagejsfields = explode(':
', $backtopagejsfields);
2408 if (empty($tmpbacktopagejsfields[1])) { // If the part 'keyforpopupid:
' is missing, we add $name for it.
2409 $backtopagejsfields = $name.":".$backtopagejsfields;
2410 $tmp2backtopagejsfields = explode(',
', $tmpbacktopagejsfields[0]);
2412 $tmp2backtopagejsfields = explode(',
', $tmpbacktopagejsfields[1]);
2414 $backtopagejsfieldsid = empty($tmp2backtopagejsfields[0]) ? '' : $tmp2backtopagejsfields[0];
2415 $backtopagejsfieldslabel = empty($tmp2backtopagejsfields[1]) ? '' : $tmp2backtopagejsfields[1];
2416 $url .= '&backtopagejsfields=
'.urlencode($backtopagejsfields);
2419 //print '<input
type=
"submit" class=
"button bordertransp"'.$disabled.' value=
"'.dol_escape_htmltag($langs->trans("MediaFiles
")).'" name=
"file_manager">
';
2420 $out .= '<!-- a link
for button to open url into a dialog popup with backtopagejsfields =
'.$backtopagejsfields.' -->
';
2421 $out .= '<a
'.($accesskey ? ' accesskey=
"'.$accesskey.'"' : '').' class=
"cursorpointer reposition button_'.$name.($morecss ? ' '.$morecss : '').'"'.$disabled.' title=
"'.dol_escape_htmltag($label).'"';
2422 if (empty($conf->use_javascript_ajax)) {
2423 $out .= ' href=
"'.DOL_URL_ROOT.$url.'" target=
"_blank"';
2424 } elseif ($jsonopen) {
2425 $out .= ' href=
"#" onclick=
"'.$jsonopen.'"';
2427 $out .= ' href=
"#"';
2429 $out .= '>
'.$buttonstring.'</a>
';
2431 if (!empty($conf->use_javascript_ajax)) {
2432 // Add code to open url using the popup. Add also hidden field to retrieve the returned variables
2433 $out .= '<!-- code to open popup and variables to retrieve returned variables -->
';
2434 $out .= '<div
id=
"idfordialog'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for dialog
' : '').'</div>
';
2435 $out .= '<div
id=
"varforreturndialogid'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for returned
id' : '').'</div>
';
2436 $out .= '<div
id=
"varforreturndialoglabel'.$name.'" class=
"hidden">
'.(getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
') < 2 ? 'div
for returned label
' : '').'</div>
';
2438 $out .= '<!-- Add js code to open dialog popup on dialog -->
';
2439 $out .= '<script nonce=
"'.getNonce().'" type=
"text/javascript">
2440 jQuery(document).ready(
function () {
2441 jQuery(
".button_'.$name.'").click(
function () {
2442 console.log(\
'Open popup with jQuery(...).dialog() on URL '.
dol_escape_js(DOL_URL_ROOT.$url).
'\');
2443 var $tmpdialog = $(\
'#idfordialog'.$name.
'\');
2444 $tmpdialog.html(\
'<iframe class="iframedialog" id="iframedialog'.$name.
'" style="border: 0px;" src="'.DOL_URL_ROOT.$url.
'" width="100%" height="98%"></iframe>\');
2448 height: (window.innerHeight - 150),
2451 open: function (event, ui) {
2452 console.log(
"open popup name='.$name.', backtopagejsfields='.$backtopagejsfields.'");
2454 close:
function (event, ui) {
2455 var returnedid = jQuery(
"#varforreturndialogid'.$name.'").text();
2456 var returnedlabel = jQuery(
"#varforreturndialoglabel'.$name.'").text();
2457 console.log(
"popup has been closed. returnedid (js var defined into parent page)="+returnedid+
" returnedlabel="+returnedlabel);
2458 if (returnedid !=
"" && returnedid !=
"div for returned id") {
2459 jQuery(
"#'.(empty($backtopagejsfieldsid) ? "none
" : $backtopagejsfieldsid).'").val(returnedid);
2461 if (returnedlabel !=
"" && returnedlabel !=
"div for returned label") {
2462 jQuery(
"#'.(empty($backtopagejsfieldslabel) ? "none
" : $backtopagejsfieldslabel).'").val(returnedlabel);
2467 $tmpdialog.dialog(\
'open\');
2492function dol_fiche_head($links = array(), $active =
'0', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'')
2494 print
dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow, $moretabssuffix);
2513function dol_get_fiche_head($links = array(), $active =
'', $title =
'', $notab = 0, $picto =
'', $pictoisfullpath = 0, $morehtmlright =
'', $morecss =
'', $limittoshow = 0, $moretabssuffix =
'', $dragdropfile = 0)
2515 global $conf, $langs, $hookmanager;
2519 if (!empty($conf->dol_optimize_smallscreen)) {
2523 $out =
"\n".
'<!-- dol_fiche_head - dol_get_fiche_head -->';
2525 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2526 $out .=
'<div class="tabs'.($picto ?
'' :
' nopaddingleft').
'" data-role="controlgroup" data-type="horizontal">'.
"\n";
2530 if ($morehtmlright) {
2531 $out .=
'<div class="inline-block floatright tabsElem">'.$morehtmlright.
'</div>';
2535 if (!empty($title) && $showtitle && !
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER')) {
2537 $out .=
'<a class="tabTitle">';
2539 $noprefix = $pictoisfullpath;
2540 if (strpos($picto,
'fontawesome_') !==
false) {
2543 $out .=
img_picto($title, ($noprefix ?
'' :
'object_').$picto,
'', $pictoisfullpath, 0, 0,
'',
'imgTabTitle').
' ';
2545 $out .=
'<span class="tabTitleText">'.dol_escape_htmltag(
dol_trunc($title, $limittitle)).
'</span>';
2553 if (is_array($links) && !empty($links)) {
2554 $keys = array_keys($links);
2556 $maxkey = max($keys);
2562 if (empty($limittoshow)) {
2563 $limittoshow = (!
getDolGlobalString(
'MAIN_MAXTABS_IN_CARD') ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD);
2565 if (!empty($conf->dol_optimize_smallscreen)) {
2573 for ($i = 0; $i <= $maxkey; $i++) {
2574 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2576 if ($i >= $limittoshow) {
2582 for ($i = 0; $i <= $maxkey; $i++) {
2583 if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
2589 if ($i < $limittoshow || $isactive) {
2591 $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])).
' -->';
2593 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2594 if (!empty($links[$i][0])) {
2595 $out .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2597 $out .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2599 } elseif (!empty($links[$i][1])) {
2601 $out .=
'<div class="tab tab'.($isactive ?
'active' :
'unactive').
'" style="margin: 0 !important">';
2602 if (!empty($links[$i][0])) {
2603 $titletoshow = preg_replace(
'/<.*$/',
'', $links[$i][1]);
2604 $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).
'">';
2606 $out .= $links[$i][1];
2607 if (!empty($links[$i][0])) {
2608 $out .=
'</a>'.
"\n";
2610 $out .= empty($links[$i][4]) ?
'' : $links[$i][4];
2619 $outmore .=
'<div class="popuptabset wordwrap">';
2621 $outmore .=
'<div class="popuptab wordwrap" style="display:inherit;">';
2622 if (isset($links[$i][2]) && $links[$i][2] ==
'image') {
2623 if (!empty($links[$i][0])) {
2624 $outmore .=
'<a class="tabimage'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">'.$links[$i][1].
'</a>'.
"\n";
2626 $outmore .=
'<span class="tabspan">'.$links[$i][1].
'</span>'.
"\n";
2628 } elseif (!empty($links[$i][1])) {
2629 $outmore .=
'<a'.(!empty($links[$i][2]) ?
' id="'.$links[$i][2].
'"' :
'').
' class="wordwrap inline-block'.($morecss ?
' '.$morecss :
'').
'" href="'.$links[$i][0].
'">';
2630 $outmore .= preg_replace(
'/([a-z])\|([a-z])/i',
'\\1 | \\2', $links[$i][1]);
2631 $outmore .=
'</a>'.
"\n";
2633 $outmore .=
'</div>';
2640 $outmore .=
'</div>';
2644 $left = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'right' :
'left');
2645 $right = ($langs->trans(
"DIRECTION") ==
'rtl' ?
'left' :
'right');
2646 $widthofpopup = 200;
2648 $tabsname = $moretabssuffix;
2649 if (empty($tabsname)) {
2650 $tabsname = str_replace(
"@",
"", $picto);
2652 $out .=
'<div id="moretabs'.$tabsname.
'" class="inline-block tabsElem valignmiddle">';
2654 $out .=
'<div class="tab valignmiddle"><a href="#" class="tab moretab inline-block tabunactive valignmiddle"><span class="hideonsmartphone">'.$langs->trans(
"More").
'</span>... ('.$nbintab.
')</a></div>';
2656 $out .=
'<div id="moretabsList'.$tabsname.
'" style="width: '.$widthofpopup.
'px; position: absolute; '.$left.
': -999em; text-align: '.$left.
'; margin:0px; padding:2px; z-index:10;">';
2659 $out .=
'<div></div>';
2662 $out .=
'<script nonce="'.getNonce().
'">';
2663 $out .=
"$('#moretabs".$tabsname.
"').mouseenter( function() {
2664 var x = this.offsetLeft, y = this.offsetTop;
2665 console.log('mouseenter ".$left.
" x='+x+' y='+y+' window.innerWidth='+window.innerWidth);
2666 if ((window.innerWidth - x) < ".($widthofpopup + 10).
") {
2667 $('#moretabsList".$tabsname.
"').css('".$right.
"','8px');
2669 $('#moretabsList".$tabsname.
"').css('".$left.
"','auto');
2672 $out .=
"$('#moretabs".$tabsname.
"').mouseleave( function() { console.log('mouseleave ".$left.
"'); $('#moretabsList".$tabsname.
"').css('".$left.
"','-999em');});";
2673 $out .=
"</script>";
2676 if ((!empty($title) && $showtitle) || $morehtmlright || !empty($links)) {
2680 if (!$notab || $notab == -1 || $notab == -2 || $notab == -3) {
2681 $out .=
"\n".
'<div id="dragDropAreaTabBar" class="tabBar'.($notab == -1 ?
'' : ($notab == -2 ?
' tabBarNoTop' : (($notab == -3 ?
' noborderbottom' :
'').
' tabBarWithBottom')));
2684 if (!empty($dragdropfile)) {
2685 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2688 $parameters = array(
'tabname' => $active,
'out' => $out);
2689 $reshook = $hookmanager->executeHooks(
'printTabsHead', $parameters);
2691 $out = $hookmanager->resPrint;
2717 if (!$notab || $notab == -1) {
2718 return "\n</div>\n";
2743function dol_banner_tab(
$object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $onlybanner = 0, $morehtmlright =
'')
2745 global $conf, $form, $user, $langs, $hookmanager, $action;
2749 $maxvisiblephotos = 1;
2751 $entity = (empty(
$object->entity) ? $conf->entity :
$object->entity);
2753 $showbarcode = !isModEnabled(
'barcode') ? 0 : (empty(
$object->barcode) ? 0 : 1);
2754 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2757 $modulepart =
'unknown';
2759 if (in_array(
$object->element, [
'societe',
'contact',
'product',
'ticket',
'bom'])) {
2760 $modulepart =
$object->element;
2761 } elseif (
$object->element ==
'member') {
2762 $modulepart =
'memberphoto';
2763 } elseif (
$object->element ==
'user') {
2764 $modulepart =
'userphoto';
2767 if (class_exists(
"Imagick")) {
2768 if (
$object->element ==
'expensereport' ||
$object->element ==
'propal' ||
$object->element ==
'commande' ||
$object->element ==
'facture' ||
$object->element ==
'supplier_proposal') {
2769 $modulepart =
$object->element;
2770 } elseif (
$object->element ==
'fichinter' ||
$object->element ==
'intervention') {
2771 $modulepart =
'ficheinter';
2772 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
2773 $modulepart =
'contract';
2774 } elseif (
$object->element ==
'order_supplier') {
2775 $modulepart =
'supplier_order';
2776 } elseif (
$object->element ==
'invoice_supplier') {
2777 $modulepart =
'supplier_invoice';
2781 if (
$object->element ==
'product') {
2783 '@phan-var-force Product $object';
2785 $cssclass =
'photowithmargin photoref';
2786 $showimage =
$object->is_photo_available($conf->product->multidir_output[$entity]);
2788 if ($conf->browser->layout ==
'phone') {
2789 $maxvisiblephotos = 1;
2792 $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>';
2796 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2798 $nophoto =
'/public/theme/common/nophoto.png';
2799 $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>';
2802 } elseif (
$object->element ==
'category') {
2804 '@phan-var-force Categorie $object';
2806 $cssclass =
'photowithmargin photoref';
2807 $showimage =
$object->isAnyPhotoAvailable($conf->categorie->multidir_output[$entity]);
2809 if ($conf->browser->layout ==
'phone') {
2810 $maxvisiblephotos = 1;
2813 $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>';
2817 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2819 $nophoto =
'/public/theme/common/nophoto.png';
2820 $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>';
2823 } elseif (
$object->element ==
'bom') {
2825 '@phan-var-force Bom $object';
2827 $cssclass =
'photowithmargin photoref';
2828 $showimage =
$object->is_photo_available($conf->bom->multidir_output[$entity]);
2830 if ($conf->browser->layout ==
'phone') {
2831 $maxvisiblephotos = 1;
2834 $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>';
2838 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2840 $nophoto =
'/public/theme/common/nophoto.png';
2841 $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>';
2844 } elseif (
$object->element ==
'ticket') {
2846 $cssclass =
'photoref';
2848 '@phan-var-force Ticket $object';
2849 $showimage =
$object->is_photo_available($conf->ticket->multidir_output[$entity].
'/'.
$object->ref);
2851 if ($conf->browser->layout ==
'phone') {
2852 $maxvisiblephotos = 1;
2856 $showphoto =
$object->show_photos(
'ticket', $conf->ticket->multidir_output[$entity],
'small', $maxvisiblephotos, 0, 0, 0, $width, 0);
2858 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$showphoto.
'</div>';
2866 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"></div>';
2868 $nophoto =
img_picto(
'No photo',
'object_ticket');
2869 $morehtmlleft .=
'<!-- No photo to show -->';
2870 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2871 $morehtmlleft .= $nophoto;
2872 $morehtmlleft .=
'</div></div>';
2877 if ($modulepart !=
'unknown' || method_exists(
$object,
'getDataToShowPhoto')) {
2880 if (in_array($modulepart, array(
'propal',
'commande',
'facture',
'ficheinter',
'contract',
'supplier_order',
'supplier_proposal',
'supplier_invoice',
'expensereport')) && class_exists(
"Imagick")) {
2882 $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]).
"/";
2883 if (in_array($modulepart, array(
'invoice_supplier',
'supplier_invoice'))) {
2885 $subdir .= ((!empty($subdir) && !preg_match(
'/\/$/', $subdir)) ?
'/' :
'').$objectref;
2889 if (empty($subdir)) {
2890 $subdir =
'errorgettingsubdirofobject';
2893 $filepath = $dir_output.$subdir.
"/";
2895 $filepdf = $filepath.$objectref.
".pdf";
2896 $relativepath = $subdir.
'/'.$objectref.
'.pdf';
2899 $fileimage = $filepdf.
'_preview.png';
2900 $relativepathimage = $relativepath.
'_preview.png';
2902 $pdfexists = file_exists($filepdf);
2907 if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
2909 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2918 if ($pdfexists && !$error) {
2919 $heightforphotref = 80;
2920 if (!empty($conf->dol_optimize_smallscreen)) {
2921 $heightforphotref = 60;
2924 if (file_exists($fileimage)) {
2925 $phototoshow =
'<div class="photoref">';
2926 $phototoshow .=
'<img height="'.$heightforphotref.
'" class="photo photowithborder" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=apercu'.$modulepart.
'&file='.urlencode($relativepathimage).
'">';
2927 $phototoshow .=
'</div>';
2930 } elseif (!$phototoshow) {
2931 $phototoshow .= $form->showphoto($modulepart,
$object, 0, 0, 0,
'photowithmargin photoref',
'small', 1, 0, $maxvisiblephotos);
2935 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">';
2936 $morehtmlleft .= $phototoshow;
2937 $morehtmlleft .=
'</div>';
2941 if (empty($phototoshow)) {
2942 if (
$object->element ==
'action') {
2944 $cssclass =
'photorefcenter';
2945 $nophoto =
img_picto(
'No photo',
'title_agenda');
2948 $cssclass =
'photorefcenter';
2950 $prefix =
'object_';
2954 if (strpos($picto,
'fontawesome_') !==
false) {
2957 $nophoto =
img_picto(
'No photo', $prefix.$picto);
2959 $morehtmlleft .=
'<!-- No photo to show -->';
2960 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
2961 $morehtmlleft .= $nophoto;
2962 $morehtmlleft .=
'</div></div>';
2969 $morehtmlleft .=
'<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode(
$object, 100,
'photoref valignmiddle').
'</div>';
2972 if (
$object->element ==
'societe') {
2973 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'societe',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
2976 $morehtmlstatus .=
$object->getLibStatut(6);
2978 } elseif (
$object->element ==
'product') {
2980 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
2981 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status',
'tosell',
'ProductStatusOnSell',
'ProductStatusNotOnSell');
2983 $morehtmlstatus .=
'<span class="statusrefsell">'.$object->getLibStatut(6, 0).
'</span>';
2985 $morehtmlstatus .=
' ';
2987 if (!empty($conf->use_javascript_ajax) && $user->hasRight(
'produit',
'creer') &&
getDolGlobalString(
'MAIN_DIRECT_STATUS_UPDATE')) {
2988 $morehtmlstatus .=
ajax_object_onoff(
$object,
'status_buy',
'tobuy',
'ProductStatusOnBuy',
'ProductStatusNotOnBuy');
2990 $morehtmlstatus .=
'<span class="statusrefbuy">'.$object->getLibStatut(6, 1).
'</span>';
2992 } elseif (in_array(
$object->element, array(
'salary'))) {
2994 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
2997 $morehtmlstatus .= $tmptxt;
2998 } elseif (in_array(
$object->element, array(
'facture',
'invoice',
'invoice_supplier'))) {
2999 $totalallpayments =
$object->getSommePaiement(0);
3000 $totalallpayments +=
$object->getSumCreditNotesUsed(0);
3001 $totalallpayments +=
$object->getSumDepositsUsed(0);
3002 $tmptxt =
$object->getLibStatut(6, $totalallpayments);
3003 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3004 $tmptxt =
$object->getLibStatut(5, $totalallpayments);
3006 $morehtmlstatus .= $tmptxt;
3007 } elseif (in_array(
$object->element, array(
'chargesociales',
'loan',
'tva'))) {
3009 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3012 $morehtmlstatus .= $tmptxt;
3013 } elseif (
$object->element ==
'contrat' ||
$object->element ==
'contract') {
3015 $morehtmlstatus .=
$object->getLibStatut(5);
3017 $morehtmlstatus .=
$object->getLibStatut(4);
3019 } elseif (
$object->element ==
'facturerec') {
3020 '@phan-var-force FactureRec $object';
3021 if (
$object->frequency == 0) {
3022 $morehtmlstatus .=
$object->getLibStatut(2);
3024 $morehtmlstatus .=
$object->getLibStatut(5);
3026 } elseif (
$object->element ==
'project_task') {
3031 if (
$object->progress >= 100) {
3034 $tmptxt =
$object->getLibStatut(5);
3035 $morehtmlstatus .= $tmptxt;
3036 } elseif (method_exists(
$object,
'getLibStatut')) {
3037 $tmptxt =
$object->getLibStatut(6);
3038 if (empty($tmptxt) || $tmptxt ==
$object->getLibStatut(3)) {
3039 $tmptxt =
$object->getLibStatut(5);
3041 $morehtmlstatus .= $tmptxt;
3045 if (isModEnabled(
'accounting') && in_array(
$object->element, array(
'bank',
'paiementcharge',
'facture',
'invoice',
'invoice_supplier',
'expensereport',
'payment_various'))) {
3047 if (method_exists(
$object,
'getVentilExportCompta')) {
3048 $accounted =
$object->getVentilExportCompta();
3049 $langs->load(
"accountancy");
3050 $morehtmlstatus .=
'</div><div class="statusref statusrefbis"><span class="opacitymedium">'.($accounted > 0 ? $langs->trans(
"Accounted") : $langs->trans(
"NotYetAccounted")).
'</span>';
3055 if (!empty(
$object->name_alias)) {
3056 '@phan-var-force Societe $object';
3057 $morehtmlref .=
'<div class="refidno opacitymedium">'.dol_escape_htmltag(
$object->name_alias).
'</div>';
3061 if (in_array(
$object->element, array(
'product',
'bank_account',
'project_task'))) {
3063 $morehtmlref .=
'<div class="refidno opacitymedium">'.$object->label.
'</div>';
3067 if (method_exists(
$object,
'getBannerAddress') && !in_array(
$object->element, array(
'product',
'bookmark',
'ecm_directories',
'ecm_files'))) {
3070 $morehtmlref .=
'<div class="refidno refaddress">';
3071 $morehtmlref .= $moreaddress;
3072 $morehtmlref .=
'</div>';
3076 $morehtmlref .=
'<div style="clear: both;"></div>';
3077 $morehtmlref .=
'<div class="refidno opacitymedium">';
3078 $morehtmlref .= $langs->trans(
"TechnicalID").
': '.((int)
$object->id);
3079 $morehtmlref .=
'</div>';
3082 $parameters = array(
'morehtmlref' => &$morehtmlref,
'moreparam' => &$moreparam,
'morehtmlleft' => &$morehtmlleft,
'morehtmlstatus' => &$morehtmlstatus,
'morehtmlright' => &$morehtmlright);
3083 $reshook = $hookmanager->executeHooks(
'formDolBanner', $parameters,
$object, $action);
3086 } elseif (empty($reshook)) {
3087 $morehtmlref .= $hookmanager->resPrint;
3088 } elseif ($reshook > 0) {
3089 $morehtmlref = $hookmanager->resPrint;
3097 print
'<div class="'.($onlybanner ?
'arearefnobottom ' :
'arearef ').
'heightref valignmiddle centpercent">';
3098 print $form->showrefnav(
$object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
3100 print
'<div class="underrefbanner clearboth"></div>';
3112function fieldLabel($langkey, $fieldkey, $fieldrequired = 0)
3116 if ($fieldrequired) {
3117 $ret .=
'<span class="fieldrequired">';
3119 $ret .=
'<label for="'.$fieldkey.
'">';
3120 $ret .= $langs->trans($langkey);
3122 if ($fieldrequired) {
3135function dol_bc($var, $moreclass =
'')
3138 $ret =
' '.$bc[$var];
3140 $ret = preg_replace(
'/class=\"/',
'class="'.$moreclass.
' ', $ret);
3160 global $langs, $hookmanager;
3163 $countriesusingstate = array(
'AU',
'CA',
'US',
'IN',
'GB',
'ES',
'UK',
'TR',
'CN');
3168 $ret .= ($extralangcode ?
$object->array_languages[
'address'][$extralangcode] : (empty(
$object->address) ?
'' : preg_replace(
'/(\r\n|\r|\n)+/', $sep,
$object->address)));
3171 if (isset(
$object->country_code) && in_array(
$object->country_code, array(
'AU',
'CA',
'US',
'CN')) ||
getDolGlobalString(
'MAIN_FORCE_STATE_INTO_ADDRESS')) {
3173 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3174 $ret .= (($ret && $town) ? $sep :
'').$town;
3177 $ret .= ($ret ? ($town ?
", " : $sep) :
'').
$object->state;
3180 $ret .= ($ret ? (($town ||
$object->state) ?
", " : $sep) :
'').
$object->zip;
3182 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'GB',
'UK'))) {
3184 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3185 $ret .= ($ret ? $sep :
'').$town;
3187 $ret .= ($ret ?
", " :
'').
$object->state;
3190 $ret .= ($ret ? $sep :
'').
$object->zip;
3192 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'ES',
'TR'))) {
3194 $ret .= ($ret ? $sep :
'').
$object->zip;
3195 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3196 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3198 $ret .= $sep.$object->state;
3200 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'JP'))) {
3203 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3205 } elseif (isset(
$object->country_code) && in_array(
$object->country_code, array(
'IT'))) {
3207 $ret .= ($ret ? $sep :
'').
$object->zip;
3208 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3209 $ret .= ($town ? ((
$object->zip ?
' ' :
'').$town) :
'');
3210 $ret .= (empty(
$object->state_code) ?
'' : (
' '.$object->state_code));
3213 $town = ($extralangcode ?
$object->array_languages[
'town'][$extralangcode] : (empty(
$object->town) ?
'' :
$object->town));
3214 $ret .= !empty(
$object->zip) ? (($ret ? $sep :
'').
$object->zip) :
'';
3215 $ret .= ($town ? ((
$object->zip ?
' ' : ($ret ? $sep :
'')).$town) :
'');
3216 if (!empty(
$object->state) && in_array(
$object->country_code, $countriesusingstate)) {
3217 $ret .= ($ret ?
", " :
'').
$object->state;
3221 if (!is_object($outputlangs)) {
3222 $outputlangs = $langs;
3225 $langs->load(
"dict");
3226 $ret .= (empty(
$object->country_code) ?
'' : ($ret ? $sep :
'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv(
"Country".$object->country_code)));
3229 $parameters = array(
'withcountry' => $withcountry,
'sep' => $sep,
'outputlangs' => $outputlangs,
'mode' => $mode,
'extralangcode' => $extralangcode);
3230 $reshook = $hookmanager->executeHooks(
'formatAddress', $parameters,
$object);
3234 $ret .= $hookmanager->resPrint;
3251function dol_strftime($fmt, $ts =
false, $is_gmt =
false)
3253 if ((abs($ts) <= 0x7FFFFFFF)) {
3256 return 'Error date outside supported range';
3281function dol_print_date($time, $format =
'', $tzoutput =
'auto', $outputlangs =
null, $encodetooutput =
false)
3283 global $conf, $langs;
3290 if ($tzoutput ===
'auto') {
3291 $tzoutput = (empty($conf) ?
'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey :
'tzserver'));
3296 $offsettz = $offsetdst = 0;
3299 if (is_string($tzoutput)) {
3300 if ($tzoutput ==
'tzserver') {
3302 $offsettzstring = @date_default_timezone_get();
3307 } elseif ($tzoutput ==
'tzuser' || $tzoutput ==
'tzuserrel') {
3309 $offsettzstring = (empty($_SESSION[
'dol_tz_string']) ?
'UTC' : $_SESSION[
'dol_tz_string']);
3311 if (class_exists(
'DateTimeZone')) {
3312 $user_date_tz =
new DateTimeZone($offsettzstring);
3313 $user_dt =
new DateTime();
3314 $user_dt->setTimezone($user_date_tz);
3315 $user_dt->setTimestamp($tzoutput ==
'tzuser' ?
dol_now() : (int) $time);
3316 $offsettz = $user_dt->getOffset();
3318 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3319 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3324 if (!is_object($outputlangs)) {
3325 $outputlangs = $langs;
3328 $format =
'daytextshort';
3333 $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array(
'day',
'dayhour',
'dayhoursec'))) ? 1 : 0;
3334 $format = preg_replace(
'/inputnoreduce/',
'', $format);
3335 $formatwithoutreduce = preg_replace(
'/reduceformat/',
'', $format);
3336 if ($formatwithoutreduce != $format) {
3337 $format = $formatwithoutreduce;
3343 if ($format ==
'day') {
3344 $format = ($outputlangs->trans(
"FormatDateShort") !=
"FormatDateShort" ? $outputlangs->trans(
"FormatDateShort") : $conf->format_date_short);
3345 } elseif ($format ==
'hour') {
3346 $format = ($outputlangs->trans(
"FormatHourShort") !=
"FormatHourShort" ? $outputlangs->trans(
"FormatHourShort") : $conf->format_hour_short);
3347 } elseif ($format ==
'hourduration') {
3348 $format = ($outputlangs->trans(
"FormatHourShortDuration") !=
"FormatHourShortDuration" ? $outputlangs->trans(
"FormatHourShortDuration") : $conf->format_hour_short_duration);
3349 } elseif ($format ==
'daytext') {
3350 $format = ($outputlangs->trans(
"FormatDateText") !=
"FormatDateText" ? $outputlangs->trans(
"FormatDateText") : $conf->format_date_text);
3351 } elseif ($format ==
'daytextshort') {
3352 $format = ($outputlangs->trans(
"FormatDateTextShort") !=
"FormatDateTextShort" ? $outputlangs->trans(
"FormatDateTextShort") : $conf->format_date_text_short);
3353 } elseif ($format ==
'dayhour') {
3354 $format = ($outputlangs->trans(
"FormatDateHourShort") !=
"FormatDateHourShort" ? $outputlangs->trans(
"FormatDateHourShort") : $conf->format_date_hour_short);
3355 } elseif ($format ==
'dayhoursec') {
3356 $format = ($outputlangs->trans(
"FormatDateHourSecShort") !=
"FormatDateHourSecShort" ? $outputlangs->trans(
"FormatDateHourSecShort") : $conf->format_date_hour_sec_short);
3357 } elseif ($format ==
'dayhourtext') {
3358 $format = ($outputlangs->trans(
"FormatDateHourText") !=
"FormatDateHourText" ? $outputlangs->trans(
"FormatDateHourText") : $conf->format_date_hour_text);
3359 } elseif ($format ==
'dayhourtextshort') {
3360 $format = ($outputlangs->trans(
"FormatDateHourTextShort") !=
"FormatDateHourTextShort" ? $outputlangs->trans(
"FormatDateHourTextShort") : $conf->format_date_hour_text_short);
3361 } elseif ($format ==
'dayhourlog') {
3363 $format =
'%Y%m%d%H%M%S';
3364 } elseif ($format ==
'dayhourlogsmall') {
3366 $format =
'%y%m%d%H%M';
3367 } elseif ($format ==
'dayhourldap') {
3368 $format =
'%Y%m%d%H%M%SZ';
3369 } elseif ($format ==
'dayhourxcard') {
3370 $format =
'%Y%m%dT%H%M%SZ';
3371 } elseif ($format ==
'dayxcard') {
3373 } elseif ($format ==
'dayrfc') {
3374 $format =
'%Y-%m-%d';
3375 } elseif ($format ==
'dayhourrfc') {
3376 $format =
'%Y-%m-%dT%H:%M:%SZ';
3377 } elseif ($format ==
'standard') {
3378 $format =
'%Y-%m-%d %H:%M:%S';
3381 if ($reduceformat) {
3382 $format = str_replace(
'%Y',
'%y', $format);
3383 $format = str_replace(
'yyyy',
'yy', $format);
3387 if (preg_match(
'/%b/i', $format)) {
3389 $format = str_replace(
'%b',
'__b__', $format);
3390 $format = str_replace(
'%B',
'__B__', $format);
3392 if (preg_match(
'/%a/i', $format)) {
3394 $format = str_replace(
'%a',
'__a__', $format);
3395 $format = str_replace(
'%A',
'__A__', $format);
3400 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)) {
3401 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"]));
3403 } elseif (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', (
string) $time, $reg)) {
3405 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);
3408 $syear = (!empty($reg[1]) ? $reg[1] :
'');
3409 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
3410 $sday = (!empty($reg[3]) ? $reg[3] :
'');
3411 $shour = (!empty($reg[4]) ? $reg[4] :
'');
3412 $smin = (!empty($reg[5]) ? $reg[5] :
'');
3413 $ssec = (!empty($reg[6]) ? $reg[6] :
'');
3415 $time =
dol_mktime($shour, $smin, $ssec, $smonth, $sday, $syear,
true);
3418 $tzo =
new DateTimeZone(
'UTC');
3420 $tzo =
new DateTimeZone(date_default_timezone_get());
3422 $dtts =
new DateTime();
3423 $dtts->setTimestamp($time);
3424 $dtts->setTimezone($tzo);
3425 $newformat = str_replace(
3426 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3427 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3430 $ret = $dtts->format($newformat);
3432 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3433 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3438 if ($time < 100000000000) {
3439 $timetouse = $time + $offsettz + $offsetdst;
3442 $tzo =
new DateTimeZone(
'UTC');
3444 $tzo =
new DateTimeZone(date_default_timezone_get());
3446 $dtts =
new DateTime();
3447 $dtts->setTimestamp($timetouse);
3448 $dtts->setTimezone($tzo);
3449 $newformat = str_replace(
3450 array(
'%Y',
'%y',
'%m',
'%d',
'%H',
'%I',
'%M',
'%S',
'%p',
'%w',
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3451 array(
'Y',
'y',
'm',
'd',
'H',
'h',
'i',
's',
'A',
'w',
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3454 $ret = $dtts->format($newformat);
3456 array(
'__£__',
'__$__',
'__{__',
'__}__',
'__[__',
'__]__'),
3457 array(
'T',
'Z',
'__a__',
'__A__',
'__b__',
'__B__'),
3462 $ret =
'Bad value '.$time.
' for date';
3466 if (preg_match(
'/__b__/i', $format)) {
3467 $timetouse = $time + $offsettz + $offsetdst;
3470 $tzo =
new DateTimeZone(
'UTC');
3472 $tzo =
new DateTimeZone(date_default_timezone_get());
3474 $dtts =
new DateTime();
3475 $dtts->setTimestamp($timetouse);
3476 $dtts->setTimezone($tzo);
3477 $month = (int) $dtts->format(
"m");
3478 $month = sprintf(
"%02d", $month);
3479 if ($encodetooutput) {
3480 $monthtext = $outputlangs->transnoentities(
'Month'.$month);
3481 $monthtextshort = $outputlangs->transnoentities(
'MonthShort'.$month);
3483 $monthtext = $outputlangs->transnoentitiesnoconv(
'Month'.$month);
3484 $monthtextshort = $outputlangs->transnoentitiesnoconv(
'MonthShort'.$month);
3487 $ret = str_replace(
'__b__', $monthtextshort, $ret);
3488 $ret = str_replace(
'__B__', $monthtext, $ret);
3492 if (preg_match(
'/__a__/i', $format)) {
3494 $timetouse = $time + $offsettz + $offsetdst;
3497 $tzo =
new DateTimeZone(
'UTC');
3499 $tzo =
new DateTimeZone(date_default_timezone_get());
3501 $dtts =
new DateTime();
3502 $dtts->setTimestamp($timetouse);
3503 $dtts->setTimezone($tzo);
3504 $w = $dtts->format(
"w");
3505 $dayweek = $outputlangs->transnoentitiesnoconv(
'Day'.$w);
3507 $ret = str_replace(
'__A__', $dayweek, $ret);
3508 $ret = str_replace(
'__a__',
dol_substr($dayweek, 0, 3), $ret);
3535function dol_getdate($timestamp, $fast =
false, $forcetimezone =
'')
3537 if ($timestamp ===
'') {
3541 $datetimeobj =
new DateTime();
3542 $datetimeobj->setTimestamp($timestamp);
3543 if ($forcetimezone) {
3544 $datetimeobj->setTimezone(
new DateTimeZone($forcetimezone ==
'gmt' ?
'UTC' : $forcetimezone));
3547 'year' => ((
int) date_format($datetimeobj,
'Y')),
3548 'mon' => ((
int) date_format($datetimeobj,
'm')),
3549 'mday' => ((
int) date_format($datetimeobj,
'd')),
3550 'wday' => ((
int) date_format($datetimeobj,
'w')),
3551 'yday' => ((
int) date_format($datetimeobj,
'z')),
3552 'hours' => ((
int) date_format($datetimeobj,
'H')),
3553 'minutes' => ((
int) date_format($datetimeobj,
'i')),
3554 'seconds' => ((
int) date_format($datetimeobj,
's')),
3582function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm =
'auto', $check = 1)
3587 if ($gm ===
'auto') {
3588 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
3593 if ($hour == -1 || empty($hour)) {
3596 if ($minute == -1 || empty($minute)) {
3599 if ($second == -1 || empty($second)) {
3605 if (!$month || !$day) {
3614 if ($hour < 0 || $hour > 24) {
3617 if ($minute < 0 || $minute > 60) {
3620 if ($second < 0 || $second > 60) {
3625 if (empty($gm) || ($gm ===
'server' || $gm ===
'tzserver')) {
3626 $default_timezone = @date_default_timezone_get();
3627 $localtz =
new DateTimeZone($default_timezone);
3628 } elseif ($gm ===
'user' || $gm ===
'tzuser' || $gm ===
'tzuserrel') {
3630 $default_timezone = (empty($_SESSION[
"dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION[
"dol_tz_string"]);
3632 $localtz =
new DateTimeZone($default_timezone);
3634 dol_syslog(
"Warning dol_tz_string contains an invalid value ".json_encode($_SESSION[
"dol_tz_string"] ??
null), LOG_WARNING);
3635 $default_timezone = @date_default_timezone_get();
3637 } elseif (strrpos($gm,
"tz,") !==
false) {
3638 $timezone = str_replace(
"tz,",
"", $gm);
3640 $localtz =
new DateTimeZone($timezone);
3642 dol_syslog(
"Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
3646 if (empty($localtz)) {
3647 $localtz =
new DateTimeZone(
'UTC');
3651 $dt =
new DateTime(
'now', $localtz);
3652 $dt->setDate((
int) $year, (
int) $month, (
int) $day);
3653 $dt->setTime((
int) $hour, (
int) $minute, (
int) $second);
3654 $date = $dt->getTimestamp();
3670function dol_now($mode =
'auto')
3674 if ($mode ===
'auto') {
3678 if ($mode ==
'gmt') {
3680 } elseif ($mode ==
'tzserver') {
3681 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
3683 $ret = (int) (
dol_now(
'gmt') + ($tzsecond * 3600));
3689 } elseif ($mode ==
'tzuser' || $mode ==
'tzuserrel') {
3692 $offsettz = (empty($_SESSION[
'dol_tz']) ? 0 : $_SESSION[
'dol_tz']) * 60 * 60;
3693 $offsetdst = (empty($_SESSION[
'dol_dst']) ? 0 : $_SESSION[
'dol_dst']) * 60 * 60;
3694 $ret = (int) (
dol_now(
'gmt') + ($offsettz + $offsetdst));
3711 global $conf, $langs;
3714 if (!empty($conf->dol_optimize_smallscreen)) {
3719 if (empty($shortvalue) || $size < ($level * 10)) {
3721 $textunitshort = $langs->trans(
"b");
3722 $textunitlong = $langs->trans(
"Bytes");
3724 $ret = round($size / $level, 0);
3725 $textunitshort = $langs->trans(
"Kb");
3726 $textunitlong = $langs->trans(
"KiloBytes");
3729 if (empty($shortunit)) {
3730 $ret .=
' '.$textunitlong;
3732 $ret .=
' '.$textunitshort;
3748function dol_print_url($url, $target =
'_blank', $max = 32, $withpicto = 0, $morecss =
'')
3756 $linkstart =
'<a href="';
3757 if (!preg_match(
'/^http/i', $url)) {
3758 $linkstart .=
'http://';
3763 $linkstart .=
' target="'.$target.
'"';
3765 $linkstart .=
' title="'.$langs->trans(
"URL").
': '.$url.
'"';
3769 if (!preg_match(
'/^http/i', $url)) {
3776 if ($morecss ==
'float') {
3777 return '<div class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto($langs->trans(
"Url"),
'globe',
'class="paddingrightonly"') :
'').$link.
'</div>';
3779 return $linkstart.
'<span class="nospan'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">'.($withpicto ?
img_picto(
'',
'globe',
'class="paddingrightonly"') :
'').$link.
'</span>'.$linkend;
3795function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0)
3797 global $user, $langs, $hookmanager;
3808 if (empty($email)) {
3812 if (!empty($addlink)) {
3813 $newemail =
'<a class="paddingrightonly" style="text-overflow: ellipsis;" href="';
3814 if (!preg_match(
'/^mailto:/i', $email)) {
3815 $newemail .=
'mailto:';
3817 $newemail .= $email;
3820 $newemail .= ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'');
3823 $newemail .=
'</a>';
3825 $langs->load(
"errors");
3826 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email),
'',
'paddingrightonly');
3829 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
3831 $linktoaddaction =
'';
3833 $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>';
3835 if ($linktoaddaction) {
3836 $newemail =
'<div>'.$newemail.
' '.$linktoaddaction.
'</div>';
3840 $newemail = ($withpicto ?
img_picto($langs->trans(
"EMail").
' : '.$email, (is_numeric($withpicto) ?
'email' : $withpicto),
'class="paddingrightonly"') :
'').$newemail;
3843 $langs->load(
"errors");
3844 $newemail .=
img_warning($langs->trans(
"ErrorBadEMail", $email));
3854 $parameters = array(
'cid' => $cid,
'socid' => $socid,
'addlink' => $addlink,
'picto' => $withpicto);
3856 $reshook = $hookmanager->executeHooks(
'printEmail', $parameters, $email);
3860 $rep .= $hookmanager->resPrint;
3875 $socialnetworks = array();
3877 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
3878 $cachekey =
'socialnetworks_' . $conf->entity;
3880 if (!is_null($dataretrieved)) {
3881 $socialnetworks = $dataretrieved;
3883 $sql =
"SELECT rowid, code, label, url, icon, active FROM ".MAIN_DB_PREFIX.
"c_socialnetworks";
3884 $sql .=
" WHERE entity=".$conf->entity;
3885 $resql = $db->query($sql);
3887 while ($obj = $db->fetch_object($resql)) {
3888 $socialnetworks[$obj->code] = array(
3889 'rowid' => $obj->rowid,
3890 'label' => $obj->label,
3892 'icon' => $obj->icon,
3893 'active' => $obj->active,
3899 return $socialnetworks;
3914 global $user, $langs;
3918 if (empty($value)) {
3922 if (!empty($type)) {
3923 $htmllink =
'<div class="divsocialnetwork inline-block valignmiddle">';
3925 $htmllink .=
'<span class="fab pictofixedwidth '.($dictsocialnetworks[$type][
'icon'] ? $dictsocialnetworks[$type][
'icon'] :
'fa-link').
'"></span>';
3926 if ($type ==
'skype') {
3928 $htmllink .=
' <a href="skype:';
3930 $htmllink .=
'?call" alt="'.$langs->trans(
"Call").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Call").
' '.$value).
'">';
3931 $htmllink .=
'<img src="'.DOL_URL_ROOT.
'/theme/common/skype_callbutton.png" border="0">';
3932 $htmllink .=
'</a><a href="skype:';
3934 $htmllink .=
'?chat" alt="'.$langs->trans(
"Chat").
' '.$value.
'" title="'.
dol_escape_htmltag($langs->trans(
"Chat").
' '.$value).
'">';
3935 $htmllink .=
'<img class="paddingleft" src="'.DOL_URL_ROOT.
'/theme/common/skype_chatbutton.png" border="0">';
3936 $htmllink .=
'</a>';
3937 if (($cid || $socid) && isModEnabled(
'agenda') && $user->hasRight(
'agenda',
'myactions',
'create')) {
3938 $addlink =
'AC_SKYPE';
3941 $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>';
3943 $htmllink .= ($link ?
' '.$link :
'');
3946 $networkconstname =
'MAIN_INFO_SOCIETE_'.strtoupper($type).
'_URL';
3949 if (preg_match(
'/^https?:\/\//i', $link)) {
3950 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3952 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3954 } elseif (!empty($dictsocialnetworks[$type][
'url'])) {
3955 $tmpvirginurl = preg_replace(
'/\/?{socialid}/',
'', $dictsocialnetworks[$type][
'url']);
3956 if ($tmpvirginurl) {
3957 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3958 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl,
'/').
'\/?/',
'', $value);
3960 $tmpvirginurl3 = preg_replace(
'/^https:\/\//i',
'https://www.', $tmpvirginurl);
3961 if ($tmpvirginurl3) {
3962 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3963 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl3,
'/').
'\/?/',
'', $value);
3966 $tmpvirginurl2 = preg_replace(
'/^https?:\/\//i',
'', $tmpvirginurl);
3967 if ($tmpvirginurl2) {
3968 $value = preg_replace(
'/^www\.'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3969 $value = preg_replace(
'/^'.preg_quote($tmpvirginurl2,
'/').
'\/?/',
'', $value);
3972 $link = str_replace(
'{socialid}', $value, $dictsocialnetworks[$type][
'url']);
3973 if (preg_match(
'/^https?:\/\//i', $link)) {
3974 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 0).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3976 $htmllink .=
'<a href="'.dol_sanitizeUrl($link, 1).
'" target="_blank" rel="noopener noreferrer">'.
dol_escape_htmltag($value).
'</a>';
3982 $htmllink .=
'</div>';
3984 $langs->load(
"errors");
3985 $htmllink .=
img_warning($langs->trans(
"ErrorBadSocialNetworkValue", $value));
3999function dol_print_profids($profID, $profIDtype, $countrycode =
'', $addcpButton = 1)
4003 if (empty($profID) || empty($profIDtype)) {
4006 if (empty($countrycode)) {
4007 $countrycode = $mysoc->country_code;
4009 $newProfID = $profID;
4010 $id = substr($profIDtype, -1);
4012 if (strtoupper($countrycode) ==
'FR') {
4016 if ($id == 1 &&
dol_strlen($newProfID) == 9) {
4018 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3);
4020 if ($id == 2 &&
dol_strlen($newProfID) == 14) {
4022 $newProfID = substr($newProfID, 0, 3).
' '.substr($newProfID, 3, 3).
' '.substr($newProfID, 6, 3).
' '.substr($newProfID, 9, 5);
4024 if ($id == 3 &&
dol_strlen($newProfID) == 5) {
4026 $newProfID = substr($newProfID, 0, 2).
'.'.substr($newProfID, 2, 3);
4028 if ($profIDtype ===
'VAT' &&
dol_strlen($newProfID) == 13) {
4030 $newProfID = substr($newProfID, 0, 4).
' '.substr($newProfID, 4, 3).
' '.substr($newProfID, 7, 3).
' '.substr($newProfID, 10, 3);
4033 if (!empty($addcpButton)) {
4056function dol_print_phone($phone, $countrycode =
'', $cid = 0, $socid = 0, $addlink =
'', $separ =
" ", $withpicto =
'', $titlealt =
'', $adddivfloat = 0, $morecss =
'')
4058 global $conf, $user, $langs, $mysoc, $hookmanager;
4061 $phone = is_null($phone) ?
'' : preg_replace(
"/[\s.-]/",
"", trim($phone));
4062 if (empty($phone)) {
4068 if (empty($countrycode) && is_object($mysoc)) {
4069 $countrycode = $mysoc->country_code;
4073 if (!empty($conf->dol_optimize_smallscreen) && $separ !=
'hidenum') {
4078 $newphonewa = $phone;
4079 if (strtoupper($countrycode) ==
"FR") {
4082 $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);
4084 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
4086 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
4088 $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);
4090 $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);
4092 $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);
4094 } elseif (strtoupper($countrycode) ==
"CA") {
4096 $newphone = ($separ !=
'' ?
'(' :
'').substr($newphone, 0, 3).($separ !=
'' ?
')' :
'').$separ.substr($newphone, 3, 3).($separ !=
'' ?
'-' :
'').substr($newphone, 6, 4);
4098 } elseif (strtoupper($countrycode) ==
"PT") {
4100 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4102 } elseif (strtoupper($countrycode) ==
"SR") {
4104 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
4106 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
4108 } elseif (strtoupper($countrycode) ==
"DE") {
4110 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
4112 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
4114 } elseif (strtoupper($countrycode) ==
"ES") {
4116 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4118 } elseif (strtoupper($countrycode) ==
"BF") {
4120 $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);
4122 } elseif (strtoupper($countrycode) ==
"RO") {
4124 $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);
4126 } elseif (strtoupper($countrycode) ==
"TR") {
4128 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4130 } elseif (strtoupper($countrycode) ==
"US") {
4132 $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4134 } elseif (strtoupper($countrycode) ==
"MX") {
4136 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4138 $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);
4140 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
4142 } elseif (strtoupper($countrycode) ==
"ML") {
4144 $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);
4146 } elseif (strtoupper($countrycode) ==
"TH") {
4148 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4150 $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);
4152 } elseif (strtoupper($countrycode) ==
"MU") {
4155 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
4157 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
4159 } elseif (strtoupper($countrycode) ==
"ZA") {
4161 $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);
4163 } elseif (strtoupper($countrycode) ==
"SY") {
4165 $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);
4167 $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);
4169 } elseif (strtoupper($countrycode) ==
"AE") {
4171 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
4173 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4175 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
4177 } elseif (strtoupper($countrycode) ==
"DZ") {
4179 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4181 } elseif (strtoupper($countrycode) ==
"BE") {
4183 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
4185 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4187 } elseif (strtoupper($countrycode) ==
"PF") {
4189 $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);
4191 } elseif (strtoupper($countrycode) ==
"CO") {
4193 $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);
4195 } elseif (strtoupper($countrycode) ==
"JO") {
4197 $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);
4199 } elseif (strtoupper($countrycode) ==
"JM") {
4201 $newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
4203 } elseif (strtoupper($countrycode) ==
"MG") {
4205 $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);
4207 } elseif (strtoupper($countrycode) ==
"GB") {
4209 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
4211 } elseif (strtoupper($countrycode) ==
"CH") {
4213 $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);
4215 $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);
4217 } elseif (strtoupper($countrycode) ==
"TN") {
4219 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4221 } elseif (strtoupper($countrycode) ==
"GF") {
4223 $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);
4225 } elseif (strtoupper($countrycode) ==
"GP") {
4227 $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);
4229 } elseif (strtoupper($countrycode) ==
"MQ") {
4231 $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);
4233 } elseif (strtoupper($countrycode) ==
"IT") {
4235 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
4237 $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);
4239 } elseif (strtoupper($countrycode) ==
"AU") {
4243 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
4245 } elseif (strtoupper($countrycode) ==
"LU") {
4248 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
4250 $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);
4252 $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);
4254 $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);
4256 } elseif (strtoupper($countrycode) ==
"PE") {
4259 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4);
4261 $newphonewa =
'+51'.$newphone;
4262 $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 10, 3);
4264 $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 8, 4);
4266 $newphonewa = $newphone;
4267 $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);
4271 $newphoneastart = $newphoneaend =
'';
4272 if (!empty($addlink)) {
4273 if ($addlink ==
'tel' || $conf->browser->layout ==
'phone' || (isModEnabled(
'clicktodial') &&
getDolGlobalString(
'CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS'))) {
4274 $newphoneastart =
'<a href="tel:'.urlencode($phone).
'">';
4275 $newphoneaend .=
'</a>';
4276 } elseif (isModEnabled(
'clicktodial') && $addlink ==
'AC_TEL') {
4277 if (empty($user->clicktodial_loaded)) {
4278 $user->fetch_clicktodial();
4282 $urlmask =
getDolGlobalString(
'CLICKTODIAL_URL',
'ErrorClickToDialModuleNotConfigured');
4283 if (!empty($user->clicktodial_url)) {
4284 $urlmask = $user->clicktodial_url;
4287 $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) :
'');
4288 $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) :
'');
4289 $clicktodial_password = (!empty($user->clicktodial_password) ? urlencode($user->clicktodial_password) :
'');
4291 $url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
4293 $substitarray = array(
'__PHONEFROM__' => $clicktodial_poste,
4294 '__PHONETO__' => urlencode($phone),
4295 '__LOGIN__' => $clicktodial_login,
4296 '__PASS__' => $clicktodial_password);
4300 $newphoneastart =
'<a href="'.$url.
'" class="cssforclicktodial">';
4301 $newphoneaend =
'</a>';
4304 $newphoneastart =
'<a href="'.$url.
'"';
4306 $newphoneastart .=
' target="_blank" rel="noopener noreferrer"';
4308 $newphoneastart .=
'>';
4309 $newphoneaend .=
'</a>';
4314 if (isModEnabled(
'agenda') && $user->hasRight(
"agenda",
"myactions",
"create")) {
4316 $addlinktoagenda =
'';
4317 if ($addlink ==
'AC_FAX') {
4321 $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>';
4323 if ($addlinktoagenda) {
4324 $newphone =
'<span>'.$newphone.
' '.$addlinktoagenda.
'</span>';
4329 if (
getDolGlobalString(
'CONTACT_PHONEMOBILE_SHOW_LINK_TO_WHATSAPP') && $withpicto ==
'mobile') {
4331 $newphone .=
' <a href="https://wa.me/'.$newphonewa.
'" target="_blank"';
4332 $newphone .=
'><span class="paddingright fab fa-whatsapp" style="color:#25D366;" title="WhatsApp"></span></a>';
4335 if (empty($titlealt)) {
4336 $titlealt = ($withpicto ==
'fax' ? $langs->trans(
"Fax") : $langs->trans(
"Phone"));
4341 $parameters = array(
'countrycode' => $countrycode,
'cid' => $cid,
'socid' => $socid,
'titlealt' => $titlealt,
'picto' => $withpicto);
4342 $reshook = $hookmanager->executeHooks(
'printPhone', $parameters, $phone);
4343 $rep .= $hookmanager->resPrint;
4345 if (empty($reshook)) {
4348 if ($withpicto ==
'fax') {
4349 $picto =
'phoning_fax';
4350 } elseif ($withpicto ==
'phone') {
4352 } elseif ($withpicto ==
'mobile') {
4353 $picto =
'phoning_mobile';
4358 if ($adddivfloat == 1) {
4359 $rep .=
'<div class="nospan float'.($morecss ?
' '.$morecss :
'').
'" style="margin-right: 10px">';
4360 } elseif (empty($adddivfloat)) {
4361 $rep .=
'<span'.($morecss ?
' class="'.$morecss.
'"' :
'').
' style="margin-right: 10px;">';
4364 $rep .= $newphoneastart;
4365 $rep .= ($withpicto ?
img_picto($titlealt,
'object_'.$picto.
'.png') :
'');
4366 if ($separ !=
'hidenum') {
4367 $rep .= ($withpicto ?
' ' :
'').$newphone;
4369 $rep .= $newphoneaend;
4371 if ($adddivfloat == 1) {
4373 } elseif (empty($adddivfloat)) {
4401 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/common/flags/'.$countrycode.
'.png')) {
4402 $ret .=
' '.img_picto($countrycode.
' '.$langs->trans(
"AccordingToGeoIPDatabase"), DOL_URL_ROOT.
'/theme/common/flags/'.$countrycode.
'.png',
'', 1);
4404 $ret .=
' ('.$countrycode.
')';
4424 if (empty($_SERVER[
'HTTP_X_FORWARDED_FOR']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_X_FORWARDED_FOR'])) {
4425 if (empty($_SERVER[
'HTTP_CLIENT_IP']) || preg_match(
'/[^0-9\.\:,\[\]]/', $_SERVER[
'HTTP_CLIENT_IP'])) {
4426 if (empty($_SERVER[
"HTTP_CF_CONNECTING_IP"])) {
4427 $ip = (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']);
4429 $ip = $_SERVER[
"HTTP_CF_CONNECTING_IP"];
4432 $ip = $_SERVER[
'HTTP_CLIENT_IP'];
4435 $ip = $_SERVER[
'HTTP_X_FORWARDED_FOR'];
4451 if (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] ==
'on') {
4453 } 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') {
4471 if (!empty($conf->geoipmaxmind->enabled)) {
4475 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4476 $geoip =
new DolGeoIP(
'country', $datafile);
4478 $countrycode = $geoip->getCountryCodeFromIP($ip);
4481 return $countrycode;
4493 global $conf, $langs, $user;
4497 if (!empty($conf->geoipmaxmind->enabled)) {
4502 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeoip.class.php';
4503 $geoip =
new DolGeoIP(
'country', $datafile);
4504 $countrycode = $geoip->getCountryCodeFromIP($ip);
4505 $ret = $countrycode;
4522function dol_print_address($address, $htmlid, $element, $id, $noprint = 0, $charfornl =
'')
4524 global $conf, $user, $langs, $hookmanager;
4530 $parameters = array(
'element' => $element,
'id' => $id);
4531 $reshook = $hookmanager->executeHooks(
'printAddress', $parameters, $address);
4532 $out .= $hookmanager->resPrint;
4534 if (empty($reshook)) {
4535 if (empty($charfornl)) {
4536 $out .= nl2br($address);
4538 $out .= preg_replace(
'/[\r\n]+/', $charfornl, $address);
4542 $showgmap = $showomap = 0;
4543 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS')) {
4546 if ($element ==
'contact' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_CONTACTS')) {
4549 if ($element ==
'member' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_MEMBERS')) {
4552 if ($element ==
'user' && isModEnabled(
'google') &&
getDolGlobalString(
'GOOGLE_ENABLE_GMAPS_USERS')) {
4555 if (($element ==
'thirdparty' || $element ==
'societe') && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS')) {
4558 if ($element ==
'contact' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_CONTACTS')) {
4561 if ($element ==
'member' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_MEMBERS')) {
4564 if ($element ==
'user' && isModEnabled(
'openstreetmap') &&
getDolGlobalString(
'OPENSTREETMAP_ENABLE_MAPS_USERS')) {
4568 $url =
dol_buildpath(
'/google/gmaps.php?mode='.$element.
'&id='.$id, 1);
4569 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4572 $url =
dol_buildpath(
'/openstreetmap/maps.php?mode='.$element.
'&id='.$id, 1);
4573 $out .=
' <a href="'.$url.
'" target="_gmaps"><img id="'.$htmlid.
'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.
'/theme/common/gmap.png"></a>';
4594function isValidEmail($address, $acceptsupervisorkey = 0, $acceptuserkey = 0)
4596 if ($acceptsupervisorkey && $address ==
'__SUPERVISOREMAIL__') {
4599 if ($acceptuserkey && $address ==
'__USER_EMAIL__') {
4602 if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
4620 if (function_exists(
'idn_to_ascii') && function_exists(
'checkdnsrr')) {
4621 if (!checkdnsrr(idn_to_ascii($domain),
'MX')) {
4624 if (function_exists(
'getmxrr')) {
4627 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
4628 if (count($mxhosts) > 1) {
4631 if (count($mxhosts) == 1 && !in_array((
string) $mxhosts[0], array(
'',
'.'))) {
4668 $tmparray = explode(
' ', $s);
4669 foreach ($tmparray as $tmps) {
4684function dol_strlen($string, $stringencoding =
'UTF-8')
4686 if (is_null($string)) {
4690 if (function_exists(
'mb_strlen')) {
4691 return mb_strlen($string, $stringencoding);
4693 return strlen($string);
4707function dol_substr($string, $start, $length =
null, $stringencoding =
'', $trunconbytes = 0)
4711 if (empty($stringencoding)) {
4712 $stringencoding = (empty($langs) ?
'UTF-8' : $langs->charset_output);
4716 if (empty($trunconbytes)) {
4717 if (function_exists(
'mb_substr')) {
4718 $ret = mb_substr($string, $start, $length, $stringencoding);
4720 $ret = substr($string, $start, $length);
4723 if (function_exists(
'mb_strcut')) {
4724 $ret = mb_strcut($string, $start, $length, $stringencoding);
4726 $ret = substr($string, $start, $length);
4746function dol_trunc($string, $size = 40, $trunc =
'right', $stringencoding =
'UTF-8', $nodot = 0, $display = 0)
4754 if (empty($stringencoding)) {
4755 $stringencoding =
'UTF-8';
4758 if (!empty($conf->dol_optimize_smallscreen) && $conf->dol_optimize_smallscreen == 1 && $display == 1) {
4759 $size = round($size / 3);
4763 if ($trunc ==
'right') {
4765 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
4767 return dol_substr($newstring, 0, $size, $stringencoding).($nodot ?
'' :
'…');
4772 } elseif ($trunc ==
'middle') {
4774 if (
dol_strlen($newstring, $stringencoding) > 2 &&
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4775 $size1 = round($size / 2);
4776 $size2 = round($size / 2);
4777 return dol_substr($newstring, 0, $size1, $stringencoding).
'…'.
dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
4781 } elseif ($trunc ==
'left') {
4783 if (
dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 1))) {
4785 return '…'.dol_substr($newstring,
dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
4789 } elseif ($trunc ==
'wrap') {
4791 if (
dol_strlen($newstring, $stringencoding) > ($size + 1)) {
4797 return 'BadParam3CallingDolTrunc';
4811 $type2picto = array(
4812 'varchar' =>
'font',
4815 'int' =>
'sort-numeric-down',
4816 'double' =>
'sort-numeric-down',
4817 'price' =>
'currency',
4818 'pricecy' =>
'multicurrency',
4819 'password' =>
'key',
4820 'boolean' =>
'check-square',
4821 'date' =>
'calendar',
4822 'datetime' =>
'calendar',
4828 'sellist' =>
'list',
4829 'radio' =>
'check-circle',
4830 'checkbox' =>
'list',
4831 'chkbxlst' =>
'list',
4833 'icon' =>
"question",
4834 'point' =>
"country",
4835 'multipts' =>
'country',
4836 'linestrg' =>
"country",
4837 'polygon' =>
"country",
4838 'separate' =>
'minus'
4841 if (!empty($type2picto[$key])) {
4842 return img_picto(
'', $type2picto[$key],
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
4845 return img_picto(
'',
'generic',
'class="pictofixedwidth'.($morecss ?
' '.$morecss :
'').
'"');
4870function img_picto($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0, $alt =
'', $morecss =
'', $marginleftonlyshort = 2)
4875 $url = DOL_URL_ROOT;
4876 $theme = isset($conf->theme) ? $conf->theme :
null;
4877 $path =
'theme/'.$theme;
4878 if (empty($picto)) {
4883 if ($pictoisfullpath) {
4885 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
4888 $fullpathpicto = $picto;
4890 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4891 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4892 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4895 $pictowithouttext = preg_replace(
'/(\.png|\.gif|\.svg)$/',
'', (is_null($picto) ?
'' : $picto));
4896 $pictowithouttext = str_replace(
'object_',
'', $pictowithouttext);
4897 $pictowithouttext = str_replace(
'_nocolor',
'', $pictowithouttext);
4899 if (strpos($pictowithouttext,
'fontawesome_') === 0 || strpos($pictowithouttext,
'fa-') === 0) {
4901 $pictowithouttext = str_replace(
'fontawesome_',
'', $pictowithouttext);
4902 $pictowithouttext = str_replace(
'fa-',
'', $pictowithouttext);
4905 if ($pictowithouttext ==
'file-o') {
4906 $pictowithouttext =
'file';
4909 $pictowithouttextarray = explode(
'_', $pictowithouttext);
4910 $marginleftonlyshort = 0;
4912 if (!empty($pictowithouttextarray[1])) {
4914 $fakey =
'fa-'.$pictowithouttextarray[0];
4915 $faprefix = empty($pictowithouttextarray[1]) ?
'fas' : $pictowithouttextarray[1];
4916 $facolor = empty($pictowithouttextarray[2]) ?
'' : $pictowithouttextarray[2];
4917 $fasize = empty($pictowithouttextarray[3]) ?
'' : $pictowithouttextarray[3];
4919 $fakey =
'fa-'.$pictowithouttext;
4929 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
4930 $morecss .= ($morecss ?
' ' :
'').$reg[1];
4931 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
4933 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
4934 $morestyle = $reg[1];
4935 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
4937 $moreatt = trim($moreatt);
4939 $enabledisablehtml =
'<span class="'.$faprefix.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
4940 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
4944 $enabledisablehtml .=
'</span>';
4946 return $enabledisablehtml;
4949 if (empty($srconly) && in_array($pictowithouttext, array(
4950 '1downarrow',
'1uparrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected',
4951 'accountancy',
'accounting_account',
'account',
'accountline',
'action',
'add',
'address',
'ai',
'angle-double-down',
'angle-double-up',
'asset',
4952 'bank_account',
'barcode',
'bank',
'bell',
'bill',
'billa',
'billr',
'billd',
'birthday-cake',
'bom',
'bookcal',
'bookmark',
'briefcase-medical',
'bug',
'building',
4953 'card',
'calendarlist',
'calendar',
'calendarmonth',
'calendarweek',
'calendarday',
'calendarperuser',
'calendarpertype',
4954 'cash-register',
'category',
'chart',
'check',
'clock',
'clone',
'close_title',
'code',
'cog',
'collab',
'company',
'contact',
'country',
'contract',
'conversation',
'cron',
'cross',
'cubes',
4955 'check-circle',
'check-square',
'circle',
'stop-circle',
'currency',
'multicurrency',
4956 'chevron-left',
'chevron-right',
'chevron-down',
'chevron-top',
4957 'chevron-double-left',
'chevron-double-right',
'chevron-double-down',
'chevron-double-top',
4958 'commercial',
'companies',
4959 'delete',
'dolly',
'dollyrevert',
'donation',
'download',
'dynamicprice',
4960 'edit',
'ellipsis-h',
'email',
'entity',
'envelope',
'eraser',
'establishment',
'expensereport',
'external-link-alt',
'external-link-square-alt',
'eye',
4961 'filter',
'file',
'file-o',
'file-code',
'file-export',
'file-import',
'file-upload',
'autofill',
'folder',
'folder-open',
'folder-plus',
'font',
4962 'gears',
'generate',
'generic',
'globe',
'globe-americas',
'graph',
'grip',
'grip_title',
'group',
4963 'hands-helping',
'help',
'holiday',
4964 'id-card',
'images',
'incoterm',
'info',
'intervention',
'inventory',
'intracommreport',
'jobprofile',
4965 'key',
'knowledgemanagement',
4966 'label',
'language',
'layout',
'line',
'link',
'list',
'list-alt',
'listlight',
'loan',
'lock',
'lot',
'long-arrow-alt-right',
4967 'margin',
'map-marker-alt',
'member',
'meeting',
'minus',
'money-bill-alt',
'movement',
'mrp',
'note',
'next',
4968 'off',
'on',
'order',
4969 'paiment',
'paragraph',
'play',
'pdf',
'phone',
'phoning',
'phoning_mobile',
'phoning_fax',
'playdisabled',
'previous',
'poll',
'pos',
'printer',
'product',
'propal',
'proposal',
'puce',
4970 'stock',
'resize',
'service',
'stats',
4971 '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',
4972 'github',
'google',
'jabber',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'youtube',
'google-plus-g',
'whatsapp',
4973 'generic',
'home',
'hrm',
'members',
'products',
'invoicing',
4974 'partnership',
'payment',
'payment_vat',
'pencil-ruler',
'pictoconfirm',
'preview',
'project',
'projectpub',
'projecttask',
'question',
'refresh',
'region',
4975 'salary',
'shipment',
'state',
'supplier_invoice',
'supplier_invoicea',
'supplier_invoicer',
'supplier_invoiced',
4976 'technic',
'ticket',
4978 'recent',
'reception',
'recruitmentcandidature',
'recruitmentjobposition',
'replacement',
'resource',
'recurring',
'rss',
4979 'shapes',
'skill',
'square',
'sort-numeric-down',
'status',
'stop-circle',
'supplier',
'supplier_proposal',
'supplier_order',
'supplier_invoice',
4980 'terminal',
'tick',
'timespent',
'title_setup',
'title_accountancy',
'title_bank',
'title_hrm',
'title_agenda',
'trip',
4981 'uncheck',
'url',
'user-cog',
'user-injured',
'user-md',
'vat',
'website',
'workstation',
'webhook',
'world',
'private',
4982 'conferenceorbooth',
'eventorganization',
4983 'stamp',
'signature',
4986 $fakey = $pictowithouttext;
4990 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'))) {
4993 if (in_array($pictowithouttext, array(
'black-tie',
'github',
'google',
'microsoft',
'skype',
'twitter',
'facebook',
'linkedin',
'instagram',
'snapchat',
'stripe',
'stripe-s',
'youtube',
'google-plus-g',
'whatsapp'))) {
4997 $arrayconvpictotofa = array(
4998 'account' =>
'university',
'accounting_account' =>
'clipboard-list',
'accountline' =>
'receipt',
'accountancy' =>
'search-dollar',
'action' =>
'calendar-alt',
'add' =>
'plus-circle',
'address' =>
'address-book',
'ai' =>
'magic',
4999 'asset' =>
'money-check-alt',
'autofill' =>
'fill',
5000 'bank_account' =>
'university',
5001 'bill' =>
'file-invoice-dollar',
'billa' =>
'file-excel',
'billr' =>
'file-invoice-dollar',
'billd' =>
'file-medical',
5002 'bookcal' =>
'calendar-check',
5003 'supplier_invoice' =>
'file-invoice-dollar',
'supplier_invoicea' =>
'file-excel',
'supplier_invoicer' =>
'file-invoice-dollar',
'supplier_invoiced' =>
'file-medical',
5005 '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',
5006 'chevron-double-left' =>
'angle-double-left',
'chevron-double-right' =>
'angle-double-right',
'chevron-double-down' =>
'angle-double-down',
'chevron-double-top' =>
'angle-double-up',
5007 'donation' =>
'file-alt',
'dynamicprice' =>
'hand-holding-usd',
5008 'setup' =>
'cog',
'companies' =>
'building',
'products' =>
'cube',
'commercial' =>
'suitcase',
'invoicing' =>
'coins',
5009 'accounting' =>
'search-dollar',
'category' =>
'tag',
'dollyrevert' =>
'dolly',
5010 'file-o' =>
'file',
'generate' =>
'plus-square',
'hrm' =>
'user-tie',
'incoterm' =>
'truck-loading',
5011 'margin' =>
'calculator',
'members' =>
'user-friends',
'ticket' =>
'ticket-alt',
'globe' =>
'external-link-alt',
'lot' =>
'barcode',
5012 'email' =>
'at',
'establishment' =>
'building',
'edit' =>
'pencil-alt',
'entity' =>
'globe',
5013 'graph' =>
'chart-line',
'grip_title' =>
'arrows-alt',
'grip' =>
'arrows-alt',
'help' =>
'question-circle',
5014 'generic' =>
'file',
'holiday' =>
'umbrella-beach',
5015 'info' =>
'info-circle',
'inventory' =>
'boxes',
'intracommreport' =>
'globe-europe',
'jobprofile' =>
'cogs',
5016 'knowledgemanagement' =>
'ticket-alt',
'label' =>
'layer-group',
'layout' =>
'columns',
'line' =>
'bars',
'loan' =>
'money-bill-alt',
5017 'member' =>
'user-alt',
'meeting' =>
'chalkboard-teacher',
'mrp' =>
'cubes',
'next' =>
'arrow-alt-circle-right',
5018 'trip' =>
'wallet',
'expensereport' =>
'wallet',
'group' =>
'users',
'movement' =>
'people-carry',
5019 'sign-out' =>
'sign-out-alt',
5020 'switch_off' =>
'toggle-off',
'switch_on' =>
'toggle-on',
'switch_on_warning' =>
'toggle-on',
'switch_on_red' =>
'toggle-on',
'check' =>
'check',
'bookmark' =>
'star',
5021 'bank' =>
'university',
'close_title' =>
'times',
'delete' =>
'trash',
'filter' =>
'filter',
5022 'list-alt' =>
'list-alt',
'calendarlist' =>
'bars',
'calendar' =>
'calendar-alt',
'calendarmonth' =>
'calendar-alt',
'calendarweek' =>
'calendar-week',
'calendarday' =>
'calendar-day',
'calendarperuser' =>
'table',
5023 'intervention' =>
'ambulance',
'invoice' =>
'file-invoice-dollar',
'order' =>
'file-invoice',
5024 'error' =>
'exclamation-triangle',
'warning' =>
'exclamation-triangle',
5025 'other' =>
'square',
5026 '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',
5027 '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',
5028 'recent' =>
'check-square',
'reception' =>
'dolly',
'recruitmentjobposition' =>
'id-card-alt',
'recruitmentcandidature' =>
'id-badge',
5029 'resize' =>
'crop',
'supplier_order' =>
'dol-order_supplier',
'supplier_proposal' =>
'file-signature',
5030 'refresh' =>
'redo',
'region' =>
'map-marked',
'replacement' =>
'exchange-alt',
'resource' =>
'laptop-house',
'recurring' =>
'history',
5031 'service' =>
'concierge-bell',
5032 'skill' =>
'shapes',
'state' =>
'map-marked-alt',
'security' =>
'key',
'salary' =>
'wallet',
'shipment' =>
'dolly',
'stock' =>
'box-open',
'stats' =>
'chart-bar',
'split' =>
'code-branch',
5033 'status' =>
'stop-circle',
5034 'stripe' =>
'stripe-s',
'supplier' =>
'building',
5035 'technic' =>
'cogs',
'tick' =>
'check',
'timespent' =>
'clock',
'title_setup' =>
'tools',
'title_accountancy' =>
'money-check-alt',
'title_bank' =>
'university',
'title_hrm' =>
'umbrella-beach',
5036 'title_agenda' =>
'calendar-alt',
5037 'uncheck' =>
'times',
'uparrow' =>
'share',
'url' =>
'external-link-alt',
'vat' =>
'money-check-alt',
'vcard' =>
'arrow-alt-circle-down',
5038 'jabber' =>
'comment-o',
5039 'website' =>
'globe-americas',
'workstation' =>
'pallet',
'webhook' =>
'bullseye',
'world' =>
'globe',
'private' =>
'user-lock',
5040 'conferenceorbooth' =>
'chalkboard-teacher',
'eventorganization' =>
'project-diagram',
5041 'webportal' =>
'door-open'
5043 if ($conf->currency ==
'EUR') {
5044 $arrayconvpictotofa[
'currency'] =
'euro-sign';
5045 $arrayconvpictotofa[
'multicurrency'] =
'dollar-sign';
5047 $arrayconvpictotofa[
'currency'] =
'dollar-sign';
5048 $arrayconvpictotofa[
'multicurrency'] =
'euro-sign';
5050 if ($pictowithouttext ==
'off') {
5051 $fakey =
'fa-square';
5053 } elseif ($pictowithouttext ==
'on') {
5054 $fakey =
'fa-check-square';
5056 } elseif ($pictowithouttext ==
'listlight') {
5057 $fakey =
'fa-download';
5058 $marginleftonlyshort = 1;
5059 } elseif ($pictowithouttext ==
'printer') {
5060 $fakey =
'fa-print';
5062 } elseif ($pictowithouttext ==
'note') {
5063 $fakey =
'fa-sticky-note';
5064 $marginleftonlyshort = 1;
5065 } elseif (in_array($pictowithouttext, array(
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'))) {
5066 $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');
5067 $fakey =
'fa-'.$convertarray[$pictowithouttext];
5068 if (preg_match(
'/selected/', $pictowithouttext)) {
5071 $marginleftonlyshort = 1;
5072 } elseif (!empty($arrayconvpictotofa[$pictowithouttext])) {
5073 $fakey =
'fa-'.$arrayconvpictotofa[$pictowithouttext];
5075 $fakey =
'fa-'.$pictowithouttext;
5078 if (in_array($pictowithouttext, array(
'dollyrevert',
'member',
'members',
'contract',
'group',
'resource',
'shipment',
'reception'))) {
5079 $morecss .=
' em092';
5081 if (in_array($pictowithouttext, array(
'conferenceorbooth',
'collab',
'eventorganization',
'holiday',
'info',
'project',
'workstation'))) {
5082 $morecss .=
' em088';
5084 if (in_array($pictowithouttext, array(
'asset',
'intervention',
'payment',
'loan',
'partnership',
'stock',
'technic'))) {
5085 $morecss .=
' em080';
5089 $arrayconvpictotomarginleftonly = array(
5090 'bank',
'check',
'delete',
'generic',
'grip',
'grip_title',
'jabber',
5091 'grip_title',
'grip',
'listlight',
'note',
'on',
'off',
'playdisabled',
'printer',
'resize',
'sign-out',
'stats',
'switch_on',
'switch_on_red',
'switch_off',
5092 'uparrow',
'1uparrow',
'1downarrow',
'1leftarrow',
'1rightarrow',
'1uparrow_selected',
'1downarrow_selected',
'1leftarrow_selected',
'1rightarrow_selected'
5094 if (!isset($arrayconvpictotomarginleftonly[$pictowithouttext])) {
5095 $marginleftonlyshort = 0;
5099 $arrayconvpictotomorcess = array(
5100 'action' =>
'infobox-action',
'account' =>
'infobox-bank_account',
'accounting_account' =>
'infobox-bank_account',
'accountline' =>
'infobox-bank_account',
'accountancy' =>
'infobox-bank_account',
'asset' =>
'infobox-bank_account',
5101 'bank_account' =>
'infobox-bank_account',
5102 'bill' =>
'infobox-commande',
'billa' =>
'infobox-commande',
'billr' =>
'infobox-commande',
'billd' =>
'infobox-commande',
5103 'bookcal' =>
'infobox-action',
5104 'margin' =>
'infobox-bank_account',
'conferenceorbooth' =>
'infobox-project',
5105 'cash-register' =>
'infobox-bank_account',
'contract' =>
'infobox-contrat',
'check' =>
'font-status4',
'collab' =>
'infobox-action',
'conversation' =>
'infobox-contrat',
5106 'donation' =>
'infobox-commande',
'dolly' =>
'infobox-commande',
'dollyrevert' =>
'flip infobox-order_supplier',
5107 'ecm' =>
'infobox-action',
'eventorganization' =>
'infobox-project',
5108 'hrm' =>
'infobox-adherent',
'group' =>
'infobox-adherent',
'intervention' =>
'infobox-contrat',
5109 'incoterm' =>
'infobox-supplier_proposal',
5110 'currency' =>
'infobox-bank_account',
'multicurrency' =>
'infobox-bank_account',
5111 'members' =>
'infobox-adherent',
'member' =>
'infobox-adherent',
'money-bill-alt' =>
'infobox-bank_account',
5112 'order' =>
'infobox-commande',
5113 'user' =>
'infobox-adherent',
'users' =>
'infobox-adherent',
5114 'error' =>
'pictoerror',
'warning' =>
'pictowarning',
'switch_on' =>
'font-status4',
'switch_on_warning' =>
'font-status4 warning',
'switch_on_red' =>
'font-status8',
5115 'holiday' =>
'infobox-holiday',
'info' =>
'opacityhigh',
'invoice' =>
'infobox-commande',
5116 'knowledgemanagement' =>
'infobox-contrat rotate90',
'loan' =>
'infobox-bank_account',
5117 'payment' =>
'infobox-bank_account',
'payment_vat' =>
'infobox-bank_account',
'poll' =>
'infobox-adherent',
'pos' =>
'infobox-bank_account',
'project' =>
'infobox-project',
'projecttask' =>
'infobox-project',
5118 'propal' =>
'infobox-propal',
'proposal' =>
'infobox-propal',
'private' =>
'infobox-project',
5119 'reception' =>
'flip infobox-order_supplier',
'recruitmentjobposition' =>
'infobox-adherent',
'recruitmentcandidature' =>
'infobox-adherent',
5120 'resource' =>
'infobox-action',
5121 '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',
5122 'supplier' =>
'infobox-order_supplier',
'supplier_order' =>
'infobox-order_supplier',
'supplier_proposal' =>
'infobox-supplier_proposal',
5123 'ticket' =>
'infobox-contrat',
'title_accountancy' =>
'infobox-bank_account',
'title_hrm' =>
'infobox-holiday',
'expensereport' =>
'infobox-expensereport',
'trip' =>
'infobox-expensereport',
'title_agenda' =>
'infobox-action',
5124 'vat' =>
'infobox-bank_account',
5126 'list-alt' =>
'imgforviewmode',
'calendar' =>
'imgforviewmode',
'calendarweek' =>
'imgforviewmode',
'calendarmonth' =>
'imgforviewmode',
'calendarday' =>
'imgforviewmode',
'calendarperuser' =>
'imgforviewmode'
5128 if (!empty($arrayconvpictotomorcess[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5129 $morecss .= ($morecss ?
' ' :
'').$arrayconvpictotomorcess[$pictowithouttext];
5133 $arrayconvpictotocolor = array(
5134 'address' =>
'#6c6aa8',
'building' =>
'#6c6aa8',
'bom' =>
'#a69944',
5135 'clone' =>
'#999',
'cog' =>
'#999',
'companies' =>
'#6c6aa8',
'company' =>
'#6c6aa8',
'contact' =>
'#6c6aa8',
'cron' =>
'#555',
5136 'dynamicprice' =>
'#a69944',
5137 'edit' =>
'#444',
'note' =>
'#999',
'error' =>
'',
'help' =>
'#bbb',
'listlight' =>
'#999',
'language' =>
'#555',
5139 'lock' =>
'#ddd',
'lot' =>
'#a69944',
5140 'map-marker-alt' =>
'#aaa',
'mrp' =>
'#a69944',
'product' =>
'#a69944',
'service' =>
'#a69944',
'inventory' =>
'#a69944',
'stock' =>
'#a69944',
'movement' =>
'#a69944',
5141 'other' =>
'#ddd',
'world' =>
'#986c6a',
5142 'partnership' =>
'#6c6aa8',
'playdisabled' =>
'#ccc',
'printer' =>
'#444',
'projectpub' =>
'#986c6a',
'resize' =>
'#444',
'rss' =>
'#cba',
5144 'security' =>
'#999',
'square' =>
'#888',
'stop-circle' =>
'#888',
'stats' =>
'#444',
'switch_off' =>
'#999',
5145 'technic' =>
'#999',
'tick' =>
'#282',
'timespent' =>
'#555',
5146 'uncheck' =>
'#800',
'uparrow' =>
'#555',
'user-cog' =>
'#999',
'country' =>
'#aaa',
'globe-americas' =>
'#aaa',
'region' =>
'#aaa',
'state' =>
'#aaa',
5147 'website' =>
'#304',
'workstation' =>
'#a69944'
5149 if (isset($arrayconvpictotocolor[$pictowithouttext]) && strpos($picto,
'_nocolor') ===
false) {
5150 $facolor = $arrayconvpictotocolor[$pictowithouttext];
5157 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
5158 $morecss .= ($morecss ?
' ' :
'').$reg[1];
5159 $moreatt = str_replace(
'class="'.$reg[1].
'"',
'', $moreatt);
5161 if (preg_match(
'/style="([^"]+)"/', $moreatt, $reg)) {
5162 $morestyle = $reg[1];
5163 $moreatt = str_replace(
'style="'.$reg[1].
'"',
'', $moreatt);
5165 $moreatt = trim($moreatt);
5167 $enabledisablehtml =
'<span class="'.$fa.
' '.$fakey.($marginleftonlyshort ? ($marginleftonlyshort == 1 ?
' marginleftonlyshort' :
' marginleftonly') :
'');
5168 $enabledisablehtml .= ($morecss ?
' '.$morecss :
'').
'" style="'.($fasize ? (
'font-size: '.$fasize.
';') :
'').($facolor ? (
' color: '.$facolor.
';') :
'').($morestyle ?
' '.$morestyle :
'').
'"'.(($notitle || empty($titlealt)) ?
'' :
' title="'.
dol_escape_htmltag($titlealt).
'"').($moreatt ?
' '.$moreatt :
'').
'>';
5172 $enabledisablehtml .=
'</span>';
5174 return $enabledisablehtml;
5181 } elseif (!empty($conf->modules_parts[
'theme']) && array_key_exists($theme, $conf->modules_parts[
'theme'])) {
5182 $path = $theme.
'/theme/'.$theme;
5187 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
5193 if (!preg_match(
'/(\.png|\.gif|\.svg)$/i', $picto)) {
5198 foreach ($conf->file->dol_document_root as $type => $dirroot) {
5199 if ($type ==
'main') {
5203 if (file_exists($dirroot.
'/'.$path.
'/img/'.$picto)) {
5204 $url = DOL_URL_ROOT.$conf->file->dol_url_root[$type];
5210 $fullpathpicto = $url.
'/'.$path.
'/img/'.$picto;
5214 return $fullpathpicto;
5218 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 :
'').
'"').
'>';
5234function img_object($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $srconly = 0, $notitle = 0)
5236 if (strpos($picto,
'^') === 0) {
5237 return img_picto($titlealt, str_replace(
'^',
'', $picto), $moreatt, $pictoisfullpath, $srconly, $notitle);
5239 return img_picto($titlealt,
'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
5254function img_weather($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $morecss =
'')
5258 if (is_numeric($picto)) {
5261 return '<i class="fa fa-weather-level'.$picto.
'"></i>';
5262 } elseif (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5266 $path = DOL_URL_ROOT.
'/theme/'.$conf->theme.
'/img/weather/'.$picto;
5268 return img_picto($titlealt, $path, $moreatt, 1, 0, 0,
'', $morecss);
5282function img_picto_common($titlealt, $picto, $moreatt =
'', $pictoisfullpath = 0, $notitle = 0)
5286 if (!preg_match(
'/(\.png|\.gif)$/i', $picto)) {
5290 if ($pictoisfullpath) {
5293 $path = DOL_URL_ROOT.
'/theme/common/'.$picto;
5296 $themepath = DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/img/'.$picto;
5298 if (file_exists($themepath)) {
5304 return img_picto($titlealt, $path, $moreatt, 1, 0, $notitle);
5320function img_action($titlealt, $numaction, $picto =
'', $moreatt =
'')
5324 if (empty($titlealt) || $titlealt ==
'default') {
5325 if ($numaction ==
'-1' || $numaction ==
'ST_NO') {
5327 $titlealt = $langs->transnoentitiesnoconv(
'ChangeDoNotContact');
5328 } elseif ($numaction ==
'0' || $numaction ==
'ST_NEVER') {
5330 $titlealt = $langs->transnoentitiesnoconv(
'ChangeNeverContacted');
5331 } elseif ($numaction ==
'1' || $numaction ==
'ST_TODO') {
5333 $titlealt = $langs->transnoentitiesnoconv(
'ChangeToContact');
5334 } elseif ($numaction ==
'2' || $numaction ==
'ST_PEND') {
5336 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactInProcess');
5337 } elseif ($numaction ==
'3' || $numaction ==
'ST_DONE') {
5339 $titlealt = $langs->transnoentitiesnoconv(
'ChangeContactDone');
5341 $titlealt = $langs->transnoentitiesnoconv(
'ChangeStatus '.$numaction);
5345 if (!is_numeric($numaction)) {
5349 return img_picto($titlealt, (empty($picto) ?
'stcomm'.$numaction.
'.png' : $picto), $moreatt);
5359function img_pdf($titlealt =
'default', $size = 3)
5363 if ($titlealt ==
'default') {
5364 $titlealt = $langs->trans(
'Show');
5367 return img_picto($titlealt,
'pdf'.$size.
'.png');
5377function img_edit_add($titlealt =
'default', $other =
'')
5381 if ($titlealt ==
'default') {
5382 $titlealt = $langs->trans(
'Add');
5385 return img_picto($titlealt,
'edit_add.png', $other);
5398 if ($titlealt ==
'default') {
5399 $titlealt = $langs->trans(
'Remove');
5402 return img_picto($titlealt,
'edit_remove.png', $other);
5413function img_edit($titlealt =
'default', $float = 0, $other =
'')
5417 if ($titlealt ==
'default') {
5418 $titlealt = $langs->trans(
'Modify');
5421 return img_picto($titlealt,
'edit.png', ($float ?
'style="float: '.($langs->tab_translate[
"DIRECTION"] ==
'rtl' ?
'left' :
'right').
'"' :
"").($other ?
' '.$other :
''));
5432function img_view($titlealt =
'default', $float = 0, $other =
'class="valignmiddle"')
5436 if ($titlealt ==
'default') {
5437 $titlealt = $langs->trans(
'View');
5440 $moreatt = ($float ?
'style="float: right" ' :
'').$other;
5442 return img_picto($titlealt,
'eye', $moreatt);
5453function img_delete($titlealt =
'default', $other =
'class="pictodelete"', $morecss =
'')
5457 if ($titlealt ==
'default') {
5458 $titlealt = $langs->trans(
'Delete');
5461 return img_picto($titlealt,
'delete.png', $other, 0, 0, 0,
'', $morecss);
5471function img_printer($titlealt =
"default", $other =
'')
5474 if ($titlealt ==
"default") {
5475 $titlealt = $langs->trans(
"Print");
5477 return img_picto($titlealt,
'printer.png', $other);
5487function img_split($titlealt =
'default', $other =
'class="pictosplit"')
5491 if ($titlealt ==
'default') {
5492 $titlealt = $langs->trans(
'Split');
5495 return img_picto($titlealt,
'split.png', $other);
5505function img_help($usehelpcursor = 1, $usealttitle = 1)
5510 if (is_string($usealttitle)) {
5513 $usealttitle = $langs->trans(
'Info');
5517 return img_picto($usealttitle,
'info.png',
'style="vertical-align: middle;'.($usehelpcursor == 1 ?
' cursor: help' : ($usehelpcursor == 2 ?
' cursor: pointer' :
'')).
'"');
5526function img_info($titlealt =
'default')
5530 if ($titlealt ==
'default') {
5531 $titlealt = $langs->trans(
'Informations');
5534 return img_picto($titlealt,
'info.png',
'style="vertical-align: middle;"');
5545function img_warning($titlealt =
'default', $moreatt =
'', $morecss =
'pictowarning')
5549 if ($titlealt ==
'default') {
5550 $titlealt = $langs->trans(
'Warning');
5554 return img_picto($titlealt,
'warning.png',
'class="'.$morecss.
'"'.($moreatt ? ($moreatt ==
'1' ?
' style="float: right"' :
' '.$moreatt) :
''));
5563function img_error($titlealt =
'default')
5567 if ($titlealt ==
'default') {
5568 $titlealt = $langs->trans(
'Error');
5571 return img_picto($titlealt,
'error.png');
5581function img_next($titlealt =
'default', $moreatt =
'')
5585 if ($titlealt ==
'default') {
5586 $titlealt = $langs->trans(
'Next');
5590 return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
5600function img_previous($titlealt =
'default', $moreatt =
'')
5604 if ($titlealt ==
'default') {
5605 $titlealt = $langs->trans(
'Previous');
5609 return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).
'"></span>';
5620function img_down($titlealt =
'default', $selected = 0, $moreclass =
'')
5624 if ($titlealt ==
'default') {
5625 $titlealt = $langs->trans(
'Down');
5628 return img_picto($titlealt, ($selected ?
'1downarrow_selected.png' :
'1downarrow.png'),
'class="imgdown'.($moreclass ?
" ".$moreclass :
"").
'"');
5639function img_up($titlealt =
'default', $selected = 0, $moreclass =
'')
5643 if ($titlealt ==
'default') {
5644 $titlealt = $langs->trans(
'Up');
5647 return img_picto($titlealt, ($selected ?
'1uparrow_selected.png' :
'1uparrow.png'),
'class="imgup'.($moreclass ?
" ".$moreclass :
"").
'"');
5658function img_left($titlealt =
'default', $selected = 0, $moreatt =
'')
5662 if ($titlealt ==
'default') {
5663 $titlealt = $langs->trans(
'Left');
5666 return img_picto($titlealt, ($selected ?
'1leftarrow_selected.png' :
'1leftarrow.png'), $moreatt);
5677function img_right($titlealt =
'default', $selected = 0, $moreatt =
'')
5681 if ($titlealt ==
'default') {
5682 $titlealt = $langs->trans(
'Right');
5685 return img_picto($titlealt, ($selected ?
'1rightarrow_selected.png' :
'1rightarrow.png'), $moreatt);
5695function img_allow($allow, $titlealt =
'default')
5699 if ($titlealt ==
'default') {
5700 $titlealt = $langs->trans(
'Active');
5704 return img_picto($titlealt,
'tick.png');
5719 if (is_null($morecss)) {
5723 if ($brand ==
'visa' || $brand ==
'Visa') {
5725 } elseif ($brand ==
'mastercard' || $brand ==
'MasterCard') {
5726 $brand =
'cc-mastercard';
5727 } elseif ($brand ==
'amex' || $brand ==
'American Express') {
5729 } elseif ($brand ==
'discover' || $brand ==
'Discover') {
5730 $brand =
'cc-discover';
5731 } elseif ($brand ==
'jcb' || $brand ==
'JCB') {
5733 } elseif ($brand ==
'diners' || $brand ==
'Diners club') {
5734 $brand =
'cc-diners-club';
5735 } elseif (!in_array($brand, array(
'cc-visa',
'cc-mastercard',
'cc-amex',
'cc-discover',
'cc-jcb',
'cc-diners-club'))) {
5736 $brand =
'credit-card';
5739 return '<span class="fa fa-'.$brand.
' fa-fw'.($morecss ?
' '.$morecss :
'').
'"></span>';
5750function img_mime($file, $titlealt =
'', $morecss =
'')
5752 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
5758 if (empty($titlealt)) {
5759 $titlealt =
'Mime type: '.$mimetype;
5763 return '<i class="fa fa-'.$mimefa.
' paddingright'.($morecss ?
' '.$morecss :
'').
'"'.($titlealt ?
' title="'.$titlealt.
'"' :
'').
'></i>';
5774function img_search($titlealt =
'default', $other =
'')
5778 if ($titlealt ==
'default') {
5779 $titlealt = $langs->trans(
'Search');
5782 $img =
img_picto($titlealt,
'search.png', $other, 0, 1);
5784 $input =
'<input type="image" class="liste_titre" name="button_search" src="'.$img.
'" ';
5785 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
5801 if ($titlealt ==
'default') {
5802 $titlealt = $langs->trans(
'Search');
5805 $img =
img_picto($titlealt,
'searchclear.png', $other, 0, 1);
5807 $input =
'<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.
'" ';
5808 $input .=
'value="'.dol_escape_htmltag($titlealt).
'" title="'.
dol_escape_htmltag($titlealt).
'" >';
5825function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin =
'1', $morecss =
'hideonsmartphone', $textfordropdown =
'', $picto =
'')
5827 global $conf, $langs;
5829 if ($infoonimgalt) {
5830 $result =
img_picto($text,
'info',
'class="'.($morecss ?
' '.$morecss :
'').
'"');
5832 if (empty($conf->use_javascript_ajax)) {
5833 $textfordropdown =
'';
5836 $class = (empty($admin) ?
'undefined' : ($admin ==
'1' ?
'info' : $admin));
5837 $fa =
'info-circle';
5838 if ($picto ==
'warning') {
5839 $fa =
'exclamation-triangle';
5841 $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> ';
5843 $result .= ($nodiv ?
'' :
'</div>');
5845 if ($textfordropdown) {
5846 $tmpresult =
'<span class="'.$class.
'text opacitymedium cursorpointer">'.$langs->trans($textfordropdown).
' '.
img_picto($langs->trans($textfordropdown),
'1downarrow').
'</span>';
5847 $tmpresult .=
'<script nonce="'.getNonce().
'" type="text/javascript">
5848 jQuery(document).ready(function() {
5849 jQuery(".'.$class.
'text").click(function() {
5850 console.log("toggle text");
5851 jQuery(".'.$class.
'").toggle();
5856 $result = $tmpresult.$result;
5877 global $conf, $langs, $user, $argv;
5878 global $dolibarr_main_prod;
5885 require_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
5887 $langs->load(
"main");
5891 $langs->loadLangs(array(
'main',
'errors'));
5893 if ($_SERVER[
'DOCUMENT_ROOT']) {
5894 $out .= $langs->trans(
"DolibarrHasDetectedError").
".<br>\n";
5896 $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";
5898 $out .= $langs->trans(
"InformationToHelpDiagnose").
":<br>\n";
5900 $out .=
"<b>".$langs->trans(
"Date").
":</b> ".
dol_print_date(time(),
'dayhourlog').
"<br>\n";
5901 $out .=
"<b>".$langs->trans(
"Dolibarr").
":</b> ".DOL_VERSION.
" - https://www.dolibarr.org<br>\n";
5902 if (isset($conf->global->MAIN_FEATURES_LEVEL)) {
5903 $out .=
"<b>".$langs->trans(
"LevelOfFeature").
":</b> ".
getDolGlobalInt(
'MAIN_FEATURES_LEVEL').
"<br>\n";
5905 if ($user instanceof
User) {
5906 $out .=
"<b>".$langs->trans(
"Login").
":</b> ".$user->login.
"<br>\n";
5908 if (function_exists(
"phpversion")) {
5909 $out .=
"<b>".$langs->trans(
"PHP").
":</b> ".phpversion().
"<br>\n";
5911 $out .=
"<b>".$langs->trans(
"Server").
":</b> ".(isset($_SERVER[
"SERVER_SOFTWARE"]) ?
dol_htmlentities($_SERVER[
"SERVER_SOFTWARE"], ENT_COMPAT) :
'').
"<br>\n";
5912 if (function_exists(
"php_uname")) {
5913 $out .=
"<b>".$langs->trans(
"OS").
":</b> ".php_uname().
"<br>\n";
5915 $out .=
"<b>".$langs->trans(
"UserAgent").
":</b> ".(isset($_SERVER[
"HTTP_USER_AGENT"]) ?
dol_htmlentities($_SERVER[
"HTTP_USER_AGENT"], ENT_COMPAT) :
'').
"<br>\n";
5917 $out .=
"<b>".$langs->trans(
"RequestedUrl").
":</b> ".
dol_htmlentities($_SERVER[
"REQUEST_URI"], ENT_COMPAT).
"<br>\n";
5918 $out .=
"<b>".$langs->trans(
"Referer").
":</b> ".(isset($_SERVER[
"HTTP_REFERER"]) ?
dol_htmlentities($_SERVER[
"HTTP_REFERER"], ENT_COMPAT) :
'').
"<br>\n";
5919 $out .=
"<b>".$langs->trans(
"MenuManager").
":</b> ".(isset($conf->standard_menu) ?
dol_htmlentities($conf->standard_menu, ENT_COMPAT) :
'').
"<br>\n";
5921 $syslog .=
"url=".dol_escape_htmltag($_SERVER[
"REQUEST_URI"]);
5922 $syslog .=
", query_string=".dol_escape_htmltag($_SERVER[
"QUERY_STRING"]);
5924 $out .=
'> '.$langs->transnoentities(
"ErrorInternalErrorDetected").
":\n".$argv[0].
"\n";
5925 $syslog .=
"pid=".dol_getmypid();
5928 if (!empty($conf->modules)) {
5929 $out .=
"<b>".$langs->trans(
"Modules").
":</b> ".implode(
', ', $conf->modules).
"<br>\n";
5932 if (is_object($db)) {
5933 if ($_SERVER[
'DOCUMENT_ROOT']) {
5934 $out .=
"<b>".$langs->trans(
"DatabaseTypeManager").
":</b> ".$db->type.
"<br>\n";
5935 $lastqueryerror = $db->lastqueryerror();
5937 $lastqueryerror =
"SQL error string is not a valid UTF8 string. We can't show it.";
5939 $out .=
"<b>".$langs->trans(
"RequestLastAccessInError").
":</b> ".($lastqueryerror ?
dol_escape_htmltag($lastqueryerror) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5940 $out .=
"<b>".$langs->trans(
"ReturnCodeLastAccessInError").
":</b> ".($db->lasterrno() ?
dol_escape_htmltag($db->lasterrno()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5941 $out .=
"<b>".$langs->trans(
"InformationLastAccessInError").
":</b> ".($db->lasterror() ?
dol_escape_htmltag($db->lasterror()) : $langs->trans(
"ErrorNoRequestInError")).
"<br>\n";
5945 $out .=
'> '.$langs->transnoentities(
"DatabaseTypeManager").
":\n".$db->type.
"\n";
5946 $out .=
'> '.$langs->transnoentities(
"RequestLastAccessInError").
":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5947 $out .=
'> '.$langs->transnoentities(
"ReturnCodeLastAccessInError").
":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5948 $out .=
'> '.$langs->transnoentities(
"InformationLastAccessInError").
":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities(
"ErrorNoRequestInError")).
"\n";
5950 $syslog .=
", sql=".$db->lastquery();
5951 $syslog .=
", db_error=".$db->lasterror();
5954 if ($error || $errors) {
5956 if (is_array($error) && is_array($errors)) {
5957 $errors = array_merge($error, $errors);
5958 } elseif (is_array($error)) {
5960 } elseif (is_array($errors) && !empty($error)) {
5961 $errors = array_merge(array($error), $errors);
5962 } elseif (!empty($error)) {
5963 $errors = array_merge(array($error), array($errors));
5966 $langs->load(
"errors");
5968 foreach ($errors as $msg) {
5972 if ($_SERVER[
'DOCUMENT_ROOT']) {
5975 $out .=
'> '.$langs->transnoentities(
"Message").
":\n".$msg.
"\n";
5977 $syslog .=
", msg=".$msg;
5980 if (empty($dolibarr_main_prod) && $_SERVER[
'DOCUMENT_ROOT'] && function_exists(
'xdebug_print_function_stack') && function_exists(
'xdebug_call_file')) {
5981 xdebug_print_function_stack();
5982 $out .=
'<b>XDebug information:</b>'.
"<br>\n";
5983 $out .=
'File: '.xdebug_call_file().
"<br>\n";
5984 $out .=
'Line: '.xdebug_call_line().
"<br>\n";
5985 $out .=
'Function: '.xdebug_call_function().
"<br>\n";
5990 if (!headers_sent()) {
5991 if (function_exists(
'top_httphead')) {
5995 http_response_code(202);
5998 if (empty($dolibarr_main_prod)) {
6001 if (empty($langs->defaultlang)) {
6002 $langs->setDefaultLang();
6004 $langs->loadLangs(array(
"main",
"errors"));
6006 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";
6007 print $langs->trans(
"DolibarrHasDetectedError").
'. ';
6008 print $langs->trans(
"YouCanSetOptionDolibarrMainProdToZero");
6009 if (!defined(
"MAIN_CORE_ERROR")) {
6010 define(
"MAIN_CORE_ERROR", 1);
6027function dol_print_error_email($prefixcode, $errormessage =
'', $errormessages = array(), $morecss =
'error', $email =
'')
6031 if (empty($email)) {
6035 $langs->load(
"errors");
6038 print
'<br><div class="center login_main_message"><div class="'.$morecss.
'">';
6039 print $langs->trans(
"ErrorContactEMail", $email, $prefixcode.
'-'.
dol_print_date($now,
'%Y%m%d%H%M%S'));
6040 if ($errormessage) {
6041 print
'<br><br>'.$errormessage;
6043 if (is_array($errormessages) && count($errormessages)) {
6044 foreach ($errormessages as $mesgtoshow) {
6045 print
'<br><br>'.$mesgtoshow;
6048 print
'</div></div>';
6067function print_liste_field_titre($name, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $tooltip =
"", $forcenowrapcolumntitle = 0)
6069 print
getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $moreattrib, $sortfield, $sortorder, $prefix, 0, $tooltip, $forcenowrapcolumntitle);
6090function getTitleFieldOfList($name, $thead = 0, $file =
"", $field =
"", $begin =
"", $moreparam =
"", $moreattrib =
"", $sortfield =
"", $sortorder =
"", $prefix =
"", $disablesortlink = 0, $tooltip =
'', $forcenowrapcolumntitle = 0)
6092 global $langs, $form;
6095 if ($moreattrib ==
'class="right"') {
6096 $prefix .=
'right ';
6099 $sortorder = strtoupper($sortorder);
6108 $tmpsortfield = explode(
',', $sortfield);
6109 $sortfield1 = trim($tmpsortfield[0]);
6110 $tmpfield = explode(
',', $field);
6111 $field1 = trim($tmpfield[0]);
6113 if (!
getDolGlobalString(
'MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE') && empty($forcenowrapcolumntitle)) {
6114 $prefix =
'wrapcolumntitle '.$prefix;
6120 $liste_titre =
'liste_titre';
6121 if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace(
"/^[^\.]+\./",
"", $field1))) {
6122 $liste_titre =
'liste_titre_sel';
6125 $tagstart =
'<'.$tag.
' class="'.$prefix.$liste_titre.
'" '.$moreattrib;
6130 if (empty($thead) && $field && empty($disablesortlink)) {
6131 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6132 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6133 $options = preg_replace(
'/&+/i',
'&', $options);
6134 if (!preg_match(
'/^&/', $options)) {
6135 $options =
'&'.$options;
6138 $sortordertouseinlink =
'';
6139 if ($field1 != $sortfield1) {
6140 if (preg_match(
'/^DESC/i', $sortorder)) {
6141 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6143 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6146 if (preg_match(
'/^ASC/i', $sortorder)) {
6147 $sortordertouseinlink .= str_repeat(
'desc,', count(explode(
',', $field)));
6149 $sortordertouseinlink .= str_repeat(
'asc,', count(explode(
',', $field)));
6152 $sortordertouseinlink = preg_replace(
'/,$/',
'', $sortordertouseinlink);
6153 $out .=
'<a class="reposition" href="'.$file.
'?sortfield='.$field.
'&sortorder='.$sortordertouseinlink.
'&begin='.$begin.$options.
'"';
6159 if (preg_match(
'/:\w+$/', $tooltip)) {
6160 $tmptooltip = explode(
':', $tooltip);
6162 $tmptooltip = array($tooltip);
6164 $out .= $form->textwithpicto($langs->trans($name), $langs->trans($tmptooltip[0]), 1,
'help',
'', 0, 3, (empty($tmptooltip[1]) ?
'' :
'extra_'.str_replace(
'.',
'_', $field).
'_'.$tmptooltip[1]));
6166 $out .= $langs->trans($name);
6169 if (empty($thead) && $field && empty($disablesortlink)) {
6173 if (empty($thead) && $field) {
6174 $options = preg_replace(
'/sortfield=([a-zA-Z0-9,\s\.]+)/i',
'', (is_scalar($moreparam) ? $moreparam :
''));
6175 $options = preg_replace(
'/sortorder=([a-zA-Z0-9,\s\.]+)/i',
'', $options);
6176 $options = preg_replace(
'/&+/i',
'&', $options);
6177 if (!preg_match(
'/^&/', $options)) {
6178 $options =
'&'.$options;
6181 if (!$sortorder || ($field1 != $sortfield1)) {
6185 if (preg_match(
'/^DESC/', $sortorder)) {
6188 $sortimg .=
'<span class="nowrap">'.img_up(
"Z-A", 0,
'paddingright').
'</span>';
6190 if (preg_match(
'/^ASC/', $sortorder)) {
6193 $sortimg .=
'<span class="nowrap">'.img_down(
"A-Z", 0,
'paddingright').
'</span>';
6198 $tagend =
'</'.$tag.
'>';
6200 $out = $tagstart.$sortimg.$out.$tagend;
6215 dol_syslog(__FUNCTION__.
" is deprecated", LOG_WARNING);
6217 print
'<div class="titre">'.$title.
'</div>';
6231function print_fiche_titre($title, $mesg =
'', $picto =
'generic', $pictoisfullpath = 0, $id =
'')
6249function load_fiche_titre($title, $morehtmlright =
'', $picto =
'generic', $pictoisfullpath = 0, $id =
'', $morecssontable =
'', $morehtmlcenter =
'')
6253 if ($picto ==
'setup') {
6258 $return .=
'<table '.($id ?
'id="'.$id.
'" ' :
'').
'class="centpercent notopnoleftnoright table-fiche-title'.($morecssontable ?
' '.$morecssontable :
'').
'">';
6259 $return .=
'<tr class="titre">';
6261 $return .=
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).
'</td>';
6263 $return .=
'<td class="nobordernopadding valignmiddle col-title">';
6264 $return .=
'<div class="titre inline-block">';
6266 $return .=
'</div>';
6269 $return .=
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
6272 $return .=
'<td class="nobordernopadding titre_right wordbreakimp right valignmiddle col-right">'.$morehtmlright.
'</td>';
6274 $return .=
'</tr></table>'.
"\n";
6302function 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 =
'')
6307 $savtotalnboflines = $totalnboflines;
6308 if (is_numeric($totalnboflines)) {
6309 $totalnboflines = abs($totalnboflines);
6312 $page = (int) $page;
6314 if ($picto ==
'setup') {
6315 $picto =
'title_setup.png';
6317 if (($conf->browser->name ==
'ie') && $picto ==
'generic') {
6318 $picto =
'title.gif';
6321 $limit = $conf->liste_limit;
6324 if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
6332 print
"<!-- Begin title -->\n";
6333 print
'<table class="centpercent notopnoleftnoright table-fiche-title'.($morecss ?
' '.$morecss :
'').
'"><tr>';
6337 if ($picto && $title) {
6338 print
'<td class="nobordernopadding widthpictotitle valignmiddle col-picto">'.img_picto(
'', $picto,
'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath).
'</td>';
6341 print
'<td class="nobordernopadding valignmiddle col-title">';
6342 print
'<div class="titre inline-block">';
6344 if (!empty($title) && $savtotalnboflines >= 0 && (
string) $savtotalnboflines !=
'') {
6345 print
'<span class="opacitymedium colorblack paddingleft totalnboflines">('.$totalnboflines.
')</span>';
6347 print
'</div></td>';
6350 if ($morehtmlcenter && empty($conf->dol_optimize_smallscreen)) {
6351 print
'<td class="nobordernopadding center valignmiddle col-center">'.$morehtmlcenter.
'</td>';
6355 print
'<td class="nobordernopadding valignmiddle right col-right">';
6356 print
'<input type="hidden" name="pageplusoneold" value="'.((int) $page + 1).
'">';
6358 $options .=
"&sortfield=".urlencode($sortfield);
6361 $options .=
"&sortorder=".urlencode($sortorder);
6365 if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
6366 if ($totalnboflines) {
6368 $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 0);
6371 $nbpages = ceil($totalnboflines / $limit);
6375 $cpt = ($page - $maxnbofpage);
6381 if (empty($pagenavastextinput)) {
6382 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page=0'.$options.
'">1</a></li>';
6384 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
6385 } elseif ($cpt == 2) {
6386 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page=1'.$options.
'">2</a></li>';
6392 if ($pagenavastextinput) {
6393 if ($cpt == $page) {
6394 $pagelist .=
'<li class="pagination pageplusone valignmiddle"><input type="text" class="'.($totalnboflines > 100 ?
'width40' :
'width25').
' center pageplusone" name="pageplusone" value="'.($page + 1).
'"></li>';
6398 if ($cpt == $page) {
6399 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
'</span></li>';
6401 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.$cpt.$options.
'">'.($cpt + 1).
'</a></li>';
6405 }
while ($cpt < $nbpages && $cpt <= ($page + $maxnbofpage));
6407 if (empty($pagenavastextinput)) {
6408 if ($cpt < $nbpages) {
6409 if ($cpt < $nbpages - 2) {
6410 $pagelist .=
'<li class="pagination"><span class="inactive">...</span></li>';
6411 } elseif ($cpt == $nbpages - 2) {
6412 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.($nbpages - 2).$options.
'">'.($nbpages - 1).
'</a></li>';
6414 $pagelist .=
'<li class="pagination"><a class="reposition" href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
6418 $pagelist .=
'<li class="pagination paginationlastpage"><a class="reposition" href="'.$file.
'?page='.($nbpages - 1).$options.
'">'.$nbpages.
'</a></li>';
6421 $pagelist .=
'<li class="pagination"><span class="active">'.($page + 1).
"</li>";
6425 if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
6426 print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow, $hidenavigation);
6430 if ($pagenavastextinput) {
6437 print
'</table>'.
"\n";
6440 if ($morehtmlcenter && !empty($conf->dol_optimize_smallscreen)) {
6441 print
'<div class="nobordernopadding marginbottomonly center valignmiddle col-center centpercent">'.$morehtmlcenter.
'</div>';
6444 print
"<!-- End title -->\n\n";
6463function print_fleche_navigation($page, $file, $options =
'', $nextpage = 0, $betweenarrows =
'', $afterarrows =
'', $limit = -1, $totalnboflines = 0, $hideselectlimit = 0, $beforearrows =
'', $hidenavigation = 0)
6465 global $conf, $langs;
6467 print
'<div class="pagination"><ul>';
6468 if ($beforearrows) {
6469 print
'<li class="paginationbeforearrows">';
6470 print $beforearrows;
6474 if (empty($hidenavigation)) {
6475 if ((
int) $limit > 0 && empty($hideselectlimit)) {
6476 $pagesizechoices =
'10:10,15:15,20:20,25:25,50:50,100:100,250:250,500:500,1000:1000';
6477 $pagesizechoices .=
',5000:5000,10000:10000';
6486 print
'<li class="pagination">';
6487 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.
'">';
6488 print
'<datalist id="limitlist">';
6490 print
'<li class="paginationcombolimit valignmiddle">';
6491 print
'<select id="limit" class="flat selectlimit nopadding maxwidth75 center" name="limit" title="'.dol_escape_htmltag($langs->trans(
"MaxNbOfRecordPerPage")).
'">';
6493 $tmpchoice = explode(
',', $pagesizechoices);
6494 $tmpkey = $limit.
':'.$limit;
6495 if (!in_array($tmpkey, $tmpchoice)) {
6496 $tmpchoice[] = $tmpkey;
6498 $tmpkey = $conf->liste_limit.
':'.$conf->liste_limit;
6499 if (!in_array($tmpkey, $tmpchoice)) {
6500 $tmpchoice[] = $tmpkey;
6502 asort($tmpchoice, SORT_NUMERIC);
6503 foreach ($tmpchoice as $val) {
6505 $tmp = explode(
':', $val);
6508 if ($key !=
'' && $val !=
'') {
6509 if ((
int) $key == (
int) $limit) {
6510 $selected =
' selected="selected"';
6512 print
'<option name="'.$key.
'"'.$selected.
'>'.
dol_escape_htmltag($val).
'</option>'.
"\n";
6516 print
'</datalist>';
6519 print
ajax_combobox(
"limit", array(), 0, 0,
'resolve', -1,
'limit');
6523 if ($conf->use_javascript_ajax) {
6524 print
'<!-- JS CODE TO ENABLE select limit to launch submit of page -->
6526 jQuery(document).ready(function () {
6527 jQuery(".selectlimit").change(function() {
6528 console.log("Change limit. Send submit");
6529 $(this).parents(\'form:first\').submit();
6538 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>';
6540 if ($betweenarrows) {
6541 print
'<!--<div class="betweenarrows nowraponall inline-block">-->';
6542 print $betweenarrows;
6543 print
'<!--</div>-->';
6545 if ($nextpage > 0) {
6546 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>';
6549 print
'<li class="paginationafterarrows">';
6554 print
'</ul></div>'.
"\n";
6569function vatrate($rate, $addpercent =
false, $info_bits = 0, $usestarfornpr = 0, $html = 0)
6573 if (preg_match(
'/%/', $rate)) {
6574 $rate = str_replace(
'%',
'', $rate);
6578 if (preg_match(
'/\((.*)\)/', $rate, $reg)) {
6579 $morelabel =
' ('.$reg[1].
')';
6580 $rate = preg_replace(
'/\s*'.preg_quote($morelabel,
'/').
'/',
'', $rate);
6581 $morelabel =
' '.($html ?
'<span class="opacitymedium">' :
'').
'('.$reg[1].
')'.($html ?
'</span>' :
'');
6583 if (preg_match(
'/\*/', $rate)) {
6584 $rate = str_replace(
'*',
'', $rate);
6589 if (!preg_match(
'/\//', $rate)) {
6590 $ret =
price($rate, 0,
'', 0, 0).($addpercent ?
'%' :
'');
6593 $ret = $rate.($addpercent ?
'%' :
'');
6595 if (($info_bits & 1) && $usestarfornpr >= 0) {
6618function price($amount, $form = 0, $outlangs =
'', $trunc = 1, $rounding = -1, $forcerounding = -1, $currency_code =
'')
6620 global $langs, $conf;
6623 if (empty($amount)) {
6626 $amount = (is_numeric($amount) ? $amount : 0);
6627 if ($rounding == -1) {
6630 $nbdecimal = $rounding;
6632 if ($outlangs ===
'none') {
6642 if (!($outlangs instanceof
Translate)) {
6646 if ($outlangs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
6647 $dec = $outlangs->transnoentitiesnoconv(
"SeparatorDecimal");
6649 if ($outlangs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
6650 $thousand = $outlangs->transnoentitiesnoconv(
"SeparatorThousand");
6652 if ($thousand ==
'None') {
6654 } elseif ($thousand ==
'Space') {
6661 $amount = str_replace(
',',
'.', $amount);
6663 $data = explode(
'.', $amount);
6664 $decpart = isset($data[1]) ? $data[1] :
'';
6665 $decpart = preg_replace(
'/0+$/i',
'', $decpart);
6675 $nbdecimalmaxshown = (int) str_replace(
'...',
'',
getDolGlobalString(
'MAIN_MAX_DECIMALS_SHOWN'));
6676 if ($trunc && $nbdecimal > $nbdecimalmaxshown) {
6677 $nbdecimal = $nbdecimalmaxshown;
6685 if ((
string) $forcerounding !=
'-1') {
6686 if ($forcerounding ===
'MU') {
6688 } elseif ($forcerounding ===
'MT') {
6690 } elseif ($forcerounding >= 0) {
6691 $nbdecimal = $forcerounding;
6696 $output = number_format((
float) $amount, $nbdecimal, $dec, $thousand);
6698 $output = preg_replace(
'/\s/',
' ', $output);
6699 $output = preg_replace(
'/\'/',
''', $output);
6702 $cursymbolbefore = $cursymbolafter =
'';
6703 if ($currency_code && is_object($outlangs)) {
6704 if ($currency_code ==
'auto') {
6705 $currency_code = $conf->currency;
6708 $listofcurrenciesbefore = array(
'AUD',
'CAD',
'CNY',
'COP',
'CLP',
'GBP',
'HKD',
'MXN',
'PEN',
'USD',
'CRC',
'ZAR');
6709 $listoflanguagesbefore = array(
'nl_NL');
6710 if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) {
6711 $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
6713 $tmpcur = $outlangs->getCurrencySymbol($currency_code);
6714 $cursymbolafter .= ($tmpcur == $currency_code ?
' '.$tmpcur : $tmpcur);
6717 $output = $cursymbolbefore.$output.$end.($cursymbolafter ?
' ' :
'').$cursymbolafter;
6746function price2num($amount, $rounding =
'', $option = 0)
6748 global $langs, $conf;
6751 if (is_null($amount)) {
6760 if (is_null($langs)) {
6764 if ($langs->transnoentitiesnoconv(
"SeparatorDecimal") !=
"SeparatorDecimal") {
6765 $dec = $langs->transnoentitiesnoconv(
"SeparatorDecimal");
6767 if ($langs->transnoentitiesnoconv(
"SeparatorThousand") !=
"SeparatorThousand") {
6768 $thousand = $langs->transnoentitiesnoconv(
"SeparatorThousand");
6771 if ($thousand ==
'None') {
6773 } elseif ($thousand ==
'Space') {
6781 if (!is_numeric($amount)) {
6782 $amount = preg_replace(
'/[a-zA-Z\/\\\*\(\)<>\_]/',
'', $amount);
6785 if ($option == 2 && $thousand ==
'.' && preg_match(
'/\.(\d\d\d)$/', (
string) $amount)) {
6786 $amount = str_replace($thousand,
'', $amount);
6792 if (is_numeric($amount)) {
6794 $temps = sprintf(
"%10.10F", $amount - intval($amount));
6795 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
6797 $amount = number_format($amount, $nbofdec, $dec, $thousand);
6802 if ($thousand !=
',' && $thousand !=
'.') {
6803 $amount = str_replace(
',',
'.', $amount);
6806 $amount = str_replace(
' ',
'', $amount);
6807 $amount = str_replace($thousand,
'', $amount);
6808 $amount = str_replace($dec,
'.', $amount);
6810 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
6816 $nbofdectoround =
'';
6817 if ($rounding ==
'MU') {
6819 } elseif ($rounding ==
'MT') {
6821 } elseif ($rounding ==
'MS') {
6822 $nbofdectoround = isset($conf->global->MAIN_MAX_DECIMALS_STOCK) ? $conf->global->MAIN_MAX_DECIMALS_STOCK : 5;
6823 } elseif ($rounding ==
'CU') {
6825 } elseif ($rounding ==
'CT') {
6827 } elseif (is_numeric($rounding)) {
6828 $nbofdectoround = (int) $rounding;
6833 $amount = round(is_string($amount) ? (
float) $amount : $amount, $nbofdectoround);
6835 return 'ErrorBadParameterProvidedToFunction';
6841 if (is_numeric($amount)) {
6843 $temps = sprintf(
"%10.10F", $amount - intval($amount));
6844 $temps = preg_replace(
'/([\.1-9])0+$/',
'\\1', $temps);
6846 $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand);
6852 if ($thousand !=
',' && $thousand !=
'.') {
6853 $amount = str_replace(
',',
'.', $amount);
6856 $amount = str_replace(
' ',
'', $amount);
6857 $amount = str_replace($thousand,
'', $amount);
6858 $amount = str_replace($dec,
'.', $amount);
6860 $amount = preg_replace(
'/[^0-9\-\.]/',
'', $amount);
6878function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput =
'no', $use_short_label = 0)
6880 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
6882 if (($forceunitoutput ==
'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
6883 $dimension *= 1000000;
6885 } elseif (($forceunitoutput ==
'no' && $dimension < 1 / 10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) {
6888 } elseif (($forceunitoutput ==
'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) {
6889 $dimension /= 1000000;
6891 } elseif (($forceunitoutput ==
'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) {
6908 $ret =
price($dimension, 0, $outputlangs, 0, 0, $round);
6910 $ret .=
' '.measuringUnitString(0, $type, $unit, $use_short_label, $outputlangs);
6928function get_localtax($vatrate, $local, $thirdparty_buyer =
null, $thirdparty_seller =
null, $vatnpr = 0)
6930 global $db, $conf, $mysoc;
6932 if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) {
6933 $thirdparty_seller = $mysoc;
6936 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);
6938 $vatratecleaned = $vatrate;
6940 if (preg_match(
'/^(.*)\s*\((.*)\)$/', (
string) $vatrate, $reg)) {
6941 $vatratecleaned = trim($reg[1]);
6942 $vatratecode = $reg[2];
6951 if ($mysoc->country_code ==
'ES') {
6953 if (!$mysoc->localtax1_assuj || (
string) $vatratecleaned ==
"0") {
6956 if ($thirdparty_seller->id == $mysoc->id) {
6957 if (!$thirdparty_buyer->localtax1_assuj) {
6961 if (!$thirdparty_seller->localtax1_assuj) {
6969 if (!$mysoc->localtax2_assuj) {
6972 if ($thirdparty_seller->id == $mysoc->id) {
6973 if (!$thirdparty_buyer->localtax2_assuj) {
6977 if (!$thirdparty_seller->localtax2_assuj) {
6983 if ($local == 1 && !$thirdparty_seller->localtax1_assuj) {
6986 if ($local == 2 && !$thirdparty_seller->localtax2_assuj) {
6992 if (in_array($mysoc->country_code, array(
'ES'))) {
6993 $conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY = 1;
6999 if ($thirdparty_seller != $mysoc) {
7001 return $thirdparty_seller->localtax1_value;
7005 return $conf->global->MAIN_INFO_VALUE_LOCALTAX1;
7010 if ($thirdparty_seller != $mysoc) {
7013 return $thirdparty_seller->localtax2_value;
7016 if (in_array($mysoc->country_code, array(
'ES'))) {
7017 return $thirdparty_buyer->localtax2_value;
7019 return $conf->global->MAIN_INFO_VALUE_LOCALTAX2;
7026 $sql =
"SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
7027 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7028 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdparty_seller->country_code).
"'";
7029 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7030 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7031 if (!empty($vatratecode)) {
7032 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
7034 $sql .=
" AND t.recuperableonly = '".$db->escape($vatnpr).
"'";
7037 $resql = $db->query($sql);
7040 $obj = $db->fetch_object($resql);
7043 return $obj->localtax1;
7044 } elseif ($local == 2) {
7045 return $obj->localtax2;
7066 $valors = explode(
":", $tax);
7068 if (count($valors) > 1) {
7085 $sql =
" SELECT t.localtax".$local.
" as localtax";
7086 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t INNER JOIN ".MAIN_DB_PREFIX.
"c_country as c ON c.rowid = t.fk_pays";
7087 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.active = 1 AND t.entity IN (".
getEntity(
'c_tva').
") AND t.taux = (";
7088 $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";
7089 $sql .=
" WHERE c.code = '".$db->escape($mysoc->country_code).
"' AND t.entity IN (".
getEntity(
'c_tva').
") AND tt.active = 1)";
7090 $sql .=
" AND t.localtax".$local.
"_type <> '0'";
7091 $sql .=
" ORDER BY t.rowid DESC";
7093 $resql = $db->query($sql);
7095 $obj = $db->fetch_object($resql);
7097 return $obj->localtax;
7118function getTaxesFromId($vatrate, $buyer =
null, $seller =
null, $firstparamisid = 1)
7122 dol_syslog(
"getTaxesFromId vat id or rate = ".$vatrate);
7125 $sql =
"SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy,";
7126 $sql .=
" t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
7127 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
7128 if ($firstparamisid) {
7129 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
7131 $vatratecleaned = $vatrate;
7134 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
7135 $vatratecleaned = $reg[1];
7136 $vatratecode = $reg[2];
7139 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
7142 $sql .=
" WHERE t.fk_pays = c.rowid";
7144 $sql .=
" AND c.code = '".$db->escape($buyer->country_code).
"'";
7146 $sql .=
" AND c.code = '".$db->escape($seller->country_code).
"'";
7148 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7149 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7151 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
7155 $resql = $db->query($sql);
7157 $obj = $db->fetch_object($resql);
7160 'rowid' => $obj->rowid,
7161 'code' => $obj->code,
7162 'rate' => $obj->rate,
7163 'localtax1' => $obj->localtax1,
7164 'localtax1_type' => $obj->localtax1_type,
7165 'localtax2' => $obj->localtax2,
7166 'localtax2_type' => $obj->localtax2_type,
7168 'accountancy_code_sell' => $obj->accountancy_code_sell,
7169 'accountancy_code_buy' => $obj->accountancy_code_buy
7201 dol_syslog(
"getLocalTaxesFromRate vatrate=".$vatrate.
" local=".$local);
7204 $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";
7205 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t";
7206 if ($firstparamisid) {
7207 $sql .=
" WHERE t.rowid = ".(int) $vatrate;
7209 $vatratecleaned = $vatrate;
7212 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {
7213 $vatratecleaned = $reg[1];
7214 $vatratecode = $reg[2];
7217 $sql .=
", ".MAIN_DB_PREFIX.
"c_country as c";
7218 if (!empty($mysoc) && $mysoc->country_code ==
'ES') {
7219 $countrycodetouse = ((empty($buyer) || empty($buyer->country_code)) ? $mysoc->country_code : $buyer->country_code);
7220 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
7222 $countrycodetouse = ((empty($seller) || empty($seller->country_code)) ? $mysoc->country_code : $seller->country_code);
7223 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse).
"'";
7225 $sql .=
" AND t.taux = ".((float) $vatratecleaned).
" AND t.active = 1";
7227 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
7231 $resql = $db->query($sql);
7233 $obj = $db->fetch_object($resql);
7236 $vateratestring = $obj->rate.($obj->code ?
' ('.$obj->code.
')' :
'');
7239 return array($obj->localtax1_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
7240 } elseif ($local == 2) {
7241 return array($obj->localtax2_type,
get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy);
7243 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);
7265 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
7273 $product->fetch($idprod);
7275 if (($mysoc->country_code == $thirdpartytouse->country_code)
7276 || (in_array($mysoc->country_code, array(
'FR',
'MC')) && in_array($thirdpartytouse->country_code, array(
'FR',
'MC')))
7277 || (in_array($mysoc->country_code, array(
'MQ',
'GP')) && in_array($thirdpartytouse->country_code, array(
'MQ',
'GP')))
7280 if ($idprodfournprice > 0) {
7281 $result = $product->get_buyprice($idprodfournprice, 0, 0, 0);
7283 $ret = $product->vatrate_supplier;
7284 if ($product->default_vat_code_supplier) {
7285 $ret .=
' ('.$product->default_vat_code_supplier.
')';
7291 $ret = $product->tva_tx;
7292 if ($product->default_vat_code) {
7293 $ret .=
' ('.$product->default_vat_code.
')';
7306 $sql =
"SELECT t.taux as vat_rate, t.code as default_vat_code";
7307 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7308 $sql .=
" WHERE t.active = 1 AND t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdpartytouse->country_code).
"'";
7309 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7310 $sql .=
" ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC";
7311 $sql .= $db->plimit(1);
7313 $resql = $db->query($sql);
7315 $obj = $db->fetch_object($resql);
7317 $ret = $obj->vat_rate;
7318 if ($obj->default_vat_code) {
7319 $ret .=
' ('.$obj->default_vat_code.
')';
7343 dol_syslog(
"get_product_vat_for_country: ret=".$ret);
7360 if (!class_exists(
'Product')) {
7361 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
7370 $result = $product->fetch($idprod);
7372 if ($mysoc->country_code == $thirdpartytouse->country_code) {
7386 $sql =
"SELECT taux as vat_rate, localtax1, localtax2";
7387 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
7388 $sql .=
" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdpartytouse->country_code).
"'";
7389 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7390 $sql .=
" ORDER BY t.taux DESC, t.recuperableonly ASC";
7391 $sql .= $db->plimit(1);
7393 $resql = $db->query($sql);
7395 $obj = $db->fetch_object($resql);
7398 $ret = $obj->localtax1;
7399 } elseif ($local == 2) {
7400 $ret = $obj->localtax2;
7408 dol_syslog(
"get_product_localtax_for_country: ret=".$ret);
7432 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
7435 $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;
7437 $seller_country_code = $thirdparty_seller->country_code;
7438 $seller_in_cee =
isInEEC($thirdparty_seller);
7440 $buyer_country_code = $thirdparty_buyer->country_code;
7441 $buyer_in_cee =
isInEEC($thirdparty_buyer);
7443 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 :
''));
7448 if ($seller_in_cee && $buyer_in_cee) {
7449 $isacompany = $thirdparty_buyer->isACompany();
7450 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
7451 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
7465 if (!$seller_use_vat) {
7471 if (($seller_country_code == $buyer_country_code)
7472 || (in_array($seller_country_code, array(
'FR',
'MC')) && in_array($buyer_country_code, array(
'FR',
'MC')))
7473 || (in_array($seller_country_code, array(
'MQ',
'GP')) && in_array($buyer_country_code, array(
'MQ',
'GP')))
7478 if ($seller_country_code ==
'IN' &&
getDolGlobalString(
'MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA')) {
7482 if (preg_match(
'/C+S-(\d+)/', $tmpvat, $reg) && $thirdparty_seller->state_id != $thirdparty_buyer->state_id) {
7484 $tmpvat = str_replace(
"C+S",
"I", $tmpvat);
7485 } elseif (preg_match(
'/I-(\d+)/', $tmpvat, $reg) && $thirdparty_seller->state_id == $thirdparty_buyer->state_id) {
7487 $tmpvat = str_replace(
"I",
"C+S", $tmpvat);
7499 if (($seller_in_cee && $buyer_in_cee)) {
7500 $isacompany = $thirdparty_buyer->isACompany();
7501 if ($isacompany &&
getDolGlobalString(
'MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
7502 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
7519 if (
getDolGlobalString(
'MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC') && empty($buyer_in_cee)) {
7520 $isacompany = $thirdparty_buyer->isACompany();
7548 if ($idprodfournprice > 0) {
7549 if (!class_exists(
'ProductFournisseur')) {
7550 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
7553 $prodprice->fetch_product_fournisseur_price($idprodfournprice);
7554 return $prodprice->fourn_tva_npr;
7555 } elseif ($idprod > 0) {
7556 if (!class_exists(
'Product')) {
7557 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
7560 $prod->fetch($idprod);
7561 return $prod->tva_npr;
7584 if (!is_object($thirdparty_seller)) {
7587 if (!is_object($thirdparty_buyer)) {
7592 if ($mysoc->country_code ==
'ES') {
7593 if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) {
7598 if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) {
7601 if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj ==
'localtax1off') {
7605 } elseif ($local == 2) {
7607 if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) {
7610 if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj ==
'localtax2off') {
7615 if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
7630function yn($yesno, $case = 1, $color = 0)
7634 $result =
'unknown';
7636 if ($yesno == 1 || (isset($yesno) && (strtolower($yesno) ==
'yes' || strtolower($yesno) ==
'true'))) {
7637 $result = $langs->trans(
'yes');
7638 if ($case == 1 || $case == 3) {
7639 $result = $langs->trans(
"Yes");
7642 $result =
'<input type="checkbox" value="1" checked disabled>';
7645 $result =
'<input type="checkbox" value="1" checked disabled> '.$result;
7652 } elseif ($yesno == 0 || strtolower($yesno) ==
'no' || strtolower($yesno) ==
'false') {
7653 $result = $langs->trans(
"no");
7654 if ($case == 1 || $case == 3) {
7655 $result = $langs->trans(
"No");
7658 $result =
'<input type="checkbox" value="0" disabled>';
7661 $result =
'<input type="checkbox" value="0" disabled> '.$result;
7664 $result =
img_picto(
'uncheck',
'uncheck');
7670 $classname =
'error';
7674 return '<span class="'.$classname.
'">'.$result.
'</span>';
7697function get_exdir($num, $level, $alpha, $withoutslash,
$object, $modulepart =
'')
7699 if (empty($modulepart) && is_object(
$object)) {
7700 if (!empty(
$object->module)) {
7701 $modulepart =
$object->module;
7702 } elseif (!empty(
$object->element)) {
7703 $modulepart =
$object->element;
7710 $arrayforoldpath = array(
'cheque' => 2,
'category' => 2,
'holiday' => 2,
'supplier_invoice' => 2,
'invoice_supplier' => 2,
'mailing' => 2,
'supplier_payment' => 2);
7712 $arrayforoldpath[
'product'] = 2;
7715 if (empty($level) && array_key_exists($modulepart, $arrayforoldpath)) {
7716 $level = $arrayforoldpath[$modulepart];
7718 if (!empty($level) && array_key_exists($modulepart, $arrayforoldpath)) {
7720 if (empty($num) && is_object(
$object)) {
7723 if (empty($alpha)) {
7724 $num = preg_replace(
'/([^0-9])/i',
'', $num);
7726 $num = preg_replace(
'/^.*\-/i',
'', $num);
7728 $num = substr(
"000".$num, -$level);
7730 $path = substr($num, 0, 1);
7733 $path = substr($num, 1, 1).
'/'.substr($num, 0, 1);
7736 $path = substr($num, 2, 1).
'/'.substr($num, 1, 1).
'/'.substr($num, 0, 1);
7742 if (in_array($modulepart, array(
'societe',
'thirdparty')) &&
$object instanceOf
Societe) {
7750 if (empty($withoutslash) && !empty($path)) {
7765function dol_mkdir($dir, $dataroot =
'', $newmask =
'')
7769 dol_syslog(
"functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
7772 if (@is_dir($dir_osencoded)) {
7780 if (!empty($dataroot)) {
7782 $dir = str_replace($dataroot.
'/',
'', $dir);
7783 $ccdir = $dataroot.
'/';
7786 $cdir = explode(
"/", $dir);
7787 $num = count($cdir);
7788 for ($i = 0; $i < $num; $i++) {
7790 $ccdir .=
'/'.$cdir[$i];
7792 $ccdir .= $cdir[$i];
7795 if (preg_match(
"/^.:$/", $ccdir, $regs)) {
7803 if (!@is_dir($ccdir_osencoded)) {
7804 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG);
7807 $dirmaskdec = octdec((
string) $newmask);
7808 if (empty($newmask)) {
7809 $dirmaskdec = !
getDolGlobalString(
'MAIN_UMASK') ? octdec(
'0755') : octdec($conf->global->MAIN_UMASK);
7811 $dirmaskdec |= octdec(
'0111');
7812 if (!@mkdir($ccdir_osencoded, $dirmaskdec)) {
7814 dol_syslog(
"functions.lib::dol_mkdir: Fails to create directory '".$ccdir.
"' or directory already exists.", LOG_WARNING);
7817 dol_syslog(
"functions.lib::dol_mkdir: Directory '".$ccdir.
"' created", LOG_DEBUG);
7826 return ($nberr ? -$nberr : $nbcreated);
7837function dolChmod($filepath, $newmask =
'')
7841 if (!empty($newmask)) {
7842 @chmod($filepath, octdec($newmask));
7844 @chmod($filepath, octdec($conf->global->MAIN_UMASK));
7856 return '<span class="fieldrequired">*</span>';
7876function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
'UTF-8', $strip_tags = 0, $removedoublespaces = 1)
7878 if (is_null($stringtoclean)) {
7882 if ($removelinefeed == 2) {
7883 $stringtoclean = preg_replace(
'/<br[^>]*>(\n|\r)+/ims',
'<br>', $stringtoclean);
7885 $temp = preg_replace(
'/<br[^>]*>/i',
"\n", $stringtoclean);
7890 $temp = str_replace(
'< ',
'__ltspace__', $temp);
7891 $temp = str_replace(
'<:',
'__lttwopoints__', $temp);
7894 $temp = strip_tags($temp);
7897 $pattern =
"/<[^<>]+>/";
7904 $tempbis = str_replace(
'<>',
'', $temp);
7905 $tempbis = preg_replace($pattern,
'', $tempbis);
7907 }
while ($tempbis != $temp);
7912 $temp = preg_replace(
'/<+([a-z]+)/i',
'\1', $temp);
7918 if ($removelinefeed == 1) {
7919 $temp = str_replace(array(
"\r\n",
"\r",
"\n"),
" ", $temp);
7923 if ($removedoublespaces) {
7924 while (strpos($temp,
" ")) {
7925 $temp = str_replace(
" ",
" ", $temp);
7929 $temp = str_replace(
'__ltspace__',
'< ', $temp);
7930 $temp = str_replace(
'__lttwopoints__',
'<:', $temp);
7950function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1, $removeclassattribute = 1, $cleanalsojavascript = 0, $allowiframe = 0, $allowed_tags = array(), $allowlink = 0)
7952 if (empty($allowed_tags)) {
7953 $allowed_tags = array(
7954 "html",
"head",
"meta",
"body",
"article",
"a",
"abbr",
"b",
"blockquote",
"br",
"cite",
"div",
"dl",
"dd",
"dt",
"em",
"font",
"img",
"ins",
"hr",
"i",
"li",
7955 "ol",
"p",
"q",
"s",
"span",
"strike",
"strong",
"title",
"table",
"tr",
"th",
"td",
"u",
"ul",
"sup",
"sub",
"blockquote",
"pre",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
7956 "header",
"footer",
"nav",
"section",
"menu",
"menuitem"
7959 $allowed_tags[] =
"comment";
7961 if (!in_array(
'iframe', $allowed_tags)) {
7962 $allowed_tags[] =
"iframe";
7966 if (!in_array(
'link', $allowed_tags)) {
7967 $allowed_tags[] =
"link";
7971 $allowed_tags_string = implode(
"><", $allowed_tags);
7972 $allowed_tags_string =
'<'.$allowed_tags_string.
'>';
7974 $stringtoclean = str_replace(
'<!DOCTYPE html>',
'__!DOCTYPE_HTML__', $stringtoclean);
7979 $stringtoclean = preg_replace(
'/<!--([^>]*)-->/',
'<comment>\1</comment>', $stringtoclean);
7981 $stringtoclean = preg_replace(
'/:/i',
':', $stringtoclean);
7982 $stringtoclean = preg_replace(
'/:|�+58|:/i',
'', $stringtoclean);
7985 $temp = strip_tags($stringtoclean, $allowed_tags_string);
7987 if ($cleanalsosomestyles) {
7988 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/i',
'', $temp);
7990 if ($removeclassattribute) {
7991 $temp = preg_replace(
'/(<[^>]+)\s+class=((["\']).*?\\3|\\w*)/i',
'\\1', $temp);
7996 if ($cleanalsojavascript) {
7997 $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);
8000 $temp = str_replace(
'__!DOCTYPE_HTML__',
'<!DOCTYPE html>', $temp);
8002 $temp = preg_replace(
'/<comment>([^>]*)<\/comment>/',
'<!--\1-->', $temp);
8023 if (is_null($allowed_attributes)) {
8024 $allowed_attributes = array(
8025 "allow",
"allowfullscreen",
"alt",
"class",
"contenteditable",
"data-html",
"frameborder",
"height",
"href",
"id",
"name",
"src",
"style",
"target",
"title",
"width",
8027 "header",
"footer",
"nav",
"section",
"menu",
"menuitem"
8031 if (class_exists(
'DOMDocument') && !empty($stringtoclean)) {
8032 $stringtoclean =
'<?xml encoding="UTF-8"><html><body>'.$stringtoclean.
'</body></html>';
8035 $dom =
new DOMDocument(
'',
'UTF-8');
8037 $savwarning = error_reporting();
8038 error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);
8039 $dom->loadHTML($stringtoclean, LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOXMLDECL);
8040 error_reporting($savwarning);
8042 if ($dom instanceof DOMDocument) {
8043 for ($els = $dom->getElementsByTagname(
'*'), $i = $els->length - 1; $i >= 0; $i--) {
8044 $el = $els->item($i);
8045 if (!$el instanceof DOMElement) {
8048 $attrs = $el->attributes;
8049 for ($ii = $attrs->length - 1; $ii >= 0; $ii--) {
8051 if (!empty($attrs->item($ii)->name)) {
8052 if (! in_array($attrs->item($ii)->name, $allowed_attributes)) {
8054 $els->item($i)->removeAttribute($attrs->item($ii)->name);
8055 } elseif (in_array($attrs->item($ii)->name, array(
'style'))) {
8057 $valuetoclean = $attrs->item($ii)->value;
8059 if (isset($valuetoclean)) {
8061 $oldvaluetoclean = $valuetoclean;
8062 $valuetoclean = preg_replace(
'/\/\*.*\*\//m',
'', $valuetoclean);
8063 $valuetoclean = preg_replace(
'/position\s*:\s*[a-z]+/mi',
'', $valuetoclean);
8064 if ($els->item($i)->tagName ==
'a') {
8065 $valuetoclean = preg_replace(
'/display\s*:/mi',
'', $valuetoclean);
8066 $valuetoclean = preg_replace(
'/z-index\s*:/mi',
'', $valuetoclean);
8067 $valuetoclean = preg_replace(
'/\s+(top|left|right|bottom)\s*:/mi',
'', $valuetoclean);
8071 $valuetoclean = preg_replace(
'/(logout|passwordforgotten)\.php/mi',
'', $valuetoclean);
8072 $valuetoclean = preg_replace(
'/action=/mi',
'', $valuetoclean);
8073 }
while ($oldvaluetoclean != $valuetoclean);
8076 $attrs->item($ii)->value = $valuetoclean;
8083 $return = $dom->saveHTML();
8086 $return = preg_replace(
'/^'.preg_quote(
'<?xml encoding="UTF-8">',
'/').
'/',
'', $return);
8087 $return = preg_replace(
'/^'.preg_quote(
'<html><body>',
'/').
'/',
'', $return);
8088 $return = preg_replace(
'/'.preg_quote(
'</body></html>',
'/').
'$/',
'', $return);
8089 return trim($return);
8091 return $stringtoclean;
8108 $temp = $stringtoclean;
8109 foreach ($disallowed_tags as $tagtoremove) {
8110 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'>/',
'', $temp);
8111 $temp = preg_replace(
'/<\/?'.$tagtoremove.
'\s+[^>]*>/',
'', $temp);
8114 if ($cleanalsosomestyles) {
8115 $temp = preg_replace(
'/position\s*:\s*(absolute|fixed)\s*!\s*important/',
'', $temp);
8133 if ($nboflines == 1) {
8135 $firstline = preg_replace(
'/<br[^>]*>.*$/s',
'', $text);
8136 $firstline = preg_replace(
'/<div[^>]*>.*$/s',
'', $firstline);
8139 $firstline = preg_replace(
'/[\n\r].*/',
'', $text);
8144 return $firstline.(isset($firstline) && isset($text) && (strlen($firstline) != strlen($text)) ?
'...' :
'');
8148 $text = preg_replace(
'/\n/',
'', $text);
8150 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8152 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8155 $text = strtr($text, $repTable);
8156 if ($charset ==
'UTF-8') {
8157 $pattern =
'/(<br[^>]*>)/Uu';
8160 $pattern =
'/(<br[^>]*>)/U';
8162 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
8167 $lastaddediscontent = 1;
8168 while ($countline < $nboflines && isset($a[$i])) {
8169 if (preg_match(
'/<br[^>]*>/', $a[$i])) {
8170 if (array_key_exists($i + 1, $a) && !empty($a[$i + 1])) {
8171 $firstline .= ($ishtml ?
"<br>\n" :
"\n");
8173 if (!$lastaddediscontent) {
8176 $lastaddediscontent = 0;
8179 $firstline .= $a[$i];
8180 $lastaddediscontent = 1;
8186 $adddots = (isset($a[$i]) && (!preg_match(
'/<br[^>]*>/', $a[$i]) || (array_key_exists($i + 1, $a) && !empty($a[$i + 1]))));
8188 $ret = $firstline.($adddots ?
'...' :
'');
8206function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml =
false)
8208 if (is_null($stringtoencode)) {
8213 return nl2br($stringtoencode, $forxml);
8215 $ret = preg_replace(
'/(\r\n|\r|\n)/i', ($forxml ?
'<br />' :
'<br>'), $stringtoencode);
8229function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check =
'restricthtml')
8231 if (empty($nouseofiframesandbox) &&
getDolGlobalString(
'MAIN_SECURITY_USE_SANDBOX_FOR_HTMLWITHNOJS')) {
8236 return $stringtoencode;
8238 $out = $stringtoencode;
8242 $oldstringtoclean = $out;
8244 if (!empty($out) &&
getDolGlobalString(
'MAIN_RESTRICTHTML_ONLY_VALID_HTML') && $check !=
'restricthtmlallowunvalid') {
8246 libxml_use_internal_errors(
false);
8247 if (LIBXML_VERSION < 20900) {
8251 libxml_disable_entity_loader(
true);
8254 $dom =
new DOMDocument();
8260 $out =
'<?xml encoding="UTF-8"><div class="tricktoremove">'.$out.
'</div>';
8262 $out =
'<?xml encoding="UTF-8"><div class="tricktoremove">'.dol_nl2br($out).
'</div>';
8265 $dom->loadHTML($out, LIBXML_HTML_NODEFDTD | LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOERROR | LIBXML_NOXMLDECL);
8266 $out = trim($dom->saveHTML());
8269 $out = preg_replace(
'/^<\?xml encoding="UTF-8"><div class="tricktoremove">/',
'', $out);
8270 $out = preg_replace(
'/<\/div>$/',
'', $out);
8274 $out =
'InvalidHTMLStringCantBeCleaned '.$e->getMessage();
8278 if (!empty($out) &&
getDolGlobalString(
'MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY') && $check !=
'restricthtmlallowunvalid') {
8281 if (extension_loaded(
'tidy') && class_exists(
"tidy")) {
8287 'quote-marks' =>
false,
8288 'doctype' =>
'strict',
8289 'show-body-only' =>
true,
8290 "indent-attributes" =>
false,
8291 "vertical-space" =>
false,
8303 $out = $tidy->repairString($out, $config,
'utf8');
8310 $out =
'InvalidHTMLStringCantBeCleaned '.$e->getMessage();
8315 $out = preg_replace(
'/[\x{200B}-\x{200D}\x{FEFF}]/u',
' ', $out);
8318 $out = preg_replace(
'/&(tab|newline);/i',
' ', $out);
8322 $out = preg_replace(
'/'/i',
''', $out);
8327 $out = preg_replace_callback(
8328 '/&#(x?[0-9][0-9a-f]+;?)/i',
8333 static function ($m) {
8340 $out = preg_replace(
'/&#x?[0-9]+/i',
'', $out);
8343 if ($check ==
'restricthtmlallowclass' || $check ==
'restricthtmlallowunvalid') {
8355 $out = preg_replace(
'/'/i',
"'", $out);
8359 $out = preg_replace(
'/on(mouse|drag|key|load|touch|pointer|select|transition)[a-z]*\s*=/i',
'', $out);
8360 $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);
8361 $out = preg_replace(
'/on(dblclick|drop|durationchange|emptied|end|ended|error|focus|focusin|focusout|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i',
'', $out);
8362 $out = preg_replace(
'/on(lostpointercapture|offline|online|pagehide|pageshow)[a-z]*\s*=/i',
'', $out);
8363 $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);
8364 $out = preg_replace(
'/on(timeupdate|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i',
'', $out);
8366 $out = preg_replace(
'/on(repeat|begin|finish|beforeinput)[a-z]*\s*=/i',
'', $out);
8367 }
while ($oldstringtoclean != $out);
8374 $tmpout = preg_replace(
'/<img src="data:/mi',
'<__IMG_SRC_DATA__ src="data:', $out);
8375 preg_match_all(
'/(<img|url\(|<link)/i', $tmpout, $reg);
8376 $nblinks = count($reg[0]);
8377 if ($nblinks >
getDolGlobalInt(
"MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 1000)) {
8378 $out =
'ErrorTooManyLinksIntoHTMLString';
8381 if (
getDolGlobalInt(
'MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 2 || $check ==
'restricthtmlnolink') {
8383 $out =
'ErrorHTMLLinksNotAllowed';
8385 } elseif (
getDolGlobalInt(
'MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 1) {
8388 $pattern =
'/src=["\']?(http[^"\']+)|url\(["\']?(http[^\)]+)/';
8391 if (preg_match_all($pattern, $out, $matches)) {
8393 $urls = $matches[1];
8396 foreach ($urls as $url) {
8398 echo
"Found url = ".$url .
"\n";
8401 $out =
'ErrorHTMLExternalLinksNotAllowed';
8430function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom =
'UTF-8', $removelasteolbr = 1)
8432 if (is_null($stringtoencode)) {
8436 $newstring = $stringtoencode;
8438 $newstring = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
'<br>', $newstring);
8439 if ($removelasteolbr) {
8440 $newstring = preg_replace(
'/<br>$/i',
'', $newstring);
8442 $newstring = preg_replace(
'/[\x{200B}-\x{200D}\x{FEFF}]/u',
' ', $newstring);
8443 $newstring = strtr($newstring, array(
'&' =>
'__and__',
'<' =>
'__lt__',
'>' =>
'__gt__',
'"' =>
'__dquot__'));
8445 $newstring = strtr($newstring, array(
'__and__' =>
'&',
'__lt__' =>
'<',
'__gt__' =>
'>',
'__dquot__' =>
'"'));
8447 if ($removelasteolbr) {
8448 $newstring = preg_replace(
'/(\r\n|\r|\n)$/i',
'', $newstring);
8467 $ret = preg_replace(
'/'.
"\r\n".
'<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"<br>", $ret);
8468 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\r\n".
'/i',
"\r\n", $ret);
8469 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>'.
"\n".
'/i',
"\n", $ret);
8470 $ret = preg_replace(
'/<br(\s[\sa-zA-Z_="]*)?\/?>/i',
"\n", $ret);
8482 $ret = preg_replace(
'/ $/i',
"", $stringtodecode);
8483 $ret = preg_replace(
'/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'.
"\n".
'|'.
"\r".
')+$/i',
"", $ret);
8499 if ($keepsomeentities) {
8500 $newstring = strtr($newstring, array(
'&' =>
'__andamp__',
'<' =>
'__andlt__',
'>' =>
'__andgt__',
'"' =>
'__dquot__'));
8502 $newstring = html_entity_decode((
string) $newstring, (
int) $b, (
string) $c);
8503 if ($keepsomeentities) {
8504 $newstring = strtr($newstring, array(
'__andamp__' =>
'&',
'__andlt__' =>
'<',
'__andgt__' =>
'>',
'__dquot__' =>
'"'));
8520function dol_htmlentities($string, $flags = ENT_QUOTES | ENT_SUBSTITUTE, $encoding =
'UTF-8', $double_encode =
false)
8522 return htmlentities($string, $flags, $encoding, $double_encode);
8541 for ($scursor = 0; $scursor < $len; $scursor++) {
8542 $ordchar = ord($s[$scursor]);
8544 if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) {
8547 } elseif ($ordchar > 126 && $ordchar < 160) {
8551 $out .= $s[$scursor];
8573 $arraystring = explode(
"\n", $s);
8574 $nb = count($arraystring);
8591 $repTable = array(
"\t" =>
" ",
"\n" =>
"<br>",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8593 $repTable = array(
"\t" =>
" ",
"\n" =>
" ",
"\r" =>
" ",
"\0" =>
" ",
"\x0B" =>
" ");
8596 $text = strtr($text, $repTable);
8597 if ($charset ==
'UTF-8') {
8598 $pattern =
'/(<br[^>]*>)/Uu';
8601 $pattern =
'/(<br[^>]*>)/U';
8603 $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
8605 $nblines = (int) floor((count($a) + 1) / 2);
8608 foreach ($a as $line) {
8611 $line_dec = html_entity_decode($line);
8613 $line_dec = wordwrap($line_dec, $maxlinesize,
'\n',
true);
8614 $nblines += substr_count($line_dec,
'\n');
8634 if (is_null($msg)) {
8639 if (preg_match(
'/<html/i', $msg)) {
8641 } elseif (preg_match(
'/<body/i', $msg)) {
8643 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
8645 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
8647 } elseif (preg_match(
'/<br/i', $msg)) {
8653 $msg = preg_replace(
'/https?:\/\/[^"\'\s]+/i',
'', $msg);
8654 if (preg_match(
'/<html/i', $msg)) {
8656 } elseif (preg_match(
'/<body/i', $msg)) {
8658 } elseif (preg_match(
'/<\/textarea/i', $msg)) {
8660 } elseif (preg_match(
'/<(b|em|i|u)(\s+[^>]+)?>/i', $msg)) {
8662 } elseif (preg_match(
'/<(br|hr)\/>/i', $msg)) {
8664 } elseif (preg_match(
'/<(br|hr|div|font|li|p|span|strong|table)>/i', $msg)) {
8666 } elseif (preg_match(
'/<(br|hr|div|font|li|p|span|strong|table)\s+[^<>\/]*\/?>/i', $msg)) {
8668 } elseif (preg_match(
'/<img\s+[^<>]*src[^<>]*>/i', $msg)) {
8670 } elseif (preg_match(
'/<a\s+[^<>]*href[^<>]*>/i', $msg)) {
8672 } elseif (preg_match(
'/<h[0-9]>/i', $msg)) {
8674 } elseif (preg_match(
'/&[A-Z0-9]{1,6};/i', $msg)) {
8677 } elseif (preg_match(
'/&#[0-9]{2,3};/i', $msg)) {
8699function dol_concatdesc($text1, $text2, $forxml =
false, $invert =
false)
8701 if (!empty($invert)) {
8709 $ret .= (!empty($text1) && !empty($text2)) ? ((
dol_textishtml($text1) ||
dol_textishtml($text2)) ? ($forxml ?
"<br >\n" :
"<br>\n") :
"\n") :
"";
8731 global $db, $conf, $mysoc, $user, $extrafields;
8733 $substitutionarray = array();
8735 if ((empty($exclude) || !in_array(
'user', $exclude)) && (empty($include) || in_array(
'user', $include))) {
8739 $emailsendersignature = $user->signature;
8740 $usersignature = $user->signature;
8741 $substitutionarray = array_merge($substitutionarray, array(
8742 '__SENDEREMAIL_SIGNATURE__' => (
string) ((!
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN')) ? ($onlykey == 2 ?
dol_trunc(
'SignatureFromTheSelectedSenderProfile', 30) : $emailsendersignature) :
''),
8746 if (is_object($user) && ($user instanceof
User)) {
8747 $substitutionarray = array_merge($substitutionarray, array(
8748 '__USER_ID__' => (
string) $user->id,
8749 '__USER_LOGIN__' => (
string) $user->login,
8750 '__USER_EMAIL__' => (
string) $user->email,
8751 '__USER_PHONE__' => (
string)
dol_print_phone($user->office_phone,
'', 0, 0,
'',
" ",
'',
'', -1),
8752 '__USER_PHONEPRO__' => (
string)
dol_print_phone($user->user_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
8753 '__USER_PHONEMOBILE__' => (
string)
dol_print_phone($user->personal_mobile,
'', 0, 0,
'',
" ",
'',
'', -1),
8754 '__USER_FAX__' => (
string) $user->office_fax,
8755 '__USER_LASTNAME__' => (
string) $user->lastname,
8756 '__USER_FIRSTNAME__' => (
string) $user->firstname,
8757 '__USER_FULLNAME__' => (
string) $user->getFullName($outputlangs),
8758 '__USER_SUPERVISOR_ID__' => (
string) ($user->fk_user ? $user->fk_user :
'0'),
8759 '__USER_JOB__' => (string) $user->job,
8761 '__USER_VCARD_URL__' => (string) $user->getOnlineVirtualCardUrl(
'',
'external')
8765 if ((empty($exclude) || !in_array(
'mycompany', $exclude)) && is_object($mysoc) && (empty($include) || in_array(
'mycompany', $include))) {
8766 $substitutionarray = array_merge($substitutionarray, array(
8767 '__MYCOMPANY_NAME__' => $mysoc->name,
8768 '__MYCOMPANY_EMAIL__' => $mysoc->email,
8769 '__MYCOMPANY_PHONE__' =>
dol_print_phone($mysoc->phone,
'', 0, 0,
'',
" ",
'',
'', -1),
8770 '__MYCOMPANY_FAX__' =>
dol_print_phone($mysoc->fax,
'', 0, 0,
'',
" ",
'',
'', -1),
8771 '__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
8772 '__MYCOMPANY_PROFID2__' => $mysoc->idprof2,
8773 '__MYCOMPANY_PROFID3__' => $mysoc->idprof3,
8774 '__MYCOMPANY_PROFID4__' => $mysoc->idprof4,
8775 '__MYCOMPANY_PROFID5__' => $mysoc->idprof5,
8776 '__MYCOMPANY_PROFID6__' => $mysoc->idprof6,
8777 '__MYCOMPANY_PROFID7__' => $mysoc->idprof7,
8778 '__MYCOMPANY_PROFID8__' => $mysoc->idprof8,
8779 '__MYCOMPANY_PROFID9__' => $mysoc->idprof9,
8780 '__MYCOMPANY_PROFID10__' => $mysoc->idprof10,
8781 '__MYCOMPANY_CAPITAL__' => $mysoc->capital,
8782 '__MYCOMPANY_FULLADDRESS__' => (method_exists($mysoc,
'getFullAddress') ? $mysoc->getFullAddress(1,
', ') :
''),
8783 '__MYCOMPANY_ADDRESS__' => $mysoc->address,
8784 '__MYCOMPANY_ZIP__' => $mysoc->zip,
8785 '__MYCOMPANY_TOWN__' => $mysoc->town,
8786 '__MYCOMPANY_COUNTRY__' => $mysoc->country,
8787 '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id,
8788 '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code,
8789 '__MYCOMPANY_CURRENCY_CODE__' => $conf->currency
8793 if (($onlykey || is_object(
$object)) && (empty($exclude) || !in_array(
'object', $exclude)) && (empty($include) || in_array(
'object', $include))) {
8795 $substitutionarray[
'__ID__'] =
'__ID__';
8796 $substitutionarray[
'__REF__'] =
'__REF__';
8797 $substitutionarray[
'__NEWREF__'] =
'__NEWREF__';
8798 $substitutionarray[
'__LABEL__'] =
'__LABEL__';
8799 $substitutionarray[
'__REF_CLIENT__'] =
'__REF_CLIENT__';
8800 $substitutionarray[
'__REF_SUPPLIER__'] =
'__REF_SUPPLIER__';
8801 $substitutionarray[
'__NOTE_PUBLIC__'] =
'__NOTE_PUBLIC__';
8802 $substitutionarray[
'__NOTE_PRIVATE__'] =
'__NOTE_PRIVATE__';
8803 $substitutionarray[
'__EXTRAFIELD_XXX__'] =
'__EXTRAFIELD_XXX__';
8805 if (isModEnabled(
"societe")) {
8806 $substitutionarray[
'__THIRDPARTY_ID__'] =
'__THIRDPARTY_ID__';
8807 $substitutionarray[
'__THIRDPARTY_NAME__'] =
'__THIRDPARTY_NAME__';
8808 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] =
'__THIRDPARTY_NAME_ALIAS__';
8809 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] =
'__THIRDPARTY_CODE_CLIENT__';
8810 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] =
'__THIRDPARTY_CODE_FOURNISSEUR__';
8811 $substitutionarray[
'__THIRDPARTY_EMAIL__'] =
'__THIRDPARTY_EMAIL__';
8813 $substitutionarray[
'__THIRDPARTY_PHONE__'] =
'__THIRDPARTY_PHONE__';
8814 $substitutionarray[
'__THIRDPARTY_FAX__'] =
'__THIRDPARTY_FAX__';
8815 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] =
'__THIRDPARTY_ADDRESS__';
8816 $substitutionarray[
'__THIRDPARTY_ZIP__'] =
'__THIRDPARTY_ZIP__';
8817 $substitutionarray[
'__THIRDPARTY_TOWN__'] =
'__THIRDPARTY_TOWN__';
8818 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] =
'__THIRDPARTY_IDPROF1__';
8819 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] =
'__THIRDPARTY_IDPROF2__';
8820 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] =
'__THIRDPARTY_IDPROF3__';
8821 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] =
'__THIRDPARTY_IDPROF4__';
8822 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] =
'__THIRDPARTY_IDPROF5__';
8823 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] =
'__THIRDPARTY_IDPROF6__';
8824 $substitutionarray[
'__THIRDPARTY_IDPROF7__'] =
'__THIRDPARTY_IDPROF7__';
8825 $substitutionarray[
'__THIRDPARTY_IDPROF8__'] =
'__THIRDPARTY_IDPROF8__';
8826 $substitutionarray[
'__THIRDPARTY_IDPROF9__'] =
'__THIRDPARTY_IDPROF9__';
8827 $substitutionarray[
'__THIRDPARTY_IDPROF10__'] =
'__THIRDPARTY_IDPROF10__';
8828 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] =
'__THIRDPARTY_TVAINTRA__';
8829 $substitutionarray[
'__THIRDPARTY_NOTE_PUBLIC__'] =
'__THIRDPARTY_NOTE_PUBLIC__';
8830 $substitutionarray[
'__THIRDPARTY_NOTE_PRIVATE__'] =
'__THIRDPARTY_NOTE_PRIVATE__';
8832 if (isModEnabled(
'member') && (!is_object(
$object) ||
$object->element ==
'adherent') && (empty($exclude) || !in_array(
'member', $exclude)) && (empty($include) || in_array(
'member', $include))) {
8833 $substitutionarray[
'__MEMBER_ID__'] =
'__MEMBER_ID__';
8834 $substitutionarray[
'__MEMBER_CIVILITY__'] =
'__MEMBER_CIVILITY__';
8835 $substitutionarray[
'__MEMBER_FIRSTNAME__'] =
'__MEMBER_FIRSTNAME__';
8836 $substitutionarray[
'__MEMBER_LASTNAME__'] =
'__MEMBER_LASTNAME__';
8837 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'Login and pass of the external user account';
8842 if (isModEnabled(
'ticket') && (!is_object(
$object) ||
$object->element ==
'ticket') && (empty($exclude) || !in_array(
'ticket', $exclude)) && (empty($include) || in_array(
'ticket', $include))) {
8843 $substitutionarray[
'__TICKET_TRACKID__'] =
'__TICKET_TRACKID__';
8844 $substitutionarray[
'__TICKET_SUBJECT__'] =
'__TICKET_SUBJECT__';
8845 $substitutionarray[
'__TICKET_TYPE__'] =
'__TICKET_TYPE__';
8846 $substitutionarray[
'__TICKET_SEVERITY__'] =
'__TICKET_SEVERITY__';
8847 $substitutionarray[
'__TICKET_CATEGORY__'] =
'__TICKET_CATEGORY__';
8848 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
'__TICKET_ANALYTIC_CODE__';
8849 $substitutionarray[
'__TICKET_MESSAGE__'] =
'__TICKET_MESSAGE__';
8850 $substitutionarray[
'__TICKET_PROGRESSION__'] =
'__TICKET_PROGRESSION__';
8851 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
'__TICKET_USER_ASSIGN__';
8854 if (isModEnabled(
'recruitment') && (!is_object(
$object) ||
$object->element ==
'recruitmentcandidature') && (empty($exclude) || !in_array(
'recruitment', $exclude)) && (empty($include) || in_array(
'recruitment', $include))) {
8855 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
'__CANDIDATE_FULLNAME__';
8856 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] =
'__CANDIDATE_FIRSTNAME__';
8857 $substitutionarray[
'__CANDIDATE_LASTNAME__'] =
'__CANDIDATE_LASTNAME__';
8859 if (isModEnabled(
'project') && (empty($exclude) || !in_array(
'project', $exclude)) && (empty($include) || in_array(
'project', $include))) {
8860 $substitutionarray[
'__PROJECT_ID__'] =
'__PROJECT_ID__';
8861 $substitutionarray[
'__PROJECT_REF__'] =
'__PROJECT_REF__';
8862 $substitutionarray[
'__PROJECT_NAME__'] =
'__PROJECT_NAME__';
8866 if (isModEnabled(
'contract') && (!is_object(
$object) ||
$object->element ==
'contract') && (empty($exclude) || !in_array(
'contract', $exclude)) && (empty($include) || in_array(
'contract', $include))) {
8867 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
'Highest date planned for a service start';
8868 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
'Highest date and hour planned for service start';
8869 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
'Lowest data for planned expiration of service';
8870 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
'Lowest date and hour for planned expiration of service';
8872 if (isModEnabled(
"propal") && (!is_object(
$object) ||
$object->element ==
'propal') && (empty($exclude) || !in_array(
'propal', $exclude)) && (empty($include) || in_array(
'propal', $include))) {
8873 $substitutionarray[
'__ONLINE_SIGN_URL__'] =
'ToOfferALinkForOnlineSignature';
8875 if (isModEnabled(
"intervention") && (!is_object(
$object) ||
$object->element ==
'fichinter') && (empty($exclude) || !in_array(
'intervention', $exclude)) && (empty($include) || in_array(
'intervention', $include))) {
8876 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] =
'ToOfferALinkForOnlineSignature';
8878 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] =
'UrlToPayOnlineIfApplicable';
8879 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] =
'TextAndUrlToPayOnlineIfApplicable';
8880 $substitutionarray[
'__SECUREKEYPAYMENT__'] =
'Security key (if key is not unique per record)';
8881 $substitutionarray[
'__SECUREKEYPAYMENT_MEMBER__'] =
'Security key for payment on a member subscription (one key per member)';
8882 $substitutionarray[
'__SECUREKEYPAYMENT_ORDER__'] =
'Security key for payment on an order';
8883 $substitutionarray[
'__SECUREKEYPAYMENT_INVOICE__'] =
'Security key for payment on an invoice';
8884 $substitutionarray[
'__SECUREKEYPAYMENT_CONTRACTLINE__'] =
'Security key for payment on a service of a contract';
8886 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'Direct download url of a proposal';
8887 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'Direct download url of an order';
8888 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'Direct download url of an invoice';
8889 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'Direct download url of a contract';
8890 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'Direct download url of a supplier proposal';
8892 if (isModEnabled(
"shipping") && (!is_object(
$object) ||
$object->element ==
'shipping')) {
8893 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
'Shipping tracking number';
8894 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
'Shipping tracking url';
8895 $substitutionarray[
'__SHIPPINGMETHOD__'] =
'Shipping method';
8897 if (isModEnabled(
"reception") && (!is_object(
$object) ||
$object->element ==
'reception')) {
8898 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
'Shipping tracking number of shipment';
8899 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
'Shipping tracking url';
8902 '@phan-var-force Adherent|Delivery $object';
8903 $substitutionarray[
'__ID__'] =
$object->id;
8904 $substitutionarray[
'__REF__'] =
$object->ref;
8905 $substitutionarray[
'__NEWREF__'] =
$object->newref;
8907 $substitutionarray[
'__REF_CLIENT__'] = (isset(
$object->ref_client) ?
$object->ref_client : (isset(
$object->ref_customer) ?
$object->ref_customer :
null));
8908 $substitutionarray[
'__REF_SUPPLIER__'] = (isset(
$object->ref_supplier) ?
$object->ref_supplier :
null);
8909 $substitutionarray[
'__NOTE_PUBLIC__'] = (isset(
$object->note_public) ?
$object->note_public :
null);
8910 $substitutionarray[
'__NOTE_PRIVATE__'] = (isset(
$object->note_private) ?
$object->note_private :
null);
8912 $substitutionarray[
'__DATE_CREATION__'] = (isset(
$object->date_creation) ?
dol_print_date(
$object->date_creation,
'day', 0, $outputlangs) :
'');
8913 $substitutionarray[
'__DATE_MODIFICATION__'] = (isset(
$object->date_modification) ?
dol_print_date(
$object->date_modification,
'day', 0, $outputlangs) :
'');
8914 $substitutionarray[
'__DATE_VALIDATION__'] = (isset(
$object->date_validation) ?
dol_print_date(
$object->date_validation,
'day', 0, $outputlangs) :
'');
8917 $date_delivery =
null;
8918 if (property_exists(
$object,
'date_delivery')) {
8919 $date_delivery =
$object->date_delivery;
8920 } elseif (property_exists(
$object,
'delivery_date')) {
8921 $date_delivery =
$object->delivery_date;
8923 $substitutionarray[
'__DATE_DELIVERY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
'day', 0, $outputlangs) :
'');
8924 $substitutionarray[
'__DATE_DELIVERY_DAY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%d") :
'');
8925 $substitutionarray[
'__DATE_DELIVERY_DAY_TEXT__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%A") :
'');
8926 $substitutionarray[
'__DATE_DELIVERY_MON__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%m") :
'');
8927 $substitutionarray[
'__DATE_DELIVERY_MON_TEXT__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%b") :
'');
8928 $substitutionarray[
'__DATE_DELIVERY_YEAR__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%Y") :
'');
8929 $substitutionarray[
'__DATE_DELIVERY_HH__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%H") :
'');
8930 $substitutionarray[
'__DATE_DELIVERY_MM__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%M") :
'');
8931 $substitutionarray[
'__DATE_DELIVERY_SS__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
"%S") :
'');
8934 $substitutionarray[
'__REFCLIENT__'] = (isset(
$object->ref_client) ?
$object->ref_client : (isset(
$object->ref_customer) ?
$object->ref_customer :
null));
8935 $substitutionarray[
'__REFSUPPLIER__'] = (isset(
$object->ref_supplier) ?
$object->ref_supplier :
null);
8936 $substitutionarray[
'__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($date_delivery) ?
dol_print_date($date_delivery,
'day', 0, $outputlangs) :
'');
8937 $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 :
'')) :
'');
8941 '@phan-var-force Adherent $object';
8944 $substitutionarray[
'__MEMBER_ID__'] = (isset(
$object->id) ?
$object->id :
'');
8945 if (method_exists(
$object,
'getCivilityLabel')) {
8946 $substitutionarray[
'__MEMBER_CIVILITY__'] =
$object->getCivilityLabel();
8948 $substitutionarray[
'__MEMBER_FIRSTNAME__'] = (isset(
$object->firstname) ?
$object->firstname :
'');
8949 $substitutionarray[
'__MEMBER_LASTNAME__'] = (isset(
$object->lastname) ?
$object->lastname :
'');
8950 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] =
'';
8951 if (method_exists(
$object,
'getFullName')) {
8952 $substitutionarray[
'__MEMBER_FULLNAME__'] =
$object->getFullName($outputlangs);
8954 $substitutionarray[
'__MEMBER_COMPANY__'] = (isset(
$object->societe) ?
$object->societe :
'');
8955 $substitutionarray[
'__MEMBER_ADDRESS__'] = (isset(
$object->address) ?
$object->address :
'');
8956 $substitutionarray[
'__MEMBER_ZIP__'] = (isset(
$object->zip) ?
$object->zip :
'');
8957 $substitutionarray[
'__MEMBER_TOWN__'] = (isset(
$object->town) ?
$object->town :
'');
8958 $substitutionarray[
'__MEMBER_COUNTRY__'] = (isset(
$object->country) ?
$object->country :
'');
8959 $substitutionarray[
'__MEMBER_EMAIL__'] = (isset(
$object->email) ?
$object->email :
'');
8960 $substitutionarray[
'__MEMBER_BIRTH__'] = (isset($birthday) ? $birthday :
'');
8961 $substitutionarray[
'__MEMBER_PHOTO__'] = (isset(
$object->photo) ?
$object->photo :
'');
8962 $substitutionarray[
'__MEMBER_LOGIN__'] = (isset(
$object->login) ?
$object->login :
'');
8963 $substitutionarray[
'__MEMBER_PASSWORD__'] = (isset(
$object->pass) ?
$object->pass :
'');
8967 $substitutionarray[
'__MEMBER_TYPE__'] = (isset(
$object->type) ?
$object->type :
'');
8968 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE__'] =
dol_print_date(
$object->first_subscription_date,
'day');
8970 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_RFC__'] =
dol_print_date(
$object->first_subscription_date,
'dayrfc');
8971 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = (isset(
$object->first_subscription_date_start) ?
dol_print_date(
$object->first_subscription_date_start,
'day') :
'');
8972 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_START_RFC__'] = (isset(
$object->first_subscription_date_start) ?
dol_print_date(
$object->first_subscription_date_start,
'dayrfc') :
'');
8973 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = (isset(
$object->first_subscription_date_end) ?
dol_print_date(
$object->first_subscription_date_end,
'day') :
'');
8974 $substitutionarray[
'__MEMBER_FIRST_SUBSCRIPTION_DATE_END_RFC__'] = (isset(
$object->first_subscription_date_end) ?
dol_print_date(
$object->first_subscription_date_end,
'dayrfc') :
'');
8975 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE__'] =
dol_print_date(
$object->last_subscription_date,
'day');
8976 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_RFC__'] =
dol_print_date(
$object->last_subscription_date,
'dayrfc');
8977 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] =
dol_print_date(
$object->last_subscription_date_start,
'day');
8978 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_START_RFC__'] =
dol_print_date(
$object->last_subscription_date_start,
'dayrfc');
8979 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] =
dol_print_date(
$object->last_subscription_date_end,
'day');
8980 $substitutionarray[
'__MEMBER_LAST_SUBSCRIPTION_DATE_END_RFC__'] =
dol_print_date(
$object->last_subscription_date_end,
'dayrfc');
8984 '@phan-var-force Societe $object';
8985 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object(
$object) ?
$object->id :
'');
8986 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object(
$object) ?
$object->name :
'');
8987 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object(
$object) ?
$object->name_alias :
'');
8988 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object(
$object) ?
$object->code_client :
'');
8989 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object(
$object) ?
$object->code_fournisseur :
'');
8990 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object(
$object) ?
$object->email :
'');
8991 $substitutionarray[
'__THIRDPARTY_EMAIL_URLENCODED__'] = urlencode(is_object(
$object) ?
$object->email :
'');
8994 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object(
$object) ?
$object->address :
'');
8995 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object(
$object) ?
$object->zip :
'');
8996 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object(
$object) ?
$object->town :
'');
8997 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object(
$object) ?
$object->country_id :
'');
8998 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object(
$object) ?
$object->country_code :
'');
8999 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object(
$object) ?
$object->idprof1 :
'');
9000 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object(
$object) ?
$object->idprof2 :
'');
9001 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object(
$object) ?
$object->idprof3 :
'');
9002 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object(
$object) ?
$object->idprof4 :
'');
9003 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object(
$object) ?
$object->idprof5 :
'');
9004 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object(
$object) ?
$object->idprof6 :
'');
9005 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object(
$object) ?
$object->tva_intra :
'');
9008 } elseif (is_object(
$object->thirdparty)) {
9009 $substitutionarray[
'__THIRDPARTY_ID__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->id :
'');
9010 $substitutionarray[
'__THIRDPARTY_NAME__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->name :
'');
9011 $substitutionarray[
'__THIRDPARTY_NAME_ALIAS__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->name_alias :
'');
9012 $substitutionarray[
'__THIRDPARTY_CODE_CLIENT__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->code_client :
'');
9013 $substitutionarray[
'__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->code_fournisseur :
'');
9014 $substitutionarray[
'__THIRDPARTY_EMAIL__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->email :
'');
9015 $substitutionarray[
'__THIRDPARTY_EMAIL_URLENCODED__'] = urlencode(is_object(
$object->thirdparty) ?
$object->thirdparty->email :
'');
9018 $substitutionarray[
'__THIRDPARTY_ADDRESS__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->address :
'');
9019 $substitutionarray[
'__THIRDPARTY_ZIP__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->zip :
'');
9020 $substitutionarray[
'__THIRDPARTY_TOWN__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->town :
'');
9021 $substitutionarray[
'__THIRDPARTY_COUNTRY_ID__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->country_id :
'');
9022 $substitutionarray[
'__THIRDPARTY_COUNTRY_CODE__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->country_code :
'');
9023 $substitutionarray[
'__THIRDPARTY_IDPROF1__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof1 :
'');
9024 $substitutionarray[
'__THIRDPARTY_IDPROF2__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof2 :
'');
9025 $substitutionarray[
'__THIRDPARTY_IDPROF3__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof3 :
'');
9026 $substitutionarray[
'__THIRDPARTY_IDPROF4__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof4 :
'');
9027 $substitutionarray[
'__THIRDPARTY_IDPROF5__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof5 :
'');
9028 $substitutionarray[
'__THIRDPARTY_IDPROF6__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->idprof6 :
'');
9029 $substitutionarray[
'__THIRDPARTY_TVAINTRA__'] = (is_object(
$object->thirdparty) ?
$object->thirdparty->tva_intra :
'');
9034 if (is_object(
$object) &&
$object->element ==
'recruitmentcandidature') {
9035 '@phan-var-force RecruitmentCandidature $object';
9036 $substitutionarray[
'__CANDIDATE_FULLNAME__'] =
$object->getFullName($outputlangs);
9037 $substitutionarray[
'__CANDIDATE_FIRSTNAME__'] = isset(
$object->firstname) ?
$object->firstname :
'';
9038 $substitutionarray[
'__CANDIDATE_LASTNAME__'] = isset(
$object->lastname) ?
$object->lastname :
'';
9040 if (is_object(
$object) &&
$object->element ==
'conferenceorboothattendee') {
9041 '@phan-var-force ConferenceOrBoothAttendee $object';
9042 $substitutionarray[
'__ATTENDEE_FULLNAME__'] =
$object->getFullName($outputlangs);
9043 $substitutionarray[
'__ATTENDEE_FIRSTNAME__'] = isset(
$object->firstname) ?
$object->firstname :
'';
9044 $substitutionarray[
'__ATTENDEE_LASTNAME__'] = isset(
$object->lastname) ?
$object->lastname :
'';
9048 '@phan-var-force Project $object';
9049 $substitutionarray[
'__PROJECT_ID__'] =
$object->id;
9050 $substitutionarray[
'__PROJECT_REF__'] =
$object->ref;
9051 $substitutionarray[
'__PROJECT_NAME__'] =
$object->title;
9052 } elseif (is_object(
$object)) {
9054 if (!empty(
$object->project)) {
9056 } elseif (!empty(
$object->projet)) {
9059 if (!is_null($project) && is_object($project)) {
9060 $substitutionarray[
'__PROJECT_ID__'] = $project->id;
9061 $substitutionarray[
'__PROJECT_REF__'] = $project->ref;
9062 $substitutionarray[
'__PROJECT_NAME__'] = $project->title;
9067 $project_id =
$object->fk_project;
9068 } elseif (!empty(
$object->fk_projet) &&
$object->fk_projet > 0) {
9069 $project_id =
$object->fk_project;
9071 if ($project_id > 0) {
9073 $substitutionarray[
'__PROJECT_ID__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9074 $substitutionarray[
'__PROJECT_REF__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9075 $substitutionarray[
'__PROJECT_NAME__@lazyload'] =
'/projet/class/project.class.php:Project:fetchAndSetSubstitution:' . $project_id;
9081 '@phan-var-force Facture $object';
9082 $substitutionarray[
'__INVOICE_SITUATION_NUMBER__'] = isset(
$object->situation_counter) ?
$object->situation_counter :
'';
9085 '@phan-var-force Expedition $object';
9086 $substitutionarray[
'__SHIPPINGTRACKNUM__'] =
$object->tracking_number;
9087 $substitutionarray[
'__SHIPPINGTRACKNUMURL__'] =
$object->tracking_url;
9088 $substitutionarray[
'__SHIPPINGMETHOD__'] =
$object->shipping_method;
9091 '@phan-var-force Reception $object';
9092 $substitutionarray[
'__RECEPTIONTRACKNUM__'] =
$object->tracking_number;
9093 $substitutionarray[
'__RECEPTIONTRACKNUMURL__'] =
$object->tracking_url;
9097 '@phan-var-force Contrat $object';
9098 $dateplannedstart =
'';
9099 $datenextexpiration =
'';
9100 foreach (
$object->lines as $line) {
9101 if ($line->date_start > $dateplannedstart) {
9102 $dateplannedstart = $line->date_start;
9104 if ($line->statut == 4 && $line->date_end && (!$datenextexpiration || $line->date_end < $datenextexpiration)) {
9105 $datenextexpiration = $line->date_end;
9108 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE__'] =
dol_print_date($dateplannedstart,
'day');
9109 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATE_RFC__'] =
dol_print_date($dateplannedstart,
'dayrfc');
9110 $substitutionarray[
'__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] =
dol_print_date($dateplannedstart,
'standard');
9112 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE__'] =
dol_print_date($datenextexpiration,
'day');
9113 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATE_RFC__'] =
dol_print_date($datenextexpiration,
'dayrfc');
9114 $substitutionarray[
'__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] =
dol_print_date($datenextexpiration,
'standard');
9118 '@phan-var-force Ticket $object';
9119 $substitutionarray[
'__TICKET_TRACKID__'] =
$object->track_id;
9120 $substitutionarray[
'__TICKET_SUBJECT__'] =
$object->subject;
9121 $substitutionarray[
'__TICKET_TYPE__'] =
$object->type_code;
9122 $substitutionarray[
'__TICKET_SEVERITY__'] =
$object->severity_code;
9123 $substitutionarray[
'__TICKET_CATEGORY__'] =
$object->category_code;
9124 $substitutionarray[
'__TICKET_ANALYTIC_CODE__'] =
$object->category_code;
9125 $substitutionarray[
'__TICKET_MESSAGE__'] =
$object->message;
9126 $substitutionarray[
'__TICKET_PROGRESSION__'] =
$object->progress;
9127 $userstat =
new User($db);
9128 if (
$object->fk_user_assign > 0) {
9129 $userstat->fetch(
$object->fk_user_assign);
9130 $substitutionarray[
'__TICKET_USER_ASSIGN__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
9133 if (
$object->fk_user_create > 0) {
9134 $userstat->fetch(
$object->fk_user_create);
9135 $substitutionarray[
'__USER_CREATE__'] =
dolGetFirstLastname($userstat->firstname, $userstat->lastname);
9141 if (!is_object($extrafields)) {
9144 $extrafields->fetch_name_optionals_label(
$object->table_element,
true);
9146 if (
$object->fetch_optionals() > 0) {
9147 if (is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label']) > 0) {
9148 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $label) {
9149 if ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'date') {
9150 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'day');
9151 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'day',
'tzserver', $outputlangs);
9152 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] =
dol_print_date(
$object->array_options[
'options_'.$key],
'dayrfc');
9153 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'datetime') {
9154 $datetime =
$object->array_options[
'options_'.$key];
9155 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour') :
'');
9156 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhour',
'tzserver', $outputlangs) :
'');
9157 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_DAY_LOCALE__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'day',
'tzserver', $outputlangs) :
'');
9158 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_RFC__'] = ($datetime !=
"0000-00-00 00:00:00" ?
dol_print_date($datetime,
'dayhourrfc') :
'');
9159 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'phone') {
9160 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
dol_print_phone(
$object->array_options[
'options_'.$key]);
9161 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] ==
'price') {
9162 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] =
$object->array_options[
'options_'.$key];
9163 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATED__'] =
price(
$object->array_options[
'options_'.$key]);
9164 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'_FORMATTED__'] =
price(
$object->array_options[
'options_'.$key]);
9165 } elseif ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separator') {
9166 $substitutionarray[
'__EXTRAFIELD_'.strtoupper($key).
'__'] = !empty(
$object->array_options[
'options_'.$key]) ?
$object->array_options[
'options_'.$key] :
'';
9174 if (empty($substitutionarray[
'__REF__'])) {
9178 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
9179 $outputlangs->loadLangs(array(
'paypal',
'other'));
9182 $typeforonlinepayment =
'free';
9184 $typeforonlinepayment =
'order';
9187 $typeforonlinepayment =
'invoice';
9190 $typeforonlinepayment =
'member';
9191 if (!empty(
$object->last_subscription_amount)) {
9192 $amounttouse =
$object->last_subscription_amount;
9196 $typeforonlinepayment =
'contract';
9199 $typeforonlinepayment =
'ficheinter';
9202 $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray[
'__REF__'], $amounttouse);
9207 $substitutionarray[
'__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ? str_replace(
'\n',
"\n", $outputlangs->trans(
"PredefinedMailContentLink", $paymenturl)) :
'');
9208 $substitutionarray[
'__ONLINE_PAYMENT_URL__'] = $paymenturl;
9211 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
$object->getLastMainDocLink(
$object->element);
9213 $substitutionarray[
'__DIRECTDOWNLOAD_URL_PROPOSAL__'] =
'';
9216 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
$object->getLastMainDocLink(
$object->element);
9218 $substitutionarray[
'__DIRECTDOWNLOAD_URL_ORDER__'] =
'';
9221 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
$object->getLastMainDocLink(
$object->element);
9223 $substitutionarray[
'__DIRECTDOWNLOAD_URL_INVOICE__'] =
'';
9226 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
$object->getLastMainDocLink(
$object->element);
9228 $substitutionarray[
'__DIRECTDOWNLOAD_URL_CONTRACT__'] =
'';
9231 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] =
$object->getLastMainDocLink(
$object->element);
9233 $substitutionarray[
'__DIRECTDOWNLOAD_URL_FICHINTER__'] =
'';
9236 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
$object->getLastMainDocLink(
$object->element);
9238 $substitutionarray[
'__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] =
'';
9242 '@phan-var-force Propal $object';
9243 $substitutionarray[
'__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/comm/propal/card.php?id=".
$object->id;
9244 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9245 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'proposal',
$object->ref, 1,
$object);
9248 '@phan-var-force Commande $object';
9249 $substitutionarray[
'__URL_ORDER__'] = DOL_MAIN_URL_ROOT.
"/commande/card.php?id=".
$object->id;
9252 '@phan-var-force Facture $object';
9253 $substitutionarray[
'__URL_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/compta/facture/card.php?id=".
$object->id;
9256 '@phan-var-force Contrat $object';
9257 $substitutionarray[
'__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT.
"/contrat/card.php?id=".
$object->id;
9258 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9259 $substitutionarray[
'__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0,
'contract',
$object->ref, 1,
$object);
9262 '@phan-var-force Fichinter $object';
9263 $substitutionarray[
'__URL_FICHINTER__'] = DOL_MAIN_URL_ROOT.
"/fichinter/card.php?id=".
$object->id;
9264 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
9265 $substitutionarray[
'__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0,
'fichinter',
$object->ref, 1,
$object);
9267 if (is_object(
$object) &&
$object->element ==
'supplier_proposal') {
9268 '@phan-var-force SupplierProposal $object';
9269 $substitutionarray[
'__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT.
"/supplier_proposal/card.php?id=".
$object->id;
9271 if (is_object(
$object) &&
$object->element ==
'invoice_supplier') {
9272 '@phan-var-force FactureFournisseur $object';
9273 $substitutionarray[
'__URL_SUPPLIER_INVOICE__'] = DOL_MAIN_URL_ROOT.
"/fourn/facture/card.php?id=".
$object->id;
9276 '@phan-var-force Expedition $object';
9277 $substitutionarray[
'__URL_SHIPMENT__'] = DOL_MAIN_URL_ROOT.
"/expedition/card.php?id=".
$object->id;
9282 '@phan-var-force ActionComm $object';
9283 $substitutionarray[
'__EVENT_LABEL__'] =
$object->label;
9284 $substitutionarray[
'__EVENT_TYPE__'] = $outputlangs->trans(
"Action".
$object->type_code);
9286 $substitutionarray[
'__EVENT_TIME__'] =
dol_print_date(
$object->datep,
'hour',
'auto', $outputlangs);
9290 if ((empty($exclude) || !in_array(
'objectamount', $exclude)) && (empty($include) || in_array(
'objectamount', $include))) {
9291 '@phan-var-force Facture|FactureRec $object';
9292 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functionsnumtoword.lib.php';
9295 $substitutionarray[
'__DATE_DUE_YMD__'] = is_object(
$object) ? (isset(
$object->date_lim_reglement) ?
dol_print_date(
$object->date_lim_reglement,
'day', 0, $outputlangs) : null) :
'';
9297 $substitutionarray[
'__DATE_DUE_YMD_TEXT__'] = is_object(
$object) ? (isset(
$object->date_lim_reglement) ?
dol_print_date(
$object->date_lim_reglement,
'daytext', 0, $outputlangs) : null) :
'';
9299 $already_payed_all = 0;
9304 $substitutionarray[
'__AMOUNT_EXCL_TAX__'] = is_object(
$object) ?
$object->total_ht :
'';
9306 $substitutionarray[
'__AMOUNT_EXCL_TAX_TEXTCURRENCY__'] = is_object(
$object) ?
dol_convertToWord(
$object->total_ht, $outputlangs, $conf->currency,
true) :
'';
9308 $substitutionarray[
'__AMOUNT__'] = is_object(
$object) ?
$object->total_ttc :
'';
9312 $substitutionarray[
'__AMOUNT_REMAIN__'] = is_object(
$object) ?
price2num(
$object->total_ttc - $already_payed_all,
'MT') :
'';
9314 $substitutionarray[
'__AMOUNT_VAT__'] = is_object(
$object) ? (isset(
$object->total_vat) ?
$object->total_vat :
$object->total_tva) :
'';
9318 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
9319 $substitutionarray[
'__AMOUNT_TAX2__'] = is_object(
$object) ?
$object->total_localtax1 :
'';
9321 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
9322 $substitutionarray[
'__AMOUNT_TAX3__'] = is_object(
$object) ?
$object->total_localtax2 :
'';
9326 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATTED__'] = is_object(
$object) ? (
$object->total_ht ?
price(
$object->total_ht, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) :
'';
9327 $substitutionarray[
'__AMOUNT_FORMATTED__'] = is_object(
$object) ? (
$object->total_ttc ?
price(
$object->total_ttc, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) :
'';
9328 $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) :
'';
9329 $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)) :
'';
9330 if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
9331 $substitutionarray[
'__AMOUNT_TAX2_FORMATTED__'] = is_object(
$object) ? (
$object->total_localtax1 ?
price(
$object->total_localtax1, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) :
'';
9333 if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
9334 $substitutionarray[
'__AMOUNT_TAX3_FORMATTED__'] = is_object(
$object) ? (
$object->total_localtax2 ?
price(
$object->total_localtax2, 0, $outputlangs, 0, -1, -1, $conf->currency) : null) :
'';
9337 if ($onlykey != 2) {
9338 $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATED__'] = $substitutionarray[
'__AMOUNT_EXCL_TAX_FORMATTED__'];
9339 $substitutionarray[
'__AMOUNT_FORMATED__'] = $substitutionarray[
'__AMOUNT_FORMATTED__'];
9340 $substitutionarray[
'__AMOUNT_REMAIN_FORMATED__'] = $substitutionarray[
'__AMOUNT_REMAIN_FORMATTED__'];
9341 $substitutionarray[
'__AMOUNT_VAT_FORMATED__'] = $substitutionarray[
'__AMOUNT_VAT_FORMATTED__'];
9342 if ($mysoc instanceof
Societe && $mysoc->useLocalTax(1)) {
9343 $substitutionarray[
'__AMOUNT_TAX2_FORMATED__'] = $substitutionarray[
'__AMOUNT_TAX2_FORMATTED__'];
9345 if ($mysoc instanceof
Societe && $mysoc->useLocalTax(2)) {
9346 $substitutionarray[
'__AMOUNT_TAX3_FORMATED__'] = $substitutionarray[
'__AMOUNT_TAX3_FORMATTED__'];
9350 $substitutionarray[
'__AMOUNT_MULTICURRENCY__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
$object->multicurrency_total_ttc :
'';
9351 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXT__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
dol_convertToWord(
$object->multicurrency_total_ttc, $outputlangs,
'',
true) :
'';
9352 $substitutionarray[
'__AMOUNT_MULTICURRENCY_TEXTCURRENCY__'] = (is_object(
$object) && isset(
$object->multicurrency_total_ttc)) ?
dol_convertToWord(
$object->multicurrency_total_ttc, $outputlangs,
$object->multicurrency_code,
true) :
'';
9356 if ($onlykey != 2) {
9357 $substitutionarray[
'__TOTAL_TTC__'] = is_object(
$object) ?
$object->total_ttc :
'';
9358 $substitutionarray[
'__TOTAL_HT__'] = is_object(
$object) ?
$object->total_ht :
'';
9364 if ((empty($exclude) || !in_array(
'date', $exclude)) && (empty($include) || in_array(
'date', $include))) {
9365 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
9375 $daytext = $outputlangs->trans(
'Day'.$tmp[
'wday']);
9377 $substitutionarray = array_merge($substitutionarray, array(
9378 '__NOW_TMS__' => (
string) $now,
9379 '__NOW_TMS_YMD__' =>
dol_print_date($now,
'day',
'auto', $outputlangs),
9380 '__DAY__' => (
string) $tmp[
'mday'],
9381 '__DAY_TEXT__' => $daytext,
9382 '__DAY_TEXT_SHORT__' =>
dol_trunc($daytext, 3,
'right',
'UTF-8', 1),
9383 '__DAY_TEXT_MIN__' =>
dol_trunc($daytext, 1,
'right',
'UTF-8', 1),
9384 '__MONTH__' => (
string) $tmp[
'mon'],
9385 '__MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp[
'mon'])),
9386 '__MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp[
'mon'])),
9387 '__MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp[
'mon'])),
9388 '__YEAR__' => (
string) $tmp[
'year'],
9389 '__PREVIOUS_DAY__' => (
string) $tmp2[
'day'],
9390 '__PREVIOUS_MONTH__' => (
string) $tmp3[
'month'],
9391 '__PREVIOUS_YEAR__' => (
string) ($tmp[
'year'] - 1),
9392 '__NEXT_DAY__' => (
string) $tmp4[
'day'],
9393 '__NEXT_MONTH__' => (
string) $tmp5[
'month'],
9394 '__NEXT_MONTH_TEXT__' => $outputlangs->trans(
'Month'.sprintf(
"%02d", $tmp5[
'month'])),
9395 '__NEXT_MONTH_TEXT_SHORT__' => $outputlangs->trans(
'MonthShort'.sprintf(
"%02d", $tmp5[
'month'])),
9396 '__NEXT_MONTH_TEXT_MIN__' => $outputlangs->trans(
'MonthVeryShort'.sprintf(
"%02d", $tmp5[
'month'])),
9397 '__NEXT_YEAR__' => (
string) ($tmp[
'year'] + 1),
9401 if (isModEnabled(
'multicompany')) {
9402 $substitutionarray = array_merge($substitutionarray, array(
'__ENTITY_ID__' => $conf->entity));
9404 if ((empty($exclude) || !in_array(
'system', $exclude)) && (empty($include) || in_array(
'user', $include))) {
9405 $substitutionarray[
'__DOL_MAIN_URL_ROOT__'] = DOL_MAIN_URL_ROOT;
9406 $substitutionarray[
'__(AnyTranslationKey)__'] = $outputlangs->trans(
'TranslationOfKey');
9407 $substitutionarray[
'__(AnyTranslationKey|langfile)__'] = $outputlangs->trans(
'TranslationOfKey').
' (load also language file before)';
9408 $substitutionarray[
'__[AnyConstantKey]__'] = $outputlangs->trans(
'ValueOfConstantKey');
9413 return $substitutionarray;
9432function make_substitutions($text, $substitutionarray, $outputlangs =
null, $converttextinhtmlifnecessary = 0)
9434 global $conf, $db, $langs;
9436 if (!is_array($substitutionarray)) {
9437 return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
9440 if (empty($outputlangs)) {
9441 $outputlangs = $langs;
9451 if (is_object($outputlangs)) {
9453 while (preg_match(
'/__\(([^\)]+)\)__/', $text, $reg)) {
9455 $tmp = explode(
'|', $reg[1]);
9456 if (!empty($tmp[1])) {
9457 $outputlangs->load($tmp[1]);
9460 $value = $outputlangs->transnoentitiesnoconv($reg[1]);
9462 if (empty($converttextinhtmlifnecessary)) {
9464 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
9478 $text = preg_replace(
'/__\('.preg_quote($reg[1],
'/').
'\)__/', $value, $text);
9486 while (preg_match(
'/__\[([^\]]+)\]__/', $text, $reg)) {
9487 $keyfound = $reg[1];
9489 $value =
'*****forbidden*****';
9491 $value = empty($conf->global->$keyfound) ?
'' : $conf->global->$keyfound;
9494 if (empty($converttextinhtmlifnecessary)) {
9496 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $msgishtml ?
dol_htmlentitiesbr($value) : $value, $text);
9509 $text = preg_replace(
'/__\['.preg_quote($keyfound,
'/').
'\]__/', $value, $text);
9514 foreach ($substitutionarray as $key => $value) {
9515 if (!isset($value)) {
9519 if (($key ==
'__USER_SIGNATURE__' || $key ==
'__SENDEREMAIL_SIGNATURE__') && (
getDolGlobalString(
'MAIN_MAIL_DO_NOT_USE_SIGN'))) {
9523 if (empty($converttextinhtmlifnecessary)) {
9524 $text = str_replace(
"$key",
"$value", $text);
9536 $text = str_replace(
"$key",
"$value", $text);
9552 $memory_object_list = array();
9553 foreach ($substitutionarray as $key => $value) {
9554 $lazy_load_arr = array();
9555 if (preg_match(
'/(__[A-Z\_]+__)@lazyload$/', $key, $lazy_load_arr)) {
9556 if (isset($lazy_load_arr[1]) && !empty($lazy_load_arr[1])) {
9557 $key_to_substitute = $lazy_load_arr[1];
9558 if (preg_match(
'/' . preg_quote($key_to_substitute,
'/') .
'/', $text)) {
9559 $param_arr = explode(
':', $value);
9561 if (count($param_arr) == 4) {
9562 $path = $param_arr[0];
9563 $class = $param_arr[1];
9564 $method = $param_arr[2];
9565 $id = (int) $param_arr[3];
9568 if (!isset($memory_object_list[$class])) {
9570 require_once DOL_DOCUMENT_ROOT . $path;
9571 if (class_exists($class)) {
9572 $memory_object_list[$class] = array(
9580 if (isset($memory_object_list[$class]) && isset($memory_object_list[$class][
'list'])) {
9581 if (method_exists($class, $method)) {
9582 if (!isset($memory_object_list[$class][
'list'][$id])) {
9583 $tmpobj =
new $class($db);
9585 $valuetouseforsubstitution = $tmpobj->$method($id, $key_to_substitute);
9586 $memory_object_list[$class][
'list'][$id] = $tmpobj;
9589 $tmpobj = $memory_object_list[$class][
'list'][$id];
9591 $valuetouseforsubstitution = $tmpobj->$method($id, $key_to_substitute,
true);
9594 $text = str_replace(
"$key_to_substitute",
"$valuetouseforsubstitution", $text);
9620 global $conf, $user;
9622 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
9627 $dirsubstitutions = array_merge(array(), (array) $conf->modules_parts[
'substitutions']);
9629 foreach ($dirsubstitutions as $reldir) {
9637 $substitfiles =
dol_dir_list($dir,
'files', 0,
'functions_');
9638 foreach ($substitfiles as $substitfile) {
9640 if (preg_match(
'/functions_(.*)\.lib\.php/i', $substitfile[
'name'], $reg)) {
9643 dol_syslog(
"Library ".$substitfile[
'name'].
" found into ".$dir);
9645 require_once $dir.$substitfile[
'name'];
9647 $function_name = $module.
"_".$callfunc;
9648 if (function_exists($function_name)) {
9649 $function_name($substitutionarray, $outputlangs,
$object, $parameters);
9657 foreach ($substitutionarray as $key => $value) {
9658 $tags .=
'{'.$key.
'} => '.$value.
"\n";
9660 $substitutionarray = array_merge($substitutionarray, array(
'__ALL_TAGS__' => $tags));
9673function print_date_range($date_start, $date_end, $format =
'', $outputlangs =
null)
9675 print
get_date_range($date_start, $date_end, $format, $outputlangs);
9688function get_date_range($date_start, $date_end, $format =
'', $outputlangs =
null, $withparenthesis = 1)
9694 if (!is_object($outputlangs)) {
9695 $outputlangs = $langs;
9698 if ($date_start && $date_end) {
9699 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFromTo',
dol_print_date($date_start, $format,
false, $outputlangs),
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
9701 if ($date_start && !$date_end) {
9702 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateFrom',
dol_print_date($date_start, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
9704 if (!$date_start && $date_end) {
9705 $out .= ($withparenthesis ?
' (' :
'').$outputlangs->transnoentitiesnoconv(
'DateUntil',
dol_print_date($date_end, $format,
false, $outputlangs)).($withparenthesis ?
')' :
'');
9725 if ($nameorder < 0) {
9728 if ($nameorder == 1) {
9730 if ($firstname && $lastname) {
9734 } elseif ($nameorder == 2 || $nameorder == 3) {
9736 if (empty($ret) && $nameorder == 3) {
9741 if (empty($ret) && $nameorder == 5) {
9744 if ($nameorder == 0) {
9745 if ($firstname && $lastname) {
9769 if (!is_array($mesgs)) {
9770 $mesgs = trim((
string) $mesgs);
9773 if (!empty($noduplicate) && isset($_SESSION[
'dol_events'][$style]) && in_array($mesgs, $_SESSION[
'dol_events'][$style])) {
9776 $_SESSION[
'dol_events'][$style][] = $mesgs;
9780 foreach ($mesgs as $mesg) {
9781 $mesg = trim((
string) $mesg);
9783 if (!empty($noduplicate) && isset($_SESSION[
'dol_events'][$style]) && in_array($mesg, $_SESSION[
'dol_events'][$style])) {
9786 $_SESSION[
'dol_events'][$style][] = $mesg;
9804function setEventMessages($mesg, $mesgs, $style =
'mesgs', $messagekey =
'', $noduplicate = 0)
9806 if (empty($mesg) && empty($mesgs)) {
9807 dol_syslog(
"Try to add a message in stack, but value to add is empty message", LOG_WARNING);
9814 if (empty($messagekey) || empty($_COOKIE[
"DOLHIDEMESSAGE".$messagekey])) {
9815 if (!in_array((
string) $style, array(
'mesgs',
'warnings',
'errors'))) {
9816 dol_print_error(
null,
'Bad parameter style='.$style.
' for setEventMessages');
9818 if (empty($mesgs)) {
9821 if (!empty($mesg) && !in_array($mesg, $mesgs)) {
9842 if (isset($_SESSION[
'dol_events'][
'mesgs'])) {
9843 if (empty($disabledoutputofmessages)) {
9846 unset($_SESSION[
'dol_events'][
'mesgs']);
9849 if (isset($_SESSION[
'dol_events'][
'errors'])) {
9850 if (empty($disabledoutputofmessages)) {
9853 unset($_SESSION[
'dol_events'][
'errors']);
9857 if (isset($_SESSION[
'dol_events'][
'warnings'])) {
9858 if (empty($disabledoutputofmessages)) {
9861 unset($_SESSION[
'dol_events'][
'warnings']);
9879function get_htmloutput_mesg($mesgstring =
'', $mesgarray = [], $style =
'ok', $keepembedded = 0)
9881 global $conf, $langs;
9886 $divstart = $divend =
'';
9889 if ((empty($conf->use_javascript_ajax) ||
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') || $keepembedded) && !preg_match(
'/<div class=".*">/i', $out)) {
9890 $divstart =
'<div class="'.$style.
' clearboth">';
9894 if ((is_array($mesgarray) && count($mesgarray)) || $mesgstring) {
9895 $langs->load(
"errors");
9897 if (is_array($mesgarray) && count($mesgarray)) {
9898 foreach ($mesgarray as $message) {
9900 $out .= $langs->trans($message);
9901 if ($ret < count($mesgarray)) {
9908 $out .= $langs->trans($mesgstring);
9914 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_DISABLE_JQUERY_JNOTIFY') && empty($keepembedded)) {
9915 $return =
'<script nonce="'.getNonce().
'">
9916 $(document).ready(function() {
9921 /* jnotify(message, preset of message type, keepmessage) */
9923 "'.($style ==
"ok" ? 3000 : $style).
'",
9924 '.($style ==
"ok" ?
"false" :
"true").
',
9925 { remove: function (){} } );
9966function dol_htmloutput_mesg($mesgstring =
'', $mesgarray = array(), $style =
'ok', $keepembedded = 0)
9968 if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) {
9974 if (is_array($mesgarray)) {
9975 foreach ($mesgarray as $val) {
9976 if ($val && preg_match(
'/class="error"/i', $val)) {
9980 if ($val && preg_match(
'/class="warning"/i', $val)) {
9985 } elseif ($mesgstring && preg_match(
'/class="error"/i', $mesgstring)) {
9987 } elseif ($mesgstring && preg_match(
'/class="warning"/i', $mesgstring)) {
9990 if ($style ==
'error') {
9993 if ($style ==
'warning') {
9997 if ($iserror || $iswarning) {
9999 $mesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $mesgstring);
10000 $mesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $mesgstring);
10001 $mesgstring = preg_replace(
'/<\/div>/',
'', $mesgstring);
10003 if (is_array($mesgarray)) {
10004 $newmesgarray = array();
10005 foreach ($mesgarray as $val) {
10006 if (is_string($val)) {
10007 $tmpmesgstring = preg_replace(
'/<\/div><div class="(error|warning)">/',
'<br>', $val);
10008 $tmpmesgstring = preg_replace(
'/<div class="(error|warning)">/',
'', $tmpmesgstring);
10009 $tmpmesgstring = preg_replace(
'/<\/div>/',
'', $tmpmesgstring);
10010 $newmesgarray[] = $tmpmesgstring;
10012 dol_syslog(
"Error call of dol_htmloutput_mesg with an array with a value that is not a string", LOG_WARNING);
10015 $mesgarray = $newmesgarray;
10017 print
get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ?
'error' :
'warning'), $keepembedded);
10052function dol_sort_array(&$array, $index, $order =
'asc', $natsort = 0, $case_sensitive = 0, $keepindex = 0)
10055 $order = strtolower($order);
10057 if (is_array($array)) {
10058 $sizearray = count($array);
10059 if ($sizearray > 0) {
10061 foreach (array_keys($array) as $key) {
10062 if (is_object($array[$key])) {
10063 $temp[$key] = empty($array[$key]->$index) ? 0 : $array[$key]->$index;
10066 $temp[$key] = empty($array[$key][$index]) ? 0 : $array[$key][$index];
10068 if ($natsort == -1) {
10069 $temp[$key] =
'___'.$temp[$key];
10073 if (empty($natsort) || $natsort == -1) {
10074 if ($order ==
'asc') {
10080 if ($case_sensitive) {
10083 natcasesort($temp);
10085 if ($order !=
'asc') {
10086 $temp = array_reverse($temp,
true);
10092 foreach (array_keys($temp) as $key) {
10093 (is_numeric($key) && empty($keepindex)) ? $sorted[] = $array[$key] : $sorted[$key] = $array[$key];
10112 $str = (string) $str;
10115 $strLength = strlen($str);
10116 for ($i = 0; $i < $strLength; $i++) {
10117 if (ord($str[$i]) < 0x80) {
10119 } elseif ((ord($str[$i]) & 0xE0) == 0xC0) {
10121 } elseif ((ord($str[$i]) & 0xF0) == 0xE0) {
10123 } elseif ((ord($str[$i]) & 0xF8) == 0xF0) {
10125 } elseif ((ord($str[$i]) & 0xFC) == 0xF8) {
10127 } elseif ((ord($str[$i]) & 0xFE) == 0xFC) {
10132 for ($j = 0; $j < $n; $j++) {
10133 if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) {
10154 return preg_match(
'//u', $str) ? true :
false;
10166 if (function_exists(
'mb_check_encoding')) {
10168 if (!mb_check_encoding($str,
'ASCII')) {
10172 if (preg_match(
'/[^\x00-\x7f]/', $str)) {
10190 $tmp = ini_get(
"unicode.filesystem_encoding");
10191 if (empty($tmp) && !empty($_SERVER[
"WINDIR"])) {
10192 $tmp =
'iso-8859-1';
10201 if ($tmp ==
'iso-8859-1') {
10202 return mb_convert_encoding($str,
'ISO-8859-1',
'UTF-8');
10223function dol_getIdFromCode($db, $key, $tablename, $fieldkey =
'code', $fieldid =
'id', $entityfilter = 0, $filters =
'', $useCache =
true)
10233 if ($useCache && isset($conf->cache[
'codeid'][$tablename][$key][$fieldid])) {
10234 return $conf->cache[
'codeid'][$tablename][$key][$fieldid];
10237 dol_syslog(
'dol_getIdFromCode (value for field '.$fieldid.
' from key '.$key.
' not found into cache)', LOG_DEBUG);
10239 $sql =
"SELECT ".$fieldid.
" as valuetoget";
10240 $sql .=
" FROM ".MAIN_DB_PREFIX.$tablename;
10241 $sql .=
" WHERE ".$fieldkey.
" = '".$db->escape($key).
"'";
10242 if (!empty($entityfilter)) {
10243 $sql .=
" AND entity IN (".getEntity($tablename).
")";
10249 $resql = $db->query($sql);
10251 $obj = $db->fetch_object($resql);
10254 $valuetoget = $obj->valuetoget;
10255 $conf->cache[
'codeid'][$tablename][$key][$fieldid] = $valuetoget;
10257 $conf->cache[
'codeid'][$tablename][$key][$fieldid] =
'';
10261 return $valuetoget;
10278 if ($matchrule == 1) {
10279 if ($var ==
'mainmenu') {
10281 return (preg_match(
'/^'.$regextext.
'/', $mainmenu));
10282 } elseif ($var ==
'leftmenu') {
10284 return (preg_match(
'/^'.$regextext.
'/', $leftmenu));
10286 return 'This variable is not accessible with dol_eval';
10289 return 'This value for matchrule is not implemented';
10303function verifCond($strToEvaluate, $onlysimplestring =
'1')
10307 if (isset($strToEvaluate) && $strToEvaluate !==
'') {
10310 $rep =
dol_eval($strToEvaluate, 1, 1, $onlysimplestring);
10311 $rights = (bool) $rep && (!is_string($rep) || strpos($rep,
'Bad string syntax to evaluate') ===
false);
10331function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring =
'1')
10335 global $db, $langs, $user, $website, $websitepage;
10336 global $action, $mainmenu, $leftmenu;
10338 global $objectoffield;
10344 $isObBufferActive =
false;
10345 if (!in_array($onlysimplestring, array(
'0',
'1',
'2'))) {
10346 return "Bad call of dol_eval. Parameter onlysimplestring must be '0' (deprecated), '1' or '2'";
10351 if ($onlysimplestring ==
'1' || $onlysimplestring ==
'2') {
10357 $specialcharsallowed =
'^$_+-.*>&|=!?():"\',/@';
10358 if ($onlysimplestring ==
'2') {
10359 $specialcharsallowed .=
'[]';
10362 $specialcharsallowed .=
getDolGlobalString(
'MAIN_ALLOW_UNSECURED_SPECIAL_CHARS_IN_DOL_EVAL');
10364 if (preg_match(
'/[^a-z0-9\s'.preg_quote($specialcharsallowed,
'/').
']/i', $s)) {
10365 if ($returnvalue) {
10366 return 'Bad string syntax to evaluate (found chars that are not chars for a simple clean eval string): '.$s;
10368 dol_syslog(
'Bad string syntax to evaluate (found chars that are not chars for a simple clean eval string): '.$s, LOG_WARNING);
10374 if (preg_match(
'/\$[\w]*\s*\(/', $s)) {
10375 if ($returnvalue) {
10376 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;
10378 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);
10386 while ($scheck && $savescheck != $scheck) {
10387 $savescheck = $scheck;
10388 $scheck = preg_replace(
'/->[a-zA-Z0-9_]+\(/',
'->__METHOD__', $scheck);
10389 $scheck = preg_replace(
'/^\(/',
'__PARENTHESIS__ ', $scheck);
10390 $scheck = preg_replace(
'/\s\(/',
'__PARENTHESIS__ ', $scheck);
10391 $scheck = preg_replace(
'/^!?[a-zA-Z0-9_]+\(/',
'__FUNCTION__', $scheck);
10392 $scheck = preg_replace(
'/\s!?[a-zA-Z0-9_]+\(/',
'__FUNCTION__', $scheck);
10393 $scheck = preg_replace(
'/(\^|\')\(/',
'__REGEXSTART__', $scheck);
10396 if (strpos($scheck,
'(') !==
false) {
10397 if ($returnvalue) {
10398 return 'Bad string syntax to evaluate (mode '.$onlysimplestring.
', found call of a function or method without using the direct name of the function): '.$s;
10400 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);
10409 if (is_array($s) || $s ===
'Array') {
10410 if ($returnvalue) {
10411 return 'Bad string syntax to evaluate (value is Array): '.var_export($s,
true);
10413 dol_syslog(
'Bad string syntax to evaluate (value is Array): '.var_export($s,
true), LOG_WARNING);
10418 if (!
getDolGlobalString(
'MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL') && strpos($s,
'::') !==
false) {
10419 if ($returnvalue) {
10420 return 'Bad string syntax to evaluate (double : char is forbidden without setting MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL): '.$s;
10422 dol_syslog(
'Bad string syntax to evaluate (double : char is forbidden without setting MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL): '.$s, LOG_WARNING);
10427 if (strpos($s,
'`') !==
false) {
10428 if ($returnvalue) {
10429 return 'Bad string syntax to evaluate (backtick char is forbidden): '.$s;
10431 dol_syslog(
'Bad string syntax to evaluate (backtick char is forbidden): '.$s, LOG_WARNING);
10438 if (preg_match(
'/[^0-9]+\.[^0-9]+/', $s)) {
10439 if ($returnvalue) {
10440 return 'Bad string syntax to evaluate (dot char is forbidden): '.$s;
10442 dol_syslog(
'Bad string syntax to evaluate (dot char is forbidden): '.$s, LOG_WARNING);
10449 $forbiddenphpstrings = array(
'$$',
'$_',
'}[');
10450 $forbiddenphpstrings = array_merge($forbiddenphpstrings, array(
'_ENV',
'_SESSION',
'_COOKIE',
'_GET',
'_POST',
'_REQUEST',
'ReflectionFunction'));
10452 $forbiddenphpfunctions = array();
10454 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"base64".
"_".
"decode",
"rawurl".
"decode",
"url".
"decode",
"str".
"_rot13",
"hex".
"2bin"));
10455 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"fopen",
"file_put_contents",
"fputs",
"fputscsv",
"fwrite",
"fpassthru",
"require",
"include",
"mkdir",
"rmdir",
"symlink",
"touch",
"unlink",
"umask"));
10456 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"override_function",
"session_id",
"session_create_id",
"session_regenerate_id"));
10457 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"get_defined_functions",
"get_defined_vars",
"get_defined_constants",
"get_declared_classes"));
10458 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"function",
"call_user_func"));
10459 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"require",
"include",
"require_once",
"include_once"));
10460 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"exec",
"passthru",
"shell_exec",
"system",
"proc_open",
"popen"));
10461 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_eval",
"executeCLI",
"verifCond"));
10462 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"eval",
"create_function",
"assert",
"mb_ereg_replace"));
10463 $forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array(
"dol_compress_dir",
"dol_decode",
"dol_delete_file",
"dol_delete_dir",
"dol_delete_dir_recursive",
"dol_copy",
"archiveOrBackupFile"));
10465 $forbiddenphpmethods = array(
'invoke',
'invokeArgs');
10467 $forbiddenphpregex =
'global\s+\$|\b('.implode(
'|', $forbiddenphpfunctions).
')\b';
10469 $forbiddenphpmethodsregex =
'->('.implode(
'|', $forbiddenphpmethods).
')';
10472 $oldstringtoclean = $s;
10473 $s = str_ireplace($forbiddenphpstrings,
'__forbiddenstring__', $s);
10474 $s = preg_replace(
'/'.$forbiddenphpregex.
'/i',
'__forbiddenstring__', $s);
10475 $s = preg_replace(
'/'.$forbiddenphpmethodsregex.
'/i',
'__forbiddenstring__', $s);
10477 }
while ($oldstringtoclean != $s);
10480 if (strpos($s,
'__forbiddenstring__') !==
false) {
10481 dol_syslog(
'Bad string syntax to evaluate: '.$s, LOG_WARNING);
10482 if ($returnvalue) {
10483 return 'Bad string syntax to evaluate: '.$s;
10485 dol_syslog(
'Bad string syntax to evaluate: '.$s);
10491 if ($returnvalue) {
10494 $isObBufferActive =
true;
10495 $tmps = @eval(
'return '.$s.
';');
10496 $tmpo = ob_get_clean();
10497 $isObBufferActive =
false;
10499 print
'Bad string syntax to evaluate. Some data were output when it should not when evaluating: '.$s;
10504 $isObBufferActive =
true;
10505 $tmps = eval(
'return '.$s.
';');
10506 $tmpo = ob_get_clean();
10507 $isObBufferActive =
false;
10509 print
'Bad string syntax to evaluate. Some data were output when it should not when evaluating: '.$s;
10514 dol_syslog(
'Do not use anymore dol_eval with param returnvalue=0', LOG_WARNING);
10522 }
catch (Error $e) {
10523 if ($isObBufferActive) {
10525 $tmpo = ob_get_clean();
10526 $isObBufferActive =
false;
10528 $error =
'dol_eval try/catch error : ';
10529 $error .= $e->getMessage();
10531 if ($returnvalue) {
10532 return 'Exception during evaluation: '.$s;
10548 return (trim($element) !=
'');
10561 if (empty($codelang)) {
10565 if ($codelang ==
'auto') {
10566 return '<span class="fa fa-language"></span>';
10569 $langtocountryflag = array(
10571 'ca_ES' =>
'catalonia',
10575 'sw_SW' =>
'unknown',
10585 if (isset($langtocountryflag[$codelang])) {
10586 $flagImage = $langtocountryflag[$codelang];
10588 $tmparray = explode(
'_', $codelang);
10589 $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
10594 if (preg_match(
'/class="([^"]+)"/', $moreatt, $reg)) {
10595 $morecss = $reg[1];
10600 return '<span class="flag-sprite '.strtolower($flagImage).($morecss ?
' '.$morecss :
'').
'"'.($moreatt ?
' '.$moreatt :
'').(!$notitlealt ?
' title="'.$codelang.
'"' :
'').
'></span>';
10614 if (empty($countrycode)) {
10618 if (strtoupper($countrycode) ==
'MQ') {
10621 if (strtoupper($countrycode) ==
'SE') {
10624 if (strtoupper($countrycode) ==
'CH') {
10625 if ($mysoc->country_code ==
'FR') {
10628 if ($mysoc->country_code ==
'DE') {
10631 if ($mysoc->country_code ==
'IT') {
10813 $buildprimarykeytotest = strtolower($countrycode).
'-'.strtoupper($countrycode);
10814 if (in_array($buildprimarykeytotest, $locales)) {
10815 return strtolower($countrycode).
'_'.strtoupper($countrycode);
10818 if (function_exists(
'locale_get_primary_language') && function_exists(
'locale_get_region')) {
10819 foreach ($locales as $locale) {
10820 $locale_language = locale_get_primary_language($locale);
10821 $locale_region = locale_get_region($locale);
10822 if (strtoupper($countrycode) == $locale_region) {
10824 return strtolower($locale_language).
'_'.strtoupper($locale_region);
10828 dol_syslog(
"Warning Extension php-intl is not available", LOG_WARNING);
10866 global $hookmanager, $db;
10868 if (isset($conf->modules_parts[
'tabs'][$type]) && is_array($conf->modules_parts[
'tabs'][$type])) {
10869 foreach ($conf->modules_parts[
'tabs'][$type] as $value) {
10870 $values = explode(
':', $value);
10873 if ($mode ==
'add' && !preg_match(
'/^\-/', $values[1])) {
10878 $posstart = strpos($str,
'(');
10879 if ($posstart > 0) {
10880 $posend = strpos($str,
')');
10881 if ($posstart > 0) {
10882 $res1 = substr($str, $posstart + 1, $posend - $posstart - 1);
10883 if (is_numeric($res1)) {
10884 $postab = (int) $res1;
10885 $values[1] =
'+' . substr($str, $posend + 1);
10889 if (count($values) == 6) {
10893 if ($values[0] != $type) {
10899 if ($filterorigmodule) {
10900 if (strpos($values[3],
'@')) {
10901 if ($filterorigmodule !=
'external') {
10905 if ($filterorigmodule !=
'core') {
10910 $langs->load($values[3]);
10912 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
10914 $substitutionarray = array();
10919 $labeltemp = explode(
',', $values[2]);
10920 $label = $langs->trans($labeltemp[0]);
10922 if (!empty($labeltemp[1]) && is_object(
$object) && !empty(
$object->id)) {
10924 $classtoload = $labeltemp[1];
10925 if (class_exists($classtoload)) {
10926 $obj =
new $classtoload($db);
10927 $function = $labeltemp[3];
10928 if ($obj && $function && method_exists($obj, $function)) {
10930 $nbrec = $obj->$function(
$object->id, $obj);
10931 if (!empty($nbrec)) {
10932 $label .=
'<span class="badge marginleftonlyshort">'.$nbrec.
'</span>';
10940 $newtab[1] = $label;
10941 $newtab[2] = str_replace(
'+',
'', $values[1]);
10946 } elseif (count($values) == 5) {
10947 dol_syslog(
'Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
10949 if ($values[0] != $type) {
10953 if ($filterorigmodule) {
10954 if (strpos($values[3],
'@')) {
10955 if ($filterorigmodule !=
'external') {
10959 if ($filterorigmodule !=
'core') {
10964 $langs->load($values[3]);
10966 if (preg_match(
'/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
10967 $substitutionarray = array();
10971 $label = $langs->trans($values[2]);
10975 $newtab[1] = $label;
10976 $newtab[2] = str_replace(
'+',
'', $values[1]);
10980 $head = array_merge(array_slice($head, 0, $postab), array($newtab), array_slice($head, $postab));
10981 } elseif ($mode ==
'remove' && preg_match(
'/^\-/', $values[1])) {
10982 if ($values[0] != $type) {
10985 $tabname = str_replace(
'-',
'', $values[1]);
10986 foreach ($head as $key => $val) {
10987 $condition = (!empty($values[3]) ?
verifCond($values[3],
'2') : 1);
10989 if ($head[$key][2] == $tabname && $condition) {
10990 unset($head[$key]);
10999 if (!empty($hookmanager)) {
11000 $parameters = array(
'object' =>
$object,
'mode' => $mode,
'head' => &$head,
'filterorigmodule' => $filterorigmodule);
11001 $reshook = $hookmanager->executeHooks(
'completeTabsHead', $parameters,
$object);
11002 if ($reshook > 0) {
11003 $head = $hookmanager->resArray;
11005 $head = array_merge($head, $hookmanager->resArray);
11024 global $conf, $hookmanager, $user, $langs;
11027 global $micro_start_time;
11029 if ($zone ==
'private') {
11030 print
"\n".
'<!-- Common footer for private page -->'.
"\n";
11032 print
"\n".
'<!-- Common footer for public page -->'.
"\n";
11036 print
"\n<!-- A div to store page_y POST parameter -->\n";
11037 print
'<div id="page_y" style="display: none;">'.(GETPOST(
'page_y') ?
GETPOST(
'page_y') :
'').
'</div>'.
"\n";
11039 $parameters = array();
11040 $reshook = $hookmanager->executeHooks(
'printCommonFooter', $parameters);
11041 if (empty($reshook)) {
11047 if (!empty($conf->use_javascript_ajax)) {
11048 print
"\n<!-- A script section to add menuhider handler on backoffice, manage focus and mandatory fields, tuning info, ... -->\n";
11049 print
'<script>'.
"\n";
11050 print
'jQuery(document).ready(function() {'.
"\n";
11052 if ($zone ==
'private' && empty($conf->dol_use_jmobile)) {
11054 print
'/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'.
"\n";
11055 print
'jQuery("li.menuhider").click(function(event) {';
11056 print
' if (!$( "body" ).hasClass( "sidebar-collapse" )){ event.preventDefault(); }'.
"\n";
11057 print
' console.log("We click on .menuhider");'.
"\n";
11058 print
' $("body").toggleClass("sidebar-collapse")'.
"\n";
11063 if ($action ==
'create' || $action ==
'add' || $action ==
'edit' || (empty($action) && (preg_match(
'/new\.php/', $_SERVER[
"PHP_SELF"]))) || ((empty($action) || $action ==
'addline') && (preg_match(
'/card\.php/', $_SERVER[
"PHP_SELF"])))) {
11064 print
'/* JS CODE TO ENABLE to manage focus and mandatory form fields */'.
"\n";
11065 $relativepathstring = $_SERVER[
"PHP_SELF"];
11067 if (constant(
'DOL_URL_ROOT')) {
11068 $relativepathstring = preg_replace(
'/^'.preg_quote(constant(
'DOL_URL_ROOT'),
'/').
'/',
'', $relativepathstring);
11070 $relativepathstring = preg_replace(
'/^\//',
'', $relativepathstring);
11071 $relativepathstring = preg_replace(
'/^custom\//',
'', $relativepathstring);
11074 if (!empty($user->default_values[$relativepathstring][
'focus'])) {
11075 foreach ($user->default_values[$relativepathstring][
'focus'] as $defkey => $defval) {
11077 if ($defkey !=
'_noquery_') {
11078 $tmpqueryarraytohave = explode(
'&', $defkey);
11080 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
11081 $tmpquerytohaveparam = explode(
'=', $tmpquerytohave);
11083 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] !=
GETPOST($tmpquerytohaveparam[0]))) {
11087 if (!$foundintru) {
11096 print
'console.log("set the focus by executing jQuery(...).focus();")'.
"\n";
11097 foreach ($defval as $paramkey => $paramval) {
11099 print
'jQuery("input[name=\''.$paramkey.
'\']
").focus();'."\n
";
11100 print 'jQuery("textarea[
name=\
''.$paramkey.
'\']
").focus();'."\n
"; // TODO KO with ckeditor
11101 print 'jQuery("select[
name=\
''.$paramkey.
'\']
").focus();'."\n
"; // Not really useful, but we keep it in case of.
11106 if (!empty($user->default_values[$relativepathstring]['mandatory'])) {
11107 foreach ($user->default_values[$relativepathstring]['mandatory'] as $defkey => $defval) {
11109 if ($defkey != '_noquery_') {
11110 $tmpqueryarraytohave = explode('&', $defkey);
11112 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
11113 $tmpquerytohaveparam = explode('=', $tmpquerytohave);
11114 //print "console.log(
'".$tmpquerytohaveparam[0]." ".$tmpquerytohaveparam[1]." ".GETPOST($tmpquerytohaveparam[0])."');
";
11115 if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] != GETPOST($tmpquerytohaveparam[0]))) {
11119 if (!$foundintru) {
11122 //var_dump($defkey.'-'.$qualified);
11128 print 'console.log("set the js code to manage fields that are
set as mandatory
");'."\n
";
11130 foreach ($defval as $paramkey => $paramval) {
11131 // Solution 1: Add handler on submit to check if mandatory fields are empty
11132 print 'var form = $(\'#'.dol_escape_js($paramkey).'\').closest("form
");'."\n
";
11133 print "form.on(
'submit',
function(event) {
11134 var submitter = $(
this).find(
':submit:focus').get(0);
11136 var buttonName = $(submitter).attr(
'name');
11137 if (buttonName ==
'cancel') {
11138 console.log(
'We click on cancel button so we accept submit with no need to check mandatory fields');
11143 console.log(
'We did not click on cancel button but on something else, we check that field #".dol_escape_js($paramkey)." is not empty');
11145 var tmpvalue = jQuery(
'#".dol_escape_js($paramkey)."').val();
11146 let tmptypefield = jQuery(
'#".dol_escape_js($paramkey)."').prop(
'nodeName').toLowerCase();
11148 if (tmptypefield ==
'textarea') {
11150 var tmpeditor = CKEDITOR.instances[
'".dol_escape_js($paramkey)."'];
11152 tmpvalue = tmpeditor.getData();
11153 console.log(
'For textarea tmpvalue is '+tmpvalue);
11157 let tmpvalueisempty =
false;
11158 if (tmpvalue ===
null || tmpvalue === undefined || tmpvalue ===
'') {
11159 tmpvalueisempty =
true;
11161 if (tmpvalue ===
'0' && (tmptypefield ==
'select' || tmptypefield ==
'input')) {
11162 tmpvalueisempty =
true;
11164 if (tmpvalueisempty && (buttonName ==
'save')) {
11165 console.log(
'field has type '+tmptypefield+
' and is empty, we cancel the submit');
11166 event.preventDefault();
11167 event.stopPropagation();
11168 alert(
'".dol_escape_js($langs->trans("ErrorFieldRequired", $paramkey).' (
'.$langs->trans("CustomMandatoryFieldRule").')
')."');
11171 console.log(
'field has type '+tmptypefield+
' and is defined to '+tmpvalue);
11176 // Solution 2: Add property 'required' on input
11177 // so browser will check value and try to focus on it when submitting the form.
11178 //print 'setTimeout(function() {'; // If we want to wait that ckeditor beuatifier has finished its job.
11179 //print 'jQuery("input[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
11180 //print 'jQuery("textarea[
id=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";
11181 //print 'jQuery("select[
name=\
''.$paramkey.
'\']
").prop(\'required\',true);'."\n
";*/
11182 //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
";
11183 //print 'jQuery("select[
name=\
''.$paramkey.
'\'] option[value=\
'-1\']").prop(\'value\', \'\');'.
"\n";
11189 print
'jQuery(\':input[name="' .
dol_escape_js($paramkey) .
'"]\').closest("tr").find("td:first").addClass("fieldrequired");'.
"\n";
11194 print
'jQuery("input[name=\'cancel\']").click(function() {
11195 console.log("We click on cancel button so removed all required attribute");
11196 jQuery("input, textarea, select").each(function(){this.removeAttribute(\'required\');});
11206 if (!empty($_SERVER[
'MAIN_SHOW_TUNING_INFO']) ||
getDolGlobalString(
'MAIN_SHOW_TUNING_INFO')) {
11208 print
"/* JS CODE TO ENABLE to add memory info */\n";
11209 print
'window.console && console.log("';
11214 if (!empty($micro_start_time)) {
11215 $micro_end_time = microtime(
true);
11216 print
' - Build time: '.ceil(1000 * ($micro_end_time - $micro_start_time)).
' ms';
11219 if (function_exists(
"memory_get_usage")) {
11220 print
' - Mem: '.memory_get_usage();
11222 if (function_exists(
"memory_get_peak_usage")) {
11223 print
' - Real mem peak: '.memory_get_peak_usage(
true);
11225 if (function_exists(
"zend_loader_file_encoded")) {
11226 print
' - Zend encoded file: '.(zend_loader_file_encoded() ?
'yes' :
'no');
11231 print
"\n".
'</script>'.
"\n";
11237 foreach ($tmptagarray as $tmptag) {
11239 print
"<!-- JS CODE TO ENABLE for google analtics tag -->\n";
11241 <!-- Global site tag (gtag.js) - Google Analytics -->
11242 <script nonce="'.getNonce().
'" async src="https://www.googletagmanager.com/gtag/js?id='.trim($tmptag).
'"></script>
11244 window.dataLayer = window.dataLayer || [];
11245 function gtag(){dataLayer.push(arguments);}
11246 gtag(\'js\', new Date());
11248 gtag(\'config\', \''.trim($tmptag).
'\');
11255 // Add Xdebug coverage of code
11256 if (defined('XDEBUGCOVERAGE
')) {
11257 print_r(xdebug_get_code_coverage());
11260 // Add DebugBar data
11261 if ($user->hasRight('debugbar
', 'read
') && $debugbar instanceof DebugBar\DebugBar) {
11262 if (isset($debugbar['time
'])) {
11263 // @phan-suppress-next-line PhanPluginUnknownObjectMethodCall
11264 $debugbar['time
']->stopMeasure('pageaftermaster
');
11266 print '<!-- Output debugbar data -->
'."\n";
11267 $renderer = $debugbar->getJavascriptRenderer();
11268 print $renderer->render();
11269 } elseif (count($conf->logbuffer)) { // If there is some logs in buffer to show
11271 print "<!-- Start of log output\n";
11272 //print '<div
class=
"hidden">
'."\n";
11273 foreach ($conf->logbuffer as $logline) {
11274 print $logline."<br>\n";
11276 //print '</div>
'."\n";
11277 print "End of log output -->\n";
11291function dolExplodeIntoArray($string, $delimiter = ';
', $kv = '=
')
11293 if (is_null($string)) {
11297 if (preg_match('/^\[.*\]$/sm
', $delimiter) || preg_match('/^\(.*\)$/sm
', $delimiter)) {
11298 // This is a regex string
11299 $newdelimiter = $delimiter;
11301 // This is a simple string
11302 // @phan-suppress-next-line PhanPluginSuspiciousParamPositionInternal
11303 $newdelimiter = preg_quote($delimiter, '/
');
11306 if ($a = preg_split('/
'.$newdelimiter.'/
', $string)) {
11308 foreach ($a as $s) { // each part
11310 if ($pos = strpos($s, $kv)) { // key/value delimiter
11311 $ka[trim(substr($s, 0, $pos))] = trim(substr($s, $pos + strlen($kv)));
11312 } else { // key delimiter not found
11330function dol_set_focus($selector)
11332 print "\n".'<!-- Set focus onto a specific field -->
'."\n";
11333 print '<script nonce=
"'.getNonce().'">jQuery(document).ready(
function() { jQuery(
"'.dol_escape_js($selector).'").focus(); });</script>
'."\n";
11344function dol_getmypid()
11346 if (!function_exists('getmypid
')) {
11347 return mt_rand(99900000, 99965535);
11349 return getmypid(); // May be a number on 64 bits (depending on OS)
11375function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
11377 global $db, $langs;
11379 $value = trim($value);
11382 $value = preg_replace('/\*/
', '%
', $value); // Replace * with %
11385 $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
11388 $value = preg_replace('/\s*\|\s*/
', '|
', $value);
11390 //natural mode search type 3 allow spaces into search ...
11391 if ($mode == 3 || $mode == -3) {
11392 $crits = explode(',
', $value);
11394 $crits = explode(' ', $value);
11397 if (!is_array($fields)) {
11398 $fields = array($fields);
11401 $i1 = 0; // count the nb of and criteria added (all fields / criteria)
11402 foreach ($crits as $crit) { // Loop on each AND criteria
11403 $crit = trim($crit);
11404 $i2 = 0; // count the nb of valid criteria added for this this first criteria
11406 foreach ($fields as $field) {
11408 $tmpcrits = explode('|
', $crit);
11409 $i3 = 0; // count the nb of valid criteria added for this current field
11410 foreach ($tmpcrits as $tmpcrit) {
11411 if ($tmpcrit !== '0
' && empty($tmpcrit)) {
11414 $tmpcrit = trim($tmpcrit);
11416 $newres .= (($i2 > 0 || $i3 > 0) ? ' OR
' : '');
11419 $newcrit = preg_replace('/([!<>=]+)/
', '', $tmpcrit);
11422 preg_match('/([!<>=]+)/
', $tmpcrit, $reg);
11423 if (!empty($reg[1])) {
11424 $operator = $reg[1];
11426 if ($newcrit != '') {
11427 $numnewcrit = price2num($newcrit);
11428 if (is_numeric($numnewcrit)) {
11429 $newres .= $field.' '.$operator.' '.((float) $numnewcrit); // should be a numeric
11431 $newres .= '1 = 2
'; // force false, we received a corrupted data
11433 $i3++; // a criteria was added to string
11436 $i2++; // a criteria for 1 more field was added to string
11437 } elseif ($mode == 2 || $mode == -2) {
11438 $crit = preg_replace('/[^0-9,]/
', '', $crit); // ID are always integer
11439 $newres .= ($i2 > 0 ? ' OR
' : '').$field." ".($mode == -2 ? 'NOT
' : '');
11440 $newres .= $crit ? "IN (".$db->sanitize($db->escape($crit)).")" : "IN (0)";
11442 $newres .= ' OR
'.$field.' IS NULL
';
11444 $i2++; // a criteria for 1 more field was added to string
11445 } elseif ($mode == 3 || $mode == -3) {
11446 $tmparray = explode(',
', $crit);
11447 if (count($tmparray)) {
11449 foreach ($tmparray as $val) {
11452 $listofcodes .= ($listofcodes ? ',
' : '');
11453 $listofcodes .= "'".$db->escape($val)."'";
11456 $newres .= ($i2 > 0 ? ' OR
' : '').$field." ".($mode == -3 ? 'NOT
' : '')."IN (".$db->sanitize($listofcodes, 1, 0, 1).")";
11457 $i2++; // a criteria for 1 more field was added to string
11460 $newres .= ' OR
'.$field.' IS NULL
';
11462 } elseif ($mode == 4) {
11463 $tmparray = explode(',
', $crit);
11464 if (count($tmparray)) {
11466 foreach ($tmparray as $val) {
11469 $newres .= ($i2 > 0 ? " OR (" : "(").$field." LIKE '".$db->escape($val).",%
'";
11470 $newres .= ' OR
'.$field." = '".$db->escape($val)."'";
11471 $newres .= ' OR
'.$field." LIKE '%,
".$db->escape($val)."'";
11472 $newres .= ' OR
'.$field." LIKE '%,
".$db->escape($val).",%
'";
11474 $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)
11478 } else { // $mode=0
11479 $tmpcrits = explode('|
', $crit);
11480 $i3 = 0; // count the nb of valid criteria added for the current couple criteria/field
11481 foreach ($tmpcrits as $tmpcrit) { // loop on each OR criteria
11482 if ($tmpcrit !== '0
' && empty($tmpcrit)) {
11485 $tmpcrit = trim($tmpcrit);
11487 if ($tmpcrit == '^$
' || strpos($crit, '!
') === 0) { // If we search empty, we must combined different OR fields with AND
11488 $newres .= (($i2 > 0 || $i3 > 0) ? ' AND
' : '');
11490 $newres .= (($i2 > 0 || $i3 > 0) ? ' OR
' : '');
11493 if (preg_match('/\.(
id|
rowid)$/
', $field)) { // Special case for rowid that is sometimes a ref so used as a search field
11494 $newres .= $field." = ".(is_numeric($tmpcrit) ? ((float) $tmpcrit) : '0
');
11496 $tmpcrit2 = $tmpcrit;
11501 if (preg_match('/^!/
', $tmpcrit)) {
11502 $tmps .= $field." NOT LIKE "; // ! as exclude character
11503 $tmpcrit2 = preg_replace('/^!/
', '', $tmpcrit2);
11505 $tmps .= $field." LIKE ";
11509 if (preg_match('/^[\^\$]/', $tmpcrit)) {
11511 $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
11513 if (preg_match('/[\^\$]$/', $tmpcrit)) {
11515 $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
11518 if ($tmpcrit2 == '' || preg_match('/^!/', $tmpcrit)) {
11522 $newres .= $tmpbefore;
11523 $newres .= $db->escape($tmpcrit2);
11524 $newres .= $tmpafter;
11526 if ($tmpcrit2 == '' || preg_match('/^!/
', $tmpcrit)) {
11527 $newres .= " OR ".$field." IS NULL)";
11534 $i2++; // a criteria for 1 more field was added to string
11539 $res = $res.($res ? ' AND
' : '').($i2 > 1 ? '(
' : '').$newres.($i2 > 1 ? ')
' : '');
11543 $res = ($nofirstand ? "" : " AND ")."(".$res.")";
11554function showDirectDownloadLink($object)
11556 global $conf, $langs;
11559 $url = $object->getLastMainDocLink($object->element);
11561 $out .= img_picto($langs->trans("PublicDownloadLinkDesc"), 'globe
').' <span
class=
"opacitymedium">
'.$langs->trans("DirectDownloadLink").'</span><br>
';
11563 $out .= '<div
class=
"urllink"><input
type=
"text" id=
"directdownloadlink" class=
"quatrevingtpercent" value=
"'.$url.'"></div>
';
11564 $out .= ajax_autoselect("directdownloadlink", 0);
11566 $out .= '<div
class=
"urllink">
'.$langs->trans("FileNotShared").'</div>
';
11580function getImageFileNameForSize($file, $extName, $extImgTarget = '
')
11582 $dirName = dirname($file);
11583 if ($dirName == '.
') {
11587 $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp|\.webp)$/i
', '', $file); // We remove extension, whatever is its case
11588 $fileName = basename($fileName);
11590 if (empty($extImgTarget)) {
11591 $extImgTarget = (preg_match('/\.jpg$/i
', $file) ? '.jpg
' : '');
11593 if (empty($extImgTarget)) {
11594 $extImgTarget = (preg_match('/\.jpeg$/i
', $file) ? '.jpeg
' : '');
11596 if (empty($extImgTarget)) {
11597 $extImgTarget = (preg_match('/\.gif$/i
', $file) ? '.gif
' : '');
11599 if (empty($extImgTarget)) {
11600 $extImgTarget = (preg_match('/\.png$/i
', $file) ? '.png
' : '');
11602 if (empty($extImgTarget)) {
11603 $extImgTarget = (preg_match('/\.bmp$/i
', $file) ? '.bmp
' : '');
11605 if (empty($extImgTarget)) {
11606 $extImgTarget = (preg_match('/\.webp$/i
', $file) ? '.webp
' : '');
11609 if (!$extImgTarget) {
11615 $subdir = 'thumbs/
';
11618 return ($dirName ? $dirName.'/
' : '').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb
11631function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param = '
')
11633 global $conf, $langs;
11635 if (empty($conf->use_javascript_ajax)) {
11639 $isAllowedForPreview = dolIsAllowedForPreview($relativepath);
11641 if ($alldata == 1) {
11642 if ($isAllowedForPreview) {
11643 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));
11649 // old behavior, return a string
11650 if ($isAllowedForPreview) {
11651 $tmpurl = DOL_URL_ROOT.'/document.php?modulepart=
'.urlencode($modulepart).'&attachment=0&file=
'.urlencode($relativepath).($param ? '&
'.$param : '');
11652 $title = $langs->transnoentities("Preview");
11653 //$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().
11654 //$tmpurl = 'file=
'.urlencode("'-alert(document.domain)-
'_small.jpg"); // An example of tmpurl that should be blocked by the dol_escape_uri()
11656 // 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,
11657 // 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.
11674function ajax_autoselect($htmlname, $addlink = '
', $textonlink = 'Link')
11677 $out = '<script nonce=
"'.getNonce().'">
11678 jQuery(document).ready(
function () {
11679 jQuery(
"'.((strpos($htmlname, '.') === 0 ? '' : '#').$htmlname).'").click(
function() { jQuery(
this).select(); } );
11683 if ($textonlink === 'image
') {
11684 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.img_picto('', 'globe
').'</a>
';
11686 $out .= ' <a href=
"'.$addlink.'" target=
"_blank" rel=
"noopener noreferrer">
'.$langs->trans("Link").'</a>
';
11699function dolIsAllowedForPreview($file)
11701 // Check .noexe extension in filename
11702 if (preg_match('/\.noexe$/i
', $file)) {
11706 // Check mime types
11707 $mime_preview = array('bmp
', 'jpeg
', 'png
', 'gif
', 'tiff
', 'pdf
', 'plain
', 'css
', 'webp
');
11708 if (getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES
')) {
11709 $mime_preview[] = 'svg+xml
';
11711 //$mime_preview[]='vnd.oasis.opendocument.presentation
';
11712 //$mime_preview[]='archive
';
11713 $num_mime = array_search(dol_mimetype($file, '', 1), $mime_preview);
11714 if ($num_mime !== false) {
11718 // By default, not allowed for preview
11732function dol_mimetype($file, $default = 'application/octet-stream
', $mode = 0)
11735 $imgmime = 'other.png
';
11736 $famime = 'file-o
';
11739 $tmpfile = preg_replace('/\.noexe$/
', '', $file);
11741 // Plain text files
11742 if (preg_match('/\.txt$/i
', $tmpfile)) {
11743 $mime = 'text/plain
';
11744 $imgmime = 'text.png
';
11745 $famime = 'file-alt
';
11746 } elseif (preg_match('/\.rtx$/i
', $tmpfile)) {
11747 $mime = 'text/richtext
';
11748 $imgmime = 'text.png
';
11749 $famime = 'file-alt
';
11750 } elseif (preg_match('/\.csv$/i
', $tmpfile)) {
11751 $mime = 'text/csv
';
11752 $imgmime = 'text.png
';
11753 $famime = 'file-csv
';
11754 } elseif (preg_match('/\.tsv$/i
', $tmpfile)) {
11755 $mime = 'text/tab-separated-values
';
11756 $imgmime = 'text.png
';
11757 $famime = 'file-alt
';
11758 } elseif (preg_match('/\.(cf|
conf|log)$/i
', $tmpfile)) {
11759 $mime = 'text/plain
';
11760 $imgmime = 'text.png
';
11761 $famime = 'file-alt
';
11762 } elseif (preg_match('/\.ini$/i
', $tmpfile)) {
11763 $mime = 'text/plain
';
11764 $imgmime = 'text.png
';
11766 $famime = 'file-alt
';
11767 } elseif (preg_match('/\.md$/i
', $tmpfile)) {
11768 $mime = 'text/plain
';
11769 $imgmime = 'text.png
';
11771 $famime = 'file-alt
';
11772 } elseif (preg_match('/\.css$/i
', $tmpfile)) {
11773 $mime = 'text/css
';
11774 $imgmime = 'css.png
';
11776 $famime = 'file-alt
';
11777 } elseif (preg_match('/\.lang$/i
', $tmpfile)) {
11778 $mime = 'text/plain
';
11779 $imgmime = 'text.png
';
11781 $famime = 'file-alt
';
11782 } elseif (preg_match('/\.(crt|cer|key|pub)$/i
', $tmpfile)) { // Certificate files
11783 $mime = 'text/plain
';
11784 $imgmime = 'text.png
';
11785 $famime = 'file-alt
';
11786 } elseif (preg_match('/\.(html|htm|shtml)$/i
', $tmpfile)) { // XML based (HTML/XML/XAML)
11787 $mime = 'text/html
';
11788 $imgmime = 'html.png
';
11790 $famime = 'file-alt
';
11791 } elseif (preg_match('/\.(xml|xhtml)$/i
', $tmpfile)) {
11792 $mime = 'text/xml
';
11793 $imgmime = 'other.png
';
11795 $famime = 'file-alt
';
11796 } elseif (preg_match('/\.xaml$/i
', $tmpfile)) {
11797 $mime = 'text/xml
';
11798 $imgmime = 'other.png
';
11800 $famime = 'file-alt
';
11801 } elseif (preg_match('/\.bas$/i
', $tmpfile)) { // Languages
11802 $mime = 'text/plain
';
11803 $imgmime = 'text.png
';
11805 $famime = 'file-code
';
11806 } elseif (preg_match('/\.(c)$/i
', $tmpfile)) {
11807 $mime = 'text/plain
';
11808 $imgmime = 'text.png
';
11810 $famime = 'file-code
';
11811 } elseif (preg_match('/\.(cpp)$/i
', $tmpfile)) {
11812 $mime = 'text/plain
';
11813 $imgmime = 'text.png
';
11815 $famime = 'file-code
';
11816 } elseif (preg_match('/\.cs$/i
', $tmpfile)) {
11817 $mime = 'text/plain
';
11818 $imgmime = 'text.png
';
11820 $famime = 'file-code
';
11821 } elseif (preg_match('/\.(h)$/i
', $tmpfile)) {
11822 $mime = 'text/plain
';
11823 $imgmime = 'text.png
';
11825 $famime = 'file-code
';
11826 } elseif (preg_match('/\.(java|jsp)$/i
', $tmpfile)) {
11827 $mime = 'text/plain
';
11828 $imgmime = 'text.png
';
11830 $famime = 'file-code
';
11831 } elseif (preg_match('/\.php([0-9]{1})?$/i
', $tmpfile)) {
11832 $mime = 'text/plain
';
11833 $imgmime = 'php.png
';
11835 $famime = 'file-code
';
11836 } elseif (preg_match('/\.phtml$/i
', $tmpfile)) {
11837 $mime = 'text/plain
';
11838 $imgmime = 'php.png
';
11840 $famime = 'file-code
';
11841 } elseif (preg_match('/\.(pl|pm)$/i
', $tmpfile)) {
11842 $mime = 'text/plain
';
11843 $imgmime = 'pl.png
';
11845 $famime = 'file-code
';
11846 } elseif (preg_match('/\.sql$/i
', $tmpfile)) {
11847 $mime = 'text/plain
';
11848 $imgmime = 'text.png
';
11850 $famime = 'file-code
';
11851 } elseif (preg_match('/\.js$/i
', $tmpfile)) {
11852 $mime = 'text/x-javascript
';
11853 $imgmime = 'jscript.png
';
11855 $famime = 'file-code
';
11856 } elseif (preg_match('/\.odp$/i
', $tmpfile)) { // Open office
11857 $mime = 'application/vnd.oasis.opendocument.presentation
';
11858 $imgmime = 'ooffice.png
';
11859 $famime = 'file-powerpoint
';
11860 } elseif (preg_match('/\.ods$/i
', $tmpfile)) {
11861 $mime = 'application/vnd.oasis.opendocument.spreadsheet
';
11862 $imgmime = 'ooffice.png
';
11863 $famime = 'file-excel
';
11864 } elseif (preg_match('/\.odt$/i
', $tmpfile)) {
11865 $mime = 'application/vnd.oasis.opendocument.text
';
11866 $imgmime = 'ooffice.png
';
11867 $famime = 'file-word
';
11868 } elseif (preg_match('/\.mdb$/i
', $tmpfile)) { // MS Office
11869 $mime = 'application/msaccess
';
11870 $imgmime = 'mdb.png
';
11872 } elseif (preg_match('/\.doc[xm]?$/i
', $tmpfile)) {
11873 $mime = 'application/msword
';
11874 $imgmime = 'doc.png
';
11875 $famime = 'file-word
';
11876 } elseif (preg_match('/\.dot[xm]?$/i
', $tmpfile)) {
11877 $mime = 'application/msword
';
11878 $imgmime = 'doc.png
';
11879 $famime = 'file-word
';
11880 } elseif (preg_match('/\.xlt(x)?$/i
', $tmpfile)) {
11881 $mime = 'application/vnd.ms-excel
';
11882 $imgmime = 'xls.png
';
11883 $famime = 'file-excel
';
11884 } elseif (preg_match('/\.xla(m)?$/i
', $tmpfile)) {
11885 $mime = 'application/vnd.ms-excel
';
11886 $imgmime = 'xls.png
';
11887 $famime = 'file-excel
';
11888 } elseif (preg_match('/\.xls$/i
', $tmpfile)) {
11889 $mime = 'application/vnd.ms-excel
';
11890 $imgmime = 'xls.png
';
11891 $famime = 'file-excel
';
11892 } elseif (preg_match('/\.xls[bmx]$/i
', $tmpfile)) {
11893 $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
';
11894 $imgmime = 'xls.png
';
11895 $famime = 'file-excel
';
11896 } elseif (preg_match('/\.pps[mx]?$/i
', $tmpfile)) {
11897 $mime = 'application/vnd.ms-powerpoint
';
11898 $imgmime = 'ppt.png
';
11899 $famime = 'file-powerpoint
';
11900 } elseif (preg_match('/\.ppt[mx]?$/i
', $tmpfile)) {
11901 $mime = 'application/x-mspowerpoint
';
11902 $imgmime = 'ppt.png
';
11903 $famime = 'file-powerpoint
';
11904 } elseif (preg_match('/\.pdf$/i
', $tmpfile)) { // Other
11905 $mime = 'application/pdf
';
11906 $imgmime = 'pdf.png
';
11907 $famime = 'file-pdf
';
11908 } elseif (preg_match('/\.bat$/i
', $tmpfile)) { // Scripts
11909 $mime = 'text/x-bat
';
11910 $imgmime = 'script.png
';
11912 $famime = 'file-code
';
11913 } elseif (preg_match('/\.sh$/i
', $tmpfile)) {
11914 $mime = 'text/x-sh
';
11915 $imgmime = 'script.png
';
11917 $famime = 'file-code
';
11918 } elseif (preg_match('/\.ksh$/i
', $tmpfile)) {
11919 $mime = 'text/x-ksh
';
11920 $imgmime = 'script.png
';
11922 $famime = 'file-code
';
11923 } elseif (preg_match('/\.bash$/i
', $tmpfile)) {
11924 $mime = 'text/x-bash
';
11925 $imgmime = 'script.png
';
11927 $famime = 'file-code
';
11928 } elseif (preg_match('/\.ico$/i
', $tmpfile)) { // Images
11929 $mime = 'image/x-
icon';
11930 $imgmime = 'image.png
';
11931 $famime = 'file-image
';
11932 } elseif (preg_match('/\.(jpg|jpeg)$/i
', $tmpfile)) {
11933 $mime = 'image/jpeg
';
11934 $imgmime = 'image.png
';
11935 $famime = 'file-image
';
11936 } elseif (preg_match('/\.png$/i
', $tmpfile)) {
11937 $mime = 'image/png
';
11938 $imgmime = 'image.png
';
11939 $famime = 'file-image
';
11940 } elseif (preg_match('/\.gif$/i
', $tmpfile)) {
11941 $mime = 'image/gif
';
11942 $imgmime = 'image.png
';
11943 $famime = 'file-image
';
11944 } elseif (preg_match('/\.bmp$/i
', $tmpfile)) {
11945 $mime = 'image/bmp
';
11946 $imgmime = 'image.png
';
11947 $famime = 'file-image
';
11948 } elseif (preg_match('/\.(tif|tiff)$/i
', $tmpfile)) {
11949 $mime = 'image/tiff
';
11950 $imgmime = 'image.png
';
11951 $famime = 'file-image
';
11952 } elseif (preg_match('/\.svg$/i
', $tmpfile)) {
11953 $mime = 'image/svg+xml
';
11954 $imgmime = 'image.png
';
11955 $famime = 'file-image
';
11956 } elseif (preg_match('/\.webp$/i
', $tmpfile)) {
11957 $mime = 'image/webp
';
11958 $imgmime = 'image.png
';
11959 $famime = 'file-image
';
11960 } elseif (preg_match('/\.vcs$/i
', $tmpfile)) { // Calendar
11961 $mime = 'text/calendar
';
11962 $imgmime = 'other.png
';
11963 $famime = 'file-alt
';
11964 } elseif (preg_match('/\.ics$/i
', $tmpfile)) {
11965 $mime = 'text/calendar
';
11966 $imgmime = 'other.png
';
11967 $famime = 'file-alt
';
11968 } elseif (preg_match('/\.torrent$/i
', $tmpfile)) { // Other
11969 $mime = 'application/x-bittorrent
';
11970 $imgmime = 'other.png
';
11971 $famime = 'file-o
';
11972 } elseif (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i
', $tmpfile)) { // Audio
11974 $imgmime = 'audio.png
';
11975 $famime = 'file-audio
';
11976 } elseif (preg_match('/\.mp4$/i
', $tmpfile)) { // Video
11977 $mime = 'video/mp4
';
11978 $imgmime = 'video.png
';
11979 $famime = 'file-video
';
11980 } elseif (preg_match('/\.ogv$/i
', $tmpfile)) {
11981 $mime = 'video/ogg
';
11982 $imgmime = 'video.png
';
11983 $famime = 'file-video
';
11984 } elseif (preg_match('/\.webm$/i
', $tmpfile)) {
11985 $mime = 'video/webm
';
11986 $imgmime = 'video.png
';
11987 $famime = 'file-video
';
11988 } elseif (preg_match('/\.avi$/i
', $tmpfile)) {
11989 $mime = 'video/x-msvideo
';
11990 $imgmime = 'video.png
';
11991 $famime = 'file-video
';
11992 } elseif (preg_match('/\.divx$/i
', $tmpfile)) {
11993 $mime = 'video/divx
';
11994 $imgmime = 'video.png
';
11995 $famime = 'file-video
';
11996 } elseif (preg_match('/\.xvid$/i
', $tmpfile)) {
11997 $mime = 'video/xvid
';
11998 $imgmime = 'video.png
';
11999 $famime = 'file-video
';
12000 } elseif (preg_match('/\.(wmv|mpg|mpeg)$/i
', $tmpfile)) {
12002 $imgmime = 'video.png
';
12003 $famime = 'file-video
';
12004 } elseif (preg_match('/\.(zip|rar|gz|tgz|xz|z|cab|bz2|7z|tar|lzh|zst)$/i
', $tmpfile)) { // Archive
12005 // application/xxx where zzz is zip, ...
12007 $imgmime = 'archive.png
';
12008 $famime = 'file-archive
';
12009 } elseif (preg_match('/\.(exe|com)$/i
', $tmpfile)) { // Exe
12010 $mime = 'application/octet-stream
';
12011 $imgmime = 'other.png
';
12012 $famime = 'file-o
';
12013 } elseif (preg_match('/\.(dll|lib|o|so|a)$/i
', $tmpfile)) { // Lib
12015 $imgmime = 'library.png
';
12016 $famime = 'file-o
';
12017 } elseif (preg_match('/\.err$/i
', $tmpfile)) { // phpcs:ignore
12019 $imgmime = 'error.png
';
12020 $famime = 'file-alt
';
12023 // Return mimetype string
12024 switch ((int) $mode) {
12026 $tmp = explode('/
', $mime);
12027 return (!empty($tmp[1]) ? $tmp[1] : $tmp[0]);
12049function getDictionaryValue($tablename, $field, $id, $checkentity = false, $rowidfield = '
rowid')
12053 $tablename = preg_replace('/^
'.preg_quote(MAIN_DB_PREFIX, '/
').'/
', '', $tablename); // Clean name of table for backward compatibility.
12055 $dictvalues = (isset($conf->cache['dictvalues_
'.$tablename]) ? $conf->cache['dictvalues_
'.$tablename] : null);
12057 if (is_null($dictvalues)) {
12058 $dictvalues = array();
12060 $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
12061 if ($checkentity) {
12062 $sql .=
' AND entity IN (0,'.getEntity($tablename).
')';
12065 $resql = $db->query($sql);
12067 while ($obj = $db->fetch_object($resql)) {
12068 $dictvalues[$obj->$rowidfield] = $obj;
12074 $conf->cache[
'dictvalues_'.$tablename] = $dictvalues;
12077 if (!empty($dictvalues[$id])) {
12079 $tmp = $dictvalues[$id];
12080 return (property_exists($tmp, $field) ? $tmp->$field :
'');
12095 $stringcolor = str_replace(
'#',
'', $stringcolor);
12097 if (!empty($stringcolor)) {
12099 $tmp = explode(
',', $stringcolor);
12100 if (count($tmp) > 1) {
12105 $hexr = $stringcolor[0].$stringcolor[1];
12106 $hexg = $stringcolor[2].$stringcolor[3];
12107 $hexb = $stringcolor[4].$stringcolor[5];
12108 $r = hexdec($hexr);
12109 $g = hexdec($hexg);
12110 $b = hexdec($hexb);
12112 $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0;
12113 if ($bright > 0.6) {
12134 if (empty($menuentry[
'enabled'])) {
12137 if ($type_user && $menuentry[
'module']) {
12138 $tmploops = explode(
'|', $menuentry[
'module']);
12140 foreach ($tmploops as $tmploop) {
12141 if (in_array($tmploop, $listofmodulesforexternal)) {
12150 if (!$menuentry[
'perms'] && $type_user) {
12156 if (!$menuentry[
'perms']) {
12171 $result = (ceil($n) % $x === 0) ? ceil($n) : (round(($n + $x / 2) / $x) * $x);
12172 return (
int) $result;
12186function dolGetBadge($label, $html =
'', $type =
'primary', $mode =
'', $url =
'', $params = array())
12188 $csstouse =
'badge';
12189 $csstouse .= (!empty($mode) ?
' badge-'.$mode :
'');
12190 $csstouse .= (!empty($type) ?
' badge-'.$type :
'');
12191 $csstouse .= (empty($params[
'css']) ?
'' :
' '.$params[
'css']);
12194 'class' => $csstouse
12197 if (empty($html)) {
12201 if (!empty($url)) {
12202 $attr[
'href'] = $url;
12205 if ($mode ===
'dot') {
12206 $attr[
'class'] .=
' classfortooltip';
12207 $attr[
'title'] = $html;
12208 $attr[
'aria-label'] = $label;
12213 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
12214 foreach ($params[
'attr'] as $key => $value) {
12215 if ($key ==
'class') {
12216 $attr[
'class'] .=
' '.$value;
12217 } elseif ($key ==
'classOverride') {
12218 $attr[
'class'] = $value;
12220 $attr[$key] = $value;
12228 $attr = array_map(
'dol_escape_htmltag', $attr);
12230 $TCompiledAttr = array();
12231 foreach ($attr as $key => $value) {
12232 $TCompiledAttr[] = $key.
'="'.$value.
'"';
12235 $compiledAttributes = !empty($TCompiledAttr) ? implode(
' ', $TCompiledAttr) :
'';
12237 $tag = !empty($url) ?
'a' :
'span';
12239 return '<'.$tag.
' '.$compiledAttributes.
'>'.$html.
'</'.$tag.
'>';
12255function dolGetStatus($statusLabel =
'', $statusLabelShort =
'', $html =
'', $statusType =
'status0', $displayMode = 0, $url =
'', $params = array())
12260 $dolGetBadgeParams = array();
12262 if (!empty($params[
'badgeParams'])) {
12263 $dolGetBadgeParams = $params[
'badgeParams'];
12267 if ($displayMode == 0) {
12268 $return = !empty($html) ? $html : (empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort));
12269 } elseif ($displayMode == 1) {
12270 $return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
12274 $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ?
'<span class="hideonsmartphone">' :
'').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ?
'</span>' :
'');
12275 $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>' :
'');
12278 if (!empty($conf->dol_optimize_smallscreen)) {
12279 if ($displayMode == 0) {
12281 } elseif ($displayMode == 4) {
12283 } elseif ($displayMode == 6) {
12289 $statusImg = array(
12290 'status0' =>
'statut0',
12291 'status1' =>
'statut1',
12292 'status2' =>
'statut2',
12293 'status3' =>
'statut3',
12294 'status4' =>
'statut4',
12295 'status5' =>
'statut5',
12296 'status6' =>
'statut6',
12297 'status7' =>
'statut7',
12298 'status8' =>
'statut8',
12299 'status9' =>
'statut9'
12302 if (!empty($statusImg[$statusType])) {
12303 $htmlImg =
img_picto($statusLabel, $statusImg[$statusType]);
12305 $htmlImg =
img_picto($statusLabel, $statusType);
12308 if ($displayMode === 2) {
12309 $return = $htmlImg.
' '.$htmlLabelShort;
12310 } elseif ($displayMode === 3) {
12311 $return = $htmlImg;
12312 } elseif ($displayMode === 4) {
12313 $return = $htmlImg.
' '.$htmlLabel;
12314 } elseif ($displayMode === 5) {
12315 $return = $htmlLabelShort.
' '.$htmlImg;
12317 $return = $htmlLabel.
' '.$htmlImg;
12321 $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort);
12323 $dolGetBadgeParams[
'attr'][
'class'] =
'badge-status';
12324 if (empty($dolGetBadgeParams[
'attr'][
'title'])) {
12325 $dolGetBadgeParams[
'attr'][
'title'] = empty($params[
'tooltip']) ? $statusLabel : ($params[
'tooltip'] !=
'no' ? $params[
'tooltip'] :
'');
12327 $dolGetBadgeParams[
'attr'][
'class'] .=
' classfortooltip';
12329 $dolGetBadgeParams[
'attr'][
'title'] =
dol_htmlentitiesbr($dolGetBadgeParams[
'attr'][
'title'], 1);
12332 if ($displayMode == 3) {
12333 $return = dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)),
'', $statusType,
'dot', $url, $dolGetBadgeParams);
12334 } elseif ($displayMode === 5) {
12335 $return = dolGetBadge($statusLabelShort, $html, $statusType,
'', $url, $dolGetBadgeParams);
12337 $return = dolGetBadge((empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)), $html, $statusType,
'', $url, $dolGetBadgeParams);
12383function dolGetButtonAction($label, $text =
'', $actionType =
'default', $url =
'', $id =
'', $userRight = 1, $params = array())
12385 global $hookmanager, $action,
$object, $langs;
12388 if (is_array($url)) {
12390 foreach ($url as $key => $subbutton) {
12391 if (isset($subbutton[
'enabled']) && empty($subbutton[
'enabled'])) {
12398 if (isset($params[
"areDropdownButtons"]) && $params[
"areDropdownButtons"] ===
false) {
12399 foreach ($url as $button) {
12400 if (!empty($button[
'lang'])) {
12401 $langs->load($button[
'lang']);
12403 $label = $langs->trans($button[
'label']);
12404 $text = $button[
'text'] ??
'';
12405 $actionType = $button[
'actionType'] ??
'';
12406 $tmpUrl = DOL_URL_ROOT.$button[
'url'].(empty($params[
'backtopage']) ?
'' :
'&backtopage='.urlencode($params[
'backtopage']));
12407 $id = $button[
'id'] ??
'';
12408 $userRight = $button[
'perm'] ?? 1;
12409 $button[
'params'] = $button[
'params'] ?? [];
12411 $out .=
dolGetButtonAction($label, $text, $actionType, $tmpUrl, $id, $userRight, $button[
'params']);
12416 if (count($url) > 1) {
12417 $out .=
'<div class="dropdown inline-block dropdown-holder">';
12418 $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>';
12419 $out .=
'<div class="dropdown-content">';
12420 foreach ($url as $subbutton) {
12421 if (!empty($subbutton[
'lang'])) {
12422 $langs->load($subbutton[
'lang']);
12425 if (!empty($subbutton[
'urlraw'])) {
12426 $tmpurl = $subbutton[
'urlraw'];
12428 $tmpurl = !empty($subbutton[
'urlroot']) ? $subbutton[
'urlroot'] : $subbutton[
'url'];
12432 $subbuttonparam = array();
12433 if (!empty($subbutton[
'attr'])) {
12434 $subbuttonparam[
'attr'] = $subbutton[
'attr'];
12436 $subbuttonparam[
'isDropDown'] = (empty($params[
'isDropDown']) ? ($subbutton[
'isDropDown']??
false) : $params[
'isDropDown']);
12438 $out .=
dolGetButtonAction(
'', $langs->trans($subbutton[
'label']),
'default', $tmpurl, $subbutton[
'id'] ??
'', $subbutton[
'perm'], $subbuttonparam);
12443 foreach ($url as $subbutton) {
12444 if (!empty($subbutton[
'lang'])) {
12445 $langs->load($subbutton[
'lang']);
12448 if (!empty($subbutton[
'urlraw'])) {
12449 $tmpurl = $subbutton[
'urlraw'];
12451 $tmpurl = !empty($subbutton[
'urlroot']) ? $subbutton[
'urlroot'] : $subbutton[
'url'];
12455 $out .=
dolGetButtonAction(
'', $langs->trans($subbutton[
'label']),
'default', $tmpurl,
'', $subbutton[
'perm'], $params);
12464 if (!empty($params[
'isDropdown']) || !empty($params[
'isDropDown'])) {
12465 $class =
"dropdown-item";
12467 $class =
'butAction';
12468 if ($actionType ==
'danger' || $actionType ==
'delete') {
12469 $class =
'butActionDelete';
12470 if (!empty($url) && strpos($url,
'token=') ===
false) {
12471 $url .=
'&token='.newToken();
12477 'href' => empty($url) ?
'' : $url,
12481 if (empty($text)) {
12483 $attr[
'title'] =
'';
12485 $attr[
'title'] = $label;
12486 $attr[
'aria-label'] = $label;
12489 if (empty($userRight)) {
12490 $attr[
'class'] =
'butActionRefused';
12491 $attr[
'href'] =
'';
12492 $attr[
'title'] = (($label && $text && $label != $text) ? $label :
'');
12493 $attr[
'title'] = ($attr[
'title'] ? $attr[
'title'].
'<br>' :
'').$langs->trans(
'NotEnoughPermissions');
12501 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
12502 foreach ($params[
'attr'] as $key => $value) {
12503 if ($key ==
'class') {
12504 $attr[
'class'] .=
' '.$value;
12505 } elseif ($key ==
'classOverride') {
12506 $attr[
'class'] = $value;
12508 $attr[$key] = $value;
12514 if (!empty($attr[
'title']) && !empty($attr[
'class']) && strpos($attr[
'class'],
'classfortooltip') ===
false) {
12515 $attr[
'class'] .=
' classfortooltip';
12519 if ($userRight && !empty($params[
'confirm'])) {
12520 if (!is_array($params[
'confirm'])) {
12521 $params[
'confirm'] = array();
12524 if (empty($params[
'confirm'][
'url'])) {
12525 $params[
'confirm'][
'url'] = $url . (strpos($url,
'?') > 0 ?
'&' :
'?') .
'confirm=yes';
12529 $attr[
'data-confirm-url'] = $params[
'confirm'][
'url'];
12530 $attr[
'data-confirm-title'] = !empty($params[
'confirm'][
'title']) ? $params[
'confirm'][
'title'] : $langs->trans(
'ConfirmBtnCommonTitle', $label);
12531 $attr[
'data-confirm-content'] = !empty($params[
'confirm'][
'content']) ? $params[
'confirm'][
'content'] : $langs->trans(
'ConfirmBtnCommonContent', $label);
12532 $attr[
'data-confirm-content'] = preg_replace(
"/\r|\n/",
"", $attr[
'data-confirm-content']);
12533 $attr[
'data-confirm-action-btn-label'] = !empty($params[
'confirm'][
'action-btn-label']) ? $params[
'confirm'][
'action-btn-label'] : $langs->trans(
'Confirm');
12534 $attr[
'data-confirm-cancel-btn-label'] = !empty($params[
'confirm'][
'cancel-btn-label']) ? $params[
'confirm'][
'cancel-btn-label'] : $langs->trans(
'CloseDialog');
12535 $attr[
'data-confirm-modal'] = !empty($params[
'confirm'][
'modal']) ? $params[
'confirm'][
'modal'] :
true;
12537 $attr[
'class'] .=
' butActionConfirm';
12540 if (isset($attr[
'href']) && empty($attr[
'href'])) {
12541 unset($attr[
'href']);
12545 if (!empty($params[
'use_unsecured_unescapedattr'])) {
12546 if (is_array($params[
'use_unsecured_unescapedattr'])) {
12547 foreach ($attr as $attrK => $attrV) {
12548 if (in_array($attrK, $params[
'use_unsecured_unescapedattr'])) {
12555 $attr = array_map(
'dol_htmlentities', $attr);
12558 $attr = array_map(
'dolPrintHTMLForAttribute', $attr);
12561 $TCompiledAttr = array();
12562 foreach ($attr as $key => $value) {
12563 $TCompiledAttr[] = $key.
'= "'.$value.
'"';
12566 $compiledAttributes = empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr);
12568 $tag = !empty($attr[
'href']) ?
'a' :
'span';
12571 $parameters = array(
12572 'TCompiledAttr' => $TCompiledAttr,
12573 'compiledAttributes' => $compiledAttributes,
12578 'actionType' => $actionType,
12581 'userRight' => $userRight,
12582 'params' => $params
12585 $reshook = $hookmanager->executeHooks(
'dolGetButtonAction', $parameters,
$object, $action);
12586 if ($reshook < 0) {
12590 if (empty($reshook)) {
12592 return '<' . $tag .
' ' . $compiledAttributes .
'>' . $text .
'</' . $tag .
'>';
12594 return '<' . $tag .
' ' . $compiledAttributes .
'>' .
dol_escape_htmltag($text) .
'</' . $tag .
'>';
12597 return $hookmanager->resPrint;
12616 $parsedUrl = parse_url($url);
12617 if ((isset($parsedUrl[
'scheme']) && in_array($parsedUrl[
'scheme'], [
'javascript',
'mailto',
'tel'])) || strpos($url,
'#') === 0) {
12621 if (!empty($parsedUrl[
'query'])) {
12623 parse_str($parsedUrl[
'query'], $urlQuery);
12624 if (!isset($urlQuery[
'backtopage']) && isset($params[
'backtopage'])) {
12625 $url.=
'&backtopage='.urlencode($params[
'backtopage']);
12629 if (!isset($parsedUrl[
'scheme']) && $addDolUrlRoot) {
12630 $url = DOL_URL_ROOT.$url;
12645 return '<span class="button-title-separator '.$moreClass.
'" ></span>';
12657 if (!empty($fieldValidationErrorMsg)) {
12658 $out .=
'<span class="field-error-icon classfortooltip" title="'.dol_escape_htmltag($fieldValidationErrorMsg, 1).
'" role="alert" >';
12659 $out .=
'<span class="fa fa-exclamation-circle" aria-hidden="true" ></span>';
12678function dolGetButtonTitle($label, $helpText =
'', $iconClass =
'fa fa-file', $url =
'', $id =
'', $status = 1, $params = array())
12680 global $langs, $conf, $user;
12683 if (
getDolGlobalString(
'MAIN_BUTTON_HIDE_UNAUTHORIZED') && (!$user->admin) && $status <= 0) {
12687 $class =
'btnTitle';
12688 if (in_array($iconClass, array(
'fa fa-plus-circle',
'fa fa-plus-circle size15x',
'fa fa-comment-dots',
'fa fa-paper-plane'))) {
12689 $class .=
' btnTitlePlus';
12691 $useclassfortooltip = 1;
12693 if (!empty($params[
'morecss'])) {
12694 $class .=
' '.$params[
'morecss'];
12699 'href' => empty($url) ?
'' : $url
12702 if (!empty($helpText)) {
12704 } elseif (empty($attr[
'title']) && $label) {
12705 $attr[
'title'] = $label;
12706 $useclassfortooltip = 0;
12709 if ($status == 2) {
12710 $attr[
'class'] .=
' btnTitleSelected';
12711 } elseif ($status <= 0) {
12712 $attr[
'class'] .=
' refused';
12714 $attr[
'href'] =
'';
12716 if ($status == -1) {
12717 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"FeatureDisabled"));
12718 } elseif ($status == 0) {
12719 $attr[
'title'] =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"NotEnoughPermissions"));
12723 if (!empty($attr[
'title']) && $useclassfortooltip) {
12724 $attr[
'class'] .=
' classfortooltip';
12732 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
12733 foreach ($params[
'attr'] as $key => $value) {
12734 if ($key ==
'class') {
12735 $attr[
'class'] .=
' '.$value;
12736 } elseif ($key ==
'classOverride') {
12737 $attr[
'class'] = $value;
12739 $attr[$key] = $value;
12744 if (isset($attr[
'href']) && empty($attr[
'href'])) {
12745 unset($attr[
'href']);
12751 $attr = array_map(
'dol_escape_htmltag', $attr);
12753 $TCompiledAttr = array();
12754 foreach ($attr as $key => $value) {
12755 $TCompiledAttr[] = $key.
'="'.$value.
'"';
12758 $compiledAttributes = (empty($TCompiledAttr) ?
'' : implode(
' ', $TCompiledAttr));
12760 $tag = (empty($attr[
'href']) ?
'span' :
'a');
12762 $button =
'<'.$tag.
' '.$compiledAttributes.
'>';
12763 $button .=
'<span class="'.$iconClass.
' valignmiddle btnTitle-icon"></span>';
12764 if (!empty($params[
'forcenohideoftext'])) {
12765 $button .=
'<span class="valignmiddle text-plus-circle btnTitle-label'.(empty($params[
'forcenohideoftext']) ?
' hideonsmartphone' :
'').
'">'.$label.
'</span>';
12767 $button .=
'</'.$tag.
'>';
12783 global $conf, $db, $hookmanager;
12789 $classfile = $classname = $classpath = $subdir = $dir_output =
'';
12792 $module = $elementType;
12793 $element = $elementType;
12794 $subelement = $elementType;
12795 $table_element = $elementType;
12798 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $elementType, $regs)) {
12799 $element = $subelement = $regs[1];
12800 $module = $regs[2];
12805 if (preg_match(
'/^([^_]+)_([^_]+)/i', $element, $regs)) {
12806 $module = $element = $regs[1];
12807 $subelement = $regs[2];
12811 if (substr($elementType, -3) ==
'det') {
12812 $module = preg_replace(
'/det$/',
'', $element);
12813 $subelement = preg_replace(
'/det$/',
'', $subelement);
12814 $classpath = $module.
'/class';
12815 $classfile = $module;
12816 $classname = preg_replace(
'/det$/',
'Line', $element);
12817 if (in_array($module, array(
'expedition',
'propale',
'facture',
'contrat',
'fichinter',
'commandefournisseur'))) {
12818 $classname = preg_replace(
'/det$/',
'Ligne', $element);
12822 if ($elementType ==
"action" || $elementType ==
"actioncomm") {
12823 $classpath =
'comm/action/class';
12824 $subelement =
'Actioncomm';
12825 $module =
'agenda';
12826 $table_element =
'actioncomm';
12827 } elseif ($elementType ==
'cronjob') {
12828 $classpath =
'cron/class';
12830 $table_element =
'cron';
12831 } elseif ($elementType ==
'adherent_type') {
12832 $classpath =
'adherents/class';
12833 $classfile =
'adherent_type';
12834 $module =
'adherent';
12835 $subelement =
'adherent_type';
12836 $classname =
'AdherentType';
12837 $table_element =
'adherent_type';
12838 } elseif ($elementType ==
'bank_account') {
12839 $classpath =
'compta/bank/class';
12841 $classfile =
'account';
12842 $classname =
'Account';
12843 } elseif ($elementType ==
'category') {
12844 $classpath =
'categories/class';
12845 $module =
'categorie';
12846 $subelement =
'categorie';
12847 $table_element =
'categorie';
12848 } elseif ($elementType ==
'contact') {
12849 $classpath =
'contact/class';
12850 $classfile =
'contact';
12851 $module =
'societe';
12852 $subelement =
'contact';
12853 $table_element =
'socpeople';
12854 } elseif ($elementType ==
'inventory') {
12855 $module =
'product';
12856 $classpath =
'product/inventory/class';
12857 } elseif ($elementType ==
'stock' || $elementType ==
'entrepot') {
12859 $classpath =
'product/stock/class';
12860 $classfile =
'entrepot';
12861 $classname =
'Entrepot';
12862 $table_element =
'entrepot';
12863 } elseif ($elementType ==
'project') {
12864 $classpath =
'projet/class';
12865 $module =
'projet';
12866 $table_element =
'projet';
12867 } elseif ($elementType ==
'project_task') {
12868 $classpath =
'projet/class';
12869 $module =
'projet';
12870 $subelement =
'task';
12871 $table_element =
'projet_task';
12872 } elseif ($elementType ==
'facture' || $elementType ==
'invoice') {
12873 $classpath =
'compta/facture/class';
12874 $module =
'facture';
12875 $subelement =
'facture';
12876 $table_element =
'facture';
12877 } elseif ($elementType ==
'facturerec') {
12878 $classpath =
'compta/facture/class';
12879 $module =
'facture';
12880 $classname =
'FactureRec';
12881 } elseif ($elementType ==
'commande' || $elementType ==
'order') {
12882 $classpath =
'commande/class';
12883 $module =
'commande';
12884 $subelement =
'commande';
12885 $table_element =
'commande';
12886 } elseif ($elementType ==
'propal') {
12887 $classpath =
'comm/propal/class';
12888 $table_element =
'propal';
12889 } elseif ($elementType ==
'shipping') {
12890 $classpath =
'expedition/class';
12891 $classfile =
'expedition';
12892 $classname =
'Expedition';
12893 $module =
'expedition';
12894 $table_element =
'expedition';
12895 } elseif ($elementType ==
'delivery_note') {
12896 $classpath =
'delivery/class';
12897 $subelement =
'delivery';
12898 $module =
'expedition';
12899 } elseif ($elementType ==
'delivery') {
12900 $classpath =
'delivery/class';
12901 $subelement =
'delivery';
12902 $module =
'expedition';
12903 } elseif ($elementType ==
'supplier_proposal') {
12904 $classpath =
'supplier_proposal/class';
12905 $module =
'supplier_proposal';
12906 $element =
'supplierproposal';
12907 $classfile =
'supplier_proposal';
12908 $subelement =
'supplierproposal';
12909 } elseif ($elementType ==
'contract') {
12910 $classpath =
'contrat/class';
12911 $module =
'contrat';
12912 $subelement =
'contrat';
12913 $table_element =
'contract';
12914 } elseif ($elementType ==
'mailing') {
12915 $classpath =
'comm/mailing/class';
12916 $module =
'mailing';
12917 $classfile =
'mailing';
12918 $classname =
'Mailing';
12920 } elseif ($elementType ==
'member' || $elementType ==
'adherent') {
12921 $classpath =
'adherents/class';
12922 $module =
'adherent';
12923 $subelement =
'adherent';
12924 $table_element =
'adherent';
12925 } elseif ($elementType ==
'usergroup') {
12926 $classpath =
'user/class';
12928 } elseif ($elementType ==
'mo') {
12929 $classpath =
'mrp/class';
12934 $table_element =
'mrp_mo';
12935 } elseif ($elementType ==
'cabinetmed_cons') {
12936 $classpath =
'cabinetmed/class';
12937 $module =
'cabinetmed';
12938 $subelement =
'cabinetmedcons';
12939 $table_element =
'cabinetmedcons';
12940 } elseif ($elementType ==
'fichinter') {
12941 $classpath =
'fichinter/class';
12942 $module =
'ficheinter';
12943 $subelement =
'fichinter';
12944 $table_element =
'fichinter';
12945 } elseif ($elementType ==
'dolresource' || $elementType ==
'resource') {
12946 $classpath =
'resource/class';
12947 $module =
'resource';
12948 $subelement =
'dolresource';
12949 $table_element =
'resource';
12950 } elseif ($elementType ==
'propaldet') {
12951 $classpath =
'comm/propal/class';
12952 $module =
'propal';
12953 $subelement =
'propaleligne';
12954 } elseif ($elementType ==
'opensurvey_sondage') {
12955 $classpath =
'opensurvey/class';
12956 $module =
'opensurvey';
12957 $subelement =
'opensurveysondage';
12958 } elseif ($elementType ==
'order_supplier') {
12959 $classpath =
'fourn/class';
12960 $module =
'fournisseur';
12961 $classfile =
'fournisseur.commande';
12962 $element =
'order_supplier';
12964 $classname =
'CommandeFournisseur';
12965 $table_element =
'commande_fournisseur';
12966 } elseif ($elementType ==
'commande_fournisseurdet') {
12967 $classpath =
'fourn/class';
12968 $module =
'fournisseur';
12969 $classfile =
'fournisseur.commande';
12970 $element =
'commande_fournisseurdet';
12972 $classname =
'CommandeFournisseurLigne';
12973 $table_element =
'commande_fournisseurdet';
12974 } elseif ($elementType ==
'invoice_supplier') {
12975 $classpath =
'fourn/class';
12976 $module =
'fournisseur';
12977 $classfile =
'fournisseur.facture';
12978 $element =
'invoice_supplier';
12980 $classname =
'FactureFournisseur';
12981 $table_element =
'facture_fourn';
12982 } elseif ($elementType ==
"service") {
12983 $classpath =
'product/class';
12984 $subelement =
'product';
12985 $table_element =
'product';
12986 } elseif ($elementType ==
'salary') {
12987 $classpath =
'salaries/class';
12988 $module =
'salaries';
12989 } elseif ($elementType ==
'payment_salary') {
12990 $classpath =
'salaries/class';
12991 $classfile =
'paymentsalary';
12992 $classname =
'PaymentSalary';
12993 $module =
'salaries';
12994 } elseif ($elementType ==
'productlot') {
12995 $module =
'productbatch';
12996 $classpath =
'product/stock/class';
12997 $classfile =
'productlot';
12998 $classname =
'Productlot';
12999 $element =
'productlot';
13001 $table_element =
'product_lot';
13002 } elseif ($elementType ==
'societeaccount') {
13003 $classpath =
'societe/class';
13004 $classfile =
'societeaccount';
13005 $classname =
'SocieteAccount';
13006 $module =
'societe';
13007 } elseif ($elementType ==
'websitepage') {
13008 $classpath =
'website/class';
13009 $classfile =
'websitepage';
13010 $classname =
'Websitepage';
13011 $module =
'website';
13012 $subelement =
'websitepage';
13013 $table_element =
'website_page';
13014 } elseif ($elementType ==
'fiscalyear') {
13015 $classpath =
'core/class';
13016 $module =
'accounting';
13017 $subelement =
'fiscalyear';
13018 } elseif ($elementType ==
'chargesociales') {
13019 $classpath =
'compta/sociales/class';
13021 $table_element =
'chargesociales';
13022 } elseif ($elementType ==
'tva') {
13023 $classpath =
'compta/tva/class';
13026 $table_element =
'tva';
13027 } elseif ($elementType ==
'emailsenderprofile') {
13029 $classpath =
'core/class';
13030 $classfile =
'emailsenderprofile';
13031 $classname =
'EmailSenderProfile';
13032 $table_element =
'c_email_senderprofile';
13034 } elseif ($elementType ==
'conferenceorboothattendee') {
13035 $classpath =
'eventorganization/class';
13036 $classfile =
'conferenceorboothattendee';
13037 $classname =
'ConferenceOrBoothAttendee';
13038 $module =
'eventorganization';
13039 } elseif ($elementType ==
'conferenceorbooth') {
13040 $classpath =
'eventorganization/class';
13041 $classfile =
'conferenceorbooth';
13042 $classname =
'ConferenceOrBooth';
13043 $module =
'eventorganization';
13044 } elseif ($elementType ==
'ccountry') {
13046 $classpath =
'core/class';
13047 $classfile =
'ccountry';
13048 $classname =
'Ccountry';
13049 $table_element =
'c_country';
13053 if (empty($classfile)) {
13054 $classfile = strtolower($subelement);
13056 if (empty($classname)) {
13057 $classname = ucfirst($subelement);
13059 if (empty($classpath)) {
13060 $classpath = $module.
'/class';
13066 if ($module && isset($conf->$module)) {
13067 if (!empty($conf->$module->multidir_output[$conf->entity])) {
13068 $dir_output = $conf->$module->multidir_output[$conf->entity];
13069 } elseif (!empty($conf->$module->output[$conf->entity])) {
13070 $dir_output = $conf->$module->output[$conf->entity];
13071 } elseif (!empty($conf->$module->dir_output)) {
13072 $dir_output = $conf->$module->dir_output;
13077 if ($element ==
'order_supplier') {
13078 $dir_output = $conf->fournisseur->commande->dir_output;
13079 } elseif ($element ==
'invoice_supplier') {
13080 $dir_output = $conf->fournisseur->facture->dir_output;
13082 $dir_output .= $subdir;
13084 $elementProperties = array(
13085 'module' => $module,
13086 'element' => $element,
13087 'table_element' => $table_element,
13088 'subelement' => $subelement,
13089 'classpath' => $classpath,
13090 'classfile' => $classfile,
13091 'classname' => $classname,
13092 'dir_output' => $dir_output
13097 if (!is_object($hookmanager)) {
13098 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
13101 $hookmanager->initHooks(array(
'elementproperties'));
13105 $parameters = array(
13106 'elementType' => $elementType,
13107 'elementProperties' => $elementProperties
13110 $reshook = $hookmanager->executeHooks(
'getElementProperties', $parameters);
13113 $elementProperties = $hookmanager->resArray;
13114 } elseif (!empty($hookmanager->resArray) && is_array($hookmanager->resArray)) {
13115 $elementProperties = array_replace($elementProperties, $hookmanager->resArray);
13119 if (($key = array_search(
'elementproperties', $hookmanager->contextarray)) !==
false) {
13120 unset($hookmanager->contextarray[$key]);
13123 return $elementProperties;
13138function fetchObjectByElement($element_id, $element_type, $element_ref =
'', $useCache = 0, $maxCacheByType = 10)
13146 if ($element_prop[
'module'] ==
'product' || $element_prop[
'module'] ==
'service') {
13151 $ismodenabled = (isModEnabled(
'product') || isModEnabled(
'service'));
13152 } elseif ($element_prop[
'module'] ==
'societeaccount') {
13153 $ismodenabled = isModEnabled(
'website') || isModEnabled(
'webportal');
13155 $ismodenabled = isModEnabled($element_prop[
'module']);
13160 if (is_array($element_prop) && (empty($element_prop[
'module']) || $ismodenabled)) {
13161 if ($useCache === 1
13162 && !empty($conf->cache[
'fetchObjectByElement'][$element_type])
13163 && !empty($conf->cache[
'fetchObjectByElement'][$element_type][$element_id])
13164 && is_object($conf->cache[
'fetchObjectByElement'][$element_type][$element_id])
13166 return $conf->cache[
'fetchObjectByElement'][$element_type][$element_id];
13169 dol_include_once(
'/'.$element_prop[
'classpath'].
'/'.$element_prop[
'classfile'].
'.class.php');
13171 if (class_exists($element_prop[
'classname'])) {
13172 $className = $element_prop[
'classname'];
13173 $objecttmp =
new $className($db);
13174 '@phan-var-force CommonObject $objecttmp';
13176 if ($element_id > 0 || !empty($element_ref)) {
13177 $ret = $objecttmp->fetch($element_id, $element_ref);
13179 if (empty($objecttmp->module)) {
13180 $objecttmp->module = $element_prop[
'module'];
13183 if ($useCache > 0) {
13184 if (!isset($conf->cache[
'fetchObjectByElement'][$element_type])) {
13185 $conf->cache[
'fetchObjectByElement'][$element_type] = [];
13189 if (! empty($conf->cache[
'fetchObjectByElement'][$element_type]) && is_array($conf->cache[
'fetchObjectByElement'][$element_type]) && count($conf->cache[
'fetchObjectByElement'][$element_type]) >= $maxCacheByType) {
13190 array_shift($conf->cache[
'fetchObjectByElement'][$element_type]);
13193 $conf->cache[
'fetchObjectByElement'][$element_type][$element_id] = $objecttmp;
13217 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)) {
13233 return empty($_SESSION[
'newtoken']) ?
'' : $_SESSION[
'newtoken'];
13245 return isset($_SESSION[
'token']) ? $_SESSION[
'token'] :
'';
13257 if (empty($conf->cache[
'nonce'])) {
13261 return $conf->cache[
'nonce'];
13278function startSimpleTable($header, $link =
"", $arguments =
"", $emptyColumns = 0, $number = -1, $pictofulllist =
'')
13282 print
'<div class="div-table-responsive-no-min">';
13283 print
'<table class="noborder centpercent">';
13284 print
'<tr class="liste_titre">';
13286 print ($emptyColumns < 1) ?
'<th>' :
'<th colspan="'.($emptyColumns + 1).
'">';
13288 print
'<span class="valignmiddle">'.$langs->trans($header).
'</span>';
13290 if (!empty($link)) {
13291 if (!empty($arguments)) {
13292 print
'<a href="'.DOL_URL_ROOT.
'/'.$link.
'?'.$arguments.
'">';
13294 print
'<a href="'.DOL_URL_ROOT.
'/'.$link.
'">';
13298 if ($number > -1) {
13299 print
'<span class="badge marginleftonlyshort">'.$number.
'</span>';
13300 } elseif (!empty($link)) {
13301 print
'<span class="badge marginleftonlyshort">...</span>';
13304 if (!empty($link)) {
13310 if ($number < 0 && !empty($link)) {
13311 print
'<th class="right">';
13331 if ($addLineBreak) {
13347function addSummaryTableLine($tableColumnCount, $num, $nbofloop = 0, $total = 0, $noneWord =
"None", $extraRightColumn =
false)
13352 print
'<tr class="oddeven">';
13353 print
'<td colspan="'.$tableColumnCount.
'"><span class="opacitymedium">'.$langs->trans($noneWord).
'</span></td>';
13358 if ($nbofloop === 0) {
13364 $colspan = $tableColumnCount;
13365 } elseif ($num > $nbofloop) {
13366 $colspan = $tableColumnCount;
13368 $colspan = $tableColumnCount - 1;
13371 if ($extraRightColumn) {
13375 print
'<tr class="liste_total">';
13377 if ($nbofloop > 0 && $num > $nbofloop) {
13378 print
'<td colspan="'.$colspan.
'" class="right">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
'</td>';
13380 print
'<td colspan="'.$colspan.
'" class="right"> '.$langs->trans(
"Total").
'</td>';
13381 print
'<td class="right centpercent">'.price($total).
'</td>';
13384 if ($extraRightColumn) {
13401 if ($method == -1) {
13412 while (ob_get_level()) {
13417 if ($method == 0) {
13418 readfile($fullpath_original_file_osencoded);
13419 } elseif ($method == 1) {
13421 $handle = fopen($fullpath_original_file_osencoded,
"rb");
13422 while (!feof($handle)) {
13423 print fread($handle, 8192);
13426 } elseif ($method == 2) {
13428 $handle1 = fopen($fullpath_original_file_osencoded,
"rb");
13429 $handle2 = fopen(
"php://output",
"wb");
13430 stream_copy_to_stream($handle1, $handle2);
13455 if ($texttoshow ===
'none') {
13456 $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>';
13457 } elseif ($texttoshow) {
13458 $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>';
13460 $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>';
13475 $result = json_decode($stringtodecode);
13476 if ($result ===
null) {
13477 $result = unserialize($stringtodecode);
13504 if (is_null($filter) || !is_string($filter) || $filter ===
'') {
13507 if (!preg_match(
'/^\(.*\)$/', $filter)) {
13508 $filter =
'(' . $filter .
')';
13511 $regexstring =
'\(([a-zA-Z0-9_\.]+:[<>!=insotlke]+:[^\(\)]+)\)';
13512 $firstandlastparenthesis = 0;
13514 if (!
dolCheckFilters($filter, $errorstr, $firstandlastparenthesis)) {
13518 return 'Filter syntax error - '.$errorstr;
13523 $t = preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeDummyCriteriaCallback', $filter);
13524 $t = str_replace(array(
'and',
'or',
'AND',
'OR',
' '),
'', $t);
13527 if (preg_match(
'/[^\(\)]/', $t)) {
13528 $tmperrorstr =
'Bad syntax of the search string';
13529 $errorstr =
'Bad syntax of the search string: '.$filter;
13533 dol_syslog(
"forgeSQLFromUniversalSearchCriteria Filter error - ".$errorstr, LOG_WARNING);
13534 return 'Filter error - '.$tmperrorstr;
13538 $ret = ($noand ?
"" :
" AND ").($nopar ?
"" :
'(').preg_replace_callback(
'/'.$regexstring.
'/i',
'dolForgeCriteriaCallback', $filter).($nopar ?
"" :
')');
13540 if (is_object($db)) {
13541 $ret = str_replace(
'__NOW__',
"'".$db->idate(
dol_now()).
"'", $ret);
13543 if (is_object($user)) {
13544 $ret = str_replace(
'__USER_ID__', (
string) $user->id, $ret);
13559 $arrayofandtags = array();
13563 $parenthesislevel = 0;
13568 if ($parenthesislevel >= 1) {
13569 $sqlfilters = preg_replace(
'/^\(/',
'', preg_replace(
'/\)$/',
'', $sqlfilters));
13574 $countparenthesis = 0;
13575 while ($i < $nbofchars) {
13578 if ($char ==
'(') {
13579 $countparenthesis++;
13580 } elseif ($char ==
')') {
13581 $countparenthesis--;
13584 if ($countparenthesis == 0) {
13585 $char2 =
dol_substr($sqlfilters, $i + 1, 1);
13586 $char3 =
dol_substr($sqlfilters, $i + 2, 1);
13587 if ($char ==
'A' && $char2 ==
'N' && $char3 ==
'D') {
13590 if (!preg_match(
'/^\(.*\)$/', $s)) {
13593 $arrayofandtags[] = $s;
13606 if (!preg_match(
'/^\(.*\)$/', $s)) {
13609 $arrayofandtags[] = $s;
13612 return $arrayofandtags;
13624function dolCheckFilters($sqlfilters, &$error =
'', &$parenthesislevel = 0)
13628 $tmp = $sqlfilters;
13632 $parenthesislevel = 0;
13640 if ($char ==
'(') {
13641 if ($i == $parenthesislevel && $parenthesislevel == $counter) {
13643 $parenthesislevel++;
13646 } elseif ($char ==
')') {
13647 $nbcharremaining = ($nb - $i - 1);
13648 if ($nbcharremaining >= $counter) {
13649 $parenthesislevel = min($parenthesislevel, $counter - 1);
13651 if ($parenthesislevel > $counter && $nbcharremaining >= $counter) {
13652 $parenthesislevel = $counter;
13657 if ($counter < 0) {
13658 $error =
"Wrong balance of parenthesis in sqlfilters=".$sqlfilters;
13659 $parenthesislevel = 0;
13667 if ($counter > 0) {
13668 $error =
"Wrong balance of parenthesis in sqlfilters=".$sqlfilters;
13669 $parenthesislevel = 0;
13687 if (empty($matches[1])) {
13690 $tmp = explode(
':', $matches[1]);
13691 if (count($tmp) < 3) {
13711 if (empty($matches[1])) {
13714 $tmp = explode(
':', $matches[1], 3);
13715 if (count($tmp) < 3) {
13719 $operand = preg_replace(
'/[^a-z0-9\._]/i',
'', trim($tmp[0]));
13721 $operator = strtoupper(preg_replace(
'/[^a-z<>!=]/i',
'', trim($tmp[1])));
13724 'NOTLIKE' =>
'NOT LIKE',
13725 'ISNOT' =>
'IS NOT',
13726 'NOTIN' =>
'NOT IN',
13730 if (array_key_exists($operator, $realOperator)) {
13731 $operator = $realOperator[$operator];
13734 $tmpescaped = $tmp[2];
13740 if ($operator ==
'IN' || $operator ==
'NOT IN') {
13742 $tmpescaped2 =
'(';
13744 $tmpelemarray = explode(
',', $tmpescaped);
13745 foreach ($tmpelemarray as $tmpkey => $tmpelem) {
13747 if (preg_match(
'/^\'(.*)\'$/', $tmpelem, $reg)) {
13748 $tmpelemarray[$tmpkey] =
"'".$db->escape($db->sanitize($reg[1], 1, 1, 1)).
"'";
13750 $tmpelemarray[$tmpkey] = $db->escape($db->sanitize($tmpelem, 1, 1, 1));
13753 $tmpescaped2 .= implode(
',', $tmpelemarray);
13754 $tmpescaped2 .=
')';
13756 $tmpescaped = $tmpescaped2;
13757 } elseif ($operator ==
'LIKE' || $operator ==
'NOT LIKE') {
13758 if (preg_match(
'/^\'([^\']*)\'$/', $tmpescaped, $regbis)) {
13759 $tmpescaped = $regbis[1];
13762 $tmpescaped =
"'".$db->escape($tmpescaped).
"'";
13763 } elseif (preg_match(
'/^\'(.*)\'$/', $tmpescaped, $regbis)) {
13766 $tmpescaped =
"'".$db->escape($regbis[1]).
"'";
13768 if (strtoupper($tmpescaped) ==
'NULL') {
13769 $tmpescaped =
'NULL';
13770 } elseif (is_int($tmpescaped)) {
13771 $tmpescaped = (int) $tmpescaped;
13772 } elseif (is_numeric((
string) $tmpescaped)) {
13773 $tmpescaped = (float) $tmpescaped;
13775 $tmpescaped = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpescaped);
13779 return '('.$db->escape($operand).
' '.strtoupper($operator).
' '.$tmpescaped.
')';
13796 $out =
'<!-- timeline icon -->'.
"\n";
13797 $iconClass =
'fa fa-comments';
13802 if ($histo[$key][
'percent'] == -1) {
13803 $colorClass =
'timeline-icon-not-applicble';
13804 $pictoTitle = $langs->trans(
'StatusNotApplicable');
13805 } elseif ($histo[$key][
'percent'] == 0) {
13806 $colorClass =
'timeline-icon-todo';
13807 $pictoTitle = $langs->trans(
'StatusActionToDo').
' (0%)';
13808 } elseif ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100) {
13809 $colorClass =
'timeline-icon-in-progress';
13810 $pictoTitle = $langs->trans(
'StatusActionInProcess').
' ('.$histo[$key][
'percent'].
'%)';
13811 } elseif ($histo[$key][
'percent'] >= 100) {
13812 $colorClass =
'timeline-icon-done';
13813 $pictoTitle = $langs->trans(
'StatusActionDone').
' (100%)';
13816 if ($actionstatic->code ==
'AC_TICKET_CREATE') {
13817 $iconClass =
'fa fa-ticket';
13818 } elseif ($actionstatic->code ==
'AC_TICKET_MODIFY') {
13819 $iconClass =
'fa fa-pencilxxx';
13820 } elseif (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
13821 $iconClass =
'fa fa-comments';
13822 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
13823 $iconClass =
'fa fa-mask';
13825 if ($actionstatic->type_picto) {
13826 $img_picto =
img_picto(
'', $actionstatic->type_picto);
13828 if ($actionstatic->type_code ==
'AC_RDV') {
13829 $iconClass =
'fa fa-handshake';
13830 } elseif ($actionstatic->type_code ==
'AC_TEL') {
13831 $iconClass =
'fa fa-phone';
13832 } elseif ($actionstatic->type_code ==
'AC_FAX') {
13833 $iconClass =
'fa fa-fax';
13834 } elseif ($actionstatic->type_code ==
'AC_EMAIL') {
13835 $iconClass =
'fa fa-envelope';
13836 } elseif ($actionstatic->type_code ==
'AC_INT') {
13837 $iconClass =
'fa fa-shipping-fast';
13838 } elseif ($actionstatic->type_code ==
'AC_OTH_AUTO') {
13839 $iconClass =
'fa fa-robot';
13840 } elseif (!preg_match(
'/_AUTO/', $actionstatic->type_code)) {
13841 $iconClass =
'fa fa-robot';
13846 $out .=
'<i class="'.$iconClass.
' '.$colorClass.
'" title="'.$pictoTitle.
'">'.$img_picto.
'</i>'.
"\n";
13860 $documents = array();
13862 $sql =
'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.filepath, ecm.filename';
13863 $sql .=
' FROM '.MAIN_DB_PREFIX.
'ecm_files ecm';
13864 $sql .=
" WHERE ecm.filepath = 'agenda/".((int)
$object->id).
"'";
13866 $sql .=
' ORDER BY ecm.position ASC';
13868 $resql = $db->query($sql);
13870 if ($db->num_rows($resql)) {
13871 while ($obj = $db->fetch_object($resql)) {
13872 $documents[$obj->id] = $obj;
13898function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon =
null, $noprint = 0, $actioncode =
'', $donetodo =
'done', $filters = array(), $sortfield =
'a.datep,a.id', $sortorder =
'DESC')
13900 global $user, $conf;
13903 global $param, $massactionbutton;
13905 require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
13908 if (!is_object($filterobj) && !is_object($objcon)) {
13913 '@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';
13918 $sortfield_list = explode(
',', $sortfield);
13919 $sortfield_label_list = array(
'a.id' =>
'id',
'a.datep' =>
'dp',
'a.percent' =>
'percent');
13920 $sortfield_new_list = array();
13921 foreach ($sortfield_list as $sortfield_value) {
13922 $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
13924 $sortfield_new = implode(
',', $sortfield_new_list);
13929 if (isModEnabled(
'agenda')) {
13931 if (is_object($objcon) && $objcon->id > 0) {
13932 $sql =
"SELECT DISTINCT a.id, a.label as label,";
13934 $sql =
"SELECT a.id, a.label as label,";
13936 $sql .=
" a.datep as dp,";
13937 $sql .=
" a.note as message,";
13938 $sql .=
" a.datep2 as dp2,";
13939 $sql .=
" a.percent as percent, 'action' as type,";
13940 $sql .=
" a.fk_element, a.elementtype,";
13941 $sql .=
" a.fk_contact,";
13942 $sql .=
" a.email_from as msg_from,";
13943 $sql .=
" c.code as acode, c.libelle as alabel, c.picto as apicto,";
13944 $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";
13945 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
13946 $sql .=
", sp.lastname, sp.firstname";
13947 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
13948 $sql .=
", m.lastname, m.firstname";
13949 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
13951 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
13953 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
13955 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
13957 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
13960 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm as a";
13961 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on u.rowid = a.fk_user_action";
13962 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_actioncomm as c ON a.fk_action = c.id";
13964 $force_filter_contact = $filterobj instanceof
User;
13966 if (is_object($objcon) && $objcon->id > 0) {
13967 $force_filter_contact =
true;
13968 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm_resources as r ON a.id = r.fk_actioncomm";
13969 $sql .=
" AND r.element_type = '".$db->escape($objcon->table_element).
"' AND r.fk_element = ".((int) $objcon->id);
13972 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
13973 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON a.fk_contact = sp.rowid";
13974 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Dolresource') {
13975 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"element_resources as er";
13976 $sql .=
" ON er.resource_type = 'dolresource'";
13977 $sql .=
" AND er.element_id = a.id";
13978 $sql .=
" AND er.resource_id = ".((int) $filterobj->id);
13979 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
13980 $sql .=
", ".MAIN_DB_PREFIX.
"adherent as m";
13981 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
13982 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as o";
13983 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
13984 $sql .=
", ".MAIN_DB_PREFIX.
"product as o";
13985 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
13986 $sql .=
", ".MAIN_DB_PREFIX.
"ticket as o";
13987 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
13988 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as o";
13989 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
13990 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as o";
13993 $sql .=
" WHERE a.entity IN (".getEntity(
'agenda').
")";
13994 if (!$force_filter_contact) {
13995 if (is_object($filterobj) && in_array(get_class($filterobj), array(
'Societe',
'Client',
'Fournisseur')) && $filterobj->id) {
13996 $sql .=
" AND a.fk_soc = ".((int) $filterobj->id);
13997 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Project' && $filterobj->id) {
13998 $sql .=
" AND a.fk_project = ".((int) $filterobj->id);
13999 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
14000 $sql .=
" AND a.fk_element = m.rowid AND a.elementtype = 'member'";
14001 if ($filterobj->id) {
14002 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
14004 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
14005 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
14006 if ($filterobj->id) {
14007 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
14009 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
14010 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'product'";
14011 if ($filterobj->id) {
14012 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
14014 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
14015 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
14016 if ($filterobj->id) {
14017 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
14019 } elseif (is_object($filterobj) && get_class($filterobj) ==
'BOM') {
14020 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
14021 if ($filterobj->id) {
14022 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
14024 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Contrat') {
14025 $sql .=
" AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
14026 if ($filterobj->id) {
14027 $sql .=
" AND a.fk_element = ".((int) $filterobj->id);
14031 $sql .=
" AND u.rowid = ". ((int) $filterobj->id);
14035 if (!empty($actioncode)) {
14037 if ($actioncode ==
'AC_NON_AUTO') {
14038 $sql .=
" AND c.type != 'systemauto'";
14039 } elseif ($actioncode ==
'AC_ALL_AUTO') {
14040 $sql .=
" AND c.type = 'systemauto'";
14042 if ($actioncode ==
'AC_OTH') {
14043 $sql .=
" AND c.type != 'systemauto'";
14044 } elseif ($actioncode ==
'AC_OTH_AUTO') {
14045 $sql .=
" AND c.type = 'systemauto'";
14049 if ($actioncode ==
'AC_NON_AUTO') {
14050 $sql .=
" AND c.type != 'systemauto'";
14051 } elseif ($actioncode ==
'AC_ALL_AUTO') {
14052 $sql .=
" AND c.type = 'systemauto'";
14054 $sql .=
" AND c.code = '".$db->escape($actioncode).
"'";
14058 if ($donetodo ==
'todo') {
14059 $sql .=
" AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now).
"'))";
14060 } elseif ($donetodo ==
'done') {
14061 $sql .=
" AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now).
"'))";
14063 if (is_array($filters) && $filters[
'search_agenda_label']) {
14064 $sql .=
natural_search(
'a.label', $filters[
'search_agenda_label']);
14069 if (isModEnabled(
'mailing') && !empty($objcon->email)
14070 && (empty($actioncode) || $actioncode ==
'AC_OTH_AUTO' || $actioncode ==
'AC_EMAILING')) {
14071 $langs->load(
"mails");
14073 $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";
14074 $sql2 .=
", null as fk_element, '' as elementtype, null as contact_id";
14075 $sql2 .=
", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
14076 $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";
14077 if (is_object($filterobj) && get_class($filterobj) ==
'Societe') {
14078 $sql2 .=
", '' as lastname, '' as firstname";
14079 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Adherent') {
14080 $sql2 .=
", '' as lastname, '' as firstname";
14081 } elseif (is_object($filterobj) && get_class($filterobj) ==
'CommandeFournisseur') {
14082 $sql2 .=
", '' as ref";
14083 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Product') {
14084 $sql2 .=
", '' as ref";
14085 } elseif (is_object($filterobj) && get_class($filterobj) ==
'Ticket') {
14086 $sql2 .=
", '' as ref";
14088 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"mailing as m, ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"user as u";
14089 $sql2 .=
" WHERE mc.email = '".$db->escape($objcon->email).
"'";
14090 $sql2 .=
" AND mc.statut = 1";
14091 $sql2 .=
" AND u.rowid = m.fk_user_valid";
14092 $sql2 .=
" AND mc.fk_mailing=m.rowid";
14095 if ($sql || $sql2) {
14096 if (!empty($sql) && !empty($sql2)) {
14097 $sql = $sql.
" UNION ".$sql2;
14098 } elseif (empty($sql) && !empty($sql2)) {
14107 $sql .= $db->order($sortfield_new, $sortorder);
14109 $sql .= $db->plimit($limit + 1, $offset);
14112 dol_syslog(
"function.lib::show_actions_messaging", LOG_DEBUG);
14113 $resql = $db->query($sql);
14116 $num = $db->num_rows($resql);
14118 $imaxinloop = ($limit ? min($num, $limit) : $num);
14119 while ($i < $imaxinloop) {
14120 $obj = $db->fetch_object($resql);
14122 if ($obj->type ==
'action') {
14124 $contactaction->id = $obj->id;
14125 $result = $contactaction->fetchResources();
14128 setEventMessage(
"actions.lib::show_actions_messaging Error fetch resource",
'errors');
14134 if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->dp > $now)) {
14135 $tododone =
'todo';
14138 $histo[$numaction] = array(
14139 'type' => $obj->type,
14140 'tododone' => $tododone,
14142 'datestart' => $db->jdate($obj->dp),
14143 'dateend' => $db->jdate($obj->dp2),
14144 'note' => $obj->label,
14146 'percent' => $obj->percent,
14148 'userid' => $obj->user_id,
14149 'login' => $obj->user_login,
14150 'userfirstname' => $obj->user_firstname,
14151 'userlastname' => $obj->user_lastname,
14152 'userphoto' => $obj->user_photo,
14153 'msg_from' => $obj->msg_from,
14155 'contact_id' => $obj->fk_contact,
14156 'socpeopleassigned' => $contactaction->socpeopleassigned,
14157 'lastname' => (empty($obj->lastname) ?
'' : $obj->lastname),
14158 'firstname' => (empty($obj->firstname) ?
'' : $obj->firstname),
14159 'fk_element' => $obj->fk_element,
14160 'elementtype' => $obj->elementtype,
14162 'acode' => $obj->acode,
14163 'alabel' => $obj->alabel,
14164 'libelle' => $obj->alabel,
14165 'apicto' => $obj->apicto
14168 $histo[$numaction] = array(
14169 'type' => $obj->type,
14170 'tododone' =>
'done',
14172 'datestart' => $db->jdate($obj->dp),
14173 'dateend' => $db->jdate($obj->dp2),
14174 'note' => $obj->label,
14176 'percent' => $obj->percent,
14177 'acode' => $obj->acode,
14179 'userid' => $obj->user_id,
14180 'login' => $obj->user_login,
14181 'userfirstname' => $obj->user_firstname,
14182 'userlastname' => $obj->user_lastname,
14183 'userphoto' => $obj->user_photo
14198 if (!isModEnabled(
'agenda')) {
14199 $langs->loadLangs(array(
"admin",
"errors"));
14200 $out =
info_admin($langs->trans(
"WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv(
"Module2400Name")), 0, 0,
'warning');
14203 if (isModEnabled(
'agenda') || (isModEnabled(
'mailing') && !empty($objcon->email))) {
14204 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
14206 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
14207 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
14208 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
14209 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
14214 $userstatic =
new User($db);
14215 $contactstatic =
new Contact($db);
14216 $userGetNomUrlCache = array();
14217 $contactGetNomUrlCache = array();
14219 $out .=
'<div class="filters-container" >';
14220 $out .=
'<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
14221 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
14223 if ($objcon && get_class($objcon) ==
'Contact' &&
14224 (is_null($filterobj) || get_class($filterobj) ==
'Societe')) {
14225 $out .=
'<input type="hidden" name="id" value="'.$objcon->id.
'" />';
14227 $out .=
'<input type="hidden" name="id" value="'.$filterobj->id.
'" />';
14229 if (($filterobj && get_class($filterobj) ==
'Societe')) {
14230 $out .=
'<input type="hidden" name="socid" value="'.$filterobj->id.
'" />';
14232 $out .=
'<input type="hidden" name="userid" value="'.$filterobj->id.
'" />';
14237 $out .=
'<div class="div-table-responsive-no-min">';
14238 $out .=
'<table class="noborder borderbottom centpercent">';
14240 $out .=
'<tr class="liste_titre">';
14244 $out .=
'<th class="liste_titre width50 middle">';
14245 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
14246 $out .= $searchpicto;
14250 $out .=
getTitleFieldOfList(
'Date', 0, $_SERVER[
"PHP_SELF"],
'a.datep',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
14252 $out .=
'<th class="liste_titre"><strong class="hideonsmartphone">'.$langs->trans(
"Search").
' : </strong></th>';
14254 $out .=
'<th class="liste_titre"></th>';
14256 $out .=
'<th class="liste_titre">';
14257 $out .=
'<span class="fas fa-square inline-block fawidth30" style=" color: #ddd;" title="'.$langs->trans(
"ActionType").
'"></span>';
14259 $out .= $formactions->select_type_actions($actioncode,
"actioncode",
'', !
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 1 : -1, 0, 0, 1,
'minwidth200imp');
14261 $out .=
'<th class="liste_titre maxwidth100onsmartphone">';
14262 $out .=
'<input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters[
'search_agenda_label'].
'" placeholder="'.$langs->trans(
"Label").
'">';
14267 $out .=
'<th class="liste_titre width50 middle">';
14268 $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0,
'checkforselect', 1);
14269 $out .= $searchpicto;
14276 $out .=
'</table>';
14283 $out .=
'<ul class="timeline">';
14287 if ($filterobj instanceof
Societe) {
14288 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
14290 if ($filterobj instanceof
User) {
14291 $tmp .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.
'&status=done">';
14293 $tmp .= ($donetodo !=
'done' ? $langs->trans(
"ActionsToDoShort") :
'');
14294 $tmp .= ($donetodo !=
'done' && $donetodo !=
'todo' ?
' / ' :
'');
14295 $tmp .= ($donetodo !=
'todo' ? $langs->trans(
"ActionsDoneShort") :
'');
14297 if ($filterobj instanceof
Societe) {
14300 if ($filterobj instanceof
User) {
14306 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
14308 $arraylist = $caction->liste_array(1,
'code',
'', (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ? 1 : 0),
'', 1);
14310 $actualCycleDate =
false;
14313 foreach ($histo as $key => $value) {
14314 $actionstatic->fetch($histo[$key][
'id']);
14316 $actionstatic->type_picto = $histo[$key][
'apicto'];
14317 $actionstatic->type_code = $histo[$key][
'acode'];
14319 $labeltype = $actionstatic->type_code;
14320 if (!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labeltype])) {
14321 $labeltype =
'AC_OTH';
14323 if (!empty($actionstatic->code) && preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
14324 $labeltype = $langs->trans(
"Message");
14326 if (!empty($arraylist[$labeltype])) {
14327 $labeltype = $arraylist[$labeltype];
14329 if ($actionstatic->type_code ==
'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
14330 $labeltype .=
' - '.$arraylist[$actionstatic->code];
14334 $url = DOL_URL_ROOT.
'/comm/action/card.php?id='.$histo[$key][
'id'];
14336 $tmpa =
dol_getdate($histo[$key][
'datestart'],
false);
14338 if (isset($tmpa[
'year']) && isset($tmpa[
'yday']) && $actualCycleDate !== $tmpa[
'year'].
'-'.$tmpa[
'yday']) {
14339 $actualCycleDate = $tmpa[
'year'].
'-'.$tmpa[
'yday'];
14340 $out .=
'<!-- timeline time label -->';
14341 $out .=
'<li class="time-label">';
14342 $out .=
'<span class="timeline-badge-date">';
14343 $out .=
dol_print_date($histo[$key][
'datestart'],
'daytext',
'tzuserrel', $langs);
14346 $out .=
'<!-- /.timeline-label -->';
14350 $out .=
'<!-- timeline item -->'.
"\n";
14351 $out .=
'<li class="timeline-code-'.strtolower($actionstatic->code).
'">';
14354 $typeicon = $actionstatic->getTypePicto(
'pictofixedwidth timeline-icon-not-applicble', $labeltype);
14359 $out .=
'<div class="timeline-item">'.
"\n";
14361 $out .=
'<span class="time timeline-header-action2">';
14363 if (isset($histo[$key][
'type']) && $histo[$key][
'type'] ==
'mailing') {
14364 $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").
' ';
14365 $out .= $histo[$key][
'id'];
14368 $out .= $actionstatic->getNomUrl(1, -1,
'valignmiddle').
' ';
14371 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
14372 (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
14373 $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).
'">';
14375 $out .=
img_picto($langs->trans(
"Modify"),
'edit',
'class="edita"');
14382 $out .=
'<span class="time"><i class="fa fa-clock-o valignmiddle"></i> <span class="valignmiddle">';
14383 $out .=
dol_print_date($histo[$key][
'datestart'],
'dayhour',
'tzuserrel');
14384 if ($histo[$key][
'dateend'] && $histo[$key][
'dateend'] != $histo[$key][
'datestart']) {
14385 $tmpa =
dol_getdate($histo[$key][
'datestart'],
true);
14386 $tmpb =
dol_getdate($histo[$key][
'dateend'],
true);
14387 if ($tmpa[
'mday'] == $tmpb[
'mday'] && $tmpa[
'mon'] == $tmpb[
'mon'] && $tmpa[
'year'] == $tmpb[
'year']) {
14388 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'hour',
'tzuserrel');
14390 $out .=
'-'.dol_print_date($histo[$key][
'dateend'],
'dayhour',
'tzuserrel');
14394 if ($histo[$key][
'percent'] == 0 && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
14397 if ($histo[$key][
'percent'] == 0 && !$histo[$key][
'datestart'] && $histo[$key][
'dateend'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
14400 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && $histo[$key][
'dateend'] && $histo[$key][
'dateend'] < ($now - $delay_warning)) {
14403 if ($histo[$key][
'percent'] > 0 && $histo[$key][
'percent'] < 100 && !$histo[$key][
'dateend'] && $histo[$key][
'datestart'] && $histo[$key][
'datestart'] < ($now - $delay_warning)) {
14409 $out .=
"</span></span>\n";
14412 $out .=
'<h3 class="timeline-header">';
14415 $out .=
'<div class="messaging-author inline-block tdoverflowmax150 valignmiddle marginrightonly">';
14416 if ($histo[$key][
'userid'] > 0) {
14417 if (!isset($userGetNomUrlCache[$histo[$key][
'userid']])) {
14418 $userstatic->fetch($histo[$key][
'userid']);
14419 $userGetNomUrlCache[$histo[$key][
'userid']] = $userstatic->getNomUrl(-1,
'', 0, 0, 16, 0,
'firstelselast',
'');
14421 $out .= $userGetNomUrlCache[$histo[$key][
'userid']];
14422 } elseif (!empty($histo[$key][
'msg_from']) && $actionstatic->code ==
'TICKET_MSG') {
14423 if (!isset($contactGetNomUrlCache[$histo[$key][
'msg_from']])) {
14424 if ($contactstatic->fetch(0,
null,
'', $histo[$key][
'msg_from']) > 0) {
14425 $contactGetNomUrlCache[$histo[$key][
'msg_from']] = $contactstatic->getNomUrl(-1,
'', 16);
14427 $contactGetNomUrlCache[$histo[$key][
'msg_from']] = $histo[$key][
'msg_from'];
14430 $out .= $contactGetNomUrlCache[$histo[$key][
'msg_from']];
14435 $out .=
' <div class="messaging-title inline-block">';
14437 if (empty($conf->dol_optimize_smallscreen) && $actionstatic->type_code !=
'AC_OTH_AUTO') {
14438 $out .= $labeltype.
' - ';
14442 if (preg_match(
'/^TICKET_MSG/', $actionstatic->code)) {
14443 $out .= $langs->trans(
'TicketNewMessage');
14444 } elseif (preg_match(
'/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
14445 $out .= $langs->trans(
'TicketNewMessage').
' <em>('.$langs->trans(
'Private').
')</em>';
14446 } elseif (isset($histo[$key][
'type'])) {
14447 if ($histo[$key][
'type'] ==
'action') {
14448 $transcode = $langs->transnoentitiesnoconv(
"Action".$histo[$key][
'acode']);
14449 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode : $histo[$key][
'alabel']);
14450 $libelle = $histo[$key][
'note'];
14451 $actionstatic->id = $histo[$key][
'id'];
14453 } elseif ($histo[$key][
'type'] ==
'mailing') {
14454 $out .=
'<a href="'.DOL_URL_ROOT.
'/comm/mailing/card.php?id='.$histo[$key][
'id'].
'">'.
img_object($langs->trans(
"ShowEMailing"),
"email").
' ';
14455 $transcode = $langs->transnoentitiesnoconv(
"Action".$histo[$key][
'acode']);
14456 $libelle = ($transcode !=
"Action".$histo[$key][
'acode'] ? $transcode :
'Send mass mailing');
14459 $libelle .= $histo[$key][
'note'];
14464 if (isset($histo[$key][
'elementtype']) && !empty($histo[$key][
'fk_element'])) {
14465 if (isset($conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']]) && isset($conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']])) {
14466 $link = $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']];
14468 if (!isset($conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']])) {
14469 $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']] = array();
14471 $link =
dolGetElementUrl($histo[$key][
'fk_element'], $histo[$key][
'elementtype'], 1);
14472 $conf->cache[
'elementlinkcache'][$histo[$key][
'elementtype']][$histo[$key][
'fk_element']] = $link;
14475 $out .=
' - '.$link;
14484 if (!empty($histo[$key][
'message'] && $histo[$key][
'message'] != $libelle)
14485 && $actionstatic->code !=
'AC_TICKET_CREATE'
14486 && $actionstatic->code !=
'AC_TICKET_MODIFY'
14488 $out .=
'<div class="timeline-body wordbreak small">';
14489 $truncateLines =
getDolGlobalInt(
'MAIN_TRUNCATE_TIMELINE_MESSAGE', 3);
14491 if ($truncateLines > 0 && strlen($histo[$key][
'message']) > strlen($truncatedText)) {
14492 $out .=
'<div class="readmore-block --closed" >';
14493 $out .=
' <div class="readmore-block__excerpt">';
14495 $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>';
14497 $out .=
' <div class="readmore-block__full-text" >';
14499 $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>';
14513 if (isset($histo[$key][
'socpeopleassigned']) && is_array($histo[$key][
'socpeopleassigned']) && count($histo[$key][
'socpeopleassigned']) > 0) {
14515 foreach ($histo[$key][
'socpeopleassigned'] as $cid => $Tab) {
14516 if (empty($conf->cache[
'contact'][$histo[$key][
'contact_id']])) {
14518 $contact->fetch($cid);
14519 $conf->cache[
'contact'][$histo[$key][
'contact_id']] = $contact;
14521 $contact = $conf->cache[
'contact'][$histo[$key][
'contact_id']];
14525 $contactList .= !empty($contactList) ?
', ' :
'';
14526 $contactList .= $contact->getNomUrl(1);
14527 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
14528 if (!empty($contact->phone_pro)) {
14529 $contactList .=
'('.dol_print_phone($contact->phone_pro).
')';
14535 $footer .= $langs->trans(
'ActionOnContact').
' : '.$contactList;
14536 } elseif (empty($objcon->id) && isset($histo[$key][
'contact_id']) && $histo[$key][
'contact_id'] > 0) {
14537 if (empty($conf->cache[
'contact'][$histo[$key][
'contact_id']])) {
14539 $result = $contact->fetch($histo[$key][
'contact_id']);
14540 $conf->cache[
'contact'][$histo[$key][
'contact_id']] = $contact;
14542 $contact = $conf->cache[
'contact'][$histo[$key][
'contact_id']];
14543 $result = ($contact instanceof
Contact) ? $contact->id : 0;
14547 $footer .= $contact->getNomUrl(1);
14548 if (isset($histo[$key][
'acode']) && $histo[$key][
'acode'] ==
'AC_TEL') {
14549 if (!empty($contact->phone_pro)) {
14550 $footer .=
'('.dol_print_phone($contact->phone_pro).
')';
14557 if (!empty($documents)) {
14558 $footer .=
'<div class="timeline-documents-container">';
14559 foreach ($documents as $doc) {
14560 $footer .=
'<span id="document_'.$doc->id.
'" class="timeline-documents" ';
14561 $footer .=
' data-id="'.$doc->id.
'" ';
14562 $footer .=
' data-path="'.$doc->filepath.
'"';
14563 $footer .=
' data-filename="'.dol_escape_htmltag($doc->filename).
'" ';
14566 $filePath = DOL_DATA_ROOT.
'/'.$doc->filepath.
'/'.$doc->filename;
14568 $file = $actionstatic->id.
'/'.$doc->filename;
14569 $thumb = $actionstatic->id.
'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename,
'.')).
'_mini'.substr($doc->filename, strrpos($doc->filename,
'.'));
14570 $doclink =
dol_buildpath(
'document.php', 1).
'?modulepart=actions&attachment=0&file='.urlencode($file).
'&entity='.$conf->entity;
14571 $viewlink =
dol_buildpath(
'viewimage.php', 1).
'?modulepart=actions&file='.urlencode($thumb).
'&entity='.$conf->entity;
14573 $mimeAttr =
' mime="'.$mime.
'" ';
14575 if (in_array($mime, array(
'image/png',
'image/jpeg',
'application/pdf'))) {
14576 $class .=
' documentpreview';
14579 $footer .=
'<a href="'.$doclink.
'" class="btn-link '.$class.
'" target="_blank" rel="noopener noreferrer" '.$mimeAttr.
' >';
14580 $footer .=
img_mime($filePath).
' '.$doc->filename;
14583 $footer .=
'</span>';
14585 $footer .=
'</div>';
14588 if (!empty($footer)) {
14589 $out .=
'<div class="timeline-footer">'.$footer.
'</div>';
14592 $out .=
'</div>'.
"\n";
14595 $out .=
'<!-- END timeline item -->';
14601 jQuery(document).ready(function () {
14602 $(document).on("click", "[data-read-more-action]", function(e){
14603 let readMoreBloc = $(this).closest(".readmore-block");
14604 if(readMoreBloc.length > 0){
14605 e.preventDefault();
14606 if($(this).attr("data-read-more-action") == "close"){
14607 readMoreBloc.addClass("--closed").removeClass("--open");
14608 $("html, body").animate({
14609 scrollTop: readMoreBloc.offset().top - 200
14612 readMoreBloc.addClass("--open").removeClass("--closed");
14620 if (empty($histo)) {
14621 $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
14642function GETPOSTDATE($prefix, $hourTime =
'', $gm =
'auto')
14645 if ($hourTime ===
'getpost') {
14649 } elseif (preg_match(
'/^(\d\d):(\d\d):(\d\d)$/', $hourTime, $m)) {
14650 $hour = intval($m[1]);
14651 $minute = intval($m[2]);
14652 $second = intval($m[3]);
14654 $hour = $minute = $second = 0;
14657 $hour = min($hour, 23);
14658 $minute = min($minute, 59);
14659 $second = min($second, 59);
14674function buildParamDate($prefix, $timestamp =
null, $hourTime =
'', $gm =
'auto')
14676 if ($timestamp ===
null) {
14677 $timestamp =
GETPOSTDATE($prefix, $hourTime, $gm);
14684 if ($hourTime ===
'getpost' || ($timestamp !==
null &&
dol_print_date($timestamp,
'%H:%M:%S') !==
'00:00:00')) {
14685 $TParam = array_merge($TParam, array(
14692 return '&' . http_build_query($TParam);
14714function recordNotFound($message =
'', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params =
null)
14716 global $conf, $db, $langs, $hookmanager;
14719 if (!is_object($langs)) {
14720 include_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
14722 $langs->setDefaultLang();
14725 $langs->load(
"errors");
14727 if ($printheader) {
14728 if (function_exists(
"llxHeader")) {
14730 } elseif (function_exists(
"llxHeaderVierge")) {
14735 print
'<div class="error">';
14736 if (empty($message)) {
14737 print $langs->trans(
"ErrorRecordNotFound");
14739 print $langs->trans($message);
14744 if (empty($showonlymessage)) {
14745 if (empty($hookmanager)) {
14746 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
14749 $hookmanager->initHooks(array(
'main'));
14752 $parameters = array(
'message' => $message,
'params' => $params);
14753 $reshook = $hookmanager->executeHooks(
'getErrorRecordNotFound', $parameters,
$object, $action);
14754 print $hookmanager->resPrint;
14757 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.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
dolCheckFilters($sqlfilters, &$error='', &$parenthesislevel=0)
Return if a $sqlfilters parameter has a valid balance of parenthesis.
finishSimpleTable($addLineBreak=false)
Add the correct HTML close tags for "startSimpleTable(...)" (use after the last table line)
show_actions_messaging($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC')
Show html area with actions in messaging format.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
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_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