Ajout d'un graph sur les commandes en utilisant artichow
This commit is contained in:
parent
ca7b72519a
commit
949263f0a7
@ -116,113 +116,133 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
$HEIGHT=160;
|
$HEIGHT=160;
|
||||||
$dir = $conf->produit->dir_temp;
|
$dir = $conf->produit->dir_temp;
|
||||||
if (! file_exists($dir.'/'.$product->id))
|
if (! file_exists($dir.'/'.$product->id))
|
||||||
{
|
{
|
||||||
if (create_exdir($dir.'/'.$product->id) < 0)
|
if (create_exdir($dir.'/'.$product->id) < 0)
|
||||||
{
|
{
|
||||||
$mesg = $langs->trans("ErrorCanNotCreateDir",$dir);
|
$mesg = $langs->trans("ErrorCanNotCreateDir",$dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$graphfiles=array(
|
$graphfiles=array(
|
||||||
'propal' =>array('modulepart'=>'productstats_proposals', 'file' => $product->id.'/propal12m.png', 'label' => $langs->trans("Nombre propal sur les 12 derniers mois")),
|
'propal' =>array('modulepart'=>'productstats_proposals',
|
||||||
// 'orders' =>array('modulepart'=>'productstats_orders', 'file' => $product->id.'/orders12m.png', 'label' => $langs->trans("Nombre commande clients sur les 12 derniers mois")),
|
'file' => $product->id.'/propal12m.png',
|
||||||
// 'orderssuppliers' =>array('modulepart'=>'productstats_orderssuppliers', 'file' => $product->id.'/orderssuppliers12m.png', 'label' => $langs->trans("Nombre commande fournisseurs sur les 12 derniers mois")),
|
'label' => $langs->trans("Nombre propal sur les 12 derniers mois")),
|
||||||
// 'contracts' =>array('modulepart'=>'productstats_contracts', 'file' => $product->id.'/contracts12m.png', 'label' => $langs->trans("Nombre contrats sur les 12 derniers mois")),
|
'orders' =>array('modulepart'=>'productstats_orders',
|
||||||
'invoices' =>array('modulepart'=>'productstats_invoices', 'file' => $product->id.'/invoices12m.png', 'label' => $langs->trans("Nombre facture clients sur les 12 derniers mois")),
|
'file' => $product->id.'/orders12m.png',
|
||||||
'invoicessuppliers'=>array('modulepart'=>'productstats_invoicessuppliers', 'file' => $product->id.'/invoicessuppliers12m.png', 'label' => $langs->trans("Nombre facture fournisseurs sur les 12 derniers mois")),
|
'label' => $langs->trans("Nombre commande clients sur les 12 derniers mois")),
|
||||||
);
|
'invoices' =>array('modulepart'=>'productstats_invoices',
|
||||||
|
'file' => $product->id.'/invoices12m.png',
|
||||||
|
'label' => $langs->trans("Nombre facture clients sur les 12 derniers mois")),
|
||||||
|
'invoicessuppliers'=>array('modulepart'=>'productstats_invoicessuppliers',
|
||||||
|
'file' => $product->id.'/invoicessuppliers12m.png',
|
||||||
|
'label' => $langs->trans("Nombre facture fournisseurs sur les 12 derniers mois")),
|
||||||
|
|
||||||
|
// 'orderssuppliers' =>array('modulepart'=>'productstats_orderssuppliers', 'file' => $product->id.'/orderssuppliers12m.png', 'label' => $langs->trans("Nombre commande fournisseurs sur les 12 derniers mois")),
|
||||||
|
// 'contracts' =>array('modulepart'=>'productstats_contracts', 'file' => $product->id.'/contracts12m.png', 'label' => $langs->trans("Nombre contrats sur les 12 derniers mois")),
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
$px = new DolGraph();
|
$px = new DolGraph();
|
||||||
$mesg = $px->isGraphKo();
|
$mesg = $px->isGraphKo();
|
||||||
if (! $mesg)
|
if (! $mesg)
|
||||||
{
|
{
|
||||||
foreach($graphfiles as $key => $val)
|
foreach($graphfiles as $key => $val)
|
||||||
{
|
{
|
||||||
if (! $graphfiles[$key]['file']) continue;
|
if (! $graphfiles[$key]['file']) continue;
|
||||||
|
|
||||||
$graph_data = array();
|
$graph_data = array();
|
||||||
|
|
||||||
// \todo Test si deja existant et recent, on ne genere pas
|
// \todo Test si deja existant et recent, on ne genere pas
|
||||||
if ($key == 'propal') $graph_data = $product->get_nb_propal($socid);
|
if ($key == 'propal') $graph_data = $product->get_nb_propal($socid);
|
||||||
if ($key == 'invoices') $graph_data = $product->get_nb_vente($socid);
|
if ($key == 'orders') $graph_data = $product->get_nb_order($socid);
|
||||||
if ($key == 'invoicessuppliers') $graph_data = $product->get_nb_achat($socid);
|
if ($key == 'invoices') $graph_data = $product->get_nb_vente($socid);
|
||||||
if (is_array($graph_data))
|
if ($key == 'invoicessuppliers') $graph_data = $product->get_nb_achat($socid);
|
||||||
{
|
if (is_array($graph_data))
|
||||||
$px->SetData($graph_data);
|
{
|
||||||
$px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue());
|
$px->SetData($graph_data);
|
||||||
$px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue());
|
$px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue());
|
||||||
$px->SetWidth($WIDTH);
|
$px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue());
|
||||||
$px->SetHeight($HEIGHT);
|
$px->SetWidth($WIDTH);
|
||||||
$px->SetHorizTickIncrement(1);
|
$px->SetHeight($HEIGHT);
|
||||||
$px->SetPrecisionY(0);
|
$px->SetHorizTickIncrement(1);
|
||||||
$px->SetShading(5);
|
$px->SetPrecisionY(0);
|
||||||
//print 'x '.$key.' '.$graphfiles[$key]['file'];
|
$px->SetShading(5);
|
||||||
$px->draw($dir."/".$graphfiles[$key]['file']);
|
//print 'x '.$key.' '.$graphfiles[$key]['file'];
|
||||||
}
|
|
||||||
else
|
if ($key == 'orders')
|
||||||
{
|
{
|
||||||
dolibarr_print_error($db,'Error for calculating graph on key='.$key.' - '.$product->error);
|
$px->library = 'artichow';
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
|
$px->library = 'phplot';
|
||||||
|
}
|
||||||
|
|
||||||
|
$px->draw($dir."/".$graphfiles[$key]['file']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db,'Error for calculating graph on key='.$key.' - '.$product->error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$mesg = $langs->trans("ChartGenerated");
|
$mesg = $langs->trans("ChartGenerated");
|
||||||
|
|
||||||
// Affichage graphs
|
// Affichage graphs
|
||||||
$i=0;
|
$i=0;
|
||||||
foreach($graphfiles as $key => $val)
|
foreach($graphfiles as $key => $val)
|
||||||
{
|
{
|
||||||
if (! $graphfiles[$key]['file']) continue;
|
if (! $graphfiles[$key]['file']) continue;
|
||||||
|
|
||||||
if ($graphfiles == 'propal' && ! $user->right->propale->lire) continue;
|
if ($graphfiles == 'propal' && ! $user->right->propale->lire) continue;
|
||||||
if ($graphfiles == 'invoices' && ! $user->right->facture->lire) continue;
|
if ($graphfiles == 'order' && ! $user->right->commande->lire) continue;
|
||||||
if ($graphfiles == 'invoices_suppliers' && ! $user->right->fournisseur->facture->lire) continue;
|
if ($graphfiles == 'invoices' && ! $user->right->facture->lire) continue;
|
||||||
|
if ($graphfiles == 'invoices_suppliers' && ! $user->right->fournisseur->facture->lire) continue;
|
||||||
|
|
||||||
|
|
||||||
if ($i % 2 == 0) print '<tr>';
|
if ($i % 2 == 0) print '<tr>';
|
||||||
|
|
||||||
// Show graph
|
// Show graph
|
||||||
print '<td width="50%" align="center">';
|
print '<td width="50%" align="center">';
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
// Label
|
// Label
|
||||||
print '<tr class="liste_titre"><td colspan="2">';
|
print '<tr class="liste_titre"><td colspan="2">';
|
||||||
print $graphfiles[$key]['label'];
|
print $graphfiles[$key]['label'];
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
// Image
|
// Image
|
||||||
print '<tr><td colspan="2" align="center">';
|
print '<tr><td colspan="2" align="center">';
|
||||||
$url=DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&file='.urlencode($graphfiles[$key]['file']);
|
$url=DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&file='.urlencode($graphfiles[$key]['file']);
|
||||||
//print $url;
|
//print $url;
|
||||||
print '<img src="'.$url.'">';
|
print '<img src="'.$url.'">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
// Date génération
|
// Date génération
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file']) && ! $px->isGraphKo())
|
if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file']) && ! $px->isGraphKo())
|
||||||
{
|
{
|
||||||
print '<td>'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($dir."/".$graphfiles[$key]['file']),"%d %b %Y %H:%M:%S")).'</td>';
|
print '<td>'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($dir."/".$graphfiles[$key]['file']),"%d %b %Y %H:%M:%S")).'</td>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<td>'.($mesg?'<font class="error">'.$mesg.'</font>':$langs->trans("ChartNotGenerated")).'</td>';
|
print '<td>'.($mesg?'<font class="error">'.$mesg.'</font>':$langs->trans("ChartNotGenerated")).'</td>';
|
||||||
}
|
}
|
||||||
print '<td align="center"><a href="fiche.php?id='.$product->id.'&action=recalcul">'.img_picto($langs->trans("ReCalculate"),'refresh').'</a></td>';
|
print '<td align="center"><a href="fiche.php?id='.$product->id.'&action=recalcul">'.img_picto($langs->trans("ReCalculate"),'refresh').'</a></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
if ($i % 2 == 1) print '</tr>';
|
if ($i % 2 == 1) print '</tr>';
|
||||||
|
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($i % 2 == 1) print '<td> </td></tr>';
|
|
||||||
|
|
||||||
|
if ($i % 2 == 1) print '<td> </td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|
||||||
// Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent en fin de page
|
// Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent en fin de page
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user