53 $this->family =
"projects";
54 $this->module_position =
'16';
56 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
57 $this->
description =
"Follow events or rendez-vous. Record manual events into Agendas or let application record automatic events for log tracking.";
59 $this->version =
'dolibarr';
61 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
62 $this->picto =
'action';
65 $this->dirs = array(
"/agenda/temp");
68 $this->config_page_url = array(
"agenda_other.php");
71 $this->hidden =
false;
72 $this->depends = array();
73 $this->requiredby = array();
74 $this->conflictwith = array();
75 $this->langfiles = array(
"companies",
"project");
76 $this->phpmin = array(7, 0);
77 $this->enabled_bydefault =
true;
80 $this->module_parts = array();
88 $this->
const = array();
90 $sqlreadactions =
"SELECT code, label, description FROM ".MAIN_DB_PREFIX.
"c_action_trigger ORDER by rang";
91 $resql = $this->db->query($sqlreadactions);
93 while ($obj = $this->db->fetch_object($resql)) {
95 if (preg_match(
'/^TASK_/', $obj->code)) {
99 $this->
const[] = array(
'MAIN_AGENDA_ACTIONAUTO_'.$obj->code,
"chaine",
"1",
'', 0,
'current');
108 $this->tabs = array();
112 $this->boxes = array(
113 0 => array(
'file' =>
'box_actions.php',
'enabledbydefaulton' =>
'Home'),
114 1 => array(
'file' =>
'box_actions_future.php',
'enabledbydefaulton' =>
'Home')
120 $this->cronjobs = array(
121 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 $this->rights = array();
127 $this->rights_class =
'agenda';
138 $this->rights[$r][0] = 2401;
139 $this->rights[$r][1] =
'Read actions/tasks linked to his account';
140 $this->rights[$r][2] =
'r';
141 $this->rights[$r][3] = 0;
142 $this->rights[$r][4] =
'myactions';
143 $this->rights[$r][5] =
'read';
146 $this->rights[$r][0] = 2402;
147 $this->rights[$r][1] =
'Create/modify actions/tasks linked to his account';
148 $this->rights[$r][2] =
'w';
149 $this->rights[$r][3] = 0;
150 $this->rights[$r][4] =
'myactions';
151 $this->rights[$r][5] =
'create';
154 $this->rights[$r][0] = 2403;
155 $this->rights[$r][1] =
'Delete actions/tasks linked to his account';
156 $this->rights[$r][2] =
'w';
157 $this->rights[$r][3] = 0;
158 $this->rights[$r][4] =
'myactions';
159 $this->rights[$r][5] =
'delete';
162 $this->rights[$r][0] = 2411;
163 $this->rights[$r][1] =
'Read actions/tasks of others';
164 $this->rights[$r][2] =
'r';
165 $this->rights[$r][3] = 0;
166 $this->rights[$r][4] =
'allactions';
167 $this->rights[$r][5] =
'read';
170 $this->rights[$r][0] = 2412;
171 $this->rights[$r][1] =
'Create/modify actions/tasks of others';
172 $this->rights[$r][2] =
'w';
173 $this->rights[$r][3] = 0;
174 $this->rights[$r][4] =
'allactions';
175 $this->rights[$r][5] =
'create';
178 $this->rights[$r][0] = 2413;
179 $this->rights[$r][1] =
'Delete actions/tasks of others';
180 $this->rights[$r][2] =
'w';
181 $this->rights[$r][3] = 0;
182 $this->rights[$r][4] =
'allactions';
183 $this->rights[$r][5] =
'delete';
186 $this->rights[$r][0] = 2414;
187 $this->rights[$r][1] =
'Export actions/tasks of others';
188 $this->rights[$r][2] =
'w';
189 $this->rights[$r][3] = 0;
190 $this->rights[$r][4] =
'export';
193 $this->menu = array();
210 $this->menu[$r] = array(
213 'titre' =>
'TMenuAgenda',
214 'prefix' =>
img_picto(
'', $this->picto,
'class="pictofixedwidth"'),
215 'mainmenu' =>
'agenda',
216 'url' =>
'/comm/action/index.php',
219 'perms' =>
'$user->hasRight("agenda", "myactions", "read") || $user->hasRight("resource", "read")',
220 'enabled' =>
'isModEnabled("agenda") || isModEnabled("resource")',
226 $this->menu[$r] = array(
229 'titre' =>
'Actions',
230 'prefix' =>
img_picto(
'', $this->picto,
'class="paddingright pictofixedwidth"'),
231 'mainmenu' =>
'agenda',
232 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda',
235 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
236 'enabled' =>
'isModEnabled("agenda")',
241 $this->menu[$r] = array(
244 'titre' =>
'NewAction',
245 'mainmenu' =>
'agenda',
246 'url' =>
'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create',
247 'langs' =>
'commercial',
249 'perms' =>
'($user->hasRight("agenda", "myactions", "create") || $user->hasRight("agenda", "allactions", "create"))',
250 'enabled' =>
'isModEnabled("agenda")',
256 $this->menu[$r] = array(
259 'titre' =>
'Calendar',
260 'mainmenu' =>
'agenda',
261 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda',
264 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
265 'enabled' =>
'isModEnabled("agenda")',
270 $this->menu[$r] = array(
273 'titre' =>
'MenuToDoMyActions',
274 'mainmenu' =>
'agenda',
275 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine',
278 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
279 'enabled' =>
'isModEnabled("agenda")',
284 $this->menu[$r] = array(
287 'titre' =>
'MenuDoneMyActions',
288 'mainmenu' =>
'agenda',
289 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine',
292 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
293 'enabled' =>
'isModEnabled("agenda")',
298 $this->menu[$r] = array(
301 'titre' =>
'MenuToDoActions',
302 'mainmenu' =>
'agenda',
303 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1',
306 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
307 'enabled' =>
'isModEnabled("agenda")',
312 $this->menu[$r] = array(
315 'titre' =>
'MenuDoneActions',
316 'mainmenu' =>
'agenda',
317 'url' =>
'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1',
320 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
321 'enabled' =>
'isModEnabled("agenda")',
328 $this->menu[$r] = array(
332 'mainmenu' =>
'agenda',
333 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda',
336 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
337 'enabled' =>
'isModEnabled("agenda")',
342 $this->menu[$r] = array(
345 'titre' =>
'MenuToDoMyActions',
346 'mainmenu' =>
'agenda',
347 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine',
350 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
351 'enabled' =>
'isModEnabled("agenda")',
356 $this->menu[$r] = array(
359 'titre' =>
'MenuDoneMyActions',
360 'mainmenu' =>
'agenda',
361 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine',
364 'perms' =>
'$user->hasRight("agenda", "myactions", "read")',
365 'enabled' =>
'isModEnabled("agenda")',
370 $this->menu[$r] = array(
373 'titre' =>
'MenuToDoActions',
374 'mainmenu' =>
'agenda',
375 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1',
378 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
379 'enabled' =>
'isModEnabled("agenda")',
384 $this->menu[$r] = array(
387 'titre' =>
'MenuDoneActions',
388 'mainmenu' =>
'agenda',
389 'url' =>
'/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1',
392 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
393 'enabled' =>
'isModEnabled("agenda")',
399 $this->menu[$r] = array(
402 'titre' =>
'Reportings',
403 'mainmenu' =>
'agenda',
404 'url' =>
'/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda',
407 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
408 'enabled' =>
'isModEnabled("agenda")',
414 $this->menu[$r] = array(
417 'titre' =>
'Categories',
418 'mainmenu' =>
'agenda',
419 'url' =>
'/categories/index.php?mainmenu=agenda&leftmenu=agenda&type=10',
422 'perms' =>
'$user->hasRight("agenda", "allactions", "read")',
423 'enabled' =>
'isModEnabled("category")',
435 $this->export_code[$r] = $this->rights_class.
'_'.$r;
436 $this->export_label[$r] =
"ExportDataset_event1";
437 $this->export_permission[$r] = array(array(
"agenda",
"export"));
438 $this->export_fields_array[$r] = array(
'ac.id' =>
"IdAgenda",
'ac.ref_ext' =>
"ExternalRef",
'ac.ref' =>
"Ref",
'ac.datec' =>
"DateCreation",
'ac.datep' =>
"DateActionBegin",
439 'ac.datep2' =>
"DateActionEnd",
'ac.location' =>
'Location',
'ac.label' =>
"Title",
'ac.note' =>
"Note",
'ac.percent' =>
"Percentage",
'ac.durationp' =>
"Duration",
440 '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",
441 'cac.libelle' =>
"ActionType",
'cac.code' =>
"Code",
442 's.rowid' =>
"IdCompany",
's.nom' =>
'CompanyName',
's.address' =>
'Address',
's.zip' =>
'Zip',
's.town' =>
'Town',
443 'co.code' =>
'CountryCode',
's.phone' =>
'Phone',
's.siren' =>
'ProfId1',
's.siret' =>
'ProfId2',
's.ape' =>
'ProfId3',
's.idprof4' =>
'ProfId4',
's.idprof5' =>
'ProfId5',
's.idprof6' =>
'ProfId6',
444 's.code_compta' =>
'CustomerAccountancyCode',
's.code_compta_fournisseur' =>
'SupplierAccountancyCode',
's.tva_intra' =>
'VATIntra',
445 'p.ref' =>
'ProjectRef',
449 $nbofallowedentities = count(explode(
',',
getEntity(
'agenda')));
450 if (isModEnabled(
'multicompany') && $nbofallowedentities > 1) {
451 $this->export_fields_array[$r][
'ac.entity'] =
'Entity';
454 $this->export_TypeFields_array[$r] = array(
'ac.ref_ext' =>
"Text",
'ac.ref' =>
"Text",
'ac.datec' =>
"Date",
'ac.datep' =>
"Date",
455 'ac.datep2' =>
"Date",
'ac.location' =>
'Text',
'ac.label' =>
"Text",
'ac.note' =>
"Text",
'ac.percent' =>
"Numeric",
456 '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",
457 'cac.libelle' =>
"List:c_actioncomm:libelle:libelle",
'cac.code' =>
"Text",
458 's.nom' =>
'Text',
's.address' =>
'Text',
's.zip' =>
'Text',
's.town' =>
'Text',
459 'co.code' =>
'Text',
's.phone' =>
'Text',
's.siren' =>
'Text',
's.siret' =>
'Text',
's.ape' =>
'Text',
's.idprof4' =>
'Text',
's.idprof5' =>
'Text',
's.idprof6' =>
'Text',
460 's.code_compta' =>
'Text',
's.code_compta_fournisseur' =>
'Text',
's.tva_intra' =>
'Text',
461 'p.ref' =>
'Text',
'ac.entity' =>
'List:entity:label:rowid'
464 $this->export_entities_array[$r] = array(
'ac.id' =>
"action",
'ac.ref_ext' =>
"action",
'ac.ref' =>
"action",
'ac.datec' =>
"action",
'ac.datep' =>
"action",
465 '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",
466 's.rowid' =>
"company",
's.nom' =>
'company',
's.address' =>
'company',
's.zip' =>
'company',
's.town' =>
'company',
467 'co.code' =>
'company',
's.phone' =>
'company',
's.siren' =>
'company',
's.siret' =>
'company',
's.ape' =>
'company',
's.idprof4' =>
'company',
's.idprof5' =>
'company',
's.idprof6' =>
'company',
468 's.code_compta' =>
'company',
's.code_compta_fournisseur' =>
'company',
's.tva_intra' =>
'company',
469 'p.ref' =>
'project',
472 $keyforselect =
'actioncomm';
473 $keyforelement =
'action';
474 $keyforaliasextra =
'extra';
475 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';
477 $this->export_sql_start[$r] =
'SELECT DISTINCT ';
478 $this->export_sql_end[$r] =
' FROM '.MAIN_DB_PREFIX.
'actioncomm as ac';
479 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'actioncomm_extrafields as extra ON ac.id = extra.fk_object';
480 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_actioncomm as cac on ac.fk_action = cac.id';
481 if (!empty($user) && !$user->hasRight(
'agenda',
'allactions',
'read')) {
482 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'actioncomm_resources acr on ac.id = acr.fk_actioncomm';
484 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'socpeople as sp on ac.fk_contact = sp.rowid';
485 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s on ac.fk_soc = s.rowid';
486 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
487 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
489 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as uc ON ac.fk_user_author = uc.rowid';
490 $this->export_sql_end[$r] .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as co on s.fk_pays = co.rowid';
491 $this->export_sql_end[$r] .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = ac.fk_project";
492 $this->export_sql_end[$r] .=
' WHERE ac.entity IN ('.getEntity(
'agenda').
')';
493 if (!empty($user) && !$user->hasRight(
'societe',
'client',
'voir')) {
494 $this->export_sql_end[$r] .=
' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).
' OR ac.fk_soc IS NULL)';
496 if (!empty($user) && !$user->hasRight(
'agenda',
'allactions',
'read')) {
497 $this->export_sql_end[$r] .=
' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);
499 $this->export_sql_end[$r] .=
' AND ac.entity IN ('.getEntity(
'agenda').
')';
500 $this->export_sql_order[$r] =
' ORDER BY ac.datep';
507 $this->import_code[$r] = $this->rights_class.
'_'.$r;
508 $this->import_label[$r] =
"ExportDataset_event1";
509 $this->import_icon[$r] = $this->picto;
510 $this->import_entities_array[$r] = array();
511 $this->import_tables_array[$r] = array(
'ac' => MAIN_DB_PREFIX.
'actioncomm',
'extra' => MAIN_DB_PREFIX.
'actioncomm_extrafields');
512 $this->import_tables_creator_array[$r] = array(
'ac' =>
'fk_user_author');
513 $this->import_fields_array[$r] = array(
514 'ac.ref_ext' =>
'ExternalRef',
516 'ac.datec' =>
'DateCreation',
517 'ac.datep' =>
'DateActionBegin',
518 'ac.datep2' =>
'DateActionEnd',
519 'ac.location' =>
'Location',
520 'ac.label' =>
'Title*',
522 'ac.percent' =>
'Percentage*',
523 'ac.transparency' =>
'Transparency',
524 'ac.priority' =>
'Priority',
525 'ac.fk_action' =>
'Code*',
526 'ac.fk_soc' =>
'ThirdPartyName',
527 'ac.fk_project' =>
'ProjectRef',
528 'ac.fk_user_mod' =>
'ModifiedBy',
529 'ac.fk_user_action' =>
'AffectedTo*',
530 'ac.fk_element' =>
'ElementID',
531 'ac.elementtype' =>
'ElementType',
533 $import_sample = array();
536 $import_extrafield_sample = array();
537 $sql =
"SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX.
"extrafields WHERE elementtype = 'actioncomm' AND entity IN (0, ".$conf->entity.
")";
538 $resql = $this->db->query($sql);
541 while ($obj = $this->db->fetch_object($resql)) {
542 $fieldname =
'extra.'.$obj->name;
543 $fieldlabel = ucfirst($obj->label);
544 $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ?
'*' :
'');
549 $this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
550 $this->import_fieldshidden_array[$r] = array(
'extra.fk_object' =>
'lastrowid-'.MAIN_DB_PREFIX.
'actioncomm');
552 $this->import_convertvalue_array[$r] = array(
553 'ac.fk_soc' => array(
554 'rule' =>
'fetchidfromref',
555 'file' =>
'/societe/class/societe.class.php',
556 'class' =>
'Societe',
558 'element' =>
'ThirdParty'
560 'ac.fk_user_action' => array(
561 'rule' =>
'fetchidfromref',
562 'file' =>
'/user/class/user.class.php',
567 'ac.fk_user_mod' => array(
568 'rule' =>
'fetchidfromref',
569 'file' =>
'/user/class/user.class.php',
574 'ac.fk_action' => array(
575 'rule' =>
'fetchidfromcodeid',
576 'classfile' =>
'/comm/action/class/cactioncomm.class.php',
577 'class' =>
'CActionComm',
579 'dict' =>
'DictionaryActions'
584 $keyforselect =
'actioncomm';
585 $keyforelement =
'action';
586 $keyforaliasextra =
'extra';
587 include DOL_DOCUMENT_ROOT.
'/core/extrafieldsinexport.inc.php';