* Copyright (C) 2001-2002 Jean-Louis Bergamo * Copyright (C) 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/public/adherents/priv_edit.php \ingroup adherent \brief Page edition de sa fiche adherent \version $Revision$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php"); $adho = new AdherentOptions($db); $langs->load("companies"); $langs->load("main"); $langs->load("other"); $langs->load("users"); $errmsg=''; $num=0; $error=0; /* * Actions */ if ($action == 'update') { if ($_POST["bouton"] == $langs->trans("Save")) { if (isset($user->login)){ $adh = new Adherent($db); $adh->fetch_login($user->login); if ($_POST["rowid"] == $adh->id){ // user and rowid is the same => good // test some values // test si le login existe deja $sql = "SELECT rowid,login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$user->login."';"; $result = $db->query($sql); if ($result) { $num = $db->num_rows(); } if (!isset($nom) || !isset($prenom) || $prenom=='' || $nom==''){ $error+=1; $errmsg .="Nom et Prenom obligatoires
\n"; } if (!isset($email) || $email == '' || !ereg('@',$email)){ $error+=1; $errmsg .="Adresse Email invalide
\n"; } if ($num !=0){ $obj=$db->fetch_object(0); if ($obj->rowid != $adh->id){ $error+=1; $errmsg .="Login deja utilise. Veuillez en changer
\n"; } } if (isset($naiss) && $naiss !=''){ if (!preg_match("/^\d\d\d\d-\d\d-\d\d$/",$naiss)){ $error+=1; $errmsg .="Date de naissance invalide (Format AAAA-MM-JJ)
\n"; } } if (!$error){ // email a peu pres correct et le login n'existe pas $adh->id = $_POST["rowid"]; $adh->prenom = $prenom; $adh->nom = $nom; $adh->societe = $societe; $adh->adresse = $adresse; $adh->amount = $amount; $adh->cp = $cp; $adh->ville = $_POST["ville"]; $adh->email = $_POST["email"]; // interdiction de la modif du login adherent // $adh->login = $_POST["login"]; $adh->login = $adh->login; $adh->pass = $_POST["pass"]; $adh->naiss = $_POST["naiss"]; $adh->photo = $_POST["photo"]; $adh->date = mktime(12, 0 , 0, $remonth, $reday, $reyear); $adh->note = $_POST["note"]; $adh->pays = $_POST["pays"]; $adh->typeid = $_POST["type"]; $adh->note = $_POST["comment"]; $adh->morphy = $_POST["morphy"]; // recuperation du statut et public $adh->statut = $_POST["statut"]; if (isset($public)){ $public=1; }else{ $public=0; } $adh->public = $public; foreach($_POST as $key => $value){ if (ereg("^options_",$key)){ $adh->array_options[$key]=$_POST[$key]; } } if ($adh->update($user->id) ) { $adh->send_an_email($email,$conf->adherent->email_edit,$conf->adherent->email_edit_subject); //Header("Location: fiche.php?rowid=$adh->id&action=edit"); Header("Location: priv_edit.php"); } } }else{ Header("Location: priv_edit.php"); } } } else { //Header("Location: fiche.php?rowid=$rowid&action=edit"); Header("Location: priv_edit.php"); } } llxHeaderVierge(); if (isset($_GET["id"])) { $adh = new Adherent($db); $result=$adh->fetch($_GET["id"]); $adh->fetch_optionals($adh->id); // fetch optionals attibutes $adho->fetch_optionals(); $adht = new AdherentType($db); print_titre("Edition de la fiche adhérent de $adh->prenom $adh->nom"); if ($errmsg != ''){ print ''; print ''; print "\n"; // print "$errmsg\n"; print '
Erreur dans le formulaire
$errmsg
'; } // Formulaire modifications print '
'; print ""; print "id\">"; print "statut."\">"; print "login."\">"; print "typeid."\">"; print "morphy."\">"; // print "public."\">"; $htmls = new Form($db); $caneditfield=1; print ''; // Nom print ''; // Photo $rowspan=14; $rowspan+=sizeof($adho->attribute_label); print ''; print ''; // Prenom print ''; print ''; // Login // print ''; print ''; // Password print ''; // Société print ''; // Adresse print ''; // Cp print ''; // Pays print ''; // Tel print ''; // Tel perso print ''; // Tel mobile print ''; // EMail print ''; // Date naissance print "\n"; // Profil public print "\n"; // Attributs supplémentaires foreach($adho->attribute_label as $key=>$value) { print "\n"; } print ''; print '
'.$langs->trans("Lastname").'*'; if (file_exists($conf->adherent->dir_output."/".$adh->id.".jpg")) { print ''; } else { print ''; } if ($caneditfield) { print '

'; print '
'.$langs->trans("PhotoFile").'
'; print ''; print '
'; } print '
'.$langs->trans("Firstname").'*
'.$langs->trans("Login").'*
'.$langs->trans("Login").'*'.$adh->login.'
'.$langs->trans("Password").'*
'.$langs->trans("Company").'
'.$langs->trans("Address").''; print '
'.$langs->trans("Zip").'/'.$langs->trans("Town").'
'.$langs->trans("Country").''; $htmls->select_pays($adh->pays_code?$adh->pays_code:$mysoc->pays_code,'pays'); print '
'.$langs->trans("PhonePro").'
'.$langs->trans("PhonePerso").'
'.$langs->trans("PhoneMobile").'
'.$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'*':'').'
".$langs->trans("Birthday")."\n"; $htmls->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'update'); print "
".$langs->trans("Public")."\n"; print $htmls->selectyesno("public",$adh->public,1); print "
$valuearray_options["options_$key"]."\">
'; print ''; // print '       '; // print ''; print '
'; print '
'; } $db->close(); llxFooter('$Date$ - $Revision$'); ?>