Subversion Repositories Applications.papyrus

Rev

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

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