modCategorie.class.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  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 = '20';
  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 (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
  108. $typeexample .= ($typeexample ? " / " : "")."0=Product-Service";
  109. }
  110. if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
  111. $typeexample .= ($typeexample ? "/" : "")."1=Supplier";
  112. }
  113. if (!empty($conf->societe->enabled)) {
  114. $typeexample .= ($typeexample ? " / " : "")."2=Customer-Prospect";
  115. }
  116. if (!empty($conf->adherent->enabled)) {
  117. $typeexample .= ($typeexample ? " / " : "")."3=Member";
  118. }
  119. if (!empty($conf->societe->enabled)) {
  120. $typeexample .= ($typeexample ? " / " : "")."4=Contact";
  121. }
  122. if (!empty($conf->bank->enabled)) {
  123. $typeexample .= ($typeexample ? " / " : "")."5=Bank account";
  124. }
  125. if (!empty($conf->project->enabled)) {
  126. $typeexample .= ($typeexample ? " / " : "")."6=Project";
  127. }
  128. if (!empty($conf->user->enabled)) {
  129. $typeexample .= ($typeexample ? " / " : "")."7=User";
  130. }
  131. if (!empty($conf->bank->enabled)) {
  132. $typeexample .= ($typeexample ? " / " : "")."8=Bank line";
  133. }
  134. if (!empty($conf->stock->enabled)) {
  135. $typeexample .= ($typeexample ? " / " : "")."9=Warehouse";
  136. }
  137. if (isModEnabled('agenda')) {
  138. $typeexample .= ($typeexample ? " / " : "")."10=Agenda event";
  139. }
  140. if (!empty($conf->website->enabled)) {
  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");
  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] = '!empty($conf->product->enabled) || !empty($conf->service->abled)';
  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", '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] = '!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)';
  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. 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_fournisseur'=>"SupplierCode",
  184. 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode",
  185. 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email",
  186. 's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_public'=>"NotePublic",
  187. 't.libelle'=>'ThirdPartyType'
  188. );
  189. $this->export_TypeFields_array[$r] = array(
  190. 'cat.rowid'=>'Numeric', 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text',
  191. '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",
  192. 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text",
  193. 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text",
  194. 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text",
  195. 't.libelle'=>'List:c_typent:libelle:code'
  196. );
  197. $this->export_entities_array[$r] = array(
  198. 's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.fournisseur'=>"company", 's.datec'=>"company", 's.tms'=>"company", 's.code_fournisseur'=>"company",
  199. 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company",
  200. 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company",
  201. 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company", 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company",
  202. 't.libelle'=>'company'
  203. ); // We define here only fields that use another picto
  204. $keyforselect = 'societe';
  205. $keyforelement = 'company';
  206. $keyforaliasextra = 'extra';
  207. include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
  208. $this->export_sql_start[$r] = 'SELECT DISTINCT ';
  209. $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat';
  210. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent';
  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. // 2 Customers/Prospects
  219. $r++;
  220. $this->export_code[$r] = $this->rights_class.'_2_'.Categorie::$MAP_ID_TO_CODE[2];
  221. $this->export_label[$r] = 'CatCusList';
  222. $this->export_icon[$r] = $this->picto;
  223. $this->export_enabled[$r] = '!empty($conf->societe->enabled)';
  224. $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "export"));
  225. $this->export_fields_array[$r] = array(
  226. 'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel",
  227. 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", 's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode",
  228. 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode",
  229. 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email",
  230. 's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_public'=>"NotePublic",
  231. 't.libelle'=>'ThirdPartyType', 'pl.code'=>'ProspectLevel', 'st.code'=>'ProspectStatus'
  232. );
  233. $this->export_TypeFields_array[$r] = array(
  234. 'cat.rowid'=>'Numeric', 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text',
  235. '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",
  236. 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text",
  237. 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text",
  238. 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text",
  239. 't.libelle'=>'List:c_typent:libelle:code', 'pl.code'=>'List:c_prospectlevel:label:code', 'st.code'=>'List:c_stcomm:libelle:code'
  240. );
  241. $this->export_entities_array[$r] = array(
  242. 's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company", 's.code_client'=>"company",
  243. 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company",
  244. 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company",
  245. 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company", 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company",
  246. 't.libelle'=>'company', 'pl.code'=>'company', 'st.code'=>'company'
  247. ); // We define here only fields that use another picto
  248. $keyforselect = 'societe';
  249. $keyforelement = 'company';
  250. $keyforaliasextra = 'extra';
  251. include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
  252. $this->export_sql_start[$r] = 'SELECT DISTINCT ';
  253. $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat';
  254. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent';
  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. // 3 Members
  265. $r++;
  266. $this->export_code[$r] = $this->rights_class.'_3_'.Categorie::$MAP_ID_TO_CODE[3];
  267. $this->export_label[$r] = 'CatMemberList';
  268. $this->export_icon[$r] = $this->picto;
  269. $this->export_enabled[$r] = '!empty($conf->adherent->enabled)';
  270. $this->export_permission[$r] = array(array("categorie", "lire"), array("adherent", "export"));
  271. $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');
  272. $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');
  273. $this->export_entities_array[$r] = array('p.rowid'=>'member', 'p.lastname'=>'member', 'p.firstname'=>'member'); // We define here only fields that use another picto
  274. $keyforselect = 'adherent';
  275. $keyforelement = 'member';
  276. $keyforaliasextra = 'extra';
  277. include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
  278. $this->export_sql_start[$r] = 'SELECT DISTINCT ';
  279. $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat';
  280. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent';
  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. // 4 Contacts
  287. $r++;
  288. $this->export_code[$r] = $this->rights_class.'_4_'.Categorie::$MAP_ID_TO_CODE[4];
  289. $this->export_label[$r] = 'CatContactList';
  290. $this->export_icon[$r] = $this->picto;
  291. $this->export_enabled[$r] = '!empty($conf->societe->enabled)';
  292. $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "contact", "export"));
  293. $this->export_fields_array[$r] = array(
  294. 'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel",
  295. 'p.rowid' => 'ContactId', 'civ.label' => 'UserTitle', 'p.lastname' => 'LastName', 'p.firstname' => 'Firstname',
  296. 'p.address' => 'Address', 'p.zip' => 'Zip', 'p.town' => 'Town', 'c.code' => 'CountryCode', 'c.label' => 'Country',
  297. 'p.birthday' => 'DateOfBirth', 'p.poste' => 'PostOrFunction',
  298. 'p.phone' => 'Phone', 'p.phone_perso' => 'PhonePerso', 'p.phone_mobile' => 'PhoneMobile', 'p.fax' => 'Fax', 'p.email' => 'Email',
  299. 'p.note_private' => 'NotePrivate', 'p.note_public' => 'NotePublic', 'p.statut' => 'Status',
  300. 's.nom'=>"Name", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.status'=>"Status",
  301. 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town",
  302. 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email"
  303. );
  304. $this->export_TypeFields_array[$r] = array(
  305. 'cat.rowid'=>'Numeric', 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text',
  306. 'civ.label' => 'List:c_civility:label:label', 'p.rowid'=>'Numeric', 'p.lastname' => 'Text', 'p.firstname' => 'Text',
  307. 'p.address' => 'Text', 'p.zip' => 'Text', 'p.town' => 'Text', 'c.code' => 'Text', 'c.label' => 'List:c_country:label:label',
  308. 'p.birthday' => 'Date', 'p.poste' => 'Text',
  309. 'p.phone' => 'Text', 'p.phone_perso' => 'Text', 'p.phone_mobile' => 'Text', 'p.fax' => 'Text', 'p.email' => 'Text',
  310. 'p.note_private' => 'Text', 'p.note_public' => 'Text', 'p.statut' => 'Boolean',
  311. 's.nom'=>"Text", 's.client'=>"Boolean", 's.fournisseur'=>"Boolean", 's.status'=>"Boolean",
  312. 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text",
  313. 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text"
  314. );
  315. $this->export_entities_array[$r] = array(
  316. 'p.rowid' => 'contact', 'civ.label' => 'contact', 'p.lastname' => 'contact', 'p.firstname' => 'contact',
  317. 'p.address' => 'contact', 'p.zip' => 'contact', 'p.town' => 'contact', 'c.code' => 'contact', 'c.label' => 'contact',
  318. 'p.birthday' => 'contact', 'p.poste' => 'contact',
  319. 'p.phone' => 'contact', 'p.phone_perso' => 'contact', 'p.phone_mobile' => 'contact', 'p.fax' => 'contact', 'p.email' => 'contact',
  320. 'p.note_private' => 'contact', 'p.note_public' => 'contact', 'p.statut' => 'contact',
  321. 's.nom'=>"company", 's.client'=>"company", 's.fournisseur'=>"company", 's.status'=>"company",
  322. 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company",
  323. 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company"
  324. ); // We define here only fields that use another picto
  325. $keyforselect = 'socpeople';
  326. $keyforelement = 'contact';
  327. $keyforaliasextra = 'extra';
  328. include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
  329. $this->export_sql_start[$r] = 'SELECT DISTINCT ';
  330. $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat';
  331. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent';
  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. // 5 Bank accounts, TODO ?
  341. // 6 Projects
  342. $r++;
  343. $this->export_code[$r] = $this->rights_class.'_6_'.Categorie::$MAP_ID_TO_CODE[6];
  344. $this->export_label[$r] = 'CatProjectsList';
  345. $this->export_icon[$r] = $this->picto;
  346. $this->export_enabled[$r] = '!empty($conf->project->enabled)';
  347. $this->export_permission[$r] = array(array("categorie", "lire"), array("projet", "export"));
  348. $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'pcat.label'=>"ParentCategoryLabel", 'p.rowid'=>'ProjectId', 'p.ref'=>'Ref', 's.rowid'=>"IdThirdParty", 's.nom'=>"Name");
  349. $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");
  350. $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
  351. $keyforselect = 'projet';
  352. $keyforelement = 'project';
  353. $keyforaliasextra = 'extra';
  354. include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
  355. $this->export_sql_start[$r] = 'SELECT DISTINCT ';
  356. $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat';
  357. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent';
  358. $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_project as cp ON cp.fk_categorie = cat.rowid';
  359. $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'projet as p ON p.rowid = cp.fk_project';
  360. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON extra.fk_object = p.rowid';
  361. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc';
  362. $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')';
  363. $this->export_sql_end[$r] .= ' AND cat.type = 6';
  364. // 7 Users
  365. $r++;
  366. $this->export_code[$r] = $this->rights_class.'_7_'.Categorie::$MAP_ID_TO_CODE[7];
  367. $this->export_label[$r] = 'CatUsersList';
  368. $this->export_icon[$r] = $this->picto;
  369. $this->export_enabled[$r] = '!empty($conf->user->enabled)';
  370. $this->export_permission[$r] = array(array("categorie", "lire"), array("user", "export"));
  371. $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'pcat.label'=>"ParentCategoryLabel", 'p.rowid'=>'UserID', 'p.login'=>'Login', 'p.lastname'=>'Lastname', 'p.firstname'=>'Firstname');
  372. $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');
  373. $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
  374. $keyforselect = 'user';
  375. $keyforelement = 'user';
  376. $keyforaliasextra = 'extra';
  377. include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
  378. $this->export_sql_start[$r] = 'SELECT DISTINCT ';
  379. $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat';
  380. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent';
  381. $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_user as cu ON cu.fk_categorie = cat.rowid';
  382. $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'user as p ON p.rowid = cu.fk_user';
  383. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user_extrafields as extra ON extra.fk_object = p.rowid';
  384. $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')';
  385. $this->export_sql_end[$r] .= ' AND cat.type = 7';
  386. // 8 Bank Lines, TODO ?
  387. // 9 Warehouses, TODO ?
  388. // 10 Agenda Events, TODO ?
  389. // 11 Website Pages, TODO ?
  390. // Imports
  391. //--------
  392. $r = 0;
  393. // Categories
  394. $r++;
  395. $this->import_code[$r] = $this->rights_class.'_list';
  396. $this->import_label[$r] = "CatList"; // Translation key
  397. $this->import_icon[$r] = $this->picto;
  398. $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
  399. $this->import_tables_array[$r] = array('ca'=>MAIN_DB_PREFIX.'categorie');
  400. $this->import_fields_array[$r] = array(
  401. 'ca.label'=>"Label*", 'ca.type'=>"Type*", 'ca.description'=>"Description",
  402. 'ca.fk_parent' => 'ParentCategory'
  403. );
  404. $this->import_regex_array[$r] = array('ca.type'=>'^(0|1|2|3|4|5|6|7|8|9|10|11)$');
  405. $this->import_convertvalue_array[$r] = array(
  406. 'ca.fk_parent' => array(
  407. 'rule' => 'fetchidfromcodeandlabel',
  408. 'classfile' => '/categories/class/categorie.class.php',
  409. 'class' => 'Categorie',
  410. 'method' => 'fetch',
  411. 'element' => 'category',
  412. 'codefromfield' => 'ca.type'
  413. )
  414. );
  415. $this->import_examplevalues_array[$r] = array(
  416. 'ca.label'=>"My Category Label", 'ca.type'=>$typeexample, 'ca.description'=>"My Category description", // $typeexample built above in exports
  417. 'ca.fk_parent' => 'rowid or label'
  418. );
  419. $this->import_updatekeys_array[$r] = array('ca.label'=>'Label');
  420. // 0 Products
  421. if (!empty($conf->product->enabled)) {
  422. $r++;
  423. $this->import_code[$r] = $this->rights_class.'_0_'.Categorie::$MAP_ID_TO_CODE[0];
  424. $this->import_label[$r] = "CatProdLinks"; // Translation key
  425. $this->import_icon[$r] = $this->picto;
  426. $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
  427. $this->import_tables_array[$r] = array('cp'=>MAIN_DB_PREFIX.'categorie_product');
  428. $this->import_fields_array[$r] = array('cp.fk_categorie'=>"Category*", 'cp.fk_product'=>"Product*");
  429. $this->import_regex_array[$r] = array('cp.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=0');
  430. $this->import_convertvalue_array[$r] = array(
  431. 'cp.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),
  432. 'cp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')
  433. );
  434. $this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"rowid or label", 'cp.fk_product'=>"rowid or ref");
  435. $this->import_updatekeys_array[$r] = array('cp.fk_categorie' => 'Category', 'cp.fk_product' => 'ProductRef');
  436. }
  437. // 1 Suppliers
  438. if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
  439. $r++;
  440. $this->import_code[$r] = $this->rights_class.'_1_'.Categorie::$MAP_ID_TO_CODE[1];
  441. $this->import_label[$r] = "CatSupLinks"; // Translation key
  442. $this->import_icon[$r] = $this->picto;
  443. $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
  444. $this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_fournisseur');
  445. $this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_soc'=>"Supplier*");
  446. $this->import_regex_array[$r] = array(
  447. 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=1',
  448. 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:fournisseur>0'
  449. );
  450. $this->import_convertvalue_array[$r] = array(
  451. 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),
  452. 'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty')
  453. );
  454. $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"rowid or label", 'cs.fk_soc'=>"rowid or name");
  455. }
  456. // 2 Customers
  457. if (!empty($conf->societe->enabled)) {
  458. $r++;
  459. $this->import_code[$r] = $this->rights_class.'_2_'.Categorie::$MAP_ID_TO_CODE[2];
  460. $this->import_label[$r] = "CatCusLinks"; // Translation key
  461. $this->import_icon[$r] = $this->picto;
  462. $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
  463. $this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_societe');
  464. $this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_soc'=>"Customer*");
  465. $this->import_regex_array[$r] = array(
  466. 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=2',
  467. 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:client>0'
  468. );
  469. $this->import_convertvalue_array[$r] = array(
  470. 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),
  471. 'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty')
  472. );
  473. $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"rowid or label", 'cs.fk_soc'=>"rowid or name");
  474. }
  475. // 3 Members
  476. if (!empty($conf->adherent->enabled)) {
  477. $r++;
  478. $this->import_code[$r] = $this->rights_class.'_3_'.Categorie::$MAP_ID_TO_CODE[3];
  479. $this->import_label[$r] = "CatMembersLinks"; // Translation key
  480. $this->import_icon[$r] = $this->picto;
  481. $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
  482. $this->import_tables_array[$r] = array('cm'=>MAIN_DB_PREFIX.'categorie_contact');
  483. $this->import_fields_array[$r] = array('cm.fk_categorie'=>"Category*", 'cm.fk_member'=>"Member*");
  484. $this->import_regex_array[$r] = array('cm.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=3');
  485. $this->import_convertvalue_array[$r] = array(
  486. 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),
  487. 'cs.fk_member'=>array('rule'=>'fetchidfromref', 'classfile'=>'/adherents/class/adherent.class.php', 'class'=>'Adherent', 'method'=>'fetch', 'element'=>'Member')
  488. );
  489. $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"rowid or label", 'cs.fk_member'=>"rowid or ref");
  490. }
  491. // 4 Contacts/Addresses
  492. if (!empty($conf->societe->enabled)) {
  493. $r++;
  494. $this->import_code[$r] = $this->rights_class.'_4_'.Categorie::$MAP_ID_TO_CODE[4];
  495. $this->import_label[$r] = "CatContactsLinks"; // Translation key
  496. $this->import_icon[$r] = $this->picto;
  497. $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
  498. $this->import_tables_array[$r] = array('cc'=>MAIN_DB_PREFIX.'categorie_contact');
  499. $this->import_fields_array[$r] = array('cc.fk_categorie'=>"Category*", 'cc.fk_socpeople'=>"IdContact*");
  500. $this->import_regex_array[$r] = array(
  501. 'cc.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=4'
  502. //'cc.fk_socpeople'=>'rowid@'.MAIN_DB_PREFIX.'socpeople'
  503. );
  504. $this->import_convertvalue_array[$r] = array(
  505. 'cc.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),
  506. //'cc.fk_socpeople'=>array('rule'=>'fetchidfromref','classfile'=>'/contact/class/contact.class.php','class'=>'Contact','method'=>'fetch','element'=>'Contact')
  507. );
  508. $this->import_examplevalues_array[$r] = array('cc.fk_categorie'=>"rowid or label", 'cc.fk_socpeople'=>"rowid");
  509. }
  510. // 5 Bank accounts, TODO ?
  511. // 6 Projects
  512. if (!empty($conf->project->enabled)) {
  513. $r++;
  514. $this->import_code[$r] = $this->rights_class.'_6_'.Categorie::$MAP_ID_TO_CODE[6];
  515. $this->import_label[$r] = "CatProjectsLinks"; // Translation key
  516. $this->import_icon[$r] = $this->picto;
  517. $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
  518. $this->import_tables_array[$r] = array('cp'=>MAIN_DB_PREFIX.'categorie_project');
  519. $this->import_fields_array[$r] = array('cp.fk_categorie'=>"Category*", 'cp.fk_project'=>"Project*");
  520. $this->import_regex_array[$r] = array('cp.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=6');
  521. $this->import_convertvalue_array[$r] = array(
  522. 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),
  523. 'cs.fk_project'=>array('rule'=>'fetchidfromref', 'classfile'=>'/projet/class/project.class.php', 'class'=>'Project', 'method'=>'fetch', 'element'=>'Project')
  524. );
  525. $this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"rowid or label", 'cp.fk_project'=>"rowid or ref");
  526. }
  527. // 7 Users
  528. if (!empty($conf->user->enabled)) {
  529. $r++;
  530. $this->import_code[$r] = $this->rights_class.'_7_'.Categorie::$MAP_ID_TO_CODE[7];
  531. $this->import_label[$r] = "CatUsersLinks"; // Translation key
  532. $this->import_icon[$r] = $this->picto;
  533. $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
  534. $this->import_tables_array[$r] = array('cu'=>MAIN_DB_PREFIX.'categorie_user');
  535. $this->import_fields_array[$r] = array('cu.fk_categorie'=>"Category*", 'cu.fk_user'=>"User*");
  536. $this->import_regex_array[$r] = array('cu.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=7');
  537. $this->import_convertvalue_array[$r] = array(
  538. 'cu.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),
  539. 'cu.fk_user'=>array('rule'=>'fetchidfromref', 'classfile'=>'/user/class/user.class.php', 'class'=>'User', 'method'=>'fetch', 'element'=>'User')
  540. );
  541. $this->import_examplevalues_array[$r] = array('cu.fk_categorie'=>"rowid or label", 'cu.fk_user'=>"rowid or login");
  542. }
  543. // 8 Bank Lines, TODO ?
  544. // 9 Warehouses, TODO ?
  545. // 10 Agenda Events, TODO ?
  546. // 11 Website Pages, TODO ?
  547. }
  548. /**
  549. * Function called when module is enabled.
  550. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  551. * It also creates data directories
  552. *
  553. * @param string $options Options when enabling module ('', 'noboxes')
  554. * @return int 1 if OK, 0 if KO
  555. */
  556. public function init($options = '')
  557. {
  558. // Permissions
  559. $this->remove($options);
  560. $sql = array();
  561. return $this->_init($sql, $options);
  562. }
  563. }