Issues (2811)

Dolibarr/Modules/Workflow.php (1 issue)

Labels
Severity
1
<?php
2
3
/* Copyright (C) 2010-2012  Regis Houssin        <[email protected]>
4
 * Copyright (C) 2010		Laurent Destailleur  <[email protected]>
5
 * Copyright (C) 2024		MDW							<[email protected]>
6
 * Copyright (C) 2024       Rafael San José             <[email protected]>
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
22
namespace Dolibarr\Modules;
23
24
/**
25
 *      \defgroup   workflow     Module workflow
26
 *      \brief      Workflow management
27
 *      \file       htdocs/core/modules/modWorkflow.class.php
28
 *      \ingroup    workflow
29
 *      \brief      Description and activation file for the module Workflow
30
 */
31
32
use Dolibarr\Core\Base\DolibarrModules;
33
34
/**
35
 *  Class to describe and enable module Workflow
36
 */
37
class Workflow 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
48
        // Id for module (must be unique).
49
        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
50
        $this->numero = 6000;
51
        // Key text used to identify module (for permissions, menus, etc...)
52
        $this->rights_class = 'workflow';
53
54
        $this->family = "technic";
55
        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
56
        $this->name = preg_replace('/^mod/i', '', get_only_class($this));
57
        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
58
        $this->description = "Inter-modules workflow management";
59
        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
60
        $this->version = 'dolibarr';
61
        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
62
        $this->const_name = 'MAIN_MODULE_' . static::getNameOf($this->name); // strtoupper($this->name);
63
        // Name of png file (without png) used for this module.
64
        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
65
        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
66
        $this->picto = 'technic';
67
68
        // Data directories to create when module is enabled
69
        $this->dirs = array("/workflow/temp");
70
71
        // Config pages. Put here list of php page names stored in admmin directory used to setup module.
72
        $this->config_page_url = array('workflow.php');
73
74
        // Dependencies
75
        $this->hidden = false; // A condition to hide module
76
        $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
77
        $this->requiredby = array(); // List of module ids to disable if this one is disabled
78
        $this->conflictwith = array(); // List of module class names as string this module is in conflict with
79
        $this->phpmin = array(7, 0); // Minimum version of PHP required by module
80
        $this->need_dolibarr_version = array(2, 8); // Minimum version of Dolibarr required by module
81
        $this->langfiles = array("@workflow");
82
83
        // Constants
84
        // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
85
        // Example: $this->const=array(1 => array('MYMODULE_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
86
        //                             2 => array('MYMODULE_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
87
        // );
88
        $this->const = array(
89
            //0=>array('WORKFLOW_PROPAL_AUTOCREATE_ORDER', 'chaine', '1', 'WORKFLOW_PROPAL_AUTOCREATE_ORDER', 0, 'current', 0),
90
            //0=>array('WORKFLOW_ORDER_AUTOCREATE_INVOICE', 'chaine', '1', 'WORKFLOW_ORDER_AUTOCREATE_INVOICE', 0, 'current', 0),
91
            0 => array('WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL', 0, 'current', 0),
92
            1 => array('WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL', 'chaine', '1', 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL', 0, 'current', 0),
93
            2 => array('WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING', 0, 'current', 0),
94
            3 => array('WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED', 0, 'current', 0),
95
            4 => array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER', 0, 'current', 0),
96
            5 => array('WORKFLOW_SUM_INVOICES_AMOUNT_CLASSIFY_BILLED_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER', 0, 'current', 0),
97
            6 => array('WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL', 0, 'current', 0),
98
            7 => array('WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION', 0, 'current', 0),
99
            8 => array('WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION_CLOSED', 'chaine', '1', 'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION_CLOSED', 0, 'current', 0),
100
            9 => array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 0, 'current', 0),
101
            10 => array('WORKFLOW_TICKET_LINK_CONTRACT', 'chaine', '0', 'Automatically link a ticket to available contracts', 0, 'current', 0),
102
            11 => array('WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS', 'chaine', '0', 'Search among parent companies contracts when automatically linking a ticket to available contracts', 0, 'current', 0),
103
            12 => array('WORKFLOW_TICKET_CREATE_INTERVENTION', 'chaine', '0', 'WORKFLOW_TICKET_CREATE_INTERVENTION', 0, 'current', 0),
104
        );
105
106
        // Boxes
107
        $this->boxes = array();
108
109
        // Permissions
110
        $this->rights = array();
111
        $r = 0;
112
113
        /*
114
        $r++;
115
        $this->rights[$r][0] = 6001; // id de la permission
116
        $this->rights[$r][1] = "Lire les workflow"; // libelle de la permission
117
        $this->rights[$r][2] = 'r'; // type de la permission (deprecated)
118
        $this->rights[$r][3] = 0; // La permission est-elle une permission par default
119
        $this->rights[$r][4] = 'read';
120
        */
121
122
        // Main menu entries
123
        $this->menu = array(); // List of menus to add
124
        $r = 0;
125
        /*
126
        $this->menu[$r]=array('fk_menu'=>0,
127
                                'type'=>'top',
128
                                'titre'=>'Workflow',
129
                                'mainmenu'=>'workflow',
130
                                'url'=>'/workflow/index.php',
131
                                'langs'=>'@workflow',
132
                                'position'=>100,
133
                                'perms'=>'$user->rights->workflow->read',
134
                                'enabled'=>'$conf->workflow->enabled',
135
                                'target'=>'',
136
                                'user'=>0);
137
        $r++;
138
139
        $this->menu[$r]=array(  'fk_menu'=>'r=0',
140
                                'type'=>'left',
141
                                'titre'=>'Workflow',
142
                                'mainmenu'=>'workflow',
143
                                'url'=>'/workflow/index.php',
144
                                'langs'=>'@workflow',
145
                                'position'=>101,
146
                                'enabled'=>1,
147
                                'perms'=>'$user->rights->workflow->read',
148
                                'target'=>'',
149
                                'user'=>0);
150
        $r++;
151
        */
152
    }
153
154
155
    /**
156
     *      Function called when module is enabled.
157
     *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
158
     *      It also creates data directories
159
     *
160
     * @param string $options Options when enabling module ('', 'noboxes')
161
     * @return     int                 1 if OK, 0 if KO
162
     */
163
    public function init($options = '')
164
    {
165
        // Permissions
166
        $this->remove($options);
167
168
        $sql = array();
169
170
        return $this->_init($sql, $options);
171
    }
172
}
173