Subversion Repositories Applications.papyrus

Rev

Rev 938 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
448 ddelon 1
<?php
2
 
3
// +--------------------------------------------------------------------------------+
4
// | admin_annu.php 				                          						|
5
// +--------------------------------------------------------------------------------+
6
// | Copyright (c) 2002 					   							        	|
7
// +--------------------------------------------------------------------------------+
8
// | Administration des inscrits à un annuaire de type annuaire_tela			    |
9
// | de Gsite, 													                    |
10
// | Sont également mises en jeux les tables gen_COUNTRY, gen_FRENCH_DPT,	        |
11
// | LABELS															                |
12
// | Plus spécifique la fonction cotisation($id) en bas permet de				    |
13
// | gérer les cotisations versées par les inscrits, avec la table					|
14
// | annuaire_COTISATION													                |
15
// +--------------------------------------------------------------------------------+
16
// | Auteur : Alexandre Granier <alexandre@tela-botanica.org> 		  		        |
17
// +--------------------------------------------------------------------------------+
18
//
1292 neiluj 19
// $Id: edition_fiche.php,v 1.4 2007-04-06 08:35:46 neiluj Exp $
448 ddelon 20
 
21
 
679 alexandre_ 22
define ("URL_RECU", $GLOBALS['ins_url']->protocol. '://'.$GLOBALS['ins_url']->host."/client/annuaire/voir_recu_pdf.php") ;
448 ddelon 23
 
24
include_once ("HTML/Table.php") ;
25
 
26
// admin_annu est une application cliente de gsite elle commence donc
27
// dans une fonction putFrame()
28
 
29
 
30
function putFrame()
31
{
32
 
679 alexandre_ 33
    $url = $GLOBALS['ins_url']->getURL() ;
448 ddelon 34
 
35
    // mise à jour si il y lieu
36
 
679 alexandre_ 37
    if (isset ($_REQUEST['action']) && $_REQUEST['action'] == 'up') {
448 ddelon 38
        upSQL() ;
39
	}
40
 
41
    // Requete de pour récupérer toutes les infos d'un usager
42
 
679 alexandre_ 43
    $query = 'select '.INS_ANNUAIRE.'.* ,'.INS_TABLE_PAYS.'.'.INS_CHAMPS_LABEL_PAYS ;
44
    $query .= ' from '.INS_ANNUAIRE.','.INS_TABLE_PAYS.','.INS_TABLE_DPT ;
45
    $query .= ' where '.INS_CHAMPS_ID.'='.$_REQUEST[INS_CHAMPS_ID] ;
46
    $query .= ' and '.INS_ANNUAIRE.'.'.INS_CHAMPS_PAYS.'='.INS_TABLE_PAYS.'.'.INS_CHAMPS_ID_PAYS ;
448 ddelon 47
 
679 alexandre_ 48
    $result = $GLOBALS['ins_db']->query($query) ;
49
    if (DB::isError($result)) {
50
        echo $result->getMessage().'<br />'.$query ;
51
    }
448 ddelon 52
 
679 alexandre_ 53
    $row = $result->fetchRow(DB_FETCHMODE_ASSOC) ;
448 ddelon 54
 
679 alexandre_ 55
    $res = '<h1>Edition d\'un adh&eacute;rent : '.$row[INS_CHAMPS_NOM].' '.$row[INS_CHAMPS_PRENOM].'</h1>'."\n" ;
56
    $res .= "<div>".form("Nom : ", INS_CHAMPS_NOM, $row[INS_CHAMPS_NOM])."</div>\n" ;
57
    $res .= "<div>".form("Pr&eacute;nom : ", INS_CHAMPS_PRENOM, $row[INS_CHAMPS_PRENOM])."</div>\n" ;
58
    $res .= "<div>".form("Adresse mail : ", INS_CHAMPS_MAIL, $row[INS_CHAMPS_MAIL])."</div>\n" ;
59
    $res .= "<div>".form("Date d'inscription : ", INS_CHAMPS_DATE, $row[INS_CHAMPS_DATE])."</div>\n" ;
60
    $res .= "<div>".form("Adresse 1 : ", INS_CHAMPS_ADRESSE_1, $row[INS_CHAMPS_ADRESSE_1])."</div>\n" ;
61
    $res .= "<div>".form("Adresse 2 : ", INS_CHAMPS_ADRESSE_2, $row[INS_CHAMPS_ADRESSE_2])."</div>\n" ;
62
    $res .= "<div>".form("Région : ", "a_region", $row['a_region'])."</div>\n" ;
63
    $res .= "<div>".form("Code postal : ", INS_CHAMPS_CODE_POSTAL, $row[INS_CHAMPS_CODE_POSTAL])."</div>\n" ;
64
    $res .= "<div>".form("Ville : ", INS_CHAMPS_VILLE, $row[INS_CHAMPS_VILLE])."</div>\n" ;
65
    $res .= "<div>".form("Pays : ", INS_CHAMPS_PAYS, $row[INS_CHAMPS_PAYS])."</div>\n" ;
66
    $res .= "<div>".form("Site web personnel : ", INS_CHAMPS_SITE_INTERNET, $row[INS_CHAMPS_SITE_INTERNET])."</div>\n" ;
67
	$res .= suppression($row[INS_CHAMPS_ID]) ;
68
    $formulaire = new HTML_formulaireInscription('formulaire_inscription', 'post',
69
    					 preg_replace('/&amp;/', '&', $GLOBALS['ins_url']->getURL()), '_self', '', 0) ;
70
 
71
    $formulaire->construitFormulaire(preg_replace('/&amp;/', '&', $GLOBALS['ins_url']->getURL()));
72
    if (isset($_REQUEST['form_structure'])) {
73
    	if ($_REQUEST['form_structure']==1) {
74
    		$formulaire->formulaireStructure() ;
75
    	}
76
    }
77
 
78
    //pour la modification d'une inscription, on charge les valeurs par défauts
79
    if (isset ($_REQUEST[INS_CHAMPS_ID]) == 'modifier') {
80
        $formulaire->addElement('hidden', 'modifier_v', '1') ;
81
        $formulaire->setDefaults(formulaire_defaults($_REQUEST[INS_CHAMPS_ID])) ;
82
    }
83
 
84
    if (isset ($_REQUEST['modifier_v'])) {
85
        if ($formulaire->validate()) {
86
            mise_a_jour($formulaire->getSubmitValues(), $_REQUEST[INS_CHAMPS_ID]);
87
        } else {
88
        	return $res.$formulaire->toHTML();
448 ddelon 89
        }
679 alexandre_ 90
        return $res;
448 ddelon 91
    }
679 alexandre_ 92
    $res .= $formulaire->toHTML();
93
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'suppr_adh') {
94
    	$res .= suppression($_REQUEST[INS_CHAMPS_ID]) ;
95
    	return ;
96
    }
448 ddelon 97
    return $res ;
98
}
99
 
100
 
101
// form construit soit un formulaire de type <input type="text" ...> et
102
// de nom $field_ et place un $label devant
103
// soit construit un lien vers un formulaire à partir du champs $field_
104
 
105
 
106
function form($label, $field_, $value)
107
{
108
    global $u_id, $GS_GLOBAL, $field ;
109
 
679 alexandre_ 110
    $url = $GLOBALS['ins_url']->getURL() ;
448 ddelon 111
 
112
    if ($field != $field_) {
113
        $res = "<b>$label</b>" ;
114
        $res .= "<a href=\"$url&amp;field=$field_\">" ;
679 alexandre_ 115
		$res .= $value ? $value : "(vide)";
116
        $res .= "</a>\n" ;
117
    }
118
    if ($field == $field_) {
119
        $res = '<form action="'.$url.'&amp;'.INS_CHAMPS_ID.'='.$_REQUEST[INS_CHAMPS_ID].'&amp;action=up&amp;field_='.$field_.'" method="post">' ;
120
        $res .= "<b>$label</b>\n" ;
121
        switch ($field_) {
122
            case INS_CHAMPS_PAYS :
123
                $res .= select (INS_TABLE_PAYS, INS_CHAMPS_ID_PAYS, INS_CHAMPS_LABEL_PAYS, $value);
124
            break ;
125
            default :
126
                $res .= '<input type="text" size="40" name="'.$field_.'" value="'.$value.'">'."\n" ;
127
        }
128
        $res .= '<input type="submit" value="valider">'."\n" ;
129
        $res .= "</form>" ;
130
    }
131
    return $res ;
448 ddelon 132
}
133
 
134
 
135
// upSQL met à jour la table annuaire_tela
136
 
137
function upSQL()
138
{
139
    global $field_ ;
140
 
141
    // Recherche de l'ancien mail
679 alexandre_ 142
    $req_am = 'select '.INS_CHAMPS_MAIL.' from '.INS_ANNUAIRE.' where '.INS_CHAMPS_ID.'='.$_REQUEST[INS_CHAMPS_ID] ;
143
    $res_am = $GLOBALS['ins_db']->query ($req_am) ;
144
    $ligne_am = $res_am->fetchRow(DB_FETCHMODE_ASSOC) ;
145
    $ancien_mail = $ligne_am[INS_CHAMPS_MAIL] ;
146
 
147
    if ($field_ == INS_CHAMPS_PAYS) {
148
        $field_ = INS_CHAMPS_PAYS ;
149
        $_REQUEST[$field_] = $_REQUEST[INS_TABLE_PAYS] ;
150
    }
151
    $query = 'update '.INS_ANNUAIRE.' set '.$field_.'="'.$_REQUEST[$field_].'" where '.INS_CHAMPS_ID.'='.$_REQUEST[INS_CHAMPS_ID] ;
1292 neiluj 152
    $GLOBALS['ins_db']->query($query) ;echo $query;
153
 
448 ddelon 154
    // Traitement du département
679 alexandre_ 155
    if ($field_ == INS_CHAMPS_CODE_POSTAL) {
156
        if (preg_match("/^97|98[0-9]*/", $HTTP_POST_VARS[INS_CHAMPS_CODE_POSTAL])) {
157
            $n_dpt = substr($HTTP_POST_VARS[INS_CHAMPS_CODE_POSTAL], 0, 3) ;
448 ddelon 158
        } else {
679 alexandre_ 159
            $n_dpt = substr($HTTP_POST_VARS[INS_CHAMPS_CODE_POSTAL], 0, 2) ;
448 ddelon 160
        }
679 alexandre_ 161
        $GLOBALS['ins_db']->query ('update '.INS_ANNUAIRE.' set '.INS_CHAMPS_DEPARTEMENT.'='.$n_dpt.' where '.INS_CHAMPS_ID.'='.$_REQUEST[INS_CHAMPS_ID]) ;
448 ddelon 162
    }
163
}
164
 
165
function suppression($u_id) {
679 alexandre_ 166
 
448 ddelon 167
 
679 alexandre_ 168
    $url = $GLOBALS['ins_url']->getURL() ;
448 ddelon 169
 
170
    $res = "<div>Supprimer l'inscription</div>\n" ;
171
    $res .="<div><form action=\"$url&action=suppr_adh\" method=\"post\">\n" ;
679 alexandre_ 172
    $res .= "<input type=\"submit\" value=\"Supprimer\" " ;
173
    $res .= "onclick=\"javascript:return confirm('&ecirc;tes-vous s&ucirc;r de vouloir supprimer cet adh&eacute;rent');\">\n" ;
448 ddelon 174
    $res .= "</form></div>\n" ;
175
 
679 alexandre_ 176
    if (isset ($_REQUEST['action']) && $_REQUEST['action'] =="suppr_adh") {
177
        $queryLogin = 'select '.INS_CHAMPS_MAIL.' from '.INS_ANNUAIRE.' where '.INS_CHAMPS_ID.'='.$_REQUEST[INS_CHAMPS_ID] ;
178
        $resultLogin = $GLOBALS['ins_db']->query($queryLogin) ;
179
        $rowLogin = $resultLogin->fetchRow(DB_FETCHMODE_ASSOC) ;
180
        $mail = $rowLogin[INS_CHAMPS_MAIL];
448 ddelon 181
 
182
        // suppression
679 alexandre_ 183
        $query = 'delete from '.INS_ANNUAIRE.' where '.INS_CHAMPS_ID.'='.$_REQUEST[INS_CHAMPS_ID] ;
184
        $GLOBALS['ins_db']->query($query);
185
 
186
         // Appel des actions desinscriptions des applications clientes
187
        $d = dir(GEN_CHEMIN_CLIENT);
188
		$id_utilisateur = $_REQUEST[INS_CHAMPS_ID];
189
		while (false !== ($repertoire = $d->read())) {
190
			if (file_exists(GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.$repertoire.'.desinscription.inc.php'))
191
			include_once GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.$repertoire.'.desinscription.inc.php' ;
192
		}
193
		$d->close();
448 ddelon 194
    }
195
    return $res ;
196
}
197
 
679 alexandre_ 198
function select ($table, $champs_id, $champs_label, $defaut = '') {
199
    $requete = 'select * from '.$table.' where gip_id_i18n like "'.$GLOBALS['lang'].'%"' ;
200
    $resultat = $GLOBALS['ins_db']->query($requete) ;
201
    if (DB::isError($resultat)) {
202
        echo $resultat->getMessage().'<br />'.$requete ;
448 ddelon 203
    }
679 alexandre_ 204
    $res = '<select name="'.$table.'">' ;
205
 
206
    while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
207
        $res .= '<option value="'.$ligne[$champs_id].'"' ;
208
        if ($defaut != '' && $defaut == $ligne[$champs_id]) $res .= ' selected' ;
209
        $res .= '>'.$ligne[$champs_label].'</option>' ;
210
    }
211
    $res .= '</select>' ;
448 ddelon 212
    return $res ;
213
}
214
 
215
?>