dolibarr 20.0.2
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
34include_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 //$this->const[] = array("MAIN_AGENDA_XCAL_EXPORTKEY", "chaine", "123456", "Securekey for the public link");
105
106 // New pages on tabs
107 // -----------------
108 $this->tabs = array();
109
110 // Boxes
111 //------
112 $this->boxes = array(
113 0 => array('file' => 'box_actions.php', 'enabledbydefaulton' => 'Home'),
114 1 => array('file' => 'box_actions_future.php', 'enabledbydefaulton' => 'Home')
115 );
116
117 // Cronjobs
118 //------------
119 $datestart = dol_now();
120 $this->cronjobs = array(
121 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),
122 );
123
124 // Permissions
125 //------------
126 $this->rights = array();
127 $this->rights_class = 'agenda';
128 $r = 0;
129
130 // $this->rights[$r][0] Id permission (unique tous modules confondus)
131 // $this->rights[$r][1] Libelle par default si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)
132 // $this->rights[$r][2] Non utilise
133 // $this->rights[$r][3] 1=Permis par default, 0=Non permis par default
134 // $this->rights[$r][4] Niveau 1 pour nommer permission dans code
135 // $this->rights[$r][5] Niveau 2 pour nommer permission dans code
136 // $r++;
137
138 $this->rights[$r][0] = 2401;
139 $this->rights[$r][1] = 'Read actions/tasks linked to his account';
140 $this->rights[$r][2] = 'r';
141 $this->rights[$r][3] = 0;
142 $this->rights[$r][4] = 'myactions';
143 $this->rights[$r][5] = 'read';
144 $r++;
145
146 $this->rights[$r][0] = 2402;
147 $this->rights[$r][1] = 'Create/modify actions/tasks linked to his account';
148 $this->rights[$r][2] = 'w';
149 $this->rights[$r][3] = 0;
150 $this->rights[$r][4] = 'myactions';
151 $this->rights[$r][5] = 'create';
152 $r++;
153
154 $this->rights[$r][0] = 2403;
155 $this->rights[$r][1] = 'Delete actions/tasks linked to his account';
156 $this->rights[$r][2] = 'w';
157 $this->rights[$r][3] = 0;
158 $this->rights[$r][4] = 'myactions';
159 $this->rights[$r][5] = 'delete';
160 $r++;
161
162 $this->rights[$r][0] = 2411;
163 $this->rights[$r][1] = 'Read actions/tasks of others';
164 $this->rights[$r][2] = 'r';
165 $this->rights[$r][3] = 0;
166 $this->rights[$r][4] = 'allactions';
167 $this->rights[$r][5] = 'read';
168 $r++;
169
170 $this->rights[$r][0] = 2412;
171 $this->rights[$r][1] = 'Create/modify actions/tasks of others';
172 $this->rights[$r][2] = 'w';
173 $this->rights[$r][3] = 0;
174 $this->rights[$r][4] = 'allactions';
175 $this->rights[$r][5] = 'create';
176 $r++;
177
178 $this->rights[$r][0] = 2413;
179 $this->rights[$r][1] = 'Delete actions/tasks of others';
180 $this->rights[$r][2] = 'w';
181 $this->rights[$r][3] = 0;
182 $this->rights[$r][4] = 'allactions';
183 $this->rights[$r][5] = 'delete';
184 $r++;
185
186 $this->rights[$r][0] = 2414;
187 $this->rights[$r][1] = 'Export actions/tasks of others';
188 $this->rights[$r][2] = 'w';
189 $this->rights[$r][3] = 0;
190 $this->rights[$r][4] = 'export';
191
192 // Main menu entries
193 $this->menu = array(); // List of menus to add
194 $r = 0;
195
196 // Add here entries to declare new menus
197 // Example to declare the Top Menu entry:
198 // $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu
199 // 'type'=>'top', // This is a Top menu entry
200 // 'titre'=>'MyModule top menu',
201 // 'mainmenu'=>'mymodule',
202 // 'url'=>'/mymodule/pagetop.php',
203 // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
204 // 'position'=>100,
205 // 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
206 // 'perms'=>'1', // Use 'perms'=>'$user->hasRight('mymodule', 'level1', 'level2') if you want your menu with a permission rules
207 // 'target'=>'',
208 // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
209 // $r++;
210 $this->menu[$r] = array(
211 'fk_menu' => 0,
212 'type' => 'top',
213 'titre' => 'TMenuAgenda',
214 'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth"'),
215 'mainmenu' => 'agenda',
216 'url' => '/comm/action/index.php',
217 'langs' => 'agenda',
218 'position' => 86,
219 'perms' => '$user->hasRight("agenda", "myactions", "read") || $user->hasRight("resource", "read")',
220 'enabled' => 'isModEnabled("agenda") || isModEnabled("resource")',
221 'target' => '',
222 'user' => 2,
223 );
224 $r++;
225
226 $this->menu[$r] = array(
227 'fk_menu' => 'r=0',
228 'type' => 'left',
229 'titre' => 'Actions',
230 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
231 'mainmenu' => 'agenda',
232 'url' => '/comm/action/index.php?mainmenu=agenda&amp;leftmenu=agenda',
233 'langs' => 'agenda',
234 'position' => 100,
235 'perms' => '$user->hasRight("agenda", "myactions", "read")',
236 'enabled' => 'isModEnabled("agenda")',
237 'target' => '',
238 'user' => 2,
239 );
240 $r++;
241 $this->menu[$r] = array(
242 'fk_menu' => 'r=1',
243 'type' => 'left',
244 'titre' => 'NewAction',
245 'mainmenu' => 'agenda',
246 'url' => '/comm/action/card.php?mainmenu=agenda&amp;leftmenu=agenda&amp;action=create',
247 'langs' => 'commercial',
248 'position' => 101,
249 'perms' => '($user->hasRight("agenda", "myactions", "create") || $user->hasRight("agenda", "allactions", "create"))',
250 'enabled' => 'isModEnabled("agenda")',
251 'target' => '',
252 'user' => 2
253 );
254 $r++;
255 // Calendar
256 $this->menu[$r] = array(
257 'fk_menu' => 'r=1',
258 'type' => 'left',
259 'titre' => 'Calendar',
260 'mainmenu' => 'agenda',
261 'url' => '/comm/action/index.php?mainmenu=agenda&amp;leftmenu=agenda',
262 'langs' => 'agenda',
263 'position' => 140,
264 'perms' => '$user->hasRight("agenda", "myactions", "read")',
265 'enabled' => 'isModEnabled("agenda")',
266 'target' => '',
267 'user' => 2
268 );
269 $r++;
270 $this->menu[$r] = array(
271 'fk_menu' => 'r=3',
272 'type' => 'left',
273 'titre' => 'MenuToDoMyActions',
274 'mainmenu' => 'agenda',
275 'url' => '/comm/action/index.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filter=mine',
276 'langs' => 'agenda',
277 'position' => 141,
278 'perms' => '$user->hasRight("agenda", "myactions", "read")',
279 'enabled' => 'isModEnabled("agenda")',
280 'target' => '',
281 'user' => 2
282 );
283 $r++;
284 $this->menu[$r] = array(
285 'fk_menu' => 'r=3',
286 'type' => 'left',
287 'titre' => 'MenuDoneMyActions',
288 'mainmenu' => 'agenda',
289 'url' => '/comm/action/index.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filter=mine',
290 'langs' => 'agenda',
291 'position' => 142,
292 'perms' => '$user->hasRight("agenda", "myactions", "read")',
293 'enabled' => 'isModEnabled("agenda")',
294 'target' => '',
295 'user' => 2
296 );
297 $r++;
298 $this->menu[$r] = array(
299 'fk_menu' => 'r=3',
300 'type' => 'left',
301 'titre' => 'MenuToDoActions',
302 'mainmenu' => 'agenda',
303 'url' => '/comm/action/index.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filtert=-1',
304 'langs' => 'agenda',
305 'position' => 143,
306 'perms' => '$user->hasRight("agenda", "allactions", "read")',
307 'enabled' => 'isModEnabled("agenda")',
308 'target' => '',
309 'user' => 2
310 );
311 $r++;
312 $this->menu[$r] = array(
313 'fk_menu' => 'r=3',
314 'type' => 'left',
315 'titre' => 'MenuDoneActions',
316 'mainmenu' => 'agenda',
317 'url' => '/comm/action/index.php?mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filtert=-1',
318 'langs' => 'agenda',
319 'position' => 144,
320 'perms' => '$user->hasRight("agenda", "allactions", "read")',
321 'enabled' => 'isModEnabled("agenda")',
322 'target' => '',
323 'user' => 2
324 );
325
326 // List
327 $r++;
328 $this->menu[$r] = array(
329 'fk_menu' => 'r=1',
330 'type' => 'left',
331 'titre' => 'List',
332 'mainmenu' => 'agenda',
333 'url' => '/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda',
334 'langs' => 'agenda',
335 'position' => 110,
336 'perms' => '$user->hasRight("agenda", "myactions", "read")',
337 'enabled' => 'isModEnabled("agenda")',
338 'target' => '',
339 'user' => 2
340 );
341 $r++;
342 $this->menu[$r] = array(
343 'fk_menu' => 'r=8',
344 'type' => 'left',
345 'titre' => 'MenuToDoMyActions',
346 'mainmenu' => 'agenda',
347 'url' => '/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filter=mine',
348 'langs' => 'agenda',
349 'position' => 111,
350 'perms' => '$user->hasRight("agenda", "myactions", "read")',
351 'enabled' => 'isModEnabled("agenda")',
352 'target' => '',
353 'user' => 2
354 );
355 $r++;
356 $this->menu[$r] = array(
357 'fk_menu' => 'r=8',
358 'type' => 'left',
359 'titre' => 'MenuDoneMyActions',
360 'mainmenu' => 'agenda',
361 'url' => '/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filter=mine',
362 'langs' => 'agenda',
363 'position' => 112,
364 'perms' => '$user->hasRight("agenda", "myactions", "read")',
365 'enabled' => 'isModEnabled("agenda")',
366 'target' => '',
367 'user' => 2
368 );
369 $r++;
370 $this->menu[$r] = array(
371 'fk_menu' => 'r=8',
372 'type' => 'left',
373 'titre' => 'MenuToDoActions',
374 'mainmenu' => 'agenda',
375 'url' => '/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=todo&amp;filtert=-1',
376 'langs' => 'agenda',
377 'position' => 113,
378 'perms' => '$user->hasRight("agenda", "allactions", "read")',
379 'enabled' => 'isModEnabled("agenda")',
380 'target' => '',
381 'user' => 2
382 );
383 $r++;
384 $this->menu[$r] = array(
385 'fk_menu' => 'r=8',
386 'type' => 'left',
387 'titre' => 'MenuDoneActions',
388 'mainmenu' => 'agenda',
389 'url' => '/comm/action/list.php?mode=show_list&amp;mainmenu=agenda&amp;leftmenu=agenda&amp;status=done&amp;filtert=-1',
390 'langs' => 'agenda',
391 'position' => 114,
392 'perms' => '$user->hasRight("agenda", "allactions", "read")',
393 'enabled' => 'isModEnabled("agenda")',
394 'target' => '',
395 'user' => 2
396 );
397 $r++;
398 // Reports
399 $this->menu[$r] = array(
400 'fk_menu' => 'r=1',
401 'type' => 'left',
402 'titre' => 'Reportings',
403 'mainmenu' => 'agenda',
404 'url' => '/comm/action/rapport/index.php?mainmenu=agenda&amp;leftmenu=agenda',
405 'langs' => 'agenda',
406 'position' => 160,
407 'perms' => '$user->hasRight("agenda", "allactions", "read")',
408 'enabled' => 'isModEnabled("agenda")',
409 'target' => '',
410 'user' => 2
411 );
412 $r++;
413 // Categories
414 $this->menu[$r] = array(
415 'fk_menu' => 'r=1',
416 'type' => 'left',
417 'titre' => 'Categories',
418 'mainmenu' => 'agenda',
419 'url' => '/categories/index.php?mainmenu=agenda&amp;leftmenu=agenda&type=10',
420 'langs' => 'agenda',
421 'position' => 170,
422 'perms' => '$user->hasRight("agenda", "allactions", "read")',
423 'enabled' => 'isModEnabled("category")',
424 'target' => '',
425 'user' => 2
426 );
427 $r++;
428
429
430 // Exports
431 //--------
432 $r = 0;
433
434 $r++;
435 $this->export_code[$r] = $this->rights_class.'_'.$r;
436 $this->export_label[$r] = "ExportDataset_event1";
437 $this->export_permission[$r] = array(array("agenda", "export"));
438 $this->export_fields_array[$r] = array('ac.id' => "IdAgenda", 'ac.ref_ext' => "ExternalRef",'ac.ref' => "Ref", 'ac.datec' => "DateCreation", 'ac.datep' => "DateActionBegin",
439 'ac.datep2' => "DateActionEnd", 'ac.location' => 'Location', 'ac.label' => "Title", 'ac.note' => "Note", 'ac.percent' => "Percentage", 'ac.durationp' => "Duration",
440 '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",
441 'cac.libelle' => "ActionType", 'cac.code' => "Code",
442 's.rowid' => "IdCompany", 's.nom' => 'CompanyName', 's.address' => 'Address', 's.zip' => 'Zip', 's.town' => 'Town',
443 'co.code' => 'CountryCode', 's.phone' => 'Phone', 's.siren' => 'ProfId1', 's.siret' => 'ProfId2', 's.ape' => 'ProfId3', 's.idprof4' => 'ProfId4', 's.idprof5' => 'ProfId5', 's.idprof6' => 'ProfId6',
444 's.code_compta' => 'CustomerAccountancyCode', 's.code_compta_fournisseur' => 'SupplierAccountancyCode', 's.tva_intra' => 'VATIntra',
445 'p.ref' => 'ProjectRef',
446 );
447 // Add multicompany field
448 if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) {
449 $nbofallowedentities = count(explode(',', getEntity('agenda')));
450 if (isModEnabled('multicompany') && $nbofallowedentities > 1) {
451 $this->export_fields_array[$r]['ac.entity'] = 'Entity';
452 }
453 }
454 $this->export_TypeFields_array[$r] = array('ac.ref_ext' => "Text", 'ac.ref' => "Text", 'ac.datec' => "Date", 'ac.datep' => "Date",
455 'ac.datep2' => "Date", 'ac.location' => 'Text', 'ac.label' => "Text", 'ac.note' => "Text", 'ac.percent' => "Numeric",
456 '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",
457 'cac.libelle' => "List:c_actioncomm:libelle:libelle", 'cac.code' => "Text",
458 's.nom' => 'Text', 's.address' => 'Text', 's.zip' => 'Text', 's.town' => 'Text',
459 'co.code' => 'Text', 's.phone' => 'Text', 's.siren' => 'Text', 's.siret' => 'Text', 's.ape' => 'Text', 's.idprof4' => 'Text', 's.idprof5' => 'Text', 's.idprof6' => 'Text',
460 's.code_compta' => 'Text', 's.code_compta_fournisseur' => 'Text', 's.tva_intra' => 'Text',
461 'p.ref' => 'Text', 'ac.entity' => 'List:entity:label:rowid'
462
463 );
464 $this->export_entities_array[$r] = array('ac.id' => "action", 'ac.ref_ext' => "action", 'ac.ref' => "action", 'ac.datec' => "action", 'ac.datep' => "action",
465 '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",
466 's.rowid' => "company", 's.nom' => 'company', 's.address' => 'company', 's.zip' => 'company', 's.town' => 'company',
467 'co.code' => 'company', 's.phone' => 'company', 's.siren' => 'company', 's.siret' => 'company', 's.ape' => 'company', 's.idprof4' => 'company', 's.idprof5' => 'company', 's.idprof6' => 'company',
468 's.code_compta' => 'company', 's.code_compta_fournisseur' => 'company', 's.tva_intra' => 'company',
469 'p.ref' => 'project',
470 );
471
472 $keyforselect = 'actioncomm';
473 $keyforelement = 'action';
474 $keyforaliasextra = 'extra';
475 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
476
477 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
478 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'actioncomm as ac';
479 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_extrafields as extra ON ac.id = extra.fk_object';
480 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id';
481 if (!empty($user) && !$user->hasRight('agenda', 'allactions', 'read')) {
482 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm';
483 }
484 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid';
485 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid';
486 if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {
487 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
488 }
489 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON ac.fk_user_author = uc.rowid';
490 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
491 $this->export_sql_end[$r] .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = ac.fk_project";
492 $this->export_sql_end[$r] .= ' WHERE ac.entity IN ('.getEntity('agenda').')';
493 if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {
494 $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR ac.fk_soc IS NULL)';
495 }
496 if (!empty($user) && !$user->hasRight('agenda', 'allactions', 'read')) {
497 $this->export_sql_end[$r] .= ' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);
498 }
499 $this->export_sql_end[$r] .= ' AND ac.entity IN ('.getEntity('agenda').')';
500 $this->export_sql_order[$r] = ' ORDER BY ac.datep';
501
502 // Imports
503 $r = 0;
504
505 // Import Events
506 $r++;
507 $this->import_code[$r] = $this->rights_class.'_'.$r;
508 $this->import_label[$r] = "ExportDataset_event1";
509 $this->import_icon[$r] = $this->picto;
510 $this->import_entities_array[$r] = array();
511 $this->import_tables_array[$r] = array('ac' => MAIN_DB_PREFIX.'actioncomm', 'extra' => MAIN_DB_PREFIX.'actioncomm_extrafields');
512 $this->import_tables_creator_array[$r] = array('ac' => 'fk_user_author'); // Fields to store import user id
513 $this->import_fields_array[$r] = array(
514 'ac.ref_ext' => 'ExternalRef',
515 'ac.ref' => 'Ref*',
516 'ac.datec' => 'DateCreation',
517 'ac.datep' => 'DateActionBegin',
518 'ac.datep2' => 'DateActionEnd',
519 'ac.location' => 'Location',
520 'ac.label' => 'Title*',
521 'ac.note' => 'Note',
522 'ac.percent' => 'Percentage*',
523 'ac.transparency' => 'Transparency',
524 'ac.priority' => 'Priority',
525 'ac.fk_action' => 'Code*',
526 'ac.fk_soc' => 'ThirdPartyName',
527 'ac.fk_project' => 'ProjectRef',
528 'ac.fk_user_mod' => 'ModifiedBy',
529 'ac.fk_user_action' => 'AffectedTo*',
530 'ac.fk_element' => 'ElementID',
531 'ac.elementtype' => 'ElementType',
532 );
533 $import_sample = array();
534
535 // Add extra fields
536 $import_extrafield_sample = array();
537 $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'actioncomm' AND entity IN (0, ".$conf->entity.")";
538 $resql = $this->db->query($sql);
539
540 if ($resql) {
541 while ($obj = $this->db->fetch_object($resql)) {
542 $fieldname = 'extra.'.$obj->name;
543 $fieldlabel = ucfirst($obj->label);
544 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
545 }
546 }
547 // End add extra fields
548
549 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
550 $this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'actioncomm');
551 //$this->import_updatekeys_array[$r] = array('ac.fk_user_creat' => 'User');
552 $this->import_convertvalue_array[$r] = array(
553 'ac.fk_soc' => array(
554 'rule' => 'fetchidfromref',
555 'file' => '/societe/class/societe.class.php',
556 'class' => 'Societe',
557 'method' => 'fetch',
558 'element' => 'ThirdParty'
559 ),
560 'ac.fk_user_action' => array(
561 'rule' => 'fetchidfromref',
562 'file' => '/user/class/user.class.php',
563 'class' => 'User',
564 'method' => 'fetch',
565 'element' => 'user'
566 ),
567 'ac.fk_user_mod' => array(
568 'rule' => 'fetchidfromref',
569 'file' => '/user/class/user.class.php',
570 'class' => 'User',
571 'method' => 'fetch',
572 'element' => 'user'
573 ),
574 'ac.fk_action' => array(
575 'rule' => 'fetchidfromcodeid',
576 'classfile' => '/comm/action/class/cactioncomm.class.php',
577 'class' => 'CActionComm',
578 'method' => 'fetch',
579 'dict' => 'DictionaryActions'
580 )
581 );
582
583 // Import Event Extra Fields
584 $keyforselect = 'actioncomm';
585 $keyforelement = 'action';
586 $keyforaliasextra = 'extra';
587 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
588 }
589
590
599 public function init($options = '')
600 {
601 global $conf;
602
603 // Permissions
604 $this->remove($options);
605
606 $sql = array(
607 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type='member' AND entity = ".((int) $conf->entity),
608 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','member',".((int) $conf->entity).")"
609 );
610
611 return $this->_init($sql, $options);
612 }
613}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
Class to describe and enable/disable module Agenda.
__construct($db)
Constructor.
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.
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.
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:140