From 8c870e6185c4e6034548582658c35580c7a1278e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 14 Nov 2008 11:56:47 +0000 Subject: [PATCH] Fix: Generation of donation receipts --- htdocs/compta/dons/fiche.php | 52 ++++++++++++++++++++++++---------- htdocs/compta/facture.php | 1 + htdocs/document.php | 2 +- htdocs/html.formfile.class.php | 12 +++++++- 4 files changed, 50 insertions(+), 17 deletions(-) diff --git a/htdocs/compta/dons/fiche.php b/htdocs/compta/dons/fiche.php index 1369c814f25..cac6deb194b 100644 --- a/htdocs/compta/dons/fiche.php +++ b/htdocs/compta/dons/fiche.php @@ -15,18 +15,17 @@ * 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$ */ /** - \file htdocs/compta/dons/fiche.php - \ingroup don - \brief Page de fiche de don - \version $Revision$ -*/ + * \file htdocs/compta/dons/fiche.php + * \ingroup don + * \brief Page de fiche de don + * \version $Id$ + */ require_once("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/includes/modules/dons/modules_don.php"); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/don.class.php"); require_once(DOL_DOCUMENT_ROOT."/paiement.class.php"); @@ -45,7 +44,6 @@ $mesg=""; if ($_POST["action"] == 'update') { - if ($_POST["amount"] > 0) { @@ -83,7 +81,6 @@ if ($_POST["action"] == 'update') if ($_POST["action"] == 'add') { - if ($_POST["amount"] > 0) { $don = new Don($db); @@ -162,13 +159,39 @@ if ($_GET["action"] == 'set_encaisse') /* * Générer ou regénérer le document */ -if ($_GET['action'] == 'builddoc') +if ($_REQUEST['action'] == 'builddoc') { - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/dons/modules_don.php"); - $result=don_create($db, $_GET['rowid']); + $donation = new Don($db, 0, $_GET['rowid']); + $donation->fetch($_GET['rowid']); + + if ($_REQUEST['model']) + { + $donation->setDocModel($user, $_REQUEST['model']); + } + + $outputlangs = $langs; + if (! empty($_REQUEST['lang_id'])) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + $result=don_create($db, $donation->id, '', $donation->modelpdf, $outputlangs); + if ($result <= 0) + { + dolibarr_print_error($db,$result); + exit; + } + else + { + Header ('Location: '.$_SERVER["PHP_SELF"].'?rowid='.$donation->id.'#builddoc'); + exit; + } } +/* + * View + */ llxHeader(); @@ -427,13 +450,13 @@ if ($_GET["rowid"] && $_GET["action"] != 'edit') $urlsource=$_SERVER['PHP_SELF'].'?rowid='.$don->id; // $genallowed=($fac->statut == 1 && ($fac->paye == 0 || $user->admin) && $user->rights->facture->creer); // $delallowed=$user->rights->facture->supprimer; - $genallowed=0; + $genallowed=1; $delallowed=0; $var=true; print '
'; - $formfile->show_documents('don',$filename,$filedir,$urlsource,$genallowed,$delallowed); + $formfile->show_documents('donation',$filename,$filedir,$urlsource,$genallowed,$delallowed); print ' '; @@ -446,5 +469,4 @@ if ($_GET["rowid"] && $_GET["action"] != 'edit') $db->close(); llxFooter('$Date$ - $Revision$'); - ?> diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c847e61db20..896c9e14ac4 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1261,6 +1261,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post else { Header ('Location: '.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'#builddoc'); + exit; } } diff --git a/htdocs/document.php b/htdocs/document.php index 562445688a0..5eea18de65e 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -335,7 +335,7 @@ if ($modulepart) } // Wrapping pour les dons - if ($modulepart == 'don') + if ($modulepart == 'donation') { $user->getrights('don'); if ($user->rights->don->lire || eregi('^specimen',$original_file)) diff --git a/htdocs/html.formfile.class.php b/htdocs/html.formfile.class.php index 1a5f483f1c5..2a2bab7eff4 100644 --- a/htdocs/html.formfile.class.php +++ b/htdocs/html.formfile.class.php @@ -259,6 +259,16 @@ class FormFile // ?? } } + elseif ($modulepart == 'donation') + { + if (is_array($genallowed)) $modellist=$genallowed; + else + { + include_once(DOL_DOCUMENT_ROOT.'/includes/modules/dons/modules_don.php'); + $model=new ModeleDon(); + $modellist=$model->liste_modeles($this->db); + } + } else if ($modulepart == 'unpayed') { $modellist=''; @@ -337,7 +347,7 @@ class FormFile $relativepath=$file["name"]; // Cas general if ($filename) $relativepath=$filename."/".$file["name"]; // Cas propal, facture... // Autre cas - if ($modulepart == 'don') { $relativepath = get_exdir($filename,2).$file["name"]; } + if ($modulepart == 'donation') { $relativepath = get_exdir($filename,2).$file["name"]; } if ($modulepart == 'export') { $relativepath = $file["name"]; } if (!$iconPDF) print "";