From 55348c7381705686a9a3901f106a10b2dc2af833 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 May 2007 09:42:20 +0000 Subject: [PATCH] Fix: Gere erreur creation type adherent --- htdocs/adherents/adherent_type.class.php | 31 +++++++++++++----------- htdocs/adherents/type.php | 13 +++++++--- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/htdocs/adherents/adherent_type.class.php b/htdocs/adherents/adherent_type.class.php index d63051f873a..71b34d3fedd 100644 --- a/htdocs/adherents/adherent_type.class.php +++ b/htdocs/adherents/adherent_type.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * 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 @@ -18,7 +18,6 @@ * * $Id$ * $Source$ - * */ /** @@ -37,6 +36,10 @@ class AdherentType { + var $error; + var $errors=array(); + var $db; + var $id; var $libelle; var $statut; @@ -45,8 +48,6 @@ class AdherentType var $commentaire; /**< commentaire */ var $mail_valid; /**< mail envoye lors de la validation */ - var $error; - var $db; /** @@ -83,8 +84,8 @@ class AdherentType { $this->statut=trim($this->statut); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (statut)"; - $sql.= " VALUES ($this->statut)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (libelle)"; + $sql.= " VALUES ('".addslashes($this->libelle)."')"; dolibarr_syslog("Adherent_type::create sql=".$sql); $result = $this->db->query($sql); @@ -95,6 +96,7 @@ class AdherentType } else { + $this->error=$this->db->error().' sql='.$sql; return -1; } } @@ -108,13 +110,14 @@ class AdherentType { $this->libelle=trim($this->libelle); - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type SET "; - $sql .= "libelle = '".$this->libelle ."'"; - $sql .= ",statut=".$this->statut; - $sql .= ",cotisation='".$this->cotisation."'"; - $sql .= ",note='".$this->commentaire."'"; - $sql .= ",vote='".$this->vote."'"; - $sql .= ",mail_valid='".$this->mail_valid."'"; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type "; + $sql.= "SET "; + $sql.= "statut=".$this->statut.","; + $sql.= "libelle = '".addslashes($this->libelle) ."',"; + $sql.= "cotisation='".$this->cotisation."',"; + $sql.= "note='".addslashes($this->commentaire)."',"; + $sql.= "vote='".$this->vote."',"; + $sql.= "mail_valid='".addslashes($this->mail_valid)."'"; $sql .= " WHERE rowid = $this->id"; @@ -126,7 +129,7 @@ class AdherentType } else { - $error=$this->db->error(); + $this->error=$this->db->error().' sql='.$sql; return -1; } } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index ad914af650a..24422a7dd51 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -63,6 +63,11 @@ if ($_POST["action"] == 'add') Header("Location: type.php"); exit; } + else + { + $mesg=$adht->error; + $_GET["action"] = 'create'; + } } else { @@ -205,11 +210,11 @@ if ($_GET["action"] == 'create') print ''.$langs->trans("SubscriptionRequired").''; print $htmls->selectyesnonum("cotisation",1); - print ''; + print ''; print ''.$langs->trans("VoteAllowed").''; print $htmls->selectyesnonum("vote",0); - print ''; + print ''; print ''.$langs->trans("Comments").''; print ""; @@ -336,11 +341,11 @@ if ($rowid > 0) print ''.$langs->trans("SubscriptionRequired").''; print $htmls->selectyesnonum("cotisation",$adht->cotisation); - print ''; + print ''; print ''.$langs->trans("VoteAllowed").''; print $htmls->selectyesnonum("vote",$adht->vote); - print ''; + print ''; print ''.$langs->trans("Comments").''; print "";