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