dolibarr 24.0.0-beta
modEventOrganization.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2021 Florian Henry <florian.henry@scopen.fr>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
28include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
29require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
30
37{
43 public function __construct($db)
44 {
45 global $conf, $langs;
46
47 $this->db = $db;
48
49 $this->numero = 2450;
50
51 $this->rights_class = 'eventorganization';
52
53 $this->family = "projects";
54
55 $this->module_position = '15';
56
57 $this->name = preg_replace('/^mod/i', '', get_class($this));
58
59 $this->description = "EventOrganizationDescription";
60 $this->descriptionlong = "EventOrganizationDescriptionLong";
61
62 $this->version = 'dolibarr';
63
64
65 // Key used in llx_const table to save module status enabled/disabled (where EVENTORGANIZATION is value of property name of module in uppercase)
66 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
67
68 $this->picto = 'conferenceorbooth';
69
70 // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
71 $this->module_parts = array(
72 // Set this to 1 if module has its own trigger directory (core/triggers)
73 'triggers' => 1,
74 // Set this to 1 if module has its own login method file (core/login)
75 'login' => 0,
76 // Set this to 1 if module has its own substitution function file (core/substitutions)
77 'substitutions' => 0,
78 // Set this to 1 if module has its own menus handler directory (core/menus)
79 'menus' => 0,
80 // Set this to 1 if module overwrite template dir (core/tpl)
81 'tpl' => 0,
82 // Set this to 1 if module has its own barcode directory (core/modules/barcode)
83 'barcode' => 0,
84 // Set this to 1 if module has its own models directory (core/modules/xxx)
85 'models' => 1,
86 // Set this to 1 if module has its own printing directory (core/modules/printing)
87 'printing' => 0,
88 // Set this to 1 if module has its own theme directory (theme)
89 'theme' => 0,
90 // Set this to relative path of css file if module has its own css file
91 'css' => array(
92 // '/eventorganization/css/eventorganization.css.php',
93 ),
94 // Set this to relative path of js file if module must load a js on all pages
95 'js' => array(
96 // '/eventorganization/js/eventorganization.js.php',
97 ),
98 // 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'
99 'hooks' => array(
100 // 'data' => array(
101 // 'hookcontext1',
102 // 'hookcontext2',
103 // ),
104 // 'entity' => '0',
105 ),
106 // Set this to 1 if features of module are opened to external users
107 'moduleforexternal' => 0,
108 );
109
110 // Data directories to create when module is enabled.
111 // Example: this->dirs = array("/eventorganization/temp","/eventorganization/subdir");
112 $this->dirs = array("/eventorganization/temp");
113
114 // Config pages. Put here list of php page, stored into eventorganization/admin directory, to use to setup module.
115 $this->config_page_url = array("eventorganization.php");
116
117 // Dependencies
118 // A condition to hide module
119 $this->hidden = false;
120 // 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'...))
121 $this->depends = array('modProjet', 'modCategorie', 'modAgenda');
122 $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
123 $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
124
125 // The language file dedicated to your module
126 $this->langfiles = array("eventorganization");
127
128 // Prerequisites
129 $this->phpmin = array(7, 0); // Minimum version of PHP required by module
130 $this->need_dolibarr_version = array(13, -3); // Minimum version of Dolibarr required by module
131
132 // Messages at activation
133 $this->warnings_activation = array();
134 $this->warnings_activation_ext = array();
135 //$this->automatic_activation = array('FR'=>'EventOrganizationWasAutomaticallyActivatedBecauseOfYourCountryChoice');
136
137 // Constants
138 include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
139 $this->const = array(
140 [
141 'EVENTORGANIZATION_TASK_LABEL',
142 'chaine',
143 '',
144 '',
145 0
146 ],
147 [
148 "EVENTORGANIZATION_SECUREKEY",
149 "chaine",
150 getRandomPassword(true),
151 "",
152 0,
153 ],
154 );
155
156
157 // Some keys to add into the overwriting translation tables
158 /*$this->overwrite_translation = array(
159 'en_US:ParentCompany'=>'Parent company or reseller',
160 'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
161 )*/
162
163 if (!isset($conf->eventorganization) || !isset($conf->eventorganization->enabled)) {
164 $conf->eventorganization = new stdClass();
165 $conf->eventorganization->enabled = 0;
166 }
167
168 // Array to add new pages in new tabs
169 $this->tabs = array();
170 // Example:
171 // $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
172 // $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.
173 // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
174 //
175 // Where objecttype can be
176 // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
177 // 'contact' to add a tab in contact view
178 // 'contract' to add a tab in contract view
179 // 'group' to add a tab in group view
180 // 'intervention' to add a tab in intervention view
181 // 'invoice' to add a tab in customer invoice view
182 // 'invoice_supplier' to add a tab in supplier invoice view
183 // 'member' to add a tab in foundation member view
184 // 'opensurveypoll' to add a tab in opensurvey poll view
185 // 'order' to add a tab in sales order view
186 // 'order_supplier' to add a tab in supplier order view
187 // 'payment' to add a tab in payment view
188 // 'payment_supplier' to add a tab in supplier payment view
189 // 'product' to add a tab in product view
190 // 'propal' to add a tab in propal view
191 // 'project' to add a tab in project view
192 // 'stock' to add a tab in stock view
193 // 'thirdparty' to add a tab in third party view
194 // 'user' to add a tab in user view
195
196 // Dictionaries
197 $this->dictionaries = array();
198
199 // Boxes/Widgets
200 // Add here list of php file(s) stored in eventorganization/core/boxes that contains a class to show a widget.
201 $this->boxes = array(
202 // 0 => array(
203 // 'file' => 'eventorganizationwidget1.php@eventorganization',
204 // 'note' => 'Widget provided by EventOrganization',
205 // 'enabledbydefaulton' => 'Home',
206 // ),
207 // ...
208 );
209
210 // Cronjobs (List of cron jobs entries to add when module is enabled)
211 // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
212 $this->cronjobs = array(
213 );
214
215
216 // Permissions provided by this module
217 $this->rights = array();
218 $r = 1;
219
220 // Add here entries to declare new permissions
221 /* BEGIN MODULEBUILDER PERMISSIONS */
222 /*
223 $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
224 $this->rights[$r][1] = 'Read objects of EventOrganization'; // Permission label
225 $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
226 $r++;
227 $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
228 $this->rights[$r][1] = 'Create/Update objects of EventOrganization'; // Permission label
229 $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
230 $r++;
231 $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
232 $this->rights[$r][1] = 'Delete objects of EventOrganization'; // Permission label
233 $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->eventorganization->level1)
234 $r++;
235 */
236 /* END MODULEBUILDER PERMISSIONS */
237
238 // Main menu entries to add
239 $this->menu = array();
240 $r = 0;
241 // Add here entries to declare new menus
242 /* BEGIN MODULEBUILDER TOPMENU */
243 /* END MODULEBUILDER TOPMENU */
244 /* BEGIN MODULEBUILDER LEFTMENU CONFERENCEORBOOTH*/
245 $this->menu[$r++] = array(
246 '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
247 'type' => 'left', // This is a Left menu entry
248 'titre' => 'EventOrganizationMenuLeft',
249 'prefix' => img_picto('', 'eventorganization', 'class="paddingright pictofixedwidth"'),
250 'mainmenu' => 'project',
251 'leftmenu' => 'eventorganization',
252 'url' => '/projet/list.php?search_usage_event_organization=1&search_status=99&mainmenu=project&contextpage=organizedevents',
253 'langs' => 'eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
254 'position' => 1000 + $r,
255 'enabled' => 'isModEnabled("eventorganization")', // 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.
256 'perms' => '$user->hasRight("project", "read")', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
257 'target' => '',
258 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
259 );
260 $this->menu[$r++] = array(
261 '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
262 'type' => 'left', // This is a Left menu entry
263 'titre' => 'New',
264 'url' => '/projet/card.php?leftmenu=projects&action=create&usage_organize_event=1&usage_opportunity=0',
265 'langs' => 'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
266 'position' => 1000 + $r,
267 'enabled' => 'isModEnabled("eventorganization")', // 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.
268 'perms' => '$user->hasRight("project", "write")', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
269 'target' => '',
270 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
271 );
272 $this->menu[$r++] = array(
273 '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
274 'type' => 'left', // This is a Left menu entry
275 'titre' => 'List',
276 'url' => '/projet/list.php?search_usage_event_organization=1&search_status=99&mainmenu=project&contextpage=organizedevents',
277 'langs' => 'eventorganization@eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
278 'position' => 1000 + $r,
279 'enabled' => 'isModEnabled("eventorganization")', // 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.
280 'perms' => '$user->hasRight("project", "write")', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
281 'target' => '',
282 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
283 );
284 $this->menu[$r++] = array(
285 '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
286 'type' => 'left', // This is a Left menu entry
287 'titre' => 'EventOrganizationConfOrBoothes',
288 'prefix' => img_picto('', 'conferenceorbooth', 'class="paddingright pictofixedwidth"'),
289 'mainmenu' => 'project',
290 'leftmenu' => 'eventorganizationconforbooth',
291 'url' => '/eventorganization/conferenceorbooth_list.php?mainmenu=project',
292 'langs' => 'eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
293 'position' => 1000 + $r,
294 'enabled' => 'isModEnabled("eventorganization")', // 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.
295 'perms' => '$user->hasRight("project", "read")', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
296 'target' => '',
297 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
298 );
299 $this->menu[$r++] = array(
300 '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
301 'type' => 'left', // This is a Left menu entry
302 'titre' => 'New',
303 'url' => '/eventorganization/conferenceorbooth_card.php?leftmenu=projects&action=create',
304 'langs' => 'eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
305 'position' => 1000 + $r,
306 'enabled' => 'isModEnabled("eventorganization")', // 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.
307 'perms' => '$user->hasRight("project", "write")', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
308 'target' => '',
309 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
310 );
311 $this->menu[$r++] = array(
312 '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
313 'type' => 'left', // This is a Left menu entry
314 'titre' => 'List',
315 'url' => '/eventorganization/conferenceorbooth_list.php?mainmenu=project',
316 'langs' => 'eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
317 'position' => 1000 + $r,
318 'enabled' => 'isModEnabled("eventorganization")', // 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.
319 'perms' => '$user->hasRight("project", "read")', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
320 'target' => '',
321 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
322 );
323 $this->menu[$r++] = array(
324 '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
325 'type' => 'left', // This is a Left menu entry
326 'titre' => 'ConferenceOrBoothAttendeesShort',
327 'prefix' => img_picto('', 'contact', 'class="paddingright pictofixedwidth"'),
328 'mainmenu' => 'project',
329 'leftmenu' => 'eventorganizationconforattendee',
330 'url' => '/eventorganization/conferenceorboothattendee_list.php?withproject=0&mainmenu=project',
331 'langs' => 'eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
332 'position' => 1000 + $r,
333 'enabled' => 'isModEnabled("eventorganization")', // 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.
334 'perms' => '$user->hasRight("project", "read")', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
335 'target' => '',
336 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
337 );
338 $this->menu[$r++] = array(
339 'fk_menu' => 'fk_mainmenu=project,fk_leftmenu=eventorganizationconforattendee', // '' 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
340 'type' => 'left', // This is a Left menu entry
341 'titre' => 'List',
342 'url' => '/eventorganization/conferenceorboothattendee_list.php?withproject=0&mainmenu=project',
343 'langs' => 'eventorganization', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
344 'position' => 1000 + $r,
345 'enabled' => 'isModEnabled("eventorganization")', // 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.
346 'perms' => '$user->hasRight("project", "read")', // Use 'perms'=>'$user->rights->eventorganization->level1->level2' if you want your menu with a permission rules
347 'target' => '',
348 'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
349 );
350 /* END MODULEBUILDER LEFTMENU CONFERENCEORBOOTH */
351
352 // Exports profiles provided by this module
353 $r = 1;
354
355 /* BEGIN MODULEBUILDER EXPORT CONFERENCEORBOOTHATTENDEES */
356 $langs->load("eventorganization");
357 $this->export_code[$r] = $this->rights_class.'_'.$r;
358 $this->export_label[$r] = 'ListOfAttendeesOfEvent'; // Translation key (used only if key ExportDataset_xxx_z not found)
359 $this->export_icon[$r] = $this->picto;
360 // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array
361 $keyforclass = 'ConferenceOrBoothAttendee';
362 $keyforclassfile = '/eventorganization/class/conferenceorboothattendee.class.php';
363 $keyforelement = 'conferenceorboothattendee';
364 include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
365 $this->export_entities_array[$r]['t.fk_invoice'] = 'invoice';
366 unset($this->export_fields_array[$r]['t.fk_project']); // Remove field so we can add it at end just after
367 unset($this->export_fields_array[$r]['t.fk_soc']); // Remove field so we can add it at end just after
368 $this->export_fields_array[$r]['t.fk_invoice'] = 'InvoiceId';
369 $this->export_fields_array[$r]['t.fk_project'] = 'ProjectId';
370 $this->export_fields_array[$r]['p.ref'] = 'ProjectRef';
371 $this->export_fields_array[$r]['t.fk_soc'] = 'IdThirdParty';
372 $this->export_entities_array[$r]['t.fk_project'] = 'project';
373 $this->export_entities_array[$r]['p.ref'] = 'project';
374 $this->export_entities_array[$r]['t.fk_soc'] = 'company';
375 $this->export_TypeFields_array[$r]['t.fk_project'] = 'Numeric';
376 $this->export_TypeFields_array[$r]['t.fk_invoice'] = 'Numeric';
377 $this->export_TypeFields_array[$r]['p.ref'] = 'Text';
378 $this->export_TypeFields_array[$r]['t.fk_soc'] = 'Numeric';
379 //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text';
380 //unset($this->export_fields_array[$r]['t.fieldtoremove']);
381 $keyforselect = 'eventorganization_conferenceorboothattendee'; // The value in column elementtype of llx_extrafields table
382 $keyforaliasextra = 'extra';
383 $keyforelement = 'conferenceorboothattendee'; // The value of key for icon and class
384 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
385 //$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)
386 //$this->export_special_array[$r] = array('t.field'=>'...');
387 //$this->export_examplevalues_array[$r] = array('t.field'=>'Example');
388 //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp');
389 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
390 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'eventorganization_conferenceorboothattendee as t';
391 $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'projet as p ON t.fk_project = p.rowid AND p.entity IN ('.getEntity('conferenceorboothattendee').')';
392 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'eventorganization_conferenceorboothattendee_extrafields as extra on t.rowid = extra.fk_object';
393 $r++;
394 /* END MODULEBUILDER EXPORT CONFERENCEORBOOTHATTENDEES */
395
396 /* BEGIN MODULEBUILDER EXPORT CONFERENCEORBOOTH */
397 $langs->load("eventorganization");
398 $this->export_code[$r] = $this->rights_class.'_'.$r;
399 $this->export_label[$r] = 'ListOfConfOrBoothOfEvent'; // Translation key (used only if key ExportDataset_xxx_z not found)
400 $this->export_icon[$r] = 'conferenceorbooth';
401 // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array
402 $keyforclass = 'ConferenceOrBooth';
403 $keyforclassfile = '/eventorganization/class/conferenceorbooth.class.php';
404 $keyforelement = 'conferenceorbooth';
405 include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
406 unset($this->export_fields_array[$r]['t.fk_action']); // Remove field so we can add it at end just after
407 unset($this->export_fields_array[$r]['t.fk_project']); // Remove field so we can add it at end just after
408 unset($this->export_fields_array[$r]['t.fk_soc']); // Remove field so we can add it at end just after
409 $this->export_fields_array[$r]['t.fk_action'] = 'ConferenceOrBoothFormatID';
410 $this->export_fields_array[$r]['ca.code'] = 'ConferenceOrBoothFormatCode';
411 $this->export_fields_array[$r]['ca.libelle'] = 'ConferenceOrBoothFormatLabel';
412 $this->export_fields_array[$r]['t.fk_project'] = 'ProjectId';
413 $this->export_fields_array[$r]['p.ref'] = 'ProjectRef';
414 $this->export_fields_array[$r]['t.fk_soc'] = 'IdThirdParty';
415 $this->export_fields_array[$r]['s.nom'] = 'ThirdPartyName';
416 $this->export_entities_array[$r]['ca.code'] = 'conferenceorbooth';
417 $this->export_entities_array[$r]['ca.libelle'] = 'conferenceorbooth';
418 $this->export_entities_array[$r]['t.fk_project'] = 'project';
419 $this->export_entities_array[$r]['p.ref'] = 'project';
420 $this->export_entities_array[$r]['t.fk_soc'] = 'company';
421 $this->export_entities_array[$r]['s.nom'] = 'company';
422 $this->export_TypeFields_array[$r]['ca.code'] = 'Text';
423 $this->export_TypeFields_array[$r]['ca.libelle'] = 'Text';
424 $this->export_TypeFields_array[$r]['t.fk_project'] = 'Numeric';
425 $this->export_TypeFields_array[$r]['p.ref'] = 'Text';
426 $this->export_TypeFields_array[$r]['t.fk_soc'] = 'Numeric';
427 $this->export_TypeFields_array[$r]['s.nom'] = 'Text';
428 //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text';
429 //unset($this->export_fields_array[$r]['t.fieldtoremove']);
430 $keyforselect = 'actioncomm'; // The value in column elementtype of llx_extrafields table
431 $keyforaliasextra = 'extra';
432 $keyforelement = 'conferenceorbooth';
433 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
434 //$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)
435 //$this->export_special_array[$r] = array('t.field'=>'...');
436 //$this->export_examplevalues_array[$r] = array('t.field'=>'Example');
437 //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp');
438 $this->export_sql_start[$r] = "SELECT DISTINCT ";
439 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'actioncomm as t';
440 $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'projet as p ON t.fk_project = p.rowid AND p.usage_organize_event = 1 AND p.entity IN ('.getEntity('conferenceorboothattendee').')';
441 $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_actioncomm as ca ON ca.id = t.fk_action';
442 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON t.fk_soc = s.rowid';
443 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_extrafields as extra on t.id = extra.fk_object';
444 $this->export_sql_end[$r] .= " WHERE t.code LIKE 'AC_EO_%'";
445 $r++;
446 /* END MODULEBUILDER EXPORT CONFERENCEORBOOTH */
447
448
449 // Imports profiles provided by this module
450 $r = 1;
451 /* BEGIN MODULEBUILDER IMPORT CONFERENCEORBOOTH */
452 /* END MODULEBUILDER IMPORT CONFERENCEORBOOTH */
453 }
454
463 public function init($options = '')
464 {
465 global $conf, $langs, $user;
466
467 /*$result = run_sql(DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_c_email_templates.sql', 1, '', 1);
468 if ($result <= 0) {
469 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')
470 }
471 TODO Instead use the array merge of the sql found into llx_c_email_templates for this module
472 */
473
474 // Permissions
475 $this->remove($options);
476
477 $sql = array();
478
479 // Document templates
480 $moduledir = 'eventorganization';
481 $myTmpObjects = array();
482 $myTmpObjects['ConferenceOrBooth'] = array('includerefgeneration' => 0, 'includedocgeneration' => 0);
483
484 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
485 if ($myTmpObjectArray['includerefgeneration']) {
486 $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/eventorganization/template_conferenceorbooths.odt';
487 $dirodt = DOL_DATA_ROOT.'/doctemplates/eventorganization';
488 $dest = $dirodt.'/template_conferenceorbooths.odt';
489
490 if (file_exists($src) && !file_exists($dest)) {
491 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
492 dol_mkdir($dirodt);
493 $result = dol_copy($src, $dest, '0', 0);
494 if ($result < 0) {
495 $langs->load("errors");
496 $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
497 return 0;
498 }
499 }
500
501 $sql = array_merge($sql, array(
502 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity),
503 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."','".$this->db->escape(strtolower($myTmpObjectKey))."',".((int) $conf->entity).")",
504 "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),
505 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")"
506 ));
507 }
508 }
509
510 $init = $this->_init($sql, $options);
511
512
513 // Insert some vars
514 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
515 $formmail = new FormMail($this->db);
516
517 include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
518 if (!is_object($user)) {
519 $user = new User($this->db); // To avoid error during migration
520 }
521
522 $template = $formmail->getEMailTemplate($this->db, 'conferenceorbooth', $user, $langs, 0, 1, '(EventOrganizationEmailAskConf)');
523 if ($template->id > 0) {
524 dolibarr_set_const($this->db, 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF', $template->id, 'chaine', 0, '', $conf->entity);
525 }
526 $template = $formmail->getEMailTemplate($this->db, 'conferenceorbooth', $user, $langs, 0, 1, '(EventOrganizationEmailAskBooth)');
527 if ($template->id > 0) {
528 dolibarr_set_const($this->db, 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH', $template->id, 'chaine', 0, '', $conf->entity);
529 }
530 $template = $formmail->getEMailTemplate($this->db, 'conferenceorbooth', $user, $langs, 0, 1, '(EventOrganizationEmailBoothPayment)');
531 if ($template->id > 0) {
532 dolibarr_set_const($this->db, 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH', $template->id, 'chaine', 0, '', $conf->entity);
533 }
534 $template = $formmail->getEMailTemplate($this->db, 'conferenceorbooth', $user, $langs, 0, 1, '(EventOrganizationEmailRegistrationPayment)');
535 if ($template->id > 0) {
536 dolibarr_set_const($this->db, 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT', $template->id, 'chaine', 0, '', $conf->entity);
537 }
538
539 return $init;
540 }
541
550 public function remove($options = '')
551 {
552 $sql = array();
553 return $this->_remove($sql, $options);
554 }
555}
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
_remove($array_sql, $options='')
Disable function.
Class to manage a HTML form to send a unitary email Usage: $formail = new FormMail($db) $formmail->pr...
Class to manage Dolibarr users.
Description and activation class for module EventOrganization This module is base on this specificati...
init($options='')
Function called when module is enabled.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_copy($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:133
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.