[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com> 4 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 * 20 * $Id: apercu.php,v 1.32 2005/12/07 02:40:37 eldy Exp $ 21 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/facture/apercu.php,v $ 22 */ 23 24 /** 25 \file htdocs/compta/facture/apercu.php 26 \ingroup facture 27 \brief Page de l'onglet aperçu d'une facture 28 \version $Revision: 1.32 $ 29 */ 30 31 require ("./pre.inc.php"); 32 require_once (DOL_DOCUMENT_ROOT."/facture.class.php"); 33 require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php'); 34 if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/project.class.php"); 35 36 37 $user->getrights('facture'); 38 if (!$user->rights->facture->lire) 39 accessforbidden(); 40 41 $langs->load("bills"); 42 43 44 // Sécurité accés client 45 if ($user->societe_id > 0) 46 { 47 $action = ''; 48 $socidp = $user->societe_id; 49 } 50 51 52 llxHeader('',$langs->trans("Bill"),'Facture'); 53 54 $html = new Form($db); 55 56 /* *************************************************************************** */ 57 /* */ 58 /* Mode fiche */ 59 /* */ 60 /* *************************************************************************** */ 61 62 if ($_GET["facid"] > 0) 63 { 64 $fac = New Facture($db); 65 if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0) 66 { 67 $soc = new Societe($db, $fac->socidp); 68 $soc->fetch($fac->socidp); 69 $author = new User($db); 70 if ($fac->user_author) 71 { 72 $author->id = $fac->user_author; 73 $author->fetch(); 74 } 75 76 $head = facture_prepare_head($fac); 77 $hselected = $conf->use_preview_tabs ? 2 : false; 78 dolibarr_fiche_head($head, $hselected, $langs->trans("Bill")." : $fac->ref"); 79 80 81 /* 82 * Facture 83 */ 84 print '<table class="border" width="100%">'; 85 $rowspan=3; 86 87 // Societe 88 print '<tr><td>'.$langs->trans("Company").'</td>'; 89 print '<td colspan="5">'; 90 print '<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>'; 91 print '</tr>'; 92 93 // Dates 94 print '<tr><td>'.$langs->trans("Date").'</td>'; 95 print '<td colspan="3">'.dolibarr_print_date($fac->date,"%A %d %B %Y").'</td>'; 96 print '<td>'.$langs->trans("DateClosing").'</td><td>' . dolibarr_print_date($fac->date_lim_reglement,"%A %d %B %Y"); 97 if ($fac->paye == 0 && $fac->date_lim_reglement < (time() - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late")); 98 print "</td></tr>"; 99 100 // Conditions et modes de réglement 101 print '<tr><td>'.$langs->trans("PaymentConditions").'</td><td colspan="3">'; 102 $html->form_conditions_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->cond_reglement_id,"none"); 103 print '</td>'; 104 print '<td width="25%">'.$langs->trans("PaymentMode").'</td><td width="25%">'; 105 $html->form_modes_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->mode_reglement_id,"none"); 106 print '</td></tr>'; 107 108 print '<tr>'; 109 if ($conf->projet->enabled) 110 { 111 $langs->load("projects"); 112 print '<td>'.$langs->trans("Project").'</td><td colspan="3">'; 113 if ($fac->projetid > 0) 114 { 115 $projet = New Project($db); 116 $projet->fetch($fac->projetid); 117 print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$fac->projetid.'">'.$projet->title.'</a>'; 118 } 119 else 120 { 121 print ' '; 122 } 123 } 124 else 125 { 126 print '<td> </td><td colspan="3">'; 127 } 128 print '</td>'; 129 130 // partie Droite sur $rowspan lignes 131 print '<td colspan="2" rowspan="'.$rowspan.'" valign="top" width="50%">'; 132 133 134 /* 135 * Documents 136 */ 137 $facref = sanitize_string($fac->ref); 138 $file = $conf->facture->dir_output . "/" . $facref . "/" . $facref . ".pdf"; 139 $filedetail = $conf->facture->dir_output . "/" . $facref . "/" . $facref . "-detail.pdf"; 140 $relativepath = "$facref}/$facref}.pdf"; 141 $relativepathdetail = "$facref}/$facref}-detail.pdf"; 142 143 // Chemin vers png aperçus 144 $relativepathimage = "$facref}/$facref}.pdf.png"; 145 $relativepathimagebis = "$facref}/$facref}.pdf.png.0"; 146 $fileimage = $file.".png"; // Si PDF d'1 page 147 $fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page 148 149 150 $var=true; 151 152 // Si fichier PDF existe 153 if (file_exists($file)) 154 { 155 $encfile = urlencode($file); 156 print_titre($langs->trans("Documents")); 157 print '<table class="border" width="100%">'; 158 159 print "<tr $bc[$var]><td>".$langs->trans("Bill")." PDF</td>"; 160 161 print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepath).'">'.$fac->ref.'.pdf</a></td>'; 162 print '<td align="right">'.filesize($file). ' bytes</td>'; 163 print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>'; 164 print '</tr>'; 165 166 // Si fichier detail PDF existe 167 if (file_exists($filedetail)) // facture détaillée supplémentaire 168 { 169 print "<tr $bc[$var]><td>Facture détaillée</td>"; 170 171 print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepathdetail).'">'.$fac->ref.'-detail.pdf</a></td>'; 172 print '<td align="right">'.filesize($filedetail). ' bytes</td>'; 173 print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($filedetail)).'</td>'; 174 print '</tr>'; 175 } 176 177 print "</table>\n"; 178 179 // Conversion du PDF en image png si fichier png non existant 180 if (! file_exists($fileimage) && ! file_exists($fileimagebis)) 181 { 182 if (function_exists("imagick_readimage")) 183 { 184 $handle = imagick_readimage( $file ) ; 185 if ( imagick_iserror( $handle ) ) 186 { 187 $reason = imagick_failedreason( $handle ) ; 188 $description = imagick_faileddescription( $handle ) ; 189 190 print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n"; 191 } 192 193 imagick_convert( $handle, "PNG" ) ; 194 195 if ( imagick_iserror( $handle ) ) 196 { 197 $reason = imagick_failedreason( $handle ) ; 198 $description = imagick_faileddescription( $handle ) ; 199 200 print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n"; 201 } 202 203 imagick_writeimage( $handle, $file .".png"); 204 } 205 else 206 { 207 $langs->load("other"); 208 print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>'; 209 } 210 } 211 212 } 213 print "</td></tr>"; 214 215 216 print '<tr><td nowrap>'.$langs->trans("GlobalDiscount").'</td>'; 217 print '<td align="right" colspan="2">'.$fac->remise_percent.'</td>'; 218 print '<td>%</td></tr>'; 219 220 print '<tr><td>'.$langs->trans("AmountHT").'</td>'; 221 print '<td align="right" colspan="2"><b>'.price($fac->total_ht).'</b></td>'; 222 print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; 223 224 print '</table>'; 225 226 } 227 else 228 { 229 // Facture non trouvée 230 print $langs->trans("ErrorBillNotFound",$_GET["facid"]); 231 } 232 } 233 234 // Si fichier png PDF d'1 page trouvé 235 if (file_exists($fileimage)) 236 { 237 print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($relativepathimage).'">'; 238 } 239 // Si fichier png PDF de plus d'1 page trouvé 240 elseif (file_exists($fileimagebis)) 241 { 242 print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&file='.urlencode($relativepathimagebis).'">'; 243 } 244 245 246 print '</div>'; 247 248 249 // Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent 250 print '<div class="tabsAction">'; 251 print '</div>'; 252 253 254 $db->close(); 255 256 llxFooter('$Date: 2005/12/07 02:40:37 $ - $Revision: 1.32 $'); 257 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |