Subversion Repositories Applications.papyrus

Rev

Rev 1688 | 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
//
1796 alexandre_ 19
// $Id: edition_fiche.php,v 1.6.2.1 2008-02-08 08:24:12 alexandre_tb 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
 
1682 alexandre_ 30
function putFrame() {
31
	if (isset($_REQUEST[INS_CHAMPS_ID]) && !isset($_REQUEST['action'])) {
32
		$_REQUEST['action'] = 'modifier';
448 ddelon 33
	}
34
 
1682 alexandre_ 35
    $res = '<h1>Edition d\'un adh&eacute;rent : </h1>'."\n" ;
1796 alexandre_ 36
 	if (isset($_GET['id_inscription'])) {
37
 		$GLOBALS['ins_url']->addQueryString ('id_inscription', $_GET['id_inscription']);
38
 	}
679 alexandre_ 39
    $formulaire = new HTML_formulaireInscription('formulaire_inscription', 'post',
40
    					 preg_replace('/&amp;/', '&', $GLOBALS['ins_url']->getURL()), '_self', '', 0) ;
1682 alexandre_ 41
    $formulaire->addElement('hidden', 'id_inscription', $GLOBALS['ins_config']['ic_id_inscription']) ;
42
    $formulaire->construitFormulaire(preg_replace('/&amp;/', '&', $GLOBALS['ins_url']->getURL()), $_REQUEST[INS_CHAMPS_ID]);
679 alexandre_ 43
    if (isset($_REQUEST['form_structure'])) {
44
    	if ($_REQUEST['form_structure']==1) {
45
    		$formulaire->formulaireStructure() ;
46
    	}
47
    }
48
    //pour la modification d'une inscription, on charge les valeurs par défauts
49
    if (isset ($_REQUEST[INS_CHAMPS_ID]) == 'modifier') {
1682 alexandre_ 50
        $formulaire->addElement('hidden', 'action', 'modifier_v') ;
679 alexandre_ 51
        $formulaire->setDefaults(formulaire_defaults($_REQUEST[INS_CHAMPS_ID])) ;
52
    }
53
 
1682 alexandre_ 54
    if (isset ($_REQUEST['action']) && $_REQUEST['action'] == 'modifier_v') {
55
        $GLOBALS['id_utilisateur'] = $_REQUEST[INS_CHAMPS_ID];
679 alexandre_ 56
        if ($formulaire->validate()) {
1682 alexandre_ 57
            inscription_mise_a_jour($formulaire->getSubmitValues(), $_REQUEST[INS_CHAMPS_ID]);
58
            return $res.$formulaire->toHTML();
679 alexandre_ 59
        } else {
1682 alexandre_ 60
        	return $res.$formulaire->toHTML();
448 ddelon 61
        }
62
    }
679 alexandre_ 63
    $res .= $formulaire->toHTML();
64
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'suppr_adh') {
65
    	$res .= suppression($_REQUEST[INS_CHAMPS_ID]) ;
66
    	return ;
67
    }
448 ddelon 68
    return $res ;
69
}
70
 
71
 
72
// form construit soit un formulaire de type <input type="text" ...> et
73
// de nom $field_ et place un $label devant
74
// soit construit un lien vers un formulaire à partir du champs $field_
75
 
76
 
77
function form($label, $field_, $value)
78
{
1682 alexandre_ 79
    global $u_id, $field ;
448 ddelon 80
 
679 alexandre_ 81
    $url = $GLOBALS['ins_url']->getURL() ;
448 ddelon 82
 
83
    if ($field != $field_) {
84
        $res = "<b>$label</b>" ;
85
        $res .= "<a href=\"$url&amp;field=$field_\">" ;
679 alexandre_ 86
		$res .= $value ? $value : "(vide)";
87
        $res .= "</a>\n" ;
88
    }
89
    if ($field == $field_) {
90
        $res = '<form action="'.$url.'&amp;'.INS_CHAMPS_ID.'='.$_REQUEST[INS_CHAMPS_ID].'&amp;action=up&amp;field_='.$field_.'" method="post">' ;
91
        $res .= "<b>$label</b>\n" ;
92
        switch ($field_) {
93
            case INS_CHAMPS_PAYS :
94
                $res .= select (INS_TABLE_PAYS, INS_CHAMPS_ID_PAYS, INS_CHAMPS_LABEL_PAYS, $value);
95
            break ;
96
            default :
97
                $res .= '<input type="text" size="40" name="'.$field_.'" value="'.$value.'">'."\n" ;
98
        }
99
        $res .= '<input type="submit" value="valider">'."\n" ;
100
        $res .= "</form>" ;
101
    }
102
    return $res ;
448 ddelon 103
}
104
 
105
 
106
// upSQL met à jour la table annuaire_tela
107
 
108
function upSQL()
109
{
110
    global $field_ ;
111
 
112
    // Recherche de l'ancien mail
679 alexandre_ 113
    $req_am = 'select '.INS_CHAMPS_MAIL.' from '.INS_ANNUAIRE.' where '.INS_CHAMPS_ID.'='.$_REQUEST[INS_CHAMPS_ID] ;
114
    $res_am = $GLOBALS['ins_db']->query ($req_am) ;
115
    $ligne_am = $res_am->fetchRow(DB_FETCHMODE_ASSOC) ;
116
    $ancien_mail = $ligne_am[INS_CHAMPS_MAIL] ;
117
 
118
    if ($field_ == INS_CHAMPS_PAYS) {
119
        $field_ = INS_CHAMPS_PAYS ;
120
        $_REQUEST[$field_] = $_REQUEST[INS_TABLE_PAYS] ;
121
    }
122
    $query = 'update '.INS_ANNUAIRE.' set '.$field_.'="'.$_REQUEST[$field_].'" where '.INS_CHAMPS_ID.'='.$_REQUEST[INS_CHAMPS_ID] ;
1298 neiluj 123
    $GLOBALS['ins_db']->query($query) ;
448 ddelon 124
    // Traitement du département
679 alexandre_ 125
    if ($field_ == INS_CHAMPS_CODE_POSTAL) {
126
        if (preg_match("/^97|98[0-9]*/", $HTTP_POST_VARS[INS_CHAMPS_CODE_POSTAL])) {
127
            $n_dpt = substr($HTTP_POST_VARS[INS_CHAMPS_CODE_POSTAL], 0, 3) ;
448 ddelon 128
        } else {
679 alexandre_ 129
            $n_dpt = substr($HTTP_POST_VARS[INS_CHAMPS_CODE_POSTAL], 0, 2) ;
448 ddelon 130
        }
679 alexandre_ 131
        $GLOBALS['ins_db']->query ('update '.INS_ANNUAIRE.' set '.INS_CHAMPS_DEPARTEMENT.'='.$n_dpt.' where '.INS_CHAMPS_ID.'='.$_REQUEST[INS_CHAMPS_ID]) ;
448 ddelon 132
    }
133
}
134
 
135
function suppression($u_id) {
679 alexandre_ 136
 
448 ddelon 137
 
679 alexandre_ 138
    $url = $GLOBALS['ins_url']->getURL() ;
448 ddelon 139
 
140
    $res = "<div>Supprimer l'inscription</div>\n" ;
141
    $res .="<div><form action=\"$url&action=suppr_adh\" method=\"post\">\n" ;
679 alexandre_ 142
    $res .= "<input type=\"submit\" value=\"Supprimer\" " ;
143
    $res .= "onclick=\"javascript:return confirm('&ecirc;tes-vous s&ucirc;r de vouloir supprimer cet adh&eacute;rent');\">\n" ;
448 ddelon 144
    $res .= "</form></div>\n" ;
145
 
679 alexandre_ 146
    if (isset ($_REQUEST['action']) && $_REQUEST['action'] =="suppr_adh") {
147
        $queryLogin = 'select '.INS_CHAMPS_MAIL.' from '.INS_ANNUAIRE.' where '.INS_CHAMPS_ID.'='.$_REQUEST[INS_CHAMPS_ID] ;
148
        $resultLogin = $GLOBALS['ins_db']->query($queryLogin) ;
149
        $rowLogin = $resultLogin->fetchRow(DB_FETCHMODE_ASSOC) ;
150
        $mail = $rowLogin[INS_CHAMPS_MAIL];
448 ddelon 151
 
152
        // suppression
679 alexandre_ 153
        $query = 'delete from '.INS_ANNUAIRE.' where '.INS_CHAMPS_ID.'='.$_REQUEST[INS_CHAMPS_ID] ;
154
        $GLOBALS['ins_db']->query($query);
155
 
156
         // Appel des actions desinscriptions des applications clientes
157
        $d = dir(GEN_CHEMIN_CLIENT);
158
		$id_utilisateur = $_REQUEST[INS_CHAMPS_ID];
159
		while (false !== ($repertoire = $d->read())) {
160
			if (file_exists(GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.$repertoire.'.desinscription.inc.php'))
161
			include_once GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.$repertoire.'.desinscription.inc.php' ;
162
		}
163
		$d->close();
448 ddelon 164
    }
165
    return $res ;
166
}
167
 
679 alexandre_ 168
function select ($table, $champs_id, $champs_label, $defaut = '') {
169
    $requete = 'select * from '.$table.' where gip_id_i18n like "'.$GLOBALS['lang'].'%"' ;
170
    $resultat = $GLOBALS['ins_db']->query($requete) ;
171
    if (DB::isError($resultat)) {
172
        echo $resultat->getMessage().'<br />'.$requete ;
448 ddelon 173
    }
679 alexandre_ 174
    $res = '<select name="'.$table.'">' ;
175
 
176
    while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
177
        $res .= '<option value="'.$ligne[$champs_id].'"' ;
178
        if ($defaut != '' && $defaut == $ligne[$champs_id]) $res .= ' selected' ;
179
        $res .= '>'.$ligne[$champs_label].'</option>' ;
180
    }
181
    $res .= '</select>' ;
448 ddelon 182
    return $res ;
183
}
184
 
185
?>