* Copyright (C) 2004 Éric Seigne * Copyright (C) 2004-2005 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/apercu.php \ingroup facture \brief Page de l'onglet aperçu d'une facture \version $Revision$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php'); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/project.class.php"); $user->getrights('facture'); if (!$user->rights->facture->lire) accessforbidden(); $langs->load("bills"); // Sécurité accés client if ($user->societe_id > 0) { $action = ''; $socid = $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->socid); $soc->fetch($fac->socid); $author = new User($db); if ($fac->user_author) { $author->id = $fac->user_author; $author->fetch(); } $head = facture_prepare_head($fac); $hselected = $conf->use_preview_tabs ? 2 : false; dolibarr_fiche_head($head, $hselected, $langs->trans("InvoiceCustomer")); /* * Facture */ print ''; $rowspan=3; // Reference print ''; // Societe print ''; print ''; print ''; // Dates print ''; print ''; print '"; // Conditions et modes de réglement print ''; print ''; // Remise globale print ''; /* if ($fac->brouillon == 1 && $user->rights->facture->creer) { print ''; print ''; print ''; print ''; } else { */ print ''; // } $nbrows=5; if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF) $nbrows++; if ($conf->projet->enabled) $nbrows++; print '"; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Statut print ''; // Projet if ($conf->projet->enabled) { $langs->load("projects"); print ''; print ''; } print '
'.$langs->trans('Ref').''.$fac->ref.'
'.$langs->trans("Company").''.$soc->getNomUrl(1,'compta').'
'.$langs->trans("Date").''.dolibarr_print_date($fac->date,"%A %d %B %Y").''.$langs->trans("DateMaxPayment").'' . dolibarr_print_date($fac->date_lim_reglement,"%A %d %B %Y"); if ($fac->paye == 0 && $fac->date_lim_reglement < (time() - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late")); print "
'.$langs->trans("PaymentConditions").''; $html->form_conditions_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->cond_reglement_id,"none"); print ''.$langs->trans("PaymentMode").''; $html->form_modes_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->mode_reglement_id,"none"); print '
'.$langs->trans('GlobalDiscount').'
% '; print ''.$fac->remise_percent.'%'; /* * Documents */ $facref = sanitize_string($fac->ref); $dir_output = $conf->facture->dir_output . "/"; $filepath = $dir_output . $facref . "/"; $file = $filepath . $facref . ".pdf"; $filedetail = $filepath . $facref . "-detail.pdf"; $relativepath = "${facref}/${facref}.pdf"; $relativepathdetail = "${facref}/${facref}-detail.pdf"; // Chemin vers png aperçus $relativepathimage = "${facref}/${facref}.pdf.png"; $fileimage = $file.".png"; // Si PDF d'1 page $fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page $var=true; // Si fichier PDF existe if (file_exists($file)) { $encfile = urlencode($file); print_titre($langs->trans("Documents")); print ''; print ""; print ''; print ''; print ''; print ''; // Si fichier detail PDF existe if (file_exists($filedetail)) // facture détaillée supplémentaire { 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) && ! file_exists($fileimagebis)) { 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_writeimages( $handle, $file .".png"); } else { $langs->load("other"); print ''.$langs->trans("ErrorNoImagickReadimage").''; } } } print "
'.$langs->trans("AmountHT").''.price($fac->total_ht).''.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('AmountVAT').''.price($fac->total_tva).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('AmountTTC').''.price($fac->total_ttc).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('Status').''.($fac->getLibStatut()).'
'.$langs->trans("Project").''; if ($fac->projetid > 0) { $projet = New Project($db); $projet->fetch($fac->projetid); print ''.$projet->title.''; } else { print ' '; } print '
'; } else { // Facture non trouvée print $langs->trans("ErrorBillNotFound",$_GET["facid"]); } } // Si fichier png PDF d'1 page trouvé if (file_exists($fileimage)) { print ''; } // Si fichier png PDF de plus d'1 page trouvé elseif (file_exists($fileimagebis)) { $multiple = $relativepathimage . "."; for ($i = 0; $i < 20; $i++) { $preview = $multiple.$i; if (file_exists($dir_output.$preview)) { print '

'; } } } print ''; // Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent print '

'; print '
'; $db->close(); llxFooter('$Date$ - $Revision$'); ?>