@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | if ($found) return $result; |
| 76 | 76 | } */ |
| 77 | 77 | |
| 78 | - if (isset($class::$member)) |
|
| 79 | - return $class::$member; |
|
| 78 | + if (isset($class::$member)) { |
|
| 79 | + return $class::$member; |
|
| 80 | + } |
|
| 80 | 81 | dol_print_error('', 'Try to get a static member "' . $member . '" in class "' . $class . '" that does not exists or is not static.');
|
| 81 | 82 | return null; |
| 82 | 83 | } |
@@ -127,8 +128,9 @@ discard block |
||
| 127 | 128 | } else {
|
| 128 | 129 | $out = ''; |
| 129 | 130 | $addzero = array('user', 'usergroup', 'c_email_templates', 'email_template', 'default_values');
|
| 130 | - if (in_array($element, $addzero)) |
|
| 131 | - $out .= '0,'; |
|
| 131 | + if (in_array($element, $addzero)) { |
|
| 132 | + $out .= '0,'; |
|
| 133 | + } |
|
| 132 | 134 | $out .= Globals::$conf->entity; |
| 133 | 135 | return $out; |
| 134 | 136 | } |
@@ -307,32 +309,35 @@ discard block |
||
| 307 | 309 | {
|
| 308 | 310 | // global $mysoc, $user, Globals::$conf; |
| 309 | 311 | |
| 310 | - if (empty($paramname)) |
|
| 311 | - return 'BadFirstParameterForDolUtils::GETPOST'; |
|
| 312 | + if (empty($paramname)) { |
|
| 313 | + return 'BadFirstParameterForDolUtils::GETPOST'; |
|
| 314 | + } |
|
| 312 | 315 | if (empty($check)) {
|
| 313 | 316 | dol_syslog("Deprecated use of DolUtils::GETPOST, called with 1st param = " . $paramname . " and 2nd param is '', when calling page " . $_SERVER["PHP_SELF"], LOG_WARNING);
|
| 314 | 317 | // Enable this line to know who call the DolUtils::GETPOST with '' $check parameter. |
| 315 | 318 | //var_dump(debug_backtrace()[0]); |
| 316 | 319 | } |
| 317 | 320 | |
| 318 | - if (empty($method)) |
|
| 319 | - $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : ''); |
|
| 320 | - elseif ($method == 1) |
|
| 321 | - $out = isset($_GET[$paramname]) ? $_GET[$paramname] : ''; |
|
| 322 | - elseif ($method == 2) |
|
| 323 | - $out = isset($_POST[$paramname]) ? $_POST[$paramname] : ''; |
|
| 324 | - elseif ($method == 3) |
|
| 325 | - $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : ''); |
|
| 326 | - elseif ($method == 4) |
|
| 327 | - $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_COOKIE[$paramname]) ? $_COOKIE[$paramname] : '')); |
|
| 328 | - else |
|
| 329 | - return 'BadThirdParameterForDolUtils::GETPOST'; |
|
| 321 | + if (empty($method)) { |
|
| 322 | + $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : ''); |
|
| 323 | + } elseif ($method == 1) { |
|
| 324 | + $out = isset($_GET[$paramname]) ? $_GET[$paramname] : ''; |
|
| 325 | + } elseif ($method == 2) { |
|
| 326 | + $out = isset($_POST[$paramname]) ? $_POST[$paramname] : ''; |
|
| 327 | + } elseif ($method == 3) { |
|
| 328 | + $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : ''); |
|
| 329 | + } elseif ($method == 4) { |
|
| 330 | + $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_COOKIE[$paramname]) ? $_COOKIE[$paramname] : '')); |
|
| 331 | + } else { |
|
| 332 | + return 'BadThirdParameterForDolUtils::GETPOST'; |
|
| 333 | + } |
|
| 330 | 334 | |
| 331 | 335 | if (empty($method) || $method == 3 || $method == 4) {
|
| 332 | 336 | $relativepathstring = $_SERVER["PHP_SELF"]; |
| 333 | 337 | // Clean $relativepathstring |
| 334 | - if (constant('DOL_BASE_URI'))
|
|
| 335 | - $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
|
|
| 338 | + if (constant('DOL_BASE_URI')) { |
|
| 339 | + $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring); |
|
| 340 | + } |
|
| 336 | 341 | $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
|
| 337 | 342 | $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
|
| 338 | 343 | //var_dump($relativepathstring); |
@@ -381,14 +386,17 @@ discard block |
||
| 381 | 386 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
| 382 | 387 | $foundintru = 0; |
| 383 | 388 | foreach ($tmpqueryarraytohave as $tmpquerytohave) {
|
| 384 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
| 385 | - $foundintru = 1; |
|
| 389 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
| 390 | + $foundintru = 1; |
|
| 391 | + } |
|
| 386 | 392 | } |
| 387 | - if (!$foundintru) |
|
| 388 | - $qualified = 1; |
|
| 393 | + if (!$foundintru) { |
|
| 394 | + $qualified = 1; |
|
| 395 | + } |
|
| 389 | 396 | //var_dump($defkey.'-'.$qualified); |
| 390 | - } else |
|
| 391 | - $qualified = 1; |
|
| 397 | + } else { |
|
| 398 | + $qualified = 1; |
|
| 399 | + } |
|
| 392 | 400 | |
| 393 | 401 | if ($qualified) {
|
| 394 | 402 | //var_dump($user->default_values[$relativepathstring][$defkey]['createform']); |
@@ -415,20 +423,24 @@ discard block |
||
| 415 | 423 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
| 416 | 424 | $foundintru = 0; |
| 417 | 425 | foreach ($tmpqueryarraytohave as $tmpquerytohave) {
|
| 418 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
| 419 | - $foundintru = 1; |
|
| 426 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
| 427 | + $foundintru = 1; |
|
| 428 | + } |
|
| 420 | 429 | } |
| 421 | - if (!$foundintru) |
|
| 422 | - $qualified = 1; |
|
| 430 | + if (!$foundintru) { |
|
| 431 | + $qualified = 1; |
|
| 432 | + } |
|
| 423 | 433 | //var_dump($defkey.'-'.$qualified); |
| 424 | - } else |
|
| 425 | - $qualified = 1; |
|
| 434 | + } else { |
|
| 435 | + $qualified = 1; |
|
| 436 | + } |
|
| 426 | 437 | |
| 427 | 438 | if ($qualified) {
|
| 428 | 439 | $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and ,
|
| 429 | 440 | foreach ($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) {
|
| 430 | - if ($out) |
|
| 431 | - $out .= ', '; |
|
| 441 | + if ($out) { |
|
| 442 | + $out .= ', '; |
|
| 443 | + } |
|
| 432 | 444 | if ($paramname == 'sortfield') {
|
| 433 | 445 | $out .= dol_string_nospecial($key, '', $forbidden_chars_to_replace); |
| 434 | 446 | } |
@@ -448,14 +460,17 @@ discard block |
||
| 448 | 460 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
| 449 | 461 | $foundintru = 0; |
| 450 | 462 | foreach ($tmpqueryarraytohave as $tmpquerytohave) {
|
| 451 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
| 452 | - $foundintru = 1; |
|
| 463 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
| 464 | + $foundintru = 1; |
|
| 465 | + } |
|
| 453 | 466 | } |
| 454 | - if (!$foundintru) |
|
| 455 | - $qualified = 1; |
|
| 467 | + if (!$foundintru) { |
|
| 468 | + $qualified = 1; |
|
| 469 | + } |
|
| 456 | 470 | //var_dump($defkey.'-'.$qualified); |
| 457 | - } else |
|
| 458 | - $qualified = 1; |
|
| 471 | + } else { |
|
| 472 | + $qualified = 1; |
|
| 473 | + } |
|
| 459 | 474 | |
| 460 | 475 | if ($qualified) {
|
| 461 | 476 | if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) {
|
@@ -527,8 +542,10 @@ discard block |
||
| 527 | 542 | $newout = $user->fk_user; |
| 528 | 543 | } elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') {
|
| 529 | 544 | $newout = Globals::$conf->entity; |
| 530 | - } else |
|
| 531 | - $newout = ''; // Key not found, we replace with empty string |
|
| 545 | + } else { |
|
| 546 | + $newout = ''; |
|
| 547 | + } |
|
| 548 | + // Key not found, we replace with empty string |
|
| 532 | 549 | |
| 533 | 550 | |
| 534 | 551 | |
@@ -577,18 +594,20 @@ discard block |
||
| 577 | 594 | } |
| 578 | 595 | break; |
| 579 | 596 | case 'intcomma': |
| 580 | - if (preg_match('/[^0-9,-]+/i', $out))
|
|
| 581 | - $out = ''; |
|
| 597 | + if (preg_match('/[^0-9,-]+/i', $out)) { |
|
| 598 | + $out = ''; |
|
| 599 | + } |
|
| 582 | 600 | break; |
| 583 | 601 | case 'alpha': |
| 584 | 602 | if (!is_array($out)) {
|
| 585 | 603 | $out = trim($out); |
| 586 | 604 | // '"' is dangerous because param in url can close the href= or src= and add javascript functions. |
| 587 | 605 | // '../' is dangerous because it allows dir transversals |
| 588 | - if (preg_match('/"/', $out))
|
|
| 589 | - $out = ''; |
|
| 590 | - else if (preg_match('/\.\.\//', $out))
|
|
| 591 | - $out = ''; |
|
| 606 | + if (preg_match('/"/', $out)) { |
|
| 607 | + $out = ''; |
|
| 608 | + } else if (preg_match('/\.\.\//', $out)) { |
|
| 609 | + $out = ''; |
|
| 610 | + } |
|
| 592 | 611 | } |
| 593 | 612 | break; |
| 594 | 613 | case 'san_alpha': |
@@ -597,27 +616,31 @@ discard block |
||
| 597 | 616 | case 'aZ': |
| 598 | 617 | if (!is_array($out)) {
|
| 599 | 618 | $out = trim($out); |
| 600 | - if (preg_match('/[^a-z]+/i', $out))
|
|
| 601 | - $out = ''; |
|
| 619 | + if (preg_match('/[^a-z]+/i', $out)) { |
|
| 620 | + $out = ''; |
|
| 621 | + } |
|
| 602 | 622 | } |
| 603 | 623 | break; |
| 604 | 624 | case 'aZ09': |
| 605 | 625 | if (!is_array($out)) {
|
| 606 | 626 | $out = trim($out); |
| 607 | - if (preg_match('/[^a-z0-9_\-\.]+/i', $out))
|
|
| 608 | - $out = ''; |
|
| 627 | + if (preg_match('/[^a-z0-9_\-\.]+/i', $out)) { |
|
| 628 | + $out = ''; |
|
| 629 | + } |
|
| 609 | 630 | } |
| 610 | 631 | break; |
| 611 | 632 | case 'aZ09comma': // great to sanitize sortfield or sortorder params that can be t.abc,t.def_gh |
| 612 | 633 | if (!is_array($out)) {
|
| 613 | 634 | $out = trim($out); |
| 614 | - if (preg_match('/[^a-z0-9_\-\.,]+/i', $out))
|
|
| 615 | - $out = ''; |
|
| 635 | + if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) { |
|
| 636 | + $out = ''; |
|
| 637 | + } |
|
| 616 | 638 | } |
| 617 | 639 | break; |
| 618 | 640 | case 'array': |
| 619 | - if (!is_array($out) || empty($out)) |
|
| 620 | - $out = array(); |
|
| 641 | + if (!is_array($out) || empty($out)) { |
|
| 642 | + $out = array(); |
|
| 643 | + } |
|
| 621 | 644 | break; |
| 622 | 645 | case 'nohtml': // Recommended for most scalar parameters |
| 623 | 646 | $out = dol_string_nohtmltag($out, 0); |
@@ -627,16 +650,18 @@ discard block |
||
| 627 | 650 | $out = trim($out); |
| 628 | 651 | // '"' is dangerous because param in url can close the href= or src= and add javascript functions. |
| 629 | 652 | // '../' is dangerous because it allows dir transversals |
| 630 | - if (preg_match('/"/', $out))
|
|
| 631 | - $out = ''; |
|
| 632 | - else if (preg_match('/\.\.\//', $out))
|
|
| 633 | - $out = ''; |
|
| 653 | + if (preg_match('/"/', $out)) { |
|
| 654 | + $out = ''; |
|
| 655 | + } else if (preg_match('/\.\.\//', $out)) { |
|
| 656 | + $out = ''; |
|
| 657 | + } |
|
| 634 | 658 | $out = dol_string_nohtmltag($out); |
| 635 | 659 | } |
| 636 | 660 | break; |
| 637 | 661 | case 'custom': |
| 638 | - if (empty($filter)) |
|
| 639 | - return 'BadFourthParameterForDolUtils::GETPOST'; |
|
| 662 | + if (empty($filter)) { |
|
| 663 | + return 'BadFourthParameterForDolUtils::GETPOST'; |
|
| 664 | + } |
|
| 640 | 665 | $out = filter_var($out, $filter, $options); |
| 641 | 666 | break; |
| 642 | 667 | } |
@@ -754,11 +779,11 @@ discard block |
||
| 754 | 779 | } |
| 755 | 780 | } |
| 756 | 781 | if ($returnemptyifnotfound) { // Not found into alternate dir
|
| 757 | - if ($returnemptyifnotfound == 1 || !file_exists($res)) |
|
| 758 | - return ''; |
|
| 782 | + if ($returnemptyifnotfound == 1 || !file_exists($res)) { |
|
| 783 | + return ''; |
|
| 784 | + } |
|
| 759 | 785 | } |
| 760 | - } |
|
| 761 | - else { // For an url path
|
|
| 786 | + } else { // For an url path
|
|
| 762 | 787 | // We try to get local path of file on filesystem from url |
| 763 | 788 | // Note that trying to know if a file on disk exist by forging path on disk from url |
| 764 | 789 | // works only for some web server and some setup. This is bugged when |
@@ -853,12 +878,14 @@ discard block |
||
| 853 | 878 | static function dol_size($size, $type = '') |
| 854 | 879 | {
|
| 855 | 880 | //global Globals::$conf; |
| 856 | - if (empty(Globals::$conf->dol_optimize_smallscreen)) |
|
| 857 | - return $size; |
|
| 858 | - if ($type == 'width' && $size > 250) |
|
| 859 | - return 250; |
|
| 860 | - else |
|
| 861 | - return 10; |
|
| 881 | + if (empty(Globals::$conf->dol_optimize_smallscreen)) { |
|
| 882 | + return $size; |
|
| 883 | + } |
|
| 884 | + if ($type == 'width' && $size > 250) { |
|
| 885 | + return 250; |
|
| 886 | + } else { |
|
| 887 | + return 10; |
|
| 888 | + } |
|
| 862 | 889 | } |
| 863 | 890 | |
| 864 | 891 | /** |
@@ -958,9 +985,10 @@ discard block |
||
| 958 | 985 | {
|
| 959 | 986 | $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°'); // more complete than dol_sanitizeFileName
|
| 960 | 987 | $forbidden_chars_to_remove = array(); |
| 961 | - if (is_array($badcharstoreplace)) |
|
| 962 | - $forbidden_chars_to_replace = $badcharstoreplace; |
|
| 963 | -//$forbidden_chars_to_remove=array("(",")");
|
|
| 988 | + if (is_array($badcharstoreplace)) { |
|
| 989 | + $forbidden_chars_to_replace = $badcharstoreplace; |
|
| 990 | + } |
|
| 991 | + //$forbidden_chars_to_remove=array("(",")");
|
|
| 964 | 992 | |
| 965 | 993 | return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove, "", $str)); |
| 966 | 994 | } |
@@ -996,9 +1024,9 @@ discard block |
||
| 996 | 1024 | if (empty($mode)) {
|
| 997 | 1025 | $substitjs["'"] = "\\'"; |
| 998 | 1026 | $substitjs['"'] = "\\'"; |
| 999 | - } else if ($mode == 1) |
|
| 1000 | - $substitjs["'"] = "\\'"; |
|
| 1001 | - else if ($mode == 2) {
|
|
| 1027 | + } else if ($mode == 1) { |
|
| 1028 | + $substitjs["'"] = "\\'"; |
|
| 1029 | + } else if ($mode == 2) {
|
|
| 1002 | 1030 | $substitjs['"'] = '\\"'; |
| 1003 | 1031 | } else if ($mode == 3) {
|
| 1004 | 1032 | $substitjs["'"] = "\\'"; |
@@ -1020,10 +1048,12 @@ discard block |
||
| 1020 | 1048 | {
|
| 1021 | 1049 | // escape quotes and backslashes, newlines, etc. |
| 1022 | 1050 | $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars_decode instead, that make only required change for html tags |
| 1023 | - if (!$keepb) |
|
| 1024 | - $tmp = strtr($tmp, array("<b>" => '', '</b>' => ''));
|
|
| 1025 | - if (!$keepn) |
|
| 1026 | - $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n'));
|
|
| 1051 | + if (!$keepb) { |
|
| 1052 | + $tmp = strtr($tmp, array("<b>" => '', '</b>' => '')); |
|
| 1053 | + } |
|
| 1054 | + if (!$keepn) { |
|
| 1055 | + $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n')); |
|
| 1056 | + } |
|
| 1027 | 1057 | return htmlentities($tmp, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars instead, that make only required change for html tags |
| 1028 | 1058 | } |
| 1029 | 1059 | |
@@ -1073,8 +1103,9 @@ discard block |
||
| 1073 | 1103 | {
|
| 1074 | 1104 | // global Globals::$conf, $user; |
| 1075 | 1105 | // If syslog module enabled |
| 1076 | - if (empty(Globals::$conf->syslog->enabled)) |
|
| 1077 | - return; |
|
| 1106 | + if (empty(Globals::$conf->syslog->enabled)) { |
|
| 1107 | + return; |
|
| 1108 | + } |
|
| 1078 | 1109 | |
| 1079 | 1110 | if ($ident < 0) {
|
| 1080 | 1111 | foreach (Globals::$conf->loghandlers as $loghandlerinstance) {
|
@@ -1088,8 +1119,9 @@ discard block |
||
| 1088 | 1119 | if (!in_array($level, $logLevels, true)) {
|
| 1089 | 1120 | throw new Exception('Incorrect log level');
|
| 1090 | 1121 | } |
| 1091 | - if ($level > Globals::$conf->global->SYSLOG_LEVEL) |
|
| 1092 | - return; |
|
| 1122 | + if ($level > Globals::$conf->global->SYSLOG_LEVEL) { |
|
| 1123 | + return; |
|
| 1124 | + } |
|
| 1093 | 1125 | |
| 1094 | 1126 | $message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log
|
| 1095 | 1127 | // If adding log inside HTML page is required |
@@ -1114,24 +1146,30 @@ discard block |
||
| 1114 | 1146 | ); |
| 1115 | 1147 | |
| 1116 | 1148 | // This is when server run behind a reverse proxy |
| 1117 | - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) |
|
| 1118 | - $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']); |
|
| 1119 | -// This is when server run normally on a server |
|
| 1120 | - else if (!empty($_SERVER["REMOTE_ADDR"])) |
|
| 1121 | - $data['ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 1122 | -// This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) |
|
| 1123 | - else if (!empty($_SERVER['SERVER_ADDR'])) |
|
| 1124 | - $data['ip'] = $_SERVER['SERVER_ADDR']; |
|
| 1125 | -// This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it). |
|
| 1126 | - else if (!empty($_SERVER['COMPUTERNAME'])) |
|
| 1127 | - $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']); |
|
| 1128 | -// This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it). |
|
| 1129 | - else if (!empty($_SERVER['LOGNAME'])) |
|
| 1130 | - $data['ip'] = '???@' . $_SERVER['LOGNAME']; |
|
| 1131 | -// Loop on each log handler and send output |
|
| 1149 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 1150 | + $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']); |
|
| 1151 | + } |
|
| 1152 | + // This is when server run normally on a server |
|
| 1153 | + else if (!empty($_SERVER["REMOTE_ADDR"])) { |
|
| 1154 | + $data['ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 1155 | + } |
|
| 1156 | + // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) |
|
| 1157 | + else if (!empty($_SERVER['SERVER_ADDR'])) { |
|
| 1158 | + $data['ip'] = $_SERVER['SERVER_ADDR']; |
|
| 1159 | + } |
|
| 1160 | + // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it). |
|
| 1161 | + else if (!empty($_SERVER['COMPUTERNAME'])) { |
|
| 1162 | + $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']); |
|
| 1163 | + } |
|
| 1164 | + // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it). |
|
| 1165 | + else if (!empty($_SERVER['LOGNAME'])) { |
|
| 1166 | + $data['ip'] = '???@' . $_SERVER['LOGNAME']; |
|
| 1167 | + } |
|
| 1168 | + // Loop on each log handler and send output |
|
| 1132 | 1169 | foreach (Globals::$conf->loghandlers as $loghandlerinstance) {
|
| 1133 | - if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) |
|
| 1134 | - continue; |
|
| 1170 | + if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) { |
|
| 1171 | + continue; |
|
| 1172 | + } |
|
| 1135 | 1173 | $loghandlerinstance->export($data, $suffixinfilename); |
| 1136 | 1174 | } |
| 1137 | 1175 | unset($data); |
@@ -1187,13 +1225,15 @@ discard block |
||
| 1187 | 1225 | |
| 1188 | 1226 | // Show title |
| 1189 | 1227 | $showtitle = 1; |
| 1190 | - if (!empty(Globals::$conf->dol_optimize_smallscreen)) |
|
| 1191 | - $showtitle = 0; |
|
| 1228 | + if (!empty(Globals::$conf->dol_optimize_smallscreen)) { |
|
| 1229 | + $showtitle = 0; |
|
| 1230 | + } |
|
| 1192 | 1231 | if (!empty($title) && $showtitle) {
|
| 1193 | 1232 | $limittitle = 30; |
| 1194 | 1233 | $out .= '<a class="tabTitle">'; |
| 1195 | - if ($picto) |
|
| 1196 | - $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' '; |
|
| 1234 | + if ($picto) { |
|
| 1235 | + $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' '; |
|
| 1236 | + } |
|
| 1197 | 1237 | $out .= '<span class="tabTitleText">' . dol_trunc($title, $limittitle) . '</span>'; |
| 1198 | 1238 | $out .= '</a>'; |
| 1199 | 1239 | } |
@@ -1202,12 +1242,14 @@ discard block |
||
| 1202 | 1242 | $maxkey = -1; |
| 1203 | 1243 | if (is_array($links) && !empty($links)) {
|
| 1204 | 1244 | $keys = array_keys($links); |
| 1205 | - if (count($keys)) |
|
| 1206 | - $maxkey = max($keys); |
|
| 1245 | + if (count($keys)) { |
|
| 1246 | + $maxkey = max($keys); |
|
| 1247 | + } |
|
| 1207 | 1248 | } |
| 1208 | 1249 | |
| 1209 | - if (!empty(Globals::$conf->dol_optimize_smallscreen)) |
|
| 1210 | - Globals::$conf->global->MAIN_MAXTABS_IN_CARD = 2; |
|
| 1250 | + if (!empty(Globals::$conf->dol_optimize_smallscreen)) { |
|
| 1251 | + Globals::$conf->global->MAIN_MAXTABS_IN_CARD = 2; |
|
| 1252 | + } |
|
| 1211 | 1253 | |
| 1212 | 1254 | // Show tabs |
| 1213 | 1255 | $bactive = false; |
@@ -1220,8 +1262,9 @@ discard block |
||
| 1220 | 1262 | for ($i = 0; $i <= $maxkey; $i++) {
|
| 1221 | 1263 | if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
|
| 1222 | 1264 | // If active tab is already present |
| 1223 | - if ($i >= $limittoshow) |
|
| 1224 | - $limittoshow--; |
|
| 1265 | + if ($i >= $limittoshow) { |
|
| 1266 | + $limittoshow--; |
|
| 1267 | + } |
|
| 1225 | 1268 | } |
| 1226 | 1269 | } |
| 1227 | 1270 | |
@@ -1262,12 +1305,12 @@ discard block |
||
| 1262 | 1305 | } |
| 1263 | 1306 | $outmore .= '<div class="popuptab wordwrap" style="display:inherit;">'; |
| 1264 | 1307 | if (isset($links[$i][2]) && $links[$i][2] == 'image') {
|
| 1265 | - if (!empty($links[$i][0])) |
|
| 1266 | - $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n"; |
|
| 1267 | - else |
|
| 1268 | - $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n"; |
|
| 1269 | - } |
|
| 1270 | - else if (!empty($links[$i][1])) {
|
|
| 1308 | + if (!empty($links[$i][0])) { |
|
| 1309 | + $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n"; |
|
| 1310 | + } else { |
|
| 1311 | + $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n"; |
|
| 1312 | + } |
|
| 1313 | + } else if (!empty($links[$i][1])) {
|
|
| 1271 | 1314 | $outmore .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="wordwrap inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">'; |
| 1272 | 1315 | $outmore .= preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts.
|
| 1273 | 1316 | $outmore .= '</a>' . "\n"; |
@@ -1278,8 +1321,9 @@ discard block |
||
| 1278 | 1321 | } |
| 1279 | 1322 | $displaytab = $i; |
| 1280 | 1323 | } |
| 1281 | - if ($popuptab) |
|
| 1282 | - $outmore .= '</div>'; |
|
| 1324 | + if ($popuptab) { |
|
| 1325 | + $outmore .= '</div>'; |
|
| 1326 | + } |
|
| 1283 | 1327 | |
| 1284 | 1328 | if ($displaytab > $limittoshow) {
|
| 1285 | 1329 | $left = (Globals::$langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
|
@@ -1302,8 +1346,9 @@ discard block |
||
| 1302 | 1346 | |
| 1303 | 1347 | $out .= "</div>\n"; |
| 1304 | 1348 | |
| 1305 | - if (!$notab || $notab == -1) |
|
| 1306 | - $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n"; |
|
| 1349 | + if (!$notab || $notab == -1) { |
|
| 1350 | + $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n"; |
|
| 1351 | + } |
|
| 1307 | 1352 | |
| 1308 | 1353 | $parameters = array('tabname' => $active, 'out' => $out);
|
| 1309 | 1354 | $reshook = $hookmanager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead"
|
@@ -1333,10 +1378,11 @@ discard block |
||
| 1333 | 1378 | */ |
| 1334 | 1379 | static function dol_get_fiche_end($notab = 0) |
| 1335 | 1380 | {
|
| 1336 | - if (!$notab || $notab == -1) |
|
| 1337 | - return "\n</div>\n"; |
|
| 1338 | - else |
|
| 1339 | - return ''; |
|
| 1381 | + if (!$notab || $notab == -1) { |
|
| 1382 | + return "\n</div>\n"; |
|
| 1383 | + } else { |
|
| 1384 | + return ''; |
|
| 1385 | + } |
|
| 1340 | 1386 | } |
| 1341 | 1387 | |
| 1342 | 1388 | /** |
@@ -1368,40 +1414,55 @@ discard block |
||
| 1368 | 1414 | $showimage = 1; |
| 1369 | 1415 | $entity = (empty($object->entity) ? Globals::$conf->entity : $object->entity); |
| 1370 | 1416 | $showbarcode = empty(Globals::$conf->barcode->enabled) ? 0 : ($object->barcode ? 1 : 0); |
| 1371 | - if (!empty(Globals::$conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) |
|
| 1372 | - $showbarcode = 0; |
|
| 1417 | + if (!empty(Globals::$conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { |
|
| 1418 | + $showbarcode = 0; |
|
| 1419 | + } |
|
| 1373 | 1420 | $modulepart = 'unknown'; |
| 1374 | 1421 | |
| 1375 | - if ($object->element == 'societe') |
|
| 1376 | - $modulepart = 'societe'; |
|
| 1377 | - if ($object->element == 'contact') |
|
| 1378 | - $modulepart = 'contact'; |
|
| 1379 | - if ($object->element == 'member') |
|
| 1380 | - $modulepart = 'memberphoto'; |
|
| 1381 | - if ($object->element == 'user') |
|
| 1382 | - $modulepart = 'userphoto'; |
|
| 1383 | - if ($object->element == 'product') |
|
| 1384 | - $modulepart = 'product'; |
|
| 1422 | + if ($object->element == 'societe') { |
|
| 1423 | + $modulepart = 'societe'; |
|
| 1424 | + } |
|
| 1425 | + if ($object->element == 'contact') { |
|
| 1426 | + $modulepart = 'contact'; |
|
| 1427 | + } |
|
| 1428 | + if ($object->element == 'member') { |
|
| 1429 | + $modulepart = 'memberphoto'; |
|
| 1430 | + } |
|
| 1431 | + if ($object->element == 'user') { |
|
| 1432 | + $modulepart = 'userphoto'; |
|
| 1433 | + } |
|
| 1434 | + if ($object->element == 'product') { |
|
| 1435 | + $modulepart = 'product'; |
|
| 1436 | + } |
|
| 1385 | 1437 | |
| 1386 | 1438 | if (class_exists("Imagick")) {
|
| 1387 | - if ($object->element == 'propal') |
|
| 1388 | - $modulepart = 'propal'; |
|
| 1389 | - if ($object->element == 'commande') |
|
| 1390 | - $modulepart = 'commande'; |
|
| 1391 | - if ($object->element == 'facture') |
|
| 1392 | - $modulepart = 'facture'; |
|
| 1393 | - if ($object->element == 'fichinter') |
|
| 1394 | - $modulepart = 'ficheinter'; |
|
| 1395 | - if ($object->element == 'contrat') |
|
| 1396 | - $modulepart = 'contract'; |
|
| 1397 | - if ($object->element == 'supplier_proposal') |
|
| 1398 | - $modulepart = 'supplier_proposal'; |
|
| 1399 | - if ($object->element == 'order_supplier') |
|
| 1400 | - $modulepart = 'supplier_order'; |
|
| 1401 | - if ($object->element == 'invoice_supplier') |
|
| 1402 | - $modulepart = 'supplier_invoice'; |
|
| 1403 | - if ($object->element == 'expensereport') |
|
| 1404 | - $modulepart = 'expensereport'; |
|
| 1439 | + if ($object->element == 'propal') { |
|
| 1440 | + $modulepart = 'propal'; |
|
| 1441 | + } |
|
| 1442 | + if ($object->element == 'commande') { |
|
| 1443 | + $modulepart = 'commande'; |
|
| 1444 | + } |
|
| 1445 | + if ($object->element == 'facture') { |
|
| 1446 | + $modulepart = 'facture'; |
|
| 1447 | + } |
|
| 1448 | + if ($object->element == 'fichinter') { |
|
| 1449 | + $modulepart = 'ficheinter'; |
|
| 1450 | + } |
|
| 1451 | + if ($object->element == 'contrat') { |
|
| 1452 | + $modulepart = 'contract'; |
|
| 1453 | + } |
|
| 1454 | + if ($object->element == 'supplier_proposal') { |
|
| 1455 | + $modulepart = 'supplier_proposal'; |
|
| 1456 | + } |
|
| 1457 | + if ($object->element == 'order_supplier') { |
|
| 1458 | + $modulepart = 'supplier_order'; |
|
| 1459 | + } |
|
| 1460 | + if ($object->element == 'invoice_supplier') { |
|
| 1461 | + $modulepart = 'supplier_invoice'; |
|
| 1462 | + } |
|
| 1463 | + if ($object->element == 'expensereport') { |
|
| 1464 | + $modulepart = 'expensereport'; |
|
| 1465 | + } |
|
| 1405 | 1466 | } |
| 1406 | 1467 | |
| 1407 | 1468 | if ($object->element == 'product') {
|
@@ -1409,11 +1470,12 @@ discard block |
||
| 1409 | 1470 | $cssclass = 'photoref'; |
| 1410 | 1471 | $showimage = $object->is_photo_available(Globals::$conf->product->multidir_output[$entity]); |
| 1411 | 1472 | $maxvisiblephotos = (isset(Globals::$conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? Globals::$conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5); |
| 1412 | - if (Globals::$conf->browser->layout == 'phone') |
|
| 1413 | - $maxvisiblephotos = 1; |
|
| 1414 | - if ($showimage) |
|
| 1415 | - $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('product', Globals::$conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
|
|
| 1416 | - else {
|
|
| 1473 | + if (Globals::$conf->browser->layout == 'phone') { |
|
| 1474 | + $maxvisiblephotos = 1; |
|
| 1475 | + } |
|
| 1476 | + if ($showimage) { |
|
| 1477 | + $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('product', Globals::$conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>'; |
|
| 1478 | + } else {
|
|
| 1417 | 1479 | if (!empty(Globals::$conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
|
| 1418 | 1480 | $nophoto = ''; |
| 1419 | 1481 | $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"></div>'; |
@@ -1429,11 +1491,12 @@ discard block |
||
| 1429 | 1491 | $cssclass = 'photoref'; |
| 1430 | 1492 | $showimage = $object->is_photo_available(Globals::$conf->ticket->multidir_output[$entity] . '/' . $object->track_id); |
| 1431 | 1493 | $maxvisiblephotos = (isset(Globals::$conf->global->TICKETSUP_MAX_VISIBLE_PHOTO) ? Globals::$conf->global->TICKETSUP_MAX_VISIBLE_PHOTO : 2); |
| 1432 | - if (Globals::$conf->browser->layout == 'phone') |
|
| 1433 | - $maxvisiblephotos = 1; |
|
| 1434 | - if ($showimage) |
|
| 1435 | - $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('ticket', Globals::$conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
|
|
| 1436 | - else {
|
|
| 1494 | + if (Globals::$conf->browser->layout == 'phone') { |
|
| 1495 | + $maxvisiblephotos = 1; |
|
| 1496 | + } |
|
| 1497 | + if ($showimage) { |
|
| 1498 | + $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('ticket', Globals::$conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>'; |
|
| 1499 | + } else {
|
|
| 1437 | 1500 | if (!empty(Globals::$conf->global->TICKETSUP_NODISPLAYIFNOPHOTO)) {
|
| 1438 | 1501 | $nophoto = ''; |
| 1439 | 1502 | $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"></div>'; |
@@ -1458,8 +1521,10 @@ discard block |
||
| 1458 | 1521 | } else {
|
| 1459 | 1522 | $subdir = get_exdir($object->id, 0, 0, 1, $object, $modulepart); |
| 1460 | 1523 | } |
| 1461 | - if (empty($subdir)) |
|
| 1462 | - $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path |
|
| 1524 | + if (empty($subdir)) { |
|
| 1525 | + $subdir = 'errorgettingsubdirofobject'; |
|
| 1526 | + } |
|
| 1527 | + // Protection to avoid to return empty path |
|
| 1463 | 1528 | |
| 1464 | 1529 | $filepath = $dir_output . $subdir . "/"; |
| 1465 | 1530 | |
@@ -1480,14 +1545,16 @@ discard block |
||
| 1480 | 1545 | if (empty(Globals::$conf->global->MAIN_DISABLE_PDF_THUMBS)) { // If you experienc trouble with pdf thumb generation and imagick, you can disable here.
|
| 1481 | 1546 | include_once DOL_BASE_PATH . '/core/lib/files.lib.php'; |
| 1482 | 1547 | $ret = dol_convert_file($file, 'png', $fileimage); |
| 1483 | - if ($ret < 0) |
|
| 1484 | - $error++; |
|
| 1548 | + if ($ret < 0) { |
|
| 1549 | + $error++; |
|
| 1550 | + } |
|
| 1485 | 1551 | } |
| 1486 | 1552 | } |
| 1487 | 1553 | |
| 1488 | 1554 | $heightforphotref = 70; |
| 1489 | - if (!empty(Globals::$conf->dol_optimize_smallscreen)) |
|
| 1490 | - $heightforphotref = 60; |
|
| 1555 | + if (!empty(Globals::$conf->dol_optimize_smallscreen)) { |
|
| 1556 | + $heightforphotref = 60; |
|
| 1557 | + } |
|
| 1491 | 1558 | // Si fichier png PDF d'1 page trouve |
| 1492 | 1559 | if (file_exists($fileimage)) {
|
| 1493 | 1560 | $phototoshow = '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">'; |
@@ -1523,8 +1590,10 @@ discard block |
||
| 1523 | 1590 | $width = 14; |
| 1524 | 1591 | $cssclass = 'photorefcenter'; |
| 1525 | 1592 | $picto = $object->picto; |
| 1526 | - if ($object->element == 'project' && !$object->public) |
|
| 1527 | - $picto = 'project'; // instead of projectpub |
|
| 1593 | + if ($object->element == 'project' && !$object->public) { |
|
| 1594 | + $picto = 'project'; |
|
| 1595 | + } |
|
| 1596 | + // instead of projectpub |
|
| 1528 | 1597 | $nophoto = img_picto('', 'object_' . $picto, '', false, 1);
|
| 1529 | 1598 | } |
| 1530 | 1599 | $morehtmlleft .= '<!-- No photo to show -->'; |
@@ -1535,8 +1604,9 @@ discard block |
||
| 1535 | 1604 | } |
| 1536 | 1605 | } |
| 1537 | 1606 | |
| 1538 | - if ($showbarcode) |
|
| 1539 | - $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>'; |
|
| 1607 | + if ($showbarcode) { |
|
| 1608 | + $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>'; |
|
| 1609 | + } |
|
| 1540 | 1610 | |
| 1541 | 1611 | if ($object->element == 'societe') {
|
| 1542 | 1612 | if (!empty(Globals::$conf->use_javascript_ajax) && $user->rights->societe->creer && !empty(Globals::$conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
|
@@ -1560,35 +1630,37 @@ discard block |
||
| 1560 | 1630 | } |
| 1561 | 1631 | } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) {
|
| 1562 | 1632 | $tmptxt = $object->getLibStatut(6, $object->totalpaye); |
| 1563 | - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone') |
|
| 1564 | - $tmptxt = $object->getLibStatut(5, $object->totalpaye); |
|
| 1633 | + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone') { |
|
| 1634 | + $tmptxt = $object->getLibStatut(5, $object->totalpaye); |
|
| 1635 | + } |
|
| 1565 | 1636 | $morehtmlstatus .= $tmptxt; |
| 1566 | - } |
|
| 1567 | - elseif ($object->element == 'contrat' || $object->element == 'contract') {
|
|
| 1568 | - if ($object->statut == 0) |
|
| 1569 | - $morehtmlstatus .= $object->getLibStatut(5); |
|
| 1570 | - else |
|
| 1571 | - $morehtmlstatus .= $object->getLibStatut(4); |
|
| 1572 | - } |
|
| 1573 | - elseif ($object->element == 'facturerec') {
|
|
| 1574 | - if ($object->frequency == 0) |
|
| 1575 | - $morehtmlstatus .= $object->getLibStatut(2); |
|
| 1576 | - else |
|
| 1577 | - $morehtmlstatus .= $object->getLibStatut(5); |
|
| 1578 | - } |
|
| 1579 | - elseif ($object->element == 'project_task') {
|
|
| 1637 | + } elseif ($object->element == 'contrat' || $object->element == 'contract') {
|
|
| 1638 | + if ($object->statut == 0) { |
|
| 1639 | + $morehtmlstatus .= $object->getLibStatut(5); |
|
| 1640 | + } else { |
|
| 1641 | + $morehtmlstatus .= $object->getLibStatut(4); |
|
| 1642 | + } |
|
| 1643 | + } elseif ($object->element == 'facturerec') {
|
|
| 1644 | + if ($object->frequency == 0) { |
|
| 1645 | + $morehtmlstatus .= $object->getLibStatut(2); |
|
| 1646 | + } else { |
|
| 1647 | + $morehtmlstatus .= $object->getLibStatut(5); |
|
| 1648 | + } |
|
| 1649 | + } elseif ($object->element == 'project_task') {
|
|
| 1580 | 1650 | $object->fk_statut = 1; |
| 1581 | - if ($object->progress > 0) |
|
| 1582 | - $object->fk_statut = 2; |
|
| 1583 | - if ($object->progress >= 100) |
|
| 1584 | - $object->fk_statut = 3; |
|
| 1651 | + if ($object->progress > 0) { |
|
| 1652 | + $object->fk_statut = 2; |
|
| 1653 | + } |
|
| 1654 | + if ($object->progress >= 100) { |
|
| 1655 | + $object->fk_statut = 3; |
|
| 1656 | + } |
|
| 1585 | 1657 | $tmptxt = $object->getLibStatut(5); |
| 1586 | 1658 | $morehtmlstatus .= $tmptxt; // No status on task |
| 1587 | - } |
|
| 1588 | - else { // Generic case
|
|
| 1659 | + } else { // Generic case
|
|
| 1589 | 1660 | $tmptxt = $object->getLibStatut(6); |
| 1590 | - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone') |
|
| 1591 | - $tmptxt = $object->getLibStatut(5); |
|
| 1661 | + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone') { |
|
| 1662 | + $tmptxt = $object->getLibStatut(5); |
|
| 1663 | + } |
|
| 1592 | 1664 | $morehtmlstatus .= $tmptxt; |
| 1593 | 1665 | } |
| 1594 | 1666 | |
@@ -1602,13 +1674,15 @@ discard block |
||
| 1602 | 1674 | } |
| 1603 | 1675 | |
| 1604 | 1676 | // Add alias for thirdparty |
| 1605 | - if (!empty($object->name_alias)) |
|
| 1606 | - $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>'; |
|
| 1677 | + if (!empty($object->name_alias)) { |
|
| 1678 | + $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>'; |
|
| 1679 | + } |
|
| 1607 | 1680 | |
| 1608 | 1681 | // Add label |
| 1609 | 1682 | if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task') {
|
| 1610 | - if (!empty($object->label)) |
|
| 1611 | - $morehtmlref .= '<div class="refidno">' . $object->label . '</div>'; |
|
| 1683 | + if (!empty($object->label)) { |
|
| 1684 | + $morehtmlref .= '<div class="refidno">' . $object->label . '</div>'; |
|
| 1685 | + } |
|
| 1612 | 1686 | } |
| 1613 | 1687 | |
| 1614 | 1688 | if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') {
|
@@ -1641,15 +1715,19 @@ discard block |
||
| 1641 | 1715 | {
|
| 1642 | 1716 | // global Globals::$conf, Globals::$langs; |
| 1643 | 1717 | $ret = ''; |
| 1644 | - if ($fieldrequired) |
|
| 1645 | - $ret .= '<span class="fieldrequired">'; |
|
| 1646 | - if ((Globals::$conf->dol_use_jmobile != 4)) |
|
| 1647 | - $ret .= '<label for="' . $fieldkey . '">'; |
|
| 1718 | + if ($fieldrequired) { |
|
| 1719 | + $ret .= '<span class="fieldrequired">'; |
|
| 1720 | + } |
|
| 1721 | + if ((Globals::$conf->dol_use_jmobile != 4)) { |
|
| 1722 | + $ret .= '<label for="' . $fieldkey . '">'; |
|
| 1723 | + } |
|
| 1648 | 1724 | $ret .= Globals::$langs->trans($langkey); |
| 1649 | - if ((Globals::$conf->dol_use_jmobile != 4)) |
|
| 1650 | - $ret .= '</label>'; |
|
| 1651 | - if ($fieldrequired) |
|
| 1652 | - $ret .= '</span>'; |
|
| 1725 | + if ((Globals::$conf->dol_use_jmobile != 4)) { |
|
| 1726 | + $ret .= '</label>'; |
|
| 1727 | + } |
|
| 1728 | + if ($fieldrequired) { |
|
| 1729 | + $ret .= '</span>'; |
|
| 1730 | + } |
|
| 1653 | 1731 | return $ret; |
| 1654 | 1732 | } |
| 1655 | 1733 | |
@@ -1664,8 +1742,9 @@ discard block |
||
| 1664 | 1742 | {
|
| 1665 | 1743 | // global $bc; |
| 1666 | 1744 | $ret = ' ' . $bc[$var]; |
| 1667 | - if ($moreclass) |
|
| 1668 | - $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret);
|
|
| 1745 | + if ($moreclass) { |
|
| 1746 | + $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret); |
|
| 1747 | + } |
|
| 1669 | 1748 | return $ret; |
| 1670 | 1749 | } |
| 1671 | 1750 | |
@@ -1696,18 +1775,18 @@ discard block |
||
| 1696 | 1775 | if ($object->state) {
|
| 1697 | 1776 | $ret .= ($ret ? ", " : '') . $object->state; |
| 1698 | 1777 | } |
| 1699 | - if ($object->zip) |
|
| 1700 | - $ret .= ($ret ? ", " : '') . $object->zip; |
|
| 1701 | - } |
|
| 1702 | - else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country
|
|
| 1778 | + if ($object->zip) { |
|
| 1779 | + $ret .= ($ret ? ", " : '') . $object->zip; |
|
| 1780 | + } |
|
| 1781 | + } else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country
|
|
| 1703 | 1782 | $ret .= ($ret ? $sep : '' ) . $object->town; |
| 1704 | 1783 | if ($object->state) {
|
| 1705 | 1784 | $ret .= ($ret ? ", " : '') . $object->state; |
| 1706 | 1785 | } |
| 1707 | - if ($object->zip) |
|
| 1708 | - $ret .= ($ret ? $sep : '' ) . $object->zip; |
|
| 1709 | - } |
|
| 1710 | - else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country
|
|
| 1786 | + if ($object->zip) { |
|
| 1787 | + $ret .= ($ret ? $sep : '' ) . $object->zip; |
|
| 1788 | + } |
|
| 1789 | + } else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country
|
|
| 1711 | 1790 | $ret .= ($ret ? $sep : '' ) . $object->zip; |
| 1712 | 1791 | $ret .= ($object->town ? (($object->zip ? ' ' : '') . $object->town) : ''); |
| 1713 | 1792 | if ($object->state) {
|
@@ -1724,8 +1803,9 @@ discard block |
||
| 1724 | 1803 | $ret .= ($ret ? ", " : '') . $object->state; |
| 1725 | 1804 | } |
| 1726 | 1805 | } |
| 1727 | - if (!is_object($outputlangs)) |
|
| 1728 | - $outputlangs = Globals::$langs; |
|
| 1806 | + if (!is_object($outputlangs)) { |
|
| 1807 | + $outputlangs = Globals::$langs; |
|
| 1808 | + } |
|
| 1729 | 1809 | if ($withcountry) {
|
| 1730 | 1810 | Globals::$langs->load("dict");
|
| 1731 | 1811 | $ret .= ($object->country_code ? ($ret ? $sep : '') . $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country" . $object->country_code)) : '');
|
@@ -1746,8 +1826,9 @@ discard block |
||
| 1746 | 1826 | {
|
| 1747 | 1827 | if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
|
| 1748 | 1828 | return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts); |
| 1749 | - } else |
|
| 1750 | - return 'Error date into a not supported range'; |
|
| 1829 | + } else { |
|
| 1830 | + return 'Error date into a not supported range'; |
|
| 1831 | + } |
|
| 1751 | 1832 | } |
| 1752 | 1833 | |
| 1753 | 1834 | /** |
@@ -1793,10 +1874,12 @@ discard block |
||
| 1793 | 1874 | } |
| 1794 | 1875 | } |
| 1795 | 1876 | } |
| 1796 | - if (!is_object($outputlangs)) |
|
| 1797 | - $outputlangs = Globals::$langs; |
|
| 1798 | - if (!$format) |
|
| 1799 | - $format = 'daytextshort'; |
|
| 1877 | + if (!is_object($outputlangs)) { |
|
| 1878 | + $outputlangs = Globals::$langs; |
|
| 1879 | + } |
|
| 1880 | + if (!$format) { |
|
| 1881 | + $format = 'daytextshort'; |
|
| 1882 | + } |
|
| 1800 | 1883 | $reduceformat = (!empty(Globals::$conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0;
|
| 1801 | 1884 | $formatwithoutreduce = preg_replace('/reduceformat/', '', $format);
|
| 1802 | 1885 | if ($formatwithoutreduce != $format) {
|
@@ -1805,40 +1888,46 @@ discard block |
||
| 1805 | 1888 | } // so format 'dayreduceformat' is processed like day |
| 1806 | 1889 | // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. |
| 1807 | 1890 | // TODO Add format daysmallyear and dayhoursmallyear |
| 1808 | - if ($format == 'day') |
|
| 1809 | - $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : Globals::$conf->format_date_short);
|
|
| 1810 | - else if ($format == 'hour') |
|
| 1811 | - $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : Globals::$conf->format_hour_short);
|
|
| 1812 | - else if ($format == 'hourduration') |
|
| 1813 | - $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : Globals::$conf->format_hour_short_duration);
|
|
| 1814 | - else if ($format == 'daytext') |
|
| 1815 | - $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : Globals::$conf->format_date_text);
|
|
| 1816 | - else if ($format == 'daytextshort') |
|
| 1817 | -// Notice: Undefined property: stdClass::$format_date_text_short in \alixar\dolibarr\htdocs\core\lib\functions.lib.php on line 1781 |
|
| 1818 | - $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : Globals::$conf->format_date_text_short);
|
|
| 1819 | - else if ($format == 'dayhour') |
|
| 1820 | - $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : Globals::$conf->format_date_hour_short);
|
|
| 1821 | - else if ($format == 'dayhoursec') |
|
| 1822 | - $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : Globals::$conf->format_date_hour_sec_short);
|
|
| 1823 | - else if ($format == 'dayhourtext') |
|
| 1824 | - $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : Globals::$conf->format_date_hour_text);
|
|
| 1825 | - else if ($format == 'dayhourtextshort') |
|
| 1826 | - $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : Globals::$conf->format_date_hour_text_short);
|
|
| 1827 | -// Format not sensitive to language |
|
| 1828 | - else if ($format == 'dayhourlog') |
|
| 1829 | - $format = '%Y%m%d%H%M%S'; |
|
| 1830 | - else if ($format == 'dayhourldap') |
|
| 1831 | - $format = '%Y%m%d%H%M%SZ'; |
|
| 1832 | - else if ($format == 'dayhourxcard') |
|
| 1833 | - $format = '%Y%m%dT%H%M%SZ'; |
|
| 1834 | - else if ($format == 'dayxcard') |
|
| 1835 | - $format = '%Y%m%d'; |
|
| 1836 | - else if ($format == 'dayrfc') |
|
| 1837 | - $format = '%Y-%m-%d'; // DATE_RFC3339 |
|
| 1838 | - else if ($format == 'dayhourrfc') |
|
| 1839 | - $format = '%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 |
|
| 1840 | - else if ($format == 'standard') |
|
| 1841 | - $format = '%Y-%m-%d %H:%M:%S'; |
|
| 1891 | + if ($format == 'day') { |
|
| 1892 | + $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : Globals::$conf->format_date_short); |
|
| 1893 | + } else if ($format == 'hour') { |
|
| 1894 | + $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : Globals::$conf->format_hour_short); |
|
| 1895 | + } else if ($format == 'hourduration') { |
|
| 1896 | + $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : Globals::$conf->format_hour_short_duration); |
|
| 1897 | + } else if ($format == 'daytext') { |
|
| 1898 | + $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : Globals::$conf->format_date_text); |
|
| 1899 | + } else if ($format == 'daytextshort') { |
|
| 1900 | + // Notice: Undefined property: stdClass::$format_date_text_short in \alixar\dolibarr\htdocs\core\lib\functions.lib.php on line 1781 |
|
| 1901 | + $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : Globals::$conf->format_date_text_short); |
|
| 1902 | + } else if ($format == 'dayhour') { |
|
| 1903 | + $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : Globals::$conf->format_date_hour_short); |
|
| 1904 | + } else if ($format == 'dayhoursec') { |
|
| 1905 | + $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : Globals::$conf->format_date_hour_sec_short); |
|
| 1906 | + } else if ($format == 'dayhourtext') { |
|
| 1907 | + $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : Globals::$conf->format_date_hour_text); |
|
| 1908 | + } else if ($format == 'dayhourtextshort') { |
|
| 1909 | + $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : Globals::$conf->format_date_hour_text_short); |
|
| 1910 | + } |
|
| 1911 | + // Format not sensitive to language |
|
| 1912 | + else if ($format == 'dayhourlog') { |
|
| 1913 | + $format = '%Y%m%d%H%M%S'; |
|
| 1914 | + } else if ($format == 'dayhourldap') { |
|
| 1915 | + $format = '%Y%m%d%H%M%SZ'; |
|
| 1916 | + } else if ($format == 'dayhourxcard') { |
|
| 1917 | + $format = '%Y%m%dT%H%M%SZ'; |
|
| 1918 | + } else if ($format == 'dayxcard') { |
|
| 1919 | + $format = '%Y%m%d'; |
|
| 1920 | + } else if ($format == 'dayrfc') { |
|
| 1921 | + $format = '%Y-%m-%d'; |
|
| 1922 | + } |
|
| 1923 | + // DATE_RFC3339 |
|
| 1924 | + else if ($format == 'dayhourrfc') { |
|
| 1925 | + $format = '%Y-%m-%dT%H:%M:%SZ'; |
|
| 1926 | + } |
|
| 1927 | + // DATETIME RFC3339 |
|
| 1928 | + else if ($format == 'standard') { |
|
| 1929 | + $format = '%Y-%m-%d %H:%M:%S'; |
|
| 1930 | + } |
|
| 1842 | 1931 | |
| 1843 | 1932 | if ($reduceformat) {
|
| 1844 | 1933 | $format = str_replace('%Y', '%y', $format);
|
@@ -1846,8 +1935,10 @@ discard block |
||
| 1846 | 1935 | } |
| 1847 | 1936 | |
| 1848 | 1937 | // If date undefined or "", we return "" |
| 1849 | - if (dol_strlen($time) == 0) |
|
| 1850 | - return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) |
|
| 1938 | + if (dol_strlen($time) == 0) { |
|
| 1939 | + return ''; |
|
| 1940 | + } |
|
| 1941 | + // $time=0 allowed (it means 01/01/1970 00:00:00) |
|
| 1851 | 1942 | |
| 1852 | 1943 | |
| 1853 | 1944 | |
@@ -1915,8 +2006,9 @@ discard block |
||
| 1915 | 2006 | $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with static function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. |
| 1916 | 2007 | |
| 1917 | 2008 | $ret = adodb_strftime($format, $timetouse, $to_gmt); |
| 1918 | - } else |
|
| 1919 | - $ret = 'Bad value ' . $time . ' for date'; |
|
| 2009 | + } else { |
|
| 2010 | + $ret = 'Bad value ' . $time . ' for date'; |
|
| 2011 | + } |
|
| 1920 | 2012 | } |
| 1921 | 2013 | |
| 1922 | 2014 | if (preg_match('/__b__/i', $format)) {
|
@@ -1987,10 +2079,14 @@ discard block |
||
| 1987 | 2079 | // global Globals::$conf; |
| 1988 | 2080 | |
| 1989 | 2081 | $usealternatemethod = false; |
| 1990 | - if ($timestamp <= 0) |
|
| 1991 | - $usealternatemethod = true; // <= 1970 |
|
| 1992 | - if ($timestamp >= 2145913200) |
|
| 1993 | - $usealternatemethod = true; // >= 2038 |
|
| 2082 | + if ($timestamp <= 0) { |
|
| 2083 | + $usealternatemethod = true; |
|
| 2084 | + } |
|
| 2085 | + // <= 1970 |
|
| 2086 | + if ($timestamp >= 2145913200) { |
|
| 2087 | + $usealternatemethod = true; |
|
| 2088 | + } |
|
| 2089 | + // >= 2038 |
|
| 1994 | 2090 | |
| 1995 | 2091 | if ($usealternatemethod) {
|
| 1996 | 2092 | $arrayinfo = adodb_getdate($timestamp, $fast); |
@@ -2025,27 +2121,36 @@ discard block |
||
| 2025 | 2121 | // global Globals::$conf; |
| 2026 | 2122 | //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; |
| 2027 | 2123 | // Clean parameters |
| 2028 | - if ($hour == -1 || empty($hour)) |
|
| 2029 | - $hour = 0; |
|
| 2030 | - if ($minute == -1 || empty($minute)) |
|
| 2031 | - $minute = 0; |
|
| 2032 | - if ($second == -1 || empty($second)) |
|
| 2033 | - $second = 0; |
|
| 2124 | + if ($hour == -1 || empty($hour)) { |
|
| 2125 | + $hour = 0; |
|
| 2126 | + } |
|
| 2127 | + if ($minute == -1 || empty($minute)) { |
|
| 2128 | + $minute = 0; |
|
| 2129 | + } |
|
| 2130 | + if ($second == -1 || empty($second)) { |
|
| 2131 | + $second = 0; |
|
| 2132 | + } |
|
| 2034 | 2133 | |
| 2035 | 2134 | // Check parameters |
| 2036 | 2135 | if ($check) {
|
| 2037 | - if (!$month || !$day) |
|
| 2038 | - return ''; |
|
| 2039 | - if ($day > 31) |
|
| 2040 | - return ''; |
|
| 2041 | - if ($month > 12) |
|
| 2042 | - return ''; |
|
| 2043 | - if ($hour < 0 || $hour > 24) |
|
| 2044 | - return ''; |
|
| 2045 | - if ($minute < 0 || $minute > 60) |
|
| 2046 | - return ''; |
|
| 2047 | - if ($second < 0 || $second > 60) |
|
| 2048 | - return ''; |
|
| 2136 | + if (!$month || !$day) { |
|
| 2137 | + return ''; |
|
| 2138 | + } |
|
| 2139 | + if ($day > 31) { |
|
| 2140 | + return ''; |
|
| 2141 | + } |
|
| 2142 | + if ($month > 12) { |
|
| 2143 | + return ''; |
|
| 2144 | + } |
|
| 2145 | + if ($hour < 0 || $hour > 24) { |
|
| 2146 | + return ''; |
|
| 2147 | + } |
|
| 2148 | + if ($minute < 0 || $minute > 60) { |
|
| 2149 | + return ''; |
|
| 2150 | + } |
|
| 2151 | + if ($second < 0 || $second > 60) { |
|
| 2152 | + return ''; |
|
| 2153 | + } |
|
| 2049 | 2154 | } |
| 2050 | 2155 | |
| 2051 | 2156 | if (method_exists('DateTime', 'getTimestamp')) {
|
@@ -2102,8 +2207,10 @@ discard block |
||
| 2102 | 2207 | |
| 2103 | 2208 | // Note that gmmktime and mktime return same value (GMT) when used without parameters |
| 2104 | 2209 | //if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() static function instead |
| 2105 | - if ($mode == 'gmt') |
|
| 2106 | - $ret = time(); // Time for now at greenwich. |
|
| 2210 | + if ($mode == 'gmt') { |
|
| 2211 | + $ret = time(); |
|
| 2212 | + } |
|
| 2213 | + // Time for now at greenwich. |
|
| 2107 | 2214 | else if ($mode == 'tzserver') { // Time for now with PHP server timezone added
|
| 2108 | 2215 | require_once DOL_BASE_PATH . '/core/lib/date.lib.php'; |
| 2109 | 2216 | $tzsecond = getServerTimeZoneInt('now'); // Contains tz+dayling saving time
|
@@ -2137,8 +2244,9 @@ discard block |
||
| 2137 | 2244 | // global Globals::$conf, Globals::$langs; |
| 2138 | 2245 | $level = 1024; |
| 2139 | 2246 | |
| 2140 | - if (!empty(Globals::$conf->dol_optimize_smallscreen)) |
|
| 2141 | - $shortunit = 1; |
|
| 2247 | + if (!empty(Globals::$conf->dol_optimize_smallscreen)) { |
|
| 2248 | + $shortunit = 1; |
|
| 2249 | + } |
|
| 2142 | 2250 | |
| 2143 | 2251 | // Set value text |
| 2144 | 2252 | if (empty($shortvalue) || $size < ($level * 10)) {
|
@@ -2173,19 +2281,23 @@ discard block |
||
| 2173 | 2281 | {
|
| 2174 | 2282 | // global Globals::$langs; |
| 2175 | 2283 | |
| 2176 | - if (empty($url)) |
|
| 2177 | - return ''; |
|
| 2284 | + if (empty($url)) { |
|
| 2285 | + return ''; |
|
| 2286 | + } |
|
| 2178 | 2287 | |
| 2179 | 2288 | $link = '<a href="'; |
| 2180 | - if (!preg_match('/^http/i', $url))
|
|
| 2181 | - $link .= 'http://'; |
|
| 2289 | + if (!preg_match('/^http/i', $url)) { |
|
| 2290 | + $link .= 'http://'; |
|
| 2291 | + } |
|
| 2182 | 2292 | $link .= $url; |
| 2183 | 2293 | $link .= '"'; |
| 2184 | - if ($target) |
|
| 2185 | - $link .= ' target="' . $target . '"'; |
|
| 2294 | + if ($target) { |
|
| 2295 | + $link .= ' target="' . $target . '"'; |
|
| 2296 | + } |
|
| 2186 | 2297 | $link .= '>'; |
| 2187 | - if (!preg_match('/^http/i', $url))
|
|
| 2188 | - $link .= 'http://'; |
|
| 2298 | + if (!preg_match('/^http/i', $url)) { |
|
| 2299 | + $link .= 'http://'; |
|
| 2300 | + } |
|
| 2189 | 2301 | $link .= dol_trunc($url, $max); |
| 2190 | 2302 | $link .= '</a>'; |
| 2191 | 2303 | return '<div class="nospan float" style="margin-right: 10px">' . ($withpicto ? img_picto(Globals::$langs->trans("Url"), 'object_globe.png') . ' ' : '') . $link . '</div>';
|
@@ -2209,13 +2321,15 @@ discard block |
||
| 2209 | 2321 | |
| 2210 | 2322 | $newemail = $email; |
| 2211 | 2323 | |
| 2212 | - if (empty($email)) |
|
| 2213 | - return ' '; |
|
| 2324 | + if (empty($email)) { |
|
| 2325 | + return ' '; |
|
| 2326 | + } |
|
| 2214 | 2327 | |
| 2215 | 2328 | if (!empty($addlink)) {
|
| 2216 | 2329 | $newemail = '<a style="text-overflow: ellipsis;" href="'; |
| 2217 | - if (!preg_match('/^mailto:/i', $email))
|
|
| 2218 | - $newemail .= 'mailto:'; |
|
| 2330 | + if (!preg_match('/^mailto:/i', $email)) { |
|
| 2331 | + $newemail .= 'mailto:'; |
|
| 2332 | + } |
|
| 2219 | 2333 | $newemail .= $email; |
| 2220 | 2334 | $newemail .= '">'; |
| 2221 | 2335 | $newemail .= dol_trunc($email, $max); |
@@ -2228,13 +2342,14 @@ discard block |
||
| 2228 | 2342 | if (($cid || $socid) && !empty(Globals::$conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
|
| 2229 | 2343 | $type = 'AC_EMAIL'; |
| 2230 | 2344 | $link = ''; |
| 2231 | - if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFOREMAIL)) |
|
| 2232 | - $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $type . '&contactid=' . $cid . '&socid=' . $socid . '">' . img_object(Globals::$langs->trans("AddAction"), "calendar") . '</a>';
|
|
| 2233 | - if ($link) |
|
| 2234 | - $newemail = '<div>' . $newemail . ' ' . $link . '</div>'; |
|
| 2345 | + if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFOREMAIL)) { |
|
| 2346 | + $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $type . '&contactid=' . $cid . '&socid=' . $socid . '">' . img_object(Globals::$langs->trans("AddAction"), "calendar") . '</a>'; |
|
| 2347 | + } |
|
| 2348 | + if ($link) { |
|
| 2349 | + $newemail = '<div>' . $newemail . ' ' . $link . '</div>'; |
|
| 2350 | + } |
|
| 2235 | 2351 | } |
| 2236 | - } |
|
| 2237 | - else {
|
|
| 2352 | + } else {
|
|
| 2238 | 2353 | if ($showinvalid && !isValidEmail($email)) {
|
| 2239 | 2354 | Globals::$langs->load("errors");
|
| 2240 | 2355 | $newemail .= img_warning(Globals::$langs->trans("ErrorBadEMail", $email));
|
@@ -2266,8 +2381,9 @@ discard block |
||
| 2266 | 2381 | |
| 2267 | 2382 | $newskype = $value; |
| 2268 | 2383 | |
| 2269 | - if (empty($value)) |
|
| 2270 | - return ' '; |
|
| 2384 | + if (empty($value)) { |
|
| 2385 | + return ' '; |
|
| 2386 | + } |
|
| 2271 | 2387 | |
| 2272 | 2388 | if (!empty($type)) {
|
| 2273 | 2389 | $newskype = '<div class="divsocialnetwork inline-block valignmiddle">'; |
@@ -2288,13 +2404,13 @@ discard block |
||
| 2288 | 2404 | if (($cid || $socid) && !empty(Globals::$conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type == 'skype') {
|
| 2289 | 2405 | $addlink = 'AC_SKYPE'; |
| 2290 | 2406 | $link = ''; |
| 2291 | - if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORSKYPE)) |
|
| 2292 | - $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $addlink . '&contactid=' . $cid . '&socid=' . $socid . '">' . img_object(Globals::$langs->trans("AddAction"), "calendar") . '</a>';
|
|
| 2407 | + if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORSKYPE)) { |
|
| 2408 | + $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $addlink . '&contactid=' . $cid . '&socid=' . $socid . '">' . img_object(Globals::$langs->trans("AddAction"), "calendar") . '</a>'; |
|
| 2409 | + } |
|
| 2293 | 2410 | $newskype .= ($link ? ' ' . $link : ''); |
| 2294 | 2411 | } |
| 2295 | 2412 | $newskype .= '</div>'; |
| 2296 | - } |
|
| 2297 | - else {
|
|
| 2413 | + } else {
|
|
| 2298 | 2414 | Globals::$langs->load("errors");
|
| 2299 | 2415 | $newskype .= img_warning(Globals::$langs->trans("ErrorBadSocialNetworkValue", $value));
|
| 2300 | 2416 | } |
@@ -2323,12 +2439,14 @@ discard block |
||
| 2323 | 2439 | if (empty($phone)) {
|
| 2324 | 2440 | return ''; |
| 2325 | 2441 | } |
| 2326 | - if (empty($countrycode)) |
|
| 2327 | - $countrycode = $mysoc->country_code; |
|
| 2442 | + if (empty($countrycode)) { |
|
| 2443 | + $countrycode = $mysoc->country_code; |
|
| 2444 | + } |
|
| 2328 | 2445 | |
| 2329 | 2446 | // Short format for small screens |
| 2330 | - if (Globals::$conf->dol_optimize_smallscreen) |
|
| 2331 | - $separ = ''; |
|
| 2447 | + if (Globals::$conf->dol_optimize_smallscreen) { |
|
| 2448 | + $separ = ''; |
|
| 2449 | + } |
|
| 2332 | 2450 | |
| 2333 | 2451 | $newphone = $phone; |
| 2334 | 2452 | if (strtoupper($countrycode) == "FR") {
|
@@ -2494,15 +2612,18 @@ discard block |
||
| 2494 | 2612 | $newphone = '<a href="tel:' . $phone . '"'; |
| 2495 | 2613 | $newphone .= '>' . $phone . '</a>'; |
| 2496 | 2614 | } else if (!empty(Globals::$conf->clicktodial->enabled) && $addlink == 'AC_TEL') { // If click to dial, we use click to dial url
|
| 2497 | - if (empty($user->clicktodial_loaded)) |
|
| 2498 | - $user->fetch_clicktodial(); |
|
| 2615 | + if (empty($user->clicktodial_loaded)) { |
|
| 2616 | + $user->fetch_clicktodial(); |
|
| 2617 | + } |
|
| 2499 | 2618 | |
| 2500 | 2619 | // Define urlmask |
| 2501 | 2620 | $urlmask = 'ErrorClickToDialModuleNotConfigured'; |
| 2502 | - if (!empty(Globals::$conf->global->CLICKTODIAL_URL)) |
|
| 2503 | - $urlmask = Globals::$conf->global->CLICKTODIAL_URL; |
|
| 2504 | - if (!empty($user->clicktodial_url)) |
|
| 2505 | - $urlmask = $user->clicktodial_url; |
|
| 2621 | + if (!empty(Globals::$conf->global->CLICKTODIAL_URL)) { |
|
| 2622 | + $urlmask = Globals::$conf->global->CLICKTODIAL_URL; |
|
| 2623 | + } |
|
| 2624 | + if (!empty($user->clicktodial_url)) { |
|
| 2625 | + $urlmask = $user->clicktodial_url; |
|
| 2626 | + } |
|
| 2506 | 2627 | |
| 2507 | 2628 | $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) : ''); |
| 2508 | 2629 | $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) : ''); |
@@ -2517,8 +2638,9 @@ discard block |
||
| 2517 | 2638 | $url = make_substitutions($url, $substitarray); |
| 2518 | 2639 | $newphonesav = $newphone; |
| 2519 | 2640 | $newphone = '<a href="' . $url . '"'; |
| 2520 | - if (!empty(Globals::$conf->global->CLICKTODIAL_FORCENEWTARGET)) |
|
| 2521 | - $newphone .= ' target="_blank"'; |
|
| 2641 | + if (!empty(Globals::$conf->global->CLICKTODIAL_FORCENEWTARGET)) { |
|
| 2642 | + $newphone .= ' target="_blank"'; |
|
| 2643 | + } |
|
| 2522 | 2644 | $newphone .= '>' . $newphonesav . '</a>'; |
| 2523 | 2645 | } |
| 2524 | 2646 | |
@@ -2526,12 +2648,15 @@ discard block |
||
| 2526 | 2648 | if (!empty(Globals::$conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
|
| 2527 | 2649 | $type = 'AC_TEL'; |
| 2528 | 2650 | $link = ''; |
| 2529 | - if ($addlink == 'AC_FAX') |
|
| 2530 | - $type = 'AC_FAX'; |
|
| 2531 | - if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORPHONE)) |
|
| 2532 | - $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $type . ($cid ? '&contactid=' . $cid : '') . ($socid ? '&socid=' . $socid : '') . '">' . img_object(Globals::$langs->trans("AddAction"), "calendar") . '</a>';
|
|
| 2533 | - if ($link) |
|
| 2534 | - $newphone = '<div>' . $newphone . ' ' . $link . '</div>'; |
|
| 2651 | + if ($addlink == 'AC_FAX') { |
|
| 2652 | + $type = 'AC_FAX'; |
|
| 2653 | + } |
|
| 2654 | + if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORPHONE)) { |
|
| 2655 | + $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $type . ($cid ? '&contactid=' . $cid : '') . ($socid ? '&socid=' . $socid : '') . '">' . img_object(Globals::$langs->trans("AddAction"), "calendar") . '</a>'; |
|
| 2656 | + } |
|
| 2657 | + if ($link) { |
|
| 2658 | + $newphone = '<div>' . $newphone . ' ' . $link . '</div>'; |
|
| 2659 | + } |
|
| 2535 | 2660 | } |
| 2536 | 2661 | } |
| 2537 | 2662 | |
@@ -2558,15 +2683,17 @@ discard block |
||
| 2558 | 2683 | $picto = ''; |
| 2559 | 2684 | } |
| 2560 | 2685 | } |
| 2561 | - if ($adddivfloat) |
|
| 2562 | - $rep .= '<div class="nospan float" style="margin-right: 10px">'; |
|
| 2563 | - else |
|
| 2564 | - $rep .= '<span style="margin-right: 10px;">'; |
|
| 2686 | + if ($adddivfloat) { |
|
| 2687 | + $rep .= '<div class="nospan float" style="margin-right: 10px">'; |
|
| 2688 | + } else { |
|
| 2689 | + $rep .= '<span style="margin-right: 10px;">'; |
|
| 2690 | + } |
|
| 2565 | 2691 | $rep .= ($withpicto ? img_picto($titlealt, 'object_' . $picto . '.png') . ' ' : '') . $newphone; |
| 2566 | - if ($adddivfloat) |
|
| 2567 | - $rep .= '</div>'; |
|
| 2568 | - else |
|
| 2569 | - $rep .= '</span>'; |
|
| 2692 | + if ($adddivfloat) { |
|
| 2693 | + $rep .= '</div>'; |
|
| 2694 | + } else { |
|
| 2695 | + $rep .= '</span>'; |
|
| 2696 | + } |
|
| 2570 | 2697 | } |
| 2571 | 2698 | |
| 2572 | 2699 | return $rep; |
@@ -2596,8 +2723,9 @@ discard block |
||
| 2596 | 2723 | if ($countrycode) { // If success, countrycode is us, fr, ...
|
| 2597 | 2724 | if (file_exists(DOL_BASE_PATH . '/theme/common/flags/' . $countrycode . '.png')) {
|
| 2598 | 2725 | $ret .= ' ' . img_picto($countrycode . ' ' . Globals::$langs->trans("AccordingToGeoIPDatabase"), DOL_BASE_URI . '/theme/common/flags/' . $countrycode . '.png', '', 1);
|
| 2599 | - } else |
|
| 2600 | - $ret .= ' (' . $countrycode . ')';
|
|
| 2726 | + } else { |
|
| 2727 | + $ret .= ' (' . $countrycode . ')'; |
|
| 2728 | + } |
|
| 2601 | 2729 | } |
| 2602 | 2730 | } |
| 2603 | 2731 | |
@@ -2694,26 +2822,33 @@ discard block |
||
| 2694 | 2822 | $out .= $hookmanager->resPrint; |
| 2695 | 2823 | } |
| 2696 | 2824 | if (empty($reshook)) {
|
| 2697 | - if (empty($charfornl)) |
|
| 2698 | - $out .= nl2br($address); |
|
| 2699 | - else |
|
| 2700 | - $out .= preg_replace('/[\r\n]+/', $charfornl, $address);
|
|
| 2825 | + if (empty($charfornl)) { |
|
| 2826 | + $out .= nl2br($address); |
|
| 2827 | + } else { |
|
| 2828 | + $out .= preg_replace('/[\r\n]+/', $charfornl, $address); |
|
| 2829 | + } |
|
| 2701 | 2830 | |
| 2702 | 2831 | $showgmap = $showomap = 0; |
| 2703 | 2832 | |
| 2704 | 2833 | // TODO Add a hook here |
| 2705 | - if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS)) |
|
| 2706 | - $showgmap = 1; |
|
| 2707 | - if ($mode == 'contact' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) |
|
| 2708 | - $showgmap = 1; |
|
| 2709 | - if ($mode == 'member' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) |
|
| 2710 | - $showgmap = 1; |
|
| 2711 | - if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS)) |
|
| 2712 | - $showomap = 1; |
|
| 2713 | - if ($mode == 'contact' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) |
|
| 2714 | - $showomap = 1; |
|
| 2715 | - if ($mode == 'member' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) |
|
| 2716 | - $showomap = 1; |
|
| 2834 | + if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS)) { |
|
| 2835 | + $showgmap = 1; |
|
| 2836 | + } |
|
| 2837 | + if ($mode == 'contact' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) { |
|
| 2838 | + $showgmap = 1; |
|
| 2839 | + } |
|
| 2840 | + if ($mode == 'member' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) { |
|
| 2841 | + $showgmap = 1; |
|
| 2842 | + } |
|
| 2843 | + if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS)) { |
|
| 2844 | + $showomap = 1; |
|
| 2845 | + } |
|
| 2846 | + if ($mode == 'contact' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) { |
|
| 2847 | + $showomap = 1; |
|
| 2848 | + } |
|
| 2849 | + if ($mode == 'member' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) { |
|
| 2850 | + $showomap = 1; |
|
| 2851 | + } |
|
| 2717 | 2852 | |
| 2718 | 2853 | if ($showgmap) {
|
| 2719 | 2854 | $url = dol_buildpath('/google/gmaps.php?mode=' . $mode . '&id=' . $id, 1);
|
@@ -2725,10 +2860,11 @@ discard block |
||
| 2725 | 2860 | } |
| 2726 | 2861 | } |
| 2727 | 2862 | } |
| 2728 | - if ($noprint) |
|
| 2729 | - return $out; |
|
| 2730 | - else |
|
| 2731 | - print $out; |
|
| 2863 | + if ($noprint) { |
|
| 2864 | + return $out; |
|
| 2865 | + } else { |
|
| 2866 | + print $out; |
|
| 2867 | + } |
|
| 2732 | 2868 | } |
| 2733 | 2869 | |
| 2734 | 2870 | /** |
@@ -2740,10 +2876,12 @@ discard block |
||
| 2740 | 2876 | */ |
| 2741 | 2877 | static function isValidEmail($address, $acceptsupervisorkey = 0) |
| 2742 | 2878 | {
|
| 2743 | - if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__') |
|
| 2744 | - return true; |
|
| 2745 | - if (filter_var($address, FILTER_VALIDATE_EMAIL)) |
|
| 2746 | - return true; |
|
| 2879 | + if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__') { |
|
| 2880 | + return true; |
|
| 2881 | + } |
|
| 2882 | + if (filter_var($address, FILTER_VALIDATE_EMAIL)) { |
|
| 2883 | + return true; |
|
| 2884 | + } |
|
| 2747 | 2885 | |
| 2748 | 2886 | return false; |
| 2749 | 2887 | } |
@@ -2765,10 +2903,12 @@ discard block |
||
| 2765 | 2903 | $mxhosts = array(); |
| 2766 | 2904 | $weight = array(); |
| 2767 | 2905 | getmxrr(idn_to_ascii($domain), $mxhosts, $weight); |
| 2768 | - if (count($mxhosts) > 1) |
|
| 2769 | - return 1; |
|
| 2770 | - if (count($mxhosts) == 1 && !empty($mxhosts[0])) |
|
| 2771 | - return 1; |
|
| 2906 | + if (count($mxhosts) > 1) { |
|
| 2907 | + return 1; |
|
| 2908 | + } |
|
| 2909 | + if (count($mxhosts) == 1 && !empty($mxhosts[0])) { |
|
| 2910 | + return 1; |
|
| 2911 | + } |
|
| 2772 | 2912 | |
| 2773 | 2913 | return 0; |
| 2774 | 2914 | } |
@@ -2797,10 +2937,11 @@ discard block |
||
| 2797 | 2937 | */ |
| 2798 | 2938 | static function dol_strlen($string, $stringencoding = 'UTF-8') |
| 2799 | 2939 | {
|
| 2800 | - if (function_exists('mb_strlen'))
|
|
| 2801 | - return mb_strlen($string, $stringencoding); |
|
| 2802 | - else |
|
| 2803 | - return strlen($string); |
|
| 2940 | + if (function_exists('mb_strlen')) { |
|
| 2941 | + return mb_strlen($string, $stringencoding); |
|
| 2942 | + } else { |
|
| 2943 | + return strlen($string); |
|
| 2944 | + } |
|
| 2804 | 2945 | } |
| 2805 | 2946 | |
| 2806 | 2947 | /** |
@@ -2817,8 +2958,9 @@ discard block |
||
| 2817 | 2958 | {
|
| 2818 | 2959 | // global Globals::$langs; |
| 2819 | 2960 | |
| 2820 | - if (empty($stringencoding)) |
|
| 2821 | - $stringencoding = Globals::$langs->charset_output; |
|
| 2961 | + if (empty($stringencoding)) { |
|
| 2962 | + $stringencoding = Globals::$langs->charset_output; |
|
| 2963 | + } |
|
| 2822 | 2964 | |
| 2823 | 2965 | $ret = ''; |
| 2824 | 2966 | if (empty($trunconbytes)) {
|
@@ -2854,48 +2996,55 @@ discard block |
||
| 2854 | 2996 | {
|
| 2855 | 2997 | // global Globals::$conf; |
| 2856 | 2998 | |
| 2857 | - if ($size == 0 || !empty(Globals::$conf->global->MAIN_DISABLE_TRUNC)) |
|
| 2858 | - return $string; |
|
| 2999 | + if ($size == 0 || !empty(Globals::$conf->global->MAIN_DISABLE_TRUNC)) { |
|
| 3000 | + return $string; |
|
| 3001 | + } |
|
| 2859 | 3002 | |
| 2860 | - if (empty($stringencoding)) |
|
| 2861 | - $stringencoding = 'UTF-8'; |
|
| 2862 | -// reduce for small screen |
|
| 2863 | - if (Globals::$conf->dol_optimize_smallscreen == 1 && $display == 1) |
|
| 2864 | - $size = round($size / 3); |
|
| 3003 | + if (empty($stringencoding)) { |
|
| 3004 | + $stringencoding = 'UTF-8'; |
|
| 3005 | + } |
|
| 3006 | + // reduce for small screen |
|
| 3007 | + if (Globals::$conf->dol_optimize_smallscreen == 1 && $display == 1) { |
|
| 3008 | + $size = round($size / 3); |
|
| 3009 | + } |
|
| 2865 | 3010 | |
| 2866 | 3011 | // We go always here |
| 2867 | 3012 | if ($trunc == 'right') {
|
| 2868 | 3013 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
| 2869 | - if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
| 2870 | - return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...'); |
|
| 2871 | - else |
|
| 2872 | -//return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string; |
|
| 2873 | - return $string; |
|
| 2874 | - } |
|
| 2875 | - elseif ($trunc == 'middle') {
|
|
| 3014 | + if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) { |
|
| 3015 | + // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
| 3016 | + return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...'); |
|
| 3017 | + } else { |
|
| 3018 | + //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string; |
|
| 3019 | + return $string; |
|
| 3020 | + } |
|
| 3021 | + } elseif ($trunc == 'middle') {
|
|
| 2876 | 3022 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
| 2877 | 3023 | if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) {
|
| 2878 | 3024 | $size1 = round($size / 2); |
| 2879 | 3025 | $size2 = round($size / 2); |
| 2880 | 3026 | return dol_substr($newstring, 0, $size1, $stringencoding) . '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding); |
| 2881 | - } else |
|
| 2882 | - return $string; |
|
| 2883 | - } |
|
| 2884 | - elseif ($trunc == 'left') {
|
|
| 3027 | + } else { |
|
| 3028 | + return $string; |
|
| 3029 | + } |
|
| 3030 | + } elseif ($trunc == 'left') {
|
|
| 2885 | 3031 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
| 2886 | - if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
| 2887 | - return '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding); |
|
| 2888 | - else |
|
| 2889 | - return $string; |
|
| 2890 | - } |
|
| 2891 | - elseif ($trunc == 'wrap') {
|
|
| 3032 | + if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) { |
|
| 3033 | + // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
| 3034 | + return '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding); |
|
| 3035 | + } else { |
|
| 3036 | + return $string; |
|
| 3037 | + } |
|
| 3038 | + } elseif ($trunc == 'wrap') {
|
|
| 2892 | 3039 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
| 2893 | - if (dol_strlen($newstring, $stringencoding) > ($size + 1)) |
|
| 2894 | - return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc); |
|
| 2895 | - else |
|
| 2896 | - return $string; |
|
| 2897 | - } else |
|
| 2898 | - return 'BadParam3CallingDolTrunc'; |
|
| 3040 | + if (dol_strlen($newstring, $stringencoding) > ($size + 1)) { |
|
| 3041 | + return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc); |
|
| 3042 | + } else { |
|
| 3043 | + return $string; |
|
| 3044 | + } |
|
| 3045 | + } else { |
|
| 3046 | + return 'BadParam3CallingDolTrunc'; |
|
| 3047 | + } |
|
| 2899 | 3048 | } |
| 2900 | 3049 | |
| 2901 | 3050 | /** |
@@ -3105,8 +3254,9 @@ discard block |
||
| 3105 | 3254 | {
|
| 3106 | 3255 | // global Globals::$conf; |
| 3107 | 3256 | |
| 3108 | - if (!preg_match('/(\.png|\.gif)$/i', $picto))
|
|
| 3109 | - $picto .= '.png'; |
|
| 3257 | + if (!preg_match('/(\.png|\.gif)$/i', $picto)) { |
|
| 3258 | + $picto .= '.png'; |
|
| 3259 | + } |
|
| 3110 | 3260 | |
| 3111 | 3261 | //$path = DOL_BASE_URI . '/theme/' . Globals::$conf->theme . '/img/weather/' . $picto; |
| 3112 | 3262 | $path = DOL_BASE_URI . '/theme/' . Globals::$conf->theme . '/img/weather/' . $picto; |
@@ -3128,20 +3278,22 @@ discard block |
||
| 3128 | 3278 | {
|
| 3129 | 3279 | // global Globals::$conf; |
| 3130 | 3280 | |
| 3131 | - if (!preg_match('/(\.png|\.gif)$/i', $picto))
|
|
| 3132 | - $picto .= '.png'; |
|
| 3281 | + if (!preg_match('/(\.png|\.gif)$/i', $picto)) { |
|
| 3282 | + $picto .= '.png'; |
|
| 3283 | + } |
|
| 3133 | 3284 | |
| 3134 | - if ($pictoisfullpath) |
|
| 3135 | - $path = $picto; |
|
| 3136 | - else {
|
|
| 3285 | + if ($pictoisfullpath) { |
|
| 3286 | + $path = $picto; |
|
| 3287 | + } else {
|
|
| 3137 | 3288 | //$path = DOL_BASE_URI . '/theme/common/' . $picto; |
| 3138 | 3289 | $path = DOL_BASE_URI . '/theme/common/' . $picto; |
| 3139 | 3290 | |
| 3140 | 3291 | if (!empty(Globals::$conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) {
|
| 3141 | 3292 | $themepath = DOL_BASE_PATH . 'theme/' . Globals::$conf->theme . '/img/' . $picto; |
| 3142 | 3293 | |
| 3143 | - if (file_exists($themepath)) |
|
| 3144 | - $path = $themepath; |
|
| 3294 | + if (file_exists($themepath)) { |
|
| 3295 | + $path = $themepath; |
|
| 3296 | + } |
|
| 3145 | 3297 | } |
| 3146 | 3298 | } |
| 3147 | 3299 | |
@@ -3180,8 +3332,9 @@ discard block |
||
| 3180 | 3332 | $numaction = 0; |
| 3181 | 3333 | } |
| 3182 | 3334 | } |
| 3183 | - if (!is_numeric($numaction)) |
|
| 3184 | - $numaction = 0; |
|
| 3335 | + if (!is_numeric($numaction)) { |
|
| 3336 | + $numaction = 0; |
|
| 3337 | + } |
|
| 3185 | 3338 | |
| 3186 | 3339 | return img_picto($titlealt, 'stcomm' . $numaction . '.png'); |
| 3187 | 3340 | } |
@@ -3197,8 +3350,9 @@ discard block |
||
| 3197 | 3350 | {
|
| 3198 | 3351 | // global Globals::$conf, Globals::$langs; |
| 3199 | 3352 | |
| 3200 | - if ($titlealt == 'default') |
|
| 3201 | - $titlealt = Globals::$langs->trans('Show');
|
|
| 3353 | + if ($titlealt == 'default') { |
|
| 3354 | + $titlealt = Globals::$langs->trans('Show'); |
|
| 3355 | + } |
|
| 3202 | 3356 | |
| 3203 | 3357 | return img_picto($titlealt, 'pdf' . $size . '.png'); |
| 3204 | 3358 | } |
@@ -3214,8 +3368,9 @@ discard block |
||
| 3214 | 3368 | {
|
| 3215 | 3369 | // global Globals::$conf, Globals::$langs; |
| 3216 | 3370 | |
| 3217 | - if ($titlealt == 'default') |
|
| 3218 | - $titlealt = Globals::$langs->trans('Add');
|
|
| 3371 | + if ($titlealt == 'default') { |
|
| 3372 | + $titlealt = Globals::$langs->trans('Add'); |
|
| 3373 | + } |
|
| 3219 | 3374 | |
| 3220 | 3375 | return img_picto($titlealt, 'edit_add.png', $other); |
| 3221 | 3376 | } |
@@ -3231,8 +3386,9 @@ discard block |
||
| 3231 | 3386 | {
|
| 3232 | 3387 | // global Globals::$conf, Globals::$langs; |
| 3233 | 3388 | |
| 3234 | - if ($titlealt == 'default') |
|
| 3235 | - $titlealt = Globals::$langs->trans('Remove');
|
|
| 3389 | + if ($titlealt == 'default') { |
|
| 3390 | + $titlealt = Globals::$langs->trans('Remove'); |
|
| 3391 | + } |
|
| 3236 | 3392 | |
| 3237 | 3393 | return img_picto($titlealt, 'edit_remove.png', $other); |
| 3238 | 3394 | } |
@@ -3249,8 +3405,9 @@ discard block |
||
| 3249 | 3405 | {
|
| 3250 | 3406 | // global Globals::$conf, Globals::$langs; |
| 3251 | 3407 | |
| 3252 | - if ($titlealt == 'default') |
|
| 3253 | - $titlealt = Globals::$langs->trans('Modify');
|
|
| 3408 | + if ($titlealt == 'default') { |
|
| 3409 | + $titlealt = Globals::$langs->trans('Modify'); |
|
| 3410 | + } |
|
| 3254 | 3411 | |
| 3255 | 3412 | return img_picto($titlealt, 'edit.png', ($float ? 'style="float: ' . (Globals::$langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right') . '"' : "") . ($other ? ' ' . $other : '')); |
| 3256 | 3413 | } |
@@ -3267,8 +3424,9 @@ discard block |
||
| 3267 | 3424 | {
|
| 3268 | 3425 | // global Globals::$conf, Globals::$langs; |
| 3269 | 3426 | |
| 3270 | - if ($titlealt == 'default') |
|
| 3271 | - $titlealt = Globals::$langs->trans('View');
|
|
| 3427 | + if ($titlealt == 'default') { |
|
| 3428 | + $titlealt = Globals::$langs->trans('View'); |
|
| 3429 | + } |
|
| 3272 | 3430 | |
| 3273 | 3431 | $moreatt = ($float ? 'style="float: right" ' : '') . $other; |
| 3274 | 3432 | |
@@ -3286,8 +3444,9 @@ discard block |
||
| 3286 | 3444 | {
|
| 3287 | 3445 | // global Globals::$conf, Globals::$langs; |
| 3288 | 3446 | |
| 3289 | - if ($titlealt == 'default') |
|
| 3290 | - $titlealt = Globals::$langs->trans('Delete');
|
|
| 3447 | + if ($titlealt == 'default') { |
|
| 3448 | + $titlealt = Globals::$langs->trans('Delete'); |
|
| 3449 | + } |
|
| 3291 | 3450 | |
| 3292 | 3451 | return img_picto($titlealt, 'delete.png', $other); |
| 3293 | 3452 | //return '<span class="fa fa-trash fa-2x fa-fw" style="font-size: 1.7em;" title="'.$titlealt.'"></span>'; |
@@ -3303,8 +3462,9 @@ discard block |
||
| 3303 | 3462 | static function img_printer($titlealt = "default", $other = '') |
| 3304 | 3463 | {
|
| 3305 | 3464 | // global Globals::$conf, Globals::$langs; |
| 3306 | - if ($titlealt == "default") |
|
| 3307 | - $titlealt = Globals::$langs->trans("Print");
|
|
| 3465 | + if ($titlealt == "default") { |
|
| 3466 | + $titlealt = Globals::$langs->trans("Print"); |
|
| 3467 | + } |
|
| 3308 | 3468 | return img_picto($titlealt, 'printer.png', $other); |
| 3309 | 3469 | } |
| 3310 | 3470 | |
@@ -3319,8 +3479,9 @@ discard block |
||
| 3319 | 3479 | {
|
| 3320 | 3480 | // global Globals::$conf, Globals::$langs; |
| 3321 | 3481 | |
| 3322 | - if ($titlealt == 'default') |
|
| 3323 | - $titlealt = Globals::$langs->trans('Split');
|
|
| 3482 | + if ($titlealt == 'default') { |
|
| 3483 | + $titlealt = Globals::$langs->trans('Split'); |
|
| 3484 | + } |
|
| 3324 | 3485 | |
| 3325 | 3486 | return img_picto($titlealt, 'split.png', $other); |
| 3326 | 3487 | } |
@@ -3337,10 +3498,11 @@ discard block |
||
| 3337 | 3498 | // global Globals::$conf, Globals::$langs; |
| 3338 | 3499 | |
| 3339 | 3500 | if ($usealttitle) {
|
| 3340 | - if (is_string($usealttitle)) |
|
| 3341 | - $usealttitle = dol_escape_htmltag($usealttitle); |
|
| 3342 | - else |
|
| 3343 | - $usealttitle = Globals::$langs->trans('Info');
|
|
| 3501 | + if (is_string($usealttitle)) { |
|
| 3502 | + $usealttitle = dol_escape_htmltag($usealttitle); |
|
| 3503 | + } else { |
|
| 3504 | + $usealttitle = Globals::$langs->trans('Info'); |
|
| 3505 | + } |
|
| 3344 | 3506 | } |
| 3345 | 3507 | |
| 3346 | 3508 | return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;' . ($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')) . '"'); |
@@ -3356,8 +3518,9 @@ discard block |
||
| 3356 | 3518 | {
|
| 3357 | 3519 | // global Globals::$conf, Globals::$langs; |
| 3358 | 3520 | |
| 3359 | - if ($titlealt == 'default') |
|
| 3360 | - $titlealt = Globals::$langs->trans('Informations');
|
|
| 3521 | + if ($titlealt == 'default') { |
|
| 3522 | + $titlealt = Globals::$langs->trans('Informations'); |
|
| 3523 | + } |
|
| 3361 | 3524 | |
| 3362 | 3525 | return img_picto($titlealt, 'info.png', 'style="vertical-align: middle;"'); |
| 3363 | 3526 | } |
@@ -3373,8 +3536,9 @@ discard block |
||
| 3373 | 3536 | {
|
| 3374 | 3537 | // global Globals::$conf, Globals::$langs; |
| 3375 | 3538 | |
| 3376 | - if ($titlealt == 'default') |
|
| 3377 | - $titlealt = Globals::$langs->trans('Warning');
|
|
| 3539 | + if ($titlealt == 'default') { |
|
| 3540 | + $titlealt = Globals::$langs->trans('Warning'); |
|
| 3541 | + } |
|
| 3378 | 3542 | |
| 3379 | 3543 | //return '<div class="imglatecoin">'.img_picto($titlealt, 'warning_white.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')).'</div>'; |
| 3380 | 3544 | return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"' . ($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' ' . $moreatt) : '')); |
@@ -3390,8 +3554,9 @@ discard block |
||
| 3390 | 3554 | {
|
| 3391 | 3555 | // global Globals::$conf, Globals::$langs; |
| 3392 | 3556 | |
| 3393 | - if ($titlealt == 'default') |
|
| 3394 | - $titlealt = Globals::$langs->trans('Error');
|
|
| 3557 | + if ($titlealt == 'default') { |
|
| 3558 | + $titlealt = Globals::$langs->trans('Error'); |
|
| 3559 | + } |
|
| 3395 | 3560 | |
| 3396 | 3561 | return img_picto($titlealt, 'error.png', 'class="valigntextbottom"'); |
| 3397 | 3562 | } |
@@ -3407,8 +3572,9 @@ discard block |
||
| 3407 | 3572 | {
|
| 3408 | 3573 | // global Globals::$conf, Globals::$langs; |
| 3409 | 3574 | |
| 3410 | - if ($titlealt == 'default') |
|
| 3411 | - $titlealt = Globals::$langs->trans('Next');
|
|
| 3575 | + if ($titlealt == 'default') { |
|
| 3576 | + $titlealt = Globals::$langs->trans('Next'); |
|
| 3577 | + } |
|
| 3412 | 3578 | |
| 3413 | 3579 | //return img_picto($titlealt, 'next.png', $moreatt); |
| 3414 | 3580 | return '<span class="fa fa-chevron-right paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>'; |
@@ -3425,8 +3591,9 @@ discard block |
||
| 3425 | 3591 | {
|
| 3426 | 3592 | // global Globals::$conf, Globals::$langs; |
| 3427 | 3593 | |
| 3428 | - if ($titlealt == 'default') |
|
| 3429 | - $titlealt = Globals::$langs->trans('Previous');
|
|
| 3594 | + if ($titlealt == 'default') { |
|
| 3595 | + $titlealt = Globals::$langs->trans('Previous'); |
|
| 3596 | + } |
|
| 3430 | 3597 | |
| 3431 | 3598 | //return img_picto($titlealt, 'previous.png', $moreatt); |
| 3432 | 3599 | return '<span class="fa fa-chevron-left paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>'; |
@@ -3444,8 +3611,9 @@ discard block |
||
| 3444 | 3611 | {
|
| 3445 | 3612 | // global Globals::$conf, Globals::$langs; |
| 3446 | 3613 | |
| 3447 | - if ($titlealt == 'default') |
|
| 3448 | - $titlealt = Globals::$langs->trans('Down');
|
|
| 3614 | + if ($titlealt == 'default') { |
|
| 3615 | + $titlealt = Globals::$langs->trans('Down'); |
|
| 3616 | + } |
|
| 3449 | 3617 | |
| 3450 | 3618 | return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown' . ($moreclass ? " " . $moreclass : "") . '"'); |
| 3451 | 3619 | } |
@@ -3462,8 +3630,9 @@ discard block |
||
| 3462 | 3630 | {
|
| 3463 | 3631 | // global Globals::$conf, Globals::$langs; |
| 3464 | 3632 | |
| 3465 | - if ($titlealt == 'default') |
|
| 3466 | - $titlealt = Globals::$langs->trans('Up');
|
|
| 3633 | + if ($titlealt == 'default') { |
|
| 3634 | + $titlealt = Globals::$langs->trans('Up'); |
|
| 3635 | + } |
|
| 3467 | 3636 | |
| 3468 | 3637 | return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup' . ($moreclass ? " " . $moreclass : "") . '"'); |
| 3469 | 3638 | } |
@@ -3480,8 +3649,9 @@ discard block |
||
| 3480 | 3649 | {
|
| 3481 | 3650 | // global Globals::$conf, Globals::$langs; |
| 3482 | 3651 | |
| 3483 | - if ($titlealt == 'default') |
|
| 3484 | - $titlealt = Globals::$langs->trans('Left');
|
|
| 3652 | + if ($titlealt == 'default') { |
|
| 3653 | + $titlealt = Globals::$langs->trans('Left'); |
|
| 3654 | + } |
|
| 3485 | 3655 | |
| 3486 | 3656 | return img_picto($titlealt, ($selected ? '1leftarrow_selected.png' : '1leftarrow.png'), $moreatt); |
| 3487 | 3657 | } |
@@ -3498,8 +3668,9 @@ discard block |
||
| 3498 | 3668 | {
|
| 3499 | 3669 | // global Globals::$conf, Globals::$langs; |
| 3500 | 3670 | |
| 3501 | - if ($titlealt == 'default') |
|
| 3502 | - $titlealt = Globals::$langs->trans('Right');
|
|
| 3671 | + if ($titlealt == 'default') { |
|
| 3672 | + $titlealt = Globals::$langs->trans('Right'); |
|
| 3673 | + } |
|
| 3503 | 3674 | |
| 3504 | 3675 | return img_picto($titlealt, ($selected ? '1rightarrow_selected.png' : '1rightarrow.png'), $moreatt); |
| 3505 | 3676 | } |
@@ -3515,11 +3686,13 @@ discard block |
||
| 3515 | 3686 | {
|
| 3516 | 3687 | // global Globals::$conf, Globals::$langs; |
| 3517 | 3688 | |
| 3518 | - if ($titlealt == 'default') |
|
| 3519 | - $titlealt = Globals::$langs->trans('Active');
|
|
| 3689 | + if ($titlealt == 'default') { |
|
| 3690 | + $titlealt = Globals::$langs->trans('Active'); |
|
| 3691 | + } |
|
| 3520 | 3692 | |
| 3521 | - if ($allow == 1) |
|
| 3522 | - return img_picto($titlealt, 'tick.png'); |
|
| 3693 | + if ($allow == 1) { |
|
| 3694 | + return img_picto($titlealt, 'tick.png'); |
|
| 3695 | + } |
|
| 3523 | 3696 | |
| 3524 | 3697 | return '-'; |
| 3525 | 3698 | } |
@@ -3567,8 +3740,9 @@ discard block |
||
| 3567 | 3740 | $mimeimg = dol_mimetype($file, '', 2); |
| 3568 | 3741 | $mimefa = dol_mimetype($file, '', 4); |
| 3569 | 3742 | |
| 3570 | - if (empty($titlealt)) |
|
| 3571 | - $titlealt = 'Mime type: ' . $mimetype; |
|
| 3743 | + if (empty($titlealt)) { |
|
| 3744 | + $titlealt = 'Mime type: ' . $mimetype; |
|
| 3745 | + } |
|
| 3572 | 3746 | |
| 3573 | 3747 | //return img_picto_common($titlealt, 'mime/'.$mimeimg, 'class="'.$morecss.'"'); |
| 3574 | 3748 | return '<i class="fa fa-' . $mimefa . ' paddingright"></i>'; |
@@ -3590,13 +3764,15 @@ discard block |
||
| 3590 | 3764 | |
| 3591 | 3765 | // global Globals::$conf, Globals::$langs; |
| 3592 | 3766 | |
| 3593 | - if ($titlealt == 'default') |
|
| 3594 | - $titlealt = Globals::$langs->trans('Call');
|
|
| 3767 | + if ($titlealt == 'default') { |
|
| 3768 | + $titlealt = Globals::$langs->trans('Call'); |
|
| 3769 | + } |
|
| 3595 | 3770 | |
| 3596 | - if ($option == 1) |
|
| 3597 | - $img = 'call'; |
|
| 3598 | - else |
|
| 3599 | - $img = 'call_out'; |
|
| 3771 | + if ($option == 1) { |
|
| 3772 | + $img = 'call'; |
|
| 3773 | + } else { |
|
| 3774 | + $img = 'call_out'; |
|
| 3775 | + } |
|
| 3600 | 3776 | |
| 3601 | 3777 | return img_picto($titlealt, $img); |
| 3602 | 3778 | } |
@@ -3612,8 +3788,9 @@ discard block |
||
| 3612 | 3788 | {
|
| 3613 | 3789 | // global Globals::$conf, Globals::$langs; |
| 3614 | 3790 | |
| 3615 | - if ($titlealt == 'default') |
|
| 3616 | - $titlealt = Globals::$langs->trans('Search');
|
|
| 3791 | + if ($titlealt == 'default') { |
|
| 3792 | + $titlealt = Globals::$langs->trans('Search'); |
|
| 3793 | + } |
|
| 3617 | 3794 | |
| 3618 | 3795 | $img = img_picto($titlealt, 'search.png', $other, false, 1); |
| 3619 | 3796 | |
@@ -3634,8 +3811,9 @@ discard block |
||
| 3634 | 3811 | {
|
| 3635 | 3812 | // global Globals::$conf, Globals::$langs; |
| 3636 | 3813 | |
| 3637 | - if ($titlealt == 'default') |
|
| 3638 | - $titlealt = Globals::$langs->trans('Search');
|
|
| 3814 | + if ($titlealt == 'default') { |
|
| 3815 | + $titlealt = Globals::$langs->trans('Search'); |
|
| 3816 | + } |
|
| 3639 | 3817 | |
| 3640 | 3818 | $img = img_picto($titlealt, 'searchclear.png', $other, false, 1); |
| 3641 | 3819 | |
@@ -3697,14 +3875,16 @@ discard block |
||
| 3697 | 3875 | |
| 3698 | 3876 | if ($_SERVER['DOCUMENT_ROOT']) { // Mode web
|
| 3699 | 3877 | $out .= Globals::$langs->trans("DolibarrHasDetectedError") . ".<br>\n";
|
| 3700 | - if (!empty(Globals::$conf->global->MAIN_FEATURES_LEVEL)) |
|
| 3701 | - $out .= "You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.<br>\n"; |
|
| 3878 | + if (!empty(Globals::$conf->global->MAIN_FEATURES_LEVEL)) { |
|
| 3879 | + $out .= "You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.<br>\n"; |
|
| 3880 | + } |
|
| 3702 | 3881 | $out .= Globals::$langs->trans("InformationToHelpDiagnose") . ":<br>\n";
|
| 3703 | 3882 | |
| 3704 | 3883 | $out .= "<b>" . Globals::$langs->trans("Date") . ":</b> " . dol_print_date(time(), 'dayhourlog') . "<br>\n";
|
| 3705 | 3884 | $out .= "<b>" . Globals::$langs->trans("Dolibarr") . ":</b> " . DOL_VERSION . "<br>\n";
|
| 3706 | - if (isset(Globals::$conf->global->MAIN_FEATURES_LEVEL)) |
|
| 3707 | - $out .= "<b>" . Globals::$langs->trans("LevelOfFeature") . ":</b> " . Globals::$conf->global->MAIN_FEATURES_LEVEL . "<br>\n";
|
|
| 3885 | + if (isset(Globals::$conf->global->MAIN_FEATURES_LEVEL)) { |
|
| 3886 | + $out .= "<b>" . Globals::$langs->trans("LevelOfFeature") . ":</b> " . Globals::$conf->global->MAIN_FEATURES_LEVEL . "<br>\n"; |
|
| 3887 | + } |
|
| 3708 | 3888 | if (function_exists("phpversion")) {
|
| 3709 | 3889 | $out .= "<b>" . Globals::$langs->trans("PHP") . ":</b> " . phpversion() . "<br>\n";
|
| 3710 | 3890 | } |
@@ -3747,18 +3927,20 @@ discard block |
||
| 3747 | 3927 | Globals::$langs->load("errors");
|
| 3748 | 3928 | |
| 3749 | 3929 | // Merge all into $errors array |
| 3750 | - if (is_array($error) && is_array($errors)) |
|
| 3751 | - $errors = array_merge($error, $errors); |
|
| 3752 | - elseif (is_array($error)) |
|
| 3753 | - $errors = $error; |
|
| 3754 | - elseif (is_array($errors)) |
|
| 3755 | - $errors = array_merge(array($error), $errors); |
|
| 3756 | - else |
|
| 3757 | - $errors = array_merge(array($error)); |
|
| 3930 | + if (is_array($error) && is_array($errors)) { |
|
| 3931 | + $errors = array_merge($error, $errors); |
|
| 3932 | + } elseif (is_array($error)) { |
|
| 3933 | + $errors = $error; |
|
| 3934 | + } elseif (is_array($errors)) { |
|
| 3935 | + $errors = array_merge(array($error), $errors); |
|
| 3936 | + } else { |
|
| 3937 | + $errors = array_merge(array($error)); |
|
| 3938 | + } |
|
| 3758 | 3939 | |
| 3759 | 3940 | foreach ($errors as $msg) {
|
| 3760 | - if (empty($msg)) |
|
| 3761 | - continue; |
|
| 3941 | + if (empty($msg)) { |
|
| 3942 | + continue; |
|
| 3943 | + } |
|
| 3762 | 3944 | if ($_SERVER['DOCUMENT_ROOT']) { // Mode web
|
| 3763 | 3945 | $out .= "<b>" . Globals::$langs->trans("Message") . ":</b> " . dol_escape_htmltag($msg) . "<br>\n";
|
| 3764 | 3946 | } else { // Mode CLI
|
@@ -3776,9 +3958,9 @@ discard block |
||
| 3776 | 3958 | $out .= "<br>\n"; |
| 3777 | 3959 | } |
| 3778 | 3960 | |
| 3779 | - if (empty($dolibarr_main_prod)) |
|
| 3780 | - print $out; |
|
| 3781 | - else {
|
|
| 3961 | + if (empty($dolibarr_main_prod)) { |
|
| 3962 | + print $out; |
|
| 3963 | + } else {
|
|
| 3782 | 3964 | print Globals::$langs->trans("DolibarrHasDetectedError") . '. ';
|
| 3783 | 3965 | print Globals::$langs->trans("YouCanSetOptionDolibarrMainProdToZero");
|
| 3784 | 3966 | define("MAIN_CORE_ERROR", 1);
|
@@ -3801,16 +3983,18 @@ discard block |
||
| 3801 | 3983 | {
|
| 3802 | 3984 | // global Globals::$langs, Globals::$conf; |
| 3803 | 3985 | |
| 3804 | - if (empty($email)) |
|
| 3805 | - $email = Globals::$conf->global->MAIN_INFO_SOCIETE_MAIL; |
|
| 3986 | + if (empty($email)) { |
|
| 3987 | + $email = Globals::$conf->global->MAIN_INFO_SOCIETE_MAIL; |
|
| 3988 | + } |
|
| 3806 | 3989 | |
| 3807 | 3990 | Globals::$langs->load("errors");
|
| 3808 | 3991 | $now = dol_now(); |
| 3809 | 3992 | |
| 3810 | 3993 | print '<br><div class="center login_main_message"><div class="' . $morecss . '">'; |
| 3811 | 3994 | print Globals::$langs->trans("ErrorContactEMail", $email, $prefixcode . dol_print_date($now, '%Y%m%d'));
|
| 3812 | - if ($errormessage) |
|
| 3813 | - print '<br><br>' . $errormessage; |
|
| 3995 | + if ($errormessage) { |
|
| 3996 | + print '<br><br>' . $errormessage; |
|
| 3997 | + } |
|
| 3814 | 3998 | if (is_array($errormessages) && count($errormessages)) {
|
| 3815 | 3999 | foreach ($errormessages as $mesgtoshow) {
|
| 3816 | 4000 | print '<br><br>' . $mesgtoshow; |
@@ -4053,12 +4237,15 @@ discard block |
||
| 4053 | 4237 | $savtotalnboflines = $totalnboflines; |
| 4054 | 4238 | $totalnboflines = abs($totalnboflines); |
| 4055 | 4239 | |
| 4056 | - if ($picto == 'setup') |
|
| 4057 | - $picto = 'title_setup.png'; |
|
| 4058 | - if ((Globals::$conf->browser->name == 'ie') && $picto == 'title_generic.png') |
|
| 4059 | - $picto = 'title.gif'; |
|
| 4060 | - if ($limit < 0) |
|
| 4061 | - $limit = Globals::$conf->liste_limit; |
|
| 4240 | + if ($picto == 'setup') { |
|
| 4241 | + $picto = 'title_setup.png'; |
|
| 4242 | + } |
|
| 4243 | + if ((Globals::$conf->browser->name == 'ie') && $picto == 'title_generic.png') { |
|
| 4244 | + $picto = 'title.gif'; |
|
| 4245 | + } |
|
| 4246 | + if ($limit < 0) { |
|
| 4247 | + $limit = Globals::$conf->liste_limit; |
|
| 4248 | + } |
|
| 4062 | 4249 | if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
|
| 4063 | 4250 | $nextpage = 1; |
| 4064 | 4251 | } else {
|
@@ -4072,11 +4259,13 @@ discard block |
||
| 4072 | 4259 | // Left |
| 4073 | 4260 | //if ($picto && $titre) print '<td class="nobordernopadding hideonsmartphone" width="40" align="left" valign="middle">'.img_picto('', $picto, 'id="pictotitle"', $pictoisfullpath).'</td>';
|
| 4074 | 4261 | print '<td class="nobordernopadding valignmiddle">'; |
| 4075 | - if ($picto && $titre) |
|
| 4076 | - print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath);
|
|
| 4262 | + if ($picto && $titre) { |
|
| 4263 | + print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath); |
|
| 4264 | + } |
|
| 4077 | 4265 | print '<div class="titre inline-block">' . $titre; |
| 4078 | - if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') |
|
| 4079 | - print ' (' . $totalnboflines . ')';
|
|
| 4266 | + if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') { |
|
| 4267 | + print ' (' . $totalnboflines . ')'; |
|
| 4268 | + } |
|
| 4080 | 4269 | print '</div></td>'; |
| 4081 | 4270 | |
| 4082 | 4271 | // Center |
@@ -4086,21 +4275,24 @@ discard block |
||
| 4086 | 4275 | |
| 4087 | 4276 | // Right |
| 4088 | 4277 | print '<td class="nobordernopadding valignmiddle" align="right">'; |
| 4089 | - if ($sortfield) |
|
| 4090 | - $options .= "&sortfield=" . urlencode($sortfield); |
|
| 4091 | - if ($sortorder) |
|
| 4092 | - $options .= "&sortorder=" . urlencode($sortorder); |
|
| 4093 | -// Show navigation bar |
|
| 4278 | + if ($sortfield) { |
|
| 4279 | + $options .= "&sortfield=" . urlencode($sortfield); |
|
| 4280 | + } |
|
| 4281 | + if ($sortorder) { |
|
| 4282 | + $options .= "&sortorder=" . urlencode($sortorder); |
|
| 4283 | + } |
|
| 4284 | + // Show navigation bar |
|
| 4094 | 4285 | $pagelist = ''; |
| 4095 | 4286 | if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
|
| 4096 | 4287 | if ($totalnboflines) { // If we know total nb of lines
|
| 4097 | 4288 | // Define nb of extra page links before and after selected page + ... + first or last |
| 4098 | 4289 | $maxnbofpage = (empty(Globals::$conf->dol_optimize_smallscreen) ? 4 : 1); |
| 4099 | 4290 | |
| 4100 | - if ($limit > 0) |
|
| 4101 | - $nbpages = ceil($totalnboflines / $limit); |
|
| 4102 | - else |
|
| 4103 | - $nbpages = 1; |
|
| 4291 | + if ($limit > 0) { |
|
| 4292 | + $nbpages = ceil($totalnboflines / $limit); |
|
| 4293 | + } else { |
|
| 4294 | + $nbpages = 1; |
|
| 4295 | + } |
|
| 4104 | 4296 | $cpt = ($page - $maxnbofpage); |
| 4105 | 4297 | if ($cpt < 0) {
|
| 4106 | 4298 | $cpt = 0; |
@@ -4108,10 +4300,11 @@ discard block |
||
| 4108 | 4300 | |
| 4109 | 4301 | if ($cpt >= 1) {
|
| 4110 | 4302 | $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=0' . $options . '">1</a></li>'; |
| 4111 | - if ($cpt > 2) |
|
| 4112 | - $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
| 4113 | - else if ($cpt == 2) |
|
| 4114 | - $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>'; |
|
| 4303 | + if ($cpt > 2) { |
|
| 4304 | + $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
| 4305 | + } else if ($cpt == 2) { |
|
| 4306 | + $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>'; |
|
| 4307 | + } |
|
| 4115 | 4308 | } |
| 4116 | 4309 | |
| 4117 | 4310 | do {
|
@@ -4124,14 +4317,14 @@ discard block |
||
| 4124 | 4317 | } while ($cpt < $nbpages && $cpt <= $page + $maxnbofpage); |
| 4125 | 4318 | |
| 4126 | 4319 | if ($cpt < $nbpages) {
|
| 4127 | - if ($cpt < $nbpages - 2) |
|
| 4128 | - $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
| 4129 | - else if ($cpt == $nbpages - 2) |
|
| 4130 | - $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>'; |
|
| 4320 | + if ($cpt < $nbpages - 2) { |
|
| 4321 | + $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
| 4322 | + } else if ($cpt == $nbpages - 2) { |
|
| 4323 | + $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>'; |
|
| 4324 | + } |
|
| 4131 | 4325 | $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 1) . $options . '">' . $nbpages . '</a></li>'; |
| 4132 | 4326 | } |
| 4133 | - } |
|
| 4134 | - else {
|
|
| 4327 | + } else {
|
|
| 4135 | 4328 | $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="active"' : '') . '>' . ($page + 1) . "</li>"; |
| 4136 | 4329 | } |
| 4137 | 4330 | } |
@@ -4167,18 +4360,21 @@ discard block |
||
| 4167 | 4360 | $pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000'; |
| 4168 | 4361 | //$pagesizechoices.=',0:'.Globals::$langs->trans("All"); // Not yet supported
|
| 4169 | 4362 | //$pagesizechoices.=',2:2'; |
| 4170 | - if (!empty(Globals::$conf->global->MAIN_PAGESIZE_CHOICES)) |
|
| 4171 | - $pagesizechoices = Globals::$conf->global->MAIN_PAGESIZE_CHOICES; |
|
| 4363 | + if (!empty(Globals::$conf->global->MAIN_PAGESIZE_CHOICES)) { |
|
| 4364 | + $pagesizechoices = Globals::$conf->global->MAIN_PAGESIZE_CHOICES; |
|
| 4365 | + } |
|
| 4172 | 4366 | |
| 4173 | 4367 | print '<li class="pagination">'; |
| 4174 | 4368 | print '<select class="flat selectlimit" name="limit" title="' . dol_escape_htmltag(Globals::$langs->trans("MaxNbOfRecordPerPage")) . '">';
|
| 4175 | 4369 | $tmpchoice = explode(',', $pagesizechoices);
|
| 4176 | 4370 | $tmpkey = $limit . ':' . $limit; |
| 4177 | - if (!in_array($tmpkey, $tmpchoice)) |
|
| 4178 | - $tmpchoice[] = $tmpkey; |
|
| 4371 | + if (!in_array($tmpkey, $tmpchoice)) { |
|
| 4372 | + $tmpchoice[] = $tmpkey; |
|
| 4373 | + } |
|
| 4179 | 4374 | $tmpkey = Globals::$conf->liste_limit . ':' . Globals::$conf->liste_limit; |
| 4180 | - if (!in_array($tmpkey, $tmpchoice)) |
|
| 4181 | - $tmpchoice[] = $tmpkey; |
|
| 4375 | + if (!in_array($tmpkey, $tmpchoice)) { |
|
| 4376 | + $tmpchoice[] = $tmpkey; |
|
| 4377 | + } |
|
| 4182 | 4378 | asort($tmpchoice, SORT_NUMERIC); |
| 4183 | 4379 | $found = false; |
| 4184 | 4380 | foreach ($tmpchoice as $val) {
|
@@ -4254,14 +4450,15 @@ discard block |
||
| 4254 | 4450 | } |
| 4255 | 4451 | |
| 4256 | 4452 | // If rate is '9/9/9' we don't change it. If rate is '9.000' we apply price() |
| 4257 | - if (!preg_match('/\//', $rate))
|
|
| 4258 | - $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : ''); |
|
| 4259 | - else {
|
|
| 4453 | + if (!preg_match('/\//', $rate)) { |
|
| 4454 | + $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : ''); |
|
| 4455 | + } else {
|
|
| 4260 | 4456 | // TODO Split on / and output with a price2num to have clean numbers without ton of 000. |
| 4261 | 4457 | $ret = $rate . ($addpercent ? '%' : ''); |
| 4262 | 4458 | } |
| 4263 | - if (($info_bits & 1) && $usestarfornpr >= 0) |
|
| 4264 | - $ret .= ' *'; |
|
| 4459 | + if (($info_bits & 1) && $usestarfornpr >= 0) { |
|
| 4460 | + $ret .= ' *'; |
|
| 4461 | + } |
|
| 4265 | 4462 | $ret .= $morelabel; |
| 4266 | 4463 | return $ret; |
| 4267 | 4464 | } |
@@ -4285,11 +4482,14 @@ discard block |
||
| 4285 | 4482 | {
|
| 4286 | 4483 | // global Globals::$langs, Globals::$conf; |
| 4287 | 4484 | // Clean parameters |
| 4288 | - if (empty($amount)) |
|
| 4289 | - $amount = 0; // To have a numeric value if amount not defined or = '' |
|
| 4485 | + if (empty($amount)) { |
|
| 4486 | + $amount = 0; |
|
| 4487 | + } |
|
| 4488 | + // To have a numeric value if amount not defined or = '' |
|
| 4290 | 4489 | $amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) |
| 4291 | - if ($rounding < 0) |
|
| 4292 | - $rounding = min(Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT, Globals::$conf->global->MAIN_MAX_DECIMALS_TOT); |
|
| 4490 | + if ($rounding < 0) { |
|
| 4491 | + $rounding = min(Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT, Globals::$conf->global->MAIN_MAX_DECIMALS_TOT); |
|
| 4492 | + } |
|
| 4293 | 4493 | $nbdecimal = $rounding; |
| 4294 | 4494 | |
| 4295 | 4495 | // Output separators by default (french) |
@@ -4297,18 +4497,22 @@ discard block |
||
| 4297 | 4497 | $thousand = ' '; |
| 4298 | 4498 | |
| 4299 | 4499 | // If $outlangs not forced, we use use language |
| 4300 | - if (!is_object($outlangs)) |
|
| 4301 | - $outlangs = Globals::$langs; |
|
| 4302 | - |
|
| 4303 | - if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal")
|
|
| 4304 | - $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal");
|
|
| 4305 | - if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand")
|
|
| 4306 | - $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand");
|
|
| 4307 | - if ($thousand == 'None') |
|
| 4308 | - $thousand = ''; |
|
| 4309 | - else if ($thousand == 'Space') |
|
| 4310 | - $thousand = ' '; |
|
| 4311 | -//print "outlangs=".$outlangs->defaultlang." amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>"; |
|
| 4500 | + if (!is_object($outlangs)) { |
|
| 4501 | + $outlangs = Globals::$langs; |
|
| 4502 | + } |
|
| 4503 | + |
|
| 4504 | + if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") { |
|
| 4505 | + $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal"); |
|
| 4506 | + } |
|
| 4507 | + if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") { |
|
| 4508 | + $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand"); |
|
| 4509 | + } |
|
| 4510 | + if ($thousand == 'None') { |
|
| 4511 | + $thousand = ''; |
|
| 4512 | + } else if ($thousand == 'Space') { |
|
| 4513 | + $thousand = ' '; |
|
| 4514 | + } |
|
| 4515 | + //print "outlangs=".$outlangs->defaultlang." amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>"; |
|
| 4312 | 4516 | //print "amount=".$amount."-"; |
| 4313 | 4517 | $amount = str_replace(',', '.', $amount); // should be useless
|
| 4314 | 4518 | //print $amount."-"; |
@@ -4319,9 +4523,10 @@ discard block |
||
| 4319 | 4523 | $end = ''; |
| 4320 | 4524 | |
| 4321 | 4525 | // We increase nbdecimal if there is more decimal than asked (to not loose information) |
| 4322 | - if (dol_strlen($decpart) > $nbdecimal) |
|
| 4323 | - $nbdecimal = dol_strlen($decpart); |
|
| 4324 | -// Si on depasse max |
|
| 4526 | + if (dol_strlen($decpart) > $nbdecimal) { |
|
| 4527 | + $nbdecimal = dol_strlen($decpart); |
|
| 4528 | + } |
|
| 4529 | + // Si on depasse max |
|
| 4325 | 4530 | if ($trunc && $nbdecimal > Globals::$conf->global->MAIN_MAX_DECIMALS_SHOWN) {
|
| 4326 | 4531 | $nbdecimal = Globals::$conf->global->MAIN_MAX_DECIMALS_SHOWN; |
| 4327 | 4532 | if (preg_match('/\.\.\./i', Globals::$conf->global->MAIN_MAX_DECIMALS_SHOWN)) {
|
@@ -4331,8 +4536,9 @@ discard block |
||
| 4331 | 4536 | } |
| 4332 | 4537 | |
| 4333 | 4538 | // If force rounding |
| 4334 | - if ($forcerounding >= 0) |
|
| 4335 | - $nbdecimal = $forcerounding; |
|
| 4539 | + if ($forcerounding >= 0) { |
|
| 4540 | + $nbdecimal = $forcerounding; |
|
| 4541 | + } |
|
| 4336 | 4542 | |
| 4337 | 4543 | // Format number |
| 4338 | 4544 | $output = number_format($amount, $nbdecimal, $dec, $thousand); |
@@ -4343,13 +4549,14 @@ discard block |
||
| 4343 | 4549 | // Add symbol of currency if requested |
| 4344 | 4550 | $cursymbolbefore = $cursymbolafter = ''; |
| 4345 | 4551 | if ($currency_code) {
|
| 4346 | - if ($currency_code == 'auto') |
|
| 4347 | - $currency_code = Globals::$conf->currency; |
|
| 4552 | + if ($currency_code == 'auto') { |
|
| 4553 | + $currency_code = Globals::$conf->currency; |
|
| 4554 | + } |
|
| 4348 | 4555 | |
| 4349 | 4556 | $listofcurrenciesbefore = array('USD', 'GBP', 'AUD', 'MXN', 'PEN', 'CNY');
|
| 4350 | - if (in_array($currency_code, $listofcurrenciesbefore)) |
|
| 4351 | - $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code); |
|
| 4352 | - else {
|
|
| 4557 | + if (in_array($currency_code, $listofcurrenciesbefore)) { |
|
| 4558 | + $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code); |
|
| 4559 | + } else {
|
|
| 4353 | 4560 | $tmpcur = $outlangs->getCurrencySymbol($currency_code); |
| 4354 | 4561 | $cursymbolafter .= ($tmpcur == $currency_code ? ' ' . $tmpcur : $tmpcur); |
| 4355 | 4562 | } |
@@ -4382,15 +4589,18 @@ discard block |
||
| 4382 | 4589 | // Decimal delimiter for PHP and database SQL requests must be '.' |
| 4383 | 4590 | $dec = ','; |
| 4384 | 4591 | $thousand = ' '; |
| 4385 | - if (Globals::$langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal")
|
|
| 4386 | - $dec = Globals::$langs->transnoentitiesnoconv("SeparatorDecimal");
|
|
| 4387 | - if (Globals::$langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand")
|
|
| 4388 | - $thousand = Globals::$langs->transnoentitiesnoconv("SeparatorThousand");
|
|
| 4389 | - if ($thousand == 'None') |
|
| 4390 | - $thousand = ''; |
|
| 4391 | - elseif ($thousand == 'Space') |
|
| 4392 | - $thousand = ' '; |
|
| 4393 | -//print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>"; |
|
| 4592 | + if (Globals::$langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") { |
|
| 4593 | + $dec = Globals::$langs->transnoentitiesnoconv("SeparatorDecimal"); |
|
| 4594 | + } |
|
| 4595 | + if (Globals::$langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") { |
|
| 4596 | + $thousand = Globals::$langs->transnoentitiesnoconv("SeparatorThousand"); |
|
| 4597 | + } |
|
| 4598 | + if ($thousand == 'None') { |
|
| 4599 | + $thousand = ''; |
|
| 4600 | + } elseif ($thousand == 'Space') { |
|
| 4601 | + $thousand = ' '; |
|
| 4602 | + } |
|
| 4603 | + //print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>"; |
|
| 4394 | 4604 | // Convert value to universal number format (no thousand separator, '.' as decimal separator) |
| 4395 | 4605 | if ($alreadysqlnb != 1) { // If not a PHP number or unknown, we change format
|
| 4396 | 4606 | //print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>'; |
@@ -4405,8 +4615,10 @@ discard block |
||
| 4405 | 4615 | } |
| 4406 | 4616 | //print "QQ".$amount.'<br>'; |
| 4407 | 4617 | // Now make replace (the main goal of function) |
| 4408 | - if ($thousand != ',' && $thousand != '.') |
|
| 4409 | - $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
|
|
| 4618 | + if ($thousand != ',' && $thousand != '.') { |
|
| 4619 | + $amount = str_replace(',', '.', $amount); |
|
| 4620 | + } |
|
| 4621 | + // To accept 2 notations for french users |
|
| 4410 | 4622 | $amount = str_replace(' ', '', $amount); // To avoid spaces
|
| 4411 | 4623 | $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . |
| 4412 | 4624 | $amount = str_replace($dec, '.', $amount); |
@@ -4415,20 +4627,24 @@ discard block |
||
| 4415 | 4627 | // Now, make a rounding if required |
| 4416 | 4628 | if ($rounding) {
|
| 4417 | 4629 | $nbofdectoround = ''; |
| 4418 | - if ($rounding == 'MU') |
|
| 4419 | - $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT; |
|
| 4420 | - elseif ($rounding == 'MT') |
|
| 4421 | - $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_TOT; |
|
| 4422 | - elseif ($rounding == 'MS') |
|
| 4423 | - $nbofdectoround = empty(Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK; |
|
| 4424 | - elseif (is_numeric($rounding)) |
|
| 4425 | - $nbofdectoround = $rounding; |
|
| 4426 | -//print "RR".$amount.' - '.$nbofdectoround.'<br>'; |
|
| 4427 | - if (dol_strlen($nbofdectoround)) |
|
| 4428 | - $amount = round($amount, $nbofdectoround); // $nbofdectoround can be 0. |
|
| 4429 | - else |
|
| 4430 | - return 'ErrorBadParameterProvidedToFunction'; |
|
| 4431 | -//print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>'; |
|
| 4630 | + if ($rounding == 'MU') { |
|
| 4631 | + $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT; |
|
| 4632 | + } elseif ($rounding == 'MT') { |
|
| 4633 | + $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_TOT; |
|
| 4634 | + } elseif ($rounding == 'MS') { |
|
| 4635 | + $nbofdectoround = empty(Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK; |
|
| 4636 | + } elseif (is_numeric($rounding)) { |
|
| 4637 | + $nbofdectoround = $rounding; |
|
| 4638 | + } |
|
| 4639 | + //print "RR".$amount.' - '.$nbofdectoround.'<br>'; |
|
| 4640 | + if (dol_strlen($nbofdectoround)) { |
|
| 4641 | + $amount = round($amount, $nbofdectoround); |
|
| 4642 | + } |
|
| 4643 | + // $nbofdectoround can be 0. |
|
| 4644 | + else { |
|
| 4645 | + return 'ErrorBadParameterProvidedToFunction'; |
|
| 4646 | + } |
|
| 4647 | + //print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>'; |
|
| 4432 | 4648 | // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number |
| 4433 | 4649 | // to format defined by LC_NUMERIC after a calculation and we want source format to be defined by Dolibarr setup. |
| 4434 | 4650 | if (is_numeric($amount)) {
|
@@ -4441,8 +4657,10 @@ discard block |
||
| 4441 | 4657 | //print "TT".$amount.'<br>'; |
| 4442 | 4658 | // Always make replace because each math static function (like round) replace |
| 4443 | 4659 | // with local values and we want a number that has a SQL string format x.y |
| 4444 | - if ($thousand != ',' && $thousand != '.') |
|
| 4445 | - $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
|
|
| 4660 | + if ($thousand != ',' && $thousand != '.') { |
|
| 4661 | + $amount = str_replace(',', '.', $amount); |
|
| 4662 | + } |
|
| 4663 | + // To accept 2 notations for french users |
|
| 4446 | 4664 | $amount = str_replace(' ', '', $amount); // To avoid spaces
|
| 4447 | 4665 | $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . |
| 4448 | 4666 | $amount = str_replace($dec, '.', $amount); |
@@ -4501,8 +4719,9 @@ discard block |
||
| 4501 | 4719 | {
|
| 4502 | 4720 | // global $db, Globals::$conf, $mysoc; |
| 4503 | 4721 | |
| 4504 | - if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) |
|
| 4505 | - $thirdparty_seller = $mysoc; |
|
| 4722 | + if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) { |
|
| 4723 | + $thirdparty_seller = $mysoc; |
|
| 4724 | + } |
|
| 4506 | 4725 | |
| 4507 | 4726 | 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);
|
| 4508 | 4727 | |
@@ -4520,37 +4739,43 @@ discard block |
||
| 4520 | 4739 | // Some test to guess with no need to make database access |
| 4521 | 4740 | if ($mysoc->country_code == 'ES') { // For spain localtaxes 1 and 2, tax is qualified if buyer use local tax
|
| 4522 | 4741 | if ($local == 1) {
|
| 4523 | - if (!$mysoc->localtax1_assuj || (string) $vatratecleaned == "0") |
|
| 4524 | - return 0; |
|
| 4742 | + if (!$mysoc->localtax1_assuj || (string) $vatratecleaned == "0") { |
|
| 4743 | + return 0; |
|
| 4744 | + } |
|
| 4525 | 4745 | if ($thirdparty_seller->id == $mysoc->id) {
|
| 4526 | - if (!$thirdparty_buyer->localtax1_assuj) |
|
| 4527 | - return 0; |
|
| 4528 | - } |
|
| 4529 | - else {
|
|
| 4530 | - if (!$thirdparty_seller->localtax1_assuj) |
|
| 4531 | - return 0; |
|
| 4746 | + if (!$thirdparty_buyer->localtax1_assuj) { |
|
| 4747 | + return 0; |
|
| 4748 | + } |
|
| 4749 | + } else {
|
|
| 4750 | + if (!$thirdparty_seller->localtax1_assuj) { |
|
| 4751 | + return 0; |
|
| 4752 | + } |
|
| 4532 | 4753 | } |
| 4533 | 4754 | } |
| 4534 | 4755 | |
| 4535 | 4756 | if ($local == 2) {
|
| 4536 | 4757 | //if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0; |
| 4537 | - if (!$mysoc->localtax2_assuj) |
|
| 4538 | - return 0; // If main vat is 0, IRPF may be different than 0. |
|
| 4758 | + if (!$mysoc->localtax2_assuj) { |
|
| 4759 | + return 0; |
|
| 4760 | + } |
|
| 4761 | + // If main vat is 0, IRPF may be different than 0. |
|
| 4539 | 4762 | if ($thirdparty_seller->id == $mysoc->id) {
|
| 4540 | - if (!$thirdparty_buyer->localtax2_assuj) |
|
| 4541 | - return 0; |
|
| 4542 | - } |
|
| 4543 | - else {
|
|
| 4544 | - if (!$thirdparty_seller->localtax2_assuj) |
|
| 4545 | - return 0; |
|
| 4763 | + if (!$thirdparty_buyer->localtax2_assuj) { |
|
| 4764 | + return 0; |
|
| 4765 | + } |
|
| 4766 | + } else {
|
|
| 4767 | + if (!$thirdparty_seller->localtax2_assuj) { |
|
| 4768 | + return 0; |
|
| 4769 | + } |
|
| 4546 | 4770 | } |
| 4547 | 4771 | } |
| 4548 | - } |
|
| 4549 | - else {
|
|
| 4550 | - if ($local == 1 && !$thirdparty_seller->localtax1_assuj) |
|
| 4551 | - return 0; |
|
| 4552 | - if ($local == 2 && !$thirdparty_seller->localtax2_assuj) |
|
| 4553 | - return 0; |
|
| 4772 | + } else {
|
|
| 4773 | + if ($local == 1 && !$thirdparty_seller->localtax1_assuj) { |
|
| 4774 | + return 0; |
|
| 4775 | + } |
|
| 4776 | + if ($local == 2 && !$thirdparty_seller->localtax2_assuj) { |
|
| 4777 | + return 0; |
|
| 4778 | + } |
|
| 4554 | 4779 | } |
| 4555 | 4780 | |
| 4556 | 4781 | // For some country MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY is forced to on. |
@@ -4592,19 +4817,23 @@ discard block |
||
| 4592 | 4817 | $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c"; |
| 4593 | 4818 | $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $thirdparty_seller->country_code . "'"; |
| 4594 | 4819 | $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; |
| 4595 | - if ($vatratecode) |
|
| 4596 | - $sql .= " AND t.code ='" . $vatratecode . "'"; // If we have the code, we use it in priority |
|
| 4597 | - else |
|
| 4598 | - $sql .= " AND t.recuperableonly ='" . $vatnpr . "'"; |
|
| 4820 | + if ($vatratecode) { |
|
| 4821 | + $sql .= " AND t.code ='" . $vatratecode . "'"; |
|
| 4822 | + } |
|
| 4823 | + // If we have the code, we use it in priority |
|
| 4824 | + else { |
|
| 4825 | + $sql .= " AND t.recuperableonly ='" . $vatnpr . "'"; |
|
| 4826 | + } |
|
| 4599 | 4827 | dol_syslog("get_localtax", LOG_DEBUG);
|
| 4600 | 4828 | $resql = $db->query($sql); |
| 4601 | 4829 | |
| 4602 | 4830 | if ($resql) {
|
| 4603 | 4831 | $obj = $db->fetch_object($resql); |
| 4604 | - if ($local == 1) |
|
| 4605 | - return $obj->localtax1; |
|
| 4606 | - elseif ($local == 2) |
|
| 4607 | - return $obj->localtax2; |
|
| 4832 | + if ($local == 1) { |
|
| 4833 | + return $obj->localtax1; |
|
| 4834 | + } elseif ($local == 2) { |
|
| 4835 | + return $obj->localtax2; |
|
| 4836 | + } |
|
| 4608 | 4837 | } |
| 4609 | 4838 | |
| 4610 | 4839 | return 0; |
@@ -4650,10 +4879,11 @@ discard block |
||
| 4650 | 4879 | $resql = $db->query($sql); |
| 4651 | 4880 | if ($resql) {
|
| 4652 | 4881 | $obj = $db->fetch_object($resql); |
| 4653 | - if ($local == 1) |
|
| 4654 | - return $obj->localtax1; |
|
| 4655 | - elseif ($local == 2) |
|
| 4656 | - return $obj->localtax2; |
|
| 4882 | + if ($local == 1) { |
|
| 4883 | + return $obj->localtax1; |
|
| 4884 | + } elseif ($local == 2) { |
|
| 4885 | + return $obj->localtax2; |
|
| 4886 | + } |
|
| 4657 | 4887 | } |
| 4658 | 4888 | |
| 4659 | 4889 | return 0; |
@@ -4679,9 +4909,9 @@ discard block |
||
| 4679 | 4909 | // Search local taxes |
| 4680 | 4910 | $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy"; |
| 4681 | 4911 | $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t"; |
| 4682 | - if ($firstparamisid) |
|
| 4683 | - $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
| 4684 | - else {
|
|
| 4912 | + if ($firstparamisid) { |
|
| 4913 | + $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
| 4914 | + } else {
|
|
| 4685 | 4915 | $vatratecleaned = $vatrate; |
| 4686 | 4916 | $vatratecode = ''; |
| 4687 | 4917 | if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) { // If vat is "xx (yy)"
|
@@ -4694,19 +4924,22 @@ discard block |
||
| 4694 | 4924 | else $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; */ |
| 4695 | 4925 | $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'"; |
| 4696 | 4926 | $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; |
| 4697 | - if ($vatratecode) |
|
| 4698 | - $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
| 4927 | + if ($vatratecode) { |
|
| 4928 | + $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
| 4929 | + } |
|
| 4699 | 4930 | } |
| 4700 | 4931 | |
| 4701 | 4932 | $resql = $db->query($sql); |
| 4702 | 4933 | if ($resql) {
|
| 4703 | 4934 | $obj = $db->fetch_object($resql); |
| 4704 | - if ($obj) |
|
| 4705 | - return array('rowid' => $obj->rowid, 'code' => $obj->code, 'rate' => $obj->rate, 'npr' => $obj->npr, 'accountancy_code_sell' => $obj->accountancy_code_sell, 'accountancy_code_buy' => $obj->accountancy_code_buy);
|
|
| 4706 | - else |
|
| 4707 | - return array(); |
|
| 4708 | - } else |
|
| 4709 | - dol_print_error($db); |
|
| 4935 | + if ($obj) { |
|
| 4936 | + return array('rowid' => $obj->rowid, 'code' => $obj->code, 'rate' => $obj->rate, 'npr' => $obj->npr, 'accountancy_code_sell' => $obj->accountancy_code_sell, 'accountancy_code_buy' => $obj->accountancy_code_buy); |
|
| 4937 | + } else { |
|
| 4938 | + return array(); |
|
| 4939 | + } |
|
| 4940 | + } else { |
|
| 4941 | + dol_print_error($db); |
|
| 4942 | + } |
|
| 4710 | 4943 | |
| 4711 | 4944 | return array(); |
| 4712 | 4945 | } |
@@ -4736,9 +4969,9 @@ discard block |
||
| 4736 | 4969 | // Search local taxes |
| 4737 | 4970 | $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; |
| 4738 | 4971 | $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t"; |
| 4739 | - if ($firstparamisid) |
|
| 4740 | - $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
| 4741 | - else {
|
|
| 4972 | + if ($firstparamisid) { |
|
| 4973 | + $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
| 4974 | + } else {
|
|
| 4742 | 4975 | $vatratecleaned = $vatrate; |
| 4743 | 4976 | $vatratecode = ''; |
| 4744 | 4977 | if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) { // If vat is "x.x (yy)"
|
@@ -4747,13 +4980,17 @@ discard block |
||
| 4747 | 4980 | } |
| 4748 | 4981 | |
| 4749 | 4982 | $sql .= ", " . MAIN_DB_PREFIX . "c_country as c"; |
| 4750 | - if ($mysoc->country_code == 'ES') |
|
| 4751 | - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'"; // local tax in spain use the buyer country ?? |
|
| 4752 | - else |
|
| 4753 | - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'"; |
|
| 4983 | + if ($mysoc->country_code == 'ES') { |
|
| 4984 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'"; |
|
| 4985 | + } |
|
| 4986 | + // local tax in spain use the buyer country ?? |
|
| 4987 | + else { |
|
| 4988 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'"; |
|
| 4989 | + } |
|
| 4754 | 4990 | $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; |
| 4755 | - if ($vatratecode) |
|
| 4756 | - $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
| 4991 | + if ($vatratecode) { |
|
| 4992 | + $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
| 4993 | + } |
|
| 4757 | 4994 | } |
| 4758 | 4995 | |
| 4759 | 4996 | $resql = $db->query($sql); |
@@ -4799,17 +5036,17 @@ discard block |
||
| 4799 | 5036 | if ($idprodfournprice > 0) { // We want vat for product for a "supplier" object
|
| 4800 | 5037 | $product->get_buyprice($idprodfournprice, 0, 0, 0); |
| 4801 | 5038 | $ret = $product->vatrate_supplier; |
| 4802 | - if ($product->default_vat_code) |
|
| 4803 | - $ret .= ' (' . $product->default_vat_code . ')';
|
|
| 4804 | - } |
|
| 4805 | - else {
|
|
| 5039 | + if ($product->default_vat_code) { |
|
| 5040 | + $ret .= ' (' . $product->default_vat_code . ')'; |
|
| 5041 | + } |
|
| 5042 | + } else {
|
|
| 4806 | 5043 | $ret = $product->tva_tx; // Default vat of product we defined |
| 4807 | - if ($product->default_vat_code) |
|
| 4808 | - $ret .= ' (' . $product->default_vat_code . ')';
|
|
| 5044 | + if ($product->default_vat_code) { |
|
| 5045 | + $ret .= ' (' . $product->default_vat_code . ')'; |
|
| 5046 | + } |
|
| 4809 | 5047 | } |
| 4810 | 5048 | $found = 1; |
| 4811 | - } |
|
| 4812 | - else {
|
|
| 5049 | + } else {
|
|
| 4813 | 5050 | // TODO Read default product vat according to countrycode and product. Vat for couple countrycode/product is a feature not implemeted yet. |
| 4814 | 5051 | // May be usefull/required if hidden option SERVICE_ARE_ECOMMERCE_200238EC is on |
| 4815 | 5052 | } |
@@ -4829,14 +5066,18 @@ discard block |
||
| 4829 | 5066 | $obj = $db->fetch_object($resql); |
| 4830 | 5067 | if ($obj) {
|
| 4831 | 5068 | $ret = $obj->vat_rate; |
| 4832 | - if ($obj->default_vat_code) |
|
| 4833 | - $ret .= ' (' . $obj->default_vat_code . ')';
|
|
| 5069 | + if ($obj->default_vat_code) { |
|
| 5070 | + $ret .= ' (' . $obj->default_vat_code . ')'; |
|
| 5071 | + } |
|
| 4834 | 5072 | } |
| 4835 | 5073 | $db->free($sql); |
| 4836 | - } else |
|
| 4837 | - dol_print_error($db); |
|
| 4838 | - } else |
|
| 4839 | - $ret = Globals::$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; // Forced value if autodetect fails |
|
| 5074 | + } else { |
|
| 5075 | + dol_print_error($db); |
|
| 5076 | + } |
|
| 5077 | + } else { |
|
| 5078 | + $ret = Globals::$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; |
|
| 5079 | + } |
|
| 5080 | + // Forced value if autodetect fails |
|
| 4840 | 5081 | } |
| 4841 | 5082 | |
| 4842 | 5083 | dol_syslog("get_product_vat_for_country: ret=" . $ret);
|
@@ -4891,13 +5132,15 @@ discard block |
||
| 4891 | 5132 | if ($resql) {
|
| 4892 | 5133 | $obj = $db->fetch_object($resql); |
| 4893 | 5134 | if ($obj) {
|
| 4894 | - if ($local == 1) |
|
| 4895 | - $ret = $obj->localtax1; |
|
| 4896 | - elseif ($local == 2) |
|
| 4897 | - $ret = $obj->localtax2; |
|
| 5135 | + if ($local == 1) { |
|
| 5136 | + $ret = $obj->localtax1; |
|
| 5137 | + } elseif ($local == 2) { |
|
| 5138 | + $ret = $obj->localtax2; |
|
| 5139 | + } |
|
| 4898 | 5140 | } |
| 4899 | - } else |
|
| 4900 | - dol_print_error($db); |
|
| 5141 | + } else { |
|
| 5142 | + dol_print_error($db); |
|
| 5143 | + } |
|
| 4901 | 5144 | } |
| 4902 | 5145 | |
| 4903 | 5146 | dol_syslog("get_product_localtax_for_country: ret=" . $ret);
|
@@ -5000,15 +5243,16 @@ discard block |
||
| 5000 | 5243 | // global $db; |
| 5001 | 5244 | |
| 5002 | 5245 | if ($idprodfournprice > 0) {
|
| 5003 | - if (!class_exists('ProductFournisseur'))
|
|
| 5004 | - require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php'; |
|
| 5246 | + if (!class_exists('ProductFournisseur')) { |
|
| 5247 | + require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php'; |
|
| 5248 | + } |
|
| 5005 | 5249 | $prodprice = new ProductFournisseur($db); |
| 5006 | 5250 | $prodprice->fetch_product_fournisseur_price($idprodfournprice); |
| 5007 | 5251 | return $prodprice->fourn_tva_npr; |
| 5008 | - } |
|
| 5009 | - elseif ($idprod > 0) {
|
|
| 5010 | - if (!class_exists('Product'))
|
|
| 5011 | - require_once DOL_BASE_PATH . 'product/class/product.class.php'; |
|
| 5252 | + } elseif ($idprod > 0) {
|
|
| 5253 | + if (!class_exists('Product')) { |
|
| 5254 | + require_once DOL_BASE_PATH . 'product/class/product.class.php'; |
|
| 5255 | + } |
|
| 5012 | 5256 | $prod = new Product($db); |
| 5013 | 5257 | $prod->fetch($idprod); |
| 5014 | 5258 | return $prod->tva_npr; |
@@ -5034,30 +5278,35 @@ discard block |
||
| 5034 | 5278 | {
|
| 5035 | 5279 | // global $mysoc; |
| 5036 | 5280 | |
| 5037 | - if (!is_object($thirdparty_seller)) |
|
| 5038 | - return -1; |
|
| 5039 | - if (!is_object($thirdparty_buyer)) |
|
| 5040 | - return -1; |
|
| 5281 | + if (!is_object($thirdparty_seller)) { |
|
| 5282 | + return -1; |
|
| 5283 | + } |
|
| 5284 | + if (!is_object($thirdparty_buyer)) { |
|
| 5285 | + return -1; |
|
| 5286 | + } |
|
| 5041 | 5287 | |
| 5042 | 5288 | if ($local == 1) { // Localtax 1
|
| 5043 | 5289 | if ($mysoc->country_code == 'ES') {
|
| 5044 | - if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) |
|
| 5045 | - return 0; |
|
| 5046 | - } |
|
| 5047 | - else {
|
|
| 5290 | + if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) { |
|
| 5291 | + return 0; |
|
| 5292 | + } |
|
| 5293 | + } else {
|
|
| 5048 | 5294 | // Si vendeur non assujeti a Localtax1, localtax1 par default=0 |
| 5049 | - if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) |
|
| 5050 | - return 0; |
|
| 5051 | - if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off') |
|
| 5052 | - return 0; |
|
| 5053 | - } |
|
| 5054 | - } |
|
| 5055 | - elseif ($local == 2) { //I Localtax 2
|
|
| 5295 | + if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) { |
|
| 5296 | + return 0; |
|
| 5297 | + } |
|
| 5298 | + if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off') { |
|
| 5299 | + return 0; |
|
| 5300 | + } |
|
| 5301 | + } |
|
| 5302 | + } elseif ($local == 2) { //I Localtax 2
|
|
| 5056 | 5303 | // Si vendeur non assujeti a Localtax2, localtax2 par default=0 |
| 5057 | - if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) |
|
| 5058 | - return 0; |
|
| 5059 | - if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off') |
|
| 5060 | - return 0; |
|
| 5304 | + if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) { |
|
| 5305 | + return 0; |
|
| 5306 | + } |
|
| 5307 | + if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off') { |
|
| 5308 | + return 0; |
|
| 5309 | + } |
|
| 5061 | 5310 | } |
| 5062 | 5311 | |
| 5063 | 5312 | if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
|
@@ -5082,31 +5331,38 @@ discard block |
||
| 5082 | 5331 | $classname = ''; |
| 5083 | 5332 | if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') { // A mettre avant test sur no a cause du == 0
|
| 5084 | 5333 | $result = Globals::$langs->trans('yes');
|
| 5085 | - if ($case == 1 || $case == 3) |
|
| 5086 | - $result = Globals::$langs->trans("Yes");
|
|
| 5087 | - if ($case == 2) |
|
| 5088 | - $result = '<input type="checkbox" value="1" checked disabled>'; |
|
| 5089 | - if ($case == 3) |
|
| 5090 | - $result = '<input type="checkbox" value="1" checked disabled> ' . $result; |
|
| 5334 | + if ($case == 1 || $case == 3) { |
|
| 5335 | + $result = Globals::$langs->trans("Yes"); |
|
| 5336 | + } |
|
| 5337 | + if ($case == 2) { |
|
| 5338 | + $result = '<input type="checkbox" value="1" checked disabled>'; |
|
| 5339 | + } |
|
| 5340 | + if ($case == 3) { |
|
| 5341 | + $result = '<input type="checkbox" value="1" checked disabled> ' . $result; |
|
| 5342 | + } |
|
| 5091 | 5343 | |
| 5092 | 5344 | $classname = 'ok'; |
| 5093 | - } |
|
| 5094 | - elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') {
|
|
| 5345 | + } elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') {
|
|
| 5095 | 5346 | $result = Globals::$langs->trans("no");
|
| 5096 | - if ($case == 1 || $case == 3) |
|
| 5097 | - $result = Globals::$langs->trans("No");
|
|
| 5098 | - if ($case == 2) |
|
| 5099 | - $result = '<input type="checkbox" value="0" disabled>'; |
|
| 5100 | - if ($case == 3) |
|
| 5101 | - $result = '<input type="checkbox" value="0" disabled> ' . $result; |
|
| 5102 | - |
|
| 5103 | - if ($color == 2) |
|
| 5104 | - $classname = 'ok'; |
|
| 5105 | - else |
|
| 5106 | - $classname = 'error'; |
|
| 5107 | - } |
|
| 5108 | - if ($color) |
|
| 5109 | - return '<font class="' . $classname . '">' . $result . '</font>'; |
|
| 5347 | + if ($case == 1 || $case == 3) { |
|
| 5348 | + $result = Globals::$langs->trans("No"); |
|
| 5349 | + } |
|
| 5350 | + if ($case == 2) { |
|
| 5351 | + $result = '<input type="checkbox" value="0" disabled>'; |
|
| 5352 | + } |
|
| 5353 | + if ($case == 3) { |
|
| 5354 | + $result = '<input type="checkbox" value="0" disabled> ' . $result; |
|
| 5355 | + } |
|
| 5356 | + |
|
| 5357 | + if ($color == 2) { |
|
| 5358 | + $classname = 'ok'; |
|
| 5359 | + } else { |
|
| 5360 | + $classname = 'error'; |
|
| 5361 | + } |
|
| 5362 | + } |
|
| 5363 | + if ($color) { |
|
| 5364 | + return '<font class="' . $classname . '">' . $result . '</font>'; |
|
| 5365 | + } |
|
| 5110 | 5366 | return $result; |
| 5111 | 5367 | } |
| 5112 | 5368 | |
@@ -5132,23 +5388,27 @@ discard block |
||
| 5132 | 5388 | $path = ''; |
| 5133 | 5389 | |
| 5134 | 5390 | $arrayforoldpath = array('cheque', 'user', 'category', 'holiday', 'supplier_invoice', 'invoice_supplier', 'mailing', 'supplier_payment');
|
| 5135 | - if (!empty(Globals::$conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) |
|
| 5136 | - $arrayforoldpath[] = 'product'; |
|
| 5391 | + if (!empty(Globals::$conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { |
|
| 5392 | + $arrayforoldpath[] = 'product'; |
|
| 5393 | + } |
|
| 5137 | 5394 | if (!empty($level) && in_array($modulepart, $arrayforoldpath)) {
|
| 5138 | 5395 | // This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided. |
| 5139 | - if (empty($alpha)) |
|
| 5140 | - $num = preg_replace('/([^0-9])/i', '', $num);
|
|
| 5141 | - else |
|
| 5142 | - $num = preg_replace('/^.*\-/i', '', $num);
|
|
| 5396 | + if (empty($alpha)) { |
|
| 5397 | + $num = preg_replace('/([^0-9])/i', '', $num); |
|
| 5398 | + } else { |
|
| 5399 | + $num = preg_replace('/^.*\-/i', '', $num); |
|
| 5400 | + } |
|
| 5143 | 5401 | $num = substr("000" . $num, -$level);
|
| 5144 | - if ($level == 1) |
|
| 5145 | - $path = substr($num, 0, 1); |
|
| 5146 | - if ($level == 2) |
|
| 5147 | - $path = substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
| 5148 | - if ($level == 3) |
|
| 5149 | - $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
| 5150 | - } |
|
| 5151 | - else {
|
|
| 5402 | + if ($level == 1) { |
|
| 5403 | + $path = substr($num, 0, 1); |
|
| 5404 | + } |
|
| 5405 | + if ($level == 2) { |
|
| 5406 | + $path = substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
| 5407 | + } |
|
| 5408 | + if ($level == 3) { |
|
| 5409 | + $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
| 5410 | + } |
|
| 5411 | + } else {
|
|
| 5152 | 5412 | // TODO |
| 5153 | 5413 | // We will enhance here a common way of forging path for document storage |
| 5154 | 5414 | // Here, object->id, object->ref and modulepart are required. |
@@ -5159,8 +5419,9 @@ discard block |
||
| 5159 | 5419 | } |
| 5160 | 5420 | } |
| 5161 | 5421 | |
| 5162 | - if (empty($withoutslash) && !empty($path)) |
|
| 5163 | - $path .= '/'; |
|
| 5422 | + if (empty($withoutslash) && !empty($path)) { |
|
| 5423 | + $path .= '/'; |
|
| 5424 | + } |
|
| 5164 | 5425 | |
| 5165 | 5426 | return $path; |
| 5166 | 5427 | } |
@@ -5180,8 +5441,9 @@ discard block |
||
| 5180 | 5441 | dol_syslog("functions.lib::dol_mkdir: dir=" . $dir, LOG_INFO);
|
| 5181 | 5442 | |
| 5182 | 5443 | $dir_osencoded = dol_osencode($dir); |
| 5183 | - if (@is_dir($dir_osencoded)) |
|
| 5184 | - return 0; |
|
| 5444 | + if (@is_dir($dir_osencoded)) { |
|
| 5445 | + return 0; |
|
| 5446 | + } |
|
| 5185 | 5447 | |
| 5186 | 5448 | $nberr = 0; |
| 5187 | 5449 | $nbcreated = 0; |
@@ -5196,12 +5458,15 @@ discard block |
||
| 5196 | 5458 | $cdir = explode("/", $dir);
|
| 5197 | 5459 | $num = count($cdir); |
| 5198 | 5460 | for ($i = 0; $i < $num; $i++) {
|
| 5199 | - if ($i > 0) |
|
| 5200 | - $ccdir .= '/' . $cdir[$i]; |
|
| 5201 | - else |
|
| 5202 | - $ccdir .= $cdir[$i]; |
|
| 5203 | - if (preg_match("/^.:$/", $ccdir, $regs))
|
|
| 5204 | - continue; // Si chemin Windows incomplet, on poursuit par rep suivant |
|
| 5461 | + if ($i > 0) { |
|
| 5462 | + $ccdir .= '/' . $cdir[$i]; |
|
| 5463 | + } else { |
|
| 5464 | + $ccdir .= $cdir[$i]; |
|
| 5465 | + } |
|
| 5466 | + if (preg_match("/^.:$/", $ccdir, $regs)) { |
|
| 5467 | + continue; |
|
| 5468 | + } |
|
| 5469 | + // Si chemin Windows incomplet, on poursuit par rep suivant |
|
| 5205 | 5470 | |
| 5206 | 5471 | |
| 5207 | 5472 | |
@@ -5293,8 +5558,9 @@ discard block |
||
| 5293 | 5558 | */ |
| 5294 | 5559 | static function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = 'UTF-8', $strip_tags = 0) |
| 5295 | 5560 | {
|
| 5296 | - if ($removelinefeed == 2) |
|
| 5297 | - $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean);
|
|
| 5561 | + if ($removelinefeed == 2) { |
|
| 5562 | + $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean); |
|
| 5563 | + } |
|
| 5298 | 5564 | $temp = preg_replace('/<br[^>]*>/i', "\n", $stringtoclean);
|
| 5299 | 5565 | |
| 5300 | 5566 | if ($strip_tags) {
|
@@ -5311,8 +5577,9 @@ discard block |
||
| 5311 | 5577 | $temp = dol_html_entity_decode($temp, ENT_COMPAT, $pagecodeto); |
| 5312 | 5578 | |
| 5313 | 5579 | // Supprime aussi les retours |
| 5314 | - if ($removelinefeed == 1) |
|
| 5315 | - $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp);
|
|
| 5580 | + if ($removelinefeed == 1) { |
|
| 5581 | + $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp); |
|
| 5582 | + } |
|
| 5316 | 5583 | |
| 5317 | 5584 | // et les espaces doubles |
| 5318 | 5585 | while (strpos($temp, " ")) {
|
@@ -5398,18 +5665,21 @@ discard block |
||
| 5398 | 5665 | if ($charset == 'UTF-8') {
|
| 5399 | 5666 | $pattern = '/(<br[^>]*>)/Uu'; |
| 5400 | 5667 | } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support |
| 5401 | - else |
|
| 5402 | - $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. |
|
| 5668 | + else { |
|
| 5669 | + $pattern = '/(<br[^>]*>)/U'; |
|
| 5670 | + } |
|
| 5671 | + // /U is to have UNGREEDY regex to limit to one html tag. |
|
| 5403 | 5672 | $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 5404 | 5673 | |
| 5405 | 5674 | $firstline = ''; |
| 5406 | 5675 | $i = 0; |
| 5407 | 5676 | $nba = count($a); // 2x nb of lines in $a because $a contains also a line for each new line separator |
| 5408 | 5677 | while (($i < $nba) && ($i < ($nboflines * 2))) {
|
| 5409 | - if ($i % 2 == 0) |
|
| 5410 | - $firstline .= $a[$i]; |
|
| 5411 | - elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) |
|
| 5412 | - $firstline .= ($ishtml ? "<br>\n" : "\n"); |
|
| 5678 | + if ($i % 2 == 0) { |
|
| 5679 | + $firstline .= $a[$i]; |
|
| 5680 | + } elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) { |
|
| 5681 | + $firstline .= ($ishtml ? "<br>\n" : "\n"); |
|
| 5682 | + } |
|
| 5413 | 5683 | $i++; |
| 5414 | 5684 | } |
| 5415 | 5685 | unset($a); |
@@ -5458,15 +5728,18 @@ discard block |
||
| 5458 | 5728 | $newstring = $stringtoencode; |
| 5459 | 5729 | if (dol_textishtml($stringtoencode)) { // Check if text is already HTML or not
|
| 5460 | 5730 | $newstring = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $newstring); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF.
|
| 5461 | - if ($removelasteolbr) |
|
| 5462 | - $newstring = preg_replace('/<br>$/i', '', $newstring); // Remove last <br> (remove only last one)
|
|
| 5731 | + if ($removelasteolbr) { |
|
| 5732 | + $newstring = preg_replace('/<br>$/i', '', $newstring); |
|
| 5733 | + } |
|
| 5734 | + // Remove last <br> (remove only last one) |
|
| 5463 | 5735 | $newstring = strtr($newstring, array('&' => '__and__', '<' => '__lt__', '>' => '__gt__', '"' => '__dquot__'));
|
| 5464 | 5736 | $newstring = dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom); // Make entity encoding |
| 5465 | 5737 | $newstring = strtr($newstring, array('__and__' => '&', '__lt__' => '<', '__gt__' => '>', '__dquot__' => '"'));
|
| 5466 | - } |
|
| 5467 | - else {
|
|
| 5468 | - if ($removelasteolbr) |
|
| 5469 | - $newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring); // Remove last \n (may remove several)
|
|
| 5738 | + } else {
|
|
| 5739 | + if ($removelasteolbr) { |
|
| 5740 | + $newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring); |
|
| 5741 | + } |
|
| 5742 | + // Remove last \n (may remove several) |
|
| 5470 | 5743 | $newstring = dol_nl2br(dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom), $nl2brmode); |
| 5471 | 5744 | } |
| 5472 | 5745 | // Other substitutions that htmlentities does not do |
@@ -5568,8 +5841,9 @@ discard block |
||
| 5568 | 5841 | */ |
| 5569 | 5842 | static function dol_nboflines($s, $maxchar = 0) |
| 5570 | 5843 | {
|
| 5571 | - if ($s == '') |
|
| 5572 | - return 0; |
|
| 5844 | + if ($s == '') { |
|
| 5845 | + return 0; |
|
| 5846 | + } |
|
| 5573 | 5847 | $arraystring = explode("\n", $s);
|
| 5574 | 5848 | $nb = count($arraystring); |
| 5575 | 5849 | |
@@ -5588,15 +5862,18 @@ discard block |
||
| 5588 | 5862 | static function dol_nboflines_bis($text, $maxlinesize = 0, $charset = 'UTF-8') |
| 5589 | 5863 | {
|
| 5590 | 5864 | $repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " ");
|
| 5591 | - if (dol_textishtml($text)) |
|
| 5592 | - $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " ");
|
|
| 5865 | + if (dol_textishtml($text)) { |
|
| 5866 | + $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " "); |
|
| 5867 | + } |
|
| 5593 | 5868 | |
| 5594 | 5869 | $text = strtr($text, $repTable); |
| 5595 | 5870 | if ($charset == 'UTF-8') {
|
| 5596 | 5871 | $pattern = '/(<br[^>]*>)/Uu'; |
| 5597 | 5872 | } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support |
| 5598 | - else |
|
| 5599 | - $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. |
|
| 5873 | + else { |
|
| 5874 | + $pattern = '/(<br[^>]*>)/U'; |
|
| 5875 | + } |
|
| 5876 | + // /U is to have UNGREEDY regex to limit to one html tag. |
|
| 5600 | 5877 | $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 5601 | 5878 | |
| 5602 | 5879 | $nblines = (int) floor((count($a) + 1) / 2); |
@@ -5643,39 +5920,47 @@ discard block |
||
| 5643 | 5920 | static function dol_textishtml($msg, $option = 0) |
| 5644 | 5921 | {
|
| 5645 | 5922 | if ($option == 1) {
|
| 5646 | - if (preg_match('/<html/i', $msg))
|
|
| 5647 | - return true; |
|
| 5648 | - elseif (preg_match('/<body/i', $msg))
|
|
| 5649 | - return true; |
|
| 5650 | - elseif (preg_match('/<br/i', $msg))
|
|
| 5651 | - return true; |
|
| 5923 | + if (preg_match('/<html/i', $msg)) { |
|
| 5924 | + return true; |
|
| 5925 | + } elseif (preg_match('/<body/i', $msg)) { |
|
| 5926 | + return true; |
|
| 5927 | + } elseif (preg_match('/<br/i', $msg)) { |
|
| 5928 | + return true; |
|
| 5929 | + } |
|
| 5652 | 5930 | return false; |
| 5653 | - } |
|
| 5654 | - else {
|
|
| 5655 | - if (preg_match('/<html/i', $msg))
|
|
| 5656 | - return true; |
|
| 5657 | - elseif (preg_match('/<body/i', $msg))
|
|
| 5658 | - return true; |
|
| 5659 | - elseif (preg_match('/<(b|em|i|u)>/i', $msg))
|
|
| 5660 | - return true; |
|
| 5661 | - elseif (preg_match('/<br\/>/i', $msg))
|
|
| 5662 | - return true; |
|
| 5663 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg))
|
|
| 5664 | - return true; |
|
| 5665 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg))
|
|
| 5666 | - return true; |
|
| 5667 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg))
|
|
| 5668 | - return true; |
|
| 5669 | - elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i', $msg))
|
|
| 5670 | - return true; // must accept <img src="http://example.com/aaa.png" /> |
|
| 5671 | - elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i', $msg))
|
|
| 5672 | - return true; // must accept <a href="http://example.com/aaa.png" /> |
|
| 5673 | - elseif (preg_match('/<h[0-9]>/i', $msg))
|
|
| 5674 | - return true; |
|
| 5675 | - elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg))
|
|
| 5676 | - return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) |
|
| 5677 | - elseif (preg_match('/&#[0-9]{2,3};/i', $msg))
|
|
| 5678 | - return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) |
|
| 5931 | + } else {
|
|
| 5932 | + if (preg_match('/<html/i', $msg)) { |
|
| 5933 | + return true; |
|
| 5934 | + } elseif (preg_match('/<body/i', $msg)) { |
|
| 5935 | + return true; |
|
| 5936 | + } elseif (preg_match('/<(b|em|i|u)>/i', $msg)) { |
|
| 5937 | + return true; |
|
| 5938 | + } elseif (preg_match('/<br\/>/i', $msg)) { |
|
| 5939 | + return true; |
|
| 5940 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg)) { |
|
| 5941 | + return true; |
|
| 5942 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg)) { |
|
| 5943 | + return true; |
|
| 5944 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg)) { |
|
| 5945 | + return true; |
|
| 5946 | + } elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i', $msg)) { |
|
| 5947 | + return true; |
|
| 5948 | + } |
|
| 5949 | + // must accept <img src="http://example.com/aaa.png" /> |
|
| 5950 | + elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i', $msg)) { |
|
| 5951 | + return true; |
|
| 5952 | + } |
|
| 5953 | + // must accept <a href="http://example.com/aaa.png" /> |
|
| 5954 | + elseif (preg_match('/<h[0-9]>/i', $msg)) { |
|
| 5955 | + return true; |
|
| 5956 | + } elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg)) { |
|
| 5957 | + return true; |
|
| 5958 | + } |
|
| 5959 | + // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) |
|
| 5960 | + elseif (preg_match('/&#[0-9]{2,3};/i', $msg)) { |
|
| 5961 | + return true; |
|
| 5962 | + } |
|
| 5963 | + // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) |
|
| 5679 | 5964 | |
| 5680 | 5965 | return false; |
| 5681 | 5966 | } |
@@ -5827,12 +6112,14 @@ discard block |
||
| 5827 | 6112 | $birthday = dol_print_date($object->birth, 'day'); |
| 5828 | 6113 | |
| 5829 | 6114 | $substitutionarray['__MEMBER_ID__'] = $object->id; |
| 5830 | - if (method_exists($object, 'getCivilityLabel')) |
|
| 5831 | - $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); |
|
| 6115 | + if (method_exists($object, 'getCivilityLabel')) { |
|
| 6116 | + $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); |
|
| 6117 | + } |
|
| 5832 | 6118 | $substitutionarray['__MEMBER_FIRSTNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->firstname) : $object->firstname; |
| 5833 | 6119 | $substitutionarray['__MEMBER_LASTNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->lastname) : $object->lastname; |
| 5834 | - if (method_exists($object, 'getFullName')) |
|
| 5835 | - $substitutionarray['__MEMBER_FULLNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->getFullName($outputlangs)) : $object->getFullName($outputlangs); |
|
| 6120 | + if (method_exists($object, 'getFullName')) { |
|
| 6121 | + $substitutionarray['__MEMBER_FULLNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->getFullName($outputlangs)) : $object->getFullName($outputlangs); |
|
| 6122 | + } |
|
| 5836 | 6123 | $substitutionarray['__MEMBER_COMPANY__'] = $msgishtml ? dol_htmlentitiesbr($object->societe) : $object->societe; |
| 5837 | 6124 | $substitutionarray['__MEMBER_ADDRESS__'] = $msgishtml ? dol_htmlentitiesbr($object->address) : $object->address; |
| 5838 | 6125 | $substitutionarray['__MEMBER_ZIP__'] = $msgishtml ? dol_htmlentitiesbr($object->zip) : $object->zip; |
@@ -5880,10 +6167,12 @@ discard block |
||
| 5880 | 6167 | $dateplannedstart = ''; |
| 5881 | 6168 | $datenextexpiration = ''; |
| 5882 | 6169 | foreach ($object->lines as $line) {
|
| 5883 | - if ($line->date_ouverture_prevue > $dateplannedstart) |
|
| 5884 | - $dateplannedstart = $line->date_ouverture_prevue; |
|
| 5885 | - if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) |
|
| 5886 | - $datenextexpiration = $line->date_fin_prevue; |
|
| 6170 | + if ($line->date_ouverture_prevue > $dateplannedstart) { |
|
| 6171 | + $dateplannedstart = $line->date_ouverture_prevue; |
|
| 6172 | + } |
|
| 6173 | + if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) { |
|
| 6174 | + $datenextexpiration = $line->date_fin_prevue; |
|
| 6175 | + } |
|
| 5887 | 6176 | } |
| 5888 | 6177 | $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = dol_print_date($dateplannedstart, 'dayrfc'); |
| 5889 | 6178 | $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = dol_print_date($dateplannedstart, 'standard'); |
@@ -5893,8 +6182,9 @@ discard block |
||
| 5893 | 6182 | |
| 5894 | 6183 | // Create dynamic tags for __EXTRAFIELD_FIELD__ |
| 5895 | 6184 | if ($object->table_element && $object->id > 0) {
|
| 5896 | - if (!is_object($extrafields)) |
|
| 5897 | - $extrafields = new ExtraFields($db); |
|
| 6185 | + if (!is_object($extrafields)) { |
|
| 6186 | + $extrafields = new ExtraFields($db); |
|
| 6187 | + } |
|
| 5898 | 6188 | $extrafields->fetch_name_optionals_label($object->table_element, true); |
| 5899 | 6189 | |
| 5900 | 6190 | if ($object->fetch_optionals() > 0) {
|
@@ -5915,12 +6205,15 @@ discard block |
||
| 5915 | 6205 | require_once DOL_BASE_PATH . '/core/lib/payments.lib.php'; |
| 5916 | 6206 | $outputlangs->loadLangs(array('paypal', 'other'));
|
| 5917 | 6207 | $typeforonlinepayment = 'free'; |
| 5918 | - if (is_object($object) && $object->element == 'commande') |
|
| 5919 | - $typeforonlinepayment = 'order'; |
|
| 5920 | - if (is_object($object) && $object->element == 'facture') |
|
| 5921 | - $typeforonlinepayment = 'invoice'; |
|
| 5922 | - if (is_object($object) && $object->element == 'member') |
|
| 5923 | - $typeforonlinepayment = 'member'; |
|
| 6208 | + if (is_object($object) && $object->element == 'commande') { |
|
| 6209 | + $typeforonlinepayment = 'order'; |
|
| 6210 | + } |
|
| 6211 | + if (is_object($object) && $object->element == 'facture') { |
|
| 6212 | + $typeforonlinepayment = 'invoice'; |
|
| 6213 | + } |
|
| 6214 | + if (is_object($object) && $object->element == 'member') { |
|
| 6215 | + $typeforonlinepayment = 'member'; |
|
| 6216 | + } |
|
| 5924 | 6217 | $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray['__REF__']); |
| 5925 | 6218 | $paymenturl = $url; |
| 5926 | 6219 | } |
@@ -5930,16 +6223,19 @@ discard block |
||
| 5930 | 6223 | |
| 5931 | 6224 | if (!empty(Globals::$conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal') {
|
| 5932 | 6225 | $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element); |
| 5933 | - } else |
|
| 5934 | - $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = ''; |
|
| 6226 | + } else { |
|
| 6227 | + $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = ''; |
|
| 6228 | + } |
|
| 5935 | 6229 | if (!empty(Globals::$conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'commande') {
|
| 5936 | 6230 | $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element); |
| 5937 | - } else |
|
| 5938 | - $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = ''; |
|
| 6231 | + } else { |
|
| 6232 | + $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = ''; |
|
| 6233 | + } |
|
| 5939 | 6234 | if (!empty(Globals::$conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'facture') {
|
| 5940 | 6235 | $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element); |
| 5941 | - } else |
|
| 5942 | - $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = ''; |
|
| 6236 | + } else { |
|
| 6237 | + $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = ''; |
|
| 6238 | + } |
|
| 5943 | 6239 | } |
| 5944 | 6240 | } |
| 5945 | 6241 | if (empty($exclude) || !in_array('objectamount', $exclude)) {
|
@@ -5949,18 +6245,22 @@ discard block |
||
| 5949 | 6245 | $substitutionarray['__AMOUNT__'] = is_object($object) ? $object->total_ttc : ''; |
| 5950 | 6246 | $substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht : ''; |
| 5951 | 6247 | $substitutionarray['__AMOUNT_VAT__'] = is_object($object) ? ($object->total_vat ? $object->total_vat : $object->total_tva) : ''; |
| 5952 | - if ($onlykey != 2 || $mysoc->useLocalTax(1)) |
|
| 5953 | - $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : ''; |
|
| 5954 | - if ($onlykey != 2 || $mysoc->useLocalTax(2)) |
|
| 5955 | - $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : ''; |
|
| 6248 | + if ($onlykey != 2 || $mysoc->useLocalTax(1)) { |
|
| 6249 | + $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : ''; |
|
| 6250 | + } |
|
| 6251 | + if ($onlykey != 2 || $mysoc->useLocalTax(2)) { |
|
| 6252 | + $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : ''; |
|
| 6253 | + } |
|
| 5956 | 6254 | |
| 5957 | 6255 | $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object) ? price($object->total_ttc, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : ''; |
| 5958 | 6256 | $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object) ? price($object->total_ht, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : ''; |
| 5959 | 6257 | $substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object) ? ($object->total_vat ? price($object->total_vat, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : price($object->total_tva, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency)) : ''; |
| 5960 | - if ($onlykey != 2 || $mysoc->useLocalTax(1)) |
|
| 5961 | - $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : ''; |
|
| 5962 | - if ($onlykey != 2 || $mysoc->useLocalTax(2)) |
|
| 5963 | - $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : ''; |
|
| 6258 | + if ($onlykey != 2 || $mysoc->useLocalTax(1)) { |
|
| 6259 | + $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : ''; |
|
| 6260 | + } |
|
| 6261 | + if ($onlykey != 2 || $mysoc->useLocalTax(2)) { |
|
| 6262 | + $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : ''; |
|
| 6263 | + } |
|
| 5964 | 6264 | |
| 5965 | 6265 | // TODO Add keys for foreign multicurrency |
| 5966 | 6266 | // For backward compatibility |
@@ -6030,23 +6330,27 @@ discard block |
||
| 6030 | 6330 | {
|
| 6031 | 6331 | // global Globals::$conf, Globals::$langs; |
| 6032 | 6332 | |
| 6033 | - if (!is_array($substitutionarray)) |
|
| 6034 | - return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions'; |
|
| 6333 | + if (!is_array($substitutionarray)) { |
|
| 6334 | + return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions'; |
|
| 6335 | + } |
|
| 6035 | 6336 | |
| 6036 | - if (empty($outputlangs)) |
|
| 6037 | - $outputlangs = Globals::$langs; |
|
| 6337 | + if (empty($outputlangs)) { |
|
| 6338 | + $outputlangs = Globals::$langs; |
|
| 6339 | + } |
|
| 6038 | 6340 | |
| 6039 | 6341 | // Make substitution for language keys |
| 6040 | 6342 | if (is_object($outputlangs)) {
|
| 6041 | 6343 | while (preg_match('/__\(([^\)]+)\)__/', $text, $reg)) {
|
| 6042 | 6344 | $msgishtml = 0; |
| 6043 | - if (DolUtils::dol_textishtml($text, 1)) |
|
| 6044 | - $msgishtml = 1; |
|
| 6345 | + if (DolUtils::dol_textishtml($text, 1)) { |
|
| 6346 | + $msgishtml = 1; |
|
| 6347 | + } |
|
| 6045 | 6348 | |
| 6046 | 6349 | // If key is __(TranslationKey|langfile)__, then force load of langfile.lang |
| 6047 | 6350 | $tmp = explode('|', $reg[1]);
|
| 6048 | - if (!empty($tmp[1])) |
|
| 6049 | - $outputlangs->load($tmp[1]); |
|
| 6351 | + if (!empty($tmp[1])) { |
|
| 6352 | + $outputlangs->load($tmp[1]); |
|
| 6353 | + } |
|
| 6050 | 6354 | |
| 6051 | 6355 | $text = preg_replace('/__\(' . preg_quote($reg[1], '/') . '\)__/', $msgishtml ? dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])) : $outputlangs->transnoentitiesnoconv($reg[1]), $text);
|
| 6052 | 6356 | } |
@@ -6056,23 +6360,29 @@ discard block |
||
| 6056 | 6360 | // it is also converted. |
| 6057 | 6361 | while (preg_match('/__\[([^\]]+)\]__/', $text, $reg)) {
|
| 6058 | 6362 | $msgishtml = 0; |
| 6059 | - if (DolUtils::dol_textishtml($text, 1)) |
|
| 6060 | - $msgishtml = 1; |
|
| 6363 | + if (DolUtils::dol_textishtml($text, 1)) { |
|
| 6364 | + $msgishtml = 1; |
|
| 6365 | + } |
|
| 6061 | 6366 | |
| 6062 | 6367 | $keyfound = $reg[1]; |
| 6063 | - if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound))
|
|
| 6064 | - $newval = '*****forbidden*****'; |
|
| 6065 | - else |
|
| 6066 | - $newval = empty(Globals::$conf->global->$keyfound) ? '' : Globals::$conf->global->$keyfound; |
|
| 6368 | + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) { |
|
| 6369 | + $newval = '*****forbidden*****'; |
|
| 6370 | + } else { |
|
| 6371 | + $newval = empty(Globals::$conf->global->$keyfound) ? '' : Globals::$conf->global->$keyfound; |
|
| 6372 | + } |
|
| 6067 | 6373 | $text = preg_replace('/__\[' . preg_quote($keyfound, '/') . '\]__/', $msgishtml ? dol_htmlentitiesbr($newval) : $newval, $text);
|
| 6068 | 6374 | } |
| 6069 | 6375 | |
| 6070 | 6376 | // Make substitition for array $substitutionarray |
| 6071 | 6377 | foreach ($substitutionarray as $key => $value) {
|
| 6072 | - if ($key == '__SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) |
|
| 6073 | - $value = ''; // Protection |
|
| 6074 | - if ($key == '__USER_SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) |
|
| 6075 | - $value = ''; // Protection |
|
| 6378 | + if ($key == '__SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) { |
|
| 6379 | + $value = ''; |
|
| 6380 | + } |
|
| 6381 | + // Protection |
|
| 6382 | + if ($key == '__USER_SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) { |
|
| 6383 | + $value = ''; |
|
| 6384 | + } |
|
| 6385 | + // Protection |
|
| 6076 | 6386 | |
| 6077 | 6387 | $text = str_replace("$key", "$value", $text); // We must keep the " to work when value is 123.5 for example
|
| 6078 | 6388 | } |
@@ -6118,8 +6428,9 @@ discard block |
||
| 6118 | 6428 | $dir = dol_buildpath($reldir, 0); |
| 6119 | 6429 | |
| 6120 | 6430 | // Check if directory exists |
| 6121 | - if (!dol_is_dir($dir)) |
|
| 6122 | - continue; |
|
| 6431 | + if (!dol_is_dir($dir)) { |
|
| 6432 | + continue; |
|
| 6433 | + } |
|
| 6123 | 6434 | |
| 6124 | 6435 | $substitfiles = dol_dir_list($dir, 'files', 0, 'functions_'); |
| 6125 | 6436 | foreach ($substitfiles as $substitfile) {
|
@@ -6131,8 +6442,9 @@ discard block |
||
| 6131 | 6442 | require_once $dir . $substitfile['name']; |
| 6132 | 6443 | // Call the user's function, and only if it is defined |
| 6133 | 6444 | $function_name = $module . "_" . $callfunc; |
| 6134 | - if (function_exists($function_name)) |
|
| 6135 | - $function_name($substitutionarray, $outputlangs, $object, $parameters); |
|
| 6445 | + if (function_exists($function_name)) { |
|
| 6446 | + $function_name($substitutionarray, $outputlangs, $object, $parameters); |
|
| 6447 | + } |
|
| 6136 | 6448 | } |
| 6137 | 6449 | } |
| 6138 | 6450 | } |
@@ -6168,8 +6480,9 @@ discard block |
||
| 6168 | 6480 | |
| 6169 | 6481 | $out = ''; |
| 6170 | 6482 | |
| 6171 | - if (!is_object($outputlangs)) |
|
| 6172 | - $outputlangs = Globals::$langs; |
|
| 6483 | + if (!is_object($outputlangs)) { |
|
| 6484 | + $outputlangs = Globals::$langs; |
|
| 6485 | + } |
|
| 6173 | 6486 | |
| 6174 | 6487 | if ($date_start && $date_end) {
|
| 6175 | 6488 | $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($date_start, $format, false, $outputlangs), dol_print_date($date_end, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
|
@@ -6198,20 +6511,22 @@ discard block |
||
| 6198 | 6511 | |
| 6199 | 6512 | $ret = ''; |
| 6200 | 6513 | // If order not defined, we use the setup |
| 6201 | - if ($nameorder < 0) |
|
| 6202 | - $nameorder = (empty(Globals::$conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0); |
|
| 6514 | + if ($nameorder < 0) { |
|
| 6515 | + $nameorder = (empty(Globals::$conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0); |
|
| 6516 | + } |
|
| 6203 | 6517 | if ($nameorder && ((string) $nameorder != '2')) {
|
| 6204 | 6518 | $ret .= $firstname; |
| 6205 | - if ($firstname && $lastname) |
|
| 6206 | - $ret .= ' '; |
|
| 6519 | + if ($firstname && $lastname) { |
|
| 6520 | + $ret .= ' '; |
|
| 6521 | + } |
|
| 6207 | 6522 | $ret .= $lastname; |
| 6208 | - } |
|
| 6209 | - else if ($nameorder == 2) {
|
|
| 6523 | + } else if ($nameorder == 2) {
|
|
| 6210 | 6524 | $ret .= $firstname; |
| 6211 | 6525 | } else {
|
| 6212 | 6526 | $ret .= $lastname; |
| 6213 | - if ($firstname && $lastname) |
|
| 6214 | - $ret .= ' '; |
|
| 6527 | + if ($firstname && $lastname) { |
|
| 6528 | + $ret .= ' '; |
|
| 6529 | + } |
|
| 6215 | 6530 | $ret .= $firstname; |
| 6216 | 6531 | } |
| 6217 | 6532 | return $ret; |
@@ -6231,13 +6546,14 @@ discard block |
||
| 6231 | 6546 | {
|
| 6232 | 6547 | //dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); This is not deprecated, it is used by setEventMessages function |
| 6233 | 6548 | if (!is_array($mesgs)) { // If mesgs is a string
|
| 6234 | - if ($mesgs) |
|
| 6235 | - $_SESSION['dol_events'][$style][] = $mesgs; |
|
| 6236 | - } |
|
| 6237 | - else { // If mesgs is an array
|
|
| 6549 | + if ($mesgs) { |
|
| 6550 | + $_SESSION['dol_events'][$style][] = $mesgs; |
|
| 6551 | + } |
|
| 6552 | + } else { // If mesgs is an array
|
|
| 6238 | 6553 | foreach ($mesgs as $mesg) {
|
| 6239 | - if ($mesg) |
|
| 6240 | - $_SESSION['dol_events'][$style][] = $mesg; |
|
| 6554 | + if ($mesg) { |
|
| 6555 | + $_SESSION['dol_events'][$style][] = $mesg; |
|
| 6556 | + } |
|
| 6241 | 6557 | } |
| 6242 | 6558 | } |
| 6243 | 6559 | } |
@@ -6257,13 +6573,16 @@ discard block |
||
| 6257 | 6573 | if (empty($mesg) && empty($mesgs)) {
|
| 6258 | 6574 | dol_syslog("Try to add a message in stack with empty message", LOG_WARNING);
|
| 6259 | 6575 | } else {
|
| 6260 | - if (!in_array((string) $style, array('mesgs', 'warnings', 'errors')))
|
|
| 6261 | - dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages');
|
|
| 6262 | - if (empty($mesgs)) |
|
| 6263 | - setEventMessage($mesg, $style); |
|
| 6264 | - else {
|
|
| 6265 | - if (!empty($mesg) && !in_array($mesg, $mesgs)) |
|
| 6266 | - setEventMessage($mesg, $style); // Add message string if not already into array |
|
| 6576 | + if (!in_array((string) $style, array('mesgs', 'warnings', 'errors'))) { |
|
| 6577 | + dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages'); |
|
| 6578 | + } |
|
| 6579 | + if (empty($mesgs)) { |
|
| 6580 | + setEventMessage($mesg, $style); |
|
| 6581 | + } else {
|
|
| 6582 | + if (!empty($mesg) && !in_array($mesg, $mesgs)) { |
|
| 6583 | + setEventMessage($mesg, $style); |
|
| 6584 | + } |
|
| 6585 | + // Add message string if not already into array |
|
| 6267 | 6586 | setEventMessage($mesgs, $style); |
| 6268 | 6587 | } |
| 6269 | 6588 | } |
@@ -6282,22 +6601,25 @@ discard block |
||
| 6282 | 6601 | {
|
| 6283 | 6602 | // Show mesgs |
| 6284 | 6603 | if (isset($_SESSION['dol_events']['mesgs'])) {
|
| 6285 | - if (empty($disabledoutputofmessages)) |
|
| 6286 | - dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']);
|
|
| 6604 | + if (empty($disabledoutputofmessages)) { |
|
| 6605 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']); |
|
| 6606 | + } |
|
| 6287 | 6607 | unset($_SESSION['dol_events']['mesgs']); |
| 6288 | 6608 | } |
| 6289 | 6609 | |
| 6290 | 6610 | // Show errors |
| 6291 | 6611 | if (isset($_SESSION['dol_events']['errors'])) {
|
| 6292 | - if (empty($disabledoutputofmessages)) |
|
| 6293 | - dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error');
|
|
| 6612 | + if (empty($disabledoutputofmessages)) { |
|
| 6613 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error'); |
|
| 6614 | + } |
|
| 6294 | 6615 | unset($_SESSION['dol_events']['errors']); |
| 6295 | 6616 | } |
| 6296 | 6617 | |
| 6297 | 6618 | // Show warnings |
| 6298 | 6619 | if (isset($_SESSION['dol_events']['warnings'])) {
|
| 6299 | - if (empty($disabledoutputofmessages)) |
|
| 6300 | - dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning');
|
|
| 6620 | + if (empty($disabledoutputofmessages)) { |
|
| 6621 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning'); |
|
| 6622 | + } |
|
| 6301 | 6623 | unset($_SESSION['dol_events']['warnings']); |
| 6302 | 6624 | } |
| 6303 | 6625 | } |
@@ -6338,8 +6660,9 @@ discard block |
||
| 6338 | 6660 | foreach ($mesgarray as $message) {
|
| 6339 | 6661 | $ret++; |
| 6340 | 6662 | $out .= Globals::$langs->trans($message); |
| 6341 | - if ($ret < count($mesgarray)) |
|
| 6342 | - $out .= "<br>\n"; |
|
| 6663 | + if ($ret < count($mesgarray)) { |
|
| 6664 | + $out .= "<br>\n"; |
|
| 6665 | + } |
|
| 6343 | 6666 | } |
| 6344 | 6667 | } |
| 6345 | 6668 | if ($mesgstring) {
|
@@ -6405,8 +6728,9 @@ discard block |
||
| 6405 | 6728 | */ |
| 6406 | 6729 | static function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'ok', $keepembedded = 0) |
| 6407 | 6730 | {
|
| 6408 | - if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) |
|
| 6409 | - return; |
|
| 6731 | + if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) { |
|
| 6732 | + return; |
|
| 6733 | + } |
|
| 6410 | 6734 | |
| 6411 | 6735 | $iserror = 0; |
| 6412 | 6736 | $iswarning = 0; |
@@ -6421,14 +6745,17 @@ discard block |
||
| 6421 | 6745 | break; |
| 6422 | 6746 | } |
| 6423 | 6747 | } |
| 6424 | - } else if ($mesgstring && preg_match('/class="error"/i', $mesgstring))
|
|
| 6425 | - $iserror++; |
|
| 6426 | - else if ($mesgstring && preg_match('/class="warning"/i', $mesgstring))
|
|
| 6427 | - $iswarning++; |
|
| 6428 | - if ($style == 'error') |
|
| 6429 | - $iserror++; |
|
| 6430 | - if ($style == 'warning') |
|
| 6431 | - $iswarning++; |
|
| 6748 | + } else if ($mesgstring && preg_match('/class="error"/i', $mesgstring)) { |
|
| 6749 | + $iserror++; |
|
| 6750 | + } else if ($mesgstring && preg_match('/class="warning"/i', $mesgstring)) { |
|
| 6751 | + $iswarning++; |
|
| 6752 | + } |
|
| 6753 | + if ($style == 'error') { |
|
| 6754 | + $iserror++; |
|
| 6755 | + } |
|
| 6756 | + if ($style == 'warning') { |
|
| 6757 | + $iswarning++; |
|
| 6758 | + } |
|
| 6432 | 6759 | |
| 6433 | 6760 | if ($iserror || $iswarning) {
|
| 6434 | 6761 | // Remove div from texts |
@@ -6447,8 +6774,9 @@ discard block |
||
| 6447 | 6774 | $mesgarray = $newmesgarray; |
| 6448 | 6775 | } |
| 6449 | 6776 | print get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ? 'error' : 'warning'), $keepembedded); |
| 6450 | - } else |
|
| 6451 | - print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded); |
|
| 6777 | + } else { |
|
| 6778 | + print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded); |
|
| 6779 | + } |
|
| 6452 | 6780 | } |
| 6453 | 6781 | |
| 6454 | 6782 | /** |
@@ -6489,15 +6817,17 @@ discard block |
||
| 6489 | 6817 | $sizearray = count($array); |
| 6490 | 6818 | if ($sizearray > 0) {
|
| 6491 | 6819 | $temp = array(); |
| 6492 | - foreach (array_keys($array) as $key) |
|
| 6493 | - $temp[$key] = $array[$key][$index]; |
|
| 6820 | + foreach (array_keys($array) as $key) { |
|
| 6821 | + $temp[$key] = $array[$key][$index]; |
|
| 6822 | + } |
|
| 6494 | 6823 | |
| 6495 | - if (!$natsort) |
|
| 6496 | - ($order == 'asc') ? asort($temp) : arsort($temp); |
|
| 6497 | - else {
|
|
| 6824 | + if (!$natsort) { |
|
| 6825 | + ($order == 'asc') ? asort($temp) : arsort($temp); |
|
| 6826 | + } else {
|
|
| 6498 | 6827 | ($case_sensitive) ? natsort($temp) : natcasesort($temp); |
| 6499 | - if ($order != 'asc') |
|
| 6500 | - $temp = array_reverse($temp, true); |
|
| 6828 | + if ($order != 'asc') { |
|
| 6829 | + $temp = array_reverse($temp, true); |
|
| 6830 | + } |
|
| 6501 | 6831 | } |
| 6502 | 6832 | |
| 6503 | 6833 | $sorted = array(); |
@@ -6523,23 +6853,38 @@ discard block |
||
| 6523 | 6853 | // We must use here a binary strlen static function (so not dol_strlen) |
| 6524 | 6854 | $strLength = dol_strlen($str); |
| 6525 | 6855 | for ($i = 0; $i < $strLength; $i++) {
|
| 6526 | - if (ord($str[$i]) < 0x80) |
|
| 6527 | - continue; // 0bbbbbbb |
|
| 6528 | - elseif ((ord($str[$i]) & 0xE0) == 0xC0) |
|
| 6529 | - $n = 1; // 110bbbbb |
|
| 6530 | - elseif ((ord($str[$i]) & 0xF0) == 0xE0) |
|
| 6531 | - $n = 2; // 1110bbbb |
|
| 6532 | - elseif ((ord($str[$i]) & 0xF8) == 0xF0) |
|
| 6533 | - $n = 3; // 11110bbb |
|
| 6534 | - elseif ((ord($str[$i]) & 0xFC) == 0xF8) |
|
| 6535 | - $n = 4; // 111110bb |
|
| 6536 | - elseif ((ord($str[$i]) & 0xFE) == 0xFC) |
|
| 6537 | - $n = 5; // 1111110b |
|
| 6538 | - else |
|
| 6539 | - return false; // Does not match any model |
|
| 6856 | + if (ord($str[$i]) < 0x80) { |
|
| 6857 | + continue; |
|
| 6858 | + } |
|
| 6859 | + // 0bbbbbbb |
|
| 6860 | + elseif ((ord($str[$i]) & 0xE0) == 0xC0) { |
|
| 6861 | + $n = 1; |
|
| 6862 | + } |
|
| 6863 | + // 110bbbbb |
|
| 6864 | + elseif ((ord($str[$i]) & 0xF0) == 0xE0) { |
|
| 6865 | + $n = 2; |
|
| 6866 | + } |
|
| 6867 | + // 1110bbbb |
|
| 6868 | + elseif ((ord($str[$i]) & 0xF8) == 0xF0) { |
|
| 6869 | + $n = 3; |
|
| 6870 | + } |
|
| 6871 | + // 11110bbb |
|
| 6872 | + elseif ((ord($str[$i]) & 0xFC) == 0xF8) { |
|
| 6873 | + $n = 4; |
|
| 6874 | + } |
|
| 6875 | + // 111110bb |
|
| 6876 | + elseif ((ord($str[$i]) & 0xFE) == 0xFC) { |
|
| 6877 | + $n = 5; |
|
| 6878 | + } |
|
| 6879 | + // 1111110b |
|
| 6880 | + else { |
|
| 6881 | + return false; |
|
| 6882 | + } |
|
| 6883 | + // Does not match any model |
|
| 6540 | 6884 | for ($j = 0; $j < $n; $j++) { // n bytes matching 10bbbbbb follow ?
|
| 6541 | - if (( ++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) |
|
| 6542 | - return false; |
|
| 6885 | + if (( ++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) { |
|
| 6886 | + return false; |
|
| 6887 | + } |
|
| 6543 | 6888 | } |
| 6544 | 6889 | } |
| 6545 | 6890 | return true; |
@@ -6557,15 +6902,21 @@ discard block |
||
| 6557 | 6902 | // global Globals::$conf; |
| 6558 | 6903 | |
| 6559 | 6904 | $tmp = ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0
|
| 6560 | - if (empty($tmp) && !empty($_SERVER["WINDIR"])) |
|
| 6561 | - $tmp = 'iso-8859-1'; // By default for windows |
|
| 6562 | - if (empty($tmp)) |
|
| 6563 | - $tmp = 'utf-8'; // By default for other |
|
| 6564 | - if (!empty(Globals::$conf->global->MAIN_FILESYSTEM_ENCODING)) |
|
| 6565 | - $tmp = Globals::$conf->global->MAIN_FILESYSTEM_ENCODING; |
|
| 6566 | - |
|
| 6567 | - if ($tmp == 'iso-8859-1') |
|
| 6568 | - return utf8_decode($str); |
|
| 6905 | + if (empty($tmp) && !empty($_SERVER["WINDIR"])) { |
|
| 6906 | + $tmp = 'iso-8859-1'; |
|
| 6907 | + } |
|
| 6908 | + // By default for windows |
|
| 6909 | + if (empty($tmp)) { |
|
| 6910 | + $tmp = 'utf-8'; |
|
| 6911 | + } |
|
| 6912 | + // By default for other |
|
| 6913 | + if (!empty(Globals::$conf->global->MAIN_FILESYSTEM_ENCODING)) { |
|
| 6914 | + $tmp = Globals::$conf->global->MAIN_FILESYSTEM_ENCODING; |
|
| 6915 | + } |
|
| 6916 | + |
|
| 6917 | + if ($tmp == 'iso-8859-1') { |
|
| 6918 | + return utf8_decode($str); |
|
| 6919 | + } |
|
| 6569 | 6920 | return $str; |
| 6570 | 6921 | } |
| 6571 | 6922 | |
@@ -6586,8 +6937,9 @@ discard block |
||
| 6586 | 6937 | {
|
| 6587 | 6938 | // global $cache_codes; |
| 6588 | 6939 | // If key empty |
| 6589 | - if ($key == '') |
|
| 6590 | - return ''; |
|
| 6940 | + if ($key == '') { |
|
| 6941 | + return ''; |
|
| 6942 | + } |
|
| 6591 | 6943 | |
| 6592 | 6944 | // Check in cache |
| 6593 | 6945 | if (isset($cache_codes[$tablename][$key][$fieldid])) { // Can be defined to 0 or ''
|
@@ -6599,20 +6951,21 @@ discard block |
||
| 6599 | 6951 | $sql = "SELECT " . $fieldid . " as valuetoget"; |
| 6600 | 6952 | $sql .= " FROM " . MAIN_DB_PREFIX . $tablename; |
| 6601 | 6953 | $sql .= " WHERE " . $fieldkey . " = '" . $db->escape($key) . "'"; |
| 6602 | - if (!empty($entityfilter)) |
|
| 6603 | - $sql .= " AND entity IN (" . getEntity($tablename) . ")";
|
|
| 6954 | + if (!empty($entityfilter)) { |
|
| 6955 | + $sql .= " AND entity IN (" . getEntity($tablename) . ")"; |
|
| 6956 | + } |
|
| 6604 | 6957 | |
| 6605 | 6958 | $resql = $db->query($sql); |
| 6606 | 6959 | if ($resql) {
|
| 6607 | 6960 | $obj = $db->fetch_object($resql); |
| 6608 | - if ($obj) |
|
| 6609 | - $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget; |
|
| 6610 | - else |
|
| 6611 | - $cache_codes[$tablename][$key][$fieldid] = ''; |
|
| 6961 | + if ($obj) { |
|
| 6962 | + $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget; |
|
| 6963 | + } else { |
|
| 6964 | + $cache_codes[$tablename][$key][$fieldid] = ''; |
|
| 6965 | + } |
|
| 6612 | 6966 | $db->free($resql); |
| 6613 | 6967 | return $cache_codes[$tablename][$key][$fieldid]; |
| 6614 | - } |
|
| 6615 | - else {
|
|
| 6968 | + } else {
|
|
| 6616 | 6969 | return -1; |
| 6617 | 6970 | } |
| 6618 | 6971 | } |
@@ -6658,16 +7011,17 @@ discard block |
||
| 6658 | 7011 | // global $soc; // For backward compatibility |
| 6659 | 7012 | //print $s."<br>\n"; |
| 6660 | 7013 | if ($returnvalue) {
|
| 6661 | - if ($hideerrors) |
|
| 6662 | - return @eval('return ' . $s . ';');
|
|
| 6663 | - else |
|
| 6664 | - return eval('return ' . $s . ';');
|
|
| 6665 | - } |
|
| 6666 | - else {
|
|
| 6667 | - if ($hideerrors) |
|
| 6668 | - @eval($s); |
|
| 6669 | - else |
|
| 6670 | - eval($s); |
|
| 7014 | + if ($hideerrors) { |
|
| 7015 | + return @eval('return ' . $s . ';'); |
|
| 7016 | + } else { |
|
| 7017 | + return eval('return ' . $s . ';'); |
|
| 7018 | + } |
|
| 7019 | + } else {
|
|
| 7020 | + if ($hideerrors) { |
|
| 7021 | + @eval($s); |
|
| 7022 | + } else { |
|
| 7023 | + eval($s); |
|
| 7024 | + } |
|
| 6671 | 7025 | } |
| 6672 | 7026 | } |
| 6673 | 7027 | |
@@ -6693,8 +7047,9 @@ discard block |
||
| 6693 | 7047 | {
|
| 6694 | 7048 | // global Globals::$langs; |
| 6695 | 7049 | |
| 6696 | - if (empty($codelang)) |
|
| 6697 | - return ''; |
|
| 7050 | + if (empty($codelang)) { |
|
| 7051 | + return ''; |
|
| 7052 | + } |
|
| 6698 | 7053 | |
| 6699 | 7054 | if ($codelang == 'auto') {
|
| 6700 | 7055 | return '<span class="fa fa-globe"></span>'; |
@@ -6708,9 +7063,9 @@ discard block |
||
| 6708 | 7063 | 'sv_SV' => 'se' |
| 6709 | 7064 | ); |
| 6710 | 7065 | |
| 6711 | - if (isset($langtocountryflag[$codelang])) |
|
| 6712 | - $flagImage = $langtocountryflag[$codelang]; |
|
| 6713 | - else {
|
|
| 7066 | + if (isset($langtocountryflag[$codelang])) { |
|
| 7067 | + $flagImage = $langtocountryflag[$codelang]; |
|
| 7068 | + } else {
|
|
| 6714 | 7069 | $tmparray = explode('_', $codelang);
|
| 6715 | 7070 | $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1]; |
| 6716 | 7071 | } |
@@ -6728,15 +7083,20 @@ discard block |
||
| 6728 | 7083 | {
|
| 6729 | 7084 | // global $mysoc; |
| 6730 | 7085 | |
| 6731 | - if (strtoupper($countrycode) == 'MQ') |
|
| 6732 | - return 'fr_CA'; |
|
| 6733 | - if (strtoupper($countrycode) == 'SE') |
|
| 6734 | - return 'sv_SE'; // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country |
|
| 7086 | + if (strtoupper($countrycode) == 'MQ') { |
|
| 7087 | + return 'fr_CA'; |
|
| 7088 | + } |
|
| 7089 | + if (strtoupper($countrycode) == 'SE') { |
|
| 7090 | + return 'sv_SE'; |
|
| 7091 | + } |
|
| 7092 | + // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country |
|
| 6735 | 7093 | if (strtoupper($countrycode) == 'CH') {
|
| 6736 | - if ($mysoc->country_code == 'FR') |
|
| 6737 | - return 'fr_CH'; |
|
| 6738 | - if ($mysoc->country_code == 'DE') |
|
| 6739 | - return 'de_CH'; |
|
| 7094 | + if ($mysoc->country_code == 'FR') { |
|
| 7095 | + return 'fr_CH'; |
|
| 7096 | + } |
|
| 7097 | + if ($mysoc->country_code == 'DE') { |
|
| 7098 | + return 'de_CH'; |
|
| 7099 | + } |
|
| 6740 | 7100 | } |
| 6741 | 7101 | |
| 6742 | 7102 | // Locale list taken from: |
@@ -6914,8 +7274,9 @@ discard block |
||
| 6914 | 7274 | ); |
| 6915 | 7275 | |
| 6916 | 7276 | $buildprimarykeytotest = strtolower($countrycode) . '-' . strtoupper($countrycode); |
| 6917 | - if (in_array($buildprimarykeytotest, $locales)) |
|
| 6918 | - return strtolower($countrycode) . '_' . strtoupper($countrycode); |
|
| 7277 | + if (in_array($buildprimarykeytotest, $locales)) { |
|
| 7278 | + return strtolower($countrycode) . '_' . strtoupper($countrycode); |
|
| 7279 | + } |
|
| 6919 | 7280 | |
| 6920 | 7281 | foreach ($locales as $locale) {
|
| 6921 | 7282 | $locale_language = locale_get_primary_language($locale); |
@@ -6969,18 +7330,21 @@ discard block |
||
| 6969 | 7330 | |
| 6970 | 7331 | if ($mode == 'add' && !preg_match('/^\-/', $values[1])) {
|
| 6971 | 7332 | if (count($values) == 6) { // new declaration with permissions: $value='objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'
|
| 6972 | - if ($values[0] != $type) |
|
| 6973 | - continue; |
|
| 7333 | + if ($values[0] != $type) { |
|
| 7334 | + continue; |
|
| 7335 | + } |
|
| 6974 | 7336 | |
| 6975 | 7337 | if (verifCond($values[4])) {
|
| 6976 | - if ($values[3]) |
|
| 6977 | - Globals::$langs->load($values[3]); |
|
| 7338 | + if ($values[3]) { |
|
| 7339 | + Globals::$langs->load($values[3]); |
|
| 7340 | + } |
|
| 6978 | 7341 | if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
|
| 6979 | 7342 | $substitutionarray = array(); |
| 6980 | 7343 | complete_substitutions_array($substitutionarray, Globals::$langs, $object, array('needforkey' => $values[2]));
|
| 6981 | 7344 | $label = make_substitutions($reg[1], $substitutionarray); |
| 6982 | - } else |
|
| 6983 | - $label = Globals::$langs->trans($values[2]); |
|
| 7345 | + } else { |
|
| 7346 | + $label = Globals::$langs->trans($values[2]); |
|
| 7347 | + } |
|
| 6984 | 7348 | |
| 6985 | 7349 | //$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]), 1);
|
| 6986 | 7350 | $head[$h][0] = BASE_URI . preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]);
|
@@ -6988,30 +7352,32 @@ discard block |
||
| 6988 | 7352 | $head[$h][2] = str_replace('+', '', $values[1]);
|
| 6989 | 7353 | $h++; |
| 6990 | 7354 | } |
| 6991 | - } |
|
| 6992 | - else if (count($values) == 5) { // deprecated
|
|
| 7355 | + } else if (count($values) == 5) { // deprecated
|
|
| 6993 | 7356 | dol_syslog('Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
|
| 6994 | 7357 | |
| 6995 | - if ($values[0] != $type) |
|
| 6996 | - continue; |
|
| 6997 | - if ($values[3]) |
|
| 6998 | - Globals::$langs->load($values[3]); |
|
| 7358 | + if ($values[0] != $type) { |
|
| 7359 | + continue; |
|
| 7360 | + } |
|
| 7361 | + if ($values[3]) { |
|
| 7362 | + Globals::$langs->load($values[3]); |
|
| 7363 | + } |
|
| 6999 | 7364 | if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
|
| 7000 | 7365 | $substitutionarray = array(); |
| 7001 | 7366 | complete_substitutions_array($substitutionarray, Globals::$langs, $object, array('needforkey' => $values[2]));
|
| 7002 | 7367 | $label = make_substitutions($reg[1], $substitutionarray); |
| 7003 | - } else |
|
| 7004 | - $label = Globals::$langs->trans($values[2]); |
|
| 7368 | + } else { |
|
| 7369 | + $label = Globals::$langs->trans($values[2]); |
|
| 7370 | + } |
|
| 7005 | 7371 | |
| 7006 | 7372 | $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[4]), 1);
|
| 7007 | 7373 | $head[$h][1] = $label; |
| 7008 | 7374 | $head[$h][2] = str_replace('+', '', $values[1]);
|
| 7009 | 7375 | $h++; |
| 7010 | 7376 | } |
| 7011 | - } |
|
| 7012 | - else if ($mode == 'remove' && preg_match('/^\-/', $values[1])) {
|
|
| 7013 | - if ($values[0] != $type) |
|
| 7014 | - continue; |
|
| 7377 | + } else if ($mode == 'remove' && preg_match('/^\-/', $values[1])) {
|
|
| 7378 | + if ($values[0] != $type) { |
|
| 7379 | + continue; |
|
| 7380 | + } |
|
| 7015 | 7381 | $tabname = str_replace('-', '', $values[1]);
|
| 7016 | 7382 | foreach ($head as $key => $val) {
|
| 7017 | 7383 | $condition = (!empty($values[3]) ? verifCond($values[3]) : 1); |
@@ -7053,10 +7419,11 @@ discard block |
||
| 7053 | 7419 | // global $action; |
| 7054 | 7420 | // global $micro_start_time; |
| 7055 | 7421 | |
| 7056 | - if ($zone == 'private') |
|
| 7057 | - print "\n" . '<!-- Common footer for private page -->' . "\n"; |
|
| 7058 | - else |
|
| 7059 | - print "\n" . '<!-- Common footer for public page -->' . "\n"; |
|
| 7422 | + if ($zone == 'private') { |
|
| 7423 | + print "\n" . '<!-- Common footer for private page -->' . "\n"; |
|
| 7424 | + } else { |
|
| 7425 | + print "\n" . '<!-- Common footer for public page -->' . "\n"; |
|
| 7426 | + } |
|
| 7060 | 7427 | |
| 7061 | 7428 | // A div to store page_y POST parameter so we can read it using javascript |
| 7062 | 7429 | print "\n<!-- A div to store page_y POST paramater -->\n"; |
@@ -7065,8 +7432,9 @@ discard block |
||
| 7065 | 7432 | $parameters = array(); |
| 7066 | 7433 | $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters); // Note that $action and $object may have been modified by some hooks
|
| 7067 | 7434 | if (empty($reshook)) {
|
| 7068 | - if (!empty(Globals::$conf->global->MAIN_HTML_FOOTER)) |
|
| 7069 | - print Globals::$conf->global->MAIN_HTML_FOOTER . "\n"; |
|
| 7435 | + if (!empty(Globals::$conf->global->MAIN_HTML_FOOTER)) { |
|
| 7436 | + print Globals::$conf->global->MAIN_HTML_FOOTER . "\n"; |
|
| 7437 | + } |
|
| 7070 | 7438 | |
| 7071 | 7439 | print "\n"; |
| 7072 | 7440 | if (!empty(Globals::$conf->use_javascript_ajax)) {
|
@@ -7089,8 +7457,9 @@ discard block |
||
| 7089 | 7457 | print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */' . "\n"; |
| 7090 | 7458 | $relativepathstring = $_SERVER["PHP_SELF"]; |
| 7091 | 7459 | // Clean $relativepathstring |
| 7092 | - if (constant('DOL_BASE_URI'))
|
|
| 7093 | - $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
|
|
| 7460 | + if (constant('DOL_BASE_URI')) { |
|
| 7461 | + $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring); |
|
| 7462 | + } |
|
| 7094 | 7463 | $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
|
| 7095 | 7464 | $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
|
| 7096 | 7465 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
@@ -7101,14 +7470,17 @@ discard block |
||
| 7101 | 7470 | $tmpqueryarraytohave = explode('&', $defkey);
|
| 7102 | 7471 | $foundintru = 0; |
| 7103 | 7472 | foreach ($tmpqueryarraytohave as $tmpquerytohave) {
|
| 7104 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
| 7105 | - $foundintru = 1; |
|
| 7473 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
| 7474 | + $foundintru = 1; |
|
| 7475 | + } |
|
| 7106 | 7476 | } |
| 7107 | - if (!$foundintru) |
|
| 7108 | - $qualified = 1; |
|
| 7477 | + if (!$foundintru) { |
|
| 7478 | + $qualified = 1; |
|
| 7479 | + } |
|
| 7109 | 7480 | //var_dump($defkey.'-'.$qualified); |
| 7110 | - } else |
|
| 7111 | - $qualified = 1; |
|
| 7481 | + } else { |
|
| 7482 | + $qualified = 1; |
|
| 7483 | + } |
|
| 7112 | 7484 | |
| 7113 | 7485 | if ($qualified) {
|
| 7114 | 7486 | foreach ($defval as $paramkey => $paramval) {
|
@@ -7127,14 +7499,17 @@ discard block |
||
| 7127 | 7499 | $tmpqueryarraytohave = explode('&', $defkey);
|
| 7128 | 7500 | $foundintru = 0; |
| 7129 | 7501 | foreach ($tmpqueryarraytohave as $tmpquerytohave) {
|
| 7130 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
| 7131 | - $foundintru = 1; |
|
| 7502 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
| 7503 | + $foundintru = 1; |
|
| 7504 | + } |
|
| 7132 | 7505 | } |
| 7133 | - if (!$foundintru) |
|
| 7134 | - $qualified = 1; |
|
| 7506 | + if (!$foundintru) { |
|
| 7507 | + $qualified = 1; |
|
| 7508 | + } |
|
| 7135 | 7509 | //var_dump($defkey.'-'.$qualified); |
| 7136 | - } else |
|
| 7137 | - $qualified = 1; |
|
| 7510 | + } else { |
|
| 7511 | + $qualified = 1; |
|
| 7512 | + } |
|
| 7138 | 7513 | |
| 7139 | 7514 | if ($qualified) {
|
| 7140 | 7515 | foreach ($defval as $paramkey => $paramval) {
|
@@ -7173,8 +7548,9 @@ discard block |
||
| 7173 | 7548 | print "\n"; |
| 7174 | 7549 | print "/* JS CODE TO ENABLE to add memory info */\n"; |
| 7175 | 7550 | print 'window.console && console.log("';
|
| 7176 | - if (!empty(Globals::$conf->global->MEMCACHED_SERVER)) |
|
| 7177 | - print 'MEMCACHED_SERVER=' . Globals::$conf->global->MEMCACHED_SERVER . ' - '; |
|
| 7551 | + if (!empty(Globals::$conf->global->MEMCACHED_SERVER)) { |
|
| 7552 | + print 'MEMCACHED_SERVER=' . Globals::$conf->global->MEMCACHED_SERVER . ' - '; |
|
| 7553 | + } |
|
| 7178 | 7554 | print 'MAIN_OPTIMIZE_SPEED=' . (isset(Globals::$conf->global->MAIN_OPTIMIZE_SPEED) ? Globals::$conf->global->MAIN_OPTIMIZE_SPEED : 'off'); |
| 7179 | 7555 | if (!empty($micro_start_time)) { // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in// global variable.
|
| 7180 | 7556 | $micro_end_time = microtime(true); |
@@ -7304,8 +7680,9 @@ discard block |
||
| 7304 | 7680 | |
| 7305 | 7681 | $crits = explode(' ', $value);
|
| 7306 | 7682 | $res = ''; |
| 7307 | - if (!is_array($fields)) |
|
| 7308 | - $fields = array($fields); |
|
| 7683 | + if (!is_array($fields)) { |
|
| 7684 | + $fields = array($fields); |
|
| 7685 | + } |
|
| 7309 | 7686 | |
| 7310 | 7687 | $nboffields = count($fields); |
| 7311 | 7688 | $end2 = count($crits); |
@@ -7368,8 +7745,9 @@ discard block |
||
| 7368 | 7745 | $tmpcrits = explode('|', $crit);
|
| 7369 | 7746 | $i3 = 0; |
| 7370 | 7747 | foreach ($tmpcrits as $tmpcrit) {
|
| 7371 | - if (empty($tmpcrit)) |
|
| 7372 | - continue; |
|
| 7748 | + if (empty($tmpcrit)) { |
|
| 7749 | + continue; |
|
| 7750 | + } |
|
| 7373 | 7751 | |
| 7374 | 7752 | $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); |
| 7375 | 7753 | |
@@ -7405,8 +7783,9 @@ discard block |
||
| 7405 | 7783 | } |
| 7406 | 7784 | $i++; |
| 7407 | 7785 | } |
| 7408 | - if ($newres) |
|
| 7409 | - $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : '');
|
|
| 7786 | + if ($newres) { |
|
| 7787 | + $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : ''); |
|
| 7788 | + } |
|
| 7410 | 7789 | $j++; |
| 7411 | 7790 | } |
| 7412 | 7791 | $res = ($nofirstand ? "" : " AND ") . "(" . $res . ")";
|
@@ -7446,29 +7825,37 @@ discard block |
||
| 7446 | 7825 | static function getImageFileNameForSize($file, $extName, $extImgTarget = '') |
| 7447 | 7826 | {
|
| 7448 | 7827 | $dirName = dirname($file); |
| 7449 | - if ($dirName == '.') |
|
| 7450 | - $dirName = ''; |
|
| 7828 | + if ($dirName == '.') { |
|
| 7829 | + $dirName = ''; |
|
| 7830 | + } |
|
| 7451 | 7831 | |
| 7452 | 7832 | $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // We remove extension, whatever is its case
|
| 7453 | 7833 | $fileName = basename($fileName); |
| 7454 | 7834 | |
| 7455 | - if (empty($extImgTarget)) |
|
| 7456 | - $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : '');
|
|
| 7457 | - if (empty($extImgTarget)) |
|
| 7458 | - $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '');
|
|
| 7459 | - if (empty($extImgTarget)) |
|
| 7460 | - $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : '');
|
|
| 7461 | - if (empty($extImgTarget)) |
|
| 7462 | - $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : '');
|
|
| 7463 | - if (empty($extImgTarget)) |
|
| 7464 | - $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : '');
|
|
| 7465 | - |
|
| 7466 | - if (!$extImgTarget) |
|
| 7467 | - return $file; |
|
| 7835 | + if (empty($extImgTarget)) { |
|
| 7836 | + $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : ''); |
|
| 7837 | + } |
|
| 7838 | + if (empty($extImgTarget)) { |
|
| 7839 | + $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : ''); |
|
| 7840 | + } |
|
| 7841 | + if (empty($extImgTarget)) { |
|
| 7842 | + $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : ''); |
|
| 7843 | + } |
|
| 7844 | + if (empty($extImgTarget)) { |
|
| 7845 | + $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : ''); |
|
| 7846 | + } |
|
| 7847 | + if (empty($extImgTarget)) { |
|
| 7848 | + $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : ''); |
|
| 7849 | + } |
|
| 7850 | + |
|
| 7851 | + if (!$extImgTarget) { |
|
| 7852 | + return $file; |
|
| 7853 | + } |
|
| 7468 | 7854 | |
| 7469 | 7855 | $subdir = ''; |
| 7470 | - if ($extName) |
|
| 7471 | - $subdir = 'thumbs/'; |
|
| 7856 | + if ($extName) { |
|
| 7857 | + $subdir = 'thumbs/'; |
|
| 7858 | + } |
|
| 7472 | 7859 | |
| 7473 | 7860 | return ($dirName ? $dirName . '/' : '') . $subdir . $fileName . $extName . $extImgTarget; // New filename for thumb |
| 7474 | 7861 | } |
@@ -7486,8 +7873,9 @@ discard block |
||
| 7486 | 7873 | {
|
| 7487 | 7874 | // global Globals::$conf, Globals::$langs; |
| 7488 | 7875 | |
| 7489 | - if (empty(Globals::$conf->use_javascript_ajax)) |
|
| 7490 | - return ''; |
|
| 7876 | + if (empty(Globals::$conf->use_javascript_ajax)) { |
|
| 7877 | + return ''; |
|
| 7878 | + } |
|
| 7491 | 7879 | |
| 7492 | 7880 | $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'svg+xml');
|
| 7493 | 7881 | //$mime_preview[]='vnd.oasis.opendocument.presentation'; |
@@ -7495,17 +7883,19 @@ discard block |
||
| 7495 | 7883 | $num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview); |
| 7496 | 7884 | |
| 7497 | 7885 | if ($alldata == 1) {
|
| 7498 | - if ($num_mime !== false) |
|
| 7499 | - return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_BASE_URI . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''), 'mime' => dol_mimetype($relativepath),);
|
|
| 7500 | - else |
|
| 7501 | - return array(); |
|
| 7886 | + if ($num_mime !== false) { |
|
| 7887 | + return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_BASE_URI . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''), 'mime' => dol_mimetype($relativepath),); |
|
| 7888 | + } else { |
|
| 7889 | + return array(); |
|
| 7890 | + } |
|
| 7502 | 7891 | } |
| 7503 | 7892 | |
| 7504 | 7893 | // old behavior |
| 7505 | - if ($num_mime !== false) |
|
| 7506 | - return 'javascript:document_preview(\'' . dol_escape_js(DOL_BASE_URI . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : '')) . '\', \'' . dol_mimetype($relativepath) . '\', \'' . dol_escape_js(Globals::$langs->trans('Preview')) . '\')';
|
|
| 7507 | - else |
|
| 7508 | - return ''; |
|
| 7894 | + if ($num_mime !== false) { |
|
| 7895 | + return 'javascript:document_preview(\'' . dol_escape_js(DOL_BASE_URI . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : '')) . '\', \'' . dol_mimetype($relativepath) . '\', \'' . dol_escape_js(Globals::$langs->trans('Preview')) . '\')'; |
|
| 7896 | + } else { |
|
| 7897 | + return ''; |
|
| 7898 | + } |
|
| 7509 | 7899 | } |
| 7510 | 7900 | |
| 7511 | 7901 | /** |
@@ -7523,8 +7913,9 @@ discard block |
||
| 7523 | 7913 | jQuery("#' . $htmlname . '").click(function() { jQuery(this).select(); } );
|
| 7524 | 7914 | }); |
| 7525 | 7915 | </script>'; |
| 7526 | - if ($addlink) |
|
| 7527 | - $out .= ' <a href="' . $addlink . '" target="_blank">' . Globals::$langs->trans("Link") . '</a>';
|
|
| 7916 | + if ($addlink) { |
|
| 7917 | + $out .= ' <a href="' . $addlink . '" target="_blank">' . Globals::$langs->trans("Link") . '</a>'; |
|
| 7918 | + } |
|
| 7528 | 7919 | return $out; |
| 7529 | 7920 | } |
| 7530 | 7921 | |
@@ -7906,8 +8297,9 @@ discard block |
||
| 7906 | 8297 | if (!isset($dictvalues[$tablename])) {
|
| 7907 | 8298 | $dictvalues[$tablename] = array(); |
| 7908 | 8299 | $sql = 'SELECT * FROM ' . $tablename . ' WHERE 1'; |
| 7909 | - if ($checkentity) |
|
| 7910 | - $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')'; |
|
| 8300 | + if ($checkentity) { |
|
| 8301 | + $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')'; |
|
| 8302 | + } |
|
| 7911 | 8303 | |
| 7912 | 8304 | $resql = $db->query($sql); |
| 7913 | 8305 | if ($resql) {
|
@@ -7919,11 +8311,14 @@ discard block |
||
| 7919 | 8311 | } |
| 7920 | 8312 | } |
| 7921 | 8313 | |
| 7922 | - if (!empty($dictvalues[$tablename][$id])) |
|
| 7923 | - return $dictvalues[$tablename][$id]->{$field}; // Found
|
|
| 8314 | + if (!empty($dictvalues[$tablename][$id])) { |
|
| 8315 | + return $dictvalues[$tablename][$id]->{$field}; |
|
| 8316 | + } |
|
| 8317 | + // Found |
|
| 7924 | 8318 | else { // Not found
|
| 7925 | - if ($id > 0) |
|
| 7926 | - return $id; |
|
| 8319 | + if ($id > 0) { |
|
| 8320 | + return $id; |
|
| 8321 | + } |
|
| 7927 | 8322 | return ''; |
| 7928 | 8323 | } |
| 7929 | 8324 | } |
@@ -7953,8 +8348,9 @@ discard block |
||
| 7953 | 8348 | $b = hexdec($hexb); |
| 7954 | 8349 | } |
| 7955 | 8350 | $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm |
| 7956 | - if ($bright > 0.6) |
|
| 7957 | - $res = 1; |
|
| 8351 | + if ($bright > 0.6) { |
|
| 8352 | + $res = 1; |
|
| 8353 | + } |
|
| 7958 | 8354 | } |
| 7959 | 8355 | return $res; |
| 7960 | 8356 | } |
@@ -7972,8 +8368,10 @@ discard block |
||
| 7972 | 8368 | // global Globals::$conf; |
| 7973 | 8369 | //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms']; |
| 7974 | 8370 | //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal); |
| 7975 | - if (empty($menuentry['enabled'])) |
|
| 7976 | - return 0; // Entry disabled by condition |
|
| 8371 | + if (empty($menuentry['enabled'])) { |
|
| 8372 | + return 0; |
|
| 8373 | + } |
|
| 8374 | + // Entry disabled by condition |
|
| 7977 | 8375 | if ($type_user && $menuentry['module']) {
|
| 7978 | 8376 | $tmploops = explode('|', $menuentry['module']);
|
| 7979 | 8377 | $found = 0; |
@@ -7983,15 +8381,23 @@ discard block |
||
| 7983 | 8381 | break; |
| 7984 | 8382 | } |
| 7985 | 8383 | } |
| 7986 | - if (!$found) |
|
| 7987 | - return 0; // Entry is for menus all excluded to external users |
|
| 7988 | - } |
|
| 7989 | - if (!$menuentry['perms'] && $type_user) |
|
| 7990 | - return 0; // No permissions and user is external |
|
| 7991 | - if (!$menuentry['perms'] && !empty(Globals::$conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) |
|
| 7992 | - return 0; // No permissions and option to hide when not allowed, even for internal user, is on |
|
| 7993 | - if (!$menuentry['perms']) |
|
| 7994 | - return 2; // No permissions and user is external |
|
| 8384 | + if (!$found) { |
|
| 8385 | + return 0; |
|
| 8386 | + } |
|
| 8387 | + // Entry is for menus all excluded to external users |
|
| 8388 | + } |
|
| 8389 | + if (!$menuentry['perms'] && $type_user) { |
|
| 8390 | + return 0; |
|
| 8391 | + } |
|
| 8392 | + // No permissions and user is external |
|
| 8393 | + if (!$menuentry['perms'] && !empty(Globals::$conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { |
|
| 8394 | + return 0; |
|
| 8395 | + } |
|
| 8396 | + // No permissions and option to hide when not allowed, even for internal user, is on |
|
| 8397 | + if (!$menuentry['perms']) { |
|
| 8398 | + return 2; |
|
| 8399 | + } |
|
| 8400 | + // No permissions and user is external |
|
| 7995 | 8401 | return 1; |
| 7996 | 8402 | } |
| 7997 | 8403 | |
@@ -303,8 +303,9 @@ discard block |
||
| 303 | 303 | if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") {
|
| 304 | 304 | $classname = 'class="tmenusel"'; |
| 305 | 305 | $_SESSION['idmenu'] = ''; |
| 306 | - } else |
|
| 307 | - $classname = 'class="tmenu"'; |
|
| 306 | + } else { |
|
| 307 | + $classname = 'class="tmenu"'; |
|
| 308 | + } |
|
| 308 | 309 | $idsel = 'bank'; |
| 309 | 310 | |
| 310 | 311 | //$menu->add('/compta/bank/list.php?mainmenu=bank&leftmenu=', Globals::$langs->trans("MenuBankCash"), 0, $showmode, $atarget, "bank", '', 52, $id, $idsel, $classname);
|
@@ -1383,25 +1384,33 @@ discard block |
||
| 1383 | 1384 | $nature = ''; |
| 1384 | 1385 | |
| 1385 | 1386 | // Must match array $sourceList defined into journals_list.php |
| 1386 | - if ($objp->nature == 2 && !empty($conf->facture->enabled)) |
|
| 1387 | - $nature = "sells"; |
|
| 1388 | - if ($objp->nature == 3 && !empty($conf->fournisseur->enabled)) |
|
| 1389 | - $nature = "purchases"; |
|
| 1390 | - if ($objp->nature == 4 && !empty($conf->banque->enabled)) |
|
| 1391 | - $nature = "bank"; |
|
| 1392 | - if ($objp->nature == 5 && !empty($conf->expensereport->enabled)) |
|
| 1393 | - $nature = "expensereports"; |
|
| 1394 | - if ($objp->nature == 1) |
|
| 1395 | - $nature = "various"; |
|
| 1396 | - if ($objp->nature == 8) |
|
| 1397 | - $nature = "inventory"; |
|
| 1398 | - if ($objp->nature == 9) |
|
| 1399 | - $nature = "hasnew"; |
|
| 1387 | + if ($objp->nature == 2 && !empty($conf->facture->enabled)) { |
|
| 1388 | + $nature = "sells"; |
|
| 1389 | + } |
|
| 1390 | + if ($objp->nature == 3 && !empty($conf->fournisseur->enabled)) { |
|
| 1391 | + $nature = "purchases"; |
|
| 1392 | + } |
|
| 1393 | + if ($objp->nature == 4 && !empty($conf->banque->enabled)) { |
|
| 1394 | + $nature = "bank"; |
|
| 1395 | + } |
|
| 1396 | + if ($objp->nature == 5 && !empty($conf->expensereport->enabled)) { |
|
| 1397 | + $nature = "expensereports"; |
|
| 1398 | + } |
|
| 1399 | + if ($objp->nature == 1) { |
|
| 1400 | + $nature = "various"; |
|
| 1401 | + } |
|
| 1402 | + if ($objp->nature == 8) { |
|
| 1403 | + $nature = "inventory"; |
|
| 1404 | + } |
|
| 1405 | + if ($objp->nature == 9) { |
|
| 1406 | + $nature = "hasnew"; |
|
| 1407 | + } |
|
| 1400 | 1408 | |
| 1401 | 1409 | // To enable when page exists |
| 1402 | 1410 | if (empty(Conf::$global->ACCOUNTANCY_SHOW_DEVELOP_JOURNAL)) {
|
| 1403 | - if ($nature == 'various' || $nature == 'hasnew' || $nature == 'inventory') |
|
| 1404 | - $nature = ''; |
|
| 1411 | + if ($nature == 'various' || $nature == 'hasnew' || $nature == 'inventory') { |
|
| 1412 | + $nature = ''; |
|
| 1413 | + } |
|
| 1405 | 1414 | } |
| 1406 | 1415 | |
| 1407 | 1416 | if ($nature) {
|
@@ -1416,8 +1425,9 @@ discard block |
||
| 1416 | 1425 | // Should not happend. Entries are added |
| 1417 | 1426 | $newmenu->add('', Globals::$langs->trans("NoJournalDefined"), 2, Globals::$user->rights->accounting->comptarapport->lire);
|
| 1418 | 1427 | } |
| 1419 | - } else |
|
| 1420 | - dol_print_error(Config::$dbEngine); |
|
| 1428 | + } else { |
|
| 1429 | + dol_print_error(Config::$dbEngine); |
|
| 1430 | + } |
|
| 1421 | 1431 | Config::$dbEngine->free($resql); |
| 1422 | 1432 | } |
| 1423 | 1433 | |
@@ -1451,8 +1461,10 @@ discard block |
||
| 1451 | 1461 | } |
| 1452 | 1462 | |
| 1453 | 1463 | $modecompta = 'CREANCES-DETTES'; |
| 1454 | - if (!empty($conf->accounting->enabled) && !empty(Globals::$user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') |
|
| 1455 | - $modecompta = 'BOOKKEEPING'; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED |
|
| 1464 | + if (!empty($conf->accounting->enabled) && !empty(Globals::$user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') { |
|
| 1465 | + $modecompta = 'BOOKKEEPING'; |
|
| 1466 | + } |
|
| 1467 | + // Not yet implemented. Should be BOOKKEEPINGCOLLECTED |
|
| 1456 | 1468 | if ($modecompta) {
|
| 1457 | 1469 | if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
|
| 1458 | 1470 | /* |
@@ -189,15 +189,20 @@ discard block |
||
| 189 | 189 | if (!empty(Globals::$conf->global->MAIN_APPLICATION_TITLE)) { |
| 190 | 190 | $appli = Globals::$conf->global->MAIN_APPLICATION_TITLE; |
| 191 | 191 | if (preg_match('/\d\.\d/', $appli)) { |
| 192 | - if (!preg_match('/' . preg_quote(DOL_VERSION) . '/', $appli)) |
|
| 193 | - $appli .= " (" . DOL_VERSION . ")"; // If new title contains a version that is different than core |
|
| 194 | - } else |
|
| 195 | - $appli .= " " . DOL_VERSION; |
|
| 196 | - } else |
|
| 197 | - $appli .= " " . DOL_VERSION; |
|
| 192 | + if (!preg_match('/' . preg_quote(DOL_VERSION) . '/', $appli)) { |
|
| 193 | + $appli .= " (" . DOL_VERSION . ")"; |
|
| 194 | + } |
|
| 195 | + // If new title contains a version that is different than core |
|
| 196 | + } else { |
|
| 197 | + $appli .= " " . DOL_VERSION; |
|
| 198 | + } |
|
| 199 | + } else { |
|
| 200 | + $appli .= " " . DOL_VERSION; |
|
| 201 | + } |
|
| 198 | 202 | |
| 199 | - if (!empty(Globals::$conf->global->MAIN_FEATURES_LEVEL)) |
|
| 200 | - $appli .= "<br>" . Globals::$langs->trans("LevelOfFeature") . ': ' . Globals::$conf->global->MAIN_FEATURES_LEVEL; |
|
| 203 | + if (!empty(Globals::$conf->global->MAIN_FEATURES_LEVEL)) { |
|
| 204 | + $appli .= "<br>" . Globals::$langs->trans("LevelOfFeature") . ': ' . Globals::$conf->global->MAIN_FEATURES_LEVEL; |
|
| 205 | + } |
|
| 201 | 206 | |
| 202 | 207 | $logouttext = ''; |
| 203 | 208 | if (empty(Globals::$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { |
@@ -237,12 +242,15 @@ discard block |
||
| 237 | 242 | $parameters = array(); |
| 238 | 243 | $result = Globals::$hookManager->executeHooks('printTopRightMenu', $parameters); // Note that $action and $object may have been modified by some hooks |
| 239 | 244 | if (is_numeric($result)) { |
| 240 | - if ($result == 0) |
|
| 241 | - $toprightmenu .= Globals::$hookManager->resPrint; // add |
|
| 242 | - else |
|
| 243 | - $toprightmenu = Globals::$hookManager->resPrint; // replace |
|
| 244 | - } |
|
| 245 | - else { |
|
| 245 | + if ($result == 0) { |
|
| 246 | + $toprightmenu .= Globals::$hookManager->resPrint; |
|
| 247 | + } |
|
| 248 | + // add |
|
| 249 | + else { |
|
| 250 | + $toprightmenu = Globals::$hookManager->resPrint; |
|
| 251 | + } |
|
| 252 | + // replace |
|
| 253 | + } else { |
|
| 246 | 254 | $toprightmenu .= $result; // For backward compatibility |
| 247 | 255 | } |
| 248 | 256 | |
@@ -336,8 +344,9 @@ discard block |
||
| 336 | 344 | print "<!-- End top horizontal menu -->\n\n"; |
| 337 | 345 | } |
| 338 | 346 | |
| 339 | - if (empty(Globals::$conf->dol_hide_leftmenu) && empty(Globals::$conf->dol_use_jmobile)) |
|
| 340 | - print '<!-- Begin div id-container --><div id="id-container" class="id-container' . ($morecss ? ' ' . $morecss : '') . '">'; |
|
| 347 | + if (empty(Globals::$conf->dol_hide_leftmenu) && empty(Globals::$conf->dol_use_jmobile)) { |
|
| 348 | + print '<!-- Begin div id-container --><div id="id-container" class="id-container' . ($morecss ? ' ' . $morecss : '') . '">'; |
|
| 349 | + } |
|
| 341 | 350 | } |
| 342 | 351 | |
| 343 | 352 | /** |
@@ -362,8 +371,9 @@ discard block |
||
| 362 | 371 | $searchform = ''; |
| 363 | 372 | $bookmarks = ''; |
| 364 | 373 | |
| 365 | - if (!empty($menu_array_before)) |
|
| 366 | - dol_syslog("Deprecated parameter menu_array_before was used when calling main::left_menu function. Menu entries of module should now be defined into module descriptor and not provided when calling left_menu.", LOG_WARNING); |
|
| 374 | + if (!empty($menu_array_before)) { |
|
| 375 | + dol_syslog("Deprecated parameter menu_array_before was used when calling main::left_menu function. Menu entries of module should now be defined into module descriptor and not provided when calling left_menu.", LOG_WARNING); |
|
| 376 | + } |
|
| 367 | 377 | |
| 368 | 378 | if (empty(Globals::$conf->dol_hide_leftmenu) && (!defined('NOREQUIREMENU') || !constant('NOREQUIREMENU'))) { |
| 369 | 379 | // Instantiate hooks of thirdparty module |
@@ -371,8 +381,10 @@ discard block |
||
| 371 | 381 | |
| 372 | 382 | print "\n" . '<!-- Begin side-nav id-left -->' . "\n" . '<div class="side-nav"><div id="id-left">' . "\n"; |
| 373 | 383 | |
| 374 | - if (Globals::$conf->browser->layout == 'phone') |
|
| 375 | - Globals::$conf->global->MAIN_USE_OLD_SEARCH_FORM = 1; // Select into select2 is awfull on smartphone. TODO Is this still true with select2 v4 ? |
|
| 384 | + if (Globals::$conf->browser->layout == 'phone') { |
|
| 385 | + Globals::$conf->global->MAIN_USE_OLD_SEARCH_FORM = 1; |
|
| 386 | + } |
|
| 387 | + // Select into select2 is awfull on smartphone. TODO Is this still true with select2 v4 ? |
|
| 376 | 388 | |
| 377 | 389 | print "\n"; |
| 378 | 390 | |
@@ -399,8 +411,9 @@ discard block |
||
| 399 | 411 | $reshook = Globals::$hookManager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks |
| 400 | 412 | if (empty($reshook)) { |
| 401 | 413 | $searchform .= Globals::$hookManager->resPrint; |
| 402 | - } else |
|
| 403 | - $searchform = Globals::$hookManager->resPrint; |
|
| 414 | + } else { |
|
| 415 | + $searchform = Globals::$hookManager->resPrint; |
|
| 416 | + } |
|
| 404 | 417 | |
| 405 | 418 | // Force special value for $searchform |
| 406 | 419 | if (!empty(Globals::$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) || empty(Globals::$conf->use_javascript_ajax)) { |
@@ -444,38 +457,49 @@ discard block |
||
| 444 | 457 | if (empty(Globals::$conf->global->MAIN_HIDE_VERSION)) { // Version is already on help picto and on login page. |
| 445 | 458 | $doliurl = 'https://www.dolibarr.org'; |
| 446 | 459 | //local communities |
| 447 | - if (preg_match('/fr/i', Globals::$langs->defaultlang)) |
|
| 448 | - $doliurl = 'https://www.dolibarr.fr'; |
|
| 449 | - if (preg_match('/es/i', Globals::$langs->defaultlang)) |
|
| 450 | - $doliurl = 'https://www.dolibarr.es'; |
|
| 451 | - if (preg_match('/de/i', Globals::$langs->defaultlang)) |
|
| 452 | - $doliurl = 'https://www.dolibarr.de'; |
|
| 453 | - if (preg_match('/it/i', Globals::$langs->defaultlang)) |
|
| 454 | - $doliurl = 'https://www.dolibarr.it'; |
|
| 455 | - if (preg_match('/gr/i', Globals::$langs->defaultlang)) |
|
| 456 | - $doliurl = 'https://www.dolibarr.gr'; |
|
| 460 | + if (preg_match('/fr/i', Globals::$langs->defaultlang)) { |
|
| 461 | + $doliurl = 'https://www.dolibarr.fr'; |
|
| 462 | + } |
|
| 463 | + if (preg_match('/es/i', Globals::$langs->defaultlang)) { |
|
| 464 | + $doliurl = 'https://www.dolibarr.es'; |
|
| 465 | + } |
|
| 466 | + if (preg_match('/de/i', Globals::$langs->defaultlang)) { |
|
| 467 | + $doliurl = 'https://www.dolibarr.de'; |
|
| 468 | + } |
|
| 469 | + if (preg_match('/it/i', Globals::$langs->defaultlang)) { |
|
| 470 | + $doliurl = 'https://www.dolibarr.it'; |
|
| 471 | + } |
|
| 472 | + if (preg_match('/gr/i', Globals::$langs->defaultlang)) { |
|
| 473 | + $doliurl = 'https://www.dolibarr.gr'; |
|
| 474 | + } |
|
| 457 | 475 | |
| 458 | 476 | $appli = constant('DOL_APPLICATION_TITLE'); |
| 459 | 477 | if (!empty(Globals::$conf->global->MAIN_APPLICATION_TITLE)) { |
| 460 | 478 | $appli = Globals::$conf->global->MAIN_APPLICATION_TITLE; |
| 461 | 479 | $doliurl = ''; |
| 462 | 480 | if (preg_match('/\d\.\d/', $appli)) { |
| 463 | - if (!preg_match('/' . preg_quote(DOL_VERSION) . '/', $appli)) |
|
| 464 | - $appli .= " (" . DOL_VERSION . ")"; // If new title contains a version that is different than core |
|
| 465 | - } else |
|
| 466 | - $appli .= " " . DOL_VERSION; |
|
| 467 | - } else |
|
| 468 | - $appli .= " " . DOL_VERSION; |
|
| 481 | + if (!preg_match('/' . preg_quote(DOL_VERSION) . '/', $appli)) { |
|
| 482 | + $appli .= " (" . DOL_VERSION . ")"; |
|
| 483 | + } |
|
| 484 | + // If new title contains a version that is different than core |
|
| 485 | + } else { |
|
| 486 | + $appli .= " " . DOL_VERSION; |
|
| 487 | + } |
|
| 488 | + } else { |
|
| 489 | + $appli .= " " . DOL_VERSION; |
|
| 490 | + } |
|
| 469 | 491 | print '<div id="blockvmenuhelpapp" class="blockvmenuhelp">'; |
| 470 | - if ($doliurl) |
|
| 471 | - print '<a class="help" target="_blank" rel="noopener" href="' . $doliurl . '">'; |
|
| 472 | - else |
|
| 473 | - print '<span class="help">'; |
|
| 492 | + if ($doliurl) { |
|
| 493 | + print '<a class="help" target="_blank" rel="noopener" href="' . $doliurl . '">'; |
|
| 494 | + } else { |
|
| 495 | + print '<span class="help">'; |
|
| 496 | + } |
|
| 474 | 497 | print $appli; |
| 475 | - if ($doliurl) |
|
| 476 | - print '</a>'; |
|
| 477 | - else |
|
| 478 | - print '</span>'; |
|
| 498 | + if ($doliurl) { |
|
| 499 | + print '</a>'; |
|
| 500 | + } else { |
|
| 501 | + print '</span>'; |
|
| 502 | + } |
|
| 479 | 503 | print '</div>' . "\n"; |
| 480 | 504 | } |
| 481 | 505 | |
@@ -522,8 +546,9 @@ discard block |
||
| 522 | 546 | print "\n"; |
| 523 | 547 | print '<!-- Begin right area -->' . "\n"; |
| 524 | 548 | |
| 525 | - if (empty($leftmenuwithoutmainarea)) |
|
| 526 | - main_area($title); |
|
| 549 | + if (empty($leftmenuwithoutmainarea)) { |
|
| 550 | + main_area($title); |
|
| 551 | + } |
|
| 527 | 552 | } |
| 528 | 553 | |
| 529 | 554 | /** |
@@ -536,15 +561,17 @@ discard block |
||
| 536 | 561 | { |
| 537 | 562 | // global Globals::$conf, Globals::$langs; |
| 538 | 563 | |
| 539 | - if (empty(Globals::$conf->dol_hide_leftmenu)) |
|
| 540 | - print '<div id="id-right">'; |
|
| 564 | + if (empty(Globals::$conf->dol_hide_leftmenu)) { |
|
| 565 | + print '<div id="id-right">'; |
|
| 566 | + } |
|
| 541 | 567 | |
| 542 | 568 | print "\n"; |
| 543 | 569 | |
| 544 | 570 | print '<!-- Begin div class="fiche" -->' . "\n" . '<div class="fiche">' . "\n"; |
| 545 | 571 | |
| 546 | - if (!empty(Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED)) |
|
| 547 | - print info_admin(Globals::$langs->trans("WarningYouAreInMaintenanceMode", Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED)); |
|
| 572 | + if (!empty(Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { |
|
| 573 | + print info_admin(Globals::$langs->trans("WarningYouAreInMaintenanceMode", Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED)); |
|
| 574 | + } |
|
| 548 | 575 | } |
| 549 | 576 | |
| 550 | 577 | /** |
@@ -569,18 +596,21 @@ discard block |
||
| 569 | 596 | // If WIKI URL |
| 570 | 597 | if (preg_match('/^es/i', Globals::$langs->defaultlang)) { |
| 571 | 598 | $helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s'; |
| 572 | - if (preg_match('/ES:([^|]+)/i', $helppagename, $reg)) |
|
| 573 | - $helppage = $reg[1]; |
|
| 599 | + if (preg_match('/ES:([^|]+)/i', $helppagename, $reg)) { |
|
| 600 | + $helppage = $reg[1]; |
|
| 601 | + } |
|
| 574 | 602 | } |
| 575 | 603 | if (preg_match('/^fr/i', Globals::$langs->defaultlang)) { |
| 576 | 604 | $helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s'; |
| 577 | - if (preg_match('/FR:([^|]+)/i', $helppagename, $reg)) |
|
| 578 | - $helppage = $reg[1]; |
|
| 605 | + if (preg_match('/FR:([^|]+)/i', $helppagename, $reg)) { |
|
| 606 | + $helppage = $reg[1]; |
|
| 607 | + } |
|
| 579 | 608 | } |
| 580 | 609 | if (empty($helppage)) { // If help page not already found |
| 581 | 610 | $helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s'; |
| 582 | - if (preg_match('/EN:([^|]+)/i', $helppagename, $reg)) |
|
| 583 | - $helppage = $reg[1]; |
|
| 611 | + if (preg_match('/EN:([^|]+)/i', $helppagename, $reg)) { |
|
| 612 | + $helppage = $reg[1]; |
|
| 613 | + } |
|
| 584 | 614 | } |
| 585 | 615 | $mode = 'wiki'; |
| 586 | 616 | } |
@@ -611,8 +641,9 @@ discard block |
||
| 611 | 641 | $ret .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
| 612 | 642 | $ret .= '<input type="hidden" name="mode" value="search">'; |
| 613 | 643 | $ret .= '<input type="hidden" name="savelogin" value="' . dol_escape_htmltag(Globals::$user->login) . '">'; |
| 614 | - if ($showtitlebefore) |
|
| 615 | - $ret .= $title . ' '; |
|
| 644 | + if ($showtitlebefore) { |
|
| 645 | + $ret .= $title . ' '; |
|
| 646 | + } |
|
| 616 | 647 | $ret .= '<input type="text" class="flat ' . $htmlmorecss . '"'; |
| 617 | 648 | $ret .= ' style="text-indent: 22px; background-image: url(\'' . $img . '\'); background-repeat: no-repeat; background-position: 3px;"'; |
| 618 | 649 | $ret .= ($accesskey ? ' accesskey="' . $accesskey . '"' : ''); |
@@ -654,10 +685,12 @@ discard block |
||
| 654 | 685 | foreach (Globals::$user->lastsearch_values_tmp as $key => $val) { |
| 655 | 686 | unset($_SESSION['lastsearch_values_tmp_' . $key]); // Clean array to rebuild it just after |
| 656 | 687 | if (count($val) && empty($_POST['button_removefilter'])) { // If there is search criteria to save and we did not click on 'Clear filter' button |
| 657 | - if (empty($val['sortfield'])) |
|
| 658 | - unset($val['sortfield']); |
|
| 659 | - if (empty($val['sortorder'])) |
|
| 660 | - unset($val['sortorder']); |
|
| 688 | + if (empty($val['sortfield'])) { |
|
| 689 | + unset($val['sortfield']); |
|
| 690 | + } |
|
| 691 | + if (empty($val['sortorder'])) { |
|
| 692 | + unset($val['sortorder']); |
|
| 693 | + } |
|
| 661 | 694 | dol_syslog('Save lastsearch_values_tmp_' . $key . '=' . json_encode($val, 0) . " (systematic recording of last search criterias)"); |
| 662 | 695 | $_SESSION['lastsearch_values_tmp_' . $key] = json_encode($val); |
| 663 | 696 | unset($_SESSION['lastsearch_values_' . $key]); |
@@ -668,8 +701,9 @@ discard block |
||
| 668 | 701 | |
| 669 | 702 | $relativepathstring = $_SERVER["PHP_SELF"]; |
| 670 | 703 | // Clean $relativepathstring |
| 671 | - if (constant('DOL_BASE_URI')) |
|
| 672 | - $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring); |
|
| 704 | + if (constant('DOL_BASE_URI')) { |
|
| 705 | + $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring); |
|
| 706 | + } |
|
| 673 | 707 | $relativepathstring = preg_replace('/^\//', '', $relativepathstring); |
| 674 | 708 | $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); |
| 675 | 709 | if (preg_match('/list\.php$/', $relativepathstring)) { |
@@ -677,12 +711,15 @@ discard block |
||
| 677 | 711 | unset($_SESSION['lastsearch_page_tmp_' . $relativepathstring]); |
| 678 | 712 | unset($_SESSION['lastsearch_limit_tmp_' . $relativepathstring]); |
| 679 | 713 | |
| 680 | - if (!empty($contextpage)) |
|
| 681 | - $_SESSION['lastsearch_contextpage_tmp_' . $relativepathstring] = $contextpage; |
|
| 682 | - if (!empty($page) && $page > 1) |
|
| 683 | - $_SESSION['lastsearch_page_tmp_' . $relativepathstring] = $page; |
|
| 684 | - if (!empty($limit) && $limit != Globals::$conf->limit) |
|
| 685 | - $_SESSION['lastsearch_limit_tmp_' . $relativepathstring] = $limit; |
|
| 714 | + if (!empty($contextpage)) { |
|
| 715 | + $_SESSION['lastsearch_contextpage_tmp_' . $relativepathstring] = $contextpage; |
|
| 716 | + } |
|
| 717 | + if (!empty($page) && $page > 1) { |
|
| 718 | + $_SESSION['lastsearch_page_tmp_' . $relativepathstring] = $page; |
|
| 719 | + } |
|
| 720 | + if (!empty($limit) && $limit != Globals::$conf->limit) { |
|
| 721 | + $_SESSION['lastsearch_limit_tmp_' . $relativepathstring] = $limit; |
|
| 722 | + } |
|
| 686 | 723 | |
| 687 | 724 | unset($_SESSION['lastsearch_contextpage_' . $relativepathstring]); |
| 688 | 725 | unset($_SESSION['lastsearch_page_' . $relativepathstring]); |
@@ -709,20 +746,26 @@ discard block |
||
| 709 | 746 | |
| 710 | 747 | print '</div> <!-- End div class="fiche" -->' . "\n"; // End div fiche |
| 711 | 748 | |
| 712 | - if (empty(Globals::$conf->dol_hide_leftmenu)) |
|
| 713 | - print '</div> <!-- End div id-right -->' . "\n"; // End div id-right |
|
| 749 | + if (empty(Globals::$conf->dol_hide_leftmenu)) { |
|
| 750 | + print '</div> <!-- End div id-right -->' . "\n"; |
|
| 751 | + } |
|
| 752 | + // End div id-right |
|
| 714 | 753 | |
| 715 | - if (empty(Globals::$conf->dol_hide_leftmenu) && empty(Globals::$conf->dol_use_jmobile)) |
|
| 716 | - print '</div> <!-- End div id-container -->' . "\n"; // End div container |
|
| 754 | + if (empty(Globals::$conf->dol_hide_leftmenu) && empty(Globals::$conf->dol_use_jmobile)) { |
|
| 755 | + print '</div> <!-- End div id-container -->' . "\n"; |
|
| 756 | + } |
|
| 757 | + // End div container |
|
| 717 | 758 | |
| 718 | 759 | print "\n"; |
| 719 | - if ($comment) |
|
| 720 | - print '<!-- ' . $comment . ' -->' . "\n"; |
|
| 760 | + if ($comment) { |
|
| 761 | + print '<!-- ' . $comment . ' -->' . "\n"; |
|
| 762 | + } |
|
| 721 | 763 | |
| 722 | 764 | printCommonFooter($zone); |
| 723 | 765 | |
| 724 | - if (!empty($delayedhtmlcontent)) |
|
| 725 | - print $delayedhtmlcontent; |
|
| 766 | + if (!empty($delayedhtmlcontent)) { |
|
| 767 | + print $delayedhtmlcontent; |
|
| 768 | + } |
|
| 726 | 769 | |
| 727 | 770 | if (!empty(Globals::$conf->use_javascript_ajax)) { |
| 728 | 771 | print "\n" . '<!-- Includes JS Footer of Dolibarr -->' . "\n"; |
@@ -520,16 +520,17 @@ discard block |
||
| 520 | 520 | $nid = $obj->id; |
| 521 | 521 | |
| 522 | 522 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "user_rights WHERE fk_user = " . $this->id . " AND fk_id=" . $nid . " AND entity = " . $entity; |
| 523 | - if (!Config::$dbEngine->query($sql)) |
|
| 524 | - $error++; |
|
| 523 | + if (!Config::$dbEngine->query($sql)) { |
|
| 524 | + $error++; |
|
| 525 | + } |
|
| 525 | 526 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . "user_rights (entity, fk_user, fk_id) VALUES (" . $entity . ", " . $this->id . ", " . $nid . ")";
|
| 526 | - if (!Config::$dbEngine->query($sql)) |
|
| 527 | - $error++; |
|
| 527 | + if (!Config::$dbEngine->query($sql)) { |
|
| 528 | + $error++; |
|
| 529 | + } |
|
| 528 | 530 | |
| 529 | 531 | $i++; |
| 530 | 532 | } |
| 531 | - } |
|
| 532 | - else {
|
|
| 533 | + } else {
|
|
| 533 | 534 | $error++; |
| 534 | 535 | dol_print_error(Config::$dbEngine); |
| 535 | 536 | } |
@@ -2224,8 +2225,9 @@ discard block |
||
| 2224 | 2225 | } else {
|
| 2225 | 2226 | $result .= $this->getFullName(Globals::$langs, '', ($mode == 'firstname' ? 2 : -1), $maxlen); |
| 2226 | 2227 | } |
| 2227 | - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 2228 | - $result .= '</div>'; |
|
| 2228 | + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { |
|
| 2229 | + $result .= '</div>'; |
|
| 2230 | + } |
|
| 2229 | 2231 | } |
| 2230 | 2232 | $result .= (($option == 'nolink') ? '' : $linkend); |
| 2231 | 2233 | //if ($withpictoimg == -1) $result.='</div>'; |
@@ -156,27 +156,32 @@ discard block |
||
| 156 | 156 | $this->modules_parts[$partname] = array(); |
| 157 | 157 | } |
| 158 | 158 | $arrValue = json_decode($value, true); |
| 159 | - if (is_array($arrValue) && !empty($arrValue)) |
|
| 160 | - $value = $arrValue; |
|
| 161 | - else if (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl')))
|
|
| 162 | - $value = '/' . $modulename . '/core/' . $partname . '/'; |
|
| 163 | - else if (in_array($partname, array('models', 'theme')))
|
|
| 164 | - $value = '/' . $modulename . '/'; |
|
| 165 | - else if (in_array($partname, array('sms')))
|
|
| 166 | - $value = '/' . $modulename . '/'; |
|
| 167 | - else if ($value == 1) |
|
| 168 | - $value = '/' . $modulename . '/core/modules/' . $partname . '/'; // ex: partname = societe |
|
| 159 | + if (is_array($arrValue) && !empty($arrValue)) { |
|
| 160 | + $value = $arrValue; |
|
| 161 | + } else if (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl'))) { |
|
| 162 | + $value = '/' . $modulename . '/core/' . $partname . '/'; |
|
| 163 | + } else if (in_array($partname, array('models', 'theme'))) { |
|
| 164 | + $value = '/' . $modulename . '/'; |
|
| 165 | + } else if (in_array($partname, array('sms'))) { |
|
| 166 | + $value = '/' . $modulename . '/'; |
|
| 167 | + } else if ($value == 1) { |
|
| 168 | + $value = '/' . $modulename . '/core/modules/' . $partname . '/'; |
|
| 169 | + } |
|
| 170 | + // ex: partname = societe |
|
| 169 | 171 | $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array |
| 170 | 172 | } |
| 171 | 173 | // If this is a module constant (must be at end) |
| 172 | 174 | elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) {
|
| 173 | 175 | $modulename = strtolower($reg[1]); |
| 174 | - if ($modulename == 'propale') |
|
| 175 | - $modulename = 'propal'; |
|
| 176 | - if ($modulename == 'supplierproposal') |
|
| 177 | - $modulename = 'supplier_proposal'; |
|
| 178 | - if (!isset($this->$modulename) || !is_object($this->$modulename)) |
|
| 179 | - $this->$modulename = new \stdClass(); |
|
| 176 | + if ($modulename == 'propale') { |
|
| 177 | + $modulename = 'propal'; |
|
| 178 | + } |
|
| 179 | + if ($modulename == 'supplierproposal') { |
|
| 180 | + $modulename = 'supplier_proposal'; |
|
| 181 | + } |
|
| 182 | + if (!isset($this->$modulename) || !is_object($this->$modulename)) { |
|
| 183 | + $this->$modulename = new \stdClass(); |
|
| 184 | + } |
|
| 180 | 185 | $this->$modulename->enabled = true; |
| 181 | 186 | $this->modules[] = $modulename; // Add this module in list of enabled modules |
| 182 | 187 | } |
@@ -224,46 +229,60 @@ discard block |
||
| 224 | 229 | } |
| 225 | 230 | |
| 226 | 231 | // Clean some variables |
| 227 | - if (empty(Conf::$global->MAIN_MENU_STANDARD)) |
|
| 228 | - Conf::$global->MAIN_MENU_STANDARD = "eldy_menu.php"; |
|
| 229 | - if (empty(Conf::$global->MAIN_MENUFRONT_STANDARD)) |
|
| 230 | - Conf::$global->MAIN_MENUFRONT_STANDARD = "eldy_menu.php"; |
|
| 231 | - if (empty(Conf::$global->MAIN_MENU_SMARTPHONE)) |
|
| 232 | - Conf::$global->MAIN_MENU_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones |
|
| 233 | - if (empty(Conf::$global->MAIN_MENUFRONT_SMARTPHONE)) |
|
| 234 | - Conf::$global->MAIN_MENUFRONT_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones |
|
| 232 | + if (empty(Conf::$global->MAIN_MENU_STANDARD)) { |
|
| 233 | + Conf::$global->MAIN_MENU_STANDARD = "eldy_menu.php"; |
|
| 234 | + } |
|
| 235 | + if (empty(Conf::$global->MAIN_MENUFRONT_STANDARD)) { |
|
| 236 | + Conf::$global->MAIN_MENUFRONT_STANDARD = "eldy_menu.php"; |
|
| 237 | + } |
|
| 238 | + if (empty(Conf::$global->MAIN_MENU_SMARTPHONE)) { |
|
| 239 | + Conf::$global->MAIN_MENU_SMARTPHONE = "eldy_menu.php"; |
|
| 240 | + } |
|
| 241 | + // Use eldy by default because smartphone does not work on all phones |
|
| 242 | + if (empty(Conf::$global->MAIN_MENUFRONT_SMARTPHONE)) { |
|
| 243 | + Conf::$global->MAIN_MENUFRONT_SMARTPHONE = "eldy_menu.php"; |
|
| 244 | + } |
|
| 245 | + // Use eldy by default because smartphone does not work on all phones |
|
| 235 | 246 | |
| 236 | 247 | |
| 237 | 248 | |
| 238 | 249 | |
| 239 | 250 | // Clean var use vat for company |
| 240 | - if (!isset(Conf::$global->FACTURE_TVAOPTION)) |
|
| 241 | - Conf::$global->FACTURE_TVAOPTION = 1; |
|
| 242 | - else if (!empty(Conf::$global->FACTURE_TVAOPTION) && !is_numeric(Conf::$global->FACTURE_TVAOPTION)) {
|
|
| 251 | + if (!isset(Conf::$global->FACTURE_TVAOPTION)) { |
|
| 252 | + Conf::$global->FACTURE_TVAOPTION = 1; |
|
| 253 | + } else if (!empty(Conf::$global->FACTURE_TVAOPTION) && !is_numeric(Conf::$global->FACTURE_TVAOPTION)) {
|
|
| 243 | 254 | // Old value of option, we clean to use new value (0 or 1) |
| 244 | - if (Conf::$global->FACTURE_TVAOPTION != "franchise") |
|
| 245 | - Conf::$global->FACTURE_TVAOPTION = 1; |
|
| 246 | - else |
|
| 247 | - Conf::$global->FACTURE_TVAOPTION = 0; |
|
| 255 | + if (Conf::$global->FACTURE_TVAOPTION != "franchise") { |
|
| 256 | + Conf::$global->FACTURE_TVAOPTION = 1; |
|
| 257 | + } else { |
|
| 258 | + Conf::$global->FACTURE_TVAOPTION = 0; |
|
| 259 | + } |
|
| 248 | 260 | } |
| 249 | 261 | |
| 250 | 262 | // Variable globales LDAP |
| 251 | - if (empty(Conf::$global->LDAP_FIELD_FULLNAME)) |
|
| 252 | - Conf::$global->LDAP_FIELD_FULLNAME = ''; |
|
| 253 | - if (!isset(Conf::$global->LDAP_KEY_USERS)) |
|
| 254 | - Conf::$global->LDAP_KEY_USERS = Conf::$global->LDAP_FIELD_FULLNAME; |
|
| 255 | - if (!isset(Conf::$global->LDAP_KEY_GROUPS)) |
|
| 256 | - Conf::$global->LDAP_KEY_GROUPS = Conf::$global->LDAP_FIELD_FULLNAME; |
|
| 257 | - if (!isset(Conf::$global->LDAP_KEY_CONTACTS)) |
|
| 258 | - Conf::$global->LDAP_KEY_CONTACTS = Conf::$global->LDAP_FIELD_FULLNAME; |
|
| 259 | - if (!isset(Conf::$global->LDAP_KEY_MEMBERS)) |
|
| 260 | - Conf::$global->LDAP_KEY_MEMBERS = Conf::$global->LDAP_FIELD_FULLNAME; |
|
| 261 | - if (!isset(Conf::$global->LDAP_KEY_MEMBERS_TYPES)) |
|
| 262 | - Conf::$global->LDAP_KEY_MEMBERS_TYPES = Conf::$global->LDAP_FIELD_FULLNAME; |
|
| 263 | + if (empty(Conf::$global->LDAP_FIELD_FULLNAME)) { |
|
| 264 | + Conf::$global->LDAP_FIELD_FULLNAME = ''; |
|
| 265 | + } |
|
| 266 | + if (!isset(Conf::$global->LDAP_KEY_USERS)) { |
|
| 267 | + Conf::$global->LDAP_KEY_USERS = Conf::$global->LDAP_FIELD_FULLNAME; |
|
| 268 | + } |
|
| 269 | + if (!isset(Conf::$global->LDAP_KEY_GROUPS)) { |
|
| 270 | + Conf::$global->LDAP_KEY_GROUPS = Conf::$global->LDAP_FIELD_FULLNAME; |
|
| 271 | + } |
|
| 272 | + if (!isset(Conf::$global->LDAP_KEY_CONTACTS)) { |
|
| 273 | + Conf::$global->LDAP_KEY_CONTACTS = Conf::$global->LDAP_FIELD_FULLNAME; |
|
| 274 | + } |
|
| 275 | + if (!isset(Conf::$global->LDAP_KEY_MEMBERS)) { |
|
| 276 | + Conf::$global->LDAP_KEY_MEMBERS = Conf::$global->LDAP_FIELD_FULLNAME; |
|
| 277 | + } |
|
| 278 | + if (!isset(Conf::$global->LDAP_KEY_MEMBERS_TYPES)) { |
|
| 279 | + Conf::$global->LDAP_KEY_MEMBERS_TYPES = Conf::$global->LDAP_FIELD_FULLNAME; |
|
| 280 | + } |
|
| 263 | 281 | |
| 264 | 282 | // Load translation object with current language |
| 265 | - if (empty(Conf::$global->MAIN_LANG_DEFAULT)) |
|
| 266 | - Conf::$global->MAIN_LANG_DEFAULT = "en_US"; |
|
| 283 | + if (empty(Conf::$global->MAIN_LANG_DEFAULT)) { |
|
| 284 | + Conf::$global->MAIN_LANG_DEFAULT = "en_US"; |
|
| 285 | + } |
|
| 267 | 286 | |
| 268 | 287 | $rootfordata = DOL_DATA_ROOT; |
| 269 | 288 | $rootforuser = DOL_DATA_ROOT; |
@@ -413,21 +432,29 @@ discard block |
||
| 413 | 432 | Conf::$global->MAIN_MAIL_USE_MULTI_PART = 1; |
| 414 | 433 | |
| 415 | 434 | // societe |
| 416 | - if (empty(Conf::$global->SOCIETE_CODECLIENT_ADDON)) |
|
| 417 | - Conf::$global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard"; |
|
| 418 | - if (empty(Conf::$global->SOCIETE_CODECOMPTA_ADDON)) |
|
| 419 | - Conf::$global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum"; |
|
| 420 | - |
|
| 421 | - if (empty(Conf::$global->CHEQUERECEIPTS_ADDON)) |
|
| 422 | - Conf::$global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint'; |
|
| 423 | - if (empty($conf->global->TICKETSUP_ADDON)) |
|
| 424 | - Conf::$global->TICKETSUP_ADDON = 'mod_ticket_simple'; |
|
| 435 | + if (empty(Conf::$global->SOCIETE_CODECLIENT_ADDON)) { |
|
| 436 | + Conf::$global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard"; |
|
| 437 | + } |
|
| 438 | + if (empty(Conf::$global->SOCIETE_CODECOMPTA_ADDON)) { |
|
| 439 | + Conf::$global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum"; |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + if (empty(Conf::$global->CHEQUERECEIPTS_ADDON)) { |
|
| 443 | + Conf::$global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint'; |
|
| 444 | + } |
|
| 445 | + if (empty($conf->global->TICKETSUP_ADDON)) { |
|
| 446 | + Conf::$global->TICKETSUP_ADDON = 'mod_ticket_simple'; |
|
| 447 | + } |
|
| 425 | 448 | |
| 426 | 449 | // Security |
| 427 | - if (empty(Conf::$global->USER_PASSWORD_GENERATED)) |
|
| 428 | - Conf::$global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator |
|
| 429 | - if (empty(Conf::$global->MAIN_UMASK)) |
|
| 430 | - Conf::$global->MAIN_UMASK = '0664'; // Default mask |
|
| 450 | + if (empty(Conf::$global->USER_PASSWORD_GENERATED)) { |
|
| 451 | + Conf::$global->USER_PASSWORD_GENERATED = 'standard'; |
|
| 452 | + } |
|
| 453 | + // Default password generator |
|
| 454 | + if (empty(Conf::$global->MAIN_UMASK)) { |
|
| 455 | + Conf::$global->MAIN_UMASK = '0664'; |
|
| 456 | + } |
|
| 457 | + // Default mask |
|
| 431 | 458 | |
| 432 | 459 | |
| 433 | 460 | |
@@ -435,8 +462,9 @@ discard block |
||
| 435 | 462 | |
| 436 | 463 | // conf->use_javascript_ajax |
| 437 | 464 | $this->use_javascript_ajax = 1; |
| 438 | - if (isset(Conf::$global->MAIN_DISABLE_JAVASCRIPT)) |
|
| 439 | - $this->use_javascript_ajax = !Conf::$global->MAIN_DISABLE_JAVASCRIPT; |
|
| 465 | + if (isset(Conf::$global->MAIN_DISABLE_JAVASCRIPT)) { |
|
| 466 | + $this->use_javascript_ajax = !Conf::$global->MAIN_DISABLE_JAVASCRIPT; |
|
| 467 | + } |
|
| 440 | 468 | // If no javascript_ajax, Ajax features are disabled. |
| 441 | 469 | if (empty($this->use_javascript_ajax)) {
|
| 442 | 470 | unset(Conf::$global->PRODUIT_USE_SEARCH_TO_SELECT); |
@@ -452,29 +480,34 @@ discard block |
||
| 452 | 480 | Conf::$global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 0; |
| 453 | 481 | Conf::$global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0; |
| 454 | 482 | Conf::$global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0; |
| 455 | - if (empty($this->reception->enabled)) |
|
| 456 | - Conf::$global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1; |
|
| 457 | - else {
|
|
| 483 | + if (empty($this->reception->enabled)) { |
|
| 484 | + Conf::$global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1; |
|
| 485 | + } else {
|
|
| 458 | 486 | Conf::$global->STOCK_CALCULATE_ON_RECEPTION = 1; |
| 459 | 487 | Conf::$global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 0; |
| 460 | 488 | } |
| 461 | 489 | } |
| 462 | 490 | |
| 463 | 491 | // conf->currency |
| 464 | - if (empty(Conf::$global->MAIN_MONNAIE)) |
|
| 465 | - Conf::$global->MAIN_MONNAIE = 'EUR'; |
|
| 492 | + if (empty(Conf::$global->MAIN_MONNAIE)) { |
|
| 493 | + Conf::$global->MAIN_MONNAIE = 'EUR'; |
|
| 494 | + } |
|
| 466 | 495 | $this->currency = Conf::$global->MAIN_MONNAIE; |
| 467 | 496 | |
| 468 | - if (empty(Conf::$global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) |
|
| 469 | - Conf::$global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure |
|
| 497 | + if (empty(Conf::$global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) { |
|
| 498 | + Conf::$global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; |
|
| 499 | + } |
|
| 500 | + // Less than 1 minutes to be sure |
|
| 470 | 501 | |
| 471 | 502 | |
| 472 | 503 | |
| 473 | 504 | |
| 474 | 505 | |
| 475 | 506 | // conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...) |
| 476 | - if (empty(Conf::$global->ACCOUNTING_MODE)) |
|
| 477 | - Conf::$global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' |
|
| 507 | + if (empty(Conf::$global->ACCOUNTING_MODE)) { |
|
| 508 | + Conf::$global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; |
|
| 509 | + } |
|
| 510 | + // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' |
|
| 478 | 511 | |
| 479 | 512 | |
| 480 | 513 | |
@@ -484,44 +517,53 @@ discard block |
||
| 484 | 517 | Conf::$global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1; |
| 485 | 518 | |
| 486 | 519 | // MAIN_HTML_TITLE |
| 487 | - if (!isset(Conf::$global->MAIN_HTML_TITLE)) |
|
| 488 | - Conf::$global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly'; |
|
| 520 | + if (!isset(Conf::$global->MAIN_HTML_TITLE)) { |
|
| 521 | + Conf::$global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly'; |
|
| 522 | + } |
|
| 489 | 523 | |
| 490 | 524 | // conf->liste_limit = constante de taille maximale des listes |
| 491 | - if (empty(Conf::$global->MAIN_SIZE_LISTE_LIMIT)) |
|
| 492 | - Conf::$global->MAIN_SIZE_LISTE_LIMIT = 25; |
|
| 525 | + if (empty(Conf::$global->MAIN_SIZE_LISTE_LIMIT)) { |
|
| 526 | + Conf::$global->MAIN_SIZE_LISTE_LIMIT = 25; |
|
| 527 | + } |
|
| 493 | 528 | $this->liste_limit = Conf::$global->MAIN_SIZE_LISTE_LIMIT; |
| 494 | 529 | |
| 495 | 530 | // conf->product->limit_size = constante de taille maximale des select de produit |
| 496 | - if (!isset(Conf::$global->PRODUIT_LIMIT_SIZE)) |
|
| 497 | - Conf::$global->PRODUIT_LIMIT_SIZE = 1000; |
|
| 531 | + if (!isset(Conf::$global->PRODUIT_LIMIT_SIZE)) { |
|
| 532 | + Conf::$global->PRODUIT_LIMIT_SIZE = 1000; |
|
| 533 | + } |
|
| 498 | 534 | $this->product->limit_size = Conf::$global->PRODUIT_LIMIT_SIZE; |
| 499 | 535 | |
| 500 | 536 | // conf->theme et $this->css |
| 501 | - if (empty(Conf::$global->MAIN_THEME)) |
|
| 502 | - Conf::$global->MAIN_THEME = "eldy"; |
|
| 503 | - if (!empty(Conf::$global->MAIN_FORCETHEME)) |
|
| 504 | - Conf::$global->MAIN_THEME = Conf::$global->MAIN_FORCETHEME; |
|
| 537 | + if (empty(Conf::$global->MAIN_THEME)) { |
|
| 538 | + Conf::$global->MAIN_THEME = "eldy"; |
|
| 539 | + } |
|
| 540 | + if (!empty(Conf::$global->MAIN_FORCETHEME)) { |
|
| 541 | + Conf::$global->MAIN_THEME = Conf::$global->MAIN_FORCETHEME; |
|
| 542 | + } |
|
| 505 | 543 | $this->theme = Conf::$global->MAIN_THEME; |
| 506 | 544 | //$this->css = "/theme/".$this->theme."/style.css.php"; |
| 507 | 545 | $this->css = '?controller=theme/' . $this->theme . '&method=style.css'; |
| 508 | 546 | |
| 509 | 547 | // conf->email_from = email pour envoi par dolibarr des mails automatiques |
| 510 | 548 | $this->email_from = "[email protected]"; |
| 511 | - if (!empty(Conf::$global->MAIN_MAIL_EMAIL_FROM)) |
|
| 512 | - $this->email_from = Conf::$global->MAIN_MAIL_EMAIL_FROM; |
|
| 549 | + if (!empty(Conf::$global->MAIN_MAIL_EMAIL_FROM)) { |
|
| 550 | + $this->email_from = Conf::$global->MAIN_MAIL_EMAIL_FROM; |
|
| 551 | + } |
|
| 513 | 552 | |
| 514 | 553 | // conf->notification->email_from = email pour envoi par Dolibarr des notifications |
| 515 | 554 | $this->notification->email_from = $this->email_from; |
| 516 | - if (!empty(Conf::$global->NOTIFICATION_EMAIL_FROM)) |
|
| 517 | - $this->notification->email_from = Conf::$global->NOTIFICATION_EMAIL_FROM; |
|
| 555 | + if (!empty(Conf::$global->NOTIFICATION_EMAIL_FROM)) { |
|
| 556 | + $this->notification->email_from = Conf::$global->NOTIFICATION_EMAIL_FROM; |
|
| 557 | + } |
|
| 518 | 558 | |
| 519 | 559 | // conf->mailing->email_from = email pour envoi par Dolibarr des mailings |
| 520 | 560 | $this->mailing->email_from = $this->email_from; |
| 521 | - if (!empty(Conf::$global->MAILING_EMAIL_FROM)) |
|
| 522 | - $this->mailing->email_from = Conf::$global->MAILING_EMAIL_FROM; |
|
| 523 | - if (!isset(Conf::$global->MAIN_EMAIL_ADD_TRACK_ID)) |
|
| 524 | - Conf::$global->MAIN_EMAIL_ADD_TRACK_ID = 1; |
|
| 561 | + if (!empty(Conf::$global->MAILING_EMAIL_FROM)) { |
|
| 562 | + $this->mailing->email_from = Conf::$global->MAILING_EMAIL_FROM; |
|
| 563 | + } |
|
| 564 | + if (!isset(Conf::$global->MAIN_EMAIL_ADD_TRACK_ID)) { |
|
| 565 | + Conf::$global->MAIN_EMAIL_ADD_TRACK_ID = 1; |
|
| 566 | + } |
|
| 525 | 567 | |
| 526 | 568 | // Format for date (used by default when not found or not searched in lang) |
| 527 | 569 | $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) |
@@ -536,81 +578,105 @@ discard block |
||
| 536 | 578 | $this->format_date_hour_text = "%d %B %Y %H:%M"; |
| 537 | 579 | |
| 538 | 580 | // Duration of workday |
| 539 | - if (!isset(Conf::$global->MAIN_DURATION_OF_WORKDAY)) |
|
| 540 | - Conf::$global->MAIN_DURATION_OF_WORKDAY = 86400; |
|
| 581 | + if (!isset(Conf::$global->MAIN_DURATION_OF_WORKDAY)) { |
|
| 582 | + Conf::$global->MAIN_DURATION_OF_WORKDAY = 86400; |
|
| 583 | + } |
|
| 541 | 584 | |
| 542 | 585 | // Limites decimales si non definie (peuvent etre egale a 0) |
| 543 | - if (!isset(Conf::$global->MAIN_MAX_DECIMALS_UNIT)) |
|
| 544 | - Conf::$global->MAIN_MAX_DECIMALS_UNIT = 5; |
|
| 545 | - if (!isset(Conf::$global->MAIN_MAX_DECIMALS_TOT)) |
|
| 546 | - Conf::$global->MAIN_MAX_DECIMALS_TOT = 2; |
|
| 547 | - if (!isset(Conf::$global->MAIN_MAX_DECIMALS_SHOWN)) |
|
| 548 | - Conf::$global->MAIN_MAX_DECIMALS_SHOWN = 8; |
|
| 586 | + if (!isset(Conf::$global->MAIN_MAX_DECIMALS_UNIT)) { |
|
| 587 | + Conf::$global->MAIN_MAX_DECIMALS_UNIT = 5; |
|
| 588 | + } |
|
| 589 | + if (!isset(Conf::$global->MAIN_MAX_DECIMALS_TOT)) { |
|
| 590 | + Conf::$global->MAIN_MAX_DECIMALS_TOT = 2; |
|
| 591 | + } |
|
| 592 | + if (!isset(Conf::$global->MAIN_MAX_DECIMALS_SHOWN)) { |
|
| 593 | + Conf::$global->MAIN_MAX_DECIMALS_SHOWN = 8; |
|
| 594 | + } |
|
| 549 | 595 | |
| 550 | 596 | // Default pdf option |
| 551 | - if (!isset(Conf::$global->MAIN_PDF_DASH_BETWEEN_LINES)) |
|
| 552 | - Conf::$global->MAIN_PDF_DASH_BETWEEN_LINES = 1; // use dash between lines |
|
| 553 | - if (!isset(Conf::$global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) |
|
| 554 | - Conf::$global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; // allow html content into free footer text |
|
| 597 | + if (!isset(Conf::$global->MAIN_PDF_DASH_BETWEEN_LINES)) { |
|
| 598 | + Conf::$global->MAIN_PDF_DASH_BETWEEN_LINES = 1; |
|
| 599 | + } |
|
| 600 | + // use dash between lines |
|
| 601 | + if (!isset(Conf::$global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { |
|
| 602 | + Conf::$global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; |
|
| 603 | + } |
|
| 604 | + // allow html content into free footer text |
|
| 555 | 605 | |
| 556 | 606 | |
| 557 | 607 | |
| 558 | 608 | |
| 559 | 609 | |
| 560 | 610 | // Set default value to MAIN_SHOW_LOGO |
| 561 | - if (!isset(Conf::$global->MAIN_SHOW_LOGO)) |
|
| 562 | - Conf::$global->MAIN_SHOW_LOGO = 1; |
|
| 611 | + if (!isset(Conf::$global->MAIN_SHOW_LOGO)) { |
|
| 612 | + Conf::$global->MAIN_SHOW_LOGO = 1; |
|
| 613 | + } |
|
| 563 | 614 | |
| 564 | 615 | // Default max file size for upload |
| 565 | 616 | $this->maxfilesize = (empty(Conf::$global->MAIN_UPLOAD_DOC) ? 0 : (int) Conf::$global->MAIN_UPLOAD_DOC * 1024); |
| 566 | 617 | |
| 567 | 618 | // By default, we propagate contacts |
| 568 | - if (!isset(Conf::$global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) |
|
| 569 | - Conf::$global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN = '*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented) |
|
| 619 | + if (!isset(Conf::$global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) { |
|
| 620 | + Conf::$global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN = '*'; |
|
| 621 | + } |
|
| 622 | + // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented) |
|
| 570 | 623 | |
| 571 | 624 | |
| 572 | 625 | |
| 573 | 626 | |
| 574 | 627 | |
| 575 | 628 | // By default, we do not use the zip town table but the table of third parties |
| 576 | - if (!isset(Conf::$global->MAIN_USE_ZIPTOWN_DICTIONNARY)) |
|
| 577 | - Conf::$global->MAIN_USE_ZIPTOWN_DICTIONNARY = 0; |
|
| 629 | + if (!isset(Conf::$global->MAIN_USE_ZIPTOWN_DICTIONNARY)) { |
|
| 630 | + Conf::$global->MAIN_USE_ZIPTOWN_DICTIONNARY = 0; |
|
| 631 | + } |
|
| 578 | 632 | |
| 579 | 633 | // By default, we open card if one found |
| 580 | - if (!isset(Conf::$global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) |
|
| 581 | - Conf::$global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE = 1; |
|
| 634 | + if (!isset(Conf::$global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) { |
|
| 635 | + Conf::$global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE = 1; |
|
| 636 | + } |
|
| 582 | 637 | |
| 583 | 638 | // By default, we show state code in combo list |
| 584 | - if (!isset(Conf::$global->MAIN_SHOW_STATE_CODE)) |
|
| 585 | - Conf::$global->MAIN_SHOW_STATE_CODE = 1; |
|
| 639 | + if (!isset(Conf::$global->MAIN_SHOW_STATE_CODE)) { |
|
| 640 | + Conf::$global->MAIN_SHOW_STATE_CODE = 1; |
|
| 641 | + } |
|
| 586 | 642 | |
| 587 | 643 | // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal" |
| 588 | - if (!isset(Conf::$global->MAIN_MODULES_FOR_EXTERNAL)) |
|
| 589 | - Conf::$global->MAIN_MODULES_FOR_EXTERNAL = 'user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later. |
|
| 644 | + if (!isset(Conf::$global->MAIN_MODULES_FOR_EXTERNAL)) { |
|
| 645 | + Conf::$global->MAIN_MODULES_FOR_EXTERNAL = 'user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; |
|
| 646 | + } |
|
| 647 | + // '' means 'all'. Note that contact is added here as it should be a module later. |
|
| 590 | 648 | if (!empty($this->modules_parts['moduleforexternal'])) { // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
|
| 591 | - foreach ($this->modules_parts['moduleforexternal'] as $key => $value) |
|
| 592 | - Conf::$global->MAIN_MODULES_FOR_EXTERNAL .= "," . $key; |
|
| 649 | + foreach ($this->modules_parts['moduleforexternal'] as $key => $value) { |
|
| 650 | + Conf::$global->MAIN_MODULES_FOR_EXTERNAL .= "," . $key; |
|
| 651 | + } |
|
| 593 | 652 | } |
| 594 | 653 | |
| 595 | 654 | // Enable select2 |
| 596 | - if (empty(Conf::$global->MAIN_USE_JQUERY_MULTISELECT) || Conf::$global->MAIN_USE_JQUERY_MULTISELECT == '1') |
|
| 597 | - Conf::$global->MAIN_USE_JQUERY_MULTISELECT = 'select2'; |
|
| 655 | + if (empty(Conf::$global->MAIN_USE_JQUERY_MULTISELECT) || Conf::$global->MAIN_USE_JQUERY_MULTISELECT == '1') { |
|
| 656 | + Conf::$global->MAIN_USE_JQUERY_MULTISELECT = 'select2'; |
|
| 657 | + } |
|
| 598 | 658 | |
| 599 | 659 | // Timeouts |
| 600 | - if (empty(Conf::$global->MAIN_USE_CONNECT_TIMEOUT)) |
|
| 601 | - Conf::$global->MAIN_USE_CONNECT_TIMEOUT = 10; |
|
| 602 | - if (empty(Conf::$global->MAIN_USE_RESPONSE_TIMEOUT)) |
|
| 603 | - Conf::$global->MAIN_USE_RESPONSE_TIMEOUT = 30; |
|
| 660 | + if (empty(Conf::$global->MAIN_USE_CONNECT_TIMEOUT)) { |
|
| 661 | + Conf::$global->MAIN_USE_CONNECT_TIMEOUT = 10; |
|
| 662 | + } |
|
| 663 | + if (empty(Conf::$global->MAIN_USE_RESPONSE_TIMEOUT)) { |
|
| 664 | + Conf::$global->MAIN_USE_RESPONSE_TIMEOUT = 30; |
|
| 665 | + } |
|
| 604 | 666 | |
| 605 | 667 | // Set default variable to calculate VAT as if option tax_mode was 0 (standard) |
| 606 | - if (empty(Conf::$global->TAX_MODE_SELL_PRODUCT)) |
|
| 607 | - Conf::$global->TAX_MODE_SELL_PRODUCT = 'invoice'; |
|
| 608 | - if (empty(Conf::$global->TAX_MODE_BUY_PRODUCT)) |
|
| 609 | - Conf::$global->TAX_MODE_BUY_PRODUCT = 'invoice'; |
|
| 610 | - if (empty(Conf::$global->TAX_MODE_SELL_SERVICE)) |
|
| 611 | - Conf::$global->TAX_MODE_SELL_SERVICE = 'payment'; |
|
| 612 | - if (empty(Conf::$global->TAX_MODE_BUY_SERVICE)) |
|
| 613 | - Conf::$global->TAX_MODE_BUY_SERVICE = 'payment'; |
|
| 668 | + if (empty(Conf::$global->TAX_MODE_SELL_PRODUCT)) { |
|
| 669 | + Conf::$global->TAX_MODE_SELL_PRODUCT = 'invoice'; |
|
| 670 | + } |
|
| 671 | + if (empty(Conf::$global->TAX_MODE_BUY_PRODUCT)) { |
|
| 672 | + Conf::$global->TAX_MODE_BUY_PRODUCT = 'invoice'; |
|
| 673 | + } |
|
| 674 | + if (empty(Conf::$global->TAX_MODE_SELL_SERVICE)) { |
|
| 675 | + Conf::$global->TAX_MODE_SELL_SERVICE = 'payment'; |
|
| 676 | + } |
|
| 677 | + if (empty(Conf::$global->TAX_MODE_BUY_SERVICE)) { |
|
| 678 | + Conf::$global->TAX_MODE_BUY_SERVICE = 'payment'; |
|
| 679 | + } |
|
| 614 | 680 | |
| 615 | 681 | // Delay before warnings |
| 616 | 682 | // Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx |
@@ -618,8 +684,9 @@ discard block |
||
| 618 | 684 | $this->adherent->subscription = new \stdClass(); |
| 619 | 685 | $this->adherent->subscription->warning_delay = (isset(Conf::$global->MAIN_DELAY_MEMBERS) ? Conf::$global->MAIN_DELAY_MEMBERS : 0) * 24 * 60 * 60; |
| 620 | 686 | } |
| 621 | - if (isset($this->agenda)) |
|
| 622 | - $this->agenda->warning_delay = (isset(Conf::$global->MAIN_DELAY_ACTIONS_TODO) ? Conf::$global->MAIN_DELAY_ACTIONS_TODO : 7) * 24 * 60 * 60; |
|
| 687 | + if (isset($this->agenda)) { |
|
| 688 | + $this->agenda->warning_delay = (isset(Conf::$global->MAIN_DELAY_ACTIONS_TODO) ? Conf::$global->MAIN_DELAY_ACTIONS_TODO : 7) * 24 * 60 * 60; |
|
| 689 | + } |
|
| 623 | 690 | if (isset($this->projet)) {
|
| 624 | 691 | $this->projet->warning_delay = (isset(Conf::$global->MAIN_DELAY_PROJECT_TO_CLOSE) ? Conf::$global->MAIN_DELAY_PROJECT_TO_CLOSE : 7) * 24 * 60 * 60; |
| 625 | 692 | $this->projet->task = new StdClass(); |
@@ -669,44 +736,55 @@ discard block |
||
| 669 | 736 | } |
| 670 | 737 | |
| 671 | 738 | // For modules that want to disable top or left menu |
| 672 | - if (!empty(Conf::$global->MAIN_HIDE_TOP_MENU)) |
|
| 673 | - $this->dol_hide_topmenu = Conf::$global->MAIN_HIDE_TOP_MENU; |
|
| 674 | - if (!empty(Conf::$global->MAIN_HIDE_LEFT_MENU)) |
|
| 675 | - $this->dol_hide_leftmenu = Conf::$global->MAIN_HIDE_LEFT_MENU; |
|
| 739 | + if (!empty(Conf::$global->MAIN_HIDE_TOP_MENU)) { |
|
| 740 | + $this->dol_hide_topmenu = Conf::$global->MAIN_HIDE_TOP_MENU; |
|
| 741 | + } |
|
| 742 | + if (!empty(Conf::$global->MAIN_HIDE_LEFT_MENU)) { |
|
| 743 | + $this->dol_hide_leftmenu = Conf::$global->MAIN_HIDE_LEFT_MENU; |
|
| 744 | + } |
|
| 676 | 745 | |
| 677 | - if (empty(Conf::$global->MAIN_SIZE_SHORTLIST_LIMIT)) |
|
| 678 | - Conf::$global->MAIN_SIZE_SHORTLIST_LIMIT = 3; |
|
| 746 | + if (empty(Conf::$global->MAIN_SIZE_SHORTLIST_LIMIT)) { |
|
| 747 | + Conf::$global->MAIN_SIZE_SHORTLIST_LIMIT = 3; |
|
| 748 | + } |
|
| 679 | 749 | |
| 680 | - if (!isset(Conf::$global->THEME_HIDE_BORDER_ON_INPUT)) |
|
| 681 | - Conf::$global->THEME_HIDE_BORDER_ON_INPUT = 0; |
|
| 750 | + if (!isset(Conf::$global->THEME_HIDE_BORDER_ON_INPUT)) { |
|
| 751 | + Conf::$global->THEME_HIDE_BORDER_ON_INPUT = 0; |
|
| 752 | + } |
|
| 682 | 753 | |
| 683 | 754 | // Save inconsistent option |
| 684 | 755 | if (empty(Conf::$global->AGENDA_USE_EVENT_TYPE) && (!isset(Conf::$global->AGENDA_DEFAULT_FILTER_TYPE) || Conf::$global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')) {
|
| 685 | 756 | Conf::$global->AGENDA_DEFAULT_FILTER_TYPE = '0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on. |
| 686 | 757 | } |
| 687 | 758 | |
| 688 | - if (!isset(Conf::$global->MAIN_EXTRAFIELDS_IN_ONE_TD)) |
|
| 689 | - Conf::$global->MAIN_EXTRAFIELDS_IN_ONE_TD = 1; |
|
| 759 | + if (!isset(Conf::$global->MAIN_EXTRAFIELDS_IN_ONE_TD)) { |
|
| 760 | + Conf::$global->MAIN_EXTRAFIELDS_IN_ONE_TD = 1; |
|
| 761 | + } |
|
| 690 | 762 | |
| 691 | 763 | Conf::$global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com'; |
| 692 | 764 | Conf::$global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567'; |
| 693 | 765 | |
| 694 | 766 | // For backward compatibility |
| 695 | - if (isset($this->product)) |
|
| 696 | - $this->produit = $this->product; |
|
| 697 | - if (isset($this->facture)) |
|
| 698 | - $this->invoice = $this->facture; |
|
| 699 | - if (isset($this->commande)) |
|
| 700 | - $this->order = $this->commande; |
|
| 701 | - if (isset($this->contrat)) |
|
| 702 | - $this->contract = $this->contrat; |
|
| 703 | - if (isset($this->categorie)) |
|
| 704 | - $this->category = $this->categorie; |
|
| 767 | + if (isset($this->product)) { |
|
| 768 | + $this->produit = $this->product; |
|
| 769 | + } |
|
| 770 | + if (isset($this->facture)) { |
|
| 771 | + $this->invoice = $this->facture; |
|
| 772 | + } |
|
| 773 | + if (isset($this->commande)) { |
|
| 774 | + $this->order = $this->commande; |
|
| 775 | + } |
|
| 776 | + if (isset($this->contrat)) { |
|
| 777 | + $this->contract = $this->contrat; |
|
| 778 | + } |
|
| 779 | + if (isset($this->categorie)) { |
|
| 780 | + $this->category = $this->categorie; |
|
| 781 | + } |
|
| 705 | 782 | |
| 706 | 783 | // Object $mc |
| 707 | 784 | if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) {
|
| 708 | - if (is_object($mc)) |
|
| 709 | - $mc->setValues($this); |
|
| 785 | + if (is_object($mc)) { |
|
| 786 | + $mc->setValues($this); |
|
| 787 | + } |
|
| 710 | 788 | } |
| 711 | 789 | |
| 712 | 790 | // We init log handlers |
@@ -122,7 +122,9 @@ |
||
| 122 | 122 | $nb=0; |
| 123 | 123 | foreach($this->liste as $val) |
| 124 | 124 | {
|
| 125 | - if (! empty($val['enabled'])) $nb++; |
|
| 125 | + if (! empty($val['enabled'])) { |
|
| 126 | + $nb++; |
|
| 127 | + } |
|
| 126 | 128 | } |
| 127 | 129 | return $nb; |
| 128 | 130 | } |
@@ -401,23 +401,31 @@ discard block |
||
| 401 | 401 | $sql.= " FROM ".MAIN_DB_PREFIX.$element; |
| 402 | 402 | $sql.= " WHERE entity IN (".getEntity($element).")" ;
|
| 403 | 403 | |
| 404 | - if ($id > 0) $sql.= " AND rowid = ".$db->escape($id); |
|
| 405 | - else if ($ref) $sql.= " AND ref = '".$db->escape($ref)."'"; |
|
| 406 | - else if ($ref_ext) $sql.= " AND ref_ext = '".$db->escape($ref_ext)."'"; |
|
| 407 | - else {
|
|
| 404 | + if ($id > 0) { |
|
| 405 | + $sql.= " AND rowid = ".$db->escape($id); |
|
| 406 | + } else if ($ref) { |
|
| 407 | + $sql.= " AND ref = '".$db->escape($ref)."'"; |
|
| 408 | + } else if ($ref_ext) { |
|
| 409 | + $sql.= " AND ref_ext = '".$db->escape($ref_ext)."'"; |
|
| 410 | + } else {
|
|
| 408 | 411 | $error='ErrorWrongParameters'; |
| 409 | 412 | dol_print_error(get_class()."::isExistingObject ".$error, LOG_ERR); |
| 410 | 413 | return -1; |
| 411 | 414 | } |
| 412 | - if ($ref || $ref_ext) $sql.= " AND entity = ".$conf->entity; |
|
| 415 | + if ($ref || $ref_ext) { |
|
| 416 | + $sql.= " AND entity = ".$conf->entity; |
|
| 417 | + } |
|
| 413 | 418 | |
| 414 | 419 | dol_syslog(get_class()."::isExistingObject", LOG_DEBUG); |
| 415 | 420 | $resql = $db->query($sql); |
| 416 | 421 | if ($resql) |
| 417 | 422 | {
|
| 418 | 423 | $num=$db->num_rows($resql); |
| 419 | - if ($num > 0) return 1; |
|
| 420 | - else return 0; |
|
| 424 | + if ($num > 0) { |
|
| 425 | + return 1; |
|
| 426 | + } else { |
|
| 427 | + return 0; |
|
| 428 | + } |
|
| 421 | 429 | } |
| 422 | 430 | return -1; |
| 423 | 431 | } |
@@ -446,13 +454,18 @@ discard block |
||
| 446 | 454 | //print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."<br>\n"; |
| 447 | 455 | $lastname=$this->lastname; |
| 448 | 456 | $firstname=$this->firstname; |
| 449 | - if (empty($lastname)) $lastname=(isset($this->lastname)?$this->lastname:(isset($this->name)?$this->name:(isset($this->nom)?$this->nom:(isset($this->societe)?$this->societe:(isset($this->company)?$this->company:''))))); |
|
| 457 | + if (empty($lastname)) { |
|
| 458 | + $lastname=(isset($this->lastname)?$this->lastname:(isset($this->name)?$this->name:(isset($this->nom)?$this->nom:(isset($this->societe)?$this->societe:(isset($this->company)?$this->company:''))))); |
|
| 459 | + } |
|
| 450 | 460 | |
| 451 | 461 | $ret=''; |
| 452 | 462 | if ($option && $this->civility_id) |
| 453 | 463 | {
|
| 454 | - if ($langs->transnoentitiesnoconv("Civility".$this->civility_id)!="Civility".$this->civility_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civility_id).' ';
|
|
| 455 | - else $ret.=$this->civility_id.' '; |
|
| 464 | + if ($langs->transnoentitiesnoconv("Civility".$this->civility_id)!="Civility".$this->civility_id) { |
|
| 465 | + $ret.=$langs->transnoentitiesnoconv("Civility".$this->civility_id).' '; |
|
| 466 | + } else { |
|
| 467 | + $ret.=$this->civility_id.' '; |
|
| 468 | + } |
|
| 456 | 469 | } |
| 457 | 470 | |
| 458 | 471 | $ret .= DolUtils::dolGetFirstLastname($firstname, $lastname, $nameorder); |
@@ -545,14 +558,15 @@ discard block |
||
| 545 | 558 | {
|
| 546 | 559 | if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) {
|
| 547 | 560 | $out.=($outdone?' - ':'').$this->region.' - '.$this->state; |
| 548 | - } |
|
| 549 | - else {
|
|
| 561 | + } else {
|
|
| 550 | 562 | $out.=($outdone?' - ':'').$this->state; |
| 551 | 563 | } |
| 552 | 564 | $outdone++; |
| 553 | 565 | } |
| 554 | 566 | |
| 555 | - if (! empty($this->phone) || ! empty($this->phone_pro) || ! empty($this->phone_mobile) || ! empty($this->phone_perso) || ! empty($this->fax) || ! empty($this->office_phone) || ! empty($this->user_mobile) || ! empty($this->office_fax)) $out.=($outdone?'<br>':''); |
|
| 567 | + if (! empty($this->phone) || ! empty($this->phone_pro) || ! empty($this->phone_mobile) || ! empty($this->phone_perso) || ! empty($this->fax) || ! empty($this->office_phone) || ! empty($this->user_mobile) || ! empty($this->office_fax)) { |
|
| 568 | + $out.=($outdone?'<br>':''); |
|
| 569 | + } |
|
| 556 | 570 | if (! empty($this->phone) && empty($this->phone_pro)) { // For objects that store pro phone into ->phone
|
| 557 | 571 | $out.=dol_print_phone($this->phone,$this->country_code,$contactid,$thirdpartyid,'AC_TEL',' ','phone',$langs->trans("PhonePro")); $outdone++;
|
| 558 | 572 | } |
@@ -593,13 +607,21 @@ discard block |
||
| 593 | 607 | $out.='<div style="clear: both;">'; |
| 594 | 608 | if (! empty($conf->socialnetworks->enabled)) |
| 595 | 609 | {
|
| 596 | - if ($this->skype) $out.=dol_print_socialnetworks($this->skype,$this->id,$object->id,'skype'); |
|
| 610 | + if ($this->skype) { |
|
| 611 | + $out.=dol_print_socialnetworks($this->skype,$this->id,$object->id,'skype'); |
|
| 612 | + } |
|
| 597 | 613 | $outdone++; |
| 598 | - if ($this->jabberid) $out.=dol_print_socialnetworks($this->jabberid,$this->id,$object->id,'jabber'); |
|
| 614 | + if ($this->jabberid) { |
|
| 615 | + $out.=dol_print_socialnetworks($this->jabberid,$this->id,$object->id,'jabber'); |
|
| 616 | + } |
|
| 599 | 617 | $outdone++; |
| 600 | - if ($this->twitter) $out.=dol_print_socialnetworks($this->twitter,$this->id,$object->id,'twitter'); |
|
| 618 | + if ($this->twitter) { |
|
| 619 | + $out.=dol_print_socialnetworks($this->twitter,$this->id,$object->id,'twitter'); |
|
| 620 | + } |
|
| 601 | 621 | $outdone++; |
| 602 | - if ($this->facebook) $out.=dol_print_socialnetworks($this->facebook,$this->id,$object->id,'facebook'); |
|
| 622 | + if ($this->facebook) { |
|
| 623 | + $out.=dol_print_socialnetworks($this->facebook,$this->id,$object->id,'facebook'); |
|
| 624 | + } |
|
| 603 | 625 | $outdone++; |
| 604 | 626 | } |
| 605 | 627 | $out.='</div>'; |
@@ -659,10 +681,10 @@ discard block |
||
| 659 | 681 | $this->errors = $ecmfile->errors; |
| 660 | 682 | } |
| 661 | 683 | */ |
| 662 | - } |
|
| 663 | - else return ''; |
|
| 664 | - } |
|
| 665 | - elseif (empty($ecmfile->share)) |
|
| 684 | + } else { |
|
| 685 | + return ''; |
|
| 686 | + } |
|
| 687 | + } elseif (empty($ecmfile->share)) |
|
| 666 | 688 | {
|
| 667 | 689 | // Add entry into index |
| 668 | 690 | if ($initsharekey) |
@@ -670,8 +692,9 @@ discard block |
||
| 670 | 692 | require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; |
| 671 | 693 | $ecmfile->share = getRandomPassword(true); |
| 672 | 694 | $ecmfile->update($user); |
| 673 | - } |
|
| 674 | - else return ''; |
|
| 695 | + } else { |
|
| 696 | + return ''; |
|
| 697 | + } |
|
| 675 | 698 | } |
| 676 | 699 | |
| 677 | 700 | // Define $urlwithroot |
@@ -685,14 +708,18 @@ discard block |
||
| 685 | 708 | //if (! empty($modulepart)) $paramlink.=($paramlink?'&':'').'modulepart='.$modulepart; // For sharing with hash (so public files), modulepart is not required. |
| 686 | 709 | //if (! empty($ecmfile->entity)) $paramlink.='&entity='.$ecmfile->entity; // For sharing with hash (so public files), entity is not required. |
| 687 | 710 | //$paramlink.=($paramlink?'&':'').'file='.urlencode($filepath); // No need of name of file for public link, we will use the hash |
| 688 | - if (! empty($ecmfile->share)) $paramlink.=($paramlink?'&':'').'hashp='.$ecmfile->share; // Hash for public share |
|
| 689 | - if ($forcedownload) $paramlink.=($paramlink?'&':'').'attachment=1'; |
|
| 711 | + if (! empty($ecmfile->share)) { |
|
| 712 | + $paramlink.=($paramlink?'&':'').'hashp='.$ecmfile->share; |
|
| 713 | + } |
|
| 714 | + // Hash for public share |
|
| 715 | + if ($forcedownload) { |
|
| 716 | + $paramlink.=($paramlink?'&':'').'attachment=1'; |
|
| 717 | + } |
|
| 690 | 718 | |
| 691 | 719 | if ($relativelink) |
| 692 | 720 | {
|
| 693 | 721 | $linktoreturn='document.php'.($paramlink?'?'.$paramlink:''); |
| 694 | - } |
|
| 695 | - else |
|
| 722 | + } else |
|
| 696 | 723 | {
|
| 697 | 724 | $linktoreturn=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:''); |
| 698 | 725 | } |
@@ -740,8 +767,7 @@ discard block |
||
| 740 | 767 | if (is_numeric($type_contact)) |
| 741 | 768 | {
|
| 742 | 769 | $id_type_contact=$type_contact; |
| 743 | - } |
|
| 744 | - else |
|
| 770 | + } else |
|
| 745 | 771 | {
|
| 746 | 772 | // We look for id type_contact |
| 747 | 773 | $sql = "SELECT tc.rowid"; |
@@ -754,7 +780,9 @@ discard block |
||
| 754 | 780 | if ($resql) |
| 755 | 781 | {
|
| 756 | 782 | $obj = $this->db->fetch_object($resql); |
| 757 | - if ($obj) $id_type_contact=$obj->rowid; |
|
| 783 | + if ($obj) { |
|
| 784 | + $id_type_contact=$obj->rowid; |
|
| 785 | + } |
|
| 758 | 786 | } |
| 759 | 787 | } |
| 760 | 788 | |
@@ -806,8 +834,7 @@ discard block |
||
| 806 | 834 | |
| 807 | 835 | $this->db->commit(); |
| 808 | 836 | return 1; |
| 809 | - } |
|
| 810 | - else |
|
| 837 | + } else |
|
| 811 | 838 | {
|
| 812 | 839 | if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
| 813 | 840 | {
|
@@ -815,15 +842,16 @@ discard block |
||
| 815 | 842 | $this->db->rollback(); |
| 816 | 843 | echo 'err rollback'; |
| 817 | 844 | return -2; |
| 818 | - } |
|
| 819 | - else |
|
| 845 | + } else |
|
| 820 | 846 | {
|
| 821 | 847 | $this->error=$this->db->error(); |
| 822 | 848 | $this->db->rollback(); |
| 823 | 849 | return -1; |
| 824 | 850 | } |
| 825 | 851 | } |
| 826 | - } else return 0; |
|
| 852 | + } else { |
|
| 853 | + return 0; |
|
| 854 | + } |
|
| 827 | 855 | } |
| 828 | 856 | |
| 829 | 857 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -865,15 +893,18 @@ discard block |
||
| 865 | 893 | // Insert into database |
| 866 | 894 | $sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set"; |
| 867 | 895 | $sql.= " statut = ".$statut; |
| 868 | - if ($type_contact_id) $sql.= ", fk_c_type_contact = '".$type_contact_id ."'"; |
|
| 869 | - if ($fk_socpeople) $sql.= ", fk_socpeople = '".$fk_socpeople ."'"; |
|
| 896 | + if ($type_contact_id) { |
|
| 897 | + $sql.= ", fk_c_type_contact = '".$type_contact_id ."'"; |
|
| 898 | + } |
|
| 899 | + if ($fk_socpeople) { |
|
| 900 | + $sql.= ", fk_socpeople = '".$fk_socpeople ."'"; |
|
| 901 | + } |
|
| 870 | 902 | $sql.= " where rowid = ".$rowid; |
| 871 | 903 | $resql=$this->db->query($sql); |
| 872 | 904 | if ($resql) |
| 873 | 905 | {
|
| 874 | 906 | return 0; |
| 875 | - } |
|
| 876 | - else |
|
| 907 | + } else |
|
| 877 | 908 | {
|
| 878 | 909 | $this->error=$this->db->lasterror(); |
| 879 | 910 | return -1; |
@@ -910,8 +941,7 @@ discard block |
||
| 910 | 941 | |
| 911 | 942 | $this->db->commit(); |
| 912 | 943 | return 1; |
| 913 | - } |
|
| 914 | - else |
|
| 944 | + } else |
|
| 915 | 945 | {
|
| 916 | 946 | $this->error=$this->db->lasterror(); |
| 917 | 947 | $this->db->rollback(); |
@@ -941,15 +971,15 @@ discard block |
||
| 941 | 971 | |
| 942 | 972 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; |
| 943 | 973 | $sql.= " WHERE element_id = ".$this->id; |
| 944 | - if ($listId) |
|
| 945 | - $sql.= " AND fk_c_type_contact IN (".$listId.")";
|
|
| 974 | + if ($listId) { |
|
| 975 | + $sql.= " AND fk_c_type_contact IN (".$listId.")"; |
|
| 976 | + } |
|
| 946 | 977 | |
| 947 | 978 | dol_syslog(get_class($this)."::delete_linked_contact", LOG_DEBUG); |
| 948 | 979 | if ($this->db->query($sql)) |
| 949 | 980 | {
|
| 950 | 981 | return 1; |
| 951 | - } |
|
| 952 | - else |
|
| 982 | + } else |
|
| 953 | 983 | {
|
| 954 | 984 | $this->error=$this->db->lasterror(); |
| 955 | 985 | return -1; |
@@ -974,22 +1004,38 @@ discard block |
||
| 974 | 1004 | $tab=array(); |
| 975 | 1005 | |
| 976 | 1006 | $sql = "SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact"; // This field contains id of llx_socpeople or id of llx_user |
| 977 | - if ($source == 'internal') $sql.=", '-1' as socid, t.statut as statuscontact, t.login, t.photo"; |
|
| 978 | - if ($source == 'external' || $source == 'thirdparty') $sql.=", t.fk_soc as socid, t.statut as statuscontact"; |
|
| 1007 | + if ($source == 'internal') { |
|
| 1008 | + $sql.=", '-1' as socid, t.statut as statuscontact, t.login, t.photo"; |
|
| 1009 | + } |
|
| 1010 | + if ($source == 'external' || $source == 'thirdparty') { |
|
| 1011 | + $sql.=", t.fk_soc as socid, t.statut as statuscontact"; |
|
| 1012 | + } |
|
| 979 | 1013 | $sql.= ", t.civility as civility, t.lastname as lastname, t.firstname, t.email"; |
| 980 | 1014 | $sql.= ", tc.source, tc.element, tc.code, tc.libelle"; |
| 981 | 1015 | $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact tc"; |
| 982 | 1016 | $sql.= ", ".MAIN_DB_PREFIX."element_contact ec"; |
| 983 | - if ($source == 'internal') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid"; |
|
| 984 | - if ($source == 'external'|| $source == 'thirdparty') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid"; |
|
| 1017 | + if ($source == 'internal') { |
|
| 1018 | + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid"; |
|
| 1019 | + } |
|
| 1020 | + if ($source == 'external'|| $source == 'thirdparty') { |
|
| 1021 | + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid"; |
|
| 1022 | + } |
|
| 985 | 1023 | $sql.= " WHERE ec.element_id =".$this->id; |
| 986 | 1024 | $sql.= " AND ec.fk_c_type_contact=tc.rowid"; |
| 987 | 1025 | $sql.= " AND tc.element='".$this->db->escape($this->element)."'"; |
| 988 | - if ($code) $sql.= " AND tc.code = '".$this->db->escape($code)."'"; |
|
| 989 | - if ($source == 'internal') $sql.= " AND tc.source = 'internal'"; |
|
| 990 | - if ($source == 'external' || $source == 'thirdparty') $sql.= " AND tc.source = 'external'"; |
|
| 1026 | + if ($code) { |
|
| 1027 | + $sql.= " AND tc.code = '".$this->db->escape($code)."'"; |
|
| 1028 | + } |
|
| 1029 | + if ($source == 'internal') { |
|
| 1030 | + $sql.= " AND tc.source = 'internal'"; |
|
| 1031 | + } |
|
| 1032 | + if ($source == 'external' || $source == 'thirdparty') { |
|
| 1033 | + $sql.= " AND tc.source = 'external'"; |
|
| 1034 | + } |
|
| 991 | 1035 | $sql.= " AND tc.active=1"; |
| 992 | - if ($statut >= 0) $sql.= " AND ec.statut = '".$statut."'"; |
|
| 1036 | + if ($statut >= 0) { |
|
| 1037 | + $sql.= " AND ec.statut = '".$statut."'"; |
|
| 1038 | + } |
|
| 993 | 1039 | $sql.=" ORDER BY t.lastname ASC"; |
| 994 | 1040 | |
| 995 | 1041 | dol_syslog(get_class($this)."::liste_contact", LOG_DEBUG); |
@@ -1010,8 +1056,7 @@ discard block |
||
| 1010 | 1056 | 'nom'=>$obj->lastname, // For backward compatibility |
| 1011 | 1057 | 'civility'=>$obj->civility, 'lastname'=>$obj->lastname, 'firstname'=>$obj->firstname, 'email'=>$obj->email, 'login'=>$obj->login, 'photo'=>$obj->photo, 'statuscontact'=>$obj->statuscontact, |
| 1012 | 1058 | 'rowid'=>$obj->rowid, 'code'=>$obj->code, 'libelle'=>$libelle_type, 'status'=>$obj->statuslink, 'fk_c_type_contact'=>$obj->fk_c_type_contact); |
| 1013 | - } |
|
| 1014 | - else |
|
| 1059 | + } else |
|
| 1015 | 1060 | {
|
| 1016 | 1061 | $tab[$i]=$obj->id; |
| 1017 | 1062 | } |
@@ -1020,8 +1065,7 @@ discard block |
||
| 1020 | 1065 | } |
| 1021 | 1066 | |
| 1022 | 1067 | return $tab; |
| 1023 | - } |
|
| 1024 | - else |
|
| 1068 | + } else |
|
| 1025 | 1069 | {
|
| 1026 | 1070 | $this->error=$this->db->lasterror(); |
| 1027 | 1071 | dol_print_error($this->db); |
@@ -1056,8 +1100,7 @@ discard block |
||
| 1056 | 1100 | $result = $this->update_contact($rowid, $newstatut); |
| 1057 | 1101 | $this->db->free($resql); |
| 1058 | 1102 | return $result; |
| 1059 | - } |
|
| 1060 | - else |
|
| 1103 | + } else |
|
| 1061 | 1104 | {
|
| 1062 | 1105 | $this->error=$this->db->error(); |
| 1063 | 1106 | dol_print_error($this->db); |
@@ -1081,16 +1124,27 @@ discard block |
||
| 1081 | 1124 | // phpcs:enable |
| 1082 | 1125 | global $langs; |
| 1083 | 1126 | |
| 1084 | - if (empty($order)) $order='position'; |
|
| 1085 | - if ($order == 'position') $order.=',code'; |
|
| 1127 | + if (empty($order)) { |
|
| 1128 | + $order='position'; |
|
| 1129 | + } |
|
| 1130 | + if ($order == 'position') { |
|
| 1131 | + $order.=',code'; |
|
| 1132 | + } |
|
| 1086 | 1133 | |
| 1087 | 1134 | $tab = array(); |
| 1088 | 1135 | $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position"; |
| 1089 | 1136 | $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; |
| 1090 | 1137 | $sql.= " WHERE tc.element='".$this->db->escape($this->element)."'"; |
| 1091 | - if ($activeonly == 1) $sql.= " AND tc.active=1"; // only the active types |
|
| 1092 | - if (! empty($source) && $source != 'all') $sql.= " AND tc.source='".$this->db->escape($source)."'"; |
|
| 1093 | - if (! empty($code)) $sql.= " AND tc.code='".$this->db->escape($code)."'"; |
|
| 1138 | + if ($activeonly == 1) { |
|
| 1139 | + $sql.= " AND tc.active=1"; |
|
| 1140 | + } |
|
| 1141 | + // only the active types |
|
| 1142 | + if (! empty($source) && $source != 'all') { |
|
| 1143 | + $sql.= " AND tc.source='".$this->db->escape($source)."'"; |
|
| 1144 | + } |
|
| 1145 | + if (! empty($code)) { |
|
| 1146 | + $sql.= " AND tc.code='".$this->db->escape($code)."'"; |
|
| 1147 | + } |
|
| 1094 | 1148 | $sql.= $this->db->order($order,'ASC'); |
| 1095 | 1149 | |
| 1096 | 1150 | //print "sql=".$sql; |
@@ -1105,13 +1159,15 @@ discard block |
||
| 1105 | 1159 | |
| 1106 | 1160 | $transkey="TypeContact_".$this->element."_".$source."_".$obj->code; |
| 1107 | 1161 | $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); |
| 1108 | - if (empty($option)) $tab[$obj->rowid]=$libelle_type; |
|
| 1109 | - else $tab[$obj->code]=$libelle_type; |
|
| 1162 | + if (empty($option)) { |
|
| 1163 | + $tab[$obj->rowid]=$libelle_type; |
|
| 1164 | + } else { |
|
| 1165 | + $tab[$obj->code]=$libelle_type; |
|
| 1166 | + } |
|
| 1110 | 1167 | $i++; |
| 1111 | 1168 | } |
| 1112 | 1169 | return $tab; |
| 1113 | - } |
|
| 1114 | - else |
|
| 1170 | + } else |
|
| 1115 | 1171 | {
|
| 1116 | 1172 | $this->error=$this->db->lasterror(); |
| 1117 | 1173 | //dol_print_error($this->db); |
@@ -1150,19 +1206,29 @@ discard block |
||
| 1150 | 1206 | |
| 1151 | 1207 | $sql = "SELECT ec.fk_socpeople"; |
| 1152 | 1208 | $sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec,"; |
| 1153 | - if ($source == 'internal') $sql.= " ".MAIN_DB_PREFIX."user as c,"; |
|
| 1154 | - if ($source == 'external') $sql.= " ".MAIN_DB_PREFIX."socpeople as c,"; |
|
| 1209 | + if ($source == 'internal') { |
|
| 1210 | + $sql.= " ".MAIN_DB_PREFIX."user as c,"; |
|
| 1211 | + } |
|
| 1212 | + if ($source == 'external') { |
|
| 1213 | + $sql.= " ".MAIN_DB_PREFIX."socpeople as c,"; |
|
| 1214 | + } |
|
| 1155 | 1215 | $sql.= " ".MAIN_DB_PREFIX."c_type_contact as tc"; |
| 1156 | 1216 | $sql.= " WHERE ec.element_id = ".$id; |
| 1157 | 1217 | $sql.= " AND ec.fk_socpeople = c.rowid"; |
| 1158 | - if ($source == 'internal') $sql.= " AND c.entity IN (".getEntity('user').")";
|
|
| 1159 | - if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('societe').")";
|
|
| 1218 | + if ($source == 'internal') { |
|
| 1219 | + $sql.= " AND c.entity IN (".getEntity('user').")"; |
|
| 1220 | + } |
|
| 1221 | + if ($source == 'external') { |
|
| 1222 | + $sql.= " AND c.entity IN (".getEntity('societe').")"; |
|
| 1223 | + } |
|
| 1160 | 1224 | $sql.= " AND ec.fk_c_type_contact = tc.rowid"; |
| 1161 | 1225 | $sql.= " AND tc.element = '".$element."'"; |
| 1162 | 1226 | $sql.= " AND tc.source = '".$source."'"; |
| 1163 | 1227 | $sql.= " AND tc.code = '".$code."'"; |
| 1164 | 1228 | $sql.= " AND tc.active = 1"; |
| 1165 | - if ($status) $sql.= " AND ec.statut = ".$status; |
|
| 1229 | + if ($status) { |
|
| 1230 | + $sql.= " AND ec.statut = ".$status; |
|
| 1231 | + } |
|
| 1166 | 1232 | |
| 1167 | 1233 | dol_syslog(get_class($this)."::getIdContact", LOG_DEBUG); |
| 1168 | 1234 | $resql=$this->db->query($sql); |
@@ -1173,8 +1239,7 @@ discard block |
||
| 1173 | 1239 | $result[$i]=$obj->fk_socpeople; |
| 1174 | 1240 | $i++; |
| 1175 | 1241 | } |
| 1176 | - } |
|
| 1177 | - else |
|
| 1242 | + } else |
|
| 1178 | 1243 | {
|
| 1179 | 1244 | $this->error=$this->db->error(); |
| 1180 | 1245 | return null; |
@@ -1193,9 +1258,13 @@ discard block |
||
| 1193 | 1258 | function fetch_contact($contactid=null) |
| 1194 | 1259 | {
|
| 1195 | 1260 | // phpcs:enable |
| 1196 | - if (empty($contactid)) $contactid=$this->contactid; |
|
| 1261 | + if (empty($contactid)) { |
|
| 1262 | + $contactid=$this->contactid; |
|
| 1263 | + } |
|
| 1197 | 1264 | |
| 1198 | - if (empty($contactid)) return 0; |
|
| 1265 | + if (empty($contactid)) { |
|
| 1266 | + return 0; |
|
| 1267 | + } |
|
| 1199 | 1268 | |
| 1200 | 1269 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
| 1201 | 1270 | $contact = new Contact($this->db); |
@@ -1216,14 +1285,16 @@ discard block |
||
| 1216 | 1285 | // phpcs:enable |
| 1217 | 1286 | global $conf; |
| 1218 | 1287 | |
| 1219 | - if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) |
|
| 1220 | - return 0; |
|
| 1288 | + if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) { |
|
| 1289 | + return 0; |
|
| 1290 | + } |
|
| 1221 | 1291 | |
| 1222 | 1292 | require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
| 1223 | 1293 | |
| 1224 | 1294 | $idtofetch = isset($this->socid) ? $this->socid : (isset($this->fk_soc) ? $this->fk_soc : $this->fk_thirdparty); |
| 1225 | - if ($force_thirdparty_id) |
|
| 1226 | - $idtofetch = $force_thirdparty_id; |
|
| 1295 | + if ($force_thirdparty_id) { |
|
| 1296 | + $idtofetch = $force_thirdparty_id; |
|
| 1297 | + } |
|
| 1227 | 1298 | |
| 1228 | 1299 | if ($idtofetch) {
|
| 1229 | 1300 | $thirdparty = new Societe($this->db); |
@@ -1236,8 +1307,9 @@ discard block |
||
| 1236 | 1307 | } |
| 1237 | 1308 | |
| 1238 | 1309 | return $result; |
| 1239 | - } else |
|
| 1240 | - return -1; |
|
| 1310 | + } else { |
|
| 1311 | + return -1; |
|
| 1312 | + } |
|
| 1241 | 1313 | } |
| 1242 | 1314 | |
| 1243 | 1315 | |
@@ -1283,18 +1355,24 @@ discard block |
||
| 1283 | 1355 | dol_syslog(get_class($this).'::fetch_barcode this->element='.$this->element.' this->barcode_type='.$this->barcode_type); |
| 1284 | 1356 | |
| 1285 | 1357 | $idtype=$this->barcode_type; |
| 1286 | - if (empty($idtype) && $idtype != '0') // If type of barcode no set, we try to guess. If set to '0' it means we forced to have type remain not defined |
|
| 1358 | + if (empty($idtype) && $idtype != '0') { |
|
| 1359 | + // If type of barcode no set, we try to guess. If set to '0' it means we forced to have type remain not defined |
|
| 1287 | 1360 | {
|
| 1288 | - if ($this->element == 'product') $idtype = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 1289 | - else if ($this->element == 'societe') $idtype = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY; |
|
| 1290 | - else dol_syslog('Call fetch_barcode with barcode_type not defined and cant be guessed', LOG_WARNING);
|
|
| 1361 | + if ($this->element == 'product') $idtype = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 1362 | + } else if ($this->element == 'societe') { |
|
| 1363 | + $idtype = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY; |
|
| 1364 | + } else { |
|
| 1365 | + dol_syslog('Call fetch_barcode with barcode_type not defined and cant be guessed', LOG_WARNING); |
|
| 1366 | + } |
|
| 1291 | 1367 | } |
| 1292 | 1368 | |
| 1293 | 1369 | if ($idtype > 0) |
| 1294 | 1370 | {
|
| 1295 | - if (empty($this->barcode_type) || empty($this->barcode_type_code) || empty($this->barcode_type_label) || empty($this->barcode_type_coder)) // If data not already loaded |
|
| 1371 | + if (empty($this->barcode_type) || empty($this->barcode_type_code) || empty($this->barcode_type_label) || empty($this->barcode_type_coder)) { |
|
| 1372 | + // If data not already loaded |
|
| 1296 | 1373 | {
|
| 1297 | - $sql = "SELECT rowid, code, libelle as label, coder"; |
|
| 1374 | + $sql = "SELECT rowid, code, libelle as label, coder"; |
|
| 1375 | + } |
|
| 1298 | 1376 | $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; |
| 1299 | 1377 | $sql.= " WHERE rowid = ".$idtype; |
| 1300 | 1378 | dol_syslog(get_class($this).'::fetch_barcode', LOG_DEBUG); |
@@ -1307,8 +1385,7 @@ discard block |
||
| 1307 | 1385 | $this->barcode_type_label = $obj->label; |
| 1308 | 1386 | $this->barcode_type_coder = $obj->coder; |
| 1309 | 1387 | return 1; |
| 1310 | - } |
|
| 1311 | - else |
|
| 1388 | + } else |
|
| 1312 | 1389 | {
|
| 1313 | 1390 | dol_print_error($this->db); |
| 1314 | 1391 | return -1; |
@@ -1329,8 +1406,13 @@ discard block |
||
| 1329 | 1406 | // phpcs:enable |
| 1330 | 1407 | include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 1331 | 1408 | |
| 1332 | - if (empty($this->fk_project) && ! empty($this->fk_projet)) $this->fk_project = $this->fk_projet; // For backward compatibility |
|
| 1333 | - if (empty($this->fk_project)) return 0; |
|
| 1409 | + if (empty($this->fk_project) && ! empty($this->fk_projet)) { |
|
| 1410 | + $this->fk_project = $this->fk_projet; |
|
| 1411 | + } |
|
| 1412 | + // For backward compatibility |
|
| 1413 | + if (empty($this->fk_project)) { |
|
| 1414 | + return 0; |
|
| 1415 | + } |
|
| 1334 | 1416 | |
| 1335 | 1417 | $project = new Project($this->db); |
| 1336 | 1418 | $result = $project->fetch($this->fk_project); |
@@ -1351,7 +1433,9 @@ discard block |
||
| 1351 | 1433 | // phpcs:enable |
| 1352 | 1434 | include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
| 1353 | 1435 | |
| 1354 | - if (empty($this->fk_product)) return 0; |
|
| 1436 | + if (empty($this->fk_product)) { |
|
| 1437 | + return 0; |
|
| 1438 | + } |
|
| 1355 | 1439 | |
| 1356 | 1440 | $product = new Product($this->db); |
| 1357 | 1441 | $result = $product->fetch($this->fk_product); |
@@ -1385,9 +1469,15 @@ discard block |
||
| 1385 | 1469 | function fetch_origin() |
| 1386 | 1470 | {
|
| 1387 | 1471 | // phpcs:enable |
| 1388 | - if ($this->origin == 'shipping') $this->origin = 'expedition'; |
|
| 1389 | - if ($this->origin == 'delivery') $this->origin = 'livraison'; |
|
| 1390 | - if ($this->origin == 'order_supplier') $this->origin = 'commandeFournisseur'; |
|
| 1472 | + if ($this->origin == 'shipping') { |
|
| 1473 | + $this->origin = 'expedition'; |
|
| 1474 | + } |
|
| 1475 | + if ($this->origin == 'delivery') { |
|
| 1476 | + $this->origin = 'livraison'; |
|
| 1477 | + } |
|
| 1478 | + if ($this->origin == 'order_supplier') { |
|
| 1479 | + $this->origin = 'commandeFournisseur'; |
|
| 1480 | + } |
|
| 1391 | 1481 | |
| 1392 | 1482 | $origin = $this->origin; |
| 1393 | 1483 | |
@@ -1479,29 +1569,48 @@ discard block |
||
| 1479 | 1569 | {
|
| 1480 | 1570 | global $user,$langs,$conf; |
| 1481 | 1571 | |
| 1482 | - if (empty($table)) $table=$this->table_element; |
|
| 1483 | - if (empty($id)) $id=$this->id; |
|
| 1484 | - if (empty($format)) $format='text'; |
|
| 1485 | - if (empty($id_field)) $id_field='rowid'; |
|
| 1572 | + if (empty($table)) { |
|
| 1573 | + $table=$this->table_element; |
|
| 1574 | + } |
|
| 1575 | + if (empty($id)) { |
|
| 1576 | + $id=$this->id; |
|
| 1577 | + } |
|
| 1578 | + if (empty($format)) { |
|
| 1579 | + $format='text'; |
|
| 1580 | + } |
|
| 1581 | + if (empty($id_field)) { |
|
| 1582 | + $id_field='rowid'; |
|
| 1583 | + } |
|
| 1486 | 1584 | |
| 1487 | 1585 | $error=0; |
| 1488 | 1586 | |
| 1489 | 1587 | $this->db->begin(); |
| 1490 | 1588 | |
| 1491 | 1589 | // Special case |
| 1492 | - if ($table == 'product' && $field == 'note_private') $field='note'; |
|
| 1493 | - if (in_array($table, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) $fk_user_field = 'fk_user_mod';
|
|
| 1590 | + if ($table == 'product' && $field == 'note_private') { |
|
| 1591 | + $field='note'; |
|
| 1592 | + } |
|
| 1593 | + if (in_array($table, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) { |
|
| 1594 | + $fk_user_field = 'fk_user_mod'; |
|
| 1595 | + } |
|
| 1494 | 1596 | |
| 1495 | 1597 | $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; |
| 1496 | 1598 | |
| 1497 | - if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; |
|
| 1498 | - else if ($format == 'int') $sql.= $field." = ".$this->db->escape($value); |
|
| 1499 | - else if ($format == 'date') $sql.= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null"); |
|
| 1599 | + if ($format == 'text') { |
|
| 1600 | + $sql.= $field." = '".$this->db->escape($value)."'"; |
|
| 1601 | + } else if ($format == 'int') { |
|
| 1602 | + $sql.= $field." = ".$this->db->escape($value); |
|
| 1603 | + } else if ($format == 'date') { |
|
| 1604 | + $sql.= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null"); |
|
| 1605 | + } |
|
| 1500 | 1606 | |
| 1501 | 1607 | if ($fk_user_field) |
| 1502 | 1608 | {
|
| 1503 | - if (! empty($fuser) && is_object($fuser)) $sql.=", ".$fk_user_field." = ".$fuser->id; |
|
| 1504 | - elseif (empty($fuser) || $fuser != 'none') $sql.=", ".$fk_user_field." = ".$user->id; |
|
| 1609 | + if (! empty($fuser) && is_object($fuser)) { |
|
| 1610 | + $sql.=", ".$fk_user_field." = ".$fuser->id; |
|
| 1611 | + } elseif (empty($fuser) || $fuser != 'none') { |
|
| 1612 | + $sql.=", ".$fk_user_field." = ".$user->id; |
|
| 1613 | + } |
|
| 1505 | 1614 | } |
| 1506 | 1615 | |
| 1507 | 1616 | $sql.= " WHERE ".$id_field." = ".$id; |
@@ -1516,28 +1625,32 @@ discard block |
||
| 1516 | 1625 | if (empty($this->fields) && method_exists($this, 'fetch')) |
| 1517 | 1626 | {
|
| 1518 | 1627 | $result = $this->fetch($id); |
| 1519 | - } |
|
| 1520 | - else |
|
| 1628 | + } else |
|
| 1521 | 1629 | {
|
| 1522 | 1630 | $result = $this->fetchCommon($id); |
| 1523 | 1631 | } |
| 1524 | - if ($result >= 0) $result=$this->call_trigger($trigkey, (! empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors |
|
| 1525 | - if ($result < 0) $error++; |
|
| 1632 | + if ($result >= 0) { |
|
| 1633 | + $result=$this->call_trigger($trigkey, (! empty($fuser) && is_object($fuser)) ? $fuser : $user); |
|
| 1634 | + } |
|
| 1635 | + // This may set this->errors |
|
| 1636 | + if ($result < 0) { |
|
| 1637 | + $error++; |
|
| 1638 | + } |
|
| 1526 | 1639 | } |
| 1527 | 1640 | |
| 1528 | 1641 | if (! $error) |
| 1529 | 1642 | {
|
| 1530 | - if (property_exists($this, $field)) $this->$field = $value; |
|
| 1643 | + if (property_exists($this, $field)) { |
|
| 1644 | + $this->$field = $value; |
|
| 1645 | + } |
|
| 1531 | 1646 | $this->db->commit(); |
| 1532 | 1647 | return 1; |
| 1533 | - } |
|
| 1534 | - else |
|
| 1648 | + } else |
|
| 1535 | 1649 | {
|
| 1536 | 1650 | $this->db->rollback(); |
| 1537 | 1651 | return -2; |
| 1538 | 1652 | } |
| 1539 | - } |
|
| 1540 | - else |
|
| 1653 | + } else |
|
| 1541 | 1654 | {
|
| 1542 | 1655 | $this->error=$this->db->lasterror(); |
| 1543 | 1656 | $this->db->rollback(); |
@@ -1564,36 +1677,66 @@ discard block |
||
| 1564 | 1677 | dol_print_error('',get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined");
|
| 1565 | 1678 | return -1; |
| 1566 | 1679 | } |
| 1567 | - if ($fieldid == 'none') return 1; |
|
| 1680 | + if ($fieldid == 'none') { |
|
| 1681 | + return 1; |
|
| 1682 | + } |
|
| 1568 | 1683 | |
| 1569 | 1684 | // Security on socid |
| 1570 | 1685 | $socid = 0; |
| 1571 | - if ($user->societe_id > 0) $socid = $user->societe_id; |
|
| 1686 | + if ($user->societe_id > 0) { |
|
| 1687 | + $socid = $user->societe_id; |
|
| 1688 | + } |
|
| 1572 | 1689 | |
| 1573 | 1690 | // this->ismultientitymanaged contains |
| 1574 | 1691 | // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe |
| 1575 | 1692 | $alias = 's'; |
| 1576 | - if ($this->element == 'societe') $alias = 'te'; |
|
| 1693 | + if ($this->element == 'societe') { |
|
| 1694 | + $alias = 'te'; |
|
| 1695 | + } |
|
| 1577 | 1696 | |
| 1578 | 1697 | $sql = "SELECT MAX(te.".$fieldid.")"; |
| 1579 | 1698 | $sql.= " FROM ".(empty($nodbprefix)?MAIN_DB_PREFIX:'').$this->table_element." as te"; |
| 1580 | 1699 | if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
| 1581 | 1700 | $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; |
| 1582 | 1701 | } |
| 1583 | - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity |
|
| 1584 | - else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid |
|
| 1585 | - else if ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid |
|
| 1586 | - if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; |
|
| 1702 | + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) { |
|
| 1703 | + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 1704 | + } |
|
| 1705 | + // If we need to link to societe to limit select to entity |
|
| 1706 | + else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 1707 | + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 1708 | + } |
|
| 1709 | + // If we need to link to societe to limit select to socid |
|
| 1710 | + else if ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 1711 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; |
|
| 1712 | + } |
|
| 1713 | + // If we need to link to societe to limit select to socid |
|
| 1714 | + if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) { |
|
| 1715 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; |
|
| 1716 | + } |
|
| 1587 | 1717 | $sql.= " WHERE te.".$fieldid." < '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) |
| 1588 | - if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id; |
|
| 1589 | - if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND (sc.fk_user = " .$user->id.' OR te.fk_soc IS NULL)'; |
|
| 1718 | + if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) { |
|
| 1719 | + $sql.= " AND sc.fk_user = " .$user->id; |
|
| 1720 | + } |
|
| 1721 | + if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) { |
|
| 1722 | + $sql.= " AND (sc.fk_user = " .$user->id.' OR te.fk_soc IS NULL)'; |
|
| 1723 | + } |
|
| 1590 | 1724 | if (! empty($filter)) |
| 1591 | 1725 | {
|
| 1592 | - if (! preg_match('/^\s*AND/i', $filter)) $sql.=" AND "; // For backward compatibility
|
|
| 1726 | + if (! preg_match('/^\s*AND/i', $filter)) { |
|
| 1727 | + $sql.=" AND "; |
|
| 1728 | + } |
|
| 1729 | + // For backward compatibility |
|
| 1593 | 1730 | $sql.=$filter; |
| 1594 | 1731 | } |
| 1595 | - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity |
|
| 1596 | - else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid |
|
| 1732 | + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) { |
|
| 1733 | + $sql.= ' AND te.fk_soc = s.rowid'; |
|
| 1734 | + } |
|
| 1735 | + // If we need to link to societe to limit select to entity |
|
| 1736 | + else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 1737 | + $sql.= ' AND te.fk_soc = s.rowid'; |
|
| 1738 | + } |
|
| 1739 | + // If we need to link to societe to limit select to socid |
|
| 1597 | 1740 | if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
|
| 1598 | 1741 | if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
| 1599 | 1742 | if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
|
@@ -1606,9 +1749,15 @@ discard block |
||
| 1606 | 1749 | $sql.= ' AND te.entity IN ('.getEntity($this->element).')';
|
| 1607 | 1750 | } |
| 1608 | 1751 | } |
| 1609 | - if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql.= ' AND te.fk_soc = ' . $socid; |
|
| 1610 | - if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)'; |
|
| 1611 | - if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql.= ' AND te.rowid = ' . $socid; |
|
| 1752 | + if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') { |
|
| 1753 | + $sql.= ' AND te.fk_soc = ' . $socid; |
|
| 1754 | + } |
|
| 1755 | + if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') { |
|
| 1756 | + $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)'; |
|
| 1757 | + } |
|
| 1758 | + if ($this->restrictiononfksoc && $socid && $this->element == 'societe') { |
|
| 1759 | + $sql.= ' AND te.rowid = ' . $socid; |
|
| 1760 | + } |
|
| 1612 | 1761 | //print 'socid='.$socid.' restrictiononfksoc='.$this->restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>"; |
| 1613 | 1762 | |
| 1614 | 1763 | $result = $this->db->query($sql); |
@@ -1626,20 +1775,44 @@ discard block |
||
| 1626 | 1775 | if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
| 1627 | 1776 | $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; |
| 1628 | 1777 | } |
| 1629 | - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity |
|
| 1630 | - else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid |
|
| 1631 | - else if ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid |
|
| 1632 | - if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; |
|
| 1778 | + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) { |
|
| 1779 | + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 1780 | + } |
|
| 1781 | + // If we need to link to societe to limit select to entity |
|
| 1782 | + else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 1783 | + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; |
|
| 1784 | + } |
|
| 1785 | + // If we need to link to societe to limit select to socid |
|
| 1786 | + else if ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 1787 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; |
|
| 1788 | + } |
|
| 1789 | + // If we need to link to societe to limit select to socid |
|
| 1790 | + if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) { |
|
| 1791 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; |
|
| 1792 | + } |
|
| 1633 | 1793 | $sql.= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists) |
| 1634 | - if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id; |
|
| 1635 | - if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND (sc.fk_user = " .$user->id.' OR te.fk_soc IS NULL)'; |
|
| 1794 | + if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) { |
|
| 1795 | + $sql.= " AND sc.fk_user = " .$user->id; |
|
| 1796 | + } |
|
| 1797 | + if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) { |
|
| 1798 | + $sql.= " AND (sc.fk_user = " .$user->id.' OR te.fk_soc IS NULL)'; |
|
| 1799 | + } |
|
| 1636 | 1800 | if (! empty($filter)) |
| 1637 | 1801 | {
|
| 1638 | - if (! preg_match('/^\s*AND/i', $filter)) $sql.=" AND "; // For backward compatibility
|
|
| 1802 | + if (! preg_match('/^\s*AND/i', $filter)) { |
|
| 1803 | + $sql.=" AND "; |
|
| 1804 | + } |
|
| 1805 | + // For backward compatibility |
|
| 1639 | 1806 | $sql.=$filter; |
| 1640 | 1807 | } |
| 1641 | - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity |
|
| 1642 | - else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid |
|
| 1808 | + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) { |
|
| 1809 | + $sql.= ' AND te.fk_soc = s.rowid'; |
|
| 1810 | + } |
|
| 1811 | + // If we need to link to societe to limit select to entity |
|
| 1812 | + else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) { |
|
| 1813 | + $sql.= ' AND te.fk_soc = s.rowid'; |
|
| 1814 | + } |
|
| 1815 | + // If we need to link to societe to limit select to socid |
|
| 1643 | 1816 | if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
|
| 1644 | 1817 | if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
| 1645 | 1818 | if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
|
@@ -1652,9 +1825,15 @@ discard block |
||
| 1652 | 1825 | $sql.= ' AND te.entity IN ('.getEntity($this->element).')';
|
| 1653 | 1826 | } |
| 1654 | 1827 | } |
| 1655 | - if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql.= ' AND te.fk_soc = ' . $socid; |
|
| 1656 | - if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)'; |
|
| 1657 | - if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql.= ' AND te.rowid = ' . $socid; |
|
| 1828 | + if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') { |
|
| 1829 | + $sql.= ' AND te.fk_soc = ' . $socid; |
|
| 1830 | + } |
|
| 1831 | + if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') { |
|
| 1832 | + $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)'; |
|
| 1833 | + } |
|
| 1834 | + if ($this->restrictiononfksoc && $socid && $this->element == 'societe') { |
|
| 1835 | + $sql.= ' AND te.rowid = ' . $socid; |
|
| 1836 | + } |
|
| 1658 | 1837 | //print 'socid='.$socid.' restrictiononfksoc='.$this->restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>"; |
| 1659 | 1838 | // Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null |
| 1660 | 1839 | |
@@ -1686,8 +1865,11 @@ discard block |
||
| 1686 | 1865 | $i = 0; |
| 1687 | 1866 | while ($i < $num) |
| 1688 | 1867 | {
|
| 1689 | - if ($source == 'thirdparty') $contactAlreadySelected[$i] = $tab[$i]['socid']; |
|
| 1690 | - else $contactAlreadySelected[$i] = $tab[$i]['id']; |
|
| 1868 | + if ($source == 'thirdparty') { |
|
| 1869 | + $contactAlreadySelected[$i] = $tab[$i]['socid']; |
|
| 1870 | + } else { |
|
| 1871 | + $contactAlreadySelected[$i] = $tab[$i]['id']; |
|
| 1872 | + } |
|
| 1691 | 1873 | $i++; |
| 1692 | 1874 | } |
| 1693 | 1875 | return $contactAlreadySelected; |
@@ -1711,14 +1893,19 @@ discard block |
||
| 1711 | 1893 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 1712 | 1894 | if ($this->table_element == 'actioncomm') |
| 1713 | 1895 | {
|
| 1714 | - if ($projectid) $sql.= ' SET fk_project = '.$projectid; |
|
| 1715 | - else $sql.= ' SET fk_project = NULL'; |
|
| 1896 | + if ($projectid) { |
|
| 1897 | + $sql.= ' SET fk_project = '.$projectid; |
|
| 1898 | + } else { |
|
| 1899 | + $sql.= ' SET fk_project = NULL'; |
|
| 1900 | + } |
|
| 1716 | 1901 | $sql.= ' WHERE id = '.$this->id; |
| 1717 | - } |
|
| 1718 | - else |
|
| 1902 | + } else |
|
| 1719 | 1903 | {
|
| 1720 | - if ($projectid) $sql.= ' SET fk_projet = '.$projectid; |
|
| 1721 | - else $sql.= ' SET fk_projet = NULL'; |
|
| 1904 | + if ($projectid) { |
|
| 1905 | + $sql.= ' SET fk_projet = '.$projectid; |
|
| 1906 | + } else { |
|
| 1907 | + $sql.= ' SET fk_projet = NULL'; |
|
| 1908 | + } |
|
| 1722 | 1909 | $sql.= ' WHERE rowid = '.$this->id; |
| 1723 | 1910 | } |
| 1724 | 1911 | |
@@ -1727,8 +1914,7 @@ discard block |
||
| 1727 | 1914 | {
|
| 1728 | 1915 | $this->fk_project = $projectid; |
| 1729 | 1916 | return 1; |
| 1730 | - } |
|
| 1731 | - else |
|
| 1917 | + } else |
|
| 1732 | 1918 | {
|
| 1733 | 1919 | dol_print_error($this->db); |
| 1734 | 1920 | return -1; |
@@ -1748,8 +1934,12 @@ discard block |
||
| 1748 | 1934 | {
|
| 1749 | 1935 | // TODO uniformize field name |
| 1750 | 1936 | $fieldname = 'fk_mode_reglement'; |
| 1751 | - if ($this->element == 'societe') $fieldname = 'mode_reglement'; |
|
| 1752 | - if (get_class($this) == 'Fournisseur') $fieldname = 'mode_reglement_supplier'; |
|
| 1937 | + if ($this->element == 'societe') { |
|
| 1938 | + $fieldname = 'mode_reglement'; |
|
| 1939 | + } |
|
| 1940 | + if (get_class($this) == 'Fournisseur') { |
|
| 1941 | + $fieldname = 'mode_reglement_supplier'; |
|
| 1942 | + } |
|
| 1753 | 1943 | |
| 1754 | 1944 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 1755 | 1945 | $sql .= ' SET '.$fieldname.' = '.$id; |
@@ -1759,17 +1949,17 @@ discard block |
||
| 1759 | 1949 | {
|
| 1760 | 1950 | $this->mode_reglement_id = $id; |
| 1761 | 1951 | // for supplier |
| 1762 | - if (get_class($this) == 'Fournisseur') $this->mode_reglement_supplier_id = $id; |
|
| 1952 | + if (get_class($this) == 'Fournisseur') { |
|
| 1953 | + $this->mode_reglement_supplier_id = $id; |
|
| 1954 | + } |
|
| 1763 | 1955 | return 1; |
| 1764 | - } |
|
| 1765 | - else |
|
| 1956 | + } else |
|
| 1766 | 1957 | {
|
| 1767 | 1958 | dol_syslog(get_class($this).'::setPaymentMethods Erreur '.$sql.' - '.$this->db->error()); |
| 1768 | 1959 | $this->error=$this->db->error(); |
| 1769 | 1960 | return -1; |
| 1770 | 1961 | } |
| 1771 | - } |
|
| 1772 | - else |
|
| 1962 | + } else |
|
| 1773 | 1963 | {
|
| 1774 | 1964 | dol_syslog(get_class($this).'::setPaymentMethods, status of the object is incompatible'); |
| 1775 | 1965 | $this->error='Status of the object is incompatible '.$this->statut; |
@@ -1799,18 +1989,18 @@ discard block |
||
| 1799 | 1989 | $this->multicurrency_code = $code; |
| 1800 | 1990 | |
| 1801 | 1991 | list($fk_multicurrency, $rate) = MultiCurrency::getIdAndTxFromCode($this->db, $code); |
| 1802 | - if ($rate) $this->setMulticurrencyRate($rate,2); |
|
| 1992 | + if ($rate) { |
|
| 1993 | + $this->setMulticurrencyRate($rate,2); |
|
| 1994 | + } |
|
| 1803 | 1995 | |
| 1804 | 1996 | return 1; |
| 1805 | - } |
|
| 1806 | - else |
|
| 1997 | + } else |
|
| 1807 | 1998 | {
|
| 1808 | 1999 | dol_syslog(get_class($this).'::setMulticurrencyCode Erreur '.$sql.' - '.$this->db->error()); |
| 1809 | 2000 | $this->error=$this->db->error(); |
| 1810 | 2001 | return -1; |
| 1811 | 2002 | } |
| 1812 | - } |
|
| 1813 | - else |
|
| 2003 | + } else |
|
| 1814 | 2004 | {
|
| 1815 | 2005 | dol_syslog(get_class($this).'::setMulticurrencyCode, status of the object is incompatible'); |
| 1816 | 2006 | $this->error='Status of the object is incompatible '.$this->statut; |
@@ -1904,15 +2094,13 @@ discard block |
||
| 1904 | 2094 | } |
| 1905 | 2095 | |
| 1906 | 2096 | return 1; |
| 1907 | - } |
|
| 1908 | - else |
|
| 2097 | + } else |
|
| 1909 | 2098 | {
|
| 1910 | 2099 | dol_syslog(get_class($this).'::setMulticurrencyRate Erreur '.$sql.' - '.$this->db->error()); |
| 1911 | 2100 | $this->error=$this->db->error(); |
| 1912 | 2101 | return -1; |
| 1913 | 2102 | } |
| 1914 | - } |
|
| 1915 | - else |
|
| 2103 | + } else |
|
| 1916 | 2104 | {
|
| 1917 | 2105 | dol_syslog(get_class($this).'::setMulticurrencyRate, status of the object is incompatible'); |
| 1918 | 2106 | $this->error='Status of the object is incompatible '.$this->statut; |
@@ -1933,8 +2121,12 @@ discard block |
||
| 1933 | 2121 | {
|
| 1934 | 2122 | // TODO uniformize field name |
| 1935 | 2123 | $fieldname = 'fk_cond_reglement'; |
| 1936 | - if ($this->element == 'societe') $fieldname = 'cond_reglement'; |
|
| 1937 | - if (get_class($this) == 'Fournisseur') $fieldname = 'cond_reglement_supplier'; |
|
| 2124 | + if ($this->element == 'societe') { |
|
| 2125 | + $fieldname = 'cond_reglement'; |
|
| 2126 | + } |
|
| 2127 | + if (get_class($this) == 'Fournisseur') { |
|
| 2128 | + $fieldname = 'cond_reglement_supplier'; |
|
| 2129 | + } |
|
| 1938 | 2130 | |
| 1939 | 2131 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 1940 | 2132 | $sql .= ' SET '.$fieldname.' = '.$id; |
@@ -1944,18 +2136,18 @@ discard block |
||
| 1944 | 2136 | {
|
| 1945 | 2137 | $this->cond_reglement_id = $id; |
| 1946 | 2138 | // for supplier |
| 1947 | - if (get_class($this) == 'Fournisseur') $this->cond_reglement_supplier_id = $id; |
|
| 2139 | + if (get_class($this) == 'Fournisseur') { |
|
| 2140 | + $this->cond_reglement_supplier_id = $id; |
|
| 2141 | + } |
|
| 1948 | 2142 | $this->cond_reglement = $id; // for compatibility |
| 1949 | 2143 | return 1; |
| 1950 | - } |
|
| 1951 | - else |
|
| 2144 | + } else |
|
| 1952 | 2145 | {
|
| 1953 | 2146 | dol_syslog(get_class($this).'::setPaymentTerms Erreur '.$sql.' - '.$this->db->error()); |
| 1954 | 2147 | $this->error=$this->db->error(); |
| 1955 | 2148 | return -1; |
| 1956 | 2149 | } |
| 1957 | - } |
|
| 1958 | - else |
|
| 2150 | + } else |
|
| 1959 | 2151 | {
|
| 1960 | 2152 | dol_syslog(get_class($this).'::setPaymentTerms, status of the object is incompatible'); |
| 1961 | 2153 | $this->error='Status of the object is incompatible '.$this->statut; |
@@ -1973,7 +2165,9 @@ discard block |
||
| 1973 | 2165 | function setDeliveryAddress($id) |
| 1974 | 2166 | {
|
| 1975 | 2167 | $fieldname = 'fk_delivery_address'; |
| 1976 | - if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address'; |
|
| 2168 | + if ($this->element == 'delivery' || $this->element == 'shipping') { |
|
| 2169 | + $fieldname = 'fk_address'; |
|
| 2170 | + } |
|
| 1977 | 2171 | |
| 1978 | 2172 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".$id; |
| 1979 | 2173 | $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; |
@@ -1982,8 +2176,7 @@ discard block |
||
| 1982 | 2176 | {
|
| 1983 | 2177 | $this->fk_delivery_address = $id; |
| 1984 | 2178 | return 1; |
| 1985 | - } |
|
| 1986 | - else |
|
| 2179 | + } else |
|
| 1987 | 2180 | {
|
| 1988 | 2181 | $this->error=$this->db->error(); |
| 1989 | 2182 | dol_syslog(get_class($this).'::setDeliveryAddress Erreur '.$sql.' - '.$this->error); |
@@ -2005,7 +2198,9 @@ discard block |
||
| 2005 | 2198 | {
|
| 2006 | 2199 | global $user; |
| 2007 | 2200 | |
| 2008 | - if (empty($userused)) $userused=$user; |
|
| 2201 | + if (empty($userused)) { |
|
| 2202 | + $userused=$user; |
|
| 2203 | + } |
|
| 2009 | 2204 | |
| 2010 | 2205 | $error = 0; |
| 2011 | 2206 | |
@@ -2016,7 +2211,9 @@ discard block |
||
| 2016 | 2211 | |
| 2017 | 2212 | $this->db->begin(); |
| 2018 | 2213 | |
| 2019 | - if ($shipping_method_id<0) $shipping_method_id='NULL'; |
|
| 2214 | + if ($shipping_method_id<0) { |
|
| 2215 | + $shipping_method_id='NULL'; |
|
| 2216 | + } |
|
| 2020 | 2217 | dol_syslog(get_class($this).'::setShippingMethod('.$shipping_method_id.')');
|
| 2021 | 2218 | |
| 2022 | 2219 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
@@ -2033,7 +2230,9 @@ discard block |
||
| 2033 | 2230 | // Call trigger |
| 2034 | 2231 | $this->context=array('shippingmethodupdate'=>1);
|
| 2035 | 2232 | $result = $this->call_trigger(strtoupper(get_class($this)) . '_MODIFY', $userused); |
| 2036 | - if ($result < 0) $error++; |
|
| 2233 | + if ($result < 0) { |
|
| 2234 | + $error++; |
|
| 2235 | + } |
|
| 2037 | 2236 | // End call trigger |
| 2038 | 2237 | } |
| 2039 | 2238 | } |
@@ -2061,7 +2260,9 @@ discard block |
||
| 2061 | 2260 | dol_syslog(get_class($this)."::setWarehouse was called on objet with property table_element not defined",LOG_ERR); |
| 2062 | 2261 | return -1; |
| 2063 | 2262 | } |
| 2064 | - if ($warehouse_id<0) $warehouse_id='NULL'; |
|
| 2263 | + if ($warehouse_id<0) { |
|
| 2264 | + $warehouse_id='NULL'; |
|
| 2265 | + } |
|
| 2065 | 2266 | dol_syslog(get_class($this).'::setWarehouse('.$warehouse_id.')');
|
| 2066 | 2267 | |
| 2067 | 2268 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
@@ -2108,8 +2309,7 @@ discard block |
||
| 2108 | 2309 | {
|
| 2109 | 2310 | $this->modelpdf=$modelpdf; |
| 2110 | 2311 | return 1; |
| 2111 | - } |
|
| 2112 | - else |
|
| 2312 | + } else |
|
| 2113 | 2313 | {
|
| 2114 | 2314 | dol_print_error($this->db); |
| 2115 | 2315 | return 0; |
@@ -2129,7 +2329,9 @@ discard block |
||
| 2129 | 2329 | {
|
| 2130 | 2330 | global $user; |
| 2131 | 2331 | |
| 2132 | - if (empty($userused)) $userused=$user; |
|
| 2332 | + if (empty($userused)) { |
|
| 2333 | + $userused=$user; |
|
| 2334 | + } |
|
| 2133 | 2335 | |
| 2134 | 2336 | $error = 0; |
| 2135 | 2337 | |
@@ -2139,7 +2341,9 @@ discard block |
||
| 2139 | 2341 | } |
| 2140 | 2342 | $this->db->begin(); |
| 2141 | 2343 | |
| 2142 | - if ($fk_account<0) $fk_account='NULL'; |
|
| 2344 | + if ($fk_account<0) { |
|
| 2345 | + $fk_account='NULL'; |
|
| 2346 | + } |
|
| 2143 | 2347 | dol_syslog(get_class($this).'::setBankAccount('.$fk_account.')');
|
| 2144 | 2348 | |
| 2145 | 2349 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
@@ -2152,15 +2356,16 @@ discard block |
||
| 2152 | 2356 | dol_syslog(get_class($this).'::setBankAccount Error '.$sql.' - '.$this->db->error()); |
| 2153 | 2357 | $this->error = $this->db->lasterror(); |
| 2154 | 2358 | $error++; |
| 2155 | - } |
|
| 2156 | - else |
|
| 2359 | + } else |
|
| 2157 | 2360 | {
|
| 2158 | 2361 | if (!$notrigger) |
| 2159 | 2362 | {
|
| 2160 | 2363 | // Call trigger |
| 2161 | 2364 | $this->context=array('bankaccountupdate'=>1);
|
| 2162 | 2365 | $result = $this->call_trigger(strtoupper(get_class($this)) . '_MODIFY', $userused); |
| 2163 | - if ($result < 0) $error++; |
|
| 2366 | + if ($result < 0) { |
|
| 2367 | + $error++; |
|
| 2368 | + } |
|
| 2164 | 2369 | // End call trigger |
| 2165 | 2370 | } |
| 2166 | 2371 | } |
@@ -2168,8 +2373,7 @@ discard block |
||
| 2168 | 2373 | {
|
| 2169 | 2374 | $this->db->rollback(); |
| 2170 | 2375 | return -1; |
| 2171 | - } |
|
| 2172 | - else |
|
| 2376 | + } else |
|
| 2173 | 2377 | {
|
| 2174 | 2378 | $this->fk_account = ($fk_account=='NULL')?null:$fk_account; |
| 2175 | 2379 | $this->db->commit(); |
@@ -2208,8 +2412,12 @@ discard block |
||
| 2208 | 2412 | $nl=0; |
| 2209 | 2413 | $sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2210 | 2414 | $sql.= ' WHERE '.$this->fk_element.'='.$this->id; |
| 2211 | - if (! $renum) $sql.= ' AND rang = 0'; |
|
| 2212 | - if ($renum) $sql.= ' AND rang <> 0'; |
|
| 2415 | + if (! $renum) { |
|
| 2416 | + $sql.= ' AND rang = 0'; |
|
| 2417 | + } |
|
| 2418 | + if ($renum) { |
|
| 2419 | + $sql.= ' AND rang <> 0'; |
|
| 2420 | + } |
|
| 2213 | 2421 | |
| 2214 | 2422 | dol_syslog(get_class($this)."::line_order", LOG_DEBUG); |
| 2215 | 2423 | $resql = $this->db->query($sql); |
@@ -2217,8 +2425,9 @@ discard block |
||
| 2217 | 2425 | {
|
| 2218 | 2426 | $row = $this->db->fetch_row($resql); |
| 2219 | 2427 | $nl = $row[0]; |
| 2220 | - } |
|
| 2221 | - else dol_print_error($this->db); |
|
| 2428 | + } else { |
|
| 2429 | + dol_print_error($this->db); |
|
| 2430 | + } |
|
| 2222 | 2431 | if ($nl > 0) |
| 2223 | 2432 | {
|
| 2224 | 2433 | // The goal of this part is to reorder all lines, with all children lines sharing the same |
@@ -2228,7 +2437,9 @@ discard block |
||
| 2228 | 2437 | // We first search all lines that are parent lines (for multilevel details lines) |
| 2229 | 2438 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2230 | 2439 | $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
| 2231 | - if ($fk_parent_line) $sql.= ' AND fk_parent_line IS NULL'; |
|
| 2440 | + if ($fk_parent_line) { |
|
| 2441 | + $sql.= ' AND fk_parent_line IS NULL'; |
|
| 2442 | + } |
|
| 2232 | 2443 | $sql.= ' ORDER BY rang ASC, rowid '.$rowidorder; |
| 2233 | 2444 | |
| 2234 | 2445 | dol_syslog(get_class($this)."::line_order search all parent lines", LOG_DEBUG); |
@@ -2260,8 +2471,7 @@ discard block |
||
| 2260 | 2471 | $this->updateRangOfLine($row, ($key+1)); |
| 2261 | 2472 | } |
| 2262 | 2473 | } |
| 2263 | - } |
|
| 2264 | - else |
|
| 2474 | + } else |
|
| 2265 | 2475 | {
|
| 2266 | 2476 | dol_print_error($this->db); |
| 2267 | 2477 | } |
@@ -2354,7 +2564,9 @@ discard block |
||
| 2354 | 2564 | function updateRangOfLine($rowid,$rang) |
| 2355 | 2565 | {
|
| 2356 | 2566 | $fieldposition = 'rang'; |
| 2357 | - if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position';
|
|
| 2567 | + if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) { |
|
| 2568 | + $fieldposition = 'position'; |
|
| 2569 | + } |
|
| 2358 | 2570 | |
| 2359 | 2571 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; |
| 2360 | 2572 | $sql.= ' WHERE rowid = '.$rowid; |
@@ -2395,7 +2607,9 @@ discard block |
||
| 2395 | 2607 | if ($rang > 1) |
| 2396 | 2608 | {
|
| 2397 | 2609 | $fieldposition = 'rang'; |
| 2398 | - if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position';
|
|
| 2610 | + if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) { |
|
| 2611 | + $fieldposition = 'position'; |
|
| 2612 | + } |
|
| 2399 | 2613 | |
| 2400 | 2614 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang ; |
| 2401 | 2615 | $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
@@ -2408,8 +2622,7 @@ discard block |
||
| 2408 | 2622 | {
|
| 2409 | 2623 | dol_print_error($this->db); |
| 2410 | 2624 | } |
| 2411 | - } |
|
| 2412 | - else |
|
| 2625 | + } else |
|
| 2413 | 2626 | {
|
| 2414 | 2627 | dol_print_error($this->db); |
| 2415 | 2628 | } |
@@ -2429,7 +2642,9 @@ discard block |
||
| 2429 | 2642 | if ($rang < $max) |
| 2430 | 2643 | {
|
| 2431 | 2644 | $fieldposition = 'rang'; |
| 2432 | - if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position';
|
|
| 2645 | + if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) { |
|
| 2646 | + $fieldposition = 'position'; |
|
| 2647 | + } |
|
| 2433 | 2648 | |
| 2434 | 2649 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; |
| 2435 | 2650 | $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
@@ -2442,8 +2657,7 @@ discard block |
||
| 2442 | 2657 | {
|
| 2443 | 2658 | dol_print_error($this->db); |
| 2444 | 2659 | } |
| 2445 | - } |
|
| 2446 | - else |
|
| 2660 | + } else |
|
| 2447 | 2661 | {
|
| 2448 | 2662 | dol_print_error($this->db); |
| 2449 | 2663 | } |
@@ -2514,8 +2728,7 @@ discard block |
||
| 2514 | 2728 | if (! empty($row[0])) |
| 2515 | 2729 | {
|
| 2516 | 2730 | return $row[0]; |
| 2517 | - } |
|
| 2518 | - else |
|
| 2731 | + } else |
|
| 2519 | 2732 | {
|
| 2520 | 2733 | return $this->getRangOfLine($fk_parent_line); |
| 2521 | 2734 | } |
@@ -2562,8 +2775,7 @@ discard block |
||
| 2562 | 2775 | {
|
| 2563 | 2776 | $this->ref_ext = $ref_ext; |
| 2564 | 2777 | return 1; |
| 2565 | - } |
|
| 2566 | - else |
|
| 2778 | + } else |
|
| 2567 | 2779 | {
|
| 2568 | 2780 | $this->error=$this->db->error(); |
| 2569 | 2781 | return -1; |
@@ -2597,7 +2809,9 @@ discard block |
||
| 2597 | 2809 | } |
| 2598 | 2810 | // Special cas |
| 2599 | 2811 | //var_dump($this->table_element);exit; |
| 2600 | - if ($this->table_element == 'product') $suffix=''; |
|
| 2812 | + if ($this->table_element == 'product') { |
|
| 2813 | + $suffix=''; |
|
| 2814 | + } |
|
| 2601 | 2815 | |
| 2602 | 2816 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; |
| 2603 | 2817 | $sql.= " SET note".$suffix." = ".(!empty($note)?("'".$this->db->escape($note)."'"):"NULL");
|
@@ -2607,16 +2821,17 @@ discard block |
||
| 2607 | 2821 | dol_syslog(get_class($this)."::update_note", LOG_DEBUG); |
| 2608 | 2822 | if ($this->db->query($sql)) |
| 2609 | 2823 | {
|
| 2610 | - if ($suffix == '_public') $this->note_public = $note; |
|
| 2611 | - else if ($suffix == '_private') $this->note_private = $note; |
|
| 2612 | - else |
|
| 2824 | + if ($suffix == '_public') { |
|
| 2825 | + $this->note_public = $note; |
|
| 2826 | + } else if ($suffix == '_private') { |
|
| 2827 | + $this->note_private = $note; |
|
| 2828 | + } else |
|
| 2613 | 2829 | {
|
| 2614 | 2830 | $this->note = $note; // deprecated |
| 2615 | 2831 | $this->note_private = $note; |
| 2616 | 2832 | } |
| 2617 | 2833 | return 1; |
| 2618 | - } |
|
| 2619 | - else |
|
| 2834 | + } else |
|
| 2620 | 2835 | {
|
| 2621 | 2836 | $this->error=$this->db->lasterror(); |
| 2622 | 2837 | return -1; |
@@ -2656,36 +2871,45 @@ discard block |
||
| 2656 | 2871 | |
| 2657 | 2872 | // Some external module want no update price after a trigger because they have another method to calculate the total (ex: with an extrafield) |
| 2658 | 2873 | $MODULE = ""; |
| 2659 | - if ($this->element == 'propal') |
|
| 2660 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_PROPOSAL"; |
|
| 2661 | - elseif ($this->element == 'order') |
|
| 2662 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_ORDER"; |
|
| 2663 | - elseif ($this->element == 'facture') |
|
| 2664 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_INVOICE"; |
|
| 2665 | - elseif ($this->element == 'facture_fourn') |
|
| 2666 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_INVOICE"; |
|
| 2667 | - elseif ($this->element == 'order_supplier') |
|
| 2668 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_ORDER"; |
|
| 2669 | - elseif ($this->element == 'supplier_proposal') |
|
| 2670 | - $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_PROPOSAL"; |
|
| 2874 | + if ($this->element == 'propal') { |
|
| 2875 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_PROPOSAL"; |
|
| 2876 | + } elseif ($this->element == 'order') { |
|
| 2877 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_ORDER"; |
|
| 2878 | + } elseif ($this->element == 'facture') { |
|
| 2879 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_INVOICE"; |
|
| 2880 | + } elseif ($this->element == 'facture_fourn') { |
|
| 2881 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_INVOICE"; |
|
| 2882 | + } elseif ($this->element == 'order_supplier') { |
|
| 2883 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_ORDER"; |
|
| 2884 | + } elseif ($this->element == 'supplier_proposal') { |
|
| 2885 | + $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_PROPOSAL"; |
|
| 2886 | + } |
|
| 2671 | 2887 | |
| 2672 | 2888 | if (! empty($MODULE)) {
|
| 2673 | 2889 | if (! empty($conf->global->$MODULE)) {
|
| 2674 | 2890 | $modsactivated = explode(',', $conf->global->$MODULE);
|
| 2675 | 2891 | foreach ($modsactivated as $mod) {
|
| 2676 | - if ($conf->$mod->enabled) |
|
| 2677 | - return 1; // update was disabled by specific setup |
|
| 2892 | + if ($conf->$mod->enabled) { |
|
| 2893 | + return 1; |
|
| 2894 | + } |
|
| 2895 | + // update was disabled by specific setup |
|
| 2678 | 2896 | } |
| 2679 | 2897 | } |
| 2680 | 2898 | } |
| 2681 | 2899 | |
| 2682 | 2900 | include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; |
| 2683 | 2901 | |
| 2684 | - if ($roundingadjust == '-1') $roundingadjust='auto'; // For backward compatibility |
|
| 2902 | + if ($roundingadjust == '-1') { |
|
| 2903 | + $roundingadjust='auto'; |
|
| 2904 | + } |
|
| 2905 | + // For backward compatibility |
|
| 2685 | 2906 | |
| 2686 | 2907 | $forcedroundingmode=$roundingadjust; |
| 2687 | - if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) $forcedroundingmode=$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND; |
|
| 2688 | - elseif ($forcedroundingmode == 'auto') $forcedroundingmode='0'; |
|
| 2908 | + if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) { |
|
| 2909 | + $forcedroundingmode=$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND; |
|
| 2910 | + } elseif ($forcedroundingmode == 'auto') { |
|
| 2911 | + $forcedroundingmode='0'; |
|
| 2912 | + } |
|
| 2689 | 2913 | |
| 2690 | 2914 | $error=0; |
| 2691 | 2915 | |
@@ -2708,15 +2932,22 @@ discard block |
||
| 2708 | 2932 | |
| 2709 | 2933 | $sql = 'SELECT rowid, qty, '.$fieldup.' as up, remise_percent, total_ht, '.$fieldtva.' as total_tva, total_ttc, '.$fieldlocaltax1.' as total_localtax1, '.$fieldlocaltax2.' as total_localtax2,'; |
| 2710 | 2934 | $sql.= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type'; |
| 2711 | - if ($this->table_element_line == 'facturedet') $sql.= ', situation_percent'; |
|
| 2935 | + if ($this->table_element_line == 'facturedet') { |
|
| 2936 | + $sql.= ', situation_percent'; |
|
| 2937 | + } |
|
| 2712 | 2938 | $sql.= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; |
| 2713 | 2939 | $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line; |
| 2714 | 2940 | $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; |
| 2715 | 2941 | if ($exclspec) |
| 2716 | 2942 | {
|
| 2717 | 2943 | $product_field='product_type'; |
| 2718 | - if ($this->table_element_line == 'contratdet') $product_field=''; // contratdet table has no product_type field |
|
| 2719 | - if ($product_field) $sql.= ' AND '.$product_field.' <> 9'; |
|
| 2944 | + if ($this->table_element_line == 'contratdet') { |
|
| 2945 | + $product_field=''; |
|
| 2946 | + } |
|
| 2947 | + // contratdet table has no product_type field |
|
| 2948 | + if ($product_field) { |
|
| 2949 | + $sql.= ' AND '.$product_field.' <> 9'; |
|
| 2950 | + } |
|
| 2720 | 2951 | } |
| 2721 | 2952 | $sql.= ' ORDER by rowid'; // We want to be sure to always use same order of line to not change lines differently when option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND is used |
| 2722 | 2953 | |
@@ -2746,9 +2977,11 @@ discard block |
||
| 2746 | 2977 | $parameters=array('fk_element' => $obj->rowid);
|
| 2747 | 2978 | $reshook = $hookmanager->executeHooks('changeRoundingMode', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
| 2748 | 2979 | |
| 2749 | - if (empty($reshook) && $forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' |
|
| 2980 | + if (empty($reshook) && $forcedroundingmode == '0') { |
|
| 2981 | + // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' |
|
| 2750 | 2982 | {
|
| 2751 | - $localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx); |
|
| 2983 | + $localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx); |
|
| 2984 | + } |
|
| 2752 | 2985 | $tmpcal=calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx); |
| 2753 | 2986 | $diff=price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); |
| 2754 | 2987 | if ($diff) |
@@ -2756,7 +2989,9 @@ discard block |
||
| 2756 | 2989 | $sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".$tmpcal[1].", total_ttc = ".$tmpcal[2]." WHERE rowid = ".$obj->rowid; |
| 2757 | 2990 | dol_syslog('We found unconsistent data into detailed line (difference of '.$diff.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix);
|
| 2758 | 2991 | $resqlfix=$this->db->query($sqlfix); |
| 2759 | - if (! $resqlfix) dol_print_error($this->db,'Failed to update line'); |
|
| 2992 | + if (! $resqlfix) { |
|
| 2993 | + dol_print_error($this->db,'Failed to update line'); |
|
| 2994 | + } |
|
| 2760 | 2995 | $obj->total_tva = $tmpcal[1]; |
| 2761 | 2996 | $obj->total_ttc = $tmpcal[2]; |
| 2762 | 2997 | // |
@@ -2772,16 +3007,24 @@ discard block |
||
| 2772 | 3007 | $this->multicurrency_total_tva += $obj->multicurrency_total_tva; |
| 2773 | 3008 | $this->multicurrency_total_ttc += $obj->multicurrency_total_ttc; |
| 2774 | 3009 | |
| 2775 | - if (! isset($total_ht_by_vats[$obj->vatrate])) $total_ht_by_vats[$obj->vatrate]=0; |
|
| 2776 | - if (! isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate]=0; |
|
| 2777 | - if (! isset($total_ttc_by_vats[$obj->vatrate])) $total_ttc_by_vats[$obj->vatrate]=0; |
|
| 3010 | + if (! isset($total_ht_by_vats[$obj->vatrate])) { |
|
| 3011 | + $total_ht_by_vats[$obj->vatrate]=0; |
|
| 3012 | + } |
|
| 3013 | + if (! isset($total_tva_by_vats[$obj->vatrate])) { |
|
| 3014 | + $total_tva_by_vats[$obj->vatrate]=0; |
|
| 3015 | + } |
|
| 3016 | + if (! isset($total_ttc_by_vats[$obj->vatrate])) { |
|
| 3017 | + $total_ttc_by_vats[$obj->vatrate]=0; |
|
| 3018 | + } |
|
| 2778 | 3019 | $total_ht_by_vats[$obj->vatrate] += $obj->total_ht; |
| 2779 | 3020 | $total_tva_by_vats[$obj->vatrate] += $obj->total_tva; |
| 2780 | 3021 | $total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc; |
| 2781 | 3022 | |
| 2782 | - if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency |
|
| 3023 | + if ($forcedroundingmode == '1') { |
|
| 3024 | + // Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency |
|
| 2783 | 3025 | {
|
| 2784 | - $tmpvat=price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); |
|
| 3026 | + $tmpvat=price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); |
|
| 3027 | + } |
|
| 2785 | 3028 | $diff=price2num($total_tva_by_vats[$obj->vatrate]-$tmpvat, 'MT', 1); |
| 2786 | 3029 | //print 'Line '.$i.' rowid='.$obj->rowid.' vat_rate='.$obj->vatrate.' total_ht='.$obj->total_ht.' total_tva='.$obj->total_tva.' total_ttc='.$obj->total_ttc.' total_ht_by_vats='.$total_ht_by_vats[$obj->vatrate].' total_tva_by_vats='.$total_tva_by_vats[$obj->vatrate].' (new calculation = '.$tmpvat.') total_ttc_by_vats='.$total_ttc_by_vats[$obj->vatrate].($diff?" => DIFF":"")."<br>\n"; |
| 2787 | 3030 | if ($diff) |
@@ -2790,7 +3033,9 @@ discard block |
||
| 2790 | 3033 | $sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".($obj->total_tva - $diff).", total_ttc = ".($obj->total_ttc - $diff)." WHERE rowid = ".$obj->rowid; |
| 2791 | 3034 | dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix);
|
| 2792 | 3035 | $resqlfix=$this->db->query($sqlfix); |
| 2793 | - if (! $resqlfix) dol_print_error($this->db,'Failed to update line'); |
|
| 3036 | + if (! $resqlfix) { |
|
| 3037 | + dol_print_error($this->db,'Failed to update line'); |
|
| 3038 | + } |
|
| 2794 | 3039 | $this->total_tva -= $diff; |
| 2795 | 3040 | $this->total_ttc -= $diff; |
| 2796 | 3041 | $total_tva_by_vats[$obj->vatrate] -= $diff; |
@@ -2831,11 +3076,21 @@ discard block |
||
| 2831 | 3076 | $fieldlocaltax2='localtax2'; |
| 2832 | 3077 | $fieldttc='total_ttc'; |
| 2833 | 3078 | // Specific code for backward compatibility with old field names |
| 2834 | - if ($this->element == 'facture' || $this->element == 'facturerec') $fieldht='total'; |
|
| 2835 | - if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva'; |
|
| 2836 | - if ($this->element == 'propal') $fieldttc='total'; |
|
| 2837 | - if ($this->element == 'expensereport') $fieldtva='total_tva'; |
|
| 2838 | - if ($this->element == 'supplier_proposal') $fieldttc='total'; |
|
| 3079 | + if ($this->element == 'facture' || $this->element == 'facturerec') { |
|
| 3080 | + $fieldht='total'; |
|
| 3081 | + } |
|
| 3082 | + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { |
|
| 3083 | + $fieldtva='total_tva'; |
|
| 3084 | + } |
|
| 3085 | + if ($this->element == 'propal') { |
|
| 3086 | + $fieldttc='total'; |
|
| 3087 | + } |
|
| 3088 | + if ($this->element == 'expensereport') { |
|
| 3089 | + $fieldtva='total_tva'; |
|
| 3090 | + } |
|
| 3091 | + if ($this->element == 'supplier_proposal') { |
|
| 3092 | + $fieldttc='total'; |
|
| 3093 | + } |
|
| 2839 | 3094 | |
| 2840 | 3095 | if (empty($nodatabaseupdate)) |
| 2841 | 3096 | {
|
@@ -2864,13 +3119,11 @@ discard block |
||
| 2864 | 3119 | if (! $error) |
| 2865 | 3120 | {
|
| 2866 | 3121 | return 1; |
| 2867 | - } |
|
| 2868 | - else |
|
| 3122 | + } else |
|
| 2869 | 3123 | {
|
| 2870 | 3124 | return -1; |
| 2871 | 3125 | } |
| 2872 | - } |
|
| 2873 | - else |
|
| 3126 | + } else |
|
| 2874 | 3127 | {
|
| 2875 | 3128 | dol_print_error($this->db,'Bad request in update_price'); |
| 2876 | 3129 | return -1; |
@@ -2893,10 +3146,18 @@ discard block |
||
| 2893 | 3146 | $origin_id = (! empty($origin_id) ? $origin_id : $this->origin_id); |
| 2894 | 3147 | |
| 2895 | 3148 | // Special case |
| 2896 | - if ($origin == 'order') $origin='commande'; |
|
| 2897 | - if ($origin == 'invoice') $origin='facture'; |
|
| 2898 | - if ($origin == 'invoice_template') $origin='facturerec'; |
|
| 2899 | - if ($origin == 'supplierorder') $origin='order_supplier'; |
|
| 3149 | + if ($origin == 'order') { |
|
| 3150 | + $origin='commande'; |
|
| 3151 | + } |
|
| 3152 | + if ($origin == 'invoice') { |
|
| 3153 | + $origin='facture'; |
|
| 3154 | + } |
|
| 3155 | + if ($origin == 'invoice_template') { |
|
| 3156 | + $origin='facturerec'; |
|
| 3157 | + } |
|
| 3158 | + if ($origin == 'supplierorder') { |
|
| 3159 | + $origin='order_supplier'; |
|
| 3160 | + } |
|
| 2900 | 3161 | $this->db->begin(); |
| 2901 | 3162 | |
| 2902 | 3163 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
|
@@ -2916,8 +3177,7 @@ discard block |
||
| 2916 | 3177 | {
|
| 2917 | 3178 | $this->db->commit(); |
| 2918 | 3179 | return 1; |
| 2919 | - } |
|
| 2920 | - else |
|
| 3180 | + } else |
|
| 2921 | 3181 | {
|
| 2922 | 3182 | $this->error=$this->db->lasterror(); |
| 2923 | 3183 | $this->db->rollback(); |
@@ -2962,12 +3222,16 @@ discard block |
||
| 2962 | 3222 | if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid)) |
| 2963 | 3223 | {
|
| 2964 | 3224 | $justsource=true; // the source (id and type) is a search criteria |
| 2965 | - if (! empty($targettype)) $withtargettype=true; |
|
| 3225 | + if (! empty($targettype)) { |
|
| 3226 | + $withtargettype=true; |
|
| 3227 | + } |
|
| 2966 | 3228 | } |
| 2967 | 3229 | if (! empty($targetid) && ! empty($targettype) && empty($sourceid)) |
| 2968 | 3230 | {
|
| 2969 | 3231 | $justtarget=true; // the target (id and type) is a search criteria |
| 2970 | - if (! empty($sourcetype)) $withsourcetype=true; |
|
| 3232 | + if (! empty($sourcetype)) { |
|
| 3233 | + $withsourcetype=true; |
|
| 3234 | + } |
|
| 2971 | 3235 | } |
| 2972 | 3236 | |
| 2973 | 3237 | $sourceid = (! empty($sourceid) ? $sourceid : $this->id); |
@@ -2990,15 +3254,17 @@ discard block |
||
| 2990 | 3254 | if ($justsource) |
| 2991 | 3255 | {
|
| 2992 | 3256 | $sql.= "fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."'"; |
| 2993 | - if ($withtargettype) $sql.= " AND targettype = '".$targettype."'"; |
|
| 2994 | - } |
|
| 2995 | - else if ($justtarget) |
|
| 3257 | + if ($withtargettype) { |
|
| 3258 | + $sql.= " AND targettype = '".$targettype."'"; |
|
| 3259 | + } |
|
| 3260 | + } else if ($justtarget) |
|
| 2996 | 3261 | {
|
| 2997 | 3262 | $sql.= "fk_target = ".$targetid." AND targettype = '".$targettype."'"; |
| 2998 | - if ($withsourcetype) $sql.= " AND sourcetype = '".$sourcetype."'"; |
|
| 3263 | + if ($withsourcetype) { |
|
| 3264 | + $sql.= " AND sourcetype = '".$sourcetype."'"; |
|
| 3265 | + } |
|
| 2999 | 3266 | } |
| 3000 | - } |
|
| 3001 | - else |
|
| 3267 | + } else |
|
| 3002 | 3268 | {
|
| 3003 | 3269 | $sql.= "(fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."')"; |
| 3004 | 3270 | $sql.= " ".$clause." (fk_target = ".$targetid." AND targettype = '".$targettype."')"; |
@@ -3019,13 +3285,11 @@ discard block |
||
| 3019 | 3285 | if ($justsource) |
| 3020 | 3286 | {
|
| 3021 | 3287 | $this->linkedObjectsIds[$obj->targettype][$obj->rowid]=$obj->fk_target; |
| 3022 | - } |
|
| 3023 | - else if ($justtarget) |
|
| 3288 | + } else if ($justtarget) |
|
| 3024 | 3289 | {
|
| 3025 | 3290 | $this->linkedObjectsIds[$obj->sourcetype][$obj->rowid]=$obj->fk_source; |
| 3026 | 3291 | } |
| 3027 | - } |
|
| 3028 | - else |
|
| 3292 | + } else |
|
| 3029 | 3293 | {
|
| 3030 | 3294 | if ($obj->fk_source == $sourceid && $obj->sourcetype == $sourcetype) |
| 3031 | 3295 | {
|
@@ -3042,10 +3306,12 @@ discard block |
||
| 3042 | 3306 | if (! empty($this->linkedObjectsIds)) |
| 3043 | 3307 | {
|
| 3044 | 3308 | $tmparray = $this->linkedObjectsIds; |
| 3045 | - foreach($tmparray as $objecttype => $objectids) // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...)
|
|
| 3309 | + foreach($tmparray as $objecttype => $objectids) { |
|
| 3310 | + // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...)
|
|
| 3046 | 3311 | {
|
| 3047 | 3312 | // Parse element/subelement (ex: project_task, cabinetmed_consultation, ...) |
| 3048 | - $module = $element = $subelement = $objecttype; |
|
| 3313 | + $module = $element = $subelement = $objecttype; |
|
| 3314 | + } |
|
| 3049 | 3315 | if ($objecttype != 'supplier_proposal' && $objecttype != 'order_supplier' && $objecttype != 'invoice_supplier' |
| 3050 | 3316 | && preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
|
| 3051 | 3317 | {
|
@@ -3057,29 +3323,21 @@ discard block |
||
| 3057 | 3323 | // To work with non standard classpath or module name |
| 3058 | 3324 | if ($objecttype == 'facture') {
|
| 3059 | 3325 | $classpath = 'compta/facture/class'; |
| 3060 | - } |
|
| 3061 | - else if ($objecttype == 'facturerec') {
|
|
| 3326 | + } else if ($objecttype == 'facturerec') {
|
|
| 3062 | 3327 | $classpath = 'compta/facture/class'; $module = 'facture'; |
| 3063 | - } |
|
| 3064 | - else if ($objecttype == 'propal') {
|
|
| 3328 | + } else if ($objecttype == 'propal') {
|
|
| 3065 | 3329 | $classpath = 'comm/propal/class'; |
| 3066 | - } |
|
| 3067 | - else if ($objecttype == 'supplier_proposal') {
|
|
| 3330 | + } else if ($objecttype == 'supplier_proposal') {
|
|
| 3068 | 3331 | $classpath = 'supplier_proposal/class'; |
| 3069 | - } |
|
| 3070 | - else if ($objecttype == 'shipping') {
|
|
| 3332 | + } else if ($objecttype == 'shipping') {
|
|
| 3071 | 3333 | $classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon'; |
| 3072 | - } |
|
| 3073 | - else if ($objecttype == 'delivery') {
|
|
| 3334 | + } else if ($objecttype == 'delivery') {
|
|
| 3074 | 3335 | $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; |
| 3075 | - } |
|
| 3076 | - else if ($objecttype == 'invoice_supplier' || $objecttype == 'order_supplier') {
|
|
| 3336 | + } else if ($objecttype == 'invoice_supplier' || $objecttype == 'order_supplier') {
|
|
| 3077 | 3337 | $classpath = 'fourn/class'; $module = 'fournisseur'; |
| 3078 | - } |
|
| 3079 | - else if ($objecttype == 'fichinter') {
|
|
| 3338 | + } else if ($objecttype == 'fichinter') {
|
|
| 3080 | 3339 | $classpath = 'fichinter/class'; $subelement = 'fichinter'; $module = 'ficheinter'; |
| 3081 | - } |
|
| 3082 | - else if ($objecttype == 'subscription') {
|
|
| 3340 | + } else if ($objecttype == 'subscription') {
|
|
| 3083 | 3341 | $classpath = 'adherents/class'; $module = 'adherent'; |
| 3084 | 3342 | } |
| 3085 | 3343 | |
@@ -3088,20 +3346,15 @@ discard block |
||
| 3088 | 3346 | |
| 3089 | 3347 | if ($objecttype == 'order') {
|
| 3090 | 3348 | $classfile = 'commande'; $classname = 'Commande'; |
| 3091 | - } |
|
| 3092 | - else if ($objecttype == 'invoice_supplier') {
|
|
| 3349 | + } else if ($objecttype == 'invoice_supplier') {
|
|
| 3093 | 3350 | $classfile = 'fournisseur.facture'; $classname = 'FactureFournisseur'; |
| 3094 | - } |
|
| 3095 | - else if ($objecttype == 'order_supplier') {
|
|
| 3351 | + } else if ($objecttype == 'order_supplier') {
|
|
| 3096 | 3352 | $classfile = 'fournisseur.commande'; $classname = 'CommandeFournisseur'; |
| 3097 | - } |
|
| 3098 | - else if ($objecttype == 'supplier_proposal') {
|
|
| 3353 | + } else if ($objecttype == 'supplier_proposal') {
|
|
| 3099 | 3354 | $classfile = 'supplier_proposal'; $classname = 'SupplierProposal'; |
| 3100 | - } |
|
| 3101 | - else if ($objecttype == 'facturerec') {
|
|
| 3355 | + } else if ($objecttype == 'facturerec') {
|
|
| 3102 | 3356 | $classfile = 'facture-rec'; $classname = 'FactureRec'; |
| 3103 | - } |
|
| 3104 | - else if ($objecttype == 'subscription') {
|
|
| 3357 | + } else if ($objecttype == 'subscription') {
|
|
| 3105 | 3358 | $classfile = 'subscription'; $classname = 'Subscription'; |
| 3106 | 3359 | } |
| 3107 | 3360 | |
@@ -3114,9 +3367,11 @@ discard block |
||
| 3114 | 3367 | //print '/'.$classpath.'/'.$classfile.'.class.php '.class_exists($classname); |
| 3115 | 3368 | if (class_exists($classname)) |
| 3116 | 3369 | {
|
| 3117 | - foreach($objectids as $i => $objectid) // $i is rowid into llx_element_element |
|
| 3370 | + foreach($objectids as $i => $objectid) { |
|
| 3371 | + // $i is rowid into llx_element_element |
|
| 3118 | 3372 | {
|
| 3119 | - $object = new $classname($this->db); |
|
| 3373 | + $object = new $classname($this->db); |
|
| 3374 | + } |
|
| 3120 | 3375 | $ret = $object->fetch($objectid); |
| 3121 | 3376 | if ($ret >= 0) |
| 3122 | 3377 | {
|
@@ -3125,16 +3380,14 @@ discard block |
||
| 3125 | 3380 | } |
| 3126 | 3381 | } |
| 3127 | 3382 | } |
| 3128 | - } |
|
| 3129 | - else |
|
| 3383 | + } else |
|
| 3130 | 3384 | {
|
| 3131 | 3385 | unset($this->linkedObjectsIds[$objecttype]); |
| 3132 | 3386 | } |
| 3133 | 3387 | } |
| 3134 | 3388 | } |
| 3135 | 3389 | return 1; |
| 3136 | - } |
|
| 3137 | - else |
|
| 3390 | + } else |
|
| 3138 | 3391 | {
|
| 3139 | 3392 | dol_print_error($this->db); |
| 3140 | 3393 | return -1; |
@@ -3156,8 +3409,11 @@ discard block |
||
| 3156 | 3409 | $updatesource=false; |
| 3157 | 3410 | $updatetarget=false; |
| 3158 | 3411 | |
| 3159 | - if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $updatesource=true; |
|
| 3160 | - else if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $updatetarget=true; |
|
| 3412 | + if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) { |
|
| 3413 | + $updatesource=true; |
|
| 3414 | + } else if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) { |
|
| 3415 | + $updatetarget=true; |
|
| 3416 | + } |
|
| 3161 | 3417 | |
| 3162 | 3418 | $sql = "UPDATE ".MAIN_DB_PREFIX."element_element SET "; |
| 3163 | 3419 | if ($updatesource) |
@@ -3166,8 +3422,7 @@ discard block |
||
| 3166 | 3422 | $sql.= ", sourcetype = '".$this->db->escape($sourcetype)."'"; |
| 3167 | 3423 | $sql.= " WHERE fk_target = ".$this->id; |
| 3168 | 3424 | $sql.= " AND targettype = '".$this->db->escape($this->element)."'"; |
| 3169 | - } |
|
| 3170 | - else if ($updatetarget) |
|
| 3425 | + } else if ($updatetarget) |
|
| 3171 | 3426 | {
|
| 3172 | 3427 | $sql.= "fk_target = ".$targetid; |
| 3173 | 3428 | $sql.= ", targettype = '".$this->db->escape($targettype)."'"; |
@@ -3179,8 +3434,7 @@ discard block |
||
| 3179 | 3434 | if ($this->db->query($sql)) |
| 3180 | 3435 | {
|
| 3181 | 3436 | return 1; |
| 3182 | - } |
|
| 3183 | - else |
|
| 3437 | + } else |
|
| 3184 | 3438 | {
|
| 3185 | 3439 | $this->error=$this->db->lasterror(); |
| 3186 | 3440 | return -1; |
@@ -3203,8 +3457,11 @@ discard block |
||
| 3203 | 3457 | $deletesource=false; |
| 3204 | 3458 | $deletetarget=false; |
| 3205 | 3459 | |
| 3206 | - if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $deletesource=true; |
|
| 3207 | - else if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $deletetarget=true; |
|
| 3460 | + if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) { |
|
| 3461 | + $deletesource=true; |
|
| 3462 | + } else if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) { |
|
| 3463 | + $deletetarget=true; |
|
| 3464 | + } |
|
| 3208 | 3465 | |
| 3209 | 3466 | $sourceid = (! empty($sourceid) ? $sourceid : $this->id); |
| 3210 | 3467 | $sourcetype = (! empty($sourcetype) ? $sourcetype : $this->element); |
@@ -3216,20 +3473,17 @@ discard block |
||
| 3216 | 3473 | if ($rowid > 0) |
| 3217 | 3474 | {
|
| 3218 | 3475 | $sql.=" rowid = ".$rowid; |
| 3219 | - } |
|
| 3220 | - else |
|
| 3476 | + } else |
|
| 3221 | 3477 | {
|
| 3222 | 3478 | if ($deletesource) |
| 3223 | 3479 | {
|
| 3224 | 3480 | $sql.= " fk_source = ".$sourceid." AND sourcetype = '".$this->db->escape($sourcetype)."'"; |
| 3225 | 3481 | $sql.= " AND fk_target = ".$this->id." AND targettype = '".$this->db->escape($this->element)."'"; |
| 3226 | - } |
|
| 3227 | - else if ($deletetarget) |
|
| 3482 | + } else if ($deletetarget) |
|
| 3228 | 3483 | {
|
| 3229 | 3484 | $sql.= " fk_target = ".$targetid." AND targettype = '".$this->db->escape($targettype)."'"; |
| 3230 | 3485 | $sql.= " AND fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."'"; |
| 3231 | - } |
|
| 3232 | - else |
|
| 3486 | + } else |
|
| 3233 | 3487 | {
|
| 3234 | 3488 | $sql.= " (fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."')"; |
| 3235 | 3489 | $sql.= " OR"; |
@@ -3241,8 +3495,7 @@ discard block |
||
| 3241 | 3495 | if ($this->db->query($sql)) |
| 3242 | 3496 | {
|
| 3243 | 3497 | return 1; |
| 3244 | - } |
|
| 3245 | - else |
|
| 3498 | + } else |
|
| 3246 | 3499 | {
|
| 3247 | 3500 | $this->error=$this->db->lasterror(); |
| 3248 | 3501 | $this->errors[]=$this->error; |
@@ -3271,17 +3524,31 @@ discard block |
||
| 3271 | 3524 | $this->db->begin(); |
| 3272 | 3525 | |
| 3273 | 3526 | $fieldstatus="fk_statut"; |
| 3274 | - if ($elementTable == 'facture_rec') $fieldstatus="suspended"; |
|
| 3275 | - if ($elementTable == 'mailing') $fieldstatus="statut"; |
|
| 3276 | - if ($elementTable == 'cronjob') $fieldstatus="status"; |
|
| 3277 | - if ($elementTable == 'user') $fieldstatus="statut"; |
|
| 3278 | - if ($elementTable == 'expensereport') $fieldstatus="fk_statut"; |
|
| 3279 | - if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus="status"; |
|
| 3527 | + if ($elementTable == 'facture_rec') { |
|
| 3528 | + $fieldstatus="suspended"; |
|
| 3529 | + } |
|
| 3530 | + if ($elementTable == 'mailing') { |
|
| 3531 | + $fieldstatus="statut"; |
|
| 3532 | + } |
|
| 3533 | + if ($elementTable == 'cronjob') { |
|
| 3534 | + $fieldstatus="status"; |
|
| 3535 | + } |
|
| 3536 | + if ($elementTable == 'user') { |
|
| 3537 | + $fieldstatus="statut"; |
|
| 3538 | + } |
|
| 3539 | + if ($elementTable == 'expensereport') { |
|
| 3540 | + $fieldstatus="fk_statut"; |
|
| 3541 | + } |
|
| 3542 | + if ($elementTable == 'commande_fournisseur_dispatch') { |
|
| 3543 | + $fieldstatus="status"; |
|
| 3544 | + } |
|
| 3280 | 3545 | |
| 3281 | 3546 | $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; |
| 3282 | 3547 | $sql.= " SET ".$fieldstatus." = ".$status; |
| 3283 | 3548 | // If status = 1 = validated, update also fk_user_valid |
| 3284 | - if ($status == 1 && $elementTable == 'expensereport') $sql.=", fk_user_valid = ".$user->id; |
|
| 3549 | + if ($status == 1 && $elementTable == 'expensereport') { |
|
| 3550 | + $sql.=", fk_user_valid = ".$user->id; |
|
| 3551 | + } |
|
| 3285 | 3552 | $sql.= " WHERE rowid=".$elementId; |
| 3286 | 3553 | |
| 3287 | 3554 | dol_syslog(get_class($this)."::setStatut", LOG_DEBUG); |
@@ -3292,12 +3559,27 @@ discard block |
||
| 3292 | 3559 | // Try autoset of trigkey |
| 3293 | 3560 | if (empty($trigkey)) |
| 3294 | 3561 | {
|
| 3295 | - if ($this->element == 'supplier_proposal' && $status == 2) $trigkey='SUPPLIER_PROPOSAL_SIGN'; // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class |
|
| 3296 | - if ($this->element == 'supplier_proposal' && $status == 3) $trigkey='SUPPLIER_PROPOSAL_REFUSE'; // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class |
|
| 3297 | - if ($this->element == 'supplier_proposal' && $status == 4) $trigkey='SUPPLIER_PROPOSAL_CLOSE'; // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class |
|
| 3298 | - if ($this->element == 'fichinter' && $status == 3) $trigkey='FICHINTER_CLASSIFY_DONE'; |
|
| 3299 | - if ($this->element == 'fichinter' && $status == 2) $trigkey='FICHINTER_CLASSIFY_BILLED'; |
|
| 3300 | - if ($this->element == 'fichinter' && $status == 1) $trigkey='FICHINTER_CLASSIFY_UNBILLED'; |
|
| 3562 | + if ($this->element == 'supplier_proposal' && $status == 2) { |
|
| 3563 | + $trigkey='SUPPLIER_PROPOSAL_SIGN'; |
|
| 3564 | + } |
|
| 3565 | + // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class |
|
| 3566 | + if ($this->element == 'supplier_proposal' && $status == 3) { |
|
| 3567 | + $trigkey='SUPPLIER_PROPOSAL_REFUSE'; |
|
| 3568 | + } |
|
| 3569 | + // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class |
|
| 3570 | + if ($this->element == 'supplier_proposal' && $status == 4) { |
|
| 3571 | + $trigkey='SUPPLIER_PROPOSAL_CLOSE'; |
|
| 3572 | + } |
|
| 3573 | + // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class |
|
| 3574 | + if ($this->element == 'fichinter' && $status == 3) { |
|
| 3575 | + $trigkey='FICHINTER_CLASSIFY_DONE'; |
|
| 3576 | + } |
|
| 3577 | + if ($this->element == 'fichinter' && $status == 2) { |
|
| 3578 | + $trigkey='FICHINTER_CLASSIFY_BILLED'; |
|
| 3579 | + } |
|
| 3580 | + if ($this->element == 'fichinter' && $status == 1) { |
|
| 3581 | + $trigkey='FICHINTER_CLASSIFY_UNBILLED'; |
|
| 3582 | + } |
|
| 3301 | 3583 | } |
| 3302 | 3584 | |
| 3303 | 3585 | if ($trigkey) |
@@ -3316,22 +3598,22 @@ discard block |
||
| 3316 | 3598 | {
|
| 3317 | 3599 | $this->db->commit(); |
| 3318 | 3600 | |
| 3319 | - if (empty($savElementId)) // If the element we update was $this (so $elementId is null) |
|
| 3601 | + if (empty($savElementId)) { |
|
| 3602 | + // If the element we update was $this (so $elementId is null) |
|
| 3320 | 3603 | {
|
| 3321 | - $this->statut = $status; |
|
| 3604 | + $this->statut = $status; |
|
| 3605 | + } |
|
| 3322 | 3606 | $this->status = $status; |
| 3323 | 3607 | } |
| 3324 | 3608 | |
| 3325 | 3609 | return 1; |
| 3326 | - } |
|
| 3327 | - else |
|
| 3610 | + } else |
|
| 3328 | 3611 | {
|
| 3329 | 3612 | $this->db->rollback(); |
| 3330 | 3613 | dol_syslog(get_class($this)."::setStatus ".$this->error,LOG_ERR); |
| 3331 | 3614 | return -1; |
| 3332 | 3615 | } |
| 3333 | - } |
|
| 3334 | - else |
|
| 3616 | + } else |
|
| 3335 | 3617 | {
|
| 3336 | 3618 | $this->error=$this->db->lasterror(); |
| 3337 | 3619 | $this->db->rollback(); |
@@ -3351,8 +3633,13 @@ discard block |
||
| 3351 | 3633 | {
|
| 3352 | 3634 | global $conf; |
| 3353 | 3635 | |
| 3354 | - if (empty($id) && empty($ref)) return 0; |
|
| 3355 | - if (! empty($conf->global->MAIN_DISABLE_CANVAS)) return 0; // To increase speed. Not enabled by default. |
|
| 3636 | + if (empty($id) && empty($ref)) { |
|
| 3637 | + return 0; |
|
| 3638 | + } |
|
| 3639 | + if (! empty($conf->global->MAIN_DISABLE_CANVAS)) { |
|
| 3640 | + return 0; |
|
| 3641 | + } |
|
| 3642 | + // To increase speed. Not enabled by default. |
|
| 3356 | 3643 | |
| 3357 | 3644 | // Clean parameters |
| 3358 | 3645 | $ref = trim($ref); |
@@ -3360,8 +3647,12 @@ discard block |
||
| 3360 | 3647 | $sql = "SELECT rowid, canvas"; |
| 3361 | 3648 | $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element; |
| 3362 | 3649 | $sql.= " WHERE entity IN (".getEntity($this->element).")";
|
| 3363 | - if (! empty($id)) $sql.= " AND rowid = ".$id; |
|
| 3364 | - if (! empty($ref)) $sql.= " AND ref = '".$this->db->escape($ref)."'"; |
|
| 3650 | + if (! empty($id)) { |
|
| 3651 | + $sql.= " AND rowid = ".$id; |
|
| 3652 | + } |
|
| 3653 | + if (! empty($ref)) { |
|
| 3654 | + $sql.= " AND ref = '".$this->db->escape($ref)."'"; |
|
| 3655 | + } |
|
| 3365 | 3656 | |
| 3366 | 3657 | $resql = $this->db->query($sql); |
| 3367 | 3658 | if ($resql) |
@@ -3371,10 +3662,10 @@ discard block |
||
| 3371 | 3662 | {
|
| 3372 | 3663 | $this->canvas = $obj->canvas; |
| 3373 | 3664 | return 1; |
| 3374 | - } |
|
| 3375 | - else return 0; |
|
| 3376 | - } |
|
| 3377 | - else |
|
| 3665 | + } else { |
|
| 3666 | + return 0; |
|
| 3667 | + } |
|
| 3668 | + } else |
|
| 3378 | 3669 | {
|
| 3379 | 3670 | dol_print_error($this->db); |
| 3380 | 3671 | return -1; |
@@ -3411,7 +3702,9 @@ discard block |
||
| 3411 | 3702 | {
|
| 3412 | 3703 | global $langs; |
| 3413 | 3704 | |
| 3414 | - if (empty($id)) $id=$this->id; |
|
| 3705 | + if (empty($id)) { |
|
| 3706 | + $id=$this->id; |
|
| 3707 | + } |
|
| 3415 | 3708 | |
| 3416 | 3709 | // Check parameters |
| 3417 | 3710 | if (! isset($this->childtables) || ! is_array($this->childtables) || count($this->childtables) == 0) |
@@ -3445,18 +3738,18 @@ discard block |
||
| 3445 | 3738 | $langs->load("errors");
|
| 3446 | 3739 | //print 'Found into table '.$table.', type '.$langs->transnoentitiesnoconv($elementname).', haschild='.$haschild; |
| 3447 | 3740 | $haschild += $obj->nb; |
| 3448 | - if (is_numeric($elementname)) // old usage |
|
| 3741 | + if (is_numeric($elementname)) { |
|
| 3742 | + // old usage |
|
| 3449 | 3743 | {
|
| 3450 | - $this->errors[]=$langs->trans("ErrorRecordHasAtLeastOneChildOfType", $table);
|
|
| 3451 | - } |
|
| 3452 | - else // new usage: $elementname=Translation key |
|
| 3744 | + $this->errors[]=$langs->trans("ErrorRecordHasAtLeastOneChildOfType", $table); |
|
| 3745 | + } |
|
| 3746 | + } else // new usage: $elementname=Translation key |
|
| 3453 | 3747 | {
|
| 3454 | 3748 | $this->errors[]=$langs->trans("ErrorRecordHasAtLeastOneChildOfType", $langs->transnoentitiesnoconv($elementname));
|
| 3455 | 3749 | } |
| 3456 | 3750 | break; // We found at least one, we stop here |
| 3457 | 3751 | } |
| 3458 | - } |
|
| 3459 | - else |
|
| 3752 | + } else |
|
| 3460 | 3753 | {
|
| 3461 | 3754 | $this->errors[]=$this->db->lasterror(); |
| 3462 | 3755 | return -1; |
@@ -3466,8 +3759,9 @@ discard block |
||
| 3466 | 3759 | {
|
| 3467 | 3760 | $this->errors[]="ErrorRecordHasChildren"; |
| 3468 | 3761 | return $haschild; |
| 3469 | - } |
|
| 3470 | - else return 0; |
|
| 3762 | + } else { |
|
| 3763 | + return 0; |
|
| 3764 | + } |
|
| 3471 | 3765 | } |
| 3472 | 3766 | |
| 3473 | 3767 | /** |
@@ -3483,12 +3777,24 @@ discard block |
||
| 3483 | 3777 | foreach($this->lines as $key => $val) |
| 3484 | 3778 | {
|
| 3485 | 3779 | $qualified=0; |
| 3486 | - if ($predefined == -1) $qualified=1; |
|
| 3487 | - if ($predefined == 1 && $val->fk_product > 0) $qualified=1; |
|
| 3488 | - if ($predefined == 0 && $val->fk_product <= 0) $qualified=1; |
|
| 3489 | - if ($predefined == 2 && $val->fk_product > 0 && $val->product_type==0) $qualified=1; |
|
| 3490 | - if ($predefined == 3 && $val->fk_product > 0 && $val->product_type==1) $qualified=1; |
|
| 3491 | - if ($qualified) $nb++; |
|
| 3780 | + if ($predefined == -1) { |
|
| 3781 | + $qualified=1; |
|
| 3782 | + } |
|
| 3783 | + if ($predefined == 1 && $val->fk_product > 0) { |
|
| 3784 | + $qualified=1; |
|
| 3785 | + } |
|
| 3786 | + if ($predefined == 0 && $val->fk_product <= 0) { |
|
| 3787 | + $qualified=1; |
|
| 3788 | + } |
|
| 3789 | + if ($predefined == 2 && $val->fk_product > 0 && $val->product_type==0) { |
|
| 3790 | + $qualified=1; |
|
| 3791 | + } |
|
| 3792 | + if ($predefined == 3 && $val->fk_product > 0 && $val->product_type==1) { |
|
| 3793 | + $qualified=1; |
|
| 3794 | + } |
|
| 3795 | + if ($qualified) { |
|
| 3796 | + $nb++; |
|
| 3797 | + } |
|
| 3492 | 3798 | } |
| 3493 | 3799 | dol_syslog(get_class($this).'::hasProductsOrServices we found '.$nb.' qualified lines of products/servcies'); |
| 3494 | 3800 | return $nb; |
@@ -3552,16 +3858,24 @@ discard block |
||
| 3552 | 3858 | {
|
| 3553 | 3859 | if (isset($line->qty_asked)) |
| 3554 | 3860 | {
|
| 3555 | - if (empty($totalOrdered)) $totalOrdered=0; // Avoid warning because $totalOrdered is '' |
|
| 3861 | + if (empty($totalOrdered)) { |
|
| 3862 | + $totalOrdered=0; |
|
| 3863 | + } |
|
| 3864 | + // Avoid warning because $totalOrdered is '' |
|
| 3556 | 3865 | $totalOrdered+=$line->qty_asked; // defined for shipment only |
| 3557 | 3866 | } |
| 3558 | 3867 | if (isset($line->qty_shipped)) |
| 3559 | 3868 | {
|
| 3560 | - if (empty($totalToShip)) $totalToShip=0; // Avoid warning because $totalToShip is '' |
|
| 3869 | + if (empty($totalToShip)) { |
|
| 3870 | + $totalToShip=0; |
|
| 3871 | + } |
|
| 3872 | + // Avoid warning because $totalToShip is '' |
|
| 3561 | 3873 | $totalToShip+=$line->qty_shipped; // defined for shipment only |
| 3562 | - }else if ($line->element == 'commandefournisseurdispatch' && isset($line->qty)) |
|
| 3874 | + } else if ($line->element == 'commandefournisseurdispatch' && isset($line->qty)) |
|
| 3563 | 3875 | {
|
| 3564 | - if (empty($totalToShip)) $totalToShip=0; |
|
| 3876 | + if (empty($totalToShip)) { |
|
| 3877 | + $totalToShip=0; |
|
| 3878 | + } |
|
| 3565 | 3879 | $totalToShip+=$line->qty; // defined for reception only |
| 3566 | 3880 | } |
| 3567 | 3881 | |
@@ -3569,8 +3883,7 @@ discard block |
||
| 3569 | 3883 | if ($this->element == 'shipping') {
|
| 3570 | 3884 | // for shipments |
| 3571 | 3885 | $qty = $line->qty_shipped ? $line->qty_shipped : 0; |
| 3572 | - } |
|
| 3573 | - else {
|
|
| 3886 | + } else {
|
|
| 3574 | 3887 | $qty = $line->qty ? $line->qty : 0; |
| 3575 | 3888 | } |
| 3576 | 3889 | |
@@ -3586,19 +3899,30 @@ discard block |
||
| 3586 | 3899 | |
| 3587 | 3900 | $weightUnit=0; |
| 3588 | 3901 | $volumeUnit=0; |
| 3589 | - if (! empty($weight_units)) $weightUnit = $weight_units; |
|
| 3590 | - if (! empty($volume_units)) $volumeUnit = $volume_units; |
|
| 3591 | - |
|
| 3592 | - if (empty($totalWeight)) $totalWeight=0; // Avoid warning because $totalWeight is '' |
|
| 3593 | - if (empty($totalVolume)) $totalVolume=0; // Avoid warning because $totalVolume is '' |
|
| 3902 | + if (! empty($weight_units)) { |
|
| 3903 | + $weightUnit = $weight_units; |
|
| 3904 | + } |
|
| 3905 | + if (! empty($volume_units)) { |
|
| 3906 | + $volumeUnit = $volume_units; |
|
| 3907 | + } |
|
| 3908 | + |
|
| 3909 | + if (empty($totalWeight)) { |
|
| 3910 | + $totalWeight=0; |
|
| 3911 | + } |
|
| 3912 | + // Avoid warning because $totalWeight is '' |
|
| 3913 | + if (empty($totalVolume)) { |
|
| 3914 | + $totalVolume=0; |
|
| 3915 | + } |
|
| 3916 | + // Avoid warning because $totalVolume is '' |
|
| 3594 | 3917 | |
| 3595 | 3918 | //var_dump($line->volume_units); |
| 3596 | - if ($weight_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) |
|
| 3919 | + if ($weight_units < 50) { |
|
| 3920 | + // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) |
|
| 3597 | 3921 | {
|
| 3598 | - $trueWeightUnit=pow(10, $weightUnit); |
|
| 3922 | + $trueWeightUnit=pow(10, $weightUnit); |
|
| 3923 | + } |
|
| 3599 | 3924 | $totalWeight += $weight * $qty * $trueWeightUnit; |
| 3600 | - } |
|
| 3601 | - else {
|
|
| 3925 | + } else {
|
|
| 3602 | 3926 | if ($weight_units == 99) {
|
| 3603 | 3927 | // conversion 1 Pound = 0.45359237 KG |
| 3604 | 3928 | $trueWeightUnit = 0.45359237; |
@@ -3607,18 +3931,20 @@ discard block |
||
| 3607 | 3931 | // conversion 1 Ounce = 0.0283495 KG |
| 3608 | 3932 | $trueWeightUnit = 0.0283495; |
| 3609 | 3933 | $totalWeight += $weight * $qty * $trueWeightUnit; |
| 3610 | - } |
|
| 3611 | - else |
|
| 3612 | - $totalWeight += $weight * $qty; // This may be wrong if we mix different units |
|
| 3934 | + } else { |
|
| 3935 | + $totalWeight += $weight * $qty; |
|
| 3936 | + } |
|
| 3937 | + // This may be wrong if we mix different units |
|
| 3613 | 3938 | } |
| 3614 | - if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) |
|
| 3939 | + if ($volume_units < 50) { |
|
| 3940 | + // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) |
|
| 3615 | 3941 | {
|
| 3616 | 3942 | //print $line->volume."x".$line->volume_units."x".($line->volume_units < 50)."x".$volumeUnit; |
| 3617 | - $trueVolumeUnit=pow(10, $volumeUnit); |
|
| 3943 | + $trueVolumeUnit=pow(10, $volumeUnit); |
|
| 3944 | + } |
|
| 3618 | 3945 | //print $line->volume; |
| 3619 | 3946 | $totalVolume += $volume * $qty * $trueVolumeUnit; |
| 3620 | - } |
|
| 3621 | - else |
|
| 3947 | + } else |
|
| 3622 | 3948 | {
|
| 3623 | 3949 | $totalVolume += $volume * $qty; // This may be wrong if we mix different units |
| 3624 | 3950 | } |
@@ -3650,8 +3976,7 @@ discard block |
||
| 3650 | 3976 | $this->error=$this->db->lasterror(); |
| 3651 | 3977 | $this->db->rollback(); |
| 3652 | 3978 | return -1; |
| 3653 | - } |
|
| 3654 | - else |
|
| 3979 | + } else |
|
| 3655 | 3980 | {
|
| 3656 | 3981 | $this->db->commit(); |
| 3657 | 3982 | return 1; |
@@ -3703,13 +4028,11 @@ discard block |
||
| 3703 | 4028 | {
|
| 3704 | 4029 | $res = $this->db->fetch_object($resql); |
| 3705 | 4030 | return 'Incoterm : '.$res->code.' - '.$this->location_incoterms; |
| 3706 | - } |
|
| 3707 | - else |
|
| 4031 | + } else |
|
| 3708 | 4032 | {
|
| 3709 | 4033 | return ''; |
| 3710 | 4034 | } |
| 3711 | - } |
|
| 3712 | - else |
|
| 4035 | + } else |
|
| 3713 | 4036 | {
|
| 3714 | 4037 | $this->errors[] = $this->db->lasterror(); |
| 3715 | 4038 | return false; |
@@ -3746,14 +4069,14 @@ discard block |
||
| 3746 | 4069 | $this->libelle_incoterms = $obj->libelle; |
| 3747 | 4070 | } |
| 3748 | 4071 | return 1; |
| 3749 | - } |
|
| 3750 | - else |
|
| 4072 | + } else |
|
| 3751 | 4073 | {
|
| 3752 | 4074 | $this->errors[] = $this->db->lasterror(); |
| 3753 | 4075 | return -1; |
| 3754 | 4076 | } |
| 3755 | - } |
|
| 3756 | - else return -1; |
|
| 4077 | + } else { |
|
| 4078 | + return -1; |
|
| 4079 | + } |
|
| 3757 | 4080 | } |
| 3758 | 4081 | |
| 3759 | 4082 | |
@@ -3792,7 +4115,9 @@ discard block |
||
| 3792 | 4115 | } else {
|
| 3793 | 4116 | $res=include $tpl; // for debug |
| 3794 | 4117 | } |
| 3795 | - if ($res) break; |
|
| 4118 | + if ($res) { |
|
| 4119 | + break; |
|
| 4120 | + } |
|
| 3796 | 4121 | } |
| 3797 | 4122 | } |
| 3798 | 4123 | |
@@ -3822,7 +4147,9 @@ discard block |
||
| 3822 | 4147 | |
| 3823 | 4148 | // Define usemargins |
| 3824 | 4149 | $usemargins=0; |
| 3825 | - if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element,array('facture','propal','commande'))) $usemargins=1;
|
|
| 4150 | + if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element,array('facture','propal','commande'))) { |
|
| 4151 | + $usemargins=1; |
|
| 4152 | + } |
|
| 3826 | 4153 | |
| 3827 | 4154 | $num = count($this->lines); |
| 3828 | 4155 | |
@@ -3841,7 +4168,9 @@ discard block |
||
| 3841 | 4168 | print '<tr class="liste_titre nodrag nodrop">'; |
| 3842 | 4169 | |
| 3843 | 4170 | // Adds a line numbering column |
| 3844 | - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print '<td class="linecolnum" align="center" width="5"> </td>'; |
|
| 4171 | + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { |
|
| 4172 | + print '<td class="linecolnum" align="center" width="5"> </td>'; |
|
| 4173 | + } |
|
| 3845 | 4174 | |
| 3846 | 4175 | // Description |
| 3847 | 4176 | print '<td class="linecoldescription">'.$langs->trans('Description').'</td>';
|
@@ -3858,9 +4187,13 @@ discard block |
||
| 3858 | 4187 | print '<td class="linecoluht" align="right" width="80">'.$langs->trans('PriceUHT').'</td>';
|
| 3859 | 4188 | |
| 3860 | 4189 | // Multicurrency |
| 3861 | - if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print '<td class="linecoluht_currency" align="right" width="80">'.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).'</td>';
|
|
| 4190 | + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { |
|
| 4191 | + print '<td class="linecoluht_currency" align="right" width="80">'.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).'</td>'; |
|
| 4192 | + } |
|
| 3862 | 4193 | |
| 3863 | - if ($inputalsopricewithtax) print '<td align="right" width="80">'.$langs->trans('PriceUTTC').'</td>';
|
|
| 4194 | + if ($inputalsopricewithtax) { |
|
| 4195 | + print '<td align="right" width="80">'.$langs->trans('PriceUTTC').'</td>'; |
|
| 4196 | + } |
|
| 3864 | 4197 | |
| 3865 | 4198 | // Qty |
| 3866 | 4199 | print '<td class="linecolqty" align="right">'.$langs->trans('Qty').'</td>';
|
@@ -3881,25 +4214,32 @@ discard block |
||
| 3881 | 4214 | {
|
| 3882 | 4215 | if (!empty($user->rights->margins->creer)) |
| 3883 | 4216 | {
|
| 3884 | - if ($conf->global->MARGIN_TYPE == "1") |
|
| 3885 | - print '<td class="linecolmargin1 margininfos" align="right" width="80">'.$langs->trans('BuyingPrice').'</td>';
|
|
| 3886 | - else |
|
| 3887 | - print '<td class="linecolmargin1 margininfos" align="right" width="80">'.$langs->trans('CostPrice').'</td>';
|
|
| 4217 | + if ($conf->global->MARGIN_TYPE == "1") { |
|
| 4218 | + print '<td class="linecolmargin1 margininfos" align="right" width="80">'.$langs->trans('BuyingPrice').'</td>'; |
|
| 4219 | + } else { |
|
| 4220 | + print '<td class="linecolmargin1 margininfos" align="right" width="80">'.$langs->trans('CostPrice').'</td>'; |
|
| 4221 | + } |
|
| 3888 | 4222 | } |
| 3889 | 4223 | |
| 3890 | - if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) |
|
| 3891 | - print '<td class="linecolmargin2 margininfos" align="right" width="50">'.$langs->trans('MarginRate').'</td>';
|
|
| 3892 | - if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) |
|
| 3893 | - print '<td class="linecolmargin2 margininfos" align="right" width="50">'.$langs->trans('MarkRate').'</td>';
|
|
| 4224 | + if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { |
|
| 4225 | + print '<td class="linecolmargin2 margininfos" align="right" width="50">'.$langs->trans('MarginRate').'</td>'; |
|
| 4226 | + } |
|
| 4227 | + if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) { |
|
| 4228 | + print '<td class="linecolmargin2 margininfos" align="right" width="50">'.$langs->trans('MarkRate').'</td>'; |
|
| 4229 | + } |
|
| 3894 | 4230 | } |
| 3895 | 4231 | |
| 3896 | 4232 | // Total HT |
| 3897 | 4233 | print '<td class="linecolht" align="right">'.$langs->trans('TotalHTShort').'</td>';
|
| 3898 | 4234 | |
| 3899 | 4235 | // Multicurrency |
| 3900 | - if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print '<td class="linecoltotalht_currency" align="right">'.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).'</td>';
|
|
| 4236 | + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { |
|
| 4237 | + print '<td class="linecoltotalht_currency" align="right">'.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).'</td>'; |
|
| 4238 | + } |
|
| 3901 | 4239 | |
| 3902 | - if ($outputalsopricetotalwithtax) print '<td align="right" width="80">'.$langs->trans('TotalTTCShort').'</td>';
|
|
| 4240 | + if ($outputalsopricetotalwithtax) { |
|
| 4241 | + print '<td align="right" width="80">'.$langs->trans('TotalTTCShort').'</td>'; |
|
| 4242 | + } |
|
| 3903 | 4243 | |
| 3904 | 4244 | print '<td class="linecoledit"></td>'; // No width to allow autodim |
| 3905 | 4245 | |
@@ -3929,14 +4269,15 @@ discard block |
||
| 3929 | 4269 | $line->fetch_optionals(); |
| 3930 | 4270 | |
| 3931 | 4271 | //if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) |
| 3932 | - if (is_object($hookmanager)) // Old code is commented on preceding line. |
|
| 4272 | + if (is_object($hookmanager)) { |
|
| 4273 | + // Old code is commented on preceding line. |
|
| 3933 | 4274 | {
|
| 3934 | 4275 | if (empty($line->fk_parent_line)) |
| 3935 | 4276 | {
|
| 3936 | - $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline);
|
|
| 4277 | + $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline); |
|
| 4278 | + } |
|
| 3937 | 4279 | $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
| 3938 | - } |
|
| 3939 | - else |
|
| 4280 | + } else |
|
| 3940 | 4281 | {
|
| 3941 | 4282 | $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline, 'fk_parent_line'=>$line->fk_parent_line);
|
| 3942 | 4283 | $reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
|
@@ -3983,8 +4324,14 @@ discard block |
||
| 3983 | 4324 | // Show product and description |
| 3984 | 4325 | $type=(! empty($line->product_type)?$line->product_type:$line->fk_product_type); |
| 3985 | 4326 | // Try to enhance type detection using date_start and date_end for free lines where type was not saved. |
| 3986 | - if (! empty($line->date_start)) $type=1; // deprecated |
|
| 3987 | - if (! empty($line->date_end)) $type=1; // deprecated |
|
| 4327 | + if (! empty($line->date_start)) { |
|
| 4328 | + $type=1; |
|
| 4329 | + } |
|
| 4330 | + // deprecated |
|
| 4331 | + if (! empty($line->date_end)) { |
|
| 4332 | + $type=1; |
|
| 4333 | + } |
|
| 4334 | + // deprecated |
|
| 3988 | 4335 | |
| 3989 | 4336 | // Ligne en mode visu |
| 3990 | 4337 | if ($action != 'editline' || $selected != $line->id) |
@@ -4013,8 +4360,13 @@ discard block |
||
| 4013 | 4360 | |
| 4014 | 4361 | $outputlangs = $langs; |
| 4015 | 4362 | $newlang=''; |
| 4016 | - if (empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
|
|
| 4017 | - if (! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && empty($newlang)) $newlang=$this->thirdparty->default_lang; // For language to language of customer |
|
| 4363 | + if (empty($newlang) && GETPOST('lang_id','aZ09')) { |
|
| 4364 | + $newlang=GETPOST('lang_id','aZ09'); |
|
| 4365 | + } |
|
| 4366 | + if (! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && empty($newlang)) { |
|
| 4367 | + $newlang=$this->thirdparty->default_lang; |
|
| 4368 | + } |
|
| 4369 | + // For language to language of customer |
|
| 4018 | 4370 | if (! empty($newlang)) |
| 4019 | 4371 | {
|
| 4020 | 4372 | $outputlangs = new Translate("",$conf);
|
@@ -4022,8 +4374,7 @@ discard block |
||
| 4022 | 4374 | } |
| 4023 | 4375 | |
| 4024 | 4376 | $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $line->product_label; |
| 4025 | - } |
|
| 4026 | - else |
|
| 4377 | + } else |
|
| 4027 | 4378 | {
|
| 4028 | 4379 | $label = $line->product_label; |
| 4029 | 4380 | } |
@@ -4045,7 +4396,9 @@ discard block |
||
| 4045 | 4396 | } else {
|
| 4046 | 4397 | $res=include $tpl; // for debug |
| 4047 | 4398 | } |
| 4048 | - if ($res) break; |
|
| 4399 | + if ($res) { |
|
| 4400 | + break; |
|
| 4401 | + } |
|
| 4049 | 4402 | } |
| 4050 | 4403 | } |
| 4051 | 4404 | |
@@ -4068,7 +4421,9 @@ discard block |
||
| 4068 | 4421 | } else {
|
| 4069 | 4422 | $res=include $tpl; // for debug |
| 4070 | 4423 | } |
| 4071 | - if ($res) break; |
|
| 4424 | + if ($res) { |
|
| 4425 | + break; |
|
| 4426 | + } |
|
| 4072 | 4427 | } |
| 4073 | 4428 | } |
| 4074 | 4429 | } |
@@ -4095,7 +4450,9 @@ discard block |
||
| 4095 | 4450 | print '<td>'.$langs->trans('Description').'</td>';
|
| 4096 | 4451 | print '<td align="right">'.$langs->trans('VATRate').'</td>';
|
| 4097 | 4452 | print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
|
| 4098 | - if (!empty($conf->multicurrency->enabled)) print '<td align="right">'.$langs->trans('PriceUHTCurrency').'</td>';
|
|
| 4453 | + if (!empty($conf->multicurrency->enabled)) { |
|
| 4454 | + print '<td align="right">'.$langs->trans('PriceUHTCurrency').'</td>'; |
|
| 4455 | + } |
|
| 4099 | 4456 | print '<td align="right">'.$langs->trans('Qty').'</td>';
|
| 4100 | 4457 | if($conf->global->PRODUCT_USE_UNITS) |
| 4101 | 4458 | {
|
@@ -4118,8 +4475,7 @@ discard block |
||
| 4118 | 4475 | $action=''; |
| 4119 | 4476 | $hookmanager->executeHooks('printOriginObjectLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
| 4120 | 4477 | } |
| 4121 | - } |
|
| 4122 | - else |
|
| 4478 | + } else |
|
| 4123 | 4479 | {
|
| 4124 | 4480 | $this->printOriginLine($line, $var, $restrictlist); |
| 4125 | 4481 | } |
@@ -4148,32 +4504,37 @@ discard block |
||
| 4148 | 4504 | if (!empty($line->date_start)) |
| 4149 | 4505 | {
|
| 4150 | 4506 | $date_start=$line->date_start; |
| 4151 | - } |
|
| 4152 | - else |
|
| 4507 | + } else |
|
| 4153 | 4508 | {
|
| 4154 | 4509 | $date_start=$line->date_debut_prevue; |
| 4155 | - if ($line->date_debut_reel) $date_start=$line->date_debut_reel; |
|
| 4510 | + if ($line->date_debut_reel) { |
|
| 4511 | + $date_start=$line->date_debut_reel; |
|
| 4512 | + } |
|
| 4156 | 4513 | } |
| 4157 | 4514 | if (!empty($line->date_end)) |
| 4158 | 4515 | {
|
| 4159 | 4516 | $date_end=$line->date_end; |
| 4160 | - } |
|
| 4161 | - else |
|
| 4517 | + } else |
|
| 4162 | 4518 | {
|
| 4163 | 4519 | $date_end=$line->date_fin_prevue; |
| 4164 | - if ($line->date_fin_reel) $date_end=$line->date_fin_reel; |
|
| 4520 | + if ($line->date_fin_reel) { |
|
| 4521 | + $date_end=$line->date_fin_reel; |
|
| 4522 | + } |
|
| 4165 | 4523 | } |
| 4166 | 4524 | |
| 4167 | 4525 | $this->tpl['label'] = ''; |
| 4168 | - if (! empty($line->fk_parent_line)) $this->tpl['label'].= img_picto('', 'rightarrow');
|
|
| 4526 | + if (! empty($line->fk_parent_line)) { |
|
| 4527 | + $this->tpl['label'].= img_picto('', 'rightarrow'); |
|
| 4528 | + } |
|
| 4169 | 4529 | |
| 4170 | - if (($line->info_bits & 2) == 2) // TODO Not sure this is used for source object |
|
| 4530 | + if (($line->info_bits & 2) == 2) { |
|
| 4531 | + // TODO Not sure this is used for source object |
|
| 4171 | 4532 | {
|
| 4172 | - $discount=new DiscountAbsolute($this->db); |
|
| 4533 | + $discount=new DiscountAbsolute($this->db); |
|
| 4534 | + } |
|
| 4173 | 4535 | $discount->fk_soc = $this->socid; |
| 4174 | 4536 | $this->tpl['label'].= $discount->getNomUrl(0,'discount'); |
| 4175 | - } |
|
| 4176 | - else if (! empty($line->fk_product)) |
|
| 4537 | + } else if (! empty($line->fk_product)) |
|
| 4177 | 4538 | {
|
| 4178 | 4539 | $productstatic = new Product($this->db); |
| 4179 | 4540 | $productstatic->id = $line->fk_product; |
@@ -4191,13 +4552,12 @@ discard block |
||
| 4191 | 4552 | {
|
| 4192 | 4553 | $this->tpl['label'].= get_date_range($date_start,$date_end); |
| 4193 | 4554 | } |
| 4194 | - } |
|
| 4195 | - else |
|
| 4555 | + } else |
|
| 4196 | 4556 | {
|
| 4197 | 4557 | $this->tpl['label'].= ($line->product_type == -1 ? ' ' : ($line->product_type == 1 ? img_object($langs->trans(''),'service') : img_object($langs->trans(''),'product')));
|
| 4198 | 4558 | if (!empty($line->desc)) {
|
| 4199 | 4559 | $this->tpl['label'].=$line->desc; |
| 4200 | - }else {
|
|
| 4560 | + } else {
|
|
| 4201 | 4561 | $this->tpl['label'].= ($line->label ? ' '.$line->label : ''); |
| 4202 | 4562 | } |
| 4203 | 4563 | |
@@ -4210,36 +4570,35 @@ discard block |
||
| 4210 | 4570 | |
| 4211 | 4571 | if (! empty($line->desc)) |
| 4212 | 4572 | {
|
| 4213 | - if ($line->desc == '(CREDIT_NOTE)') // TODO Not sure this is used for source object |
|
| 4573 | + if ($line->desc == '(CREDIT_NOTE)') { |
|
| 4574 | + // TODO Not sure this is used for source object |
|
| 4214 | 4575 | {
|
| 4215 | - $discount=new DiscountAbsolute($this->db); |
|
| 4576 | + $discount=new DiscountAbsolute($this->db); |
|
| 4577 | + } |
|
| 4216 | 4578 | $discount->fetch($line->fk_remise_except); |
| 4217 | 4579 | $this->tpl['description'] = $langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0));
|
| 4218 | - } |
|
| 4219 | - elseif ($line->desc == '(DEPOSIT)') // TODO Not sure this is used for source object |
|
| 4580 | + } elseif ($line->desc == '(DEPOSIT)') { |
|
| 4581 | + // TODO Not sure this is used for source object |
|
| 4220 | 4582 | {
|
| 4221 | - $discount=new DiscountAbsolute($this->db); |
|
| 4583 | + $discount=new DiscountAbsolute($this->db); |
|
| 4584 | + } |
|
| 4222 | 4585 | $discount->fetch($line->fk_remise_except); |
| 4223 | 4586 | $this->tpl['description'] = $langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0));
|
| 4224 | - } |
|
| 4225 | - elseif ($line->desc == '(EXCESS RECEIVED)') |
|
| 4587 | + } elseif ($line->desc == '(EXCESS RECEIVED)') |
|
| 4226 | 4588 | {
|
| 4227 | 4589 | $discount=new DiscountAbsolute($this->db); |
| 4228 | 4590 | $discount->fetch($line->fk_remise_except); |
| 4229 | 4591 | $this->tpl['description'] = $langs->transnoentities("DiscountFromExcessReceived",$discount->getNomUrl(0));
|
| 4230 | - } |
|
| 4231 | - elseif ($line->desc == '(EXCESS PAID)') |
|
| 4592 | + } elseif ($line->desc == '(EXCESS PAID)') |
|
| 4232 | 4593 | {
|
| 4233 | 4594 | $discount=new DiscountAbsolute($this->db); |
| 4234 | 4595 | $discount->fetch($line->fk_remise_except); |
| 4235 | 4596 | $this->tpl['description'] = $langs->transnoentities("DiscountFromExcessPaid",$discount->getNomUrl(0));
|
| 4236 | - } |
|
| 4237 | - else |
|
| 4597 | + } else |
|
| 4238 | 4598 | {
|
| 4239 | 4599 | $this->tpl['description'] = dol_trunc($line->desc,60); |
| 4240 | 4600 | } |
| 4241 | - } |
|
| 4242 | - else |
|
| 4601 | + } else |
|
| 4243 | 4602 | {
|
| 4244 | 4603 | $this->tpl['description'] = ' '; |
| 4245 | 4604 | } |
@@ -4247,17 +4606,23 @@ discard block |
||
| 4247 | 4606 | // VAT Rate |
| 4248 | 4607 | $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); |
| 4249 | 4608 | $this->tpl['vat_rate'] .= (($line->info_bits & 1) == 1) ? '*' : ''; |
| 4250 | - if (! empty($line->vat_src_code) && ! preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'].=' ('.$line->vat_src_code.')';
|
|
| 4609 | + if (! empty($line->vat_src_code) && ! preg_match('/\(/', $this->tpl['vat_rate'])) { |
|
| 4610 | + $this->tpl['vat_rate'].=' ('.$line->vat_src_code.')'; |
|
| 4611 | + } |
|
| 4251 | 4612 | |
| 4252 | 4613 | $this->tpl['price'] = price($line->subprice); |
| 4253 | 4614 | $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); |
| 4254 | 4615 | $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; |
| 4255 | - if ($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long'));
|
|
| 4616 | + if ($conf->global->PRODUCT_USE_UNITS) { |
|
| 4617 | + $this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long')); |
|
| 4618 | + } |
|
| 4256 | 4619 | $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' '; |
| 4257 | 4620 | |
| 4258 | 4621 | // Is the line strike or not |
| 4259 | 4622 | $this->tpl['strike']=0; |
| 4260 | - if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) $this->tpl['strike']=1; |
|
| 4623 | + if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) { |
|
| 4624 | + $this->tpl['strike']=1; |
|
| 4625 | + } |
|
| 4261 | 4626 | |
| 4262 | 4627 | // Output template part (modules that overwrite templates must declare this into descriptor) |
| 4263 | 4628 | // Use global variables + $dateSelector + $seller and $buyer |
@@ -4270,7 +4635,9 @@ discard block |
||
| 4270 | 4635 | } else {
|
| 4271 | 4636 | $res=include $tpl; // for debug |
| 4272 | 4637 | } |
| 4273 | - if ($res) break; |
|
| 4638 | + if ($res) { |
|
| 4639 | + break; |
|
| 4640 | + } |
|
| 4274 | 4641 | } |
| 4275 | 4642 | } |
| 4276 | 4643 | |
@@ -4312,8 +4679,7 @@ discard block |
||
| 4312 | 4679 | {
|
| 4313 | 4680 | $this->db->commit(); |
| 4314 | 4681 | return 1; |
| 4315 | - } |
|
| 4316 | - else |
|
| 4682 | + } else |
|
| 4317 | 4683 | {
|
| 4318 | 4684 | $this->error=$this->db->lasterror(); |
| 4319 | 4685 | $this->db->rollback(); |
@@ -4348,8 +4714,7 @@ discard block |
||
| 4348 | 4714 | $this->error=$this->db->lasterror(); |
| 4349 | 4715 | $this->db->rollback(); |
| 4350 | 4716 | return -1; |
| 4351 | - } |
|
| 4352 | - else |
|
| 4717 | + } else |
|
| 4353 | 4718 | {
|
| 4354 | 4719 | if (! $notrigger) |
| 4355 | 4720 | {
|
@@ -4416,13 +4781,20 @@ discard block |
||
| 4416 | 4781 | // Search template files |
| 4417 | 4782 | $file=''; $classname=''; $filefound=0; |
| 4418 | 4783 | $dirmodels=array('/');
|
| 4419 | - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
| 4784 | + if (is_array($conf->modules_parts['models'])) { |
|
| 4785 | + $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); |
|
| 4786 | + } |
|
| 4420 | 4787 | foreach($dirmodels as $reldir) |
| 4421 | 4788 | {
|
| 4422 | 4789 | foreach(array('doc','pdf') as $prefix)
|
| 4423 | 4790 | {
|
| 4424 | - if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php
|
|
| 4425 | - else $file = $prefix."_".$modele.".modules.php"; |
|
| 4791 | + if (in_array(get_class($this), array('Adherent'))) { |
|
| 4792 | + $file = $prefix."_".$modele.".class.php"; |
|
| 4793 | + } |
|
| 4794 | + // Member module use prefix_module.class.php |
|
| 4795 | + else { |
|
| 4796 | + $file = $prefix."_".$modele.".modules.php"; |
|
| 4797 | + } |
|
| 4426 | 4798 | |
| 4427 | 4799 | // On verifie l'emplacement du modele |
| 4428 | 4800 | $file=dol_buildpath($reldir.$modelspath.$file,0); |
@@ -4433,7 +4805,9 @@ discard block |
||
| 4433 | 4805 | break; |
| 4434 | 4806 | } |
| 4435 | 4807 | } |
| 4436 | - if ($filefound) break; |
|
| 4808 | + if ($filefound) { |
|
| 4809 | + break; |
|
| 4810 | + } |
|
| 4437 | 4811 | } |
| 4438 | 4812 | |
| 4439 | 4813 | // If generator was found |
@@ -4465,7 +4839,9 @@ discard block |
||
| 4465 | 4839 | if (is_dir($tmpdir)) |
| 4466 | 4840 | {
|
| 4467 | 4841 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0); |
| 4468 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 4842 | + if (count($tmpfiles)) { |
|
| 4843 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 4844 | + } |
|
| 4469 | 4845 | } |
| 4470 | 4846 | } |
| 4471 | 4847 | |
@@ -4503,8 +4879,7 @@ discard block |
||
| 4503 | 4879 | {
|
| 4504 | 4880 | $arrayofrecords = array(); // The write_file of templates of adherent class need this var |
| 4505 | 4881 | $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); |
| 4506 | - } |
|
| 4507 | - else |
|
| 4882 | + } else |
|
| 4508 | 4883 | {
|
| 4509 | 4884 | $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); |
| 4510 | 4885 | } |
@@ -4526,9 +4901,11 @@ discard block |
||
| 4526 | 4901 | $destfile = basename($destfull); |
| 4527 | 4902 | $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir);
|
| 4528 | 4903 | |
| 4529 | - if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir
|
|
| 4904 | + if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) { |
|
| 4905 | + // If not a tmp dir |
|
| 4530 | 4906 | {
|
| 4531 | - $filename = basename($destfile); |
|
| 4907 | + $filename = basename($destfile); |
|
| 4908 | + } |
|
| 4532 | 4909 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
| 4533 | 4910 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
| 4534 | 4911 | |
@@ -4541,18 +4918,30 @@ discard block |
||
| 4541 | 4918 | if ($this->element == 'propal') |
| 4542 | 4919 | {
|
| 4543 | 4920 | $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok |
| 4544 | - if ($useonlinesignature) $setsharekey=true; |
|
| 4545 | - if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; |
|
| 4921 | + if ($useonlinesignature) { |
|
| 4922 | + $setsharekey=true; |
|
| 4923 | + } |
|
| 4924 | + if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) { |
|
| 4925 | + $setsharekey=true; |
|
| 4926 | + } |
|
| 4546 | 4927 | } |
| 4547 | - if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; |
|
| 4548 | - if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; |
|
| 4549 | - if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; |
|
| 4928 | + if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { |
|
| 4929 | + $setsharekey=true; |
|
| 4930 | + } |
|
| 4931 | + if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { |
|
| 4932 | + $setsharekey=true; |
|
| 4933 | + } |
|
| 4934 | + if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { |
|
| 4935 | + $setsharekey=true; |
|
| 4936 | + } |
|
| 4550 | 4937 | |
| 4551 | 4938 | if ($setsharekey) |
| 4552 | 4939 | {
|
| 4553 | - if (empty($ecmfile->share)) // Because object not found or share not set yet |
|
| 4940 | + if (empty($ecmfile->share)) { |
|
| 4941 | + // Because object not found or share not set yet |
|
| 4554 | 4942 | {
|
| 4555 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; |
|
| 4943 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; |
|
| 4944 | + } |
|
| 4556 | 4945 | $ecmfile->share = getRandomPassword(true); |
| 4557 | 4946 | } |
| 4558 | 4947 | } |
@@ -4569,8 +4958,7 @@ discard block |
||
| 4569 | 4958 | {
|
| 4570 | 4959 | setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
| 4571 | 4960 | } |
| 4572 | - } |
|
| 4573 | - else |
|
| 4961 | + } else |
|
| 4574 | 4962 | {
|
| 4575 | 4963 | $ecmfile->entity = $conf->entity; |
| 4576 | 4964 | $ecmfile->filepath = $rel_dir; |
@@ -4597,17 +4985,20 @@ discard block |
||
| 4597 | 4985 | |
| 4598 | 4986 | // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) |
| 4599 | 4987 | $update_main_doc_field=0; |
| 4600 | - if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1; |
|
| 4988 | + if (! empty($obj->update_main_doc_field)) { |
|
| 4989 | + $update_main_doc_field=1; |
|
| 4990 | + } |
|
| 4601 | 4991 | if ($update_main_doc_field && ! empty($this->table_element)) |
| 4602 | 4992 | {
|
| 4603 | 4993 | $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".($ecmfile->filepath.'/'.$ecmfile->filename)."'"; |
| 4604 | 4994 | $sql.= ' WHERE rowid = '.$this->id; |
| 4605 | 4995 | $resql = $this->db->query($sql); |
| 4606 | - if (! $resql) dol_print_error($this->db); |
|
| 4996 | + if (! $resql) { |
|
| 4997 | + dol_print_error($this->db); |
|
| 4998 | + } |
|
| 4607 | 4999 | } |
| 4608 | 5000 | } |
| 4609 | - } |
|
| 4610 | - else |
|
| 5001 | + } else |
|
| 4611 | 5002 | {
|
| 4612 | 5003 | dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING);
|
| 4613 | 5004 | } |
@@ -4616,15 +5007,13 @@ discard block |
||
| 4616 | 5007 | dol_meta_create($this); |
| 4617 | 5008 | |
| 4618 | 5009 | return 1; |
| 4619 | - } |
|
| 4620 | - else |
|
| 5010 | + } else |
|
| 4621 | 5011 | {
|
| 4622 | 5012 | $outputlangs->charset_output=$sav_charset_output; |
| 4623 | 5013 | dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); |
| 4624 | 5014 | return -1; |
| 4625 | 5015 | } |
| 4626 | - } |
|
| 4627 | - else |
|
| 5016 | + } else |
|
| 4628 | 5017 | {
|
| 4629 | 5018 | $this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file);
|
| 4630 | 5019 | dol_print_error('',$this->error);
|
@@ -4680,13 +5069,21 @@ discard block |
||
| 4680 | 5069 | global $conf, $_POST; |
| 4681 | 5070 | |
| 4682 | 5071 | // If param here has been posted, we use this value first. |
| 4683 | - if (isset($_POST[$fieldname])) return GETPOST($fieldname, 2); |
|
| 5072 | + if (isset($_POST[$fieldname])) { |
|
| 5073 | + return GETPOST($fieldname, 2); |
|
| 5074 | + } |
|
| 4684 | 5075 | |
| 4685 | - if (isset($alternatevalue)) return $alternatevalue; |
|
| 5076 | + if (isset($alternatevalue)) { |
|
| 5077 | + return $alternatevalue; |
|
| 5078 | + } |
|
| 4686 | 5079 | |
| 4687 | 5080 | $newelement=$this->element; |
| 4688 | - if ($newelement == 'facture') $newelement='invoice'; |
|
| 4689 | - if ($newelement == 'commande') $newelement='order'; |
|
| 5081 | + if ($newelement == 'facture') { |
|
| 5082 | + $newelement='invoice'; |
|
| 5083 | + } |
|
| 5084 | + if ($newelement == 'commande') { |
|
| 5085 | + $newelement='order'; |
|
| 5086 | + } |
|
| 4690 | 5087 | if (empty($newelement)) |
| 4691 | 5088 | {
|
| 4692 | 5089 | dol_syslog("Ask a default value using common method getDefaultCreateValueForField on an object with no property ->element defined. Return empty string.", LOG_WARNING);
|
@@ -4695,7 +5092,9 @@ discard block |
||
| 4695 | 5092 | |
| 4696 | 5093 | $keyforfieldname=strtoupper($newelement.'_DEFAULT_'.$fieldname); |
| 4697 | 5094 | //var_dump($keyforfieldname); |
| 4698 | - if (isset($conf->global->$keyforfieldname)) return $conf->global->$keyforfieldname; |
|
| 5095 | + if (isset($conf->global->$keyforfieldname)) { |
|
| 5096 | + return $conf->global->$keyforfieldname; |
|
| 5097 | + } |
|
| 4699 | 5098 | |
| 4700 | 5099 | // TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname |
| 4701 | 5100 | } |
@@ -4729,8 +5128,7 @@ discard block |
||
| 4729 | 5128 | if (!empty($this->errors)) |
| 4730 | 5129 | {
|
| 4731 | 5130 | $this->errors=array_unique(array_merge($this->errors,$interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice. |
| 4732 | - } |
|
| 4733 | - else |
|
| 5131 | + } else |
|
| 4734 | 5132 | {
|
| 4735 | 5133 | $this->errors=$interface->errors; |
| 4736 | 5134 | } |
@@ -4754,7 +5152,9 @@ discard block |
||
| 4754 | 5152 | function fetch_optionals($rowid=null, $optionsArray=null) |
| 4755 | 5153 | {
|
| 4756 | 5154 | // phpcs:enable |
| 4757 | - if (empty($rowid)) $rowid=$this->id; |
|
| 5155 | + if (empty($rowid)) { |
|
| 5156 | + $rowid=$this->id; |
|
| 5157 | + } |
|
| 4758 | 5158 | |
| 4759 | 5159 | // To avoid SQL errors. Probably not the better solution though |
| 4760 | 5160 | if (!$this->table_element) {
|
@@ -4780,15 +5180,17 @@ discard block |
||
| 4780 | 5180 | $extrafields->fetch_name_optionals_label($this->table_element); |
| 4781 | 5181 | } |
| 4782 | 5182 | $optionsArray = (! empty($extrafields->attributes[$this->table_element]['label'])?$extrafields->attributes[$this->table_element]['label']:null); |
| 4783 | - } |
|
| 4784 | - else |
|
| 5183 | + } else |
|
| 4785 | 5184 | {
|
| 4786 | 5185 | global $extrafields; |
| 4787 | 5186 | dol_syslog("Warning: fetch_optionals was called with param optionsArray defined when you should pass null now", LOG_WARNING);
|
| 4788 | 5187 | } |
| 4789 | 5188 | |
| 4790 | 5189 | $table_element = $this->table_element; |
| 4791 | - if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility |
|
| 5190 | + if ($table_element == 'categorie') { |
|
| 5191 | + $table_element = 'categories'; |
|
| 5192 | + } |
|
| 5193 | + // For compatibility |
|
| 4792 | 5194 | |
| 4793 | 5195 | // Request to get complementary values |
| 4794 | 5196 | if (is_array($optionsArray) && count($optionsArray) > 0) |
@@ -4824,8 +5226,7 @@ discard block |
||
| 4824 | 5226 | {
|
| 4825 | 5227 | //var_dump($extrafields->attributes[$this->table_element]['type'][$key]); |
| 4826 | 5228 | $this->array_options["options_".$key]=$this->db->jdate($value); |
| 4827 | - } |
|
| 4828 | - else |
|
| 5229 | + } else |
|
| 4829 | 5230 | {
|
| 4830 | 5231 | $this->array_options["options_".$key]=$value; |
| 4831 | 5232 | } |
@@ -4837,10 +5238,12 @@ discard block |
||
| 4837 | 5238 | |
| 4838 | 5239 | $this->db->free($resql); |
| 4839 | 5240 | |
| 4840 | - if ($numrows) return $numrows; |
|
| 4841 | - else return 0; |
|
| 4842 | - } |
|
| 4843 | - else |
|
| 5241 | + if ($numrows) { |
|
| 5242 | + return $numrows; |
|
| 5243 | + } else { |
|
| 5244 | + return 0; |
|
| 5245 | + } |
|
| 5246 | + } else |
|
| 4844 | 5247 | {
|
| 4845 | 5248 | dol_print_error($this->db); |
| 4846 | 5249 | return -1; |
@@ -4859,7 +5262,10 @@ discard block |
||
| 4859 | 5262 | $this->db->begin(); |
| 4860 | 5263 | |
| 4861 | 5264 | $table_element = $this->table_element; |
| 4862 | - if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility |
|
| 5265 | + if ($table_element == 'categorie') { |
|
| 5266 | + $table_element = 'categories'; |
|
| 5267 | + } |
|
| 5268 | + // For compatibility |
|
| 4863 | 5269 | |
| 4864 | 5270 | $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id; |
| 4865 | 5271 | dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG); |
@@ -4869,8 +5275,7 @@ discard block |
||
| 4869 | 5275 | $this->error=$this->db->lasterror(); |
| 4870 | 5276 | $this->db->rollback(); |
| 4871 | 5277 | return -1; |
| 4872 | - } |
|
| 4873 | - else |
|
| 5278 | + } else |
|
| 4874 | 5279 | {
|
| 4875 | 5280 | $this->db->commit(); |
| 4876 | 5281 | return 1; |
@@ -4891,11 +5296,16 @@ discard block |
||
| 4891 | 5296 | {
|
| 4892 | 5297 | global $conf,$langs,$user; |
| 4893 | 5298 | |
| 4894 | - if (empty($userused)) $userused=$user; |
|
| 5299 | + if (empty($userused)) { |
|
| 5300 | + $userused=$user; |
|
| 5301 | + } |
|
| 4895 | 5302 | |
| 4896 | 5303 | $error=0; |
| 4897 | 5304 | |
| 4898 | - if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used |
|
| 5305 | + if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 5306 | + return 0; |
|
| 5307 | + } |
|
| 5308 | + // For avoid conflicts if trigger used |
|
| 4899 | 5309 | |
| 4900 | 5310 | if (! empty($this->array_options)) |
| 4901 | 5311 | {
|
@@ -4908,10 +5318,13 @@ discard block |
||
| 4908 | 5318 | //Eliminate copied source object extra_fields that do not exist in target object |
| 4909 | 5319 | $new_array_options=array(); |
| 4910 | 5320 | foreach ($this->array_options as $key => $value) {
|
| 4911 | - if (in_array(substr($key,8), array_keys($target_extrafields))) // We remove the 'options_' from $key for test |
|
| 4912 | - $new_array_options[$key] = $value; |
|
| 4913 | - elseif (in_array($key, array_keys($target_extrafields))) // We test on $key that does not contains the 'options_' prefix |
|
| 4914 | - $new_array_options['options_'.$key] = $value; |
|
| 5321 | + if (in_array(substr($key,8), array_keys($target_extrafields))) { |
|
| 5322 | + // We remove the 'options_' from $key for test |
|
| 5323 | + $new_array_options[$key] = $value; |
|
| 5324 | + } elseif (in_array($key, array_keys($target_extrafields))) { |
|
| 5325 | + // We test on $key that does not contains the 'options_' prefix |
|
| 5326 | + $new_array_options['options_'.$key] = $value; |
|
| 5327 | + } |
|
| 4915 | 5328 | } |
| 4916 | 5329 | |
| 4917 | 5330 | foreach($new_array_options as $key => $value) |
@@ -4925,8 +5338,12 @@ discard block |
||
| 4925 | 5338 | if ($attributeRequired) |
| 4926 | 5339 | {
|
| 4927 | 5340 | $mandatorypb=false; |
| 4928 | - if ($attributeType == 'link' && $this->array_options[$key] == '-1') $mandatorypb=true; |
|
| 4929 | - if ($this->array_options[$key] === '') $mandatorypb=true; |
|
| 5341 | + if ($attributeType == 'link' && $this->array_options[$key] == '-1') { |
|
| 5342 | + $mandatorypb=true; |
|
| 5343 | + } |
|
| 5344 | + if ($this->array_options[$key] === '') { |
|
| 5345 | + $mandatorypb=true; |
|
| 5346 | + } |
|
| 4930 | 5347 | if ($mandatorypb) |
| 4931 | 5348 | {
|
| 4932 | 5349 | dol_syslog($this->error); |
@@ -4945,8 +5362,7 @@ discard block |
||
| 4945 | 5362 | {
|
| 4946 | 5363 | $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
|
| 4947 | 5364 | return -1; |
| 4948 | - } |
|
| 4949 | - elseif ($value=='') |
|
| 5365 | + } elseif ($value=='') |
|
| 4950 | 5366 | {
|
| 4951 | 5367 | $new_array_options[$key] = null; |
| 4952 | 5368 | } |
@@ -4958,8 +5374,7 @@ discard block |
||
| 4958 | 5374 | dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG);
|
| 4959 | 5375 | $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
|
| 4960 | 5376 | return -1; |
| 4961 | - } |
|
| 4962 | - elseif ($value=='') |
|
| 5377 | + } elseif ($value=='') |
|
| 4963 | 5378 | {
|
| 4964 | 5379 | $new_array_options[$key] = null; |
| 4965 | 5380 | } |
@@ -4984,27 +5399,27 @@ discard block |
||
| 4984 | 5399 | //global $action; // $action may be 'create', 'update', 'update_extras'... |
| 4985 | 5400 | //var_dump($action); |
| 4986 | 5401 | //var_dump($this->oldcopy);exit; |
| 4987 | - if (is_object($this->oldcopy)) // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value |
|
| 5402 | + if (is_object($this->oldcopy)) { |
|
| 5403 | + // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value |
|
| 4988 | 5404 | {
|
| 4989 | 5405 | //var_dump($this->oldcopy->array_options[$key]); var_dump($this->array_options[$key]); |
| 4990 | 5406 | if ($this->array_options[$key] == $this->oldcopy->array_options[$key]) // If old value crypted in database is same than submited new value, it means we don't change it, so we don't update. |
| 4991 | 5407 | {
|
| 4992 | - $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
|
| 4993 | - } |
|
| 4994 | - else |
|
| 5408 | + $new_array_options[$key] = $this->array_options[$key]; |
|
| 5409 | + } |
|
| 5410 | + // Value is kept |
|
| 5411 | + } else |
|
| 4995 | 5412 | {
|
| 4996 | 5413 | // var_dump($algo); |
| 4997 | 5414 | $newvalue = dol_hash($this->array_options[$key], $algo); |
| 4998 | 5415 | $new_array_options[$key] = $newvalue; |
| 4999 | 5416 | } |
| 5000 | - } |
|
| 5001 | - else |
|
| 5417 | + } else |
|
| 5002 | 5418 | {
|
| 5003 | 5419 | $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
| 5004 | 5420 | } |
| 5005 | 5421 | } |
| 5006 | - } |
|
| 5007 | - else // Common usage |
|
| 5422 | + } else // Common usage |
|
| 5008 | 5423 | {
|
| 5009 | 5424 | $new_array_options[$key] = $this->array_options[$key]; |
| 5010 | 5425 | } |
@@ -5030,26 +5445,30 @@ discard block |
||
| 5030 | 5445 | dol_include_once($InfoFieldList[1]); |
| 5031 | 5446 | if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) |
| 5032 | 5447 | {
|
| 5033 | - if ($value == '-1') // -1 is key for no defined in combo list of objects |
|
| 5448 | + if ($value == '-1') { |
|
| 5449 | + // -1 is key for no defined in combo list of objects |
|
| 5034 | 5450 | {
|
| 5035 | - $new_array_options[$key]=''; |
|
| 5036 | - } |
|
| 5037 | - elseif ($value) |
|
| 5451 | + $new_array_options[$key]=''; |
|
| 5452 | + } |
|
| 5453 | + } elseif ($value) |
|
| 5038 | 5454 | {
|
| 5039 | 5455 | $object = new $InfoFieldList[0]($this->db); |
| 5040 | - if (is_numeric($value)) $res=$object->fetch($value); |
|
| 5041 | - else $res=$object->fetch('',$value);
|
|
| 5042 | - |
|
| 5043 | - if ($res > 0) $new_array_options[$key]=$object->id; |
|
| 5044 | - else |
|
| 5456 | + if (is_numeric($value)) { |
|
| 5457 | + $res=$object->fetch($value); |
|
| 5458 | + } else { |
|
| 5459 | + $res=$object->fetch('',$value); |
|
| 5460 | + } |
|
| 5461 | + |
|
| 5462 | + if ($res > 0) { |
|
| 5463 | + $new_array_options[$key]=$object->id; |
|
| 5464 | + } else |
|
| 5045 | 5465 | {
|
| 5046 | 5466 | $this->error="Id/Ref '".$value."' for object '".$object->element."' not found"; |
| 5047 | 5467 | $this->db->rollback(); |
| 5048 | 5468 | return -1; |
| 5049 | 5469 | } |
| 5050 | 5470 | } |
| 5051 | - } |
|
| 5052 | - else |
|
| 5471 | + } else |
|
| 5053 | 5472 | {
|
| 5054 | 5473 | dol_syslog('Error bad setup of extrafield', LOG_WARNING);
|
| 5055 | 5474 | } |
@@ -5060,7 +5479,10 @@ discard block |
||
| 5060 | 5479 | $this->db->begin(); |
| 5061 | 5480 | |
| 5062 | 5481 | $table_element = $this->table_element; |
| 5063 | - if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility |
|
| 5482 | + if ($table_element == 'categorie') { |
|
| 5483 | + $table_element = 'categories'; |
|
| 5484 | + } |
|
| 5485 | + // For compatibility |
|
| 5064 | 5486 | |
| 5065 | 5487 | $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id; |
| 5066 | 5488 | dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG); |
@@ -5071,8 +5493,10 @@ discard block |
||
| 5071 | 5493 | {
|
| 5072 | 5494 | $attributeKey = substr($key,8); // Remove 'options_' prefix |
| 5073 | 5495 | // Add field of attribut |
| 5074 | - if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator |
|
| 5075 | - $sql.=",".$attributeKey; |
|
| 5496 | + if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') { |
|
| 5497 | + // Only for other type than separator |
|
| 5498 | + $sql.=",".$attributeKey; |
|
| 5499 | + } |
|
| 5076 | 5500 | } |
| 5077 | 5501 | $sql .= ") VALUES (".$this->id;
|
| 5078 | 5502 | |
@@ -5080,13 +5504,14 @@ discard block |
||
| 5080 | 5504 | {
|
| 5081 | 5505 | $attributeKey = substr($key,8); // Remove 'options_' prefix |
| 5082 | 5506 | // Add field of attribute |
| 5083 | - if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator) |
|
| 5507 | + if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') { |
|
| 5508 | + // Only for other type than separator) |
|
| 5084 | 5509 | {
|
| 5085 | 5510 | if ($new_array_options[$key] != '') |
| 5086 | 5511 | {
|
| 5087 | - $sql.=",'".$this->db->escape($new_array_options[$key])."'"; |
|
| 5088 | - } |
|
| 5089 | - else |
|
| 5512 | + $sql.=",'".$this->db->escape($new_array_options[$key])."'"; |
|
| 5513 | + } |
|
| 5514 | + } else |
|
| 5090 | 5515 | {
|
| 5091 | 5516 | $sql.=",null"; |
| 5092 | 5517 | } |
@@ -5107,7 +5532,9 @@ discard block |
||
| 5107 | 5532 | // Call trigger |
| 5108 | 5533 | $this->context=array('extrafieldaddupdate'=>1);
|
| 5109 | 5534 | $result=$this->call_trigger($trigger, $userused); |
| 5110 | - if ($result < 0) $error++; |
|
| 5535 | + if ($result < 0) { |
|
| 5536 | + $error++; |
|
| 5537 | + } |
|
| 5111 | 5538 | // End call trigger |
| 5112 | 5539 | } |
| 5113 | 5540 | |
@@ -5115,14 +5542,14 @@ discard block |
||
| 5115 | 5542 | {
|
| 5116 | 5543 | $this->db->rollback(); |
| 5117 | 5544 | return -1; |
| 5118 | - } |
|
| 5119 | - else |
|
| 5545 | + } else |
|
| 5120 | 5546 | {
|
| 5121 | 5547 | $this->db->commit(); |
| 5122 | 5548 | return 1; |
| 5123 | 5549 | } |
| 5124 | - } |
|
| 5125 | - else return 0; |
|
| 5550 | + } else { |
|
| 5551 | + return 0; |
|
| 5552 | + } |
|
| 5126 | 5553 | } |
| 5127 | 5554 | |
| 5128 | 5555 | /** |
@@ -5139,11 +5566,16 @@ discard block |
||
| 5139 | 5566 | {
|
| 5140 | 5567 | global $conf,$langs,$user; |
| 5141 | 5568 | |
| 5142 | - if (empty($userused)) $userused=$user; |
|
| 5569 | + if (empty($userused)) { |
|
| 5570 | + $userused=$user; |
|
| 5571 | + } |
|
| 5143 | 5572 | |
| 5144 | 5573 | $error=0; |
| 5145 | 5574 | |
| 5146 | - if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used |
|
| 5575 | + if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
| 5576 | + return 0; |
|
| 5577 | + } |
|
| 5578 | + // For avoid conflicts if trigger used |
|
| 5147 | 5579 | |
| 5148 | 5580 | if (! empty($this->array_options) && isset($this->array_options["options_".$key])) |
| 5149 | 5581 | {
|
@@ -5170,8 +5602,7 @@ discard block |
||
| 5170 | 5602 | {
|
| 5171 | 5603 | $this->errors[]=$langs->trans("ExtraFieldHasWrongValue",$attributeLabel);
|
| 5172 | 5604 | return -1; |
| 5173 | - } |
|
| 5174 | - elseif ($value=='') |
|
| 5605 | + } elseif ($value=='') |
|
| 5175 | 5606 | {
|
| 5176 | 5607 | $this->array_options["options_".$key] = null; |
| 5177 | 5608 | } |
@@ -5183,8 +5614,7 @@ discard block |
||
| 5183 | 5614 | dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG);
|
| 5184 | 5615 | $this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
|
| 5185 | 5616 | return -1; |
| 5186 | - } |
|
| 5187 | - elseif ($value=='') |
|
| 5617 | + } elseif ($value=='') |
|
| 5188 | 5618 | {
|
| 5189 | 5619 | $this->array_options["options_".$key] = null; |
| 5190 | 5620 | } |
@@ -5236,7 +5666,9 @@ discard block |
||
| 5236 | 5666 | // Call trigger |
| 5237 | 5667 | $this->context=array('extrafieldupdate'=>1);
|
| 5238 | 5668 | $result=$this->call_trigger($trigger, $userused); |
| 5239 | - if ($result < 0) $error++; |
|
| 5669 | + if ($result < 0) { |
|
| 5670 | + $error++; |
|
| 5671 | + } |
|
| 5240 | 5672 | // End call trigger |
| 5241 | 5673 | } |
| 5242 | 5674 | |
@@ -5245,14 +5677,14 @@ discard block |
||
| 5245 | 5677 | dol_syslog(get_class($this) . "::".__METHOD__ . $this->error, LOG_ERR); |
| 5246 | 5678 | $this->db->rollback(); |
| 5247 | 5679 | return -1; |
| 5248 | - } |
|
| 5249 | - else |
|
| 5680 | + } else |
|
| 5250 | 5681 | {
|
| 5251 | 5682 | $this->db->commit(); |
| 5252 | 5683 | return 1; |
| 5253 | 5684 | } |
| 5254 | - } |
|
| 5255 | - else return 0; |
|
| 5685 | + } else { |
|
| 5686 | + return 0; |
|
| 5687 | + } |
|
| 5256 | 5688 | } |
| 5257 | 5689 | |
| 5258 | 5690 | |
@@ -5327,8 +5759,11 @@ discard block |
||
| 5327 | 5759 | |
| 5328 | 5760 | if ($computed) |
| 5329 | 5761 | {
|
| 5330 | - if (! preg_match('/^search_/', $keyprefix)) return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>';
|
|
| 5331 | - else return ''; |
|
| 5762 | + if (! preg_match('/^search_/', $keyprefix)) { |
|
| 5763 | + return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>'; |
|
| 5764 | + } else { |
|
| 5765 | + return ''; |
|
| 5766 | + } |
|
| 5332 | 5767 | } |
| 5333 | 5768 | |
| 5334 | 5769 | |
@@ -5342,33 +5777,27 @@ discard block |
||
| 5342 | 5777 | if ($type == 'date') |
| 5343 | 5778 | {
|
| 5344 | 5779 | $morecss = 'minwidth100imp'; |
| 5345 | - } |
|
| 5346 | - elseif ($type == 'datetime') |
|
| 5780 | + } elseif ($type == 'datetime') |
|
| 5347 | 5781 | {
|
| 5348 | 5782 | $morecss = 'minwidth200imp'; |
| 5349 | - } |
|
| 5350 | - elseif (in_array($type,array('int','integer','price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/',$type))
|
|
| 5783 | + } elseif (in_array($type,array('int','integer','price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/',$type))
|
|
| 5351 | 5784 | {
|
| 5352 | 5785 | $morecss = 'maxwidth75'; |
| 5353 | - }elseif ($type == 'url') |
|
| 5786 | + } elseif ($type == 'url') |
|
| 5354 | 5787 | {
|
| 5355 | 5788 | $morecss='minwidth400'; |
| 5356 | - } |
|
| 5357 | - elseif ($type == 'boolean') |
|
| 5789 | + } elseif ($type == 'boolean') |
|
| 5358 | 5790 | {
|
| 5359 | 5791 | $morecss=''; |
| 5360 | - } |
|
| 5361 | - else |
|
| 5792 | + } else |
|
| 5362 | 5793 | {
|
| 5363 | 5794 | if (round($size) < 12) |
| 5364 | 5795 | {
|
| 5365 | 5796 | $morecss = 'minwidth100'; |
| 5366 | - } |
|
| 5367 | - else if (round($size) <= 48) |
|
| 5797 | + } else if (round($size) <= 48) |
|
| 5368 | 5798 | {
|
| 5369 | 5799 | $morecss = 'minwidth200'; |
| 5370 | - } |
|
| 5371 | - else |
|
| 5800 | + } else |
|
| 5372 | 5801 | {
|
| 5373 | 5802 | $morecss = 'minwidth400'; |
| 5374 | 5803 | } |
@@ -5383,52 +5812,50 @@ discard block |
||
| 5383 | 5812 | $showtime = in_array($type,array('datetime')) ? 1 : 0;
|
| 5384 | 5813 | |
| 5385 | 5814 | // Do not show current date when field not required (see selectDate() method) |
| 5386 | - if (!$required && $value == '') $value = '-1'; |
|
| 5815 | + if (!$required && $value == '') { |
|
| 5816 | + $value = '-1'; |
|
| 5817 | + } |
|
| 5387 | 5818 | |
| 5388 | 5819 | // TODO Must also support $moreparam |
| 5389 | 5820 | $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); |
| 5390 | - } |
|
| 5391 | - elseif (in_array($type,array('int','integer')))
|
|
| 5821 | + } elseif (in_array($type,array('int','integer')))
|
|
| 5392 | 5822 | {
|
| 5393 | 5823 | $tmp=explode(',',$size);
|
| 5394 | 5824 | $newsize=$tmp[0]; |
| 5395 | 5825 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>'; |
| 5396 | - } |
|
| 5397 | - elseif (preg_match('/varchar/', $type))
|
|
| 5826 | + } elseif (preg_match('/varchar/', $type))
|
|
| 5398 | 5827 | {
|
| 5399 | 5828 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>'; |
| 5400 | - } |
|
| 5401 | - elseif (in_array($type, array('mail', 'phone', 'url')))
|
|
| 5829 | + } elseif (in_array($type, array('mail', 'phone', 'url')))
|
|
| 5402 | 5830 | {
|
| 5403 | 5831 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>'; |
| 5404 | - } |
|
| 5405 | - elseif ($type == 'text') |
|
| 5832 | + } elseif ($type == 'text') |
|
| 5406 | 5833 | {
|
| 5407 | - if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field
|
|
| 5834 | + if (! preg_match('/search_/', $keyprefix)) { |
|
| 5835 | + // If keyprefix is search_ or search_options_, we must just use a simple text field |
|
| 5408 | 5836 | {
|
| 5409 | - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
| 5837 | + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
| 5838 | + } |
|
| 5410 | 5839 | $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,false,ROWS_5,'90%'); |
| 5411 | 5840 | $out=$doleditor->Create(1); |
| 5412 | - } |
|
| 5413 | - else |
|
| 5841 | + } else |
|
| 5414 | 5842 | {
|
| 5415 | 5843 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>'; |
| 5416 | 5844 | } |
| 5417 | - } |
|
| 5418 | - elseif ($type == 'html') |
|
| 5845 | + } elseif ($type == 'html') |
|
| 5419 | 5846 | {
|
| 5420 | - if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field
|
|
| 5847 | + if (! preg_match('/search_/', $keyprefix)) { |
|
| 5848 | + // If keyprefix is search_ or search_options_, we must just use a simple text field |
|
| 5421 | 5849 | {
|
| 5422 | - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
| 5850 | + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
|
| 5851 | + } |
|
| 5423 | 5852 | $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%'); |
| 5424 | 5853 | $out=$doleditor->Create(1); |
| 5425 | - } |
|
| 5426 | - else |
|
| 5854 | + } else |
|
| 5427 | 5855 | {
|
| 5428 | 5856 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>'; |
| 5429 | 5857 | } |
| 5430 | - } |
|
| 5431 | - elseif ($type == 'boolean') |
|
| 5858 | + } elseif ($type == 'boolean') |
|
| 5432 | 5859 | {
|
| 5433 | 5860 | $checked=''; |
| 5434 | 5861 | if (!empty($value)) {
|
@@ -5437,22 +5864,19 @@ discard block |
||
| 5437 | 5864 | $checked=' value="1" '; |
| 5438 | 5865 | } |
| 5439 | 5866 | $out='<input type="checkbox" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.$checked.' '.($moreparam?$moreparam:'').'>'; |
| 5440 | - } |
|
| 5441 | - elseif ($type == 'price') |
|
| 5867 | + } elseif ($type == 'price') |
|
| 5442 | 5868 | {
|
| 5443 | 5869 | if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
|
| 5444 | 5870 | $value=price($value); |
| 5445 | 5871 | } |
| 5446 | 5872 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency); |
| 5447 | - } |
|
| 5448 | - elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/',$type))
|
|
| 5873 | + } elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/',$type))
|
|
| 5449 | 5874 | {
|
| 5450 | 5875 | if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
|
| 5451 | 5876 | $value=price($value); |
| 5452 | 5877 | } |
| 5453 | 5878 | $out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '; |
| 5454 | - } |
|
| 5455 | - elseif ($type == 'select') |
|
| 5879 | + } elseif ($type == 'select') |
|
| 5456 | 5880 | {
|
| 5457 | 5881 | $out = ''; |
| 5458 | 5882 | if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) |
@@ -5462,10 +5886,14 @@ discard block |
||
| 5462 | 5886 | } |
| 5463 | 5887 | |
| 5464 | 5888 | $out.='<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>'; |
| 5465 | - if((! isset($this->fields[$key]['default'])) ||($this->fields[$key]['notnull']!=1))$out.='<option value="0"> </option>'; |
|
| 5889 | + if((! isset($this->fields[$key]['default'])) ||($this->fields[$key]['notnull']!=1)) { |
|
| 5890 | + $out.='<option value="0"> </option>'; |
|
| 5891 | + } |
|
| 5466 | 5892 | foreach ($param['options'] as $key => $val) |
| 5467 | 5893 | {
|
| 5468 | - if ((string) $key == '') continue; |
|
| 5894 | + if ((string) $key == '') { |
|
| 5895 | + continue; |
|
| 5896 | + } |
|
| 5469 | 5897 | list($val, $parent) = explode('|', $val);
|
| 5470 | 5898 | $out.='<option value="'.$key.'"'; |
| 5471 | 5899 | $out.= (((string) $value == (string) $key)?' selected':''); |
@@ -5473,8 +5901,7 @@ discard block |
||
| 5473 | 5901 | $out.='>'.$val.'</option>'; |
| 5474 | 5902 | } |
| 5475 | 5903 | $out.='</select>'; |
| 5476 | - } |
|
| 5477 | - elseif ($type == 'sellist') |
|
| 5904 | + } elseif ($type == 'sellist') |
|
| 5478 | 5905 | {
|
| 5479 | 5906 | $out = ''; |
| 5480 | 5907 | if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) |
@@ -5541,13 +5968,11 @@ discard block |
||
| 5541 | 5968 | {
|
| 5542 | 5969 | $sql.= ' as main, '.MAIN_DB_PREFIX .$InfoFieldList[0].'_extrafields as extra'; |
| 5543 | 5970 | $sqlwhere.= ' WHERE extra.fk_object=main.'.$InfoFieldList[2]. ' AND '.$InfoFieldList[4]; |
| 5544 | - } |
|
| 5545 | - else |
|
| 5971 | + } else |
|
| 5546 | 5972 | {
|
| 5547 | 5973 | $sqlwhere.= ' WHERE '.$InfoFieldList[4]; |
| 5548 | 5974 | } |
| 5549 | - } |
|
| 5550 | - else |
|
| 5975 | + } else |
|
| 5551 | 5976 | {
|
| 5552 | 5977 | $sqlwhere.= ' WHERE 1=1'; |
| 5553 | 5978 | } |
@@ -5583,8 +6008,7 @@ discard block |
||
| 5583 | 6008 | {
|
| 5584 | 6009 | $labeltoshow.= $obj->$field_toshow.' '; |
| 5585 | 6010 | } |
| 5586 | - } |
|
| 5587 | - else |
|
| 6011 | + } else |
|
| 5588 | 6012 | {
|
| 5589 | 6013 | $labeltoshow=$obj->{$InfoFieldList[1]};
|
| 5590 | 6014 | } |
@@ -5597,25 +6021,25 @@ discard block |
||
| 5597 | 6021 | $translabel=$langs->trans($obj->$field_toshow); |
| 5598 | 6022 | if ($translabel!=$obj->$field_toshow) {
|
| 5599 | 6023 | $labeltoshow=dol_trunc($translabel,18).' '; |
| 5600 | - }else {
|
|
| 6024 | + } else {
|
|
| 5601 | 6025 | $labeltoshow=dol_trunc($obj->$field_toshow,18).' '; |
| 5602 | 6026 | } |
| 5603 | 6027 | } |
| 5604 | 6028 | $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
| 5605 | - } |
|
| 5606 | - else |
|
| 6029 | + } else |
|
| 5607 | 6030 | {
|
| 5608 | 6031 | if (! $notrans) |
| 5609 | 6032 | {
|
| 5610 | 6033 | $translabel=$langs->trans($obj->{$InfoFieldList[1]});
|
| 5611 | 6034 | if ($translabel!=$obj->{$InfoFieldList[1]}) {
|
| 5612 | 6035 | $labeltoshow=dol_trunc($translabel,18); |
| 5613 | - } |
|
| 5614 | - else {
|
|
| 6036 | + } else {
|
|
| 5615 | 6037 | $labeltoshow=dol_trunc($obj->{$InfoFieldList[1]},18);
|
| 5616 | 6038 | } |
| 5617 | 6039 | } |
| 5618 | - if (empty($labeltoshow)) $labeltoshow='(not defined)'; |
|
| 6040 | + if (empty($labeltoshow)) { |
|
| 6041 | + $labeltoshow='(not defined)'; |
|
| 6042 | + } |
|
| 5619 | 6043 | if ($value==$obj->rowid) |
| 5620 | 6044 | {
|
| 5621 | 6045 | $out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
@@ -5635,19 +6059,16 @@ discard block |
||
| 5635 | 6059 | $i++; |
| 5636 | 6060 | } |
| 5637 | 6061 | $this->db->free($resql); |
| 5638 | - } |
|
| 5639 | - else {
|
|
| 6062 | + } else {
|
|
| 5640 | 6063 | print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>'; |
| 5641 | 6064 | } |
| 5642 | 6065 | } |
| 5643 | 6066 | $out.='</select>'; |
| 5644 | - } |
|
| 5645 | - elseif ($type == 'checkbox') |
|
| 6067 | + } elseif ($type == 'checkbox') |
|
| 5646 | 6068 | {
|
| 5647 | 6069 | $value_arr=explode(',',$value);
|
| 5648 | 6070 | $out=$form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); |
| 5649 | - } |
|
| 5650 | - elseif ($type == 'radio') |
|
| 6071 | + } elseif ($type == 'radio') |
|
| 5651 | 6072 | {
|
| 5652 | 6073 | $out=''; |
| 5653 | 6074 | foreach ($param['options'] as $keyopt => $val) |
@@ -5658,13 +6079,11 @@ discard block |
||
| 5658 | 6079 | $out.= ($value==$keyopt?'checked':''); |
| 5659 | 6080 | $out.='/><label for="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'">'.$val.'</label><br>'; |
| 5660 | 6081 | } |
| 5661 | - } |
|
| 5662 | - elseif ($type == 'chkbxlst') |
|
| 6082 | + } elseif ($type == 'chkbxlst') |
|
| 5663 | 6083 | {
|
| 5664 | 6084 | if (is_array($value)) {
|
| 5665 | 6085 | $value_arr = $value; |
| 5666 | - } |
|
| 5667 | - else {
|
|
| 6086 | + } else {
|
|
| 5668 | 6087 | $value_arr = explode(',', $value);
|
| 5669 | 6088 | } |
| 5670 | 6089 | |
@@ -5779,8 +6198,9 @@ discard block |
||
| 5779 | 6198 | $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18);
|
| 5780 | 6199 | } |
| 5781 | 6200 | } |
| 5782 | - if (empty($labeltoshow)) |
|
| 5783 | - $labeltoshow = '(not defined)'; |
|
| 6201 | + if (empty($labeltoshow)) { |
|
| 6202 | + $labeltoshow = '(not defined)'; |
|
| 6203 | + } |
|
| 5784 | 6204 | |
| 5785 | 6205 | if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
|
| 5786 | 6206 | $data[$obj->rowid]=$labeltoshow; |
@@ -5802,8 +6222,7 @@ discard block |
||
| 5802 | 6222 | print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>'; |
| 5803 | 6223 | } |
| 5804 | 6224 | } |
| 5805 | - } |
|
| 5806 | - elseif ($type == 'link') |
|
| 6225 | + } elseif ($type == 'link') |
|
| 5807 | 6226 | {
|
| 5808 | 6227 | $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' |
| 5809 | 6228 | $showempty=(($required && $default != '')?0:1); |
@@ -5811,18 +6230,19 @@ discard block |
||
| 5811 | 6230 | if ($conf->global->MAIN_FEATURES_LEVEL >= 2) |
| 5812 | 6231 | {
|
| 5813 | 6232 | list($class,$classfile)=explode(':',$param_list[0]);
|
| 5814 | - if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php',1); |
|
| 5815 | - else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.$class.'_card.php',1); |
|
| 6233 | + if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) { |
|
| 6234 | + $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php',1); |
|
| 6235 | + } else { |
|
| 6236 | + $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.$class.'_card.php',1); |
|
| 6237 | + } |
|
| 5816 | 6238 | $out.='<a class="butActionNew" href="'.$url_path.'?action=create&backtopage='.$_SERVER['PHP_SELF'].'"><span class="fa fa-plus-circle valignmiddle"></span></a>'; |
| 5817 | 6239 | // TODO Add Javascript code to add input fields contents to new elements urls |
| 5818 | 6240 | } |
| 5819 | - } |
|
| 5820 | - elseif ($type == 'password') |
|
| 6241 | + } elseif ($type == 'password') |
|
| 5821 | 6242 | {
|
| 5822 | 6243 | // If prefix is 'search_', field is used as a filter, we use a common text field. |
| 5823 | 6244 | $out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>'; |
| 5824 | - } |
|
| 5825 | - elseif ($type == 'array') |
|
| 6245 | + } elseif ($type == 'array') |
|
| 5826 | 6246 | {
|
| 5827 | 6247 | $newval = $val; |
| 5828 | 6248 | $newval['type'] = 'varchar(256)'; |
@@ -5900,17 +6320,25 @@ discard block |
||
| 5900 | 6320 | {
|
| 5901 | 6321 | $type = 'varchar'; // convert varchar(xx) int varchar |
| 5902 | 6322 | $size = $reg[1]; |
| 5903 | - } |
|
| 5904 | - elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar
|
|
| 5905 | - if (is_array($val['arrayofkeyval'])) $type='select'; |
|
| 5906 | - if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type='link';
|
|
| 6323 | + } elseif (preg_match('/varchar/', $type)) { |
|
| 6324 | + $type = 'varchar'; |
|
| 6325 | + } |
|
| 6326 | + // convert varchar(xx) int varchar |
|
| 6327 | + if (is_array($val['arrayofkeyval'])) { |
|
| 6328 | + $type='select'; |
|
| 6329 | + } |
|
| 6330 | + if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) { |
|
| 6331 | + $type='link'; |
|
| 6332 | + } |
|
| 5907 | 6333 | |
| 5908 | 6334 | $default=$val['default']; |
| 5909 | 6335 | $computed=$val['computed']; |
| 5910 | 6336 | $unique=$val['unique']; |
| 5911 | 6337 | $required=$val['required']; |
| 5912 | 6338 | $param=$val['param']; |
| 5913 | - if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; |
|
| 6339 | + if (is_array($val['arrayofkeyval'])) { |
|
| 6340 | + $param['options'] = $val['arrayofkeyval']; |
|
| 6341 | + } |
|
| 5914 | 6342 | if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg))
|
| 5915 | 6343 | {
|
| 5916 | 6344 | $type='link'; |
@@ -5921,7 +6349,9 @@ discard block |
||
| 5921 | 6349 | $help=$val['help']; |
| 5922 | 6350 | $hidden=(($val['visible'] == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) |
| 5923 | 6351 | |
| 5924 | - if ($hidden) return ''; |
|
| 6352 | + if ($hidden) { |
|
| 6353 | + return ''; |
|
| 6354 | + } |
|
| 5925 | 6355 | |
| 5926 | 6356 | // If field is a computed field, value must become result of compute |
| 5927 | 6357 | if ($computed) |
@@ -5937,36 +6367,29 @@ discard block |
||
| 5937 | 6367 | {
|
| 5938 | 6368 | //$showsize=10; |
| 5939 | 6369 | $showsize = 'minwidth100imp'; |
| 5940 | - } |
|
| 5941 | - elseif ($type == 'datetime') |
|
| 6370 | + } elseif ($type == 'datetime') |
|
| 5942 | 6371 | {
|
| 5943 | 6372 | //$showsize=19; |
| 5944 | 6373 | $showsize = 'minwidth200imp'; |
| 5945 | - } |
|
| 5946 | - elseif (in_array($type,array('int','double','price')))
|
|
| 6374 | + } elseif (in_array($type,array('int','double','price')))
|
|
| 5947 | 6375 | {
|
| 5948 | 6376 | //$showsize=10; |
| 5949 | 6377 | $showsize = 'maxwidth75'; |
| 5950 | - } |
|
| 5951 | - elseif ($type == 'url') |
|
| 6378 | + } elseif ($type == 'url') |
|
| 5952 | 6379 | {
|
| 5953 | 6380 | $showsize='minwidth400'; |
| 5954 | - } |
|
| 5955 | - elseif ($type == 'boolean') |
|
| 6381 | + } elseif ($type == 'boolean') |
|
| 5956 | 6382 | {
|
| 5957 | 6383 | $showsize=''; |
| 5958 | - } |
|
| 5959 | - else |
|
| 6384 | + } else |
|
| 5960 | 6385 | {
|
| 5961 | 6386 | if (round($size) < 12) |
| 5962 | 6387 | {
|
| 5963 | 6388 | $showsize = 'minwidth100'; |
| 5964 | - } |
|
| 5965 | - else if (round($size) <= 48) |
|
| 6389 | + } else if (round($size) <= 48) |
|
| 5966 | 6390 | {
|
| 5967 | 6391 | $showsize = 'minwidth200'; |
| 5968 | - } |
|
| 5969 | - else |
|
| 6392 | + } else |
|
| 5970 | 6393 | {
|
| 5971 | 6394 | //$showsize=48; |
| 5972 | 6395 | $showsize = 'minwidth400'; |
@@ -5975,59 +6398,52 @@ discard block |
||
| 5975 | 6398 | } |
| 5976 | 6399 | |
| 5977 | 6400 | // Format output value differently according to properties of field |
| 5978 | - if ($key == 'ref' && method_exists($this, 'getNomUrl')) $value=$this->getNomUrl(1, '', 0, '', 1); |
|
| 5979 | - elseif ($key == 'status' && method_exists($this, 'getLibStatut')) $value=$this->getLibStatut(3); |
|
| 5980 | - elseif ($type == 'date') |
|
| 6401 | + if ($key == 'ref' && method_exists($this, 'getNomUrl')) { |
|
| 6402 | + $value=$this->getNomUrl(1, '', 0, '', 1); |
|
| 6403 | + } elseif ($key == 'status' && method_exists($this, 'getLibStatut')) { |
|
| 6404 | + $value=$this->getLibStatut(3); |
|
| 6405 | + } elseif ($type == 'date') |
|
| 5981 | 6406 | {
|
| 5982 | 6407 | if(! empty($value)) {
|
| 5983 | 6408 | $value=dol_print_date($value,'day'); |
| 5984 | 6409 | } else {
|
| 5985 | 6410 | $value=''; |
| 5986 | 6411 | } |
| 5987 | - } |
|
| 5988 | - elseif ($type == 'datetime') |
|
| 6412 | + } elseif ($type == 'datetime') |
|
| 5989 | 6413 | {
|
| 5990 | 6414 | if(! empty($value)) {
|
| 5991 | 6415 | $value=dol_print_date($value,'dayhour'); |
| 5992 | 6416 | } else {
|
| 5993 | 6417 | $value=''; |
| 5994 | 6418 | } |
| 5995 | - } |
|
| 5996 | - elseif ($type == 'double') |
|
| 6419 | + } elseif ($type == 'double') |
|
| 5997 | 6420 | {
|
| 5998 | 6421 | if (!empty($value)) {
|
| 5999 | 6422 | $value=price($value); |
| 6000 | 6423 | } |
| 6001 | - } |
|
| 6002 | - elseif ($type == 'boolean') |
|
| 6424 | + } elseif ($type == 'boolean') |
|
| 6003 | 6425 | {
|
| 6004 | 6426 | $checked=''; |
| 6005 | 6427 | if (!empty($value)) {
|
| 6006 | 6428 | $checked=' checked '; |
| 6007 | 6429 | } |
| 6008 | 6430 | $value='<input type="checkbox" '.$checked.' '.($moreparam?$moreparam:'').' readonly disabled>'; |
| 6009 | - } |
|
| 6010 | - elseif ($type == 'mail') |
|
| 6431 | + } elseif ($type == 'mail') |
|
| 6011 | 6432 | {
|
| 6012 | 6433 | $value=dol_print_email($value,0,0,0,64,1,1); |
| 6013 | - } |
|
| 6014 | - elseif ($type == 'url') |
|
| 6434 | + } elseif ($type == 'url') |
|
| 6015 | 6435 | {
|
| 6016 | 6436 | $value=dol_print_url($value,'_blank',32,1); |
| 6017 | - } |
|
| 6018 | - elseif ($type == 'phone') |
|
| 6437 | + } elseif ($type == 'phone') |
|
| 6019 | 6438 | {
|
| 6020 | 6439 | $value=dol_print_phone($value, '', 0, 0, '', ' ', 1); |
| 6021 | - } |
|
| 6022 | - elseif ($type == 'price') |
|
| 6440 | + } elseif ($type == 'price') |
|
| 6023 | 6441 | {
|
| 6024 | 6442 | $value=price($value,0,$langs,0,0,-1,$conf->currency); |
| 6025 | - } |
|
| 6026 | - elseif ($type == 'select') |
|
| 6443 | + } elseif ($type == 'select') |
|
| 6027 | 6444 | {
|
| 6028 | 6445 | $value=$param['options'][$value]; |
| 6029 | - } |
|
| 6030 | - elseif ($type == 'sellist') |
|
| 6446 | + } elseif ($type == 'sellist') |
|
| 6031 | 6447 | {
|
| 6032 | 6448 | $param_list=array_keys($param['options']); |
| 6033 | 6449 | $InfoFieldList = explode(":", $param_list[0]);
|
@@ -6057,7 +6473,7 @@ discard block |
||
| 6057 | 6473 | $sql.= " WHERE ".$selectkey."=0"; |
| 6058 | 6474 | } elseif ($selectkey=='rowid') {
|
| 6059 | 6475 | $sql.= " WHERE ".$selectkey."=".$this->db->escape($value); |
| 6060 | - }else {
|
|
| 6476 | + } else {
|
|
| 6061 | 6477 | $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; |
| 6062 | 6478 | } |
| 6063 | 6479 | |
@@ -6084,12 +6500,11 @@ discard block |
||
| 6084 | 6500 | } |
| 6085 | 6501 | if ($translabel!=$field_toshow) {
|
| 6086 | 6502 | $value.=dol_trunc($translabel,18).' '; |
| 6087 | - }else {
|
|
| 6503 | + } else {
|
|
| 6088 | 6504 | $value.=$obj->$field_toshow.' '; |
| 6089 | 6505 | } |
| 6090 | 6506 | } |
| 6091 | - } |
|
| 6092 | - else |
|
| 6507 | + } else |
|
| 6093 | 6508 | {
|
| 6094 | 6509 | $translabel=''; |
| 6095 | 6510 | if (!empty($obj->{$InfoFieldList[1]})) {
|
@@ -6097,18 +6512,17 @@ discard block |
||
| 6097 | 6512 | } |
| 6098 | 6513 | if ($translabel!=$obj->{$InfoFieldList[1]}) {
|
| 6099 | 6514 | $value=dol_trunc($translabel,18); |
| 6100 | - }else {
|
|
| 6515 | + } else {
|
|
| 6101 | 6516 | $value=$obj->{$InfoFieldList[1]};
|
| 6102 | 6517 | } |
| 6103 | 6518 | } |
| 6104 | - } |
|
| 6105 | - else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); |
|
| 6106 | - } |
|
| 6107 | - elseif ($type == 'radio') |
|
| 6519 | + } else { |
|
| 6520 | + dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING); |
|
| 6521 | + } |
|
| 6522 | + } elseif ($type == 'radio') |
|
| 6108 | 6523 | {
|
| 6109 | 6524 | $value=$param['options'][$value]; |
| 6110 | - } |
|
| 6111 | - elseif ($type == 'checkbox') |
|
| 6525 | + } elseif ($type == 'checkbox') |
|
| 6112 | 6526 | {
|
| 6113 | 6527 | $value_arr=explode(',',$value);
|
| 6114 | 6528 | $value=''; |
@@ -6119,8 +6533,7 @@ discard block |
||
| 6119 | 6533 | } |
| 6120 | 6534 | $value='<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
|
| 6121 | 6535 | } |
| 6122 | - } |
|
| 6123 | - elseif ($type == 'chkbxlst') |
|
| 6536 | + } elseif ($type == 'chkbxlst') |
|
| 6124 | 6537 | {
|
| 6125 | 6538 | $value_arr = explode(',', $value);
|
| 6126 | 6539 | |
@@ -6188,8 +6601,7 @@ discard block |
||
| 6188 | 6601 | } else {
|
| 6189 | 6602 | dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING); |
| 6190 | 6603 | } |
| 6191 | - } |
|
| 6192 | - elseif ($type == 'link') |
|
| 6604 | + } elseif ($type == 'link') |
|
| 6193 | 6605 | {
|
| 6194 | 6606 | $out=''; |
| 6195 | 6607 | |
@@ -6211,24 +6623,21 @@ discard block |
||
| 6211 | 6623 | $object->fetch($value); |
| 6212 | 6624 | $value=$object->getNomUrl($getnomurlparam); |
| 6213 | 6625 | } |
| 6214 | - } |
|
| 6215 | - else |
|
| 6626 | + } else |
|
| 6216 | 6627 | {
|
| 6217 | 6628 | dol_syslog('Error bad setup of extrafield', LOG_WARNING);
|
| 6218 | 6629 | return 'Error bad setup of extrafield'; |
| 6219 | 6630 | } |
| 6220 | - } |
|
| 6221 | - else $value=''; |
|
| 6222 | - } |
|
| 6223 | - elseif ($type == 'text' || $type == 'html') |
|
| 6631 | + } else { |
|
| 6632 | + $value=''; |
|
| 6633 | + } |
|
| 6634 | + } elseif ($type == 'text' || $type == 'html') |
|
| 6224 | 6635 | {
|
| 6225 | 6636 | $value=dol_htmlentitiesbr($value); |
| 6226 | - } |
|
| 6227 | - elseif ($type == 'password') |
|
| 6637 | + } elseif ($type == 'password') |
|
| 6228 | 6638 | {
|
| 6229 | 6639 | $value=preg_replace('/./i','*',$value);
|
| 6230 | - } |
|
| 6231 | - elseif ($type == 'array') |
|
| 6640 | + } elseif ($type == 'array') |
|
| 6232 | 6641 | {
|
| 6233 | 6642 | $value = implode('<br>', $value);
|
| 6234 | 6643 | } |
@@ -6255,7 +6664,9 @@ discard block |
||
| 6255 | 6664 | {
|
| 6256 | 6665 | global $db, $conf, $langs, $action, $form; |
| 6257 | 6666 | |
| 6258 | - if (! is_object($form)) $form=new Form($db); |
|
| 6667 | + if (! is_object($form)) { |
|
| 6668 | + $form=new Form($db); |
|
| 6669 | + } |
|
| 6259 | 6670 | |
| 6260 | 6671 | $out = ''; |
| 6261 | 6672 | |
@@ -6269,7 +6680,9 @@ discard block |
||
| 6269 | 6680 | foreach($extrafields->attributes[$this->table_element]['label'] as $key=>$label) |
| 6270 | 6681 | {
|
| 6271 | 6682 | // Show only the key field in params |
| 6272 | - if (is_array($params) && array_key_exists('onlykey',$params) && $key != $params['onlykey']) continue;
|
|
| 6683 | + if (is_array($params) && array_key_exists('onlykey',$params) && $key != $params['onlykey']) { |
|
| 6684 | + continue; |
|
| 6685 | + } |
|
| 6273 | 6686 | |
| 6274 | 6687 | $enabled = 1; |
| 6275 | 6688 | if ($enabled && isset($extrafields->attributes[$this->table_element]['list'][$key])) |
@@ -6283,11 +6696,18 @@ discard block |
||
| 6283 | 6696 | $perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1); |
| 6284 | 6697 | } |
| 6285 | 6698 | |
| 6286 | - if (($mode == 'create' || $mode == 'edit') && abs($enabled) != 1 && abs($enabled) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list |
|
| 6287 | - if (empty($perms)) continue; |
|
| 6699 | + if (($mode == 'create' || $mode == 'edit') && abs($enabled) != 1 && abs($enabled) != 3) { |
|
| 6700 | + continue; |
|
| 6701 | + } |
|
| 6702 | + // <> -1 and <> 1 and <> 3 = not visible on forms, only on list |
|
| 6703 | + if (empty($perms)) { |
|
| 6704 | + continue; |
|
| 6705 | + } |
|
| 6288 | 6706 | |
| 6289 | 6707 | // Load language if required |
| 6290 | - if (! empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); |
|
| 6708 | + if (! empty($extrafields->attributes[$this->table_element]['langfile'][$key])) { |
|
| 6709 | + $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); |
|
| 6710 | + } |
|
| 6291 | 6711 | |
| 6292 | 6712 | $colspan='3'; |
| 6293 | 6713 | if (is_array($params) && count($params)>0) {
|
@@ -6321,8 +6741,7 @@ discard block |
||
| 6321 | 6741 | if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate') |
| 6322 | 6742 | {
|
| 6323 | 6743 | $out .= $extrafields->showSeparator($key, $this); |
| 6324 | - } |
|
| 6325 | - else |
|
| 6744 | + } else |
|
| 6326 | 6745 | {
|
| 6327 | 6746 | $csstyle=''; |
| 6328 | 6747 | $class=(!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : ''); |
@@ -6352,9 +6771,11 @@ discard block |
||
| 6352 | 6771 | if (in_array($extrafields->attributes[$this->table_element]['type'][$key],array('date','datetime')))
|
| 6353 | 6772 | {
|
| 6354 | 6773 | $datenotinstring = $this->array_options['options_' . $key]; |
| 6355 | - if (! is_numeric($this->array_options['options_' . $key])) // For backward compatibility |
|
| 6774 | + if (! is_numeric($this->array_options['options_' . $key])) { |
|
| 6775 | + // For backward compatibility |
|
| 6356 | 6776 | {
|
| 6357 | - $datenotinstring = $this->db->jdate($datenotinstring); |
|
| 6777 | + $datenotinstring = $this->db->jdate($datenotinstring); |
|
| 6778 | + } |
|
| 6358 | 6779 | } |
| 6359 | 6780 | $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min",'int',3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year",'int',3)):$datenotinstring; |
| 6360 | 6781 | } |
@@ -6367,11 +6788,18 @@ discard block |
||
| 6367 | 6788 | $labeltoshow = $langs->trans($label); |
| 6368 | 6789 | |
| 6369 | 6790 | $out .= '<td class="titlefield'; |
| 6370 | - if (GETPOST('action','none') == 'create') $out.='create';
|
|
| 6371 | - if ($mode != 'view' && ! empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' fieldrequired'; |
|
| 6791 | + if (GETPOST('action','none') == 'create') { |
|
| 6792 | + $out.='create'; |
|
| 6793 | + } |
|
| 6794 | + if ($mode != 'view' && ! empty($extrafields->attributes[$this->table_element]['required'][$key])) { |
|
| 6795 | + $out .= ' fieldrequired'; |
|
| 6796 | + } |
|
| 6372 | 6797 | $out .= '">'; |
| 6373 | - if (! empty($extrafields->attributes[$object->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$object->table_element]['help'][$key]); |
|
| 6374 | - else $out .= $labeltoshow; |
|
| 6798 | + if (! empty($extrafields->attributes[$object->table_element]['help'][$key])) { |
|
| 6799 | + $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$object->table_element]['help'][$key]); |
|
| 6800 | + } else { |
|
| 6801 | + $out .= $labeltoshow; |
|
| 6802 | + } |
|
| 6375 | 6803 | $out .= '</td>'; |
| 6376 | 6804 | |
| 6377 | 6805 | $html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : ''; |
@@ -6388,8 +6816,11 @@ discard block |
||
| 6388 | 6816 | |
| 6389 | 6817 | $out .= '</td>'; |
| 6390 | 6818 | |
| 6391 | - if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>'; |
|
| 6392 | - else $out .= '</tr>'; |
|
| 6819 | + if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) { |
|
| 6820 | + $out .= '</tr>'; |
|
| 6821 | + } else { |
|
| 6822 | + $out .= '</tr>'; |
|
| 6823 | + } |
|
| 6393 | 6824 | $e++; |
| 6394 | 6825 | } |
| 6395 | 6826 | } |
@@ -6441,7 +6872,9 @@ discard block |
||
| 6441 | 6872 | global $user; |
| 6442 | 6873 | |
| 6443 | 6874 | $element = $this->element; |
| 6444 | - if ($element == 'facturerec') $element='facture'; |
|
| 6875 | + if ($element == 'facturerec') { |
|
| 6876 | + $element='facture'; |
|
| 6877 | + } |
|
| 6445 | 6878 | |
| 6446 | 6879 | return $user->rights->{$element};
|
| 6447 | 6880 | } |
@@ -6466,7 +6899,10 @@ discard block |
||
| 6466 | 6899 | |
| 6467 | 6900 | if (! $db->query($sql)) |
| 6468 | 6901 | {
|
| 6469 | - if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. |
|
| 6902 | + if ($ignoreerrors) { |
|
| 6903 | + return true; |
|
| 6904 | + } |
|
| 6905 | + // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. |
|
| 6470 | 6906 | //$this->errors = $db->lasterror(); |
| 6471 | 6907 | return false; |
| 6472 | 6908 | } |
@@ -6493,11 +6929,12 @@ discard block |
||
| 6493 | 6929 | |
| 6494 | 6930 | $buyPrice = 0; |
| 6495 | 6931 | |
| 6496 | - if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) // In most cases, test here is false |
|
| 6932 | + if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { |
|
| 6933 | + // In most cases, test here is false |
|
| 6497 | 6934 | {
|
| 6498 | - $buyPrice = $unitPrice * (1 - $discountPercent / 100); |
|
| 6499 | - } |
|
| 6500 | - else |
|
| 6935 | + $buyPrice = $unitPrice * (1 - $discountPercent / 100); |
|
| 6936 | + } |
|
| 6937 | + } else |
|
| 6501 | 6938 | {
|
| 6502 | 6939 | // Get cost price for margin calculation |
| 6503 | 6940 | if (! empty($fk_product)) |
@@ -6515,13 +6952,11 @@ discard block |
||
| 6515 | 6952 | if ($product->cost_price > 0) |
| 6516 | 6953 | {
|
| 6517 | 6954 | $buyPrice = $product->cost_price; |
| 6518 | - } |
|
| 6519 | - else if ($product->pmp > 0) |
|
| 6955 | + } else if ($product->pmp > 0) |
|
| 6520 | 6956 | {
|
| 6521 | 6957 | $buyPrice = $product->pmp; |
| 6522 | 6958 | } |
| 6523 | - } |
|
| 6524 | - else if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp') |
|
| 6959 | + } else if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp') |
|
| 6525 | 6960 | {
|
| 6526 | 6961 | require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
| 6527 | 6962 | $product = new Product($this->db); |
@@ -6544,8 +6979,7 @@ discard block |
||
| 6544 | 6979 | if (($result = $productFournisseur->find_min_price_product_fournisseur($fk_product)) > 0) |
| 6545 | 6980 | {
|
| 6546 | 6981 | $buyPrice = $productFournisseur->fourn_unitprice; |
| 6547 | - } |
|
| 6548 | - else if ($result < 0) |
|
| 6982 | + } else if ($result < 0) |
|
| 6549 | 6983 | {
|
| 6550 | 6984 | $this->errors[] = $productFournisseur->error; |
| 6551 | 6985 | return -2; |
@@ -6591,8 +7025,7 @@ discard block |
||
| 6591 | 7025 | {
|
| 6592 | 7026 | $dir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->track_id.'/'; |
| 6593 | 7027 | $pdir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->track_id.'/'; |
| 6594 | - } |
|
| 6595 | - else |
|
| 7028 | + } else |
|
| 6596 | 7029 | {
|
| 6597 | 7030 | $dir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->ref.'/'; |
| 6598 | 7031 | $pdir .= get_exdir(0, 0, 0, 0, $this, $modulepart).$this->ref.'/'; |
@@ -6655,19 +7088,26 @@ discard block |
||
| 6655 | 7088 | |
| 6656 | 7089 | // Find name of thumb file |
| 6657 | 7090 | $photo_vignette=basename(getImageFileNameForSize($dir.$file, '_small')); |
| 6658 | - if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette=''; |
|
| 7091 | + if (! dol_is_file($dirthumb.$photo_vignette)) { |
|
| 7092 | + $photo_vignette=''; |
|
| 7093 | + } |
|
| 6659 | 7094 | |
| 6660 | 7095 | // Get filesize of original file |
| 6661 | 7096 | $imgarray=dol_getImageSize($dir.$photo); |
| 6662 | 7097 | |
| 6663 | 7098 | if ($nbbyrow > 0) |
| 6664 | 7099 | {
|
| 6665 | - if ($nbphoto == 1) $return.= '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; |
|
| 7100 | + if ($nbphoto == 1) { |
|
| 7101 | + $return.= '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; |
|
| 7102 | + } |
|
| 6666 | 7103 | |
| 6667 | - if ($nbphoto % $nbbyrow == 1) $return.= '<tr align=center valign=middle border=1>'; |
|
| 7104 | + if ($nbphoto % $nbbyrow == 1) { |
|
| 7105 | + $return.= '<tr align=center valign=middle border=1>'; |
|
| 7106 | + } |
|
| 6668 | 7107 | $return.= '<td width="'.ceil(100/$nbbyrow).'%" class="photo">'; |
| 6669 | - } |
|
| 6670 | - else if ($nbbyrow < 0) $return .= '<div class="inline-block">'; |
|
| 7108 | + } else if ($nbbyrow < 0) { |
|
| 7109 | + $return .= '<div class="inline-block">'; |
|
| 7110 | + } |
|
| 6671 | 7111 | |
| 6672 | 7112 | $return.= "\n"; |
| 6673 | 7113 | |
@@ -6675,15 +7115,20 @@ discard block |
||
| 6675 | 7115 | if (empty($nolink)) |
| 6676 | 7116 | {
|
| 6677 | 7117 | $urladvanced=getAdvancedPreviewUrl($modulepart, $relativefile, 0, 'entity='.$this->entity); |
| 6678 | - if ($urladvanced) $return.='<a href="'.$urladvanced.'">'; |
|
| 6679 | - else $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">'; |
|
| 7118 | + if ($urladvanced) { |
|
| 7119 | + $return.='<a href="'.$urladvanced.'">'; |
|
| 7120 | + } else { |
|
| 7121 | + $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">'; |
|
| 7122 | + } |
|
| 6680 | 7123 | } |
| 6681 | 7124 | |
| 6682 | 7125 | // Show image (width height=$maxHeight) |
| 6683 | 7126 | // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine |
| 6684 | 7127 | $alt=$langs->transnoentitiesnoconv('File').': '.$relativefile;
|
| 6685 | 7128 | $alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height'];
|
| 6686 | - if ($notitle) $alt=''; |
|
| 7129 | + if ($notitle) { |
|
| 7130 | + $alt=''; |
|
| 7131 | + } |
|
| 6687 | 7132 | |
| 6688 | 7133 | if ($usesharelink) |
| 6689 | 7134 | {
|
@@ -6693,35 +7138,35 @@ discard block |
||
| 6693 | 7138 | {
|
| 6694 | 7139 | $return.= '<!-- Show original file (thumb not yet available with shared links) -->'; |
| 6695 | 7140 | $return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">'; |
| 6696 | - } |
|
| 6697 | - else {
|
|
| 7141 | + } else {
|
|
| 6698 | 7142 | $return.= '<!-- Show original file -->'; |
| 6699 | 7143 | $return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">'; |
| 6700 | 7144 | } |
| 6701 | - } |
|
| 6702 | - else |
|
| 7145 | + } else |
|
| 6703 | 7146 | {
|
| 6704 | 7147 | $return.= '<!-- Show nophoto file (because file is not shared) -->'; |
| 6705 | 7148 | $return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png" title="'.dol_escape_htmltag($alt).'">'; |
| 6706 | 7149 | } |
| 6707 | - } |
|
| 6708 | - else |
|
| 7150 | + } else |
|
| 6709 | 7151 | {
|
| 6710 | 7152 | if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) |
| 6711 | 7153 | {
|
| 6712 | 7154 | $return.= '<!-- Show thumb -->'; |
| 6713 | 7155 | $return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">'; |
| 6714 | - } |
|
| 6715 | - else {
|
|
| 7156 | + } else {
|
|
| 6716 | 7157 | $return.= '<!-- Show original file -->'; |
| 6717 | 7158 | $return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; |
| 6718 | 7159 | } |
| 6719 | 7160 | } |
| 6720 | 7161 | |
| 6721 | - if (empty($nolink)) $return.= '</a>'; |
|
| 7162 | + if (empty($nolink)) { |
|
| 7163 | + $return.= '</a>'; |
|
| 7164 | + } |
|
| 6722 | 7165 | $return.="\n"; |
| 6723 | 7166 | |
| 6724 | - if ($showfilename) $return.= '<br>'.$viewfilename; |
|
| 7167 | + if ($showfilename) { |
|
| 7168 | + $return.= '<br>'.$viewfilename; |
|
| 7169 | + } |
|
| 6725 | 7170 | if ($showaction) |
| 6726 | 7171 | {
|
| 6727 | 7172 | $return.= '<br>'; |
@@ -6746,15 +7191,20 @@ discard block |
||
| 6746 | 7191 | if ($nbbyrow > 0) |
| 6747 | 7192 | {
|
| 6748 | 7193 | $return.= '</td>'; |
| 6749 | - if (($nbphoto % $nbbyrow) == 0) $return.= '</tr>'; |
|
| 6750 | - } |
|
| 6751 | - else if ($nbbyrow < 0) $return.='</div>'; |
|
| 7194 | + if (($nbphoto % $nbbyrow) == 0) { |
|
| 7195 | + $return.= '</tr>'; |
|
| 7196 | + } |
|
| 7197 | + } else if ($nbbyrow < 0) { |
|
| 7198 | + $return.='</div>'; |
|
| 7199 | + } |
|
| 6752 | 7200 | } |
| 6753 | 7201 | |
| 6754 | 7202 | if (empty($size)) { // Format origine
|
| 6755 | 7203 | $return.= '<img class="photo photowithmargin" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">'; |
| 6756 | 7204 | |
| 6757 | - if ($showfilename) $return.= '<br>'.$viewfilename; |
|
| 7205 | + if ($showfilename) { |
|
| 7206 | + $return.= '<br>'.$viewfilename; |
|
| 7207 | + } |
|
| 6758 | 7208 | if ($showaction) |
| 6759 | 7209 | {
|
| 6760 | 7210 | // Special case for product |
@@ -6771,7 +7221,9 @@ discard block |
||
| 6771 | 7221 | } |
| 6772 | 7222 | |
| 6773 | 7223 | // On continue ou on arrete de boucler ? |
| 6774 | - if ($nbmax && $nbphoto >= $nbmax) break; |
|
| 7224 | + if ($nbmax && $nbphoto >= $nbmax) { |
|
| 7225 | + break; |
|
| 7226 | + } |
|
| 6775 | 7227 | } |
| 6776 | 7228 | } |
| 6777 | 7229 | |
@@ -6786,7 +7238,9 @@ discard block |
||
| 6786 | 7238 | $nbphoto++; |
| 6787 | 7239 | } |
| 6788 | 7240 | |
| 6789 | - if ($nbphoto) $return.= '</table>'; |
|
| 7241 | + if ($nbphoto) { |
|
| 7242 | + $return.= '</table>'; |
|
| 7243 | + } |
|
| 6790 | 7244 | } |
| 6791 | 7245 | } |
| 6792 | 7246 | } |
@@ -6807,10 +7261,14 @@ discard block |
||
| 6807 | 7261 | {
|
| 6808 | 7262 | if(is_array($info)) |
| 6809 | 7263 | {
|
| 6810 | - if(isset($info['type']) && $info['type']=='array') return true; |
|
| 6811 | - else return false; |
|
| 6812 | - } |
|
| 6813 | - else return false; |
|
| 7264 | + if(isset($info['type']) && $info['type']=='array') { |
|
| 7265 | + return true; |
|
| 7266 | + } else { |
|
| 7267 | + return false; |
|
| 7268 | + } |
|
| 7269 | + } else { |
|
| 7270 | + return false; |
|
| 7271 | + } |
|
| 6814 | 7272 | } |
| 6815 | 7273 | |
| 6816 | 7274 | /** |
@@ -6823,10 +7281,14 @@ discard block |
||
| 6823 | 7281 | {
|
| 6824 | 7282 | if(is_array($info)) |
| 6825 | 7283 | {
|
| 6826 | - if(isset($info['type']) && $info['type']=='null') return true; |
|
| 6827 | - else return false; |
|
| 6828 | - } |
|
| 6829 | - else return false; |
|
| 7284 | + if(isset($info['type']) && $info['type']=='null') { |
|
| 7285 | + return true; |
|
| 7286 | + } else { |
|
| 7287 | + return false; |
|
| 7288 | + } |
|
| 7289 | + } else { |
|
| 7290 | + return false; |
|
| 7291 | + } |
|
| 6830 | 7292 | } |
| 6831 | 7293 | |
| 6832 | 7294 | /** |
@@ -6837,8 +7299,11 @@ discard block |
||
| 6837 | 7299 | */ |
| 6838 | 7300 | public function isDate($info) |
| 6839 | 7301 | {
|
| 6840 | - if(isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true; |
|
| 6841 | - else return false; |
|
| 7302 | + if(isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) { |
|
| 7303 | + return true; |
|
| 7304 | + } else { |
|
| 7305 | + return false; |
|
| 7306 | + } |
|
| 6842 | 7307 | } |
| 6843 | 7308 | |
| 6844 | 7309 | /** |
@@ -6851,10 +7316,14 @@ discard block |
||
| 6851 | 7316 | {
|
| 6852 | 7317 | if(is_array($info)) |
| 6853 | 7318 | {
|
| 6854 | - if(isset($info['type']) && ($info['type']=='int' || preg_match('/^integer/i',$info['type']) ) ) return true;
|
|
| 6855 | - else return false; |
|
| 6856 | - } |
|
| 6857 | - else return false; |
|
| 7319 | + if(isset($info['type']) && ($info['type']=='int' || preg_match('/^integer/i',$info['type']) ) ) { |
|
| 7320 | + return true; |
|
| 7321 | + } else { |
|
| 7322 | + return false; |
|
| 7323 | + } |
|
| 7324 | + } else { |
|
| 7325 | + return false; |
|
| 7326 | + } |
|
| 6858 | 7327 | } |
| 6859 | 7328 | |
| 6860 | 7329 | /** |
@@ -6867,10 +7336,14 @@ discard block |
||
| 6867 | 7336 | {
|
| 6868 | 7337 | if(is_array($info)) |
| 6869 | 7338 | {
|
| 6870 | - if (isset($info['type']) && (preg_match('/^(double|real)/i', $info['type']))) return true;
|
|
| 6871 | - else return false; |
|
| 6872 | - } |
|
| 6873 | - else return false; |
|
| 7339 | + if (isset($info['type']) && (preg_match('/^(double|real)/i', $info['type']))) { |
|
| 7340 | + return true; |
|
| 7341 | + } else { |
|
| 7342 | + return false; |
|
| 7343 | + } |
|
| 7344 | + } else { |
|
| 7345 | + return false; |
|
| 7346 | + } |
|
| 6874 | 7347 | } |
| 6875 | 7348 | |
| 6876 | 7349 | /** |
@@ -6883,10 +7356,14 @@ discard block |
||
| 6883 | 7356 | {
|
| 6884 | 7357 | if(is_array($info)) |
| 6885 | 7358 | {
|
| 6886 | - if(isset($info['type']) && $info['type']=='text') return true; |
|
| 6887 | - else return false; |
|
| 6888 | - } |
|
| 6889 | - else return false; |
|
| 7359 | + if(isset($info['type']) && $info['type']=='text') { |
|
| 7360 | + return true; |
|
| 7361 | + } else { |
|
| 7362 | + return false; |
|
| 7363 | + } |
|
| 7364 | + } else { |
|
| 7365 | + return false; |
|
| 7366 | + } |
|
| 6890 | 7367 | } |
| 6891 | 7368 | |
| 6892 | 7369 | /** |
@@ -6899,10 +7376,14 @@ discard block |
||
| 6899 | 7376 | {
|
| 6900 | 7377 | if(is_array($info)) |
| 6901 | 7378 | {
|
| 6902 | - if(isset($info['index']) && $info['index']==true) return true; |
|
| 6903 | - else return false; |
|
| 6904 | - } |
|
| 6905 | - else return false; |
|
| 7379 | + if(isset($info['index']) && $info['index']==true) { |
|
| 7380 | + return true; |
|
| 7381 | + } else { |
|
| 7382 | + return false; |
|
| 7383 | + } |
|
| 7384 | + } else { |
|
| 7385 | + return false; |
|
| 7386 | + } |
|
| 6906 | 7387 | } |
| 6907 | 7388 | |
| 6908 | 7389 | /** |
@@ -6916,21 +7397,21 @@ discard block |
||
| 6916 | 7397 | global $conf; |
| 6917 | 7398 | |
| 6918 | 7399 | $queryarray=array(); |
| 6919 | - foreach ($this->fields as $field=>$info) // Loop on definition of fields |
|
| 7400 | + foreach ($this->fields as $field=>$info) { |
|
| 7401 | + // Loop on definition of fields |
|
| 6920 | 7402 | {
|
| 6921 | 7403 | // Depending on field type ('datetime', ...)
|
| 6922 | 7404 | if($this->isDate($info)) |
| 6923 | 7405 | {
|
| 6924 | 7406 | if(empty($this->{$field}))
|
| 6925 | 7407 | {
|
| 6926 | - $queryarray[$field] = null; |
|
| 6927 | - } |
|
| 6928 | - else |
|
| 7408 | + $queryarray[$field] = null; |
|
| 7409 | + } |
|
| 7410 | + } else |
|
| 6929 | 7411 | {
|
| 6930 | 7412 | $queryarray[$field] = $this->db->idate($this->{$field});
|
| 6931 | 7413 | } |
| 6932 | - } |
|
| 6933 | - else if($this->isArray($info)) |
|
| 7414 | + } else if($this->isArray($info)) |
|
| 6934 | 7415 | {
|
| 6935 | 7416 | if(! empty($this->{$field})) {
|
| 6936 | 7417 | if(! is_array($this->{$field})) {
|
@@ -6940,28 +7421,35 @@ discard block |
||
| 6940 | 7421 | } else {
|
| 6941 | 7422 | $queryarray[$field] = null; |
| 6942 | 7423 | } |
| 6943 | - } |
|
| 6944 | - else if($this->isInt($info)) |
|
| 7424 | + } else if($this->isInt($info)) |
|
| 6945 | 7425 | {
|
| 6946 | - if ($field == 'entity' && is_null($this->{$field})) $queryarray[$field]=$conf->entity;
|
|
| 6947 | - else |
|
| 7426 | + if ($field == 'entity' && is_null($this->{$field})) { |
|
| 7427 | + $queryarray[$field]=$conf->entity; |
|
| 7428 | + } else |
|
| 6948 | 7429 | {
|
| 6949 | 7430 | $queryarray[$field] = (int) price2num($this->{$field});
|
| 6950 | - if (empty($queryarray[$field])) $queryarray[$field]=0; // May be reset to null later if property 'notnull' is -1 for this field. |
|
| 7431 | + if (empty($queryarray[$field])) { |
|
| 7432 | + $queryarray[$field]=0; |
|
| 7433 | + } |
|
| 7434 | + // May be reset to null later if property 'notnull' is -1 for this field. |
|
| 6951 | 7435 | } |
| 6952 | - } |
|
| 6953 | - else if($this->isFloat($info)) |
|
| 7436 | + } else if($this->isFloat($info)) |
|
| 6954 | 7437 | {
|
| 6955 | 7438 | $queryarray[$field] = (double) price2num($this->{$field});
|
| 6956 | - if (empty($queryarray[$field])) $queryarray[$field]=0; |
|
| 6957 | - } |
|
| 6958 | - else |
|
| 7439 | + if (empty($queryarray[$field])) { |
|
| 7440 | + $queryarray[$field]=0; |
|
| 7441 | + } |
|
| 7442 | + } else |
|
| 6959 | 7443 | {
|
| 6960 | 7444 | $queryarray[$field] = $this->{$field};
|
| 6961 | 7445 | } |
| 6962 | 7446 | |
| 6963 | - if ($info['type'] == 'timestamp' && empty($queryarray[$field])) unset($queryarray[$field]); |
|
| 6964 | - if (! empty($info['notnull']) && $info['notnull'] == -1 && empty($queryarray[$field])) $queryarray[$field] = null; |
|
| 7447 | + if ($info['type'] == 'timestamp' && empty($queryarray[$field])) { |
|
| 7448 | + unset($queryarray[$field]); |
|
| 7449 | + } |
|
| 7450 | + if (! empty($info['notnull']) && $info['notnull'] == -1 && empty($queryarray[$field])) { |
|
| 7451 | + $queryarray[$field] = null; |
|
| 7452 | + } |
|
| 6965 | 7453 | } |
| 6966 | 7454 | |
| 6967 | 7455 | return $queryarray; |
@@ -6979,42 +7467,47 @@ discard block |
||
| 6979 | 7467 | {
|
| 6980 | 7468 | if($this->isDate($info)) |
| 6981 | 7469 | {
|
| 6982 | - if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0;
|
|
| 6983 | - else $this->{$field} = strtotime($obj->{$field});
|
|
| 6984 | - } |
|
| 6985 | - elseif($this->isArray($info)) |
|
| 7470 | + if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') { |
|
| 7471 | + $this->{$field} = 0; |
|
| 7472 | + } else { |
|
| 7473 | + $this->{$field} = strtotime($obj->{$field}); |
|
| 7474 | + } |
|
| 7475 | + } elseif($this->isArray($info)) |
|
| 6986 | 7476 | {
|
| 6987 | 7477 | if(! empty($obj->{$field})) {
|
| 6988 | 7478 | $this->{$field} = @unserialize($obj->{$field});
|
| 6989 | 7479 | // Hack for data not in UTF8 |
| 6990 | - if($this->{$field } === false) @unserialize(utf8_decode($obj->{$field}));
|
|
| 7480 | + if($this->{$field } === false) { |
|
| 7481 | + @unserialize(utf8_decode($obj->{$field})); |
|
| 7482 | + } |
|
| 6991 | 7483 | } else {
|
| 6992 | 7484 | $this->{$field} = array();
|
| 6993 | 7485 | } |
| 6994 | - } |
|
| 6995 | - elseif($this->isInt($info)) |
|
| 7486 | + } elseif($this->isInt($info)) |
|
| 6996 | 7487 | {
|
| 6997 | - if ($field == 'rowid') $this->id = (int) $obj->{$field};
|
|
| 6998 | - else $this->{$field} = (int) $obj->{$field};
|
|
| 6999 | - } |
|
| 7000 | - elseif($this->isFloat($info)) |
|
| 7488 | + if ($field == 'rowid') { |
|
| 7489 | + $this->id = (int) $obj->{$field}; |
|
| 7490 | + } else { |
|
| 7491 | + $this->{$field} = (int) $obj->{$field}; |
|
| 7492 | + } |
|
| 7493 | + } elseif($this->isFloat($info)) |
|
| 7001 | 7494 | {
|
| 7002 | 7495 | $this->{$field} = (double) $obj->{$field};
|
| 7003 | - } |
|
| 7004 | - elseif($this->isNull($info)) |
|
| 7496 | + } elseif($this->isNull($info)) |
|
| 7005 | 7497 | {
|
| 7006 | 7498 | $val = $obj->{$field};
|
| 7007 | 7499 | // zero is not null |
| 7008 | 7500 | $this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val);
|
| 7009 | - } |
|
| 7010 | - else |
|
| 7501 | + } else |
|
| 7011 | 7502 | {
|
| 7012 | 7503 | $this->{$field} = $obj->{$field};
|
| 7013 | 7504 | } |
| 7014 | 7505 | } |
| 7015 | 7506 | |
| 7016 | 7507 | // If there is no 'ref' field, we force property ->ref to ->id for a better compatibility with common functions. |
| 7017 | - if (! isset($this->fields['ref']) && isset($this->id)) $this->ref = $this->id; |
|
| 7508 | + if (! isset($this->fields['ref']) && isset($this->id)) { |
|
| 7509 | + $this->ref = $this->id; |
|
| 7510 | + } |
|
| 7018 | 7511 | } |
| 7019 | 7512 | |
| 7020 | 7513 | /** |
@@ -7037,9 +7530,13 @@ discard block |
||
| 7037 | 7530 | */ |
| 7038 | 7531 | protected function quote($value, $fieldsentry) |
| 7039 | 7532 | {
|
| 7040 | - if (is_null($value)) return 'NULL'; |
|
| 7041 | - else if (preg_match('/^(int|double|real)/i', $fieldsentry['type'])) return $this->db->escape("$value");
|
|
| 7042 | - else return "'".$this->db->escape($value)."'"; |
|
| 7533 | + if (is_null($value)) { |
|
| 7534 | + return 'NULL'; |
|
| 7535 | + } else if (preg_match('/^(int|double|real)/i', $fieldsentry['type'])) { |
|
| 7536 | + return $this->db->escape("$value"); |
|
| 7537 | + } else { |
|
| 7538 | + return "'".$this->db->escape($value)."'"; |
|
| 7539 | + } |
|
| 7043 | 7540 | } |
| 7044 | 7541 | |
| 7045 | 7542 | |
@@ -7059,8 +7556,12 @@ discard block |
||
| 7059 | 7556 | $now=dol_now(); |
| 7060 | 7557 | |
| 7061 | 7558 | $fieldvalues = $this->setSaveQuery(); |
| 7062 | - if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation']=$this->db->idate($now);
|
|
| 7063 | - if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat']=$user->id;
|
|
| 7559 | + if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) { |
|
| 7560 | + $fieldvalues['date_creation']=$this->db->idate($now); |
|
| 7561 | + } |
|
| 7562 | + if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) { |
|
| 7563 | + $fieldvalues['fk_user_creat']=$user->id; |
|
| 7564 | + } |
|
| 7064 | 7565 | unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. |
| 7065 | 7566 | |
| 7066 | 7567 | $keys=array(); |
@@ -7075,8 +7576,12 @@ discard block |
||
| 7075 | 7576 | foreach($keys as $key) |
| 7076 | 7577 | {
|
| 7077 | 7578 | // If field is an implicit foreign key field |
| 7078 | - if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key]='';
|
|
| 7079 | - if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]=''; |
|
| 7579 | + if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') { |
|
| 7580 | + $values[$key]=''; |
|
| 7581 | + } |
|
| 7582 | + if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') { |
|
| 7583 | + $values[$key]=''; |
|
| 7584 | + } |
|
| 7080 | 7585 | |
| 7081 | 7586 | //var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1)); |
| 7082 | 7587 | if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && ! isset($values[$key]) && is_null($val['default'])) |
@@ -7086,11 +7591,17 @@ discard block |
||
| 7086 | 7591 | } |
| 7087 | 7592 | |
| 7088 | 7593 | // If field is an implicit foreign key field |
| 7089 | - if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) $values[$key]='null';
|
|
| 7090 | - if (! empty($this->fields[$key]['foreignkey']) && empty($values[$key])) $values[$key]='null'; |
|
| 7594 | + if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) { |
|
| 7595 | + $values[$key]='null'; |
|
| 7596 | + } |
|
| 7597 | + if (! empty($this->fields[$key]['foreignkey']) && empty($values[$key])) { |
|
| 7598 | + $values[$key]='null'; |
|
| 7599 | + } |
|
| 7091 | 7600 | } |
| 7092 | 7601 | |
| 7093 | - if ($error) return -1; |
|
| 7602 | + if ($error) { |
|
| 7603 | + return -1; |
|
| 7604 | + } |
|
| 7094 | 7605 | |
| 7095 | 7606 | $this->db->begin(); |
| 7096 | 7607 | |
@@ -7116,7 +7627,9 @@ discard block |
||
| 7116 | 7627 | if (! $error) |
| 7117 | 7628 | {
|
| 7118 | 7629 | $result=$this->insertExtraFields(); |
| 7119 | - if ($result < 0) $error++; |
|
| 7630 | + if ($result < 0) { |
|
| 7631 | + $error++; |
|
| 7632 | + } |
|
| 7120 | 7633 | } |
| 7121 | 7634 | |
| 7122 | 7635 | // Triggers |
@@ -7149,15 +7662,24 @@ discard block |
||
| 7149 | 7662 | */ |
| 7150 | 7663 | public function fetchCommon($id, $ref = null, $morewhere = '') |
| 7151 | 7664 | {
|
| 7152 | - if (empty($id) && empty($ref) && empty($morewhere)) return -1; |
|
| 7665 | + if (empty($id) && empty($ref) && empty($morewhere)) { |
|
| 7666 | + return -1; |
|
| 7667 | + } |
|
| 7153 | 7668 | |
| 7154 | 7669 | $sql = 'SELECT '.$this->getFieldList(); |
| 7155 | 7670 | $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
| 7156 | 7671 | |
| 7157 | - if (!empty($id)) $sql.= ' WHERE rowid = '.$id; |
|
| 7158 | - elseif (!empty($ref)) $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); |
|
| 7159 | - else $sql.=' WHERE 1 = 1'; // usage with empty id and empty ref is very rare |
|
| 7160 | - if ($morewhere) $sql.= $morewhere; |
|
| 7672 | + if (!empty($id)) { |
|
| 7673 | + $sql.= ' WHERE rowid = '.$id; |
|
| 7674 | + } elseif (!empty($ref)) { |
|
| 7675 | + $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); |
|
| 7676 | + } else { |
|
| 7677 | + $sql.=' WHERE 1 = 1'; |
|
| 7678 | + } |
|
| 7679 | + // usage with empty id and empty ref is very rare |
|
| 7680 | + if ($morewhere) { |
|
| 7681 | + $sql.= $morewhere; |
|
| 7682 | + } |
|
| 7161 | 7683 | $sql.=' LIMIT 1'; // This is a fetch, to be sure to get only one record |
| 7162 | 7684 | |
| 7163 | 7685 | $res = $this->db->query($sql); |
@@ -7168,13 +7690,11 @@ discard block |
||
| 7168 | 7690 | {
|
| 7169 | 7691 | $this->setVarsFromFetchObj($obj); |
| 7170 | 7692 | return $this->id; |
| 7171 | - } |
|
| 7172 | - else |
|
| 7693 | + } else |
|
| 7173 | 7694 | {
|
| 7174 | 7695 | return 0; |
| 7175 | 7696 | } |
| 7176 | - } |
|
| 7177 | - else |
|
| 7697 | + } else |
|
| 7178 | 7698 | {
|
| 7179 | 7699 | $this->error = $this->db->lasterror(); |
| 7180 | 7700 | $this->errors[] = $this->error; |
@@ -7198,8 +7718,12 @@ discard block |
||
| 7198 | 7718 | $now=dol_now(); |
| 7199 | 7719 | |
| 7200 | 7720 | $fieldvalues = $this->setSaveQuery(); |
| 7201 | - if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification']=$this->db->idate($now);
|
|
| 7202 | - if (array_key_exists('fk_user_modif', $fieldvalues) && ! ($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif']=$user->id;
|
|
| 7721 | + if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) { |
|
| 7722 | + $fieldvalues['date_modification']=$this->db->idate($now); |
|
| 7723 | + } |
|
| 7724 | + if (array_key_exists('fk_user_modif', $fieldvalues) && ! ($fieldvalues['fk_user_modif'] > 0)) { |
|
| 7725 | + $fieldvalues['fk_user_modif']=$user->id; |
|
| 7726 | + } |
|
| 7203 | 7727 | unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update. |
| 7204 | 7728 | |
| 7205 | 7729 | $keys=array(); |
@@ -7214,8 +7738,14 @@ discard block |
||
| 7214 | 7738 | // Clean and check mandatory |
| 7215 | 7739 | foreach($keys as $key) |
| 7216 | 7740 | {
|
| 7217 | - if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key]=''; // This is an implicit foreign key field
|
|
| 7218 | - if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]=''; // This is an explicit foreign key field |
|
| 7741 | + if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') { |
|
| 7742 | + $values[$key]=''; |
|
| 7743 | + } |
|
| 7744 | + // This is an implicit foreign key field |
|
| 7745 | + if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') { |
|
| 7746 | + $values[$key]=''; |
|
| 7747 | + } |
|
| 7748 | + // This is an explicit foreign key field |
|
| 7219 | 7749 | |
| 7220 | 7750 | //var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1)); |
| 7221 | 7751 | /* |
@@ -7296,10 +7826,11 @@ discard block |
||
| 7296 | 7826 | return -1; |
| 7297 | 7827 | } |
| 7298 | 7828 | } |
| 7299 | - } |
|
| 7300 | - elseif (! empty($this->fk_element) && ! empty($this->childtables)) // If object has childs linked with a foreign key field, we check all child tables. |
|
| 7829 | + } elseif (! empty($this->fk_element) && ! empty($this->childtables)) { |
|
| 7830 | + // If object has childs linked with a foreign key field, we check all child tables. |
|
| 7301 | 7831 | {
|
| 7302 | - $objectisused = $this->isObjectUsed($this->id); |
|
| 7832 | + $objectisused = $this->isObjectUsed($this->id); |
|
| 7833 | + } |
|
| 7303 | 7834 | if (! empty($objectisused)) |
| 7304 | 7835 | {
|
| 7305 | 7836 | dol_syslog(get_class($this)."::deleteCommon Can't delete record as it has some child", LOG_WARNING); |
@@ -7406,7 +7937,9 @@ discard block |
||
| 7406 | 7937 | */ |
| 7407 | 7938 | public function trimParameters($parameters) |
| 7408 | 7939 | {
|
| 7409 | - if (!is_array($parameters)) return; |
|
| 7940 | + if (!is_array($parameters)) { |
|
| 7941 | + return; |
|
| 7942 | + } |
|
| 7410 | 7943 | foreach ($parameters as $parameter) {
|
| 7411 | 7944 | if (isset($this->$parameter)) {
|
| 7412 | 7945 | $this->$parameter = trim($this->$parameter); |