Le test sur l'aperçu n'est fait que si il y a un PDF
This commit is contained in:
parent
0e8151fe9e
commit
a735e33409
@ -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,67 +128,72 @@ 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>';
|
||||||
|
|
||||||
print '<td align="right">'.filesize($file). ' bytes</td>';
|
print '<td align="right">'.filesize($file). ' bytes</td>';
|
||||||
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>';
|
||||||
|
|
||||||
if (file_exists($filedetail)) // facture détaillée supplémentaire
|
// Si fichier detail PDF existe
|
||||||
{
|
if (file_exists($filedetail)) // facture détaillée supplémentaire
|
||||||
$encfile = urlencode($filedetail);
|
{
|
||||||
print "<tr $bc[0]><td>Facture détaillée</td>";
|
$encfile = urlencode($filedetail);
|
||||||
|
print "<tr $bc[0]><td>Facture détaillée</td>";
|
||||||
print '<td><a href="'.DOL_URL_ROOT . '/document.php?file='.$encfile.'">'.$fac->ref.'-detail.pdf</a></td>';
|
|
||||||
print '<td align="right">'.filesize($filedetail). ' bytes</td>';
|
print '<td><a href="'.DOL_URL_ROOT . '/document.php?file='.$encfile.'">'.$fac->ref.'-detail.pdf</a></td>';
|
||||||
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($filedetail)).'</td>';
|
print '<td align="right">'.filesize($filedetail). ' bytes</td>';
|
||||||
print '</tr>';
|
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($filedetail)).'</td>';
|
||||||
}
|
print '</tr>';
|
||||||
|
}
|
||||||
$fileimage = $file.".png";
|
|
||||||
|
print "</table>\n";
|
||||||
print "</table>\n";
|
|
||||||
}
|
// Conversion du PDF en image png si fichier png non existant
|
||||||
|
if (!file_exists($fileimage))
|
||||||
/* Conversion en image */
|
{
|
||||||
|
if (function_exists(imagick_readimage)) {
|
||||||
if (!file_exists($fileimage))
|
$handle = imagick_readimage( $file ) ;
|
||||||
{
|
if ( imagick_iserror( $handle ) )
|
||||||
$handle = imagick_readimage( $file ) ;
|
{
|
||||||
if ( imagick_iserror( $handle ) )
|
$reason = imagick_failedreason( $handle ) ;
|
||||||
{
|
$description = imagick_faileddescription( $handle ) ;
|
||||||
$reason = imagick_failedreason( $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 ) ;
|
||||||
{
|
$description = imagick_faileddescription( $handle ) ;
|
||||||
$reason = imagick_failedreason( $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_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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user