modAdherent.class.php 20 KB

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