Passed
Branch develop (66e4de)
by Laurent
33:03
created
htdocs/core/class/dolgraph.class.php 2 patches
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		$this->datacolor = array(array(120, 130, 150), array(160, 160, 180), array(190, 190, 220));
104 104
 		$this->bgcolor = array(235, 235, 224);
105 105
 
106
-		$color_file = DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php';
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 109
 			if (isset($theme_bordercolor)) $this->bordercolor = $theme_bordercolor;
@@ -626,19 +626,19 @@  discard block
 block discarded – undo
626 626
 	{
627 627
 		if (empty($file)) {
628 628
 			$this->error = "Call to draw method was made with empty value for parameter file.";
629
-			dol_syslog(get_class($this) . "::draw " . $this->error, LOG_ERR);
629
+			dol_syslog(get_class($this)."::draw ".$this->error, LOG_ERR);
630 630
 			return -2;
631 631
 		}
632 632
 		if (!is_array($this->data)) {
633 633
 			$this->error = "Call to draw method was made but SetData was not called or called with an empty dataset for parameters";
634
-			dol_syslog(get_class($this) . "::draw " . $this->error, LOG_ERR);
634
+			dol_syslog(get_class($this)."::draw ".$this->error, LOG_ERR);
635 635
 			return -1;
636 636
 		}
637 637
 		if (count($this->data) < 1) {
638 638
 			$this->error = "Call to draw method was made but SetData was is an empty dataset";
639
-			dol_syslog(get_class($this) . "::draw " . $this->error, LOG_WARNING);
639
+			dol_syslog(get_class($this)."::draw ".$this->error, LOG_WARNING);
640 640
 		}
641
-		$call = "draw_" . $this->_library;
641
+		$call = "draw_".$this->_library;
642 642
 		call_user_func_array(array($this, $call), array($file, $fileurl));
643 643
 	}
644 644
 
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 		// phpcs:enable
665 665
 		global $conf, $langs;
666 666
 
667
-		dol_syslog(get_class($this) . "::draw_jflot this->type=" . join(',', $this->type) . " this->MaxValue=" . $this->MaxValue);
667
+		dol_syslog(get_class($this)."::draw_jflot this->type=".join(',', $this->type)." this->MaxValue=".$this->MaxValue);
668 668
 
669 669
 		if (empty($this->width) && empty($this->height)) {
670 670
 			print 'Error width or height not set';
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 		while ($i < $nblot)	// Loop on each serie
687 687
 		{
688 688
 			$values = array(); // Array with horizontal y values (specific values of a serie) for each abscisse x
689
-			$serie[$i] = "var d" . $i . " = [];\n";
689
+			$serie[$i] = "var d".$i." = [];\n";
690 690
 
691 691
 			// Fill array $values
692 692
 			$x = 0;
@@ -699,11 +699,11 @@  discard block
 block discarded – undo
699 699
 
700 700
 			if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) {
701 701
 				foreach ($values as $x => $y) {
702
-					if (isset($y)) $serie[$i] .= 'd' . $i . '.push({"label":"' . dol_escape_js($legends[$x]) . '", "data":' . $y . '});' . "\n";
702
+					if (isset($y)) $serie[$i] .= 'd'.$i.'.push({"label":"'.dol_escape_js($legends[$x]).'", "data":'.$y.'});'."\n";
703 703
 				}
704 704
 			} else {
705 705
 				foreach ($values as $x => $y) {
706
-					if (isset($y)) $serie[$i] .= 'd' . $i . '.push([' . $x . ', ' . $y . ']);' . "\n";
706
+					if (isset($y)) $serie[$i] .= 'd'.$i.'.push(['.$x.', '.$y.']);'."\n";
707 707
 				}
708 708
 			}
709 709
 
@@ -712,28 +712,28 @@  discard block
 block discarded – undo
712 712
 		}
713 713
 		$tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.'))));
714 714
 
715
-		$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>';
715
+		$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>';
717 717
 		if (!empty($this->shownographyet)) {
718
-			$this->stringtoshow .= '<div style="width:' . $this->width . 'px;height:' . $this->height . 'px;" class="nographyet"></div>';
719
-			$this->stringtoshow .= '<div class="nographyettext margintoponly">' . $langs->trans("NotEnoughDataYet") . '...</div>';
718
+			$this->stringtoshow .= '<div style="width:'.$this->width.'px;height:'.$this->height.'px;" class="nographyet"></div>';
719
+			$this->stringtoshow .= '<div class="nographyettext margintoponly">'.$langs->trans("NotEnoughDataYet").'...</div>';
720 720
 			return;
721 721
 		}
722 722
 
723 723
 		// Start the div that will contains all the graph
724 724
 		$dolxaxisvertical = '';
725 725
 		if (count($this->data) > 20) $dolxaxisvertical = 'dol-xaxis-vertical';
726
-		$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";
726
+		$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 727
 
728
-		$this->stringtoshow .= '<script id="' . $tag . '">' . "\n";
729
-		$this->stringtoshow .= '$(function () {' . "\n";
728
+		$this->stringtoshow .= '<script id="'.$tag.'">'."\n";
729
+		$this->stringtoshow .= '$(function () {'."\n";
730 730
 		$i = $firstlot;
731 731
 		if ($nblot < 0) {
732
-			$this->stringtoshow .= '<!-- No series of data -->' . "\n";
732
+			$this->stringtoshow .= '<!-- No series of data -->'."\n";
733 733
 		} else {
734 734
 			while ($i < $nblot) {
735
-				$this->stringtoshow .= '<!-- Serie ' . $i . ' -->' . "\n";
736
-				$this->stringtoshow .= $serie[$i] . "\n";
735
+				$this->stringtoshow .= '<!-- Serie '.$i.' -->'."\n";
736
+				$this->stringtoshow .= $serie[$i]."\n";
737 737
 				$i++;
738 738
 			}
739 739
 		}
@@ -743,8 +743,8 @@  discard block
 block discarded – undo
743 743
 		if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) {
744 744
 			$datacolor = array();
745 745
 			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'
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'
748 748
 			}
749 749
 
750 750
 			$urltemp = ''; // TODO Add support for url link into labels
@@ -753,8 +753,8 @@  discard block
 block discarded – undo
753 753
 			$showpercent = $this->showpercent;
754 754
 
755 755
 			$this->stringtoshow .= '
756
-			function plotWithOptions_' . $tag . '() {
757
-			$.plot($("#placeholder_' . $tag . '"), d0,
756
+			function plotWithOptions_' . $tag.'() {
757
+			$.plot($("#placeholder_' . $tag.'"), d0,
758 758
 			{
759 759
 				series: {
760 760
 					pie: {
@@ -762,8 +762,8 @@  discard block
 block discarded – undo
762 762
 						radius: 0.8,
763 763
 						' . ($this->combine ? '
764 764
 						combine: {
765
-						 	threshold: ' . $this->combine . '
766
-						},' : '') . '
765
+						 	threshold: ' . $this->combine.'
766
+						},' : '').'
767 767
 						label: {
768 768
 							show: true,
769 769
 							radius: 0.9,
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 								var number=series.data[0][1];
773 773
 								return \'';
774 774
 			$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 . '">';
775
+			if ($urltemp) $this->stringtoshow .= '<a style="color: #FFFFFF;" border="0" href="'.$urltemp.'">';
776 776
 			$this->stringtoshow .= '\'+';
777 777
 			$this->stringtoshow .= ($showlegend ? '' : 'label+\' \'+'); // Hide label if already shown in legend
778 778
 			$this->stringtoshow .= ($showpointvalue ? 'number+' : '');
@@ -795,9 +795,9 @@  discard block
 block discarded – undo
795 795
 				interactive: true
796 796
 			},';
797 797
 			if (count($datacolor)) {
798
-				$this->stringtoshow .= 'colors: ' . (!empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor)) . ',';
798
+				$this->stringtoshow .= 'colors: '.(!empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor)).',';
799 799
 			}
800
-			$this->stringtoshow .= 'legend: {show: ' . ($showlegend ? 'true' : 'false') . ', position: \'ne\' }
800
+			$this->stringtoshow .= 'legend: {show: '.($showlegend ? 'true' : 'false').', position: \'ne\' }
801 801
 		});
802 802
 		}' . "\n";
803 803
 		}
@@ -806,8 +806,8 @@  discard block
 block discarded – undo
806 806
 			// Add code to support tooltips
807 807
 			// TODO: remove js css and use graph-tooltip-inner class instead by adding css in each themes
808 808
 			$this->stringtoshow .= '
809
-			function showTooltip_' . $tag . '(x, y, contents) {
810
-				$(\'<div class="graph-tooltip-inner" id="tooltip_' . $tag . '">\' + contents + \'</div>\').css({
809
+			function showTooltip_' . $tag.'(x, y, contents) {
810
+				$(\'<div class="graph-tooltip-inner" id="tooltip_' . $tag.'">\' + contents + \'</div>\').css({
811 811
 					position: \'absolute\',
812 812
 					display: \'none\',
813 813
 					top: y + 10,
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 			}
824 824
 
825 825
 			var previousPoint = null;
826
-			$("#placeholder_' . $tag . '").bind("plothover", function (event, pos, item) {
826
+			$("#placeholder_' . $tag.'").bind("plothover", function (event, pos, item) {
827 827
 				$("#x").text(pos.x.toFixed(2));
828 828
 				$("#y").text(pos.y.toFixed(2));
829 829
 
@@ -838,25 +838,25 @@  discard block
 block discarded – undo
838 838
 						var z = item.series.xaxis.ticks[item.dataIndex].label;
839 839
 						';
840 840
 			if ($this->showpointvalue > 0) $this->stringtoshow .= '
841
-							showTooltip_' . $tag . '(item.pageX, item.pageY, item.series.label + "<br>" + z + " => " + y);
841
+							showTooltip_' . $tag.'(item.pageX, item.pageY, item.series.label + "<br>" + z + " => " + y);
842 842
 						';
843 843
 			$this->stringtoshow .= '
844 844
 					}
845 845
 				}
846 846
 				else {
847
-					$("#tooltip_' . $tag . '").remove();
847
+					$("#tooltip_' . $tag.'").remove();
848 848
 					previousPoint = null;
849 849
 				}
850 850
 			});
851 851
 			';
852 852
 
853
-			$this->stringtoshow .= 'var stack = null, steps = false;' . "\n";
853
+			$this->stringtoshow .= 'var stack = null, steps = false;'."\n";
854 854
 
855
-			$this->stringtoshow .= 'function plotWithOptions_' . $tag . '() {' . "\n";
856
-			$this->stringtoshow .= '$.plot($("#placeholder_' . $tag . '"), [ ' . "\n";
855
+			$this->stringtoshow .= 'function plotWithOptions_'.$tag.'() {'."\n";
856
+			$this->stringtoshow .= '$.plot($("#placeholder_'.$tag.'"), [ '."\n";
857 857
 			$i = $firstlot;
858 858
 			while ($i < $nblot) {
859
-				if ($i > $firstlot) $this->stringtoshow .= ', ' . "\n";
859
+				if ($i > $firstlot) $this->stringtoshow .= ', '."\n";
860 860
 				$color = sprintf("%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]);
861 861
 				$this->stringtoshow .= '{ ';
862 862
 				if (!isset($this->type[$i]) || $this->type[$i] == 'bars') {
@@ -864,41 +864,41 @@  discard block
 block discarded – undo
864 864
 						if ($i == $firstlot) $align = 'right';
865 865
 						elseif ($i == $firstlot + 1) $align = 'center';
866 866
 						else $align = 'left';
867
-						$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 }, ';
867
+						$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 }, ';
869 869
 				}
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
-				$this->stringtoshow .= 'color: "#' . $color . '", label: "' . (isset($this->Legend[$i]) ? dol_escape_js($this->Legend[$i]) : '') . '", data: d' . $i . ' }';
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
+				$this->stringtoshow .= 'color: "#'.$color.'", label: "'.(isset($this->Legend[$i]) ? dol_escape_js($this->Legend[$i]) : '').'", data: d'.$i.' }';
872 872
 				$i++;
873 873
 			}
874 874
 			// shadowSize: 0 -> Drawing is faster without shadows
875
-			$this->stringtoshow .= "\n" . ' ], { series: { shadowSize: 0, stack: stack, lines: { fill: false, steps: steps }, bars: { barWidth: 0.6,  fillColor: { colors: [{opacity: 0.9 }, {opacity: 0.85}] }} }' . "\n";
875
+			$this->stringtoshow .= "\n".' ], { series: { shadowSize: 0, stack: stack, lines: { fill: false, steps: steps }, bars: { barWidth: 0.6,  fillColor: { colors: [{opacity: 0.9 }, {opacity: 0.85}] }} }'."\n";
876 876
 
877 877
 			// Xaxis
878
-			$this->stringtoshow .= ', xaxis: { ticks: [' . "\n";
878
+			$this->stringtoshow .= ', xaxis: { ticks: ['."\n";
879 879
 			$x = 0;
880 880
 			foreach ($this->data as $key => $valarray) {
881
-				if ($x > 0) $this->stringtoshow .= ', ' . "\n";
882
-				$this->stringtoshow .= ' [' . $x . ', "' . $valarray[0] . '"]';
881
+				if ($x > 0) $this->stringtoshow .= ', '."\n";
882
+				$this->stringtoshow .= ' ['.$x.', "'.$valarray[0].'"]';
883 883
 				$x++;
884 884
 			}
885
-			$this->stringtoshow .= '] }' . "\n";
885
+			$this->stringtoshow .= '] }'."\n";
886 886
 
887 887
 			// Yaxis
888
-			$this->stringtoshow .= ', yaxis: { min: ' . $this->MinValue . ', max: ' . ($this->MaxValue) . ' }' . "\n";
888
+			$this->stringtoshow .= ', yaxis: { min: '.$this->MinValue.', max: '.($this->MaxValue).' }'."\n";
889 889
 
890 890
 			// Background color
891 891
 			$color1 = sprintf("%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[0], $this->bgcolorgrid[2]);
892 892
 			$color2 = sprintf("%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]);
893
-			$this->stringtoshow .= ', grid: { hoverable: true, backgroundColor: { colors: ["#' . $color1 . '", "#' . $color2 . '"] }, borderWidth: 1, borderColor: \'#e6e6e6\', tickColor  : \'#e6e6e6\' }' . "\n";
893
+			$this->stringtoshow .= ', grid: { hoverable: true, backgroundColor: { colors: ["#'.$color1.'", "#'.$color2.'"] }, borderWidth: 1, borderColor: \'#e6e6e6\', tickColor  : \'#e6e6e6\' }'."\n";
894 894
 			//$this->stringtoshow.=', shadowSize: 20'."\n";    TODO Uncommet this
895
-			$this->stringtoshow .= '});' . "\n";
896
-			$this->stringtoshow .= '}' . "\n";
895
+			$this->stringtoshow .= '});'."\n";
896
+			$this->stringtoshow .= '}'."\n";
897 897
 		}
898 898
 
899
-		$this->stringtoshow .= 'plotWithOptions_' . $tag . '();' . "\n";
900
-		$this->stringtoshow .= '});' . "\n";
901
-		$this->stringtoshow .= '</script>' . "\n";
899
+		$this->stringtoshow .= 'plotWithOptions_'.$tag.'();'."\n";
900
+		$this->stringtoshow .= '});'."\n";
901
+		$this->stringtoshow .= '</script>'."\n";
902 902
 	}
903 903
 
904 904
 
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
 		// phpcs:enable
925 925
 		global $conf, $langs;
926 926
 
927
-		dol_syslog(get_class($this) . "::draw_chart this->type=" . join(',', $this->type) . " this->MaxValue=" . $this->MaxValue);
927
+		dol_syslog(get_class($this)."::draw_chart this->type=".join(',', $this->type)." this->MaxValue=".$this->MaxValue);
928 928
 
929 929
 		if (empty($this->width) && empty($this->height)) {
930 930
 			print 'Error width or height not set';
@@ -966,15 +966,15 @@  discard block
 block discarded – undo
966 966
 				$alabelexists = 1;
967 967
 				$tmpykey = explode('_', ($array_of_ykeys[$i + ($alabelexists ? 1 : 0)]), 3);
968 968
 				if (!empty($tmpykey[2]) || $tmpykey[2] == '0') {		// This is a 'Group by' array
969
-					$tmpvalue = (array_key_exists('y_' . $tmpykey[1] . '_' . $tmpykey[2], $valarray) ? $valarray['y_' . $tmpykey[1] . '_' . $tmpykey[2]] : $valarray[$i + 1]);
969
+					$tmpvalue = (array_key_exists('y_'.$tmpykey[1].'_'.$tmpykey[2], $valarray) ? $valarray['y_'.$tmpykey[1].'_'.$tmpykey[2]] : $valarray[$i + 1]);
970 970
 					$values[$x] = (is_numeric($tmpvalue) ? $tmpvalue : null);
971 971
 					$arrayofgroupslegend[$i] = array(
972 972
 						'stacknum' => $tmpykey[1],
973 973
 						'legend' => $this->Legend[$tmpykey[1]],
974
-						'legendwithgroup' => $this->Legend[$tmpykey[1]] . ' - ' . $tmpykey[2]
974
+						'legendwithgroup' => $this->Legend[$tmpykey[1]].' - '.$tmpykey[2]
975 975
 					);
976 976
 				} else {
977
-					$tmpvalue = (array_key_exists('y_' . $i, $valarray) ? $valarray['y_' . $i] : $valarray[$i + 1]);
977
+					$tmpvalue = (array_key_exists('y_'.$i, $valarray) ? $valarray['y_'.$i] : $valarray[$i + 1]);
978 978
 					//var_dump($i.'_'.$x.'_'.$tmpvalue);
979 979
 					$values[$x] = (is_numeric($tmpvalue) ? $tmpvalue : null);
980 980
 				}
@@ -984,9 +984,9 @@  discard block
 block discarded – undo
984 984
 			$j = 0;
985 985
 			foreach ($values as $x => $y) {
986 986
 				if (isset($y)) {
987
-					$serie[$i] .= ($j > 0 ? ", " : "") . $y;
987
+					$serie[$i] .= ($j > 0 ? ", " : "").$y;
988 988
 				} else {
989
-					$serie[$i] .= ($j > 0 ? ", " : "") . 'null';
989
+					$serie[$i] .= ($j > 0 ? ", " : "").'null';
990 990
 				}
991 991
 				$j++;
992 992
 			}
@@ -999,11 +999,11 @@  discard block
 block discarded – undo
999 999
 
1000 1000
 		$tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.'))));
1001 1001
 
1002
-		$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>';
1002
+		$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>';
1004 1004
 		if (!empty($this->shownographyet)) {
1005
-			$this->stringtoshow .= '<div style="width:' . $this->width . (strpos($this->width, '%') > 0 ? '' : 'px') . '; height:' . $this->height . 'px;" class="nographyet"></div>';
1006
-			$this->stringtoshow .= '<div class="nographyettext margintoponly">' . $langs->trans("NotEnoughDataYet") . '...</div>';
1005
+			$this->stringtoshow .= '<div style="width:'.$this->width.(strpos($this->width, '%') > 0 ? '' : 'px').'; height:'.$this->height.'px;" class="nographyet"></div>';
1006
+			$this->stringtoshow .= '<div class="nographyettext margintoponly">'.$langs->trans("NotEnoughDataYet").'...</div>';
1007 1007
 			return;
1008 1008
 		}
1009 1009
 
@@ -1012,10 +1012,10 @@  discard block
 block discarded – undo
1012 1012
 		if (count($this->data) > 20) $dolxaxisvertical = 'dol-xaxis-vertical';
1013 1013
 		// No height for the pie grah
1014 1014
 		$cssfordiv = 'dolgraphchart';
1015
-		if (isset($this->type[$firstlot])) $cssfordiv .= ' dolgraphchar' . $this->type[$firstlot];
1016
-		$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";
1015
+		if (isset($this->type[$firstlot])) $cssfordiv .= ' dolgraphchar'.$this->type[$firstlot];
1016
+		$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 1017
 
1018
-		$this->stringtoshow .= '<script id="' . $tag . '">' . "\n";
1018
+		$this->stringtoshow .= '<script id="'.$tag.'">'."\n";
1019 1019
 		$i = $firstlot;
1020 1020
 		if ($nblot < 0) {
1021 1021
 			$this->stringtoshow .= '<!-- No series of data -->';
@@ -1031,67 +1031,67 @@  discard block
 block discarded – undo
1031 1031
 		// Special case for Graph of type 'pie', 'piesemicircle', or 'polar'
1032 1032
 		if (isset($this->type[$firstlot]) && (in_array($this->type[$firstlot], array('pie', 'polar', 'piesemicircle')))) {
1033 1033
 			$type = $this->type[$firstlot]; // pie or polar
1034
-			$this->stringtoshow .= 'var options = {' . "\n";
1034
+			$this->stringtoshow .= 'var options = {'."\n";
1035 1035
 			$legendMaxLines = 0; // Does not work
1036 1036
 			if (empty($showlegend)) {
1037 1037
 				$this->stringtoshow .= 'legend: { display: false }, ';
1038 1038
 			} else {
1039
-				$this->stringtoshow .= 'legend: { position: \'' . ($showlegend == 2 ? 'right' : 'top') . '\'';
1039
+				$this->stringtoshow .= 'legend: { position: \''.($showlegend == 2 ? 'right' : 'top').'\'';
1040 1040
 				if (!empty($legendMaxLines)) {
1041
-					$this->stringtoshow .= ', maxLines: ' . $legendMaxLines . '';
1041
+					$this->stringtoshow .= ', maxLines: '.$legendMaxLines.'';
1042 1042
 				}
1043
-				$this->stringtoshow .= ' }, ' . "\n";
1043
+				$this->stringtoshow .= ' }, '."\n";
1044 1044
 			}
1045 1045
 
1046 1046
 			if ($this->type[$firstlot] == 'piesemicircle') {
1047
-				$this->stringtoshow .= 'circumference: Math.PI,' . "\n";
1048
-				$this->stringtoshow .= 'rotation: -Math.PI,' . "\n";
1047
+				$this->stringtoshow .= 'circumference: Math.PI,'."\n";
1048
+				$this->stringtoshow .= 'rotation: -Math.PI,'."\n";
1049 1049
 			}
1050
-			$this->stringtoshow .= 'elements: { arc: {' . "\n";
1050
+			$this->stringtoshow .= 'elements: { arc: {'."\n";
1051 1051
 			// Color of earch arc
1052 1052
 			$this->stringtoshow .= 'backgroundColor: [';
1053 1053
 			$i = 0;
1054 1054
 			$foundnegativecolor = 0;
1055 1055
 			foreach ($legends as $val)	// Loop on each serie
1056 1056
 			{
1057
-				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)
1057
+				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)
1059 1059
 				else {
1060 1060
 					$tmp = str_replace('#', '', $this->datacolor[$i]);
1061 1061
 					if (strpos($tmp, '-') !== false) {
1062 1062
 						$foundnegativecolor++;
1063 1063
 						$color = '#FFFFFF'; // If $val is '-123'
1064
-					} else $color = "#" . $tmp; // If $val is '123' or '#123'
1064
+					} else $color = "#".$tmp; // If $val is '123' or '#123'
1065 1065
 				}
1066
-				$this->stringtoshow .= "'" . $color . "'";
1066
+				$this->stringtoshow .= "'".$color."'";
1067 1067
 				$i++;
1068 1068
 			}
1069
-			$this->stringtoshow .= '], ' . "\n";
1069
+			$this->stringtoshow .= '], '."\n";
1070 1070
 			// Border color
1071 1071
 			if ($foundnegativecolor) {
1072 1072
 				$this->stringtoshow .= 'borderColor: [';
1073 1073
 				$i = 0;
1074 1074
 				foreach ($legends as $val)	// Loop on each serie
1075 1075
 				{
1076
-					if ($i > 0) $this->stringtoshow .= ', ' . "\n";
1076
+					if ($i > 0) $this->stringtoshow .= ', '."\n";
1077 1077
 					if (is_array($this->datacolor[$i])) $color = 'null'; // If datacolor is array(R, G, B)
1078 1078
 					else {
1079 1079
 						$tmp = str_replace('#', '', $this->datacolor[$i]);
1080
-						if (strpos($tmp, '-') !== false) $color = '#' . str_replace('-', '', $tmp); // If $val is '-123'
1080
+						if (strpos($tmp, '-') !== false) $color = '#'.str_replace('-', '', $tmp); // If $val is '-123'
1081 1081
 						else $color = 'null'; // If $val is '123' or '#123'
1082 1082
 					}
1083
-					$this->stringtoshow .= ($color == 'null' ? "'rgba(0,0,0,0.2)'" : "'" . $color . "'");
1083
+					$this->stringtoshow .= ($color == 'null' ? "'rgba(0,0,0,0.2)'" : "'".$color."'");
1084 1084
 					$i++;
1085 1085
 				}
1086 1086
 				$this->stringtoshow .= ']';
1087 1087
 			}
1088
-			$this->stringtoshow .= '} } };' . "\n";
1088
+			$this->stringtoshow .= '} } };'."\n";
1089 1089
 
1090 1090
 			$this->stringtoshow .= '
1091
-				var ctx = document.getElementById("canvas_' . $tag . '").getContext("2d");
1091
+				var ctx = document.getElementById("canvas_' . $tag.'").getContext("2d");
1092 1092
 				var chart = new Chart(ctx, {
1093 1093
 			    // The type of chart we want to create
1094
-    			type: \'' . (in_array($type, array('pie', 'piesemicircle')) ? 'doughnut' : 'polarArea') . '\',
1094
+    			type: \'' . (in_array($type, array('pie', 'piesemicircle')) ? 'doughnut' : 'polarArea').'\',
1095 1095
 				// Configuration options go here
1096 1096
     			options: options,
1097 1097
 				data: {
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
 			foreach ($legends as $val)	// Loop on each serie
1102 1102
 			{
1103 1103
 				if ($i > 0) $this->stringtoshow .= ', ';
1104
-				$this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 32)) . "'";
1104
+				$this->stringtoshow .= "'".dol_escape_js(dol_trunc($val, 32))."'";
1105 1105
 				$i++;
1106 1106
 			}
1107 1107
 
@@ -1111,20 +1111,20 @@  discard block
 block discarded – undo
1111 1111
 			$i = 0;
1112 1112
 			while ($i < $nblot)	// Loop on each serie
1113 1113
 			{
1114
-				$color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ')';
1114
+				$color = 'rgb('.$this->datacolor[$i][0].', '.$this->datacolor[$i][1].', '.$this->datacolor[$i][2].')';
1115 1115
 				//$color = (!empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor));
1116 1116
 
1117
-				if ($i > 0) $this->stringtoshow .= ', ' . "\n";
1118
-				$this->stringtoshow .= '{' . "\n";
1117
+				if ($i > 0) $this->stringtoshow .= ', '."\n";
1118
+				$this->stringtoshow .= '{'."\n";
1119 1119
 				//$this->stringtoshow .= 'borderColor: \''.$color.'\', ';
1120 1120
 				//$this->stringtoshow .= 'backgroundColor: \''.$color.'\', ';
1121
-				$this->stringtoshow .= '  data: [' . $serie[$i] . ']';
1122
-				$this->stringtoshow .= '}' . "\n";
1121
+				$this->stringtoshow .= '  data: ['.$serie[$i].']';
1122
+				$this->stringtoshow .= '}'."\n";
1123 1123
 				$i++;
1124 1124
 			}
1125
-			$this->stringtoshow .= ']' . "\n";
1126
-			$this->stringtoshow .= '}' . "\n";
1127
-			$this->stringtoshow .= '});' . "\n";
1125
+			$this->stringtoshow .= ']'."\n";
1126
+			$this->stringtoshow .= '}'."\n";
1127
+			$this->stringtoshow .= '});'."\n";
1128 1128
 		}
1129 1129
 		// Other cases, graph of type 'bars', 'lines', 'linesnopoint'
1130 1130
 		else {
@@ -1170,10 +1170,10 @@  discard block
 block discarded – undo
1170 1170
 			}
1171 1171
 			$this->stringtoshow .= '};';
1172 1172
 			$this->stringtoshow .= '
1173
-				var ctx = document.getElementById("canvas_' . $tag . '").getContext("2d");
1173
+				var ctx = document.getElementById("canvas_' . $tag.'").getContext("2d");
1174 1174
 				var chart = new Chart(ctx, {
1175 1175
 			    // The type of chart we want to create
1176
-    			type: \'' . $type . '\',
1176
+    			type: \'' . $type.'\',
1177 1177
 				// Configuration options go here
1178 1178
     			options: options,
1179 1179
 				data: {
@@ -1238,12 +1238,12 @@  discard block
 block discarded – undo
1238 1238
 					}
1239 1239
 					$oldstacknum = $arrayofgroupslegend[$i]['stacknum'];
1240 1240
 
1241
-					$color = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ', 0.9)';
1242
-					$bordercolor = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ')';
1241
+					$color = 'rgb('.$newcolor[0].', '.$newcolor[1].', '.$newcolor[2].', 0.9)';
1242
+					$bordercolor = 'rgb('.$newcolor[0].', '.$newcolor[1].', '.$newcolor[2].')';
1243 1243
 				} else { // We do not use a 'group by'
1244 1244
 					if ($isfunnel) {
1245 1245
 						if (is_array($this->datacolor[$i])) {
1246
-							$color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ', 0.9)'; // If datacolor is array(R, G, B)
1246
+							$color = 'rgb('.$this->datacolor[$i][0].', '.$this->datacolor[$i][1].', '.$this->datacolor[$i][2].', 0.9)'; // If datacolor is array(R, G, B)
1247 1247
 						} else {
1248 1248
 							// TODO FIXME This logic must be in the caller that set $this->datacolor
1249 1249
 							$tmp = str_replace('#', '', $this->datacolor[$i]);
@@ -1251,17 +1251,17 @@  discard block
 block discarded – undo
1251 1251
 								$foundnegativecolor++;
1252 1252
 								$color = '#FFFFFF'; // If $val is '-123'
1253 1253
 							} else {
1254
-								$color = "#" . $tmp; // If $val is '123' or '#123'
1254
+								$color = "#".$tmp; // If $val is '123' or '#123'
1255 1255
 								$bordercolor = $color;
1256 1256
 							}
1257 1257
 							if ($foundnegativecolor) {
1258 1258
 								if (is_array($this->datacolor[$i])) $color = 'null'; // If datacolor is array(R, G, B)
1259 1259
 								else {
1260 1260
 									$tmp = str_replace('#', '', $this->datacolor[$i]);
1261
-									if (strpos($tmp, '-') !== false) $bordercolor = '#' . str_replace('-', '', $tmp); // If $val is '-123'
1261
+									if (strpos($tmp, '-') !== false) $bordercolor = '#'.str_replace('-', '', $tmp); // If $val is '-123'
1262 1262
 									else $bordercolor = 'null'; // If $val is '123' or '#123'
1263 1263
 								}
1264
-								$bordercolor == 'null' ? "'rgba(0,0,0,0.2)'" : "'" . $bordercolor . "'";
1264
+								$bordercolor == 'null' ? "'rgba(0,0,0,0.2)'" : "'".$bordercolor."'";
1265 1265
 							}
1266 1266
 						}
1267 1267
 					} else {
@@ -1274,36 +1274,36 @@  discard block
 block discarded – undo
1274 1274
 				if ($i > 0) $this->stringtoshow .= ', ';
1275 1275
 				$this->stringtoshow .= "\n";
1276 1276
 				$this->stringtoshow .= '{';
1277
-				$this->stringtoshow .= 'dolibarrinfo: \'y_' . $i . '\', ';
1278
-				$this->stringtoshow .= 'label: \'' . dol_escape_js(dol_string_nohtmltag($textoflegend)) . '\', ';
1279
-				$this->stringtoshow .= 'pointStyle: \'' . ($this->type[$i] == 'linesnopoint' ? 'line' : 'circle') . '\', ';
1280
-				$this->stringtoshow .= 'fill: ' . ($type == 'bar' ? 'true' : 'false') . ', ';
1277
+				$this->stringtoshow .= 'dolibarrinfo: \'y_'.$i.'\', ';
1278
+				$this->stringtoshow .= 'label: \''.dol_escape_js(dol_string_nohtmltag($textoflegend)).'\', ';
1279
+				$this->stringtoshow .= 'pointStyle: \''.($this->type[$i] == 'linesnopoint' ? 'line' : 'circle').'\', ';
1280
+				$this->stringtoshow .= 'fill: '.($type == 'bar' ? 'true' : 'false').', ';
1281 1281
 				if ($isfunnel) {
1282 1282
 					$this->stringtoshow .= 'borderWidth: \'2\', ';
1283 1283
 				} elseif ($type == 'bar' || $type == 'horizontalBar') {
1284 1284
 					$this->stringtoshow .= 'borderWidth: \'1\', ';
1285 1285
 				}
1286
-				$this->stringtoshow .= 'borderColor: \'' . $bordercolor . '\', ';
1287
-				$this->stringtoshow .= 'backgroundColor: \'' . $color . '\', ';
1288
-				if ($arrayofgroupslegend[$i]) $this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', ';
1289
-				$this->stringtoshow .='data: [';
1286
+				$this->stringtoshow .= 'borderColor: \''.$bordercolor.'\', ';
1287
+				$this->stringtoshow .= 'backgroundColor: \''.$color.'\', ';
1288
+				if ($arrayofgroupslegend[$i]) $this->stringtoshow .= 'stack: \''.$arrayofgroupslegend[$i]['stacknum'].'\', ';
1289
+				$this->stringtoshow .= 'data: [';
1290 1290
 				if ($isfunnel) {
1291 1291
 					$this->stringtoshow .= '['.-$serie[$i].','.$serie[$i].']';
1292 1292
 				} else {
1293 1293
 					$this->stringtoshow .= $serie[$i];
1294 1294
 				}
1295
-				$this->stringtoshow .=']';
1296
-				$this->stringtoshow .= '}' . "\n";
1295
+				$this->stringtoshow .= ']';
1296
+				$this->stringtoshow .= '}'."\n";
1297 1297
 
1298 1298
 				$i++;
1299 1299
 				$iinstack++;
1300 1300
 			}
1301
-			$this->stringtoshow .= ']' . "\n";
1302
-			$this->stringtoshow .= '}' . "\n";
1303
-			$this->stringtoshow .= '});' . "\n";
1301
+			$this->stringtoshow .= ']'."\n";
1302
+			$this->stringtoshow .= '}'."\n";
1303
+			$this->stringtoshow .= '});'."\n";
1304 1304
 		}
1305 1305
 
1306
-		$this->stringtoshow .= '</script>' . "\n";
1306
+		$this->stringtoshow .= '</script>'."\n";
1307 1307
 	}
1308 1308
 
1309 1309
 
@@ -1333,12 +1333,12 @@  discard block
 block discarded – undo
1333 1333
 		global $langs;
1334 1334
 
1335 1335
 		if ($shownographyet) {
1336
-			$s = '<div class="nographyet" style="width:' . (preg_match('/%/', $this->width) ? $this->width : $this->width . 'px') . '; height:' . (preg_match('/%/', $this->height) ? $this->height : $this->height . 'px') . ';"></div>';
1336
+			$s = '<div class="nographyet" style="width:'.(preg_match('/%/', $this->width) ? $this->width : $this->width.'px').'; height:'.(preg_match('/%/', $this->height) ? $this->height : $this->height.'px').';"></div>';
1337 1337
 			$s .= '<div class="nographyettext margintoponly">';
1338 1338
 			if (is_numeric($shownographyet)) {
1339
-				$s .= $langs->trans("NotEnoughDataYet") . '...';
1339
+				$s .= $langs->trans("NotEnoughDataYet").'...';
1340 1340
 			} else {
1341
-				$s .= $shownographyet . '...';
1341
+				$s .= $shownographyet.'...';
1342 1342
 			}
1343 1343
 			$s .= '</div>';
1344 1344
 			return $s;
Please login to merge, or discard this patch.
Braces   +190 added lines, -62 removed lines patch added patch discarded remove patch
@@ -106,9 +106,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		{
Please login to merge, or discard this patch.
htdocs/admin/emailcollector_list.php 1 patch
Braces   +160 added lines, -59 removed lines patch added patch discarded remove patch
@@ -70,16 +70,23 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.