Issues (2811)

Dolibarr/Modules/DocumentGeneration.php (1 issue)

Labels
Severity
1
<?php
2
3
/* Copyright (C) 2007      Rodolphe Quiedeville <[email protected]>
4
 * Copyright (C) 2005-2009 Regis Houssin        <[email protected]>
5
 * Copyright (C) 2024       Rafael San José             <[email protected]>
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
 * or see https://www.gnu.org/
20
 */
21
22
namespace Dolibarr\Modules;
23
24
/**
25
 *  \defgroup       document     Module mass mailings
26
 *  \brief          Module pour gerer des generations de documents
27
 *  \file           htdocs/core/modules/modDocumentGeneration.class.php
28
 *  \ingroup        document
29
 *  \brief          Description and activation file for the module Generation document
30
 */
31
32
use Dolibarr\Core\Base\DolibarrModules;
33
34
/**
35
 *  Class to describe and enable module Document
36
 */
37
class DocumentGeneration extends DolibarrModules
38
{
39
    /**
40
     *   Constructor. Define names, constants, directories, boxes, permissions
41
     *
42
     * @param DoliDB $db Database handler
0 ignored issues
show
The type Dolibarr\Modules\DoliDB was not found. Did you mean DoliDB? If so, make sure to prefix the type with \.
Loading history...
43
     */
44
    public function __construct($db)
45
    {
46
        $this->db = $db;
47
        $this->numero = 1520;
48
49
        $this->family = "technic";
50
        $this->module_position = '78';
51
        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
52
        $this->name = preg_replace('/^mod/i', '', get_only_class($this));
53
        $this->description = "Direct mail document generation";
54
        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
55
        $this->version = 'development';
56
57
        $this->const_name = 'MAIN_MODULE_' . static::getNameOf($this->name); // strtoupper($this->name);
58
        $this->picto = 'email';
59
60
        // Data directories to create when module is enabled
61
        $this->dirs = array("/documentgeneration/temp");
62
63
        // Config pages
64
        //$this->config_page_url = array("document.php");
65
66
        // Dependencies
67
        $this->depends = array();
68
        $this->requiredby = array();
69
        $this->conflictwith = array();
70
        $this->langfiles = array("orders", "bills", "companies", "mails");
71
72
        // Constants
73
74
        $this->const = array();
75
76
        // Boxes
77
        $this->boxes = array();
78
79
        // Permissions
80
        $this->rights = array();
81
        $this->rights_class = 'document';
82
83
        $r = 0;
84
85
        $this->rights[$r][0] = 1521;
86
        $this->rights[$r][1] = 'Lire les documents';
87
        $this->rights[$r][2] = 'r';
88
        $this->rights[$r][3] = 0;
89
        $this->rights[$r][4] = 'lire';
90
91
        $r++;
92
        $this->rights[$r][0] = 1522;
93
        $this->rights[$r][1] = 'Supprimer les documents clients';
94
        $this->rights[$r][2] = 'd';
95
        $this->rights[$r][3] = 0;
96
        $this->rights[$r][4] = 'supprimer';
97
    }
98
99
100
    /**
101
     *  Function called when module is enabled.
102
     *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
103
     *  It also creates data directories
104
     *
105
     * @param string $options Options when enabling module ('', 'noboxes')
106
     * @return     int                 1 if OK, 0 if KO
107
     */
108
    public function init($options = '')
109
    {
110
        global $conf;
111
112
        // Permissions
113
        $this->remove($options);
114
115
        $sql = array();
116
117
        return $this->_init($sql, $options);
118
    }
119
}
120