dolibarr  20.0.0-beta
modAgenda.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003,2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4  * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
6  * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
7  * Copyright (C) 2009-2011 Regis Houssin <regis.houssin@inodbox.com>
8  * Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr>
9  * Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
10  * Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es>
11  * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <https://www.gnu.org/licenses/>.
25  */
26 
34 include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
35 
40 {
46  public function __construct($db)
47  {
48  global $conf, $user;
49 
50  $this->db = $db;
51  $this->numero = 2400;
52 
53  $this->family = "projects";
54  $this->module_position = '16';
55  // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
56  $this->name = preg_replace('/^mod/i', '', get_class($this));
57  $this->description = "Follow events or rendez-vous. Record manual events into Agendas or let application record automatic events for log tracking.";
58  // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
59  $this->version = 'dolibarr';
60  // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
61  $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
62  $this->picto = 'action';
63 
64  // Data directories to create when module is enabled
65  $this->dirs = array("/agenda/temp");
66 
67  // Config pages
68  $this->config_page_url = array("agenda_other.php");
69 
70  // Dependencies
71  $this->hidden = false; // A condition to hide module
72  $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
73  $this->requiredby = array(); // List of module ids to disable if this one is disabled
74  $this->conflictwith = array(); // List of module class names as string this module is in conflict with
75  $this->langfiles = array("companies","project");
76  $this->phpmin = array(7, 0); // Minimum version of PHP required by module
77  $this->enabled_bydefault = true; // Will be enabled during install
78 
79  // Module parts
80  $this->module_parts = array();
81 
82  // Constants
83  //-----------
84  // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
85  // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
86  // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
87  // );
88  $this->const = array();
89  //$this->const[] = array('AGENDA_DEFAULT_FILTER_TYPE', 'chaine', 'AC_NON_AUTO', 'Default filter for type of event on agenda', 0, 'current');
90  $sqlreadactions = "SELECT code, label, description FROM ".MAIN_DB_PREFIX."c_action_trigger ORDER by rang";
91  $resql = $this->db->query($sqlreadactions);
92  if ($resql) {
93  while ($obj = $this->db->fetch_object($resql)) {
94  //if (preg_match('/_CREATE$/',$obj->code) && (! in_array($obj->code, array('COMPANY_CREATE','PRODUCT_CREATE','TASK_CREATE')))) continue; // We don't track such events (*_CREATE) by default, we prefer validation (except thirdparty/product/task creation because there is no validation).
95  if (preg_match('/^TASK_/', $obj->code)) {
96  continue; // We don't track such events by default.
97  }
98  //if (preg_match('/^_MODIFY/',$obj->code)) continue; // We don't track such events by default.
99  $this->const[] = array('MAIN_AGENDA_ACTIONAUTO_'.$obj->code, "chaine", "1", '', 0, 'current');
100  }
101  } else {
102  dol_print_error($this->db->lasterror());
103  }
104 
105  // New pages on tabs
106  // -----------------
107  $this->tabs = array();
108 
109  // Boxes
110  //------
111  $this->boxes = array(
112  0 => array('file' => 'box_actions.php', 'enabledbydefaulton' => 'Home'),
113  1 => array('file' => 'box_actions_future.php', 'enabledbydefaulton' => 'Home')
114  );
115 
116  // Cronjobs
117  //------------
118  $datestart = dol_now();
119  $this->cronjobs = array(
120  0 => array('label' => 'SendEmailsReminders', 'jobtype' => 'method', 'class' => 'comm/action/class/actioncomm.class.php', 'objectname' => 'ActionComm', 'method' => 'sendEmailsReminder', 'parameters' => '', 'comment' => 'SendEMailsReminder', 'frequency' => 5, 'unitfrequency' => 60, 'priority' => 10, 'status' => 1, 'test' => 'isModEnabled("agenda")', 'datestart' => $datestart),
121  );
122 
123  // Permissions
124  //------------
125  $this->rights = array();
126  $this->rights_class = 'agenda';
127  $r = 0;
128 
129  // $this->rights[$r][0] Id permission (unique tous modules confondus)
130  // $this->rights[$r][1] Libelle par default si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)
131  // $this->rights[$r][2] Non utilise
132  // $this->rights[$r][3] 1=Permis par default, 0=Non permis par default
133  // $this->rights[$r][4] Niveau 1 pour nommer permission dans code
134  // $this->rights[$r][5] Niveau 2 pour nommer permission dans code
135  // $r++;
136 
137  $this->rights[$r][0] = 2401;
138  $this->rights[$r][1] = 'Read actions/tasks linked to his account';
139  $this->rights[$r][2] = 'r';
140  $this->rights[$r][3] = 0;
141  $this->rights[$r][4] = 'myactions';
142  $this->rights[$r][5] = 'read';
143  $r++;
144 
145  $this->rights[$r][0] = 2402;
146  $this->rights[$r][1] = 'Create/modify actions/tasks linked to his account';
147  $this->rights[$r][2] = 'w';
148  $this->rights[$r][3] = 0;
149  $this->rights[$r][4] = 'myactions';
150  $this->rights[$r][5] = 'create';
151  $r++;
152 
153  $this->rights[$r][0] = 2403;
154  $this->rights[$r][1] = 'Delete actions/tasks linked to his account';
155  $this->rights[$r][2] = 'w';
156  $this->rights[$r][3] = 0;
157  $this->rights[$r][4] = 'myactions';
158  $this->rights[$r][5] = 'delete';
159  $r++;
160 
161  $this->rights[$r][0] = 2411;
162  $this->rights[$r][1] = 'Read actions/tasks of others';
163  $this->rights[$r][2] = 'r';
164  $this->rights[$r][3] = 0;
165  $this->rights[$r][4] = 'allactions';
166  $this->rights[$r][5] = 'read';
167  $r++;
168 
169  $this->rights[$r][0] = 2412;
170  $this->rights[$r][1] = 'Create/modify actions/tasks of others';
171  $this->rights[$r][2] = 'w';
172  $this->rights[$r][3] = 0;
173  $this->rights[$r][4] = 'allactions';
174  $this->rights[$r][5] = 'create';
175  $r++;
176 
177  $this->rights[$r][0] = 2413;
178  $this->rights[$r][1] = 'Delete actions/tasks of others';
179  $this->rights[$r][2] = 'w';
180  $this->rights[$r][3] = 0;
181  $this->rights[$r][4] = 'allactions';
182  $this->rights[$r][5] = 'delete';
183  $r++;
184 
185  $this->rights[$r][0] = 2414;
186  $this->rights[$r][1] = 'Export actions/tasks of others';
187  $this->rights[$r][2] = 'w';
188  $this->rights[$r][3] = 0;
189  $this->rights[$r][4] = 'export';
190 
191  // Main menu entries
192  $this->menu = array(); // List of menus to add
193  $r = 0;
194 
195  // Add here entries to declare new menus
196  // Example to declare the Top Menu entry:
197  // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu
198  // 'type'=>'top', // This is a Top menu entry
199  // 'titre'=>'MyModule top menu',
200  // 'mainmenu'=>'mymodule',
201  // 'url'=>'/mymodule/pagetop.php',
202  // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
203  // 'position'=>100,
204  // 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
205  // 'perms'=>'1', // Use 'perms'=>'$user->hasRight('mymodule', 'level1', 'level2') if you want your menu with a permission rules
206  // 'target'=>'',
207  // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
208  // $r++;
209  $this->menu[$r] = array(
210  'fk_menu' => 0,
211  'type' => 'top',
212  'titre' => 'TMenuAgenda',
213  'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth"'),
214  'mainmenu' => 'agenda',
215  'url' => '/comm/action/index.php',
216  'langs' => 'agenda',
217  'position' => 86,
218  'perms' => '$user->hasRight("agenda", "myactions", "read") || $user->hasRight("resource", "read")',
219  'enabled' => 'isModEnabled("agenda") || isModEnabled("resource")',
220  'target' => '',
221  'user' => 2,
222  );
223  $r++;
224 
225  $this->menu[$r] = array(
226  'fk_menu' => 'r=0',
227  'type' => 'left',
228  'titre' => 'Actions',
229  'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
230  'mainmenu' => 'agenda',
231  'url' => '/comm/action/index.php?mainmenu=agenda&amp;leftmenu=agenda',
232  'langs' => 'agenda',
233  'position' => 100,
234  'perms' => '$user->hasRight("agenda", "myactions", "read")',
235  'enabled' => 'isModEnabled("agenda")',
236  'target' => '',
237  'user' => 2,
238  );
239  $r++;
240  $this->menu[$r] = array(
241  'fk_menu' => 'r=1',
242  'type' => 'left',
243  'titre' => 'NewAction',
244  'mainmenu' => 'agenda',
245  'url' => '/comm/action/card.php?mainmenu=agenda&amp;leftmenu=agenda&amp;action=create',
246  'langs' => 'commercial',
247  'position' => 101,
248  'perms' => '($user->hasRight("agenda", "myactions", "create") || $user->hasRight("agenda", "allactions", "create"))',
249  'enabled' => 'isModEnabled("agenda")',
250  'target' => '',
251  'user' => 2
252  );
253  $r++;
254  // Calendar
255  $this->menu[$r] = array(
256  'fk_menu' => 'r=1',
257  'type' => 'left',
258  'titre' => 'Calendar',
259  'mainmenu' => 'agenda',
260  'url' => '/comm/action/index.php?action=default&amp;mainmenu=agenda&amp;leftmenu=agenda',
261  'langs' => 'agenda',
262  'position' => 140,
263  'perms' => '$user->hasRight("agenda", "myactions", "read")',
264  'enabled' => 'isModEnabled("agenda")',
265  'target' => '',
266  'user' => 2
267  );
268  $r++;
269  $this->menu[$r] = array(
270  'fk_menu' => 'r=3',
271  'type' => 'left',
272  'titre' => 'MenuToDoMyActions',
273  'mainmenu' => 'agenda',
274  'url' => '/comm/action/index.php?action=default&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filter=mine',
275  'langs' => 'agenda',
276  'position' => 141,
277  'perms' => '$user->hasRight("agenda", "myactions", "read")',
278  'enabled' => 'isModEnabled("agenda")',
279  'target' => '',
280  'user' => 2
281  );
282  $r++;
283  $this->menu[$r] = array(
284  'fk_menu' => 'r=3',
285  'type' => 'left',
286  'titre' => 'MenuDoneMyActions',
287  'mainmenu' => 'agenda',
288  'url' => '/comm/action/index.php?action=default&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filter=mine',
289  'langs' => 'agenda',
290  'position' => 142,
291  'perms' => '$user->hasRight("agenda", "myactions", "read")',
292  'enabled' => 'isModEnabled("agenda")',
293  'target' => '',
294  'user' => 2
295  );
296  $r++;
297  $this->menu[$r] = array(
298  'fk_menu' => 'r=3',
299  'type' => 'left',
300  'titre' => 'MenuToDoActions',
301  'mainmenu' => 'agenda',
302  'url' => '/comm/action/index.php?action=default&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filtert=-1',
303  'langs' => 'agenda',
304  'position' => 143,
305  'perms' => '$user->hasRight("agenda", "allactions", "read")',
306  'enabled' => 'isModEnabled("agenda")',
307  'target' => '',
308  'user' => 2
309  );
310  $r++;
311  $this->menu[$r] = array(
312  'fk_menu' => 'r=3',
313  'type' => 'left',
314  'titre' => 'MenuDoneActions',
315  'mainmenu' => 'agenda',
316  'url' => '/comm/action/index.php?action=default&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filtert=-1',
317  'langs' => 'agenda',
318  'position' => 144,
319  'perms' => '$user->hasRight("agenda", "allactions", "read")',
320  'enabled' => 'isModEnabled("agenda")',
321  'target' => '',
322  'user' => 2
323  );
324 
325  // List
326  $r++;
327  $this->menu[$r] = array(
328  'fk_menu' => 'r=1',
329  'type' => 'left',
330  'titre' => 'List',
331  'mainmenu' => 'agenda',
332  'url' => '/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda',
333  'langs' => 'agenda',
334  'position' => 110,
335  'perms' => '$user->hasRight("agenda", "myactions", "read")',
336  'enabled' => 'isModEnabled("agenda")',
337  'target' => '',
338  'user' => 2
339  );
340  $r++;
341  $this->menu[$r] = array(
342  'fk_menu' => 'r=8',
343  'type' => 'left',
344  'titre' => 'MenuToDoMyActions',
345  'mainmenu' => 'agenda',
346  'url' => '/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filter=mine',
347  'langs' => 'agenda',
348  'position' => 111,
349  'perms' => '$user->hasRight("agenda", "myactions", "read")',
350  'enabled' => 'isModEnabled("agenda")',
351  'target' => '',
352  'user' => 2
353  );
354  $r++;
355  $this->menu[$r] = array(
356  'fk_menu' => 'r=8',
357  'type' => 'left',
358  'titre' => 'MenuDoneMyActions',
359  'mainmenu' => 'agenda',
360  'url' => '/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filter=mine',
361  'langs' => 'agenda',
362  'position' => 112,
363  'perms' => '$user->hasRight("agenda", "myactions", "read")',
364  'enabled' => 'isModEnabled("agenda")',
365  'target' => '',
366  'user' => 2
367  );
368  $r++;
369  $this->menu[$r] = array(
370  'fk_menu' => 'r=8',
371  'type' => 'left',
372  'titre' => 'MenuToDoActions',
373  'mainmenu' => 'agenda',
374  'url' => '/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filtert=-1',
375  'langs' => 'agenda',
376  'position' => 113,
377  'perms' => '$user->hasRight("agenda", "allactions", "read")',
378  'enabled' => 'isModEnabled("agenda")',
379  'target' => '',
380  'user' => 2
381  );
382  $r++;
383  $this->menu[$r] = array(
384  'fk_menu' => 'r=8',
385  'type' => 'left',
386  'titre' => 'MenuDoneActions',
387  'mainmenu' => 'agenda',
388  'url' => '/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filtert=-1',
389  'langs' => 'agenda',
390  'position' => 114,
391  'perms' => '$user->hasRight("agenda", "allactions", "read")',
392  'enabled' => 'isModEnabled("agenda")',
393  'target' => '',
394  'user' => 2
395  );
396  $r++;
397  // Reports
398  $this->menu[$r] = array(
399  'fk_menu' => 'r=1',
400  'type' => 'left',
401  'titre' => 'Reportings',
402  'mainmenu' => 'agenda',
403  'url' => '/comm/action/rapport/index.php?mainmenu=agenda&amp;leftmenu=agenda',
404  'langs' => 'agenda',
405  'position' => 160,
406  'perms' => '$user->hasRight("agenda", "allactions", "read")',
407  'enabled' => 'isModEnabled("agenda")',
408  'target' => '',
409  'user' => 2
410  );
411  $r++;
412  // Categories
413  $this->menu[$r] = array(
414  'fk_menu' => 'r=1',
415  'type' => 'left',
416  'titre' => 'Categories',
417  'mainmenu' => 'agenda',
418  'url' => '/categories/index.php?mainmenu=agenda&amp;leftmenu=agenda&type=10',
419  'langs' => 'agenda',
420  'position' => 170,
421  'perms' => '$user->hasRight("agenda", "allactions", "read")',
422  'enabled' => 'isModEnabled("category")',
423  'target' => '',
424  'user' => 2
425  );
426  $r++;
427 
428 
429  // Exports
430  //--------
431  $r = 0;
432 
433  $r++;
434  $this->export_code[$r] = $this->rights_class.'_'.$r;
435  $this->export_label[$r] = "ExportDataset_event1";
436  $this->export_permission[$r] = array(array("agenda", "export"));
437  $this->export_fields_array[$r] = array('ac.id' => "IdAgenda", 'ac.ref_ext' => "ExternalRef",'ac.ref' => "Ref", 'ac.datec' => "DateCreation", 'ac.datep' => "DateActionBegin",
438  'ac.datep2' => "DateActionEnd", 'ac.location' => 'Location', 'ac.label' => "Title", 'ac.note' => "Note", 'ac.percent' => "Percentage", 'ac.durationp' => "Duration",
439  'ac.fk_user_author' => 'CreatedById', 'ac.fk_user_action' => 'ActionsOwnedBy', 'ac.fk_user_mod' => 'ModifiedBy', 'ac.transparency' => "Transparency", 'ac.priority' => "Priority", 'ac.fk_element' => "ElementID", 'ac.elementtype' => "ElementType",
440  'cac.libelle' => "ActionType", 'cac.code' => "Code",
441  's.rowid' => "IdCompany", 's.nom' => 'CompanyName', 's.address' => 'Address', 's.zip' => 'Zip', 's.town' => 'Town',
442  'co.code' => 'CountryCode', 's.phone' => 'Phone', 's.siren' => 'ProfId1', 's.siret' => 'ProfId2', 's.ape' => 'ProfId3', 's.idprof4' => 'ProfId4', 's.idprof5' => 'ProfId5', 's.idprof6' => 'ProfId6',
443  's.code_compta' => 'CustomerAccountancyCode', 's.code_compta_fournisseur' => 'SupplierAccountancyCode', 's.tva_intra' => 'VATIntra',
444  'p.ref' => 'ProjectRef',
445  );
446  // Add multicompany field
447  if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) {
448  $nbofallowedentities = count(explode(',', getEntity('agenda')));
449  if (isModEnabled('multicompany') && $nbofallowedentities > 1) {
450  $this->export_fields_array[$r]['ac.entity'] = 'Entity';
451  }
452  }
453  $this->export_TypeFields_array[$r] = array('ac.ref_ext' => "Text", 'ac.ref' => "Text", 'ac.datec' => "Date", 'ac.datep' => "Date",
454  'ac.datep2' => "Date", 'ac.location' => 'Text', 'ac.label' => "Text", 'ac.note' => "Text", 'ac.percent' => "Numeric",
455  'ac.durationp' => "Duree",'ac.fk_user_author' => 'Numeric', 'ac.fk_user_action' => 'Numeric', 'ac.fk_user_mod' => 'Numeric', 'ac.transparency' => "Numeric", 'ac.priority' => "Numeric", 'ac.fk_element' => "Numeric", 'ac.elementtype' => "Text",
456  'cac.libelle' => "List:c_actioncomm:libelle:libelle", 'cac.code' => "Text",
457  's.nom' => 'Text', 's.address' => 'Text', 's.zip' => 'Text', 's.town' => 'Text',
458  'co.code' => 'Text', 's.phone' => 'Text', 's.siren' => 'Text', 's.siret' => 'Text', 's.ape' => 'Text', 's.idprof4' => 'Text', 's.idprof5' => 'Text', 's.idprof6' => 'Text',
459  's.code_compta' => 'Text', 's.code_compta_fournisseur' => 'Text', 's.tva_intra' => 'Text',
460  'p.ref' => 'Text', 'ac.entity' => 'List:entity:label:rowid'
461 
462  );
463  $this->export_entities_array[$r] = array('ac.id' => "action", 'ac.ref_ext' => "action", 'ac.ref' => "action", 'ac.datec' => "action", 'ac.datep' => "action",
464  'ac.datep2' => "action", 'ac.location' => 'action', 'ac.label' => "action", 'ac.note' => "action", 'ac.percent' => "action", 'ac.durationp' => "action",'ac.fk_user_author' => 'user', 'ac.fk_user_action' => 'user', 'ac.fk_user_mod' => 'user', 'ac.transparency' => "action", 'ac.priority' => "action", 'ac.fk_element' => "action", 'ac.elementtype' => "action",
465  's.rowid' => "company", 's.nom' => 'company', 's.address' => 'company', 's.zip' => 'company', 's.town' => 'company',
466  'co.code' => 'company', 's.phone' => 'company', 's.siren' => 'company', 's.siret' => 'company', 's.ape' => 'company', 's.idprof4' => 'company', 's.idprof5' => 'company', 's.idprof6' => 'company',
467  's.code_compta' => 'company', 's.code_compta_fournisseur' => 'company', 's.tva_intra' => 'company',
468  'p.ref' => 'project',
469  );
470 
471  $keyforselect = 'actioncomm';
472  $keyforelement = 'action';
473  $keyforaliasextra = 'extra';
474  include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
475 
476  $this->export_sql_start[$r] = 'SELECT DISTINCT ';
477  $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'actioncomm as ac';
478  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_extrafields as extra ON ac.id = extra.fk_object';
479  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id';
480  if (!empty($user) && !$user->hasRight('agenda', 'allactions', 'read')) {
481  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm';
482  }
483  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid';
484  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid';
485  if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {
486  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
487  }
488  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON ac.fk_user_author = uc.rowid';
489  $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
490  $this->export_sql_end[$r] .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = ac.fk_project";
491  $this->export_sql_end[$r] .= ' WHERE ac.entity IN ('.getEntity('agenda').')';
492  if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {
493  $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR ac.fk_soc IS NULL)';
494  }
495  if (!empty($user) && !$user->hasRight('agenda', 'allactions', 'read')) {
496  $this->export_sql_end[$r] .= ' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);
497  }
498  $this->export_sql_end[$r] .= ' AND ac.entity IN ('.getEntity('agenda').')';
499  $this->export_sql_order[$r] = ' ORDER BY ac.datep';
500 
501  // Imports
502  $r = 0;
503 
504  // Import Events
505  $r++;
506  $this->import_code[$r] = $this->rights_class.'_'.$r;
507  $this->import_label[$r] = "ExportDataset_event1";
508  $this->import_icon[$r] = $this->picto;
509  $this->import_entities_array[$r] = array();
510  $this->import_tables_array[$r] = array('ac' => MAIN_DB_PREFIX.'actioncomm', 'extra' => MAIN_DB_PREFIX.'actioncomm_extrafields');
511  $this->import_tables_creator_array[$r] = array('ac' => 'fk_user_author'); // Fields to store import user id
512  $this->import_fields_array[$r] = array(
513  'ac.ref_ext' => 'ExternalRef',
514  'ac.ref' => 'Ref*',
515  'ac.datec' => 'DateCreation',
516  'ac.datep' => 'DateActionBegin',
517  'ac.datep2' => 'DateActionEnd',
518  'ac.location' => 'Location',
519  'ac.label' => 'Title*',
520  'ac.note' => 'Note',
521  'ac.percent' => 'Percentage*',
522  'ac.transparency' => 'Transparency',
523  'ac.priority' => 'Priority',
524  'ac.fk_action' => 'Code*',
525  'ac.fk_soc' => 'ThirdPartyName',
526  'ac.fk_project' => 'ProjectRef',
527  'ac.fk_user_mod' => 'ModifiedBy',
528  'ac.fk_user_action' => 'AffectedTo*',
529  'ac.fk_element' => 'ElementID',
530  'ac.elementtype' => 'ElementType',
531  );
532  $import_sample = array();
533 
534  // Add extra fields
535  $import_extrafield_sample = array();
536  $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'actioncomm' AND entity IN (0, ".$conf->entity.")";
537  $resql = $this->db->query($sql);
538 
539  if ($resql) {
540  while ($obj = $this->db->fetch_object($resql)) {
541  $fieldname = 'extra.'.$obj->name;
542  $fieldlabel = ucfirst($obj->label);
543  $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
544  }
545  }
546  // End add extra fields
547 
548  $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
549  $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'actioncomm');
550  //$this->import_updatekeys_array[$r] = array('ac.fk_user_creat' => 'User');
551  $this->import_convertvalue_array[$r] = array(
552  'ac.fk_soc' => array(
553  'rule' => 'fetchidfromref',
554  'file' => '/societe/class/societe.class.php',
555  'class' => 'Societe',
556  'method' => 'fetch',
557  'element' => 'ThirdParty'
558  ),
559  'ac.fk_user_action' => array(
560  'rule' => 'fetchidfromref',
561  'file' => '/user/class/user.class.php',
562  'class' => 'User',
563  'method' => 'fetch',
564  'element' => 'user'
565  ),
566  'ac.fk_user_mod' => array(
567  'rule' => 'fetchidfromref',
568  'file' => '/user/class/user.class.php',
569  'class' => 'User',
570  'method' => 'fetch',
571  'element' => 'user'
572  ),
573  'ac.fk_action' => array(
574  'rule' => 'fetchidfromcodeid',
575  'classfile' => '/comm/action/class/cactioncomm.class.php',
576  'class' => 'CActionComm',
577  'method' => 'fetch',
578  'dict' => 'DictionaryActions'
579  )
580  );
581 
582  // Import Event Extra Fields
583  $keyforselect = 'actioncomm';
584  $keyforelement = 'action';
585  $keyforaliasextra = 'extra';
586  include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
587  }
588 }
Class DolibarrModules.
Class to describe and enable/disable module Agenda.
__construct($db)
Constructor.
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.
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_now($mode='auto')
Return date for now.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:126