|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* Copyright (C) 2003,2005 Rodolphe Quiedeville <[email protected]> |
|
4
|
|
|
* Copyright (C) 2003 Jean-Louis Bergamo <[email protected]> |
|
5
|
|
|
* Copyright (C) 2004-2014 Laurent Destailleur <[email protected]> |
|
6
|
|
|
* Copyright (C) 2004 Sebastien Di Cintio <[email protected]> |
|
7
|
|
|
* Copyright (C) 2004 Benoit Mortier <[email protected]> |
|
8
|
|
|
* Copyright (C) 2009-2011 Regis Houssin <[email protected]> |
|
9
|
|
|
* Copyright (C) 2013 Cedric Gross <[email protected]> |
|
10
|
|
|
* Copyright (C) 2015 Bahfir Abbes <[email protected]> |
|
11
|
|
|
* Copyright (C) 2017 Juanjo Menent <[email protected]> |
|
12
|
|
|
* Copyright (C) 2024 MDW <[email protected]> |
|
13
|
|
|
* Copyright (C) 2024 Rafael San José <[email protected]> |
|
14
|
|
|
* |
|
15
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
16
|
|
|
* it under the terms of the GNU General Public License as published by |
|
17
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
18
|
|
|
* (at your option) any later version. |
|
19
|
|
|
* |
|
20
|
|
|
* This program is distributed in the hope that it will be useful, |
|
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23
|
|
|
* GNU General Public License for more details. |
|
24
|
|
|
* |
|
25
|
|
|
* You should have received a copy of the GNU General Public License |
|
26
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
27
|
|
|
*/ |
|
28
|
|
|
|
|
29
|
|
|
namespace Dolibarr\Modules; |
|
30
|
|
|
/** |
|
31
|
|
|
* \defgroup agenda Module agenda |
|
32
|
|
|
* \brief Module to manage agenda and events |
|
33
|
|
|
* \file htdocs/core/modules/modAgenda.class.php |
|
34
|
|
|
* \ingroup agenda |
|
35
|
|
|
* \brief Description and activation file for the module agenda |
|
36
|
|
|
*/ |
|
37
|
|
|
|
|
38
|
|
|
use Dolibarr\Core\Base\DolibarrModules; |
|
39
|
|
|
use Modules\Agenda\DoliDB; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Class to describe and enable/disable module Agenda |
|
43
|
|
|
*/ |
|
44
|
|
|
class Agenda extends DolibarrModules |
|
45
|
|
|
{ |
|
46
|
|
|
/** |
|
47
|
|
|
* Constructor. Define names, constants, directories, boxes, permissions |
|
48
|
|
|
* |
|
49
|
|
|
* @param DoliDB $db Database handler |
|
50
|
|
|
*/ |
|
51
|
|
|
public function __construct($db) |
|
52
|
|
|
{ |
|
53
|
|
|
global $conf, $user; |
|
54
|
|
|
|
|
55
|
|
|
$this->db = $db; |
|
56
|
|
|
$this->numero = 2400; |
|
57
|
|
|
|
|
58
|
|
|
$this->family = "projects"; |
|
59
|
|
|
$this->module_position = '16'; |
|
60
|
|
|
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
|
61
|
|
|
$this->name = preg_replace('/^mod/i', '', get_only_class($this)); |
|
62
|
|
|
$this->description = "Follow events or rendez-vous. Record manual events into Agendas or let application record automatic events for log tracking."; |
|
63
|
|
|
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
|
64
|
|
|
$this->version = 'dolibarr'; |
|
65
|
|
|
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) |
|
66
|
|
|
$this->const_name = 'MAIN_MODULE_' . static::getNameOf($this->name); // strtoupper($this->name); |
|
67
|
|
|
$this->picto = 'action'; |
|
68
|
|
|
|
|
69
|
|
|
// Data directories to create when module is enabled |
|
70
|
|
|
$this->dirs = array("/agenda/temp"); |
|
71
|
|
|
|
|
72
|
|
|
// Config pages |
|
73
|
|
|
$this->config_page_url = array("agenda_other.php"); |
|
74
|
|
|
|
|
75
|
|
|
// Dependencies |
|
76
|
|
|
$this->hidden = false; // A condition to hide module |
|
77
|
|
|
$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled |
|
78
|
|
|
$this->requiredby = array(); // List of module ids to disable if this one is disabled |
|
79
|
|
|
$this->conflictwith = array(); // List of module class names as string this module is in conflict with |
|
80
|
|
|
$this->langfiles = array("companies", "project"); |
|
81
|
|
|
$this->phpmin = array(7, 0); // Minimum version of PHP required by module |
|
82
|
|
|
$this->enabled_bydefault = true; // Will be enabled during install |
|
83
|
|
|
|
|
84
|
|
|
// Module parts |
|
85
|
|
|
$this->module_parts = array(); |
|
86
|
|
|
|
|
87
|
|
|
// Constants |
|
88
|
|
|
//----------- |
|
89
|
|
|
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) |
|
90
|
|
|
// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), |
|
91
|
|
|
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) |
|
92
|
|
|
// ); |
|
93
|
|
|
$this->const = array(); |
|
94
|
|
|
//$this->const[] = array('AGENDA_DEFAULT_FILTER_TYPE', 'chaine', 'AC_NON_AUTO', 'Default filter for type of event on agenda', 0, 'current'); |
|
95
|
|
|
$sqlreadactions = "SELECT code, label, description FROM " . MAIN_DB_PREFIX . "c_action_trigger ORDER by rang"; |
|
96
|
|
|
$resql = $this->db->query($sqlreadactions); |
|
97
|
|
|
if ($resql) { |
|
98
|
|
|
while ($obj = $this->db->fetch_object($resql)) { |
|
99
|
|
|
//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). |
|
100
|
|
|
if (preg_match('/^TASK_/', $obj->code)) { |
|
101
|
|
|
continue; // We don't track such events by default. |
|
102
|
|
|
} |
|
103
|
|
|
//if (preg_match('/^_MODIFY/',$obj->code)) continue; // We don't track such events by default. |
|
104
|
|
|
$this->const[] = array('MAIN_AGENDA_ACTIONAUTO_' . $obj->code, "chaine", "1", '', 0, 'current'); |
|
105
|
|
|
} |
|
106
|
|
|
} else { |
|
107
|
|
|
dol_print_error($this->db->lasterror()); |
|
108
|
|
|
} |
|
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
|
|
|
$this->menu[$r] = array( |
|
215
|
|
|
'fk_menu' => 0, |
|
216
|
|
|
'type' => 'top', |
|
217
|
|
|
'titre' => 'TMenuAgenda', |
|
218
|
|
|
'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth"'), |
|
219
|
|
|
'mainmenu' => 'agenda', |
|
220
|
|
|
'url' => '/comm/action/index.php', |
|
221
|
|
|
'langs' => 'agenda', |
|
222
|
|
|
'position' => 86, |
|
223
|
|
|
'perms' => '$user->hasRight("agenda", "myactions", "read") || $user->hasRight("resource", "read")', |
|
224
|
|
|
'enabled' => 'isModEnabled("agenda") || isModEnabled("resource")', |
|
225
|
|
|
'target' => '', |
|
226
|
|
|
'user' => 2, |
|
227
|
|
|
); |
|
228
|
|
|
$r++; |
|
229
|
|
|
|
|
230
|
|
|
$this->menu[$r] = array( |
|
231
|
|
|
'fk_menu' => 'r=0', |
|
232
|
|
|
'type' => 'left', |
|
233
|
|
|
'titre' => 'Actions', |
|
234
|
|
|
'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'), |
|
235
|
|
|
'mainmenu' => 'agenda', |
|
236
|
|
|
'url' => '/comm/action/index.php?mainmenu=agenda&leftmenu=agenda', |
|
237
|
|
|
'langs' => 'agenda', |
|
238
|
|
|
'position' => 100, |
|
239
|
|
|
'perms' => '$user->hasRight("agenda", "myactions", "read")', |
|
240
|
|
|
'enabled' => 'isModEnabled("agenda")', |
|
241
|
|
|
'target' => '', |
|
242
|
|
|
'user' => 2, |
|
243
|
|
|
); |
|
244
|
|
|
$r++; |
|
245
|
|
|
$this->menu[$r] = array( |
|
246
|
|
|
'fk_menu' => 'r=1', |
|
247
|
|
|
'type' => 'left', |
|
248
|
|
|
'titre' => 'NewAction', |
|
249
|
|
|
'mainmenu' => 'agenda', |
|
250
|
|
|
'url' => '/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create', |
|
251
|
|
|
'langs' => 'commercial', |
|
252
|
|
|
'position' => 101, |
|
253
|
|
|
'perms' => '($user->hasRight("agenda", "myactions", "create") || $user->hasRight("agenda", "allactions", "create"))', |
|
254
|
|
|
'enabled' => 'isModEnabled("agenda")', |
|
255
|
|
|
'target' => '', |
|
256
|
|
|
'user' => 2 |
|
257
|
|
|
); |
|
258
|
|
|
$r++; |
|
259
|
|
|
// Calendar |
|
260
|
|
|
$this->menu[$r] = array( |
|
261
|
|
|
'fk_menu' => 'r=1', |
|
262
|
|
|
'type' => 'left', |
|
263
|
|
|
'titre' => 'Calendar', |
|
264
|
|
|
'mainmenu' => 'agenda', |
|
265
|
|
|
'url' => '/comm/action/index.php?mainmenu=agenda&leftmenu=agenda', |
|
266
|
|
|
'langs' => 'agenda', |
|
267
|
|
|
'position' => 140, |
|
268
|
|
|
'perms' => '$user->hasRight("agenda", "myactions", "read")', |
|
269
|
|
|
'enabled' => 'isModEnabled("agenda")', |
|
270
|
|
|
'target' => '', |
|
271
|
|
|
'user' => 2 |
|
272
|
|
|
); |
|
273
|
|
|
$r++; |
|
274
|
|
|
$this->menu[$r] = array( |
|
275
|
|
|
'fk_menu' => 'r=3', |
|
276
|
|
|
'type' => 'left', |
|
277
|
|
|
'titre' => 'MenuToDoMyActions', |
|
278
|
|
|
'mainmenu' => 'agenda', |
|
279
|
|
|
'url' => '/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine', |
|
280
|
|
|
'langs' => 'agenda', |
|
281
|
|
|
'position' => 141, |
|
282
|
|
|
'perms' => '$user->hasRight("agenda", "myactions", "read")', |
|
283
|
|
|
'enabled' => 'isModEnabled("agenda")', |
|
284
|
|
|
'target' => '', |
|
285
|
|
|
'user' => 2 |
|
286
|
|
|
); |
|
287
|
|
|
$r++; |
|
288
|
|
|
$this->menu[$r] = array( |
|
289
|
|
|
'fk_menu' => 'r=3', |
|
290
|
|
|
'type' => 'left', |
|
291
|
|
|
'titre' => 'MenuDoneMyActions', |
|
292
|
|
|
'mainmenu' => 'agenda', |
|
293
|
|
|
'url' => '/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine', |
|
294
|
|
|
'langs' => 'agenda', |
|
295
|
|
|
'position' => 142, |
|
296
|
|
|
'perms' => '$user->hasRight("agenda", "myactions", "read")', |
|
297
|
|
|
'enabled' => 'isModEnabled("agenda")', |
|
298
|
|
|
'target' => '', |
|
299
|
|
|
'user' => 2 |
|
300
|
|
|
); |
|
301
|
|
|
$r++; |
|
302
|
|
|
$this->menu[$r] = array( |
|
303
|
|
|
'fk_menu' => 'r=3', |
|
304
|
|
|
'type' => 'left', |
|
305
|
|
|
'titre' => 'MenuToDoActions', |
|
306
|
|
|
'mainmenu' => 'agenda', |
|
307
|
|
|
'url' => '/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1', |
|
308
|
|
|
'langs' => 'agenda', |
|
309
|
|
|
'position' => 143, |
|
310
|
|
|
'perms' => '$user->hasRight("agenda", "allactions", "read")', |
|
311
|
|
|
'enabled' => 'isModEnabled("agenda")', |
|
312
|
|
|
'target' => '', |
|
313
|
|
|
'user' => 2 |
|
314
|
|
|
); |
|
315
|
|
|
$r++; |
|
316
|
|
|
$this->menu[$r] = array( |
|
317
|
|
|
'fk_menu' => 'r=3', |
|
318
|
|
|
'type' => 'left', |
|
319
|
|
|
'titre' => 'MenuDoneActions', |
|
320
|
|
|
'mainmenu' => 'agenda', |
|
321
|
|
|
'url' => '/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1', |
|
322
|
|
|
'langs' => 'agenda', |
|
323
|
|
|
'position' => 144, |
|
324
|
|
|
'perms' => '$user->hasRight("agenda", "allactions", "read")', |
|
325
|
|
|
'enabled' => 'isModEnabled("agenda")', |
|
326
|
|
|
'target' => '', |
|
327
|
|
|
'user' => 2 |
|
328
|
|
|
); |
|
329
|
|
|
|
|
330
|
|
|
// List |
|
331
|
|
|
$r++; |
|
332
|
|
|
$this->menu[$r] = array( |
|
333
|
|
|
'fk_menu' => 'r=1', |
|
334
|
|
|
'type' => 'left', |
|
335
|
|
|
'titre' => 'List', |
|
336
|
|
|
'mainmenu' => 'agenda', |
|
337
|
|
|
'url' => '/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda', |
|
338
|
|
|
'langs' => 'agenda', |
|
339
|
|
|
'position' => 110, |
|
340
|
|
|
'perms' => '$user->hasRight("agenda", "myactions", "read")', |
|
341
|
|
|
'enabled' => 'isModEnabled("agenda")', |
|
342
|
|
|
'target' => '', |
|
343
|
|
|
'user' => 2 |
|
344
|
|
|
); |
|
345
|
|
|
$r++; |
|
346
|
|
|
$this->menu[$r] = array( |
|
347
|
|
|
'fk_menu' => 'r=8', |
|
348
|
|
|
'type' => 'left', |
|
349
|
|
|
'titre' => 'MenuToDoMyActions', |
|
350
|
|
|
'mainmenu' => 'agenda', |
|
351
|
|
|
'url' => '/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine', |
|
352
|
|
|
'langs' => 'agenda', |
|
353
|
|
|
'position' => 111, |
|
354
|
|
|
'perms' => '$user->hasRight("agenda", "myactions", "read")', |
|
355
|
|
|
'enabled' => 'isModEnabled("agenda")', |
|
356
|
|
|
'target' => '', |
|
357
|
|
|
'user' => 2 |
|
358
|
|
|
); |
|
359
|
|
|
$r++; |
|
360
|
|
|
$this->menu[$r] = array( |
|
361
|
|
|
'fk_menu' => 'r=8', |
|
362
|
|
|
'type' => 'left', |
|
363
|
|
|
'titre' => 'MenuDoneMyActions', |
|
364
|
|
|
'mainmenu' => 'agenda', |
|
365
|
|
|
'url' => '/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine', |
|
366
|
|
|
'langs' => 'agenda', |
|
367
|
|
|
'position' => 112, |
|
368
|
|
|
'perms' => '$user->hasRight("agenda", "myactions", "read")', |
|
369
|
|
|
'enabled' => 'isModEnabled("agenda")', |
|
370
|
|
|
'target' => '', |
|
371
|
|
|
'user' => 2 |
|
372
|
|
|
); |
|
373
|
|
|
$r++; |
|
374
|
|
|
$this->menu[$r] = array( |
|
375
|
|
|
'fk_menu' => 'r=8', |
|
376
|
|
|
'type' => 'left', |
|
377
|
|
|
'titre' => 'MenuToDoActions', |
|
378
|
|
|
'mainmenu' => 'agenda', |
|
379
|
|
|
'url' => '/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1', |
|
380
|
|
|
'langs' => 'agenda', |
|
381
|
|
|
'position' => 113, |
|
382
|
|
|
'perms' => '$user->hasRight("agenda", "allactions", "read")', |
|
383
|
|
|
'enabled' => 'isModEnabled("agenda")', |
|
384
|
|
|
'target' => '', |
|
385
|
|
|
'user' => 2 |
|
386
|
|
|
); |
|
387
|
|
|
$r++; |
|
388
|
|
|
$this->menu[$r] = array( |
|
389
|
|
|
'fk_menu' => 'r=8', |
|
390
|
|
|
'type' => 'left', |
|
391
|
|
|
'titre' => 'MenuDoneActions', |
|
392
|
|
|
'mainmenu' => 'agenda', |
|
393
|
|
|
'url' => '/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1', |
|
394
|
|
|
'langs' => 'agenda', |
|
395
|
|
|
'position' => 114, |
|
396
|
|
|
'perms' => '$user->hasRight("agenda", "allactions", "read")', |
|
397
|
|
|
'enabled' => 'isModEnabled("agenda")', |
|
398
|
|
|
'target' => '', |
|
399
|
|
|
'user' => 2 |
|
400
|
|
|
); |
|
401
|
|
|
$r++; |
|
402
|
|
|
// Reports |
|
403
|
|
|
$this->menu[$r] = array( |
|
404
|
|
|
'fk_menu' => 'r=1', |
|
405
|
|
|
'type' => 'left', |
|
406
|
|
|
'titre' => 'Reportings', |
|
407
|
|
|
'mainmenu' => 'agenda', |
|
408
|
|
|
'url' => '/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda', |
|
409
|
|
|
'langs' => 'agenda', |
|
410
|
|
|
'position' => 160, |
|
411
|
|
|
'perms' => '$user->hasRight("agenda", "allactions", "read")', |
|
412
|
|
|
'enabled' => 'isModEnabled("agenda")', |
|
413
|
|
|
'target' => '', |
|
414
|
|
|
'user' => 2 |
|
415
|
|
|
); |
|
416
|
|
|
$r++; |
|
417
|
|
|
// Categories |
|
418
|
|
|
$this->menu[$r] = array( |
|
419
|
|
|
'fk_menu' => 'r=1', |
|
420
|
|
|
'type' => 'left', |
|
421
|
|
|
'titre' => 'Categories', |
|
422
|
|
|
'mainmenu' => 'agenda', |
|
423
|
|
|
'url' => '/categories/index.php?mainmenu=agenda&leftmenu=agenda&type=10', |
|
424
|
|
|
'langs' => 'agenda', |
|
425
|
|
|
'position' => 170, |
|
426
|
|
|
'perms' => '$user->hasRight("agenda", "allactions", "read")', |
|
427
|
|
|
'enabled' => 'isModEnabled("category")', |
|
428
|
|
|
'target' => '', |
|
429
|
|
|
'user' => 2 |
|
430
|
|
|
); |
|
431
|
|
|
$r++; |
|
432
|
|
|
|
|
433
|
|
|
|
|
434
|
|
|
// Exports |
|
435
|
|
|
//-------- |
|
436
|
|
|
$r = 0; |
|
437
|
|
|
|
|
438
|
|
|
$r++; |
|
439
|
|
|
$this->export_code[$r] = $this->rights_class . '_' . $r; |
|
440
|
|
|
$this->export_label[$r] = "ExportDataset_event1"; |
|
441
|
|
|
$this->export_permission[$r] = array(array("agenda", "export")); |
|
442
|
|
|
$this->export_fields_array[$r] = array('ac.id' => "IdAgenda", 'ac.ref_ext' => "ExternalRef", 'ac.ref' => "Ref", 'ac.datec' => "DateCreation", 'ac.datep' => "DateActionBegin", |
|
443
|
|
|
'ac.datep2' => "DateActionEnd", 'ac.location' => 'Location', 'ac.label' => "Title", 'ac.note' => "Note", 'ac.percent' => "Percentage", 'ac.durationp' => "Duration", |
|
444
|
|
|
'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", |
|
445
|
|
|
'cac.libelle' => "ActionType", 'cac.code' => "Code", |
|
446
|
|
|
's.rowid' => "IdCompany", 's.nom' => 'CompanyName', 's.address' => 'Address', 's.zip' => 'Zip', 's.town' => 'Town', |
|
447
|
|
|
'co.code' => 'CountryCode', 's.phone' => 'Phone', 's.siren' => 'ProfId1', 's.siret' => 'ProfId2', 's.ape' => 'ProfId3', 's.idprof4' => 'ProfId4', 's.idprof5' => 'ProfId5', 's.idprof6' => 'ProfId6', |
|
448
|
|
|
's.code_compta' => 'CustomerAccountancyCode', 's.code_compta_fournisseur' => 'SupplierAccountancyCode', 's.tva_intra' => 'VATIntra', |
|
449
|
|
|
'p.ref' => 'ProjectRef', |
|
450
|
|
|
); |
|
451
|
|
|
// Add multicompany field |
|
452
|
|
|
if (getDolGlobalString('MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED')) { |
|
453
|
|
|
$nbofallowedentities = count(explode(',', getEntity('agenda'))); |
|
454
|
|
|
if (isModEnabled('multicompany') && $nbofallowedentities > 1) { |
|
455
|
|
|
$this->export_fields_array[$r]['ac.entity'] = 'Entity'; |
|
456
|
|
|
} |
|
457
|
|
|
} |
|
458
|
|
|
$this->export_TypeFields_array[$r] = array('ac.ref_ext' => "Text", 'ac.ref' => "Text", 'ac.datec' => "Date", 'ac.datep' => "Date", |
|
459
|
|
|
'ac.datep2' => "Date", 'ac.location' => 'Text', 'ac.label' => "Text", 'ac.note' => "Text", 'ac.percent' => "Numeric", |
|
460
|
|
|
'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", |
|
461
|
|
|
'cac.libelle' => "List:c_actioncomm:libelle:libelle", 'cac.code' => "Text", |
|
462
|
|
|
's.nom' => 'Text', 's.address' => 'Text', 's.zip' => 'Text', 's.town' => 'Text', |
|
463
|
|
|
'co.code' => 'Text', 's.phone' => 'Text', 's.siren' => 'Text', 's.siret' => 'Text', 's.ape' => 'Text', 's.idprof4' => 'Text', 's.idprof5' => 'Text', 's.idprof6' => 'Text', |
|
464
|
|
|
's.code_compta' => 'Text', 's.code_compta_fournisseur' => 'Text', 's.tva_intra' => 'Text', |
|
465
|
|
|
'p.ref' => 'Text', 'ac.entity' => 'List:entity:label:rowid' |
|
466
|
|
|
|
|
467
|
|
|
); |
|
468
|
|
|
$this->export_entities_array[$r] = array('ac.id' => "action", 'ac.ref_ext' => "action", 'ac.ref' => "action", 'ac.datec' => "action", 'ac.datep' => "action", |
|
469
|
|
|
'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", |
|
470
|
|
|
's.rowid' => "company", 's.nom' => 'company', 's.address' => 'company', 's.zip' => 'company', 's.town' => 'company', |
|
471
|
|
|
'co.code' => 'company', 's.phone' => 'company', 's.siren' => 'company', 's.siret' => 'company', 's.ape' => 'company', 's.idprof4' => 'company', 's.idprof5' => 'company', 's.idprof6' => 'company', |
|
472
|
|
|
's.code_compta' => 'company', 's.code_compta_fournisseur' => 'company', 's.tva_intra' => 'company', |
|
473
|
|
|
'p.ref' => 'project', |
|
474
|
|
|
); |
|
475
|
|
|
|
|
476
|
|
|
$keyforselect = 'actioncomm'; |
|
477
|
|
|
$keyforelement = 'action'; |
|
478
|
|
|
$keyforaliasextra = 'extra'; |
|
479
|
|
|
include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php'; |
|
480
|
|
|
|
|
481
|
|
|
$this->export_sql_start[$r] = 'SELECT DISTINCT '; |
|
482
|
|
|
$this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'actioncomm as ac'; |
|
483
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'actioncomm_extrafields as extra ON ac.id = extra.fk_object'; |
|
484
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_actioncomm as cac on ac.fk_action = cac.id'; |
|
485
|
|
|
if (!empty($user) && !$user->hasRight('agenda', 'allactions', 'read')) { |
|
486
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'actioncomm_resources acr on ac.id = acr.fk_actioncomm'; |
|
487
|
|
|
} |
|
488
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople as sp on ac.fk_contact = sp.rowid'; |
|
489
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s on ac.fk_soc = s.rowid'; |
|
490
|
|
|
if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) { |
|
491
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
492
|
|
|
} |
|
493
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'user as uc ON ac.fk_user_author = uc.rowid'; |
|
494
|
|
|
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as co on s.fk_pays = co.rowid'; |
|
495
|
|
|
$this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet as p ON p.rowid = ac.fk_project"; |
|
496
|
|
|
$this->export_sql_end[$r] .= ' WHERE ac.entity IN (' . getEntity('agenda') . ')'; |
|
497
|
|
|
if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) { |
|
498
|
|
|
$this->export_sql_end[$r] .= ' AND (sc.fk_user = ' . (empty($user) ? 0 : $user->id) . ' OR ac.fk_soc IS NULL)'; |
|
499
|
|
|
} |
|
500
|
|
|
if (!empty($user) && !$user->hasRight('agenda', 'allactions', 'read')) { |
|
501
|
|
|
$this->export_sql_end[$r] .= ' AND acr.fk_element = ' . (empty($user) ? 0 : $user->id); |
|
502
|
|
|
} |
|
503
|
|
|
$this->export_sql_end[$r] .= ' AND ac.entity IN (' . getEntity('agenda') . ')'; |
|
504
|
|
|
$this->export_sql_order[$r] = ' ORDER BY ac.datep'; |
|
505
|
|
|
|
|
506
|
|
|
// Imports |
|
507
|
|
|
$r = 0; |
|
508
|
|
|
|
|
509
|
|
|
// Import Events |
|
510
|
|
|
$r++; |
|
511
|
|
|
$this->import_code[$r] = $this->rights_class . '_' . $r; |
|
512
|
|
|
$this->import_label[$r] = "ExportDataset_event1"; |
|
513
|
|
|
$this->import_icon[$r] = $this->picto; |
|
514
|
|
|
$this->import_entities_array[$r] = array(); |
|
515
|
|
|
$this->import_tables_array[$r] = array('ac' => MAIN_DB_PREFIX . 'actioncomm', 'extra' => MAIN_DB_PREFIX . 'actioncomm_extrafields'); |
|
516
|
|
|
$this->import_tables_creator_array[$r] = array('ac' => 'fk_user_author'); // Fields to store import user id |
|
517
|
|
|
$this->import_fields_array[$r] = array( |
|
518
|
|
|
'ac.ref_ext' => 'ExternalRef', |
|
519
|
|
|
'ac.ref' => 'Ref*', |
|
520
|
|
|
'ac.datec' => 'DateCreation', |
|
521
|
|
|
'ac.datep' => 'DateActionBegin', |
|
522
|
|
|
'ac.datep2' => 'DateActionEnd', |
|
523
|
|
|
'ac.location' => 'Location', |
|
524
|
|
|
'ac.label' => 'Title*', |
|
525
|
|
|
'ac.note' => 'Note', |
|
526
|
|
|
'ac.percent' => 'Percentage*', |
|
527
|
|
|
'ac.transparency' => 'Transparency', |
|
528
|
|
|
'ac.priority' => 'Priority', |
|
529
|
|
|
'ac.fk_action' => 'Code*', |
|
530
|
|
|
'ac.fk_soc' => 'ThirdPartyName', |
|
531
|
|
|
'ac.fk_project' => 'ProjectRef', |
|
532
|
|
|
'ac.fk_user_mod' => 'ModifiedBy', |
|
533
|
|
|
'ac.fk_user_action' => 'AffectedTo*', |
|
534
|
|
|
'ac.fk_element' => 'ElementID', |
|
535
|
|
|
'ac.elementtype' => 'ElementType', |
|
536
|
|
|
); |
|
537
|
|
|
$import_sample = array(); |
|
538
|
|
|
|
|
539
|
|
|
// Add extra fields |
|
540
|
|
|
$import_extrafield_sample = array(); |
|
541
|
|
|
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE elementtype = 'actioncomm' AND entity IN (0, " . $conf->entity . ")"; |
|
542
|
|
|
$resql = $this->db->query($sql); |
|
543
|
|
|
|
|
544
|
|
|
if ($resql) { |
|
545
|
|
|
while ($obj = $this->db->fetch_object($resql)) { |
|
546
|
|
|
$fieldname = 'extra.' . $obj->name; |
|
547
|
|
|
$fieldlabel = ucfirst($obj->label); |
|
548
|
|
|
$this->import_fields_array[$r][$fieldname] = $fieldlabel . ($obj->fieldrequired ? '*' : ''); |
|
549
|
|
|
} |
|
550
|
|
|
} |
|
551
|
|
|
// End add extra fields |
|
552
|
|
|
|
|
553
|
|
|
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample); |
|
554
|
|
|
$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'actioncomm'); |
|
555
|
|
|
//$this->import_updatekeys_array[$r] = array('ac.fk_user_creat' => 'User'); |
|
556
|
|
|
$this->import_convertvalue_array[$r] = array( |
|
557
|
|
|
'ac.fk_soc' => array( |
|
558
|
|
|
'rule' => 'fetchidfromref', |
|
559
|
|
|
'file' => '/societe/class/societe.class.php', |
|
560
|
|
|
'class' => 'Societe', |
|
561
|
|
|
'method' => 'fetch', |
|
562
|
|
|
'element' => 'ThirdParty' |
|
563
|
|
|
), |
|
564
|
|
|
'ac.fk_user_action' => array( |
|
565
|
|
|
'rule' => 'fetchidfromref', |
|
566
|
|
|
'file' => '/user/class/user.class.php', |
|
567
|
|
|
'class' => 'User', |
|
568
|
|
|
'method' => 'fetch', |
|
569
|
|
|
'element' => 'user' |
|
570
|
|
|
), |
|
571
|
|
|
'ac.fk_user_mod' => array( |
|
572
|
|
|
'rule' => 'fetchidfromref', |
|
573
|
|
|
'file' => '/user/class/user.class.php', |
|
574
|
|
|
'class' => 'User', |
|
575
|
|
|
'method' => 'fetch', |
|
576
|
|
|
'element' => 'user' |
|
577
|
|
|
), |
|
578
|
|
|
'ac.fk_action' => array( |
|
579
|
|
|
'rule' => 'fetchidfromcodeid', |
|
580
|
|
|
'classfile' => '/comm/action/class/cactioncomm.class.php', |
|
581
|
|
|
'class' => 'CActionComm', |
|
582
|
|
|
'method' => 'fetch', |
|
583
|
|
|
'dict' => 'DictionaryActions' |
|
584
|
|
|
) |
|
585
|
|
|
); |
|
586
|
|
|
|
|
587
|
|
|
// Import Event Extra Fields |
|
588
|
|
|
$keyforselect = 'actioncomm'; |
|
589
|
|
|
$keyforelement = 'action'; |
|
590
|
|
|
$keyforaliasextra = 'extra'; |
|
591
|
|
|
include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php'; |
|
592
|
|
|
} |
|
593
|
|
|
} |
|
594
|
|
|
|