modEventOrganization.class.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <?php
  2. /* Copyright (C) 2021 Florian Henry <florian.henry@scopen.fr>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \defgroup eventorganization Module EventOrganization
  19. * \brief EventOrganization module descriptor.
  20. *
  21. * \file htdocs/core/modules/modEventOrganization.class.php
  22. * \ingroup eventorganization
  23. * \brief Description and activation file for the EventOrganization
  24. */
  25. include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  27. /**
  28. * Description and activation class for module EventOrganization
  29. * This module is base on this specification :
  30. * https://wiki.dolibarr.org/index.php/Draft:Module_Event_Organization
  31. */
  32. class modEventOrganization 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, $langs;
  42. $this->db = $db;
  43. $this->numero = 2450;
  44. $this->rights_class = 'eventorganization';
  45. $this->family = "projects";
  46. $this->module_position = '15';
  47. $this->name = preg_replace('/^mod/i', '', get_class($this));
  48. $this->description = "EventOrganizationDescription";
  49. $this->descriptionlong = "EventOrganizationDescriptionLong";
  50. $this->version = 'dolibarr';
  51. // Key used in llx_const table to save module status enabled/disabled (where EVENTORGANIZATION is value of property name of module in uppercase)
  52. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  53. $this->picto = 'conferenceorbooth';
  54. // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
  55. $this->module_parts = array(
  56. // Set this to 1 if module has its own trigger directory (core/triggers)
  57. 'triggers' => 1,
  58. // Set this to 1 if module has its own login method file (core/login)
  59. 'login' => 0,
  60. // Set this to 1 if module has its own substitution function file (core/substitutions)
  61. 'substitutions' => 0,
  62. // Set this to 1 if module has its own menus handler directory (core/menus)
  63. 'menus' => 0,
  64. // Set this to 1 if module overwrite template dir (core/tpl)
  65. 'tpl' => 0,
  66. // Set this to 1 if module has its own barcode directory (core/modules/barcode)
  67. 'barcode' => 0,
  68. // Set this to 1 if module has its own models directory (core/modules/xxx)
  69. 'models' => 1,
  70. // Set this to 1 if module has its own printing directory (core/modules/printing)
  71. 'printing' => 0,
  72. // Set this to 1 if module has its own theme directory (theme)
  73. 'theme' => 0,
  74. // Set this to relative path of css file if module has its own css file
  75. 'css' => array(
  76. // '/eventorganization/css/eventorganization.css.php',
  77. ),
  78. // Set this to relative path of js file if module must load a js on all pages
  79. 'js' => array(
  80. // '/eventorganization/js/eventorganization.js.php',
  81. ),
  82. // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
  83. 'hooks' => array(
  84. // 'data' => array(
  85. // 'hookcontext1',
  86. // 'hookcontext2',
  87. // ),
  88. // 'entity' => '0',
  89. ),
  90. // Set this to 1 if features of module are opened to external users
  91. 'moduleforexternal' => 0,
  92. );
  93. // Data directories to create when module is enabled.
  94. // Example: this->dirs = array("/eventorganization/temp","/eventorganization/subdir");
  95. $this->dirs = array("/eventorganization/temp");
  96. // Config pages. Put here list of php page, stored into eventorganization/admin directory, to use to setup module.
  97. $this->config_page_url = array("eventorganization.php");
  98. // Dependencies
  99. // A condition to hide module
  100. $this->hidden = false;
  101. // List of module class names as string that must be enabled if this module is enabled. Example: array('always'=>array('modModuleToEnable1','modModuleToEnable2'), 'FR'=>array('modModuleToEnableFR'...))
  102. $this->depends = array('modProjet','modCategorie');
  103. $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
  104. $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
  105. // The language file dedicated to your module
  106. $this->langfiles = array("eventorganization");
  107. // Prerequisites
  108. $this->phpmin = array(7, 0); // Minimum version of PHP required by module
  109. $this->need_dolibarr_version = array(13, -3); // Minimum version of Dolibarr required by module
  110. // Messages at activation
  111. $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
  112. $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
  113. //$this->automatic_activation = array('FR'=>'EventOrganizationWasAutomaticallyActivatedBecauseOfYourCountryChoice');
  114. //$this->always_enabled = true; // If true, can't be disabled
  115. // Constants
  116. // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
  117. // Example: $this->const=array(1 => array('EVENTORGANIZATION_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
  118. // 2 => array('EVENTORGANIZATION_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
  119. // );
  120. $this->const = array(1 => array('EVENTORGANIZATION_TASK_LABEL', 'chaine', '', '', 0));
  121. // Some keys to add into the overwriting translation tables
  122. /*$this->overwrite_translation = array(
  123. 'en_US:ParentCompany'=>'Parent company or reseller',
  124. 'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
  125. )*/
  126. if (!isset($conf->eventorganization) || !isset($conf->eventorganization->enabled)) {
  127. $conf->eventorganization = new stdClass();
  128. $conf->eventorganization->enabled = 0;
  129. }
  130. // Array to add new pages in new tabs
  131. $this->tabs = array();
  132. // Example:
  133. // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@eventorganization:$user->rights->eventorganization->read:/eventorganization/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
  134. // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@eventorganization:$user->rights->othermodule->read:/eventorganization/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
  135. // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
  136. //
  137. // Where objecttype can be
  138. // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
  139. // 'contact' to add a tab in contact view
  140. // 'contract' to add a tab in contract view
  141. // 'group' to add a tab in group view
  142. // 'intervention' to add a tab in intervention view
  143. // 'invoice' to add a tab in customer invoice view
  144. // 'invoice_supplier' to add a tab in supplier invoice view
  145. // 'member' to add a tab in fundation member view
  146. // 'opensurveypoll' to add a tab in opensurvey poll view
  147. // 'order' to add a tab in sales order view
  148. // 'order_supplier' to add a tab in supplier order view
  149. // 'payment' to add a tab in payment view
  150. // 'payment_supplier' to add a tab in supplier payment view
  151. // 'product' to add a tab in product view
  152. // 'propal' to add a tab in propal view
  153. // 'project' to add a tab in project view
  154. // 'stock' to add a tab in stock view
  155. // 'thirdparty' to add a tab in third party view
  156. // 'user' to add a tab in user view
  157. // Dictionaries
  158. $this->dictionaries = array();
  159. // Boxes/Widgets
  160. // Add here list of php file(s) stored in eventorganization/core/boxes that contains a class to show a widget.
  161. $this->boxes = array(
  162. // 0 => array(
  163. // 'file' => 'eventorganizationwidget1.php@eventorganization',
  164. // 'note' => 'Widget provided by EventOrganization',
  165. // 'enabledbydefaulton' => 'Home',
  166. // ),
  167. // ...
  168. );
  169. // Cronjobs (List of cron jobs entries to add when module is enabled)
  170. // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
  171. $this->cronjobs = array(
  172. );
  173. // Permissions provided by this module
  174. $this->rights = array();
  175. $r = 1;
  176. // Add here entries to declare new permissions
  177. /* BEGIN MODULEBUILDER PERMISSIONS */
  178. $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
  179. $this->rights[$r][1] = 'Read objects of EventOrganization'; // Permission label
  180. $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
  181. $r++;
  182. $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
  183. $this->rights[$r][1] = 'Create/Update objects of EventOrganization'; // Permission label
  184. $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
  185. $r++;
  186. $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
  187. $this->rights[$r][1] = 'Delete objects of EventOrganization'; // Permission label
  188. $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
  189. $r++;
  190. /* END MODULEBUILDER PERMISSIONS */
  191. // Main menu entries to add
  192. $this->menu = array();
  193. $r = 0;
  194. // Add here entries to declare new menus
  195. /* BEGIN MODULEBUILDER TOPMENU */
  196. /* END MODULEBUILDER TOPMENU */
  197. /* BEGIN MODULEBUILDER LEFTMENU CONFERENCEORBOOTH*/
  198. $this->menu[$r++]=array(
  199. 'fk_menu'=>'fk_mainmenu=project', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
  200. 'type'=>'left', // This is a Left menu entry
  201. 'titre'=>'EventOrganizationMenuLeft',
  202. 'prefix' => img_picto('', 'eventorganization', 'class="paddingright pictofixedwidth"'),
  203. 'mainmenu'=>'project',
  204. 'leftmenu'=>'eventorganization',
  205. 'url'=>'',
  206. 'langs'=>'eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
  207. 'position'=>1000+$r,
  208. 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
  209. 'perms'=>'$user->rights->eventorganization->read', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
  210. 'target'=>'',
  211. 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
  212. );
  213. $this->menu[$r++]=array(
  214. 'fk_menu'=>'fk_mainmenu=project,fk_leftmenu=eventorganization', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
  215. 'type'=>'left', // This is a Left menu entry
  216. 'titre'=>'List',
  217. 'url'=>'/projet/list.php?search_usage_event_organization=1&search_status=99&mainmenu=project&contextpage=organizedevents',
  218. 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
  219. 'position'=>1000+$r,
  220. 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
  221. 'perms'=>'$user->rights->eventorganization->read', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
  222. 'target'=>'',
  223. 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
  224. );
  225. $this->menu[$r++]=array(
  226. 'fk_menu'=>'fk_mainmenu=project,fk_leftmenu=eventorganization', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
  227. 'type'=>'left', // This is a Left menu entry
  228. 'titre'=>'New',
  229. 'url'=>'/projet/card.php?leftmenu=projects&action=create&usage_organize_event=1&usage_opportunity=0',
  230. 'langs'=>'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
  231. 'position'=>1000+$r,
  232. 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
  233. 'perms'=>'$user->rights->eventorganization->write', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
  234. 'target'=>'',
  235. 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
  236. );
  237. $this->menu[$r++]=array(
  238. 'fk_menu'=>'fk_mainmenu=project', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
  239. 'type'=>'left', // This is a Left menu entry
  240. 'titre'=>'ConferenceOrBooth',
  241. 'prefix' => img_picto('', 'conferenceorbooth', 'class="paddingright pictofixedwidth"'),
  242. 'mainmenu'=>'project',
  243. 'leftmenu'=>'eventorganizationconforbooth',
  244. 'url'=>'',
  245. 'langs'=>'eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
  246. 'position'=>1000+$r,
  247. 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
  248. 'perms'=>'$user->rights->eventorganization->read', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
  249. 'target'=>'',
  250. 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
  251. );
  252. $this->menu[$r++]=array(
  253. 'fk_menu'=>'fk_mainmenu=project,fk_leftmenu=eventorganizationconforbooth', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
  254. 'type'=>'left', // This is a Left menu entry
  255. 'titre'=>'List',
  256. 'url'=>'/eventorganization/conferenceorbooth_list.php?mainmenu=project',
  257. 'langs'=>'eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
  258. 'position'=>1000+$r,
  259. 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
  260. 'perms'=>'$user->rights->eventorganization->read', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
  261. 'target'=>'',
  262. 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
  263. );
  264. $this->menu[$r++]=array(
  265. 'fk_menu'=>'fk_mainmenu=project,fk_leftmenu=eventorganizationconforbooth', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
  266. 'type'=>'left', // This is a Left menu entry
  267. 'titre'=>'New',
  268. 'url'=>'/eventorganization/conferenceorbooth_card.php?leftmenu=projects&action=create',
  269. 'langs'=>'eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
  270. 'position'=>1000+$r,
  271. 'enabled'=>'$conf->eventorganization->enabled', // Define condition to show or hide menu entry. Use '$conf->eventorganization->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
  272. 'perms'=>'$user->rights->eventorganization->write', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
  273. 'target'=>'',
  274. 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
  275. );
  276. /* END MODULEBUILDER LEFTMENU CONFERENCEORBOOTH */
  277. // Exports profiles provided by this module
  278. $r = 1;
  279. /* BEGIN MODULEBUILDER EXPORT CONFERENCEORBOOTHATTENDEES */
  280. $langs->load("eventorganization");
  281. $this->export_code[$r]=$this->rights_class.'_'.$r;
  282. $this->export_label[$r]='ListOfAttendeesOfEvent'; // Translation key (used only if key ExportDataset_xxx_z not found)
  283. $this->export_icon[$r]=$this->picto;
  284. // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array
  285. $keyforclass = 'ConferenceOrBoothAttendee';
  286. $keyforclassfile='/eventorganization/class/conferenceorboothattendee.class.php';
  287. $keyforelement='conferenceorboothattendee';
  288. include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
  289. $this->export_entities_array[$r]['t.fk_invoice'] = 'invoice';
  290. unset($this->export_fields_array[$r]['t.fk_project']); // Remove field so we can add it at end just after
  291. unset($this->export_fields_array[$r]['t.fk_soc']); // Remove field so we can add it at end just after
  292. $this->export_fields_array[$r]['t.fk_invoice'] = 'InvoiceId';
  293. $this->export_fields_array[$r]['t.fk_project'] = 'ProjectId';
  294. $this->export_fields_array[$r]['p.ref'] = 'ProjectRef';
  295. $this->export_fields_array[$r]['t.fk_soc'] = 'IdThirdParty';
  296. $this->export_entities_array[$r]['t.fk_project'] = 'project';
  297. $this->export_entities_array[$r]['p.ref'] = 'project';
  298. $this->export_entities_array[$r]['t.fk_soc'] = 'company';
  299. $this->export_TypeFields_array[$r]['t.fk_project'] = 'Numeric';
  300. $this->export_TypeFields_array[$r]['t.fk_invoice'] = 'Numeric';
  301. $this->export_TypeFields_array[$r]['p.ref'] = 'Text';
  302. $this->export_TypeFields_array[$r]['t.fk_soc'] = 'Numeric';
  303. //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text';
  304. //unset($this->export_fields_array[$r]['t.fieldtoremove']);
  305. $keyforselect='conferenceorboothattendee';
  306. $keyforaliasextra='extra';
  307. $keyforelement='conferenceorboothattendee';
  308. include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
  309. //$this->export_dependencies_array[$r] = array('aaaline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
  310. //$this->export_special_array[$r] = array('t.field'=>'...');
  311. //$this->export_examplevalues_array[$r] = array('t.field'=>'Example');
  312. //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp');
  313. $this->export_sql_start[$r]='SELECT DISTINCT ';
  314. $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'eventorganization_conferenceorboothattendee as t, '.MAIN_DB_PREFIX.'projet as p';
  315. $this->export_sql_end[$r] .=' WHERE t.fk_project = p.rowid';
  316. $this->export_sql_end[$r] .=' AND p.entity IN ('.getEntity('conferenceorboothattendee').')';
  317. $r++;
  318. /* END MODULEBUILDER EXPORT CONFERENCEORBOOTHATTENDEES */
  319. /* BEGIN MODULEBUILDER EXPORT CONFERENCEORBOOTH */
  320. /*
  321. $r++;
  322. $this->export_code[$r] = $this->rights_class.'_'.$r;
  323. $this->export_label[$r] = "ExportDataset_event1";
  324. $this->export_permission[$r] = array(array("agenda", "export"));
  325. $this->export_fields_array[$r] = array('ac.id'=>"IdAgenda", 'ac.ref_ext'=>"ExternalRef", 'ac.datec'=>"DateCreation", 'ac.datep'=>"DateActionBegin",
  326. 'ac.datep2'=>"DateActionEnd", 'ac.label'=>"Title", 'ac.note'=>"Note", 'ac.percent'=>"Percent", 'ac.durationp'=>"Duration",
  327. 'cac.libelle'=>"ActionType",
  328. 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town',
  329. 'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6',
  330. 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
  331. 'p.ref' => 'ProjectRef',
  332. );
  333. $this->export_TypeFields_array[$r] = array('ac.ref_ext'=>"Text", 'ac.datec'=>"Date", 'ac.datep'=>"Date",
  334. 'ac.datep2'=>"Date", 'ac.label'=>"Text", 'ac.note'=>"Text", 'ac.percent'=>"Numeric",
  335. 'ac.durationp'=>"Duree",
  336. 'cac.libelle'=>"List:c_actioncomm:libelle:libelle",
  337. 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text',
  338. 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text',
  339. 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
  340. 'p.ref' => 'Text',
  341. );
  342. $this->export_entities_array[$r] = array('ac.id'=>"action", 'ac.ref_ext'=>"action", 'ac.datec'=>"action", 'ac.datep'=>"action",
  343. 'ac.datep2'=>"action", 'ac.label'=>"action", 'ac.note'=>"action", 'ac.percent'=>"action", 'ac.durationp'=>"action",
  344. 'cac.libelle'=>"action",
  345. 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company',
  346. 'co.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company',
  347. 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company',
  348. 'p.ref' => 'project',
  349. );
  350. $keyforselect = 'actioncomm'; $keyforelement = 'action'; $keyforaliasextra = 'extra';
  351. include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
  352. $this->export_sql_start[$r] = 'SELECT DISTINCT ';
  353. $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'actioncomm as ac';
  354. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_extrafields as extra ON ac.id = extra.fk_object';
  355. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id';
  356. if (!empty($user) && empty($user->rights->agenda->allactions->read)) {
  357. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm';
  358. }
  359. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid';
  360. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid';
  361. if (!empty($user) && empty($user->rights->societe->client->voir)) {
  362. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
  363. }
  364. $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
  365. $this->export_sql_end[$r] .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = ac.fk_project";
  366. $this->export_sql_end[$r] .= " WHERE ac.entity IN (".getEntity('agenda').")";
  367. $this->export_sql_end[$r] .= " AND ac.code = 'AC_EO_INDOORCONF'";
  368. if (empty($user->rights->societe->client->voir)) {
  369. $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR ac.fk_soc IS NULL)';
  370. }
  371. if (!$user->hasRight('agenda', 'allactions', 'read')) {
  372. $this->export_sql_end[$r] .= ' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);
  373. }
  374. $this->export_sql_order[$r] = ' ORDER BY ac.datep';
  375. */
  376. /* END MODULEBUILDER EXPORT CONFERENCEORBOOTH */
  377. // Imports profiles provided by this module
  378. $r = 1;
  379. /* BEGIN MODULEBUILDER IMPORT CONFERENCEORBOOTH */
  380. /* END MODULEBUILDER IMPORT CONFERENCEORBOOTH */
  381. }
  382. /**
  383. * Function called when module is enabled.
  384. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  385. * It also creates data directories
  386. *
  387. * @param string $options Options when enabling module ('', 'noboxes')
  388. * @return int 1 if OK, 0 if KO
  389. */
  390. public function init($options = '')
  391. {
  392. global $conf, $langs, $user;
  393. /*$result = run_sql(DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_c_email_templates.sql', 1, '', 1);
  394. if ($result <= 0) {
  395. return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
  396. }
  397. TODO Instead use the array merge of the sql found into llx_c_email_templates for this module
  398. */
  399. // Permissions
  400. $this->remove($options);
  401. $sql = array();
  402. // Document templates
  403. $moduledir = 'eventorganization';
  404. $myTmpObjects = array();
  405. $myTmpObjects['ConferenceOrBooth'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
  406. foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
  407. if ($myTmpObjectKey == 'ConferenceOrBooth') {
  408. continue;
  409. }
  410. if ($myTmpObjectArray['includerefgeneration']) {
  411. $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/eventorganization/template_conferenceorbooths.odt';
  412. $dirodt = DOL_DATA_ROOT.'/doctemplates/eventorganization';
  413. $dest = $dirodt.'/template_conferenceorbooths.odt';
  414. if (file_exists($src) && !file_exists($dest)) {
  415. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  416. dol_mkdir($dirodt);
  417. $result = dol_copy($src, $dest, 0, 0);
  418. if ($result < 0) {
  419. $langs->load("errors");
  420. $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
  421. return 0;
  422. }
  423. }
  424. $sql = array_merge($sql, array(
  425. "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity),
  426. "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."','".$this->db->escape(strtolower($myTmpObjectKey))."',".((int) $conf->entity).")",
  427. "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity),
  428. "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")"
  429. ));
  430. }
  431. }
  432. $init = $this->_init($sql, $options);
  433. // Insert some vars
  434. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
  435. $formmail = new FormMail($this->db);
  436. include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
  437. if (!is_object($user)) {
  438. $user = new User($this->db); // To avoid error during migration
  439. }
  440. $template = $formmail->getEMailTemplate($this->db, 'conferenceorbooth', $user, $langs, 0, 1, '(EventOrganizationEmailAskConf)');
  441. if ($template->id > 0) {
  442. dolibarr_set_const($this->db, 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF', $template->id, 'chaine', 0, '', $conf->entity);
  443. }
  444. $template = $formmail->getEMailTemplate($this->db, 'conferenceorbooth', $user, $langs, 0, 1, '(EventOrganizationEmailAskBooth)');
  445. if ($template->id > 0) {
  446. dolibarr_set_const($this->db, 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH', $template->id, 'chaine', 0, '', $conf->entity);
  447. }
  448. $template = $formmail->getEMailTemplate($this->db, 'conferenceorbooth', $user, $langs, 0, 1, '(EventOrganizationEmailBoothPayment)');
  449. if ($template->id > 0) {
  450. dolibarr_set_const($this->db, 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH', $template->id, 'chaine', 0, '', $conf->entity);
  451. }
  452. $template = $formmail->getEMailTemplate($this->db, 'conferenceorbooth', $user, $langs, 0, 1, '(EventOrganizationEmailRegistrationPayment)');
  453. if ($template->id > 0) {
  454. dolibarr_set_const($this->db, 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT', $template->id, 'chaine', 0, '', $conf->entity);
  455. }
  456. return $init;
  457. }
  458. /**
  459. * Function called when module is disabled.
  460. * Remove from database constants, boxes and permissions from Dolibarr database.
  461. * Data directories are not deleted
  462. *
  463. * @param string $options Options when enabling module ('', 'noboxes')
  464. * @return int 1 if OK, 0 if KO
  465. */
  466. public function remove($options = '')
  467. {
  468. $sql = array();
  469. return $this->_remove($sql, $options);
  470. }
  471. }