dolibarr 18.0.6
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 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
29include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30
31
36{
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 // Dependancies
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 = array();
71 $r = 0;
72
73 $this->const[$r][0] = "DON_ADDON_MODEL";
74 $this->const[$r][1] = "chaine";
75 $this->const[$r][2] = "html_cerfafr";
76 $this->const[$r][3] = 'Nom du gestionnaire de generation de recu de dons';
77 $this->const[$r][4] = 0;
78
79 $r++;
80 $this->const[$r][0] = "DONATION_ART200";
81 $this->const[$r][1] = "yesno";
82 $this->const[$r][2] = "0";
83 $this->const[$r][3] = 'Option Française - Eligibilité Art200 du CGI';
84 $this->const[$r][4] = 0;
85
86 $r++;
87 $this->const[$r][0] = "DONATION_ART238";
88 $this->const[$r][1] = "yesno";
89 $this->const[$r][2] = "0";
90 $this->const[$r][3] = 'Option Française - Eligibilité Art238 bis du CGI';
91 $this->const[$r][4] = 0;
92
93 $r++;
94 $this->const[$r][0] = "DONATION_ART978";
95 $this->const[$r][1] = "yesno";
96 $this->const[$r][2] = "0";
97 $this->const[$r][3] = 'Option Française - Eligibilité Art978 du CGI';
98 $this->const[$r][4] = 0;
99
100 $r++;
101 $this->const[$r][0] = "DONATION_MESSAGE";
102 $this->const[$r][1] = "chaine";
103 $this->const[$r][2] = "Thank you";
104 $this->const[$r][3] = 'Message affiché sur le récépissé de versements ou dons';
105 $this->const[$r][4] = 0;
106
107 $r++;
108 $this->const[$r][0] = "DONATION_ACCOUNTINGACCOUNT";
109 $this->const[$r][1] = "chaine";
110 $this->const[$r][2] = "758";
111 $this->const[$r][3] = 'Compte comptable de remise des versements ou dons';
112 $this->const[$r][4] = 0;
113
114 // Boxes
115 $this->boxes = array();
116
117 // Permissions
118 $this->rights = array();
119 $this->rights_class = 'don';
120
121 $this->rights[1][0] = 701;
122 $this->rights[1][1] = 'Lire les dons';
123 $this->rights[1][2] = 'r';
124 $this->rights[1][3] = 1;
125 $this->rights[1][4] = 'lire';
126
127 $this->rights[2][0] = 702;
128 $this->rights[2][1] = 'Creer/modifier les dons';
129 $this->rights[2][2] = 'w';
130 $this->rights[2][3] = 0;
131 $this->rights[2][4] = 'creer';
132
133 $this->rights[3][0] = 703;
134 $this->rights[3][1] = 'Supprimer les dons';
135 $this->rights[3][2] = 'd';
136 $this->rights[3][3] = 0;
137 $this->rights[3][4] = 'supprimer';
138
139
140 // Menus
141 //-------
142 $this->menu = 1; // This module add menu entries. They are coded into menu manager.
143 }
144
145
154 public function init($options = '')
155 {
156 global $conf;
157
158 $result = $this->_load_tables('/install/mysql/', 'don');
159 if ($result < 0) {
160 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')
161 }
162
163 $sql = array(
164 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'donation' AND entity = ".((int) $conf->entity),
165 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','donation',".((int) $conf->entity).")",
166 );
167
168 return $this->_init($sql, $options);
169 }
170}
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.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:123