@@ -74,7 +74,9 @@ discard block |
||
| 74 | 74 | $sql = "SELECT rowid, label"; |
| 75 | 75 | $sql.= " FROM ".MAIN_DB_PREFIX."export_model"; |
| 76 | 76 | $sql.= " WHERE type = '".$type."'"; |
| 77 | - if (!empty($fk_user)) $sql.=" AND fk_user=".$fk_user; |
|
| 77 | + if (!empty($fk_user)) { |
|
| 78 | + $sql.=" AND fk_user=".$fk_user; |
|
| 79 | + } |
|
| 78 | 80 | $sql.= " ORDER BY rowid"; |
| 79 | 81 | $result = $this->db->query($sql); |
| 80 | 82 | if ($result) |
@@ -93,8 +95,7 @@ discard block |
||
| 93 | 95 | if ($selected == $obj->rowid) |
| 94 | 96 | {
|
| 95 | 97 | print '<option value="'.$obj->rowid.'" selected>'; |
| 96 | - } |
|
| 97 | - else |
|
| 98 | + } else |
|
| 98 | 99 | {
|
| 99 | 100 | print '<option value="'.$obj->rowid.'">'; |
| 100 | 101 | } |
@@ -103,8 +104,7 @@ discard block |
||
| 103 | 104 | $i++; |
| 104 | 105 | } |
| 105 | 106 | print "</select>"; |
| 106 | - } |
|
| 107 | - else {
|
|
| 107 | + } else {
|
|
| 108 | 108 | dol_print_error($this->db); |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -144,8 +144,7 @@ discard block |
||
| 144 | 144 | if ($selected == $obj->rowid) |
| 145 | 145 | {
|
| 146 | 146 | print '<option value="'.$obj->rowid.'" selected>'; |
| 147 | - } |
|
| 148 | - else |
|
| 147 | + } else |
|
| 149 | 148 | {
|
| 150 | 149 | print '<option value="'.$obj->rowid.'">'; |
| 151 | 150 | } |
@@ -154,8 +153,7 @@ discard block |
||
| 154 | 153 | $i++; |
| 155 | 154 | } |
| 156 | 155 | print "</select>"; |
| 157 | - } |
|
| 158 | - else {
|
|
| 156 | + } else {
|
|
| 159 | 157 | dol_print_error($this->db); |
| 160 | 158 | } |
| 161 | 159 | } |
@@ -196,8 +194,7 @@ discard block |
||
| 196 | 194 | if ($selected && $selected == $obj->rowid) |
| 197 | 195 | {
|
| 198 | 196 | print '<option value="'.$obj->rowid.'" selected>'; |
| 199 | - } |
|
| 200 | - else |
|
| 197 | + } else |
|
| 201 | 198 | {
|
| 202 | 199 | print '<option value="'.$obj->rowid.'">'; |
| 203 | 200 | //print '<option onmouseover="showtip(\''.$obj->label.'\')" onMouseout="hidetip()" value="'.$obj->rowid.'">'; |
@@ -210,8 +207,7 @@ discard block |
||
| 210 | 207 | } |
| 211 | 208 | print '</select>'; |
| 212 | 209 | return 0; |
| 213 | - } |
|
| 214 | - else |
|
| 210 | + } else |
|
| 215 | 211 | {
|
| 216 | 212 | dol_print_error($this->db); |
| 217 | 213 | return 1; |
@@ -256,8 +252,7 @@ discard block |
||
| 256 | 252 | if (($selected && $selected == $obj->taux) || $num == 1) |
| 257 | 253 | {
|
| 258 | 254 | $out.='<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent"' : '').' selected>'; |
| 259 | - } |
|
| 260 | - else |
|
| 255 | + } else |
|
| 261 | 256 | {
|
| 262 | 257 | $out.='<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent"' : '').'>'; |
| 263 | 258 | //print '<option onmouseover="showtip(\''.$obj->libelle.'\')" onMouseout="hidetip()" value="'.$obj->rowid.'">'; |
@@ -269,8 +264,7 @@ discard block |
||
| 269 | 264 | } |
| 270 | 265 | $out.='</select>'; |
| 271 | 266 | return $out; |
| 272 | - } |
|
| 273 | - else |
|
| 267 | + } else |
|
| 274 | 268 | {
|
| 275 | 269 | dol_print_error($this->db); |
| 276 | 270 | return ''; |
@@ -295,15 +289,16 @@ discard block |
||
| 295 | 289 | {
|
| 296 | 290 | // phpcs:enable |
| 297 | 291 | $return = '<select class="flat" name="'.$htmlname.'" '.($disabled?'disabled':'').'>'; |
| 298 | - if ($showempty) $return.='<option value="-1"'.(($selected == -1 || $selected == '')?' selected':'').'> </option>'; |
|
| 292 | + if ($showempty) { |
|
| 293 | + $return.='<option value="-1"'.(($selected == -1 || $selected == '')?' selected':'').'> </option>'; |
|
| 294 | + } |
|
| 299 | 295 | |
| 300 | 296 | for ($i = $start ; $i <= $end ; $i += $increment) |
| 301 | 297 | {
|
| 302 | 298 | if ($selected != '' && (int) $selected == $i) |
| 303 | 299 | {
|
| 304 | 300 | $return.= '<option value="'.$i.'" selected>'; |
| 305 | - } |
|
| 306 | - else |
|
| 301 | + } else |
|
| 307 | 302 | {
|
| 308 | 303 | $return.= '<option value="'.$i.'">'; |
| 309 | 304 | } |
@@ -355,14 +350,19 @@ discard block |
||
| 355 | 350 | |
| 356 | 351 | // Print a select with each of them |
| 357 | 352 | $moreforfilter.='<select class="flat minwidth100'.($morecss?' '.$morecss:'').'" id="select_categ_'.$htmlname.'" name="'.$htmlname.'">'; |
| 358 | - if ($showempty) $moreforfilter.='<option value="0"> </option>'; // Should use -1 to say nothing |
|
| 353 | + if ($showempty) { |
|
| 354 | + $moreforfilter.='<option value="0"> </option>'; |
|
| 355 | + } |
|
| 356 | + // Should use -1 to say nothing |
|
| 359 | 357 | |
| 360 | 358 | if (is_array($tab_categs)) |
| 361 | 359 | {
|
| 362 | 360 | foreach ($tab_categs as $categ) |
| 363 | 361 | {
|
| 364 | 362 | $moreforfilter.='<option value="'.$categ['id'].'"'; |
| 365 | - if ($categ['id'] == $selected) $moreforfilter.=' selected'; |
|
| 363 | + if ($categ['id'] == $selected) { |
|
| 364 | + $moreforfilter.=' selected'; |
|
| 365 | + } |
|
| 366 | 366 | $moreforfilter.='>'.dol_trunc($categ['fulllabel'],50,'middle').'</option>'; |
| 367 | 367 | } |
| 368 | 368 | } |
@@ -408,14 +408,20 @@ discard block |
||
| 408 | 408 | } |
| 409 | 409 | // Select each sales and print them in a select input |
| 410 | 410 | $out.='<select class="flat'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'">'; |
| 411 | - if ($showempty) $out.='<option value="0"> </option>'; |
|
| 411 | + if ($showempty) { |
|
| 412 | + $out.='<option value="0"> </option>'; |
|
| 413 | + } |
|
| 412 | 414 | |
| 413 | 415 | // Get list of users allowed to be viewed |
| 414 | 416 | $sql_usr = "SELECT u.rowid, u.lastname, u.firstname, u.statut, u.login"; |
| 415 | 417 | $sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u"; |
| 416 | 418 | $sql_usr .= " WHERE u.entity IN (0," . Globals::$conf->entity . ")"; |
| 417 | - if (empty($user->rights->user->user->lire)) $sql_usr.=" AND u.rowid = ".$user->id; |
|
| 418 | - if (! empty($user->societe_id)) $sql_usr.=" AND u.fk_soc = ".$user->societe_id; |
|
| 419 | + if (empty($user->rights->user->user->lire)) { |
|
| 420 | + $sql_usr.=" AND u.rowid = ".$user->id; |
|
| 421 | + } |
|
| 422 | + if (! empty($user->societe_id)) { |
|
| 423 | + $sql_usr.=" AND u.fk_soc = ".$user->societe_id; |
|
| 424 | + } |
|
| 419 | 425 | // Add existing sales representatives of thirdparty of external user |
| 420 | 426 | if (empty($user->rights->user->user->lire) && $user->societe_id) |
| 421 | 427 | {
|
@@ -436,7 +442,9 @@ discard block |
||
| 436 | 442 | |
| 437 | 443 | $out.='<option value="'.$obj_usr->rowid.'"'; |
| 438 | 444 | |
| 439 | - if ($obj_usr->rowid == $selected) $out.=' selected'; |
|
| 445 | + if ($obj_usr->rowid == $selected) { |
|
| 446 | + $out.=' selected'; |
|
| 447 | + } |
|
| 440 | 448 | |
| 441 | 449 | $out.='>'; |
| 442 | 450 | $out.=dolGetFirstLastname($obj_usr->firstname,$obj_usr->lastname); |
@@ -463,8 +471,7 @@ discard block |
||
| 463 | 471 | $out.='</option>'; |
| 464 | 472 | } |
| 465 | 473 | $this->db->free($resql_usr); |
| 466 | - } |
|
| 467 | - else |
|
| 474 | + } else |
|
| 468 | 475 | {
|
| 469 | 476 | dol_print_error($this->db); |
| 470 | 477 | } |
@@ -500,15 +507,16 @@ discard block |
||
| 500 | 507 | if ($tasksarray) |
| 501 | 508 | {
|
| 502 | 509 | print '<select class="flat'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
| 503 | - if ($useempty) print '<option value="0"> </option>'; |
|
| 510 | + if ($useempty) { |
|
| 511 | + print '<option value="0"> </option>'; |
|
| 512 | + } |
|
| 504 | 513 | $j=0; |
| 505 | 514 | $level=0; |
| 506 | 515 | $this->_pLineSelect($j, 0, $tasksarray, $level, $selectedtask, $projectid, $disablechildoftaskid); |
| 507 | 516 | print '</select>'; |
| 508 | 517 | |
| 509 | 518 | print ajax_combobox($htmlname); |
| 510 | - } |
|
| 511 | - else |
|
| 519 | + } else |
|
| 512 | 520 | {
|
| 513 | 521 | print '<div class="warning">'.$langs->trans("NoProject").'</div>';
|
| 514 | 522 | } |
@@ -542,20 +550,23 @@ discard block |
||
| 542 | 550 | //var_dump($selectedproject."--".$selectedtask."--".$lines[$i]->fk_project."_".$lines[$i]->id); // $lines[$i]->id may be empty if project has no lines |
| 543 | 551 | |
| 544 | 552 | // Break on a new project |
| 545 | - if ($parent == 0) // We are on a task at first level |
|
| 553 | + if ($parent == 0) { |
|
| 554 | + // We are on a task at first level |
|
| 546 | 555 | {
|
| 547 | 556 | if ($lines[$i]->fk_project != $lastprojectid) // Break found on project |
| 548 | 557 | {
|
| 549 | - if ($i > 0) print '<option value="0" disabled>----------</option>'; |
|
| 558 | + if ($i > 0) print '<option value="0" disabled>----------</option>'; |
|
| 559 | + } |
|
| 550 | 560 | print '<option value="'.$lines[$i]->fk_project.'_0"'; |
| 551 | - if ($selectedproject == $lines[$i]->fk_project) print ' selected'; |
|
| 561 | + if ($selectedproject == $lines[$i]->fk_project) { |
|
| 562 | + print ' selected'; |
|
| 563 | + } |
|
| 552 | 564 | print '>'; // Project -> Task |
| 553 | 565 | print $langs->trans("Project").' '.$lines[$i]->projectref;
|
| 554 | 566 | if (empty($lines[$i]->public)) |
| 555 | 567 | {
|
| 556 | 568 | print ' ('.$langs->trans("Visibility").': '.$langs->trans("PrivateProject").')';
|
| 557 | - } |
|
| 558 | - else |
|
| 569 | + } else |
|
| 559 | 570 | {
|
| 560 | 571 | print ' ('.$langs->trans("Visibility").': '.$langs->trans("SharedProject").')';
|
| 561 | 572 | } |
@@ -570,31 +581,41 @@ discard block |
||
| 570 | 581 | $newdisablechildoftaskid=$disablechildoftaskid; |
| 571 | 582 | |
| 572 | 583 | // Print task |
| 573 | - if (isset($lines[$i]->id)) // We use isset because $lines[$i]->id may be null if project has no task and are on root project (tasks may be caught by a left join). We enter here only if '0' or >0 |
|
| 584 | + if (isset($lines[$i]->id)) { |
|
| 585 | + // We use isset because $lines[$i]->id may be null if project has no task and are on root project (tasks may be caught by a left join). We enter here only if '0' or >0 |
|
| 574 | 586 | {
|
| 575 | 587 | // Check if we must disable entry |
| 576 | - $disabled=0; |
|
| 588 | + $disabled=0; |
|
| 589 | + } |
|
| 577 | 590 | if ($disablechildoftaskid && (($lines[$i]->id == $disablechildoftaskid || $lines[$i]->fk_parent == $disablechildoftaskid))) |
| 578 | 591 | {
|
| 579 | 592 | $disabled++; |
| 580 | - if ($lines[$i]->fk_parent == $disablechildoftaskid) $newdisablechildoftaskid=$lines[$i]->id; // If task is child of a disabled parent, we will propagate id to disable next child too |
|
| 593 | + if ($lines[$i]->fk_parent == $disablechildoftaskid) { |
|
| 594 | + $newdisablechildoftaskid=$lines[$i]->id; |
|
| 595 | + } |
|
| 596 | + // If task is child of a disabled parent, we will propagate id to disable next child too |
|
| 581 | 597 | } |
| 582 | 598 | |
| 583 | 599 | print '<option value="'.$lines[$i]->fk_project.'_'.$lines[$i]->id.'"'; |
| 584 | - if (($lines[$i]->id == $selectedtask) || ($lines[$i]->fk_project.'_'.$lines[$i]->id == $selectedtask)) print ' selected'; |
|
| 585 | - if ($disabled) print ' disabled'; |
|
| 600 | + if (($lines[$i]->id == $selectedtask) || ($lines[$i]->fk_project.'_'.$lines[$i]->id == $selectedtask)) { |
|
| 601 | + print ' selected'; |
|
| 602 | + } |
|
| 603 | + if ($disabled) { |
|
| 604 | + print ' disabled'; |
|
| 605 | + } |
|
| 586 | 606 | print '>'; |
| 587 | 607 | print $langs->trans("Project").' '.$lines[$i]->projectref;
|
| 588 | 608 | print ' '.$lines[$i]->projectlabel; |
| 589 | 609 | if (empty($lines[$i]->public)) |
| 590 | 610 | {
|
| 591 | 611 | print ' ('.$langs->trans("Visibility").': '.$langs->trans("PrivateProject").')';
|
| 592 | - } |
|
| 593 | - else |
|
| 612 | + } else |
|
| 594 | 613 | {
|
| 595 | 614 | print ' ('.$langs->trans("Visibility").': '.$langs->trans("SharedProject").')';
|
| 596 | 615 | } |
| 597 | - if ($lines[$i]->id) print ' > '; |
|
| 616 | + if ($lines[$i]->id) { |
|
| 617 | + print ' > '; |
|
| 618 | + } |
|
| 598 | 619 | for ($k = 0 ; $k < $level ; $k++) |
| 599 | 620 | {
|
| 600 | 621 | print " "; |
@@ -604,7 +625,9 @@ discard block |
||
| 604 | 625 | } |
| 605 | 626 | |
| 606 | 627 | $level++; |
| 607 | - if ($lines[$i]->id) $this->_pLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject, $newdisablechildoftaskid); |
|
| 628 | + if ($lines[$i]->id) { |
|
| 629 | + $this->_pLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject, $newdisablechildoftaskid); |
|
| 630 | + } |
|
| 608 | 631 | $level--; |
| 609 | 632 | } |
| 610 | 633 | } |
@@ -623,12 +646,17 @@ discard block |
||
| 623 | 646 | {
|
| 624 | 647 | $textcolor='FFF'; |
| 625 | 648 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
| 626 | - if(colorIsLight($color)) $textcolor='000'; |
|
| 649 | + if(colorIsLight($color)) { |
|
| 650 | + $textcolor='000'; |
|
| 651 | + } |
|
| 627 | 652 | |
| 628 | 653 | $color = colorArrayToHex(colorStringToArray($color,array()),''); |
| 629 | 654 | |
| 630 | - if ($color) print '<input type="text" class="colorthumb" disabled style="padding: 1px; margin-top: 0; margin-bottom: 0; color: #'.$textcolor.'; background-color: #'.$color.'" value="'.$color.'">'; |
|
| 631 | - else print $textifnotdefined; |
|
| 655 | + if ($color) { |
|
| 656 | + print '<input type="text" class="colorthumb" disabled style="padding: 1px; margin-top: 0; margin-bottom: 0; color: #'.$textcolor.'; background-color: #'.$color.'" value="'.$color.'">'; |
|
| 657 | + } else { |
|
| 658 | + print $textifnotdefined; |
|
| 659 | + } |
|
| 632 | 660 | } |
| 633 | 661 | |
| 634 | 662 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -718,8 +746,7 @@ discard block |
||
| 718 | 746 | </script>'; |
| 719 | 747 | } |
| 720 | 748 | $out.= '<input id="colorpicker'.$prefix.'" name="'.$prefix.'" size="6" maxlength="7" class="flat'.($morecss?' '.$morecss:'').'" type="text" value="'.$set_color.'" />'; |
| 721 | - } |
|
| 722 | - else // In most cases, this is not used. We used instead function with no specific list of colors |
|
| 749 | + } else // In most cases, this is not used. We used instead function with no specific list of colors |
|
| 723 | 750 | {
|
| 724 | 751 | if (empty(Globals::$conf->dol_use_jmobile)) {
|
| 725 | 752 | $out.= '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/colorpicker/jquery.colorpicker.css" type="text/css" media="screen" />'; |
@@ -739,7 +766,9 @@ discard block |
||
| 739 | 766 | foreach ($arrayofcolors as $val) |
| 740 | 767 | {
|
| 741 | 768 | $out.= '<option value="'.$val.'"'; |
| 742 | - if ($set_color == $val) $out.= ' selected'; |
|
| 769 | + if ($set_color == $val) { |
|
| 770 | + $out.= ' selected'; |
|
| 771 | + } |
|
| 743 | 772 | $out.= '>'.$val.'</option>'; |
| 744 | 773 | } |
| 745 | 774 | $out.= '</select>'; |
@@ -822,8 +851,7 @@ discard block |
||
| 822 | 851 | if ($selected == $key) |
| 823 | 852 | {
|
| 824 | 853 | $select_week .= '<option value="'.$key.'" selected>'; |
| 825 | - } |
|
| 826 | - else |
|
| 854 | + } else |
|
| 827 | 855 | {
|
| 828 | 856 | $select_week .= '<option value="'.$key.'">'; |
| 829 | 857 | } |
@@ -852,8 +880,13 @@ discard block |
||
| 852 | 880 | |
| 853 | 881 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
| 854 | 882 | |
| 855 | - if ($longlabel) $montharray = monthArray($langs, 0); // Get array |
|
| 856 | - else $montharray = monthArray($langs, 1); |
|
| 883 | + if ($longlabel) { |
|
| 884 | + $montharray = monthArray($langs, 0); |
|
| 885 | + } |
|
| 886 | + // Get array |
|
| 887 | + else { |
|
| 888 | + $montharray = monthArray($langs, 1); |
|
| 889 | + } |
|
| 857 | 890 | |
| 858 | 891 | $select_month = '<select class="flat'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
| 859 | 892 | if ($useempty) |
@@ -865,8 +898,7 @@ discard block |
||
| 865 | 898 | if ($selected == $key) |
| 866 | 899 | {
|
| 867 | 900 | $select_month .= '<option value="'.$key.'" selected>'; |
| 868 | - } |
|
| 869 | - else |
|
| 901 | + } else |
|
| 870 | 902 | {
|
| 871 | 903 | $select_month .= '<option value="'.$key.'">'; |
| 872 | 904 | } |
@@ -919,13 +951,17 @@ discard block |
||
| 919 | 951 | $currentyear = date("Y")+$offset;
|
| 920 | 952 | $max_year = $currentyear+$max_year; |
| 921 | 953 | $min_year = $currentyear-$min_year; |
| 922 | - if(empty($selected) && empty($useempty)) $selected = $currentyear; |
|
| 954 | + if(empty($selected) && empty($useempty)) { |
|
| 955 | + $selected = $currentyear; |
|
| 956 | + } |
|
| 923 | 957 | |
| 924 | 958 | $out.= '<select class="flat'.($morecss?' '.$morecss:'').'" id="' . $htmlname . '" name="' . $htmlname . '"'.$option.' >'; |
| 925 | 959 | if($useempty) |
| 926 | 960 | {
|
| 927 | 961 | $selected_html=''; |
| 928 | - if ($selected == '') $selected_html = ' selected'; |
|
| 962 | + if ($selected == '') { |
|
| 963 | + $selected_html = ' selected'; |
|
| 964 | + } |
|
| 929 | 965 | $out.= '<option value=""' . $selected_html . '> </option>'; |
| 930 | 966 | } |
| 931 | 967 | if (! $invert) |
@@ -933,16 +969,19 @@ discard block |
||
| 933 | 969 | for ($y = $max_year; $y >= $min_year; $y--) |
| 934 | 970 | {
|
| 935 | 971 | $selected_html=''; |
| 936 | - if ($selected > 0 && $y == $selected) $selected_html = ' selected'; |
|
| 972 | + if ($selected > 0 && $y == $selected) { |
|
| 973 | + $selected_html = ' selected'; |
|
| 974 | + } |
|
| 937 | 975 | $out.= '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>'; |
| 938 | 976 | } |
| 939 | - } |
|
| 940 | - else |
|
| 977 | + } else |
|
| 941 | 978 | {
|
| 942 | 979 | for ($y = $min_year; $y <= $max_year; $y++) |
| 943 | 980 | {
|
| 944 | 981 | $selected_html=''; |
| 945 | - if ($selected > 0 && $y == $selected) $selected_html = ' selected'; |
|
| 982 | + if ($selected > 0 && $y == $selected) { |
|
| 983 | + $selected_html = ' selected'; |
|
| 984 | + } |
|
| 946 | 985 | $out.= '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>'; |
| 947 | 986 | } |
| 948 | 987 | } |
@@ -979,8 +1018,7 @@ discard block |
||
| 979 | 1018 | $langs->load("companies");
|
| 980 | 1019 | print ' <a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$socid.'&action=create&origin='.$origin.'&originid='.$originid.'>'.$langs->trans("AddAddress").'</a>';
|
| 981 | 1020 | print '</form>'; |
| 982 | - } |
|
| 983 | - else |
|
| 1021 | + } else |
|
| 984 | 1022 | {
|
| 985 | 1023 | if ($selected) |
| 986 | 1024 | {
|
@@ -988,8 +1026,7 @@ discard block |
||
| 988 | 1026 | $address=new Address($this->db); |
| 989 | 1027 | $result=$address->fetch_address($selected); |
| 990 | 1028 | print '<a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$address->socid.'&id='.$address->id.'&action=edit&origin='.$origin.'&originid='.$originid.'>'.$address->label.'</a>'; |
| 991 | - } |
|
| 992 | - else |
|
| 1029 | + } else |
|
| 993 | 1030 | {
|
| 994 | 1031 | print " "; |
| 995 | 1032 | } |
@@ -1023,7 +1060,10 @@ discard block |
||
| 1023 | 1060 | $boxidactivatedforuser=array(); |
| 1024 | 1061 | foreach($boxactivated as $box) |
| 1025 | 1062 | {
|
| 1026 | - if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user |
|
| 1063 | + if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) { |
|
| 1064 | + $boxidactivatedforuser[$box->id]=$box->id; |
|
| 1065 | + } |
|
| 1066 | + // We keep only boxes to show for user |
|
| 1027 | 1067 | } |
| 1028 | 1068 | |
| 1029 | 1069 | // Define selectboxlist |
@@ -1034,7 +1074,10 @@ discard block |
||
| 1034 | 1074 | $langs->load("boxes"); // Load label of boxes
|
| 1035 | 1075 | foreach($boxactivated as $box) |
| 1036 | 1076 | {
|
| 1037 | - if (! empty($boxidactivatedforuser[$box->id])) continue; // Already visible for user |
|
| 1077 | + if (! empty($boxidactivatedforuser[$box->id])) { |
|
| 1078 | + continue; |
|
| 1079 | + } |
|
| 1080 | + // Already visible for user |
|
| 1038 | 1081 | $label=$langs->transnoentitiesnoconv($box->boxlabel); |
| 1039 | 1082 | //if (preg_match('/graph/',$box->class)) $label.=' ('.$langs->trans("Graph").')';
|
| 1040 | 1083 | if (preg_match('/graph/', $box->class) && Globals::$conf->browser->layout != 'phone') {
|
@@ -1044,7 +1087,9 @@ discard block |
||
| 1044 | 1087 | } |
| 1045 | 1088 | foreach($boxidactivatedforuser as $boxid) |
| 1046 | 1089 | {
|
| 1047 | - if (empty($boxorder)) $boxorder.='A:'; |
|
| 1090 | + if (empty($boxorder)) { |
|
| 1091 | + $boxorder.='A:'; |
|
| 1092 | + } |
|
| 1048 | 1093 | $boxorder.=$boxid.','; |
| 1049 | 1094 | } |
| 1050 | 1095 | |
@@ -1058,8 +1103,9 @@ discard block |
||
| 1058 | 1103 | $selectboxlist.='<input type="hidden" name="areacode" value="'.$areacode.'">'; |
| 1059 | 1104 | $selectboxlist.='<input type="hidden" name="boxorder" value="'.$boxorder.'">'; |
| 1060 | 1105 | $selectboxlist.=Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth150onsmartphone', 0, 'hidden selected', 0, 1);
|
| 1061 | - if (empty(Globals::$conf->use_javascript_ajax)) |
|
| 1062 | - $selectboxlist .= ' <input type="submit" class="button" value="' . $langs->trans("AddBox") . '">';
|
|
| 1106 | + if (empty(Globals::$conf->use_javascript_ajax)) { |
|
| 1107 | + $selectboxlist .= ' <input type="submit" class="button" value="' . $langs->trans("AddBox") . '">'; |
|
| 1108 | + } |
|
| 1063 | 1109 | $selectboxlist.='</form>'; |
| 1064 | 1110 | if (!empty(Globals::$conf->use_javascript_ajax)) {
|
| 1065 | 1111 | include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
@@ -1108,7 +1154,9 @@ discard block |
||
| 1108 | 1154 | window.location.search=\'mainmenu='.GETPOST("mainmenu","aZ09").'&leftmenu='.GETPOST('leftmenu',"aZ09").'&action=addbox&boxid=\'+boxid;
|
| 1109 | 1155 | } |
| 1110 | 1156 | });'; |
| 1111 | - if (! count($arrayboxtoactivatelabel)) $selectboxlist.='jQuery("#boxcombo").hide();';
|
|
| 1157 | + if (! count($arrayboxtoactivatelabel)) { |
|
| 1158 | + $selectboxlist.='jQuery("#boxcombo").hide();'; |
|
| 1159 | + } |
|
| 1112 | 1160 | $selectboxlist.=' |
| 1113 | 1161 | |
| 1114 | 1162 | jQuery("#boxhalfleft, #boxhalfright").sortable({
|
@@ -1151,17 +1199,25 @@ discard block |
||
| 1151 | 1199 | |
| 1152 | 1200 | // Define $box_max_lines |
| 1153 | 1201 | $box_max_lines=5; |
| 1154 | - if (!empty(Globals::$conf->global->MAIN_BOXES_MAXLINES)) |
|
| 1155 | - $box_max_lines = Globals::$conf->global->MAIN_BOXES_MAXLINES; |
|
| 1202 | + if (!empty(Globals::$conf->global->MAIN_BOXES_MAXLINES)) { |
|
| 1203 | + $box_max_lines = Globals::$conf->global->MAIN_BOXES_MAXLINES; |
|
| 1204 | + } |
|
| 1156 | 1205 | |
| 1157 | 1206 | $ii=0; |
| 1158 | 1207 | foreach ($boxactivated as $key => $box) |
| 1159 | 1208 | {
|
| 1160 | - if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; |
|
| 1161 | - if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='A'.sprintf("%02d",($ii+1)); // When box_order was not yet set to Axx or Bxx and is still 0
|
|
| 1162 | - if (preg_match('/^A/i',$box->box_order)) // column A
|
|
| 1209 | + if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) { |
|
| 1210 | + continue; |
|
| 1211 | + } |
|
| 1212 | + if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) { |
|
| 1213 | + $box->box_order='A'.sprintf("%02d",($ii+1)); |
|
| 1214 | + } |
|
| 1215 | + // When box_order was not yet set to Axx or Bxx and is still 0 |
|
| 1216 | + if (preg_match('/^A/i',$box->box_order)) { |
|
| 1217 | + // column A |
|
| 1163 | 1218 | {
|
| 1164 | - $ii++; |
|
| 1219 | + $ii++; |
|
| 1220 | + } |
|
| 1165 | 1221 | //print 'box_id '.$boxactivated[$ii]->box_id.' '; |
| 1166 | 1222 | //print 'box_order '.$boxactivated[$ii]->box_order.'<br>'; |
| 1167 | 1223 | // Show box |
@@ -1183,11 +1239,18 @@ discard block |
||
| 1183 | 1239 | $ii=0; |
| 1184 | 1240 | foreach ($boxactivated as $key => $box) |
| 1185 | 1241 | {
|
| 1186 | - if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; |
|
| 1187 | - if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='B'.sprintf("%02d",($ii+1)); // When box_order was not yet set to Axx or Bxx and is still 0
|
|
| 1188 | - if (preg_match('/^B/i',$box->box_order)) // colonne B
|
|
| 1242 | + if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) { |
|
| 1243 | + continue; |
|
| 1244 | + } |
|
| 1245 | + if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) { |
|
| 1246 | + $box->box_order='B'.sprintf("%02d",($ii+1)); |
|
| 1247 | + } |
|
| 1248 | + // When box_order was not yet set to Axx or Bxx and is still 0 |
|
| 1249 | + if (preg_match('/^B/i',$box->box_order)) { |
|
| 1250 | + // colonne B |
|
| 1189 | 1251 | {
|
| 1190 | - $ii++; |
|
| 1252 | + $ii++; |
|
| 1253 | + } |
|
| 1191 | 1254 | //print 'box_id '.$boxactivated[$ii]->box_id.' '; |
| 1192 | 1255 | //print 'box_order '.$boxactivated[$ii]->box_order.'<br>'; |
| 1193 | 1256 | // Show box |
@@ -1254,8 +1317,7 @@ discard block |
||
| 1254 | 1317 | if ($selected == $obj->rowid || $selected == $obj->$keyfield) |
| 1255 | 1318 | {
|
| 1256 | 1319 | print '<option value="'.$obj->$keyfield.'" selected>'; |
| 1257 | - } |
|
| 1258 | - else |
|
| 1320 | + } else |
|
| 1259 | 1321 | {
|
| 1260 | 1322 | print '<option value="'.$obj->$keyfield.'">'; |
| 1261 | 1323 | } |
@@ -1264,13 +1326,11 @@ discard block |
||
| 1264 | 1326 | $i++; |
| 1265 | 1327 | } |
| 1266 | 1328 | print "</select>"; |
| 1267 | - } |
|
| 1268 | - else |
|
| 1329 | + } else |
|
| 1269 | 1330 | {
|
| 1270 | 1331 | print $langs->trans("DictionaryEmpty");
|
| 1271 | 1332 | } |
| 1272 | - } |
|
| 1273 | - else {
|
|
| 1333 | + } else {
|
|
| 1274 | 1334 | dol_print_error($this->db); |
| 1275 | 1335 | } |
| 1276 | 1336 | } |
@@ -59,8 +59,7 @@ discard block |
||
| 59 | 59 | $entity = "&#". $unicode . ';'; |
| 60 | 60 | $decodedStr .= utf8_encode($entity); |
| 61 | 61 | $pos += 4; |
| 62 | - } |
|
| 63 | - else {
|
|
| 62 | + } else {
|
|
| 64 | 63 | // we have an escaped ascii character |
| 65 | 64 | $hexVal = substr($source, $pos, 2); |
| 66 | 65 | $decodedStr .= chr(hexdec($hexVal)); |
@@ -100,7 +99,10 @@ discard block |
||
| 100 | 99 | {
|
| 101 | 100 | while (($file = readdir($handle))!==false) |
| 102 | 101 | {
|
| 103 | - if (preg_match('/disabled/',$file)) continue; // We discard module if it contains disabled into name.
|
|
| 102 | + if (preg_match('/disabled/',$file)) { |
|
| 103 | + continue; |
|
| 104 | + } |
|
| 105 | + // We discard module if it contains disabled into name. |
|
| 104 | 106 | |
| 105 | 107 | if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') |
| 106 | 108 | {
|
@@ -132,8 +134,14 @@ discard block |
||
| 132 | 134 | $outputlangs=$langs; |
| 133 | 135 | } |
| 134 | 136 | |
| 135 | - if ($outputlangs->defaultlang == 'ca_CA') $selected='CAP4'; // Canada |
|
| 136 | - if ($outputlangs->defaultlang == 'en_US') $selected='USLetter'; // US |
|
| 137 | + if ($outputlangs->defaultlang == 'ca_CA') { |
|
| 138 | + $selected='CAP4'; |
|
| 139 | + } |
|
| 140 | + // Canada |
|
| 141 | + if ($outputlangs->defaultlang == 'en_US') { |
|
| 142 | + $selected='USLetter'; |
|
| 143 | + } |
|
| 144 | + // US |
|
| 137 | 145 | return $selected; |
| 138 | 146 | } |
| 139 | 147 | |
@@ -158,33 +166,42 @@ discard block |
||
| 158 | 166 | {
|
| 159 | 167 | $content=file_get_contents($formfile); |
| 160 | 168 | $isutf8=utf8_check($content); |
| 161 | - if (!$isutf8 && Globals::$conf->file->character_set_client == 'UTF-8') |
|
| 162 | - print utf8_encode($content); |
|
| 163 | - elseif ($isutf8 && Globals::$conf->file->character_set_client == 'ISO-8859-1') |
|
| 164 | - print utf8_decode($content); |
|
| 165 | - else print $content; |
|
| 169 | + if (!$isutf8 && Globals::$conf->file->character_set_client == 'UTF-8') { |
|
| 170 | + print utf8_encode($content); |
|
| 171 | + } elseif ($isutf8 && Globals::$conf->file->character_set_client == 'ISO-8859-1') { |
|
| 172 | + print utf8_decode($content); |
|
| 173 | + } else { |
|
| 174 | + print $content; |
|
| 175 | + } |
|
| 166 | 176 | return true; |
| 167 | - } |
|
| 168 | - else dol_syslog('functions2::dol_print_file not found', LOG_DEBUG);
|
|
| 177 | + } else { |
|
| 178 | + dol_syslog('functions2::dol_print_file not found', LOG_DEBUG); |
|
| 179 | + } |
|
| 169 | 180 | |
| 170 | 181 | if ($searchalt) {
|
| 171 | 182 | // Test si fichier dans repertoire de la langue alternative |
| 172 | - if ($langs->defaultlang != "en_US") $formfilealt = $searchdir."/langs/en_US/".$filename; |
|
| 173 | - else $formfilealt = $searchdir."/langs/fr_FR/".$filename; |
|
| 183 | + if ($langs->defaultlang != "en_US") { |
|
| 184 | + $formfilealt = $searchdir."/langs/en_US/".$filename; |
|
| 185 | + } else { |
|
| 186 | + $formfilealt = $searchdir."/langs/fr_FR/".$filename; |
|
| 187 | + } |
|
| 174 | 188 | dol_syslog('functions2::dol_print_file search alt file '.$formfilealt, LOG_DEBUG);
|
| 175 | 189 | //print 'getcwd='.getcwd().' htmlfilealt='.$formfilealt.' X '.file_exists(getcwd().'/'.$formfilealt); |
| 176 | 190 | if (is_readable($formfilealt)) |
| 177 | 191 | {
|
| 178 | 192 | $content=file_get_contents($formfilealt); |
| 179 | 193 | $isutf8=utf8_check($content); |
| 180 | - if (!$isutf8 && Globals::$conf->file->character_set_client == 'UTF-8') |
|
| 181 | - print utf8_encode($content); |
|
| 182 | - elseif ($isutf8 && Globals::$conf->file->character_set_client == 'ISO-8859-1') |
|
| 183 | - print utf8_decode($content); |
|
| 184 | - else print $content; |
|
| 194 | + if (!$isutf8 && Globals::$conf->file->character_set_client == 'UTF-8') { |
|
| 195 | + print utf8_encode($content); |
|
| 196 | + } elseif ($isutf8 && Globals::$conf->file->character_set_client == 'ISO-8859-1') { |
|
| 197 | + print utf8_decode($content); |
|
| 198 | + } else { |
|
| 199 | + print $content; |
|
| 200 | + } |
|
| 185 | 201 | return true; |
| 186 | - } |
|
| 187 | - else dol_syslog('functions2::dol_print_file not found', LOG_DEBUG);
|
|
| 202 | + } else { |
|
| 203 | + dol_syslog('functions2::dol_print_file not found', LOG_DEBUG); |
|
| 204 | + } |
|
| 188 | 205 | } |
| 189 | 206 | } |
| 190 | 207 | |
@@ -214,279 +231,460 @@ discard block |
||
| 214 | 231 | $deltadateforuser=round($deltadateforclient-$deltadateforserver); |
| 215 | 232 | //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser; |
| 216 | 233 | |
| 217 | - if ($usetable) print '<table class="border centpercent">'; |
|
| 234 | + if ($usetable) { |
|
| 235 | + print '<table class="border centpercent">'; |
|
| 236 | + } |
|
| 218 | 237 | |
| 219 | 238 | // Import key |
| 220 | 239 | if (! empty($object->import_key)) |
| 221 | 240 | {
|
| 222 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 241 | + if ($usetable) { |
|
| 242 | + print '<tr><td class="titlefield">'; |
|
| 243 | + } |
|
| 223 | 244 | print $langs->trans("ImportedWithSet");
|
| 224 | - if ($usetable) print '</td><td>'; |
|
| 225 | - else print ': '; |
|
| 245 | + if ($usetable) { |
|
| 246 | + print '</td><td>'; |
|
| 247 | + } else { |
|
| 248 | + print ': '; |
|
| 249 | + } |
|
| 226 | 250 | print $object->import_key; |
| 227 | - if ($usetable) print '</td></tr>'; |
|
| 228 | - else print '<br>'; |
|
| 251 | + if ($usetable) { |
|
| 252 | + print '</td></tr>'; |
|
| 253 | + } else { |
|
| 254 | + print '<br>'; |
|
| 255 | + } |
|
| 229 | 256 | } |
| 230 | 257 | |
| 231 | 258 | // User creation (old method using already loaded object and not id is kept for backward compatibility) |
| 232 | 259 | if (! empty($object->user_creation) || ! empty($object->user_creation_id)) |
| 233 | 260 | {
|
| 234 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 261 | + if ($usetable) { |
|
| 262 | + print '<tr><td class="titlefield">'; |
|
| 263 | + } |
|
| 235 | 264 | print $langs->trans("CreatedBy");
|
| 236 | - if ($usetable) print '</td><td>'; |
|
| 237 | - else print ': '; |
|
| 265 | + if ($usetable) { |
|
| 266 | + print '</td><td>'; |
|
| 267 | + } else { |
|
| 268 | + print ': '; |
|
| 269 | + } |
|
| 238 | 270 | if (is_object($object->user_creation)) |
| 239 | 271 | {
|
| 240 | - if ($object->user_creation->id) print $object->user_creation->getNomUrl(1, '', 0, 0, 0); |
|
| 241 | - else print $langs->trans("Unknown");
|
|
| 242 | - } |
|
| 243 | - else |
|
| 272 | + if ($object->user_creation->id) { |
|
| 273 | + print $object->user_creation->getNomUrl(1, '', 0, 0, 0); |
|
| 274 | + } else { |
|
| 275 | + print $langs->trans("Unknown"); |
|
| 276 | + } |
|
| 277 | + } else |
|
| 244 | 278 | {
|
| 245 | 279 | $userstatic=new User($db); |
| 246 | 280 | $userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation); |
| 247 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
| 248 | - else print $langs->trans("Unknown");
|
|
| 281 | + if ($userstatic->id) { |
|
| 282 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
| 283 | + } else { |
|
| 284 | + print $langs->trans("Unknown"); |
|
| 285 | + } |
|
| 249 | 286 | } |
| 250 | - if ($usetable) print '</td></tr>'; |
|
| 251 | - else print '<br>'; |
|
| 287 | + if ($usetable) { |
|
| 288 | + print '</td></tr>'; |
|
| 289 | + } else { |
|
| 290 | + print '<br>'; |
|
| 291 | + } |
|
| 252 | 292 | } |
| 253 | 293 | |
| 254 | 294 | // Date creation |
| 255 | 295 | if (! empty($object->date_creation)) |
| 256 | 296 | {
|
| 257 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 297 | + if ($usetable) { |
|
| 298 | + print '<tr><td class="titlefield">'; |
|
| 299 | + } |
|
| 258 | 300 | print $langs->trans("DateCreation");
|
| 259 | - if ($usetable) print '</td><td>'; |
|
| 260 | - else print ': '; |
|
| 301 | + if ($usetable) { |
|
| 302 | + print '</td><td>'; |
|
| 303 | + } else { |
|
| 304 | + print ': '; |
|
| 305 | + } |
|
| 261 | 306 | print dol_print_date($object->date_creation, 'dayhour'); |
| 262 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_creation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
|
|
| 263 | - if ($usetable) print '</td></tr>'; |
|
| 264 | - else print '<br>'; |
|
| 307 | + if ($deltadateforuser) { |
|
| 308 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_creation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
| 309 | + } |
|
| 310 | + if ($usetable) { |
|
| 311 | + print '</td></tr>'; |
|
| 312 | + } else { |
|
| 313 | + print '<br>'; |
|
| 314 | + } |
|
| 265 | 315 | } |
| 266 | 316 | |
| 267 | 317 | // User change (old method using already loaded object and not id is kept for backward compatibility) |
| 268 | 318 | if (! empty($object->user_modification) || ! empty($object->user_modification_id)) |
| 269 | 319 | {
|
| 270 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 320 | + if ($usetable) { |
|
| 321 | + print '<tr><td class="titlefield">'; |
|
| 322 | + } |
|
| 271 | 323 | print $langs->trans("ModifiedBy");
|
| 272 | - if ($usetable) print '</td><td>'; |
|
| 273 | - else print ': '; |
|
| 324 | + if ($usetable) { |
|
| 325 | + print '</td><td>'; |
|
| 326 | + } else { |
|
| 327 | + print ': '; |
|
| 328 | + } |
|
| 274 | 329 | if (is_object($object->user_modification)) |
| 275 | 330 | {
|
| 276 | - if ($object->user_modification->id) print $object->user_modification->getNomUrl(1, '', 0, 0, 0); |
|
| 277 | - else print $langs->trans("Unknown");
|
|
| 278 | - } |
|
| 279 | - else |
|
| 331 | + if ($object->user_modification->id) { |
|
| 332 | + print $object->user_modification->getNomUrl(1, '', 0, 0, 0); |
|
| 333 | + } else { |
|
| 334 | + print $langs->trans("Unknown"); |
|
| 335 | + } |
|
| 336 | + } else |
|
| 280 | 337 | {
|
| 281 | 338 | $userstatic=new User($db); |
| 282 | 339 | $userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification); |
| 283 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
| 284 | - else print $langs->trans("Unknown");
|
|
| 340 | + if ($userstatic->id) { |
|
| 341 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
| 342 | + } else { |
|
| 343 | + print $langs->trans("Unknown"); |
|
| 344 | + } |
|
| 285 | 345 | } |
| 286 | - if ($usetable) print '</td></tr>'; |
|
| 287 | - else print '<br>'; |
|
| 346 | + if ($usetable) { |
|
| 347 | + print '</td></tr>'; |
|
| 348 | + } else { |
|
| 349 | + print '<br>'; |
|
| 350 | + } |
|
| 288 | 351 | } |
| 289 | 352 | |
| 290 | 353 | // Date change |
| 291 | 354 | if (! empty($object->date_modification)) |
| 292 | 355 | {
|
| 293 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 356 | + if ($usetable) { |
|
| 357 | + print '<tr><td class="titlefield">'; |
|
| 358 | + } |
|
| 294 | 359 | print $langs->trans("DateLastModification");
|
| 295 | - if ($usetable) print '</td><td>'; |
|
| 296 | - else print ': '; |
|
| 360 | + if ($usetable) { |
|
| 361 | + print '</td><td>'; |
|
| 362 | + } else { |
|
| 363 | + print ': '; |
|
| 364 | + } |
|
| 297 | 365 | print dol_print_date($object->date_modification, 'dayhour'); |
| 298 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_modification+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
|
|
| 299 | - if ($usetable) print '</td></tr>'; |
|
| 300 | - else print '<br>'; |
|
| 366 | + if ($deltadateforuser) { |
|
| 367 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_modification+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
| 368 | + } |
|
| 369 | + if ($usetable) { |
|
| 370 | + print '</td></tr>'; |
|
| 371 | + } else { |
|
| 372 | + print '<br>'; |
|
| 373 | + } |
|
| 301 | 374 | } |
| 302 | 375 | |
| 303 | 376 | // User validation (old method using already loaded object and not id is kept for backward compatibility) |
| 304 | 377 | if (! empty($object->user_validation) || ! empty($object->user_validation_id)) |
| 305 | 378 | {
|
| 306 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 379 | + if ($usetable) { |
|
| 380 | + print '<tr><td class="titlefield">'; |
|
| 381 | + } |
|
| 307 | 382 | print $langs->trans("ValidatedBy");
|
| 308 | - if ($usetable) print '</td><td>'; |
|
| 309 | - else print ': '; |
|
| 383 | + if ($usetable) { |
|
| 384 | + print '</td><td>'; |
|
| 385 | + } else { |
|
| 386 | + print ': '; |
|
| 387 | + } |
|
| 310 | 388 | if (is_object($object->user_validation)) |
| 311 | 389 | {
|
| 312 | - if ($object->user_validation->id) print $object->user_validation->getNomUrl(1, '', 0, 0, 0); |
|
| 313 | - else print $langs->trans("Unknown");
|
|
| 314 | - } |
|
| 315 | - else |
|
| 390 | + if ($object->user_validation->id) { |
|
| 391 | + print $object->user_validation->getNomUrl(1, '', 0, 0, 0); |
|
| 392 | + } else { |
|
| 393 | + print $langs->trans("Unknown"); |
|
| 394 | + } |
|
| 395 | + } else |
|
| 316 | 396 | {
|
| 317 | 397 | $userstatic=new User($db); |
| 318 | 398 | $userstatic->fetch($object->user_validation_id ? $object->user_validation_id : $object->user_validation); |
| 319 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
| 320 | - else print $langs->trans("Unknown");
|
|
| 399 | + if ($userstatic->id) { |
|
| 400 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
| 401 | + } else { |
|
| 402 | + print $langs->trans("Unknown"); |
|
| 403 | + } |
|
| 321 | 404 | } |
| 322 | - if ($usetable) print '</td></tr>'; |
|
| 323 | - else print '<br>'; |
|
| 405 | + if ($usetable) { |
|
| 406 | + print '</td></tr>'; |
|
| 407 | + } else { |
|
| 408 | + print '<br>'; |
|
| 409 | + } |
|
| 324 | 410 | } |
| 325 | 411 | |
| 326 | 412 | // Date validation |
| 327 | 413 | if (! empty($object->date_validation)) |
| 328 | 414 | {
|
| 329 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 415 | + if ($usetable) { |
|
| 416 | + print '<tr><td class="titlefield">'; |
|
| 417 | + } |
|
| 330 | 418 | print $langs->trans("DateValidation");
|
| 331 | - if ($usetable) print '</td><td>'; |
|
| 332 | - else print ': '; |
|
| 419 | + if ($usetable) { |
|
| 420 | + print '</td><td>'; |
|
| 421 | + } else { |
|
| 422 | + print ': '; |
|
| 423 | + } |
|
| 333 | 424 | print dol_print_date($object->date_validation, 'dayhour'); |
| 334 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_validation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
|
|
| 335 | - if ($usetable) print '</td></tr>'; |
|
| 336 | - else print '<br>'; |
|
| 425 | + if ($deltadateforuser) { |
|
| 426 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_validation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
| 427 | + } |
|
| 428 | + if ($usetable) { |
|
| 429 | + print '</td></tr>'; |
|
| 430 | + } else { |
|
| 431 | + print '<br>'; |
|
| 432 | + } |
|
| 337 | 433 | } |
| 338 | 434 | |
| 339 | 435 | // User approve (old method using already loaded object and not id is kept for backward compatibility) |
| 340 | 436 | if (! empty($object->user_approve) || ! empty($object->user_approve_id)) |
| 341 | 437 | {
|
| 342 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 438 | + if ($usetable) { |
|
| 439 | + print '<tr><td class="titlefield">'; |
|
| 440 | + } |
|
| 343 | 441 | print $langs->trans("ApprovedBy");
|
| 344 | - if ($usetable) print '</td><td>'; |
|
| 345 | - else print ': '; |
|
| 442 | + if ($usetable) { |
|
| 443 | + print '</td><td>'; |
|
| 444 | + } else { |
|
| 445 | + print ': '; |
|
| 446 | + } |
|
| 346 | 447 | if (is_object($object->user_approve)) |
| 347 | 448 | {
|
| 348 | - if ($object->user_approve->id) print $object->user_approve->getNomUrl(1, '', 0, 0, 0); |
|
| 349 | - else print $langs->trans("Unknown");
|
|
| 350 | - } |
|
| 351 | - else |
|
| 449 | + if ($object->user_approve->id) { |
|
| 450 | + print $object->user_approve->getNomUrl(1, '', 0, 0, 0); |
|
| 451 | + } else { |
|
| 452 | + print $langs->trans("Unknown"); |
|
| 453 | + } |
|
| 454 | + } else |
|
| 352 | 455 | {
|
| 353 | 456 | $userstatic=new User($db); |
| 354 | 457 | $userstatic->fetch($object->user_approve_id ? $object->user_approve_id : $object->user_approve); |
| 355 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
| 356 | - else print $langs->trans("Unknown");
|
|
| 458 | + if ($userstatic->id) { |
|
| 459 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
| 460 | + } else { |
|
| 461 | + print $langs->trans("Unknown"); |
|
| 462 | + } |
|
| 357 | 463 | } |
| 358 | - if ($usetable) print '</td></tr>'; |
|
| 359 | - else print '<br>'; |
|
| 464 | + if ($usetable) { |
|
| 465 | + print '</td></tr>'; |
|
| 466 | + } else { |
|
| 467 | + print '<br>'; |
|
| 468 | + } |
|
| 360 | 469 | } |
| 361 | 470 | |
| 362 | 471 | // Date approve |
| 363 | 472 | if (! empty($object->date_approve)) |
| 364 | 473 | {
|
| 365 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 474 | + if ($usetable) { |
|
| 475 | + print '<tr><td class="titlefield">'; |
|
| 476 | + } |
|
| 366 | 477 | print $langs->trans("DateApprove");
|
| 367 | - if ($usetable) print '</td><td>'; |
|
| 368 | - else print ': '; |
|
| 478 | + if ($usetable) { |
|
| 479 | + print '</td><td>'; |
|
| 480 | + } else { |
|
| 481 | + print ': '; |
|
| 482 | + } |
|
| 369 | 483 | print dol_print_date($object->date_approve, 'dayhour'); |
| 370 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
|
|
| 371 | - if ($usetable) print '</td></tr>'; |
|
| 372 | - else print '<br>'; |
|
| 484 | + if ($deltadateforuser) { |
|
| 485 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
| 486 | + } |
|
| 487 | + if ($usetable) { |
|
| 488 | + print '</td></tr>'; |
|
| 489 | + } else { |
|
| 490 | + print '<br>'; |
|
| 491 | + } |
|
| 373 | 492 | } |
| 374 | 493 | |
| 375 | 494 | // User approve |
| 376 | 495 | if (! empty($object->user_approve_id2)) |
| 377 | 496 | {
|
| 378 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 497 | + if ($usetable) { |
|
| 498 | + print '<tr><td class="titlefield">'; |
|
| 499 | + } |
|
| 379 | 500 | print $langs->trans("ApprovedBy");
|
| 380 | - if ($usetable) print '</td><td>'; |
|
| 381 | - else print ': '; |
|
| 501 | + if ($usetable) { |
|
| 502 | + print '</td><td>'; |
|
| 503 | + } else { |
|
| 504 | + print ': '; |
|
| 505 | + } |
|
| 382 | 506 | $userstatic=new User($db); |
| 383 | 507 | $userstatic->fetch($object->user_approve_id2); |
| 384 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
| 385 | - else print $langs->trans("Unknown");
|
|
| 386 | - if ($usetable) print '</td></tr>'; |
|
| 387 | - else print '<br>'; |
|
| 508 | + if ($userstatic->id) { |
|
| 509 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
| 510 | + } else { |
|
| 511 | + print $langs->trans("Unknown"); |
|
| 512 | + } |
|
| 513 | + if ($usetable) { |
|
| 514 | + print '</td></tr>'; |
|
| 515 | + } else { |
|
| 516 | + print '<br>'; |
|
| 517 | + } |
|
| 388 | 518 | } |
| 389 | 519 | |
| 390 | 520 | // Date approve |
| 391 | 521 | if (! empty($object->date_approve2)) |
| 392 | 522 | {
|
| 393 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 523 | + if ($usetable) { |
|
| 524 | + print '<tr><td class="titlefield">'; |
|
| 525 | + } |
|
| 394 | 526 | print $langs->trans("DateApprove2");
|
| 395 | - if ($usetable) print '</td><td>'; |
|
| 396 | - else print ': '; |
|
| 527 | + if ($usetable) { |
|
| 528 | + print '</td><td>'; |
|
| 529 | + } else { |
|
| 530 | + print ': '; |
|
| 531 | + } |
|
| 397 | 532 | print dol_print_date($object->date_approve2, 'dayhour'); |
| 398 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve2+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
|
|
| 399 | - if ($usetable) print '</td></tr>'; |
|
| 400 | - else print '<br>'; |
|
| 533 | + if ($deltadateforuser) { |
|
| 534 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve2+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
| 535 | + } |
|
| 536 | + if ($usetable) { |
|
| 537 | + print '</td></tr>'; |
|
| 538 | + } else { |
|
| 539 | + print '<br>'; |
|
| 540 | + } |
|
| 401 | 541 | } |
| 402 | 542 | |
| 403 | 543 | // User close |
| 404 | 544 | if (! empty($object->user_cloture)) |
| 405 | 545 | {
|
| 406 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 546 | + if ($usetable) { |
|
| 547 | + print '<tr><td class="titlefield">'; |
|
| 548 | + } |
|
| 407 | 549 | print $langs->trans("ClosedBy");
|
| 408 | - if ($usetable) print '</td><td>'; |
|
| 409 | - else print ': '; |
|
| 550 | + if ($usetable) { |
|
| 551 | + print '</td><td>'; |
|
| 552 | + } else { |
|
| 553 | + print ': '; |
|
| 554 | + } |
|
| 410 | 555 | if (is_object($object->user_cloture)) |
| 411 | 556 | {
|
| 412 | - if ($object->user_cloture->id) print $object->user_cloture->getNomUrl(1, '', 0, 0, 0); |
|
| 413 | - else print $langs->trans("Unknown");
|
|
| 414 | - } |
|
| 415 | - else |
|
| 557 | + if ($object->user_cloture->id) { |
|
| 558 | + print $object->user_cloture->getNomUrl(1, '', 0, 0, 0); |
|
| 559 | + } else { |
|
| 560 | + print $langs->trans("Unknown"); |
|
| 561 | + } |
|
| 562 | + } else |
|
| 416 | 563 | {
|
| 417 | 564 | $userstatic=new User($db); |
| 418 | 565 | $userstatic->fetch($object->user_cloture); |
| 419 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
| 420 | - else print $langs->trans("Unknown");
|
|
| 566 | + if ($userstatic->id) { |
|
| 567 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
| 568 | + } else { |
|
| 569 | + print $langs->trans("Unknown"); |
|
| 570 | + } |
|
| 421 | 571 | } |
| 422 | - if ($usetable) print '</td></tr>'; |
|
| 423 | - else print '<br>'; |
|
| 572 | + if ($usetable) { |
|
| 573 | + print '</td></tr>'; |
|
| 574 | + } else { |
|
| 575 | + print '<br>'; |
|
| 576 | + } |
|
| 424 | 577 | } |
| 425 | 578 | |
| 426 | 579 | // Date close |
| 427 | 580 | if (! empty($object->date_cloture)) |
| 428 | 581 | {
|
| 429 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 582 | + if ($usetable) { |
|
| 583 | + print '<tr><td class="titlefield">'; |
|
| 584 | + } |
|
| 430 | 585 | print $langs->trans("DateClosing");
|
| 431 | - if ($usetable) print '</td><td>'; |
|
| 432 | - else print ': '; |
|
| 586 | + if ($usetable) { |
|
| 587 | + print '</td><td>'; |
|
| 588 | + } else { |
|
| 589 | + print ': '; |
|
| 590 | + } |
|
| 433 | 591 | print dol_print_date($object->date_cloture, 'dayhour'); |
| 434 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_cloture+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
|
|
| 435 | - if ($usetable) print '</td></tr>'; |
|
| 436 | - else print '<br>'; |
|
| 592 | + if ($deltadateforuser) { |
|
| 593 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_cloture+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
| 594 | + } |
|
| 595 | + if ($usetable) { |
|
| 596 | + print '</td></tr>'; |
|
| 597 | + } else { |
|
| 598 | + print '<br>'; |
|
| 599 | + } |
|
| 437 | 600 | } |
| 438 | 601 | |
| 439 | 602 | // User conciliate |
| 440 | 603 | if (! empty($object->user_rappro)) |
| 441 | 604 | {
|
| 442 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 605 | + if ($usetable) { |
|
| 606 | + print '<tr><td class="titlefield">'; |
|
| 607 | + } |
|
| 443 | 608 | print $langs->trans("ConciliatedBy");
|
| 444 | - if ($usetable) print '</td><td>'; |
|
| 445 | - else print ': '; |
|
| 609 | + if ($usetable) { |
|
| 610 | + print '</td><td>'; |
|
| 611 | + } else { |
|
| 612 | + print ': '; |
|
| 613 | + } |
|
| 446 | 614 | if (is_object($object->user_rappro)) |
| 447 | 615 | {
|
| 448 | - if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(1, '', 0, 0, 0); |
|
| 449 | - else print $langs->trans("Unknown");
|
|
| 450 | - } |
|
| 451 | - else |
|
| 616 | + if ($object->user_rappro->id) { |
|
| 617 | + print $object->user_rappro->getNomUrl(1, '', 0, 0, 0); |
|
| 618 | + } else { |
|
| 619 | + print $langs->trans("Unknown"); |
|
| 620 | + } |
|
| 621 | + } else |
|
| 452 | 622 | {
|
| 453 | 623 | $userstatic=new User($db); |
| 454 | 624 | $userstatic->fetch($object->user_rappro); |
| 455 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
| 456 | - else print $langs->trans("Unknown");
|
|
| 625 | + if ($userstatic->id) { |
|
| 626 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
| 627 | + } else { |
|
| 628 | + print $langs->trans("Unknown"); |
|
| 629 | + } |
|
| 457 | 630 | } |
| 458 | - if ($usetable) print '</td></tr>'; |
|
| 459 | - else print '<br>'; |
|
| 631 | + if ($usetable) { |
|
| 632 | + print '</td></tr>'; |
|
| 633 | + } else { |
|
| 634 | + print '<br>'; |
|
| 635 | + } |
|
| 460 | 636 | } |
| 461 | 637 | |
| 462 | 638 | // Date conciliate |
| 463 | 639 | if (! empty($object->date_rappro)) |
| 464 | 640 | {
|
| 465 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 641 | + if ($usetable) { |
|
| 642 | + print '<tr><td class="titlefield">'; |
|
| 643 | + } |
|
| 466 | 644 | print $langs->trans("DateConciliating");
|
| 467 | - if ($usetable) print '</td><td>'; |
|
| 468 | - else print ': '; |
|
| 645 | + if ($usetable) { |
|
| 646 | + print '</td><td>'; |
|
| 647 | + } else { |
|
| 648 | + print ': '; |
|
| 649 | + } |
|
| 469 | 650 | print dol_print_date($object->date_rappro, 'dayhour'); |
| 470 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_rappro+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
|
|
| 471 | - if ($usetable) print '</td></tr>'; |
|
| 472 | - else print '<br>'; |
|
| 651 | + if ($deltadateforuser) { |
|
| 652 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_rappro+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
| 653 | + } |
|
| 654 | + if ($usetable) { |
|
| 655 | + print '</td></tr>'; |
|
| 656 | + } else { |
|
| 657 | + print '<br>'; |
|
| 658 | + } |
|
| 473 | 659 | } |
| 474 | 660 | |
| 475 | 661 | // Date send |
| 476 | 662 | if (! empty($object->date_envoi)) |
| 477 | 663 | {
|
| 478 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
| 664 | + if ($usetable) { |
|
| 665 | + print '<tr><td class="titlefield">'; |
|
| 666 | + } |
|
| 479 | 667 | print $langs->trans("DateLastSend");
|
| 480 | - if ($usetable) print '</td><td>'; |
|
| 481 | - else print ': '; |
|
| 668 | + if ($usetable) { |
|
| 669 | + print '</td><td>'; |
|
| 670 | + } else { |
|
| 671 | + print ': '; |
|
| 672 | + } |
|
| 482 | 673 | print dol_print_date($object->date_envoi, 'dayhour'); |
| 483 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_envoi+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
|
|
| 484 | - if ($usetable) print '</td></tr>'; |
|
| 485 | - else print '<br>'; |
|
| 674 | + if ($deltadateforuser) { |
|
| 675 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_envoi+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
| 676 | + } |
|
| 677 | + if ($usetable) { |
|
| 678 | + print '</td></tr>'; |
|
| 679 | + } else { |
|
| 680 | + print '<br>'; |
|
| 681 | + } |
|
| 486 | 682 | } |
| 487 | 683 | |
| 488 | - if ($usetable) print '</table>'; |
|
| 489 | -} |
|
| 684 | + if ($usetable) { |
|
| 685 | + print '</table>'; |
|
| 686 | + } |
|
| 687 | + } |
|
| 490 | 688 | |
| 491 | 689 | |
| 492 | 690 | /** |
@@ -515,8 +713,7 @@ discard block |
||
| 515 | 713 | if (checkdnsrr($domain, "MX")) |
| 516 | 714 | {
|
| 517 | 715 | return true; |
| 518 | - } |
|
| 519 | - else |
|
| 716 | + } else |
|
| 520 | 717 | {
|
| 521 | 718 | return false; |
| 522 | 719 | } |
@@ -541,10 +738,14 @@ discard block |
||
| 541 | 738 | $urlregex = ''; |
| 542 | 739 | |
| 543 | 740 | // SCHEME |
| 544 | - if ($http) $urlregex .= "^(http:\/\/|https:\/\/)"; |
|
| 741 | + if ($http) { |
|
| 742 | + $urlregex .= "^(http:\/\/|https:\/\/)"; |
|
| 743 | + } |
|
| 545 | 744 | |
| 546 | 745 | // USER AND PASS |
| 547 | - if ($pass) $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)"; |
|
| 746 | + if ($pass) { |
|
| 747 | + $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)"; |
|
| 748 | + } |
|
| 548 | 749 | |
| 549 | 750 | // HOSTNAME OR IP |
| 550 | 751 | //$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*"; // x allowed (ex. http://localhost, http://routerlogin) |
@@ -553,13 +754,21 @@ discard block |
||
| 553 | 754 | //use only one of the above |
| 554 | 755 | |
| 555 | 756 | // PORT |
| 556 | - if ($port) $urlregex .= "(\:[0-9]{2,5})";
|
|
| 757 | + if ($port) { |
|
| 758 | + $urlregex .= "(\:[0-9]{2,5})"; |
|
| 759 | + } |
|
| 557 | 760 | // PATH |
| 558 | - if ($path) $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/"; |
|
| 761 | + if ($path) { |
|
| 762 | + $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/"; |
|
| 763 | + } |
|
| 559 | 764 | // GET Query |
| 560 | - if ($query) $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@\/&%=+\$_.-]*)"; |
|
| 765 | + if ($query) { |
|
| 766 | + $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@\/&%=+\$_.-]*)"; |
|
| 767 | + } |
|
| 561 | 768 | // ANCHOR |
| 562 | - if ($anchor) $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)$"; |
|
| 769 | + if ($anchor) { |
|
| 770 | + $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)$"; |
|
| 771 | + } |
|
| 563 | 772 | |
| 564 | 773 | // check |
| 565 | 774 | if (preg_match('/'.$urlregex.'/i', $url))
|
@@ -607,9 +816,10 @@ discard block |
||
| 607 | 816 | $CleanUrl = preg_replace('/^'.preg_quote($proto.$domain,'/').'/i', $newproto.strtolower($domain), $url);
|
| 608 | 817 | |
| 609 | 818 | return $CleanUrl; |
| 819 | + } else { |
|
| 820 | + return $url; |
|
| 821 | + } |
|
| 610 | 822 | } |
| 611 | - else return $url; |
|
| 612 | -} |
|
| 613 | 823 | |
| 614 | 824 | |
| 615 | 825 | |
@@ -626,7 +836,9 @@ discard block |
||
| 626 | 836 | */ |
| 627 | 837 | function dolObfuscateEmail($mail, $replace="*", $nbreplace=8, $nbdisplaymail=4, $nbdisplaydomain=3, $displaytld=true) |
| 628 | 838 | {
|
| 629 | - if(!isValidEmail($mail))return ''; |
|
| 839 | + if(!isValidEmail($mail)) { |
|
| 840 | + return ''; |
|
| 841 | + } |
|
| 630 | 842 | $tab = explode('@', $mail);
|
| 631 | 843 | $tab2 = explode('.',$tab[1]);
|
| 632 | 844 | $string_replace = ''; |
@@ -688,7 +900,9 @@ discard block |
||
| 688 | 900 | function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdoptions='') |
| 689 | 901 | {
|
| 690 | 902 | $text='' ; |
| 691 | - if($tableMarkup) $text = '<table '.$tableoptions.'>' ; |
|
| 903 | + if($tableMarkup) { |
|
| 904 | + $text = '<table '.$tableoptions.'>' ; |
|
| 905 | + } |
|
| 692 | 906 | foreach($data as $key => $item){
|
| 693 | 907 | if(is_array($item)){
|
| 694 | 908 | $text.=array2tr($item,$troptions,$tdoptions); |
@@ -699,7 +913,9 @@ discard block |
||
| 699 | 913 | $text.= '</tr>' ; |
| 700 | 914 | } |
| 701 | 915 | } |
| 702 | - if($tableMarkup) $text.= '</table>' ; |
|
| 916 | + if($tableMarkup) { |
|
| 917 | + $text.= '</table>' ; |
|
| 918 | + } |
|
| 703 | 919 | return $text ; |
| 704 | 920 | } |
| 705 | 921 | |
@@ -723,15 +939,25 @@ discard block |
||
| 723 | 939 | {
|
| 724 | 940 | global $conf,$user; |
| 725 | 941 | |
| 726 | - if (! is_object($objsoc)) $valueforccc=$objsoc; |
|
| 727 | - else if ($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=$objsoc->code_fournisseur; |
|
| 728 | - else $valueforccc=$objsoc->code_client; |
|
| 942 | + if (! is_object($objsoc)) { |
|
| 943 | + $valueforccc=$objsoc; |
|
| 944 | + } else if ($table == "commande_fournisseur" || $table == "facture_fourn" ) { |
|
| 945 | + $valueforccc=$objsoc->code_fournisseur; |
|
| 946 | + } else { |
|
| 947 | + $valueforccc=$objsoc->code_client; |
|
| 948 | + } |
|
| 729 | 949 | |
| 730 | 950 | $sharetable = $table; |
| 731 | - if ($table == 'facture' || $table == 'invoice') $sharetable = 'invoicenumber'; // for getEntity function |
|
| 951 | + if ($table == 'facture' || $table == 'invoice') { |
|
| 952 | + $sharetable = 'invoicenumber'; |
|
| 953 | + } |
|
| 954 | + // for getEntity function |
|
| 732 | 955 | |
| 733 | 956 | // Clean parameters |
| 734 | - if ($date == '') $date=dol_now(); // We use local year and month of PHP server to search numbers |
|
| 957 | + if ($date == '') { |
|
| 958 | + $date=dol_now(); |
|
| 959 | + } |
|
| 960 | + // We use local year and month of PHP server to search numbers |
|
| 735 | 961 | // but we should use local year and month of user |
| 736 | 962 | |
| 737 | 963 | // For debugging |
@@ -748,8 +974,7 @@ discard block |
||
| 748 | 974 | $masktri=$reg[1].(! empty($reg[2])?$reg[2]:'').(! empty($reg[3])?$reg[3]:''); |
| 749 | 975 | $maskcounter=$reg[1]; |
| 750 | 976 | $hasglobalcounter=true; |
| 751 | - } |
|
| 752 | - else |
|
| 977 | + } else |
|
| 753 | 978 | {
|
| 754 | 979 | // setting some defaults so the rest of the code won't fail if there is a third party counter |
| 755 | 980 | $masktri='00000'; |
@@ -759,8 +984,9 @@ discard block |
||
| 759 | 984 | $maskraz=-1; |
| 760 | 985 | $maskoffset=0; |
| 761 | 986 | $resetEveryMonth=false; |
| 762 | - if (dol_strlen($maskcounter) < 3 && empty(Globals::$conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) |
|
| 763 | - return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
| 987 | + if (dol_strlen($maskcounter) < 3 && empty(Globals::$conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) { |
|
| 988 | + return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
| 989 | + } |
|
| 764 | 990 | |
| 765 | 991 | // Extract value for third party mask counter |
| 766 | 992 | if (preg_match('/\{(c+)(0*)\}/i',$mask,$regClientRef))
|
@@ -772,9 +998,12 @@ discard block |
||
| 772 | 998 | $maskrefclient_clientcode=substr($valueforccc,0,dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code where n is length in mask |
| 773 | 999 | $maskrefclient_clientcode=str_pad($maskrefclient_clientcode,dol_strlen($maskrefclient_maskclientcode),"#",STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode |
| 774 | 1000 | $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like |
| 775 | - if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
| 776 | - } |
|
| 777 | - else $maskrefclient=''; |
|
| 1001 | + if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) { |
|
| 1002 | + return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
| 1003 | + } |
|
| 1004 | + } else { |
|
| 1005 | + $maskrefclient=''; |
|
| 1006 | + } |
|
| 778 | 1007 | |
| 779 | 1008 | // fail if there is neither a global nor a third party counter |
| 780 | 1009 | if (! $hasglobalcounter && ($maskrefclient_maskcounter == '')) |
@@ -788,8 +1017,7 @@ discard block |
||
| 788 | 1017 | $masktype=$regType[1]; |
| 789 | 1018 | $masktype_value=substr(preg_replace('/^TE_/','',$objsoc->typent_code),0,dol_strlen($regType[1]));// get n first characters of thirdpaty typent_code (where n is length in mask)
|
| 790 | 1019 | $masktype_value=str_pad($masktype_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask |
| 791 | - } |
|
| 792 | - else |
|
| 1020 | + } else |
|
| 793 | 1021 | {
|
| 794 | 1022 | $masktype=''; |
| 795 | 1023 | $masktype_value=''; |
@@ -799,13 +1027,14 @@ discard block |
||
| 799 | 1027 | if (preg_match('/\{(u+)\}/i',$mask,$regType))
|
| 800 | 1028 | {
|
| 801 | 1029 | $lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; |
| 802 | - if (is_object($objuser)) $lastname = $objuser->lastname; |
|
| 1030 | + if (is_object($objuser)) { |
|
| 1031 | + $lastname = $objuser->lastname; |
|
| 1032 | + } |
|
| 803 | 1033 | |
| 804 | 1034 | $maskuser=$regType[1]; |
| 805 | 1035 | $maskuser_value=substr($lastname,0,dol_strlen($regType[1]));// get n first characters of user firstname (where n is length in mask) |
| 806 | 1036 | $maskuser_value=str_pad($maskuser_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask |
| 807 | - } |
|
| 808 | - else |
|
| 1037 | + } else |
|
| 809 | 1038 | {
|
| 810 | 1039 | $maskuser=''; |
| 811 | 1040 | $maskuser_value=''; |
@@ -852,8 +1081,12 @@ discard block |
||
| 852 | 1081 | //var_dump($reg); |
| 853 | 1082 | |
| 854 | 1083 | // If an offset is asked |
| 855 | - if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) $maskoffset=preg_replace('/^\+/','',$reg[2]);
|
|
| 856 | - if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) $maskoffset=preg_replace('/^\+/','',$reg[3]);
|
|
| 1084 | + if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) { |
|
| 1085 | + $maskoffset=preg_replace('/^\+/','',$reg[2]); |
|
| 1086 | + } |
|
| 1087 | + if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) { |
|
| 1088 | + $maskoffset=preg_replace('/^\+/','',$reg[3]); |
|
| 1089 | + } |
|
| 857 | 1090 | |
| 858 | 1091 | // Define $sqlwhere |
| 859 | 1092 | $sqlwhere=''; |
@@ -861,14 +1094,21 @@ discard block |
||
| 861 | 1094 | $yearoffsettype=false; // false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x |
| 862 | 1095 | |
| 863 | 1096 | // If a restore to zero after a month is asked we check if there is already a value for this year. |
| 864 | - if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) $yearoffsettype = preg_replace('/^@/','',$reg[2]);
|
|
| 865 | - if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) $yearoffsettype = preg_replace('/^@/','',$reg[3]);
|
|
| 1097 | + if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) { |
|
| 1098 | + $yearoffsettype = preg_replace('/^@/','',$reg[2]); |
|
| 1099 | + } |
|
| 1100 | + if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) { |
|
| 1101 | + $yearoffsettype = preg_replace('/^@/','',$reg[3]); |
|
| 1102 | + } |
|
| 866 | 1103 | |
| 867 | 1104 | //print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype; |
| 868 | - if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) |
|
| 869 | - $maskraz=$yearoffsettype; // For backward compatibility |
|
| 870 | - else if ($yearoffsettype === '0' || (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && Globals::$conf->global->SOCIETE_FISCAL_MONTH_START > 1)) |
|
| 871 | - $maskraz = Globals::$conf->global->SOCIETE_FISCAL_MONTH_START; |
|
| 1105 | + if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) { |
|
| 1106 | + $maskraz=$yearoffsettype; |
|
| 1107 | + } |
|
| 1108 | + // For backward compatibility |
|
| 1109 | + else if ($yearoffsettype === '0' || (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && Globals::$conf->global->SOCIETE_FISCAL_MONTH_START > 1)) { |
|
| 1110 | + $maskraz = Globals::$conf->global->SOCIETE_FISCAL_MONTH_START; |
|
| 1111 | + } |
|
| 872 | 1112 | //print "maskraz=".$maskraz; // -1=no reset |
| 873 | 1113 | |
| 874 | 1114 | if ($maskraz > 0) { // A reset is required
|
@@ -876,23 +1116,28 @@ discard block |
||
| 876 | 1116 | $maskraz = date('m', $date);
|
| 877 | 1117 | $resetEveryMonth = true; |
| 878 | 1118 | } |
| 879 | - if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; |
|
| 1119 | + if ($maskraz > 12) { |
|
| 1120 | + return 'ErrorBadMaskBadRazMonth'; |
|
| 1121 | + } |
|
| 880 | 1122 | |
| 881 | 1123 | // Define posy, posm and reg |
| 882 | - if ($maskraz > 1) // if reset is not first month, we need month and year into mask |
|
| 1124 | + if ($maskraz > 1) { |
|
| 1125 | + // if reset is not first month, we need month and year into mask |
|
| 883 | 1126 | {
|
| 884 | - if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; }
|
|
| 885 | - elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; }
|
|
| 886 | - else return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; |
|
| 887 | - |
|
| 888 | - if (dol_strlen($reg[$posy]) < 2) return 'ErrorCantUseRazWithYearOnOneDigit'; |
|
| 889 | - } |
|
| 890 | - else // if reset is for a specific month in year, we need year |
|
| 1127 | + if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; |
|
| 1128 | + } |
|
| 1129 | + $posm=3; } elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } else { |
|
| 1130 | + return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; |
|
| 1131 | + } |
|
| 1132 | + |
|
| 1133 | + if (dol_strlen($reg[$posy]) < 2) { |
|
| 1134 | + return 'ErrorCantUseRazWithYearOnOneDigit'; |
|
| 1135 | + } |
|
| 1136 | + } else // if reset is for a specific month in year, we need year |
|
| 891 | 1137 | {
|
| 892 | - if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; }
|
|
| 893 | - else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; }
|
|
| 894 | - else if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; }
|
|
| 895 | - else return 'ErrorCantUseRazIfNoYearInMask'; |
|
| 1138 | + if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } else if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; } else { |
|
| 1139 | + return 'ErrorCantUseRazIfNoYearInMask'; |
|
| 1140 | + } |
|
| 896 | 1141 | } |
| 897 | 1142 | // Define length |
| 898 | 1143 | $yearlen = $posy?dol_strlen($reg[$posy]):0; |
@@ -910,9 +1155,11 @@ discard block |
||
| 910 | 1155 | $monthcomp=$maskraz; |
| 911 | 1156 | $yearcomp=0; |
| 912 | 1157 | |
| 913 | - if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // $yearoffsettype is - or + |
|
| 1158 | + if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') { |
|
| 1159 | + // $yearoffsettype is - or + |
|
| 914 | 1160 | {
|
| 915 | - $currentyear=date("Y", $date);
|
|
| 1161 | + $currentyear=date("Y", $date); |
|
| 1162 | + } |
|
| 916 | 1163 | $fiscaldate=dol_mktime('0','0','0',$maskraz,'1',$currentyear);
|
| 917 | 1164 | $newyeardate=dol_mktime('0','0','0','1','1',$currentyear);
|
| 918 | 1165 | $nextnewyeardate=dol_mktime('0','0','0','1','1',$currentyear+1);
|
@@ -922,21 +1169,32 @@ discard block |
||
| 922 | 1169 | if ($date >= $fiscaldate) |
| 923 | 1170 | {
|
| 924 | 1171 | // If before of next new year date |
| 925 | - if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset=1; |
|
| 1172 | + if ($date < $nextnewyeardate && $yearoffsettype == '+') { |
|
| 1173 | + $yearoffset=1; |
|
| 1174 | + } |
|
| 926 | 1175 | } |
| 927 | 1176 | // If after or equal of current new year date |
| 928 | - else if ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset=-1; |
|
| 1177 | + else if ($date >= $newyeardate && $yearoffsettype == '-') { |
|
| 1178 | + $yearoffset=-1; |
|
| 1179 | + } |
|
| 929 | 1180 | } |
| 930 | 1181 | // For backward compatibility |
| 931 | 1182 | else if (date("m",$date) < $maskraz && empty($resetEveryMonth)) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year
|
| 932 | 1183 | |
| 933 | - if ($yearlen == 4) $yearcomp=sprintf("%04d",date("Y",$date)+$yearoffset);
|
|
| 934 | - elseif ($yearlen == 2) $yearcomp=sprintf("%02d",date("y",$date)+$yearoffset);
|
|
| 935 | - elseif ($yearlen == 1) $yearcomp=substr(date("y",$date),2,1)+$yearoffset;
|
|
| 936 | - if ($monthcomp > 1 && empty($resetEveryMonth)) // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) |
|
| 1184 | + if ($yearlen == 4) { |
|
| 1185 | + $yearcomp=sprintf("%04d",date("Y",$date)+$yearoffset); |
|
| 1186 | + } elseif ($yearlen == 2) { |
|
| 1187 | + $yearcomp=sprintf("%02d",date("y",$date)+$yearoffset); |
|
| 1188 | + } elseif ($yearlen == 1) { |
|
| 1189 | + $yearcomp=substr(date("y",$date),2,1)+$yearoffset; |
|
| 1190 | + } |
|
| 1191 | + if ($monthcomp > 1 && empty($resetEveryMonth)) { |
|
| 1192 | + // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) |
|
| 937 | 1193 | {
|
| 938 | - if ($yearlen == 4) $yearcomp1=sprintf("%04d",date("Y",$date)+$yearoffset+1);
|
|
| 939 | - elseif ($yearlen == 2) $yearcomp1=sprintf("%02d",date("y",$date)+$yearoffset+1);
|
|
| 1194 | + if ($yearlen == 4) $yearcomp1=sprintf("%04d",date("Y",$date)+$yearoffset+1); |
|
| 1195 | + } elseif ($yearlen == 2) { |
|
| 1196 | + $yearcomp1=sprintf("%02d",date("y",$date)+$yearoffset+1); |
|
| 1197 | + } |
|
| 940 | 1198 | |
| 941 | 1199 | $sqlwhere.="(";
|
| 942 | 1200 | $sqlwhere.=" (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'";
|
@@ -945,13 +1203,11 @@ discard block |
||
| 945 | 1203 | $sqlwhere.=" (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp1."'";
|
| 946 | 1204 | $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") < '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."') ";
|
| 947 | 1205 | $sqlwhere.=')'; |
| 948 | - } |
|
| 949 | - else if ($resetEveryMonth) |
|
| 1206 | + } else if ($resetEveryMonth) |
|
| 950 | 1207 | {
|
| 951 | 1208 | $sqlwhere.="(SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'";
|
| 952 | 1209 | $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") = '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')";
|
| 953 | - } |
|
| 954 | - else // reset is done on january |
|
| 1210 | + } else // reset is done on january |
|
| 955 | 1211 | {
|
| 956 | 1212 | $sqlwhere.='(SUBSTRING('.$field.', '.$yearpos.', '.$yearlen.") = '".$yearcomp."')";
|
| 957 | 1213 | } |
@@ -963,12 +1219,13 @@ discard block |
||
| 963 | 1219 | if (function_exists('mb_strrpos'))
|
| 964 | 1220 | {
|
| 965 | 1221 | $posnumstart=mb_strrpos($maskwithnocode,$maskcounter, 'UTF-8'); |
| 966 | - } |
|
| 967 | - else |
|
| 1222 | + } else |
|
| 968 | 1223 | {
|
| 969 | 1224 | $posnumstart=strrpos($maskwithnocode,$maskcounter); |
| 970 | 1225 | } // Pos of counter in final string (from 0 to ...) |
| 971 | - if ($posnumstart < 0) return 'ErrorBadMaskFailedToLocatePosOfSequence'; |
|
| 1226 | + if ($posnumstart < 0) { |
|
| 1227 | + return 'ErrorBadMaskFailedToLocatePosOfSequence'; |
|
| 1228 | + } |
|
| 972 | 1229 | $sqlstring='SUBSTRING('.$field.', '.($posnumstart+1).', '.dol_strlen($maskcounter).')';
|
| 973 | 1230 | |
| 974 | 1231 | // Define $maskLike |
@@ -981,9 +1238,15 @@ discard block |
||
| 981 | 1238 | $maskLike = preg_replace('/\{mm\}/i','__',$maskLike);
|
| 982 | 1239 | $maskLike = preg_replace('/\{dd\}/i','__',$maskLike);
|
| 983 | 1240 | $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'),str_pad("",dol_strlen($maskcounter),"_"),$maskLike);
|
| 984 | - if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike);
|
|
| 985 | - if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike);
|
|
| 986 | - if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike);
|
|
| 1241 | + if ($maskrefclient) { |
|
| 1242 | + $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike); |
|
| 1243 | + } |
|
| 1244 | + if ($masktype) { |
|
| 1245 | + $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike); |
|
| 1246 | + } |
|
| 1247 | + if ($maskuser) { |
|
| 1248 | + $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike); |
|
| 1249 | + } |
|
| 987 | 1250 | foreach($maskperso as $key => $val) |
| 988 | 1251 | {
|
| 989 | 1252 | $maskLike = str_replace(dol_string_nospecial($maskperso[$key]),$maskpersonew[$key],$maskLike); |
@@ -995,12 +1258,18 @@ discard block |
||
| 995 | 1258 | $sql.= " FROM ".MAIN_DB_PREFIX.$table; |
| 996 | 1259 | $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; |
| 997 | 1260 | $sql.= " AND ".$field." NOT LIKE '(PROV%)'"; |
| 998 | - if ($bentityon) // only if entity enable |
|
| 999 | - $sql.= " AND entity IN (".getEntity($sharetable).")";
|
|
| 1000 | - else if (! empty($forceentity)) |
|
| 1001 | - $sql.= " AND entity IN (".$forceentity.")";
|
|
| 1002 | - if ($where) $sql.=$where; |
|
| 1003 | - if ($sqlwhere) $sql.=' AND '.$sqlwhere; |
|
| 1261 | + if ($bentityon) { |
|
| 1262 | + // only if entity enable |
|
| 1263 | + $sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
| 1264 | + } else if (! empty($forceentity)) { |
|
| 1265 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
| 1266 | + } |
|
| 1267 | + if ($where) { |
|
| 1268 | + $sql.=$where; |
|
| 1269 | + } |
|
| 1270 | + if ($sqlwhere) { |
|
| 1271 | + $sql.=' AND '.$sqlwhere; |
|
| 1272 | + } |
|
| 1004 | 1273 | |
| 1005 | 1274 | //print $sql.'<br>'; |
| 1006 | 1275 | dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG);
|
@@ -1009,22 +1278,26 @@ discard block |
||
| 1009 | 1278 | {
|
| 1010 | 1279 | $obj = $db->fetch_object($resql); |
| 1011 | 1280 | $counter = $obj->val; |
| 1012 | - } |
|
| 1013 | - else dol_print_error($db); |
|
| 1281 | + } else { |
|
| 1282 | + dol_print_error($db); |
|
| 1283 | + } |
|
| 1014 | 1284 | |
| 1015 | 1285 | // Check if we must force counter to maskoffset |
| 1016 | - if (empty($counter)) $counter=$maskoffset; |
|
| 1017 | - else if (preg_match('/[^0-9]/i',$counter))
|
|
| 1286 | + if (empty($counter)) { |
|
| 1287 | + $counter=$maskoffset; |
|
| 1288 | + } else if (preg_match('/[^0-9]/i',$counter))
|
|
| 1018 | 1289 | {
|
| 1019 | 1290 | $counter=0; |
| 1020 | 1291 | dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR);
|
| 1021 | - } |
|
| 1022 | - else if ($counter < $maskoffset && empty(Globals::$conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) |
|
| 1023 | - $counter = $maskoffset; |
|
| 1292 | + } else if ($counter < $maskoffset && empty(Globals::$conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) { |
|
| 1293 | + $counter = $maskoffset; |
|
| 1294 | + } |
|
| 1024 | 1295 | |
| 1025 | - if ($mode == 'last') // We found value for counter = last counter value. Now need to get corresponding ref of invoice. |
|
| 1296 | + if ($mode == 'last') { |
|
| 1297 | + // We found value for counter = last counter value. Now need to get corresponding ref of invoice. |
|
| 1026 | 1298 | {
|
| 1027 | - $counterpadded=str_pad($counter,dol_strlen($maskcounter),"0",STR_PAD_LEFT); |
|
| 1299 | + $counterpadded=str_pad($counter,dol_strlen($maskcounter),"0",STR_PAD_LEFT); |
|
| 1300 | + } |
|
| 1028 | 1301 | |
| 1029 | 1302 | // Define $maskLike |
| 1030 | 1303 | $maskLike = dol_string_nospecial($mask); |
@@ -1036,34 +1309,48 @@ discard block |
||
| 1036 | 1309 | $maskLike = preg_replace('/\{mm\}/i','__',$maskLike);
|
| 1037 | 1310 | $maskLike = preg_replace('/\{dd\}/i','__',$maskLike);
|
| 1038 | 1311 | $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'),$counterpadded,$maskLike);
|
| 1039 | - if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike);
|
|
| 1040 | - if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike);
|
|
| 1041 | - if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike);
|
|
| 1312 | + if ($maskrefclient) { |
|
| 1313 | + $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike); |
|
| 1314 | + } |
|
| 1315 | + if ($masktype) { |
|
| 1316 | + $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike); |
|
| 1317 | + } |
|
| 1318 | + if ($maskuser) { |
|
| 1319 | + $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike); |
|
| 1320 | + } |
|
| 1042 | 1321 | |
| 1043 | 1322 | $ref=''; |
| 1044 | 1323 | $sql = "SELECT ".$field." as ref"; |
| 1045 | 1324 | $sql.= " FROM ".MAIN_DB_PREFIX.$table; |
| 1046 | 1325 | $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; |
| 1047 | 1326 | $sql.= " AND ".$field." NOT LIKE '%PROV%'"; |
| 1048 | - if ($bentityon) // only if entity enable |
|
| 1049 | - $sql.= " AND entity IN (".getEntity($sharetable).")";
|
|
| 1050 | - else if (! empty($forceentity)) |
|
| 1051 | - $sql.= " AND entity IN (".$forceentity.")";
|
|
| 1052 | - if ($where) $sql.=$where; |
|
| 1053 | - if ($sqlwhere) $sql.=' AND '.$sqlwhere; |
|
| 1327 | + if ($bentityon) { |
|
| 1328 | + // only if entity enable |
|
| 1329 | + $sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
| 1330 | + } else if (! empty($forceentity)) { |
|
| 1331 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
| 1332 | + } |
|
| 1333 | + if ($where) { |
|
| 1334 | + $sql.=$where; |
|
| 1335 | + } |
|
| 1336 | + if ($sqlwhere) { |
|
| 1337 | + $sql.=' AND '.$sqlwhere; |
|
| 1338 | + } |
|
| 1054 | 1339 | |
| 1055 | 1340 | dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG);
|
| 1056 | 1341 | $resql=$db->query($sql); |
| 1057 | 1342 | if ($resql) |
| 1058 | 1343 | {
|
| 1059 | 1344 | $obj = $db->fetch_object($resql); |
| 1060 | - if ($obj) $ref = $obj->ref; |
|
| 1061 | - } |
|
| 1062 | - else dol_print_error($db); |
|
| 1345 | + if ($obj) { |
|
| 1346 | + $ref = $obj->ref; |
|
| 1347 | + } |
|
| 1348 | + } else { |
|
| 1349 | + dol_print_error($db); |
|
| 1350 | + } |
|
| 1063 | 1351 | |
| 1064 | 1352 | $numFinal=$ref; |
| 1065 | - } |
|
| 1066 | - else if ($mode == 'next') |
|
| 1353 | + } else if ($mode == 'next') |
|
| 1067 | 1354 | {
|
| 1068 | 1355 | $counter++; |
| 1069 | 1356 | |
@@ -1079,7 +1366,9 @@ discard block |
||
| 1079 | 1366 | |
| 1080 | 1367 | // Define $sqlstring |
| 1081 | 1368 | $maskrefclient_posnumstart=strpos($maskwithnocode,$maskrefclient_maskcounter,strpos($maskwithnocode,$maskrefclient)); // Pos of counter in final string (from 0 to ...) |
| 1082 | - if ($maskrefclient_posnumstart <= 0) return 'ErrorBadMask'; |
|
| 1369 | + if ($maskrefclient_posnumstart <= 0) { |
|
| 1370 | + return 'ErrorBadMask'; |
|
| 1371 | + } |
|
| 1083 | 1372 | $maskrefclient_sqlstring='SUBSTRING('.$field.', '.($maskrefclient_posnumstart+1).', '.dol_strlen($maskrefclient_maskcounter).')';
|
| 1084 | 1373 | //print "x".$sqlstring; |
| 1085 | 1374 | |
@@ -1101,12 +1390,20 @@ discard block |
||
| 1101 | 1390 | $maskrefclient_sql.= " FROM ".MAIN_DB_PREFIX.$table; |
| 1102 | 1391 | //$sql.= " WHERE ".$field." not like '(%'"; |
| 1103 | 1392 | $maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'"; |
| 1104 | - if ($bentityon) // only if entity enable |
|
| 1105 | - $maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")";
|
|
| 1106 | - else if (! empty($forceentity)) |
|
| 1107 | - $sql.= " AND entity IN (".$forceentity.")";
|
|
| 1108 | - if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask |
|
| 1109 | - if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask |
|
| 1393 | + if ($bentityon) { |
|
| 1394 | + // only if entity enable |
|
| 1395 | + $maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
| 1396 | + } else if (! empty($forceentity)) { |
|
| 1397 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
| 1398 | + } |
|
| 1399 | + if ($where) { |
|
| 1400 | + $maskrefclient_sql.=$where; |
|
| 1401 | + } |
|
| 1402 | + //use the same optional where as general mask |
|
| 1403 | + if ($sqlwhere) { |
|
| 1404 | + $maskrefclient_sql.=' AND '.$sqlwhere; |
|
| 1405 | + } |
|
| 1406 | + //use the same sqlwhere as general mask |
|
| 1110 | 1407 | $maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')";
|
| 1111 | 1408 | |
| 1112 | 1409 | dol_syslog("functions2::get_next_value maskrefclient", LOG_DEBUG);
|
@@ -1115,10 +1412,13 @@ discard block |
||
| 1115 | 1412 | {
|
| 1116 | 1413 | $maskrefclient_obj = $db->fetch_object($maskrefclient_resql); |
| 1117 | 1414 | $maskrefclient_counter = $maskrefclient_obj->val; |
| 1118 | - } |
|
| 1119 | - else dol_print_error($db); |
|
| 1415 | + } else { |
|
| 1416 | + dol_print_error($db); |
|
| 1417 | + } |
|
| 1120 | 1418 | |
| 1121 | - if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) $maskrefclient_counter=$maskrefclient_maskoffset;
|
|
| 1419 | + if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) { |
|
| 1420 | + $maskrefclient_counter=$maskrefclient_maskoffset; |
|
| 1421 | + } |
|
| 1122 | 1422 | $maskrefclient_counter++; |
| 1123 | 1423 | } |
| 1124 | 1424 | |
@@ -1126,13 +1426,14 @@ discard block |
||
| 1126 | 1426 | $numFinal = $mask; |
| 1127 | 1427 | |
| 1128 | 1428 | // We replace special codes except refclient |
| 1129 | - if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year |
|
| 1429 | + if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') { |
|
| 1430 | + // yearoffsettype is - or +, so we don't want current year |
|
| 1130 | 1431 | {
|
| 1131 | - $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date)+$yearoffset, $numFinal);
|
|
| 1432 | + $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date)+$yearoffset, $numFinal); |
|
| 1433 | + } |
|
| 1132 | 1434 | $numFinal = preg_replace('/\{yy\}/i', date("y",$date)+$yearoffset, $numFinal);
|
| 1133 | 1435 | $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),1,1)+$yearoffset, $numFinal);
|
| 1134 | - } |
|
| 1135 | - else // we want yyyy to be current year |
|
| 1436 | + } else // we want yyyy to be current year |
|
| 1136 | 1437 | {
|
| 1137 | 1438 | $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date), $numFinal);
|
| 1138 | 1439 | $numFinal = preg_replace('/\{yy\}/i', date("y",$date), $numFinal);
|
@@ -1189,7 +1490,9 @@ discard block |
||
| 1189 | 1490 | {
|
| 1190 | 1491 | $string = " ".$string; |
| 1191 | 1492 | $ini = strpos($string,$start); |
| 1192 | - if ($ini == 0) return ""; |
|
| 1493 | + if ($ini == 0) { |
|
| 1494 | + return ""; |
|
| 1495 | + } |
|
| 1193 | 1496 | $ini += strlen($start); |
| 1194 | 1497 | $len = strpos($string,$end,$ini) - $ini; |
| 1195 | 1498 | return substr($string,$ini,$len); |
@@ -1213,8 +1516,7 @@ discard block |
||
| 1213 | 1516 | $masktri=$reg[1].(isset($reg[2])?$reg[2]:'').(isset($reg[3])?$reg[3]:''); |
| 1214 | 1517 | $maskcounter=$reg[1]; |
| 1215 | 1518 | $hasglobalcounter=true; |
| 1216 | - } |
|
| 1217 | - else |
|
| 1519 | + } else |
|
| 1218 | 1520 | {
|
| 1219 | 1521 | // setting some defaults so the rest of the code won't fail if there is a third party counter |
| 1220 | 1522 | $masktri='00000'; |
@@ -1223,7 +1525,9 @@ discard block |
||
| 1223 | 1525 | |
| 1224 | 1526 | $maskraz=-1; |
| 1225 | 1527 | $maskoffset=0; |
| 1226 | - if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
| 1528 | + if (dol_strlen($maskcounter) < 3) { |
|
| 1529 | + return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
| 1530 | + } |
|
| 1227 | 1531 | |
| 1228 | 1532 | // Extract value for third party mask counter |
| 1229 | 1533 | if (preg_match('/\{(c+)(0*)\}/i',$mask,$regClientRef))
|
@@ -1235,9 +1539,12 @@ discard block |
||
| 1235 | 1539 | $maskrefclient_clientcode=substr('',0,dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code to form maskrefclient_clientcode
|
| 1236 | 1540 | $maskrefclient_clientcode=str_pad($maskrefclient_clientcode,dol_strlen($maskrefclient_maskclientcode),"#",STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode |
| 1237 | 1541 | $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like |
| 1238 | - if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
| 1239 | - } |
|
| 1240 | - else $maskrefclient=''; |
|
| 1542 | + if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) { |
|
| 1543 | + return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
| 1544 | + } |
|
| 1545 | + } else { |
|
| 1546 | + $maskrefclient=''; |
|
| 1547 | + } |
|
| 1241 | 1548 | |
| 1242 | 1549 | // fail if there is neither a global nor a third party counter |
| 1243 | 1550 | if (! $hasglobalcounter && ($maskrefclient_maskcounter == '')) |
@@ -1259,21 +1566,35 @@ discard block |
||
| 1259 | 1566 | //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>"; |
| 1260 | 1567 | |
| 1261 | 1568 | // If an offset is asked |
| 1262 | - if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) $maskoffset=preg_replace('/^\+/','',$reg[2]);
|
|
| 1263 | - if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) $maskoffset=preg_replace('/^\+/','',$reg[3]);
|
|
| 1569 | + if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) { |
|
| 1570 | + $maskoffset=preg_replace('/^\+/','',$reg[2]); |
|
| 1571 | + } |
|
| 1572 | + if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) { |
|
| 1573 | + $maskoffset=preg_replace('/^\+/','',$reg[3]); |
|
| 1574 | + } |
|
| 1264 | 1575 | |
| 1265 | 1576 | // Define $sqlwhere |
| 1266 | 1577 | |
| 1267 | 1578 | // If a restore to zero after a month is asked we check if there is already a value for this year. |
| 1268 | - if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) $maskraz=preg_replace('/^@/','',$reg[2]);
|
|
| 1269 | - if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) $maskraz=preg_replace('/^@/','',$reg[3]);
|
|
| 1579 | + if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) { |
|
| 1580 | + $maskraz=preg_replace('/^@/','',$reg[2]); |
|
| 1581 | + } |
|
| 1582 | + if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) { |
|
| 1583 | + $maskraz=preg_replace('/^@/','',$reg[3]); |
|
| 1584 | + } |
|
| 1270 | 1585 | if ($maskraz >= 0) |
| 1271 | 1586 | {
|
| 1272 | - if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; |
|
| 1587 | + if ($maskraz > 12) { |
|
| 1588 | + return 'ErrorBadMaskBadRazMonth'; |
|
| 1589 | + } |
|
| 1273 | 1590 | |
| 1274 | 1591 | // Define reg |
| 1275 | - if ($maskraz > 1 && ! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask';
|
|
| 1276 | - if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazIfNoYearInMask';
|
|
| 1592 | + if ($maskraz > 1 && ! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { |
|
| 1593 | + return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; |
|
| 1594 | + } |
|
| 1595 | + if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { |
|
| 1596 | + return 'ErrorCantUseRazIfNoYearInMask'; |
|
| 1597 | + } |
|
| 1277 | 1598 | //print "x".$maskwithonlyymcode." ".$maskraz; |
| 1278 | 1599 | } |
| 1279 | 1600 | //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."<br>\n"; |
@@ -1283,7 +1604,9 @@ discard block |
||
| 1283 | 1604 | |
| 1284 | 1605 | // Check length |
| 1285 | 1606 | $len=dol_strlen($maskwithnocode); |
| 1286 | - if (dol_strlen($value) != $len) $result=-1; |
|
| 1607 | + if (dol_strlen($value) != $len) { |
|
| 1608 | + $result=-1; |
|
| 1609 | + } |
|
| 1287 | 1610 | |
| 1288 | 1611 | // Define $maskLike |
| 1289 | 1612 | /* seems not used |
@@ -1364,29 +1687,37 @@ discard block |
||
| 1364 | 1687 | */ |
| 1365 | 1688 | |
| 1366 | 1689 | // Definition du Jeudi de la semaine |
| 1367 | - if (date("w",mktime(12,0,0,$mois,$jour,$annee))==0) // Dimanche
|
|
| 1368 | - $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-3*24*60*60; |
|
| 1369 | - else if (date("w",mktime(12,0,0,$mois,$jour,$annee))<4) // du Lundi au Mercredi
|
|
| 1370 | - $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)+(4-date("w",mktime(12,0,0,$mois,$jour,$annee)))*24*60*60;
|
|
| 1371 | - else if (date("w",mktime(12,0,0,$mois,$jour,$annee))>4) // du Vendredi au Samedi
|
|
| 1372 | - $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-(date("w",mktime(12,0,0,$mois,$jour,$annee))-4)*24*60*60;
|
|
| 1373 | - else // Jeudi |
|
| 1374 | - $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee); |
|
| 1690 | + if (date("w",mktime(12,0,0,$mois,$jour,$annee))==0) { |
|
| 1691 | + // Dimanche |
|
| 1692 | + $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-3*24*60*60; |
|
| 1693 | + } else if (date("w",mktime(12,0,0,$mois,$jour,$annee))<4) { |
|
| 1694 | + // du Lundi au Mercredi |
|
| 1695 | + $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)+(4-date("w",mktime(12,0,0,$mois,$jour,$annee)))*24*60*60; |
|
| 1696 | + } else if (date("w",mktime(12,0,0,$mois,$jour,$annee))>4) { |
|
| 1697 | + // du Vendredi au Samedi |
|
| 1698 | + $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-(date("w",mktime(12,0,0,$mois,$jour,$annee))-4)*24*60*60; |
|
| 1699 | + } else { |
|
| 1700 | + // Jeudi |
|
| 1701 | + $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee); |
|
| 1702 | + } |
|
| 1375 | 1703 | |
| 1376 | 1704 | // Definition du premier Jeudi de l'annee |
| 1377 | - if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==0) // Dimanche
|
|
| 1705 | + if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==0) { |
|
| 1706 | + // Dimanche |
|
| 1378 | 1707 | {
|
| 1379 | - $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+4*24*60*60;
|
|
| 1380 | - } |
|
| 1381 | - else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))<4) // du Lundi au Mercredi
|
|
| 1708 | + $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+4*24*60*60; |
|
| 1709 | + } |
|
| 1710 | + } else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))<4) { |
|
| 1711 | + // du Lundi au Mercredi |
|
| 1382 | 1712 | {
|
| 1383 | - $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(4-date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine))))*24*60*60;
|
|
| 1384 | - } |
|
| 1385 | - else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))>4) // du Vendredi au Samedi
|
|
| 1713 | + $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(4-date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine))))*24*60*60; |
|
| 1714 | + } |
|
| 1715 | + } else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))>4) { |
|
| 1716 | + // du Vendredi au Samedi |
|
| 1386 | 1717 | {
|
| 1387 | - $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(7-(date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))-4))*24*60*60;
|
|
| 1388 | - } |
|
| 1389 | - else // Jeudi |
|
| 1718 | + $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(7-(date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))-4))*24*60*60; |
|
| 1719 | + } |
|
| 1720 | + } else // Jeudi |
|
| 1390 | 1721 | {
|
| 1391 | 1722 | $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine));
|
| 1392 | 1723 | } |
@@ -1407,8 +1738,7 @@ discard block |
||
| 1407 | 1738 | if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==4 || (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==3 && date("z",mktime(12,0,0,12,31,date("Y",$jeudiSemaine)))==365))
|
| 1408 | 1739 | {
|
| 1409 | 1740 | $numeroSemaine = 53; |
| 1410 | - } |
|
| 1411 | - else |
|
| 1741 | + } else |
|
| 1412 | 1742 | {
|
| 1413 | 1743 | $numeroSemaine = 1; |
| 1414 | 1744 | } |
@@ -1467,7 +1797,9 @@ discard block |
||
| 1467 | 1797 | function dol_set_user_param($db, $conf, &$user, $tab) |
| 1468 | 1798 | {
|
| 1469 | 1799 | // Verification parametres |
| 1470 | - if (count($tab) < 1) return -1; |
|
| 1800 | + if (count($tab) < 1) { |
|
| 1801 | + return -1; |
|
| 1802 | + } |
|
| 1471 | 1803 | |
| 1472 | 1804 | $db->begin(); |
| 1473 | 1805 | |
@@ -1479,7 +1811,9 @@ discard block |
||
| 1479 | 1811 | $i=0; |
| 1480 | 1812 | foreach ($tab as $key => $value) |
| 1481 | 1813 | {
|
| 1482 | - if ($i > 0) $sql.=','; |
|
| 1814 | + if ($i > 0) { |
|
| 1815 | + $sql.=','; |
|
| 1816 | + } |
|
| 1483 | 1817 | $sql.="'".$db->escape($key)."'"; |
| 1484 | 1818 | $i++; |
| 1485 | 1819 | } |
@@ -1513,8 +1847,7 @@ discard block |
||
| 1513 | 1847 | } |
| 1514 | 1848 | $user->conf->$key = $value; |
| 1515 | 1849 | //print "key=".$key." user->conf->key=".$user->conf->$key; |
| 1516 | - } |
|
| 1517 | - else |
|
| 1850 | + } else |
|
| 1518 | 1851 | {
|
| 1519 | 1852 | unset($user->conf->$key); |
| 1520 | 1853 | } |
@@ -1537,8 +1870,7 @@ discard block |
||
| 1537 | 1870 | if ($reduction == 100) |
| 1538 | 1871 | {
|
| 1539 | 1872 | $string = $langs->transnoentities("Offered");
|
| 1540 | - } |
|
| 1541 | - else |
|
| 1873 | + } else |
|
| 1542 | 1874 | {
|
| 1543 | 1875 | $string = vatrate($reduction,true); |
| 1544 | 1876 | } |
@@ -1625,9 +1957,11 @@ discard block |
||
| 1625 | 1957 | |
| 1626 | 1958 | // If this generation module needs to scan a directory, then description field is filled |
| 1627 | 1959 | // with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...). |
| 1628 | - if (! empty($obj->description)) // A list of directories to scan is defined |
|
| 1960 | + if (! empty($obj->description)) { |
|
| 1961 | + // A list of directories to scan is defined |
|
| 1629 | 1962 | {
|
| 1630 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 1963 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 1964 | + } |
|
| 1631 | 1965 | |
| 1632 | 1966 | $const=$obj->description; |
| 1633 | 1967 | //irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim(Globals::$conf->global->$const));
|
@@ -1646,7 +1980,9 @@ discard block |
||
| 1646 | 1980 | {
|
| 1647 | 1981 | // all type of template is allowed |
| 1648 | 1982 | $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); |
| 1649 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 1983 | + if (count($tmpfiles)) { |
|
| 1984 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
| 1985 | + } |
|
| 1650 | 1986 | } |
| 1651 | 1987 | } |
| 1652 | 1988 | |
@@ -1657,40 +1993,41 @@ discard block |
||
| 1657 | 1993 | $max=($maxfilenamelength?$maxfilenamelength:28); |
| 1658 | 1994 | $liste[$obj->id.':'.$record['fullname']]=dol_trunc($record['name'],$max,'middle'); |
| 1659 | 1995 | } |
| 1660 | - } |
|
| 1661 | - else |
|
| 1996 | + } else |
|
| 1662 | 1997 | {
|
| 1663 | 1998 | $liste[0]=$obj->label.': '.$langs->trans("None");
|
| 1664 | 1999 | } |
| 1665 | - } |
|
| 1666 | - else |
|
| 2000 | + } else |
|
| 1667 | 2001 | {
|
| 1668 | - if ($type == 'member' && $obj->lib == 'standard') // Special case, if member template, we add variant per format |
|
| 2002 | + if ($type == 'member' && $obj->lib == 'standard') { |
|
| 2003 | + // Special case, if member template, we add variant per format |
|
| 1669 | 2004 | {
|
| 1670 | - global $_Avery_Labels; |
|
| 2005 | + global $_Avery_Labels; |
|
| 2006 | + } |
|
| 1671 | 2007 | include_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; |
| 1672 | 2008 | foreach($_Avery_Labels as $key => $val) |
| 1673 | 2009 | {
|
| 1674 | 2010 | $liste[$obj->id.':'.$key]=($obj->label?$obj->label:$obj->lib).' '.$val['name']; |
| 1675 | 2011 | } |
| 1676 | - } |
|
| 1677 | - else // Common usage |
|
| 2012 | + } else // Common usage |
|
| 1678 | 2013 | {
|
| 1679 | 2014 | $liste[$obj->id]=$obj->label?$obj->label:$obj->lib; |
| 1680 | 2015 | } |
| 1681 | 2016 | } |
| 1682 | 2017 | $i++; |
| 1683 | 2018 | } |
| 1684 | - } |
|
| 1685 | - else |
|
| 2019 | + } else |
|
| 1686 | 2020 | {
|
| 1687 | 2021 | dol_print_error($db); |
| 1688 | 2022 | return -1; |
| 1689 | 2023 | } |
| 1690 | 2024 | |
| 1691 | - if ($found) return $liste; |
|
| 1692 | - else return 0; |
|
| 1693 | -} |
|
| 2025 | + if ($found) { |
|
| 2026 | + return $liste; |
|
| 2027 | + } else { |
|
| 2028 | + return 0; |
|
| 2029 | + } |
|
| 2030 | + } |
|
| 1694 | 2031 | |
| 1695 | 2032 | /** |
| 1696 | 2033 | * This function evaluates a string that should be a valid IPv4 |
@@ -1705,10 +2042,14 @@ discard block |
||
| 1705 | 2042 | if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
| 1706 | 2043 | |
| 1707 | 2044 | // Then we test if it is a private range |
| 1708 | - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) return 2; |
|
| 2045 | + if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) { |
|
| 2046 | + return 2; |
|
| 2047 | + } |
|
| 1709 | 2048 | |
| 1710 | 2049 | // Then we test if it is a reserved range |
| 1711 | - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) return 0; |
|
| 2050 | + if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) { |
|
| 2051 | + return 0; |
|
| 2052 | + } |
|
| 1712 | 2053 | |
| 1713 | 2054 | return 1; |
| 1714 | 2055 | } |
@@ -1761,8 +2102,7 @@ discard block |
||
| 1761 | 2102 | 'proxy_password' => $proxypass, |
| 1762 | 2103 | 'trace' => 1 |
| 1763 | 2104 | ); |
| 1764 | - } |
|
| 1765 | - else |
|
| 2105 | + } else |
|
| 1766 | 2106 | {
|
| 1767 | 2107 | $params=array('connection_timeout'=>$timeout,
|
| 1768 | 2108 | 'response_timeout'=>$response_timeout, |
@@ -1869,14 +2209,12 @@ discard block |
||
| 1869 | 2209 | $classname='FactureFournisseur'; |
| 1870 | 2210 | $classpath = 'fourn/class'; |
| 1871 | 2211 | $module='fournisseur'; |
| 1872 | - } |
|
| 1873 | - elseif ($objecttype == 'order_supplier') {
|
|
| 2212 | + } elseif ($objecttype == 'order_supplier') {
|
|
| 1874 | 2213 | $classfile = 'fournisseur.commande'; |
| 1875 | 2214 | $classname='CommandeFournisseur'; |
| 1876 | 2215 | $classpath = 'fourn/class'; |
| 1877 | 2216 | $module='fournisseur'; |
| 1878 | - } |
|
| 1879 | - elseif ($objecttype == 'stock') {
|
|
| 2217 | + } elseif ($objecttype == 'stock') {
|
|
| 1880 | 2218 | $classpath = 'product/stock/class'; |
| 1881 | 2219 | $classfile='entrepot'; |
| 1882 | 2220 | $classname='Entrepot'; |
@@ -1895,8 +2233,9 @@ discard block |
||
| 1895 | 2233 | $ret=$langs->trans('Deleted');
|
| 1896 | 2234 | } |
| 1897 | 2235 | unset($object); |
| 1898 | - } |
|
| 1899 | - else dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR);
|
|
| 2236 | + } else { |
|
| 2237 | + dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR); |
|
| 2238 | + } |
|
| 1900 | 2239 | } |
| 1901 | 2240 | } |
| 1902 | 2241 | return $ret; |
@@ -1928,11 +2267,12 @@ discard block |
||
| 1928 | 2267 | {
|
| 1929 | 2268 | $obj = $db->fetch_object($resql); |
| 1930 | 2269 | $listofid[]=$obj->rowid; |
| 1931 | - if ($obj->parent_id > 0) $listofparentid[$obj->rowid]=$obj->parent_id; |
|
| 2270 | + if ($obj->parent_id > 0) { |
|
| 2271 | + $listofparentid[$obj->rowid]=$obj->parent_id; |
|
| 2272 | + } |
|
| 1932 | 2273 | $i++; |
| 1933 | 2274 | } |
| 1934 | - } |
|
| 1935 | - else |
|
| 2275 | + } else |
|
| 1936 | 2276 | {
|
| 1937 | 2277 | dol_print_error($db); |
| 1938 | 2278 | } |
@@ -1967,9 +2307,11 @@ discard block |
||
| 1967 | 2307 | while ($cursor > 0) |
| 1968 | 2308 | {
|
| 1969 | 2309 | $arrayidparsed[$cursor]=1; |
| 1970 | - if ($arrayidparsed[$listofparentid[$cursor]]) // We detect a loop. A record with a parent that was already into child |
|
| 2310 | + if ($arrayidparsed[$listofparentid[$cursor]]) { |
|
| 2311 | + // We detect a loop. A record with a parent that was already into child |
|
| 1971 | 2312 | {
|
| 1972 | - print 'Found a loop between id '.$id.' - '.$cursor.'<br>'; |
|
| 2313 | + print 'Found a loop between id '.$id.' - '.$cursor.'<br>'; |
|
| 2314 | + } |
|
| 1973 | 2315 | unset($arrayidparsed); |
| 1974 | 2316 | $listofidtoclean[$cursor]=$id; |
| 1975 | 2317 | break; |
@@ -1977,7 +2319,9 @@ discard block |
||
| 1977 | 2319 | $cursor=$listofparentid[$cursor]; |
| 1978 | 2320 | } |
| 1979 | 2321 | |
| 1980 | - if (count($listofidtoclean)) break; |
|
| 2322 | + if (count($listofidtoclean)) { |
|
| 2323 | + break; |
|
| 2324 | + } |
|
| 1981 | 2325 | } |
| 1982 | 2326 | |
| 1983 | 2327 | $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; |
@@ -2124,9 +2468,15 @@ discard block |
||
| 2124 | 2468 | $classfile='fournisseur.facture'; |
| 2125 | 2469 | } |
| 2126 | 2470 | |
| 2127 | - if (!isset($classfile)) $classfile = strtolower($subelement); |
|
| 2128 | - if (!isset($classname)) $classname = ucfirst($subelement); |
|
| 2129 | - if (!isset($classpath)) $classpath = $module.'/class'; |
|
| 2471 | + if (!isset($classfile)) { |
|
| 2472 | + $classfile = strtolower($subelement); |
|
| 2473 | + } |
|
| 2474 | + if (!isset($classname)) { |
|
| 2475 | + $classname = ucfirst($subelement); |
|
| 2476 | + } |
|
| 2477 | + if (!isset($classpath)) { |
|
| 2478 | + $classpath = $module.'/class'; |
|
| 2479 | + } |
|
| 2130 | 2480 | |
| 2131 | 2481 | $element_properties = array( |
| 2132 | 2482 | 'module' => $module, |
@@ -2179,8 +2529,12 @@ discard block |
||
| 2179 | 2529 | */ |
| 2180 | 2530 | function colorArrayToHex($arraycolor,$colorifnotfound='888888') |
| 2181 | 2531 | {
|
| 2182 | - if (! is_array($arraycolor)) return $colorifnotfound; |
|
| 2183 | - if (empty($arraycolor)) return $colorifnotfound; |
|
| 2532 | + if (! is_array($arraycolor)) { |
|
| 2533 | + return $colorifnotfound; |
|
| 2534 | + } |
|
| 2535 | + if (empty($arraycolor)) { |
|
| 2536 | + return $colorifnotfound; |
|
| 2537 | + } |
|
| 2184 | 2538 | return sprintf("%02s",dechex($arraycolor[0])).sprintf("%02s",dechex($arraycolor[1])).sprintf("%02s",dechex($arraycolor[2]));
|
| 2185 | 2539 | } |
| 2186 | 2540 | |
@@ -2196,12 +2550,17 @@ discard block |
||
| 2196 | 2550 | */ |
| 2197 | 2551 | static function colorStringToArray($stringcolor, $colorifnotfound = array(88, 88, 88)) |
| 2198 | 2552 | {
|
| 2199 | - if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is |
|
| 2553 | + if (is_array($stringcolor)) { |
|
| 2554 | + return $stringcolor; |
|
| 2555 | + } |
|
| 2556 | + // If already into correct output format, we return as is |
|
| 2200 | 2557 | $tmp=preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/',$stringcolor,$reg);
|
| 2201 | 2558 | if (! $tmp) |
| 2202 | 2559 | {
|
| 2203 | 2560 | $tmp=explode(',',$stringcolor);
|
| 2204 | - if (count($tmp) < 3) return $colorifnotfound; |
|
| 2561 | + if (count($tmp) < 3) { |
|
| 2562 | + return $colorifnotfound; |
|
| 2563 | + } |
|
| 2205 | 2564 | return $tmp; |
| 2206 | 2565 | } |
| 2207 | 2566 | return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3])); |
@@ -2247,69 +2606,51 @@ discard block |
||
| 2247 | 2606 | function getModuleDirForApiClass($module) |
| 2248 | 2607 | {
|
| 2249 | 2608 | $moduledirforclass=$module; |
| 2250 | - if ($moduledirforclass != 'api') $moduledirforclass = preg_replace('/api$/i','',$moduledirforclass);
|
|
| 2609 | + if ($moduledirforclass != 'api') { |
|
| 2610 | + $moduledirforclass = preg_replace('/api$/i','',$moduledirforclass); |
|
| 2611 | + } |
|
| 2251 | 2612 | |
| 2252 | 2613 | if ($module == 'contracts') {
|
| 2253 | 2614 | $moduledirforclass = 'contrat'; |
| 2254 | - } |
|
| 2255 | - elseif (in_array($module, array('admin', 'login', 'setup', 'access', 'status', 'tools', 'documents'))) {
|
|
| 2615 | + } elseif (in_array($module, array('admin', 'login', 'setup', 'access', 'status', 'tools', 'documents'))) {
|
|
| 2256 | 2616 | $moduledirforclass = 'api'; |
| 2257 | - } |
|
| 2258 | - elseif ($module == 'contact' || $module == 'contacts' || $module == 'customer' || $module == 'thirdparty' || $module == 'thirdparties') {
|
|
| 2617 | + } elseif ($module == 'contact' || $module == 'contacts' || $module == 'customer' || $module == 'thirdparty' || $module == 'thirdparties') {
|
|
| 2259 | 2618 | $moduledirforclass = 'societe'; |
| 2260 | - } |
|
| 2261 | - elseif ($module == 'propale' || $module == 'proposals') {
|
|
| 2619 | + } elseif ($module == 'propale' || $module == 'proposals') {
|
|
| 2262 | 2620 | $moduledirforclass = 'comm/propal'; |
| 2263 | - } |
|
| 2264 | - elseif ($module == 'agenda' || $module == 'agendaevents') {
|
|
| 2621 | + } elseif ($module == 'agenda' || $module == 'agendaevents') {
|
|
| 2265 | 2622 | $moduledirforclass = 'comm/action'; |
| 2266 | - } |
|
| 2267 | - elseif ($module == 'adherent' || $module == 'members' || $module == 'memberstypes' || $module == 'subscriptions') {
|
|
| 2623 | + } elseif ($module == 'adherent' || $module == 'members' || $module == 'memberstypes' || $module == 'subscriptions') {
|
|
| 2268 | 2624 | $moduledirforclass = 'adherents'; |
| 2269 | - } |
|
| 2270 | - elseif ($module == 'banque' || $module == 'bankaccounts') {
|
|
| 2625 | + } elseif ($module == 'banque' || $module == 'bankaccounts') {
|
|
| 2271 | 2626 | $moduledirforclass = 'compta/bank'; |
| 2272 | - } |
|
| 2273 | - elseif ($module == 'category' || $module == 'categorie') {
|
|
| 2627 | + } elseif ($module == 'category' || $module == 'categorie') {
|
|
| 2274 | 2628 | $moduledirforclass = 'categories'; |
| 2275 | - } |
|
| 2276 | - elseif ($module == 'order' || $module == 'orders') {
|
|
| 2629 | + } elseif ($module == 'order' || $module == 'orders') {
|
|
| 2277 | 2630 | $moduledirforclass = 'commande'; |
| 2278 | - } |
|
| 2279 | - elseif ($module == 'shipments') {
|
|
| 2631 | + } elseif ($module == 'shipments') {
|
|
| 2280 | 2632 | $moduledirforclass = 'expedition'; |
| 2281 | - } |
|
| 2282 | - elseif ($module == 'facture' || $module == 'invoice' || $module == 'invoices') {
|
|
| 2633 | + } elseif ($module == 'facture' || $module == 'invoice' || $module == 'invoices') {
|
|
| 2283 | 2634 | $moduledirforclass = 'compta/facture'; |
| 2284 | - } |
|
| 2285 | - elseif ($module == 'products') {
|
|
| 2635 | + } elseif ($module == 'products') {
|
|
| 2286 | 2636 | $moduledirforclass = 'product'; |
| 2287 | - } |
|
| 2288 | - elseif ($module == 'project' || $module == 'projects' || $module == 'tasks') {
|
|
| 2637 | + } elseif ($module == 'project' || $module == 'projects' || $module == 'tasks') {
|
|
| 2289 | 2638 | $moduledirforclass = 'projet'; |
| 2290 | - } |
|
| 2291 | - elseif ($module == 'task') {
|
|
| 2639 | + } elseif ($module == 'task') {
|
|
| 2292 | 2640 | $moduledirforclass = 'projet'; |
| 2293 | - } |
|
| 2294 | - elseif ($module == 'stock' || $module == 'stockmovements' || $module == 'warehouses') {
|
|
| 2641 | + } elseif ($module == 'stock' || $module == 'stockmovements' || $module == 'warehouses') {
|
|
| 2295 | 2642 | $moduledirforclass = 'product/stock'; |
| 2296 | - } |
|
| 2297 | - elseif ($module == 'supplierproposals' || $module == 'supplierproposal' || $module == 'supplier_proposal') {
|
|
| 2643 | + } elseif ($module == 'supplierproposals' || $module == 'supplierproposal' || $module == 'supplier_proposal') {
|
|
| 2298 | 2644 | $moduledirforclass = 'supplier_proposal'; |
| 2299 | - } |
|
| 2300 | - elseif ($module == 'fournisseur' || $module == 'supplierinvoices' || $module == 'supplierorders') {
|
|
| 2645 | + } elseif ($module == 'fournisseur' || $module == 'supplierinvoices' || $module == 'supplierorders') {
|
|
| 2301 | 2646 | $moduledirforclass = 'fourn'; |
| 2302 | - } |
|
| 2303 | - elseif ($module == 'expensereports') {
|
|
| 2647 | + } elseif ($module == 'expensereports') {
|
|
| 2304 | 2648 | $moduledirforclass = 'expensereport'; |
| 2305 | - } |
|
| 2306 | - elseif ($module == 'users') {
|
|
| 2649 | + } elseif ($module == 'users') {
|
|
| 2307 | 2650 | $moduledirforclass = 'user'; |
| 2308 | - } |
|
| 2309 | - elseif ($module == 'ficheinter' || $module == 'interventions') {
|
|
| 2651 | + } elseif ($module == 'ficheinter' || $module == 'interventions') {
|
|
| 2310 | 2652 | $moduledirforclass = 'fichinter'; |
| 2311 | - } |
|
| 2312 | - elseif ($module == 'tickets') {
|
|
| 2653 | + } elseif ($module == 'tickets') {
|
|
| 2313 | 2654 | $moduledirforclass = 'ticket'; |
| 2314 | 2655 | } |
| 2315 | 2656 | |
@@ -196,24 +196,29 @@ discard block |
||
| 196 | 196 | // Get more permissions checks from hooks |
| 197 | 197 | $parameters = array('features' => $features, 'objectid' => $objectid, 'idtype' => $dbt_select);
|
| 198 | 198 | $reshook = $hookmanager->executeHooks('restrictedArea', $parameters);
|
| 199 | - if (!empty($hookmanager->resArray['result'])) |
|
| 200 | - return true; |
|
| 201 | - if ($reshook > 0) |
|
| 202 | - return false; |
|
| 199 | + if (!empty($hookmanager->resArray['result'])) { |
|
| 200 | + return true; |
|
| 201 | + } |
|
| 202 | + if ($reshook > 0) { |
|
| 203 | + return false; |
|
| 204 | + } |
|
| 203 | 205 | |
| 204 | - if ($dbt_select != 'rowid' && $dbt_select != 'id') |
|
| 205 | - $objectid = "'" . $objectid . "'"; |
|
| 206 | + if ($dbt_select != 'rowid' && $dbt_select != 'id') { |
|
| 207 | + $objectid = "'" . $objectid . "'"; |
|
| 208 | + } |
|
| 206 | 209 | |
| 207 | 210 | // Features/modules to check |
| 208 | 211 | $featuresarray = array($features); |
| 209 | - if (preg_match('/&/', $features))
|
|
| 210 | - $featuresarray = explode("&", $features);
|
|
| 211 | - else if (preg_match('/\|/', $features))
|
|
| 212 | - $featuresarray = explode("|", $features);
|
|
| 212 | + if (preg_match('/&/', $features)) { |
|
| 213 | + $featuresarray = explode("&", $features); |
|
| 214 | + } else if (preg_match('/\|/', $features)) { |
|
| 215 | + $featuresarray = explode("|", $features); |
|
| 216 | + } |
|
| 213 | 217 | |
| 214 | 218 | // More subfeatures to check |
| 215 | - if (!empty($feature2)) |
|
| 216 | - $feature2 = explode("|", $feature2);
|
|
| 219 | + if (!empty($feature2)) { |
|
| 220 | + $feature2 = explode("|", $feature2); |
|
| 221 | + } |
|
| 217 | 222 | |
| 218 | 223 | // More parameters |
| 219 | 224 | $params = explode('&', $tableandshare);
|
@@ -227,8 +232,9 @@ discard block |
||
| 227 | 232 | $nbko = 0; |
| 228 | 233 | foreach ($featuresarray as $feature) { // first we check nb of test ko
|
| 229 | 234 | $featureforlistofmodule = $feature; |
| 230 | - if ($featureforlistofmodule == 'produit') |
|
| 231 | - $featureforlistofmodule = 'product'; |
|
| 235 | + if ($featureforlistofmodule == 'produit') { |
|
| 236 | + $featureforlistofmodule = 'product'; |
|
| 237 | + } |
|
| 232 | 238 | if (!empty($user->societe_id) && !empty(Globals::$conf->global->MAIN_MODULES_FOR_EXTERNAL) && !in_array($featureforlistofmodule, $listofmodules)) { // If limits on modules for external users, module must be into list of modules for external users
|
| 233 | 239 | $readok = 0; |
| 234 | 240 | $nbko++; |
@@ -290,11 +296,13 @@ discard block |
||
| 290 | 296 | } |
| 291 | 297 | |
| 292 | 298 | // If a or and at least one ok |
| 293 | - if (preg_match('/\|/', $features) && $nbko < count($featuresarray))
|
|
| 294 | - $readok = 1; |
|
| 299 | + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) { |
|
| 300 | + $readok = 1; |
|
| 301 | + } |
|
| 295 | 302 | |
| 296 | - if (!$readok) |
|
| 297 | - accessforbidden(); |
|
| 303 | + if (!$readok) { |
|
| 304 | + accessforbidden(); |
|
| 305 | + } |
|
| 298 | 306 | //print "Read access is ok"; |
| 299 | 307 | // Check write permission from module (we need to know write permission to create but also to delete drafts record) |
| 300 | 308 | $createok = 1; |
@@ -351,22 +359,26 @@ discard block |
||
| 351 | 359 | } |
| 352 | 360 | |
| 353 | 361 | // If a or and at least one ok |
| 354 | - if (preg_match('/\|/', $features) && $nbko < count($featuresarray))
|
|
| 355 | - $createok = 1; |
|
| 362 | + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) { |
|
| 363 | + $createok = 1; |
|
| 364 | + } |
|
| 356 | 365 | |
| 357 | - if (GETPOST('action', 'aZ09') == 'create' && !$createok)
|
|
| 358 | - accessforbidden(); |
|
| 366 | + if (GETPOST('action', 'aZ09') == 'create' && !$createok) { |
|
| 367 | + accessforbidden(); |
|
| 368 | + } |
|
| 359 | 369 | //print "Write access is ok"; |
| 360 | 370 | } |
| 361 | 371 | |
| 362 | 372 | // Check create user permission |
| 363 | 373 | $createuserok = 1; |
| 364 | 374 | if (GETPOST('action', 'aZ09') == 'confirm_create_user' && GETPOST("confirm", 'aZ09') == 'yes') {
|
| 365 | - if (!$user->rights->user->user->creer) |
|
| 366 | - $createuserok = 0; |
|
| 375 | + if (!$user->rights->user->user->creer) { |
|
| 376 | + $createuserok = 0; |
|
| 377 | + } |
|
| 367 | 378 | |
| 368 | - if (!$createuserok) |
|
| 369 | - accessforbidden(); |
|
| 379 | + if (!$createuserok) { |
|
| 380 | + accessforbidden(); |
|
| 381 | + } |
|
| 370 | 382 | //print "Create user access is ok"; |
| 371 | 383 | } |
| 372 | 384 | |
@@ -376,62 +388,66 @@ discard block |
||
| 376 | 388 | if ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete') {
|
| 377 | 389 | foreach ($featuresarray as $feature) {
|
| 378 | 390 | if ($feature == 'contact') {
|
| 379 | - if (!$user->rights->societe->contact->supprimer) |
|
| 380 | - $deleteok = 0; |
|
| 381 | - } |
|
| 382 | - else if ($feature == 'produit|service') {
|
|
| 383 | - if (!$user->rights->produit->supprimer && !$user->rights->service->supprimer) |
|
| 384 | - $deleteok = 0; |
|
| 385 | - } |
|
| 386 | - else if ($feature == 'commande_fournisseur') {
|
|
| 387 | - if (!$user->rights->fournisseur->commande->supprimer) |
|
| 388 | - $deleteok = 0; |
|
| 389 | - } |
|
| 390 | - else if ($feature == 'banque') {
|
|
| 391 | - if (!$user->rights->banque->modifier) |
|
| 392 | - $deleteok = 0; |
|
| 393 | - } |
|
| 394 | - else if ($feature == 'cheque') {
|
|
| 395 | - if (!$user->rights->banque->cheque) |
|
| 396 | - $deleteok = 0; |
|
| 397 | - } |
|
| 398 | - else if ($feature == 'ecm') {
|
|
| 399 | - if (!$user->rights->ecm->upload) |
|
| 400 | - $deleteok = 0; |
|
| 401 | - } |
|
| 402 | - else if ($feature == 'ftp') {
|
|
| 403 | - if (!$user->rights->ftp->write) |
|
| 404 | - $deleteok = 0; |
|
| 405 | - }else if ($feature == 'salaries') {
|
|
| 406 | - if (!$user->rights->salaries->delete) |
|
| 407 | - $deleteok = 0; |
|
| 408 | - } |
|
| 409 | - else if ($feature == 'salaries') {
|
|
| 410 | - if (!$user->rights->salaries->delete) |
|
| 411 | - $deleteok = 0; |
|
| 412 | - } |
|
| 413 | - else if (!empty($feature2)) { // This should be used for permissions on 2 levels
|
|
| 391 | + if (!$user->rights->societe->contact->supprimer) { |
|
| 392 | + $deleteok = 0; |
|
| 393 | + } |
|
| 394 | + } else if ($feature == 'produit|service') {
|
|
| 395 | + if (!$user->rights->produit->supprimer && !$user->rights->service->supprimer) { |
|
| 396 | + $deleteok = 0; |
|
| 397 | + } |
|
| 398 | + } else if ($feature == 'commande_fournisseur') {
|
|
| 399 | + if (!$user->rights->fournisseur->commande->supprimer) { |
|
| 400 | + $deleteok = 0; |
|
| 401 | + } |
|
| 402 | + } else if ($feature == 'banque') {
|
|
| 403 | + if (!$user->rights->banque->modifier) { |
|
| 404 | + $deleteok = 0; |
|
| 405 | + } |
|
| 406 | + } else if ($feature == 'cheque') {
|
|
| 407 | + if (!$user->rights->banque->cheque) { |
|
| 408 | + $deleteok = 0; |
|
| 409 | + } |
|
| 410 | + } else if ($feature == 'ecm') {
|
|
| 411 | + if (!$user->rights->ecm->upload) { |
|
| 412 | + $deleteok = 0; |
|
| 413 | + } |
|
| 414 | + } else if ($feature == 'ftp') {
|
|
| 415 | + if (!$user->rights->ftp->write) { |
|
| 416 | + $deleteok = 0; |
|
| 417 | + } |
|
| 418 | + } else if ($feature == 'salaries') {
|
|
| 419 | + if (!$user->rights->salaries->delete) { |
|
| 420 | + $deleteok = 0; |
|
| 421 | + } |
|
| 422 | + } else if ($feature == 'salaries') {
|
|
| 423 | + if (!$user->rights->salaries->delete) { |
|
| 424 | + $deleteok = 0; |
|
| 425 | + } |
|
| 426 | + } else if (!empty($feature2)) { // This should be used for permissions on 2 levels
|
|
| 414 | 427 | foreach ($feature2 as $subfeature) {
|
| 415 | - if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) |
|
| 416 | - $deleteok = 0; |
|
| 417 | - else {
|
|
| 428 | + if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) { |
|
| 429 | + $deleteok = 0; |
|
| 430 | + } else {
|
|
| 418 | 431 | $deleteok = 1; |
| 419 | 432 | break; |
| 420 | 433 | } // For bypass the second test if the first is ok |
| 421 | 434 | } |
| 422 | 435 | } else if (!empty($feature)) { // This is used for permissions on 1 level
|
| 423 | 436 | //print '<br>feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete; |
| 424 | - if (empty($user->rights->$feature->supprimer) && empty($user->rights->$feature->delete) && empty($user->rights->$feature->run)) |
|
| 425 | - $deleteok = 0; |
|
| 437 | + if (empty($user->rights->$feature->supprimer) && empty($user->rights->$feature->delete) && empty($user->rights->$feature->run)) { |
|
| 438 | + $deleteok = 0; |
|
| 439 | + } |
|
| 426 | 440 | } |
| 427 | 441 | } |
| 428 | 442 | |
| 429 | 443 | // If a or and at least one ok |
| 430 | - if (preg_match('/\|/', $features) && $nbko < count($featuresarray))
|
|
| 431 | - $deleteok = 1; |
|
| 444 | + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) { |
|
| 445 | + $deleteok = 1; |
|
| 446 | + } |
|
| 432 | 447 | |
| 433 | - if (!$deleteok && !($isdraft && $createok)) |
|
| 434 | - accessforbidden(); |
|
| 448 | + if (!$deleteok && !($isdraft && $createok)) { |
|
| 449 | + accessforbidden(); |
|
| 450 | + } |
|
| 435 | 451 | //print "Delete access is ok"; |
| 436 | 452 | } |
| 437 | 453 | |
@@ -472,12 +488,15 @@ discard block |
||
| 472 | 488 | $sql = ''; |
| 473 | 489 | |
| 474 | 490 | // For backward compatibility |
| 475 | - if ($feature == 'member') |
|
| 476 | - $feature = 'adherent'; |
|
| 477 | - if ($feature == 'project') |
|
| 478 | - $feature = 'projet'; |
|
| 479 | - if ($feature == 'task') |
|
| 480 | - $feature = 'projet_task'; |
|
| 491 | + if ($feature == 'member') { |
|
| 492 | + $feature = 'adherent'; |
|
| 493 | + } |
|
| 494 | + if ($feature == 'project') { |
|
| 495 | + $feature = 'projet'; |
|
| 496 | + } |
|
| 497 | + if ($feature == 'task') { |
|
| 498 | + $feature = 'projet_task'; |
|
| 499 | + } |
|
| 481 | 500 | |
| 482 | 501 | $check = array('adherent', 'banque', 'don', 'user', 'usergroup', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource'); // Test on entity only (Objects with no link to company)
|
| 483 | 502 | $checksoc = array('societe'); // Test for societe object
|
@@ -519,8 +538,9 @@ discard block |
||
| 519 | 538 | } else if (in_array($feature, $checksoc)) { // We check feature = checksoc
|
| 520 | 539 | // If external user: Check permission for external users |
| 521 | 540 | if ($user->socid > 0) {
|
| 522 | - if ($user->socid <> $objectid) |
|
| 523 | - return false; |
|
| 541 | + if ($user->socid <> $objectid) { |
|
| 542 | + return false; |
|
| 543 | + } |
|
| 524 | 544 | } |
| 525 | 545 | // If internal user: Check permission for internal users that are restricted on their objects |
| 526 | 546 | else if (!empty(Globals::$conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) {
|
@@ -569,10 +589,10 @@ discard block |
||
| 569 | 589 | $projectstatic = new Project($db); |
| 570 | 590 | $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0); |
| 571 | 591 | $tmparray = explode(',', $tmps);
|
| 572 | - if (!in_array($objectid, $tmparray)) |
|
| 573 | - return false; |
|
| 574 | - } |
|
| 575 | - else {
|
|
| 592 | + if (!in_array($objectid, $tmparray)) { |
|
| 593 | + return false; |
|
| 594 | + } |
|
| 595 | + } else {
|
|
| 576 | 596 | $sql = "SELECT COUNT(dbt." . $dbt_select . ") as nb"; |
| 577 | 597 | $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt"; |
| 578 | 598 | $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
|
@@ -587,10 +607,10 @@ discard block |
||
| 587 | 607 | $projectstatic = new Project($db); |
| 588 | 608 | $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0); |
| 589 | 609 | $tmparray = explode(',', $tmps);
|
| 590 | - if (!in_array($task->fk_project, $tmparray)) |
|
| 591 | - return false; |
|
| 592 | - } |
|
| 593 | - else {
|
|
| 610 | + if (!in_array($task->fk_project, $tmparray)) { |
|
| 611 | + return false; |
|
| 612 | + } |
|
| 613 | + } else {
|
|
| 594 | 614 | $sql = "SELECT COUNT(dbt." . $dbt_select . ") as nb"; |
| 595 | 615 | $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt"; |
| 596 | 616 | $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
|
@@ -599,8 +619,9 @@ discard block |
||
| 599 | 619 | } else if (!in_array($feature, $nocheck)) { // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield
|
| 600 | 620 | // If external user: Check permission for external users |
| 601 | 621 | if ($user->socid > 0) {
|
| 602 | - if (empty($dbt_keyfield)) |
|
| 603 | - dol_print_error('', 'Param dbt_keyfield is required but not defined');
|
|
| 622 | + if (empty($dbt_keyfield)) { |
|
| 623 | + dol_print_error('', 'Param dbt_keyfield is required but not defined'); |
|
| 624 | + } |
|
| 604 | 625 | $sql = "SELECT COUNT(dbt." . $dbt_keyfield . ") as nb"; |
| 605 | 626 | $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt"; |
| 606 | 627 | $sql .= " WHERE dbt.rowid IN (" . $objectid . ")";
|
@@ -608,8 +629,9 @@ discard block |
||
| 608 | 629 | } |
| 609 | 630 | // If internal user: Check permission for internal users that are restricted on their objects |
| 610 | 631 | else if (!empty(Globals::$conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) {
|
| 611 | - if (empty($dbt_keyfield)) |
|
| 612 | - dol_print_error('', 'Param dbt_keyfield is required but not defined');
|
|
| 632 | + if (empty($dbt_keyfield)) { |
|
| 633 | + dol_print_error('', 'Param dbt_keyfield is required but not defined'); |
|
| 634 | + } |
|
| 613 | 635 | $sql = "SELECT COUNT(sc.fk_soc) as nb"; |
| 614 | 636 | $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt"; |
| 615 | 637 | $sql .= ", " . MAIN_DB_PREFIX . "societe as s"; |
@@ -633,10 +655,10 @@ discard block |
||
| 633 | 655 | $resql = $db->query($sql); |
| 634 | 656 | if ($resql) {
|
| 635 | 657 | $obj = $db->fetch_object($resql); |
| 636 | - if (!$obj || $obj->nb < count(explode(',', $objectid)))
|
|
| 637 | - return false; |
|
| 638 | - } |
|
| 639 | - else {
|
|
| 658 | + if (!$obj || $obj->nb < count(explode(',', $objectid))) { |
|
| 659 | + return false; |
|
| 660 | + } |
|
| 661 | + } else {
|
|
| 640 | 662 | return false; |
| 641 | 663 | } |
| 642 | 664 | } |
@@ -666,16 +688,18 @@ discard block |
||
| 666 | 688 | $langs->load("errors");
|
| 667 | 689 | |
| 668 | 690 | if ($printheader) {
|
| 669 | - if (function_exists("llxHeader"))
|
|
| 670 | - llxHeader('');
|
|
| 671 | - else if (function_exists("llxHeaderVierge"))
|
|
| 672 | - llxHeaderVierge('');
|
|
| 691 | + if (function_exists("llxHeader")) { |
|
| 692 | + llxHeader(''); |
|
| 693 | + } else if (function_exists("llxHeaderVierge")) { |
|
| 694 | + llxHeaderVierge(''); |
|
| 695 | + } |
|
| 673 | 696 | } |
| 674 | 697 | print '<div class="error">'; |
| 675 | - if (!$message) |
|
| 676 | - print $langs->trans("ErrorForbidden");
|
|
| 677 | - else |
|
| 678 | - print $message; |
|
| 698 | + if (!$message) { |
|
| 699 | + print $langs->trans("ErrorForbidden"); |
|
| 700 | + } else { |
|
| 701 | + print $message; |
|
| 702 | + } |
|
| 679 | 703 | print '</div>'; |
| 680 | 704 | print '<br>'; |
| 681 | 705 | if (empty($showonlymessage)) {
|
@@ -686,8 +710,9 @@ discard block |
||
| 686 | 710 | print $langs->trans("ErrorForbidden3");
|
| 687 | 711 | } |
| 688 | 712 | } |
| 689 | - if ($printfooter && function_exists("llxFooter"))
|
|
| 690 | - llxFooter(); |
|
| 713 | + if ($printfooter && function_exists("llxFooter")) { |
|
| 714 | + llxFooter(); |
|
| 715 | + } |
|
| 691 | 716 | exit(0); |
| 692 | 717 | } |
| 693 | 718 | } |
@@ -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 | DolUtils::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 | |
@@ -579,18 +596,20 @@ discard block |
||
| 579 | 596 | } |
| 580 | 597 | break; |
| 581 | 598 | case 'intcomma': |
| 582 | - if (preg_match('/[^0-9,-]+/i', $out))
|
|
| 583 | - $out = ''; |
|
| 599 | + if (preg_match('/[^0-9,-]+/i', $out)) { |
|
| 600 | + $out = ''; |
|
| 601 | + } |
|
| 584 | 602 | break; |
| 585 | 603 | case 'alpha': |
| 586 | 604 | if (!is_array($out)) {
|
| 587 | 605 | $out = trim($out); |
| 588 | 606 | // '"' is dangerous because param in url can close the href= or src= and add javascript functions. |
| 589 | 607 | // '../' is dangerous because it allows dir transversals |
| 590 | - if (preg_match('/"/', $out))
|
|
| 591 | - $out = ''; |
|
| 592 | - else if (preg_match('/\.\.\//', $out))
|
|
| 593 | - $out = ''; |
|
| 608 | + if (preg_match('/"/', $out)) { |
|
| 609 | + $out = ''; |
|
| 610 | + } else if (preg_match('/\.\.\//', $out)) { |
|
| 611 | + $out = ''; |
|
| 612 | + } |
|
| 594 | 613 | } |
| 595 | 614 | break; |
| 596 | 615 | case 'san_alpha': |
@@ -599,27 +618,31 @@ discard block |
||
| 599 | 618 | case 'aZ': |
| 600 | 619 | if (!is_array($out)) {
|
| 601 | 620 | $out = trim($out); |
| 602 | - if (preg_match('/[^a-z]+/i', $out))
|
|
| 603 | - $out = ''; |
|
| 621 | + if (preg_match('/[^a-z]+/i', $out)) { |
|
| 622 | + $out = ''; |
|
| 623 | + } |
|
| 604 | 624 | } |
| 605 | 625 | break; |
| 606 | 626 | case 'aZ09': |
| 607 | 627 | if (!is_array($out)) {
|
| 608 | 628 | $out = trim($out); |
| 609 | - if (preg_match('/[^a-z0-9_\-\.]+/i', $out))
|
|
| 610 | - $out = ''; |
|
| 629 | + if (preg_match('/[^a-z0-9_\-\.]+/i', $out)) { |
|
| 630 | + $out = ''; |
|
| 631 | + } |
|
| 611 | 632 | } |
| 612 | 633 | break; |
| 613 | 634 | case 'aZ09comma': // great to sanitize sortfield or sortorder params that can be t.abc,t.def_gh |
| 614 | 635 | if (!is_array($out)) {
|
| 615 | 636 | $out = trim($out); |
| 616 | - if (preg_match('/[^a-z0-9_\-\.,]+/i', $out))
|
|
| 617 | - $out = ''; |
|
| 637 | + if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) { |
|
| 638 | + $out = ''; |
|
| 639 | + } |
|
| 618 | 640 | } |
| 619 | 641 | break; |
| 620 | 642 | case 'array': |
| 621 | - if (!is_array($out) || empty($out)) |
|
| 622 | - $out = array(); |
|
| 643 | + if (!is_array($out) || empty($out)) { |
|
| 644 | + $out = array(); |
|
| 645 | + } |
|
| 623 | 646 | break; |
| 624 | 647 | case 'nohtml': // Recommended for most scalar parameters |
| 625 | 648 | $out = dol_string_nohtmltag($out, 0); |
@@ -629,16 +652,18 @@ discard block |
||
| 629 | 652 | $out = trim($out); |
| 630 | 653 | // '"' is dangerous because param in url can close the href= or src= and add javascript functions. |
| 631 | 654 | // '../' is dangerous because it allows dir transversals |
| 632 | - if (preg_match('/"/', $out))
|
|
| 633 | - $out = ''; |
|
| 634 | - else if (preg_match('/\.\.\//', $out))
|
|
| 635 | - $out = ''; |
|
| 655 | + if (preg_match('/"/', $out)) { |
|
| 656 | + $out = ''; |
|
| 657 | + } else if (preg_match('/\.\.\//', $out)) { |
|
| 658 | + $out = ''; |
|
| 659 | + } |
|
| 636 | 660 | $out = dol_string_nohtmltag($out); |
| 637 | 661 | } |
| 638 | 662 | break; |
| 639 | 663 | case 'custom': |
| 640 | - if (empty($filter)) |
|
| 641 | - return 'BadFourthParameterForDolUtils::GETPOST'; |
|
| 664 | + if (empty($filter)) { |
|
| 665 | + return 'BadFourthParameterForDolUtils::GETPOST'; |
|
| 666 | + } |
|
| 642 | 667 | $out = filter_var($out, $filter, $options); |
| 643 | 668 | break; |
| 644 | 669 | } |
@@ -756,11 +781,11 @@ discard block |
||
| 756 | 781 | } |
| 757 | 782 | } |
| 758 | 783 | if ($returnemptyifnotfound) { // Not found into alternate dir
|
| 759 | - if ($returnemptyifnotfound == 1 || !file_exists($res)) |
|
| 760 | - return ''; |
|
| 784 | + if ($returnemptyifnotfound == 1 || !file_exists($res)) { |
|
| 785 | + return ''; |
|
| 786 | + } |
|
| 761 | 787 | } |
| 762 | - } |
|
| 763 | - else { // For an url path
|
|
| 788 | + } else { // For an url path
|
|
| 764 | 789 | // We try to get local path of file on filesystem from url |
| 765 | 790 | // Note that trying to know if a file on disk exist by forging path on disk from url |
| 766 | 791 | // works only for some web server and some setup. This is bugged when |
@@ -854,12 +879,14 @@ discard block |
||
| 854 | 879 | static function dol_size($size, $type = '') |
| 855 | 880 | {
|
| 856 | 881 | //global Globals::$conf; |
| 857 | - if (empty(Globals::$conf->dol_optimize_smallscreen)) |
|
| 858 | - return $size; |
|
| 859 | - if ($type == 'width' && $size > 250) |
|
| 860 | - return 250; |
|
| 861 | - else |
|
| 862 | - return 10; |
|
| 882 | + if (empty(Globals::$conf->dol_optimize_smallscreen)) { |
|
| 883 | + return $size; |
|
| 884 | + } |
|
| 885 | + if ($type == 'width' && $size > 250) { |
|
| 886 | + return 250; |
|
| 887 | + } else { |
|
| 888 | + return 10; |
|
| 889 | + } |
|
| 863 | 890 | } |
| 864 | 891 | |
| 865 | 892 | /** |
@@ -959,9 +986,10 @@ discard block |
||
| 959 | 986 | {
|
| 960 | 987 | $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°'); // more complete than dol_sanitizeFileName
|
| 961 | 988 | $forbidden_chars_to_remove = array(); |
| 962 | - if (is_array($badcharstoreplace)) |
|
| 963 | - $forbidden_chars_to_replace = $badcharstoreplace; |
|
| 964 | -//$forbidden_chars_to_remove=array("(",")");
|
|
| 989 | + if (is_array($badcharstoreplace)) { |
|
| 990 | + $forbidden_chars_to_replace = $badcharstoreplace; |
|
| 991 | + } |
|
| 992 | + //$forbidden_chars_to_remove=array("(",")");
|
|
| 965 | 993 | |
| 966 | 994 | return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove, "", $str)); |
| 967 | 995 | } |
@@ -997,9 +1025,9 @@ discard block |
||
| 997 | 1025 | if (empty($mode)) {
|
| 998 | 1026 | $substitjs["'"] = "\\'"; |
| 999 | 1027 | $substitjs['"'] = "\\'"; |
| 1000 | - } else if ($mode == 1) |
|
| 1001 | - $substitjs["'"] = "\\'"; |
|
| 1002 | - else if ($mode == 2) {
|
|
| 1028 | + } else if ($mode == 1) { |
|
| 1029 | + $substitjs["'"] = "\\'"; |
|
| 1030 | + } else if ($mode == 2) {
|
|
| 1003 | 1031 | $substitjs['"'] = '\\"'; |
| 1004 | 1032 | } else if ($mode == 3) {
|
| 1005 | 1033 | $substitjs["'"] = "\\'"; |
@@ -1021,10 +1049,12 @@ discard block |
||
| 1021 | 1049 | {
|
| 1022 | 1050 | // escape quotes and backslashes, newlines, etc. |
| 1023 | 1051 | $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars_decode instead, that make only required change for html tags |
| 1024 | - if (!$keepb) |
|
| 1025 | - $tmp = strtr($tmp, array("<b>" => '', '</b>' => ''));
|
|
| 1026 | - if (!$keepn) |
|
| 1027 | - $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n'));
|
|
| 1052 | + if (!$keepb) { |
|
| 1053 | + $tmp = strtr($tmp, array("<b>" => '', '</b>' => '')); |
|
| 1054 | + } |
|
| 1055 | + if (!$keepn) { |
|
| 1056 | + $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n')); |
|
| 1057 | + } |
|
| 1028 | 1058 | return htmlentities($tmp, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars instead, that make only required change for html tags |
| 1029 | 1059 | } |
| 1030 | 1060 | |
@@ -1074,8 +1104,9 @@ discard block |
||
| 1074 | 1104 | {
|
| 1075 | 1105 | // global Globals::$conf, $user; |
| 1076 | 1106 | // If syslog module enabled |
| 1077 | - if (empty(Globals::$conf->syslog->enabled)) |
|
| 1078 | - return; |
|
| 1107 | + if (empty(Globals::$conf->syslog->enabled)) { |
|
| 1108 | + return; |
|
| 1109 | + } |
|
| 1079 | 1110 | |
| 1080 | 1111 | if ($ident < 0) {
|
| 1081 | 1112 | foreach (Globals::$conf->loghandlers as $loghandlerinstance) {
|
@@ -1089,8 +1120,9 @@ discard block |
||
| 1089 | 1120 | if (!in_array($level, $logLevels, true)) {
|
| 1090 | 1121 | throw new Exception('Incorrect log level');
|
| 1091 | 1122 | } |
| 1092 | - if ($level > Globals::$conf->global->SYSLOG_LEVEL) |
|
| 1093 | - return; |
|
| 1123 | + if ($level > Globals::$conf->global->SYSLOG_LEVEL) { |
|
| 1124 | + return; |
|
| 1125 | + } |
|
| 1094 | 1126 | |
| 1095 | 1127 | $message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log
|
| 1096 | 1128 | // If adding log inside HTML page is required |
@@ -1115,24 +1147,30 @@ discard block |
||
| 1115 | 1147 | ); |
| 1116 | 1148 | |
| 1117 | 1149 | // This is when server run behind a reverse proxy |
| 1118 | - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) |
|
| 1119 | - $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']); |
|
| 1120 | -// This is when server run normally on a server |
|
| 1121 | - else if (!empty($_SERVER["REMOTE_ADDR"])) |
|
| 1122 | - $data['ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 1123 | -// This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) |
|
| 1124 | - else if (!empty($_SERVER['SERVER_ADDR'])) |
|
| 1125 | - $data['ip'] = $_SERVER['SERVER_ADDR']; |
|
| 1126 | -// 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). |
|
| 1127 | - else if (!empty($_SERVER['COMPUTERNAME'])) |
|
| 1128 | - $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']); |
|
| 1129 | -// 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). |
|
| 1130 | - else if (!empty($_SERVER['LOGNAME'])) |
|
| 1131 | - $data['ip'] = '???@' . $_SERVER['LOGNAME']; |
|
| 1132 | -// Loop on each log handler and send output |
|
| 1150 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 1151 | + $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']); |
|
| 1152 | + } |
|
| 1153 | + // This is when server run normally on a server |
|
| 1154 | + else if (!empty($_SERVER["REMOTE_ADDR"])) { |
|
| 1155 | + $data['ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 1156 | + } |
|
| 1157 | + // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) |
|
| 1158 | + else if (!empty($_SERVER['SERVER_ADDR'])) { |
|
| 1159 | + $data['ip'] = $_SERVER['SERVER_ADDR']; |
|
| 1160 | + } |
|
| 1161 | + // 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). |
|
| 1162 | + else if (!empty($_SERVER['COMPUTERNAME'])) { |
|
| 1163 | + $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']); |
|
| 1164 | + } |
|
| 1165 | + // 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). |
|
| 1166 | + else if (!empty($_SERVER['LOGNAME'])) { |
|
| 1167 | + $data['ip'] = '???@' . $_SERVER['LOGNAME']; |
|
| 1168 | + } |
|
| 1169 | + // Loop on each log handler and send output |
|
| 1133 | 1170 | foreach (Globals::$conf->loghandlers as $loghandlerinstance) {
|
| 1134 | - if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) |
|
| 1135 | - continue; |
|
| 1171 | + if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) { |
|
| 1172 | + continue; |
|
| 1173 | + } |
|
| 1136 | 1174 | $loghandlerinstance->export($data, $suffixinfilename); |
| 1137 | 1175 | } |
| 1138 | 1176 | unset($data); |
@@ -1188,13 +1226,15 @@ discard block |
||
| 1188 | 1226 | |
| 1189 | 1227 | // Show title |
| 1190 | 1228 | $showtitle = 1; |
| 1191 | - if (!empty(Globals::$conf->dol_optimize_smallscreen)) |
|
| 1192 | - $showtitle = 0; |
|
| 1229 | + if (!empty(Globals::$conf->dol_optimize_smallscreen)) { |
|
| 1230 | + $showtitle = 0; |
|
| 1231 | + } |
|
| 1193 | 1232 | if (!empty($title) && $showtitle) {
|
| 1194 | 1233 | $limittitle = 30; |
| 1195 | 1234 | $out .= '<a class="tabTitle">'; |
| 1196 | - if ($picto) |
|
| 1197 | - $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' '; |
|
| 1235 | + if ($picto) { |
|
| 1236 | + $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' '; |
|
| 1237 | + } |
|
| 1198 | 1238 | $out .= '<span class="tabTitleText">' . dol_trunc($title, $limittitle) . '</span>'; |
| 1199 | 1239 | $out .= '</a>'; |
| 1200 | 1240 | } |
@@ -1203,12 +1243,14 @@ discard block |
||
| 1203 | 1243 | $maxkey = -1; |
| 1204 | 1244 | if (is_array($links) && !empty($links)) {
|
| 1205 | 1245 | $keys = array_keys($links); |
| 1206 | - if (count($keys)) |
|
| 1207 | - $maxkey = max($keys); |
|
| 1246 | + if (count($keys)) { |
|
| 1247 | + $maxkey = max($keys); |
|
| 1248 | + } |
|
| 1208 | 1249 | } |
| 1209 | 1250 | |
| 1210 | - if (!empty(Globals::$conf->dol_optimize_smallscreen)) |
|
| 1211 | - Globals::$conf->global->MAIN_MAXTABS_IN_CARD = 2; |
|
| 1251 | + if (!empty(Globals::$conf->dol_optimize_smallscreen)) { |
|
| 1252 | + Globals::$conf->global->MAIN_MAXTABS_IN_CARD = 2; |
|
| 1253 | + } |
|
| 1212 | 1254 | |
| 1213 | 1255 | // Show tabs |
| 1214 | 1256 | $bactive = false; |
@@ -1221,8 +1263,9 @@ discard block |
||
| 1221 | 1263 | for ($i = 0; $i <= $maxkey; $i++) {
|
| 1222 | 1264 | if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
|
| 1223 | 1265 | // If active tab is already present |
| 1224 | - if ($i >= $limittoshow) |
|
| 1225 | - $limittoshow--; |
|
| 1266 | + if ($i >= $limittoshow) { |
|
| 1267 | + $limittoshow--; |
|
| 1268 | + } |
|
| 1226 | 1269 | } |
| 1227 | 1270 | } |
| 1228 | 1271 | |
@@ -1263,12 +1306,12 @@ discard block |
||
| 1263 | 1306 | } |
| 1264 | 1307 | $outmore .= '<div class="popuptab wordwrap" style="display:inherit;">'; |
| 1265 | 1308 | if (isset($links[$i][2]) && $links[$i][2] == 'image') {
|
| 1266 | - if (!empty($links[$i][0])) |
|
| 1267 | - $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n"; |
|
| 1268 | - else |
|
| 1269 | - $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n"; |
|
| 1270 | - } |
|
| 1271 | - else if (!empty($links[$i][1])) {
|
|
| 1309 | + if (!empty($links[$i][0])) { |
|
| 1310 | + $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n"; |
|
| 1311 | + } else { |
|
| 1312 | + $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n"; |
|
| 1313 | + } |
|
| 1314 | + } else if (!empty($links[$i][1])) {
|
|
| 1272 | 1315 | $outmore .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="wordwrap inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">'; |
| 1273 | 1316 | $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.
|
| 1274 | 1317 | $outmore .= '</a>' . "\n"; |
@@ -1279,8 +1322,9 @@ discard block |
||
| 1279 | 1322 | } |
| 1280 | 1323 | $displaytab = $i; |
| 1281 | 1324 | } |
| 1282 | - if ($popuptab) |
|
| 1283 | - $outmore .= '</div>'; |
|
| 1325 | + if ($popuptab) { |
|
| 1326 | + $outmore .= '</div>'; |
|
| 1327 | + } |
|
| 1284 | 1328 | |
| 1285 | 1329 | if ($displaytab > $limittoshow) {
|
| 1286 | 1330 | $left = (Globals::$langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
|
@@ -1303,8 +1347,9 @@ discard block |
||
| 1303 | 1347 | |
| 1304 | 1348 | $out .= "</div>\n"; |
| 1305 | 1349 | |
| 1306 | - if (!$notab || $notab == -1) |
|
| 1307 | - $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n"; |
|
| 1350 | + if (!$notab || $notab == -1) { |
|
| 1351 | + $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n"; |
|
| 1352 | + } |
|
| 1308 | 1353 | |
| 1309 | 1354 | $parameters = array('tabname' => $active, 'out' => $out);
|
| 1310 | 1355 | $reshook = Globals::$hookManager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead"
|
@@ -1334,10 +1379,11 @@ discard block |
||
| 1334 | 1379 | */ |
| 1335 | 1380 | static function dol_get_fiche_end($notab = 0) |
| 1336 | 1381 | {
|
| 1337 | - if (!$notab || $notab == -1) |
|
| 1338 | - return "\n</div>\n"; |
|
| 1339 | - else |
|
| 1340 | - return ''; |
|
| 1382 | + if (!$notab || $notab == -1) { |
|
| 1383 | + return "\n</div>\n"; |
|
| 1384 | + } else { |
|
| 1385 | + return ''; |
|
| 1386 | + } |
|
| 1341 | 1387 | } |
| 1342 | 1388 | |
| 1343 | 1389 | /** |
@@ -1369,8 +1415,9 @@ discard block |
||
| 1369 | 1415 | $showimage = 1; |
| 1370 | 1416 | $entity = (empty($object->entity) ? Globals::$conf->entity : $object->entity); |
| 1371 | 1417 | $showbarcode = empty(Globals::$conf->barcode->enabled) ? 0 : ($object->barcode ? 1 : 0); |
| 1372 | - if (!empty(Globals::$conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) |
|
| 1373 | - $showbarcode = 0; |
|
| 1418 | + if (!empty(Globals::$conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { |
|
| 1419 | + $showbarcode = 0; |
|
| 1420 | + } |
|
| 1374 | 1421 | $modulepart = 'unknown'; |
| 1375 | 1422 | |
| 1376 | 1423 | if ($object->element == 'societe') {
|
@@ -1475,8 +1522,10 @@ discard block |
||
| 1475 | 1522 | } else {
|
| 1476 | 1523 | $subdir = get_exdir($object->id, 0, 0, 1, $object, $modulepart); |
| 1477 | 1524 | } |
| 1478 | - if (empty($subdir)) |
|
| 1479 | - $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path |
|
| 1525 | + if (empty($subdir)) { |
|
| 1526 | + $subdir = 'errorgettingsubdirofobject'; |
|
| 1527 | + } |
|
| 1528 | + // Protection to avoid to return empty path |
|
| 1480 | 1529 | |
| 1481 | 1530 | $filepath = $dir_output . $subdir . "/"; |
| 1482 | 1531 | |
@@ -1497,14 +1546,16 @@ discard block |
||
| 1497 | 1546 | if (empty(Globals::$conf->global->MAIN_DISABLE_PDF_THUMBS)) { // If you experienc trouble with pdf thumb generation and imagick, you can disable here.
|
| 1498 | 1547 | include_once DOL_BASE_PATH . '/core/lib/files.lib.php'; |
| 1499 | 1548 | $ret = dol_convert_file($file, 'png', $fileimage); |
| 1500 | - if ($ret < 0) |
|
| 1501 | - $error++; |
|
| 1549 | + if ($ret < 0) { |
|
| 1550 | + $error++; |
|
| 1551 | + } |
|
| 1502 | 1552 | } |
| 1503 | 1553 | } |
| 1504 | 1554 | |
| 1505 | 1555 | $heightforphotref = 70; |
| 1506 | - if (!empty(Globals::$conf->dol_optimize_smallscreen)) |
|
| 1507 | - $heightforphotref = 60; |
|
| 1556 | + if (!empty(Globals::$conf->dol_optimize_smallscreen)) { |
|
| 1557 | + $heightforphotref = 60; |
|
| 1558 | + } |
|
| 1508 | 1559 | // Si fichier png PDF d'1 page trouve |
| 1509 | 1560 | if (file_exists($fileimage)) {
|
| 1510 | 1561 | $phototoshow = '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">'; |
@@ -1540,8 +1591,10 @@ discard block |
||
| 1540 | 1591 | $width = 14; |
| 1541 | 1592 | $cssclass = 'photorefcenter'; |
| 1542 | 1593 | $picto = $object->picto; |
| 1543 | - if ($object->element == 'project' && !$object->public) |
|
| 1544 | - $picto = 'project'; // instead of projectpub |
|
| 1594 | + if ($object->element == 'project' && !$object->public) { |
|
| 1595 | + $picto = 'project'; |
|
| 1596 | + } |
|
| 1597 | + // instead of projectpub |
|
| 1545 | 1598 | $nophoto = img_picto('', 'object_' . $picto, '', false, 1);
|
| 1546 | 1599 | } |
| 1547 | 1600 | $morehtmlleft .= '<!-- No photo to show -->'; |
@@ -1552,8 +1605,9 @@ discard block |
||
| 1552 | 1605 | } |
| 1553 | 1606 | } |
| 1554 | 1607 | |
| 1555 | - if ($showbarcode) |
|
| 1556 | - $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>'; |
|
| 1608 | + if ($showbarcode) { |
|
| 1609 | + $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>'; |
|
| 1610 | + } |
|
| 1557 | 1611 | |
| 1558 | 1612 | if ($object->element == 'societe') {
|
| 1559 | 1613 | if (!empty(Globals::$conf->use_javascript_ajax) && $user->rights->societe->creer && !empty(Globals::$conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
|
@@ -1577,35 +1631,37 @@ discard block |
||
| 1577 | 1631 | } |
| 1578 | 1632 | } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) {
|
| 1579 | 1633 | $tmptxt = $object->getLibStatut(6, $object->totalpaye); |
| 1580 | - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone') |
|
| 1581 | - $tmptxt = $object->getLibStatut(5, $object->totalpaye); |
|
| 1634 | + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone') { |
|
| 1635 | + $tmptxt = $object->getLibStatut(5, $object->totalpaye); |
|
| 1636 | + } |
|
| 1582 | 1637 | $morehtmlstatus .= $tmptxt; |
| 1583 | - } |
|
| 1584 | - elseif ($object->element == 'contrat' || $object->element == 'contract') {
|
|
| 1585 | - if ($object->statut == 0) |
|
| 1586 | - $morehtmlstatus .= $object->getLibStatut(5); |
|
| 1587 | - else |
|
| 1588 | - $morehtmlstatus .= $object->getLibStatut(4); |
|
| 1589 | - } |
|
| 1590 | - elseif ($object->element == 'facturerec') {
|
|
| 1591 | - if ($object->frequency == 0) |
|
| 1592 | - $morehtmlstatus .= $object->getLibStatut(2); |
|
| 1593 | - else |
|
| 1594 | - $morehtmlstatus .= $object->getLibStatut(5); |
|
| 1595 | - } |
|
| 1596 | - elseif ($object->element == 'project_task') {
|
|
| 1638 | + } elseif ($object->element == 'contrat' || $object->element == 'contract') {
|
|
| 1639 | + if ($object->statut == 0) { |
|
| 1640 | + $morehtmlstatus .= $object->getLibStatut(5); |
|
| 1641 | + } else { |
|
| 1642 | + $morehtmlstatus .= $object->getLibStatut(4); |
|
| 1643 | + } |
|
| 1644 | + } elseif ($object->element == 'facturerec') {
|
|
| 1645 | + if ($object->frequency == 0) { |
|
| 1646 | + $morehtmlstatus .= $object->getLibStatut(2); |
|
| 1647 | + } else { |
|
| 1648 | + $morehtmlstatus .= $object->getLibStatut(5); |
|
| 1649 | + } |
|
| 1650 | + } elseif ($object->element == 'project_task') {
|
|
| 1597 | 1651 | $object->fk_statut = 1; |
| 1598 | - if ($object->progress > 0) |
|
| 1599 | - $object->fk_statut = 2; |
|
| 1600 | - if ($object->progress >= 100) |
|
| 1601 | - $object->fk_statut = 3; |
|
| 1652 | + if ($object->progress > 0) { |
|
| 1653 | + $object->fk_statut = 2; |
|
| 1654 | + } |
|
| 1655 | + if ($object->progress >= 100) { |
|
| 1656 | + $object->fk_statut = 3; |
|
| 1657 | + } |
|
| 1602 | 1658 | $tmptxt = $object->getLibStatut(5); |
| 1603 | 1659 | $morehtmlstatus .= $tmptxt; // No status on task |
| 1604 | - } |
|
| 1605 | - else { // Generic case
|
|
| 1660 | + } else { // Generic case
|
|
| 1606 | 1661 | $tmptxt = $object->getLibStatut(6); |
| 1607 | - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone') |
|
| 1608 | - $tmptxt = $object->getLibStatut(5); |
|
| 1662 | + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone') { |
|
| 1663 | + $tmptxt = $object->getLibStatut(5); |
|
| 1664 | + } |
|
| 1609 | 1665 | $morehtmlstatus .= $tmptxt; |
| 1610 | 1666 | } |
| 1611 | 1667 | |
@@ -1619,13 +1675,15 @@ discard block |
||
| 1619 | 1675 | } |
| 1620 | 1676 | |
| 1621 | 1677 | // Add alias for thirdparty |
| 1622 | - if (!empty($object->name_alias)) |
|
| 1623 | - $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>'; |
|
| 1678 | + if (!empty($object->name_alias)) { |
|
| 1679 | + $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>'; |
|
| 1680 | + } |
|
| 1624 | 1681 | |
| 1625 | 1682 | // Add label |
| 1626 | 1683 | if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task') {
|
| 1627 | - if (!empty($object->label)) |
|
| 1628 | - $morehtmlref .= '<div class="refidno">' . $object->label . '</div>'; |
|
| 1684 | + if (!empty($object->label)) { |
|
| 1685 | + $morehtmlref .= '<div class="refidno">' . $object->label . '</div>'; |
|
| 1686 | + } |
|
| 1629 | 1687 | } |
| 1630 | 1688 | |
| 1631 | 1689 | if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') {
|
@@ -1658,15 +1716,19 @@ discard block |
||
| 1658 | 1716 | {
|
| 1659 | 1717 | // global Globals::$conf, Globals::$langs; |
| 1660 | 1718 | $ret = ''; |
| 1661 | - if ($fieldrequired) |
|
| 1662 | - $ret .= '<span class="fieldrequired">'; |
|
| 1663 | - if ((Globals::$conf->dol_use_jmobile != 4)) |
|
| 1664 | - $ret .= '<label for="' . $fieldkey . '">'; |
|
| 1719 | + if ($fieldrequired) { |
|
| 1720 | + $ret .= '<span class="fieldrequired">'; |
|
| 1721 | + } |
|
| 1722 | + if ((Globals::$conf->dol_use_jmobile != 4)) { |
|
| 1723 | + $ret .= '<label for="' . $fieldkey . '">'; |
|
| 1724 | + } |
|
| 1665 | 1725 | $ret .= Globals::$langs->trans($langkey); |
| 1666 | - if ((Globals::$conf->dol_use_jmobile != 4)) |
|
| 1667 | - $ret .= '</label>'; |
|
| 1668 | - if ($fieldrequired) |
|
| 1669 | - $ret .= '</span>'; |
|
| 1726 | + if ((Globals::$conf->dol_use_jmobile != 4)) { |
|
| 1727 | + $ret .= '</label>'; |
|
| 1728 | + } |
|
| 1729 | + if ($fieldrequired) { |
|
| 1730 | + $ret .= '</span>'; |
|
| 1731 | + } |
|
| 1670 | 1732 | return $ret; |
| 1671 | 1733 | } |
| 1672 | 1734 | |
@@ -1681,8 +1743,9 @@ discard block |
||
| 1681 | 1743 | {
|
| 1682 | 1744 | // global $bc; |
| 1683 | 1745 | $ret = ' ' . $bc[$var]; |
| 1684 | - if ($moreclass) |
|
| 1685 | - $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret);
|
|
| 1746 | + if ($moreclass) { |
|
| 1747 | + $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret); |
|
| 1748 | + } |
|
| 1686 | 1749 | return $ret; |
| 1687 | 1750 | } |
| 1688 | 1751 | |
@@ -1713,18 +1776,18 @@ discard block |
||
| 1713 | 1776 | if ($object->state) {
|
| 1714 | 1777 | $ret .= ($ret ? ", " : '') . $object->state; |
| 1715 | 1778 | } |
| 1716 | - if ($object->zip) |
|
| 1717 | - $ret .= ($ret ? ", " : '') . $object->zip; |
|
| 1718 | - } |
|
| 1719 | - else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country
|
|
| 1779 | + if ($object->zip) { |
|
| 1780 | + $ret .= ($ret ? ", " : '') . $object->zip; |
|
| 1781 | + } |
|
| 1782 | + } else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country
|
|
| 1720 | 1783 | $ret .= ($ret ? $sep : '' ) . $object->town; |
| 1721 | 1784 | if ($object->state) {
|
| 1722 | 1785 | $ret .= ($ret ? ", " : '') . $object->state; |
| 1723 | 1786 | } |
| 1724 | - if ($object->zip) |
|
| 1725 | - $ret .= ($ret ? $sep : '' ) . $object->zip; |
|
| 1726 | - } |
|
| 1727 | - else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country
|
|
| 1787 | + if ($object->zip) { |
|
| 1788 | + $ret .= ($ret ? $sep : '' ) . $object->zip; |
|
| 1789 | + } |
|
| 1790 | + } else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country
|
|
| 1728 | 1791 | $ret .= ($ret ? $sep : '' ) . $object->zip; |
| 1729 | 1792 | $ret .= ($object->town ? (($object->zip ? ' ' : '') . $object->town) : ''); |
| 1730 | 1793 | if ($object->state) {
|
@@ -1741,8 +1804,9 @@ discard block |
||
| 1741 | 1804 | $ret .= ($ret ? ", " : '') . $object->state; |
| 1742 | 1805 | } |
| 1743 | 1806 | } |
| 1744 | - if (!is_object($outputlangs)) |
|
| 1745 | - $outputlangs = Globals::$langs; |
|
| 1807 | + if (!is_object($outputlangs)) { |
|
| 1808 | + $outputlangs = Globals::$langs; |
|
| 1809 | + } |
|
| 1746 | 1810 | if ($withcountry) {
|
| 1747 | 1811 | Globals::$langs->load("dict");
|
| 1748 | 1812 | $ret .= ($object->country_code ? ($ret ? $sep : '') . $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country" . $object->country_code)) : '');
|
@@ -1763,8 +1827,9 @@ discard block |
||
| 1763 | 1827 | {
|
| 1764 | 1828 | if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
|
| 1765 | 1829 | return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts); |
| 1766 | - } else |
|
| 1767 | - return 'Error date into a not supported range'; |
|
| 1830 | + } else { |
|
| 1831 | + return 'Error date into a not supported range'; |
|
| 1832 | + } |
|
| 1768 | 1833 | } |
| 1769 | 1834 | |
| 1770 | 1835 | /** |
@@ -1810,10 +1875,12 @@ discard block |
||
| 1810 | 1875 | } |
| 1811 | 1876 | } |
| 1812 | 1877 | } |
| 1813 | - if (!is_object($outputlangs)) |
|
| 1814 | - $outputlangs = Globals::$langs; |
|
| 1815 | - if (!$format) |
|
| 1816 | - $format = 'daytextshort'; |
|
| 1878 | + if (!is_object($outputlangs)) { |
|
| 1879 | + $outputlangs = Globals::$langs; |
|
| 1880 | + } |
|
| 1881 | + if (!$format) { |
|
| 1882 | + $format = 'daytextshort'; |
|
| 1883 | + } |
|
| 1817 | 1884 | $reduceformat = (!empty(Globals::$conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0;
|
| 1818 | 1885 | $formatwithoutreduce = preg_replace('/reduceformat/', '', $format);
|
| 1819 | 1886 | if ($formatwithoutreduce != $format) {
|
@@ -1822,40 +1889,46 @@ discard block |
||
| 1822 | 1889 | } // so format 'dayreduceformat' is processed like day |
| 1823 | 1890 | // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. |
| 1824 | 1891 | // TODO Add format daysmallyear and dayhoursmallyear |
| 1825 | - if ($format == 'day') |
|
| 1826 | - $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : Globals::$conf->format_date_short);
|
|
| 1827 | - else if ($format == 'hour') |
|
| 1828 | - $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : Globals::$conf->format_hour_short);
|
|
| 1829 | - else if ($format == 'hourduration') |
|
| 1830 | - $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : Globals::$conf->format_hour_short_duration);
|
|
| 1831 | - else if ($format == 'daytext') |
|
| 1832 | - $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : Globals::$conf->format_date_text);
|
|
| 1833 | - else if ($format == 'daytextshort') |
|
| 1834 | -// Notice: Undefined property: stdClass::$format_date_text_short in \alixar\dolibarr\htdocs\core\lib\functions.lib.php on line 1781 |
|
| 1835 | - $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : Globals::$conf->format_date_text_short);
|
|
| 1836 | - else if ($format == 'dayhour') |
|
| 1837 | - $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : Globals::$conf->format_date_hour_short ?? "%d/%m/%Y %H:%M");
|
|
| 1838 | - else if ($format == 'dayhoursec') |
|
| 1839 | - $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : Globals::$conf->format_date_hour_sec_short);
|
|
| 1840 | - else if ($format == 'dayhourtext') |
|
| 1841 | - $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : Globals::$conf->format_date_hour_text);
|
|
| 1842 | - else if ($format == 'dayhourtextshort') |
|
| 1843 | - $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : Globals::$conf->format_date_hour_text_short);
|
|
| 1844 | -// Format not sensitive to language |
|
| 1845 | - else if ($format == 'dayhourlog') |
|
| 1846 | - $format = '%Y%m%d%H%M%S'; |
|
| 1847 | - else if ($format == 'dayhourldap') |
|
| 1848 | - $format = '%Y%m%d%H%M%SZ'; |
|
| 1849 | - else if ($format == 'dayhourxcard') |
|
| 1850 | - $format = '%Y%m%dT%H%M%SZ'; |
|
| 1851 | - else if ($format == 'dayxcard') |
|
| 1852 | - $format = '%Y%m%d'; |
|
| 1853 | - else if ($format == 'dayrfc') |
|
| 1854 | - $format = '%Y-%m-%d'; // DATE_RFC3339 |
|
| 1855 | - else if ($format == 'dayhourrfc') |
|
| 1856 | - $format = '%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 |
|
| 1857 | - else if ($format == 'standard') |
|
| 1858 | - $format = '%Y-%m-%d %H:%M:%S'; |
|
| 1892 | + if ($format == 'day') { |
|
| 1893 | + $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : Globals::$conf->format_date_short); |
|
| 1894 | + } else if ($format == 'hour') { |
|
| 1895 | + $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : Globals::$conf->format_hour_short); |
|
| 1896 | + } else if ($format == 'hourduration') { |
|
| 1897 | + $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : Globals::$conf->format_hour_short_duration); |
|
| 1898 | + } else if ($format == 'daytext') { |
|
| 1899 | + $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : Globals::$conf->format_date_text); |
|
| 1900 | + } else if ($format == 'daytextshort') { |
|
| 1901 | + // Notice: Undefined property: stdClass::$format_date_text_short in \alixar\dolibarr\htdocs\core\lib\functions.lib.php on line 1781 |
|
| 1902 | + $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : Globals::$conf->format_date_text_short); |
|
| 1903 | + } else if ($format == 'dayhour') { |
|
| 1904 | + $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : Globals::$conf->format_date_hour_short ?? "%d/%m/%Y %H:%M"); |
|
| 1905 | + } else if ($format == 'dayhoursec') { |
|
| 1906 | + $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : Globals::$conf->format_date_hour_sec_short); |
|
| 1907 | + } else if ($format == 'dayhourtext') { |
|
| 1908 | + $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : Globals::$conf->format_date_hour_text); |
|
| 1909 | + } else if ($format == 'dayhourtextshort') { |
|
| 1910 | + $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : Globals::$conf->format_date_hour_text_short); |
|
| 1911 | + } |
|
| 1912 | + // Format not sensitive to language |
|
| 1913 | + else if ($format == 'dayhourlog') { |
|
| 1914 | + $format = '%Y%m%d%H%M%S'; |
|
| 1915 | + } else if ($format == 'dayhourldap') { |
|
| 1916 | + $format = '%Y%m%d%H%M%SZ'; |
|
| 1917 | + } else if ($format == 'dayhourxcard') { |
|
| 1918 | + $format = '%Y%m%dT%H%M%SZ'; |
|
| 1919 | + } else if ($format == 'dayxcard') { |
|
| 1920 | + $format = '%Y%m%d'; |
|
| 1921 | + } else if ($format == 'dayrfc') { |
|
| 1922 | + $format = '%Y-%m-%d'; |
|
| 1923 | + } |
|
| 1924 | + // DATE_RFC3339 |
|
| 1925 | + else if ($format == 'dayhourrfc') { |
|
| 1926 | + $format = '%Y-%m-%dT%H:%M:%SZ'; |
|
| 1927 | + } |
|
| 1928 | + // DATETIME RFC3339 |
|
| 1929 | + else if ($format == 'standard') { |
|
| 1930 | + $format = '%Y-%m-%d %H:%M:%S'; |
|
| 1931 | + } |
|
| 1859 | 1932 | |
| 1860 | 1933 | if ($reduceformat) {
|
| 1861 | 1934 | $format = str_replace('%Y', '%y', $format);
|
@@ -1863,8 +1936,10 @@ discard block |
||
| 1863 | 1936 | } |
| 1864 | 1937 | |
| 1865 | 1938 | // If date undefined or "", we return "" |
| 1866 | - if (DolUtils::dol_strlen($time) == 0) |
|
| 1867 | - return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) |
|
| 1939 | + if (DolUtils::dol_strlen($time) == 0) { |
|
| 1940 | + return ''; |
|
| 1941 | + } |
|
| 1942 | + // $time=0 allowed (it means 01/01/1970 00:00:00) |
|
| 1868 | 1943 | |
| 1869 | 1944 | |
| 1870 | 1945 | |
@@ -1934,8 +2009,9 @@ discard block |
||
| 1934 | 2009 | $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with static function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. |
| 1935 | 2010 | |
| 1936 | 2011 | $ret = adodb_strftime($format, $timetouse, $to_gmt); |
| 1937 | - } else |
|
| 1938 | - $ret = 'Bad value ' . $time . ' for date'; |
|
| 2012 | + } else { |
|
| 2013 | + $ret = 'Bad value ' . $time . ' for date'; |
|
| 2014 | + } |
|
| 1939 | 2015 | } |
| 1940 | 2016 | |
| 1941 | 2017 | if (preg_match('/__b__/i', $format)) {
|
@@ -2006,10 +2082,14 @@ discard block |
||
| 2006 | 2082 | // global Globals::$conf; |
| 2007 | 2083 | |
| 2008 | 2084 | $usealternatemethod = false; |
| 2009 | - if ($timestamp <= 0) |
|
| 2010 | - $usealternatemethod = true; // <= 1970 |
|
| 2011 | - if ($timestamp >= 2145913200) |
|
| 2012 | - $usealternatemethod = true; // >= 2038 |
|
| 2085 | + if ($timestamp <= 0) { |
|
| 2086 | + $usealternatemethod = true; |
|
| 2087 | + } |
|
| 2088 | + // <= 1970 |
|
| 2089 | + if ($timestamp >= 2145913200) { |
|
| 2090 | + $usealternatemethod = true; |
|
| 2091 | + } |
|
| 2092 | + // >= 2038 |
|
| 2013 | 2093 | |
| 2014 | 2094 | if ($usealternatemethod) {
|
| 2015 | 2095 | $arrayinfo = adodb_getdate($timestamp, $fast); |
@@ -2044,27 +2124,36 @@ discard block |
||
| 2044 | 2124 | // global Globals::$conf; |
| 2045 | 2125 | //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; |
| 2046 | 2126 | // Clean parameters |
| 2047 | - if ($hour == -1 || empty($hour)) |
|
| 2048 | - $hour = 0; |
|
| 2049 | - if ($minute == -1 || empty($minute)) |
|
| 2050 | - $minute = 0; |
|
| 2051 | - if ($second == -1 || empty($second)) |
|
| 2052 | - $second = 0; |
|
| 2127 | + if ($hour == -1 || empty($hour)) { |
|
| 2128 | + $hour = 0; |
|
| 2129 | + } |
|
| 2130 | + if ($minute == -1 || empty($minute)) { |
|
| 2131 | + $minute = 0; |
|
| 2132 | + } |
|
| 2133 | + if ($second == -1 || empty($second)) { |
|
| 2134 | + $second = 0; |
|
| 2135 | + } |
|
| 2053 | 2136 | |
| 2054 | 2137 | // Check parameters |
| 2055 | 2138 | if ($check) {
|
| 2056 | - if (!$month || !$day) |
|
| 2057 | - return ''; |
|
| 2058 | - if ($day > 31) |
|
| 2059 | - return ''; |
|
| 2060 | - if ($month > 12) |
|
| 2061 | - return ''; |
|
| 2062 | - if ($hour < 0 || $hour > 24) |
|
| 2063 | - return ''; |
|
| 2064 | - if ($minute < 0 || $minute > 60) |
|
| 2065 | - return ''; |
|
| 2066 | - if ($second < 0 || $second > 60) |
|
| 2067 | - return ''; |
|
| 2139 | + if (!$month || !$day) { |
|
| 2140 | + return ''; |
|
| 2141 | + } |
|
| 2142 | + if ($day > 31) { |
|
| 2143 | + return ''; |
|
| 2144 | + } |
|
| 2145 | + if ($month > 12) { |
|
| 2146 | + return ''; |
|
| 2147 | + } |
|
| 2148 | + if ($hour < 0 || $hour > 24) { |
|
| 2149 | + return ''; |
|
| 2150 | + } |
|
| 2151 | + if ($minute < 0 || $minute > 60) { |
|
| 2152 | + return ''; |
|
| 2153 | + } |
|
| 2154 | + if ($second < 0 || $second > 60) { |
|
| 2155 | + return ''; |
|
| 2156 | + } |
|
| 2068 | 2157 | } |
| 2069 | 2158 | |
| 2070 | 2159 | if (method_exists('DateTime', 'getTimestamp')) {
|
@@ -2121,8 +2210,10 @@ discard block |
||
| 2121 | 2210 | |
| 2122 | 2211 | // Note that gmmktime and mktime return same value (GMT) when used without parameters |
| 2123 | 2212 | //if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() static function instead |
| 2124 | - if ($mode == 'gmt') |
|
| 2125 | - $ret = time(); // Time for now at greenwich. |
|
| 2213 | + if ($mode == 'gmt') { |
|
| 2214 | + $ret = time(); |
|
| 2215 | + } |
|
| 2216 | + // Time for now at greenwich. |
|
| 2126 | 2217 | else if ($mode == 'tzserver') { // Time for now with PHP server timezone added
|
| 2127 | 2218 | require_once DOL_BASE_PATH . '/core/lib/date.lib.php'; |
| 2128 | 2219 | $tzsecond = getServerTimeZoneInt('now'); // Contains tz+dayling saving time
|
@@ -2156,8 +2247,9 @@ discard block |
||
| 2156 | 2247 | // global Globals::$conf, Globals::$langs; |
| 2157 | 2248 | $level = 1024; |
| 2158 | 2249 | |
| 2159 | - if (!empty(Globals::$conf->dol_optimize_smallscreen)) |
|
| 2160 | - $shortunit = 1; |
|
| 2250 | + if (!empty(Globals::$conf->dol_optimize_smallscreen)) { |
|
| 2251 | + $shortunit = 1; |
|
| 2252 | + } |
|
| 2161 | 2253 | |
| 2162 | 2254 | // Set value text |
| 2163 | 2255 | if (empty($shortvalue) || $size < ($level * 10)) {
|
@@ -2192,19 +2284,23 @@ discard block |
||
| 2192 | 2284 | {
|
| 2193 | 2285 | // global Globals::$langs; |
| 2194 | 2286 | |
| 2195 | - if (empty($url)) |
|
| 2196 | - return ''; |
|
| 2287 | + if (empty($url)) { |
|
| 2288 | + return ''; |
|
| 2289 | + } |
|
| 2197 | 2290 | |
| 2198 | 2291 | $link = '<a href="'; |
| 2199 | - if (!preg_match('/^http/i', $url))
|
|
| 2200 | - $link .= 'http://'; |
|
| 2292 | + if (!preg_match('/^http/i', $url)) { |
|
| 2293 | + $link .= 'http://'; |
|
| 2294 | + } |
|
| 2201 | 2295 | $link .= $url; |
| 2202 | 2296 | $link .= '"'; |
| 2203 | - if ($target) |
|
| 2204 | - $link .= ' target="' . $target . '"'; |
|
| 2297 | + if ($target) { |
|
| 2298 | + $link .= ' target="' . $target . '"'; |
|
| 2299 | + } |
|
| 2205 | 2300 | $link .= '>'; |
| 2206 | - if (!preg_match('/^http/i', $url))
|
|
| 2207 | - $link .= 'http://'; |
|
| 2301 | + if (!preg_match('/^http/i', $url)) { |
|
| 2302 | + $link .= 'http://'; |
|
| 2303 | + } |
|
| 2208 | 2304 | $link .= dol_trunc($url, $max); |
| 2209 | 2305 | $link .= '</a>'; |
| 2210 | 2306 | return '<div class="nospan float" style="margin-right: 10px">' . ($withpicto ? img_picto(Globals::$langs->trans("Url"), 'object_globe.png') . ' ' : '') . $link . '</div>';
|
@@ -2228,13 +2324,15 @@ discard block |
||
| 2228 | 2324 | |
| 2229 | 2325 | $newemail = $email; |
| 2230 | 2326 | |
| 2231 | - if (empty($email)) |
|
| 2232 | - return ' '; |
|
| 2327 | + if (empty($email)) { |
|
| 2328 | + return ' '; |
|
| 2329 | + } |
|
| 2233 | 2330 | |
| 2234 | 2331 | if (!empty($addlink)) {
|
| 2235 | 2332 | $newemail = '<a style="text-overflow: ellipsis;" href="'; |
| 2236 | - if (!preg_match('/^mailto:/i', $email))
|
|
| 2237 | - $newemail .= 'mailto:'; |
|
| 2333 | + if (!preg_match('/^mailto:/i', $email)) { |
|
| 2334 | + $newemail .= 'mailto:'; |
|
| 2335 | + } |
|
| 2238 | 2336 | $newemail .= $email; |
| 2239 | 2337 | $newemail .= '">'; |
| 2240 | 2338 | $newemail .= dol_trunc($email, $max); |
@@ -2247,13 +2345,14 @@ discard block |
||
| 2247 | 2345 | if (($cid || $socid) && !empty(Globals::$conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
|
| 2248 | 2346 | $type = 'AC_EMAIL'; |
| 2249 | 2347 | $link = ''; |
| 2250 | - if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFOREMAIL)) |
|
| 2251 | - $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>';
|
|
| 2252 | - if ($link) |
|
| 2253 | - $newemail = '<div>' . $newemail . ' ' . $link . '</div>'; |
|
| 2348 | + if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFOREMAIL)) { |
|
| 2349 | + $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>'; |
|
| 2350 | + } |
|
| 2351 | + if ($link) { |
|
| 2352 | + $newemail = '<div>' . $newemail . ' ' . $link . '</div>'; |
|
| 2353 | + } |
|
| 2254 | 2354 | } |
| 2255 | - } |
|
| 2256 | - else {
|
|
| 2355 | + } else {
|
|
| 2257 | 2356 | if ($showinvalid && !isValidEmail($email)) {
|
| 2258 | 2357 | Globals::$langs->load("errors");
|
| 2259 | 2358 | $newemail .= img_warning(Globals::$langs->trans("ErrorBadEMail", $email));
|
@@ -2285,8 +2384,9 @@ discard block |
||
| 2285 | 2384 | |
| 2286 | 2385 | $newskype = $value; |
| 2287 | 2386 | |
| 2288 | - if (empty($value)) |
|
| 2289 | - return ' '; |
|
| 2387 | + if (empty($value)) { |
|
| 2388 | + return ' '; |
|
| 2389 | + } |
|
| 2290 | 2390 | |
| 2291 | 2391 | if (!empty($type)) {
|
| 2292 | 2392 | $newskype = '<div class="divsocialnetwork inline-block valignmiddle">'; |
@@ -2307,13 +2407,13 @@ discard block |
||
| 2307 | 2407 | if (($cid || $socid) && !empty(Globals::$conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type == 'skype') {
|
| 2308 | 2408 | $addlink = 'AC_SKYPE'; |
| 2309 | 2409 | $link = ''; |
| 2310 | - if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORSKYPE)) |
|
| 2311 | - $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>';
|
|
| 2410 | + if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORSKYPE)) { |
|
| 2411 | + $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>'; |
|
| 2412 | + } |
|
| 2312 | 2413 | $newskype .= ($link ? ' ' . $link : ''); |
| 2313 | 2414 | } |
| 2314 | 2415 | $newskype .= '</div>'; |
| 2315 | - } |
|
| 2316 | - else {
|
|
| 2416 | + } else {
|
|
| 2317 | 2417 | Globals::$langs->load("errors");
|
| 2318 | 2418 | $newskype .= img_warning(Globals::$langs->trans("ErrorBadSocialNetworkValue", $value));
|
| 2319 | 2419 | } |
@@ -2342,12 +2442,14 @@ discard block |
||
| 2342 | 2442 | if (empty($phone)) {
|
| 2343 | 2443 | return ''; |
| 2344 | 2444 | } |
| 2345 | - if (empty($countrycode)) |
|
| 2346 | - $countrycode = $mysoc->country_code; |
|
| 2445 | + if (empty($countrycode)) { |
|
| 2446 | + $countrycode = $mysoc->country_code; |
|
| 2447 | + } |
|
| 2347 | 2448 | |
| 2348 | 2449 | // Short format for small screens |
| 2349 | - if (Globals::$conf->dol_optimize_smallscreen) |
|
| 2350 | - $separ = ''; |
|
| 2450 | + if (Globals::$conf->dol_optimize_smallscreen) { |
|
| 2451 | + $separ = ''; |
|
| 2452 | + } |
|
| 2351 | 2453 | |
| 2352 | 2454 | $newphone = $phone; |
| 2353 | 2455 | if (strtoupper($countrycode) == "FR") {
|
@@ -2513,15 +2615,18 @@ discard block |
||
| 2513 | 2615 | $newphone = '<a href="tel:' . $phone . '"'; |
| 2514 | 2616 | $newphone .= '>' . $phone . '</a>'; |
| 2515 | 2617 | } else if (!empty(Globals::$conf->clicktodial->enabled) && $addlink == 'AC_TEL') { // If click to dial, we use click to dial url
|
| 2516 | - if (empty($user->clicktodial_loaded)) |
|
| 2517 | - $user->fetch_clicktodial(); |
|
| 2618 | + if (empty($user->clicktodial_loaded)) { |
|
| 2619 | + $user->fetch_clicktodial(); |
|
| 2620 | + } |
|
| 2518 | 2621 | |
| 2519 | 2622 | // Define urlmask |
| 2520 | 2623 | $urlmask = 'ErrorClickToDialModuleNotConfigured'; |
| 2521 | - if (!empty(Globals::$conf->global->CLICKTODIAL_URL)) |
|
| 2522 | - $urlmask = Globals::$conf->global->CLICKTODIAL_URL; |
|
| 2523 | - if (!empty($user->clicktodial_url)) |
|
| 2524 | - $urlmask = $user->clicktodial_url; |
|
| 2624 | + if (!empty(Globals::$conf->global->CLICKTODIAL_URL)) { |
|
| 2625 | + $urlmask = Globals::$conf->global->CLICKTODIAL_URL; |
|
| 2626 | + } |
|
| 2627 | + if (!empty($user->clicktodial_url)) { |
|
| 2628 | + $urlmask = $user->clicktodial_url; |
|
| 2629 | + } |
|
| 2525 | 2630 | |
| 2526 | 2631 | $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) : ''); |
| 2527 | 2632 | $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) : ''); |
@@ -2536,8 +2641,9 @@ discard block |
||
| 2536 | 2641 | $url = make_substitutions($url, $substitarray); |
| 2537 | 2642 | $newphonesav = $newphone; |
| 2538 | 2643 | $newphone = '<a href="' . $url . '"'; |
| 2539 | - if (!empty(Globals::$conf->global->CLICKTODIAL_FORCENEWTARGET)) |
|
| 2540 | - $newphone .= ' target="_blank"'; |
|
| 2644 | + if (!empty(Globals::$conf->global->CLICKTODIAL_FORCENEWTARGET)) { |
|
| 2645 | + $newphone .= ' target="_blank"'; |
|
| 2646 | + } |
|
| 2541 | 2647 | $newphone .= '>' . $newphonesav . '</a>'; |
| 2542 | 2648 | } |
| 2543 | 2649 | |
@@ -2545,12 +2651,15 @@ discard block |
||
| 2545 | 2651 | if (!empty(Globals::$conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
|
| 2546 | 2652 | $type = 'AC_TEL'; |
| 2547 | 2653 | $link = ''; |
| 2548 | - if ($addlink == 'AC_FAX') |
|
| 2549 | - $type = 'AC_FAX'; |
|
| 2550 | - if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORPHONE)) |
|
| 2551 | - $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>';
|
|
| 2552 | - if ($link) |
|
| 2553 | - $newphone = '<div>' . $newphone . ' ' . $link . '</div>'; |
|
| 2654 | + if ($addlink == 'AC_FAX') { |
|
| 2655 | + $type = 'AC_FAX'; |
|
| 2656 | + } |
|
| 2657 | + if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORPHONE)) { |
|
| 2658 | + $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>'; |
|
| 2659 | + } |
|
| 2660 | + if ($link) { |
|
| 2661 | + $newphone = '<div>' . $newphone . ' ' . $link . '</div>'; |
|
| 2662 | + } |
|
| 2554 | 2663 | } |
| 2555 | 2664 | } |
| 2556 | 2665 | |
@@ -2577,15 +2686,17 @@ discard block |
||
| 2577 | 2686 | $picto = ''; |
| 2578 | 2687 | } |
| 2579 | 2688 | } |
| 2580 | - if ($adddivfloat) |
|
| 2581 | - $rep .= '<div class="nospan float" style="margin-right: 10px">'; |
|
| 2582 | - else |
|
| 2583 | - $rep .= '<span style="margin-right: 10px;">'; |
|
| 2689 | + if ($adddivfloat) { |
|
| 2690 | + $rep .= '<div class="nospan float" style="margin-right: 10px">'; |
|
| 2691 | + } else { |
|
| 2692 | + $rep .= '<span style="margin-right: 10px;">'; |
|
| 2693 | + } |
|
| 2584 | 2694 | $rep .= ($withpicto ? img_picto($titlealt, 'object_' . $picto . '.png') . ' ' : '') . $newphone; |
| 2585 | - if ($adddivfloat) |
|
| 2586 | - $rep .= '</div>'; |
|
| 2587 | - else |
|
| 2588 | - $rep .= '</span>'; |
|
| 2695 | + if ($adddivfloat) { |
|
| 2696 | + $rep .= '</div>'; |
|
| 2697 | + } else { |
|
| 2698 | + $rep .= '</span>'; |
|
| 2699 | + } |
|
| 2589 | 2700 | } |
| 2590 | 2701 | |
| 2591 | 2702 | return $rep; |
@@ -2615,8 +2726,9 @@ discard block |
||
| 2615 | 2726 | if ($countrycode) { // If success, countrycode is us, fr, ...
|
| 2616 | 2727 | if (file_exists(DOL_BASE_PATH . '/theme/common/flags/' . $countrycode . '.png')) {
|
| 2617 | 2728 | $ret .= ' ' . img_picto($countrycode . ' ' . Globals::$langs->trans("AccordingToGeoIPDatabase"), DOL_BASE_URI . '/theme/common/flags/' . $countrycode . '.png', '', 1);
|
| 2618 | - } else |
|
| 2619 | - $ret .= ' (' . $countrycode . ')';
|
|
| 2729 | + } else { |
|
| 2730 | + $ret .= ' (' . $countrycode . ')'; |
|
| 2731 | + } |
|
| 2620 | 2732 | } |
| 2621 | 2733 | } |
| 2622 | 2734 | |
@@ -2713,26 +2825,33 @@ discard block |
||
| 2713 | 2825 | $out .= Globals::$hookManager->resPrint; |
| 2714 | 2826 | } |
| 2715 | 2827 | if (empty($reshook)) {
|
| 2716 | - if (empty($charfornl)) |
|
| 2717 | - $out .= nl2br($address); |
|
| 2718 | - else |
|
| 2719 | - $out .= preg_replace('/[\r\n]+/', $charfornl, $address);
|
|
| 2828 | + if (empty($charfornl)) { |
|
| 2829 | + $out .= nl2br($address); |
|
| 2830 | + } else { |
|
| 2831 | + $out .= preg_replace('/[\r\n]+/', $charfornl, $address); |
|
| 2832 | + } |
|
| 2720 | 2833 | |
| 2721 | 2834 | $showgmap = $showomap = 0; |
| 2722 | 2835 | |
| 2723 | 2836 | // TODO Add a hook here |
| 2724 | - if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS)) |
|
| 2725 | - $showgmap = 1; |
|
| 2726 | - if ($mode == 'contact' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) |
|
| 2727 | - $showgmap = 1; |
|
| 2728 | - if ($mode == 'member' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) |
|
| 2729 | - $showgmap = 1; |
|
| 2730 | - if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS)) |
|
| 2731 | - $showomap = 1; |
|
| 2732 | - if ($mode == 'contact' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) |
|
| 2733 | - $showomap = 1; |
|
| 2734 | - if ($mode == 'member' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) |
|
| 2735 | - $showomap = 1; |
|
| 2837 | + if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS)) { |
|
| 2838 | + $showgmap = 1; |
|
| 2839 | + } |
|
| 2840 | + if ($mode == 'contact' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) { |
|
| 2841 | + $showgmap = 1; |
|
| 2842 | + } |
|
| 2843 | + if ($mode == 'member' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) { |
|
| 2844 | + $showgmap = 1; |
|
| 2845 | + } |
|
| 2846 | + if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS)) { |
|
| 2847 | + $showomap = 1; |
|
| 2848 | + } |
|
| 2849 | + if ($mode == 'contact' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) { |
|
| 2850 | + $showomap = 1; |
|
| 2851 | + } |
|
| 2852 | + if ($mode == 'member' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) { |
|
| 2853 | + $showomap = 1; |
|
| 2854 | + } |
|
| 2736 | 2855 | |
| 2737 | 2856 | if ($showgmap) {
|
| 2738 | 2857 | $url = dol_buildpath('/google/gmaps.php?mode=' . $mode . '&id=' . $id, 1);
|
@@ -2744,10 +2863,11 @@ discard block |
||
| 2744 | 2863 | } |
| 2745 | 2864 | } |
| 2746 | 2865 | } |
| 2747 | - if ($noprint) |
|
| 2748 | - return $out; |
|
| 2749 | - else |
|
| 2750 | - print $out; |
|
| 2866 | + if ($noprint) { |
|
| 2867 | + return $out; |
|
| 2868 | + } else { |
|
| 2869 | + print $out; |
|
| 2870 | + } |
|
| 2751 | 2871 | } |
| 2752 | 2872 | |
| 2753 | 2873 | /** |
@@ -2759,10 +2879,12 @@ discard block |
||
| 2759 | 2879 | */ |
| 2760 | 2880 | static function isValidEmail($address, $acceptsupervisorkey = 0) |
| 2761 | 2881 | {
|
| 2762 | - if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__') |
|
| 2763 | - return true; |
|
| 2764 | - if (filter_var($address, FILTER_VALIDATE_EMAIL)) |
|
| 2765 | - return true; |
|
| 2882 | + if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__') { |
|
| 2883 | + return true; |
|
| 2884 | + } |
|
| 2885 | + if (filter_var($address, FILTER_VALIDATE_EMAIL)) { |
|
| 2886 | + return true; |
|
| 2887 | + } |
|
| 2766 | 2888 | |
| 2767 | 2889 | return false; |
| 2768 | 2890 | } |
@@ -2784,10 +2906,12 @@ discard block |
||
| 2784 | 2906 | $mxhosts = array(); |
| 2785 | 2907 | $weight = array(); |
| 2786 | 2908 | getmxrr(idn_to_ascii($domain), $mxhosts, $weight); |
| 2787 | - if (count($mxhosts) > 1) |
|
| 2788 | - return 1; |
|
| 2789 | - if (count($mxhosts) == 1 && !empty($mxhosts[0])) |
|
| 2790 | - return 1; |
|
| 2909 | + if (count($mxhosts) > 1) { |
|
| 2910 | + return 1; |
|
| 2911 | + } |
|
| 2912 | + if (count($mxhosts) == 1 && !empty($mxhosts[0])) { |
|
| 2913 | + return 1; |
|
| 2914 | + } |
|
| 2791 | 2915 | |
| 2792 | 2916 | return 0; |
| 2793 | 2917 | } |
@@ -2816,10 +2940,11 @@ discard block |
||
| 2816 | 2940 | */ |
| 2817 | 2941 | static function dol_strlen($string, $stringencoding = 'UTF-8') |
| 2818 | 2942 | {
|
| 2819 | - if (function_exists('mb_strlen'))
|
|
| 2820 | - return mb_strlen($string, $stringencoding); |
|
| 2821 | - else |
|
| 2822 | - return strlen($string); |
|
| 2943 | + if (function_exists('mb_strlen')) { |
|
| 2944 | + return mb_strlen($string, $stringencoding); |
|
| 2945 | + } else { |
|
| 2946 | + return strlen($string); |
|
| 2947 | + } |
|
| 2823 | 2948 | } |
| 2824 | 2949 | |
| 2825 | 2950 | /** |
@@ -2836,8 +2961,9 @@ discard block |
||
| 2836 | 2961 | {
|
| 2837 | 2962 | // global Globals::$langs; |
| 2838 | 2963 | |
| 2839 | - if (empty($stringencoding)) |
|
| 2840 | - $stringencoding = Globals::$langs->charset_output; |
|
| 2964 | + if (empty($stringencoding)) { |
|
| 2965 | + $stringencoding = Globals::$langs->charset_output; |
|
| 2966 | + } |
|
| 2841 | 2967 | |
| 2842 | 2968 | $ret = ''; |
| 2843 | 2969 | if (empty($trunconbytes)) {
|
@@ -2873,48 +2999,55 @@ discard block |
||
| 2873 | 2999 | {
|
| 2874 | 3000 | // global Globals::$conf; |
| 2875 | 3001 | |
| 2876 | - if ($size == 0 || !empty(Globals::$conf->global->MAIN_DISABLE_TRUNC)) |
|
| 2877 | - return $string; |
|
| 3002 | + if ($size == 0 || !empty(Globals::$conf->global->MAIN_DISABLE_TRUNC)) { |
|
| 3003 | + return $string; |
|
| 3004 | + } |
|
| 2878 | 3005 | |
| 2879 | - if (empty($stringencoding)) |
|
| 2880 | - $stringencoding = 'UTF-8'; |
|
| 2881 | -// reduce for small screen |
|
| 2882 | - if (Globals::$conf->dol_optimize_smallscreen == 1 && $display == 1) |
|
| 2883 | - $size = round($size / 3); |
|
| 3006 | + if (empty($stringencoding)) { |
|
| 3007 | + $stringencoding = 'UTF-8'; |
|
| 3008 | + } |
|
| 3009 | + // reduce for small screen |
|
| 3010 | + if (Globals::$conf->dol_optimize_smallscreen == 1 && $display == 1) { |
|
| 3011 | + $size = round($size / 3); |
|
| 3012 | + } |
|
| 2884 | 3013 | |
| 2885 | 3014 | // We go always here |
| 2886 | 3015 | if ($trunc == 'right') {
|
| 2887 | 3016 | $newstring = DolUtils::dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
| 2888 | - if (DolUtils::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 ... |
|
| 2889 | - return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...'); |
|
| 2890 | - else |
|
| 2891 | - //return 'u'.$size.'-'.$newstring.'-'.DolUtils::dol_strlen($newstring,$stringencoding).'-'.$string; |
|
| 2892 | - return $string; |
|
| 2893 | - } |
|
| 2894 | - elseif ($trunc == 'middle') {
|
|
| 3017 | + if (DolUtils::dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) { |
|
| 3018 | + // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
| 3019 | + return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...'); |
|
| 3020 | + } else { |
|
| 3021 | + //return 'u'.$size.'-'.$newstring.'-'.DolUtils::dol_strlen($newstring,$stringencoding).'-'.$string; |
|
| 3022 | + return $string; |
|
| 3023 | + } |
|
| 3024 | + } elseif ($trunc == 'middle') {
|
|
| 2895 | 3025 | $newstring = DolUtils::dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
| 2896 | 3026 | if (DolUtils::dol_strlen($newstring, $stringencoding) > 2 && DolUtils::dol_strlen($newstring, $stringencoding) > ($size + 1)) {
|
| 2897 | 3027 | $size1 = round($size / 2); |
| 2898 | 3028 | $size2 = round($size / 2); |
| 2899 | 3029 | return dol_substr($newstring, 0, $size1, $stringencoding) . '...' . dol_substr($newstring, DolUtils::dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding); |
| 2900 | - } else |
|
| 2901 | - return $string; |
|
| 2902 | - } |
|
| 2903 | - elseif ($trunc == 'left') {
|
|
| 3030 | + } else { |
|
| 3031 | + return $string; |
|
| 3032 | + } |
|
| 3033 | + } elseif ($trunc == 'left') {
|
|
| 2904 | 3034 | $newstring = DolUtils::dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
| 2905 | - if (DolUtils::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 ... |
|
| 2906 | - return '...' . dol_substr($newstring, DolUtils::dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding); |
|
| 2907 | - else |
|
| 2908 | - return $string; |
|
| 2909 | - } |
|
| 2910 | - elseif ($trunc == 'wrap') {
|
|
| 3035 | + if (DolUtils::dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) { |
|
| 3036 | + // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
| 3037 | + return '...' . dol_substr($newstring, DolUtils::dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding); |
|
| 3038 | + } else { |
|
| 3039 | + return $string; |
|
| 3040 | + } |
|
| 3041 | + } elseif ($trunc == 'wrap') {
|
|
| 2911 | 3042 | $newstring = DolUtils::dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
| 2912 | - if (DolUtils::dol_strlen($newstring, $stringencoding) > ($size + 1)) |
|
| 2913 | - return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, DolUtils::dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc); |
|
| 2914 | - else |
|
| 2915 | - return $string; |
|
| 2916 | - } else |
|
| 2917 | - return 'BadParam3CallingDolTrunc'; |
|
| 3043 | + if (DolUtils::dol_strlen($newstring, $stringencoding) > ($size + 1)) { |
|
| 3044 | + return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, DolUtils::dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc); |
|
| 3045 | + } else { |
|
| 3046 | + return $string; |
|
| 3047 | + } |
|
| 3048 | + } else { |
|
| 3049 | + return 'BadParam3CallingDolTrunc'; |
|
| 3050 | + } |
|
| 2918 | 3051 | } |
| 2919 | 3052 | |
| 2920 | 3053 | /** |
@@ -3124,8 +3257,9 @@ discard block |
||
| 3124 | 3257 | {
|
| 3125 | 3258 | // global Globals::$conf; |
| 3126 | 3259 | |
| 3127 | - if (!preg_match('/(\.png|\.gif)$/i', $picto))
|
|
| 3128 | - $picto .= '.png'; |
|
| 3260 | + if (!preg_match('/(\.png|\.gif)$/i', $picto)) { |
|
| 3261 | + $picto .= '.png'; |
|
| 3262 | + } |
|
| 3129 | 3263 | |
| 3130 | 3264 | //$path = DOL_BASE_URI . '/theme/' . Globals::$conf->theme . '/img/weather/' . $picto; |
| 3131 | 3265 | $path = DOL_BASE_URI . '/theme/' . Globals::$conf->theme . '/img/weather/' . $picto; |
@@ -3147,20 +3281,22 @@ discard block |
||
| 3147 | 3281 | {
|
| 3148 | 3282 | // global Globals::$conf; |
| 3149 | 3283 | |
| 3150 | - if (!preg_match('/(\.png|\.gif)$/i', $picto))
|
|
| 3151 | - $picto .= '.png'; |
|
| 3284 | + if (!preg_match('/(\.png|\.gif)$/i', $picto)) { |
|
| 3285 | + $picto .= '.png'; |
|
| 3286 | + } |
|
| 3152 | 3287 | |
| 3153 | - if ($pictoisfullpath) |
|
| 3154 | - $path = $picto; |
|
| 3155 | - else {
|
|
| 3288 | + if ($pictoisfullpath) { |
|
| 3289 | + $path = $picto; |
|
| 3290 | + } else {
|
|
| 3156 | 3291 | //$path = DOL_BASE_URI . '/theme/common/' . $picto; |
| 3157 | 3292 | $path = DOL_BASE_URI . '/theme/common/' . $picto; |
| 3158 | 3293 | |
| 3159 | 3294 | if (!empty(Globals::$conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) {
|
| 3160 | 3295 | $themepath = DOL_BASE_PATH . 'theme/' . Globals::$conf->theme . '/img/' . $picto; |
| 3161 | 3296 | |
| 3162 | - if (file_exists($themepath)) |
|
| 3163 | - $path = $themepath; |
|
| 3297 | + if (file_exists($themepath)) { |
|
| 3298 | + $path = $themepath; |
|
| 3299 | + } |
|
| 3164 | 3300 | } |
| 3165 | 3301 | } |
| 3166 | 3302 | |
@@ -3199,8 +3335,9 @@ discard block |
||
| 3199 | 3335 | $numaction = 0; |
| 3200 | 3336 | } |
| 3201 | 3337 | } |
| 3202 | - if (!is_numeric($numaction)) |
|
| 3203 | - $numaction = 0; |
|
| 3338 | + if (!is_numeric($numaction)) { |
|
| 3339 | + $numaction = 0; |
|
| 3340 | + } |
|
| 3204 | 3341 | |
| 3205 | 3342 | return img_picto($titlealt, 'stcomm' . $numaction . '.png'); |
| 3206 | 3343 | } |
@@ -3216,8 +3353,9 @@ discard block |
||
| 3216 | 3353 | {
|
| 3217 | 3354 | // global Globals::$conf, Globals::$langs; |
| 3218 | 3355 | |
| 3219 | - if ($titlealt == 'default') |
|
| 3220 | - $titlealt = Globals::$langs->trans('Show');
|
|
| 3356 | + if ($titlealt == 'default') { |
|
| 3357 | + $titlealt = Globals::$langs->trans('Show'); |
|
| 3358 | + } |
|
| 3221 | 3359 | |
| 3222 | 3360 | return img_picto($titlealt, 'pdf' . $size . '.png'); |
| 3223 | 3361 | } |
@@ -3233,8 +3371,9 @@ discard block |
||
| 3233 | 3371 | {
|
| 3234 | 3372 | // global Globals::$conf, Globals::$langs; |
| 3235 | 3373 | |
| 3236 | - if ($titlealt == 'default') |
|
| 3237 | - $titlealt = Globals::$langs->trans('Add');
|
|
| 3374 | + if ($titlealt == 'default') { |
|
| 3375 | + $titlealt = Globals::$langs->trans('Add'); |
|
| 3376 | + } |
|
| 3238 | 3377 | |
| 3239 | 3378 | return img_picto($titlealt, 'edit_add.png', $other); |
| 3240 | 3379 | } |
@@ -3250,8 +3389,9 @@ discard block |
||
| 3250 | 3389 | {
|
| 3251 | 3390 | // global Globals::$conf, Globals::$langs; |
| 3252 | 3391 | |
| 3253 | - if ($titlealt == 'default') |
|
| 3254 | - $titlealt = Globals::$langs->trans('Remove');
|
|
| 3392 | + if ($titlealt == 'default') { |
|
| 3393 | + $titlealt = Globals::$langs->trans('Remove'); |
|
| 3394 | + } |
|
| 3255 | 3395 | |
| 3256 | 3396 | return img_picto($titlealt, 'edit_remove.png', $other); |
| 3257 | 3397 | } |
@@ -3268,8 +3408,9 @@ discard block |
||
| 3268 | 3408 | {
|
| 3269 | 3409 | // global Globals::$conf, Globals::$langs; |
| 3270 | 3410 | |
| 3271 | - if ($titlealt == 'default') |
|
| 3272 | - $titlealt = Globals::$langs->trans('Modify');
|
|
| 3411 | + if ($titlealt == 'default') { |
|
| 3412 | + $titlealt = Globals::$langs->trans('Modify'); |
|
| 3413 | + } |
|
| 3273 | 3414 | |
| 3274 | 3415 | return img_picto($titlealt, 'edit.png', ($float ? 'style="float: ' . (Globals::$langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right') . '"' : "") . ($other ? ' ' . $other : '')); |
| 3275 | 3416 | } |
@@ -3286,8 +3427,9 @@ discard block |
||
| 3286 | 3427 | {
|
| 3287 | 3428 | // global Globals::$conf, Globals::$langs; |
| 3288 | 3429 | |
| 3289 | - if ($titlealt == 'default') |
|
| 3290 | - $titlealt = Globals::$langs->trans('View');
|
|
| 3430 | + if ($titlealt == 'default') { |
|
| 3431 | + $titlealt = Globals::$langs->trans('View'); |
|
| 3432 | + } |
|
| 3291 | 3433 | |
| 3292 | 3434 | $moreatt = ($float ? 'style="float: right" ' : '') . $other; |
| 3293 | 3435 | |
@@ -3305,8 +3447,9 @@ discard block |
||
| 3305 | 3447 | {
|
| 3306 | 3448 | // global Globals::$conf, Globals::$langs; |
| 3307 | 3449 | |
| 3308 | - if ($titlealt == 'default') |
|
| 3309 | - $titlealt = Globals::$langs->trans('Delete');
|
|
| 3450 | + if ($titlealt == 'default') { |
|
| 3451 | + $titlealt = Globals::$langs->trans('Delete'); |
|
| 3452 | + } |
|
| 3310 | 3453 | |
| 3311 | 3454 | return img_picto($titlealt, 'delete.png', $other); |
| 3312 | 3455 | //return '<span class="fa fa-trash fa-2x fa-fw" style="font-size: 1.7em;" title="'.$titlealt.'"></span>'; |
@@ -3322,8 +3465,9 @@ discard block |
||
| 3322 | 3465 | static function img_printer($titlealt = "default", $other = '') |
| 3323 | 3466 | {
|
| 3324 | 3467 | // global Globals::$conf, Globals::$langs; |
| 3325 | - if ($titlealt == "default") |
|
| 3326 | - $titlealt = Globals::$langs->trans("Print");
|
|
| 3468 | + if ($titlealt == "default") { |
|
| 3469 | + $titlealt = Globals::$langs->trans("Print"); |
|
| 3470 | + } |
|
| 3327 | 3471 | return img_picto($titlealt, 'printer.png', $other); |
| 3328 | 3472 | } |
| 3329 | 3473 | |
@@ -3338,8 +3482,9 @@ discard block |
||
| 3338 | 3482 | {
|
| 3339 | 3483 | // global Globals::$conf, Globals::$langs; |
| 3340 | 3484 | |
| 3341 | - if ($titlealt == 'default') |
|
| 3342 | - $titlealt = Globals::$langs->trans('Split');
|
|
| 3485 | + if ($titlealt == 'default') { |
|
| 3486 | + $titlealt = Globals::$langs->trans('Split'); |
|
| 3487 | + } |
|
| 3343 | 3488 | |
| 3344 | 3489 | return img_picto($titlealt, 'split.png', $other); |
| 3345 | 3490 | } |
@@ -3356,10 +3501,11 @@ discard block |
||
| 3356 | 3501 | // global Globals::$conf, Globals::$langs; |
| 3357 | 3502 | |
| 3358 | 3503 | if ($usealttitle) {
|
| 3359 | - if (is_string($usealttitle)) |
|
| 3360 | - $usealttitle = DolUtils::dol_escape_htmltag($usealttitle); |
|
| 3361 | - else |
|
| 3362 | - $usealttitle = Globals::$langs->trans('Info');
|
|
| 3504 | + if (is_string($usealttitle)) { |
|
| 3505 | + $usealttitle = DolUtils::dol_escape_htmltag($usealttitle); |
|
| 3506 | + } else { |
|
| 3507 | + $usealttitle = Globals::$langs->trans('Info'); |
|
| 3508 | + } |
|
| 3363 | 3509 | } |
| 3364 | 3510 | |
| 3365 | 3511 | return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;' . ($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')) . '"'); |
@@ -3375,8 +3521,9 @@ discard block |
||
| 3375 | 3521 | {
|
| 3376 | 3522 | // global Globals::$conf, Globals::$langs; |
| 3377 | 3523 | |
| 3378 | - if ($titlealt == 'default') |
|
| 3379 | - $titlealt = Globals::$langs->trans('Informations');
|
|
| 3524 | + if ($titlealt == 'default') { |
|
| 3525 | + $titlealt = Globals::$langs->trans('Informations'); |
|
| 3526 | + } |
|
| 3380 | 3527 | |
| 3381 | 3528 | return img_picto($titlealt, 'info.png', 'style="vertical-align: middle;"'); |
| 3382 | 3529 | } |
@@ -3392,8 +3539,9 @@ discard block |
||
| 3392 | 3539 | {
|
| 3393 | 3540 | // global Globals::$conf, Globals::$langs; |
| 3394 | 3541 | |
| 3395 | - if ($titlealt == 'default') |
|
| 3396 | - $titlealt = Globals::$langs->trans('Warning');
|
|
| 3542 | + if ($titlealt == 'default') { |
|
| 3543 | + $titlealt = Globals::$langs->trans('Warning'); |
|
| 3544 | + } |
|
| 3397 | 3545 | |
| 3398 | 3546 | //return '<div class="imglatecoin">'.img_picto($titlealt, 'warning_white.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')).'</div>'; |
| 3399 | 3547 | return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"' . ($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' ' . $moreatt) : '')); |
@@ -3409,8 +3557,9 @@ discard block |
||
| 3409 | 3557 | {
|
| 3410 | 3558 | // global Globals::$conf, Globals::$langs; |
| 3411 | 3559 | |
| 3412 | - if ($titlealt == 'default') |
|
| 3413 | - $titlealt = Globals::$langs->trans('Error');
|
|
| 3560 | + if ($titlealt == 'default') { |
|
| 3561 | + $titlealt = Globals::$langs->trans('Error'); |
|
| 3562 | + } |
|
| 3414 | 3563 | |
| 3415 | 3564 | return img_picto($titlealt, 'error.png', 'class="valigntextbottom"'); |
| 3416 | 3565 | } |
@@ -3426,8 +3575,9 @@ discard block |
||
| 3426 | 3575 | {
|
| 3427 | 3576 | // global Globals::$conf, Globals::$langs; |
| 3428 | 3577 | |
| 3429 | - if ($titlealt == 'default') |
|
| 3430 | - $titlealt = Globals::$langs->trans('Next');
|
|
| 3578 | + if ($titlealt == 'default') { |
|
| 3579 | + $titlealt = Globals::$langs->trans('Next'); |
|
| 3580 | + } |
|
| 3431 | 3581 | |
| 3432 | 3582 | //return img_picto($titlealt, 'next.png', $moreatt); |
| 3433 | 3583 | return '<span class="fa fa-chevron-right paddingright paddingleft" title="' . DolUtils::dol_escape_htmltag($titlealt) . '"></span>'; |
@@ -3444,8 +3594,9 @@ discard block |
||
| 3444 | 3594 | {
|
| 3445 | 3595 | // global Globals::$conf, Globals::$langs; |
| 3446 | 3596 | |
| 3447 | - if ($titlealt == 'default') |
|
| 3448 | - $titlealt = Globals::$langs->trans('Previous');
|
|
| 3597 | + if ($titlealt == 'default') { |
|
| 3598 | + $titlealt = Globals::$langs->trans('Previous'); |
|
| 3599 | + } |
|
| 3449 | 3600 | |
| 3450 | 3601 | //return img_picto($titlealt, 'previous.png', $moreatt); |
| 3451 | 3602 | return '<span class="fa fa-chevron-left paddingright paddingleft" title="' . DolUtils::dol_escape_htmltag($titlealt) . '"></span>'; |
@@ -3463,8 +3614,9 @@ discard block |
||
| 3463 | 3614 | {
|
| 3464 | 3615 | // global Globals::$conf, Globals::$langs; |
| 3465 | 3616 | |
| 3466 | - if ($titlealt == 'default') |
|
| 3467 | - $titlealt = Globals::$langs->trans('Down');
|
|
| 3617 | + if ($titlealt == 'default') { |
|
| 3618 | + $titlealt = Globals::$langs->trans('Down'); |
|
| 3619 | + } |
|
| 3468 | 3620 | |
| 3469 | 3621 | return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown' . ($moreclass ? " " . $moreclass : "") . '"'); |
| 3470 | 3622 | } |
@@ -3481,8 +3633,9 @@ discard block |
||
| 3481 | 3633 | {
|
| 3482 | 3634 | // global Globals::$conf, Globals::$langs; |
| 3483 | 3635 | |
| 3484 | - if ($titlealt == 'default') |
|
| 3485 | - $titlealt = Globals::$langs->trans('Up');
|
|
| 3636 | + if ($titlealt == 'default') { |
|
| 3637 | + $titlealt = Globals::$langs->trans('Up'); |
|
| 3638 | + } |
|
| 3486 | 3639 | |
| 3487 | 3640 | return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup' . ($moreclass ? " " . $moreclass : "") . '"'); |
| 3488 | 3641 | } |
@@ -3499,8 +3652,9 @@ discard block |
||
| 3499 | 3652 | {
|
| 3500 | 3653 | // global Globals::$conf, Globals::$langs; |
| 3501 | 3654 | |
| 3502 | - if ($titlealt == 'default') |
|
| 3503 | - $titlealt = Globals::$langs->trans('Left');
|
|
| 3655 | + if ($titlealt == 'default') { |
|
| 3656 | + $titlealt = Globals::$langs->trans('Left'); |
|
| 3657 | + } |
|
| 3504 | 3658 | |
| 3505 | 3659 | return img_picto($titlealt, ($selected ? '1leftarrow_selected.png' : '1leftarrow.png'), $moreatt); |
| 3506 | 3660 | } |
@@ -3517,8 +3671,9 @@ discard block |
||
| 3517 | 3671 | {
|
| 3518 | 3672 | // global Globals::$conf, Globals::$langs; |
| 3519 | 3673 | |
| 3520 | - if ($titlealt == 'default') |
|
| 3521 | - $titlealt = Globals::$langs->trans('Right');
|
|
| 3674 | + if ($titlealt == 'default') { |
|
| 3675 | + $titlealt = Globals::$langs->trans('Right'); |
|
| 3676 | + } |
|
| 3522 | 3677 | |
| 3523 | 3678 | return img_picto($titlealt, ($selected ? '1rightarrow_selected.png' : '1rightarrow.png'), $moreatt); |
| 3524 | 3679 | } |
@@ -3534,11 +3689,13 @@ discard block |
||
| 3534 | 3689 | {
|
| 3535 | 3690 | // global Globals::$conf, Globals::$langs; |
| 3536 | 3691 | |
| 3537 | - if ($titlealt == 'default') |
|
| 3538 | - $titlealt = Globals::$langs->trans('Active');
|
|
| 3692 | + if ($titlealt == 'default') { |
|
| 3693 | + $titlealt = Globals::$langs->trans('Active'); |
|
| 3694 | + } |
|
| 3539 | 3695 | |
| 3540 | - if ($allow == 1) |
|
| 3541 | - return img_picto($titlealt, 'tick.png'); |
|
| 3696 | + if ($allow == 1) { |
|
| 3697 | + return img_picto($titlealt, 'tick.png'); |
|
| 3698 | + } |
|
| 3542 | 3699 | |
| 3543 | 3700 | return '-'; |
| 3544 | 3701 | } |
@@ -3586,8 +3743,9 @@ discard block |
||
| 3586 | 3743 | $mimeimg = dol_mimetype($file, '', 2); |
| 3587 | 3744 | $mimefa = dol_mimetype($file, '', 4); |
| 3588 | 3745 | |
| 3589 | - if (empty($titlealt)) |
|
| 3590 | - $titlealt = 'Mime type: ' . $mimetype; |
|
| 3746 | + if (empty($titlealt)) { |
|
| 3747 | + $titlealt = 'Mime type: ' . $mimetype; |
|
| 3748 | + } |
|
| 3591 | 3749 | |
| 3592 | 3750 | //return img_picto_common($titlealt, 'mime/'.$mimeimg, 'class="'.$morecss.'"'); |
| 3593 | 3751 | return '<i class="fa fa-' . $mimefa . ' paddingright"></i>'; |
@@ -3609,13 +3767,15 @@ discard block |
||
| 3609 | 3767 | |
| 3610 | 3768 | // global Globals::$conf, Globals::$langs; |
| 3611 | 3769 | |
| 3612 | - if ($titlealt == 'default') |
|
| 3613 | - $titlealt = Globals::$langs->trans('Call');
|
|
| 3770 | + if ($titlealt == 'default') { |
|
| 3771 | + $titlealt = Globals::$langs->trans('Call'); |
|
| 3772 | + } |
|
| 3614 | 3773 | |
| 3615 | - if ($option == 1) |
|
| 3616 | - $img = 'call'; |
|
| 3617 | - else |
|
| 3618 | - $img = 'call_out'; |
|
| 3774 | + if ($option == 1) { |
|
| 3775 | + $img = 'call'; |
|
| 3776 | + } else { |
|
| 3777 | + $img = 'call_out'; |
|
| 3778 | + } |
|
| 3619 | 3779 | |
| 3620 | 3780 | return img_picto($titlealt, $img); |
| 3621 | 3781 | } |
@@ -3631,8 +3791,9 @@ discard block |
||
| 3631 | 3791 | {
|
| 3632 | 3792 | // global Globals::$conf, Globals::$langs; |
| 3633 | 3793 | |
| 3634 | - if ($titlealt == 'default') |
|
| 3635 | - $titlealt = Globals::$langs->trans('Search');
|
|
| 3794 | + if ($titlealt == 'default') { |
|
| 3795 | + $titlealt = Globals::$langs->trans('Search'); |
|
| 3796 | + } |
|
| 3636 | 3797 | |
| 3637 | 3798 | $img = img_picto($titlealt, 'search.png', $other, false, 1); |
| 3638 | 3799 | |
@@ -3653,8 +3814,9 @@ discard block |
||
| 3653 | 3814 | {
|
| 3654 | 3815 | // global Globals::$conf, Globals::$langs; |
| 3655 | 3816 | |
| 3656 | - if ($titlealt == 'default') |
|
| 3657 | - $titlealt = Globals::$langs->trans('Search');
|
|
| 3817 | + if ($titlealt == 'default') { |
|
| 3818 | + $titlealt = Globals::$langs->trans('Search'); |
|
| 3819 | + } |
|
| 3658 | 3820 | |
| 3659 | 3821 | $img = img_picto($titlealt, 'searchclear.png', $other, false, 1); |
| 3660 | 3822 | |
@@ -3716,14 +3878,16 @@ discard block |
||
| 3716 | 3878 | |
| 3717 | 3879 | if ($_SERVER['DOCUMENT_ROOT']) { // Mode web
|
| 3718 | 3880 | $out .= Globals::$langs->trans("DolibarrHasDetectedError") . ".<br>\n";
|
| 3719 | - if (!empty(Globals::$conf->global->MAIN_FEATURES_LEVEL)) |
|
| 3720 | - $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"; |
|
| 3881 | + if (!empty(Globals::$conf->global->MAIN_FEATURES_LEVEL)) { |
|
| 3882 | + $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"; |
|
| 3883 | + } |
|
| 3721 | 3884 | $out .= Globals::$langs->trans("InformationToHelpDiagnose") . ":<br>\n";
|
| 3722 | 3885 | |
| 3723 | 3886 | $out .= "<b>" . Globals::$langs->trans("Date") . ":</b> " . DolUtils::dol_print_date(time(), 'dayhourlog') . "<br>\n";
|
| 3724 | 3887 | $out .= "<b>" . Globals::$langs->trans("Dolibarr") . ":</b> " . DOL_VERSION . "<br>\n";
|
| 3725 | - if (isset(Globals::$conf->global->MAIN_FEATURES_LEVEL)) |
|
| 3726 | - $out .= "<b>" . Globals::$langs->trans("LevelOfFeature") . ":</b> " . Globals::$conf->global->MAIN_FEATURES_LEVEL . "<br>\n";
|
|
| 3888 | + if (isset(Globals::$conf->global->MAIN_FEATURES_LEVEL)) { |
|
| 3889 | + $out .= "<b>" . Globals::$langs->trans("LevelOfFeature") . ":</b> " . Globals::$conf->global->MAIN_FEATURES_LEVEL . "<br>\n"; |
|
| 3890 | + } |
|
| 3727 | 3891 | if (function_exists("phpversion")) {
|
| 3728 | 3892 | $out .= "<b>" . Globals::$langs->trans("PHP") . ":</b> " . phpversion() . "<br>\n";
|
| 3729 | 3893 | } |
@@ -3766,18 +3930,20 @@ discard block |
||
| 3766 | 3930 | Globals::$langs->load("errors");
|
| 3767 | 3931 | |
| 3768 | 3932 | // Merge all into $errors array |
| 3769 | - if (is_array($error) && is_array($errors)) |
|
| 3770 | - $errors = array_merge($error, $errors); |
|
| 3771 | - elseif (is_array($error)) |
|
| 3772 | - $errors = $error; |
|
| 3773 | - elseif (is_array($errors)) |
|
| 3774 | - $errors = array_merge(array($error), $errors); |
|
| 3775 | - else |
|
| 3776 | - $errors = array_merge(array($error)); |
|
| 3933 | + if (is_array($error) && is_array($errors)) { |
|
| 3934 | + $errors = array_merge($error, $errors); |
|
| 3935 | + } elseif (is_array($error)) { |
|
| 3936 | + $errors = $error; |
|
| 3937 | + } elseif (is_array($errors)) { |
|
| 3938 | + $errors = array_merge(array($error), $errors); |
|
| 3939 | + } else { |
|
| 3940 | + $errors = array_merge(array($error)); |
|
| 3941 | + } |
|
| 3777 | 3942 | |
| 3778 | 3943 | foreach ($errors as $msg) {
|
| 3779 | - if (empty($msg)) |
|
| 3780 | - continue; |
|
| 3944 | + if (empty($msg)) { |
|
| 3945 | + continue; |
|
| 3946 | + } |
|
| 3781 | 3947 | if ($_SERVER['DOCUMENT_ROOT']) { // Mode web
|
| 3782 | 3948 | $out .= "<b>" . Globals::$langs->trans("Message") . ":</b> " . DolUtils::dol_escape_htmltag($msg) . "<br>\n";
|
| 3783 | 3949 | } else { // Mode CLI
|
@@ -3795,9 +3961,9 @@ discard block |
||
| 3795 | 3961 | $out .= "<br>\n"; |
| 3796 | 3962 | } |
| 3797 | 3963 | |
| 3798 | - if (empty($dolibarr_main_prod)) |
|
| 3799 | - print $out; |
|
| 3800 | - else {
|
|
| 3964 | + if (empty($dolibarr_main_prod)) { |
|
| 3965 | + print $out; |
|
| 3966 | + } else {
|
|
| 3801 | 3967 | print Globals::$langs->trans("DolibarrHasDetectedError") . '. ';
|
| 3802 | 3968 | print Globals::$langs->trans("YouCanSetOptionDolibarrMainProdToZero");
|
| 3803 | 3969 | define("MAIN_CORE_ERROR", 1);
|
@@ -3820,16 +3986,18 @@ discard block |
||
| 3820 | 3986 | {
|
| 3821 | 3987 | // global Globals::$langs, Globals::$conf; |
| 3822 | 3988 | |
| 3823 | - if (empty($email)) |
|
| 3824 | - $email = Globals::$conf->global->MAIN_INFO_SOCIETE_MAIL; |
|
| 3989 | + if (empty($email)) { |
|
| 3990 | + $email = Globals::$conf->global->MAIN_INFO_SOCIETE_MAIL; |
|
| 3991 | + } |
|
| 3825 | 3992 | |
| 3826 | 3993 | Globals::$langs->load("errors");
|
| 3827 | 3994 | $now = dol_now(); |
| 3828 | 3995 | |
| 3829 | 3996 | print '<br><div class="center login_main_message"><div class="' . $morecss . '">'; |
| 3830 | 3997 | print Globals::$langs->trans("ErrorContactEMail", $email, $prefixcode . DolUtils::dol_print_date($now, '%Y%m%d'));
|
| 3831 | - if ($errormessage) |
|
| 3832 | - print '<br><br>' . $errormessage; |
|
| 3998 | + if ($errormessage) { |
|
| 3999 | + print '<br><br>' . $errormessage; |
|
| 4000 | + } |
|
| 3833 | 4001 | if (is_array($errormessages) && count($errormessages)) {
|
| 3834 | 4002 | foreach ($errormessages as $mesgtoshow) {
|
| 3835 | 4003 | print '<br><br>' . $mesgtoshow; |
@@ -4072,12 +4240,15 @@ discard block |
||
| 4072 | 4240 | $savtotalnboflines = $totalnboflines; |
| 4073 | 4241 | $totalnboflines = abs($totalnboflines); |
| 4074 | 4242 | |
| 4075 | - if ($picto == 'setup') |
|
| 4076 | - $picto = 'title_setup.png'; |
|
| 4077 | - if ((Globals::$conf->browser->name == 'ie') && $picto == 'title_generic.png') |
|
| 4078 | - $picto = 'title.gif'; |
|
| 4079 | - if ($limit < 0) |
|
| 4080 | - $limit = Globals::$conf->liste_limit; |
|
| 4243 | + if ($picto == 'setup') { |
|
| 4244 | + $picto = 'title_setup.png'; |
|
| 4245 | + } |
|
| 4246 | + if ((Globals::$conf->browser->name == 'ie') && $picto == 'title_generic.png') { |
|
| 4247 | + $picto = 'title.gif'; |
|
| 4248 | + } |
|
| 4249 | + if ($limit < 0) { |
|
| 4250 | + $limit = Globals::$conf->liste_limit; |
|
| 4251 | + } |
|
| 4081 | 4252 | if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
|
| 4082 | 4253 | $nextpage = 1; |
| 4083 | 4254 | } else {
|
@@ -4091,11 +4262,13 @@ discard block |
||
| 4091 | 4262 | // Left |
| 4092 | 4263 | //if ($picto && $titre) print '<td class="nobordernopadding hideonsmartphone" width="40" align="left" valign="middle">'.img_picto('', $picto, 'id="pictotitle"', $pictoisfullpath).'</td>';
|
| 4093 | 4264 | print '<td class="nobordernopadding valignmiddle">'; |
| 4094 | - if ($picto && $titre) |
|
| 4095 | - print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath);
|
|
| 4265 | + if ($picto && $titre) { |
|
| 4266 | + print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath); |
|
| 4267 | + } |
|
| 4096 | 4268 | print '<div class="titre inline-block">' . $titre; |
| 4097 | - if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') |
|
| 4098 | - print ' (' . $totalnboflines . ')';
|
|
| 4269 | + if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') { |
|
| 4270 | + print ' (' . $totalnboflines . ')'; |
|
| 4271 | + } |
|
| 4099 | 4272 | print '</div></td>'; |
| 4100 | 4273 | |
| 4101 | 4274 | // Center |
@@ -4105,21 +4278,24 @@ discard block |
||
| 4105 | 4278 | |
| 4106 | 4279 | // Right |
| 4107 | 4280 | print '<td class="nobordernopadding valignmiddle" align="right">'; |
| 4108 | - if ($sortfield) |
|
| 4109 | - $options .= "&sortfield=" . urlencode($sortfield); |
|
| 4110 | - if ($sortorder) |
|
| 4111 | - $options .= "&sortorder=" . urlencode($sortorder); |
|
| 4112 | -// Show navigation bar |
|
| 4281 | + if ($sortfield) { |
|
| 4282 | + $options .= "&sortfield=" . urlencode($sortfield); |
|
| 4283 | + } |
|
| 4284 | + if ($sortorder) { |
|
| 4285 | + $options .= "&sortorder=" . urlencode($sortorder); |
|
| 4286 | + } |
|
| 4287 | + // Show navigation bar |
|
| 4113 | 4288 | $pagelist = ''; |
| 4114 | 4289 | if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
|
| 4115 | 4290 | if ($totalnboflines) { // If we know total nb of lines
|
| 4116 | 4291 | // Define nb of extra page links before and after selected page + ... + first or last |
| 4117 | 4292 | $maxnbofpage = (empty(Globals::$conf->dol_optimize_smallscreen) ? 4 : 1); |
| 4118 | 4293 | |
| 4119 | - if ($limit > 0) |
|
| 4120 | - $nbpages = ceil($totalnboflines / $limit); |
|
| 4121 | - else |
|
| 4122 | - $nbpages = 1; |
|
| 4294 | + if ($limit > 0) { |
|
| 4295 | + $nbpages = ceil($totalnboflines / $limit); |
|
| 4296 | + } else { |
|
| 4297 | + $nbpages = 1; |
|
| 4298 | + } |
|
| 4123 | 4299 | $cpt = ($page - $maxnbofpage); |
| 4124 | 4300 | if ($cpt < 0) {
|
| 4125 | 4301 | $cpt = 0; |
@@ -4127,10 +4303,11 @@ discard block |
||
| 4127 | 4303 | |
| 4128 | 4304 | if ($cpt >= 1) {
|
| 4129 | 4305 | $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=0' . $options . '">1</a></li>'; |
| 4130 | - if ($cpt > 2) |
|
| 4131 | - $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
| 4132 | - else if ($cpt == 2) |
|
| 4133 | - $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>'; |
|
| 4306 | + if ($cpt > 2) { |
|
| 4307 | + $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
| 4308 | + } else if ($cpt == 2) { |
|
| 4309 | + $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>'; |
|
| 4310 | + } |
|
| 4134 | 4311 | } |
| 4135 | 4312 | |
| 4136 | 4313 | do {
|
@@ -4143,14 +4320,14 @@ discard block |
||
| 4143 | 4320 | } while ($cpt < $nbpages && $cpt <= $page + $maxnbofpage); |
| 4144 | 4321 | |
| 4145 | 4322 | if ($cpt < $nbpages) {
|
| 4146 | - if ($cpt < $nbpages - 2) |
|
| 4147 | - $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
| 4148 | - else if ($cpt == $nbpages - 2) |
|
| 4149 | - $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>'; |
|
| 4323 | + if ($cpt < $nbpages - 2) { |
|
| 4324 | + $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
| 4325 | + } else if ($cpt == $nbpages - 2) { |
|
| 4326 | + $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>'; |
|
| 4327 | + } |
|
| 4150 | 4328 | $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 1) . $options . '">' . $nbpages . '</a></li>'; |
| 4151 | 4329 | } |
| 4152 | - } |
|
| 4153 | - else {
|
|
| 4330 | + } else {
|
|
| 4154 | 4331 | $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="active"' : '') . '>' . ($page + 1) . "</li>"; |
| 4155 | 4332 | } |
| 4156 | 4333 | } |
@@ -4186,18 +4363,21 @@ discard block |
||
| 4186 | 4363 | $pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000'; |
| 4187 | 4364 | //$pagesizechoices.=',0:'.Globals::$langs->trans("All"); // Not yet supported
|
| 4188 | 4365 | //$pagesizechoices.=',2:2'; |
| 4189 | - if (!empty(Globals::$conf->global->MAIN_PAGESIZE_CHOICES)) |
|
| 4190 | - $pagesizechoices = Globals::$conf->global->MAIN_PAGESIZE_CHOICES; |
|
| 4366 | + if (!empty(Globals::$conf->global->MAIN_PAGESIZE_CHOICES)) { |
|
| 4367 | + $pagesizechoices = Globals::$conf->global->MAIN_PAGESIZE_CHOICES; |
|
| 4368 | + } |
|
| 4191 | 4369 | |
| 4192 | 4370 | print '<li class="pagination">'; |
| 4193 | 4371 | print '<select class="flat selectlimit" name="limit" title="' . DolUtils::dol_escape_htmltag(Globals::$langs->trans("MaxNbOfRecordPerPage")) . '">';
|
| 4194 | 4372 | $tmpchoice = explode(',', $pagesizechoices);
|
| 4195 | 4373 | $tmpkey = $limit . ':' . $limit; |
| 4196 | - if (!in_array($tmpkey, $tmpchoice)) |
|
| 4197 | - $tmpchoice[] = $tmpkey; |
|
| 4374 | + if (!in_array($tmpkey, $tmpchoice)) { |
|
| 4375 | + $tmpchoice[] = $tmpkey; |
|
| 4376 | + } |
|
| 4198 | 4377 | $tmpkey = Globals::$conf->liste_limit . ':' . Globals::$conf->liste_limit; |
| 4199 | - if (!in_array($tmpkey, $tmpchoice)) |
|
| 4200 | - $tmpchoice[] = $tmpkey; |
|
| 4378 | + if (!in_array($tmpkey, $tmpchoice)) { |
|
| 4379 | + $tmpchoice[] = $tmpkey; |
|
| 4380 | + } |
|
| 4201 | 4381 | asort($tmpchoice, SORT_NUMERIC); |
| 4202 | 4382 | $found = false; |
| 4203 | 4383 | foreach ($tmpchoice as $val) {
|
@@ -4273,14 +4453,15 @@ discard block |
||
| 4273 | 4453 | } |
| 4274 | 4454 | |
| 4275 | 4455 | // If rate is '9/9/9' we don't change it. If rate is '9.000' we apply price() |
| 4276 | - if (!preg_match('/\//', $rate))
|
|
| 4277 | - $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : ''); |
|
| 4278 | - else {
|
|
| 4456 | + if (!preg_match('/\//', $rate)) { |
|
| 4457 | + $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : ''); |
|
| 4458 | + } else {
|
|
| 4279 | 4459 | // TODO Split on / and output with a price2num to have clean numbers without ton of 000. |
| 4280 | 4460 | $ret = $rate . ($addpercent ? '%' : ''); |
| 4281 | 4461 | } |
| 4282 | - if (($info_bits & 1) && $usestarfornpr >= 0) |
|
| 4283 | - $ret .= ' *'; |
|
| 4462 | + if (($info_bits & 1) && $usestarfornpr >= 0) { |
|
| 4463 | + $ret .= ' *'; |
|
| 4464 | + } |
|
| 4284 | 4465 | $ret .= $morelabel; |
| 4285 | 4466 | return $ret; |
| 4286 | 4467 | } |
@@ -4304,11 +4485,14 @@ discard block |
||
| 4304 | 4485 | {
|
| 4305 | 4486 | // global Globals::$langs, Globals::$conf; |
| 4306 | 4487 | // Clean parameters |
| 4307 | - if (empty($amount)) |
|
| 4308 | - $amount = 0; // To have a numeric value if amount not defined or = '' |
|
| 4488 | + if (empty($amount)) { |
|
| 4489 | + $amount = 0; |
|
| 4490 | + } |
|
| 4491 | + // To have a numeric value if amount not defined or = '' |
|
| 4309 | 4492 | $amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) |
| 4310 | - if ($rounding < 0) |
|
| 4311 | - $rounding = min(Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT, Globals::$conf->global->MAIN_MAX_DECIMALS_TOT); |
|
| 4493 | + if ($rounding < 0) { |
|
| 4494 | + $rounding = min(Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT, Globals::$conf->global->MAIN_MAX_DECIMALS_TOT); |
|
| 4495 | + } |
|
| 4312 | 4496 | $nbdecimal = $rounding; |
| 4313 | 4497 | |
| 4314 | 4498 | // Output separators by default (french) |
@@ -4316,18 +4500,22 @@ discard block |
||
| 4316 | 4500 | $thousand = ' '; |
| 4317 | 4501 | |
| 4318 | 4502 | // If $outlangs not forced, we use use language |
| 4319 | - if (!is_object($outlangs)) |
|
| 4320 | - $outlangs = Globals::$langs; |
|
| 4321 | - |
|
| 4322 | - if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal")
|
|
| 4323 | - $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal");
|
|
| 4324 | - if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand")
|
|
| 4325 | - $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand");
|
|
| 4326 | - if ($thousand == 'None') |
|
| 4327 | - $thousand = ''; |
|
| 4328 | - else if ($thousand == 'Space') |
|
| 4329 | - $thousand = ' '; |
|
| 4330 | -//print "outlangs=".$outlangs->defaultlang." amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>"; |
|
| 4503 | + if (!is_object($outlangs)) { |
|
| 4504 | + $outlangs = Globals::$langs; |
|
| 4505 | + } |
|
| 4506 | + |
|
| 4507 | + if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") { |
|
| 4508 | + $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal"); |
|
| 4509 | + } |
|
| 4510 | + if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") { |
|
| 4511 | + $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand"); |
|
| 4512 | + } |
|
| 4513 | + if ($thousand == 'None') { |
|
| 4514 | + $thousand = ''; |
|
| 4515 | + } else if ($thousand == 'Space') { |
|
| 4516 | + $thousand = ' '; |
|
| 4517 | + } |
|
| 4518 | + //print "outlangs=".$outlangs->defaultlang." amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>"; |
|
| 4331 | 4519 | //print "amount=".$amount."-"; |
| 4332 | 4520 | $amount = str_replace(',', '.', $amount); // should be useless
|
| 4333 | 4521 | //print $amount."-"; |
@@ -4338,9 +4526,10 @@ discard block |
||
| 4338 | 4526 | $end = ''; |
| 4339 | 4527 | |
| 4340 | 4528 | // We increase nbdecimal if there is more decimal than asked (to not loose information) |
| 4341 | - if (DolUtils::dol_strlen($decpart) > $nbdecimal) |
|
| 4342 | - $nbdecimal = DolUtils::dol_strlen($decpart); |
|
| 4343 | -// Si on depasse max |
|
| 4529 | + if (DolUtils::dol_strlen($decpart) > $nbdecimal) { |
|
| 4530 | + $nbdecimal = DolUtils::dol_strlen($decpart); |
|
| 4531 | + } |
|
| 4532 | + // Si on depasse max |
|
| 4344 | 4533 | if ($trunc && $nbdecimal > Globals::$conf->global->MAIN_MAX_DECIMALS_SHOWN) {
|
| 4345 | 4534 | $nbdecimal = Globals::$conf->global->MAIN_MAX_DECIMALS_SHOWN; |
| 4346 | 4535 | if (preg_match('/\.\.\./i', Globals::$conf->global->MAIN_MAX_DECIMALS_SHOWN)) {
|
@@ -4350,8 +4539,9 @@ discard block |
||
| 4350 | 4539 | } |
| 4351 | 4540 | |
| 4352 | 4541 | // If force rounding |
| 4353 | - if ($forcerounding >= 0) |
|
| 4354 | - $nbdecimal = $forcerounding; |
|
| 4542 | + if ($forcerounding >= 0) { |
|
| 4543 | + $nbdecimal = $forcerounding; |
|
| 4544 | + } |
|
| 4355 | 4545 | |
| 4356 | 4546 | // Format number |
| 4357 | 4547 | $output = number_format($amount, $nbdecimal, $dec, $thousand); |
@@ -4362,13 +4552,14 @@ discard block |
||
| 4362 | 4552 | // Add symbol of currency if requested |
| 4363 | 4553 | $cursymbolbefore = $cursymbolafter = ''; |
| 4364 | 4554 | if ($currency_code) {
|
| 4365 | - if ($currency_code == 'auto') |
|
| 4366 | - $currency_code = Globals::$conf->currency; |
|
| 4555 | + if ($currency_code == 'auto') { |
|
| 4556 | + $currency_code = Globals::$conf->currency; |
|
| 4557 | + } |
|
| 4367 | 4558 | |
| 4368 | 4559 | $listofcurrenciesbefore = array('USD', 'GBP', 'AUD', 'MXN', 'PEN', 'CNY');
|
| 4369 | - if (in_array($currency_code, $listofcurrenciesbefore)) |
|
| 4370 | - $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code); |
|
| 4371 | - else {
|
|
| 4560 | + if (in_array($currency_code, $listofcurrenciesbefore)) { |
|
| 4561 | + $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code); |
|
| 4562 | + } else {
|
|
| 4372 | 4563 | $tmpcur = $outlangs->getCurrencySymbol($currency_code); |
| 4373 | 4564 | $cursymbolafter .= ($tmpcur == $currency_code ? ' ' . $tmpcur : $tmpcur); |
| 4374 | 4565 | } |
@@ -4401,15 +4592,18 @@ discard block |
||
| 4401 | 4592 | // Decimal delimiter for PHP and database SQL requests must be '.' |
| 4402 | 4593 | $dec = ','; |
| 4403 | 4594 | $thousand = ' '; |
| 4404 | - if (Globals::$langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal")
|
|
| 4405 | - $dec = Globals::$langs->transnoentitiesnoconv("SeparatorDecimal");
|
|
| 4406 | - if (Globals::$langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand")
|
|
| 4407 | - $thousand = Globals::$langs->transnoentitiesnoconv("SeparatorThousand");
|
|
| 4408 | - if ($thousand == 'None') |
|
| 4409 | - $thousand = ''; |
|
| 4410 | - elseif ($thousand == 'Space') |
|
| 4411 | - $thousand = ' '; |
|
| 4412 | -//print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>"; |
|
| 4595 | + if (Globals::$langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") { |
|
| 4596 | + $dec = Globals::$langs->transnoentitiesnoconv("SeparatorDecimal"); |
|
| 4597 | + } |
|
| 4598 | + if (Globals::$langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") { |
|
| 4599 | + $thousand = Globals::$langs->transnoentitiesnoconv("SeparatorThousand"); |
|
| 4600 | + } |
|
| 4601 | + if ($thousand == 'None') { |
|
| 4602 | + $thousand = ''; |
|
| 4603 | + } elseif ($thousand == 'Space') { |
|
| 4604 | + $thousand = ' '; |
|
| 4605 | + } |
|
| 4606 | + //print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>"; |
|
| 4413 | 4607 | // Convert value to universal number format (no thousand separator, '.' as decimal separator) |
| 4414 | 4608 | if ($alreadysqlnb != 1) { // If not a PHP number or unknown, we change format
|
| 4415 | 4609 | //print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>'; |
@@ -4424,8 +4618,10 @@ discard block |
||
| 4424 | 4618 | } |
| 4425 | 4619 | //print "QQ".$amount.'<br>'; |
| 4426 | 4620 | // Now make replace (the main goal of function) |
| 4427 | - if ($thousand != ',' && $thousand != '.') |
|
| 4428 | - $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
|
|
| 4621 | + if ($thousand != ',' && $thousand != '.') { |
|
| 4622 | + $amount = str_replace(',', '.', $amount); |
|
| 4623 | + } |
|
| 4624 | + // To accept 2 notations for french users |
|
| 4429 | 4625 | $amount = str_replace(' ', '', $amount); // To avoid spaces
|
| 4430 | 4626 | $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . |
| 4431 | 4627 | $amount = str_replace($dec, '.', $amount); |
@@ -4434,20 +4630,24 @@ discard block |
||
| 4434 | 4630 | // Now, make a rounding if required |
| 4435 | 4631 | if ($rounding) {
|
| 4436 | 4632 | $nbofdectoround = ''; |
| 4437 | - if ($rounding == 'MU') |
|
| 4438 | - $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT; |
|
| 4439 | - elseif ($rounding == 'MT') |
|
| 4440 | - $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_TOT; |
|
| 4441 | - elseif ($rounding == 'MS') |
|
| 4442 | - $nbofdectoround = empty(Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK; |
|
| 4443 | - elseif (is_numeric($rounding)) |
|
| 4444 | - $nbofdectoround = $rounding; |
|
| 4445 | -//print "RR".$amount.' - '.$nbofdectoround.'<br>'; |
|
| 4446 | - if (DolUtils::dol_strlen($nbofdectoround)) |
|
| 4447 | - $amount = round($amount, $nbofdectoround); // $nbofdectoround can be 0. |
|
| 4448 | - else |
|
| 4449 | - return 'ErrorBadParameterProvidedToFunction'; |
|
| 4450 | -//print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>'; |
|
| 4633 | + if ($rounding == 'MU') { |
|
| 4634 | + $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT; |
|
| 4635 | + } elseif ($rounding == 'MT') { |
|
| 4636 | + $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_TOT; |
|
| 4637 | + } elseif ($rounding == 'MS') { |
|
| 4638 | + $nbofdectoround = empty(Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK; |
|
| 4639 | + } elseif (is_numeric($rounding)) { |
|
| 4640 | + $nbofdectoround = $rounding; |
|
| 4641 | + } |
|
| 4642 | + //print "RR".$amount.' - '.$nbofdectoround.'<br>'; |
|
| 4643 | + if (DolUtils::dol_strlen($nbofdectoround)) { |
|
| 4644 | + $amount = round($amount, $nbofdectoround); |
|
| 4645 | + } |
|
| 4646 | + // $nbofdectoround can be 0. |
|
| 4647 | + else { |
|
| 4648 | + return 'ErrorBadParameterProvidedToFunction'; |
|
| 4649 | + } |
|
| 4650 | + //print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>'; |
|
| 4451 | 4651 | // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number |
| 4452 | 4652 | // to format defined by LC_NUMERIC after a calculation and we want source format to be defined by Dolibarr setup. |
| 4453 | 4653 | if (is_numeric($amount)) {
|
@@ -4460,8 +4660,10 @@ discard block |
||
| 4460 | 4660 | //print "TT".$amount.'<br>'; |
| 4461 | 4661 | // Always make replace because each math static function (like round) replace |
| 4462 | 4662 | // with local values and we want a number that has a SQL string format x.y |
| 4463 | - if ($thousand != ',' && $thousand != '.') |
|
| 4464 | - $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
|
|
| 4663 | + if ($thousand != ',' && $thousand != '.') { |
|
| 4664 | + $amount = str_replace(',', '.', $amount); |
|
| 4665 | + } |
|
| 4666 | + // To accept 2 notations for french users |
|
| 4465 | 4667 | $amount = str_replace(' ', '', $amount); // To avoid spaces
|
| 4466 | 4668 | $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . |
| 4467 | 4669 | $amount = str_replace($dec, '.', $amount); |
@@ -4520,8 +4722,9 @@ discard block |
||
| 4520 | 4722 | {
|
| 4521 | 4723 | // global $db, Globals::$conf, $mysoc; |
| 4522 | 4724 | |
| 4523 | - if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) |
|
| 4524 | - $thirdparty_seller = $mysoc; |
|
| 4725 | + if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) { |
|
| 4726 | + $thirdparty_seller = $mysoc; |
|
| 4727 | + } |
|
| 4525 | 4728 | |
| 4526 | 4729 | DolUtils::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);
|
| 4527 | 4730 | |
@@ -4539,37 +4742,43 @@ discard block |
||
| 4539 | 4742 | // Some test to guess with no need to make database access |
| 4540 | 4743 | if ($mysoc->country_code == 'ES') { // For spain localtaxes 1 and 2, tax is qualified if buyer use local tax
|
| 4541 | 4744 | if ($local == 1) {
|
| 4542 | - if (!$mysoc->localtax1_assuj || (string) $vatratecleaned == "0") |
|
| 4543 | - return 0; |
|
| 4745 | + if (!$mysoc->localtax1_assuj || (string) $vatratecleaned == "0") { |
|
| 4746 | + return 0; |
|
| 4747 | + } |
|
| 4544 | 4748 | if ($thirdparty_seller->id == $mysoc->id) {
|
| 4545 | - if (!$thirdparty_buyer->localtax1_assuj) |
|
| 4546 | - return 0; |
|
| 4547 | - } |
|
| 4548 | - else {
|
|
| 4549 | - if (!$thirdparty_seller->localtax1_assuj) |
|
| 4550 | - return 0; |
|
| 4749 | + if (!$thirdparty_buyer->localtax1_assuj) { |
|
| 4750 | + return 0; |
|
| 4751 | + } |
|
| 4752 | + } else {
|
|
| 4753 | + if (!$thirdparty_seller->localtax1_assuj) { |
|
| 4754 | + return 0; |
|
| 4755 | + } |
|
| 4551 | 4756 | } |
| 4552 | 4757 | } |
| 4553 | 4758 | |
| 4554 | 4759 | if ($local == 2) {
|
| 4555 | 4760 | //if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0; |
| 4556 | - if (!$mysoc->localtax2_assuj) |
|
| 4557 | - return 0; // If main vat is 0, IRPF may be different than 0. |
|
| 4761 | + if (!$mysoc->localtax2_assuj) { |
|
| 4762 | + return 0; |
|
| 4763 | + } |
|
| 4764 | + // If main vat is 0, IRPF may be different than 0. |
|
| 4558 | 4765 | if ($thirdparty_seller->id == $mysoc->id) {
|
| 4559 | - if (!$thirdparty_buyer->localtax2_assuj) |
|
| 4560 | - return 0; |
|
| 4561 | - } |
|
| 4562 | - else {
|
|
| 4563 | - if (!$thirdparty_seller->localtax2_assuj) |
|
| 4564 | - return 0; |
|
| 4766 | + if (!$thirdparty_buyer->localtax2_assuj) { |
|
| 4767 | + return 0; |
|
| 4768 | + } |
|
| 4769 | + } else {
|
|
| 4770 | + if (!$thirdparty_seller->localtax2_assuj) { |
|
| 4771 | + return 0; |
|
| 4772 | + } |
|
| 4565 | 4773 | } |
| 4566 | 4774 | } |
| 4567 | - } |
|
| 4568 | - else {
|
|
| 4569 | - if ($local == 1 && !$thirdparty_seller->localtax1_assuj) |
|
| 4570 | - return 0; |
|
| 4571 | - if ($local == 2 && !$thirdparty_seller->localtax2_assuj) |
|
| 4572 | - return 0; |
|
| 4775 | + } else {
|
|
| 4776 | + if ($local == 1 && !$thirdparty_seller->localtax1_assuj) { |
|
| 4777 | + return 0; |
|
| 4778 | + } |
|
| 4779 | + if ($local == 2 && !$thirdparty_seller->localtax2_assuj) { |
|
| 4780 | + return 0; |
|
| 4781 | + } |
|
| 4573 | 4782 | } |
| 4574 | 4783 | |
| 4575 | 4784 | // For some country MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY is forced to on. |
@@ -4611,19 +4820,23 @@ discard block |
||
| 4611 | 4820 | $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c"; |
| 4612 | 4821 | $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $thirdparty_seller->country_code . "'"; |
| 4613 | 4822 | $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; |
| 4614 | - if ($vatratecode) |
|
| 4615 | - $sql .= " AND t.code ='" . $vatratecode . "'"; // If we have the code, we use it in priority |
|
| 4616 | - else |
|
| 4617 | - $sql .= " AND t.recuperableonly ='" . $vatnpr . "'"; |
|
| 4823 | + if ($vatratecode) { |
|
| 4824 | + $sql .= " AND t.code ='" . $vatratecode . "'"; |
|
| 4825 | + } |
|
| 4826 | + // If we have the code, we use it in priority |
|
| 4827 | + else { |
|
| 4828 | + $sql .= " AND t.recuperableonly ='" . $vatnpr . "'"; |
|
| 4829 | + } |
|
| 4618 | 4830 | DolUtils::dol_syslog("get_localtax", LOG_DEBUG);
|
| 4619 | 4831 | $resql = $db->query($sql); |
| 4620 | 4832 | |
| 4621 | 4833 | if ($resql) {
|
| 4622 | 4834 | $obj = $db->fetch_object($resql); |
| 4623 | - if ($local == 1) |
|
| 4624 | - return $obj->localtax1; |
|
| 4625 | - elseif ($local == 2) |
|
| 4626 | - return $obj->localtax2; |
|
| 4835 | + if ($local == 1) { |
|
| 4836 | + return $obj->localtax1; |
|
| 4837 | + } elseif ($local == 2) { |
|
| 4838 | + return $obj->localtax2; |
|
| 4839 | + } |
|
| 4627 | 4840 | } |
| 4628 | 4841 | |
| 4629 | 4842 | return 0; |
@@ -4669,10 +4882,11 @@ discard block |
||
| 4669 | 4882 | $resql = $db->query($sql); |
| 4670 | 4883 | if ($resql) {
|
| 4671 | 4884 | $obj = $db->fetch_object($resql); |
| 4672 | - if ($local == 1) |
|
| 4673 | - return $obj->localtax1; |
|
| 4674 | - elseif ($local == 2) |
|
| 4675 | - return $obj->localtax2; |
|
| 4885 | + if ($local == 1) { |
|
| 4886 | + return $obj->localtax1; |
|
| 4887 | + } elseif ($local == 2) { |
|
| 4888 | + return $obj->localtax2; |
|
| 4889 | + } |
|
| 4676 | 4890 | } |
| 4677 | 4891 | |
| 4678 | 4892 | return 0; |
@@ -4698,9 +4912,9 @@ discard block |
||
| 4698 | 4912 | // Search local taxes |
| 4699 | 4913 | $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy"; |
| 4700 | 4914 | $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t"; |
| 4701 | - if ($firstparamisid) |
|
| 4702 | - $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
| 4703 | - else {
|
|
| 4915 | + if ($firstparamisid) { |
|
| 4916 | + $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
| 4917 | + } else {
|
|
| 4704 | 4918 | $vatratecleaned = $vatrate; |
| 4705 | 4919 | $vatratecode = ''; |
| 4706 | 4920 | if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) { // If vat is "xx (yy)"
|
@@ -4713,19 +4927,22 @@ discard block |
||
| 4713 | 4927 | else $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; */ |
| 4714 | 4928 | $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'"; |
| 4715 | 4929 | $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; |
| 4716 | - if ($vatratecode) |
|
| 4717 | - $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
| 4930 | + if ($vatratecode) { |
|
| 4931 | + $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
| 4932 | + } |
|
| 4718 | 4933 | } |
| 4719 | 4934 | |
| 4720 | 4935 | $resql = $db->query($sql); |
| 4721 | 4936 | if ($resql) {
|
| 4722 | 4937 | $obj = $db->fetch_object($resql); |
| 4723 | - if ($obj) |
|
| 4724 | - 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);
|
|
| 4725 | - else |
|
| 4726 | - return array(); |
|
| 4727 | - } else |
|
| 4728 | - dol_print_error($db); |
|
| 4938 | + if ($obj) { |
|
| 4939 | + 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); |
|
| 4940 | + } else { |
|
| 4941 | + return array(); |
|
| 4942 | + } |
|
| 4943 | + } else { |
|
| 4944 | + dol_print_error($db); |
|
| 4945 | + } |
|
| 4729 | 4946 | |
| 4730 | 4947 | return array(); |
| 4731 | 4948 | } |
@@ -4755,9 +4972,9 @@ discard block |
||
| 4755 | 4972 | // Search local taxes |
| 4756 | 4973 | $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; |
| 4757 | 4974 | $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t"; |
| 4758 | - if ($firstparamisid) |
|
| 4759 | - $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
| 4760 | - else {
|
|
| 4975 | + if ($firstparamisid) { |
|
| 4976 | + $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
| 4977 | + } else {
|
|
| 4761 | 4978 | $vatratecleaned = $vatrate; |
| 4762 | 4979 | $vatratecode = ''; |
| 4763 | 4980 | if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) { // If vat is "x.x (yy)"
|
@@ -4766,13 +4983,17 @@ discard block |
||
| 4766 | 4983 | } |
| 4767 | 4984 | |
| 4768 | 4985 | $sql .= ", " . MAIN_DB_PREFIX . "c_country as c"; |
| 4769 | - if ($mysoc->country_code == 'ES') |
|
| 4770 | - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'"; // local tax in spain use the buyer country ?? |
|
| 4771 | - else |
|
| 4772 | - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'"; |
|
| 4986 | + if ($mysoc->country_code == 'ES') { |
|
| 4987 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'"; |
|
| 4988 | + } |
|
| 4989 | + // local tax in spain use the buyer country ?? |
|
| 4990 | + else { |
|
| 4991 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'"; |
|
| 4992 | + } |
|
| 4773 | 4993 | $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; |
| 4774 | - if ($vatratecode) |
|
| 4775 | - $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
| 4994 | + if ($vatratecode) { |
|
| 4995 | + $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
| 4996 | + } |
|
| 4776 | 4997 | } |
| 4777 | 4998 | |
| 4778 | 4999 | $resql = $db->query($sql); |
@@ -4818,17 +5039,17 @@ discard block |
||
| 4818 | 5039 | if ($idprodfournprice > 0) { // We want vat for product for a "supplier" object
|
| 4819 | 5040 | $product->get_buyprice($idprodfournprice, 0, 0, 0); |
| 4820 | 5041 | $ret = $product->vatrate_supplier; |
| 4821 | - if ($product->default_vat_code) |
|
| 4822 | - $ret .= ' (' . $product->default_vat_code . ')';
|
|
| 4823 | - } |
|
| 4824 | - else {
|
|
| 5042 | + if ($product->default_vat_code) { |
|
| 5043 | + $ret .= ' (' . $product->default_vat_code . ')'; |
|
| 5044 | + } |
|
| 5045 | + } else {
|
|
| 4825 | 5046 | $ret = $product->tva_tx; // Default vat of product we defined |
| 4826 | - if ($product->default_vat_code) |
|
| 4827 | - $ret .= ' (' . $product->default_vat_code . ')';
|
|
| 5047 | + if ($product->default_vat_code) { |
|
| 5048 | + $ret .= ' (' . $product->default_vat_code . ')'; |
|
| 5049 | + } |
|
| 4828 | 5050 | } |
| 4829 | 5051 | $found = 1; |
| 4830 | - } |
|
| 4831 | - else {
|
|
| 5052 | + } else {
|
|
| 4832 | 5053 | // TODO Read default product vat according to countrycode and product. Vat for couple countrycode/product is a feature not implemeted yet. |
| 4833 | 5054 | // May be usefull/required if hidden option SERVICE_ARE_ECOMMERCE_200238EC is on |
| 4834 | 5055 | } |
@@ -4848,14 +5069,18 @@ discard block |
||
| 4848 | 5069 | $obj = $db->fetch_object($resql); |
| 4849 | 5070 | if ($obj) {
|
| 4850 | 5071 | $ret = $obj->vat_rate; |
| 4851 | - if ($obj->default_vat_code) |
|
| 4852 | - $ret .= ' (' . $obj->default_vat_code . ')';
|
|
| 5072 | + if ($obj->default_vat_code) { |
|
| 5073 | + $ret .= ' (' . $obj->default_vat_code . ')'; |
|
| 5074 | + } |
|
| 4853 | 5075 | } |
| 4854 | 5076 | $db->free($sql); |
| 4855 | - } else |
|
| 4856 | - dol_print_error($db); |
|
| 4857 | - } else |
|
| 4858 | - $ret = Globals::$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; // Forced value if autodetect fails |
|
| 5077 | + } else { |
|
| 5078 | + dol_print_error($db); |
|
| 5079 | + } |
|
| 5080 | + } else { |
|
| 5081 | + $ret = Globals::$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; |
|
| 5082 | + } |
|
| 5083 | + // Forced value if autodetect fails |
|
| 4859 | 5084 | } |
| 4860 | 5085 | |
| 4861 | 5086 | DolUtils::dol_syslog("get_product_vat_for_country: ret=" . $ret);
|
@@ -4910,13 +5135,15 @@ discard block |
||
| 4910 | 5135 | if ($resql) {
|
| 4911 | 5136 | $obj = $db->fetch_object($resql); |
| 4912 | 5137 | if ($obj) {
|
| 4913 | - if ($local == 1) |
|
| 4914 | - $ret = $obj->localtax1; |
|
| 4915 | - elseif ($local == 2) |
|
| 4916 | - $ret = $obj->localtax2; |
|
| 5138 | + if ($local == 1) { |
|
| 5139 | + $ret = $obj->localtax1; |
|
| 5140 | + } elseif ($local == 2) { |
|
| 5141 | + $ret = $obj->localtax2; |
|
| 5142 | + } |
|
| 4917 | 5143 | } |
| 4918 | - } else |
|
| 4919 | - dol_print_error($db); |
|
| 5144 | + } else { |
|
| 5145 | + dol_print_error($db); |
|
| 5146 | + } |
|
| 4920 | 5147 | } |
| 4921 | 5148 | |
| 4922 | 5149 | DolUtils::dol_syslog("get_product_localtax_for_country: ret=" . $ret);
|
@@ -5019,15 +5246,16 @@ discard block |
||
| 5019 | 5246 | // global $db; |
| 5020 | 5247 | |
| 5021 | 5248 | if ($idprodfournprice > 0) {
|
| 5022 | - if (!class_exists('ProductFournisseur'))
|
|
| 5023 | - require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php'; |
|
| 5249 | + if (!class_exists('ProductFournisseur')) { |
|
| 5250 | + require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php'; |
|
| 5251 | + } |
|
| 5024 | 5252 | $prodprice = new ProductFournisseur($db); |
| 5025 | 5253 | $prodprice->fetch_product_fournisseur_price($idprodfournprice); |
| 5026 | 5254 | return $prodprice->fourn_tva_npr; |
| 5027 | - } |
|
| 5028 | - elseif ($idprod > 0) {
|
|
| 5029 | - if (!class_exists('Product'))
|
|
| 5030 | - require_once DOL_BASE_PATH . 'product/class/product.class.php'; |
|
| 5255 | + } elseif ($idprod > 0) {
|
|
| 5256 | + if (!class_exists('Product')) { |
|
| 5257 | + require_once DOL_BASE_PATH . 'product/class/product.class.php'; |
|
| 5258 | + } |
|
| 5031 | 5259 | $prod = new Product($db); |
| 5032 | 5260 | $prod->fetch($idprod); |
| 5033 | 5261 | return $prod->tva_npr; |
@@ -5053,30 +5281,35 @@ discard block |
||
| 5053 | 5281 | {
|
| 5054 | 5282 | // global $mysoc; |
| 5055 | 5283 | |
| 5056 | - if (!is_object($thirdparty_seller)) |
|
| 5057 | - return -1; |
|
| 5058 | - if (!is_object($thirdparty_buyer)) |
|
| 5059 | - return -1; |
|
| 5284 | + if (!is_object($thirdparty_seller)) { |
|
| 5285 | + return -1; |
|
| 5286 | + } |
|
| 5287 | + if (!is_object($thirdparty_buyer)) { |
|
| 5288 | + return -1; |
|
| 5289 | + } |
|
| 5060 | 5290 | |
| 5061 | 5291 | if ($local == 1) { // Localtax 1
|
| 5062 | 5292 | if ($mysoc->country_code == 'ES') {
|
| 5063 | - if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) |
|
| 5064 | - return 0; |
|
| 5065 | - } |
|
| 5066 | - else {
|
|
| 5293 | + if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) { |
|
| 5294 | + return 0; |
|
| 5295 | + } |
|
| 5296 | + } else {
|
|
| 5067 | 5297 | // Si vendeur non assujeti a Localtax1, localtax1 par default=0 |
| 5068 | - if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) |
|
| 5069 | - return 0; |
|
| 5070 | - if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off') |
|
| 5071 | - return 0; |
|
| 5072 | - } |
|
| 5073 | - } |
|
| 5074 | - elseif ($local == 2) { //I Localtax 2
|
|
| 5298 | + if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) { |
|
| 5299 | + return 0; |
|
| 5300 | + } |
|
| 5301 | + if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off') { |
|
| 5302 | + return 0; |
|
| 5303 | + } |
|
| 5304 | + } |
|
| 5305 | + } elseif ($local == 2) { //I Localtax 2
|
|
| 5075 | 5306 | // Si vendeur non assujeti a Localtax2, localtax2 par default=0 |
| 5076 | - if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) |
|
| 5077 | - return 0; |
|
| 5078 | - if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off') |
|
| 5079 | - return 0; |
|
| 5307 | + if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) { |
|
| 5308 | + return 0; |
|
| 5309 | + } |
|
| 5310 | + if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off') { |
|
| 5311 | + return 0; |
|
| 5312 | + } |
|
| 5080 | 5313 | } |
| 5081 | 5314 | |
| 5082 | 5315 | if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
|
@@ -5101,31 +5334,38 @@ discard block |
||
| 5101 | 5334 | $classname = ''; |
| 5102 | 5335 | if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') { // A mettre avant test sur no a cause du == 0
|
| 5103 | 5336 | $result = Globals::$langs->trans('yes');
|
| 5104 | - if ($case == 1 || $case == 3) |
|
| 5105 | - $result = Globals::$langs->trans("Yes");
|
|
| 5106 | - if ($case == 2) |
|
| 5107 | - $result = '<input type="checkbox" value="1" checked disabled>'; |
|
| 5108 | - if ($case == 3) |
|
| 5109 | - $result = '<input type="checkbox" value="1" checked disabled> ' . $result; |
|
| 5337 | + if ($case == 1 || $case == 3) { |
|
| 5338 | + $result = Globals::$langs->trans("Yes"); |
|
| 5339 | + } |
|
| 5340 | + if ($case == 2) { |
|
| 5341 | + $result = '<input type="checkbox" value="1" checked disabled>'; |
|
| 5342 | + } |
|
| 5343 | + if ($case == 3) { |
|
| 5344 | + $result = '<input type="checkbox" value="1" checked disabled> ' . $result; |
|
| 5345 | + } |
|
| 5110 | 5346 | |
| 5111 | 5347 | $classname = 'ok'; |
| 5112 | - } |
|
| 5113 | - elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') {
|
|
| 5348 | + } elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') {
|
|
| 5114 | 5349 | $result = Globals::$langs->trans("no");
|
| 5115 | - if ($case == 1 || $case == 3) |
|
| 5116 | - $result = Globals::$langs->trans("No");
|
|
| 5117 | - if ($case == 2) |
|
| 5118 | - $result = '<input type="checkbox" value="0" disabled>'; |
|
| 5119 | - if ($case == 3) |
|
| 5120 | - $result = '<input type="checkbox" value="0" disabled> ' . $result; |
|
| 5121 | - |
|
| 5122 | - if ($color == 2) |
|
| 5123 | - $classname = 'ok'; |
|
| 5124 | - else |
|
| 5125 | - $classname = 'error'; |
|
| 5126 | - } |
|
| 5127 | - if ($color) |
|
| 5128 | - return '<font class="' . $classname . '">' . $result . '</font>'; |
|
| 5350 | + if ($case == 1 || $case == 3) { |
|
| 5351 | + $result = Globals::$langs->trans("No"); |
|
| 5352 | + } |
|
| 5353 | + if ($case == 2) { |
|
| 5354 | + $result = '<input type="checkbox" value="0" disabled>'; |
|
| 5355 | + } |
|
| 5356 | + if ($case == 3) { |
|
| 5357 | + $result = '<input type="checkbox" value="0" disabled> ' . $result; |
|
| 5358 | + } |
|
| 5359 | + |
|
| 5360 | + if ($color == 2) { |
|
| 5361 | + $classname = 'ok'; |
|
| 5362 | + } else { |
|
| 5363 | + $classname = 'error'; |
|
| 5364 | + } |
|
| 5365 | + } |
|
| 5366 | + if ($color) { |
|
| 5367 | + return '<font class="' . $classname . '">' . $result . '</font>'; |
|
| 5368 | + } |
|
| 5129 | 5369 | return $result; |
| 5130 | 5370 | } |
| 5131 | 5371 | |
@@ -5151,23 +5391,27 @@ discard block |
||
| 5151 | 5391 | $path = ''; |
| 5152 | 5392 | |
| 5153 | 5393 | $arrayforoldpath = array('cheque', 'user', 'category', 'holiday', 'supplier_invoice', 'invoice_supplier', 'mailing', 'supplier_payment');
|
| 5154 | - if (!empty(Globals::$conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) |
|
| 5155 | - $arrayforoldpath[] = 'product'; |
|
| 5394 | + if (!empty(Globals::$conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { |
|
| 5395 | + $arrayforoldpath[] = 'product'; |
|
| 5396 | + } |
|
| 5156 | 5397 | if (!empty($level) && in_array($modulepart, $arrayforoldpath)) {
|
| 5157 | 5398 | // This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided. |
| 5158 | - if (empty($alpha)) |
|
| 5159 | - $num = preg_replace('/([^0-9])/i', '', $num);
|
|
| 5160 | - else |
|
| 5161 | - $num = preg_replace('/^.*\-/i', '', $num);
|
|
| 5399 | + if (empty($alpha)) { |
|
| 5400 | + $num = preg_replace('/([^0-9])/i', '', $num); |
|
| 5401 | + } else { |
|
| 5402 | + $num = preg_replace('/^.*\-/i', '', $num); |
|
| 5403 | + } |
|
| 5162 | 5404 | $num = substr("000" . $num, -$level);
|
| 5163 | - if ($level == 1) |
|
| 5164 | - $path = substr($num, 0, 1); |
|
| 5165 | - if ($level == 2) |
|
| 5166 | - $path = substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
| 5167 | - if ($level == 3) |
|
| 5168 | - $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
| 5169 | - } |
|
| 5170 | - else {
|
|
| 5405 | + if ($level == 1) { |
|
| 5406 | + $path = substr($num, 0, 1); |
|
| 5407 | + } |
|
| 5408 | + if ($level == 2) { |
|
| 5409 | + $path = substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
| 5410 | + } |
|
| 5411 | + if ($level == 3) { |
|
| 5412 | + $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
| 5413 | + } |
|
| 5414 | + } else {
|
|
| 5171 | 5415 | // TODO |
| 5172 | 5416 | // We will enhance here a common way of forging path for document storage |
| 5173 | 5417 | // Here, object->id, object->ref and modulepart are required. |
@@ -5178,8 +5422,9 @@ discard block |
||
| 5178 | 5422 | } |
| 5179 | 5423 | } |
| 5180 | 5424 | |
| 5181 | - if (empty($withoutslash) && !empty($path)) |
|
| 5182 | - $path .= '/'; |
|
| 5425 | + if (empty($withoutslash) && !empty($path)) { |
|
| 5426 | + $path .= '/'; |
|
| 5427 | + } |
|
| 5183 | 5428 | |
| 5184 | 5429 | return $path; |
| 5185 | 5430 | } |
@@ -5199,8 +5444,9 @@ discard block |
||
| 5199 | 5444 | DolUtils::dol_syslog("functions.lib::dol_mkdir: dir=" . $dir, LOG_INFO);
|
| 5200 | 5445 | |
| 5201 | 5446 | $dir_osencoded = dol_osencode($dir); |
| 5202 | - if (@is_dir($dir_osencoded)) |
|
| 5203 | - return 0; |
|
| 5447 | + if (@is_dir($dir_osencoded)) { |
|
| 5448 | + return 0; |
|
| 5449 | + } |
|
| 5204 | 5450 | |
| 5205 | 5451 | $nberr = 0; |
| 5206 | 5452 | $nbcreated = 0; |
@@ -5215,12 +5461,15 @@ discard block |
||
| 5215 | 5461 | $cdir = explode("/", $dir);
|
| 5216 | 5462 | $num = count($cdir); |
| 5217 | 5463 | for ($i = 0; $i < $num; $i++) {
|
| 5218 | - if ($i > 0) |
|
| 5219 | - $ccdir .= '/' . $cdir[$i]; |
|
| 5220 | - else |
|
| 5221 | - $ccdir .= $cdir[$i]; |
|
| 5222 | - if (preg_match("/^.:$/", $ccdir, $regs))
|
|
| 5223 | - continue; // Si chemin Windows incomplet, on poursuit par rep suivant |
|
| 5464 | + if ($i > 0) { |
|
| 5465 | + $ccdir .= '/' . $cdir[$i]; |
|
| 5466 | + } else { |
|
| 5467 | + $ccdir .= $cdir[$i]; |
|
| 5468 | + } |
|
| 5469 | + if (preg_match("/^.:$/", $ccdir, $regs)) { |
|
| 5470 | + continue; |
|
| 5471 | + } |
|
| 5472 | + // Si chemin Windows incomplet, on poursuit par rep suivant |
|
| 5224 | 5473 | |
| 5225 | 5474 | |
| 5226 | 5475 | |
@@ -5314,8 +5563,9 @@ discard block |
||
| 5314 | 5563 | */ |
| 5315 | 5564 | static function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = 'UTF-8', $strip_tags = 0) |
| 5316 | 5565 | {
|
| 5317 | - if ($removelinefeed == 2) |
|
| 5318 | - $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean);
|
|
| 5566 | + if ($removelinefeed == 2) { |
|
| 5567 | + $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean); |
|
| 5568 | + } |
|
| 5319 | 5569 | $temp = preg_replace('/<br[^>]*>/i', "\n", $stringtoclean);
|
| 5320 | 5570 | |
| 5321 | 5571 | if ($strip_tags) {
|
@@ -5332,8 +5582,9 @@ discard block |
||
| 5332 | 5582 | $temp = dol_html_entity_decode($temp, ENT_COMPAT, $pagecodeto); |
| 5333 | 5583 | |
| 5334 | 5584 | // Supprime aussi les retours |
| 5335 | - if ($removelinefeed == 1) |
|
| 5336 | - $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp);
|
|
| 5585 | + if ($removelinefeed == 1) { |
|
| 5586 | + $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp); |
|
| 5587 | + } |
|
| 5337 | 5588 | |
| 5338 | 5589 | // et les espaces doubles |
| 5339 | 5590 | while (strpos($temp, " ")) {
|
@@ -5419,18 +5670,21 @@ discard block |
||
| 5419 | 5670 | if ($charset == 'UTF-8') {
|
| 5420 | 5671 | $pattern = '/(<br[^>]*>)/Uu'; |
| 5421 | 5672 | } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support |
| 5422 | - else |
|
| 5423 | - $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. |
|
| 5673 | + else { |
|
| 5674 | + $pattern = '/(<br[^>]*>)/U'; |
|
| 5675 | + } |
|
| 5676 | + // /U is to have UNGREEDY regex to limit to one html tag. |
|
| 5424 | 5677 | $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 5425 | 5678 | |
| 5426 | 5679 | $firstline = ''; |
| 5427 | 5680 | $i = 0; |
| 5428 | 5681 | $nba = count($a); // 2x nb of lines in $a because $a contains also a line for each new line separator |
| 5429 | 5682 | while (($i < $nba) && ($i < ($nboflines * 2))) {
|
| 5430 | - if ($i % 2 == 0) |
|
| 5431 | - $firstline .= $a[$i]; |
|
| 5432 | - elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) |
|
| 5433 | - $firstline .= ($ishtml ? "<br>\n" : "\n"); |
|
| 5683 | + if ($i % 2 == 0) { |
|
| 5684 | + $firstline .= $a[$i]; |
|
| 5685 | + } elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) { |
|
| 5686 | + $firstline .= ($ishtml ? "<br>\n" : "\n"); |
|
| 5687 | + } |
|
| 5434 | 5688 | $i++; |
| 5435 | 5689 | } |
| 5436 | 5690 | unset($a); |
@@ -5479,15 +5733,18 @@ discard block |
||
| 5479 | 5733 | $newstring = $stringtoencode; |
| 5480 | 5734 | if (DolUtils::dol_textishtml($stringtoencode)) { // Check if text is already HTML or not
|
| 5481 | 5735 | $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.
|
| 5482 | - if ($removelasteolbr) |
|
| 5483 | - $newstring = preg_replace('/<br>$/i', '', $newstring); // Remove last <br> (remove only last one)
|
|
| 5736 | + if ($removelasteolbr) { |
|
| 5737 | + $newstring = preg_replace('/<br>$/i', '', $newstring); |
|
| 5738 | + } |
|
| 5739 | + // Remove last <br> (remove only last one) |
|
| 5484 | 5740 | $newstring = strtr($newstring, array('&' => '__and__', '<' => '__lt__', '>' => '__gt__', '"' => '__dquot__'));
|
| 5485 | 5741 | $newstring = DolUtils::dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom); // Make entity encoding |
| 5486 | 5742 | $newstring = strtr($newstring, array('__and__' => '&', '__lt__' => '<', '__gt__' => '>', '__dquot__' => '"'));
|
| 5487 | - } |
|
| 5488 | - else {
|
|
| 5489 | - if ($removelasteolbr) |
|
| 5490 | - $newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring); // Remove last \n (may remove several)
|
|
| 5743 | + } else {
|
|
| 5744 | + if ($removelasteolbr) { |
|
| 5745 | + $newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring); |
|
| 5746 | + } |
|
| 5747 | + // Remove last \n (may remove several) |
|
| 5491 | 5748 | $newstring = dol_nl2br(DolUtils::dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom), $nl2brmode); |
| 5492 | 5749 | } |
| 5493 | 5750 | // Other substitutions that htmlentities does not do |
@@ -5589,8 +5846,9 @@ discard block |
||
| 5589 | 5846 | */ |
| 5590 | 5847 | static function dol_nboflines($s, $maxchar = 0) |
| 5591 | 5848 | {
|
| 5592 | - if ($s == '') |
|
| 5593 | - return 0; |
|
| 5849 | + if ($s == '') { |
|
| 5850 | + return 0; |
|
| 5851 | + } |
|
| 5594 | 5852 | $arraystring = explode("\n", $s);
|
| 5595 | 5853 | $nb = count($arraystring); |
| 5596 | 5854 | |
@@ -5609,15 +5867,18 @@ discard block |
||
| 5609 | 5867 | static function dol_nboflines_bis($text, $maxlinesize = 0, $charset = 'UTF-8') |
| 5610 | 5868 | {
|
| 5611 | 5869 | $repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " ");
|
| 5612 | - if (DolUtils::dol_textishtml($text)) |
|
| 5613 | - $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " ");
|
|
| 5870 | + if (DolUtils::dol_textishtml($text)) { |
|
| 5871 | + $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " "); |
|
| 5872 | + } |
|
| 5614 | 5873 | |
| 5615 | 5874 | $text = strtr($text, $repTable); |
| 5616 | 5875 | if ($charset == 'UTF-8') {
|
| 5617 | 5876 | $pattern = '/(<br[^>]*>)/Uu'; |
| 5618 | 5877 | } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support |
| 5619 | - else |
|
| 5620 | - $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. |
|
| 5878 | + else { |
|
| 5879 | + $pattern = '/(<br[^>]*>)/U'; |
|
| 5880 | + } |
|
| 5881 | + // /U is to have UNGREEDY regex to limit to one html tag. |
|
| 5621 | 5882 | $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 5622 | 5883 | |
| 5623 | 5884 | $nblines = (int) floor((count($a) + 1) / 2); |
@@ -5664,39 +5925,47 @@ discard block |
||
| 5664 | 5925 | static function dol_textishtml($msg, $option = 0) |
| 5665 | 5926 | {
|
| 5666 | 5927 | if ($option == 1) {
|
| 5667 | - if (preg_match('/<html/i', $msg))
|
|
| 5668 | - return true; |
|
| 5669 | - elseif (preg_match('/<body/i', $msg))
|
|
| 5670 | - return true; |
|
| 5671 | - elseif (preg_match('/<br/i', $msg))
|
|
| 5672 | - return true; |
|
| 5928 | + if (preg_match('/<html/i', $msg)) { |
|
| 5929 | + return true; |
|
| 5930 | + } elseif (preg_match('/<body/i', $msg)) { |
|
| 5931 | + return true; |
|
| 5932 | + } elseif (preg_match('/<br/i', $msg)) { |
|
| 5933 | + return true; |
|
| 5934 | + } |
|
| 5673 | 5935 | return false; |
| 5674 | - } |
|
| 5675 | - else {
|
|
| 5676 | - if (preg_match('/<html/i', $msg))
|
|
| 5677 | - return true; |
|
| 5678 | - elseif (preg_match('/<body/i', $msg))
|
|
| 5679 | - return true; |
|
| 5680 | - elseif (preg_match('/<(b|em|i|u)>/i', $msg))
|
|
| 5681 | - return true; |
|
| 5682 | - elseif (preg_match('/<br\/>/i', $msg))
|
|
| 5683 | - return true; |
|
| 5684 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg))
|
|
| 5685 | - return true; |
|
| 5686 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg))
|
|
| 5687 | - return true; |
|
| 5688 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg))
|
|
| 5689 | - return true; |
|
| 5690 | - elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i', $msg))
|
|
| 5691 | - return true; // must accept <img src="http://example.com/aaa.png" /> |
|
| 5692 | - elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i', $msg))
|
|
| 5693 | - return true; // must accept <a href="http://example.com/aaa.png" /> |
|
| 5694 | - elseif (preg_match('/<h[0-9]>/i', $msg))
|
|
| 5695 | - return true; |
|
| 5696 | - elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg))
|
|
| 5697 | - return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) |
|
| 5698 | - elseif (preg_match('/&#[0-9]{2,3};/i', $msg))
|
|
| 5699 | - return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) |
|
| 5936 | + } else {
|
|
| 5937 | + if (preg_match('/<html/i', $msg)) { |
|
| 5938 | + return true; |
|
| 5939 | + } elseif (preg_match('/<body/i', $msg)) { |
|
| 5940 | + return true; |
|
| 5941 | + } elseif (preg_match('/<(b|em|i|u)>/i', $msg)) { |
|
| 5942 | + return true; |
|
| 5943 | + } elseif (preg_match('/<br\/>/i', $msg)) { |
|
| 5944 | + return true; |
|
| 5945 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg)) { |
|
| 5946 | + return true; |
|
| 5947 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg)) { |
|
| 5948 | + return true; |
|
| 5949 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg)) { |
|
| 5950 | + return true; |
|
| 5951 | + } elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i', $msg)) { |
|
| 5952 | + return true; |
|
| 5953 | + } |
|
| 5954 | + // must accept <img src="http://example.com/aaa.png" /> |
|
| 5955 | + elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i', $msg)) { |
|
| 5956 | + return true; |
|
| 5957 | + } |
|
| 5958 | + // must accept <a href="http://example.com/aaa.png" /> |
|
| 5959 | + elseif (preg_match('/<h[0-9]>/i', $msg)) { |
|
| 5960 | + return true; |
|
| 5961 | + } elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg)) { |
|
| 5962 | + return true; |
|
| 5963 | + } |
|
| 5964 | + // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) |
|
| 5965 | + elseif (preg_match('/&#[0-9]{2,3};/i', $msg)) { |
|
| 5966 | + return true; |
|
| 5967 | + } |
|
| 5968 | + // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) |
|
| 5700 | 5969 | |
| 5701 | 5970 | return false; |
| 5702 | 5971 | } |
@@ -5848,12 +6117,14 @@ discard block |
||
| 5848 | 6117 | $birthday = DolUtils::dol_print_date($object->birth, 'day'); |
| 5849 | 6118 | |
| 5850 | 6119 | $substitutionarray['__MEMBER_ID__'] = $object->id; |
| 5851 | - if (method_exists($object, 'getCivilityLabel')) |
|
| 5852 | - $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); |
|
| 6120 | + if (method_exists($object, 'getCivilityLabel')) { |
|
| 6121 | + $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); |
|
| 6122 | + } |
|
| 5853 | 6123 | $substitutionarray['__MEMBER_FIRSTNAME__'] = $msgishtml ? DolUtils::dol_htmlentitiesbr($object->firstname) : $object->firstname; |
| 5854 | 6124 | $substitutionarray['__MEMBER_LASTNAME__'] = $msgishtml ? DolUtils::dol_htmlentitiesbr($object->lastname) : $object->lastname; |
| 5855 | - if (method_exists($object, 'getFullName')) |
|
| 5856 | - $substitutionarray['__MEMBER_FULLNAME__'] = $msgishtml ? DolUtils::dol_htmlentitiesbr($object->getFullName($outputlangs)) : $object->getFullName($outputlangs); |
|
| 6125 | + if (method_exists($object, 'getFullName')) { |
|
| 6126 | + $substitutionarray['__MEMBER_FULLNAME__'] = $msgishtml ? DolUtils::dol_htmlentitiesbr($object->getFullName($outputlangs)) : $object->getFullName($outputlangs); |
|
| 6127 | + } |
|
| 5857 | 6128 | $substitutionarray['__MEMBER_COMPANY__'] = $msgishtml ? DolUtils::dol_htmlentitiesbr($object->societe) : $object->societe; |
| 5858 | 6129 | $substitutionarray['__MEMBER_ADDRESS__'] = $msgishtml ? DolUtils::dol_htmlentitiesbr($object->address) : $object->address; |
| 5859 | 6130 | $substitutionarray['__MEMBER_ZIP__'] = $msgishtml ? DolUtils::dol_htmlentitiesbr($object->zip) : $object->zip; |
@@ -5901,10 +6172,12 @@ discard block |
||
| 5901 | 6172 | $dateplannedstart = ''; |
| 5902 | 6173 | $datenextexpiration = ''; |
| 5903 | 6174 | foreach ($object->lines as $line) {
|
| 5904 | - if ($line->date_ouverture_prevue > $dateplannedstart) |
|
| 5905 | - $dateplannedstart = $line->date_ouverture_prevue; |
|
| 5906 | - if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) |
|
| 5907 | - $datenextexpiration = $line->date_fin_prevue; |
|
| 6175 | + if ($line->date_ouverture_prevue > $dateplannedstart) { |
|
| 6176 | + $dateplannedstart = $line->date_ouverture_prevue; |
|
| 6177 | + } |
|
| 6178 | + if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) { |
|
| 6179 | + $datenextexpiration = $line->date_fin_prevue; |
|
| 6180 | + } |
|
| 5908 | 6181 | } |
| 5909 | 6182 | $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = DolUtils::dol_print_date($dateplannedstart, 'dayrfc'); |
| 5910 | 6183 | $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = DolUtils::dol_print_date($dateplannedstart, 'standard'); |
@@ -5914,8 +6187,9 @@ discard block |
||
| 5914 | 6187 | |
| 5915 | 6188 | // Create dynamic tags for __EXTRAFIELD_FIELD__ |
| 5916 | 6189 | if ($object->table_element && $object->id > 0) {
|
| 5917 | - if (!is_object($extrafields)) |
|
| 5918 | - $extrafields = new ExtraFields($db); |
|
| 6190 | + if (!is_object($extrafields)) { |
|
| 6191 | + $extrafields = new ExtraFields($db); |
|
| 6192 | + } |
|
| 5919 | 6193 | $extrafields->fetch_name_optionals_label($object->table_element, true); |
| 5920 | 6194 | |
| 5921 | 6195 | if ($object->fetch_optionals() > 0) {
|
@@ -5936,12 +6210,15 @@ discard block |
||
| 5936 | 6210 | require_once DOL_BASE_PATH . '/core/lib/payments.lib.php'; |
| 5937 | 6211 | $outputlangs->loadLangs(array('paypal', 'other'));
|
| 5938 | 6212 | $typeforonlinepayment = 'free'; |
| 5939 | - if (is_object($object) && $object->element == 'commande') |
|
| 5940 | - $typeforonlinepayment = 'order'; |
|
| 5941 | - if (is_object($object) && $object->element == 'facture') |
|
| 5942 | - $typeforonlinepayment = 'invoice'; |
|
| 5943 | - if (is_object($object) && $object->element == 'member') |
|
| 5944 | - $typeforonlinepayment = 'member'; |
|
| 6213 | + if (is_object($object) && $object->element == 'commande') { |
|
| 6214 | + $typeforonlinepayment = 'order'; |
|
| 6215 | + } |
|
| 6216 | + if (is_object($object) && $object->element == 'facture') { |
|
| 6217 | + $typeforonlinepayment = 'invoice'; |
|
| 6218 | + } |
|
| 6219 | + if (is_object($object) && $object->element == 'member') { |
|
| 6220 | + $typeforonlinepayment = 'member'; |
|
| 6221 | + } |
|
| 5945 | 6222 | $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray['__REF__']); |
| 5946 | 6223 | $paymenturl = $url; |
| 5947 | 6224 | } |
@@ -5951,16 +6228,19 @@ discard block |
||
| 5951 | 6228 | |
| 5952 | 6229 | if (!empty(Globals::$conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal') {
|
| 5953 | 6230 | $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element); |
| 5954 | - } else |
|
| 5955 | - $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = ''; |
|
| 6231 | + } else { |
|
| 6232 | + $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = ''; |
|
| 6233 | + } |
|
| 5956 | 6234 | if (!empty(Globals::$conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'commande') {
|
| 5957 | 6235 | $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element); |
| 5958 | - } else |
|
| 5959 | - $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = ''; |
|
| 6236 | + } else { |
|
| 6237 | + $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = ''; |
|
| 6238 | + } |
|
| 5960 | 6239 | if (!empty(Globals::$conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'facture') {
|
| 5961 | 6240 | $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element); |
| 5962 | - } else |
|
| 5963 | - $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = ''; |
|
| 6241 | + } else { |
|
| 6242 | + $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = ''; |
|
| 6243 | + } |
|
| 5964 | 6244 | } |
| 5965 | 6245 | } |
| 5966 | 6246 | if (empty($exclude) || !in_array('objectamount', $exclude)) {
|
@@ -5970,18 +6250,22 @@ discard block |
||
| 5970 | 6250 | $substitutionarray['__AMOUNT__'] = is_object($object) ? $object->total_ttc : ''; |
| 5971 | 6251 | $substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht : ''; |
| 5972 | 6252 | $substitutionarray['__AMOUNT_VAT__'] = is_object($object) ? ($object->total_vat ? $object->total_vat : $object->total_tva) : ''; |
| 5973 | - if ($onlykey != 2 || $mysoc->useLocalTax(1)) |
|
| 5974 | - $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : ''; |
|
| 5975 | - if ($onlykey != 2 || $mysoc->useLocalTax(2)) |
|
| 5976 | - $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : ''; |
|
| 6253 | + if ($onlykey != 2 || $mysoc->useLocalTax(1)) { |
|
| 6254 | + $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : ''; |
|
| 6255 | + } |
|
| 6256 | + if ($onlykey != 2 || $mysoc->useLocalTax(2)) { |
|
| 6257 | + $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : ''; |
|
| 6258 | + } |
|
| 5977 | 6259 | |
| 5978 | 6260 | $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object) ? price($object->total_ttc, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : ''; |
| 5979 | 6261 | $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object) ? price($object->total_ht, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : ''; |
| 5980 | 6262 | $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)) : ''; |
| 5981 | - if ($onlykey != 2 || $mysoc->useLocalTax(1)) |
|
| 5982 | - $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : ''; |
|
| 5983 | - if ($onlykey != 2 || $mysoc->useLocalTax(2)) |
|
| 5984 | - $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : ''; |
|
| 6263 | + if ($onlykey != 2 || $mysoc->useLocalTax(1)) { |
|
| 6264 | + $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : ''; |
|
| 6265 | + } |
|
| 6266 | + if ($onlykey != 2 || $mysoc->useLocalTax(2)) { |
|
| 6267 | + $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : ''; |
|
| 6268 | + } |
|
| 5985 | 6269 | |
| 5986 | 6270 | // TODO Add keys for foreign multicurrency |
| 5987 | 6271 | // For backward compatibility |
@@ -6051,23 +6335,27 @@ discard block |
||
| 6051 | 6335 | {
|
| 6052 | 6336 | // global Globals::$conf, Globals::$langs; |
| 6053 | 6337 | |
| 6054 | - if (!is_array($substitutionarray)) |
|
| 6055 | - return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions'; |
|
| 6338 | + if (!is_array($substitutionarray)) { |
|
| 6339 | + return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions'; |
|
| 6340 | + } |
|
| 6056 | 6341 | |
| 6057 | - if (empty($outputlangs)) |
|
| 6058 | - $outputlangs = Globals::$langs; |
|
| 6342 | + if (empty($outputlangs)) { |
|
| 6343 | + $outputlangs = Globals::$langs; |
|
| 6344 | + } |
|
| 6059 | 6345 | |
| 6060 | 6346 | // Make substitution for language keys |
| 6061 | 6347 | if (is_object($outputlangs)) {
|
| 6062 | 6348 | while (preg_match('/__\(([^\)]+)\)__/', $text, $reg)) {
|
| 6063 | 6349 | $msgishtml = 0; |
| 6064 | - if (DolUtils::dol_textishtml($text, 1)) |
|
| 6065 | - $msgishtml = 1; |
|
| 6350 | + if (DolUtils::dol_textishtml($text, 1)) { |
|
| 6351 | + $msgishtml = 1; |
|
| 6352 | + } |
|
| 6066 | 6353 | |
| 6067 | 6354 | // If key is __(TranslationKey|langfile)__, then force load of langfile.lang |
| 6068 | 6355 | $tmp = explode('|', $reg[1]);
|
| 6069 | - if (!empty($tmp[1])) |
|
| 6070 | - $outputlangs->load($tmp[1]); |
|
| 6356 | + if (!empty($tmp[1])) { |
|
| 6357 | + $outputlangs->load($tmp[1]); |
|
| 6358 | + } |
|
| 6071 | 6359 | |
| 6072 | 6360 | $text = preg_replace('/__\(' . preg_quote($reg[1], '/') . '\)__/', $msgishtml ? DolUtils::dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])) : $outputlangs->transnoentitiesnoconv($reg[1]), $text);
|
| 6073 | 6361 | } |
@@ -6077,23 +6365,29 @@ discard block |
||
| 6077 | 6365 | // it is also converted. |
| 6078 | 6366 | while (preg_match('/__\[([^\]]+)\]__/', $text, $reg)) {
|
| 6079 | 6367 | $msgishtml = 0; |
| 6080 | - if (DolUtils::dol_textishtml($text, 1)) |
|
| 6081 | - $msgishtml = 1; |
|
| 6368 | + if (DolUtils::dol_textishtml($text, 1)) { |
|
| 6369 | + $msgishtml = 1; |
|
| 6370 | + } |
|
| 6082 | 6371 | |
| 6083 | 6372 | $keyfound = $reg[1]; |
| 6084 | - if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound))
|
|
| 6085 | - $newval = '*****forbidden*****'; |
|
| 6086 | - else |
|
| 6087 | - $newval = empty(Globals::$conf->global->$keyfound) ? '' : Globals::$conf->global->$keyfound; |
|
| 6373 | + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) { |
|
| 6374 | + $newval = '*****forbidden*****'; |
|
| 6375 | + } else { |
|
| 6376 | + $newval = empty(Globals::$conf->global->$keyfound) ? '' : Globals::$conf->global->$keyfound; |
|
| 6377 | + } |
|
| 6088 | 6378 | $text = preg_replace('/__\[' . preg_quote($keyfound, '/') . '\]__/', $msgishtml ? DolUtils::dol_htmlentitiesbr($newval) : $newval, $text);
|
| 6089 | 6379 | } |
| 6090 | 6380 | |
| 6091 | 6381 | // Make substitition for array $substitutionarray |
| 6092 | 6382 | foreach ($substitutionarray as $key => $value) {
|
| 6093 | - if ($key == '__SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) |
|
| 6094 | - $value = ''; // Protection |
|
| 6095 | - if ($key == '__USER_SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) |
|
| 6096 | - $value = ''; // Protection |
|
| 6383 | + if ($key == '__SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) { |
|
| 6384 | + $value = ''; |
|
| 6385 | + } |
|
| 6386 | + // Protection |
|
| 6387 | + if ($key == '__USER_SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) { |
|
| 6388 | + $value = ''; |
|
| 6389 | + } |
|
| 6390 | + // Protection |
|
| 6097 | 6391 | |
| 6098 | 6392 | $text = str_replace("$key", "$value", $text); // We must keep the " to work when value is 123.5 for example
|
| 6099 | 6393 | } |
@@ -6139,8 +6433,9 @@ discard block |
||
| 6139 | 6433 | $dir = dol_buildpath($reldir, 0); |
| 6140 | 6434 | |
| 6141 | 6435 | // Check if directory exists |
| 6142 | - if (!dol_is_dir($dir)) |
|
| 6143 | - continue; |
|
| 6436 | + if (!dol_is_dir($dir)) { |
|
| 6437 | + continue; |
|
| 6438 | + } |
|
| 6144 | 6439 | |
| 6145 | 6440 | $substitfiles = dol_dir_list($dir, 'files', 0, 'functions_'); |
| 6146 | 6441 | foreach ($substitfiles as $substitfile) {
|
@@ -6152,8 +6447,9 @@ discard block |
||
| 6152 | 6447 | require_once $dir . $substitfile['name']; |
| 6153 | 6448 | // Call the user's function, and only if it is defined |
| 6154 | 6449 | $function_name = $module . "_" . $callfunc; |
| 6155 | - if (function_exists($function_name)) |
|
| 6156 | - $function_name($substitutionarray, $outputlangs, $object, $parameters); |
|
| 6450 | + if (function_exists($function_name)) { |
|
| 6451 | + $function_name($substitutionarray, $outputlangs, $object, $parameters); |
|
| 6452 | + } |
|
| 6157 | 6453 | } |
| 6158 | 6454 | } |
| 6159 | 6455 | } |
@@ -6189,8 +6485,9 @@ discard block |
||
| 6189 | 6485 | |
| 6190 | 6486 | $out = ''; |
| 6191 | 6487 | |
| 6192 | - if (!is_object($outputlangs)) |
|
| 6193 | - $outputlangs = Globals::$langs; |
|
| 6488 | + if (!is_object($outputlangs)) { |
|
| 6489 | + $outputlangs = Globals::$langs; |
|
| 6490 | + } |
|
| 6194 | 6491 | |
| 6195 | 6492 | if ($date_start && $date_end) {
|
| 6196 | 6493 | $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateFromTo', DolUtils::dol_print_date($date_start, $format, false, $outputlangs), DolUtils::dol_print_date($date_end, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
|
@@ -6219,20 +6516,22 @@ discard block |
||
| 6219 | 6516 | |
| 6220 | 6517 | $ret = ''; |
| 6221 | 6518 | // If order not defined, we use the setup |
| 6222 | - if ($nameorder < 0) |
|
| 6223 | - $nameorder = (empty(Globals::$conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0); |
|
| 6519 | + if ($nameorder < 0) { |
|
| 6520 | + $nameorder = (empty(Globals::$conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0); |
|
| 6521 | + } |
|
| 6224 | 6522 | if ($nameorder && ((string) $nameorder != '2')) {
|
| 6225 | 6523 | $ret .= $firstname; |
| 6226 | - if ($firstname && $lastname) |
|
| 6227 | - $ret .= ' '; |
|
| 6524 | + if ($firstname && $lastname) { |
|
| 6525 | + $ret .= ' '; |
|
| 6526 | + } |
|
| 6228 | 6527 | $ret .= $lastname; |
| 6229 | - } |
|
| 6230 | - else if ($nameorder == 2) {
|
|
| 6528 | + } else if ($nameorder == 2) {
|
|
| 6231 | 6529 | $ret .= $firstname; |
| 6232 | 6530 | } else {
|
| 6233 | 6531 | $ret .= $lastname; |
| 6234 | - if ($firstname && $lastname) |
|
| 6235 | - $ret .= ' '; |
|
| 6532 | + if ($firstname && $lastname) { |
|
| 6533 | + $ret .= ' '; |
|
| 6534 | + } |
|
| 6236 | 6535 | $ret .= $firstname; |
| 6237 | 6536 | } |
| 6238 | 6537 | return $ret; |
@@ -6252,13 +6551,14 @@ discard block |
||
| 6252 | 6551 | {
|
| 6253 | 6552 | //DolUtils::dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); This is not deprecated, it is used by setEventMessages function |
| 6254 | 6553 | if (!is_array($mesgs)) { // If mesgs is a string
|
| 6255 | - if ($mesgs) |
|
| 6256 | - $_SESSION['dol_events'][$style][] = $mesgs; |
|
| 6257 | - } |
|
| 6258 | - else { // If mesgs is an array
|
|
| 6554 | + if ($mesgs) { |
|
| 6555 | + $_SESSION['dol_events'][$style][] = $mesgs; |
|
| 6556 | + } |
|
| 6557 | + } else { // If mesgs is an array
|
|
| 6259 | 6558 | foreach ($mesgs as $mesg) {
|
| 6260 | - if ($mesg) |
|
| 6261 | - $_SESSION['dol_events'][$style][] = $mesg; |
|
| 6559 | + if ($mesg) { |
|
| 6560 | + $_SESSION['dol_events'][$style][] = $mesg; |
|
| 6561 | + } |
|
| 6262 | 6562 | } |
| 6263 | 6563 | } |
| 6264 | 6564 | } |
@@ -6278,13 +6578,16 @@ discard block |
||
| 6278 | 6578 | if (empty($mesg) && empty($mesgs)) {
|
| 6279 | 6579 | DolUtils::dol_syslog("Try to add a message in stack with empty message", LOG_WARNING);
|
| 6280 | 6580 | } else {
|
| 6281 | - if (!in_array((string) $style, array('mesgs', 'warnings', 'errors')))
|
|
| 6282 | - dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages');
|
|
| 6283 | - if (empty($mesgs)) |
|
| 6284 | - setEventMessage($mesg, $style); |
|
| 6285 | - else {
|
|
| 6286 | - if (!empty($mesg) && !in_array($mesg, $mesgs)) |
|
| 6287 | - setEventMessage($mesg, $style); // Add message string if not already into array |
|
| 6581 | + if (!in_array((string) $style, array('mesgs', 'warnings', 'errors'))) { |
|
| 6582 | + dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages'); |
|
| 6583 | + } |
|
| 6584 | + if (empty($mesgs)) { |
|
| 6585 | + setEventMessage($mesg, $style); |
|
| 6586 | + } else {
|
|
| 6587 | + if (!empty($mesg) && !in_array($mesg, $mesgs)) { |
|
| 6588 | + setEventMessage($mesg, $style); |
|
| 6589 | + } |
|
| 6590 | + // Add message string if not already into array |
|
| 6288 | 6591 | setEventMessage($mesgs, $style); |
| 6289 | 6592 | } |
| 6290 | 6593 | } |
@@ -6303,22 +6606,25 @@ discard block |
||
| 6303 | 6606 | {
|
| 6304 | 6607 | // Show mesgs |
| 6305 | 6608 | if (isset($_SESSION['dol_events']['mesgs'])) {
|
| 6306 | - if (empty($disabledoutputofmessages)) |
|
| 6307 | - dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']);
|
|
| 6609 | + if (empty($disabledoutputofmessages)) { |
|
| 6610 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']); |
|
| 6611 | + } |
|
| 6308 | 6612 | unset($_SESSION['dol_events']['mesgs']); |
| 6309 | 6613 | } |
| 6310 | 6614 | |
| 6311 | 6615 | // Show errors |
| 6312 | 6616 | if (isset($_SESSION['dol_events']['errors'])) {
|
| 6313 | - if (empty($disabledoutputofmessages)) |
|
| 6314 | - dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error');
|
|
| 6617 | + if (empty($disabledoutputofmessages)) { |
|
| 6618 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error'); |
|
| 6619 | + } |
|
| 6315 | 6620 | unset($_SESSION['dol_events']['errors']); |
| 6316 | 6621 | } |
| 6317 | 6622 | |
| 6318 | 6623 | // Show warnings |
| 6319 | 6624 | if (isset($_SESSION['dol_events']['warnings'])) {
|
| 6320 | - if (empty($disabledoutputofmessages)) |
|
| 6321 | - dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning');
|
|
| 6625 | + if (empty($disabledoutputofmessages)) { |
|
| 6626 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning'); |
|
| 6627 | + } |
|
| 6322 | 6628 | unset($_SESSION['dol_events']['warnings']); |
| 6323 | 6629 | } |
| 6324 | 6630 | } |
@@ -6359,8 +6665,9 @@ discard block |
||
| 6359 | 6665 | foreach ($mesgarray as $message) {
|
| 6360 | 6666 | $ret++; |
| 6361 | 6667 | $out .= Globals::$langs->trans($message); |
| 6362 | - if ($ret < count($mesgarray)) |
|
| 6363 | - $out .= "<br>\n"; |
|
| 6668 | + if ($ret < count($mesgarray)) { |
|
| 6669 | + $out .= "<br>\n"; |
|
| 6670 | + } |
|
| 6364 | 6671 | } |
| 6365 | 6672 | } |
| 6366 | 6673 | if ($mesgstring) {
|
@@ -6426,8 +6733,9 @@ discard block |
||
| 6426 | 6733 | */ |
| 6427 | 6734 | static function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'ok', $keepembedded = 0) |
| 6428 | 6735 | {
|
| 6429 | - if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) |
|
| 6430 | - return; |
|
| 6736 | + if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) { |
|
| 6737 | + return; |
|
| 6738 | + } |
|
| 6431 | 6739 | |
| 6432 | 6740 | $iserror = 0; |
| 6433 | 6741 | $iswarning = 0; |
@@ -6442,14 +6750,17 @@ discard block |
||
| 6442 | 6750 | break; |
| 6443 | 6751 | } |
| 6444 | 6752 | } |
| 6445 | - } else if ($mesgstring && preg_match('/class="error"/i', $mesgstring))
|
|
| 6446 | - $iserror++; |
|
| 6447 | - else if ($mesgstring && preg_match('/class="warning"/i', $mesgstring))
|
|
| 6448 | - $iswarning++; |
|
| 6449 | - if ($style == 'error') |
|
| 6450 | - $iserror++; |
|
| 6451 | - if ($style == 'warning') |
|
| 6452 | - $iswarning++; |
|
| 6753 | + } else if ($mesgstring && preg_match('/class="error"/i', $mesgstring)) { |
|
| 6754 | + $iserror++; |
|
| 6755 | + } else if ($mesgstring && preg_match('/class="warning"/i', $mesgstring)) { |
|
| 6756 | + $iswarning++; |
|
| 6757 | + } |
|
| 6758 | + if ($style == 'error') { |
|
| 6759 | + $iserror++; |
|
| 6760 | + } |
|
| 6761 | + if ($style == 'warning') { |
|
| 6762 | + $iswarning++; |
|
| 6763 | + } |
|
| 6453 | 6764 | |
| 6454 | 6765 | if ($iserror || $iswarning) {
|
| 6455 | 6766 | // Remove div from texts |
@@ -6468,8 +6779,9 @@ discard block |
||
| 6468 | 6779 | $mesgarray = $newmesgarray; |
| 6469 | 6780 | } |
| 6470 | 6781 | print get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ? 'error' : 'warning'), $keepembedded); |
| 6471 | - } else |
|
| 6472 | - print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded); |
|
| 6782 | + } else { |
|
| 6783 | + print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded); |
|
| 6784 | + } |
|
| 6473 | 6785 | } |
| 6474 | 6786 | |
| 6475 | 6787 | /** |
@@ -6510,15 +6822,17 @@ discard block |
||
| 6510 | 6822 | $sizearray = count($array); |
| 6511 | 6823 | if ($sizearray > 0) {
|
| 6512 | 6824 | $temp = array(); |
| 6513 | - foreach (array_keys($array) as $key) |
|
| 6514 | - $temp[$key] = $array[$key][$index]; |
|
| 6825 | + foreach (array_keys($array) as $key) { |
|
| 6826 | + $temp[$key] = $array[$key][$index]; |
|
| 6827 | + } |
|
| 6515 | 6828 | |
| 6516 | - if (!$natsort) |
|
| 6517 | - ($order == 'asc') ? asort($temp) : arsort($temp); |
|
| 6518 | - else {
|
|
| 6829 | + if (!$natsort) { |
|
| 6830 | + ($order == 'asc') ? asort($temp) : arsort($temp); |
|
| 6831 | + } else {
|
|
| 6519 | 6832 | ($case_sensitive) ? natsort($temp) : natcasesort($temp); |
| 6520 | - if ($order != 'asc') |
|
| 6521 | - $temp = array_reverse($temp, true); |
|
| 6833 | + if ($order != 'asc') { |
|
| 6834 | + $temp = array_reverse($temp, true); |
|
| 6835 | + } |
|
| 6522 | 6836 | } |
| 6523 | 6837 | |
| 6524 | 6838 | $sorted = array(); |
@@ -6544,23 +6858,38 @@ discard block |
||
| 6544 | 6858 | // We must use here a binary strlen static function (so not DolUtils::dol_strlen) |
| 6545 | 6859 | $strLength = DolUtils::dol_strlen($str); |
| 6546 | 6860 | for ($i = 0; $i < $strLength; $i++) {
|
| 6547 | - if (ord($str[$i]) < 0x80) |
|
| 6548 | - continue; // 0bbbbbbb |
|
| 6549 | - elseif ((ord($str[$i]) & 0xE0) == 0xC0) |
|
| 6550 | - $n = 1; // 110bbbbb |
|
| 6551 | - elseif ((ord($str[$i]) & 0xF0) == 0xE0) |
|
| 6552 | - $n = 2; // 1110bbbb |
|
| 6553 | - elseif ((ord($str[$i]) & 0xF8) == 0xF0) |
|
| 6554 | - $n = 3; // 11110bbb |
|
| 6555 | - elseif ((ord($str[$i]) & 0xFC) == 0xF8) |
|
| 6556 | - $n = 4; // 111110bb |
|
| 6557 | - elseif ((ord($str[$i]) & 0xFE) == 0xFC) |
|
| 6558 | - $n = 5; // 1111110b |
|
| 6559 | - else |
|
| 6560 | - return false; // Does not match any model |
|
| 6861 | + if (ord($str[$i]) < 0x80) { |
|
| 6862 | + continue; |
|
| 6863 | + } |
|
| 6864 | + // 0bbbbbbb |
|
| 6865 | + elseif ((ord($str[$i]) & 0xE0) == 0xC0) { |
|
| 6866 | + $n = 1; |
|
| 6867 | + } |
|
| 6868 | + // 110bbbbb |
|
| 6869 | + elseif ((ord($str[$i]) & 0xF0) == 0xE0) { |
|
| 6870 | + $n = 2; |
|
| 6871 | + } |
|
| 6872 | + // 1110bbbb |
|
| 6873 | + elseif ((ord($str[$i]) & 0xF8) == 0xF0) { |
|
| 6874 | + $n = 3; |
|
| 6875 | + } |
|
| 6876 | + // 11110bbb |
|
| 6877 | + elseif ((ord($str[$i]) & 0xFC) == 0xF8) { |
|
| 6878 | + $n = 4; |
|
| 6879 | + } |
|
| 6880 | + // 111110bb |
|
| 6881 | + elseif ((ord($str[$i]) & 0xFE) == 0xFC) { |
|
| 6882 | + $n = 5; |
|
| 6883 | + } |
|
| 6884 | + // 1111110b |
|
| 6885 | + else { |
|
| 6886 | + return false; |
|
| 6887 | + } |
|
| 6888 | + // Does not match any model |
|
| 6561 | 6889 | for ($j = 0; $j < $n; $j++) { // n bytes matching 10bbbbbb follow ?
|
| 6562 | - if (( ++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) |
|
| 6563 | - return false; |
|
| 6890 | + if (( ++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) { |
|
| 6891 | + return false; |
|
| 6892 | + } |
|
| 6564 | 6893 | } |
| 6565 | 6894 | } |
| 6566 | 6895 | return true; |
@@ -6578,15 +6907,21 @@ discard block |
||
| 6578 | 6907 | // global Globals::$conf; |
| 6579 | 6908 | |
| 6580 | 6909 | $tmp = ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0
|
| 6581 | - if (empty($tmp) && !empty($_SERVER["WINDIR"])) |
|
| 6582 | - $tmp = 'iso-8859-1'; // By default for windows |
|
| 6583 | - if (empty($tmp)) |
|
| 6584 | - $tmp = 'utf-8'; // By default for other |
|
| 6585 | - if (!empty(Globals::$conf->global->MAIN_FILESYSTEM_ENCODING)) |
|
| 6586 | - $tmp = Globals::$conf->global->MAIN_FILESYSTEM_ENCODING; |
|
| 6587 | - |
|
| 6588 | - if ($tmp == 'iso-8859-1') |
|
| 6589 | - return utf8_decode($str); |
|
| 6910 | + if (empty($tmp) && !empty($_SERVER["WINDIR"])) { |
|
| 6911 | + $tmp = 'iso-8859-1'; |
|
| 6912 | + } |
|
| 6913 | + // By default for windows |
|
| 6914 | + if (empty($tmp)) { |
|
| 6915 | + $tmp = 'utf-8'; |
|
| 6916 | + } |
|
| 6917 | + // By default for other |
|
| 6918 | + if (!empty(Globals::$conf->global->MAIN_FILESYSTEM_ENCODING)) { |
|
| 6919 | + $tmp = Globals::$conf->global->MAIN_FILESYSTEM_ENCODING; |
|
| 6920 | + } |
|
| 6921 | + |
|
| 6922 | + if ($tmp == 'iso-8859-1') { |
|
| 6923 | + return utf8_decode($str); |
|
| 6924 | + } |
|
| 6590 | 6925 | return $str; |
| 6591 | 6926 | } |
| 6592 | 6927 | |
@@ -6607,8 +6942,9 @@ discard block |
||
| 6607 | 6942 | {
|
| 6608 | 6943 | // global $cache_codes; |
| 6609 | 6944 | // If key empty |
| 6610 | - if ($key == '') |
|
| 6611 | - return ''; |
|
| 6945 | + if ($key == '') { |
|
| 6946 | + return ''; |
|
| 6947 | + } |
|
| 6612 | 6948 | |
| 6613 | 6949 | // Check in cache |
| 6614 | 6950 | if (isset($cache_codes[$tablename][$key][$fieldid])) { // Can be defined to 0 or ''
|
@@ -6620,20 +6956,21 @@ discard block |
||
| 6620 | 6956 | $sql = "SELECT " . $fieldid . " as valuetoget"; |
| 6621 | 6957 | $sql .= " FROM " . MAIN_DB_PREFIX . $tablename; |
| 6622 | 6958 | $sql .= " WHERE " . $fieldkey . " = '" . $db->escape($key) . "'"; |
| 6623 | - if (!empty($entityfilter)) |
|
| 6624 | - $sql .= " AND entity IN (" . getEntity($tablename) . ")";
|
|
| 6959 | + if (!empty($entityfilter)) { |
|
| 6960 | + $sql .= " AND entity IN (" . getEntity($tablename) . ")"; |
|
| 6961 | + } |
|
| 6625 | 6962 | |
| 6626 | 6963 | $resql = $db->query($sql); |
| 6627 | 6964 | if ($resql) {
|
| 6628 | 6965 | $obj = $db->fetch_object($resql); |
| 6629 | - if ($obj) |
|
| 6630 | - $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget; |
|
| 6631 | - else |
|
| 6632 | - $cache_codes[$tablename][$key][$fieldid] = ''; |
|
| 6966 | + if ($obj) { |
|
| 6967 | + $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget; |
|
| 6968 | + } else { |
|
| 6969 | + $cache_codes[$tablename][$key][$fieldid] = ''; |
|
| 6970 | + } |
|
| 6633 | 6971 | $db->free($resql); |
| 6634 | 6972 | return $cache_codes[$tablename][$key][$fieldid]; |
| 6635 | - } |
|
| 6636 | - else {
|
|
| 6973 | + } else {
|
|
| 6637 | 6974 | return -1; |
| 6638 | 6975 | } |
| 6639 | 6976 | } |
@@ -6679,16 +7016,17 @@ discard block |
||
| 6679 | 7016 | // global $soc; // For backward compatibility |
| 6680 | 7017 | //print $s."<br>\n"; |
| 6681 | 7018 | if ($returnvalue) {
|
| 6682 | - if ($hideerrors) |
|
| 6683 | - return @eval('return ' . $s . ';');
|
|
| 6684 | - else |
|
| 6685 | - return eval('return ' . $s . ';');
|
|
| 6686 | - } |
|
| 6687 | - else {
|
|
| 6688 | - if ($hideerrors) |
|
| 6689 | - @eval($s); |
|
| 6690 | - else |
|
| 6691 | - eval($s); |
|
| 7019 | + if ($hideerrors) { |
|
| 7020 | + return @eval('return ' . $s . ';'); |
|
| 7021 | + } else { |
|
| 7022 | + return eval('return ' . $s . ';'); |
|
| 7023 | + } |
|
| 7024 | + } else {
|
|
| 7025 | + if ($hideerrors) { |
|
| 7026 | + @eval($s); |
|
| 7027 | + } else { |
|
| 7028 | + eval($s); |
|
| 7029 | + } |
|
| 6692 | 7030 | } |
| 6693 | 7031 | } |
| 6694 | 7032 | |
@@ -6714,8 +7052,9 @@ discard block |
||
| 6714 | 7052 | {
|
| 6715 | 7053 | // global Globals::$langs; |
| 6716 | 7054 | |
| 6717 | - if (empty($codelang)) |
|
| 6718 | - return ''; |
|
| 7055 | + if (empty($codelang)) { |
|
| 7056 | + return ''; |
|
| 7057 | + } |
|
| 6719 | 7058 | |
| 6720 | 7059 | if ($codelang == 'auto') {
|
| 6721 | 7060 | return '<span class="fa fa-globe"></span>'; |
@@ -6729,9 +7068,9 @@ discard block |
||
| 6729 | 7068 | 'sv_SV' => 'se' |
| 6730 | 7069 | ); |
| 6731 | 7070 | |
| 6732 | - if (isset($langtocountryflag[$codelang])) |
|
| 6733 | - $flagImage = $langtocountryflag[$codelang]; |
|
| 6734 | - else {
|
|
| 7071 | + if (isset($langtocountryflag[$codelang])) { |
|
| 7072 | + $flagImage = $langtocountryflag[$codelang]; |
|
| 7073 | + } else {
|
|
| 6735 | 7074 | $tmparray = explode('_', $codelang);
|
| 6736 | 7075 | $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1]; |
| 6737 | 7076 | } |
@@ -6749,15 +7088,20 @@ discard block |
||
| 6749 | 7088 | {
|
| 6750 | 7089 | // global $mysoc; |
| 6751 | 7090 | |
| 6752 | - if (strtoupper($countrycode) == 'MQ') |
|
| 6753 | - return 'fr_CA'; |
|
| 6754 | - if (strtoupper($countrycode) == 'SE') |
|
| 6755 | - return 'sv_SE'; // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country |
|
| 7091 | + if (strtoupper($countrycode) == 'MQ') { |
|
| 7092 | + return 'fr_CA'; |
|
| 7093 | + } |
|
| 7094 | + if (strtoupper($countrycode) == 'SE') { |
|
| 7095 | + return 'sv_SE'; |
|
| 7096 | + } |
|
| 7097 | + // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country |
|
| 6756 | 7098 | if (strtoupper($countrycode) == 'CH') {
|
| 6757 | - if ($mysoc->country_code == 'FR') |
|
| 6758 | - return 'fr_CH'; |
|
| 6759 | - if ($mysoc->country_code == 'DE') |
|
| 6760 | - return 'de_CH'; |
|
| 7099 | + if ($mysoc->country_code == 'FR') { |
|
| 7100 | + return 'fr_CH'; |
|
| 7101 | + } |
|
| 7102 | + if ($mysoc->country_code == 'DE') { |
|
| 7103 | + return 'de_CH'; |
|
| 7104 | + } |
|
| 6761 | 7105 | } |
| 6762 | 7106 | |
| 6763 | 7107 | // Locale list taken from: |
@@ -6935,8 +7279,9 @@ discard block |
||
| 6935 | 7279 | ); |
| 6936 | 7280 | |
| 6937 | 7281 | $buildprimarykeytotest = strtolower($countrycode) . '-' . strtoupper($countrycode); |
| 6938 | - if (in_array($buildprimarykeytotest, $locales)) |
|
| 6939 | - return strtolower($countrycode) . '_' . strtoupper($countrycode); |
|
| 7282 | + if (in_array($buildprimarykeytotest, $locales)) { |
|
| 7283 | + return strtolower($countrycode) . '_' . strtoupper($countrycode); |
|
| 7284 | + } |
|
| 6940 | 7285 | |
| 6941 | 7286 | foreach ($locales as $locale) {
|
| 6942 | 7287 | $locale_language = locale_get_primary_language($locale); |
@@ -6990,18 +7335,21 @@ discard block |
||
| 6990 | 7335 | |
| 6991 | 7336 | if ($mode == 'add' && !preg_match('/^\-/', $values[1])) {
|
| 6992 | 7337 | if (count($values) == 6) { // new declaration with permissions: $value='objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'
|
| 6993 | - if ($values[0] != $type) |
|
| 6994 | - continue; |
|
| 7338 | + if ($values[0] != $type) { |
|
| 7339 | + continue; |
|
| 7340 | + } |
|
| 6995 | 7341 | |
| 6996 | 7342 | if (verifCond($values[4])) {
|
| 6997 | - if ($values[3]) |
|
| 6998 | - Globals::$langs->load($values[3]); |
|
| 7343 | + if ($values[3]) { |
|
| 7344 | + Globals::$langs->load($values[3]); |
|
| 7345 | + } |
|
| 6999 | 7346 | if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
|
| 7000 | 7347 | $substitutionarray = array(); |
| 7001 | 7348 | complete_substitutions_array($substitutionarray, Globals::$langs, $object, array('needforkey' => $values[2]));
|
| 7002 | 7349 | $label = make_substitutions($reg[1], $substitutionarray); |
| 7003 | - } else |
|
| 7004 | - $label = Globals::$langs->trans($values[2]); |
|
| 7350 | + } else { |
|
| 7351 | + $label = Globals::$langs->trans($values[2]); |
|
| 7352 | + } |
|
| 7005 | 7353 | |
| 7006 | 7354 | //$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]), 1);
|
| 7007 | 7355 | $head[$h][0] = BASE_URI . preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]);
|
@@ -7009,30 +7357,32 @@ discard block |
||
| 7009 | 7357 | $head[$h][2] = str_replace('+', '', $values[1]);
|
| 7010 | 7358 | $h++; |
| 7011 | 7359 | } |
| 7012 | - } |
|
| 7013 | - else if (count($values) == 5) { // deprecated
|
|
| 7360 | + } else if (count($values) == 5) { // deprecated
|
|
| 7014 | 7361 | DolUtils::dol_syslog('Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
|
| 7015 | 7362 | |
| 7016 | - if ($values[0] != $type) |
|
| 7017 | - continue; |
|
| 7018 | - if ($values[3]) |
|
| 7019 | - Globals::$langs->load($values[3]); |
|
| 7363 | + if ($values[0] != $type) { |
|
| 7364 | + continue; |
|
| 7365 | + } |
|
| 7366 | + if ($values[3]) { |
|
| 7367 | + Globals::$langs->load($values[3]); |
|
| 7368 | + } |
|
| 7020 | 7369 | if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
|
| 7021 | 7370 | $substitutionarray = array(); |
| 7022 | 7371 | complete_substitutions_array($substitutionarray, Globals::$langs, $object, array('needforkey' => $values[2]));
|
| 7023 | 7372 | $label = make_substitutions($reg[1], $substitutionarray); |
| 7024 | - } else |
|
| 7025 | - $label = Globals::$langs->trans($values[2]); |
|
| 7373 | + } else { |
|
| 7374 | + $label = Globals::$langs->trans($values[2]); |
|
| 7375 | + } |
|
| 7026 | 7376 | |
| 7027 | 7377 | $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[4]), 1);
|
| 7028 | 7378 | $head[$h][1] = $label; |
| 7029 | 7379 | $head[$h][2] = str_replace('+', '', $values[1]);
|
| 7030 | 7380 | $h++; |
| 7031 | 7381 | } |
| 7032 | - } |
|
| 7033 | - else if ($mode == 'remove' && preg_match('/^\-/', $values[1])) {
|
|
| 7034 | - if ($values[0] != $type) |
|
| 7035 | - continue; |
|
| 7382 | + } else if ($mode == 'remove' && preg_match('/^\-/', $values[1])) {
|
|
| 7383 | + if ($values[0] != $type) { |
|
| 7384 | + continue; |
|
| 7385 | + } |
|
| 7036 | 7386 | $tabname = str_replace('-', '', $values[1]);
|
| 7037 | 7387 | foreach ($head as $key => $val) {
|
| 7038 | 7388 | $condition = (!empty($values[3]) ? verifCond($values[3]) : 1); |
@@ -7074,10 +7424,11 @@ discard block |
||
| 7074 | 7424 | // global $action; |
| 7075 | 7425 | // global $micro_start_time; |
| 7076 | 7426 | |
| 7077 | - if ($zone == 'private') |
|
| 7078 | - print "\n" . '<!-- Common footer for private page -->' . "\n"; |
|
| 7079 | - else |
|
| 7080 | - print "\n" . '<!-- Common footer for public page -->' . "\n"; |
|
| 7427 | + if ($zone == 'private') { |
|
| 7428 | + print "\n" . '<!-- Common footer for private page -->' . "\n"; |
|
| 7429 | + } else { |
|
| 7430 | + print "\n" . '<!-- Common footer for public page -->' . "\n"; |
|
| 7431 | + } |
|
| 7081 | 7432 | |
| 7082 | 7433 | // A div to store page_y POST parameter so we can read it using javascript |
| 7083 | 7434 | print "\n<!-- A div to store page_y POST paramater -->\n"; |
@@ -7086,8 +7437,9 @@ discard block |
||
| 7086 | 7437 | $parameters = array(); |
| 7087 | 7438 | $reshook = Globals::$hookManager->executeHooks('printCommonFooter', $parameters); // Note that $action and $object may have been modified by some hooks
|
| 7088 | 7439 | if (empty($reshook)) {
|
| 7089 | - if (!empty(Globals::$conf->global->MAIN_HTML_FOOTER)) |
|
| 7090 | - print Globals::$conf->global->MAIN_HTML_FOOTER . "\n"; |
|
| 7440 | + if (!empty(Globals::$conf->global->MAIN_HTML_FOOTER)) { |
|
| 7441 | + print Globals::$conf->global->MAIN_HTML_FOOTER . "\n"; |
|
| 7442 | + } |
|
| 7091 | 7443 | |
| 7092 | 7444 | print "\n"; |
| 7093 | 7445 | if (!empty(Globals::$conf->use_javascript_ajax)) {
|
@@ -7110,8 +7462,9 @@ discard block |
||
| 7110 | 7462 | print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */' . "\n"; |
| 7111 | 7463 | $relativepathstring = $_SERVER["PHP_SELF"]; |
| 7112 | 7464 | // Clean $relativepathstring |
| 7113 | - if (constant('DOL_BASE_URI'))
|
|
| 7114 | - $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
|
|
| 7465 | + if (constant('DOL_BASE_URI')) { |
|
| 7466 | + $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring); |
|
| 7467 | + } |
|
| 7115 | 7468 | $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
|
| 7116 | 7469 | $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
|
| 7117 | 7470 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
@@ -7122,14 +7475,17 @@ discard block |
||
| 7122 | 7475 | $tmpqueryarraytohave = explode('&', $defkey);
|
| 7123 | 7476 | $foundintru = 0; |
| 7124 | 7477 | foreach ($tmpqueryarraytohave as $tmpquerytohave) {
|
| 7125 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
| 7126 | - $foundintru = 1; |
|
| 7478 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
| 7479 | + $foundintru = 1; |
|
| 7480 | + } |
|
| 7127 | 7481 | } |
| 7128 | - if (!$foundintru) |
|
| 7129 | - $qualified = 1; |
|
| 7482 | + if (!$foundintru) { |
|
| 7483 | + $qualified = 1; |
|
| 7484 | + } |
|
| 7130 | 7485 | //var_dump($defkey.'-'.$qualified); |
| 7131 | - } else |
|
| 7132 | - $qualified = 1; |
|
| 7486 | + } else { |
|
| 7487 | + $qualified = 1; |
|
| 7488 | + } |
|
| 7133 | 7489 | |
| 7134 | 7490 | if ($qualified) {
|
| 7135 | 7491 | foreach ($defval as $paramkey => $paramval) {
|
@@ -7148,14 +7504,17 @@ discard block |
||
| 7148 | 7504 | $tmpqueryarraytohave = explode('&', $defkey);
|
| 7149 | 7505 | $foundintru = 0; |
| 7150 | 7506 | foreach ($tmpqueryarraytohave as $tmpquerytohave) {
|
| 7151 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
| 7152 | - $foundintru = 1; |
|
| 7507 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
| 7508 | + $foundintru = 1; |
|
| 7509 | + } |
|
| 7153 | 7510 | } |
| 7154 | - if (!$foundintru) |
|
| 7155 | - $qualified = 1; |
|
| 7511 | + if (!$foundintru) { |
|
| 7512 | + $qualified = 1; |
|
| 7513 | + } |
|
| 7156 | 7514 | //var_dump($defkey.'-'.$qualified); |
| 7157 | - } else |
|
| 7158 | - $qualified = 1; |
|
| 7515 | + } else { |
|
| 7516 | + $qualified = 1; |
|
| 7517 | + } |
|
| 7159 | 7518 | |
| 7160 | 7519 | if ($qualified) {
|
| 7161 | 7520 | foreach ($defval as $paramkey => $paramval) {
|
@@ -7194,8 +7553,9 @@ discard block |
||
| 7194 | 7553 | print "\n"; |
| 7195 | 7554 | print "/* JS CODE TO ENABLE to add memory info */\n"; |
| 7196 | 7555 | print 'window.console && console.log("';
|
| 7197 | - if (!empty(Globals::$conf->global->MEMCACHED_SERVER)) |
|
| 7198 | - print 'MEMCACHED_SERVER=' . Globals::$conf->global->MEMCACHED_SERVER . ' - '; |
|
| 7556 | + if (!empty(Globals::$conf->global->MEMCACHED_SERVER)) { |
|
| 7557 | + print 'MEMCACHED_SERVER=' . Globals::$conf->global->MEMCACHED_SERVER . ' - '; |
|
| 7558 | + } |
|
| 7199 | 7559 | print 'MAIN_OPTIMIZE_SPEED=' . (isset(Globals::$conf->global->MAIN_OPTIMIZE_SPEED) ? Globals::$conf->global->MAIN_OPTIMIZE_SPEED : 'off'); |
| 7200 | 7560 | if (!empty($micro_start_time)) { // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in// global variable.
|
| 7201 | 7561 | $micro_end_time = microtime(true); |
@@ -7325,8 +7685,9 @@ discard block |
||
| 7325 | 7685 | |
| 7326 | 7686 | $crits = explode(' ', $value);
|
| 7327 | 7687 | $res = ''; |
| 7328 | - if (!is_array($fields)) |
|
| 7329 | - $fields = array($fields); |
|
| 7688 | + if (!is_array($fields)) { |
|
| 7689 | + $fields = array($fields); |
|
| 7690 | + } |
|
| 7330 | 7691 | |
| 7331 | 7692 | $nboffields = count($fields); |
| 7332 | 7693 | $end2 = count($crits); |
@@ -7389,8 +7750,9 @@ discard block |
||
| 7389 | 7750 | $tmpcrits = explode('|', $crit);
|
| 7390 | 7751 | $i3 = 0; |
| 7391 | 7752 | foreach ($tmpcrits as $tmpcrit) {
|
| 7392 | - if (empty($tmpcrit)) |
|
| 7393 | - continue; |
|
| 7753 | + if (empty($tmpcrit)) { |
|
| 7754 | + continue; |
|
| 7755 | + } |
|
| 7394 | 7756 | |
| 7395 | 7757 | $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); |
| 7396 | 7758 | |
@@ -7426,8 +7788,9 @@ discard block |
||
| 7426 | 7788 | } |
| 7427 | 7789 | $i++; |
| 7428 | 7790 | } |
| 7429 | - if ($newres) |
|
| 7430 | - $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : '');
|
|
| 7791 | + if ($newres) { |
|
| 7792 | + $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : ''); |
|
| 7793 | + } |
|
| 7431 | 7794 | $j++; |
| 7432 | 7795 | } |
| 7433 | 7796 | $res = ($nofirstand ? "" : " AND ") . "(" . $res . ")";
|
@@ -7467,29 +7830,37 @@ discard block |
||
| 7467 | 7830 | static function getImageFileNameForSize($file, $extName, $extImgTarget = '') |
| 7468 | 7831 | {
|
| 7469 | 7832 | $dirName = dirname($file); |
| 7470 | - if ($dirName == '.') |
|
| 7471 | - $dirName = ''; |
|
| 7833 | + if ($dirName == '.') { |
|
| 7834 | + $dirName = ''; |
|
| 7835 | + } |
|
| 7472 | 7836 | |
| 7473 | 7837 | $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // We remove extension, whatever is its case
|
| 7474 | 7838 | $fileName = basename($fileName); |
| 7475 | 7839 | |
| 7476 | - if (empty($extImgTarget)) |
|
| 7477 | - $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : '');
|
|
| 7478 | - if (empty($extImgTarget)) |
|
| 7479 | - $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '');
|
|
| 7480 | - if (empty($extImgTarget)) |
|
| 7481 | - $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : '');
|
|
| 7482 | - if (empty($extImgTarget)) |
|
| 7483 | - $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : '');
|
|
| 7484 | - if (empty($extImgTarget)) |
|
| 7485 | - $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : '');
|
|
| 7486 | - |
|
| 7487 | - if (!$extImgTarget) |
|
| 7488 | - return $file; |
|
| 7840 | + if (empty($extImgTarget)) { |
|
| 7841 | + $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : ''); |
|
| 7842 | + } |
|
| 7843 | + if (empty($extImgTarget)) { |
|
| 7844 | + $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : ''); |
|
| 7845 | + } |
|
| 7846 | + if (empty($extImgTarget)) { |
|
| 7847 | + $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : ''); |
|
| 7848 | + } |
|
| 7849 | + if (empty($extImgTarget)) { |
|
| 7850 | + $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : ''); |
|
| 7851 | + } |
|
| 7852 | + if (empty($extImgTarget)) { |
|
| 7853 | + $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : ''); |
|
| 7854 | + } |
|
| 7855 | + |
|
| 7856 | + if (!$extImgTarget) { |
|
| 7857 | + return $file; |
|
| 7858 | + } |
|
| 7489 | 7859 | |
| 7490 | 7860 | $subdir = ''; |
| 7491 | - if ($extName) |
|
| 7492 | - $subdir = 'thumbs/'; |
|
| 7861 | + if ($extName) { |
|
| 7862 | + $subdir = 'thumbs/'; |
|
| 7863 | + } |
|
| 7493 | 7864 | |
| 7494 | 7865 | return ($dirName ? $dirName . '/' : '') . $subdir . $fileName . $extName . $extImgTarget; // New filename for thumb |
| 7495 | 7866 | } |
@@ -7507,8 +7878,9 @@ discard block |
||
| 7507 | 7878 | {
|
| 7508 | 7879 | // global Globals::$conf, Globals::$langs; |
| 7509 | 7880 | |
| 7510 | - if (empty(Globals::$conf->use_javascript_ajax)) |
|
| 7511 | - return ''; |
|
| 7881 | + if (empty(Globals::$conf->use_javascript_ajax)) { |
|
| 7882 | + return ''; |
|
| 7883 | + } |
|
| 7512 | 7884 | |
| 7513 | 7885 | $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'svg+xml');
|
| 7514 | 7886 | //$mime_preview[]='vnd.oasis.opendocument.presentation'; |
@@ -7516,17 +7888,19 @@ discard block |
||
| 7516 | 7888 | $num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview); |
| 7517 | 7889 | |
| 7518 | 7890 | if ($alldata == 1) {
|
| 7519 | - if ($num_mime !== false) |
|
| 7520 | - 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),);
|
|
| 7521 | - else |
|
| 7522 | - return array(); |
|
| 7891 | + if ($num_mime !== false) { |
|
| 7892 | + 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),); |
|
| 7893 | + } else { |
|
| 7894 | + return array(); |
|
| 7895 | + } |
|
| 7523 | 7896 | } |
| 7524 | 7897 | |
| 7525 | 7898 | // old behavior |
| 7526 | - if ($num_mime !== false) |
|
| 7527 | - 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')) . '\')';
|
|
| 7528 | - else |
|
| 7529 | - return ''; |
|
| 7899 | + if ($num_mime !== false) { |
|
| 7900 | + 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')) . '\')'; |
|
| 7901 | + } else { |
|
| 7902 | + return ''; |
|
| 7903 | + } |
|
| 7530 | 7904 | } |
| 7531 | 7905 | |
| 7532 | 7906 | /** |
@@ -7544,8 +7918,9 @@ discard block |
||
| 7544 | 7918 | jQuery("#' . $htmlname . '").click(function() { jQuery(this).select(); } );
|
| 7545 | 7919 | }); |
| 7546 | 7920 | </script>'; |
| 7547 | - if ($addlink) |
|
| 7548 | - $out .= ' <a href="' . $addlink . '" target="_blank">' . Globals::$langs->trans("Link") . '</a>';
|
|
| 7921 | + if ($addlink) { |
|
| 7922 | + $out .= ' <a href="' . $addlink . '" target="_blank">' . Globals::$langs->trans("Link") . '</a>'; |
|
| 7923 | + } |
|
| 7549 | 7924 | return $out; |
| 7550 | 7925 | } |
| 7551 | 7926 | |
@@ -7927,8 +8302,9 @@ discard block |
||
| 7927 | 8302 | if (!isset($dictvalues[$tablename])) {
|
| 7928 | 8303 | $dictvalues[$tablename] = array(); |
| 7929 | 8304 | $sql = 'SELECT * FROM ' . $tablename . ' WHERE 1'; |
| 7930 | - if ($checkentity) |
|
| 7931 | - $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')'; |
|
| 8305 | + if ($checkentity) { |
|
| 8306 | + $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')'; |
|
| 8307 | + } |
|
| 7932 | 8308 | |
| 7933 | 8309 | $resql = $db->query($sql); |
| 7934 | 8310 | if ($resql) {
|
@@ -7940,11 +8316,14 @@ discard block |
||
| 7940 | 8316 | } |
| 7941 | 8317 | } |
| 7942 | 8318 | |
| 7943 | - if (!empty($dictvalues[$tablename][$id])) |
|
| 7944 | - return $dictvalues[$tablename][$id]->{$field}; // Found
|
|
| 8319 | + if (!empty($dictvalues[$tablename][$id])) { |
|
| 8320 | + return $dictvalues[$tablename][$id]->{$field}; |
|
| 8321 | + } |
|
| 8322 | + // Found |
|
| 7945 | 8323 | else { // Not found
|
| 7946 | - if ($id > 0) |
|
| 7947 | - return $id; |
|
| 8324 | + if ($id > 0) { |
|
| 8325 | + return $id; |
|
| 8326 | + } |
|
| 7948 | 8327 | return ''; |
| 7949 | 8328 | } |
| 7950 | 8329 | } |
@@ -7974,8 +8353,9 @@ discard block |
||
| 7974 | 8353 | $b = hexdec($hexb); |
| 7975 | 8354 | } |
| 7976 | 8355 | $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm |
| 7977 | - if ($bright > 0.6) |
|
| 7978 | - $res = 1; |
|
| 8356 | + if ($bright > 0.6) { |
|
| 8357 | + $res = 1; |
|
| 8358 | + } |
|
| 7979 | 8359 | } |
| 7980 | 8360 | return $res; |
| 7981 | 8361 | } |
@@ -7993,8 +8373,10 @@ discard block |
||
| 7993 | 8373 | // global Globals::$conf; |
| 7994 | 8374 | //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms']; |
| 7995 | 8375 | //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal); |
| 7996 | - if (empty($menuentry['enabled'])) |
|
| 7997 | - return 0; // Entry disabled by condition |
|
| 8376 | + if (empty($menuentry['enabled'])) { |
|
| 8377 | + return 0; |
|
| 8378 | + } |
|
| 8379 | + // Entry disabled by condition |
|
| 7998 | 8380 | if ($type_user && $menuentry['module']) {
|
| 7999 | 8381 | $tmploops = explode('|', $menuentry['module']);
|
| 8000 | 8382 | $found = 0; |
@@ -8004,15 +8386,23 @@ discard block |
||
| 8004 | 8386 | break; |
| 8005 | 8387 | } |
| 8006 | 8388 | } |
| 8007 | - if (!$found) |
|
| 8008 | - return 0; // Entry is for menus all excluded to external users |
|
| 8009 | - } |
|
| 8010 | - if (!$menuentry['perms'] && $type_user) |
|
| 8011 | - return 0; // No permissions and user is external |
|
| 8012 | - if (!$menuentry['perms'] && !empty(Globals::$conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) |
|
| 8013 | - return 0; // No permissions and option to hide when not allowed, even for internal user, is on |
|
| 8014 | - if (!$menuentry['perms']) |
|
| 8015 | - return 2; // No permissions and user is external |
|
| 8389 | + if (!$found) { |
|
| 8390 | + return 0; |
|
| 8391 | + } |
|
| 8392 | + // Entry is for menus all excluded to external users |
|
| 8393 | + } |
|
| 8394 | + if (!$menuentry['perms'] && $type_user) { |
|
| 8395 | + return 0; |
|
| 8396 | + } |
|
| 8397 | + // No permissions and user is external |
|
| 8398 | + if (!$menuentry['perms'] && !empty(Globals::$conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { |
|
| 8399 | + return 0; |
|
| 8400 | + } |
|
| 8401 | + // No permissions and option to hide when not allowed, even for internal user, is on |
|
| 8402 | + if (!$menuentry['perms']) { |
|
| 8403 | + return 2; |
|
| 8404 | + } |
|
| 8405 | + // No permissions and user is external |
|
| 8016 | 8406 | return 1; |
| 8017 | 8407 | } |
| 8018 | 8408 | |
@@ -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(Globals::$conf->facture->enabled)) |
|
| 1387 | - $nature = "sells"; |
|
| 1388 | - if ($objp->nature == 3 && !empty(Globals::$conf->fournisseur->enabled)) |
|
| 1389 | - $nature = "purchases"; |
|
| 1390 | - if ($objp->nature == 4 && !empty(Globals::$conf->banque->enabled)) |
|
| 1391 | - $nature = "bank"; |
|
| 1392 | - if ($objp->nature == 5 && !empty(Globals::$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(Globals::$conf->facture->enabled)) { |
|
| 1388 | + $nature = "sells"; |
|
| 1389 | + } |
|
| 1390 | + if ($objp->nature == 3 && !empty(Globals::$conf->fournisseur->enabled)) { |
|
| 1391 | + $nature = "purchases"; |
|
| 1392 | + } |
|
| 1393 | + if ($objp->nature == 4 && !empty(Globals::$conf->banque->enabled)) { |
|
| 1394 | + $nature = "bank"; |
|
| 1395 | + } |
|
| 1396 | + if ($objp->nature == 5 && !empty(Globals::$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(Globals::$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(Globals::$conf->accounting->enabled) && !empty(Globals::$user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') |
|
| 1455 | - $modecompta = 'BOOKKEEPING'; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED |
|
| 1464 | + if (!empty(Globals::$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 | /* |
@@ -44,9 +44,16 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | // Chargement des includes principaux de librairies communes |
| 47 | -if (! defined('NOREQUIREUSER')) require_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php'; // Need 500ko memory
|
|
| 48 | -if (! defined('NOREQUIRETRAN')) require_once DOL_DOCUMENT_ROOT .'/core/class/translate.class.php';
|
|
| 49 | -if (! defined('NOREQUIRESOC')) require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php';
|
|
| 47 | +if (! defined('NOREQUIREUSER')) { |
|
| 48 | + require_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php'; |
|
| 49 | +} |
|
| 50 | +// Need 500ko memory |
|
| 51 | +if (! defined('NOREQUIRETRAN')) { |
|
| 52 | + require_once DOL_DOCUMENT_ROOT .'/core/class/translate.class.php'; |
|
| 53 | +} |
|
| 54 | +if (! defined('NOREQUIRESOC')) { |
|
| 55 | + require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; |
|
| 56 | +} |
|
| 50 | 57 | |
| 51 | 58 | |
| 52 | 59 | |
@@ -78,26 +85,32 @@ discard block |
||
| 78 | 85 | */ |
| 79 | 86 | |
| 80 | 87 | // By default conf->entity is 1, but we change this if we ask another value. |
| 81 | -if (session_id() && ! empty($_SESSION["dol_entity"])) // Entity inside an opened session |
|
| 88 | +if (session_id() && ! empty($_SESSION["dol_entity"])) { |
|
| 89 | + // Entity inside an opened session |
|
| 82 | 90 | {
|
| 83 | - Globals::$conf->entity = $_SESSION["dol_entity"]; |
|
| 84 | -} |
|
| 85 | -else if (! empty($_ENV["dol_entity"])) // Entity inside a CLI script |
|
| 91 | + Globals::$conf->entity = $_SESSION["dol_entity"]; |
|
| 92 | +} |
|
| 93 | +} else if (! empty($_ENV["dol_entity"])) { |
|
| 94 | + // Entity inside a CLI script |
|
| 86 | 95 | {
|
| 87 | - Globals::$conf->entity = $_ENV["dol_entity"]; |
|
| 88 | -} |
|
| 89 | -else if (isset($_POST["loginfunction"]) && GETPOST("entity",'int')) // Just after a login page
|
|
| 96 | + Globals::$conf->entity = $_ENV["dol_entity"]; |
|
| 97 | +} |
|
| 98 | +} else if (isset($_POST["loginfunction"]) && GETPOST("entity",'int')) { |
|
| 99 | + // Just after a login page |
|
| 90 | 100 | {
|
| 91 | - Globals::$conf->entity = GETPOST("entity", 'int');
|
|
| 92 | -} |
|
| 93 | -else if (defined('DOLENTITY') && is_numeric(DOLENTITY)) // For public page with MultiCompany module
|
|
| 101 | + Globals::$conf->entity = GETPOST("entity", 'int'); |
|
| 102 | +} |
|
| 103 | +} else if (defined('DOLENTITY') && is_numeric(DOLENTITY)) { |
|
| 104 | + // For public page with MultiCompany module |
|
| 94 | 105 | {
|
| 95 | - Globals::$conf->entity = DOLENTITY; |
|
| 106 | + Globals::$conf->entity = DOLENTITY; |
|
| 107 | +} |
|
| 96 | 108 | } |
| 97 | 109 | |
| 98 | 110 | // Sanitize entity |
| 99 | -if (!is_numeric(Globals::$conf->entity)) |
|
| 100 | - Globals::$conf->entity = 1; |
|
| 111 | +if (!is_numeric(Globals::$conf->entity)) { |
|
| 112 | + Globals::$conf->entity = 1; |
|
| 113 | +} |
|
| 101 | 114 | |
| 102 | 115 | if (! defined('NOREQUIREDB'))
|
| 103 | 116 | {
|
@@ -123,13 +136,26 @@ discard block |
||
| 123 | 136 | // If software has been locked. Only login Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED is allowed. |
| 124 | 137 | if (!empty(Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED)) {
|
| 125 | 138 | $ok=0; |
| 126 | - if ((! session_id() || ! isset($_SESSION["dol_login"])) && ! isset($_POST["username"]) && ! empty($_SERVER["GATEWAY_INTERFACE"])) $ok=1; // We let working pages if not logged and inside a web browser (login form, to allow login by admin) |
|
| 127 | - elseif (isset($_POST["username"]) && $_POST["username"] == Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED) |
|
| 128 | - $ok = 1; // We let working pages that is a login submission (login submit, to allow login by admin) |
|
| 129 | - elseif (defined('NOREQUIREDB')) $ok=1; // We let working pages that don't need database access (xxx.css.php)
|
|
| 130 | - elseif (defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) $ok=1; // We let working pages that ask to work even if only login enabled (logout.php)
|
|
| 131 | - elseif (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] == Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED) |
|
| 132 | - $ok = 1; // We let working if user is allowed admin |
|
| 139 | + if ((! session_id() || ! isset($_SESSION["dol_login"])) && ! isset($_POST["username"]) && ! empty($_SERVER["GATEWAY_INTERFACE"])) { |
|
| 140 | + $ok=1; |
|
| 141 | + } |
|
| 142 | + // We let working pages if not logged and inside a web browser (login form, to allow login by admin) |
|
| 143 | + elseif (isset($_POST["username"]) && $_POST["username"] == Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED) { |
|
| 144 | + $ok = 1; |
|
| 145 | + } |
|
| 146 | + // We let working pages that is a login submission (login submit, to allow login by admin) |
|
| 147 | + elseif (defined('NOREQUIREDB')) { |
|
| 148 | + $ok=1; |
|
| 149 | + } |
|
| 150 | + // We let working pages that don't need database access (xxx.css.php) |
|
| 151 | + elseif (defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) { |
|
| 152 | + $ok=1; |
|
| 153 | + } |
|
| 154 | + // We let working pages that ask to work even if only login enabled (logout.php) |
|
| 155 | + elseif (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] == Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED) { |
|
| 156 | + $ok = 1; |
|
| 157 | + } |
|
| 158 | + // We let working if user is allowed admin |
|
| 133 | 159 | if (! $ok) |
| 134 | 160 | {
|
| 135 | 161 | if (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] != Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED) {
|
@@ -137,8 +163,7 @@ discard block |
||
| 137 | 163 | print 'You are logged with user "' . $_SESSION["dol_login"] . '" and only administrator user "' . Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED . '" is allowed to connect for the moment.' . "\n"; |
| 138 | 164 | $nexturl=DOL_URL_ROOT.'/user/logout.php'; |
| 139 | 165 | print 'Please try later or <a href="'.$nexturl.'">click here to disconnect and change login user</a>...'."\n"; |
| 140 | - } |
|
| 141 | - else |
|
| 166 | + } else |
|
| 142 | 167 | {
|
| 143 | 168 | print 'Sorry, your application is offline. Only administrator user "' . Globals::$conf->global->MAIN_ONLY_LOGIN_ALLOWED . '" is allowed to connect for the moment.' . "\n"; |
| 144 | 169 | $nexturl=DOL_URL_ROOT.'/'; |
@@ -157,21 +182,26 @@ discard block |
||
| 157 | 182 | $mysoc->setMysoc($conf); |
| 158 | 183 | |
| 159 | 184 | // For some countries, we need to invert our address with customer address |
| 160 | - if ($mysoc->country_code == 'DE' && !isset(Globals::$conf->global->MAIN_INVERT_SENDER_RECIPIENT)) |
|
| 161 | - Globals::$conf->global->MAIN_INVERT_SENDER_RECIPIENT = 1; |
|
| 162 | -} |
|
| 185 | + if ($mysoc->country_code == 'DE' && !isset(Globals::$conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
| 186 | + Globals::$conf->global->MAIN_INVERT_SENDER_RECIPIENT = 1; |
|
| 187 | + } |
|
| 188 | + } |
|
| 163 | 189 | |
| 164 | 190 | |
| 165 | 191 | // Set default language (must be after the setValues setting global Globals::$conf->global->MAIN_LANG_DEFAULT. Page main.inc.php will overwrite langs->defaultlang with user value later) |
| 166 | 192 | if (! defined('NOREQUIRETRAN'))
|
| 167 | 193 | {
|
| 168 | 194 | $langcode = (GETPOST('lang', 'aZ09') ? GETPOST('lang', 'aZ09', 1) : (empty(Globals::$conf->global->MAIN_LANG_DEFAULT) ? 'auto' : Globals::$conf->global->MAIN_LANG_DEFAULT));
|
| 169 | - if (defined('MAIN_LANG_DEFAULT')) $langcode=constant('MAIN_LANG_DEFAULT');
|
|
| 195 | + if (defined('MAIN_LANG_DEFAULT')) { |
|
| 196 | + $langcode=constant('MAIN_LANG_DEFAULT'); |
|
| 197 | + } |
|
| 170 | 198 | $langs->setDefaultLang($langcode); |
| 171 | 199 | } |
| 172 | 200 | |
| 173 | 201 | |
| 174 | 202 | |
| 175 | 203 | |
| 176 | -if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR');
|
|
| 204 | +if (! defined('MAIN_LABEL_MENTION_NPR') ) { |
|
| 205 | + define('MAIN_LABEL_MENTION_NPR','NPR'); |
|
| 206 | +} |
|
| 177 | 207 | |
@@ -141,14 +141,16 @@ |
||
| 141 | 141 | $reshook = Globals::$hookManager->executeHooks('addSearchEntry', $parameters); |
| 142 | 142 | if (empty($reshook)) { |
| 143 | 143 | $arrayresult = array_merge($arrayresult, Globals::$hookManager->resArray); |
| 144 | - } else |
|
| 145 | - $arrayresult = Globals::$hookManager->resArray; |
|
| 144 | + } else { |
|
| 145 | + $arrayresult = Globals::$hookManager->resArray; |
|
| 146 | + } |
|
| 146 | 147 | |
| 147 | 148 | // This allow to keep a search entry to the top |
| 148 | 149 | if (!empty($conf->global->DEFAULT_SEARCH_INTO_MODULE)) { |
| 149 | 150 | $key = 'searchinto' . $conf->global->DEFAULT_SEARCH_INTO_MODULE; |
| 150 | - if (array_key_exists($key, $arrayresult)) |
|
| 151 | - $arrayresult[$key]['position'] = -10; |
|
| 151 | + if (array_key_exists($key, $arrayresult)) { |
|
| 152 | + $arrayresult[$key]['position'] = -10; |
|
| 153 | + } |
|
| 152 | 154 | } |
| 153 | 155 | |
| 154 | 156 | // Sort on position |
@@ -88,19 +88,19 @@ discard block |
||
| 88 | 88 | $yearref = dol_print_date($gmtnow, '%Y'); |
| 89 | 89 | $monthref = dol_print_date($gmtnow, '%m'); |
| 90 | 90 | $dayref = dol_print_date($gmtnow, '%d'); |
| 91 | - if ($refgmtdate == 'now') |
|
| 92 | - $newrefgmtdate = $yearref . '-' . $monthref . '-' . $dayref; |
|
| 93 | - elseif ($refgmtdate == 'summer') |
|
| 94 | - $newrefgmtdate = $yearref . '-08-01'; |
|
| 95 | - else |
|
| 96 | - $newrefgmtdate = $yearref . '-01-01'; |
|
| 91 | + if ($refgmtdate == 'now') { |
|
| 92 | + $newrefgmtdate = $yearref . '-' . $monthref . '-' . $dayref; |
|
| 93 | + } elseif ($refgmtdate == 'summer') { |
|
| 94 | + $newrefgmtdate = $yearref . '-08-01'; |
|
| 95 | + } else { |
|
| 96 | + $newrefgmtdate = $yearref . '-01-01'; |
|
| 97 | + } |
|
| 97 | 98 | $newrefgmtdate .= 'T00:00:00+00:00'; |
| 98 | 99 | $localtz = new DateTimeZone(getServerTimeZoneString()); |
| 99 | 100 | $localdt = new DateTime($newrefgmtdate, $localtz); |
| 100 | 101 | $tmp = -1 * $localtz->getOffset($localdt); |
| 101 | 102 | //print $refgmtdate.'='.$tmp; |
| 102 | - } |
|
| 103 | - else {
|
|
| 103 | + } else {
|
|
| 104 | 104 | $tmp = 0; |
| 105 | 105 | dol_print_error('', 'PHP version must be 5.3+');
|
| 106 | 106 | } |
@@ -120,12 +120,15 @@ discard block |
||
| 120 | 120 | {
|
| 121 | 121 | global $conf; |
| 122 | 122 | |
| 123 | - if ($duration_value == 0) |
|
| 124 | - return $time; |
|
| 125 | - if ($duration_unit == 'h') |
|
| 126 | - return $time + (3600 * $duration_value); |
|
| 127 | - if ($duration_unit == 'w') |
|
| 128 | - return $time + (3600 * 24 * 7 * $duration_value); |
|
| 123 | + if ($duration_value == 0) { |
|
| 124 | + return $time; |
|
| 125 | + } |
|
| 126 | + if ($duration_unit == 'h') { |
|
| 127 | + return $time + (3600 * $duration_value); |
|
| 128 | + } |
|
| 129 | + if ($duration_unit == 'w') { |
|
| 130 | + return $time + (3600 * 24 * 7 * $duration_value); |
|
| 131 | + } |
|
| 129 | 132 | |
| 130 | 133 | $deltastring = 'P'; |
| 131 | 134 | |
@@ -148,15 +151,17 @@ discard block |
||
| 148 | 151 | } |
| 149 | 152 | |
| 150 | 153 | $date = new DateTime(); |
| 151 | - if (!empty(Globals::$conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) |
|
| 152 | - $date->setTimezone(new DateTimeZone('UTC'));
|
|
| 154 | + if (!empty(Globals::$conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) { |
|
| 155 | + $date->setTimezone(new DateTimeZone('UTC')); |
|
| 156 | + } |
|
| 153 | 157 | $date->setTimestamp($time); |
| 154 | 158 | $interval = new DateInterval($deltastring); |
| 155 | 159 | |
| 156 | - if ($sub) |
|
| 157 | - $date->sub($interval); |
|
| 158 | - else |
|
| 159 | - $date->add($interval); |
|
| 160 | + if ($sub) { |
|
| 161 | + $date->sub($interval); |
|
| 162 | + } else { |
|
| 163 | + $date->add($interval); |
|
| 164 | + } |
|
| 160 | 165 | |
| 161 | 166 | return $date->getTimestamp(); |
| 162 | 167 | } |
@@ -200,14 +205,20 @@ discard block |
||
| 200 | 205 | {
|
| 201 | 206 | global $langs; |
| 202 | 207 | |
| 203 | - if (empty($lengthOfDay)) |
|
| 204 | - $lengthOfDay = 86400; // 1 day = 24 hours |
|
| 205 | - if (empty($lengthOfWeek)) |
|
| 206 | - $lengthOfWeek = 7; // 1 week = 7 days |
|
| 208 | + if (empty($lengthOfDay)) { |
|
| 209 | + $lengthOfDay = 86400; |
|
| 210 | + } |
|
| 211 | + // 1 day = 24 hours |
|
| 212 | + if (empty($lengthOfWeek)) { |
|
| 213 | + $lengthOfWeek = 7; |
|
| 214 | + } |
|
| 215 | + // 1 week = 7 days |
|
| 207 | 216 | |
| 208 | 217 | if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin') {
|
| 209 | - if ((int) $iSecond === 0) |
|
| 210 | - return '0'; // This is to avoid having 0 return a 12:00 AM for en_US |
|
| 218 | + if ((int) $iSecond === 0) { |
|
| 219 | + return '0'; |
|
| 220 | + } |
|
| 221 | + // This is to avoid having 0 return a 12:00 AM for en_US |
|
| 211 | 222 | |
| 212 | 223 | $sTime = ''; |
| 213 | 224 | $sDay = 0; |
@@ -219,8 +230,9 @@ discard block |
||
| 219 | 230 | $iSecond -= $lengthOfDay; |
| 220 | 231 | } |
| 221 | 232 | $dayTranslate = $langs->trans("Day");
|
| 222 | - if ($iSecond >= ($lengthOfDay * 2)) |
|
| 223 | - $dayTranslate = $langs->trans("Days");
|
|
| 233 | + if ($iSecond >= ($lengthOfDay * 2)) { |
|
| 234 | + $dayTranslate = $langs->trans("Days"); |
|
| 235 | + } |
|
| 224 | 236 | } |
| 225 | 237 | |
| 226 | 238 | if ($lengthOfWeek < 7) {
|
@@ -229,16 +241,18 @@ discard block |
||
| 229 | 241 | $sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek); |
| 230 | 242 | $sDay = $sDay % $lengthOfWeek; |
| 231 | 243 | $weekTranslate = $langs->trans("DurationWeek");
|
| 232 | - if ($sWeek >= 2) |
|
| 233 | - $weekTranslate = $langs->trans("DurationWeeks");
|
|
| 244 | + if ($sWeek >= 2) { |
|
| 245 | + $weekTranslate = $langs->trans("DurationWeeks"); |
|
| 246 | + } |
|
| 234 | 247 | $sTime .= $sWeek . ' ' . $weekTranslate . ' '; |
| 235 | 248 | } |
| 236 | 249 | } |
| 237 | 250 | } |
| 238 | 251 | if ($sDay > 0) {
|
| 239 | 252 | $dayTranslate = $langs->trans("Day");
|
| 240 | - if ($sDay > 1) |
|
| 241 | - $dayTranslate = $langs->trans("Days");
|
|
| 253 | + if ($sDay > 1) { |
|
| 254 | + $dayTranslate = $langs->trans("Days"); |
|
| 255 | + } |
|
| 242 | 256 | $sTime .= $sDay . ' ' . $dayTranslate . ' '; |
| 243 | 257 | } |
| 244 | 258 | |
@@ -294,8 +308,9 @@ discard block |
||
| 294 | 308 | } else if ($year_date > 0 && !empty($day_date)) {
|
| 295 | 309 | $sqldate .= " AND " . $datefield . " BETWEEN '" . $db->idate(dol_mktime(0, 0, 0, $month_date, $day_date, $year_date)); |
| 296 | 310 | $sqldate .= "' AND '" . $db->idate(dol_mktime(23, 59, 59, $month_date, $day_date, $year_date)) . "'"; |
| 297 | - } else |
|
| 298 | - $sqldate .= " AND date_format( " . $datefield . ", '%m') = '" . $db->escape($month_date) . "'"; |
|
| 311 | + } else { |
|
| 312 | + $sqldate .= " AND date_format( " . $datefield . ", '%m') = '" . $db->escape($month_date) . "'"; |
|
| 313 | + } |
|
| 299 | 314 | } else if ($year_date > 0) {
|
| 300 | 315 | $sqldate .= " AND " . $datefield . " BETWEEN '" . $db->idate(dol_get_first_day($year_date, 1, false)); |
| 301 | 316 | $sqldate .= "' AND '" . $db->idate(dol_get_last_day($year_date, 12, false)) . "'"; |
@@ -334,13 +349,14 @@ discard block |
||
| 334 | 349 | $shour = $reg[4]; |
| 335 | 350 | $smin = $reg[5]; |
| 336 | 351 | $ssec = $reg[6]; |
| 337 | - if ($syear < 50) |
|
| 338 | - $syear += 1900; |
|
| 339 | - if ($syear >= 50 && $syear < 100) |
|
| 340 | - $syear += 2000; |
|
| 352 | + if ($syear < 50) { |
|
| 353 | + $syear += 1900; |
|
| 354 | + } |
|
| 355 | + if ($syear >= 50 && $syear < 100) { |
|
| 356 | + $syear += 2000; |
|
| 357 | + } |
|
| 341 | 358 | $string = sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec);
|
| 342 | - } |
|
| 343 | - else if ( |
|
| 359 | + } else if ( |
|
| 344 | 360 | preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$/i', $string, $reg) // Convert date with format YYYY-MM-DDTHH:MM:SSZ (RFC3339)
|
| 345 | 361 | || preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/i', $string, $reg) // Convert date with format YYYY-MM-DD HH:MM:SS
|
| 346 | 362 | || preg_match('/^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z$/i', $string, $reg) // Convert date with format YYYYMMDDTHHMMSSZ
|
@@ -474,8 +490,9 @@ discard block |
||
| 474 | 490 | */ |
| 475 | 491 | function dol_get_first_day($year, $month = 1, $gm = false) |
| 476 | 492 | {
|
| 477 | - if ($year > 9999) |
|
| 478 | - return ''; |
|
| 493 | + if ($year > 9999) { |
|
| 494 | + return ''; |
|
| 495 | + } |
|
| 479 | 496 | return dol_mktime(0, 0, 0, $month, 1, $year, $gm); |
| 480 | 497 | } |
| 481 | 498 | |
@@ -488,8 +505,9 @@ discard block |
||
| 488 | 505 | */ |
| 489 | 506 | function dol_get_last_day($year, $month = 12, $gm = false) |
| 490 | 507 | {
|
| 491 | - if ($year > 9999) |
|
| 492 | - return ''; |
|
| 508 | + if ($year > 9999) { |
|
| 509 | + return ''; |
|
| 510 | + } |
|
| 493 | 511 | if ($month == 12) {
|
| 494 | 512 | $month = 1; |
| 495 | 513 | $year += 1; |
@@ -525,8 +543,9 @@ discard block |
||
| 525 | 543 | $tmparray = dol_getdate($date, true); // detail of current day |
| 526 | 544 | //Calculate days = offset from current day |
| 527 | 545 | $days = $start_week - $tmparray['wday']; |
| 528 | - if ($days >= 1) |
|
| 529 | - $days = 7 - $days; |
|
| 546 | + if ($days >= 1) { |
|
| 547 | + $days = 7 - $days; |
|
| 548 | + } |
|
| 530 | 549 | $days = abs($days); |
| 531 | 550 | $seconds = $days * 24 * 60 * 60; |
| 532 | 551 | //print 'start_week='.$start_week.' tmparray[wday]='.$tmparray['wday'].' day offset='.$days.' seconds offset='.$seconds.'<br>'; |
@@ -590,8 +609,9 @@ discard block |
||
| 590 | 609 | $nbFerie = 0; |
| 591 | 610 | |
| 592 | 611 | // Check to ensure we use correct parameters |
| 593 | - if ((($timestampEnd - $timestampStart) % 86400) != 0) |
|
| 594 | - return 'ErrorDates must use same hours and must be GMT dates'; |
|
| 612 | + if ((($timestampEnd - $timestampStart) % 86400) != 0) { |
|
| 613 | + return 'ErrorDates must use same hours and must be GMT dates'; |
|
| 614 | + } |
|
| 595 | 615 | |
| 596 | 616 | $i = 0; |
| 597 | 617 | while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) ) && ($i < 50000)) { // Loop end when equals (Test on i is a security loop to avoid infinite loop)
|
@@ -610,12 +630,13 @@ discard block |
||
| 610 | 630 | foreach ($arrayofdaystring as $daystring) {
|
| 611 | 631 | $tmp = explode('-', $daystring);
|
| 612 | 632 | if ($tmp[2]) {
|
| 613 | - if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) |
|
| 614 | - $ferie = true; |
|
| 615 | - } |
|
| 616 | - else {
|
|
| 617 | - if ($tmp[0] == $mois && $tmp[1] == $jour) |
|
| 618 | - $ferie = true; |
|
| 633 | + if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) { |
|
| 634 | + $ferie = true; |
|
| 635 | + } |
|
| 636 | + } else {
|
|
| 637 | + if ($tmp[0] == $mois && $tmp[1] == $jour) { |
|
| 638 | + $ferie = true; |
|
| 639 | + } |
|
| 619 | 640 | } |
| 620 | 641 | } |
| 621 | 642 | } |
@@ -624,22 +645,38 @@ discard block |
||
| 624 | 645 | $countryfound = 1; |
| 625 | 646 | |
| 626 | 647 | // Definition of fixed working days |
| 627 | - if ($jour == 1 && $mois == 1) |
|
| 628 | - $ferie = true; // 1er january |
|
| 629 | - if ($jour == 1 && $mois == 5) |
|
| 630 | - $ferie = true; // 1er may |
|
| 631 | - if ($jour == 8 && $mois == 5) |
|
| 632 | - $ferie = true; // 5 may |
|
| 633 | - if ($jour == 14 && $mois == 7) |
|
| 634 | - $ferie = true; // 14 july |
|
| 635 | - if ($jour == 15 && $mois == 8) |
|
| 636 | - $ferie = true; // 15 august |
|
| 637 | - if ($jour == 1 && $mois == 11) |
|
| 638 | - $ferie = true; // 1 november |
|
| 639 | - if ($jour == 11 && $mois == 11) |
|
| 640 | - $ferie = true; // 11 november |
|
| 641 | - if ($jour == 25 && $mois == 12) |
|
| 642 | - $ferie = true; // 25 december |
|
| 648 | + if ($jour == 1 && $mois == 1) { |
|
| 649 | + $ferie = true; |
|
| 650 | + } |
|
| 651 | + // 1er january |
|
| 652 | + if ($jour == 1 && $mois == 5) { |
|
| 653 | + $ferie = true; |
|
| 654 | + } |
|
| 655 | + // 1er may |
|
| 656 | + if ($jour == 8 && $mois == 5) { |
|
| 657 | + $ferie = true; |
|
| 658 | + } |
|
| 659 | + // 5 may |
|
| 660 | + if ($jour == 14 && $mois == 7) { |
|
| 661 | + $ferie = true; |
|
| 662 | + } |
|
| 663 | + // 14 july |
|
| 664 | + if ($jour == 15 && $mois == 8) { |
|
| 665 | + $ferie = true; |
|
| 666 | + } |
|
| 667 | + // 15 august |
|
| 668 | + if ($jour == 1 && $mois == 11) { |
|
| 669 | + $ferie = true; |
|
| 670 | + } |
|
| 671 | + // 1 november |
|
| 672 | + if ($jour == 11 && $mois == 11) { |
|
| 673 | + $ferie = true; |
|
| 674 | + } |
|
| 675 | + // 11 november |
|
| 676 | + if ($jour == 25 && $mois == 12) { |
|
| 677 | + $ferie = true; |
|
| 678 | + } |
|
| 679 | + // 25 december |
|
| 643 | 680 | |
| 644 | 681 | |
| 645 | 682 | |
@@ -647,8 +684,9 @@ discard block |
||
| 647 | 684 | $date_paques = easter_date($annee); |
| 648 | 685 | $jour_paques = date("d", $date_paques);
|
| 649 | 686 | $mois_paques = date("m", $date_paques);
|
| 650 | - if ($jour_paques == $jour && $mois_paques == $mois) |
|
| 651 | - $ferie = true; |
|
| 687 | + if ($jour_paques == $jour && $mois_paques == $mois) { |
|
| 688 | + $ferie = true; |
|
| 689 | + } |
|
| 652 | 690 | // Pâques |
| 653 | 691 | // Calculation for the monday of easter date |
| 654 | 692 | $date_lundi_paques = mktime( |
@@ -656,8 +694,9 @@ discard block |
||
| 656 | 694 | ); |
| 657 | 695 | $jour_lundi_ascension = date("d", $date_lundi_paques);
|
| 658 | 696 | $mois_lundi_ascension = date("m", $date_lundi_paques);
|
| 659 | - if ($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) |
|
| 660 | - $ferie = true; |
|
| 697 | + if ($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) { |
|
| 698 | + $ferie = true; |
|
| 699 | + } |
|
| 661 | 700 | // Lundi de Pâques |
| 662 | 701 | // Calcul du jour de l'ascension (38 days after easter day) |
| 663 | 702 | $date_ascension = mktime( |
@@ -665,8 +704,9 @@ discard block |
||
| 665 | 704 | ); |
| 666 | 705 | $jour_ascension = date("d", $date_ascension);
|
| 667 | 706 | $mois_ascension = date("m", $date_ascension);
|
| 668 | - if ($jour_ascension == $jour && $mois_ascension == $mois) |
|
| 669 | - $ferie = true; |
|
| 707 | + if ($jour_ascension == $jour && $mois_ascension == $mois) { |
|
| 708 | + $ferie = true; |
|
| 709 | + } |
|
| 670 | 710 | // Ascension |
| 671 | 711 | // Calculation of "Pentecote" (11 days after easter day) |
| 672 | 712 | $date_pentecote = mktime( |
@@ -674,8 +714,9 @@ discard block |
||
| 674 | 714 | ); |
| 675 | 715 | $jour_pentecote = date("d", $date_pentecote);
|
| 676 | 716 | $mois_pentecote = date("m", $date_pentecote);
|
| 677 | - if ($jour_pentecote == $jour && $mois_pentecote == $mois) |
|
| 678 | - $ferie = true; |
|
| 717 | + if ($jour_pentecote == $jour && $mois_pentecote == $mois) { |
|
| 718 | + $ferie = true; |
|
| 719 | + } |
|
| 679 | 720 | // "Pentecote" |
| 680 | 721 | } |
| 681 | 722 | |
@@ -685,26 +726,46 @@ discard block |
||
| 685 | 726 | $countryfound = 1; |
| 686 | 727 | |
| 687 | 728 | // Definition des dates feriees fixes |
| 688 | - if ($jour == 1 && $mois == 1) |
|
| 689 | - $ferie = true; // Capodanno |
|
| 690 | - if ($jour == 6 && $mois == 1) |
|
| 691 | - $ferie = true; // Epifania |
|
| 692 | - if ($jour == 25 && $mois == 4) |
|
| 693 | - $ferie = true; // Anniversario Liberazione |
|
| 694 | - if ($jour == 1 && $mois == 5) |
|
| 695 | - $ferie = true; // Festa del Lavoro |
|
| 696 | - if ($jour == 2 && $mois == 6) |
|
| 697 | - $ferie = true; // Festa della Repubblica |
|
| 698 | - if ($jour == 15 && $mois == 8) |
|
| 699 | - $ferie = true; // Ferragosto |
|
| 700 | - if ($jour == 1 && $mois == 11) |
|
| 701 | - $ferie = true; // Tutti i Santi |
|
| 702 | - if ($jour == 8 && $mois == 12) |
|
| 703 | - $ferie = true; // Immacolata Concezione |
|
| 704 | - if ($jour == 25 && $mois == 12) |
|
| 705 | - $ferie = true; // 25 decembre |
|
| 706 | - if ($jour == 26 && $mois == 12) |
|
| 707 | - $ferie = true; // Santo Stefano |
|
| 729 | + if ($jour == 1 && $mois == 1) { |
|
| 730 | + $ferie = true; |
|
| 731 | + } |
|
| 732 | + // Capodanno |
|
| 733 | + if ($jour == 6 && $mois == 1) { |
|
| 734 | + $ferie = true; |
|
| 735 | + } |
|
| 736 | + // Epifania |
|
| 737 | + if ($jour == 25 && $mois == 4) { |
|
| 738 | + $ferie = true; |
|
| 739 | + } |
|
| 740 | + // Anniversario Liberazione |
|
| 741 | + if ($jour == 1 && $mois == 5) { |
|
| 742 | + $ferie = true; |
|
| 743 | + } |
|
| 744 | + // Festa del Lavoro |
|
| 745 | + if ($jour == 2 && $mois == 6) { |
|
| 746 | + $ferie = true; |
|
| 747 | + } |
|
| 748 | + // Festa della Repubblica |
|
| 749 | + if ($jour == 15 && $mois == 8) { |
|
| 750 | + $ferie = true; |
|
| 751 | + } |
|
| 752 | + // Ferragosto |
|
| 753 | + if ($jour == 1 && $mois == 11) { |
|
| 754 | + $ferie = true; |
|
| 755 | + } |
|
| 756 | + // Tutti i Santi |
|
| 757 | + if ($jour == 8 && $mois == 12) { |
|
| 758 | + $ferie = true; |
|
| 759 | + } |
|
| 760 | + // Immacolata Concezione |
|
| 761 | + if ($jour == 25 && $mois == 12) { |
|
| 762 | + $ferie = true; |
|
| 763 | + } |
|
| 764 | + // 25 decembre |
|
| 765 | + if ($jour == 26 && $mois == 12) { |
|
| 766 | + $ferie = true; |
|
| 767 | + } |
|
| 768 | + // Santo Stefano |
|
| 708 | 769 | |
| 709 | 770 | |
| 710 | 771 | |
@@ -712,50 +773,81 @@ discard block |
||
| 712 | 773 | $date_paques = easter_date($annee); |
| 713 | 774 | $jour_paques = date("d", $date_paques);
|
| 714 | 775 | $mois_paques = date("m", $date_paques);
|
| 715 | - if ($jour_paques == $jour && $mois_paques == $mois) |
|
| 716 | - $ferie = true; |
|
| 776 | + if ($jour_paques == $jour && $mois_paques == $mois) { |
|
| 777 | + $ferie = true; |
|
| 778 | + } |
|
| 717 | 779 | // Paques |
| 718 | 780 | } |
| 719 | 781 | |
| 720 | 782 | if ($countrycode == 'IN') {
|
| 721 | 783 | $countryfound = 1; |
| 722 | 784 | |
| 723 | - if ($jour == 1 && $mois == 1) |
|
| 724 | - $ferie = true; // New Year's Day |
|
| 725 | - if ($jour == 26 && $mois == 1) |
|
| 726 | - $ferie = true; // Republic Day |
|
| 727 | - if ($jour == 1 && $mois == 5) |
|
| 728 | - $ferie = true; // May Day |
|
| 729 | - if ($jour == 15 && $mois == 8) |
|
| 730 | - $ferie = true; // Independence Day |
|
| 731 | - if ($jour == 2 && $mois == 10) |
|
| 732 | - $ferie = true; // Gandhi Jayanti |
|
| 733 | - if ($jour == 25 && $mois == 12) |
|
| 734 | - $ferie = true; // Christmas |
|
| 785 | + if ($jour == 1 && $mois == 1) { |
|
| 786 | + $ferie = true; |
|
| 787 | + } |
|
| 788 | + // New Year's Day |
|
| 789 | + if ($jour == 26 && $mois == 1) { |
|
| 790 | + $ferie = true; |
|
| 791 | + } |
|
| 792 | + // Republic Day |
|
| 793 | + if ($jour == 1 && $mois == 5) { |
|
| 794 | + $ferie = true; |
|
| 795 | + } |
|
| 796 | + // May Day |
|
| 797 | + if ($jour == 15 && $mois == 8) { |
|
| 798 | + $ferie = true; |
|
| 799 | + } |
|
| 800 | + // Independence Day |
|
| 801 | + if ($jour == 2 && $mois == 10) { |
|
| 802 | + $ferie = true; |
|
| 803 | + } |
|
| 804 | + // Gandhi Jayanti |
|
| 805 | + if ($jour == 25 && $mois == 12) { |
|
| 806 | + $ferie = true; |
|
| 807 | + } |
|
| 808 | + // Christmas |
|
| 735 | 809 | } |
| 736 | 810 | |
| 737 | 811 | if ($countrycode == 'ES') {
|
| 738 | 812 | $countryfound = 1; |
| 739 | 813 | |
| 740 | 814 | // Definition des dates feriees fixes |
| 741 | - if ($jour == 1 && $mois == 1) |
|
| 742 | - $ferie = true; // Año nuevo |
|
| 743 | - if ($jour == 6 && $mois == 1) |
|
| 744 | - $ferie = true; // Día Reyes |
|
| 745 | - if ($jour == 1 && $mois == 5) |
|
| 746 | - $ferie = true; // 1 Mayo |
|
| 747 | - if ($jour == 15 && $mois == 8) |
|
| 748 | - $ferie = true; // 15 Agosto |
|
| 749 | - if ($jour == 12 && $mois == 10) |
|
| 750 | - $ferie = true; // Día Hispanidad |
|
| 751 | - if ($jour == 1 && $mois == 11) |
|
| 752 | - $ferie = true; // 1 noviembre |
|
| 753 | - if ($jour == 6 && $mois == 12) |
|
| 754 | - $ferie = true; // Constitución |
|
| 755 | - if ($jour == 8 && $mois == 12) |
|
| 756 | - $ferie = true; // Inmaculada |
|
| 757 | - if ($jour == 25 && $mois == 12) |
|
| 758 | - $ferie = true; // 25 diciembre |
|
| 815 | + if ($jour == 1 && $mois == 1) { |
|
| 816 | + $ferie = true; |
|
| 817 | + } |
|
| 818 | + // Año nuevo |
|
| 819 | + if ($jour == 6 && $mois == 1) { |
|
| 820 | + $ferie = true; |
|
| 821 | + } |
|
| 822 | + // Día Reyes |
|
| 823 | + if ($jour == 1 && $mois == 5) { |
|
| 824 | + $ferie = true; |
|
| 825 | + } |
|
| 826 | + // 1 Mayo |
|
| 827 | + if ($jour == 15 && $mois == 8) { |
|
| 828 | + $ferie = true; |
|
| 829 | + } |
|
| 830 | + // 15 Agosto |
|
| 831 | + if ($jour == 12 && $mois == 10) { |
|
| 832 | + $ferie = true; |
|
| 833 | + } |
|
| 834 | + // Día Hispanidad |
|
| 835 | + if ($jour == 1 && $mois == 11) { |
|
| 836 | + $ferie = true; |
|
| 837 | + } |
|
| 838 | + // 1 noviembre |
|
| 839 | + if ($jour == 6 && $mois == 12) { |
|
| 840 | + $ferie = true; |
|
| 841 | + } |
|
| 842 | + // Constitución |
|
| 843 | + if ($jour == 8 && $mois == 12) { |
|
| 844 | + $ferie = true; |
|
| 845 | + } |
|
| 846 | + // Inmaculada |
|
| 847 | + if ($jour == 25 && $mois == 12) { |
|
| 848 | + $ferie = true; |
|
| 849 | + } |
|
| 850 | + // 25 diciembre |
|
| 759 | 851 | |
| 760 | 852 | |
| 761 | 853 | |
@@ -763,8 +855,9 @@ discard block |
||
| 763 | 855 | $date_paques = easter_date($annee); |
| 764 | 856 | $jour_paques = date("d", $date_paques);
|
| 765 | 857 | $mois_paques = date("m", $date_paques);
|
| 766 | - if ($jour_paques == $jour && $mois_paques == $mois) |
|
| 767 | - $ferie = true; |
|
| 858 | + if ($jour_paques == $jour && $mois_paques == $mois) { |
|
| 859 | + $ferie = true; |
|
| 860 | + } |
|
| 768 | 861 | // Paques |
| 769 | 862 | // Viernes Santo |
| 770 | 863 | $date_viernes = mktime( |
@@ -772,8 +865,9 @@ discard block |
||
| 772 | 865 | ); |
| 773 | 866 | $jour_viernes = date("d", $date_viernes);
|
| 774 | 867 | $mois_viernes = date("m", $date_viernes);
|
| 775 | - if ($jour_viernes == $jour && $mois_viernes == $mois) |
|
| 776 | - $ferie = true; |
|
| 868 | + if ($jour_viernes == $jour && $mois_viernes == $mois) { |
|
| 869 | + $ferie = true; |
|
| 870 | + } |
|
| 777 | 871 | //Viernes Santo |
| 778 | 872 | } |
| 779 | 873 | |
@@ -781,28 +875,50 @@ discard block |
||
| 781 | 875 | $countryfound = 1; |
| 782 | 876 | |
| 783 | 877 | // Definition des dates feriees fixes |
| 784 | - if ($jour == 1 && $mois == 1) |
|
| 785 | - $ferie = true; // Neujahr |
|
| 786 | - if ($jour == 6 && $mois == 1) |
|
| 787 | - $ferie = true; // Hl. 3 Koenige |
|
| 788 | - if ($jour == 1 && $mois == 5) |
|
| 789 | - $ferie = true; // 1. Mai |
|
| 790 | - if ($jour == 15 && $mois == 8) |
|
| 791 | - $ferie = true; // Mariae Himmelfahrt |
|
| 792 | - if ($jour == 26 && $mois == 10) |
|
| 793 | - $ferie = true; // 26. Oktober |
|
| 794 | - if ($jour == 1 && $mois == 11) |
|
| 795 | - $ferie = true; // Allerheiligen |
|
| 796 | - if ($jour == 8 && $mois == 12) |
|
| 797 | - $ferie = true; // Mariae Empfaengnis |
|
| 798 | - if ($jour == 24 && $mois == 12) |
|
| 799 | - $ferie = true; // Heilig abend |
|
| 800 | - if ($jour == 25 && $mois == 12) |
|
| 801 | - $ferie = true; // Christtag |
|
| 802 | - if ($jour == 26 && $mois == 12) |
|
| 803 | - $ferie = true; // Stefanietag |
|
| 804 | - if ($jour == 31 && $mois == 12) |
|
| 805 | - $ferie = true; // Silvester |
|
| 878 | + if ($jour == 1 && $mois == 1) { |
|
| 879 | + $ferie = true; |
|
| 880 | + } |
|
| 881 | + // Neujahr |
|
| 882 | + if ($jour == 6 && $mois == 1) { |
|
| 883 | + $ferie = true; |
|
| 884 | + } |
|
| 885 | + // Hl. 3 Koenige |
|
| 886 | + if ($jour == 1 && $mois == 5) { |
|
| 887 | + $ferie = true; |
|
| 888 | + } |
|
| 889 | + // 1. Mai |
|
| 890 | + if ($jour == 15 && $mois == 8) { |
|
| 891 | + $ferie = true; |
|
| 892 | + } |
|
| 893 | + // Mariae Himmelfahrt |
|
| 894 | + if ($jour == 26 && $mois == 10) { |
|
| 895 | + $ferie = true; |
|
| 896 | + } |
|
| 897 | + // 26. Oktober |
|
| 898 | + if ($jour == 1 && $mois == 11) { |
|
| 899 | + $ferie = true; |
|
| 900 | + } |
|
| 901 | + // Allerheiligen |
|
| 902 | + if ($jour == 8 && $mois == 12) { |
|
| 903 | + $ferie = true; |
|
| 904 | + } |
|
| 905 | + // Mariae Empfaengnis |
|
| 906 | + if ($jour == 24 && $mois == 12) { |
|
| 907 | + $ferie = true; |
|
| 908 | + } |
|
| 909 | + // Heilig abend |
|
| 910 | + if ($jour == 25 && $mois == 12) { |
|
| 911 | + $ferie = true; |
|
| 912 | + } |
|
| 913 | + // Christtag |
|
| 914 | + if ($jour == 26 && $mois == 12) { |
|
| 915 | + $ferie = true; |
|
| 916 | + } |
|
| 917 | + // Stefanietag |
|
| 918 | + if ($jour == 31 && $mois == 12) { |
|
| 919 | + $ferie = true; |
|
| 920 | + } |
|
| 921 | + // Silvester |
|
| 806 | 922 | |
| 807 | 923 | |
| 808 | 924 | |
@@ -810,8 +926,9 @@ discard block |
||
| 810 | 926 | $date_paques = easter_date($annee); |
| 811 | 927 | $jour_paques = date("d", $date_paques);
|
| 812 | 928 | $mois_paques = date("m", $date_paques);
|
| 813 | - if ($jour_paques == $jour && $mois_paques == $mois) |
|
| 814 | - $ferie = true; |
|
| 929 | + if ($jour_paques == $jour && $mois_paques == $mois) { |
|
| 930 | + $ferie = true; |
|
| 931 | + } |
|
| 815 | 932 | // Easter sunday |
| 816 | 933 | // Monday after easter |
| 817 | 934 | $date_eastermonday = mktime( |
@@ -819,8 +936,9 @@ discard block |
||
| 819 | 936 | ); |
| 820 | 937 | $jour_eastermonday = date("d", $date_eastermonday);
|
| 821 | 938 | $mois_eastermonday = date("m", $date_eastermonday);
|
| 822 | - if ($jour_eastermonday == $jour && $mois_eastermonday == $mois) |
|
| 823 | - $ferie = true; |
|
| 939 | + if ($jour_eastermonday == $jour && $mois_eastermonday == $mois) { |
|
| 940 | + $ferie = true; |
|
| 941 | + } |
|
| 824 | 942 | // Easter monday |
| 825 | 943 | // Christi Himmelfahrt (39 days after easter sunday) |
| 826 | 944 | $date_ch = mktime( |
@@ -828,8 +946,9 @@ discard block |
||
| 828 | 946 | ); |
| 829 | 947 | $jour_ch = date("d", $date_ch);
|
| 830 | 948 | $mois_ch = date("m", $date_ch);
|
| 831 | - if ($jour_ch == $jour && $mois_ch == $mois) |
|
| 832 | - $ferie = true; |
|
| 949 | + if ($jour_ch == $jour && $mois_ch == $mois) { |
|
| 950 | + $ferie = true; |
|
| 951 | + } |
|
| 833 | 952 | // Christi Himmelfahrt |
| 834 | 953 | // Pfingsten (50 days after easter sunday) |
| 835 | 954 | $date_pentecote = mktime( |
@@ -837,8 +956,9 @@ discard block |
||
| 837 | 956 | ); |
| 838 | 957 | $jour_pentecote = date("d", $date_pentecote);
|
| 839 | 958 | $mois_pentecote = date("m", $date_pentecote);
|
| 840 | - if ($jour_pentecote == $jour && $mois_pentecote == $mois) |
|
| 841 | - $ferie = true; |
|
| 959 | + if ($jour_pentecote == $jour && $mois_pentecote == $mois) { |
|
| 960 | + $ferie = true; |
|
| 961 | + } |
|
| 842 | 962 | // Pfingsten |
| 843 | 963 | // Fronleichnam (60 days after easter sunday) |
| 844 | 964 | $date_fronleichnam = mktime( |
@@ -846,8 +966,9 @@ discard block |
||
| 846 | 966 | ); |
| 847 | 967 | $jour_fronleichnam = date("d", $date_fronleichnam);
|
| 848 | 968 | $mois_fronleichnam = date("m", $date_fronleichnam);
|
| 849 | - if ($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) |
|
| 850 | - $ferie = true; |
|
| 969 | + if ($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) { |
|
| 970 | + $ferie = true; |
|
| 971 | + } |
|
| 851 | 972 | // Fronleichnam |
| 852 | 973 | } |
| 853 | 974 | |
@@ -855,14 +976,16 @@ discard block |
||
| 855 | 976 | if ($includesaturdayandsunday) {
|
| 856 | 977 | $jour_julien = unixtojd($timestampStart); |
| 857 | 978 | $jour_semaine = jddayofweek($jour_julien, 0); |
| 858 | - if ($jour_semaine == 0 || $jour_semaine == 6) |
|
| 859 | - $ferie = true; |
|
| 979 | + if ($jour_semaine == 0 || $jour_semaine == 6) { |
|
| 980 | + $ferie = true; |
|
| 981 | + } |
|
| 860 | 982 | //Saturday (6) and Sunday (0) |
| 861 | 983 | } |
| 862 | 984 | |
| 863 | 985 | // On incremente compteur |
| 864 | - if ($ferie) |
|
| 865 | - $nbFerie++; |
|
| 986 | + if ($ferie) { |
|
| 987 | + $nbFerie++; |
|
| 988 | + } |
|
| 866 | 989 | |
| 867 | 990 | // Increase number of days (on go up into loop) |
| 868 | 991 | $timestampStart = dol_time_plus_duree($timestampStart, 1, 'd'); |
@@ -914,16 +1037,19 @@ discard block |
||
| 914 | 1037 | {
|
| 915 | 1038 | global $langs, $mysoc; |
| 916 | 1039 | |
| 917 | - if (empty($country_code)) |
|
| 918 | - $country_code = $mysoc->country_code; |
|
| 1040 | + if (empty($country_code)) { |
|
| 1041 | + $country_code = $mysoc->country_code; |
|
| 1042 | + } |
|
| 919 | 1043 | |
| 920 | 1044 | dol_syslog('num_open_day timestampStart=' . $timestampStart . ' timestampEnd=' . $timestampEnd . ' bit=' . $lastday . ' country_code=' . $country_code);
|
| 921 | 1045 | |
| 922 | 1046 | // Check parameters |
| 923 | - if (!is_int($timestampStart) && !is_float($timestampStart)) |
|
| 924 | - return 'ErrorBadParameter_num_open_day'; |
|
| 925 | - if (!is_int($timestampEnd) && !is_float($timestampEnd)) |
|
| 926 | - return 'ErrorBadParameter_num_open_day'; |
|
| 1047 | + if (!is_int($timestampStart) && !is_float($timestampStart)) { |
|
| 1048 | + return 'ErrorBadParameter_num_open_day'; |
|
| 1049 | + } |
|
| 1050 | + if (!is_int($timestampEnd) && !is_float($timestampEnd)) { |
|
| 1051 | + return 'ErrorBadParameter_num_open_day'; |
|
| 1052 | + } |
|
| 927 | 1053 | |
| 928 | 1054 | //print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday; |
| 929 | 1055 | if ($timestampStart < $timestampEnd) {
|
@@ -931,17 +1057,17 @@ discard block |
||
| 931 | 1057 | $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday); |
| 932 | 1058 | $nbOpenDay = $numdays - $numholidays; |
| 933 | 1059 | $nbOpenDay .= " " . $langs->trans("Days");
|
| 934 | - if ($inhour == 1 && $nbOpenDay <= 3) |
|
| 935 | - $nbOpenDay = $nbOpenDay * 24 . $langs->trans("HourShort");
|
|
| 1060 | + if ($inhour == 1 && $nbOpenDay <= 3) { |
|
| 1061 | + $nbOpenDay = $nbOpenDay * 24 . $langs->trans("HourShort"); |
|
| 1062 | + } |
|
| 936 | 1063 | return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); |
| 937 | - } |
|
| 938 | - elseif ($timestampStart == $timestampEnd) {
|
|
| 1064 | + } elseif ($timestampStart == $timestampEnd) {
|
|
| 939 | 1065 | $nbOpenDay = $lastday; |
| 940 | - if ($inhour == 1) |
|
| 941 | - $nbOpenDay = $nbOpenDay * 24 . $langs->trans("HourShort");
|
|
| 1066 | + if ($inhour == 1) { |
|
| 1067 | + $nbOpenDay = $nbOpenDay * 24 . $langs->trans("HourShort"); |
|
| 1068 | + } |
|
| 942 | 1069 | return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); |
| 943 | - } |
|
| 944 | - else {
|
|
| 1070 | + } else {
|
|
| 945 | 1071 | return $langs->trans("Error");
|
| 946 | 1072 | } |
| 947 | 1073 | } |