2004-10-19 22:24:10 +00:00
< ? php
2014-06-15 20:18:19 +00:00
/* Copyright ( C ) 2003 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2010 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 12:43:12 +00:00
* Copyright ( C ) 2005 - 2011 Regis Houssin < regis . houssin @ inodbox . com >
2019-01-28 20:39:22 +00:00
* Copyright ( C ) 2015 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2003-11-07 17:43:32 +00: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 14:36:08 +00:00
* the Free Software Foundation ; either version 3 of the License , or
2003-11-07 17:43:32 +00: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 19:55:30 +00:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2003-11-07 17:43:32 +00:00
*/
2004-08-14 12:21:24 +00:00
2005-02-11 15:34:26 +00:00
/**
2015-03-20 05:36:48 +00:00
* \defgroup don Module donations
2014-06-15 20:18:19 +00:00
* \brief Module to manage the follow - up of the donations
2015-03-22 14:27:05 +00:00
* \file htdocs / core / modules / modDon . class . php
2015-03-20 05:36:48 +00:00
* \ingroup donations
2021-03-20 12:55:43 +00:00
* \brief Description and activation file for the module Donation
2008-10-01 19:10:17 +00:00
*/
2004-08-14 12:21:24 +00:00
2020-04-10 08:59:32 +00:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2007-10-09 23:15:25 +00:00
2003-11-07 17:43:32 +00:00
2005-05-14 14:05:39 +00:00
/**
2014-06-15 20:18:19 +00:00
* Class to describe and enable module Donation
2008-10-01 19:10:17 +00:00
*/
2017-03-07 21:31:34 +00:00
class modDon extends DolibarrModules
2003-11-07 17:43:32 +00:00
{
2008-10-01 19:10:17 +00:00
/**
2011-09-26 14:22:35 +00:00
* Constructor . Define names , constants , directories , boxes , permissions
*
2012-01-04 20:23:50 +00:00
* @ param DoliDB $db Database handler
2008-10-01 19:10:17 +00:00
*/
2019-02-25 19:35:59 +00:00
public function __construct ( $db )
2008-10-01 19:10:17 +00:00
{
2012-01-04 20:23:50 +00:00
$this -> db = $db ;
$this -> numero = 700 ;
2008-10-01 19:10:17 +00:00
$this -> family = " financial " ;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
2019-01-27 10:55:16 +00:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
2008-10-01 19:10:17 +00:00
$this -> description = " Gestion des dons " ;
2017-08-22 16:34:58 +00:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this -> version = 'dolibarr' ;
2008-10-06 07:39:52 +00:00
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
2010-06-02 19:56:14 +00:00
// Name of png file (without png) used for this module.
// Png file must be in theme/yourtheme/img directory under name object_pictovalue.png.
2020-04-24 21:56:57 +00:00
$this -> picto = 'donation' ;
2008-10-01 19:10:17 +00:00
2009-04-28 18:14:50 +00:00
// Data directories to create when module is enabled
2015-06-08 19:28:32 +00:00
$this -> dirs = array ( " /don/temp " );
2008-10-01 19:10:17 +00:00
2009-05-04 11:40:00 +00:00
// Dependancies
2008-10-01 19:10:17 +00:00
$this -> depends = array ();
$this -> requiredby = array ();
// Config pages
2015-03-26 05:29:16 +00:00
$this -> config_page_url = array ( " donation.php@don " );
2008-10-01 19:10:17 +00:00
2009-05-04 11:40:00 +00:00
// Constants
2015-06-04 19:14:30 +00:00
$this -> const = array ();
2020-04-10 08:59:32 +00:00
$r = 0 ;
2015-06-04 19:14:30 +00:00
$this -> const [ $r ][ 0 ] = " DON_ADDON_MODEL " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " html_cerfafr " ;
$this -> const [ $r ][ 3 ] = 'Nom du gestionnaire de generation de recu de dons' ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
$this -> const [ $r ][ 0 ] = " DONATION_ART200 " ;
$this -> const [ $r ][ 1 ] = " yesno " ;
$this -> const [ $r ][ 2 ] = " 0 " ;
$this -> const [ $r ][ 3 ] = 'Option Française - Eligibilité Art200 du CGI' ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
$this -> const [ $r ][ 0 ] = " DONATION_ART238 " ;
$this -> const [ $r ][ 1 ] = " yesno " ;
$this -> const [ $r ][ 2 ] = " 0 " ;
$this -> const [ $r ][ 3 ] = 'Option Française - Eligibilité Art238 bis du CGI' ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
2020-02-17 06:43:24 +00:00
$this -> const [ $r ][ 0 ] = " DONATION_ART978 " ;
2015-06-04 19:14:30 +00:00
$this -> const [ $r ][ 1 ] = " yesno " ;
$this -> const [ $r ][ 2 ] = " 0 " ;
2020-02-17 06:43:24 +00:00
$this -> const [ $r ][ 3 ] = 'Option Française - Eligibilité Art978 du CGI' ;
2015-06-04 19:14:30 +00:00
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
$this -> const [ $r ][ 0 ] = " DONATION_MESSAGE " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
$this -> const [ $r ][ 2 ] = " Thank you " ;
$this -> const [ $r ][ 3 ] = 'Message affiché sur le récépissé de versements ou dons' ;
$this -> const [ $r ][ 4 ] = 0 ;
$r ++ ;
$this -> const [ $r ][ 0 ] = " DONATION_ACCOUNTINGACCOUNT " ;
$this -> const [ $r ][ 1 ] = " chaine " ;
2015-12-26 04:56:14 +00:00
$this -> const [ $r ][ 2 ] = " 758 " ;
2015-06-04 19:14:30 +00:00
$this -> const [ $r ][ 3 ] = 'Compte comptable de remise des versements ou dons' ;
$this -> const [ $r ][ 4 ] = 0 ;
2008-10-01 19:10:17 +00:00
// Boxes
$this -> boxes = array ();
// Permissions
$this -> rights = array ();
$this -> rights_class = 'don' ;
2010-10-01 17:59:02 +00:00
$this -> rights [ 1 ][ 0 ] = 701 ;
2008-10-01 19:10:17 +00:00
$this -> rights [ 1 ][ 1 ] = 'Lire les dons' ;
$this -> rights [ 1 ][ 2 ] = 'r' ;
$this -> rights [ 1 ][ 3 ] = 1 ;
$this -> rights [ 1 ][ 4 ] = 'lire' ;
2010-10-01 17:59:02 +00:00
$this -> rights [ 2 ][ 0 ] = 702 ;
2008-10-28 20:37:30 +00:00
$this -> rights [ 2 ][ 1 ] = 'Creer/modifier les dons' ;
2008-10-01 19:10:17 +00:00
$this -> rights [ 2 ][ 2 ] = 'w' ;
$this -> rights [ 2 ][ 3 ] = 0 ;
$this -> rights [ 2 ][ 4 ] = 'creer' ;
2010-10-01 17:59:02 +00:00
$this -> rights [ 3 ][ 0 ] = 703 ;
2008-10-01 19:10:17 +00:00
$this -> rights [ 3 ][ 1 ] = 'Supprimer les dons' ;
$this -> rights [ 3 ][ 2 ] = 'd' ;
$this -> rights [ 3 ][ 3 ] = 0 ;
$this -> rights [ 3 ][ 4 ] = 'supprimer' ;
2017-08-22 16:34:58 +00:00
2016-09-30 11:02:13 +00:00
// Menus
//-------
2020-04-10 08:59:32 +00:00
$this -> menu = 1 ; // This module add menu entries. They are coded into menu manager.
2008-10-01 19:10:17 +00:00
}
/**
2012-01-04 20:23:50 +00: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
*
2020-10-31 13:32:18 +00:00
* @ param string $options Options when enabling module ( '' , 'noboxes' )
2012-01-04 20:23:50 +00:00
* @ return int 1 if OK , 0 if KO
2008-10-01 19:10:17 +00:00
*/
2019-02-26 20:13:07 +00:00
public function init ( $options = '' )
2008-10-01 19:10:17 +00:00
{
2010-07-09 23:15:06 +00:00
global $conf ;
$sql = array (
2017-05-12 14:55:11 +00:00
" DELETE FROM " . MAIN_DB_PREFIX . " document_model WHERE nom = ' " . $this -> db -> escape ( $this -> const [ 0 ][ 2 ]) . " ' AND type = 'donation' AND entity = " . $conf -> entity ,
" INSERT INTO " . MAIN_DB_PREFIX . " document_model (nom, type, entity) VALUES(' " . $this -> db -> escape ( $this -> const [ 0 ][ 2 ]) . " ','donation', " . $conf -> entity . " ) " ,
2010-07-09 23:15:06 +00:00
);
2008-10-01 19:10:17 +00:00
2019-01-27 10:55:16 +00:00
return $this -> _init ( $sql , $options );
2008-10-01 19:10:17 +00:00
}
2019-02-03 14:21:21 +00:00
}