diff --git a/htdocs/adherents/adherent_type.class.php b/htdocs/adherents/adherent_type.class.php index 6532efd0f3b..7a2f0ba4288 100644 --- a/htdocs/adherents/adherent_type.class.php +++ b/htdocs/adherents/adherent_type.class.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2002 Rodolphe Quiedeville + * 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 @@ -20,14 +21,16 @@ * */ -/** \file htdocs/adherents/adherent_type.class.php +/** + \file htdocs/adherents/adherent_type.class.php \ingroup adherent \brief Fichier de la classe gérant les types d'adhérents \author Rodolphe Quiedeville \version $Revision$ */ -/** \class AdherentType +/** + \class AdherentType \brief Classe gérant les types d'adhérents */ @@ -41,7 +44,8 @@ class AdherentType var $errorstr; var $mail_valid; /**< mail envoye lors de la validation */ var $commentaire; /**< commentaire */ - var $vote; /** droit de vote ? */ + var $vote; /** droit de vote ? */ + /** \brief AdherentType @@ -54,6 +58,7 @@ class AdherentType $this->statut = 1; } + /** \brief print_error_list */ @@ -67,16 +72,16 @@ class AdherentType } } + /** - \brief fonction qui permet de créer le status de l'adhérent - \param userid userid de l'adhérent + \brief Fonction qui permet de créer le status de l'adhérent + \param userid userid de l'adhérent + \return > 0 si ok, < 0 si ko */ function create($userid) { - /* - * Insertion dans la base - */ + $this->statut=trim($this->statut); $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (statut)"; $sql .= " VALUES ($this->statut)"; @@ -90,12 +95,18 @@ class AdherentType } else { - return 0; + return -1; } } + +/** + \brief Met a jour en base données du type + \return > 0 si ok, < 0 si ko +*/ function update() { + $this->libelle=trim($this->libelle); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type SET "; $sql .= "libelle = '".$this->libelle ."'"; @@ -115,15 +126,14 @@ class AdherentType } else { - print $this->db->error(); - print "


$sql

"; - return 0; + $error=$this->db->error(); + return -1; } } /** - \brief fonction qui permet de supprimer le status de l'adhérent - \param rowid + \brief Fonction qui permet de supprimer le status de l'adhérent + \param rowid */ function delete($rowid) @@ -156,30 +166,29 @@ class AdherentType function fetch($rowid) { - $sql = "SELECT *"; + $sql = "SELECT d.rowid, d.libelle, d.statut, d.cotisation, d.mail_valid, d.note, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.rowid = $rowid"; - + if ( $this->db->query( $sql) ) - { - if ($this->db->num_rows()) - { - - $obj = $this->db->fetch_object(); - - $this->id = $obj->rowid; - $this->libelle = $obj->libelle; - $this->statut = $obj->statut; - $this->cotisation = $obj->cotisation; - $this->mail_valid = $obj->mail_valid; - $this->commentaire = $obj->note; - $this->vote = $obj->vote; - } - } + { + if ($this->db->num_rows()) + { + $obj = $this->db->fetch_object(); + + $this->id = $obj->rowid; + $this->libelle = $obj->libelle; + $this->statut = $obj->statut; + $this->cotisation = $obj->cotisation; + $this->mail_valid = $obj->mail_valid; + $this->commentaire = $obj->note; + $this->vote = $obj->vote; + } + } else - { - print $this->db->error(); - } + { + print $this->db->error(); + } } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 24b1f6abdf3..fc747c55cae 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -41,15 +41,21 @@ if ($_POST["action"] == 'add' && $user->admin) if ($_POST["button"] != $langs->trans("Cancel")) { $adht = new AdherentType($db); - $adht->libelle = $_POST["libelle"]; + $adht->libelle = trim($_POST["libelle"]); $adht->cotisation = $yesno[$_POST["cotisation"]]; - $adht->commentaire = $_POST["comment"]; - $adht->mail_valid = $_POST["mail_valid"]; + $adht->commentaire = trim($_POST["comment"]); + $adht->mail_valid = trim($_POST["mail_valid"]); $adht->vote = $yesno[$_POST["vote"]]; - if ($_POST["libelle"]) { $adht->create($user->id); } + if ($adht->libelle) + { + $id=$adht->create($user->id); + if ($id > 0) + { + Header("Location: type.php"); + } + } } - Header("Location: type.php"); } if ($_POST["action"] == 'update' && $user->admin) @@ -170,11 +176,11 @@ if ($_GET["action"] == 'create') { print ''.$langs->trans("Label").''; print ''.$langs->trans("SubscriptionRequired").''; - $htmls->selectyesno("cotisation",""); + $htmls->selectyesnonum("cotisation",""); print ''; print ''.$langs->trans("VoteAllowed").''; - $htmls->selectyesno("vote",""); + $htmls->selectyesnonum("vote",""); print ''; print ''.$langs->trans("Comments").''; @@ -215,11 +221,11 @@ if ($_GET["rowid"] > 0 && $_GET["action"] == 'edit') print ''.$langs->trans("Label").''; print ''.$langs->trans("SubscriptionRequired").''; - $htmls->selectyesno("cotisation",$adht->cotisation); + $htmls->selectyesnonum("cotisation",$adht->cotisation); print ''; print ''.$langs->trans("VoteAllowed").''; - $htmls->selectyesno("vote",$adht->vote); + $htmls->selectyesnonum("vote",$adht->vote); print ''; print ''.$langs->trans("Comments").''; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 8361a803b68..af9eba35e66 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -847,27 +847,27 @@ class Form function selectyesno($name,$value='',$option=0) { global $langs; - + $yes="yes"; $no="no"; - if ($option) - { - $yes="1"; - $no="0"; - } - + if ($option) + { + $yes="1"; + $no="0"; + } + print ''."\n"; }