dolibarr  17.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 
26 include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
27 require_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('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'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'; $keyforclassfile='/eventorganization/class/conferenceorboothattendee.class.php'; $keyforelement='conferenceorboothattendee';
321  include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
322  $this->export_entities_array[$r]['t.fk_invoice'] = 'invoice';
323  unset($this->export_fields_array[$r]['t.fk_project']); // Remove field so we can add it at end just after
324  unset($this->export_fields_array[$r]['t.fk_soc']); // Remove field so we can add it at end just after
325  $this->export_fields_array[$r]['t.fk_invoice'] = 'InvoiceId';
326  $this->export_fields_array[$r]['t.fk_project'] = 'ProjectId';
327  $this->export_fields_array[$r]['p.ref'] = 'ProjectRef';
328  $this->export_fields_array[$r]['t.fk_soc'] = 'IdThirdParty';
329  $this->export_entities_array[$r]['t.fk_project'] = 'project';
330  $this->export_entities_array[$r]['p.ref'] = 'project';
331  $this->export_entities_array[$r]['t.fk_soc'] = 'company';
332  $this->export_TypeFields_array[$r]['t.fk_project'] = 'Numeric';
333  $this->export_TypeFields_array[$r]['t.fk_invoice'] = 'Numeric';
334  $this->export_TypeFields_array[$r]['p.ref'] = 'Text';
335  $this->export_TypeFields_array[$r]['t.fk_soc'] = 'Numeric';
336  //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text';
337  //unset($this->export_fields_array[$r]['t.fieldtoremove']);
338  $keyforselect='conferenceorboothattendee'; $keyforaliasextra='extra'; $keyforelement='conferenceorboothattendee';
339  include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
340  //$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)
341  //$this->export_special_array[$r] = array('t.field'=>'...');
342  //$this->export_examplevalues_array[$r] = array('t.field'=>'Example');
343  //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp');
344  $this->export_sql_start[$r]='SELECT DISTINCT ';
345  $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'eventorganization_conferenceorboothattendee as t, '.MAIN_DB_PREFIX.'projet as p';
346  $this->export_sql_end[$r] .=' WHERE t.fk_project = p.rowid';
347  $this->export_sql_end[$r] .=' AND p.entity IN ('.getEntity('conferenceorboothattendee').')';
348  $r++;
349  /* END MODULEBUILDER EXPORT CONFERENCEORBOOTHATTENDEES */
350 
351  /* BEGIN MODULEBUILDER EXPORT CONFERENCEORBOOTH */
352  /*
353  $r++;
354  $this->export_code[$r] = $this->rights_class.'_'.$r;
355  $this->export_label[$r] = "ExportDataset_event1";
356  $this->export_permission[$r] = array(array("agenda", "export"));
357  $this->export_fields_array[$r] = array('ac.id'=>"IdAgenda", 'ac.ref_ext'=>"ExternalRef", 'ac.datec'=>"DateCreation", 'ac.datep'=>"DateActionBegin",
358  'ac.datep2'=>"DateActionEnd", 'ac.label'=>"Title", 'ac.note'=>"Note", 'ac.percent'=>"Percent", 'ac.durationp'=>"Duration",
359  'cac.libelle'=>"ActionType",
360  's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town',
361  'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6',
362  's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
363  'p.ref' => 'ProjectRef',
364  );
365  $this->export_TypeFields_array[$r] = array('ac.ref_ext'=>"Text", 'ac.datec'=>"Date", 'ac.datep'=>"Date",
366  'ac.datep2'=>"Date", 'ac.label'=>"Text", 'ac.note'=>"Text", 'ac.percent'=>"Numeric",
367  'ac.durationp'=>"Duree",
368  'cac.libelle'=>"List:c_actioncomm:libelle:libelle",
369  's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text',
370  'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text',
371  's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
372  'p.ref' => 'Text',
373  );
374  $this->export_entities_array[$r] = array('ac.id'=>"action", 'ac.ref_ext'=>"action", 'ac.datec'=>"action", 'ac.datep'=>"action",
375  'ac.datep2'=>"action", 'ac.label'=>"action", 'ac.note'=>"action", 'ac.percent'=>"action", 'ac.durationp'=>"action",
376  'cac.libelle'=>"action",
377  's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company',
378  'co.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company',
379  's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company',
380  'p.ref' => 'project',
381  );
382 
383  $keyforselect = 'actioncomm'; $keyforelement = 'action'; $keyforaliasextra = 'extra';
384  include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
385 
386  $this->export_sql_start[$r] = 'SELECT DISTINCT ';
387  $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'actioncomm as ac';
388  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_extrafields as extra ON ac.id = extra.fk_object';
389  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id';
390  if (!empty($user) && empty($user->rights->agenda->allactions->read)) {
391  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm';
392  }
393  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid';
394  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid';
395  if (!empty($user) && empty($user->rights->societe->client->voir)) {
396  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
397  }
398  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
399  $this->export_sql_end[$r] .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = ac.fk_project";
400  $this->export_sql_end[$r] .= " WHERE ac.entity IN (".getEntity('agenda').")";
401  $this->export_sql_end[$r] .= " AND ac.code = 'AC_EO_INDOORCONF'";
402  if (empty($user->rights->societe->client->voir)) {
403  $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR ac.fk_soc IS NULL)';
404  }
405  if (empty($user->rights->agenda->allactions->read)) {
406  $this->export_sql_end[$r] .= ' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);
407  }
408  $this->export_sql_order[$r] = ' ORDER BY ac.datep';
409  */
410  /* END MODULEBUILDER EXPORT CONFERENCEORBOOTH */
411 
412  // Imports profiles provided by this module
413  $r = 1;
414  /* BEGIN MODULEBUILDER IMPORT CONFERENCEORBOOTH */
415  /* END MODULEBUILDER IMPORT CONFERENCEORBOOTH */
416  }
417 
426  public function init($options = '')
427  {
428  global $conf, $langs, $user;
429 
430  /*$result = run_sql(DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_c_email_templates.sql', 1, '', 1);
431  if ($result <= 0) {
432  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')
433  }
434  TODO Instead use the array merge of the sql found into llx_c_email_templates for this module
435  */
436 
437  // Permissions
438  $this->remove($options);
439 
440  $sql = array();
441 
442  // Document templates
443  $moduledir = 'eventorganization';
444  $myTmpObjects = array();
445  $myTmpObjects['ConferenceOrBooth'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
446 
447  foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
448  if ($myTmpObjectKey == 'ConferenceOrBooth') {
449  continue;
450  }
451  if ($myTmpObjectArray['includerefgeneration']) {
452  $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/eventorganization/template_conferenceorbooths.odt';
453  $dirodt = DOL_DATA_ROOT.'/doctemplates/eventorganization';
454  $dest = $dirodt.'/template_conferenceorbooths.odt';
455 
456  if (file_exists($src) && !file_exists($dest)) {
457  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
458  dol_mkdir($dirodt);
459  $result = dol_copy($src, $dest, 0, 0);
460  if ($result < 0) {
461  $langs->load("errors");
462  $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
463  return 0;
464  }
465  }
466 
467  $sql = array_merge($sql, array(
468  "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity),
469  "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."','".$this->db->escape(strtolower($myTmpObjectKey))."',".((int) $conf->entity).")",
470  "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),
471  "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")"
472  ));
473  }
474  }
475 
476  $init = $this->_init($sql, $options);
477 
478 
479  // Insert some vars
480  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
481  $formmail = new FormMail($this->db);
482 
483  $template = $formmail->getEMailTemplate($this->db, 'conferenceorbooth', $user, $langs, 0, 1, '(EventOrganizationEmailAskConf)');
484  if ($template->id > 0) {
485  dolibarr_set_const($this->db, 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_CONF', $template->id, 'chaine', 0, '', $conf->entity);
486  }
487  $template = $formmail->getEMailTemplate($this->db, 'conferenceorbooth', $user, $langs, 0, 1, '(EventOrganizationEmailAskBooth)');
488  if ($template->id > 0) {
489  dolibarr_set_const($this->db, 'EVENTORGANIZATION_TEMPLATE_EMAIL_ASK_BOOTH', $template->id, 'chaine', 0, '', $conf->entity);
490  }
491  $template = $formmail->getEMailTemplate($this->db, 'conferenceorbooth', $user, $langs, 0, 1, '(EventOrganizationEmailBoothPayment)');
492  if ($template->id > 0) {
493  dolibarr_set_const($this->db, 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH', $template->id, 'chaine', 0, '', $conf->entity);
494  }
495  $template = $formmail->getEMailTemplate($this->db, 'conferenceorbooth', $user, $langs, 0, 1, '(EventOrganizationEmailRegistrationPayment)');
496  if ($template->id > 0) {
497  dolibarr_set_const($this->db, 'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT', $template->id, 'chaine', 0, '', $conf->entity);
498  }
499 
500  return $init;
501  }
502 
511  public function remove($options = '')
512  {
513  $sql = array();
514  return $this->_remove($sql, $options);
515  }
516 }
db
$conf db
API class for accounts.
Definition: inc.php:41
description
print *****$script_file(".$version.") pid cd cd cd description as description
Definition: email_expire_services_to_customers.php:83
modEventOrganization
Description and activation class for module EventOrganization This module is base on this specificati...
Definition: modEventOrganization.class.php:34
name
$conf db name
Definition: repair.php:122
DolibarrModules\_remove
_remove($array_sql, $options='')
Disable function.
Definition: DolibarrModules.class.php:496
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:4024
modEventOrganization\__construct
__construct($db)
Constructor.
Definition: modEventOrganization.class.php:41
dol_copy
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
Definition: files.lib.php:713
modEventOrganization\init
init($options='')
Function called when module is enabled.
Definition: modEventOrganization.class.php:426
DolibarrModules\_init
_init($array_sql, $options='')
Enables a module.
Definition: DolibarrModules.class.php:397
dolibarr_set_const
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:632
FormMail
Classe permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new For...
Definition: html.formmail.class.php:38
dol_mkdir
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Definition: functions.lib.php:6789
DolibarrModules
Class DolibarrModules.
Definition: DolibarrModules.class.php:37