2004-10-20 00:24:10 +02:00
< ? php
2018-11-18 21:50:58 +01:00
/* Copyright ( C ) 2003 , 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2003 Jean - Louis Bergamo < jlb @ j1b . org >
* Copyright ( C ) 2004 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2004 Sebastien Di Cintio < sdicintio @ ressource - toi . org >
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
* Copyright ( C ) 2013 Juanjo Menent < jmenent @ 2 byte . es >
* Copyright ( C ) 2014 - 2015 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
2019-01-28 21:39:22 +01:00
* Copyright ( C ) 2018 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2003-09-15 16:03:49 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2003-09-15 16:03:49 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2003-09-15 16:03:49 +02:00
*/
2005-03-06 01:15:34 +01:00
/**
2011-08-31 12:27:17 +02:00
* \defgroup member Module foundation
* \brief Module to manage members of a foundation
2011-10-24 14:11:49 +02:00
* \file htdocs / core / modules / modAdherent . class . php
2009-10-10 18:00:35 +02:00
* \ingroup member
* \brief File descriptor or module Member
2009-04-10 02:29:23 +02:00
*/
2019-11-13 19:37:08 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2003-09-15 16:03:49 +02:00
2005-09-04 20:58:06 +02:00
/**
2015-09-07 15:55:26 +02:00
* Class to describe and enable module Adherent
2009-07-27 02:08:49 +02:00
*/
2003-11-15 18:42:11 +01:00
class modAdherent extends DolibarrModules
2003-09-15 16:03:49 +02:00
{
2005-09-04 20:58:06 +02:00
/**
2019-02-25 20:35:59 +01:00
* Constructor . Define names , constants , directories , boxes , permissions
*
* @ param DoliDB $db Database handler
2005-09-04 20:58:06 +02:00
*/
2019-02-25 20:35:59 +01:00
public function __construct ( $db )
2005-09-04 20:58:06 +02:00
{
2019-02-25 20:35:59 +01:00
global $conf ;
2013-06-14 02:35:30 +02:00
2012-01-04 21:23:50 +01:00
$this -> db = $db ;
$this -> numero = 310 ;
2009-02-11 21:44:00 +01:00
2005-09-04 20:58:06 +02:00
$this -> family = " hr " ;
2020-05-02 00:41:27 +02:00
$this -> module_position = '06' ;
2019-02-25 20:35:59 +01:00
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
2015-01-25 22:29:36 +01:00
$this -> description = " Management of members of a foundation or association " ;
2019-02-25 20:35:59 +01:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
2017-08-22 18:34:58 +02:00
$this -> version = 'dolibarr' ;
2008-10-06 09:39:52 +02:00
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
2020-04-07 16:45:08 +02:00
$this -> picto = 'member' ;
2009-02-11 21:44:00 +01:00
2009-04-28 15:52:08 +02:00
// Data directories to create when module is enabled
2011-06-21 14:39:09 +02:00
$this -> dirs = array ( " /adherent/temp " );
2009-02-11 21:44:00 +01:00
2005-09-04 20:58:06 +02:00
// Config pages
2010-05-01 12:32:15 +02:00
$this -> config_page_url = array ( " adherent.php@adherents " );
2009-02-11 21:44:00 +01:00
2015-09-07 15:29:51 +02:00
// Dependencies
2019-11-13 19:37:08 +01:00
$this -> hidden = false ; // A condition to hide module
$this -> depends = array (); // List of module class names as string that must be enabled if this module is enabled
$this -> requiredby = array (); // List of module ids to disable if this one is disabled
$this -> conflictwith = array ( 'modMailmanSpip' ); // List of module class names as string this module is in conflict with
$this -> langfiles = array ( " members " , " companies " );
$this -> phpmin = array ( 5 , 4 ); // Minimum version of PHP required by module
2009-02-11 21:44:00 +01:00
2015-09-07 15:40:55 +02:00
// Constants
2005-09-04 20:58:06 +02:00
$this -> const = array ();
2019-11-13 19:37:08 +01:00
$r = 0 ;
2017-08-22 18:34:58 +02:00
2016-10-02 20:00:57 +02:00
$this -> const [ $r ][ 0 ] = " ADHERENT_ADDON_PDF " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " standard " ;
$this -> const [ $r ][ 3 ] = 'Name of PDF model of member' ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2017-08-22 18:34:58 +02:00
2018-03-23 16:09:46 +01:00
// For emails
$this -> const [ $r ][ 0 ] = " ADHERENT_MAIL_FROM " ;
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 1 ] = " chaine " ;
2018-03-23 16:09:46 +01:00
$this -> const [ $r ][ 2 ] = " " ;
$this -> const [ $r ][ 3 ] = " From des mails " ;
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2017-08-22 18:34:58 +02:00
2018-03-23 16:09:46 +01:00
$this -> const [ $r ][ 0 ] = " ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER " ;
$this -> const [ $r ][ 1 ] = " emailtemplate:member " ;
$this -> const [ $r ][ 2 ] = " (SendingEmailOnAutoSubscription) " ;
$this -> const [ $r ][ 3 ] = " " ;
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2017-08-22 18:34:58 +02:00
2018-03-23 16:09:46 +01:00
$this -> const [ $r ][ 0 ] = " ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION " ;
$this -> const [ $r ][ 1 ] = " emailtemplate:member " ;
$this -> const [ $r ][ 2 ] = " (SendingEmailOnNewSubscription) " ;
$this -> const [ $r ][ 3 ] = " " ;
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2017-08-22 18:34:58 +02:00
2018-03-23 16:09:46 +01:00
$this -> const [ $r ][ 0 ] = " ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION " ;
$this -> const [ $r ][ 1 ] = " emailtemplate:member " ;
$this -> const [ $r ][ 2 ] = " (SendingReminderForExpiredSubscription) " ;
$this -> const [ $r ][ 3 ] = " " ;
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2017-08-22 18:34:58 +02:00
2018-03-23 16:09:46 +01:00
$this -> const [ $r ][ 0 ] = " ADHERENT_EMAIL_TEMPLATE_CANCELATION " ;
$this -> const [ $r ][ 1 ] = " emailtemplate:member " ;
$this -> const [ $r ][ 2 ] = " (SendingEmailOnCancelation) " ;
$this -> const [ $r ][ 3 ] = " " ;
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2017-08-22 18:34:58 +02:00
2018-03-23 16:09:46 +01:00
// For cards
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 0 ] = " ADHERENT_CARD_HEADER_TEXT " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
2017-10-09 16:33:22 +02:00
$this -> const [ $r ][ 2 ] = " __YEAR__ " ;
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 3 ] = " Texte imprimé sur le haut de la carte adhérent " ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2017-08-22 18:34:58 +02:00
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 0 ] = " ADHERENT_CARD_FOOTER_TEXT " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
2017-10-09 16:33:22 +02:00
$this -> const [ $r ][ 2 ] = " __COMPANY__ " ;
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 3 ] = " Texte imprimé sur le bas de la carte adhérent " ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2017-08-22 18:34:58 +02:00
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 0 ] = " ADHERENT_CARD_TEXT " ;
$this -> const [ $r ][ 1 ] = " texte " ;
2017-10-09 16:33:22 +02:00
$this -> const [ $r ][ 2 ] = " __FULLNAME__ \r \n ID: __ID__ \r \n __EMAIL__ \r \n __ADDRESS__ \r \n __ZIP__ __TOWN__ \r \n __COUNTRY__ " ;
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 3 ] = " Text to print on member cards " ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2017-08-22 18:34:58 +02:00
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 0 ] = " ADHERENT_MAILMAN_ADMINPW " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " " ;
$this -> const [ $r ][ 3 ] = " Mot de passe Admin des liste mailman " ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2017-08-22 18:34:58 +02:00
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 0 ] = " ADHERENT_ETIQUETTE_TYPE " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " L7163 " ;
$this -> const [ $r ][ 3 ] = " Type of address sheets " ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2017-08-22 18:34:58 +02:00
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 0 ] = " ADHERENT_ETIQUETTE_TEXT " ;
$this -> const [ $r ][ 1 ] = " texte " ;
2017-10-09 16:33:22 +02:00
$this -> const [ $r ][ 2 ] = " __FULLNAME__ \n __ADDRESS__ \n __ZIP__ __TOWN__ \n __COUNTRY% " ;
2015-09-07 17:02:53 +02:00
$this -> const [ $r ][ 3 ] = " Text to print on member address sheets " ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2017-08-22 18:34:58 +02:00
2018-03-23 16:09:46 +01:00
// For subscriptions
$this -> const [ $r ][ 0 ] = " ADHERENT_BANK_ACCOUNT " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " " ;
$this -> const [ $r ][ 3 ] = " ID of bank account to use " ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
$this -> const [ $r ][ 0 ] = " ADHERENT_BANK_CATEGORIE " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " " ;
$this -> const [ $r ][ 3 ] = " ID of bank transaction category to use " ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2012-04-28 16:37:58 +02:00
// Boxes
2005-09-04 20:58:06 +02:00
//-------
2019-08-23 13:57:22 +02:00
$this -> boxes = array (
2020-04-10 10:59:32 +02:00
0 => array ( 'file' => 'box_members.php' , 'enabledbydefaulton' => 'Home' ),
2 => array ( 'file' => 'box_birthdays_members.php' , 'enabledbydefaulton' => 'Home' )
2019-08-23 13:57:22 +02:00
);
2009-02-11 21:44:00 +01:00
2005-09-04 20:58:06 +02:00
// Permissions
//------------
$this -> rights = array ();
$this -> rights_class = 'adherent' ;
2020-04-10 10:59:32 +02:00
$r = 0 ;
2005-09-04 20:58:06 +02:00
// $this->rights[$r][0] Id permission (unique tous modules confondus)
2007-12-26 11:09:30 +01:00
// $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)
// $this->rights[$r][2] Non utilise
2005-09-04 20:58:06 +02:00
// $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut
// $this->rights[$r][4] Niveau 1 pour nommer permission dans code
// $this->rights[$r][5] Niveau 2 pour nommer permission dans code
2009-02-11 21:44:00 +01:00
2005-09-04 20:58:06 +02:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 71 ;
2009-07-18 17:01:45 +02:00
$this -> rights [ $r ][ 1 ] = 'Read members\' card' ;
2005-09-04 20:58:06 +02:00
$this -> rights [ $r ][ 2 ] = 'r' ;
2016-06-04 12:16:30 +02:00
$this -> rights [ $r ][ 3 ] = 0 ;
2005-09-04 20:58:06 +02:00
$this -> rights [ $r ][ 4 ] = 'lire' ;
2009-02-11 21:44:00 +01:00
2005-09-04 20:58:06 +02:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 72 ;
2009-07-18 17:01:45 +02:00
$this -> rights [ $r ][ 1 ] = 'Create/modify members (need also user module permissions if member linked to a user)' ;
2005-09-04 20:58:06 +02:00
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'creer' ;
2009-02-11 21:44:00 +01:00
2005-09-04 20:58:06 +02:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 74 ;
2009-07-18 17:01:45 +02:00
$this -> rights [ $r ][ 1 ] = 'Remove members' ;
2005-09-04 20:58:06 +02:00
$this -> rights [ $r ][ 2 ] = 'd' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'supprimer' ;
2009-02-11 21:44:00 +01:00
2005-09-04 20:58:06 +02:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 76 ;
2009-07-18 17:01:45 +02:00
$this -> rights [ $r ][ 1 ] = 'Export members' ;
2005-09-04 20:58:06 +02:00
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'export' ;
2009-02-11 21:44:00 +01:00
2005-09-04 20:58:06 +02:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 75 ;
2015-01-25 22:29:36 +01:00
$this -> rights [ $r ][ 1 ] = 'Setup types of membership' ;
2005-09-04 20:58:06 +02:00
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'configurer' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 78 ;
2009-07-18 17:01:45 +02:00
$this -> rights [ $r ][ 1 ] = 'Read subscriptions' ;
2005-09-04 20:58:06 +02:00
$this -> rights [ $r ][ 2 ] = 'r' ;
2016-06-04 12:16:30 +02:00
$this -> rights [ $r ][ 3 ] = 0 ;
2005-09-04 20:58:06 +02:00
$this -> rights [ $r ][ 4 ] = 'cotisation' ;
$this -> rights [ $r ][ 5 ] = 'lire' ;
2009-02-11 21:44:00 +01:00
2005-09-04 20:58:06 +02:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 79 ;
2009-07-18 17:01:45 +02:00
$this -> rights [ $r ][ 1 ] = 'Create/modify/remove subscriptions' ;
2005-09-04 20:58:06 +02:00
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'cotisation' ;
$this -> rights [ $r ][ 5 ] = 'creer' ;
2016-09-30 13:02:13 +02:00
2019-02-25 20:35:59 +01:00
// Menus
//-------
2019-11-13 19:37:08 +01:00
$this -> menu = 1 ; // This module add menu entries. They are coded into menu manager.
2017-08-22 18:34:58 +02:00
2005-09-04 20:58:06 +02:00
// Exports
//--------
2019-11-13 19:37:08 +01:00
$r = 0 ;
2005-09-04 20:58:06 +02:00
2019-04-01 09:36:52 +02:00
// $this->export_code[$r] Unique code identifying the export (all modules combined)
2019-04-01 09:38:23 +02:00
// $this->export_label[$r] Libelle by default if translation of key "ExportXXX" not found (XXX = Code)
2019-04-01 09:39:22 +02:00
// $this->export_permission[$r] List of permission codes required to export
2019-04-01 09:40:50 +02:00
// $this->export_fields_sql[$r] List of exportable fields in SQL codiffication
2019-04-01 09:42:01 +02:00
// $this->export_fields_name[$r] List of exportable fields in translation codiffication
2019-04-01 09:43:07 +02:00
// $this->export_sql[$r] SQL query that offers data for export
2005-09-04 20:58:06 +02:00
$r ++ ;
2020-04-10 10:59:32 +02:00
$this -> export_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> export_label [ $r ] = 'MembersAndSubscriptions' ;
$this -> export_permission [ $r ] = array ( array ( " adherent " , " export " ));
$this -> export_fields_array [ $r ] = array (
'a.rowid' => 'Id' , 'a.civility' => " UserTitle " , 'a.lastname' => " Lastname " , 'a.firstname' => " Firstname " , 'a.login' => " Login " , 'a.gender' => " Gender " , 'a.morphy' => 'Nature' ,
'a.societe' => 'Company' , 'a.address' => " Address " , 'a.zip' => " Zip " , 'a.town' => " Town " , 'd.nom' => " State " , 'co.code' => " CountryCode " , 'co.label' => " Country " ,
'a.phone' => " PhonePro " , 'a.phone_perso' => " PhonePerso " , 'a.phone_mobile' => " PhoneMobile " , 'a.email' => " Email " , 'a.birth' => " Birthday " , 'a.statut' => " Status " ,
'a.photo' => " Photo " , 'a.note_public' => " NotePublic " , 'a.note_private' => " NotePrivate " , 'a.datec' => 'DateCreation' , 'a.datevalid' => 'DateValidation' ,
'a.tms' => 'DateLastModification' , 'a.datefin' => 'DateEndSubscription' , 'ta.rowid' => 'MemberTypeId' , 'ta.libelle' => 'MemberTypeLabel' ,
'c.rowid' => 'SubscriptionId' , 'c.dateadh' => 'DateSubscription' , 'c.datef' => 'DateEndSubscription' , 'c.subscription' => 'Amount'
2019-02-25 20:35:59 +01:00
);
2020-04-10 10:59:32 +02:00
$this -> export_TypeFields_array [ $r ] = array (
'a.civility' => " Text " , 'a.lastname' => " Text " , 'a.firstname' => " Text " , 'a.login' => " Text " , 'a.gender' => 'Text' , 'a.morphy' => 'Text' , 'a.societe' => 'Text' , 'a.address' => " Text " ,
'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 " ,
'a.email' => " Text " , 'a.birth' => " Date " , 'a.statut' => " Status " , 'a.note_public' => " Text " , 'a.note_private' => " Text " , 'a.datec' => 'Date' , 'a.datevalid' => 'Date' ,
'a.tms' => 'Date' , 'a.datefin' => 'Date' , 'ta.rowid' => 'List:adherent_type:libelle::member_type' , 'ta.libelle' => 'Text' ,
'c.rowid' => 'Numeric' , 'c.dateadh' => 'Date' , 'c.datef' => 'Date' , 'c.subscription' => 'Numeric'
2019-02-25 20:35:59 +01:00
);
2020-04-10 10:59:32 +02:00
$this -> export_entities_array [ $r ] = array (
'a.rowid' => 'member' , 'a.civility' => " member " , 'a.lastname' => " member " , 'a.firstname' => " member " , 'a.login' => " member " , 'a.gender' => 'member' , 'a.morphy' => 'member' ,
'a.societe' => 'member' , 'a.address' => " member " , 'a.zip' => " member " , 'a.town' => " member " , 'd.nom' => " member " , 'co.code' => " member " , 'co.label' => " member " ,
'a.phone' => " member " , 'a.phone_perso' => " member " , 'a.phone_mobile' => " member " , 'a.email' => " member " , 'a.birth' => " member " , 'a.statut' => " member " ,
'a.photo' => " member " , 'a.note_public' => " member " , 'a.note_private' => " member " , 'a.datec' => 'member' , 'a.datevalid' => 'member' , 'a.tms' => 'member' ,
'a.datefin' => 'member' , 'ta.rowid' => 'member_type' , 'ta.libelle' => 'member_type' ,
'c.rowid' => 'subscription' , 'c.dateadh' => 'subscription' , 'c.datef' => 'subscription' , 'c.subscription' => 'subscription'
2019-02-25 20:35:59 +01:00
);
2016-12-06 11:52:07 +01:00
// Add extra fields
2020-04-10 10:59:32 +02:00
$keyforselect = 'adherent' ; $keyforelement = 'member' ; $keyforaliasextra = 'extra' ;
2016-12-06 11:52:07 +01:00
include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php' ;
2019-02-25 20:35:59 +01:00
// End add axtra fields
2020-04-10 10:59:32 +02:00
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
$this -> export_sql_end [ $r ] = ' FROM (' . MAIN_DB_PREFIX . 'adherent_type as ta, ' . MAIN_DB_PREFIX . 'adherent as a)' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'adherent_extrafields as extra ON a.rowid = extra.fk_object' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'subscription as c ON c.fk_adherent = a.rowid' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_departements as d ON a.state_id = d.rowid' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as co ON a.country = co.rowid' ;
$this -> export_sql_end [ $r ] .= ' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN (' . getEntity ( 'member_type' ) . ') ' ;
$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
2010-09-30 21:25:58 +02:00
// Imports
//--------
2020-04-10 10:59:32 +02:00
$r = 0 ;
2010-09-30 21:25:58 +02:00
2020-04-10 10:59:32 +02:00
$now = dol_now ();
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2010-10-02 01:37:36 +02:00
2010-09-30 21:25:58 +02:00
$r ++ ;
2020-04-10 10:59:32 +02:00
$this -> import_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> import_label [ $r ] = " Members " ; // Translation key
$this -> import_icon [ $r ] = $this -> picto ;
$this -> import_entities_array [ $r ] = array (); // We define here only fields that use another icon that the one defined into import_icon
$this -> import_tables_array [ $r ] = array ( 'a' => MAIN_DB_PREFIX . 'adherent' , 'extra' => MAIN_DB_PREFIX . 'adherent_extrafields' );
$this -> import_tables_creator_array [ $r ] = array ( 'a' => 'fk_user_author' ); // Fields to store import user id
$this -> import_fields_array [ $r ] = array (
'a.civility' => " UserTitle " , 'a.lastname' => " Lastname* " , 'a.firstname' => " Firstname " , 'a.gender' => " Gender " , 'a.login' => " Login* " , " a.pass " => " Password " ,
" a.fk_adherent_type " => " MemberType* " , 'a.morphy' => 'Nature*' , 'a.societe' => 'Company' , 'a.address' => " Address " , 'a.zip' => " Zip " , 'a.town' => " Town " ,
'a.state_id' => 'StateId' , 'a.country' => " CountryId " , 'a.phone' => " PhonePro " , 'a.phone_perso' => " PhonePerso " , 'a.phone_mobile' => " PhoneMobile " ,
'a.email' => " Email " , 'a.birth' => " Birthday " , 'a.statut' => " Status* " , 'a.photo' => " Photo " , 'a.note_public' => " NotePublic " , 'a.note_private' => " NotePrivate " ,
'a.datec' => 'DateCreation' , 'a.datefin' => 'DateEndSubscription'
2019-02-25 20:35:59 +01:00
);
// Add extra fields
2020-04-10 10:59:32 +02:00
$sql = " SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . " extrafields WHERE elementtype = 'adherent' AND entity IN (0, " . $conf -> entity . " ) " ;
$resql = $this -> db -> query ( $sql );
2019-02-25 20:35:59 +01:00
if ( $resql ) // This can fail when class is used on old database (during migration for example)
{
2020-04-10 10:59:32 +02:00
while ( $obj = $this -> db -> fetch_object ( $resql ))
2019-02-25 20:35:59 +01:00
{
2020-04-10 10:59:32 +02:00
$fieldname = 'extra.' . $obj -> name ;
$fieldlabel = ucfirst ( $obj -> label );
$this -> import_fields_array [ $r ][ $fieldname ] = $fieldlabel . ( $obj -> fieldrequired ? '*' : '' );
2019-02-25 20:35:59 +01:00
}
}
// End add extra fields
2020-04-10 10:59:32 +02:00
$this -> import_fieldshidden_array [ $r ] = array ( 'extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'adherent' ); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this -> import_regex_array [ $r ] = array (
'a.civility' => 'code@' . MAIN_DB_PREFIX . 'c_civility' , 'a.fk_adherent_type' => 'rowid@' . MAIN_DB_PREFIX . 'adherent_type' , 'a.morphy' => '(phy|mor)' ,
'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]$' );
$this -> import_examplevalues_array [ $r ] = array (
'a.civility' => " MR " , 'a.lastname' => 'Smith' , 'a.firstname' => 'John' , 'a.login' => 'jsmith' , 'a.pass' => 'passofjsmith' , 'a.fk_adherent_type' => '1' ,
'a.morphy' => '"mor" or "phy"' , 'a.societe' => 'JS company' , 'a.address' => '21 jump street' , 'a.zip' => '55000' , 'a.town' => 'New York' , 'a.country' => '1' ,
'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 " ,
'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' )
2019-02-25 20:35:59 +01:00
);
2018-03-21 16:40:09 +01:00
// Cronjobs
2020-04-10 10:59:32 +02:00
$arraydate = dol_getdate ( dol_now ());
$datestart = dol_mktime ( 22 , 0 , 0 , $arraydate [ 'mon' ], $arraydate [ 'mday' ], $arraydate [ 'year' ]);
2018-03-21 16:40:09 +01:00
$this -> cronjobs = array (
2019-02-25 20:35:59 +01:00
0 => array (
'label' => 'SendReminderForExpiredSubscriptionTitle' ,
'jobtype' => 'method' , 'class' => 'adherents/class/adherent.class.php' ,
'objectname' => 'Adherent' ,
'method' => 'sendReminderForExpiredSubscription' ,
'parameters' => '10;0' ,
'comment' => 'SendReminderForExpiredSubscription' ,
'frequency' => 1 ,
'unitfrequency' => 3600 * 24 ,
'priority' => 50 ,
'status' => 1 ,
'test' => '$conf->adherent->enabled' ,
'datestart' => $datestart
),
2018-03-21 16:40:09 +01:00
);
2005-09-04 20:58:06 +02:00
}
2017-08-22 18:34:58 +02:00
2016-10-02 20:00:57 +02:00
/**
* Function called when module is enabled .
* The init function add constants , boxes , permissions and menus ( defined in constructor ) into Dolibarr database .
* It also creates data directories
*
* @ param string $options Options when enabling module ( '' , 'newboxdefonly' , 'noboxes' )
* @ return int 1 if OK , 0 if KO
*/
2019-02-25 22:50:19 +01:00
public function init ( $options = '' )
2016-10-02 20:00:57 +02:00
{
2019-11-13 19:37:08 +01:00
global $conf , $langs ;
2017-08-22 18:34:58 +02:00
2016-10-02 20:00:57 +02:00
// Permissions
2019-02-26 21:48:21 +01:00
$this -> remove ( $options );
2017-08-22 18:34:58 +02:00
2016-10-02 20:00:57 +02:00
//ODT template
/*
$src = DOL_DOCUMENT_ROOT . '/install/doctemplates/orders/template_order.odt' ;
$dirodt = DOL_DATA_ROOT . '/doctemplates/orders' ;
$dest = $dirodt . '/template_order.odt' ;
2017-08-22 18:34:58 +02:00
2016-10-02 20:00:57 +02:00
if ( file_exists ( $src ) && ! file_exists ( $dest ))
{
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
dol_mkdir ( $dirodt );
$result = dol_copy ( $src , $dest , 0 , 0 );
if ( $result < 0 )
{
$langs -> load ( " errors " );
$this -> error = $langs -> trans ( 'ErrorFailToCopyFile' , $src , $dest );
return 0 ;
}
} */
2017-08-22 18:34:58 +02:00
2016-10-02 20:00:57 +02:00
$sql = array (
2017-05-12 16:55:11 +02:00
" DELETE FROM " . MAIN_DB_PREFIX . " document_model WHERE nom = ' " . $this -> db -> escape ( $this -> const [ 0 ][ 2 ]) . " ' AND type='member' AND entity = " . $conf -> entity ,
" INSERT INTO " . MAIN_DB_PREFIX . " document_model (nom, type, entity) VALUES(' " . $this -> db -> escape ( $this -> const [ 0 ][ 2 ]) . " ','member', " . $conf -> entity . " ) "
2016-10-02 20:00:57 +02:00
);
2017-08-22 18:34:58 +02:00
2019-02-26 21:48:21 +01:00
return $this -> _init ( $sql , $options );
2017-08-22 18:34:58 +02:00
}
2003-09-15 16:03:49 +02:00
}