[ 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 * Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 * 21 * $Id: apercu.php,v 1.7.2.1 2006/01/04 20:18:03 eldy Exp $ 22 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/propal/apercu.php,v $ 23 */ 24 25 /** 26 \file htdocs/comm/propal/apercu.php 27 \ingroup propal 28 \brief Page de l'onglet aperçu d'une propal 29 \version $Revision: 1.7.2.1 $ 30 */ 31 32 require ("./pre.inc.php"); 33 34 $user->getrights('propale'); 35 36 if (!$user->rights->propale->lire) 37 accessforbidden(); 38 39 $langs->load('propal'); 40 $langs->load("bills"); 41 $langs->load('compta'); 42 43 44 require_once(DOL_DOCUMENT_ROOT.'/propal.class.php'); 45 if ($conf->projet->enabled) { 46 require_once(DOL_DOCUMENT_ROOT."/project.class.php"); 47 } 48 49 50 /* 51 * Sécurité accés client 52 */ 53 if ($user->societe_id > 0) 54 { 55 $action = ''; 56 $socidp = $user->societe_id; 57 } 58 59 llxHeader(); 60 61 $html = new Form($db); 62 63 /* *************************************************************************** */ 64 /* */ 65 /* Mode fiche */ 66 /* */ 67 /* *************************************************************************** */ 68 69 if ($_GET["propalid"] > 0) { 70 $propal = new Propal($db); 71 72 if ( $propal->fetch($_GET["propalid"], $user->societe_id) > 0) 73 { 74 $soc = new Societe($db, $propal->socidp); 75 $soc->fetch($propal->socidp); 76 77 $h=0; 78 79 $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; 80 $head[$h][1] = $langs->trans('CommercialCard'); 81 $h++; 82 83 $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; 84 $head[$h][1] = $langs->trans('AccountancyCard'); 85 $h++; 86 87 if ($conf->use_preview_tabs) 88 { 89 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; 90 $head[$h][1] = $langs->trans("Preview"); 91 $hselected=$h; 92 $h++; 93 } 94 95 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; 96 $head[$h][1] = $langs->trans('Note'); 97 $h++; 98 99 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; 100 $head[$h][1] = $langs->trans('Info'); 101 $h++; 102 103 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id; 104 $head[$h][1] = $langs->trans('Documents'); 105 $h++; 106 107 dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal').': '.$propal->ref); 108 109 110 /* 111 * Propal 112 */ 113 $sql = 'SELECT s.nom, s.idp, p.price, p.fk_projet, p.remise, p.tva, p.total, p.ref, p.fk_statut, '.$db->pdate('p.datep').' as dp, p.note,'; 114 $sql.= ' x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture'; 115 $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'socpeople as x'; 116 $sql.= ' WHERE p.fk_soc = s.idp AND p.fk_soc_contact = x.idp AND p.rowid = '.$propal->id; 117 if ($socidp) $sql .= ' AND s.idp = '.$socidp; 118 119 $result = $db->query($sql); 120 121 122 123 124 if ($result) { 125 if ($db->num_rows($result)) { 126 $obj = $db->fetch_object($result); 127 128 $societe = new Societe($db); 129 $societe->fetch($obj->idp); 130 131 print '<table class="border" width="100%">'; 132 $rowspan=3; 133 // ligne 1 134 // partie Gauche 135 print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">'; 136 if ($societe->client == 1) 137 { 138 $url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$societe->id; 139 } 140 else 141 { 142 $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id; 143 } 144 print '<a href="'.$url.'">'.$societe->nom.'</a></td>'; 145 // partie Droite 146 print '<td align="left">Conditions de réglement</td>'; 147 print '<td>'.' '.'</td>'; 148 print '</tr>'; 149 150 // ligne 2 151 // partie Gauche 152 print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'; 153 print dolibarr_print_date($propal->date,'%a %e %B %Y'); 154 print '</td>'; 155 156 // partie Droite 157 print '<td>'.$langs->trans('DateEndPropal').'</td><td>'; 158 if ($propal->fin_validite) { 159 print dolibarr_print_date($propal->fin_validite,'%a %d %B %Y'); 160 } else { 161 print $langs->trans("Unknown"); 162 } 163 print '</td>'; 164 print '</tr>'; 165 166 // Destinataire 167 $langs->load('mails'); 168 // ligne 3 169 print '<tr>'; 170 // partie Gauche 171 print '<td>'.$langs->trans('MailTo').'</td>'; 172 173 $dests=$societe->contact_array($societe->id); 174 $numdest = count($dests); 175 print '<td colspan="3">'; 176 if ($numdest==0) { 177 print '<font class="error">Cette societe n\'a pas de contact, veuillez en créer un avant de faire votre proposition commerciale</font><br>'; 178 print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$societe->id.'&action=create&backtoreferer=1">'.$langs->trans('AddContact').'</a>'; 179 } else { 180 if (!empty($propal->contactid)) { 181 require_once(DOL_DOCUMENT_ROOT.'/contact.class.php'); 182 $contact=new Contact($db); 183 $contact->fetch($propal->contactid); 184 print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$propal->contactid.'" title="'.$langs->trans('ShowContact').'">'; 185 print $contact->firstname.' '.$contact->name; 186 print '</a>'; 187 } else { 188 print ' '; 189 } 190 } 191 print '</td>'; 192 193 // partie Droite sur $rowspan lignes 194 print '<td colspan="2" rowspan="'.$rowspan.'" valign="top" width="50%">'; 195 196 197 /* 198 * Documents 199 */ 200 $propalref = sanitize_string($propal->ref); 201 $file = $conf->propal->dir_output . "/" . $propalref . "/" . $propalref . ".pdf"; 202 $filedetail = $conf->propal->dir_output . "/" . $propalref . "/" . $propalref . "-detail.pdf"; 203 $relativepath = "$propalref}/$propalref}.pdf"; 204 $relativepathdetail = "$propalref}/$propalref}-detail.pdf"; 205 206 // Chemin vers png aperçus 207 $relativepathimage = "$propalref}/$propalref}.pdf.png"; 208 $relativepathimagebis = "$propalref}/$propalref}.pdf.png.0"; 209 $fileimage = $file.".png"; // Si PDF d'1 page 210 $fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page 211 212 $var=true; 213 214 // Si fichier PDF existe 215 if (file_exists($file)) 216 { 217 $encfile = urlencode($file); 218 print_titre($langs->trans("Documents")); 219 print '<table class="border" width="100%">'; 220 221 print "<tr $bc[$var]><td>".$langs->trans("Propal")." PDF</td>"; 222 223 print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=propal&file='.urlencode($relativepath).'">'.$propal->ref.'.pdf</a></td>'; 224 print '<td align="right">'.filesize($file). ' bytes</td>'; 225 print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>'; 226 print '</tr>'; 227 228 // Si fichier detail PDF existe 229 if (file_exists($filedetail)) { // propal détaillée supplémentaire 230 print "<tr $bc[$var]><td>Propal détaillée</td>"; 231 232 print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=propal&file='.urlencode($relativepathdetail).'">'.$propal->ref.'-detail.pdf</a></td>'; 233 print '<td align="right">'.filesize($filedetail). ' bytes</td>'; 234 print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($filedetail)).'</td>'; 235 print '</tr>'; 236 } 237 print "</table>\n"; 238 239 // Conversion du PDF en image png si fichier png non existant 240 if (! file_exists($fileimage) && ! file_exists($fileimagebis)) 241 { 242 if (function_exists("imagick_readimage")) 243 { 244 $handle = imagick_readimage( $file ) ; 245 if ( imagick_iserror( $handle ) ) 246 { 247 $reason = imagick_failedreason( $handle ) ; 248 $description = imagick_faileddescription( $handle ) ; 249 250 print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n"; 251 } 252 imagick_convert( $handle, "PNG" ) ; 253 if ( imagick_iserror( $handle ) ) 254 { 255 $reason = imagick_failedreason( $handle ) ; 256 $description = imagick_faileddescription( $handle ) ; 257 print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n"; 258 } 259 imagick_writeimage( $handle, $file .".png"); 260 } else { 261 $langs->load("other"); 262 print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>'; 263 } 264 } 265 } 266 print "</td></tr>"; 267 268 269 // ligne 4 270 // partie Gauche 271 print '<tr><td height="10" nowrap>'.$langs->trans('GlobalDiscount').'</td>'; 272 print '<td colspan="3">'.$propal->remise_percent.'%</td>'; 273 print '</tr>'; 274 275 // ligne 5 276 // partie Gauche 277 print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>'; 278 print '<td align="right" colspan="2"><b>'.price($propal->price).'</b></td>'; 279 print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; 280 print '</table>'; 281 } 282 } else { 283 dolibarr_print_error($db); 284 } 285 } else { 286 // Propal non trouvée 287 print $langs->trans("ErrorPropalNotFound",$_GET["propalid"]); 288 } 289 } 290 291 // Si fichier png PDF d'1 page trouvé 292 if (file_exists($fileimage)) 293 { 294 print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&file='.urlencode($relativepathimage).'">'; 295 } 296 // Si fichier png PDF de plus d'1 page trouvé 297 elseif (file_exists($fileimagebis)) 298 { 299 print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&file='.urlencode($relativepathimagebis).'">'; 300 } 301 302 303 print '</div>'; 304 305 306 // Juste pour éviter bug IE qui réorganise mal div précédents si celui-ci absent 307 print '<div class="tabsAction">'; 308 print '</div>'; 309 310 311 $db->close(); 312 313 llxFooter('$Date: 2006/01/04 20:18:03 $ - $Revision: 1.7.2.1 $'); 314 ?>
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 |
![]() |