* Copyright (C) 2004-2006 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$ * $Source$ */ /** \file htdocs/compta/dons/fiche.php \ingroup don \brief Page de fiche de don \version $Revision$ */ require_once("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/don.class.php"); require_once(DOL_DOCUMENT_ROOT."/paiement.class.php"); $langs->load("companies"); $langs->load("donations"); $langs->load("bills"); $mesg=""; /* * Actions */ if ($_POST["action"] == 'update') { if ($_POST["amount"] > 0) { $don = new Don($db); $don->id = $_POST["rowid"]; $don->fetch($_POST["rowid"]); $don->prenom = $_POST["prenom"]; $don->nom = $_POST["nom"]; $don->societe = $_POST["societe"]; $don->adresse = $_POST["adresse"]; $don->amount = $_POST["amount"]; $don->cp = $_POST["cp"]; $don->ville = $_POST["ville"]; $don->email = $_POST["email"]; $don->date = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $don->note = $_POST["note"]; $don->pays = $_POST["pays"]; $don->public = $_POST["public"]; $don->projetid = $_POST["projetid"]; $don->commentaire = $_POST["comment"]; $don->modepaiementid = $_POST["modepaiement"]; if ($don->update($user) > 0) { Header("Location: fiche.php?rowid=".$don->id); exit; } } else { $mesg="Montant non défini"; } } if ($_POST["action"] == 'add') { if ($_POST["amount"] > 0) { $don = new Don($db); $don->prenom = $_POST["prenom"]; $don->nom = $_POST["nom"]; $don->societe = $_POST["societe"]; $don->adresse = $_POST["adresse"]; $don->amount = $_POST["amount"]; $don->cp = $_POST["cp"]; $don->ville = $_POST["ville"]; $don->email = $_POST["email"]; $don->date = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); $don->note = $_POST["note"]; $don->pays = $_POST["pays"]; $don->public = $_POST["public"]; $don->projetid = $_POST["projetid"]; $don->commentaire = $_POST["comment"]; $don->modepaiementid = $_POST["modepaiement"]; if ($don->create($user) > 0) { Header("Location: index.php"); exit; } } else { $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Amount")); $_GET["action"] = "create"; } } if ($_GET["action"] == 'delete') { $don = new Don($db); $don->delete($_GET["rowid"]); Header("Location: liste.php"); exit; } if ($_POST["action"] == 'commentaire') { $don = new Don($db); $don->set_commentaire($_POST["rowid"],$_POST["commentaire"]); $_GET["rowid"] = $_POST["rowid"]; } if ($_GET["action"] == 'valid_promesse') { $don = new Don($db); if ($don->valid_promesse($_GET["rowid"], $user->id)) { Header("Location: fiche.php?rowid=".$_GET["rowid"]); exit; } } if ($_GET["action"] == 'set_payed') { $don = new Don($db); if ($don->set_paye($_GET["rowid"], $modepaiement)) { Header("Location: fiche.php?rowid=".$_GET["rowid"]); exit; } } if ($_GET["action"] == 'set_encaisse') { $don = new Don($db); if ($don->set_encaisse($_GET["rowid"])) { Header("Location: liste.php"); exit; } } /* * Générer ou regénérer le document */ if ($_GET['action'] == 'builddoc') { require_once(DOL_DOCUMENT_ROOT ."/includes/modules/dons/modules_don.php"); $result=don_create($db, $_GET['rowid']); } llxHeader(); $html=new Form($db); /* ************************************************************************** */ /* */ /* Création d'une fiche don */ /* */ /* ************************************************************************** */ if ($_GET["action"] == 'create') { print_titre($langs->trans("AddDonation")); print '
'; print ''; print ''; print ''; $nbrows=11; if ($conf->projet->enabled) $nbrows++; print '"; print "\n"; if ($conf->projet->enabled) { // Si module projet actif print "\n"; } print "\n"; print "".''; print "".''; print "".''; print "".''; print "".''; print "".''; print "".''; print "".''; print "".''; print "
'.$langs->trans("Date").''; $html->select_date('','','','','',"add"); print ''.$langs->trans("Comments").' :
'; print "
".$langs->trans("PaymentMode")."\n"; $form = new Form($db); $form->select_types_paiements('', 'modepaiement', 'CRDT', 0); print "
".$langs->trans("Project").""; $html->select_projects('','','',"projetid"); print "
".$langs->trans("PublicDonation").""; $html=new Form($db); print $html->selectyesno("public",1,1); print "
'.$langs->trans("Company").'
'.$langs->trans("Firstname").'
'.$langs->trans("Lastname").'
'.$langs->trans("Address").''; print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").'
'.$langs->trans("Country").'
'.$langs->trans("EMail").'
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->monnaie).'
\n"; print "
\n"; } /* ************************************************************ */ /* */ /* Fiche don en mode edition */ /* */ /* ************************************************************ */ if ($_GET["rowid"] && $_GET["action"] == 'edit') { $don = new Don($db); $don->id = $_GET["rowid"]; $don->fetch($_GET["rowid"]); $h=0; $head[$h][0] = DOL_URL_ROOT."/compta/dons/fiche.php?rowid=".$_GET["rowid"]; $head[$h][1] = $langs->trans("Donation"); $hselected=$h; $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("Ref").": ".$_GET["rowid"]); print '
'; print ''; print ''; print ''; print "".''; $nbrows=12; if ($conf->projet->enabled) $nbrows++; print '"; if ($conf->projet->enabled) { print "\n"; } print ""; print "\n"; $langs->load("companies"); print "".''; print "".''; print "".''; print "".''; print "".''; print "".''; print "".''; print "".''; print "\n"; print "".''; print "".''; print "
'.$langs->trans("Date").''; $html->select_date($don->date,'','','','',"update"); print ''.$langs->trans("Comments").' :
'; print "
".$langs->trans("Project")."
"; print "
".$langs->trans("PublicDonation").""; $html=new Form($db); print $html->selectyesno("public",1,1); print "
'.$langs->trans("Company").'
'.$langs->trans("Firstname").'
'.$langs->trans("Lastname").'
'.$langs->trans("Address").''; print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").'
'.$langs->trans("Country").'
'.$langs->trans("EMail").'
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->monnaie).'
".$langs->trans("PaymentMode")."\n"; $form = new Form($db); $form->select_types_paiements('', 'modepaiement', 'CRDT', 0); print "
'.$langs->trans("Status").''.$don->getLibStatut(4).'
\n"; print "
\n"; print "\n"; } /* ************************************************************ */ /* */ /* Fiche don en mode visu */ /* */ /* ************************************************************ */ if ($_GET["rowid"] && $_GET["action"] != 'edit') { $don = new Don($db); $don->id = $_GET["rowid"]; $don->fetch($_GET["rowid"]); $h=0; $head[$h][0] = DOL_URL_ROOT."/compta/dons/fiche.php?rowid=".$_GET["rowid"]; $head[$h][1] = $langs->trans("Donation"); $hselected=$h; $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("Ref").": ".$_GET["rowid"]); print "
"; print ''; print ""; $nbrows=12; if ($conf->projet->enabled) $nbrows++; print ''; if ($conf->projet->enabled) { print "".''; } print "\n"; print "".''; print "".''; print "".''; print "".''; print "".''; print "".''; print "".''; print "".''; print "\n"; print "".''; print "
".$langs->trans("Date").""; print dolibarr_print_date($don->date,"day"); print "'.$langs->trans("Comments").' :
'; print nl2br($don->commentaire).'
'.$langs->trans("Project").''.$don->projet.'
".$langs->trans("PublicDonation").""; print $yn[$don->public]; print "
'.$langs->trans("Company").''.$don->societe.'
'.$langs->trans("Firstname").''.$don->prenom.'
'.$langs->trans("Lastname").''.$don->nom.'
'.$langs->trans("Address").''.nl2br($don->adresse).'
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$don->cp.' '.$don->ville.'
'.$langs->trans("Country").''.$don->pays.'
'.$langs->trans("EMail").''.$don->email.'
'.$langs->trans("Amount").''.price($don->amount).' '.$langs->trans("Currency".$conf->monnaie).'
".$langs->trans("PaymentMode").""; print $don->modepaiement; print "
'.$langs->trans("Status").''.$don->getLibStatut(4).'
\n"; print "
\n"; print ""; /** * Barre d'actions */ print '
'; print ''.$langs->trans('Edit').''; if ($don->statut == 0) { print ''.$langs->trans("ValidPromess").''; } // \todo Gérer action émettre paiement if ($don->statut == 1 && $resteapayer > 0) { print "".$langs->trans("DoPayment").""; } if ($don->statut == 1 && abs($resteapayer) == 0 && $don->paye == 0) { print "id&action=set_payed\">".$langs->trans("ClassifyPayed").""; } if ($don->statut == 2 || $don->statut == 3) { print ' '.$langs->trans('BuildDonationReceipt').''; } if ($don->statut == 0) { print "id&action=delete\">".$langs->trans("Delete").""; } print "
"; print ''; print '
'; /* * Documents générés */ $filename=sanitize_string($don->id); $filedir=$conf->don->dir_output . '/' . get_exdir($filename,2); $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; $delallowed=0; $var=true; print '
'; $html->show_documents('don',$filename,$filedir,$urlsource,$genallowed,$delallowed); print '
 
'; } $db->close(); llxFooter('$Date$ - $Revision$'); ?>