dolibarr  7.0.0-beta
adherent_emails.php
1 <?php
2 /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4  * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
6  * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
7  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
8  * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
9  * Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org>
10  * Copyright (C) 2015 Jean-Fran├žois Ferry <jfefe@aternatik.fr>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
32 require '../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
35 
36 $langs->load("admin");
37 $langs->load("members");
38 
39 if (! $user->admin) accessforbidden();
40 
41 
42 $type=array('yesno','texte','chaine');
43 
44 $action = GETPOST('action','alpha');
45 
46 
47 /*
48  * Actions
49  */
50 
51 //
52 if ($action == 'updateall')
53 {
54  $db->begin();
55  $res1=$res2=$res3=$res4=$res5=$res6=0;
56  $res1=dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
57  $res2=dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
58  $res3=dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
59  $res4=dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
60  // Use vat for invoice creation
61  if ($conf->facture->enabled)
62  {
63  $res4=dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
64  $res5=dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
65  if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
66  {
67  $res6=dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
68  }
69  }
70  if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0)
71  {
72  setEventMessages('ErrorFailedToSaveDate', null, 'errors');
73  $db->rollback();
74  }
75  else
76  {
77  setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
78  $db->commit();
79  }
80 }
81 
82 // Action mise a jour ou ajout d'une constante
83 if ($action == 'update' || $action == 'add')
84 {
85  $constname=GETPOST('constname','alpha');
86  $constvalue=(GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue'));
87 
88  if (($constname=='ADHERENT_CARD_TYPE' || $constname=='ADHERENT_ETIQUETTE_TYPE' || $constname=='ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) $constvalue='';
89  if ($constname=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice
90  {
91  if ($constvalue) $constvalue=0;
92  else $constvalue=1;
93  }
94 
95  $consttype=GETPOST('consttype','alpha');
96  $constnote=GETPOST('constnote');
97  $res=dolibarr_set_const($db,$constname,$constvalue,$type[$consttype],0,$constnote,$conf->entity);
98 
99  if (! $res > 0) $error++;
100 
101  if (! $error)
102  {
103  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
104  }
105  else
106  {
107  setEventMessages($langs->trans("Error"), null, 'errors');
108  }
109 }
110 
111 // Action activation d'un sous module du module adherent
112 if ($action == 'set')
113 {
114  $result=dolibarr_set_const($db, GETPOST('name','alpha'),GETPOST('value'),'',0,'',$conf->entity);
115  if ($result < 0)
116  {
117  print $db->error();
118  }
119 }
120 
121 // Action desactivation d'un sous module du module adherent
122 if ($action == 'unset')
123 {
124  $result=dolibarr_del_const($db,GETPOST('name','alpha'),$conf->entity);
125  if ($result < 0)
126  {
127  print $db->error();
128  }
129 }
130 
131 
132 
133 /*
134  * View
135  */
136 
137 $form = new Form($db);
138 
139 $help_url='EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
140 
141 llxHeader('',$langs->trans("MembersSetup"),$help_url);
142 
143 
144 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
145 print load_fiche_titre($langs->trans("MembersSetup"),$linkback,'title_setup');
146 
147 
148 $head = member_admin_prepare_head();
149 
150 dol_fiche_head($head, 'emails', $langs->trans("Members"), -1, 'user');
151 
152 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
153 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
154 print '<input type="hidden" name="action" value="updateall">';
155 
156 /*
157  * Editing global variables not related to a specific theme
158  */
159 $constantes=array(
160  'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT',
161  'ADHERENT_AUTOREGISTER_NOTIF_MAIL',
162  'ADHERENT_AUTOREGISTER_MAIL_SUBJECT',
163  'ADHERENT_AUTOREGISTER_MAIL',
164  'ADHERENT_MAIL_VALID_SUBJECT',
165  'ADHERENT_MAIL_VALID',
166  'ADHERENT_MAIL_COTIS_SUBJECT',
167  'ADHERENT_MAIL_COTIS',
168  'ADHERENT_MAIL_RESIL_SUBJECT',
169  'ADHERENT_MAIL_RESIL',
170  'ADHERENT_MAIL_FROM',
171  );
172 
173 $helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
174 $helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
175 $helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
176 $helptext.='__YEAR__, __MONTH__, __DAY__';
177 
178 $helptext='*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
179 $helptext.='__DOL_MAIN_URL_ROOT__, __ID__, __FIRSTNAME__, __LASTNAME__, __FULLNAME__, __LOGIN__, __PASSWORD__, ';
180 $helptext.='__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL__, __BIRTH__, __PHOTO__, __TYPE__, ';
181 //$helptext.='__YEAR__, __MONTH__, __DAY__'; // Not supported
182 
183 form_constantes($constantes, 0, $helptext);
184 
185 dol_fiche_end();
186 
187 
188 llxFooter();
189 
190 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
member_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: member.lib.php:156
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:485
if(empty($reshook)) $form
View.
Definition: perms.php:103
form_constantes($tableau, $strictw3c=0, $helptext='')
Show array with constants to edit.
Definition: admin.lib.php:1309
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
Definition: admin.lib.php:410
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
print
Draft customers invoices.
Definition: index.php:91