2004-10-19 22:24:10 +00:00
< ? php
2005-01-24 09:20:57 +00:00
/* Copyright ( C ) 2004 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2010-06-14 21:16:52 +00:00
* Copyright ( C ) 2005 - 2010 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 12:43:12 +00:00
* Copyright ( C ) 2005 - 2009 Regis Houssin < regis . houssin @ inodbox . com >
2011-01-15 08:51:22 +00:00
* Copyright ( C ) 2010 - 2011 Juanjo Menent < jmenent @ 2 byte . es >
2026-04-12 09:59:56 +00:00
* Copyright ( C ) 2026 Frédéric France < frederic . france @ free . fr >
2004-09-22 10:16:34 +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
2004-09-22 10:16:34 +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 />.
2004-09-22 10:16:34 +00:00
*/
2005-04-05 14:33:56 +00:00
/**
2008-12-15 22:17:49 +00:00
* \defgroup prelevement Module prelevement
2020-05-17 13:06:09 +00:00
* \brief Module to manage Direct debit orders
2011-10-24 12:11:49 +00:00
* \file htdocs / core / modules / modPrelevement . class . php
2011-08-31 10:27:17 +00:00
* \ingroup prelevement
2021-03-20 12:55:43 +00:00
* \brief Description and activation file for the module Prelevement
2008-10-01 19:10:17 +00:00
*/
2007-10-09 23:15:25 +00:00
2020-04-10 08:59:32 +00:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2004-09-22 10:16:34 +00:00
2006-07-23 01:38:43 +00:00
2005-04-05 14:33:56 +00:00
/**
2020-05-17 13:06:09 +00:00
* Class to describe and enable module of payment by Direct Debit
2008-10-01 19:10:17 +00:00
*/
2004-09-22 10:16:34 +00:00
class modPrelevement extends DolibarrModules
{
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 )
2006-07-23 01:38:43 +00:00
{
global $conf ;
2008-10-01 19:10:17 +00:00
2012-01-04 20:23:50 +00:00
$this -> db = $db ;
$this -> numero = 57 ;
2008-10-01 19:10:17 +00:00
2006-07-23 01:38:43 +00:00
$this -> family = " financial " ;
2018-10-06 09:57:53 +00:00
$this -> module_position = '52' ;
2008-10-01 19:10:17 +00:00
// 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 ));
2020-05-17 13:06:09 +00:00
$this -> description = " Management of Direct Debit orders " ;
2008-10-01 19:10:17 +00:00
2008-12-15 22:17:49 +00:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
2010-09-05 13:24:59 +00:00
$this -> version = 'dolibarr' ;
2008-10-01 19:10:17 +00:00
2008-10-06 07:39:52 +00:00
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
2008-02-19 19:10:24 +00:00
// Name of png file (without png) used for this module
2020-04-10 08:59:32 +00:00
$this -> picto = 'payment' ;
2009-05-04 11:40:00 +00:00
2009-04-28 21:49:08 +00:00
// Data directories to create when module is enabled
2020-04-10 08:59:32 +00:00
$this -> dirs = array ( " /prelevement/temp " , " /prelevement/receipts " );
2008-10-01 19:10:17 +00:00
2018-07-09 17:04:50 +00:00
// Dependencies
2020-04-10 08:59:32 +00:00
$this -> hidden = false ; // A condition to hide module
$this -> depends = array ( " modFacture " , " modBanque " ); // 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 (); // List of module class names as string this module is in conflict with
2022-09-27 18:48:47 +00:00
$this -> phpmin = array ( 7 , 0 ); // Minimum version of PHP required by module
2010-09-05 13:24:59 +00:00
2010-06-15 08:43:50 +00:00
// Config pages
$this -> config_page_url = array ( " prelevement.php " );
2008-10-01 19:10:17 +00:00
2015-09-07 13:40:55 +00:00
// Constants
2026-04-12 09:59:56 +00:00
$this -> const = [
[
" BANK_ADDON_PDF " ,
" chaine " ,
" sepamandate " ,
'Name of manager to generate SEPA mandate' ,
0 ,
],
];
2018-02-25 09:55:02 +00:00
2015-09-07 13:46:57 +00:00
// Boxes
2006-07-23 01:38:43 +00:00
$this -> boxes = array ();
2008-10-01 19:10:17 +00:00
2006-07-23 01:38:43 +00:00
// Permissions
$this -> rights = array ();
$this -> rights_class = 'prelevement' ;
2020-04-10 08:59:32 +00:00
$r = 0 ;
2011-01-15 08:51:22 +00:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 151 ;
2016-10-01 18:12:00 +00:00
$this -> rights [ $r ][ 1 ] = 'Read direct debit payment orders' ;
2011-01-15 08:51:22 +00:00
$this -> rights [ $r ][ 2 ] = 'r' ;
2016-06-04 10:16:30 +00:00
$this -> rights [ $r ][ 3 ] = 0 ;
2011-01-15 08:51:22 +00:00
$this -> rights [ $r ][ 4 ] = 'bons' ;
$this -> rights [ $r ][ 5 ] = 'lire' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 152 ;
2016-10-01 18:12:00 +00:00
$this -> rights [ $r ][ 1 ] = 'Create/modify a direct debit payment order' ;
2011-01-15 08:51:22 +00:00
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'bons' ;
$this -> rights [ $r ][ 5 ] = 'creer' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 153 ;
2016-10-01 18:12:00 +00:00
$this -> rights [ $r ][ 1 ] = 'Send/Transmit direct debit payment orders' ;
2011-01-15 08:51:22 +00:00
$this -> rights [ $r ][ 2 ] = 'a' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'bons' ;
$this -> rights [ $r ][ 5 ] = 'send' ;
2011-08-31 10:27:17 +00:00
2011-01-15 08:51:22 +00:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 154 ;
2016-10-01 18:12:00 +00:00
$this -> rights [ $r ][ 1 ] = 'Record Credits/Rejects of direct debit payment orders' ;
2011-01-15 08:51:22 +00:00
$this -> rights [ $r ][ 2 ] = 'a' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'bons' ;
$this -> rights [ $r ][ 5 ] = 'credit' ;
2011-08-31 10:27:17 +00:00
2020-10-31 13:32:18 +00:00
// Menus
//-------
$this -> menu = 1 ; // This module add menu entries. They are coded into menu manager.
}
/**
* 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 ( '' , 'noboxes' )
* @ return int 1 if OK , 0 if KO
*/
public function init ( $options = '' )
{
global $conf ;
// Permissions
$this -> remove ( $options );
$sql = array (
2021-08-27 20:42:04 +00:00
" DELETE FROM " . MAIN_DB_PREFIX . " document_model WHERE nom = ' " . $this -> db -> escape ( $this -> const [ 0 ][ 2 ]) . " ' AND type = 'bankaccount' AND entity = " . (( int ) $conf -> entity ),
" INSERT INTO " . MAIN_DB_PREFIX . " document_model (nom, type, entity) VALUES(' " . $this -> db -> escape ( $this -> const [ 0 ][ 2 ]) . " ','bankaccount', " . (( int ) $conf -> entity ) . " ) " ,
2020-10-31 13:32:18 +00:00
);
return $this -> _init ( $sql , $options );
}
2004-09-22 10:16:34 +00:00
}