54 $this->family =
"projects";
55 $this->module_position =
'16';
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.";
60 $this->version =
'dolibarr';
62 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
63 $this->picto =
'action';
66 $this->dirs = array(
"/agenda/temp");
69 $this->config_page_url = array(
"agenda_other.php");
72 $this->hidden =
false;
73 $this->depends = array();
74 $this->requiredby = array();
75 $this->conflictwith = array();
76 $this->langfiles = array(
"companies",
"project");
77 $this->phpmin = array(7, 0);
78 $this->enabled_bydefault =
true;
81 $this->module_parts = array();
89 $this->
const = array();
94 $sqlreadactions =
"SELECT code, label, description FROM ".MAIN_DB_PREFIX.
"c_action_trigger ORDER by rang";
95 $resql = $this->db->query($sqlreadactions);
97 while ($obj = $this->db->fetch_object($resql)) {
99 if (preg_match(
'/^TASK_/', $obj->code)) {
103 $this->
const[] = array(
'MAIN_AGENDA_ACTIONAUTO_'.$obj->code,
"chaine",
"1",
'', 0,
'current');
112 $this->tabs = array();
116 $this->boxes = array(
117 0 => array(
'file' =>
'box_actions.php',
'enabledbydefaulton' =>
'Home'),
118 1 => array(
'file' =>
'box_actions_future.php',
'enabledbydefaulton' =>
'Home')
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),
130 $this->rights = array();
131 $this->rights_class =
'agenda';
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';
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';
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';
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';
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';
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';
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';
197 $this->menu = array();
216 $this->menu[$r] = array(
219 'titre' =>
'TMenuAgenda',
220 'prefix' =>
img_picto(
'', $this->picto,
'class="pictofixedwidth"'),
221 'mainmenu' =>
'agenda',
222 'url' =>
'/comm/action/index.php',
225 'perms' =>
'$user->hasRight("agenda", "myactions", "read") || $user->hasRight("resource", "read")',
226 'enabled' =>
'isModEnabled("agenda") || isModEnabled("resource")',
232 $this->menu[$r] = array(
235 'titre' =>
'Actions',
236 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth"'),
237 'mainmenu' =>
'agenda',
238 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda',
241 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
242 'enabled' =>
'isModEnabled("agenda")',
247 $this->menu[$r] = array(
250 'titre' =>
'NewAction',
251 'mainmenu' =>
'agenda',
252 'url' =>
'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create',
253 'langs' =>
'commercial',
255 'perms' =>
'($user->hasRight("agenda", "myactions", "create") || $user->hasRight("agenda", "allactions", "create"))',
256 'enabled' =>
'isModEnabled("agenda")',
262 $this->menu[$r] = array(
265 'titre' =>
'Calendar',
266 'mainmenu' =>
'agenda',
267 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda',
270 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
271 'enabled' =>
'isModEnabled("agenda")',
276 $this->menu[$r] = array(
279 'titre' =>
'MenuToDoMyActions',
280 'mainmenu' =>
'agenda',
281 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine',
284 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
285 'enabled' =>
'isModEnabled("agenda")',
290 $this->menu[$r] = array(
293 'titre' =>
'MenuDoneMyActions',
294 'mainmenu' =>
'agenda',
295 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine',
298 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
299 'enabled' =>
'isModEnabled("agenda")',
304 $this->menu[$r] = array(
307 'titre' =>
'MenuToDoActions',
308 'mainmenu' =>
'agenda',
309 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1',
312 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
313 'enabled' =>
'isModEnabled("agenda")',
318 $this->menu[$r] = array(
321 'titre' =>
'MenuDoneActions',
322 'mainmenu' =>
'agenda',
323 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1',
326 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
327 'enabled' =>
'isModEnabled("agenda")',
334 $this->menu[$r] = array(
338 'mainmenu' =>
'agenda',
339 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda',
342 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
343 'enabled' =>
'isModEnabled("agenda")',
348 $this->menu[$r] = array(
351 'titre' =>
'MenuToDoMyActions',
352 'mainmenu' =>
'agenda',
353 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine',
356 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
357 'enabled' =>
'isModEnabled("agenda")',
362 $this->menu[$r] = array(
365 'titre' =>
'MenuDoneMyActions',
366 'mainmenu' =>
'agenda',
367 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine',
370 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
371 'enabled' =>
'isModEnabled("agenda")',
376 $this->menu[$r] = array(
379 'titre' =>
'MenuToDoActions',
380 'mainmenu' =>
'agenda',
381 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1',
384 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
385 'enabled' =>
'isModEnabled("agenda")',
390 $this->menu[$r] = array(
393 'titre' =>
'MenuDoneActions',
394 'mainmenu' =>
'agenda',
395 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1',
398 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
399 'enabled' =>
'isModEnabled("agenda")',
405 $this->menu[$r] = array(
408 'titre' =>
'Reportings',
409 'mainmenu' =>
'agenda',
410 'url' =>
'/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda',
413 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
414 'enabled' =>
'isModEnabled("agenda")',
420 $this->menu[$r] = array(
423 'titre' =>
'Categories',
424 'mainmenu' =>
'agenda',
425 'url' =>
'/categories/index.php?mainmenu=agenda&leftmenu=agenda&type=10',
428 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
429 'enabled' =>
'isModEnabled("category")',
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',
455 $nbofallowedentities = count(explode(
',',
getEntity(
'agenda')));
456 if (isModEnabled(
'multicompany') && $nbofallowedentities > 1) {
457 $this->export_fields_array[$r][
'ac.entity'] =
'Entity';
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'
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',
478 $keyforselect =
'actioncomm';
479 $keyforelement =
'action';
480 $keyforaliasextra =
'extra';
481 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
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';
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';
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)';
502 if (!empty($user) && !$user->hasRight(
'agenda',
'allactions',
'read')) {
503 $this->export_sql_end[$r] .=
' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);
505 $this->export_sql_end[$r] .=
' AND ac.entity IN ('.getEntity(
'agenda').
')';
506 $this->export_sql_order[$r] =
' ORDER BY ac.datep';
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');
519 $this->import_fields_array[$r] = array(
520 'ac.ref_ext' =>
'ExternalRef',
522 'ac.datec' =>
'DateCreation',
523 'ac.datep' =>
'DateActionBegin',
524 'ac.datep2' =>
'DateActionEnd',
525 'ac.location' =>
'Location',
526 'ac.label' =>
'Title*',
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',
539 $import_sample = array();
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);
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 ?
'*' :
'');
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');
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',
564 'element' =>
'ThirdParty'
566 'ac.fk_user_action' => array(
567 'rule' =>
'fetchidfromref',
568 'file' =>
'/user/class/user.class.php',
573 'ac.fk_user_mod' => array(
574 'rule' =>
'fetchidfromref',
575 'file' =>
'/user/class/user.class.php',
580 'ac.fk_action' => array(
581 'rule' =>
'fetchidfromcodeid',
582 'classfile' =>
'/comm/action/class/cactioncomm.class.php',
583 'class' =>
'CActionComm',
585 'dict' =>
'DictionaryActions'
590 $keyforselect =
'actioncomm';
591 $keyforelement =
'action';
592 $keyforaliasextra =
'extra';
593 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';