Passed
Branch develop (5baba6)
by
unknown
30:41
created

modAdherent::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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