@@ -106,9 +106,15 @@ discard block |
||
106 | 106 | $color_file = DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php'; |
107 | 107 | if (is_readable($color_file)) { |
108 | 108 | include_once $color_file; |
109 | - if (isset($theme_bordercolor)) $this->bordercolor = $theme_bordercolor; |
|
110 | - if (isset($theme_datacolor)) $this->datacolor = $theme_datacolor; |
|
111 | - if (isset($theme_bgcolor)) $this->bgcolor = $theme_bgcolor; |
|
109 | + if (isset($theme_bordercolor)) { |
|
110 | + $this->bordercolor = $theme_bordercolor; |
|
111 | + } |
|
112 | + if (isset($theme_datacolor)) { |
|
113 | + $this->datacolor = $theme_datacolor; |
|
114 | + } |
|
115 | + if (isset($theme_bgcolor)) { |
|
116 | + $this->bgcolor = $theme_bgcolor; |
|
117 | + } |
|
112 | 118 | } |
113 | 119 | //print 'bgcolor: '.join(',',$this->bgcolor).'<br>'; |
114 | 120 | |
@@ -522,7 +528,9 @@ discard block |
||
522 | 528 | public function GetMaxValueInData() |
523 | 529 | { |
524 | 530 | // phpcs:enable |
525 | - if (!is_array($this->data)) return 0; |
|
531 | + if (!is_array($this->data)) { |
|
532 | + return 0; |
|
533 | + } |
|
526 | 534 | |
527 | 535 | $k = 0; |
528 | 536 | $vals = array(); |
@@ -549,7 +557,9 @@ discard block |
||
549 | 557 | public function GetMinValueInData() |
550 | 558 | { |
551 | 559 | // phpcs:enable |
552 | - if (!is_array($this->data)) return 0; |
|
560 | + if (!is_array($this->data)) { |
|
561 | + return 0; |
|
562 | + } |
|
553 | 563 | |
554 | 564 | $k = 0; |
555 | 565 | $vals = array(); |
@@ -577,7 +587,9 @@ discard block |
||
577 | 587 | { |
578 | 588 | // phpcs:enable |
579 | 589 | $max = $this->GetMaxValueInData(); |
580 | - if ($max != 0) $max++; |
|
590 | + if ($max != 0) { |
|
591 | + $max++; |
|
592 | + } |
|
581 | 593 | $size = dol_strlen(abs(ceil($max))); |
582 | 594 | $factor = 1; |
583 | 595 | for ($i = 0; $i < ($size - 1); $i++) { |
@@ -585,7 +597,9 @@ discard block |
||
585 | 597 | } |
586 | 598 | |
587 | 599 | $res = 0; |
588 | - if (is_numeric($max)) $res = ceil($max / $factor) * $factor; |
|
600 | + if (is_numeric($max)) { |
|
601 | + $res = ceil($max / $factor) * $factor; |
|
602 | + } |
|
589 | 603 | |
590 | 604 | //print "max=".$max." res=".$res; |
591 | 605 | return $res; |
@@ -601,8 +615,12 @@ discard block |
||
601 | 615 | { |
602 | 616 | // phpcs:enable |
603 | 617 | $min = $this->GetMinValueInData(); |
604 | - if ($min == '') $min = 0; |
|
605 | - if ($min != 0) $min--; |
|
618 | + if ($min == '') { |
|
619 | + $min = 0; |
|
620 | + } |
|
621 | + if ($min != 0) { |
|
622 | + $min--; |
|
623 | + } |
|
606 | 624 | $size = dol_strlen(abs(floor($min))); |
607 | 625 | $factor = 1; |
608 | 626 | for ($i = 0; $i < ($size - 1); $i++) { |
@@ -676,34 +694,45 @@ discard block |
||
676 | 694 | if (is_array($this->data) && is_array($this->data[0])) { |
677 | 695 | $nblot = count($this->data[0]) - 1; // -1 to remove legend |
678 | 696 | } |
679 | - if ($nblot < 0) dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING); |
|
697 | + if ($nblot < 0) { |
|
698 | + dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING); |
|
699 | + } |
|
680 | 700 | $firstlot = 0; |
681 | 701 | // Works with line but not with bars |
682 | 702 | //if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x |
683 | 703 | |
684 | 704 | $i = $firstlot; |
685 | 705 | $serie = array(); |
686 | - while ($i < $nblot) // Loop on each serie |
|
706 | + while ($i < $nblot) { |
|
707 | + // Loop on each serie |
|
687 | 708 | { |
688 | - $values = array(); // Array with horizontal y values (specific values of a serie) for each abscisse x |
|
709 | + $values = array(); |
|
710 | + } |
|
711 | + // Array with horizontal y values (specific values of a serie) for each abscisse x |
|
689 | 712 | $serie[$i] = "var d" . $i . " = [];\n"; |
690 | 713 | |
691 | 714 | // Fill array $values |
692 | 715 | $x = 0; |
693 | - foreach ($this->data as $valarray) // Loop on each x |
|
716 | + foreach ($this->data as $valarray) { |
|
717 | + // Loop on each x |
|
694 | 718 | { |
695 | 719 | $legends[$x] = $valarray[0]; |
720 | + } |
|
696 | 721 | $values[$x] = (is_numeric($valarray[$i + 1]) ? $valarray[$i + 1] : null); |
697 | 722 | $x++; |
698 | 723 | } |
699 | 724 | |
700 | 725 | if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) { |
701 | 726 | foreach ($values as $x => $y) { |
702 | - if (isset($y)) $serie[$i] .= 'd' . $i . '.push({"label":"' . dol_escape_js($legends[$x]) . '", "data":' . $y . '});' . "\n"; |
|
727 | + if (isset($y)) { |
|
728 | + $serie[$i] .= 'd' . $i . '.push({"label":"' . dol_escape_js($legends[$x]) . '", "data":' . $y . '});' . "\n"; |
|
729 | + } |
|
703 | 730 | } |
704 | 731 | } else { |
705 | 732 | foreach ($values as $x => $y) { |
706 | - if (isset($y)) $serie[$i] .= 'd' . $i . '.push([' . $x . ', ' . $y . ']);' . "\n"; |
|
733 | + if (isset($y)) { |
|
734 | + $serie[$i] .= 'd' . $i . '.push([' . $x . ', ' . $y . ']);' . "\n"; |
|
735 | + } |
|
707 | 736 | } |
708 | 737 | } |
709 | 738 | |
@@ -713,7 +742,9 @@ discard block |
||
713 | 742 | $tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.')))); |
714 | 743 | |
715 | 744 | $this->stringtoshow = '<!-- Build using jflot -->' . "\n"; |
716 | - if (!empty($this->title)) $this->stringtoshow .= '<div class="center dolgraphtitle' . (empty($this->cssprefix) ? '' : ' dolgraphtitle' . $this->cssprefix) . '">' . $this->title . '</div>'; |
|
745 | + if (!empty($this->title)) { |
|
746 | + $this->stringtoshow .= '<div class="center dolgraphtitle' . (empty($this->cssprefix) ? '' : ' dolgraphtitle' . $this->cssprefix) . '">' . $this->title . '</div>'; |
|
747 | + } |
|
717 | 748 | if (!empty($this->shownographyet)) { |
718 | 749 | $this->stringtoshow .= '<div style="width:' . $this->width . 'px;height:' . $this->height . 'px;" class="nographyet"></div>'; |
719 | 750 | $this->stringtoshow .= '<div class="nographyettext margintoponly">' . $langs->trans("NotEnoughDataYet") . '...</div>'; |
@@ -722,7 +753,9 @@ discard block |
||
722 | 753 | |
723 | 754 | // Start the div that will contains all the graph |
724 | 755 | $dolxaxisvertical = ''; |
725 | - if (count($this->data) > 20) $dolxaxisvertical = 'dol-xaxis-vertical'; |
|
756 | + if (count($this->data) > 20) { |
|
757 | + $dolxaxisvertical = 'dol-xaxis-vertical'; |
|
758 | + } |
|
726 | 759 | $this->stringtoshow .= '<div id="placeholder_' . $tag . '" style="width:' . $this->width . 'px;height:' . $this->height . 'px;" class="dolgraph' . (empty($dolxaxisvertical) ? '' : ' ' . $dolxaxisvertical) . (empty($this->cssprefix) ? '' : ' dolgraph' . $this->cssprefix) . ' center"></div>' . "\n"; |
727 | 760 | |
728 | 761 | $this->stringtoshow .= '<script id="' . $tag . '">' . "\n"; |
@@ -743,8 +776,14 @@ discard block |
||
743 | 776 | if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) { |
744 | 777 | $datacolor = array(); |
745 | 778 | foreach ($this->datacolor as $val) { |
746 | - if (is_array($val)) $datacolor[] = "#" . sprintf("%02x%02x%02x", $val[0], $val[1], $val[2]); // If datacolor is array(R, G, B) |
|
747 | - else $datacolor[] = "#" . str_replace(array('#', '-'), '', $val); // If $val is '124' or '#124' |
|
779 | + if (is_array($val)) { |
|
780 | + $datacolor[] = "#" . sprintf("%02x%02x%02x", $val[0], $val[1], $val[2]); |
|
781 | + } |
|
782 | + // If datacolor is array(R, G, B) |
|
783 | + else { |
|
784 | + $datacolor[] = "#" . str_replace(array('#', '-'), '', $val); |
|
785 | + } |
|
786 | + // If $val is '124' or '#124' |
|
748 | 787 | } |
749 | 788 | |
750 | 789 | $urltemp = ''; // TODO Add support for url link into labels |
@@ -772,13 +811,17 @@ discard block |
||
772 | 811 | var number=series.data[0][1]; |
773 | 812 | return \''; |
774 | 813 | $this->stringtoshow .= '<span style="font-size:8pt;text-align:center;padding:2px;color:black;">'; |
775 | - if ($urltemp) $this->stringtoshow .= '<a style="color: #FFFFFF;" border="0" href="' . $urltemp . '">'; |
|
814 | + if ($urltemp) { |
|
815 | + $this->stringtoshow .= '<a style="color: #FFFFFF;" border="0" href="' . $urltemp . '">'; |
|
816 | + } |
|
776 | 817 | $this->stringtoshow .= '\'+'; |
777 | 818 | $this->stringtoshow .= ($showlegend ? '' : 'label+\' \'+'); // Hide label if already shown in legend |
778 | 819 | $this->stringtoshow .= ($showpointvalue ? 'number+' : ''); |
779 | 820 | $this->stringtoshow .= ($showpercent ? '\'<br/>\'+percent+\'%\'+' : ''); |
780 | 821 | $this->stringtoshow .= '\''; |
781 | - if ($urltemp) $this->stringtoshow .= '</a>'; |
|
822 | + if ($urltemp) { |
|
823 | + $this->stringtoshow .= '</a>'; |
|
824 | + } |
|
782 | 825 | $this->stringtoshow .= '</span>\'; |
783 | 826 | }, |
784 | 827 | background: { |
@@ -837,9 +880,11 @@ discard block |
||
837 | 880 | var y = item.datapoint[1].toFixed(2); |
838 | 881 | var z = item.series.xaxis.ticks[item.dataIndex].label; |
839 | 882 | '; |
840 | - if ($this->showpointvalue > 0) $this->stringtoshow .= ' |
|
883 | + if ($this->showpointvalue > 0) { |
|
884 | + $this->stringtoshow .= ' |
|
841 | 885 | showTooltip_' . $tag . '(item.pageX, item.pageY, item.series.label + "<br>" + z + " => " + y); |
842 | 886 | '; |
887 | + } |
|
843 | 888 | $this->stringtoshow .= ' |
844 | 889 | } |
845 | 890 | } |
@@ -856,18 +901,28 @@ discard block |
||
856 | 901 | $this->stringtoshow .= '$.plot($("#placeholder_' . $tag . '"), [ ' . "\n"; |
857 | 902 | $i = $firstlot; |
858 | 903 | while ($i < $nblot) { |
859 | - if ($i > $firstlot) $this->stringtoshow .= ', ' . "\n"; |
|
904 | + if ($i > $firstlot) { |
|
905 | + $this->stringtoshow .= ', ' . "\n"; |
|
906 | + } |
|
860 | 907 | $color = sprintf("%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]); |
861 | 908 | $this->stringtoshow .= '{ '; |
862 | 909 | if (!isset($this->type[$i]) || $this->type[$i] == 'bars') { |
863 | 910 | if ($nblot == 3) { |
864 | - if ($i == $firstlot) $align = 'right'; |
|
865 | - elseif ($i == $firstlot + 1) $align = 'center'; |
|
866 | - else $align = 'left'; |
|
911 | + if ($i == $firstlot) { |
|
912 | + $align = 'right'; |
|
913 | + } elseif ($i == $firstlot + 1) { |
|
914 | + $align = 'center'; |
|
915 | + } else { |
|
916 | + $align = 'left'; |
|
917 | + } |
|
867 | 918 | $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "' . $align . '", barWidth: 0.45 }, '; |
868 | - } else $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "' . ($i == $firstlot ? 'center' : 'left') . '", barWidth: 0.5 }, '; |
|
919 | + } else { |
|
920 | + $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "' . ($i == $firstlot ? 'center' : 'left') . '", barWidth: 0.5 }, '; |
|
921 | + } |
|
922 | + } |
|
923 | + if (isset($this->type[$i]) && ($this->type[$i] == 'lines' || $this->type[$i] == 'linesnopoint')) { |
|
924 | + $this->stringtoshow .= 'lines: { show: true, fill: false }, points: { show: ' . ($this->type[$i] == 'linesnopoint' ? 'false' : 'true') . ' }, '; |
|
869 | 925 | } |
870 | - if (isset($this->type[$i]) && ($this->type[$i] == 'lines' || $this->type[$i] == 'linesnopoint')) $this->stringtoshow .= 'lines: { show: true, fill: false }, points: { show: ' . ($this->type[$i] == 'linesnopoint' ? 'false' : 'true') . ' }, '; |
|
871 | 926 | $this->stringtoshow .= 'color: "#' . $color . '", label: "' . (isset($this->Legend[$i]) ? dol_escape_js($this->Legend[$i]) : '') . '", data: d' . $i . ' }'; |
872 | 927 | $i++; |
873 | 928 | } |
@@ -878,7 +933,9 @@ discard block |
||
878 | 933 | $this->stringtoshow .= ', xaxis: { ticks: [' . "\n"; |
879 | 934 | $x = 0; |
880 | 935 | foreach ($this->data as $key => $valarray) { |
881 | - if ($x > 0) $this->stringtoshow .= ', ' . "\n"; |
|
936 | + if ($x > 0) { |
|
937 | + $this->stringtoshow .= ', ' . "\n"; |
|
938 | + } |
|
882 | 939 | $this->stringtoshow .= ' [' . $x . ', "' . $valarray[0] . '"]'; |
883 | 940 | $x++; |
884 | 941 | } |
@@ -936,13 +993,18 @@ discard block |
||
936 | 993 | $legends = array(); |
937 | 994 | $nblot = 0; |
938 | 995 | if (is_array($this->data)) { |
939 | - foreach ($this->data as $valarray) // Loop on each x |
|
996 | + foreach ($this->data as $valarray) { |
|
997 | + // Loop on each x |
|
940 | 998 | { |
941 | - $nblot = max($nblot, count($valarray) - 1); // -1 to remove legend |
|
999 | + $nblot = max($nblot, count($valarray) - 1); |
|
1000 | + } |
|
1001 | + // -1 to remove legend |
|
942 | 1002 | } |
943 | 1003 | } |
944 | 1004 | //var_dump($nblot); |
945 | - if ($nblot < 0) dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING); |
|
1005 | + if ($nblot < 0) { |
|
1006 | + dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING); |
|
1007 | + } |
|
946 | 1008 | $firstlot = 0; |
947 | 1009 | // Works with line but not with bars |
948 | 1010 | //if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x |
@@ -952,16 +1014,21 @@ discard block |
||
952 | 1014 | //var_dump($this->data); |
953 | 1015 | |
954 | 1016 | $i = $firstlot; |
955 | - while ($i < $nblot) // Loop on each serie |
|
1017 | + while ($i < $nblot) { |
|
1018 | + // Loop on each serie |
|
956 | 1019 | { |
957 | - $values = array(); // Array with horizontal y values (specific values of a serie) for each abscisse x (with x=0,1,2,...) |
|
1020 | + $values = array(); |
|
1021 | + } |
|
1022 | + // Array with horizontal y values (specific values of a serie) for each abscisse x (with x=0,1,2,...) |
|
958 | 1023 | $serie[$i] = ""; |
959 | 1024 | |
960 | 1025 | // Fill array $values |
961 | 1026 | $x = 0; |
962 | - foreach ($this->data as $valarray) // Loop on each x |
|
1027 | + foreach ($this->data as $valarray) { |
|
1028 | + // Loop on each x |
|
963 | 1029 | { |
964 | 1030 | $legends[$x] = (array_key_exists('label', $valarray) ? $valarray['label'] : $valarray[0]); |
1031 | + } |
|
965 | 1032 | $array_of_ykeys = array_keys($valarray); |
966 | 1033 | $alabelexists = 1; |
967 | 1034 | $tmpykey = explode('_', ($array_of_ykeys[$i + ($alabelexists ? 1 : 0)]), 3); |
@@ -1000,7 +1067,9 @@ discard block |
||
1000 | 1067 | $tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.')))); |
1001 | 1068 | |
1002 | 1069 | $this->stringtoshow = '<!-- Build using chart -->' . "\n"; |
1003 | - if (!empty($this->title)) $this->stringtoshow .= '<div class="center dolgraphtitle' . (empty($this->cssprefix) ? '' : ' dolgraphtitle' . $this->cssprefix) . '">' . $this->title . '</div>'; |
|
1070 | + if (!empty($this->title)) { |
|
1071 | + $this->stringtoshow .= '<div class="center dolgraphtitle' . (empty($this->cssprefix) ? '' : ' dolgraphtitle' . $this->cssprefix) . '">' . $this->title . '</div>'; |
|
1072 | + } |
|
1004 | 1073 | if (!empty($this->shownographyet)) { |
1005 | 1074 | $this->stringtoshow .= '<div style="width:' . $this->width . (strpos($this->width, '%') > 0 ? '' : 'px') . '; height:' . $this->height . 'px;" class="nographyet"></div>'; |
1006 | 1075 | $this->stringtoshow .= '<div class="nographyettext margintoponly">' . $langs->trans("NotEnoughDataYet") . '...</div>'; |
@@ -1009,10 +1078,14 @@ discard block |
||
1009 | 1078 | |
1010 | 1079 | // Start the div that will contains all the graph |
1011 | 1080 | $dolxaxisvertical = ''; |
1012 | - if (count($this->data) > 20) $dolxaxisvertical = 'dol-xaxis-vertical'; |
|
1081 | + if (count($this->data) > 20) { |
|
1082 | + $dolxaxisvertical = 'dol-xaxis-vertical'; |
|
1083 | + } |
|
1013 | 1084 | // No height for the pie grah |
1014 | 1085 | $cssfordiv = 'dolgraphchart'; |
1015 | - if (isset($this->type[$firstlot])) $cssfordiv .= ' dolgraphchar' . $this->type[$firstlot]; |
|
1086 | + if (isset($this->type[$firstlot])) { |
|
1087 | + $cssfordiv .= ' dolgraphchar' . $this->type[$firstlot]; |
|
1088 | + } |
|
1016 | 1089 | $this->stringtoshow .= '<div id="placeholder_' . $tag . '" style="min-height: ' . $this->height . (strpos($this->height, '%') > 0 ? '' : 'px') . '; width:' . $this->width . (strpos($this->width, '%') > 0 ? '' : 'px') . ';" class="' . $cssfordiv . ' dolgraph' . (empty($dolxaxisvertical) ? '' : ' ' . $dolxaxisvertical) . (empty($this->cssprefix) ? '' : ' dolgraph' . $this->cssprefix) . ' center"><canvas id="canvas_' . $tag . '"></canvas></div>' . "\n"; |
1017 | 1090 | |
1018 | 1091 | $this->stringtoshow .= '<script id="' . $tag . '">' . "\n"; |
@@ -1052,16 +1125,24 @@ discard block |
||
1052 | 1125 | $this->stringtoshow .= 'backgroundColor: ['; |
1053 | 1126 | $i = 0; |
1054 | 1127 | $foundnegativecolor = 0; |
1055 | - foreach ($legends as $val) // Loop on each serie |
|
1128 | + foreach ($legends as $val) { |
|
1129 | + // Loop on each serie |
|
1056 | 1130 | { |
1057 | 1131 | if ($i > 0) $this->stringtoshow .= ', ' . "\n"; |
1058 | - if (is_array($this->datacolor[$i])) $color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ')'; // If datacolor is array(R, G, B) |
|
1132 | + } |
|
1133 | + if (is_array($this->datacolor[$i])) { |
|
1134 | + $color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ')'; |
|
1135 | + } |
|
1136 | + // If datacolor is array(R, G, B) |
|
1059 | 1137 | else { |
1060 | 1138 | $tmp = str_replace('#', '', $this->datacolor[$i]); |
1061 | 1139 | if (strpos($tmp, '-') !== false) { |
1062 | 1140 | $foundnegativecolor++; |
1063 | 1141 | $color = '#FFFFFF'; // If $val is '-123' |
1064 | - } else $color = "#" . $tmp; // If $val is '123' or '#123' |
|
1142 | + } else { |
|
1143 | + $color = "#" . $tmp; |
|
1144 | + } |
|
1145 | + // If $val is '123' or '#123' |
|
1065 | 1146 | } |
1066 | 1147 | $this->stringtoshow .= "'" . $color . "'"; |
1067 | 1148 | $i++; |
@@ -1071,14 +1152,25 @@ discard block |
||
1071 | 1152 | if ($foundnegativecolor) { |
1072 | 1153 | $this->stringtoshow .= 'borderColor: ['; |
1073 | 1154 | $i = 0; |
1074 | - foreach ($legends as $val) // Loop on each serie |
|
1155 | + foreach ($legends as $val) { |
|
1156 | + // Loop on each serie |
|
1075 | 1157 | { |
1076 | 1158 | if ($i > 0) $this->stringtoshow .= ', ' . "\n"; |
1077 | - if (is_array($this->datacolor[$i])) $color = 'null'; // If datacolor is array(R, G, B) |
|
1159 | + } |
|
1160 | + if (is_array($this->datacolor[$i])) { |
|
1161 | + $color = 'null'; |
|
1162 | + } |
|
1163 | + // If datacolor is array(R, G, B) |
|
1078 | 1164 | else { |
1079 | 1165 | $tmp = str_replace('#', '', $this->datacolor[$i]); |
1080 | - if (strpos($tmp, '-') !== false) $color = '#' . str_replace('-', '', $tmp); // If $val is '-123' |
|
1081 | - else $color = 'null'; // If $val is '123' or '#123' |
|
1166 | + if (strpos($tmp, '-') !== false) { |
|
1167 | + $color = '#' . str_replace('-', '', $tmp); |
|
1168 | + } |
|
1169 | + // If $val is '-123' |
|
1170 | + else { |
|
1171 | + $color = 'null'; |
|
1172 | + } |
|
1173 | + // If $val is '123' or '#123' |
|
1082 | 1174 | } |
1083 | 1175 | $this->stringtoshow .= ($color == 'null' ? "'rgba(0,0,0,0.2)'" : "'" . $color . "'"); |
1084 | 1176 | $i++; |
@@ -1098,9 +1190,11 @@ discard block |
||
1098 | 1190 | labels: ['; |
1099 | 1191 | |
1100 | 1192 | $i = 0; |
1101 | - foreach ($legends as $val) // Loop on each serie |
|
1193 | + foreach ($legends as $val) { |
|
1194 | + // Loop on each serie |
|
1102 | 1195 | { |
1103 | 1196 | if ($i > 0) $this->stringtoshow .= ', '; |
1197 | + } |
|
1104 | 1198 | $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 32)) . "'"; |
1105 | 1199 | $i++; |
1106 | 1200 | } |
@@ -1109,12 +1203,16 @@ discard block |
||
1109 | 1203 | datasets: ['; |
1110 | 1204 | $i = 0; |
1111 | 1205 | $i = 0; |
1112 | - while ($i < $nblot) // Loop on each serie |
|
1206 | + while ($i < $nblot) { |
|
1207 | + // Loop on each serie |
|
1113 | 1208 | { |
1114 | 1209 | $color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ')'; |
1210 | + } |
|
1115 | 1211 | //$color = (!empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor)); |
1116 | 1212 | |
1117 | - if ($i > 0) $this->stringtoshow .= ', ' . "\n"; |
|
1213 | + if ($i > 0) { |
|
1214 | + $this->stringtoshow .= ', ' . "\n"; |
|
1215 | + } |
|
1118 | 1216 | $this->stringtoshow .= '{' . "\n"; |
1119 | 1217 | //$this->stringtoshow .= 'borderColor: \''.$color.'\', '; |
1120 | 1218 | //$this->stringtoshow .= 'backgroundColor: \''.$color.'\', '; |
@@ -1131,11 +1229,19 @@ discard block |
||
1131 | 1229 | $type = 'bar'; |
1132 | 1230 | |
1133 | 1231 | $isfunnel = false; |
1134 | - if ($file == 'idgraphleadfunnel') $isfunnel = true; |
|
1232 | + if ($file == 'idgraphleadfunnel') { |
|
1233 | + $isfunnel = true; |
|
1234 | + } |
|
1135 | 1235 | |
1136 | - if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') $type = 'bar'; |
|
1137 | - if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'horizontalbars') $type = 'horizontalBar'; |
|
1138 | - if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$firstlot] == 'linesnopoint')) $type = 'line'; |
|
1236 | + if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') { |
|
1237 | + $type = 'bar'; |
|
1238 | + } |
|
1239 | + if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'horizontalbars') { |
|
1240 | + $type = 'horizontalBar'; |
|
1241 | + } |
|
1242 | + if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$firstlot] == 'linesnopoint')) { |
|
1243 | + $type = 'line'; |
|
1244 | + } |
|
1139 | 1245 | |
1140 | 1246 | $this->stringtoshow .= 'var options = { maintainAspectRatio: false, aspectRatio: 2.5, '; |
1141 | 1247 | if (empty($showlegend)) { |
@@ -1181,9 +1287,11 @@ discard block |
||
1181 | 1287 | |
1182 | 1288 | $i = 0; |
1183 | 1289 | if (!$isfunnel) { |
1184 | - foreach ($legends as $val) // Loop on each serie |
|
1290 | + foreach ($legends as $val) { |
|
1291 | + // Loop on each serie |
|
1185 | 1292 | { |
1186 | 1293 | if ($i > 0) $this->stringtoshow .= ', '; |
1294 | + } |
|
1187 | 1295 | $this->stringtoshow .= "'".dol_escape_js(dol_trunc($val, 32))."'"; |
1188 | 1296 | $i++; |
1189 | 1297 | } |
@@ -1198,9 +1306,11 @@ discard block |
||
1198 | 1306 | //var_dump($arrayofgroupslegend); |
1199 | 1307 | $i = 0; $iinstack = 0; |
1200 | 1308 | $oldstacknum = -1; |
1201 | - while ($i < $nblot) // Loop on each serie |
|
1309 | + while ($i < $nblot) { |
|
1310 | + // Loop on each serie |
|
1202 | 1311 | { |
1203 | 1312 | $foundnegativecolor = 0; |
1313 | + } |
|
1204 | 1314 | $usecolorvariantforgroupby = 0; |
1205 | 1315 | // We used a 'group by' and we have too many colors so we generated color variants per |
1206 | 1316 | if (is_array($arrayofgroupslegend[$i]) && count($arrayofgroupslegend[$i]) > 0) { // If we used a group by. |
@@ -1255,11 +1365,20 @@ discard block |
||
1255 | 1365 | $bordercolor = $color; |
1256 | 1366 | } |
1257 | 1367 | if ($foundnegativecolor) { |
1258 | - if (is_array($this->datacolor[$i])) $color = 'null'; // If datacolor is array(R, G, B) |
|
1368 | + if (is_array($this->datacolor[$i])) { |
|
1369 | + $color = 'null'; |
|
1370 | + } |
|
1371 | + // If datacolor is array(R, G, B) |
|
1259 | 1372 | else { |
1260 | 1373 | $tmp = str_replace('#', '', $this->datacolor[$i]); |
1261 | - if (strpos($tmp, '-') !== false) $bordercolor = '#' . str_replace('-', '', $tmp); // If $val is '-123' |
|
1262 | - else $bordercolor = 'null'; // If $val is '123' or '#123' |
|
1374 | + if (strpos($tmp, '-') !== false) { |
|
1375 | + $bordercolor = '#' . str_replace('-', '', $tmp); |
|
1376 | + } |
|
1377 | + // If $val is '-123' |
|
1378 | + else { |
|
1379 | + $bordercolor = 'null'; |
|
1380 | + } |
|
1381 | + // If $val is '123' or '#123' |
|
1263 | 1382 | } |
1264 | 1383 | $bordercolor == 'null' ? "'rgba(0,0,0,0.2)'" : "'" . $bordercolor . "'"; |
1265 | 1384 | } |
@@ -1271,7 +1390,9 @@ discard block |
||
1271 | 1390 | } |
1272 | 1391 | } |
1273 | 1392 | |
1274 | - if ($i > 0) $this->stringtoshow .= ', '; |
|
1393 | + if ($i > 0) { |
|
1394 | + $this->stringtoshow .= ', '; |
|
1395 | + } |
|
1275 | 1396 | $this->stringtoshow .= "\n"; |
1276 | 1397 | $this->stringtoshow .= '{'; |
1277 | 1398 | $this->stringtoshow .= 'dolibarrinfo: \'y_' . $i . '\', '; |
@@ -1285,7 +1406,9 @@ discard block |
||
1285 | 1406 | } |
1286 | 1407 | $this->stringtoshow .= 'borderColor: \'' . $bordercolor . '\', '; |
1287 | 1408 | $this->stringtoshow .= 'backgroundColor: \'' . $color . '\', '; |
1288 | - if ($arrayofgroupslegend[$i]) $this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', '; |
|
1409 | + if ($arrayofgroupslegend[$i]) { |
|
1410 | + $this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', '; |
|
1411 | + } |
|
1289 | 1412 | $this->stringtoshow .='data: ['; |
1290 | 1413 | if ($isfunnel) { |
1291 | 1414 | $this->stringtoshow .= '['.-$serie[$i].','.$serie[$i].']'; |
@@ -1315,10 +1438,12 @@ discard block |
||
1315 | 1438 | public function total() |
1316 | 1439 | { |
1317 | 1440 | $value = 0; |
1318 | - foreach ($this->data as $valarray) // Loop on each x |
|
1441 | + foreach ($this->data as $valarray) { |
|
1442 | + // Loop on each x |
|
1319 | 1443 | { |
1320 | 1444 | $value += $valarray[1]; |
1321 | 1445 | } |
1446 | + } |
|
1322 | 1447 | return $value; |
1323 | 1448 | } |
1324 | 1449 | |
@@ -1361,8 +1486,11 @@ discard block |
||
1361 | 1486 | |
1362 | 1487 | if ($direction == 'width') |
1363 | 1488 | { |
1364 | - if (empty($conf->dol_optimize_smallscreen)) return ($defaultsize ? $defaultsize : '500'); |
|
1365 | - else return (empty($_SESSION['dol_screen_width']) ? '280' : ($_SESSION['dol_screen_width'] - 40)); |
|
1489 | + if (empty($conf->dol_optimize_smallscreen)) { |
|
1490 | + return ($defaultsize ? $defaultsize : '500'); |
|
1491 | + } else { |
|
1492 | + return (empty($_SESSION['dol_screen_width']) ? '280' : ($_SESSION['dol_screen_width'] - 40)); |
|
1493 | + } |
|
1366 | 1494 | } |
1367 | 1495 | if ($direction == 'height') |
1368 | 1496 | { |
@@ -70,16 +70,23 @@ discard block |
||
70 | 70 | $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); |
71 | 71 | |
72 | 72 | // Default sort order (if not yet defined by previous GETPOST) |
73 | -if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. |
|
74 | -if (!$sortorder) $sortorder = "ASC"; |
|
73 | +if (!$sortfield) { |
|
74 | + $sortfield = "t.".key($object->fields); |
|
75 | +} |
|
76 | +// Set here default search field. By default 1st field in definition. |
|
77 | +if (!$sortorder) { |
|
78 | + $sortorder = "ASC"; |
|
79 | +} |
|
75 | 80 | |
76 | 81 | // Security check |
77 | 82 | $socid = 0; |
78 | -if ($user->socid > 0) // Protection if external user |
|
83 | +if ($user->socid > 0) { |
|
84 | + // Protection if external user |
|
79 | 85 | { |
80 | 86 | //$socid = $user->socid; |
81 | 87 | accessforbidden(); |
82 | 88 | } |
89 | +} |
|
83 | 90 | //$result = restrictedArea($user, 'emailcollector', $id, ''); |
84 | 91 | |
85 | 92 | // Initialize array of search criterias |
@@ -87,15 +94,19 @@ discard block |
||
87 | 94 | $search = array(); |
88 | 95 | foreach ($object->fields as $key => $val) |
89 | 96 | { |
90 | - if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); |
|
91 | -} |
|
97 | + if (GETPOST('search_'.$key, 'alpha') !== '') { |
|
98 | + $search[$key] = GETPOST('search_'.$key, 'alpha'); |
|
99 | + } |
|
100 | + } |
|
92 | 101 | |
93 | 102 | // List of fields to search into when doing a "search in all" |
94 | 103 | $fieldstosearchall = array(); |
95 | 104 | foreach ($object->fields as $key => $val) |
96 | 105 | { |
97 | - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; |
|
98 | -} |
|
106 | + if ($val['searchall']) { |
|
107 | + $fieldstosearchall['t.'.$key] = $val['label']; |
|
108 | + } |
|
109 | + } |
|
99 | 110 | |
100 | 111 | // Definition of array of fields for columns |
101 | 112 | $arrayfields = array(); |
@@ -138,8 +149,12 @@ discard block |
||
138 | 149 | $permissiontoadd = $user->admin; |
139 | 150 | $permissiontodelete = $user->admin; |
140 | 151 | |
141 | -if (!$user->admin) accessforbidden(); |
|
142 | -if (empty($conf->emailcollector->enabled)) accessforbidden('Module not enabled'); |
|
152 | +if (!$user->admin) { |
|
153 | + accessforbidden(); |
|
154 | +} |
|
155 | +if (empty($conf->emailcollector->enabled)) { |
|
156 | + accessforbidden('Module not enabled'); |
|
157 | +} |
|
143 | 158 | |
144 | 159 | |
145 | 160 | |
@@ -152,7 +167,9 @@ discard block |
||
152 | 167 | |
153 | 168 | $parameters = array(); |
154 | 169 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
155 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
170 | +if ($reshook < 0) { |
|
171 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
172 | +} |
|
156 | 173 | |
157 | 174 | if (empty($reshook)) |
158 | 175 | { |
@@ -160,11 +177,13 @@ discard block |
||
160 | 177 | include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
161 | 178 | |
162 | 179 | // Purge search criteria |
163 | - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers |
|
180 | + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { |
|
181 | + // All tests are required to be compatible with all browsers |
|
164 | 182 | { |
165 | 183 | foreach ($object->fields as $key => $val) |
166 | 184 | { |
167 | 185 | $search[$key] = ''; |
186 | + } |
|
168 | 187 | } |
169 | 188 | $toselect = ''; |
170 | 189 | $search_array_options = array(); |
@@ -203,28 +222,43 @@ discard block |
||
203 | 222 | } |
204 | 223 | // Add fields from extrafields |
205 | 224 | if (!empty($extrafields->attributes[$object->table_element]['label'])) { |
206 | - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); |
|
207 | -} |
|
225 | + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { |
|
226 | + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); |
|
227 | + } |
|
228 | + } |
|
208 | 229 | // Add fields from hooks |
209 | 230 | $parameters = array(); |
210 | 231 | $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook |
211 | 232 | $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); |
212 | 233 | $sql = preg_replace('/,\s*$/', '', $sql); |
213 | 234 | $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; |
214 | -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; |
|
215 | -if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; |
|
216 | -else $sql .= " WHERE 1 = 1"; |
|
235 | +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { |
|
236 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; |
|
237 | +} |
|
238 | +if ($object->ismultientitymanaged == 1) { |
|
239 | + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; |
|
240 | +} else { |
|
241 | + $sql .= " WHERE 1 = 1"; |
|
242 | +} |
|
217 | 243 | foreach ($search as $key => $val) |
218 | 244 | { |
219 | - if ($key == 'status' && $search[$key] == -1) continue; |
|
245 | + if ($key == 'status' && $search[$key] == -1) { |
|
246 | + continue; |
|
247 | + } |
|
220 | 248 | $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); |
221 | 249 | if (strpos($object->fields[$key]['type'], 'integer:') === 0) { |
222 | - if ($search[$key] == '-1') $search[$key] = ''; |
|
250 | + if ($search[$key] == '-1') { |
|
251 | + $search[$key] = ''; |
|
252 | + } |
|
223 | 253 | $mode_search = 2; |
224 | 254 | } |
225 | - if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); |
|
255 | + if ($search[$key] != '') { |
|
256 | + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); |
|
257 | + } |
|
258 | + } |
|
259 | +if ($search_all) { |
|
260 | + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); |
|
226 | 261 | } |
227 | -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); |
|
228 | 262 | // Add where from extra fields |
229 | 263 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; |
230 | 264 | // Add where from hooks |
@@ -257,9 +291,11 @@ discard block |
||
257 | 291 | { |
258 | 292 | $resql = $db->query($sql); |
259 | 293 | $nbtotalofrecords = $db->num_rows($resql); |
260 | - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 |
|
294 | + if (($page * $limit) > $nbtotalofrecords) { |
|
295 | + // if total of record found is smaller than page * limit, goto and load page 0 |
|
261 | 296 | { |
262 | 297 | $page = 0; |
298 | + } |
|
263 | 299 | $offset = 0; |
264 | 300 | } |
265 | 301 | } |
@@ -268,7 +304,9 @@ discard block |
||
268 | 304 | { |
269 | 305 | $num = $nbtotalofrecords; |
270 | 306 | } else { |
271 | - if ($limit) $sql .= $db->plimit($limit + 1, $offset); |
|
307 | + if ($limit) { |
|
308 | + $sql .= $db->plimit($limit + 1, $offset); |
|
309 | + } |
|
272 | 310 | |
273 | 311 | $resql = $db->query($sql); |
274 | 312 | if (!$resql) |
@@ -313,14 +351,23 @@ discard block |
||
313 | 351 | $arrayofselected = is_array($toselect) ? $toselect : array(); |
314 | 352 | |
315 | 353 | $param = ''; |
316 | -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); |
|
317 | -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); |
|
354 | +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { |
|
355 | + $param .= '&contextpage='.urlencode($contextpage); |
|
356 | +} |
|
357 | +if ($limit > 0 && $limit != $conf->liste_limit) { |
|
358 | + $param .= '&limit='.urlencode($limit); |
|
359 | +} |
|
318 | 360 | foreach ($search as $key => $val) |
319 | 361 | { |
320 | - if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); |
|
321 | - else $param .= '&search_'.$key.'='.urlencode($search[$key]); |
|
362 | + if (is_array($search[$key]) && count($search[$key])) { |
|
363 | + foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); |
|
364 | + } else { |
|
365 | + $param .= '&search_'.$key.'='.urlencode($search[$key]); |
|
366 | + } |
|
367 | + } |
|
368 | +if ($optioncss != '') { |
|
369 | + $param .= '&optioncss='.urlencode($optioncss); |
|
322 | 370 | } |
323 | -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); |
|
324 | 371 | // Add $param from extra fields |
325 | 372 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
326 | 373 | |
@@ -329,12 +376,18 @@ discard block |
||
329 | 376 | //'presend'=>$langs->trans("SendByMail"), |
330 | 377 | //'builddoc'=>$langs->trans("PDFMerge"), |
331 | 378 | ); |
332 | -if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); |
|
333 | -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); |
|
379 | +if ($permissiontodelete) { |
|
380 | + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); |
|
381 | +} |
|
382 | +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { |
|
383 | + $arrayofmassactions = array(); |
|
384 | +} |
|
334 | 385 | $massactionbutton = $form->selectMassAction('', $arrayofmassactions); |
335 | 386 | |
336 | 387 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; |
337 | -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
388 | +if ($optioncss != '') { |
|
389 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
390 | +} |
|
338 | 391 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
339 | 392 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
340 | 393 | print '<input type="hidden" name="action" value="list">'; |
@@ -363,8 +416,11 @@ discard block |
||
363 | 416 | |
364 | 417 | $parameters = array(); |
365 | 418 | $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook |
366 | -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; |
|
367 | -else $moreforfilter = $hookmanager->resPrint; |
|
419 | +if (empty($reshook)) { |
|
420 | + $moreforfilter .= $hookmanager->resPrint; |
|
421 | +} else { |
|
422 | + $moreforfilter = $hookmanager->resPrint; |
|
423 | +} |
|
368 | 424 | |
369 | 425 | if (!empty($moreforfilter)) |
370 | 426 | { |
@@ -387,17 +443,25 @@ discard block |
||
387 | 443 | foreach ($object->fields as $key => $val) |
388 | 444 | { |
389 | 445 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
390 | - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
391 | - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
392 | - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
393 | - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
446 | + if ($key == 'status') { |
|
447 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
448 | + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
449 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
450 | + } elseif (in_array($val['type'], array('timestamp'))) { |
|
451 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
452 | + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { |
|
453 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
454 | + } |
|
394 | 455 | if (!empty($arrayfields['t.'.$key]['checked'])) |
395 | 456 | { |
396 | 457 | print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; |
397 | - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); |
|
398 | - elseif (strpos($val['type'], 'integer:') === 0) { |
|
458 | + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { |
|
459 | + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); |
|
460 | + } elseif (strpos($val['type'], 'integer:') === 0) { |
|
399 | 461 | print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); |
400 | - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; |
|
462 | + } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { |
|
463 | + print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; |
|
464 | + } |
|
401 | 465 | print '</td>'; |
402 | 466 | } |
403 | 467 | } |
@@ -422,10 +486,15 @@ discard block |
||
422 | 486 | foreach ($object->fields as $key => $val) |
423 | 487 | { |
424 | 488 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
425 | - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
426 | - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
427 | - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
428 | - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
489 | + if ($key == 'status') { |
|
490 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
491 | + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
492 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
493 | + } elseif (in_array($val['type'], array('timestamp'))) { |
|
494 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
495 | + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { |
|
496 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
497 | + } |
|
429 | 498 | if (!empty($arrayfields['t.'.$key]['checked'])) |
430 | 499 | { |
431 | 500 | print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; |
@@ -448,7 +517,10 @@ discard block |
||
448 | 517 | { |
449 | 518 | foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) |
450 | 519 | { |
451 | - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object |
|
520 | + if (preg_match('/\$object/', $val)) { |
|
521 | + $needToFetchEachLine++; |
|
522 | + } |
|
523 | + // There is at least one compute field that use $object |
|
452 | 524 | } |
453 | 525 | } |
454 | 526 | |
@@ -460,7 +532,10 @@ discard block |
||
460 | 532 | while ($i < ($limit ? min($num, $limit) : $num)) |
461 | 533 | { |
462 | 534 | $obj = $db->fetch_object($resql); |
463 | - if (empty($obj)) break; // Should not happen |
|
535 | + if (empty($obj)) { |
|
536 | + break; |
|
537 | + } |
|
538 | + // Should not happen |
|
464 | 539 | |
465 | 540 | // Store properties in $object |
466 | 541 | $object->setVarsFromFetchObj($obj); |
@@ -470,25 +545,40 @@ discard block |
||
470 | 545 | foreach ($object->fields as $key => $val) |
471 | 546 | { |
472 | 547 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
473 | - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
474 | - elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
548 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
549 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
550 | + } elseif ($key == 'status') { |
|
551 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
552 | + } |
|
475 | 553 | |
476 | - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
477 | - elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
554 | + if (in_array($val['type'], array('timestamp'))) { |
|
555 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
556 | + } elseif ($key == 'ref') { |
|
557 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
558 | + } |
|
478 | 559 | |
479 | - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
560 | + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) { |
|
561 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
562 | + } |
|
480 | 563 | //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; |
481 | 564 | |
482 | 565 | if (!empty($arrayfields['t.'.$key]['checked'])) |
483 | 566 | { |
484 | 567 | print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; |
485 | - if ($key == 'status') print $object->getLibStatut(5); |
|
486 | - else print $object->showOutputField($val, $key, $object->$key, ''); |
|
568 | + if ($key == 'status') { |
|
569 | + print $object->getLibStatut(5); |
|
570 | + } else { |
|
571 | + print $object->showOutputField($val, $key, $object->$key, ''); |
|
572 | + } |
|
487 | 573 | print '</td>'; |
488 | - if (!$i) $totalarray['nbfield']++; |
|
574 | + if (!$i) { |
|
575 | + $totalarray['nbfield']++; |
|
576 | + } |
|
489 | 577 | if (!empty($val['isameasure'])) |
490 | 578 | { |
491 | - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; |
|
579 | + if (!$i) { |
|
580 | + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; |
|
581 | + } |
|
492 | 582 | $totalarray['val']['t.'.$key] += $object->$key; |
493 | 583 | } |
494 | 584 | } |
@@ -501,14 +591,20 @@ discard block |
||
501 | 591 | print $hookmanager->resPrint; |
502 | 592 | // Action column |
503 | 593 | print '<td class="nowrap center">'; |
504 | - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
|
594 | + if ($massactionbutton || $massaction) { |
|
595 | + // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
|
505 | 596 | { |
506 | 597 | $selected = 0; |
507 | - if (in_array($object->id, $arrayofselected)) $selected = 1; |
|
598 | + } |
|
599 | + if (in_array($object->id, $arrayofselected)) { |
|
600 | + $selected = 1; |
|
601 | + } |
|
508 | 602 | print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>'; |
509 | 603 | } |
510 | 604 | print '</td>'; |
511 | - if (!$i) $totalarray['nbfield']++; |
|
605 | + if (!$i) { |
|
606 | + $totalarray['nbfield']++; |
|
607 | + } |
|
512 | 608 | |
513 | 609 | print '</tr>'."\n"; |
514 | 610 | |
@@ -523,7 +619,10 @@ discard block |
||
523 | 619 | if ($num == 0) |
524 | 620 | { |
525 | 621 | $colspan = 1; |
526 | - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } |
|
622 | + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { |
|
623 | + $colspan++; |
|
624 | + } |
|
625 | + } |
|
527 | 626 | print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
528 | 627 | } |
529 | 628 | |
@@ -542,7 +641,9 @@ discard block |
||
542 | 641 | if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) |
543 | 642 | { |
544 | 643 | $hidegeneratedfilelistifempty = 1; |
545 | - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; |
|
644 | + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { |
|
645 | + $hidegeneratedfilelistifempty = 0; |
|
646 | + } |
|
546 | 647 | |
547 | 648 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
548 | 649 | $formfile = new FormFile($db); |