* Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2007 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/adherents/type.php \ingroup adherent \brief Page de configuration des types d'adhérents \version $Revision$ */ require("./pre.inc.php"); require(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); require(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php"); $langs->load("members"); $user->getrights('adherent'); $rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"]; /* * Actions */ if ($_POST["action"] == 'add') { if (! $user->rights->adherent->configurer) accessforbidden(); if ($_POST["button"] != $langs->trans("Cancel")) { $adht = new AdherentType($db); $adht->libelle = trim($_POST["libelle"]); $adht->cotisation = trim($_POST["cotisation"]); $adht->commentaire = trim($_POST["comment"]); $adht->mail_valid = trim($_POST["mail_valid"]); $adht->vote = trim($_POST["vote"]); if ($adht->libelle) { $id=$adht->create($user->id); if ($id > 0) { Header("Location: type.php"); exit; } } else { $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")); $_GET["action"] = 'create'; } } } if ($_POST["action"] == 'update') { if (! $user->rights->adherent->creer) accessforbidden(); if ($_POST["button"] != $langs->trans("Cancel")) { $adht = new AdherentType($db); $adht->id = $_POST["rowid"]; $adht->libelle = trim($_POST["libelle"]); $adht->cotisation = trim($_POST["cotisation"]); $adht->commentaire = trim($_POST["comment"]); $adht->mail_valid = trim($_POST["mail_valid"]); $adht->vote = trim($_POST["vote"]); $adht->update($user->id); Header("Location: type.php?rowid=".$_POST["rowid"]); exit; } } if ($_GET["action"] == 'delete') { $adht = new AdherentType($db); $adht->delete($rowid); Header("Location: ".$_SERVER["PHP_SELF"]); exit; } if ($_GET["action"] == 'commentaire') { $don = new Don($db); $don->set_commentaire($rowid,$_POST["commentaire"]); } llxHeader(); /* ************************************************************************** */ /* */ /* Liste des types d'adhérents */ /* */ /* ************************************************************************** */ if (! $rowid && $_GET["action"] != 'create' && $_GET["action"] != 'edit') { print_titre($langs->trans("MembersTypeSetup")); print '
'; $sql = "SELECT d.rowid, d.libelle, d.cotisation, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $var=True; while ($i < $num) { $objp = $db->fetch_object($result); $var=!$var; print ""; print ''; print ''; print ''; print ''; print ''; print ""; $i++; } print "
'.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("SubscriptionRequired").''.$langs->trans("VoteAllowed").' 
'.img_object($langs->trans("ShwoType"),'group').' '.$objp->rowid.''.$objp->libelle.''.yn($objp->cotisation).''.yn($objp->vote).''.img_edit().'
"; } else { dolibarr_print_error($db); } /* * Barre d'actions * */ print '
'; // New type if ($user->rights->adherent->configurer) { print "".$langs->trans("NewType").""; } print "
"; } /* ************************************************************************** */ /* */ /* Création d'un type adherent */ /* */ /* ************************************************************************** */ if ($_GET["action"] == 'create') { $htmls = new Form($db); print_titre($langs->trans("NewMemberType")); print '
'; if ($mesg) print '
'.$mesg.'
'; print "
"; print ''; print ''; print ''; print ''; print ''; print '"; print ''; print ''; print "\n"; print "
'.$langs->trans("Label").'
'.$langs->trans("SubscriptionRequired").''; $htmls->selectyesnonum("cotisation",1); print '
'.$langs->trans("VoteAllowed").''; $htmls->selectyesnonum("vote",0); print '
'.$langs->trans("Comments").''; print "
'.$langs->trans("WelcomeEMail").''; if ($conf->fckeditor->enabled) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); $doleditor=new DolEditor('mail_valid',$adht->mail_valid,280,'dolibarr_notes','',false); $doleditor->Create(); } else { print ''; } print '
 '; print '
\n"; } /* ************************************************************************** */ /* */ /* Edition de la fiche */ /* */ /* ************************************************************************** */ if ($rowid > 0) { if ($_GET["action"] != 'edit') { $adht = new AdherentType($db); $adht->id = $rowid; $adht->fetch($rowid); $h=0; $head[$h][0] = $_SERVER["PHP_SELF"].'?rowid='.$adht->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; dolibarr_fiche_head($head, 'card', $langs->trans("MemberType")); print ''; print ''; print ''; print ''; print ''; print '"; print '"; print '
'.$langs->trans("Ref").''.$adht->id.'
'.$langs->trans("Label").''.$adht->libelle.'
'.$langs->trans("SubscriptionRequired").''; print yn($adht->cotisation); print '
'.$langs->trans("VoteAllowed").''; print yn($adht->vote); print '
'.$langs->trans("Comments").''; print nl2br($adht->commentaire)."
'.$langs->trans("WelcomeEMail").''; print nl2br($adht->mail_valid)."
'; print ''; /* * Barre d'actions * */ print '
'; // Edit if ($user->rights->adherent->configurer) { print "id."\">".$langs->trans("Edit").""; } // Add print "id."\">".$langs->trans("AddMember").""; // Delete if ($user->rights->adherent->configurer) { print "id."\">".$langs->trans("DeleteType").""; } print "
"; } if ($_GET["action"] == 'edit') { $htmls = new Form($db); $adht = new AdherentType($db); $adht->id = $rowid; $adht->fetch($rowid); $h=0; $head[$h][0] = $_SERVER["PHP_SELF"].'?rowid='.$adht->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; dolibarr_fiche_head($head, 'card', $langs->trans("MemberType")); print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '"; print '"; print ''; print '
'.$langs->trans("Ref").''.$adht->id.'
'.$langs->trans("Label").'
'.$langs->trans("SubscriptionRequired").''; $htmls->selectyesnonum("cotisation",$adht->cotisation); print '
'.$langs->trans("VoteAllowed").''; $htmls->selectyesnonum("vote",$adht->vote); print '
'.$langs->trans("Comments").''; print "
'.$langs->trans("WelcomeEMail").''; if ($conf->fckeditor->enabled) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); $doleditor=new DolEditor('mail_valid',$adht->mail_valid,280,'dolibarr_notes','',false); $doleditor->Create(); } else { print ''; } print "
   '; print '
'; print "
"; } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>