Replace deprecated dol_print_graph with DolGraph

This commit is contained in:
Laurent Destailleur 2017-11-23 18:47:24 +01:00
parent 5cf21fef05
commit 38ef5890dc

View File

@ -69,7 +69,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
{ {
$listofsearchfields['search_contact']=array('text'=>'Contact'); $listofsearchfields['search_contact']=array('text'=>'Contact');
} }
if (count($listofsearchfields)) if (count($listofsearchfields))
{ {
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">'; print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
@ -85,7 +85,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
print '</tr>'; print '</tr>';
$i++; $i++;
} }
print '</table>'; print '</table>';
print '</form>'; print '</form>';
print '<br>'; print '<br>';
} }
@ -95,7 +95,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele
/* /*
* Statistics area * Statistics area
*/ */
$third = array( $third = array(
'customer' => 0, 'customer' => 0,
'prospect' => 0, 'prospect' => 0,
@ -131,33 +131,40 @@ print '<table class="noborder nohover" width="100%">'."\n";
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>'; print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
if (! empty($conf->use_javascript_ajax) && ((round($third['prospect'])?1:0)+(round($third['customer'])?1:0)+(round($third['supplier'])?1:0)+(round($third['other'])?1:0) >= 2)) if (! empty($conf->use_javascript_ajax) && ((round($third['prospect'])?1:0)+(round($third['customer'])?1:0)+(round($third['supplier'])?1:0)+(round($third['other'])?1:0) >= 2))
{ {
print '<tr '.$bc[0].'><td align="center" colspan="2">'; print '<tr><td align="center" colspan="2">';
$dataseries=array(); $dataseries=array();
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[]=array('label'=>$langs->trans("Prospects"),'data'=>round($third['prospect'])); if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[]=array($langs->trans("Prospects"), round($third['prospect']));
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[]=array('label'=>$langs->trans("Customers"),'data'=>round($third['customer'])); if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[]=array($langs->trans("Customers"), round($third['customer']));
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[]=array('label'=>$langs->trans("Suppliers"),'data'=>round($third['supplier'])); if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[]=array($langs->trans("Suppliers"), round($third['supplier']));
if (! empty($conf->societe->enabled)) $dataseries[]=array('label'=>$langs->trans("Others"),'data'=>round($third['other'])); if (! empty($conf->societe->enabled)) $dataseries[]=array($langs->trans("Others"), round($third['other']));
$data=array('series'=>$dataseries); include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
dol_print_graph('stats',300,180,$data,1,'pie',0,'',0); $dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setWidth('100%');
$dolgraph->draw('idgraphthirdparties');
print $dolgraph->show();
print '</td></tr>'."\n"; print '</td></tr>'."\n";
} }
else else
{ {
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS))
{ {
$statstring = "<tr ".$bc[0].">"; $statstring = "<tr>";
$statstring.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=p">'.$langs->trans("Prospects").'</a></td><td align="right">'.round($third['prospect']).'</td>'; $statstring.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=p">'.$langs->trans("Prospects").'</a></td><td align="right">'.round($third['prospect']).'</td>';
$statstring.= "</tr>"; $statstring.= "</tr>";
} }
if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS))
{ {
$statstring.= "<tr ".$bc[1].">"; $statstring.= "<tr>";
$statstring.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=c">'.$langs->trans("Customers").'</a></td><td align="right">'.round($third['customer']).'</td>'; $statstring.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=c">'.$langs->trans("Customers").'</a></td><td align="right">'.round($third['customer']).'</td>';
$statstring.= "</tr>"; $statstring.= "</tr>";
} }
if (! empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire) if (! empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire)
{ {
$statstring2 = "<tr ".$bc[0].">"; $statstring2 = "<tr>";
$statstring2.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("Suppliers").'</a></td><td align="right">'.round($third['supplier']).'</td>'; $statstring2.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("Suppliers").'</a></td><td align="right">'.round($third['supplier']).'</td>';
$statstring2.= "</tr>"; $statstring2.= "</tr>";
} }
@ -202,24 +209,36 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
if ($i < $nbmax) if ($i < $nbmax)
$dataseries[]=array('label'=>$obj->label,'data'=>round($obj->nb)); {
$dataseries[]=array($obj->label, round($obj->nb));
}
else else
{
$rest+=$obj->nb; $rest+=$obj->nb;
}
$total+=$obj->nb; $total+=$obj->nb;
$i++; $i++;
} }
if ($i > $nbmax) if ($i > $nbmax)
$dataseries[]=array('label'=>$langs->trans("Other"),'data'=>round($rest)); {
$data=array('series'=>$dataseries); $dataseries[]=array($langs->trans("Other"), round($rest));
dol_print_graph('statscategclient',300,180,$data,1,'pie',0); }
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setWidth('100%');
$dolgraph->draw('idgraphcateg');
print $dolgraph->show();
} }
else else
{ {
$var=true;
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>'; print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
$total+=$obj->nb; $total+=$obj->nb;
$i++; $i++;
@ -275,16 +294,10 @@ if ($result)
print '<th align="right">'.$langs->trans('Status').'</th>'; print '<th align="right">'.$langs->trans('Status').'</th>';
print '</tr>'."\n"; print '</tr>'."\n";
$var=True;
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
print '<tr class="oddeven">';
// Name
print '<td class="nowrap">';
$thirdparty_static->id=$objp->rowid; $thirdparty_static->id=$objp->rowid;
$thirdparty_static->name=$objp->name; $thirdparty_static->name=$objp->name;
$thirdparty_static->client=$objp->client; $thirdparty_static->client=$objp->client;
@ -295,6 +308,10 @@ if ($result)
$thirdparty_static->code_client = $objp->code_client; $thirdparty_static->code_client = $objp->code_client;
$thirdparty_static->code_fournisseur = $objp->code_fournisseur; $thirdparty_static->code_fournisseur = $objp->code_fournisseur;
$thirdparty_static->canvas=$objp->canvas; $thirdparty_static->canvas=$objp->canvas;
print '<tr class="oddeven">';
// Name
print '<td class="nowrap">';
print $thirdparty_static->getNomUrl(1); print $thirdparty_static->getNomUrl(1);
print "</td>\n"; print "</td>\n";
// Type // Type