2 if (!defined('_ECRIRE_INC_VERSION')) return;
4 include_spip('inc/config');
6 function formulaires_configurer_souscription_charger_dist() {
7 /* Configuration des saisies */
8 $liste_saisies = array('input' => _T('souscription:configurer_type_saisie_input'),
9 'radio' => _T('souscription:configurer_type_saisie_radio'),
10 'selection' => _T('souscription:configurer_type_saisie_selection'));
13 foreach(array('adhesion', 'don') as $type) {
14 $saisies[] = array("saisie" => "oui_non",
15 "options" => array("nom" => "${type}_activer",
16 "label" => _T("souscription:label_activer_${type}"))
18 $saisies[] = array("saisie" => "fieldset",
19 "options" => array("nom" => "${type}_groupe",
20 "label" => _T("souscription:label_${type}_groupe"),
21 "afficher_si" => "@${type}_activer@ == 'on'"),
22 "saisies" => array(array("saisie" => "selection",
23 "options" => array("nom" => "${type}_type_saisie",
24 "label" => _T("souscription:label_type_saisie"),
25 "cacher_option_intro" => "oui",
26 "datas" => $liste_saisies)
28 array("saisie" => "input",
29 "options" => array("nom" => "${type}_montants_label",
30 "label" => _T("souscription:label_montants_label"))
32 array("saisie" => "textarea",
33 "options" => array("nom" => "${type}_montants",
35 "label" => _T("souscription:label_montants"),
36 "explication" => _T("souscription:explication_montants"))
38 array("saisie" => "textarea",
39 "options" => array("nom" => "${type}_montants_description",
41 "label" => _T("souscription:label_montants_explication")))
46 $saisies[] = array("saisie" => "fieldset",
47 "options" => array("nom" => "general_groupe",
48 "label" => _T("souscription:label_general_groupe")),
49 "saisies" => array(array('saisie' => 'textarea',
50 'options' => array('nom' => 'dispositions_fiscales_explications',
52 'label' => _T('souscription:label_dispositions_fiscales_explications')))));
56 $valeurs = array('adhesion_montants' => lire_config("souscription/adhesion_montants"),
57 'adhesion_type_saisie' => lire_config("souscription/adhesion_type_saisie"),
58 "adhesion_activer" => lire_config("souscription/adhesion_activer"),
59 "adhesion_montants_description" => lire_config("souscription/adhesion_montants_description"),
60 "adhesion_montants_label" => lire_config("souscription/adhesion_montants_label"),
62 'don_montants' => lire_config("souscription/don_montants"),
63 'don_type_saisie' => lire_config("souscription/don_type_saisie"),
64 "don_activer" => lire_config("souscription/don_activer"),
65 "don_montants_description" => lire_config("souscription/don_montants_description"),
66 "don_montants_label" => lire_config("souscription/don_montants_label"),
68 "dispositions_fiscales_explications" => lire_config("souscription/dispositions_fiscales_explications"),
69 '_saisies' => $saisies
75 function formulaires_configurer_souscription_verifier_dist() {
76 /* FIXME: vérifier le format de 'adhesion_montants' et 'don_montants' */
79 $type_saisies = array("input", "radio", "selection");
81 if(_request("adhesion_activer")) {
82 if(!_request("adhesion_type_saisie")) {
83 $erreurs["adhesion_type_saisie"] = _T("souscription:message_nok_champ_obligatoire");
86 if(!in_array(_request("adhesion_type_saisie"), $type_saisies)) {
87 $erreurs["adhesion_type_saisie"] = _T("souscription:message_nok_champ_invalide");
91 if(_request("don_activer")) {
93 if(!_request("don_type_saisie")) {
94 $erreurs["don_type_saisie"] = _T("souscription:message_nok_champ_obligatoire");
97 if(!in_array(_request("don_type_saisie"), $type_saisies)) {
98 $erreurs["don_type_saisie"] = _T("souscription:message_nok_champ_invalide");
105 function formulaires_configurer_souscription_traiter_dist() {
107 ecrire_config("souscription/adhesion_montants", _request("adhesion_montants"));
108 ecrire_config("souscription/adhesion_type_saisie", _request("adhesion_type_saisie"));
109 ecrire_config("souscription/adhesion_activer", _request("adhesion_activer"));
110 ecrire_config("souscription/adhesion_montants_description", _request("adhesion_montants_description"));
111 ecrire_config("souscription/adhesion_montants_label", _request("adhesion_montants_label"));
113 ecrire_config("souscription/don_montants", _request("don_montants"));
114 ecrire_config("souscription/don_type_saisie", _request("don_type_saisie"));
115 ecrire_config("souscription/don_activer", _request("don_activer"));
116 ecrire_config("souscription/don_montants_description", _request("don_montants_description"));
117 ecrire_config("souscription/don_montants_label", _request("don_montants_label"));
119 ecrire_config("souscription/dispositions_fiscales_explications", _request("dispositions_fiscales_explications"));
121 $res = array('message_ok'=>_T('souscription:config_info_enregistree'));