* Copyright (C) 2004 Éric Seigne * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005 Regis Houssin * * 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. */ /** \file htdocs/comm/propal/apercu.php \ingroup propal \brief Page de l'onglet aperçu d'une propal \version $Id$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/propal.class.php'); require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php"); if ($conf->projet->enabled) { require_once(DOL_DOCUMENT_ROOT."/project.class.php"); } $langs->load('propal'); $langs->load("bills"); $langs->load('compta'); $propalid = isset($_GET["propalid"])?$_GET["propalid"]:''; // Security check if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'propale', $propalid, 'propal'); /* * View */ llxHeader(); $html = new Form($db); /* *************************************************************************** */ /* */ /* Mode fiche */ /* */ /* *************************************************************************** */ if ($_GET["propalid"] > 0) { $propal = new Propal($db); if ( $propal->fetch($_GET["propalid"], $user->societe_id) > 0) { $soc = new Societe($db, $propal->socid); $soc->fetch($propal->socid); $head = propal_prepare_head($propal); dolibarr_fiche_head($head, 'preview', $langs->trans('Proposal')); /* * Propal */ $sql = 'SELECT s.nom, s.rowid, p.price, p.fk_projet, p.remise, p.tva, p.total, p.ref, p.fk_statut, '.$db->pdate('p.datep').' as dp, p.note,'; $sql.= ' p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p'; $sql.= ' WHERE p.fk_soc = s.rowid AND p.rowid = '.$propal->id; $result = $db->query($sql); if ($result) { if ($db->num_rows($result)) { $obj = $db->fetch_object($result); $societe = new Societe($db); $societe->fetch($obj->rowid); print ''; // Ref print ''; // Ref client print ''; print ''; $rowspan=2; // Tiers print ''; print ''; // Ligne info remises tiers print ''; // ligne // partie Gauche print ''; // partie Droite sur $rowspan lignes print '"; print ''; print ''; print ''; print ''; print '
'.$langs->trans('Ref').''.$propal->ref.'
'; print ''; print '
'; print $langs->trans('RefCustomer').''; print '
'; print '
'; print $propal->ref_client; print '
'.$langs->trans('Company').''.$societe->getNomUrl(1).'
'.$langs->trans('Discounts').''; if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client); else print $langs->trans("CompanyHasNoRelativeDiscount"); $absolute_discount=$societe->getAvailableDiscounts(); print '. '; if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie)); else print $langs->trans("CompanyHasNoAbsoluteDiscount"); print '.'; print '
'.$langs->trans('Date').''; print dolibarr_print_date($propal->date,'daytext'); print ''; /* * Documents */ $propalref = sanitize_string($propal->ref); $dir_output = $conf->propal->dir_output . "/"; $filepath = $dir_output . $propalref . "/"; $file = $filepath . $propalref . ".pdf"; $filedetail = $filepath . $propalref . "-detail.pdf"; $relativepath = "${propalref}/${propalref}.pdf"; $relativepathdetail = "${propalref}/${propalref}-detail.pdf"; // Chemin vers png aperçus $relativepathimage = "${propalref}/${propalref}.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)) { // propal détaillée supplémentaire print ""; print ''; print ''; print ''; print ''; } print "
".$langs->trans("Propal")." PDF'.$propal->ref.'.pdf'.filesize($file). ' bytes'.dolibarr_print_date(filemtime($file),'dayhour').'
Propal détaillée'.$propal->ref.'-detail.pdf'.filesize($filedetail). ' bytes'.dolibarr_print_date(filemtime($filedetail),'dayhour').'
\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($propal->price).''.$langs->trans("Currency".$conf->monnaie).'
'; } } else { dolibarr_print_error($db); } } else { // Propal non trouvée print $langs->trans("ErrorPropalNotFound",$_GET["propalid"]); } } // 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$'); ?>