diff --git a/htdocs/compta/facture/apercu.php b/htdocs/compta/facture/apercu.php new file mode 100644 index 00000000000..50a2bac8bf2 --- /dev/null +++ b/htdocs/compta/facture/apercu.php @@ -0,0 +1,236 @@ + + * Copyright (C) 2004 Éric Seigne + * Copyright (C) 2004 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + * + */ + +/*! \file htdocs/compta/facture.php + \ingroup facture + \brief Page de création d'une facture + \version $Revision$ +*/ + +require("./pre.inc.php"); + +$user->getrights('facture'); +if (!$user->rights->facture->lire) + accessforbidden(); + +$langs->load("bills"); + +require_once("../../facture.class.php"); + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} + +llxHeader('',$langs->trans("Bill"),'Facture'); + +$html = new Form($db); + +/* *************************************************************************** */ +/* */ +/* Mode fiche */ +/* */ +/* *************************************************************************** */ + +if ($_GET["facid"] > 0) +{ + $fac = New Facture($db); + if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0) + { + $soc = new Societe($db, $fac->socidp); + $soc->fetch($fac->socidp); + $author = new User($db); + $author->id = $fac->user_author; + $author->fetch(); + + $h = 0; + + $head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id; + $head[$h][1] = $langs->trans("Bill")." : $fac->ref"; + $h++; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/apercu.php?facid='.$fac->id; + $head[$h][1] = $langs->trans("Apercu"); + $hselected = $h; + $h++; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$fac->id; + $head[$h][1] = $langs->trans("Note"); + $h++; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$fac->id; + $head[$h][1] = $langs->trans("Info"); + $h++; + + dolibarr_fiche_head($head, $hselected, $soc->nom); + + + /* + * Facture + */ + print ''; + print ''; + print ''; + + print ""; + + print ''; + print "\n"; + print ""; + + print ''; + if ($conf->projet->enabled) + { + $langs->load("projects"); + print '"; + } + else + { + print '"; + } + print '"; + + print ""; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + + print "
'.$langs->trans("Customer").''; + print ''.$soc->nom.'Conditions de réglement : " . $fac->cond_reglement ."
'.$langs->trans("Date").'".strftime("%A %d %B %Y",$fac->date)."Date limite de réglement : " . strftime("%d %B %Y",$fac->date_lim_reglement) ."
'.$langs->trans("Projet").''; + if ($fac->projetid > 0) + { + $projet = New Project($db); + $projet->fetch($fac->projetid); + print ''.$projet->title.''; + } + else + { + print 'Classer la facture'; + } + print "  '; + print " '; + + /* + * Documents + * + * + */ + + + $file = FAC_OUTPUTDIR . "/" . $fac->ref . "/" . $fac->ref . ".pdf"; + $filedetail = FAC_OUTPUTDIR . "/" . $fac->ref . "/" . $fac->ref . "-detail.pdf"; + + + + 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_resize( $handle, 700, 700, IMAGICK_FILTER_UNKNOWN, 0, "200+200!" ) ) + { + $reason = imagick_failedreason( $handle ) ; + $description = imagick_faileddescription( $handle ) ; + + print "imagick_resize() failed
\nReason: $reason
\nDescription: $description
\n" ; + } + */ + imagick_writeimage( $handle, $file .".png"); + } + + /* + * + * + */ + + print "
".$langs->trans("Author")."$author->fullname
Remise globale'.$fac->remise_percent.'%
'.$langs->trans("AmountHT").''.price($fac->total_ht).''.MAIN_MONNAIE.' HT

"; + + + + + } + else + { + /* Facture non trouvée */ + print "Facture inexistante"; + } +} + +if (file_exists($fileimage)) +{ + print ''; +} +print ''; + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php new file mode 100644 index 00000000000..a2fae0ea746 --- /dev/null +++ b/htdocs/viewimage.php @@ -0,0 +1,45 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * or see http://www.gnu.org/ + * + * $Id$ + * $Source$ + * + */ + +$original_file = urldecode($_GET["file"]); + +$filename = basename ($original_file); + +$filename = "/home/www/dolibarr/documents/facture/297459847084/297459847084.pdf.png"; + + +header('Content-type: image/png'); + +//header('Content-Disposition: attachment; filename="'.$filename.'"'); + +// The PDF source is in original.pdf +//readfile($filename); + + +if ($fh = @fopen($original_file, "rb")) { + + fpassthru($fh); + fclose($fh); +} + +?>