modCategorie.class.php 37 KB

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