Passed
Push — dev ( f7d146...05f415 )
by Rafael
60:50
created

Category::__construct()   F

Complexity

Conditions 35
Paths > 20000

Size

Total Lines 573
Code Lines 424

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 35
eloc 424
nc 68024448
nop 1
dl 0
loc 573
rs 0
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/* Copyright (C) 2005       Matthieu Valleton           <[email protected]>
4
 * Copyright (C) 2005-2014  Laurent Destailleur         <[email protected]>
5
 * Copyright (C) 2012-2016  Juanjo Menent		        <[email protected]>
6
 * Copyright (C) 2020       Stéphane Lesage		        <[email protected]>
7
 * Copyright (C) 2024		MDW							<[email protected]>
8
 * Copyright (C) 2024       Rafael San José             <[email protected]>
9
 *
10
 * This program is free software; you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation; either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23
24
namespace Dolibarr\Modules;
25
26
/**
27
 *      \defgroup   category       Module categories
28
 *      \brief      Module to manage categories
29
 *      \file       htdocs/core/modules/modCategorie.class.php
30
 *      \ingroup    category
31
 *      \brief      Description and activation file for the module Category
32
 */
33
34
use Dolibarr\Code\Categories\Classes\Categorie;
35
use Dolibarr\Core\Base\DolibarrModules;
36
use DoliDB;
37
38
/**
39
 *  Class to describe and enable module Categorie
40
 */
41
class Category extends DolibarrModules
42
{
43
    /**
44
     *   Constructor. Define names, constants, directories, boxes, permissions
45
     *
46
     * @param DoliDB $db Database handler
47
     */
48
    public function __construct($db)
49
    {
50
        global $conf;
51
52
        $this->db = $db;
53
        $this->numero = 1780;
54
55
        $this->family = "technic";
56
        $this->module_position = '25';
57
        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
58
        $this->name = preg_replace('/^mod/i', '', get_only_class($this));
59
        $this->description = "Gestion des categories (produits, clients, fournisseurs...)";
60
61
        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
62
        $this->version = 'dolibarr';
63
64
        $this->const_name = 'MAIN_MODULE_' . static::getNameOf($this->name); // strtoupper($this->name);
65
        $this->picto = 'category';
66
67
        // Data directories to create when module is enabled
68
        $this->dirs = array();
69
70
        // Dependencies
71
        $this->depends = array();
72
73
        // Config pages
74
        $this->config_page_url = array('categorie.php@categories');
75
        $this->langfiles = array("products", "companies", "categories", "members", "stocks", "website");
76
77
        // Constants
78
        $this->const = array();
79
        $r = 0;
80
        $this->const[$r][0] = "CATEGORIE_RECURSIV_ADD";
81
        $this->const[$r][1] = "yesno";
82
        $this->const[$r][2] = "0";
83
        $this->const[$r][3] = 'Affect parent categories';
84
        $this->const[$r][4] = 0;
85
        $r++;
86
87
        // Boxes
88
        $this->boxes = array();
89
90
        // Permissions
91
        $this->rights = array();
92
        $this->rights_class = 'categorie';
93
94
        $r = 0;
95
96
        $this->rights[$r][0] = 241; // id de la permission
97
        $this->rights[$r][1] = 'Lire les categories'; // libelle de la permission
98
        $this->rights[$r][2] = 'r'; // type de la permission (deprecated)
99
        $this->rights[$r][3] = 0; // La permission est-elle une permission par default
100
        $this->rights[$r][4] = 'lire';
101
        $r++;
102
103
        $this->rights[$r][0] = 242; // id de la permission
104
        $this->rights[$r][1] = 'Creer/modifier les categories'; // libelle de la permission
105
        $this->rights[$r][2] = 'w'; // type de la permission (deprecated)
106
        $this->rights[$r][3] = 0; // La permission est-elle une permission par default
107
        $this->rights[$r][4] = 'creer';
108
        $r++;
109
110
        $this->rights[$r][0] = 243; // id de la permission
111
        $this->rights[$r][1] = 'Supprimer les categories'; // libelle de la permission
112
        $this->rights[$r][2] = 'd'; // type de la permission (deprecated)
113
        $this->rights[$r][3] = 0; // La permission est-elle une permission par default
114
        $this->rights[$r][4] = 'supprimer';
115
        $r++;
116
117
118
        // Menus
119
        //-------
120
        $this->menu = 1; // This module add menu entries. They are coded into menu manager.
121
122
123
        // Exports
124
        //--------
125
        $r = 0;
126
127
        // All Categories List
128
        $r++;
129
        $this->export_code[$r] = $this->rights_class . '_list';
130
        $this->export_label[$r] = 'CatListAll';
131
        $this->export_icon[$r] = $this->picto;
132
        $this->export_enabled[$r] = 'true';
133
        $this->export_permission[$r] = array(array("categorie", "lire"));
134
135
        $typeexample = "";
136
        if (isModEnabled("product") || isModEnabled("service")) {
137
            $typeexample .= ($typeexample ? " / " : "") . "0=Product-Service";
138
        }
139
        if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
140
            $typeexample .= ($typeexample ? "/" : "") . "1=Supplier";
141
        }
142
        if (isModEnabled("societe")) {
143
            $typeexample .= ($typeexample ? " / " : "") . "2=Customer-Prospect";
144
        }
145
        if (isModEnabled('member')) {
146
            $typeexample .= ($typeexample ? " / " : "") . "3=Member";
147
        }
148
        if (isModEnabled("societe")) {
149
            $typeexample .= ($typeexample ? " / " : "") . "4=Contact";
150
        }
151
        if (isModEnabled('bank')) {
152
            $typeexample .= ($typeexample ? " / " : "") . "5=Bank account";
153
        }
154
        if (isModEnabled('project')) {
155
            $typeexample .= ($typeexample ? " / " : "") . "6=Project";
156
        }
157
        if (isModEnabled('user')) {
158
            $typeexample .= ($typeexample ? " / " : "") . "7=User";
159
        }
160
        if (isModEnabled('bank')) {
161
            $typeexample .= ($typeexample ? " / " : "") . "8=Bank line";
162
        }
163
        if (isModEnabled('stock')) {
164
            $typeexample .= ($typeexample ? " / " : "") . "9=Warehouse";
165
        }
166
        if (isModEnabled('agenda')) {
167
            $typeexample .= ($typeexample ? " / " : "") . "10=Agenda event";
168
        }
169
        if (isModEnabled('website')) {
170
            $typeexample .= ($typeexample ? " / " : "") . "11=Website page";
171
        }
172
173
        // Definition of vars
174
        $this->export_fields_array[$r] = array('cat.rowid' => "CategId", 'cat.label' => "Label", 'cat.type' => "Type", 'cat.description' => "Description", 'cat.fk_parent' => "ParentCategoryID", 'pcat.label' => "ParentCategoryLabel", 'cat.color' => "Color", 'cat.date_creation' => "DateCreation", 'cat.tms' => "DateLastModification");
175
        $this->export_TypeFields_array[$r] = array('cat.rowid' => 'Numeric', 'cat.label' => "Text", 'cat.type' => "Numeric", 'cat.description' => "Text", 'cat.fk_parent' => 'Numeric', 'pcat.label' => 'Text');
176
        $this->export_entities_array[$r] = array(); // We define here only fields that use another picto
177
        $this->export_help_array[$r] = array('cat.type' => $typeexample);
178
179
        $this->export_sql_start[$r] = 'SELECT DISTINCT ';
180
        $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as cat';
181
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie as pcat ON pcat.rowid = cat.fk_parent';
182
        $this->export_sql_end[$r] .= ' WHERE cat.entity IN (' . getEntity('category') . ')';
183
184
        // 0 Products
185
        $r++;
186
        $this->export_code[$r] = $this->rights_class . '_0_' . Categorie::$MAP_ID_TO_CODE[0];
187
        $this->export_label[$r] = 'CatProdList';
188
        $this->export_icon[$r] = $this->picto;
189
        $this->export_enabled[$r] = 'isModEnabled("product") || isModEnabled("service")';
190
        $this->export_permission[$r] = array(array("categorie", "lire"), array("produit", "export"));
191
        $this->export_fields_array[$r] = array('cat.rowid' => "CategId", 'cat.label' => "Label", 'cat.description' => "Description", 'cat.fk_parent' => "ParentCategoryID", 'pcat.label' => "ParentCategoryLabel", 'cat.color' => "Color", 'cat.date_creation' => "DateCreation", 'cat.tms' => "DateLastModification", 'p.rowid' => 'ProductId', 'p.ref' => 'Ref', 'p.label' => 'Label');
192
        $this->export_TypeFields_array[$r] = array('cat.rowid' => 'Numeric', 'cat.label' => "Text", 'cat.description' => "Text", 'cat.fk_parent' => 'Numeric', 'pcat.label' => 'Text', 'p.rowid' => 'Numeric', 'p.ref' => 'Text', 'p.label' => 'Text');
193
        $this->export_entities_array[$r] = array('p.rowid' => 'product', 'p.ref' => 'product', 'p.label' => 'product'); // We define here only fields that use another picto
194
195
        $keyforselect = 'product';
196
        $keyforelement = 'product';
197
        $keyforaliasextra = 'extra';
198
        include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php';
199
200
        $this->export_sql_start[$r] = 'SELECT DISTINCT ';
201
        $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as cat';
202
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie as pcat ON pcat.rowid = cat.fk_parent';
203
        $this->export_sql_end[$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'categorie_product as cp ON cp.fk_categorie = cat.rowid';
204
        $this->export_sql_end[$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'product as p ON p.rowid = cp.fk_product';
205
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_extrafields as extra ON extra.fk_object = p.rowid';
206
        $this->export_sql_end[$r] .= ' WHERE cat.entity IN (' . getEntity('category') . ')';
207
        $this->export_sql_end[$r] .= ' AND cat.type = 0';
208
209
        // 1 Suppliers
210
        $r++;
211
        $this->export_code[$r] = $this->rights_class . '_1_' . Categorie::$MAP_ID_TO_CODE[1];
212
        $this->export_label[$r] = 'CatSupList';
213
        $this->export_icon[$r] = $this->picto;
214
        $this->export_enabled[$r] = 'isModEnabled("supplier_order") || isModEnabled("supplier_invoice")';
215
        $this->export_permission[$r] = array(array("categorie", "lire"), array("fournisseur", "lire"));
216
        $this->export_fields_array[$r] = array(
217
            'cat.rowid' => "CategId", 'cat.label' => "Label", 'cat.description' => "Description", 'cat.fk_parent' => "ParentCategoryID", 'pcat.label' => "ParentCategoryLabel",
218
            'cat.color' => "Color", 'cat.date_creation' => "DateCreation", 'cat.tms' => "DateLastModification",
219
            's.rowid' => 'IdThirdParty', 's.nom' => 'Name', 's.prefix_comm' => "Prefix", 's.fournisseur' => "Supplier", 's.datec' => "DateCreation", 's.tms' => "DateLastModification", 's.code_fournisseur' => "SupplierCode",
220
            's.address' => "Address", 's.zip' => "Zip", 's.town' => "Town", 'c.label' => "Country", 'c.code' => "CountryCode",
221
            's.phone' => "Phone", 's.fax' => "Fax", 's.url' => "Url", 's.email' => "Email",
222
            's.siret' => "ProfId1", 's.siren' => "ProfId2", 's.ape' => "ProfId3", 's.idprof4' => "ProfId4", 's.tva_intra' => "VATIntraShort", 's.capital' => "Capital", 's.note_public' => "NotePublic",
223
            't.libelle' => 'ThirdPartyType'
224
        );
225
        $this->export_TypeFields_array[$r] = array(
226
            'cat.rowid' => 'Numeric', 'cat.label' => "Text", 'cat.description' => "Text", 'cat.fk_parent' => 'Numeric', 'pcat.label' => 'Text',
227
            's.rowid' => 'List:societe:nom', 's.nom' => 'Text', 's.prefix_comm' => "Text", 's.fournisseur' => "Text", 's.datec' => "Date", 's.tms' => "Date", 's.code_fournisseur' => "Text",
228
            's.address' => "Text", 's.zip' => "Text", 's.town' => "Text", 'c.label' => "List:c_country:label:label", 'c.code' => "Text",
229
            's.phone' => "Text", 's.fax' => "Text", 's.url' => "Text", 's.email' => "Text",
230
            's.siret' => "Text", 's.siren' => "Text", 's.ape' => "Text", 's.idprof4' => "Text", 's.tva_intra' => "Text", 's.capital' => "Numeric", 's.note_public' => "Text",
231
            't.libelle' => 'List:c_typent:libelle:code'
232
        );
233
        $this->export_entities_array[$r] = array(
234
            's.rowid' => 'company', 's.nom' => 'company', 's.prefix_comm' => "company", 's.fournisseur' => "company", 's.datec' => "company", 's.tms' => "company", 's.code_fournisseur' => "company",
235
            's.address' => "company", 's.zip' => "company", 's.town' => "company", 'c.label' => "company", 'c.code' => "company",
236
            's.phone' => "company", 's.fax' => "company", 's.url' => "company", 's.email' => "company",
237
            's.siret' => "company", 's.siren' => "company", 's.ape' => "company", 's.idprof4' => "company", 's.tva_intra' => "company", 's.capital' => "company", 's.note_public' => "company",
238
            't.libelle' => 'company'
239
        ); // We define here only fields that use another picto
240
241
        $keyforselect = 'societe';
242
        $keyforelement = 'company';
243
        $keyforaliasextra = 'extra';
244
        include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php';
245
246
        $this->export_sql_start[$r] = 'SELECT DISTINCT ';
247
        $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as cat';
248
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie as pcat ON pcat.rowid = cat.fk_parent';
249
        $this->export_sql_end[$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'categorie_fournisseur as cf ON cf.fk_categorie = cat.rowid';
250
        $this->export_sql_end[$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = cf.fk_soc';
251
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe_extrafields as extra ON s.rowid = extra.fk_object';
252
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as c ON s.fk_pays = c.rowid';
253
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_typent as t ON s.fk_typent = t.id';
254
        $this->export_sql_end[$r] .= ' WHERE cat.entity IN (' . getEntity('category') . ')';
255
        $this->export_sql_end[$r] .= ' AND cat.type = 1';
256
257
        // 2 Customers/Prospects
258
        $r++;
259
        $this->export_code[$r] = $this->rights_class . '_2_' . Categorie::$MAP_ID_TO_CODE[2];
260
        $this->export_label[$r] = 'CatCusList';
261
        $this->export_icon[$r] = $this->picto;
262
        $this->export_enabled[$r] = 'isModEnabled("societe")';
263
        $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "export"));
264
        $this->export_fields_array[$r] = array(
265
            'cat.rowid' => "CategId", 'cat.label' => "Label", 'cat.description' => "Description", 'cat.fk_parent' => "ParentCategoryID", 'pcat.label' => "ParentCategoryLabel",
266
            'cat.color' => "Color", 'cat.date_creation' => "DateCreation", 'cat.tms' => "DateLastModification",
267
            's.rowid' => 'IdThirdParty', 's.nom' => 'Name', 's.prefix_comm' => "Prefix", 's.client' => "Customer", 's.datec' => "DateCreation", 's.tms' => "DateLastModification", 's.code_client' => "CustomerCode",
268
            's.address' => "Address", 's.zip' => "Zip", 's.town' => "Town", 'c.label' => "Country", 'c.code' => "CountryCode",
269
            's.phone' => "Phone", 's.fax' => "Fax", 's.url' => "Url", 's.email' => "Email",
270
            's.siret' => "ProfId1", 's.siren' => "ProfId2", 's.ape' => "ProfId3", 's.idprof4' => "ProfId4", 's.tva_intra' => "VATIntraShort", 's.capital' => "Capital", 's.note_public' => "NotePublic",
271
            't.libelle' => 'ThirdPartyType', 'pl.code' => 'ProspectLevel', 'st.code' => 'ProspectStatus'
272
        );
273
        $this->export_TypeFields_array[$r] = array(
274
            'cat.rowid' => 'Numeric', 'cat.label' => "Text", 'cat.description' => "Text", 'cat.fk_parent' => 'Numeric', 'pcat.label' => 'Text',
275
            's.rowid' => 'List:societe:nom', 's.nom' => 'Text', 's.prefix_comm' => "Text", 's.client' => "Text", 's.datec' => "Date", 's.tms' => "Date", 's.code_client' => "Text",
276
            's.address' => "Text", 's.zip' => "Text", 's.town' => "Text", 'c.label' => "List:c_country:label:label", 'c.code' => "Text",
277
            's.phone' => "Text", 's.fax' => "Text", 's.url' => "Text", 's.email' => "Text",
278
            's.siret' => "Text", 's.siren' => "Text", 's.ape' => "Text", 's.idprof4' => "Text", 's.tva_intra' => "Text", 's.capital' => "Numeric", 's.note_public' => "Text",
279
            't.libelle' => 'List:c_typent:libelle:code', 'pl.code' => 'List:c_prospectlevel:label:code', 'st.code' => 'List:c_stcomm:libelle:code'
280
        );
281
        $this->export_entities_array[$r] = array(
282
            's.rowid' => 'company', 's.nom' => 'company', 's.prefix_comm' => "company", 's.client' => "company", 's.datec' => "company", 's.tms' => "company", 's.code_client' => "company",
283
            's.address' => "company", 's.zip' => "company", 's.town' => "company", 'c.label' => "company", 'c.code' => "company",
284
            's.phone' => "company", 's.fax' => "company", 's.url' => "company", 's.email' => "company",
285
            's.siret' => "company", 's.siren' => "company", 's.ape' => "company", 's.idprof4' => "company", 's.tva_intra' => "company", 's.capital' => "company", 's.note_public' => "company",
286
            't.libelle' => 'company', 'pl.code' => 'company', 'st.code' => 'company'
287
        ); // We define here only fields that use another picto
288
289
        $keyforselect = 'societe';
290
        $keyforelement = 'company';
291
        $keyforaliasextra = 'extra';
292
        include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php';
293
294
        $this->export_sql_start[$r] = 'SELECT DISTINCT ';
295
        $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as cat';
296
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie as pcat ON pcat.rowid = cat.fk_parent';
297
        $this->export_sql_end[$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'categorie_societe as cs ON cs.fk_categorie = cat.rowid';
298
        $this->export_sql_end[$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = cs.fk_soc';
299
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe_extrafields as extra ON s.rowid = extra.fk_object';
300
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as c ON s.fk_pays = c.rowid';
301
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_typent as t ON s.fk_typent = t.id';
302
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_prospectlevel as pl ON s.fk_prospectlevel = pl.code';
303
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_stcomm as st ON s.fk_stcomm = st.id';
304
        $this->export_sql_end[$r] .= ' WHERE cat.entity IN (' . getEntity('category') . ')';
305
        $this->export_sql_end[$r] .= ' AND cat.type = 2';
306
307
        // 3 Members
308
        $r++;
309
        $this->export_code[$r] = $this->rights_class . '_3_' . Categorie::$MAP_ID_TO_CODE[3];
310
        $this->export_label[$r] = 'CatMemberList';
311
        $this->export_icon[$r] = $this->picto;
312
        $this->export_enabled[$r] = 'isModEnabled("member")';
313
        $this->export_permission[$r] = array(array("categorie", "lire"), array("adherent", "export"));
314
        $this->export_fields_array[$r] = array('cat.rowid' => "CategId", 'cat.label' => "Label", 'cat.description' => "Description", 'cat.fk_parent' => "ParentCategoryID", 'pcat.label' => "ParentCategoryLabel", 'p.rowid' => 'MemberId', 'p.lastname' => 'LastName', 'p.firstname' => 'Firstname');
315
        $this->export_TypeFields_array[$r] = array('cat.rowid' => "Numeric", 'cat.label' => "Text", 'cat.description' => "Text", 'cat.fk_parent' => 'Numeric', 'pcat.label' => 'Text', 'p.lastname' => 'Text', 'p.firstname' => 'Text');
316
        $this->export_entities_array[$r] = array('p.rowid' => 'member', 'p.lastname' => 'member', 'p.firstname' => 'member'); // We define here only fields that use another picto
317
318
        $keyforselect = 'adherent';
319
        $keyforelement = 'member';
320
        $keyforaliasextra = 'extra';
321
        include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php';
322
323
        $this->export_sql_start[$r] = 'SELECT DISTINCT ';
324
        $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as cat';
325
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie as pcat ON pcat.rowid = cat.fk_parent';
326
        $this->export_sql_end[$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'categorie_member as cm ON cm.fk_categorie = cat.rowid';
327
        $this->export_sql_end[$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'adherent as p ON p.rowid = cm.fk_member';
328
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'adherent_extrafields as extra ON cat.rowid = extra.fk_object ';
329
        $this->export_sql_end[$r] .= ' WHERE cat.entity IN (' . getEntity('category') . ')';
330
        $this->export_sql_end[$r] .= ' AND cat.type = 3';
331
332
        // 4 Contacts
333
        $r++;
334
        $this->export_code[$r] = $this->rights_class . '_4_' . Categorie::$MAP_ID_TO_CODE[4];
335
        $this->export_label[$r] = 'CatContactList';
336
        $this->export_icon[$r] = $this->picto;
337
        $this->export_enabled[$r] = 'isModEnabled("societe")';
338
        $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "contact", "export"));
339
        $this->export_fields_array[$r] = array(
340
            'cat.rowid' => "CategId", 'cat.label' => "Label", 'cat.description' => "Description", 'cat.fk_parent' => "ParentCategoryID", 'pcat.label' => "ParentCategoryLabel",
341
            'cat.color' => "Color", 'cat.date_creation' => "DateCreation", 'cat.tms' => "DateLastModification",
342
            'p.rowid' => 'ContactId', 'civ.label' => 'UserTitle', 'p.lastname' => 'LastName', 'p.firstname' => 'Firstname',
343
            'p.address' => 'Address', 'p.zip' => 'Zip', 'p.town' => 'Town', 'c.code' => 'CountryCode', 'c.label' => 'Country',
344
            'p.birthday' => 'DateOfBirth', 'p.poste' => 'PostOrFunction',
345
            'p.phone' => 'Phone', 'p.phone_perso' => 'PhonePerso', 'p.phone_mobile' => 'PhoneMobile', 'p.fax' => 'Fax', 'p.email' => 'Email',
346
            'p.note_private' => 'NotePrivate', 'p.note_public' => 'NotePublic', 'p.statut' => 'Status',
347
            's.nom' => "Name", 's.client' => "Customer", 's.fournisseur' => "Supplier", 's.status' => "Status",
348
            's.address' => "Address", 's.zip' => "Zip", 's.town' => "Town",
349
            's.phone' => "Phone", 's.fax' => "Fax", 's.url' => "Url", 's.email' => "Email"
350
        );
351
        $this->export_TypeFields_array[$r] = array(
352
            'cat.rowid' => 'Numeric', 'cat.label' => "Text", 'cat.description' => "Text", 'cat.fk_parent' => 'Numeric', 'pcat.label' => 'Text',
353
            'civ.label' => 'List:c_civility:label:label', 'p.rowid' => 'Numeric', 'p.lastname' => 'Text', 'p.firstname' => 'Text',
354
            'p.address' => 'Text', 'p.zip' => 'Text', 'p.town' => 'Text', 'c.code' => 'Text', 'c.label' => 'List:c_country:label:label',
355
            'p.birthday' => 'Date', 'p.poste' => 'Text',
356
            'p.phone' => 'Text', 'p.phone_perso' => 'Text', 'p.phone_mobile' => 'Text', 'p.fax' => 'Text', 'p.email' => 'Text',
357
            'p.note_private' => 'Text', 'p.note_public' => 'Text', 'p.statut' => 'Boolean',
358
            's.nom' => "Text", 's.client' => "Boolean", 's.fournisseur' => "Boolean", 's.status' => "Boolean",
359
            's.address' => "Text", 's.zip' => "Text", 's.town' => "Text",
360
            's.phone' => "Text", 's.fax' => "Text", 's.url' => "Text", 's.email' => "Text"
361
        );
362
        $this->export_entities_array[$r] = array(
363
            'p.rowid' => 'contact', 'civ.label' => 'contact', 'p.lastname' => 'contact', 'p.firstname' => 'contact',
364
            'p.address' => 'contact', 'p.zip' => 'contact', 'p.town' => 'contact', 'c.code' => 'contact', 'c.label' => 'contact',
365
            'p.birthday' => 'contact', 'p.poste' => 'contact',
366
            'p.phone' => 'contact', 'p.phone_perso' => 'contact', 'p.phone_mobile' => 'contact', 'p.fax' => 'contact', 'p.email' => 'contact',
367
            'p.note_private' => 'contact', 'p.note_public' => 'contact', 'p.statut' => 'contact',
368
            's.nom' => "company", 's.client' => "company", 's.fournisseur' => "company", 's.status' => "company",
369
            's.address' => "company", 's.zip' => "company", 's.town' => "company",
370
            's.phone' => "company", 's.fax' => "company", 's.url' => "company", 's.email' => "company"
371
        ); // We define here only fields that use another picto
372
373
        $keyforselect = 'socpeople';
374
        $keyforelement = 'contact';
375
        $keyforaliasextra = 'extra';
376
        include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php';
377
378
        $this->export_sql_start[$r] = 'SELECT DISTINCT ';
379
        $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as cat';
380
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie as pcat ON pcat.rowid = cat.fk_parent';
381
        $this->export_sql_end[$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'categorie_contact as cc ON cc.fk_categorie = cat.rowid';
382
        $this->export_sql_end[$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'socpeople as p ON p.rowid = cc.fk_socpeople';
383
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople_extrafields as extra ON extra.fk_object = p.rowid';
384
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_civility as civ ON civ.code = p.civility';
385
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as c ON c.rowid = p.fk_pays';
386
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc';
387
        $this->export_sql_end[$r] .= ' WHERE cat.entity IN (' . getEntity('category') . ')';
388
        $this->export_sql_end[$r] .= ' AND cat.type = 4';
389
390
        // 5 Bank accounts, TODO ?
391
392
        // 6 Projects
393
        $r++;
394
        $this->export_code[$r] = $this->rights_class . '_6_' . Categorie::$MAP_ID_TO_CODE[6];
395
        $this->export_label[$r] = 'CatProjectsList';
396
        $this->export_icon[$r] = $this->picto;
397
        $this->export_enabled[$r] = "isModEnabled('project')";
398
        $this->export_permission[$r] = array(array("categorie", "lire"), array("projet", "export"));
399
        $this->export_fields_array[$r] = array('cat.rowid' => "CategId", 'cat.label' => "Label", 'cat.description' => "Description", 'cat.fk_parent' => "ParentCategory", 'pcat.label' => "ParentCategoryLabel", 'cat.color' => "Color", 'cat.date_creation' => "DateCreation", 'cat.tms' => "DateLastModification", 'p.rowid' => 'ProjectId', 'p.ref' => 'Ref', 's.rowid' => "IdThirdParty", 's.nom' => "Name");
400
        $this->export_TypeFields_array[$r] = array('cat.rowid' => 'Numeric', 'cat.label' => "Text", 'cat.description' => "Text", 'cat.fk_parent' => 'Numeric', 'pcat.label' => 'Text', 'p.rowid' => 'Numeric', 'p.ref' => 'Text', 's.rowid' => "Numeric", 's.nom' => "Text");
401
        $this->export_entities_array[$r] = array('p.rowid' => 'project', 'p.ref' => 'project', 's.rowid' => "company", 's.nom' => "company"); // We define here only fields that use another picto
402
403
        $keyforselect = 'projet';
404
        $keyforelement = 'project';
405
        $keyforaliasextra = 'extra';
406
        include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php';
407
408
        $this->export_sql_start[$r] = 'SELECT DISTINCT ';
409
        $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as cat';
410
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie as pcat ON pcat.rowid = cat.fk_parent';
411
        $this->export_sql_end[$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'categorie_project as cp ON cp.fk_categorie = cat.rowid';
412
        $this->export_sql_end[$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'projet as p ON p.rowid = cp.fk_project';
413
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'projet_extrafields as extra ON extra.fk_object = p.rowid';
414
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc';
415
        $this->export_sql_end[$r] .= ' WHERE cat.entity IN (' . getEntity('category') . ')';
416
        $this->export_sql_end[$r] .= ' AND cat.type = 6';
417
418
        // 7 Users
419
        $r++;
420
        $this->export_code[$r] = $this->rights_class . '_7_' . Categorie::$MAP_ID_TO_CODE[7];
421
        $this->export_label[$r] = 'CatUsersList';
422
        $this->export_icon[$r] = $this->picto;
423
        $this->export_enabled[$r] = 'isModEnabled("user")';
424
        $this->export_permission[$r] = array(array("categorie", "lire"), array("user", "export"));
425
        $this->export_fields_array[$r] = array('cat.rowid' => "CategId", 'cat.label' => "Label", 'cat.description' => "Description", 'cat.fk_parent' => "ParentCategory", 'pcat.label' => "ParentCategoryLabel", 'cat.color' => "Color", 'cat.date_creation' => "DateCreation", 'cat.tms' => "DateLastModification", 'p.rowid' => 'UserID', 'p.login' => 'Login', 'p.lastname' => 'Lastname', 'p.firstname' => 'Firstname');
426
        $this->export_TypeFields_array[$r] = array('cat.rowid' => "Numeric", 'cat.label' => "Text", 'cat.description' => "Text", 'cat.fk_parent' => 'Numeric', 'pcat.label' => 'Text', 'p.rowid' => 'Numeric', 'p.login' => 'Text', 'p.lastname' => 'Text', 'p.firstname' => 'Text');
427
        $this->export_entities_array[$r] = array('p.rowid' => 'user', 'p.login' => 'user', 'p.lastname' => 'user', 'p.firstname' => 'user'); // We define here only fields that use another picto
428
429
        $keyforselect = 'user';
430
        $keyforelement = 'user';
431
        $keyforaliasextra = 'extra';
432
        include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php';
433
434
        $this->export_sql_start[$r] = 'SELECT DISTINCT ';
435
        $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as cat';
436
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie as pcat ON pcat.rowid = cat.fk_parent';
437
        $this->export_sql_end[$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'categorie_user as cu ON cu.fk_categorie = cat.rowid';
438
        $this->export_sql_end[$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'user as p ON p.rowid = cu.fk_user';
439
        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'user_extrafields as extra ON extra.fk_object = p.rowid';
440
        $this->export_sql_end[$r] .= ' WHERE cat.entity IN (' . getEntity('category') . ')';
441
        $this->export_sql_end[$r] .= ' AND cat.type = 7';
442
443
        // 8 Bank Lines, TODO ?
444
445
        // 9 Warehouses, TODO ?
446
447
        // 10 Agenda Events, TODO ?
448
449
        // 11 Website Pages, TODO ?
450
451
        // Imports
452
        //--------
453
454
        $r = 0;
455
456
        // Categories
457
        $r++;
458
        $this->import_code[$r] = $this->rights_class . '_list';
459
        $this->import_label[$r] = "CatList"; // Translation key
460
        $this->import_icon[$r] = $this->picto;
461
        $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
462
        $this->import_tables_array[$r] = array('ca' => MAIN_DB_PREFIX . 'categorie');
463
        $this->import_fields_array[$r] = array(
464
            'ca.label' => "Label*", 'ca.type' => "Type*", 'ca.description' => "Description",
465
            'ca.fk_parent' => 'ParentCategory'
466
        );
467
        $this->import_regex_array[$r] = array('ca.type' => '^(0|1|2|3|4|5|6|7|8|9|10|11)$');
468
        $this->import_convertvalue_array[$r] = array(
469
            'ca.fk_parent' => array(
470
                'rule' => 'fetchidfromcodeandlabel',
471
                'classfile' => '/categories/class/categorie.class.php',
472
                'class' => 'Categorie',
473
                'method' => 'fetch',
474
                'element' => 'category',
475
                'codefromfield' => 'ca.type'
476
            )
477
        );
478
479
        $this->import_examplevalues_array[$r] = array(
480
            'ca.label' => "My Category Label", 'ca.type' => $typeexample, 'ca.description' => "My Category description", // $typeexample built above in exports
481
            'ca.fk_parent' => 'rowid or label'
482
        );
483
        $this->import_updatekeys_array[$r] = array('ca.label' => 'Label', 'ca.type' => 'Type');
484
485
        // 0 Products
486
        if (isModEnabled("product")) {
487
            $r++;
488
            $this->import_code[$r] = $this->rights_class . '_0_' . Categorie::$MAP_ID_TO_CODE[0];
489
            $this->import_label[$r] = "CatProdLinks"; // Translation key
490
            $this->import_icon[$r] = $this->picto;
491
            $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
492
            $this->import_tables_array[$r] = array('cp' => MAIN_DB_PREFIX . 'categorie_product');
493
            $this->import_fields_array[$r] = array('cp.fk_categorie' => "Category*", 'cp.fk_product' => "Product*");
494
            $this->import_regex_array[$r] = array('cp.fk_categorie' => 'rowid@' . MAIN_DB_PREFIX . 'categorie:type=0');
495
496
            $this->import_convertvalue_array[$r] = array(
497
                'cp.fk_categorie' => array('rule' => 'fetchidfromref', 'classfile' => '/categories/class/categorie.class.php', 'class' => 'Categorie', 'method' => 'fetch', 'element' => 'category'),
498
                'cp.fk_product' => array('rule' => 'fetchidfromref', 'classfile' => '/product/class/product.class.php', 'class' => 'Product', 'method' => 'fetch', 'element' => 'Product')
499
            );
500
            $this->import_examplevalues_array[$r] = array('cp.fk_categorie' => "rowid or label", 'cp.fk_product' => "rowid or ref");
501
            $this->import_updatekeys_array[$r] = array('cp.fk_categorie' => 'Category', 'cp.fk_product' => 'ProductRef');
502
        }
503
504
        // 1 Suppliers
505
        if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
506
            $r++;
507
            $this->import_code[$r] = $this->rights_class . '_1_' . Categorie::$MAP_ID_TO_CODE[1];
508
            $this->import_label[$r] = "CatSupLinks"; // Translation key
509
            $this->import_icon[$r] = $this->picto;
510
            $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
511
            $this->import_tables_array[$r] = array('cs' => MAIN_DB_PREFIX . 'categorie_fournisseur');
512
            $this->import_fields_array[$r] = array('cs.fk_categorie' => "Category*", 'cs.fk_soc' => "Supplier*");
513
            $this->import_regex_array[$r] = array(
514
                'cs.fk_categorie' => 'rowid@' . MAIN_DB_PREFIX . 'categorie:type=1',
515
                'cs.fk_soc' => 'rowid@' . MAIN_DB_PREFIX . 'societe:fournisseur>0'
516
            );
517
518
            $this->import_convertvalue_array[$r] = array(
519
                'cs.fk_categorie' => array('rule' => 'fetchidfromref', 'classfile' => '/categories/class/categorie.class.php', 'class' => 'Categorie', 'method' => 'fetch', 'element' => 'category'),
520
                'cs.fk_soc' => array('rule' => 'fetchidfromref', 'classfile' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty')
521
            );
522
            $this->import_examplevalues_array[$r] = array('cs.fk_categorie' => "rowid or label", 'cs.fk_soc' => "rowid or name");
523
        }
524
525
        // 2 Customers
526
        if (isModEnabled("societe")) {
527
            $r++;
528
            $this->import_code[$r] = $this->rights_class . '_2_' . Categorie::$MAP_ID_TO_CODE[2];
529
            $this->import_label[$r] = "CatCusLinks"; // Translation key
530
            $this->import_icon[$r] = $this->picto;
531
            $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
532
            $this->import_tables_array[$r] = array('cs' => MAIN_DB_PREFIX . 'categorie_societe');
533
            $this->import_fields_array[$r] = array('cs.fk_categorie' => "Category*", 'cs.fk_soc' => "Customer*");
534
            $this->import_regex_array[$r] = array(
535
                'cs.fk_categorie' => 'rowid@' . MAIN_DB_PREFIX . 'categorie:type=2',
536
                'cs.fk_soc' => 'rowid@' . MAIN_DB_PREFIX . 'societe:client>0'
537
            );
538
539
            $this->import_convertvalue_array[$r] = array(
540
                'cs.fk_categorie' => array('rule' => 'fetchidfromref', 'classfile' => '/categories/class/categorie.class.php', 'class' => 'Categorie', 'method' => 'fetch', 'element' => 'category'),
541
                'cs.fk_soc' => array('rule' => 'fetchidfromref', 'classfile' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty')
542
            );
543
            $this->import_examplevalues_array[$r] = array('cs.fk_categorie' => "rowid or label", 'cs.fk_soc' => "rowid or name");
544
        }
545
546
        // 3 Members
547
        if (isModEnabled('member')) {
548
            $r++;
549
            $this->import_code[$r] = $this->rights_class . '_3_' . Categorie::$MAP_ID_TO_CODE[3];
550
            $this->import_label[$r] = "CatMembersLinks"; // Translation key
551
            $this->import_icon[$r] = $this->picto;
552
            $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
553
            $this->import_tables_array[$r] = array('cm' => MAIN_DB_PREFIX . 'categorie_contact');
554
            $this->import_fields_array[$r] = array('cm.fk_categorie' => "Category*", 'cm.fk_member' => "Member*");
555
            $this->import_regex_array[$r] = array('cm.fk_categorie' => 'rowid@' . MAIN_DB_PREFIX . 'categorie:type=3');
556
557
            $this->import_convertvalue_array[$r] = array(
558
                'cs.fk_categorie' => array('rule' => 'fetchidfromref', 'classfile' => '/categories/class/categorie.class.php', 'class' => 'Categorie', 'method' => 'fetch', 'element' => 'category'),
559
                'cs.fk_member' => array('rule' => 'fetchidfromref', 'classfile' => '/adherents/class/adherent.class.php', 'class' => 'Adherent', 'method' => 'fetch', 'element' => 'Member')
560
            );
561
            $this->import_examplevalues_array[$r] = array('cs.fk_categorie' => "rowid or label", 'cs.fk_member' => "rowid or ref");
562
        }
563
564
        // 4 Contacts/Addresses
565
        if (isModEnabled("societe")) {
566
            $r++;
567
            $this->import_code[$r] = $this->rights_class . '_4_' . Categorie::$MAP_ID_TO_CODE[4];
568
            $this->import_label[$r] = "CatContactsLinks"; // Translation key
569
            $this->import_icon[$r] = $this->picto;
570
            $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
571
            $this->import_tables_array[$r] = array('cc' => MAIN_DB_PREFIX . 'categorie_contact');
572
            $this->import_fields_array[$r] = array('cc.fk_categorie' => "Category*", 'cc.fk_socpeople' => "IdContact*");
573
            $this->import_regex_array[$r] = array(
574
                'cc.fk_categorie' => 'rowid@' . MAIN_DB_PREFIX . 'categorie:type=4'
575
                //'cc.fk_socpeople'=>'rowid@'.MAIN_DB_PREFIX.'socpeople'
576
            );
577
578
            $this->import_convertvalue_array[$r] = array(
579
                'cc.fk_categorie' => array('rule' => 'fetchidfromref', 'classfile' => '/categories/class/categorie.class.php', 'class' => 'Categorie', 'method' => 'fetch', 'element' => 'category'),
580
                //'cc.fk_socpeople'=>array('rule'=>'fetchidfromref','classfile'=>'/contact/class/contact.class.php','class'=>'Contact','method'=>'fetch','element'=>'Contact')
581
            );
582
            $this->import_examplevalues_array[$r] = array('cc.fk_categorie' => "rowid or label", 'cc.fk_socpeople' => "rowid");
583
        }
584
585
        // 5 Bank accounts, TODO ?
586
587
        // 6 Projects
588
        if (isModEnabled('project')) {
589
            $r++;
590
            $this->import_code[$r] = $this->rights_class . '_6_' . Categorie::$MAP_ID_TO_CODE[6];
591
            $this->import_label[$r] = "CatProjectsLinks"; // Translation key
592
            $this->import_icon[$r] = $this->picto;
593
            $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
594
            $this->import_tables_array[$r] = array('cp' => MAIN_DB_PREFIX . 'categorie_project');
595
            $this->import_fields_array[$r] = array('cp.fk_categorie' => "Category*", 'cp.fk_project' => "Project*");
596
            $this->import_regex_array[$r] = array('cp.fk_categorie' => 'rowid@' . MAIN_DB_PREFIX . 'categorie:type=6');
597
598
            $this->import_convertvalue_array[$r] = array(
599
                'cs.fk_categorie' => array('rule' => 'fetchidfromref', 'classfile' => '/categories/class/categorie.class.php', 'class' => 'Categorie', 'method' => 'fetch', 'element' => 'category'),
600
                'cs.fk_project' => array('rule' => 'fetchidfromref', 'classfile' => '/projet/class/project.class.php', 'class' => 'Project', 'method' => 'fetch', 'element' => 'Project')
601
            );
602
            $this->import_examplevalues_array[$r] = array('cp.fk_categorie' => "rowid or label", 'cp.fk_project' => "rowid or ref");
603
        }
604
605
        // 7 Users
606
        if (isModEnabled('user')) {
607
            $r++;
608
            $this->import_code[$r] = $this->rights_class . '_7_' . Categorie::$MAP_ID_TO_CODE[7];
609
            $this->import_label[$r] = "CatUsersLinks"; // Translation key
610
            $this->import_icon[$r] = $this->picto;
611
            $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
612
            $this->import_tables_array[$r] = array('cu' => MAIN_DB_PREFIX . 'categorie_user');
613
            $this->import_fields_array[$r] = array('cu.fk_categorie' => "Category*", 'cu.fk_user' => "User*");
614
            $this->import_regex_array[$r] = array('cu.fk_categorie' => 'rowid@' . MAIN_DB_PREFIX . 'categorie:type=7');
615
616
            $this->import_convertvalue_array[$r] = array(
617
                'cu.fk_categorie' => array('rule' => 'fetchidfromref', 'classfile' => '/categories/class/categorie.class.php', 'class' => 'Categorie', 'method' => 'fetch', 'element' => 'category'),
618
                'cu.fk_user' => array('rule' => 'fetchidfromref', 'classfile' => '/user/class/user.class.php', 'class' => 'User', 'method' => 'fetch', 'element' => 'User')
619
            );
620
            $this->import_examplevalues_array[$r] = array('cu.fk_categorie' => "rowid or label", 'cu.fk_user' => "rowid or login");
621
        }
622
623
        // 8 Bank Lines, TODO ?
624
625
        // 9 Warehouses, TODO ?
626
627
        // 10 Agenda Events, TODO ?
628
629
        // 11 Website Pages, TODO ?
630
    }
631
632
633
    /**
634
     *      Function called when module is enabled.
635
     *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
636
     *      It also creates data directories
637
     *
638
     * @param string $options Options when enabling module ('', 'noboxes')
639
     * @return     int                 1 if OK, 0 if KO
640
     */
641
    public function init($options = '')
642
    {
643
        // Permissions
644
        $this->remove($options);
645
646
        $sql = array();
647
648
        return $this->_init($sql, $options);
649
    }
650
}
651