dolibarr 22.0.5
modDon.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
6 * Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
30include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
31
32
37{
43 public function __construct($db)
44 {
45 $this->db = $db;
46 $this->numero = 700;
47
48 $this->family = "financial";
49 // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
50 $this->name = preg_replace('/^mod/i', '', get_class($this));
51 $this->description = "Gestion des dons";
52 // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
53 $this->version = 'dolibarr';
54 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
55 // Name of png file (without png) used for this module.
56 // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png.
57 $this->picto = 'donation';
58
59 // Data directories to create when module is enabled
60 $this->dirs = array("/don/temp");
61
62 // Dependencies
63 $this->depends = array();
64 $this->requiredby = array();
65
66 // Config pages
67 $this->config_page_url = array("donation.php@don");
68
69 // Constants
70 $this->const = [
71 [
72 "DON_ADDON_MODEL",
73 "chaine",
74 "html_cerfafr",
75 'Nom du gestionnaire de generation de recu de dons',
76 0,
77 ],
78 [
79 "DONATION_ART200",
80 "yesno",
81 "0",
82 'Option Française - Eligibilité Art200 du CGI',
83 0,
84 ],
85 [
86 "DONATION_ART238",
87 "yesno",
88 "0",
89 'Option Française - Eligibilité Art238 bis du CGI',
90 0,
91 ],
92 [
93 "DONATION_ART978",
94 "yesno",
95 "0",
96 'Option Française - Eligibilité Art978 du CGI',
97 0,
98 ],
99 [
100 "DONATION_MESSAGE",
101 "chaine",
102 "Thank you",
103 'Message affiché sur le récépissé de versements ou dons',
104 0,
105 ],
106 [
107 "DONATION_ACCOUNTINGACCOUNT",
108 "chaine",
109 "758",
110 'Compte comptable de remise des versements ou dons',
111 0,
112 ],
113 ];
114
115 // Boxes
116 $this->boxes = array();
117
118 // Permissions
119 $this->rights = array();
120 $this->rights_class = 'don';
121
122 $this->rights[1][0] = 701;
123 $this->rights[1][1] = 'Lire les dons';
124 $this->rights[1][2] = 'r';
125 $this->rights[1][3] = 0;
126 $this->rights[1][4] = 'lire';
127
128 $this->rights[2][0] = 702;
129 $this->rights[2][1] = 'Creer/modifier les dons';
130 $this->rights[2][2] = 'w';
131 $this->rights[2][3] = 0;
132 $this->rights[2][4] = 'creer';
133
134 $this->rights[3][0] = 703;
135 $this->rights[3][1] = 'Supprimer les dons';
136 $this->rights[3][2] = 'd';
137 $this->rights[3][3] = 0;
138 $this->rights[3][4] = 'supprimer';
139
140
141 // Menus
142 //-------
143 $this->menu = 1; // This module add menu entries. They are coded into menu manager.
144 }
145
146
155 public function init($options = '')
156 {
157 global $conf;
158
159 $result = $this->_load_tables('/install/mysql/', 'don');
160 if ($result < 0) {
161 return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
162 }
163
164 $sql = array(
165 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'donation' AND entity = ".((int) $conf->entity),
166 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','donation',".((int) $conf->entity).")",
167 );
168
169 return $this->_init($sql, $options);
170 }
171}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Class to describe and enable module Donation.
__construct($db)
Constructor.
init($options='')
Function called when module is enabled.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:161