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();
214 $this->menu[$r] = array(
217 'titre' =>
'TMenuAgenda',
218 'prefix' =>
img_picto(
'', $this->picto,
'class="pictofixedwidth"'),
219 'mainmenu' =>
'agenda',
220 'url' =>
'/comm/action/index.php',
223 'perms' =>
'$user->hasRight("agenda", "myactions", "read") || $user->hasRight("resource", "read")',
224 'enabled' =>
'isModEnabled("agenda") || isModEnabled("resource")',
230 $this->menu[$r] = array(
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',
239 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
240 'enabled' =>
'isModEnabled("agenda")',
245 $this->menu[$r] = array(
248 'titre' =>
'NewAction',
249 'mainmenu' =>
'agenda',
250 'url' =>
'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create',
251 'langs' =>
'commercial',
253 'perms' =>
'($user->hasRight("agenda", "myactions", "create") || $user->hasRight("agenda", "allactions", "create"))',
254 'enabled' =>
'isModEnabled("agenda")',
260 $this->menu[$r] = array(
263 'titre' =>
'Calendar',
264 'mainmenu' =>
'agenda',
265 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda',
268 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
269 'enabled' =>
'isModEnabled("agenda")',
274 $this->menu[$r] = array(
277 'titre' =>
'MenuToDoMyActions',
278 'mainmenu' =>
'agenda',
279 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine',
282 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
283 'enabled' =>
'isModEnabled("agenda")',
288 $this->menu[$r] = array(
291 'titre' =>
'MenuDoneMyActions',
292 'mainmenu' =>
'agenda',
293 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine',
296 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
297 'enabled' =>
'isModEnabled("agenda")',
302 $this->menu[$r] = array(
305 'titre' =>
'MenuToDoActions',
306 'mainmenu' =>
'agenda',
307 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1',
310 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
311 'enabled' =>
'isModEnabled("agenda")',
316 $this->menu[$r] = array(
319 'titre' =>
'MenuDoneActions',
320 'mainmenu' =>
'agenda',
321 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1',
324 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
325 'enabled' =>
'isModEnabled("agenda")',
332 $this->menu[$r] = array(
336 'mainmenu' =>
'agenda',
337 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda',
340 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
341 'enabled' =>
'isModEnabled("agenda")',
346 $this->menu[$r] = array(
349 'titre' =>
'MenuToDoMyActions',
350 'mainmenu' =>
'agenda',
351 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine',
354 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
355 'enabled' =>
'isModEnabled("agenda")',
360 $this->menu[$r] = array(
363 'titre' =>
'MenuDoneMyActions',
364 'mainmenu' =>
'agenda',
365 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine',
368 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
369 'enabled' =>
'isModEnabled("agenda")',
374 $this->menu[$r] = array(
377 'titre' =>
'MenuToDoActions',
378 'mainmenu' =>
'agenda',
379 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1',
382 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
383 'enabled' =>
'isModEnabled("agenda")',
388 $this->menu[$r] = array(
391 'titre' =>
'MenuDoneActions',
392 'mainmenu' =>
'agenda',
393 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1',
396 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
397 'enabled' =>
'isModEnabled("agenda")',
403 $this->menu[$r] = array(
406 'titre' =>
'Reportings',
407 'mainmenu' =>
'agenda',
408 'url' =>
'/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda',
411 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
412 'enabled' =>
'isModEnabled("agenda")',
418 $this->menu[$r] = array(
421 'titre' =>
'Categories',
422 'mainmenu' =>
'agenda',
423 'url' =>
'/categories/index.php?mainmenu=agenda&leftmenu=agenda&type=10',
426 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
427 'enabled' =>
'isModEnabled("category")',
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',
453 $nbofallowedentities = count(explode(
',',
getEntity(
'agenda')));
454 if (isModEnabled(
'multicompany') && $nbofallowedentities > 1) {
455 $this->export_fields_array[$r][
'ac.entity'] =
'Entity';
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'
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',
476 $keyforselect =
'actioncomm';
477 $keyforelement =
'action';
478 $keyforaliasextra =
'extra';
479 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
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';
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';
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)';
500 if (!empty($user) && !$user->hasRight(
'agenda',
'allactions',
'read')) {
501 $this->export_sql_end[$r] .=
' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);
503 $this->export_sql_end[$r] .=
' AND ac.entity IN ('.getEntity(
'agenda').
')';
504 $this->export_sql_order[$r] =
' ORDER BY ac.datep';
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');
517 $this->import_fields_array[$r] = array(
518 'ac.ref_ext' =>
'ExternalRef',
520 'ac.datec' =>
'DateCreation',
521 'ac.datep' =>
'DateActionBegin',
522 'ac.datep2' =>
'DateActionEnd',
523 'ac.location' =>
'Location',
524 'ac.label' =>
'Title*',
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',
537 $import_sample = array();
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);
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 ?
'*' :
'');
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');
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',
562 'element' =>
'ThirdParty'
564 'ac.fk_user_action' => array(
565 'rule' =>
'fetchidfromref',
566 'file' =>
'/user/class/user.class.php',
571 'ac.fk_user_mod' => array(
572 'rule' =>
'fetchidfromref',
573 'file' =>
'/user/class/user.class.php',
578 'ac.fk_action' => array(
579 'rule' =>
'fetchidfromcodeid',
580 'classfile' =>
'/comm/action/class/cactioncomm.class.php',
581 'class' =>
'CActionComm',
583 'dict' =>
'DictionaryActions'
588 $keyforselect =
'actioncomm';
589 $keyforelement =
'action';
590 $keyforaliasextra =
'extra';
591 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';