From a735e33409e0b20c7a5133582bf1ed375d275bbf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Oct 2004 18:56:46 +0000 Subject: [PATCH] =?UTF-8?q?Le=20test=20sur=20l'aper=E7u=20n'est=20fait=20q?= =?UTF-8?q?ue=20si=20il=20y=20a=20un=20PDF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/facture/apercu.php | 115 ++++++++++++++++--------------- 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/htdocs/compta/facture/apercu.php b/htdocs/compta/facture/apercu.php index ba5bdd8aab5..b2c01b6f02a 100644 --- a/htdocs/compta/facture/apercu.php +++ b/htdocs/compta/facture/apercu.php @@ -105,7 +105,7 @@ if ($_GET["facid"] > 0) if ($conf->projet->enabled) { $langs->load("projects"); - print ''.$langs->trans("Projet").''; + print ''.$langs->trans("Project").''; if ($fac->projetid > 0) { $projet = New Project($db); @@ -128,67 +128,72 @@ if ($_GET["facid"] > 0) /* * Documents * - * */ $forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","="); $facref = str_replace($forbidden_chars,"_",$fac->ref); $file = FAC_OUTPUTDIR . "/" . $facref . "/" . $facref . ".pdf"; $filedetail = FAC_OUTPUTDIR . "/" . $facref . "/" . $facref . "-detail.pdf"; + $fileimage = $file.".png"; + // Si fichier PDF existe if (file_exists($file)) { - $encfile = urlencode($file); - print_titre("Documents"); - print ''; - - print ""; - - print ''; - - print ''; - print ''; - print ''; - - if (file_exists($filedetail)) // facture détaillée supplémentaire - { - $encfile = urlencode($filedetail); - print ""; - - print ''; - print ''; - print ''; - print ''; - } - - $fileimage = $file.".png"; - - print "
Facture PDF'.$fac->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
Facture détaillée'.$fac->ref.'-detail.pdf'.filesize($filedetail). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($filedetail)).'
\n"; - } - - /* Conversion en image */ - - if (!file_exists($fileimage)) - { - $handle = imagick_readimage( $file ) ; - if ( imagick_iserror( $handle ) ) - { - $reason = imagick_failedreason( $handle ) ; - $description = imagick_faileddescription( $handle ) ; - - print "handle failed!
\nReason: $reason
\nDescription: $description
\n"; - } - - imagick_convert( $handle, "PNG" ) ; - - if ( imagick_iserror( $handle ) ) - { - $reason = imagick_failedreason( $handle ) ; - $description = imagick_faileddescription( $handle ) ; - - print "handle failed!
\nReason: $reason
\nDescription: $description
\n"; - } - - imagick_writeimage( $handle, $file .".png"); + $encfile = urlencode($file); + print_titre("Documents"); + print ''; + + print ""; + + print ''; + + print ''; + print ''; + print ''; + + // Si fichier detail PDF existe + if (file_exists($filedetail)) // facture détaillée supplémentaire + { + $encfile = urlencode($filedetail); + print ""; + + print ''; + print ''; + print ''; + print ''; + } + + print "
".$langs->trans("Bill")." PDF'.$fac->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
Facture détaillée'.$fac->ref.'-detail.pdf'.filesize($filedetail). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($filedetail)).'
\n"; + + // Conversion du PDF en image png si fichier png non existant + if (!file_exists($fileimage)) + { + if (function_exists(imagick_readimage)) { + $handle = imagick_readimage( $file ) ; + if ( imagick_iserror( $handle ) ) + { + $reason = imagick_failedreason( $handle ) ; + $description = imagick_faileddescription( $handle ) ; + + print "handle failed!
\nReason: $reason
\nDescription: $description
\n"; + } + + imagick_convert( $handle, "PNG" ) ; + + if ( imagick_iserror( $handle ) ) + { + $reason = imagick_failedreason( $handle ) ; + $description = imagick_faileddescription( $handle ) ; + + print "handle failed!
\nReason: $reason
\nDescription: $description
\n"; + } + + imagick_writeimage( $handle, $file .".png"); + } + else { + print "Les fonctions imagick ne sont pas disponibles sur ce PHP"; + } + } + } /* @@ -217,7 +222,7 @@ if ($_GET["facid"] > 0) else { /* Facture non trouvée */ - print "Facture inexistante"; + print $langs->trans("ErrorBillNotFound"); } }