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