[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/public/adherents/ -> new.php (source)

   1  <?php
   2  /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   *                         Jean-Louis Bergamo <jlb@j1b.org>
   4   * This program is free software; you can redistribute it and/or modify
   5   * it under the terms of the GNU General Public License as published by
   6   * the Free Software Foundation; either version 2 of the License, or
   7   * (at your option) any later version.
   8   *
   9   * This program is distributed in the hope that it will be useful,
  10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12   * GNU General Public License for more details.
  13   *
  14   * You should have received a copy of the GNU General Public License
  15   * along with this program; if not, write to the Free Software
  16   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17   *
  18   * $Id: new.php,v 1.15 2005/08/25 20:40:22 eldy Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/public/adherents/new.php,v $
  20   */
  21  
  22  /**
  23          \file       htdocs/public/adherents/new.php
  24          \ingroup    adherent
  25          \brief      Page liste des nouveaux adherents
  26          \version    $Revision: 1.15 $
  27  */
  28  
  29  require ("./pre.inc.php");
  30  require (DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
  31  require(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php");
  32  require(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php");
  33  
  34  $adho = new AdherentOptions($db);
  35  $errmsg='';
  36  $num=0;
  37  $error=0;
  38  
  39  if ($_POST["action"] == 'add') 
  40  {
  41    // test si le login existe deja
  42    $login=$_POST["login"];
  43    if(!isset($_POST["login"]) || $_POST["login"]=''){
  44      $error+=1;
  45      $errmsg .="Login $login vide. Veuillez en positionner un<BR>\n";
  46    }
  47    $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$login."';";
  48    $result = $db->query($sql);
  49    if ($result) {
  50      $num = $db->num_rows();
  51    }
  52    if (!isset($_POST["nom"]) || !isset($_POST["prenom"]) || $_POST["prenom"]=='' || $_POST["nom"]==''){
  53      $error+=1;
  54      $errmsg .="Nom et Prenom obligatoires<BR>\n";
  55    }
  56    if (!isset($_POST["email"]) || $_POST["email"] == '' || !ereg('@',$_POST["email"])){
  57      $error+=1;
  58      $errmsg .="Adresse Email invalide<BR>\n";
  59    }
  60    if ($num !=0){
  61      $error+=1;
  62      $errmsg .="Login ".$login." deja utilise. Veuillez en changer<BR>\n";
  63    }
  64    if (!isset($_POST["pass1"]) || !isset($_POST["pass2"]) || $_POST["pass1"] == '' || $_POST["pass2"] == '' || $_POST["pass1"]!=$_POST["pass2"]){
  65      $error+=1;
  66      $errmsg .="Password invalide<BR>\n";
  67    }
  68    if (isset($_POST["naiss"]) && $_POST["naiss"] !=''){
  69      if (!preg_match("/^\d\d\d\d-\d\d-\d\d$/",$_POST["naiss"])){
  70        $error+=1;
  71        $errmsg .="Date de naissance invalide (Format AAAA-MM-JJ)<BR>\n";
  72      }
  73    }
  74    if (isset($public)){
  75      $public=1;
  76    }else{
  77      $public=0;
  78    }
  79    if (!$error){
  80      // email a peu pres correct et le login n'existe pas
  81      $adh = new Adherent($db);
  82      $adh->statut      = -1;
  83      $adh->public      = $_POST["public"];
  84      $adh->prenom      = $_POST["prenom"];
  85      $adh->nom         = $_POST["nom"];  
  86      $adh->societe     = $_POST["societe"];
  87      $adh->adresse     = $_POST["adresse"];
  88      $adh->cp          = $_POST["cp"];
  89      $adh->ville       = $_POST["ville"];
  90      $adh->email       = $_POST["email"];
  91      $adh->login       = $login;
  92      $adh->pass        = $_POST["pass1"];
  93      $adh->naiss       = $_POST["naiss"];
  94      $adh->photo       = $_POST["photo"];
  95      $adh->note        = $_POST["note"];
  96      $adh->pays        = $_POST["pays"];
  97      $adh->typeid      = $_POST["type"];
  98      $adh->commentaire = $_POST["comment"];
  99      $adh->morphy      = $_POST["morphy"];
 100      
 101      foreach($_POST as $key => $value){
 102        if (ereg("^options_",$key)){
 103      $adh->array_options[$key]=$_POST[$key];
 104        }
 105      }
 106      if ($adh->create($user->id) ) 
 107        {      
 108      if ($cotisation > 0)
 109        {     
 110          $adh->cotisation(mktime(12, 0 , 0, $remonth, $reday, $reyear), $cotisation);
 111        }
 112      // Envoi d'un Email de confirmation au nouvel adherent
 113      $adh->send_an_email($email,$conf->adherent->email_new,$conf->adherent->email_new_subject);
 114      Header("Location: new.php?action=added");
 115        }
 116    }
 117  }
 118  
 119  llxHeader();
 120  
 121  
 122  /* ************************************************************************** */
 123  /*                                                                            */
 124  /* Création d'une fiche                                                       */
 125  /*                                                                            */
 126  /* ************************************************************************** */
 127  
 128  // fetch optionals attributes and labels
 129  $adho->fetch_optionals();
 130  
 131  if (isset($action) && $action== 'added'){
 132    print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
 133    print "<tr><td><FONT COLOR=\"blue\">Nouvel Adhérent ajouté. En attente de validation</FONT></td></tr>\n";
 134    print '</table>';
 135  }
 136  if ($errmsg != ''){
 137    print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
 138    
 139    print '<th>Erreur dans le formulaire</th>';
 140    print "<tr><td class=\"delete\"><b>$errmsg</b></td></tr>\n";
 141    //  print "<FONT COLOR=\"red\">$errmsg</FONT>\n";
 142    print '</table>';
 143  }
 144  
 145  print_titre("Nouvel adhérent");
 146  if (defined("ADH_TEXT_NEW_ADH") && ADH_TEXT_NEW_ADH !=''){
 147    print ADH_TEXT_NEW_ADH;
 148    print "<BR>\n";
 149  }
 150  print '<ul>';
 151  print '<li> Les champs Commencant par un <FONT COLOR="red">*</FONT> sont obligatoire';
 152  print '<li> Les champs Commencant par un <FONT COLOR="blue">*</FONT> seront affiche sur la liste publique des membres. Si vous ne souhaite pas cela <b>DECOCHEZ</b> la case public ci dessous'; 
 153  print "<li> Les login et password vous serviront a editer vos coordonnees ulterieurement<BR>\n";
 154  print "</ul><BR>\n";
 155  print "<form action=\"new.php\" method=\"POST\">\n";
 156  print '<table cellspacing="0" border="1" width="100%" cellpadding="3">';
 157  
 158  print '<input type="hidden" name="action" value="add">';
 159  
 160  $htmls = new Form($db);
 161  $adht = new AdherentType($db);
 162  
 163  print '<tr><td width="15%">'.$langs->trans("Type").'</td><td width="35%">';
 164  $htmls->select_array("type",  $adht->liste_array());
 165  print "</td>\n";
 166  
 167  print '<td width="50%" valign="top">'.$langs->trans("Comments").' :</td></tr>';
 168  
 169  $morphys["phy"] = "Physique";
 170  $morphys["mor"] = "Morale";
 171  
 172  print "<tr><td>Personne</td><td>\n";
 173  $htmls->select_array("morphy",  $morphys);
 174  print "</td>\n";
 175  
 176  print '<td valign="top" rowspan="14"><textarea name="comment" wrap="soft" cols="40" rows="25">'.$comment.'</textarea></td></tr>';
 177  
 178  print '<tr><td><FONT COLOR="red">*</FONT> <FONT COLOR="blue">*</FONT> Prénom</td><td><input type="text" name="prenom" size="40" value="'.$prenom.'"></td></tr>';  
 179  
 180  print '<tr><td><FONT COLOR="red">*</FONT> <FONT COLOR="blue">*</FONT> Nom</td><td><input type="text" name="nom" size="40" value="'.$nom.'"></td></tr>';
 181  print '<tr><td>Societe</td><td><input type="text" name="societe" size="40" value="'.$societe.'"></td></tr>';
 182  print '<tr><td>Adresse</td><td>';
 183  print '<textarea name="adresse" wrap="soft" cols="40" rows="3">'.$adresse.'</textarea></td></tr>';
 184  print '<tr><td>CP Ville</td><td><input type="text" name="cp" size="8" value="'.$cp.'"> <input type="text" name="ville" size="40" value="'.$ville.'"></td></tr>';
 185  print '<tr><td>Pays</td><td><input type="text" name="pays" size="40" value="'.$pays.'"></td></tr>';
 186  print '<tr><td><FONT COLOR="red">*</FONT> <FONT COLOR="blue">*</FONT> Email</td><td><input type="text" name="email" size="40" value="'.$email.'"></td></tr>';
 187  print '<tr><td><FONT COLOR="red">*</FONT> Login</td><td><input type="text" name="login" size="40" value="'.$login.'"></td></tr>';
 188  print '<tr><td><FONT COLOR="red">*</FONT> Password (a entrer 2 fois)</td><td><input type="password" name="pass1" size="40"><BR><input type="password" name="pass2" size="40"></td></tr>';
 189  print '<tr><td>Date de naissance<BR>Format AAAA-MM-JJ</td><td><input type="text" name="naiss" size="40" value="'.$naiss.'"></td></tr>';
 190  print '<tr><td><FONT COLOR="blue">*</FONT> URL Photo</td><td><input type="text" name="photo" size="40" value="'.$photo.'"></td></tr>';
 191  print '<tr><td>Profil public ?</td><td><input type="checkbox" name="public" checked></td></tr>';
 192  foreach($adho->attribute_label as $key=>$value){
 193    print "<tr><td>$value</td><td><input type=\"text\" name=\"options_$key\" size=\"40\"></td></tr>\n";
 194  }
 195  print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Save").'"></td></tr>';
 196  print "</form>\n";
 197  print "</table>\n";
 198  
 199        
 200  $db->close();
 201  
 202  llxFooter("<em>Derni&egrave;re modification $Date: 2005/08/25 20:40:22 $ r&eacute;vision $Revision: 1.15 $</em>");
 203  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics