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),
126 1 => array(
'label' =>
'SendSmsReminders',
'jobtype' =>
'method',
'class' =>
'comm/action/class/actioncomm.class.php',
'objectname' =>
'ActionComm',
'method' =>
'sendSmsReminder',
'parameters' =>
'',
'comment' =>
'SendSmsReminder',
'frequency' => 5,
'unitfrequency' => 60,
'priority' => 10,
'status' => 1,
'test' =>
'isModEnabled("agenda")',
'datestart' => $datestart),
131 $this->rights = array();
132 $this->rights_class =
'agenda';
143 $this->rights[$r][0] = 2401;
144 $this->rights[$r][1] =
'Read actions/tasks linked to his account';
145 $this->rights[$r][2] =
'r';
146 $this->rights[$r][3] = 0;
147 $this->rights[$r][4] =
'myactions';
148 $this->rights[$r][5] =
'read';
151 $this->rights[$r][0] = 2402;
152 $this->rights[$r][1] =
'Create/modify actions/tasks linked to his account';
153 $this->rights[$r][2] =
'w';
154 $this->rights[$r][3] = 0;
155 $this->rights[$r][4] =
'myactions';
156 $this->rights[$r][5] =
'create';
159 $this->rights[$r][0] = 2403;
160 $this->rights[$r][1] =
'Delete actions/tasks linked to his account';
161 $this->rights[$r][2] =
'w';
162 $this->rights[$r][3] = 0;
163 $this->rights[$r][4] =
'myactions';
164 $this->rights[$r][5] =
'delete';
167 $this->rights[$r][0] = 2411;
168 $this->rights[$r][1] =
'Read actions/tasks of others';
169 $this->rights[$r][2] =
'r';
170 $this->rights[$r][3] = 0;
171 $this->rights[$r][4] =
'allactions';
172 $this->rights[$r][5] =
'read';
175 $this->rights[$r][0] = 2412;
176 $this->rights[$r][1] =
'Create/modify actions/tasks of others';
177 $this->rights[$r][2] =
'w';
178 $this->rights[$r][3] = 0;
179 $this->rights[$r][4] =
'allactions';
180 $this->rights[$r][5] =
'create';
183 $this->rights[$r][0] = 2413;
184 $this->rights[$r][1] =
'Delete actions/tasks of others';
185 $this->rights[$r][2] =
'w';
186 $this->rights[$r][3] = 0;
187 $this->rights[$r][4] =
'allactions';
188 $this->rights[$r][5] =
'delete';
191 $this->rights[$r][0] = 2414;
192 $this->rights[$r][1] =
'Export actions/tasks of others';
193 $this->rights[$r][2] =
'w';
194 $this->rights[$r][3] = 0;
195 $this->rights[$r][4] =
'export';
198 $this->menu = array();
217 $this->menu[$r] = array(
220 'titre' =>
'TMenuAgenda',
221 'prefix' =>
img_picto(
'', $this->picto,
'class="pictofixedwidth"'),
222 'mainmenu' =>
'agenda',
223 'url' =>
'/comm/action/index.php',
226 'perms' =>
'$user->hasRight("agenda", "myactions", "read") || $user->hasRight("resource", "read")',
227 'enabled' =>
'isModEnabled("agenda") || isModEnabled("resource")',
233 $this->menu[$r] = array(
236 'titre' =>
'Actions',
237 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth"'),
238 'mainmenu' =>
'agenda',
239 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda',
242 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
243 'enabled' =>
'isModEnabled("agenda")',
248 $this->menu[$r] = array(
251 'titre' =>
'NewAction',
252 'mainmenu' =>
'agenda',
253 'url' =>
'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create',
254 'langs' =>
'commercial',
256 'perms' =>
'($user->hasRight("agenda", "myactions", "create") || $user->hasRight("agenda", "allactions", "create"))',
257 'enabled' =>
'isModEnabled("agenda")',
263 $this->menu[$r] = array(
266 'titre' =>
'Calendar',
267 'mainmenu' =>
'agenda',
268 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda',
271 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
272 'enabled' =>
'isModEnabled("agenda")',
277 $this->menu[$r] = array(
280 'titre' =>
'MenuToDoMyActions',
281 'mainmenu' =>
'agenda',
282 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine',
285 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
286 'enabled' =>
'isModEnabled("agenda")',
291 $this->menu[$r] = array(
294 'titre' =>
'MenuDoneMyActions',
295 'mainmenu' =>
'agenda',
296 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine',
299 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
300 'enabled' =>
'isModEnabled("agenda")',
305 $this->menu[$r] = array(
308 'titre' =>
'MenuToDoActions',
309 'mainmenu' =>
'agenda',
310 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1',
313 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
314 'enabled' =>
'isModEnabled("agenda")',
319 $this->menu[$r] = array(
322 'titre' =>
'MenuDoneActions',
323 'mainmenu' =>
'agenda',
324 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1',
327 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
328 'enabled' =>
'isModEnabled("agenda")',
335 $this->menu[$r] = array(
339 'mainmenu' =>
'agenda',
340 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda',
343 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
344 'enabled' =>
'isModEnabled("agenda")',
349 $this->menu[$r] = array(
352 'titre' =>
'MenuToDoMyActions',
353 'mainmenu' =>
'agenda',
354 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine',
357 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
358 'enabled' =>
'isModEnabled("agenda")',
363 $this->menu[$r] = array(
366 'titre' =>
'MenuDoneMyActions',
367 'mainmenu' =>
'agenda',
368 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine',
371 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
372 'enabled' =>
'isModEnabled("agenda")',
377 $this->menu[$r] = array(
380 'titre' =>
'MenuToDoActions',
381 'mainmenu' =>
'agenda',
382 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1',
385 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
386 'enabled' =>
'isModEnabled("agenda")',
391 $this->menu[$r] = array(
394 'titre' =>
'MenuDoneActions',
395 'mainmenu' =>
'agenda',
396 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1',
399 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
400 'enabled' =>
'isModEnabled("agenda")',
406 $this->menu[$r] = array(
409 'titre' =>
'Reportings',
410 'mainmenu' =>
'agenda',
411 'url' =>
'/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda',
414 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
415 'enabled' =>
'isModEnabled("agenda")',
421 $this->menu[$r] = array(
424 'titre' =>
'Categories',
425 'mainmenu' =>
'agenda',
426 'url' =>
'/categories/categorie_list.php?mainmenu=agenda&leftmenu=agenda&type=10',
429 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
430 'enabled' =>
'isModEnabled("category") && getDolGlobalString("CATEGORY_EDIT_IN_MENU_NOT_IN_POPUP")',
442 $this->export_code[$r] = $this->rights_class.
'_'.$r;
443 $this->export_label[$r] =
"ExportDataset_event1";
444 $this->export_permission[$r] = array(array(
"agenda",
"export"));
445 $this->export_fields_array[$r] = array(
'ac.id' =>
"IdAgenda",
'ac.ref_ext' =>
"ExternalRef",
'ac.ref' =>
"Ref",
'ac.datec' =>
"DateCreation",
'ac.datep' =>
"DateActionBegin",
446 'ac.datep2' =>
"DateActionEnd",
'ac.location' =>
'Location',
'ac.label' =>
"Title",
'ac.note' =>
"Note",
'ac.percent' =>
"Percentage",
'ac.durationp' =>
"Duration",
447 '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",
448 'cac.libelle' =>
"ActionType",
'cac.code' =>
"Code",
449 's.rowid' =>
"IdCompany",
's.nom' =>
'CompanyName',
's.address' =>
'Address',
's.zip' =>
'Zip',
's.town' =>
'Town',
450 'co.code' =>
'CountryCode',
's.phone' =>
'Phone',
's.siren' =>
'ProfId1',
's.siret' =>
'ProfId2',
's.ape' =>
'ProfId3',
's.idprof4' =>
'ProfId4',
's.idprof5' =>
'ProfId5',
's.idprof6' =>
'ProfId6',
451 's.code_compta' =>
'CustomerAccountancyCode',
's.code_compta_fournisseur' =>
'SupplierAccountancyCode',
's.tva_intra' =>
'VATIntra',
452 'p.ref' =>
'ProjectRef',
456 $nbofallowedentities = count(explode(
',',
getEntity(
'agenda')));
457 if (
isModEnabled(
'multicompany') && $nbofallowedentities > 1) {
458 $this->export_fields_array[$r][
'ac.entity'] =
'Entity';
461 $this->export_TypeFields_array[$r] = array(
'ac.ref_ext' =>
"Text",
'ac.ref' =>
"Text",
'ac.datec' =>
"Date",
'ac.datep' =>
"Date",
462 'ac.datep2' =>
"Date",
'ac.location' =>
'Text',
'ac.label' =>
"Text",
'ac.note' =>
"Text",
'ac.percent' =>
"Numeric",
463 '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",
464 'cac.libelle' =>
"List:c_actioncomm:libelle:libelle",
'cac.code' =>
"Text",
465 's.nom' =>
'Text',
's.address' =>
'Text',
's.zip' =>
'Text',
's.town' =>
'Text',
466 'co.code' =>
'Text',
's.phone' =>
'Text',
's.siren' =>
'Text',
's.siret' =>
'Text',
's.ape' =>
'Text',
's.idprof4' =>
'Text',
's.idprof5' =>
'Text',
's.idprof6' =>
'Text',
467 's.code_compta' =>
'Text',
's.code_compta_fournisseur' =>
'Text',
's.tva_intra' =>
'Text',
468 'p.ref' =>
'Text',
'ac.entity' =>
'List:entity:label:rowid'
471 $this->export_entities_array[$r] = array(
'ac.id' =>
"action",
'ac.ref_ext' =>
"action",
'ac.ref' =>
"action",
'ac.datec' =>
"action",
'ac.datep' =>
"action",
472 '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",
473 's.rowid' =>
"company",
's.nom' =>
'company',
's.address' =>
'company',
's.zip' =>
'company',
's.town' =>
'company',
474 'co.code' =>
'company',
's.phone' =>
'company',
's.siren' =>
'company',
's.siret' =>
'company',
's.ape' =>
'company',
's.idprof4' =>
'company',
's.idprof5' =>
'company',
's.idprof6' =>
'company',
475 's.code_compta' =>
'company',
's.code_compta_fournisseur' =>
'company',
's.tva_intra' =>
'company',
476 'p.ref' =>
'project',
479 $keyforselect =
'actioncomm';
480 $keyforelement =
'action';
481 $keyforaliasextra =
'extra';
482 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
484 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
485 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'actioncomm as ac';
486 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'actioncomm_extrafields as extra ON ac.id = extra.fk_object';
487 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_actioncomm as cac on ac.fk_action = cac.id';
488 if (!empty($user) && !$user->hasRight(
'agenda',
'allactions',
'read')) {
489 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'actioncomm_resources acr on ac.id = acr.fk_actioncomm';
491 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'socpeople as sp on ac.fk_contact = sp.rowid';
492 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s on ac.fk_soc = s.rowid';
493 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
494 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
496 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uc ON ac.fk_user_author = uc.rowid';
497 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as co on s.fk_pays = co.rowid';
498 $this->export_sql_end[$r] .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = ac.fk_project";
499 $this->export_sql_end[$r] .=
' WHERE ac.entity IN ('.getEntity(
'agenda').
')';
500 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
501 $this->export_sql_end[$r] .=
' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).
' OR ac.fk_soc IS NULL)';
503 if (!empty($user) && !$user->hasRight(
'agenda',
'allactions',
'read')) {
504 $this->export_sql_end[$r] .=
' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);
506 $this->export_sql_end[$r] .=
' AND ac.entity IN ('.getEntity(
'agenda').
')';
507 $this->export_sql_order[$r] =
' ORDER BY ac.datep';
514 $this->import_code[$r] = $this->rights_class.
'_'.$r;
515 $this->import_label[$r] =
"ExportDataset_event1";
516 $this->import_icon[$r] = $this->picto;
517 $this->import_entities_array[$r] = array();
518 $this->import_tables_array[$r] = array(
'ac' => MAIN_DB_PREFIX.
'actioncomm',
'extra' => MAIN_DB_PREFIX.
'actioncomm_extrafields');
519 $this->import_tables_creator_array[$r] = array(
'ac' =>
'fk_user_author');
520 $this->import_fields_array[$r] = array(
521 'ac.ref_ext' =>
'ExternalRef',
523 'ac.datec' =>
'DateCreation',
524 'ac.datep' =>
'DateActionBegin',
525 'ac.datep2' =>
'DateActionEnd',
526 'ac.location' =>
'Location',
527 'ac.label' =>
'Title*',
529 'ac.percent' =>
'Percentage*',
530 'ac.transparency' =>
'Transparency',
531 'ac.priority' =>
'Priority',
532 'ac.fk_action' =>
'Code*',
533 'ac.fk_soc' =>
'ThirdPartyName',
534 'ac.fk_project' =>
'ProjectRef',
535 'ac.fk_user_mod' =>
'ModifiedBy',
536 'ac.fk_user_action' =>
'AffectedTo*',
537 'ac.fk_element' =>
'ElementID',
538 'ac.elementtype' =>
'ElementType',
540 $import_sample = array();
543 $import_extrafield_sample = array();
544 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'actioncomm' AND entity IN (0, ".
$conf->entity.
")";
545 $resql = $this->db->query($sql);
548 while ($obj = $this->db->fetch_object($resql)) {
549 $fieldname =
'extra.'.$obj->name;
550 $fieldlabel = ucfirst($obj->label);
551 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
556 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
557 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'actioncomm');
559 $this->import_convertvalue_array[$r] = array(
560 'ac.fk_soc' => array(
561 'rule' =>
'fetchidfromref',
562 'file' =>
'/societe/class/societe.class.php',
563 'class' =>
'Societe',
565 'element' =>
'ThirdParty'
567 'ac.fk_user_action' => array(
568 'rule' =>
'fetchidfromref',
569 'file' =>
'/user/class/user.class.php',
574 'ac.fk_user_mod' => array(
575 'rule' =>
'fetchidfromref',
576 'file' =>
'/user/class/user.class.php',
581 'ac.fk_action' => array(
582 'rule' =>
'fetchidfromcodeid',
583 'classfile' =>
'/comm/action/class/cactioncomm.class.php',
584 'class' =>
'CActionComm',
586 'dict' =>
'DictionaryActions'
588 'ac.fk_project' => array(
589 'rule' =>
'fetchidfromref',
590 'file' =>
'/projet/class/project.class.php',
591 'class' =>
'Project',
593 'element' =>
'Project'
598 $keyforselect =
'actioncomm';
599 $keyforelement =
'action';
600 $keyforaliasextra =
'extra';
601 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';