Fix: Better error management

This commit is contained in:
Laurent Destailleur 2010-08-05 22:51:36 +00:00
parent dc1e3472c9
commit 1d22d0f69d

View File

@ -166,31 +166,39 @@ if ($resql)
print '<td align="center">'; print '<td align="center">';
if ($obj->coder && $obj->coder != -1) if ($obj->coder && $obj->coder != -1)
{ {
$result=0;
// Chargement de la classe de codage // Chargement de la classe de codage
foreach ($conf->file->dol_document_root as $dirroot) foreach ($conf->file->dol_document_root as $dirroot)
{ {
$dir=$dirroot . "/includes/modules/barcode/"; $dir=$dirroot . "/includes/modules/barcode/";
$result=@include_once($dir.$obj->coder.".modules.php"); $result=@include_once($dir.$obj->coder.".modules.php");
//print $dir.$obj->coder.".modules.php - ".$result;
if ($result) break; if ($result) break;
} }
if ($result) if ($result)
{ {
$classname = "mod".ucfirst($obj->coder); $classname = "mod".ucfirst($obj->coder);
$module = new $classname($db); if (class_exists($classname))
if ($module->encodingIsSupported($obj->encoding))
{ {
// Build barcode on disk (not used, this is done to make debug easier) $module = new $classname($db);
$result=$module->writeBarCode($obj->example,$obj->encoding,'Y'); if ($module->encodingIsSupported($obj->encoding))
{
// Build barcode on disk (not used, this is done to make debug easier)
$result=$module->writeBarCode($obj->example,$obj->encoding,'Y');
// Generate on the fly and output barcode with generator // Generate on the fly and output barcode with generator
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).'&code='.urlencode($obj->example).'&encoding='.urlencode($obj->encoding); $url=DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).'&code='.urlencode($obj->example).'&encoding='.urlencode($obj->encoding);
//print $url; //print $url;
print '<img src="'.$url.'" title="'.$obj->example.'" border="0">'; print '<img src="'.$url.'" title="'.$obj->example.'" border="0">';
}
else
{
print $langs->trans("FormatNotSupportedByGenerator");
}
} }
else else
{ {
print $langs->trans("FormatNotSupportedByGenerator"); print 'ErrorClassNotFoundInModule '.$classname.' '.$obj->coder;
} }
} }
} }