dolibarr/htdocs/core/modules/modPrelevement.class.php

155 lines
5.1 KiB
PHP
Raw Permalink Normal View History

<?php
2005-01-24 10:20:57 +01:00
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
2018-10-27 14:43:12 +02:00
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
2004-09-22 12:16:34 +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
* the Free Software Foundation; either version 3 of the License, or
2004-09-22 12:16:34 +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/>.
2004-09-22 12:16:34 +02:00
*/
2005-04-05 16:33:56 +02:00
/**
2008-12-15 23:17:49 +01:00
* \defgroup prelevement Module prelevement
* \brief Module to manage Direct debit orders
* \file htdocs/core/modules/modPrelevement.class.php
2011-08-31 12:27:17 +02:00
* \ingroup prelevement
2021-03-20 13:55:43 +01:00
* \brief Description and activation file for the module Prelevement
2008-10-01 21:10:17 +02:00
*/
include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
2004-09-22 12:16:34 +02:00
2005-04-05 16:33:56 +02:00
/**
* Class to describe and enable module of payment by Direct Debit
2008-10-01 21:10:17 +02:00
*/
2004-09-22 12:16:34 +02:00
class modPrelevement extends DolibarrModules
{
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)
{
global $conf;
2008-10-01 21:10:17 +02:00
2012-01-04 21:23:50 +01:00
$this->db = $db;
$this->numero = 57;
2008-10-01 21:10:17 +02:00
$this->family = "financial";
$this->module_position = '52';
2008-10-01 21:10:17 +02: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));
$this->description = "Management of Direct Debit orders";
2008-10-01 21:10:17 +02:00
2008-12-15 23:17:49 +01:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'dolibarr';
2008-10-01 21:10:17 +02:00
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
2008-02-19 20:10:24 +01:00
// Name of png file (without png) used for this module
$this->picto = 'payment';
// Data directories to create when module is enabled
$this->dirs = array("/prelevement/temp", "/prelevement/receipts");
2008-10-01 21:10:17 +02:00
2018-07-09 19:04:50 +02:00
// Dependencies
$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 20:48:47 +02:00
$this->phpmin = array(7, 0); // Minimum version of PHP required by module
// Config pages
$this->config_page_url = array("prelevement.php");
2008-10-01 21:10:17 +02:00
2015-09-07 15:40:55 +02:00
// Constants
$this->const = array();
$r = 0;
$this->const[$r][0] = "BANK_ADDON_PDF";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "sepamandate";
$this->const[$r][3] = 'Name of manager to generate SEPA mandate';
$this->const[$r][4] = 0;
$r++;
2015-09-07 15:46:57 +02:00
// Boxes
$this->boxes = array();
2008-10-01 21:10:17 +02:00
// Permissions
$this->rights = array();
$this->rights_class = 'prelevement';
$r = 0;
$r++;
$this->rights[$r][0] = 151;
2016-10-01 20:12:00 +02:00
$this->rights[$r][1] = 'Read direct debit payment orders';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'bons';
$this->rights[$r][5] = 'lire';
$r++;
$this->rights[$r][0] = 152;
2016-10-01 20:12:00 +02:00
$this->rights[$r][1] = 'Create/modify a direct debit payment order';
$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 20:12:00 +02:00
$this->rights[$r][1] = 'Send/Transmit direct debit payment orders';
$this->rights[$r][2] = 'a';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'bons';
$this->rights[$r][5] = 'send';
2011-08-31 12:27:17 +02:00
$r++;
$this->rights[$r][0] = 154;
2016-10-01 20:12:00 +02:00
$this->rights[$r][1] = 'Record Credits/Rejects of direct debit payment orders';
$this->rights[$r][2] = 'a';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'bons';
$this->rights[$r][5] = 'credit';
2011-08-31 12:27:17 +02: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 22:42:04 +02: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).")",
);
return $this->_init($sql, $options);
}
2004-09-22 12:16:34 +02:00
}