Le test sur l'aperçu n'est fait que si il y a un PDF

This commit is contained in:
Laurent Destailleur 2004-10-27 18:56:46 +00:00
parent 0e8151fe9e
commit a735e33409

View File

@ -105,7 +105,7 @@ if ($_GET["facid"] > 0)
if ($conf->projet->enabled) if ($conf->projet->enabled)
{ {
$langs->load("projects"); $langs->load("projects");
print '<td height=\"10\">'.$langs->trans("Projet").'</td><td colspan="3">'; print '<td height=\"10\">'.$langs->trans("Project").'</td><td colspan="3">';
if ($fac->projetid > 0) if ($fac->projetid > 0)
{ {
$projet = New Project($db); $projet = New Project($db);
@ -128,20 +128,21 @@ if ($_GET["facid"] > 0)
/* /*
* Documents * Documents
* *
*
*/ */
$forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","="); $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
$facref = str_replace($forbidden_chars,"_",$fac->ref); $facref = str_replace($forbidden_chars,"_",$fac->ref);
$file = FAC_OUTPUTDIR . "/" . $facref . "/" . $facref . ".pdf"; $file = FAC_OUTPUTDIR . "/" . $facref . "/" . $facref . ".pdf";
$filedetail = FAC_OUTPUTDIR . "/" . $facref . "/" . $facref . "-detail.pdf"; $filedetail = FAC_OUTPUTDIR . "/" . $facref . "/" . $facref . "-detail.pdf";
$fileimage = $file.".png";
// Si fichier PDF existe
if (file_exists($file)) if (file_exists($file))
{ {
$encfile = urlencode($file); $encfile = urlencode($file);
print_titre("Documents"); print_titre("Documents");
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print "<tr $bc[0]><td>Facture PDF</td>"; print "<tr $bc[0]><td>".$langs->trans("Bill")." PDF</td>";
print '<td><a href="'.DOL_URL_ROOT . '/document.php?file='.$encfile.'">'.$fac->ref.'.pdf</a></td>'; print '<td><a href="'.DOL_URL_ROOT . '/document.php?file='.$encfile.'">'.$fac->ref.'.pdf</a></td>';
@ -149,6 +150,7 @@ if ($_GET["facid"] > 0)
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>'; print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';
print '</tr>'; print '</tr>';
// Si fichier detail PDF existe
if (file_exists($filedetail)) // facture détaillée supplémentaire if (file_exists($filedetail)) // facture détaillée supplémentaire
{ {
$encfile = urlencode($filedetail); $encfile = urlencode($filedetail);
@ -160,15 +162,12 @@ if ($_GET["facid"] > 0)
print '</tr>'; print '</tr>';
} }
$fileimage = $file.".png";
print "</table>\n"; print "</table>\n";
}
/* Conversion en image */
// Conversion du PDF en image png si fichier png non existant
if (!file_exists($fileimage)) if (!file_exists($fileimage))
{ {
if (function_exists(imagick_readimage)) {
$handle = imagick_readimage( $file ) ; $handle = imagick_readimage( $file ) ;
if ( imagick_iserror( $handle ) ) if ( imagick_iserror( $handle ) )
{ {
@ -190,6 +189,12 @@ if ($_GET["facid"] > 0)
imagick_writeimage( $handle, $file .".png"); imagick_writeimage( $handle, $file .".png");
} }
else {
print "Les fonctions <i>imagick</i> ne sont pas disponibles sur ce PHP";
}
}
}
/* /*
* *
@ -217,7 +222,7 @@ if ($_GET["facid"] > 0)
else else
{ {
/* Facture non trouvée */ /* Facture non trouvée */
print "Facture inexistante"; print $langs->trans("ErrorBillNotFound");
} }
} }