diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php
index c4cebfcf68a..34b892d142b 100644
--- a/htdocs/core/boxes/box_funnel_of_prospection.php
+++ b/htdocs/core/boxes/box_funnel_of_prospection.php
@@ -81,6 +81,8 @@ class box_funnel_of_prospection extends ModeleBoxes
$sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_lead_status as cls";
$sql .= " WHERE active=1";
+ $sql .= " Order by cls.rowid";
+ $sql .= " AND cls.code != 'LOST'";
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
@@ -108,7 +110,6 @@ class box_funnel_of_prospection extends ModeleBoxes
$colorseriesstat[$objp->rowid] = $badgeStatus6;
break;
default:
- $colorseriesstat[$objp->rowid] = $badgeStatus2;
break;
}
$i++;
@@ -167,14 +168,16 @@ class box_funnel_of_prospection extends ModeleBoxes
$stringtoprint = '';
$stringtoprint .= '
';
$listofstatus = array_keys($listofoppstatus);
+ $liststatus = array();
+ $data = array('');
foreach ($listofstatus as $status) {
$labelStatus = '';
if ($status != 7) {
$code = dol_getIdFromCode($this->db, $status, 'c_lead_status', 'rowid', 'code');
if ($code) $labelStatus = $langs->transnoentitiesnoconv("OppStatus" . $code);
if (empty($labelStatus)) $labelStatus = $listofopplabel[$status];
-
- $dataseries[] = array($labelStatus,(isset($valsamount[$status]) ? (float) $valsamount[$status] : 0));
+ $liststatus[] = $labelStatus;
+ $data[] = (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0);
if (!$conf->use_javascript_ajax) {
$stringtoprint .= '
';
$stringtoprint .= '| ' . $labelStatus . ' | ';
@@ -183,16 +186,21 @@ class box_funnel_of_prospection extends ModeleBoxes
}
}
}
+ $dataseries[] = $data;
if ($conf->use_javascript_ajax) {
include_once DOL_DOCUMENT_ROOT . '/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
+ $dolgraph->SetMinValue(0);
$dolgraph->SetData($dataseries);
+ $dolgraph->SetLegend($liststatus);
$dolgraph->SetDataColor(array_values($colorseriesstat));
- //$dolgraph->SetLegend(array('PROSP',$dataseries['PROSP']));
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
- $dolgraph->SetType(array('pie'));
+ $dolgraph->setTitle('FunnelOfProspection');
+ $dolgraph->SetType(array('horizontalbars'));
$dolgraph->SetHeight('200');
+ $dolgraph->SetWidth('600');
+ $dolgraph->mode='depth';
$dolgraph->draw('idgraphstatus');
$stringtoprint .= $dolgraph->show($totaloppnb ? 0 : 1);
}
diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php
index 80314bcf9ed..ccce9cb1e12 100644
--- a/htdocs/core/class/dolgraph.class.php
+++ b/htdocs/core/class/dolgraph.class.php
@@ -103,9 +103,8 @@ class DolGraph
$this->datacolor = array(array(120, 130, 150), array(160, 160, 180), array(190, 190, 220));
$this->bgcolor = array(235, 235, 224);
- $color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
- if (is_readable($color_file))
- {
+ $color_file = DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php';
+ if (is_readable($color_file)) {
include_once $color_file;
if (isset($theme_bordercolor)) $this->bordercolor = $theme_bordercolor;
if (isset($theme_datacolor)) $this->datacolor = $theme_datacolor;
@@ -261,7 +260,7 @@ class DolGraph
* Set type
*
* @param array $type Array with type for each serie. Example: array('type1', 'type2', ...) where type can be:
- * 'pie', 'piesemicircle', 'polar', 'lines', 'linesnopoint', 'bars', 'horirontalbars'...
+ * 'pie', 'piesemicircle', 'polar', 'lines', 'linesnopoint', 'bars', 'horizontalbars'...
* @return void
*/
public function SetType($type)
@@ -466,10 +465,8 @@ class DolGraph
// phpcs:enable
global $theme_bgcolor, $theme_bgcoloronglet;
- if (!is_array($bg_color))
- {
- if ($bg_color == 'onglet')
- {
+ if (!is_array($bg_color)) {
+ if ($bg_color == 'onglet') {
//print 'ee'.join(',',$theme_bgcoloronglet);
$this->bgcolor = $theme_bgcoloronglet;
} else {
@@ -492,10 +489,8 @@ class DolGraph
// phpcs:enable
global $theme_bgcolor, $theme_bgcoloronglet;
- if (!is_array($bg_colorgrid))
- {
- if ($bg_colorgrid == 'onglet')
- {
+ if (!is_array($bg_colorgrid)) {
+ if ($bg_colorgrid == 'onglet') {
//print 'ee'.join(',',$theme_bgcoloronglet);
$this->bgcolorgrid = $theme_bgcoloronglet;
} else {
@@ -535,10 +530,8 @@ class DolGraph
$nblines = count($this->data);
$nbvalues = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1);
- for ($j = 0; $j < $nblines; $j++)
- {
- for ($i = 0; $i < $nbvalues; $i++)
- {
+ for ($j = 0; $j < $nblines; $j++) {
+ for ($i = 0; $i < $nbvalues; $i++) {
$vals[$k] = $this->data[$j][$i + 1];
$k++;
}
@@ -564,10 +557,8 @@ class DolGraph
$nblines = count($this->data);
$nbvalues = (empty($this->data[0]) ? 0 : count($this->data[0]) - 1);
- for ($j = 0; $j < $nblines; $j++)
- {
- for ($i = 0; $i < $nbvalues; $i++)
- {
+ for ($j = 0; $j < $nblines; $j++) {
+ for ($i = 0; $i < $nbvalues; $i++) {
$vals[$k] = $this->data[$j][$i + 1];
$k++;
}
@@ -589,8 +580,7 @@ class DolGraph
if ($max != 0) $max++;
$size = dol_strlen(abs(ceil($max)));
$factor = 1;
- for ($i = 0; $i < ($size - 1); $i++)
- {
+ for ($i = 0; $i < ($size - 1); $i++) {
$factor *= 10;
}
@@ -615,8 +605,7 @@ class DolGraph
if ($min != 0) $min--;
$size = dol_strlen(abs(floor($min)));
$factor = 1;
- for ($i = 0; $i < ($size - 1); $i++)
- {
+ for ($i = 0; $i < ($size - 1); $i++) {
$factor *= 10;
}
@@ -635,24 +624,21 @@ class DolGraph
*/
public function draw($file, $fileurl = '')
{
- if (empty($file))
- {
+ if (empty($file)) {
$this->error = "Call to draw method was made with empty value for parameter file.";
- dol_syslog(get_class($this)."::draw ".$this->error, LOG_ERR);
+ dol_syslog(get_class($this) . "::draw " . $this->error, LOG_ERR);
return -2;
}
- if (!is_array($this->data))
- {
+ if (!is_array($this->data)) {
$this->error = "Call to draw method was made but SetData was not called or called with an empty dataset for parameters";
- dol_syslog(get_class($this)."::draw ".$this->error, LOG_ERR);
+ dol_syslog(get_class($this) . "::draw " . $this->error, LOG_ERR);
return -1;
}
- if (count($this->data) < 1)
- {
+ if (count($this->data) < 1) {
$this->error = "Call to draw method was made but SetData was is an empty dataset";
- dol_syslog(get_class($this)."::draw ".$this->error, LOG_WARNING);
+ dol_syslog(get_class($this) . "::draw " . $this->error, LOG_WARNING);
}
- $call = "draw_".$this->_library;
+ $call = "draw_" . $this->_library;
call_user_func_array(array($this, $call), array($file, $fileurl));
}
@@ -678,10 +664,9 @@ class DolGraph
// phpcs:enable
global $conf, $langs;
- dol_syslog(get_class($this)."::draw_jflot this->type=".join(',', $this->type)." this->MaxValue=".$this->MaxValue);
+ dol_syslog(get_class($this) . "::draw_jflot this->type=" . join(',', $this->type) . " this->MaxValue=" . $this->MaxValue);
- if (empty($this->width) && empty($this->height))
- {
+ if (empty($this->width) && empty($this->height)) {
print 'Error width or height not set';
return;
}
@@ -701,7 +686,7 @@ class DolGraph
while ($i < $nblot) // Loop on each serie
{
$values = array(); // Array with horizontal y values (specific values of a serie) for each abscisse x
- $serie[$i] = "var d".$i." = [];\n";
+ $serie[$i] = "var d" . $i . " = [];\n";
// Fill array $values
$x = 0;
@@ -712,14 +697,13 @@ class DolGraph
$x++;
}
- if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar')))
- {
+ if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) {
foreach ($values as $x => $y) {
- if (isset($y)) $serie[$i] .= 'd'.$i.'.push({"label":"'.dol_escape_js($legends[$x]).'", "data":'.$y.'});'."\n";
+ if (isset($y)) $serie[$i] .= 'd' . $i . '.push({"label":"' . dol_escape_js($legends[$x]) . '", "data":' . $y . '});' . "\n";
}
} else {
foreach ($values as $x => $y) {
- if (isset($y)) $serie[$i] .= 'd'.$i.'.push(['.$x.', '.$y.']);'."\n";
+ if (isset($y)) $serie[$i] .= 'd' . $i . '.push([' . $x . ', ' . $y . ']);' . "\n";
}
}
@@ -728,43 +712,39 @@ class DolGraph
}
$tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.'))));
- $this->stringtoshow = ''."\n";
- if (!empty($this->title)) $this->stringtoshow .= ''.$this->title.'
';
- if (!empty($this->shownographyet))
- {
- $this->stringtoshow .= '';
- $this->stringtoshow .= ''.$langs->trans("NotEnoughDataYet").'...
';
+ $this->stringtoshow = '' . "\n";
+ if (!empty($this->title)) $this->stringtoshow .= '' . $this->title . '
';
+ if (!empty($this->shownographyet)) {
+ $this->stringtoshow .= '';
+ $this->stringtoshow .= '' . $langs->trans("NotEnoughDataYet") . '...
';
return;
}
// Start the div that will contains all the graph
$dolxaxisvertical = '';
if (count($this->data) > 20) $dolxaxisvertical = 'dol-xaxis-vertical';
- $this->stringtoshow .= ''."\n";
+ $this->stringtoshow .= '' . "\n";
- $this->stringtoshow .= ''."\n";
+ $this->stringtoshow .= 'plotWithOptions_' . $tag . '();' . "\n";
+ $this->stringtoshow .= '});' . "\n";
+ $this->stringtoshow .= '' . "\n";
}
@@ -947,10 +924,9 @@ class DolGraph
// phpcs:enable
global $conf, $langs;
- dol_syslog(get_class($this)."::draw_chart this->type=".join(',', $this->type)." this->MaxValue=".$this->MaxValue);
+ dol_syslog(get_class($this) . "::draw_chart this->type=" . join(',', $this->type) . " this->MaxValue=" . $this->MaxValue);
- if (empty($this->width) && empty($this->height))
- {
+ if (empty($this->width) && empty($this->height)) {
print 'Error width or height not set';
return;
}
@@ -971,7 +947,8 @@ class DolGraph
// Works with line but not with bars
//if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x
- $serie = array(); $arrayofgroupslegend = array();
+ $serie = array();
+ $arrayofgroupslegend = array();
//var_dump($this->data);
$i = $firstlot;
@@ -989,15 +966,15 @@ class DolGraph
$alabelexists = 1;
$tmpykey = explode('_', ($array_of_ykeys[$i + ($alabelexists ? 1 : 0)]), 3);
if (!empty($tmpykey[2]) || $tmpykey[2] == '0') { // This is a 'Group by' array
- $tmpvalue = (array_key_exists('y_'.$tmpykey[1].'_'.$tmpykey[2], $valarray) ? $valarray['y_'.$tmpykey[1].'_'.$tmpykey[2]] : $valarray[$i + 1]);
+ $tmpvalue = (array_key_exists('y_' . $tmpykey[1] . '_' . $tmpykey[2], $valarray) ? $valarray['y_' . $tmpykey[1] . '_' . $tmpykey[2]] : $valarray[$i + 1]);
$values[$x] = (is_numeric($tmpvalue) ? $tmpvalue : null);
$arrayofgroupslegend[$i] = array(
- 'stacknum'=> $tmpykey[1],
+ 'stacknum' => $tmpykey[1],
'legend' => $this->Legend[$tmpykey[1]],
- 'legendwithgroup' => $this->Legend[$tmpykey[1]].' - '.$tmpykey[2]
+ 'legendwithgroup' => $this->Legend[$tmpykey[1]] . ' - ' . $tmpykey[2]
);
} else {
- $tmpvalue = (array_key_exists('y_'.$i, $valarray) ? $valarray['y_'.$i] : $valarray[$i + 1]);
+ $tmpvalue = (array_key_exists('y_' . $i, $valarray) ? $valarray['y_' . $i] : $valarray[$i + 1]);
//var_dump($i.'_'.$x.'_'.$tmpvalue);
$values[$x] = (is_numeric($tmpvalue) ? $tmpvalue : null);
}
@@ -1007,9 +984,9 @@ class DolGraph
$j = 0;
foreach ($values as $x => $y) {
if (isset($y)) {
- $serie[$i] .= ($j > 0 ? ", " : "").$y;
+ $serie[$i] .= ($j > 0 ? ", " : "") . $y;
} else {
- $serie[$i] .= ($j > 0 ? ", " : "").'null';
+ $serie[$i] .= ($j > 0 ? ", " : "") . 'null';
}
$j++;
}
@@ -1022,12 +999,11 @@ class DolGraph
$tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.'))));
- $this->stringtoshow = ''."\n";
- if (!empty($this->title)) $this->stringtoshow .= ''.$this->title.'
';
- if (!empty($this->shownographyet))
- {
- $this->stringtoshow .= '';
- $this->stringtoshow .= ''.$langs->trans("NotEnoughDataYet").'...
';
+ $this->stringtoshow = '' . "\n";
+ if (!empty($this->title)&&$this->title!='FunnelOfProspection') $this->stringtoshow .= '' . $this->title . '
';
+ if (!empty($this->shownographyet)) {
+ $this->stringtoshow .= '';
+ $this->stringtoshow .= '' . $langs->trans("NotEnoughDataYet") . '...
';
return;
}
@@ -1036,17 +1012,15 @@ class DolGraph
if (count($this->data) > 20) $dolxaxisvertical = 'dol-xaxis-vertical';
// No height for the pie grah
$cssfordiv = 'dolgraphchart';
- if (isset($this->type[$firstlot])) $cssfordiv .= ' dolgraphchar'.$this->type[$firstlot];
- $this->stringtoshow .= ''."\n";
+ if (isset($this->type[$firstlot])) $cssfordiv .= ' dolgraphchar' . $this->type[$firstlot];
+ $this->stringtoshow .= '' . "\n";
- $this->stringtoshow .= ''."\n";
+ $this->stringtoshow .= '' . "\n";
}
@@ -1301,14 +1305,13 @@ class DolGraph
{
global $langs;
- if ($shownographyet)
- {
- $s = '';
+ if ($shownographyet) {
+ $s = '';
$s .= '';
if (is_numeric($shownographyet)) {
- $s .= $langs->trans("NotEnoughDataYet").'...';
+ $s .= $langs->trans("NotEnoughDataYet") . '...';
} else {
- $s .= $shownographyet.'...';
+ $s .= $shownographyet . '...';
}
$s .= '
';
return $s;