/tags/v4.0-djer/client/questionnaire/questionnaire.php |
---|
New file |
0,0 → 1,148 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: questionnaire.php,v 1.1 2007-04-19 14:51:10 florian Exp $ |
/** |
* Contact |
* |
* Un module d'envoi de mails a une personne de l'annuaire, choisie par une liste déroulante |
* |
*@package inscription |
//Auteur original : |
*@author Florian SCHMITT <florian@ecole-et-nature.org> |
* |
*@copyright Réseau Ecole et Nature 2005 |
*@version $Revision: 1.1 $ $Date: 2007-04-19 14:51:10 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
require_once PAP_CHEMIN_RACINE.'api/formulaire/formulaire.class.inc.php' ; |
//appel du fichier de constantes des langues |
include_once PAP_CHEMIN_RACINE.'client/questionnaire/langues/questionnaire.langue.'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php' ; |
// +------------------------------------------------------------------------------------------------------+ |
// | LISTE de FONCTIONS | |
// +------------------------------------------------------------------------------------------------------+ |
function afficherContenuCorps() { |
// Gestion des valeurs par defauts, en fonctions des donnees sauvees dans le menu |
$requete = 'SELECT gm_application_arguments FROM gen_menu WHERE gm_id_menu='.$_GET['menu'] ; |
$resultat = $GLOBALS['_GEN_commun']['pear_db']->query($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows()>0) { |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$arguments = explode('||', $ligne->gm_application_arguments) ; |
for ($i = 0; $i < count($arguments); $i++) { |
$attr = explode('=', $arguments[$i], 2) ; |
if ($attr[0] != '') { |
$info_application->$attr[0] = (isset($attr[1]) ? $attr[1] : '') ; |
} |
} |
} |
} |
// On recupere le template du questionnaire |
$requete = 'SELECT bti_nom, bti_template FROM pap_formulaires WHERE bti_id='.$info_application->num_questionnaire.' AND bti_i18n LIKE "'.$GLOBALS['_GEN_commun']['i18n'].'%"' ; |
$resultat = $GLOBALS['_GEN_commun']['pear_db']->query($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows()>0) { |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; |
$nom_questionnaire=$ligne->bti_nom ; |
$template=$ligne->bti_template ; |
} |
$url = preg_replace ('/&/', '&', $GLOBALS['_GEN_commun']['url']->getURL()) ; |
$form = new PAP_donnees ; |
$res='<h1>'.$nom_questionnaire.'</h1>'."\n" ; |
// cas du formulaire deja rempli : on envoie le mail |
if (isset($_POST['envoi']) && !isset($_SESSION['formulaire_deja_envoye']) ) { |
$_SESSION['formulaire_deja_envoye'] = 1 ; |
$headers = 'From: '.QUESTIONNAIRE.' <'.$info_application->mail_questionnaire.'>'."\n" ; |
$headers .= 'X-Mailler: Florian'."\n" ; |
$corps='' ; |
$tableau = $form->afficher_donnees($info_application->num_questionnaire) ; |
//var_dump($_POST); |
for ($i=0; $i<count($tableau); $i++) { |
if (isset($_POST[$tableau[$i]['nom_bdd']]) && ( $tableau[$i]['type']=='formulaire_texte' || $tableau[$i]['type']=='formulaire_textelong' ) ) { |
$val=$tableau[$i]['nom_bdd'] ; |
if ($_POST[$val] != '' and $_POST[$val] != FORM_CHOISIR and $_POST[$val] != FORM_NON_PRECISE) { |
$corps .= $tableau[$i]['label'].' : '.$_POST[$val]."\n"."\n" ; |
} |
} |
elseif ( $tableau[$i]['type']=='formulaire_liste' ) { |
$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'].'%"' ; |
$resultat = $GLOBALS['_GEN_commun']['pear_db']->query($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows()>0) { |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; |
$val=$ligne->plv_label ; |
} |
else $val=''; |
if ($val != '' and $val != FORM_CHOISIR and $val != FORM_NON_PRECISE) { |
$corps .= $tableau[$i]['label'].' : '.$val."\n"."\n" ; |
} |
} |
elseif ( $tableau[$i]['type']=='formulaire_listedatedeb' || $tableau[$i]['type']=='formulaire_listedatefin' ) { |
$val=$tableau[$i]['nom_bdd'] ; |
if (!in_array($val, array ('bf_date_debut_validite_fiche', 'bf_date_fin_validite_fiche'))) { |
if ($_POST[$val] != '') { |
$corps .= $tableau[$i]['label'].' : '.strftime('%d.%m.%Y',strtotime($_POST[$val]))."\n"."\n" ; |
} |
} |
} |
} |
mail($info_application->mail_questionnaire, QUESTIONNAIRE_REPONSE_AU.' : '.$nom_questionnaire, html_entity_decode($corps), $headers) ; // Envoi du mail |
$res .= $info_application->texte_questionnaire_envoye; |
return $res; |
// Cas ou l'on affiche le questionnaire |
} else { |
unset ($_SESSION['formulaire_deja_envoye']) ; |
$res .= $form->afficher_formulaire('formulaire_questionnaire', $url , $template ) ; |
} |
return $res ; |
} |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.3 2006/04/28 11:35:37 florian |
* ajout constantes chemin |
* |
* Revision 1.2 2006/01/19 10:24:37 florian |
* champs obligatoires pour le formulaire de saisie |
* |
* Revision 1.1 2005/09/22 13:28:50 florian |
* Application de contact, pour envoyer des mails. Reste a faire: configuration pour choisir les destinataires dans l'annuaire. |
* |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/tags/v4.0-djer/client/questionnaire/langues/questionnaire.langue.fr.inc.php |
---|
New file |
0,0 → 1,73 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: questionnaire.langue.fr.inc.php,v 1.1 2007-04-19 14:51:10 florian Exp $ |
/** |
* Fichier de traduction en français de l'application contact |
* |
*@package contact |
//Auteur original : |
*@author Florian SCHMITT <florian@ecole-et-nature.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Ecole et Nature 2005 |
*@version $Revision: 1.1 $ $Date: 2007-04-19 14:51:10 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
define ('QUESTIONNAIRE', 'Questionnaire') ; |
define ('QUESTIONNAIRE_REPONSE_AU', 'Réponse au questionnaire') ; |
define ('QUESTIONNAIRE_CONFIG', 'Configuration du questionnaire') ; |
define ('QUESTIONNAIRE_ENVOYER', 'Envoyer') ; |
define ('QUESTIONNAIRE_CHOIX', 'Choix du questionnaire') ; |
define ('QUESTIONNAIRE_MAIL', 'Adresse de messagerie pour la réponse au formulaire') ; |
define ('QUESTIONNAIRE_ANNULER', 'Annuler') ; |
define ('QUESTIONNAIRE_ENREGISTRER_ET_QUITTER', 'Enregistrer et quitter') ; |
define ('QUESTIONNAIRE_TEXTE_MESSAGE_ENVOYE', 'Texte apparaissant une fois le questionnaire rempli et envoyé'); |
define ('CON_VOTRE_MESSAGE', 'Votre message'); |
define ('CON_A_ETE_ENVOYE', 'a bien été envoyé.'); |
define ('CON_EMAIL_REQUIS','veuillez saisir votre adresse mail pour que l\'on puisse vous répondre'); |
define ('CON_EMAIL_INCORRECT','adresse mail incorrecte (elle doit etre de la forme nom@domaine.ext)'); |
define ('CON_DESTINATAIRE', 'Destinataire : ') ; |
define ('CON_SUJET', 'Sujet : ') ; |
define ('CON_SUJET_REQUIS', 'veuillez saisir un sujet pour le message'); |
define ('CON_MESSAGE', 'Message : ') ; |
define ('CON_MESSAGE_REQUIS', 'veuillez saisir le message'); |
define ('CON_ENVOYER_NOUS_MAIL', 'Envoyez-nous un message électronique (courriel):'); |
define ('CON_CHAMPS_REQUIS','champs obligatoires'); |
define ('CON_ERREUR_SAISIE','Erreur de saisie des champs:'); |
define ('CON_VEUILLEZ_CORRIGER','Veuillez corriger, SVP.'); |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.2 2006/01/19 10:24:37 florian |
* champs obligatoires pour le formulaire de saisie |
* |
* Revision 1.1 2005/09/22 13:28:50 florian |
* Application de contact, pour envoyer des mails. Reste a faire: configuration pour choisir les destinataires dans l'annuaire. |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/tags/v4.0-djer/client/questionnaire/questionnaire.admin.php |
---|
New file |
0,0 → 1,166 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2006 Outils Reseaux (info@outils-reseaux.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: questionnaire.admin.php,v 1.1 2007-04-19 14:51:10 florian Exp $ |
/** |
* |
*@package Questionnaire |
//Auteur original : |
*@author Florian Schmitt <florian@ecole-et-nature.org> |
//Autres auteurs : |
*@copyright Outils Reseaux 2006 |
*@version $Revision: 1.1 $ $Date: 2007-04-19 14:51:10 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm.php' ; |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/textarea.php' ; |
//appel du fichier de constantes des langues |
include_once 'langues/questionnaire.langue.'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php'; |
// +------------------------------------------------------------------------------------------------------+ |
// | CLASSE | |
// +------------------------------------------------------------------------------------------------------+ |
class Questionnaire_Admin { |
var $objet_pear_auth; |
var $objet_pear_db; |
var $objet_pear_url; |
var $sortie_xhtml; |
/** Fonction redigerContenu() - Affiche le formulaire de r?action |
* |
* |
* @return string Le HTML |
*/ |
function afficherContenuCorps() |
{ |
//------------------------------------------------------------------------------------------------------------------- |
// Initialisation des attributs |
$this->objet_pear_auth = $GLOBALS['_GEN_commun']['pear_auth']; |
$this->objet_pear_db = $GLOBALS['_GEN_commun']['pear_db']; |
$this->objet_pear_url = $GLOBALS['_GEN_commun']['url']; |
$this->sortie_xhtml = '<h1>'.QUESTIONNAIRE_CONFIG.'</h1>'."\n"; |
//------------------------------------------------------------------------------------------------------------------- |
// Gestion des boutons de l'interface |
if (isset($_POST['afficheur_annuler'])) { |
return false; |
} else if (isset($_POST['afficheur_enregistrer_quitter'])) { |
$requete = 'UPDATE gen_menu SET gm_application_arguments="num_questionnaire='.$_POST['num_questionnaire']. |
'||mail_questionnaire='.$_POST['mail_questionnaire'].'||texte_questionnaire_envoye='.$_POST['texte_questionnaire_envoye'].'" WHERE gm_id_menu='.$_GET['adme_menu_id']; |
$resultat = $this->objet_pear_db->query($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
return false; |
} |
//-------------------------------------------------------------------------------------------------------------- |
// Gestion des valeurs par defauts, en fonctions des donnees sauvees dans le menu |
$requete = 'SELECT gm_application_arguments FROM gen_menu WHERE gm_id_menu='.$_GET['adme_menu_id']; |
$resultat = $this->objet_pear_db->query($requete) ; |
//echo $requete; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$valeurs_par_defaut = array(); |
if ($resultat->numRows()>0) { |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$arguments = explode('||', $ligne->gm_application_arguments); |
for ($i = 0; $i < count($arguments); $i++) { |
$attr = explode('=', $arguments[$i], 2); |
if ($attr[0] != '') { |
$info_application->$attr[0] = (isset($attr[1]) ? $attr[1] : ''); |
} |
} |
} |
//valeurs par defaut enregistrees dans la table |
if (isset($info_application)) { |
$valeurs_par_defaut['num_questionnaire']=$info_application->num_questionnaire; |
$valeurs_par_defaut['mail_questionnaire']=$info_application->mail_questionnaire; |
$valeurs_par_defaut['texte_questionnaire_envoye']=$info_application->texte_questionnaire_envoye; |
} |
} else { |
//valeurs par defaut pour afficher une carto des structures |
$valeurs_par_defaut['num_questionnaire']=''; |
$valeurs_par_defaut['mail_questionnaire']=''; |
$valeurs_par_defaut['texte_questionnaire_envoye']=''; |
} |
//-------------------------------------------------------------------------------------------------------------- |
// Gestion du questionnaire |
$this->objet_pear_url->addQueryString('adme_site_id', $_GET['adme_site_id']); |
$this->objet_pear_url->addQueryString('adme_menu_id', $_GET['adme_menu_id']); |
$this->objet_pear_url->addQueryString('adme_action', 'administrer'); |
$form =& new HTML_QuickForm('form_param_questionnaire', 'post', str_replace('&', '&', $this->objet_pear_url->getUrl())); |
$squelette =& $form->defaultRenderer(); |
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n"); |
$squelette->setElementTemplate( '<p>'."\n". |
'<label style="width:100px;padding:5px;text-align:right;">{label}'. |
'<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n". |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n". |
' : </label>'."\n".'{element}'."\n". |
'</p>'."\n" ); |
// on récupère tous les questionnaires |
$requete = 'SELECT bti_id, bti_nom FROM pap_formulaires WHERE bti_groupe="questionnaire" AND bti_i18n LIKE "'.$GLOBALS['_GEN_commun']['i18n'].'%"' ; |
$resultat = $this->objet_pear_db->query($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows()>0) { |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$select[$ligne->bti_id]=$ligne->bti_nom; |
} |
} |
$option=array('style'=>'width: 200px;'); |
$select= new HTML_QuickForm_select('num_questionnaire', QUESTIONNAIRE_CHOIX, $select, $option); |
$select->setSize(1); |
$select->setMultiple(0); |
$form->addElement($select) ; |
$formtexte= new HTML_QuickForm_textarea('texte_questionnaire_envoye', QUESTIONNAIRE_TEXTE_MESSAGE_ENVOYE, array('style'=>'white-space: normal;')); |
$formtexte->setCols(40); |
$formtexte->setRows(10); |
$form->addElement($formtexte) ; |
$form->applyFilter('texte_questionnaire_envoye', 'addslashes') ; |
$form->addElement('text', 'mail_questionnaire', QUESTIONNAIRE_MAIL); |
$liste_bouton_debut = '<ul class="liste_bouton">'."\n"; |
$form->addElement('html', $liste_bouton_debut); |
$form->addElement('submit', 'afficheur_enregistrer_quitter', QUESTIONNAIRE_ENREGISTRER_ET_QUITTER); |
$form->addElement('submit', 'afficheur_annuler', QUESTIONNAIRE_ANNULER); |
$liste_bouton_fin = '</ul>'."\n"; |
$form->addElement('html', $liste_bouton_fin); |
$form->setDefaults($valeurs_par_defaut); |
$this->sortie_xhtml .= $form->toHTML()."\n"; |
return $this->sortie_xhtml; |
} |
}// Fin de la classe |
// +------------------------------------------------------------------------------------------------------+ |
// | PIED du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
?> |