diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 0100c98bc91..0a39e596ba3 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -37,6 +37,8 @@ require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager = new HookManager($db); @@ -102,6 +104,11 @@ print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial'); print '
'; +print getCustomerProposalPieChart($socid); +print '
'; +print getCustomerOrderPieChart($socid); +print '
'; + /* * Draft customer proposals */ diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 445fd9b5773..359084ddabe 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -28,6 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager = new HookManager($db); @@ -45,6 +46,7 @@ if (isset($user->socid) && $user->socid > 0) { $action = ''; $socid = $user->socid; } + restrictedArea($user, 'propal'); @@ -65,124 +67,8 @@ print load_fiche_titre($langs->trans("ProspectionArea"), '', 'propal'); print '
'; print '
'; -/* - * Statistics - */ - -$listofstatus = array(Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::STATUS_SIGNED, Propal::STATUS_NOTSIGNED, Propal::STATUS_BILLED); - -$sql = "SELECT count(p.rowid) as nb, p.fk_statut as status"; -$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql .= ", ".MAIN_DB_PREFIX."propal as p"; -if (!$user->rights->societe->client->voir && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -} -$sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; -$sql .= " AND p.fk_soc = s.rowid"; -if ($user->socid) { - $sql .= ' AND p.fk_soc = '.$user->socid; -} -if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; -} -$sql .= " AND p.fk_statut IN (".$db->sanitize(implode(" ,", $listofstatus)).")"; -$sql .= " GROUP BY p.fk_statut"; -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - $total = 0; - $totalinprocess = 0; - $dataseries = array(); - $colorseries = array(); - $vals = array(); - - while ($i < $num) { - $obj = $db->fetch_object($resql); - if ($obj) { - $vals[$obj->status] = $obj->nb; - $totalinprocess += $obj->nb; - - $total += $obj->nb; - } - $i++; - } - $db->free($resql); - - include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - - print '
'; - print ''; - - print ''; - print ''; - print ''; - - foreach ($listofstatus as $status) { - $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == Propal::STATUS_DRAFT) { - $colorseries[$status] = '-'.$badgeStatus0; - } - if ($status == Propal::STATUS_VALIDATED) { - $colorseries[$status] = $badgeStatus1; - } - if ($status == Propal::STATUS_SIGNED) { - $colorseries[$status] = $badgeStatus4; - } - if ($status == Propal::STATUS_NOTSIGNED) { - $colorseries[$status] = $badgeStatus9; - } - if ($status == Propal::STATUS_BILLED) { - $colorseries[$status] = $badgeStatus6; - } - - if (empty($conf->use_javascript_ajax)) { - print ''; - print ''; - print ''; - print "\n"; - } - } - - if ($conf->use_javascript_ajax) { - print ''; - print ''; - print ''; - } - - //if ($totalinprocess != $total) - //{ - // print ''; - // print ''; - // print ''; - // print ''; - //} - - print ''; - print ''; - print ''; - print ''; - - print '
'.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'
'.$propalstatic->LibStatut($status, 0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
'; - - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphthirdparties'); - print $dolgraph->show($total ? 0 : 1); - - print '
'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')'.$totalinprocess.'
'.$langs->trans("Total").''.$total.'
'; - print '
'; - print '
'; -} else { - dol_print_error($db); -} - +print getCustomerProposalPieChart($socid); +print '
'; /* * Draft proposals diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index dc15b85525c..48f1f600126 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; if (!$user->rights->commande->lire) { accessforbidden(); @@ -76,113 +77,8 @@ print load_fiche_titre($langs->trans("OrdersArea"), '', 'order'); print '
'; -/* - * Statistics - */ - -$sql = "SELECT count(c.rowid) as nb, c.fk_statut as status"; -$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql .= ", ".MAIN_DB_PREFIX."commande as c"; -if (!$user->rights->societe->client->voir && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -} -$sql .= " WHERE c.fk_soc = s.rowid"; -$sql .= " AND c.entity IN (".getEntity('societe').")"; -if ($user->socid) { - $sql .= ' AND c.fk_soc = '.$user->socid; -} -if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; -} -$sql .= " GROUP BY c.fk_statut"; - -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - - $total = 0; - $totalinprocess = 0; - $dataseries = array(); - $colorseries = array(); - $vals = array(); - // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not) - while ($i < $num) { - $row = $db->fetch_row($resql); - if ($row) { - //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) - { - if (!isset($vals[$row[1]])) { - $vals[$row[1]] = 0; - } - $vals[$row[1]] += $row[0]; - $totalinprocess += $row[0]; - } - $total += $row[0]; - } - $i++; - } - $db->free($resql); - - include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - - print '
'; - print ''; - print ''."\n"; - $listofstatus = array(0, 1, 2, 3, -1); - foreach ($listofstatus as $status) { - $dataseries[] = array($commandestatic->LibStatut($status, 0, 1, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == Commande::STATUS_DRAFT) { - $colorseries[$status] = '-'.$badgeStatus0; - } - if ($status == Commande::STATUS_VALIDATED) { - $colorseries[$status] = $badgeStatus1; - } - if ($status == Commande::STATUS_SHIPMENTONPROCESS) { - $colorseries[$status] = $badgeStatus4; - } - if ($status == Commande::STATUS_CLOSED && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { - $colorseries[$status] = $badgeStatus6; - } - if ($status == Commande::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { - $colorseries[$status] = $badgeStatus6; - } - if ($status == Commande::STATUS_CANCELED) { - $colorseries[$status] = $badgeStatus9; - } - - if (empty($conf->use_javascript_ajax)) { - print ''; - print ''; - print ''; - print "\n"; - } - } - if ($conf->use_javascript_ajax) { - print ''; - } - - //if ($totalinprocess != $total) - print ''; - print "
'.$langs->trans("Statistics").' - '.$langs->trans("CustomersOrders").'
'.$commandestatic->LibStatut($status, 0, 0, 1).''.(isset($vals[$status]) ? $vals[$status] : 0).' '; - print $commandestatic->LibStatut($status, 0, 3, 1); - print '
'; - - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(array('pie')); - $dolgraph->setHeight('200'); - $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total ? 0 : 1); - - print '
'.$langs->trans("Total").''.$total.'

"; -} else { - dol_print_error($db); -} +print getCustomerOrderPieChart($socid); +print '
'; /* diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 4a88617de4e..c9ab7372c4c 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -149,8 +149,8 @@ class box_graph_product_distribution extends ModeleBoxes $socid = empty($user->socid) ? 0 : $user->socid; $userid = 0; // No filter on user creation - $WIDTH = ($nbofgraph >= 2 || !empty($conf->dol_optimize_smallscreen)) ? '160' : '320'; - $HEIGHT = '192'; + $WIDTH = ($nbofgraph >= 2 || !empty($conf->dol_optimize_smallscreen)) ? '300' : '320'; + $HEIGHT = '120'; if (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) @@ -177,6 +177,7 @@ class box_graph_product_distribution extends ModeleBoxes $i = 0; $legend = array(); + // Truncate length of legend foreach ($data2 as $key => $val) { $data2[$key][0] = dol_trunc($data2[$key][0], 32); $legend[] = $data2[$key][0]; @@ -194,7 +195,7 @@ class box_graph_product_distribution extends ModeleBoxes $px2->setShowPointValue($showpointvalue); $px2->setShowPercent(0); $px2->SetMaxValue($px2->GetCeilMaxValue()); - //$px2->SetWidth($WIDTH); + $px2->SetWidth($WIDTH); $px2->SetHeight($HEIGHT); //$px2->SetYLabel($langs->trans("AmountOfBillsHT")); $px2->SetShading(3); @@ -236,6 +237,7 @@ class box_graph_product_distribution extends ModeleBoxes $i = 0; $legend = array(); + // Truncate length of legend foreach ($data3 as $key => $val) { $data3[$key][0] = dol_trunc($data3[$key][0], 32); $legend[] = $data3[$key][0]; @@ -253,7 +255,7 @@ class box_graph_product_distribution extends ModeleBoxes $px3->setShowPointValue($showpointvalue); $px3->setShowPercent(0); $px3->SetMaxValue($px3->GetCeilMaxValue()); - //$px3->SetWidth($WIDTH); + $px3->SetWidth($WIDTH); $px3->SetHeight($HEIGHT); //$px3->SetYLabel($langs->trans("AmountOfBillsHT")); $px3->SetShading(3); @@ -296,6 +298,7 @@ class box_graph_product_distribution extends ModeleBoxes $i = 0; $legend = array(); + // Truncate length of legend foreach ($data1 as $key => $val) { $data1[$key][0] = dol_trunc($data1[$key][0], 32); $legend[] = $data1[$key][0]; @@ -313,7 +316,7 @@ class box_graph_product_distribution extends ModeleBoxes $px1->setShowPointValue($showpointvalue); $px1->setShowPercent(0); $px1->SetMaxValue($px1->GetCeilMaxValue()); - //$px1->SetWidth($WIDTH); + $px1->SetWidth($WIDTH); $px1->SetHeight($HEIGHT); //$px1->SetYLabel($langs->trans("NumberOfBills")); $px1->SetShading(3); diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 31c230f8d78..7eecea00ff6 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1165,9 +1165,32 @@ class DolGraph if (!empty($legendMaxLines)) { $this->stringtoshow .= ', maxLines: ' . $legendMaxLines . ''; } + /* This has no effect on chartjs version with dol v14 + $this->stringtoshow .= ', labels: { + color: \'rgb(255, 0, 0)\', + // This more specific font property overrides the global property + font: { + size: 24 + } + }'; + */ $this->stringtoshow .= ' }, ' . "\n"; } + /* This has no effect on chartjs version with dol v14 + $this->stringtoshow .= 'plugins: { + legend: { + display: true, + labels: { + color: \'rgb(255, 0, 0)\', + // This more specific font property overrides the global property + font: { + size: 24 + } + } + } + },'."\n"; */ + if ($this->type[$firstlot] == 'piesemicircle') { $this->stringtoshow .= 'circumference: Math.PI,' . "\n"; $this->stringtoshow .= 'rotation: -Math.PI,' . "\n"; @@ -1236,7 +1259,7 @@ class DolGraph if ($i > 0) { $this->stringtoshow .= ', '; } - $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 32)) . "'"; + $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 22)) . "'"; $i++; } diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 4d2286c21ac..ece491d2c69 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -315,7 +315,8 @@ function getCustomerInvoicePieChart($socid = 0) $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(['pie']); - $dolgraph->setHeight('200'); + $dolgraph->setHeight('150'); + $dolgraph->setWidth('300'); $dolgraph->draw('idgraphcustomerinvoices'); $result .= ''; @@ -435,7 +436,8 @@ function getPurchaseInvoicePieChart($socid = 0) $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(['pie']); - $dolgraph->setHeight('200'); + $dolgraph->setHeight('150'); + $dolgraph->setWidth('300'); $dolgraph->draw('idgraphpurchaseinvoices'); $result .= ''; diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 2bd8707f86b..5936c63d2c3 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -171,3 +171,135 @@ function order_admin_prepare_head() return $head; } + + + +/** + * Return a HTML table that contains a pie chart of customer orders + * + * @param int $socid (Optional) Show only results from the customer with this id + * @return string A HTML table that contains a pie chart of customer invoices + */ +function getCustomerOrderPieChart($socid = 0) +{ + global $conf, $db, $langs, $user; + + $result = ''; + + if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) { + return ''; + } + + $commandestatic = new Commande($db); + + /* + * Statistics + */ + + $sql = "SELECT count(c.rowid) as nb, c.fk_statut as status"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('societe').")"; + if ($user->socid) { + $sql .= ' AND c.fk_soc = '.$user->socid; + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + $sql .= " GROUP BY c.fk_statut"; + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + + $total = 0; + $totalinprocess = 0; + $dataseries = array(); + $colorseries = array(); + $vals = array(); + // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not) + while ($i < $num) { + $row = $db->fetch_row($resql); + if ($row) { + //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) + { + if (!isset($vals[$row[1]])) { + $vals[$row[1]] = 0; + } + $vals[$row[1]] += $row[0]; + $totalinprocess += $row[0]; + } + $total += $row[0]; + } + $i++; + } + $db->free($resql); + + include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + + $result = '
'; + $result .= ''; + $result .= ''."\n"; + $listofstatus = array(0, 1, 2, 3, -1); + foreach ($listofstatus as $status) { + $dataseries[] = array($commandestatic->LibStatut($status, 0, 1, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); + if ($status == Commande::STATUS_DRAFT) { + $colorseries[$status] = '-'.$badgeStatus0; + } + if ($status == Commande::STATUS_VALIDATED) { + $colorseries[$status] = $badgeStatus1; + } + if ($status == Commande::STATUS_SHIPMENTONPROCESS) { + $colorseries[$status] = $badgeStatus4; + } + if ($status == Commande::STATUS_CLOSED && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { + $colorseries[$status] = $badgeStatus6; + } + if ($status == Commande::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { + $colorseries[$status] = $badgeStatus6; + } + if ($status == Commande::STATUS_CANCELED) { + $colorseries[$status] = $badgeStatus9; + } + + if (empty($conf->use_javascript_ajax)) { + $result .= ''; + $result .= ''; + $result .= ''; + $result .= "\n"; + } + } + if ($conf->use_javascript_ajax) { + $result .= ''; + } + + //if ($totalinprocess != $total) + $result .= ''; + $result .= "
'.$langs->trans("Statistics").' - '.$langs->trans("CustomersOrders").'
'.$commandestatic->LibStatut($status, 0, 0, 1).''.(isset($vals[$status]) ? $vals[$status] : 0).' '; + $result .= $commandestatic->LibStatut($status, 0, 3, 1); + $result .= '
'; + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('150'); + $dolgraph->setWidth('300'); + $dolgraph->draw('idgraphstatus'); + $result .= $dolgraph->show($total ? 0 : 1); + + $result .= '
'.$langs->trans("Total").''.$total.'

"; + } else { + dol_print_error($db); + } + + return $result; +} diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 3ddd3ab1b2b..38589c9e610 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -152,3 +152,141 @@ function propal_admin_prepare_head() return $head; } + + + +/** + * Return a HTML table that contains a pie chart of customer proposals + * + * @param int $socid (Optional) Show only results from the customer with this id + * @return string A HTML table that contains a pie chart of customer invoices + */ +function getCustomerProposalPieChart($socid = 0) +{ + global $conf, $db, $langs, $user; + + $result= ''; + + if (empty($conf->propal->enabled) || empty($user->rights->propal->lire)) { + return ''; + } + + $listofstatus = array(Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::STATUS_SIGNED, Propal::STATUS_NOTSIGNED, Propal::STATUS_BILLED); + + $propalstatic = new Propal($db); + + $sql = "SELECT count(p.rowid) as nb, p.fk_statut as status"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE p.entity IN (".getEntity($propalstatic->element).")"; + $sql .= " AND p.fk_soc = s.rowid"; + if ($user->socid) { + $sql .= ' AND p.fk_soc = '.$user->socid; + } + if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + } + $sql .= " AND p.fk_statut IN (".$db->sanitize(implode(" ,", $listofstatus)).")"; + $sql .= " GROUP BY p.fk_statut"; + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + $total = 0; + $totalinprocess = 0; + $dataseries = array(); + $colorseries = array(); + $vals = array(); + + while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($obj) { + $vals[$obj->status] = $obj->nb; + $totalinprocess += $obj->nb; + + $total += $obj->nb; + } + $i++; + } + $db->free($resql); + + include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + + $result = '
'; + $result .= ''; + + $result .= ''; + $result .= ''; + $result .= ''; + + foreach ($listofstatus as $status) { + $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); + if ($status == Propal::STATUS_DRAFT) { + $colorseries[$status] = '-'.$badgeStatus0; + } + if ($status == Propal::STATUS_VALIDATED) { + $colorseries[$status] = $badgeStatus1; + } + if ($status == Propal::STATUS_SIGNED) { + $colorseries[$status] = $badgeStatus4; + } + if ($status == Propal::STATUS_NOTSIGNED) { + $colorseries[$status] = $badgeStatus9; + } + if ($status == Propal::STATUS_BILLED) { + $colorseries[$status] = $badgeStatus6; + } + + if (empty($conf->use_javascript_ajax)) { + $result .= ''; + $result .= ''; + $result .= ''; + $result .= "\n"; + } + } + + if ($conf->use_javascript_ajax) { + $result .= ''; + $result .= ''; + $result .= ''; + } + + //if ($totalinprocess != $total) + //{ + // print ''; + // print ''; + // print ''; + // print ''; + //} + + $result .= ''; + $result .= ''; + $result .= ''; + $result .= ''; + + $result .= '
'.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'
'.$propalstatic->LibStatut($status, 0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
'; + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setHeight('150'); + $dolgraph->setWidth('300'); + $dolgraph->draw('idgraphthirdparties'); + $result .= $dolgraph->show($total ? 0 : 1); + + $result .= '
'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')'.$totalinprocess.'
'.$langs->trans("Total").''.$total.'
'; + $result .= '
'; + $result .= '
'; + } else { + dol_print_error($db); + } + + return $result; +}