[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2001-2002 Jean-Louis Bergamo <jlb@j1b.org> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * 19 * $Id: priv_edit.php,v 1.17 2005/08/25 20:40:22 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/public/adherents/priv_edit.php,v $ 21 * 22 */ 23 require ("./pre.inc.php"); 24 require (DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); 25 require(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php"); 26 require(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php"); 27 28 $adho = new AdherentOptions($db); 29 30 $errmsg=''; 31 $num=0; 32 $error=0; 33 /* 34 * Enregistrer les modifs 35 */ 36 37 if ($action == 'update') 38 { 39 40 if ($_POST["bouton"] == $langs->trans("Save")) 41 { 42 if (isset($user->login)){ 43 $adh = new Adherent($db); 44 $adh->fetch_login($user->login); 45 if ($_POST["rowid"] == $adh->id){ 46 // user and rowid is the same => good 47 48 // test some values 49 // test si le login existe deja 50 $sql = "SELECT rowid,login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$user->login."';"; 51 $result = $db->query($sql); 52 if ($result) { 53 $num = $db->num_rows(); 54 } 55 if (!isset($nom) || !isset($prenom) || $prenom=='' || $nom==''){ 56 $error+=1; 57 $errmsg .="Nom et Prenom obligatoires<BR>\n"; 58 } 59 if (!isset($email) || $email == '' || !ereg('@',$email)){ 60 $error+=1; 61 $errmsg .="Adresse Email invalide<BR>\n"; 62 } 63 if ($num !=0){ 64 $obj=$db->fetch_object(0); 65 if ($obj->rowid != $adh->id){ 66 $error+=1; 67 $errmsg .="Login deja utilise. Veuillez en changer<BR>\n"; 68 } 69 } 70 if (isset($naiss) && $naiss !=''){ 71 if (!preg_match("/^\d\d\d\d-\d\d-\d\d$/",$naiss)){ 72 $error+=1; 73 $errmsg .="Date de naissance invalide (Format AAAA-MM-JJ)<BR>\n"; 74 } 75 } 76 if (!$error){ 77 // email a peu pres correct et le login n'existe pas 78 $adh->id = $_POST["rowid"]; 79 $adh->prenom = $prenom; 80 $adh->nom = $nom; 81 $adh->societe = $societe; 82 $adh->adresse = $adresse; 83 $adh->amount = $amount; 84 $adh->cp = $cp; 85 $adh->ville = $_POST["ville"]; 86 $adh->email = $_POST["email"]; 87 // interdiction de la modif du login adherent 88 // $adh->login = $_POST["login"]; 89 $adh->login = $adh->login; 90 $adh->pass = $_POST["pass"]; 91 $adh->naiss = $_POST["naiss"]; 92 $adh->photo = $_POST["photo"]; 93 $adh->date = mktime(12, 0 , 0, $remonth, $reday, $reyear); 94 $adh->note = $_POST["note"]; 95 $adh->pays = $_POST["pays"]; 96 $adh->typeid = $_POST["type"]; 97 $adh->commentaire = $_POST["comment"]; 98 $adh->morphy = $_POST["morphy"]; 99 // recuperation du statut et public 100 $adh->statut = $_POST["statut"]; 101 if (isset($public)){ 102 $public=1; 103 }else{ 104 $public=0; 105 } 106 $adh->public = $public; 107 foreach($_POST as $key => $value){ 108 if (ereg("^options_",$key)){ 109 $adh->array_options[$key]=$_POST[$key]; 110 } 111 } 112 if ($adh->update($user->id) ) 113 { 114 $adh->send_an_email($email,$conf->adherent->email_edit,$conf->adherent->email_edit_subject); 115 //Header("Location: fiche.php?rowid=$adh->id&action=edit"); 116 Header("Location: priv_edit.php"); 117 } 118 } 119 }else{ 120 Header("Location: priv_edit.php"); 121 } 122 } 123 } 124 else 125 { 126 //Header("Location: fiche.php?rowid=$rowid&action=edit"); 127 Header("Location: priv_edit.php"); 128 } 129 } 130 131 132 llxHeader(); 133 134 if (isset($user->login)) 135 { 136 137 $adh = new Adherent($db); 138 $adh->login = $user->login; 139 $adh->fetch_login($user->login); 140 $adh->fetch_optionals($adh->id); 141 // fetch optionals attibutes 142 $adho->fetch_optionals(); 143 144 $adht = new AdherentType($db); 145 146 print_titre("Edition de la fiche adhérent de $adh->prenom $adh->nom"); 147 148 if ($errmsg != ''){ 149 print '<table width="100%">'; 150 151 print '<th>Erreur dans le formulaire</th>'; 152 print "<tr><td class=\"delete\"><b>$errmsg</b></td></tr>\n"; 153 // print "<FONT COLOR=\"red\">$errmsg</FONT>\n"; 154 print '</table>'; 155 } 156 157 print '<table class="border" width="100%">'; 158 159 print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$adh->type.'</td>'; 160 print '<td valign="top" width="50%">'.$langs->trans("Comments").'</td></tr>'; 161 162 print '<tr><td>Personne</td><td class="valeur">'.$adh->morphy.' </td>'; 163 print '<td rowspan="15" valign="top" width="50%">'; 164 print nl2br($adh->commentaire).' </td></tr>'; 165 166 print '<tr><td width="15%">Prénom</td><td class="valeur" width="35%">'.$adh->prenom.' </td></tr>'; 167 168 print '<tr><td>Nom</td><td class="valeur">'.$adh->nom.' </td></tr>'; 169 170 print '<tr><td>Société</td><td class="valeur">'.$adh->societe.' </td></tr>'; 171 print '<tr><td>Adresse</td><td class="valeur">'.nl2br($adh->adresse).' </td></tr>'; 172 print '<tr><td>CP Ville</td><td class="valeur">'.$adh->cp.' '.$adh->ville.' </td></tr>'; 173 print '<tr><td>Pays</td><td class="valeur">'.$adh->pays.' </td></tr>'; 174 print '<tr><td>Email</td><td class="valeur">'.$adh->email.' </td></tr>'; 175 print '<tr><td>Login</td><td class="valeur">'.$adh->login.' </td></tr>'; 176 print '<tr><td>Password</td><td class="valeur">'.$adh->pass.' </td></tr>'; 177 print '<tr><td>Date de naissance<BR>Format AAAA-MM-JJ</td><td class="valeur">'.$adh->naiss.' </td></tr>'; 178 print '<tr><td>URL Photo</td><td class="valeur">'.$adh->photo.' </td></tr>'; 179 if ($adh->public==1){ 180 print '<tr><td>Profil public ?</td><td> Oui </td></tr>'; 181 }else{ 182 print '<tr><td>Profil public ?</td><td> Non </td></tr>'; 183 } 184 foreach($adho->attribute_label as $key=>$value){ 185 print "<tr><td>$value</td><td>".$adh->array_options["options_$key"]." </td></tr>\n"; 186 } 187 188 print "</table>\n"; 189 190 print "<hr>"; 191 192 print "<form action=\"priv_edit.php\" method=\"post\">"; 193 print '<table class="border" width="100%">'; 194 195 print "<input type=\"hidden\" name=\"action\" value=\"update\">"; 196 print "<input type=\"hidden\" name=\"rowid\" value=\"$adh->id\">"; 197 print "<input type=\"hidden\" name=\"statut\" value=\"".$adh->statut."\">"; 198 print "<input type=\"hidden\" name=\"login\" value=\"".$adh->login."\">"; 199 // print "<input type=\"hidden\" name=\"public\" value=\"".$adh->public."\">"; 200 201 $htmls = new Form($db); 202 203 204 print '<tr><td>'.$langs->trans("Type").'</td><td>'; 205 $htmls->select_array("type", $adht->liste_array(), $adh->typeid); 206 print "</td>"; 207 208 print '<td valign="top" width="50%">'.$langs->trans("Comments").'</td></tr>'; 209 210 $morphys["phy"] = "Physique"; 211 $morphys["mor"] = "Morale"; 212 213 print "<tr><td>Personne</td><td>"; 214 $htmls->select_array("morphy", $morphys, $adh->morphy); 215 print "</td>"; 216 217 print '<td rowspan="15" valign="top">'; 218 print '<textarea name="comment" wrap="soft" cols="40" rows="15">'.$adh->commentaire.'</textarea></td></tr>'; 219 220 print '<tr><td width="15%">Prénom</td><td width="35%"><input type="text" name="prenom" size="40" value="'.$adh->prenom.'"></td></tr>'; 221 222 print '<tr><td>Nom</td><td><input type="text" name="nom" size="40" value="'.$adh->nom.'"></td></tr>'; 223 224 225 print '<tr><td>Societe</td><td><input type="text" name="societe" size="40" value="'.$adh->societe.'"></td></tr>'; 226 print '<tr><td>Adresse</td><td>'; 227 print '<textarea name="adresse" wrap="soft" cols="40" rows="3">'.$adh->adresse.'</textarea></td></tr>'; 228 print '<tr><td>CP Ville</td><td><input type="text" name="cp" size="6" value="'.$adh->cp.'"> <input type="text" name="ville" size="20" value="'.$adh->ville.'"></td></tr>'; 229 print '<tr><td>Pays</td><td><input type="text" name="pays" size="40" value="'.$adh->pays.'"></td></tr>'; 230 print '<tr><td>Email</td><td><input type="text" name="email" size="40" value="'.$adh->email.'"></td></tr>'; 231 print '<tr><td>Login</td><td class="valeur">'.$adh->login.' </td></tr>'; 232 // print '<tr><td>Login</td><td><input type="text" name="login" size="40" value="'.$adh->login.'"></td></tr>'; 233 print '<tr><td>Password</td><td><input type="text" name="pass" size="40" value="'.$adh->pass.'"></td></tr>'; 234 print '<tr><td>Date de naissance<BR>Format AAAA-MM-JJ</td><td><input type="text" name="naiss" size="40" value="'.$adh->naiss.'"></td></tr>'; 235 print '<tr><td>URL photo</td><td><input type="text" name="photo" size="40" value="'.$adh->photo.'"></td></tr>'; 236 if ($adh->public==1){ 237 print '<tr><td>Profil public ?</td><td><input type="checkbox" name="public" checked></td></tr>'; 238 }else{ 239 print '<tr><td>Profil public ?</td><td><input type="checkbox" name="public"></td></tr>'; 240 } 241 foreach($adho->attribute_label as $key=>$value){ 242 print "<tr><td>$value</td><td><input type=\"text\" name=\"options_$key\" size=\"40\" value=\"".$adh->array_options["options_$key"]."\"></td></tr>\n"; 243 } 244 print '<tr><td colspan="2" align="center">'; 245 print '<input type="submit" name="bouton" value="'.$langs->trans("Save").'"> '; 246 print '<input type="submit" value="'.$langs->trans("Cancel").'">'; 247 print '</td></tr>'; 248 print '</form>'; 249 print '</table>'; 250 251 } 252 253 $db->close(); 254 255 llxFooter('$Date: 2005/08/25 20:40:22 $ - $Revision: 1.17 $'); 256 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |