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