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