Skip to content
Snippets Groups Projects
Commit f54bc367 authored by Charles Benke's avatar Charles Benke Committed by GitHub
Browse files

fix : warning error if no graphfiles

append when we have no element present (start from new)
parent 3fb80d96
No related branches found
No related tags found
No related merge requests found
......@@ -244,7 +244,7 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all')
$px = new DolGraph();
if (! $error)
if (! $error && count($graphfiles)>0)
{
$mesg = $px->isGraphKo();
if (! $mesg)
......@@ -301,64 +301,67 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all')
// Show graphs
$i=0;
foreach($graphfiles as $key => $val)
if ( count($graphfiles)>0)
{
if (! $graphfiles[$key]['file']) continue;
if ($graphfiles == 'propal' && ! $user->rights->propale->lire) continue;
if ($graphfiles == 'order' && ! $user->rights->commande->lire) continue;
if ($graphfiles == 'invoices' && ! $user->rights->facture->lire) continue;
if ($graphfiles == 'proposals_suppliers' && ! $user->rights->supplier_proposal->lire) continue;
if ($graphfiles == 'invoices_suppliers' && ! $user->rights->fournisseur->facture->lire) continue;
if ($graphfiles == 'orders_suppliers' && ! $user->rights->fournisseur->commande->lire) continue;
if ($i % 2 == 0)
{
print "\n".'<div class="fichecenter"><div class="fichehalfleft">'."\n";
}
else
{
print "\n".'<div class="fichehalfright"><div class="ficheaddleft">'."\n";
}
// Show graph
print '<table class="noborder" width="100%">';
// Label
print '<tr class="liste_titre"><td colspan="2">';
print $graphfiles[$key]['label'];
print '</td></tr>';
// Image
print '<tr class="impair"><td colspan="2" class="nohover" align="center">';
print $graphfiles[$key]['output'];
print '</td></tr>';
// Date generation
print '<tr>';
if ($graphfiles[$key]['output'] && ! $px->isGraphKo())
foreach($graphfiles as $key => $val)
{
if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) print '<td>'.$langs->trans("GeneratedOn",dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']),"dayhour")).'</td>';
else print '<td>'.$langs->trans("GeneratedOn",dol_print_date(dol_now(),"dayhour")).'</td>';
}
else
{
print '<td>'.($mesg?'<font class="error">'.$mesg.'</font>':$langs->trans("ChartNotGenerated")).'</td>';
}
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id')?GETPOST('id'):$object->id).((string) $type != ''?'&amp;type='.$type:'').'&amp;action=recalcul&amp;mode='.$mode.'">'.img_picto($langs->trans("ReCalculate"),'refresh').'</a></td>';
print '</tr>';
print '</table>';
if ($i % 2 == 0)
{
print "\n".'</div>'."\n";
}
else
{
print "\n".'</div></div></div>';
print '<div class="clear"><div class="fichecenter"><br></div></div>'."\n";
if (! $graphfiles[$key]['file']) continue;
if ($graphfiles == 'propal' && ! $user->rights->propale->lire) continue;
if ($graphfiles == 'order' && ! $user->rights->commande->lire) continue;
if ($graphfiles == 'invoices' && ! $user->rights->facture->lire) continue;
if ($graphfiles == 'proposals_suppliers' && ! $user->rights->supplier_proposal->lire) continue;
if ($graphfiles == 'invoices_suppliers' && ! $user->rights->fournisseur->facture->lire) continue;
if ($graphfiles == 'orders_suppliers' && ! $user->rights->fournisseur->commande->lire) continue;
if ($i % 2 == 0)
{
print "\n".'<div class="fichecenter"><div class="fichehalfleft">'."\n";
}
else
{
print "\n".'<div class="fichehalfright"><div class="ficheaddleft">'."\n";
}
// Show graph
print '<table class="noborder" width="100%">';
// Label
print '<tr class="liste_titre"><td colspan="2">';
print $graphfiles[$key]['label'];
print '</td></tr>';
// Image
print '<tr class="impair"><td colspan="2" class="nohover" align="center">';
print $graphfiles[$key]['output'];
print '</td></tr>';
// Date generation
print '<tr>';
if ($graphfiles[$key]['output'] && ! $px->isGraphKo())
{
if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) print '<td>'.$langs->trans("GeneratedOn",dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']),"dayhour")).'</td>';
else print '<td>'.$langs->trans("GeneratedOn",dol_print_date(dol_now(),"dayhour")).'</td>';
}
else
{
print '<td>'.($mesg?'<font class="error">'.$mesg.'</font>':$langs->trans("ChartNotGenerated")).'</td>';
}
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?id='.(GETPOST('id')?GETPOST('id'):$object->id).((string) $type != ''?'&amp;type='.$type:'').'&amp;action=recalcul&amp;mode='.$mode.'">'.img_picto($langs->trans("ReCalculate"),'refresh').'</a></td>';
print '</tr>';
print '</table>';
if ($i % 2 == 0)
{
print "\n".'</div>'."\n";
}
else
{
print "\n".'</div></div></div>';
print '<div class="clear"><div class="fichecenter"><br></div></div>'."\n";
}
$i++;
}
$i++;
}
// div not closed
if ($i % 2 == 1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment