Fix: Better error management
This commit is contained in:
parent
7521acb00a
commit
ea208fda3b
@ -23,7 +23,7 @@
|
|||||||
* \file htdocs/product/stats/fiche.php
|
* \file htdocs/product/stats/fiche.php
|
||||||
* \ingroup product
|
* \ingroup product
|
||||||
* \brief Page des stats produits
|
* \brief Page des stats produits
|
||||||
* \version $Id$
|
* \version $Id: fiche.php,v 1.109 2011/07/04 10:04:18 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("../../main.inc.php");
|
require("../../main.inc.php");
|
||||||
@ -37,6 +37,8 @@ $langs->load("bills");
|
|||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
|
|
||||||
$mode=isset($_GET["mode"])?$_GET["mode"]:'byunit';
|
$mode=isset($_GET["mode"])?$_GET["mode"]:'byunit';
|
||||||
|
$error=0;
|
||||||
|
$mesg='';
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (isset($_GET["id"]) || isset($_GET["ref"]))
|
if (isset($_GET["id"]) || isset($_GET["ref"]))
|
||||||
@ -47,8 +49,6 @@ $fieldid = isset($_GET["ref"])?'ref':'rowid';
|
|||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid);
|
$result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid);
|
||||||
|
|
||||||
$mesg = '';
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
@ -135,9 +135,10 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
$dir = (!empty($conf->product->dir_temp)?$conf->product->dir_temp:$conf->service->dir_temp);
|
$dir = (!empty($conf->product->dir_temp)?$conf->product->dir_temp:$conf->service->dir_temp);
|
||||||
if (! file_exists($dir.'/'.$product->id))
|
if (! file_exists($dir.'/'.$product->id))
|
||||||
{
|
{
|
||||||
if (create_exdir($dir.'/'.$product->id) < 0)
|
if (dol_mkdir($dir.'/'.$product->id) < 0)
|
||||||
{
|
{
|
||||||
$mesg = $langs->trans("ErrorCanNotCreateDir",$dir);
|
$mesg = $langs->trans("ErrorCanNotCreateDir",$dir);
|
||||||
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,44 +162,48 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
);
|
);
|
||||||
|
|
||||||
$px = new DolGraph();
|
$px = new DolGraph();
|
||||||
$mesg = $px->isGraphKo();
|
|
||||||
if (! $mesg)
|
if (! $error)
|
||||||
{
|
{
|
||||||
foreach($graphfiles as $key => $val)
|
$mesg = $px->isGraphKo();
|
||||||
|
if (! $mesg)
|
||||||
{
|
{
|
||||||
if (! $graphfiles[$key]['file']) continue;
|
foreach($graphfiles as $key => $val)
|
||||||
|
|
||||||
$graph_data = array();
|
|
||||||
|
|
||||||
// TODO Test si deja existant et recent, on ne genere pas
|
|
||||||
if ($key == 'propal') $graph_data = $product->get_nb_propal($socid,$mode);
|
|
||||||
if ($key == 'orders') $graph_data = $product->get_nb_order($socid,$mode);
|
|
||||||
if ($key == 'invoices') $graph_data = $product->get_nb_vente($socid,$mode);
|
|
||||||
if ($key == 'invoicessuppliers') $graph_data = $product->get_nb_achat($socid,$mode);
|
|
||||||
if (is_array($graph_data))
|
|
||||||
{
|
{
|
||||||
$px->SetData($graph_data);
|
if (! $graphfiles[$key]['file']) continue;
|
||||||
$px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue());
|
|
||||||
$px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue());
|
$graph_data = array();
|
||||||
$px->SetWidth($WIDTH);
|
|
||||||
$px->SetHeight($HEIGHT);
|
// TODO Test si deja existant et recent, on ne genere pas
|
||||||
$px->SetHorizTickIncrement(1);
|
if ($key == 'propal') $graph_data = $product->get_nb_propal($socid,$mode);
|
||||||
$px->SetPrecisionY(0);
|
if ($key == 'orders') $graph_data = $product->get_nb_order($socid,$mode);
|
||||||
$px->SetShading(3);
|
if ($key == 'invoices') $graph_data = $product->get_nb_vente($socid,$mode);
|
||||||
//print 'x '.$key.' '.$graphfiles[$key]['file'];
|
if ($key == 'invoicessuppliers') $graph_data = $product->get_nb_achat($socid,$mode);
|
||||||
|
if (is_array($graph_data))
|
||||||
$px->draw($dir."/".$graphfiles[$key]['file']);
|
{
|
||||||
}
|
$px->SetData($graph_data);
|
||||||
else
|
$px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue());
|
||||||
{
|
$px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue());
|
||||||
dol_print_error($db,'Error for calculating graph on key='.$key.' - '.$product->error);
|
$px->SetWidth($WIDTH);
|
||||||
|
$px->SetHeight($HEIGHT);
|
||||||
|
$px->SetHorizTickIncrement(1);
|
||||||
|
$px->SetPrecisionY(0);
|
||||||
|
$px->SetShading(3);
|
||||||
|
//print 'x '.$key.' '.$graphfiles[$key]['file'];
|
||||||
|
|
||||||
|
$px->draw($dir."/".$graphfiles[$key]['file']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db,'Error for calculating graph on key='.$key.' - '.$product->error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$mesg = $langs->trans("ChartGenerated");
|
||||||
}
|
}
|
||||||
|
|
||||||
$mesg = $langs->trans("ChartGenerated");
|
// Show graphs
|
||||||
|
|
||||||
// Affichage graphs
|
|
||||||
$i=0;
|
$i=0;
|
||||||
foreach($graphfiles as $key => $val)
|
foreach($graphfiles as $key => $val)
|
||||||
{
|
{
|
||||||
@ -266,5 +271,5 @@ else
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter('$Date$ - $Revision$');
|
llxFooter('$Date: 2011/07/04 10:04:18 $ - $Revision: 1.109 $');
|
||||||
?>
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user