2004-10-20 00:24:10 +02:00
< ? php
2014-06-15 22:18:19 +02:00
/* Copyright ( C ) 2003 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2004 - 2010 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2011 Regis Houssin < regis . houssin @ inodbox . com >
2019-01-28 21:39:22 +01:00
* Copyright ( C ) 2015 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2003-11-07 18:43:32 +01: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-11-07 18:43:32 +01: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-11-07 18:43:32 +01:00
*/
2004-08-14 14:21:24 +02:00
2005-02-11 16:34:26 +01:00
/**
2015-03-20 06:36:48 +01:00
* \defgroup don Module donations
2014-06-15 22:18:19 +02:00
* \brief Module to manage the follow - up of the donations
2015-03-22 15:27:05 +01:00
* \file htdocs / core / modules / modDon . class . php
2015-03-20 06:36:48 +01:00
* \ingroup donations
2014-06-15 22:18:19 +02:00
* \brief Description and activation file for module Donation
2008-10-01 21:10:17 +02:00
*/
2004-08-14 14:21:24 +02:00
2020-04-10 10:59:32 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2007-10-10 01:15:25 +02:00
2003-11-07 18:43:32 +01:00
2005-05-14 16:05:39 +02:00
/**
2014-06-15 22:18:19 +02:00
* Class to describe and enable module Donation
2008-10-01 21:10:17 +02:00
*/
2017-03-07 22:31:34 +01:00
class modDon extends DolibarrModules
2003-11-07 18:43:32 +01:00
{
2008-10-01 21:10:17 +02:00
/**
2011-09-26 16:22:35 +02:00
* Constructor . Define names , constants , directories , boxes , permissions
*
2012-01-04 21:23:50 +01:00
* @ param DoliDB $db Database handler
2008-10-01 21:10:17 +02:00
*/
2019-02-25 20:35:59 +01:00
public function __construct ( $db )
2008-10-01 21:10:17 +02:00
{
2012-01-04 21:23:50 +01:00
$this -> db = $db ;
$this -> numero = 700 ;
2008-10-01 21:10:17 +02: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 11:55:16 +01:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
2008-10-01 21:10:17 +02:00
$this -> description = " Gestion des dons " ;
2017-08-22 18:34:58 +02:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this -> version = 'dolibarr' ;
2008-10-06 09:39:52 +02:00
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
2010-06-02 21:56:14 +02: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 23:56:57 +02:00
$this -> picto = 'donation' ;
2008-10-01 21:10:17 +02:00
2009-04-28 20:14:50 +02:00
// Data directories to create when module is enabled
2015-06-08 21:28:32 +02:00
$this -> dirs = array ( " /don/temp " );
2008-10-01 21:10:17 +02:00
2009-05-04 13:40:00 +02:00
// Dependancies
2008-10-01 21:10:17 +02:00
$this -> depends = array ();
$this -> requiredby = array ();
// Config pages
2015-03-26 06:29:16 +01:00
$this -> config_page_url = array ( " donation.php@don " );
2008-10-01 21:10:17 +02:00
2009-05-04 13:40:00 +02:00
// Constants
2015-06-04 21:14:30 +02:00
$this -> const = array ();
2020-04-10 10:59:32 +02:00
$r = 0 ;
2015-06-04 21:14:30 +02: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 07:43:24 +01:00
$this -> const [ $r ][ 0 ] = " DONATION_ART978 " ;
2015-06-04 21:14:30 +02:00
$this -> const [ $r ][ 1 ] = " yesno " ;
$this -> const [ $r ][ 2 ] = " 0 " ;
2020-02-17 07:43:24 +01:00
$this -> const [ $r ][ 3 ] = 'Option Française - Eligibilité Art978 du CGI' ;
2015-06-04 21:14:30 +02: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 05:56:14 +01:00
$this -> const [ $r ][ 2 ] = " 758 " ;
2015-06-04 21:14:30 +02:00
$this -> const [ $r ][ 3 ] = 'Compte comptable de remise des versements ou dons' ;
$this -> const [ $r ][ 4 ] = 0 ;
2008-10-01 21:10:17 +02:00
// Boxes
$this -> boxes = array ();
// Permissions
$this -> rights = array ();
$this -> rights_class = 'don' ;
2010-10-01 19:59:02 +02:00
$this -> rights [ 1 ][ 0 ] = 701 ;
2008-10-01 21:10:17 +02: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 19:59:02 +02:00
$this -> rights [ 2 ][ 0 ] = 702 ;
2008-10-28 21:37:30 +01:00
$this -> rights [ 2 ][ 1 ] = 'Creer/modifier les dons' ;
2008-10-01 21:10:17 +02:00
$this -> rights [ 2 ][ 2 ] = 'w' ;
$this -> rights [ 2 ][ 3 ] = 0 ;
$this -> rights [ 2 ][ 4 ] = 'creer' ;
2010-10-01 19:59:02 +02:00
$this -> rights [ 3 ][ 0 ] = 703 ;
2008-10-01 21:10:17 +02: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 18:34:58 +02:00
2016-09-30 13:02:13 +02:00
// Menus
//-------
2020-04-10 10:59:32 +02:00
$this -> menu = 1 ; // This module add menu entries. They are coded into menu manager.
2008-10-01 21:10:17 +02:00
}
/**
2012-01-04 21:23:50 +01: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 14:32:18 +01:00
* @ param string $options Options when enabling module ( '' , 'noboxes' )
2012-01-04 21:23:50 +01:00
* @ return int 1 if OK , 0 if KO
2008-10-01 21:10:17 +02:00
*/
2019-02-26 21:13:07 +01:00
public function init ( $options = '' )
2008-10-01 21:10:17 +02:00
{
2010-07-10 01:15:06 +02:00
global $conf ;
$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 = '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-10 01:15:06 +02:00
);
2008-10-01 21:10:17 +02:00
2019-01-27 11:55:16 +01:00
return $this -> _init ( $sql , $options );
2008-10-01 21:10:17 +02:00
}
2019-02-03 15:21:21 +01:00
}