Fix: Pied de page propal azur et erreur apercu

This commit is contained in:
Laurent Destailleur 2005-09-29 20:41:42 +00:00
parent aa059b456d
commit 0a585f1679

View File

@ -192,22 +192,25 @@ if ($_GET["propalid"] > 0) {
/* /*
* Documents * Documents
* */
*/
$propalref = sanitize_string($propal->ref); $propalref = sanitize_string($propal->ref);
$file = $conf->propal->dir_output . "/" . $propalref . "/" . $propalref . ".pdf"; $file = $conf->propal->dir_output . "/" . $propalref . "/" . $propalref . ".pdf";
$filedetail = $conf->propal->dir_output . "/" . $propalref . "/" . $propalref . "-detail.pdf"; $filedetail = $conf->propal->dir_output . "/" . $propalref . "/" . $propalref . "-detail.pdf";
$relativepath = "${propalref}/${propalref}.pdf"; $relativepath = "${propalref}/${propalref}.pdf";
$relativepathdetail = "${propalref}/${propalref}-detail.pdf"; $relativepathdetail = "${propalref}/${propalref}-detail.pdf";
$relativepathimage = "${propalref}/${propalref}.pdf.png";
$fileimage = $file.".png"; // Chemin vers png aperçus
$relativepathimage = "${propalref}/${propalref}.pdf.png";
$relativepathimagebis = "${propalref}/${propalref}.pdf.png.0";
$fileimage = $file.".png"; // Si PDF d'1 page
$fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page
$var=true; $var=true;
// Si fichier PDF existe // Si fichier PDF existe
if (file_exists($file)) { if (file_exists($file))
{
$encfile = urlencode($file); $encfile = urlencode($file);
print_titre($langs->trans("Documents")); print_titre($langs->trans("Documents"));
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -229,18 +232,23 @@ if ($_GET["propalid"] > 0) {
print '</tr>'; print '</tr>';
} }
print "</table>\n"; print "</table>\n";
// Conversion du PDF en image png si fichier png non existant // Conversion du PDF en image png si fichier png non existant
if (!file_exists($fileimage)) { if (! file_exists($fileimage) && ! file_exists($fileimagebis))
if (function_exists(imagick_readimage)) { {
if (function_exists("imagick_readimage"))
{
$handle = imagick_readimage( $file ) ; $handle = imagick_readimage( $file ) ;
if ( imagick_iserror( $handle ) ) { if ( imagick_iserror( $handle ) )
{
$reason = imagick_failedreason( $handle ) ; $reason = imagick_failedreason( $handle ) ;
$description = imagick_faileddescription( $handle ) ; $description = imagick_faileddescription( $handle ) ;
print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n"; print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n";
} }
imagick_convert( $handle, "PNG" ) ; imagick_convert( $handle, "PNG" ) ;
if ( imagick_iserror( $handle ) ) { if ( imagick_iserror( $handle ) )
{
$reason = imagick_failedreason( $handle ) ; $reason = imagick_failedreason( $handle ) ;
$description = imagick_faileddescription( $handle ) ; $description = imagick_faileddescription( $handle ) ;
print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n"; print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n";
@ -248,7 +256,7 @@ if ($_GET["propalid"] > 0) {
imagick_writeimage( $handle, $file .".png"); imagick_writeimage( $handle, $file .".png");
} else { } else {
$langs->load("other"); $langs->load("other");
print $langs->trans("ErrorNoImagickReadimage"); print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
} }
} }
} }
@ -277,10 +285,18 @@ if ($_GET["propalid"] > 0) {
} }
} }
// Si fichier png PDF d'1 page trouvé
if (file_exists($fileimage)) if (file_exists($fileimage))
{ {
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&file='.urlencode($relativepathimage).'">'; print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&file='.urlencode($relativepathimage).'">';
} }
// Si fichier png PDF de plus d'1 page trouvé
elseif (file_exists($fileimagebis))
{
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&file='.urlencode($relativepathimagebis).'">';
}
print '</div>'; print '</div>';
$db->close(); $db->close();