|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* Copyright (C) 2003,2005 Rodolphe Quiedeville <[email protected]> |
|
4
|
|
|
* Copyright (C) 2003 Jean-Louis Bergamo <[email protected]> |
|
5
|
|
|
* Copyright (C) 2004-2012 Laurent Destailleur <[email protected]> |
|
6
|
|
|
* Copyright (C) 2004 Sebastien Di Cintio <[email protected]> |
|
7
|
|
|
* Copyright (C) 2004 Benoit Mortier <[email protected]> |
|
8
|
|
|
* Copyright (C) 2013 Juanjo Menent <[email protected]> |
|
9
|
|
|
* Copyright (C) 2014-2015 Raphaël Doursenaud <[email protected]> |
|
10
|
|
|
* Copyright (C) 2018 Alexandre Spangaro <[email protected]> |
|
11
|
|
|
* Copyright (C) 2024 Rafael San José <[email protected]> |
|
12
|
|
|
* |
|
13
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
14
|
|
|
* it under the terms of the GNU General Public License as published by |
|
15
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
16
|
|
|
* (at your option) any later version. |
|
17
|
|
|
* |
|
18
|
|
|
* This program is distributed in the hope that it will be useful, |
|
19
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21
|
|
|
* GNU General Public License for more details. |
|
22
|
|
|
* |
|
23
|
|
|
* You should have received a copy of the GNU General Public License |
|
24
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
namespace Dolibarr\Modules; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* \defgroup member Module foundation |
|
31
|
|
|
* \brief Module to manage members of a foundation |
|
32
|
|
|
* \file htdocs/core/modules/modAdherent.class.php |
|
33
|
|
|
* \ingroup member |
|
34
|
|
|
* \brief Description and activation file for the module member |
|
35
|
|
|
*/ |
|
36
|
|
|
|
|
37
|
|
|
use Dolibarr\Core\Base\DolibarrModules; |
|
38
|
|
|
use Modules\Adherent\DoliDB; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Class to describe and enable module Adherent |
|
42
|
|
|
*/ |
|
43
|
|
|
class Adherent extends DolibarrModules |
|
44
|
|
|
{ |
|
45
|
|
|
/** |
|
46
|
|
|
* Constructor. Define names, constants, directories, boxes, permissions |
|
47
|
|
|
* |
|
48
|
|
|
* @param DoliDB $db Database handler |
|
49
|
|
|
*/ |
|
50
|
|
|
public function __construct($db) |
|
51
|
|
|
{ |
|
52
|
|
|
global $conf; |
|
53
|
|
|
|
|
54
|
|
|
$this->db = $db; |
|
55
|
|
|
$this->numero = 310; |
|
56
|
|
|
|
|
57
|
|
|
$this->family = "hr"; |
|
58
|
|
|
$this->module_position = '06'; |
|
59
|
|
|
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
60
|
|
|
$this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
61
|
|
|
$this->description = "Management of members of a foundation or association"; |
|
62
|
|
|
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
63
|
|
|
$this->version = 'dolibarr'; |
|
64
|
|
|
$this->const_name = 'MAIN_MODULE_' . static::getNameOf($this->name); // strtoupper($this->name); |
|
65
|
|
|
$this->picto = 'member'; |
|
66
|
|
|
|
|
67
|
|
|
// Data directories to create when module is enabled |
|
68
|
|
|
$this->dirs = array( |
|
69
|
|
|
"/adherent/temp", |
|
70
|
|
|
"/doctemplates/members", |
|
71
|
|
|
); |
|
72
|
|
|
|
|
73
|
|
|
// Config pages |
|
74
|
|
|
$this->config_page_url = array("member.php@adherents"); |
|
75
|
|
|
|
|
76
|
|
|
// Dependencies |
|
77
|
|
|
$this->hidden = false; // A condition to hide module |
|
78
|
|
|
$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
79
|
|
|
$this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
80
|
|
|
$this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with |
|
81
|
|
|
$this->langfiles = array("members", "companies"); |
|
82
|
|
|
$this->phpmin = array(7, 0); // Minimum version of PHP required by module |
|
83
|
|
|
|
|
84
|
|
|
// Constants |
|
85
|
|
|
$this->const = array(); |
|
86
|
|
|
$r = 0; |
|
87
|
|
|
|
|
88
|
|
|
$this->const[$r][0] = "ADHERENT_ADDON_PDF"; |
|
89
|
|
|
$this->const[$r][1] = "chaine"; |
|
90
|
|
|
$this->const[$r][2] = "standard"; |
|
91
|
|
|
$this->const[$r][3] = 'Name of PDF model of member'; |
|
92
|
|
|
$this->const[$r][4] = 0; |
|
93
|
|
|
$r++; |
|
94
|
|
|
|
|
95
|
|
|
// For emails |
|
96
|
|
|
$this->const[$r][0] = "ADHERENT_MAIL_FROM"; |
|
97
|
|
|
$this->const[$r][1] = "chaine"; |
|
98
|
|
|
$this->const[$r][2] = ""; |
|
99
|
|
|
$this->const[$r][3] = "From des mails"; |
|
100
|
|
|
$this->const[$r][4] = 0; |
|
101
|
|
|
$r++; |
|
102
|
|
|
|
|
103
|
|
|
$this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER"; |
|
104
|
|
|
$this->const[$r][1] = "emailtemplate:member"; |
|
105
|
|
|
$this->const[$r][2] = "(SendingEmailOnAutoSubscription)"; |
|
106
|
|
|
$this->const[$r][3] = ""; |
|
107
|
|
|
$this->const[$r][4] = 0; |
|
108
|
|
|
$r++; |
|
109
|
|
|
|
|
110
|
|
|
$this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION"; |
|
111
|
|
|
$this->const[$r][1] = "emailtemplate:member"; |
|
112
|
|
|
$this->const[$r][2] = "(SendingEmailOnNewSubscription)"; |
|
113
|
|
|
$this->const[$r][3] = ""; |
|
114
|
|
|
$this->const[$r][4] = 0; |
|
115
|
|
|
$r++; |
|
116
|
|
|
|
|
117
|
|
|
$this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION"; |
|
118
|
|
|
$this->const[$r][1] = "emailtemplate:member"; |
|
119
|
|
|
$this->const[$r][2] = "(SendingReminderForExpiredSubscription)"; |
|
120
|
|
|
$this->const[$r][3] = ""; |
|
121
|
|
|
$this->const[$r][4] = 0; |
|
122
|
|
|
$r++; |
|
123
|
|
|
|
|
124
|
|
|
$this->const[$r][0] = "ADHERENT_EMAIL_TEMPLATE_CANCELATION"; |
|
125
|
|
|
$this->const[$r][1] = "emailtemplate:member"; |
|
126
|
|
|
$this->const[$r][2] = "(SendingEmailOnCancelation)"; |
|
127
|
|
|
$this->const[$r][3] = ""; |
|
128
|
|
|
$this->const[$r][4] = 0; |
|
129
|
|
|
$r++; |
|
130
|
|
|
|
|
131
|
|
|
// For cards |
|
132
|
|
|
$this->const[$r][0] = "ADHERENT_CARD_HEADER_TEXT"; |
|
133
|
|
|
$this->const[$r][1] = "chaine"; |
|
134
|
|
|
$this->const[$r][2] = "__YEAR__"; |
|
135
|
|
|
$this->const[$r][3] = "Texte imprimé sur le haut de la carte adhérent"; |
|
136
|
|
|
$this->const[$r][4] = 0; |
|
137
|
|
|
$r++; |
|
138
|
|
|
|
|
139
|
|
|
$this->const[$r][0] = "ADHERENT_CARD_FOOTER_TEXT"; |
|
140
|
|
|
$this->const[$r][1] = "chaine"; |
|
141
|
|
|
$this->const[$r][2] = "__COMPANY__"; |
|
142
|
|
|
$this->const[$r][3] = "Texte imprimé sur le bas de la carte adhérent"; |
|
143
|
|
|
$this->const[$r][4] = 0; |
|
144
|
|
|
$r++; |
|
145
|
|
|
|
|
146
|
|
|
$this->const[$r][0] = "ADHERENT_CARD_TEXT"; |
|
147
|
|
|
$this->const[$r][1] = "texte"; |
|
148
|
|
|
$this->const[$r][2] = "__FULLNAME__\r\nID: __ID__\r\n__EMAIL__\r\n__ADDRESS__\r\n__ZIP__ __TOWN__\r\n__COUNTRY__"; |
|
149
|
|
|
$this->const[$r][3] = "Text to print on member cards"; |
|
150
|
|
|
$this->const[$r][4] = 0; |
|
151
|
|
|
$r++; |
|
152
|
|
|
|
|
153
|
|
|
$this->const[$r][0] = "ADHERENT_MAILMAN_ADMIN_PASSWORD"; |
|
154
|
|
|
$this->const[$r][1] = "chaine"; |
|
155
|
|
|
$this->const[$r][2] = ""; |
|
156
|
|
|
$this->const[$r][3] = "Password admin mailman lists"; |
|
157
|
|
|
$this->const[$r][4] = 0; |
|
158
|
|
|
$r++; |
|
159
|
|
|
|
|
160
|
|
|
$this->const[$r][0] = "ADHERENT_ETIQUETTE_TYPE"; |
|
161
|
|
|
$this->const[$r][1] = "chaine"; |
|
162
|
|
|
$this->const[$r][2] = "L7163"; |
|
163
|
|
|
$this->const[$r][3] = "Type of address sheets"; |
|
164
|
|
|
$this->const[$r][4] = 0; |
|
165
|
|
|
$r++; |
|
166
|
|
|
|
|
167
|
|
|
$this->const[$r][0] = "ADHERENT_ETIQUETTE_TEXT"; |
|
168
|
|
|
$this->const[$r][1] = "texte"; |
|
169
|
|
|
$this->const[$r][2] = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__"; |
|
170
|
|
|
$this->const[$r][3] = "Text to print on member address sheets"; |
|
171
|
|
|
$this->const[$r][4] = 0; |
|
172
|
|
|
$r++; |
|
173
|
|
|
|
|
174
|
|
|
// For subscriptions |
|
175
|
|
|
$this->const[$r][0] = "ADHERENT_BANK_ACCOUNT"; |
|
176
|
|
|
$this->const[$r][1] = "chaine"; |
|
177
|
|
|
$this->const[$r][2] = ""; |
|
178
|
|
|
$this->const[$r][3] = "ID of bank account to use"; |
|
179
|
|
|
$this->const[$r][4] = 0; |
|
180
|
|
|
$r++; |
|
181
|
|
|
|
|
182
|
|
|
$this->const[$r][0] = "ADHERENT_BANK_CATEGORIE"; |
|
183
|
|
|
$this->const[$r][1] = "chaine"; |
|
184
|
|
|
$this->const[$r][2] = ""; |
|
185
|
|
|
$this->const[$r][3] = "ID of bank transaction category to use"; |
|
186
|
|
|
$this->const[$r][4] = 0; |
|
187
|
|
|
$r++; |
|
188
|
|
|
|
|
189
|
|
|
$this->const[$r][0] = "MEMBER_ADDON_PDF_ODT_PATH"; |
|
190
|
|
|
$this->const[$r][1] = "chaine"; |
|
191
|
|
|
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/members"; |
|
192
|
|
|
$this->const[$r][3] = ""; |
|
193
|
|
|
$this->const[$r][4] = 0; |
|
194
|
|
|
$r++; |
|
195
|
|
|
|
|
196
|
|
|
|
|
197
|
|
|
// Boxes |
|
198
|
|
|
//------- |
|
199
|
|
|
$this->boxes = array( |
|
200
|
|
|
0 => array('file' => 'box_members.php', 'enabledbydefaulton' => 'Home'), |
|
201
|
|
|
2 => array('file' => 'box_birthdays_members.php', 'enabledbydefaulton' => 'Home'), |
|
202
|
|
|
3 => array('file' => 'box_members_last_modified.php', 'enabledbydefaulton' => 'membersindex'), |
|
203
|
|
|
4 => array('file' => 'box_members_last_subscriptions.php', 'enabledbydefaulton' => 'membersindex'), |
|
204
|
|
|
5 => array('file' => 'box_members_subscriptions_by_year.php', 'enabledbydefaulton' => 'membersindex'), |
|
205
|
|
|
6 => array('file' => 'box_members_by_type.php', 'enabledbydefaulton' => 'membersindex'), |
|
206
|
|
|
7 => array('file' => 'box_members_by_tags.php', 'enabledbydefaulton' => 'membersindex'), |
|
207
|
|
|
); |
|
208
|
|
|
|
|
209
|
|
|
// Permissions |
|
210
|
|
|
//------------ |
|
211
|
|
|
$this->rights = array(); |
|
212
|
|
|
$this->rights_class = 'adherent'; |
|
213
|
|
|
$r = 0; |
|
214
|
|
|
|
|
215
|
|
|
// $this->rights[$r][0] Id permission (unique tous modules confondus) |
|
216
|
|
|
// $this->rights[$r][1] Libelle par default si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission) |
|
217
|
|
|
// $this->rights[$r][2] Non utilise |
|
218
|
|
|
// $this->rights[$r][3] 1=Permis par default, 0=Non permis par default |
|
219
|
|
|
// $this->rights[$r][4] Niveau 1 pour nommer permission dans code |
|
220
|
|
|
// $this->rights[$r][5] Niveau 2 pour nommer permission dans code |
|
221
|
|
|
|
|
222
|
|
|
$r++; |
|
223
|
|
|
$this->rights[$r][0] = 71; |
|
224
|
|
|
$this->rights[$r][1] = 'Read members\' card'; |
|
225
|
|
|
$this->rights[$r][2] = 'r'; |
|
226
|
|
|
$this->rights[$r][3] = 0; |
|
227
|
|
|
$this->rights[$r][4] = 'lire'; |
|
228
|
|
|
|
|
229
|
|
|
$r++; |
|
230
|
|
|
$this->rights[$r][0] = 72; |
|
231
|
|
|
$this->rights[$r][1] = 'Create/modify members (need also user module permissions if member linked to a user)'; |
|
232
|
|
|
$this->rights[$r][2] = 'w'; |
|
233
|
|
|
$this->rights[$r][3] = 0; |
|
234
|
|
|
$this->rights[$r][4] = 'creer'; |
|
235
|
|
|
|
|
236
|
|
|
$r++; |
|
237
|
|
|
$this->rights[$r][0] = 74; |
|
238
|
|
|
$this->rights[$r][1] = 'Remove members'; |
|
239
|
|
|
$this->rights[$r][2] = 'd'; |
|
240
|
|
|
$this->rights[$r][3] = 0; |
|
241
|
|
|
$this->rights[$r][4] = 'supprimer'; |
|
242
|
|
|
|
|
243
|
|
|
$r++; |
|
244
|
|
|
$this->rights[$r][0] = 76; |
|
245
|
|
|
$this->rights[$r][1] = 'Export members'; |
|
246
|
|
|
$this->rights[$r][2] = 'r'; |
|
247
|
|
|
$this->rights[$r][3] = 0; |
|
248
|
|
|
$this->rights[$r][4] = 'export'; |
|
249
|
|
|
|
|
250
|
|
|
$r++; |
|
251
|
|
|
$this->rights[$r][0] = 75; |
|
252
|
|
|
$this->rights[$r][1] = 'Setup types of membership'; |
|
253
|
|
|
$this->rights[$r][2] = 'w'; |
|
254
|
|
|
$this->rights[$r][3] = 0; |
|
255
|
|
|
$this->rights[$r][4] = 'configurer'; |
|
256
|
|
|
|
|
257
|
|
|
$r++; |
|
258
|
|
|
$this->rights[$r][0] = 78; |
|
259
|
|
|
$this->rights[$r][1] = 'Read membership fees'; |
|
260
|
|
|
$this->rights[$r][2] = 'r'; |
|
261
|
|
|
$this->rights[$r][3] = 0; |
|
262
|
|
|
$this->rights[$r][4] = 'cotisation'; |
|
263
|
|
|
$this->rights[$r][5] = 'lire'; |
|
264
|
|
|
|
|
265
|
|
|
$r++; |
|
266
|
|
|
$this->rights[$r][0] = 79; |
|
267
|
|
|
$this->rights[$r][1] = 'Create/modify/remove membership fees'; |
|
268
|
|
|
$this->rights[$r][2] = 'w'; |
|
269
|
|
|
$this->rights[$r][3] = 0; |
|
270
|
|
|
$this->rights[$r][4] = 'cotisation'; |
|
271
|
|
|
$this->rights[$r][5] = 'creer'; |
|
272
|
|
|
|
|
273
|
|
|
|
|
274
|
|
|
// Menus |
|
275
|
|
|
//------- |
|
276
|
|
|
$this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
277
|
|
|
|
|
278
|
|
|
|
|
279
|
|
|
// Exports |
|
280
|
|
|
//-------- |
|
281
|
|
|
$r = 0; |
|
282
|
|
|
|
|
283
|
|
|
// $this->export_code[$r] Unique code identifying the export (all modules combined) |
|
284
|
|
|
// $this->export_label[$r] Libelle by default if translation of key "ExportXXX" not found (XXX = Code) |
|
285
|
|
|
// $this->export_permission[$r] List of permission codes required to export |
|
286
|
|
|
// $this->export_fields_sql[$r] List of exportable fields in SQL codiffication |
|
287
|
|
|
// $this->export_fields_name[$r] List of exportable fields in translation codiffication |
|
288
|
|
|
// $this->export_sql[$r] SQL query that offers data for export |
|
289
|
|
|
|
|
290
|
|
|
$r++; |
|
291
|
|
|
$this->export_code[$r] = $this->rights_class . '_' . $r; |
|
292
|
|
|
$this->export_label[$r] = 'MembersAndSubscriptions'; |
|
293
|
|
|
$this->export_permission[$r] = array(array("adherent", "export")); |
|
294
|
|
|
$this->export_fields_array[$r] = array( |
|
295
|
|
|
'a.rowid' => 'MemberId', 'a.ref' => 'MemberRef', 'a.civility' => "UserTitle", 'a.lastname' => "Lastname", 'a.firstname' => "Firstname", 'a.login' => "Login", 'a.gender' => "Gender", 'a.morphy' => 'MemberNature', |
|
296
|
|
|
'a.societe' => 'Company', 'a.address' => "Address", 'a.zip' => "Zip", 'a.town' => "Town", 'd.code_departement' => 'StateCode', 'd.nom' => "State", 'co.code' => "CountryCode", 'co.label' => "Country", |
|
297
|
|
|
'a.phone' => "PhonePro", 'a.phone_perso' => "PhonePerso", 'a.phone_mobile' => "PhoneMobile", 'a.email' => "Email", 'a.birth' => "Birthday", 'a.statut' => "Status", |
|
298
|
|
|
'a.photo' => "Photo", 'a.note_public' => "NotePublic", 'a.note_private' => "NotePrivate", 'a.datec' => 'DateCreation', 'a.datevalid' => 'DateValidation', |
|
299
|
|
|
'a.tms' => 'DateLastModification', 'a.datefin' => 'DateEndSubscription', 'ta.rowid' => 'MemberTypeId', 'ta.libelle' => 'MemberTypeLabel', |
|
300
|
|
|
'c.rowid' => 'SubscriptionId', 'c.dateadh' => 'DateSubscription', 'c.datef' => 'DateEndSubscription', 'c.subscription' => 'Amount' |
|
301
|
|
|
); |
|
302
|
|
|
$this->export_TypeFields_array[$r] = array( |
|
303
|
|
|
'a.civility' => "Text", 'a.lastname' => "Text", 'a.firstname' => "Text", 'a.login' => "Text", 'a.gender' => 'Text', 'a.morphy' => 'Text', 'a.societe' => 'Text', 'a.address' => "Text", |
|
304
|
|
|
'a.zip' => "Text", 'a.town' => "Text", 'd.nom' => "Text", 'co.code' => 'Text', 'co.label' => "Text", 'a.phone' => "Text", 'a.phone_perso' => "Text", 'a.phone_mobile' => "Text", |
|
305
|
|
|
'a.email' => "Text", 'a.birth' => "Date", 'a.statut' => "Status", 'a.note_public' => "Text", 'a.note_private' => "Text", 'a.datec' => 'Date', 'a.datevalid' => 'Date', |
|
306
|
|
|
'a.tms' => 'Date', 'a.datefin' => 'Date', 'ta.rowid' => 'List:adherent_type:libelle::member_type', 'ta.libelle' => 'Text', |
|
307
|
|
|
'c.rowid' => 'Numeric', 'c.dateadh' => 'Date', 'c.datef' => 'Date', 'c.subscription' => 'Numeric' |
|
308
|
|
|
); |
|
309
|
|
|
$this->export_entities_array[$r] = array( |
|
310
|
|
|
'a.rowid' => 'member', 'a.ref' => 'member', 'a.civility' => "member", 'a.lastname' => "member", 'a.firstname' => "member", 'a.login' => "member", 'a.gender' => 'member', 'a.morphy' => 'member', |
|
311
|
|
|
'a.societe' => 'member', 'a.address' => "member", 'a.zip' => "member", 'a.town' => "member", 'd.nom' => "member", 'co.code' => "member", 'co.label' => "member", |
|
312
|
|
|
'a.phone' => "member", 'a.phone_perso' => "member", 'a.phone_mobile' => "member", 'a.email' => "member", 'a.birth' => "member", 'a.statut' => "member", |
|
313
|
|
|
'a.photo' => "member", 'a.note_public' => "member", 'a.note_private' => "member", 'a.datec' => 'member', 'a.datevalid' => 'member', 'a.tms' => 'member', |
|
314
|
|
|
'a.datefin' => 'member', 'ta.rowid' => 'member_type', 'ta.libelle' => 'member_type', |
|
315
|
|
|
'c.rowid' => 'subscription', 'c.dateadh' => 'subscription', 'c.datef' => 'subscription', 'c.subscription' => 'subscription' |
|
316
|
|
|
); |
|
317
|
|
|
// Add extra fields |
|
318
|
|
|
$keyforselect = 'adherent'; |
|
319
|
|
|
$keyforelement = 'member'; |
|
320
|
|
|
$keyforaliasextra = 'extra'; |
|
321
|
|
|
include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php'; |
|
322
|
|
|
// End add axtra fields |
|
323
|
|
|
$this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
324
|
|
|
$this->export_sql_end[$r] = ' FROM (' . MAIN_DB_PREFIX . 'adherent_type as ta, ' . MAIN_DB_PREFIX . 'adherent as a)'; |
|
325
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'adherent_extrafields as extra ON a.rowid = extra.fk_object'; |
|
326
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'subscription as c ON c.fk_adherent = a.rowid'; |
|
327
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_departements as d ON a.state_id = d.rowid'; |
|
328
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as co ON a.country = co.rowid'; |
|
329
|
|
|
$this->export_sql_end[$r] .= ' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN (' . getEntity('member_type') . ') '; |
|
330
|
|
|
$this->export_dependencies_array[$r] = array('subscription' => 'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them |
|
331
|
|
|
|
|
332
|
|
|
// Imports |
|
333
|
|
|
//-------- |
|
334
|
|
|
$r = 0; |
|
335
|
|
|
|
|
336
|
|
|
$now = dol_now(); |
|
337
|
|
|
require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/date.lib.php'; |
|
338
|
|
|
|
|
339
|
|
|
$r++; |
|
340
|
|
|
$this->import_code[$r] = $this->rights_class . '_' . $r; |
|
341
|
|
|
$this->import_label[$r] = "Members"; // Translation key |
|
342
|
|
|
$this->import_icon[$r] = $this->picto; |
|
343
|
|
|
$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon |
|
344
|
|
|
$this->import_tables_array[$r] = array('a' => MAIN_DB_PREFIX . 'adherent', 'extra' => MAIN_DB_PREFIX . 'adherent_extrafields'); |
|
345
|
|
|
$this->import_tables_creator_array[$r] = array('a' => 'fk_user_author'); // Fields to store import user id |
|
346
|
|
|
$this->import_fields_array[$r] = array( |
|
347
|
|
|
'a.ref' => 'MemberRef*', |
|
348
|
|
|
'a.civility' => "UserTitle", 'a.lastname' => "Lastname*", 'a.firstname' => "Firstname", 'a.gender' => "Gender", 'a.login' => "Login*", "a.pass" => "Password", |
|
349
|
|
|
"a.fk_adherent_type" => "MemberTypeId*", 'a.morphy' => 'MemberNature*', 'a.societe' => 'Company', 'a.address' => "Address", 'a.zip' => "Zip", 'a.town' => "Town", |
|
350
|
|
|
'a.state_id' => 'StateId|StateCode', 'a.country' => "CountryId|CountryCode", 'a.phone' => "PhonePro", 'a.phone_perso' => "PhonePerso", 'a.phone_mobile' => "PhoneMobile", |
|
351
|
|
|
'a.email' => "Email", 'a.birth' => "Birthday", 'a.statut' => "Status*", 'a.photo' => "Photo", 'a.note_public' => "NotePublic", 'a.note_private' => "NotePrivate", |
|
352
|
|
|
'a.datec' => 'DateCreation', 'a.datefin' => 'DateEndSubscription' |
|
353
|
|
|
); |
|
354
|
|
|
if (isModEnabled("societe")) { |
|
355
|
|
|
$this->import_fields_array[$r]['a.fk_soc'] = "ThirdParty"; |
|
356
|
|
|
} |
|
357
|
|
|
// Add extra fields |
|
358
|
|
|
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE type <> 'separate' AND elementtype = 'adherent' AND entity IN (0," . $conf->entity . ")"; |
|
359
|
|
|
$resql = $this->db->query($sql); |
|
360
|
|
|
if ($resql) { // This can fail when class is used on old database (during migration for example) |
|
361
|
|
|
while ($obj = $this->db->fetch_object($resql)) { |
|
362
|
|
|
$fieldname = 'extra.' . $obj->name; |
|
363
|
|
|
$fieldlabel = ucfirst($obj->label); |
|
364
|
|
|
$this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); |
|
365
|
|
|
} |
|
366
|
|
|
} |
|
367
|
|
|
// End add extra fields |
|
368
|
|
|
$this->import_convertvalue_array[$r] = array( |
|
369
|
|
|
'a.ref' => array( |
|
370
|
|
|
'rule' => 'getrefifauto', |
|
371
|
|
|
'class' => getDolGlobalString('MEMBER_ADDON', 'mod_member_simple'), |
|
372
|
|
|
'path' => "/core/modules/member/" . getDolGlobalString('MEMBER_ADDON', 'mod_member_simple') . '.php' |
|
373
|
|
|
), |
|
374
|
|
|
'a.state_id' => array( |
|
375
|
|
|
'rule' => 'fetchidfromcodeid', |
|
376
|
|
|
'classfile' => '/core/class/cstate.class.php', |
|
377
|
|
|
'class' => 'Cstate', |
|
378
|
|
|
'method' => 'fetch', |
|
379
|
|
|
'dict' => 'DictionaryStateCode' |
|
380
|
|
|
), |
|
381
|
|
|
'a.country' => array( |
|
382
|
|
|
'rule' => 'fetchidfromcodeid', |
|
383
|
|
|
'classfile' => '/core/class/ccountry.class.php', |
|
384
|
|
|
'class' => 'Ccountry', |
|
385
|
|
|
'method' => 'fetch', |
|
386
|
|
|
'dict' => 'DictionaryCountry' |
|
387
|
|
|
) |
|
388
|
|
|
); |
|
389
|
|
|
if (isModEnabled("societe")) { |
|
390
|
|
|
$this->import_convertvalue_array[$r]['a.fk_soc'] = array('rule' => 'fetchidfromref', 'classfile' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'); |
|
391
|
|
|
} |
|
392
|
|
|
$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) |
|
393
|
|
|
$this->import_regex_array[$r] = array( |
|
394
|
|
|
'a.civility' => 'code@' . MAIN_DB_PREFIX . 'c_civility', 'a.fk_adherent_type' => 'rowid@' . MAIN_DB_PREFIX . 'adherent_type', 'a.morphy' => '(phy|mor)', |
|
395
|
|
|
'a.statut' => '^[0|1]', 'a.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'a.datefin' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); |
|
396
|
|
|
$this->import_examplevalues_array[$r] = array( |
|
397
|
|
|
'a.ref' => "auto or MEM2010-1234", |
|
398
|
|
|
'a.civility' => "MR", 'a.lastname' => 'Smith', 'a.firstname' => 'John', 'a.gender' => 'man or woman', 'a.login' => 'jsmith', 'a.pass' => 'passofjsmith', 'a.fk_adherent_type' => '1', |
|
399
|
|
|
'a.morphy' => '"mor" or "phy"', 'a.societe' => 'JS company', 'a.address' => '21 jump street', 'a.zip' => '55000', 'a.town' => 'New York', 'a.country' => '1', |
|
400
|
|
|
'a.email' => '[email protected]', 'a.birth' => '1972-10-10', 'a.statut' => "0 or 1", 'a.note_public' => "This is a public comment on member", |
|
401
|
|
|
'a.note_private' => "This is private comment on member", 'a.datec' => dol_print_date($now, '%Y-%m__%d'), 'a.datefin' => dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d') |
|
402
|
|
|
); |
|
403
|
|
|
if (isModEnabled("societe")) { |
|
404
|
|
|
$this->import_examplevalues_array[$r]['a.fk_soc'] = "rowid or name"; |
|
405
|
|
|
} |
|
406
|
|
|
$this->import_updatekeys_array[$r] = array('a.ref' => 'MemberRef', 'a.login' => 'Login'); |
|
407
|
|
|
|
|
408
|
|
|
// Cronjobs |
|
409
|
|
|
$arraydate = dol_getdate(dol_now()); |
|
410
|
|
|
$datestart = dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); |
|
411
|
|
|
$this->cronjobs = array( |
|
412
|
|
|
0 => array( |
|
413
|
|
|
'label' => 'SendReminderForExpiredSubscriptionTitle', |
|
414
|
|
|
'jobtype' => 'method', 'class' => 'adherents/class/adherent.class.php', |
|
415
|
|
|
'objectname' => 'Adherent', |
|
416
|
|
|
'method' => 'sendReminderForExpiredSubscription', |
|
417
|
|
|
'parameters' => '10;0', |
|
418
|
|
|
'comment' => 'SendReminderForExpiredSubscription', |
|
419
|
|
|
'frequency' => 1, |
|
420
|
|
|
'unitfrequency' => 3600 * 24, |
|
421
|
|
|
'priority' => 50, |
|
422
|
|
|
'status' => 1, |
|
423
|
|
|
'test' => '$conf->adherent->enabled', |
|
424
|
|
|
'datestart' => $datestart |
|
425
|
|
|
), |
|
426
|
|
|
); |
|
427
|
|
|
} |
|
428
|
|
|
|
|
429
|
|
|
|
|
430
|
|
|
/** |
|
431
|
|
|
* Function called when module is enabled. |
|
432
|
|
|
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. |
|
433
|
|
|
* It also creates data directories |
|
434
|
|
|
* |
|
435
|
|
|
* @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') |
|
436
|
|
|
* @return int 1 if OK, 0 if KO |
|
437
|
|
|
*/ |
|
438
|
|
|
public function init($options = '') |
|
439
|
|
|
{ |
|
440
|
|
|
global $conf; |
|
441
|
|
|
|
|
442
|
|
|
// Permissions |
|
443
|
|
|
$this->remove($options); |
|
444
|
|
|
|
|
445
|
|
|
// ODT template |
|
446
|
|
|
/* |
|
447
|
|
|
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; |
|
448
|
|
|
$dirodt=DOL_DATA_ROOT.'/doctemplates/orders'; |
|
449
|
|
|
$dest=$dirodt.'/template_order.odt'; |
|
450
|
|
|
|
|
451
|
|
|
if (file_exists($src) && ! file_exists($dest)) { |
|
452
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
453
|
|
|
dol_mkdir($dirodt); |
|
454
|
|
|
$result=dol_copy($src,$dest,0,0); |
|
455
|
|
|
if ($result < 0) { |
|
456
|
|
|
$langs->load("errors"); |
|
457
|
|
|
$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); |
|
458
|
|
|
return 0; |
|
459
|
|
|
} |
|
460
|
|
|
}*/ |
|
461
|
|
|
|
|
462
|
|
|
$sql = array( |
|
463
|
|
|
"DELETE FROM " . MAIN_DB_PREFIX . "document_model WHERE nom = '" . $this->db->escape($this->const[0][2]) . "' AND type='member' AND entity = " . ((int)$conf->entity), |
|
464
|
|
|
"INSERT INTO " . MAIN_DB_PREFIX . "document_model (nom, type, entity) VALUES('" . $this->db->escape($this->const[0][2]) . "','member'," . ((int)$conf->entity) . ")" |
|
465
|
|
|
); |
|
466
|
|
|
|
|
467
|
|
|
return $this->_init($sql, $options); |
|
468
|
|
|
} |
|
469
|
|
|
} |
|
470
|
|
|
|