Subversion Repositories Applications.papyrus

Rev

Rev 1332 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1332 Rev 1333
1
<?php
1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
3
// +------------------------------------------------------------------------------------------------------+
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: questionnaire.php,v 1.1 2007-04-19 14:51:10 florian Exp $
22
// CVS : $Id: questionnaire.php,v 1.1.2.1 2007-04-19 14:51:30 florian Exp $
23
/**
23
/**
24
* Contact
24
* Contact
25
*
25
*
26
* Un module d'envoi de mails a une personne de l'annuaire, choisie par une liste déroulante
26
* Un module d'envoi de mails a une personne de l'annuaire, choisie par une liste déroulante
27
*
27
*
28
*@package inscription
28
*@package inscription
29
//Auteur original :
29
//Auteur original :
30
*@author        Florian SCHMITT <florian@ecole-et-nature.org>
30
*@author        Florian SCHMITT <florian@ecole-et-nature.org>
31
*
31
*
32
*@copyright     Réseau Ecole et Nature 2005
32
*@copyright     Réseau Ecole et Nature 2005
33
*@version       $Revision: 1.1 $ $Date: 2007-04-19 14:51:10 $
33
*@version       $Revision: 1.1.2.1 $ $Date: 2007-04-19 14:51:30 $
34
// +------------------------------------------------------------------------------------------------------+
34
// +------------------------------------------------------------------------------------------------------+
35
*/
35
*/
36
 
36
 
37
// +------------------------------------------------------------------------------------------------------+
37
// +------------------------------------------------------------------------------------------------------+
38
// |                                            ENTETE du PROGRAMME                                       |
38
// |                                            ENTETE du PROGRAMME                                       |
39
// +------------------------------------------------------------------------------------------------------+
39
// +------------------------------------------------------------------------------------------------------+
40
 
40
 
41
require_once PAP_CHEMIN_RACINE.'api/formulaire/formulaire.class.inc.php' ;
41
require_once PAP_CHEMIN_RACINE.'api/formulaire/formulaire.class.inc.php' ;
42
//appel du fichier de constantes des langues
42
//appel du fichier de constantes des langues
43
include_once PAP_CHEMIN_RACINE.'client/questionnaire/langues/questionnaire.langue.'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php' ; 
43
include_once PAP_CHEMIN_RACINE.'client/questionnaire/langues/questionnaire.langue.'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php' ; 
44
 
44
 
45
 
45
 
46
// +------------------------------------------------------------------------------------------------------+
46
// +------------------------------------------------------------------------------------------------------+
47
// |                                           LISTE de FONCTIONS                                         |
47
// |                                           LISTE de FONCTIONS                                         |
48
// +------------------------------------------------------------------------------------------------------+
48
// +------------------------------------------------------------------------------------------------------+
49
 
49
 
50
function afficherContenuCorps() {
50
function afficherContenuCorps() {
51
	// Gestion des valeurs par defauts, en fonctions des donnees sauvees dans le menu
51
	// Gestion des valeurs par defauts, en fonctions des donnees sauvees dans le menu
52
    $requete = 'SELECT gm_application_arguments FROM gen_menu WHERE gm_id_menu='.$_GET['menu'] ;
52
    $requete = 'SELECT gm_application_arguments FROM gen_menu WHERE gm_id_menu='.$_GET['menu'] ;
53
    $resultat = $GLOBALS['_GEN_commun']['pear_db']->query($requete) ;
53
    $resultat = $GLOBALS['_GEN_commun']['pear_db']->query($requete) ;
54
    if (DB::isError($resultat)) {
54
    if (DB::isError($resultat)) {
55
    	die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
55
    	die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
56
    }
56
    }
57
    if ($resultat->numRows()>0) {        	        	
57
    if ($resultat->numRows()>0) {        	        	
58
    	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {        		
58
    	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {        		
59
    		$arguments = explode('||', $ligne->gm_application_arguments) ;        	
59
    		$arguments = explode('||', $ligne->gm_application_arguments) ;        	
60
			for ($i = 0; $i < count($arguments); $i++) {
60
			for ($i = 0; $i < count($arguments); $i++) {
61
				$attr = explode('=', $arguments[$i], 2) ;
61
				$attr = explode('=', $arguments[$i], 2) ;
62
				if ($attr[0] != '') {
62
				if ($attr[0] != '') {
63
					$info_application->$attr[0] = (isset($attr[1]) ? $attr[1] : '') ;
63
					$info_application->$attr[0] = (isset($attr[1]) ? $attr[1] : '') ;
64
				}
64
				}
65
		   	}
65
		   	}
66
		}    	
66
		}    	
67
    }
67
    }
68
    // On recupere le template du questionnaire 
68
    // On recupere le template du questionnaire 
69
    $requete = 'SELECT bti_nom, bti_template FROM pap_formulaires WHERE bti_id='.$info_application->num_questionnaire.' AND bti_i18n LIKE "'.$GLOBALS['_GEN_commun']['i18n'].'%"' ;     
69
    $requete = 'SELECT bti_nom, bti_template FROM pap_formulaires WHERE bti_id='.$info_application->num_questionnaire.' AND bti_i18n LIKE "'.$GLOBALS['_GEN_commun']['i18n'].'%"' ;     
70
    $resultat = $GLOBALS['_GEN_commun']['pear_db']->query($requete) ;
70
    $resultat = $GLOBALS['_GEN_commun']['pear_db']->query($requete) ;
71
    if (DB::isError($resultat)) {
71
    if (DB::isError($resultat)) {
72
    	die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
72
    	die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
73
    }              
73
    }              
74
    if ($resultat->numRows()>0) { 
74
    if ($resultat->numRows()>0) { 
75
    	$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; 
75
    	$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; 
76
    	$nom_questionnaire=$ligne->bti_nom ;
76
    	$nom_questionnaire=$ligne->bti_nom ;
77
    	$template=$ligne->bti_template ;		           	
77
    	$template=$ligne->bti_template ;		           	
78
    }
78
    }
79
	$url = preg_replace ('/&amp;/', '&', $GLOBALS['_GEN_commun']['url']->getURL()) ;
79
	$url = preg_replace ('/&amp;/', '&', $GLOBALS['_GEN_commun']['url']->getURL()) ;
80
	$form = new PAP_donnees ;
80
	$form = new PAP_donnees ;
81
	$res='<h1>'.$nom_questionnaire.'</h1>'."\n" ;
81
	$res='<h1>'.$nom_questionnaire.'</h1>'."\n" ;
82
	// cas du formulaire deja rempli : on envoie le mail
82
	// cas du formulaire deja rempli : on envoie le mail
83
	if (isset($_POST['envoi']) && !isset($_SESSION['formulaire_deja_envoye']) ) {
83
	if (isset($_POST['envoi']) && !isset($_SESSION['formulaire_deja_envoye']) ) {
84
		$_SESSION['formulaire_deja_envoye'] = 1 ;		
84
		$_SESSION['formulaire_deja_envoye'] = 1 ;		
85
		$headers  = 'From: '.QUESTIONNAIRE.' <'.$info_application->mail_questionnaire.'>'."\n" ;
85
		$headers  = 'From: '.QUESTIONNAIRE.' <'.$info_application->mail_questionnaire.'>'."\n" ;
86
		$headers .= 'X-Mailler: Florian'."\n" ;				
86
		$headers .= 'X-Mailler: Florian'."\n" ;				
87
		$corps='' ;
87
		$corps='' ;
88
		$tableau = $form->afficher_donnees($info_application->num_questionnaire) ;
88
		$tableau = $form->afficher_donnees($info_application->num_questionnaire) ;
89
		//var_dump($_POST);		
89
		//var_dump($_POST);		
90
		for ($i=0; $i<count($tableau); $i++) {
90
		for ($i=0; $i<count($tableau); $i++) {
91
			if (isset($_POST[$tableau[$i]['nom_bdd']]) && ( $tableau[$i]['type']=='formulaire_texte' || $tableau[$i]['type']=='formulaire_textelong' ) ) {
91
			if (isset($_POST[$tableau[$i]['nom_bdd']]) && ( $tableau[$i]['type']=='formulaire_texte' || $tableau[$i]['type']=='formulaire_textelong' ) ) {
92
				$val=$tableau[$i]['nom_bdd'] ;
92
				$val=$tableau[$i]['nom_bdd'] ;
93
				if ($_POST[$val] != '' and $_POST[$val] != FORM_CHOISIR and $_POST[$val] != FORM_NON_PRECISE) {
93
				if ($_POST[$val] != '' and $_POST[$val] != FORM_CHOISIR and $_POST[$val] != FORM_NON_PRECISE) {
94
					$corps .= $tableau[$i]['label'].' : '.$_POST[$val]."\n"."\n" ;
94
					$corps .= $tableau[$i]['label'].' : '.$_POST[$val]."\n"."\n" ;
95
				}				
95
				}				
96
			}
96
			}
97
			elseif ( $tableau[$i]['type']=='formulaire_liste' ) {				
97
			elseif ( $tableau[$i]['type']=='formulaire_liste' ) {				
98
				$requete = 'SELECT plv_label FROM pap_liste_valeurs WHERE plv_valeur='.$_POST['liste'.$tableau[$i]['nom_bdd'].$tableau[$i]['id_source']].' AND plv_ce_liste='.$tableau[$i]['nom_bdd'].' AND plv_ce_i18n LIKE "'.$GLOBALS['_GEN_commun']['i18n'].'%"' ;     
98
				$requete = 'SELECT plv_label FROM pap_liste_valeurs WHERE plv_valeur='.$_POST['liste'.$tableau[$i]['nom_bdd'].$tableau[$i]['id_source']].' AND plv_ce_liste='.$tableau[$i]['nom_bdd'].' AND plv_ce_i18n LIKE "'.$GLOBALS['_GEN_commun']['i18n'].'%"' ;     
99
    			$resultat = $GLOBALS['_GEN_commun']['pear_db']->query($requete) ;
99
    			$resultat = $GLOBALS['_GEN_commun']['pear_db']->query($requete) ;
100
    			if (DB::isError($resultat)) {
100
    			if (DB::isError($resultat)) {
101
    				die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
101
    				die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
102
    			}              
102
    			}              
103
    			if ($resultat->numRows()>0) { 
103
    			if ($resultat->numRows()>0) { 
104
    				$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; 
104
    				$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; 
105
    				$val=$ligne->plv_label ;		           	
105
    				$val=$ligne->plv_label ;		           	
106
    			}
106
    			}
107
    			else $val='';    			
107
    			else $val='';    			
108
				if ($val != '' and $val != FORM_CHOISIR and $val != FORM_NON_PRECISE) {
108
				if ($val != '' and $val != FORM_CHOISIR and $val != FORM_NON_PRECISE) {
109
					$corps .= $tableau[$i]['label'].' : '.$val."\n"."\n" ;
109
					$corps .= $tableau[$i]['label'].' : '.$val."\n"."\n" ;
110
				}
110
				}
111
			}
111
			}
112
			elseif ( $tableau[$i]['type']=='formulaire_listedatedeb' || $tableau[$i]['type']=='formulaire_listedatefin' ) {
112
			elseif ( $tableau[$i]['type']=='formulaire_listedatedeb' || $tableau[$i]['type']=='formulaire_listedatefin' ) {
113
				$val=$tableau[$i]['nom_bdd'] ;
113
				$val=$tableau[$i]['nom_bdd'] ;
114
				if (!in_array($val, array ('bf_date_debut_validite_fiche', 'bf_date_fin_validite_fiche'))) {
114
				if (!in_array($val, array ('bf_date_debut_validite_fiche', 'bf_date_fin_validite_fiche'))) {
115
					if ($_POST[$val] != '') {
115
					if ($_POST[$val] != '') {
116
						$corps .= $tableau[$i]['label'].' : '.strftime('%d.%m.%Y',strtotime($_POST[$val]))."\n"."\n" ;
116
						$corps .= $tableau[$i]['label'].' : '.strftime('%d.%m.%Y',strtotime($_POST[$val]))."\n"."\n" ;
117
					}
117
					}
118
				}		
118
				}		
119
			}			
119
			}			
120
		}
120
		}
121
		mail($info_application->mail_questionnaire, QUESTIONNAIRE_REPONSE_AU.' : '.$nom_questionnaire, html_entity_decode($corps), $headers) ; // Envoi du mail
121
		mail($info_application->mail_questionnaire, QUESTIONNAIRE_REPONSE_AU.' : '.$nom_questionnaire, html_entity_decode($corps), $headers) ; // Envoi du mail
122
		$res .= $info_application->texte_questionnaire_envoye;
122
		$res .= $info_application->texte_questionnaire_envoye;
123
		return $res;
123
		return $res;
124
	// Cas ou l'on affiche le questionnaire
124
	// Cas ou l'on affiche le questionnaire
125
	} else {
125
	} else {
126
		unset ($_SESSION['formulaire_deja_envoye']) ;
126
		unset ($_SESSION['formulaire_deja_envoye']) ;
127
		$res .= $form->afficher_formulaire('formulaire_questionnaire', $url , $template ) ;		
127
		$res .= $form->afficher_formulaire('formulaire_questionnaire', $url , $template ) ;		
128
	}
128
	}
129
	return $res ;
129
	return $res ;
130
}
130
}
131
 
131
 
132
/* +--Fin du code ----------------------------------------------------------------------------------------+
132
/* +--Fin du code ----------------------------------------------------------------------------------------+
133
*
133
*
134
* $Log: not supported by cvs2svn $
134
* $Log: not supported by cvs2svn $
135
* Revision 1.3  2006/04/28 11:35:37  florian
135
* Revision 1.3  2006/04/28 11:35:37  florian
136
* ajout constantes chemin
136
* ajout constantes chemin
137
*
137
*
138
* Revision 1.2  2006/01/19 10:24:37  florian
138
* Revision 1.2  2006/01/19 10:24:37  florian
139
* champs obligatoires pour le formulaire de saisie
139
* champs obligatoires pour le formulaire de saisie
140
*
140
*
141
* Revision 1.1  2005/09/22 13:28:50  florian
141
* Revision 1.1  2005/09/22 13:28:50  florian
142
* Application de contact, pour envoyer des mails. Reste a faire: configuration pour choisir les destinataires dans l'annuaire.
142
* Application de contact, pour envoyer des mails. Reste a faire: configuration pour choisir les destinataires dans l'annuaire.
143
*
143
*
144
*
144
*
145
*
145
*
146
* +-- Fin du code ----------------------------------------------------------------------------------------+
146
* +-- Fin du code ----------------------------------------------------------------------------------------+
147
*/
147
*/
148
?>
148
?>