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