diff -ur --exclude=CVS --exclude=install --exclude=conf.php --unidirectional-new-file dolibarrcvs/htdocs/comm/propal/apercu.php dolibarr/htdocs/comm/propal/apercu.php --- dolibarrcvs/htdocs/comm/propal/apercu.php 1969-12-31 20:00:00.000000000 -0400 +++ dolibarr/htdocs/comm/propal/apercu.php 2005-08-12 18:08:54.000000000 -0400 @@ -0,0 +1,286 @@ + + * 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: apercu.php,v 1.0 2005/07/16 11:10:39 chris Exp $ + * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/propal/apercu.php,v $ + * + */ + +/** + \file htdocs/comm/propal/apercu.php + \ingroup propal + \brief Page de l'onglet aperçu d'une propal + \version $Revision: 1.0 $ +*/ + +require("./pre.inc.php"); + +$user->getrights('propale'); + +if (!$user->rights->propale->lire) + accessforbidden(); + +$langs->load('propal'); +$langs->load("bills"); + + +require_once(DOL_DOCUMENT_ROOT.'/comm/propal_model_pdf.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/propal.class.php'); +if ($conf->projet->enabled) { + require_once(DOL_DOCUMENT_ROOT."/project.class.php"); +} + + +/* + * Sécurité accés client +*/ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} + +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->socidp); + $soc->fetch($propal->socidp); + + $h=0; + + $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('CommercialCard'); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('AccountancyCard'); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans("Preview"); + $hselected=$h; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('Note'); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('Info'); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans('Documents'); + $h++; + + dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal').': '.$propal->ref); + + + /* + * Propal + */ + $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,'; + $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'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'socpeople as x'; + $sql.= ' WHERE p.fk_soc = s.idp AND p.fk_soc_contact = x.idp AND p.rowid = '.$propal->id; + if ($socidp) $sql .= ' AND s.idp = '.$socidp; + + $result = $db->query($sql); + + + + + if ($result) { + if ($db->num_rows($result)) { + $obj = $db->fetch_object($result); + + $societe = new Societe($db); + $societe->fetch($obj->idp); + + print ''; + $rowspan=3; + // ligne 1 + // partie Gauche + print ''; + // partie Droite + print ''; + print ''; + print ''; + + // ligne 2 + // partie Gauche + print ''; + + // partie Droite + print ''; + print ''; + + // Destinataire + $langs->load('mails'); + // ligne 3 + print ''; + // partie Gauche + print ''; + + $dests=$societe->contact_array($societe->id); + $numdest = count($dests); + print ''; + + // partie Droite sur $rowspan lignes + print '"; + + + // ligne 4 + // partie Gauche + print ''; + print ''; + print ''; + + // ligne 5 + // partie Gauche + print ''; + print ''; + print ''; + print '
'.$langs->trans('Company').''; + if ($societe->client == 1) { + $url ='fiche.php?socid='.$societe->id; + } else { + $url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id; + } + print ''.$societe->nom.'Conditions de réglement'.' '.'
'.$langs->trans('Date').''; + print dolibarr_print_date($propal->date,'%a %e %B %Y'); + print ''.$langs->trans('DateEndPropal').''; + if ($propal->fin_validite) { + print dolibarr_print_date($propal->fin_validite); + } else { + print $langs->trans("Unknown"); + } + print '
'.$langs->trans('MailTo').''; + if ($numdest==0) { + print 'Cette societe n\'a pas de contact, veuillez en créer un avant de faire votre proposition commerciale
'; + print ''.$langs->trans('AddContact').''; + } else { + if (!empty($propal->contactid)) { + require_once(DOL_DOCUMENT_ROOT.'/contact.class.php'); + $contact=new Contact($db); + $contact->fetch($propal->contactid); + print ''; + print $contact->firstname.' '.$contact->name; + print ''; + } else { + print ' '; + } + } + print '
'; + + + /* + * Documents + * + */ + $propalref = sanitize_string($propal->ref); + $file = $conf->propal->dir_output . "/" . $propalref . "/" . $propalref . ".pdf"; + $filedetail = $conf->propal->dir_output . "/" . $propalref . "/" . $propalref . "-detail.pdf"; + $relativepath = "${propalref}/${propalref}.pdf"; + $relativepathdetail = "${propalref}/${propalref}-detail.pdf"; + $relativepathimage = "${propalref}/${propalref}.pdf.png"; + + $fileimage = $file.".png"; + + $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'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
Propal détaillée'.$propal->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)) { + 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_writeimage( $handle, $file .".png"); + } else { + $langs->load("other"); + print $langs->trans("ErrorNoImagickReadimage"); + } + } + } + print "
'.$langs->trans('GlobalDiscount').''.$propal->remise_percent.'%
'.$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"]); + } +} + +if (file_exists($fileimage)) + { + print ''; + } +print ''; + +$db->close(); + +llxFooter('$Date: 2005/08/12 11:10:39 $ - $Revision: 1.0 $'); +?> diff -ur --exclude=CVS --exclude=install --exclude=conf.php --unidirectional-new-file dolibarrcvs/htdocs/comm/propal/document.php dolibarr/htdocs/comm/propal/document.php --- dolibarrcvs/htdocs/comm/propal/document.php 2005-07-30 00:03:08.000000000 -0400 +++ dolibarr/htdocs/comm/propal/document.php 2005-08-12 16:29:25.000000000 -0400 @@ -105,6 +105,10 @@ $head[$h][1] = $langs->trans('AccountancyCard'); $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans("Preview"); + $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; $head[$h][1] = $langs->trans('Note'); $h++; diff -ur --exclude=CVS --exclude=install --exclude=conf.php --unidirectional-new-file dolibarrcvs/htdocs/comm/propal/info.php dolibarr/htdocs/comm/propal/info.php --- dolibarrcvs/htdocs/comm/propal/info.php 2005-07-10 20:49:17.000000000 -0400 +++ dolibarr/htdocs/comm/propal/info.php 2005-08-12 16:29:15.000000000 -0400 @@ -63,6 +63,10 @@ $head[$h][1] = $langs->trans('AccountancyCard'); $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans("Preview"); + $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; $head[$h][1] = $langs->trans('Note'); $h++; diff -ur --exclude=CVS --exclude=install --exclude=conf.php --unidirectional-new-file dolibarrcvs/htdocs/comm/propal/note.php dolibarr/htdocs/comm/propal/note.php --- dolibarrcvs/htdocs/comm/propal/note.php 2005-07-10 20:49:17.000000000 -0400 +++ dolibarr/htdocs/comm/propal/note.php 2005-08-12 16:28:59.000000000 -0400 @@ -83,6 +83,10 @@ $head[$h][1] = $langs->trans('AccountancyCard'); $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans("Preview"); + $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; $head[$h][1] = $langs->trans('Note'); $hselected=$h; diff -ur --exclude=CVS --exclude=install --exclude=conf.php --unidirectional-new-file dolibarrcvs/htdocs/comm/propal.php dolibarr/htdocs/comm/propal.php --- dolibarrcvs/htdocs/comm/propal.php 2005-08-11 22:25:48.000000000 -0400 +++ dolibarr/htdocs/comm/propal.php 2005-08-12 16:03:41.000000000 -0400 @@ -398,6 +398,10 @@ $head[$h][1] = $langs->trans('AccountancyCard'); $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans("Preview"); + $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; $head[$h][1] = $langs->trans('Note'); $h++; diff -ur --exclude=CVS --exclude=install --exclude=conf.php --unidirectional-new-file dolibarrcvs/htdocs/compta/propal.php dolibarr/htdocs/compta/propal.php --- dolibarrcvs/htdocs/compta/propal.php 2005-08-11 22:25:49.000000000 -0400 +++ dolibarr/htdocs/compta/propal.php 2005-08-12 16:28:42.000000000 -0400 @@ -107,6 +107,10 @@ $hselected=$h; $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; + $head[$h][1] = $langs->trans("Preview"); + $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; $head[$h][1] = $langs->trans('Note'); $h++; diff -ur --exclude=CVS --exclude=install --exclude=conf.php --unidirectional-new-file dolibarrcvs/htdocs/includes/modules/propale/modules_propale.php dolibarr/htdocs/includes/modules/propale/modules_propale.php --- dolibarrcvs/htdocs/includes/modules/propale/modules_propale.php 2004-12-23 13:52:48.000000000 -0400 +++ dolibarr/htdocs/includes/modules/propale/modules_propale.php 2005-08-12 18:19:10.000000000 -0400 @@ -127,6 +127,8 @@ if ( $obj->write_pdf_file($facid) > 0) { + // on supprime l'image correspondant au preview + propale_delete_preview($db, $facid); return 1; } else @@ -142,4 +144,33 @@ return 0; } } +/** + \brief Supprime l'image de prévisualitation, pour le cas de régénération de propal + \param db objet base de donnée + \param propalid id de la propal à effacer +*/ +function propale_delete_preview($db, $propalid) +{ + global $langs,$conf; + + $propal = new Propal($db,"",$propalid); + $propal->fetch($propalid); + $propal->fetch_client(); + + if ($conf->propal->dir_output) + { + $propalref = sanitize_string($propal->ref); + $dir = $conf->propal->dir_output . "/" . $propalref ; + $file = $dir . "/" . $propalref . ".pdf.png"; + + if ( file_exists( $file ) && is_writable( $file ) ) + { + if ( ! unlink($file) ) + { + $this->error=$langs->trans("ErrorFailedToOpenFile",$file); + return 0; + } + } + } +} ?> diff -ur --exclude=CVS --exclude=install --exclude=conf.php --unidirectional-new-file dolibarrcvs/htdocs/langs/fr_FR/propal.lang dolibarr/htdocs/langs/fr_FR/propal.lang --- dolibarrcvs/htdocs/langs/fr_FR/propal.lang 2005-08-11 22:25:53.000000000 -0400 +++ dolibarr/htdocs/langs/fr_FR/propal.lang 2005-08-12 16:44:44.000000000 -0400 @@ -57,4 +57,5 @@ ClassifyBilled=Classer facturée BuildBill=Créer facture RelatedBill=Facture associée -RelatedBills=Factures associées \ Pas de fin de ligne à la fin du fichier. +RelatedBills=Factures associées +ErrorPropalNotFound=Propal %s inexistante diff -ur --exclude=CVS --exclude=install --exclude=conf.php --unidirectional-new-file dolibarrcvs/htdocs/viewimage.php dolibarr/htdocs/viewimage.php --- dolibarrcvs/htdocs/viewimage.php 2005-08-01 01:32:47.000000000 -0400 +++ dolibarr/htdocs/viewimage.php 2005-08-12 17:44:13.000000000 -0400 @@ -70,6 +70,17 @@ $original_file=$conf->facture->dir_output.'/'.$original_file; } + // Wrapping pour les apercu propal + if ($modulepart == 'apercupropal') + { + $user->getrights('propale'); + if ($user->rights->propale->lire) + { + $accessallowed=1; + } + $original_file=$conf->propal->dir_output.'/'.$original_file; + } + // Wrapping pour les images des stats propales if ($modulepart == 'propalstats') {