Logo 32px et 16px, version et shema sur 3 chiffres
[spip_souscriptions.git] / formulaires / configurer_souscription.php
1 <?php
2 if (!defined('_ECRIRE_INC_VERSION')) return;
3
4 include_spip('inc/config');
5
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'));
11
12   $saisies = array();
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}"))
17                        );
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)
27                                                 ),
28                                           array("saisie" => "input",
29                                                 "options" => array("nom" => "${type}_montants_label",
30                                                                    "label" => _T("souscription:label_montants_label"))
31                                                 ),
32                                           array("saisie" => "textarea",
33                                                 "options" => array("nom" => "${type}_montants",
34                                                                    "rows" => "4",
35                                                                    "label" => _T("souscription:label_montants"),
36                                                                    "explication" => _T("souscription:explication_montants"))
37                                                 ),
38                                           array("saisie" => "textarea",
39                                                 "options" => array("nom" => "${type}_montants_description",
40                                                                    "rows" => "4",
41                                                                    "label" => _T("souscription:label_montants_explication")))
42                                           )
43                        );
44   }
45
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',
51                                                                  'rows' => '4',
52                                                                  'label' => _T('souscription:label_dispositions_fiscales_explications')))));
53
54
55
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"),
61
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"),
67
68                    "dispositions_fiscales_explications" => lire_config("souscription/dispositions_fiscales_explications"),
69                    '_saisies' => $saisies
70                    );
71
72   return $valeurs;
73 }
74
75 function formulaires_configurer_souscription_verifier_dist() {
76   /* FIXME: vĂ©rifier le format de 'adhesion_montants' et 'don_montants' */
77
78   $erreurs = array();
79   $type_saisies = array("input", "radio", "selection");
80
81   if(_request("adhesion_activer")) {
82     if(!_request("adhesion_type_saisie")) {
83       $erreurs["adhesion_type_saisie"] = _T("souscription:message_nok_champ_obligatoire");
84     }
85
86     if(!in_array(_request("adhesion_type_saisie"), $type_saisies)) {
87       $erreurs["adhesion_type_saisie"] = _T("souscription:message_nok_champ_invalide");
88     }
89   }
90
91   if(_request("don_activer")) {
92
93     if(!_request("don_type_saisie")) {
94       $erreurs["don_type_saisie"] = _T("souscription:message_nok_champ_obligatoire");
95     }
96
97     if(!in_array(_request("don_type_saisie"), $type_saisies)) {
98       $erreurs["don_type_saisie"] = _T("souscription:message_nok_champ_invalide");
99     }
100   }
101
102   return $erreurs;
103 }
104
105 function formulaires_configurer_souscription_traiter_dist() {
106
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"));
112
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"));
118
119   ecrire_config("souscription/dispositions_fiscales_explications", _request("dispositions_fiscales_explications"));
120
121   $res = array('message_ok'=>_T('souscription:config_info_enregistree'));
122
123   return $res;
124 }