2008-01-08 09:14:20 +01:00
< ? php
/* Copyright ( C ) 2003 , 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2003 Jean - Louis Bergamo < jlb @ j1b . org >
2014-10-12 01:59:21 +02:00
* Copyright ( C ) 2004 - 2014 Laurent Destailleur < eldy @ users . sourceforge . net >
2008-01-08 09:14:20 +01:00
* Copyright ( C ) 2004 Sebastien Di Cintio < sdicintio @ ressource - toi . org >
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2009 - 2011 Regis Houssin < regis . houssin @ inodbox . com >
2015-07-16 22:16:11 +02:00
* Copyright ( C ) 2013 Cedric Gross < c . gross @ kreiz - it . fr >
* Copyright ( C ) 2015 Bahfir Abbes < bafbes @ gmail . com >
2017-01-13 16:08:49 +01:00
* Copyright ( C ) 2017 Juanjo Menent < jmenent @ 2 byte . es >
2024-03-13 00:30:25 +01:00
* Copyright ( C ) 2024 MDW < mdeweerd @ users . noreply . github . com >
2024-07-03 02:30:53 +02:00
* Copyright ( C ) 2024 Frédéric France < frederic . france @ free . fr >
2008-01-08 09:14:20 +01:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2008-01-08 09:14:20 +01:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2008-01-08 09:14:20 +01:00
*/
/**
2010-02-04 23:00:51 +01:00
* \defgroup agenda Module agenda
2014-01-20 02:21:30 +01:00
* \brief Module to manage agenda and events
2011-10-24 14:11:49 +02:00
* \file htdocs / core / modules / modAgenda . class . php
2010-02-04 23:00:51 +01:00
* \ingroup agenda
2021-03-20 13:55:43 +01:00
* \brief Description and activation file for the module agenda
2009-07-22 22:42:31 +02:00
*/
2020-01-16 02:54:00 +01:00
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php' ;
2008-01-08 09:14:20 +01:00
/**
2014-01-20 02:21:30 +01:00
* Class to describe and enable / disable module Agenda
2009-07-22 22:42:31 +02:00
*/
2008-01-08 09:14:20 +01:00
class modAgenda extends DolibarrModules
{
2009-07-22 22:42:31 +02:00
/**
2011-08-31 13:07:16 +02:00
* Constructor . Define names , constants , directories , boxes , permissions
*
2012-01-04 21:23:50 +01:00
* @ param DoliDB $db Database handler
2009-07-22 22:42:31 +02:00
*/
2019-02-25 20:35:59 +01:00
public function __construct ( $db )
2009-07-22 22:42:31 +02:00
{
2016-06-06 17:51:39 +02:00
global $conf , $user ;
2013-09-25 21:36:40 +02:00
2012-01-04 21:23:50 +01:00
$this -> db = $db ;
2009-07-22 22:42:31 +02:00
$this -> numero = 2400 ;
2008-02-19 20:10:24 +01:00
2009-07-22 22:42:31 +02:00
$this -> family = " projects " ;
2023-05-10 13:09:44 +02:00
$this -> module_position = '16' ;
2008-10-01 21:10:17 +02:00
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
2019-01-27 11:55:16 +01:00
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
2016-04-08 14:28:49 +02:00
$this -> description = " Follow events or rendez-vous. Record manual events into Agendas or let application record automatic events for log tracking. " ;
2017-08-22 18:34:58 +02:00
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this -> version = 'dolibarr' ;
2008-10-01 21:10:17 +02:00
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this -> const_name = 'MAIN_MODULE_' . strtoupper ( $this -> name );
2020-01-16 02:54:00 +01:00
$this -> picto = 'action' ;
2009-03-12 02:44:02 +01:00
2009-07-22 22:42:31 +02:00
// Data directories to create when module is enabled
$this -> dirs = array ( " /agenda/temp " );
2009-03-12 02:44:02 +01:00
2009-07-22 22:42:31 +02:00
// Config pages
2015-07-16 22:16:11 +02:00
$this -> config_page_url = array ( " agenda_other.php " );
2009-03-12 02:44:02 +01:00
2018-07-09 10:08:27 +02:00
// Dependencies
2020-01-16 02:54:00 +01:00
$this -> hidden = false ; // A condition to hide module
$this -> depends = array (); // List of module class names as string that must be enabled if this module is enabled
$this -> requiredby = array (); // List of module ids to disable if this one is disabled
$this -> conflictwith = array (); // List of module class names as string this module is in conflict with
2024-02-08 15:31:27 +01:00
$this -> langfiles = array ( " companies " , " project " );
2022-09-27 20:48:47 +02:00
$this -> phpmin = array ( 7 , 0 ); // Minimum version of PHP required by module
2024-05-22 13:10:39 +02:00
$this -> enabled_bydefault = true ; // Will be enabled during install
2009-03-12 02:44:02 +01:00
2017-01-13 16:08:49 +01:00
// Module parts
2020-10-31 14:32:18 +01:00
$this -> module_parts = array ();
2017-01-13 16:08:49 +01:00
2015-09-07 15:40:55 +02:00
// Constants
2020-10-31 14:32:18 +01:00
//-----------
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
// );
2009-07-22 22:42:31 +02:00
$this -> const = array ();
2024-09-29 03:10:45 +02:00
$r = 0 ;
// $this->const[$r] = ["ACTION_EVENT_ADDON_PDF", "chaine", "standard", 'Name of PDF model of actioncomm', 0];
// $this->const[] = array('AGENDA_DEFAULT_FILTER_TYPE', 'chaine', 'AC_NON_AUTO', 'Default filter for type of event on agenda', 0, 'current');
2020-01-16 02:54:00 +01:00
$sqlreadactions = " SELECT code, label, description FROM " . MAIN_DB_PREFIX . " c_action_trigger ORDER by rang " ;
2016-04-08 17:07:25 +02:00
$resql = $this -> db -> query ( $sqlreadactions );
2021-02-23 22:03:23 +01:00
if ( $resql ) {
while ( $obj = $this -> db -> fetch_object ( $resql )) {
2020-10-31 14:32:18 +01:00
//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).
2021-02-23 22:03:23 +01:00
if ( preg_match ( '/^TASK_/' , $obj -> code )) {
continue ; // We don't track such events by default.
}
2020-10-31 14:32:18 +01:00
//if (preg_match('/^_MODIFY/',$obj->code)) continue; // We don't track such events by default.
$this -> const [] = array ( 'MAIN_AGENDA_ACTIONAUTO_' . $obj -> code , " chaine " , " 1 " , '' , 0 , 'current' );
}
2020-05-21 15:05:19 +02:00
} else {
2024-07-03 02:30:53 +02:00
dol_print_error ( $this -> db , $this -> db -> lasterror ());
2016-04-08 17:07:25 +02:00
}
2024-08-13 01:59:00 +02:00
//$this->const[] = array("MAIN_AGENDA_XCAL_EXPORTKEY", "chaine", "123456", "Securekey for the public link");
2017-06-27 04:25:41 +02:00
2009-03-12 02:44:02 +01:00
// New pages on tabs
// -----------------
2009-07-22 22:42:31 +02:00
$this -> tabs = array ();
2009-03-12 02:44:02 +01:00
// Boxes
2009-07-22 22:42:31 +02:00
//------
2023-05-05 13:42:38 +02:00
$this -> boxes = array (
2024-02-27 15:29:44 +01:00
0 => array ( 'file' => 'box_actions.php' , 'enabledbydefaulton' => 'Home' ),
1 => array ( 'file' => 'box_actions_future.php' , 'enabledbydefaulton' => 'Home' )
2023-05-05 13:42:38 +02:00
);
2009-07-22 22:42:31 +02:00
2017-08-03 11:42:22 +02:00
// Cronjobs
//------------
2020-01-16 02:54:00 +01:00
$datestart = dol_now ();
2017-08-03 11:42:22 +02:00
$this -> cronjobs = array (
2024-02-27 15:29:44 +01:00
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 ),
2017-08-03 11:42:22 +02:00
);
2009-07-22 22:42:31 +02:00
// Permissions
//------------
$this -> rights = array ();
$this -> rights_class = 'agenda' ;
2020-01-16 02:54:00 +01:00
$r = 0 ;
2009-07-22 22:42:31 +02:00
// $this->rights[$r][0] Id permission (unique tous modules confondus)
2024-01-13 19:48:20 +01:00
// $this->rights[$r][1] Libelle par default si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)
2009-07-22 22:42:31 +02:00
// $this->rights[$r][2] Non utilise
2024-01-13 19:48:20 +01:00
// $this->rights[$r][3] 1=Permis par default, 0=Non permis par default
2009-07-22 22:42:31 +02:00
// $this->rights[$r][4] Niveau 1 pour nommer permission dans code
// $this->rights[$r][5] Niveau 2 pour nommer permission dans code
2008-01-14 21:54:15 +01:00
// $r++;
2009-03-12 02:44:02 +01:00
2009-07-22 22:42:31 +02:00
$this -> rights [ $r ][ 0 ] = 2401 ;
$this -> rights [ $r ][ 1 ] = 'Read actions/tasks linked to his account' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
2016-06-04 12:16:30 +02:00
$this -> rights [ $r ][ 3 ] = 0 ;
2009-07-22 22:42:31 +02:00
$this -> rights [ $r ][ 4 ] = 'myactions' ;
$this -> rights [ $r ][ 5 ] = 'read' ;
$r ++ ;
$this -> rights [ $r ][ 0 ] = 2402 ;
2009-11-13 05:10:59 +01:00
$this -> rights [ $r ][ 1 ] = 'Create/modify actions/tasks linked to his account' ;
2009-07-22 22:42:31 +02:00
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'myactions' ;
$this -> rights [ $r ][ 5 ] = 'create' ;
$r ++ ;
2009-11-13 05:10:59 +01:00
2009-07-22 22:42:31 +02:00
$this -> rights [ $r ][ 0 ] = 2403 ;
2009-11-13 05:10:59 +01:00
$this -> rights [ $r ][ 1 ] = 'Delete actions/tasks linked to his account' ;
2009-11-10 13:36:30 +01:00
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'myactions' ;
2009-11-13 05:10:59 +01:00
$this -> rights [ $r ][ 5 ] = 'delete' ;
2009-11-10 13:36:30 +01:00
$r ++ ;
$this -> rights [ $r ][ 0 ] = 2411 ;
2009-07-22 22:42:31 +02:00
$this -> rights [ $r ][ 1 ] = 'Read actions/tasks of others' ;
$this -> rights [ $r ][ 2 ] = 'r' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'allactions' ;
$this -> rights [ $r ][ 5 ] = 'read' ;
$r ++ ;
2009-11-10 13:36:30 +01:00
$this -> rights [ $r ][ 0 ] = 2412 ;
2009-11-13 05:10:59 +01:00
$this -> rights [ $r ][ 1 ] = 'Create/modify actions/tasks of others' ;
2009-07-22 22:42:31 +02:00
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'allactions' ;
$this -> rights [ $r ][ 5 ] = 'create' ;
$r ++ ;
2009-11-13 05:10:59 +01:00
2009-11-10 13:36:30 +01:00
$this -> rights [ $r ][ 0 ] = 2413 ;
2009-11-13 05:10:59 +01:00
$this -> rights [ $r ][ 1 ] = 'Delete actions/tasks of others' ;
2009-11-10 13:36:30 +01:00
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'allactions' ;
2009-11-13 05:10:59 +01:00
$this -> rights [ $r ][ 5 ] = 'delete' ;
2009-11-10 13:36:30 +01:00
$r ++ ;
2009-07-22 22:42:31 +02:00
2013-03-25 18:26:35 +01:00
$this -> rights [ $r ][ 0 ] = 2414 ;
$this -> rights [ $r ][ 1 ] = 'Export actions/tasks of others' ;
$this -> rights [ $r ][ 2 ] = 'w' ;
$this -> rights [ $r ][ 3 ] = 0 ;
$this -> rights [ $r ][ 4 ] = 'export' ;
2013-09-25 21:36:40 +02:00
2009-07-26 02:21:44 +02:00
// Main menu entries
2020-01-16 02:54:00 +01:00
$this -> menu = array (); // List of menus to add
$r = 0 ;
2009-03-12 02:44:02 +01:00
2010-06-09 20:25:20 +02:00
// Add here entries to declare new menus
// Example to declare the Top Menu entry:
// $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu
// 'type'=>'top', // This is a Top menu entry
// 'titre'=>'MyModule top menu',
// 'mainmenu'=>'mymodule',
// 'url'=>'/mymodule/pagetop.php',
// 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
// 'position'=>100,
// 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
2024-03-19 22:02:42 +01:00
// 'perms'=>'1', // Use 'perms'=>'$user->hasRight('mymodule', 'level1', 'level2') if you want your menu with a permission rules
2010-06-09 20:25:20 +02:00
// 'target'=>'',
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
// $r++;
2024-11-28 16:44:19 +01:00
// TODO Move the top menu entry into the code part (eldy_menu.php and auguria.sql) so we can have a top menu shown for resource module only.
2020-01-16 02:54:00 +01:00
$this -> menu [ $r ] = array (
2024-02-27 15:29:44 +01:00
'fk_menu' => 0 ,
'type' => 'top' ,
'titre' => 'TMenuAgenda' ,
2023-10-13 15:00:51 +02:00
'prefix' => img_picto ( '' , $this -> picto , 'class="pictofixedwidth"' ),
2024-02-27 15:29:44 +01:00
'mainmenu' => 'agenda' ,
'url' => '/comm/action/index.php' ,
'langs' => 'agenda' ,
'position' => 86 ,
'perms' => '$user->hasRight("agenda", "myactions", "read") || $user->hasRight("resource", "read")' ,
'enabled' => 'isModEnabled("agenda") || isModEnabled("resource")' ,
'target' => '' ,
'user' => 2 ,
2020-10-31 14:32:18 +01:00
);
$r ++ ;
2009-03-12 02:44:02 +01:00
2020-01-18 16:17:07 +01:00
$this -> menu [ $r ] = array (
2024-02-27 15:29:44 +01:00
'fk_menu' => 'r=0' ,
'type' => 'left' ,
'titre' => 'Actions' ,
2021-02-06 17:18:00 +01:00
'prefix' => img_picto ( '' , $this -> picto , 'class="paddingright pictofixedwidth"' ),
2024-02-27 15:29:44 +01:00
'mainmenu' => 'agenda' ,
'url' => '/comm/action/index.php?mainmenu=agenda&leftmenu=agenda' ,
'langs' => 'agenda' ,
'position' => 100 ,
'perms' => '$user->hasRight("agenda", "myactions", "read")' ,
'enabled' => 'isModEnabled("agenda")' ,
'target' => '' ,
'user' => 2 ,
2019-11-13 18:44:11 +01:00
);
2010-04-05 20:41:34 +02:00
$r ++ ;
2020-01-18 16:17:07 +01:00
$this -> menu [ $r ] = array (
2024-02-27 15:29:44 +01:00
'fk_menu' => 'r=1' ,
'type' => 'left' ,
'titre' => 'NewAction' ,
'mainmenu' => 'agenda' ,
2025-01-09 13:54:25 +01:00
'url' => '/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create' ,
2024-02-27 15:29:44 +01:00
'langs' => 'commercial' ,
'position' => 101 ,
'perms' => '($user->hasRight("agenda", "myactions", "create") || $user->hasRight("agenda", "allactions", "create"))' ,
'enabled' => 'isModEnabled("agenda")' ,
'target' => '' ,
'user' => 2
2019-11-13 18:44:11 +01:00
);
2010-04-05 20:41:34 +02:00
$r ++ ;
// Calendar
2020-01-18 16:17:07 +01:00
$this -> menu [ $r ] = array (
2024-02-27 15:29:44 +01:00
'fk_menu' => 'r=1' ,
'type' => 'left' ,
'titre' => 'Calendar' ,
'mainmenu' => 'agenda' ,
2024-06-10 14:23:07 +02:00
'url' => '/comm/action/index.php?mainmenu=agenda&leftmenu=agenda' ,
2024-02-27 15:29:44 +01:00
'langs' => 'agenda' ,
'position' => 140 ,
'perms' => '$user->hasRight("agenda", "myactions", "read")' ,
'enabled' => 'isModEnabled("agenda")' ,
'target' => '' ,
'user' => 2
2019-11-13 18:44:11 +01:00
);
2010-04-05 20:41:34 +02:00
$r ++ ;
2020-01-18 16:17:07 +01:00
$this -> menu [ $r ] = array (
2024-02-27 15:29:44 +01:00
'fk_menu' => 'r=3' ,
'type' => 'left' ,
'titre' => 'MenuToDoMyActions' ,
'mainmenu' => 'agenda' ,
2024-06-10 14:23:07 +02:00
'url' => '/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine' ,
2024-02-27 15:29:44 +01:00
'langs' => 'agenda' ,
'position' => 141 ,
'perms' => '$user->hasRight("agenda", "myactions", "read")' ,
'enabled' => 'isModEnabled("agenda")' ,
'target' => '' ,
'user' => 2
2019-11-13 18:44:11 +01:00
);
2010-04-05 20:41:34 +02:00
$r ++ ;
2020-01-18 16:17:07 +01:00
$this -> menu [ $r ] = array (
2024-02-27 15:29:44 +01:00
'fk_menu' => 'r=3' ,
'type' => 'left' ,
'titre' => 'MenuDoneMyActions' ,
'mainmenu' => 'agenda' ,
2024-06-10 14:23:07 +02:00
'url' => '/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine' ,
2024-02-27 15:29:44 +01:00
'langs' => 'agenda' ,
'position' => 142 ,
'perms' => '$user->hasRight("agenda", "myactions", "read")' ,
'enabled' => 'isModEnabled("agenda")' ,
'target' => '' ,
'user' => 2
2019-11-13 18:44:11 +01:00
);
2010-04-05 20:41:34 +02:00
$r ++ ;
2020-01-18 16:17:07 +01:00
$this -> menu [ $r ] = array (
2024-02-27 15:29:44 +01:00
'fk_menu' => 'r=3' ,
'type' => 'left' ,
'titre' => 'MenuToDoActions' ,
'mainmenu' => 'agenda' ,
2024-06-10 14:23:07 +02:00
'url' => '/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1' ,
2024-02-27 15:29:44 +01:00
'langs' => 'agenda' ,
'position' => 143 ,
'perms' => '$user->hasRight("agenda", "allactions", "read")' ,
'enabled' => 'isModEnabled("agenda")' ,
'target' => '' ,
'user' => 2
2019-11-13 18:44:11 +01:00
);
2010-04-05 20:41:34 +02:00
$r ++ ;
2020-01-18 16:17:07 +01:00
$this -> menu [ $r ] = array (
2024-02-27 15:29:44 +01:00
'fk_menu' => 'r=3' ,
'type' => 'left' ,
'titre' => 'MenuDoneActions' ,
'mainmenu' => 'agenda' ,
2024-06-10 14:23:07 +02:00
'url' => '/comm/action/index.php?mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1' ,
2024-02-27 15:29:44 +01:00
'langs' => 'agenda' ,
'position' => 144 ,
'perms' => '$user->hasRight("agenda", "allactions", "read")' ,
'enabled' => 'isModEnabled("agenda")' ,
'target' => '' ,
'user' => 2
2019-11-13 18:44:11 +01:00
);
2018-04-20 13:23:34 +02:00
2010-04-05 20:41:34 +02:00
// List
2018-04-20 13:23:34 +02:00
$r ++ ;
2020-01-18 16:17:07 +01:00
$this -> menu [ $r ] = array (
2024-02-27 15:29:44 +01:00
'fk_menu' => 'r=1' ,
'type' => 'left' ,
'titre' => 'List' ,
'mainmenu' => 'agenda' ,
'url' => '/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda' ,
'langs' => 'agenda' ,
'position' => 110 ,
'perms' => '$user->hasRight("agenda", "myactions", "read")' ,
'enabled' => 'isModEnabled("agenda")' ,
'target' => '' ,
'user' => 2
2019-11-13 18:44:11 +01:00
);
2010-04-05 20:41:34 +02:00
$r ++ ;
2020-01-18 16:17:07 +01:00
$this -> menu [ $r ] = array (
2024-02-27 15:29:44 +01:00
'fk_menu' => 'r=8' ,
'type' => 'left' ,
'titre' => 'MenuToDoMyActions' ,
'mainmenu' => 'agenda' ,
'url' => '/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine' ,
'langs' => 'agenda' ,
'position' => 111 ,
'perms' => '$user->hasRight("agenda", "myactions", "read")' ,
'enabled' => 'isModEnabled("agenda")' ,
'target' => '' ,
'user' => 2
2019-11-13 18:44:11 +01:00
);
2010-04-05 20:41:34 +02:00
$r ++ ;
2020-01-18 16:17:07 +01:00
$this -> menu [ $r ] = array (
2024-02-27 15:29:44 +01:00
'fk_menu' => 'r=8' ,
'type' => 'left' ,
'titre' => 'MenuDoneMyActions' ,
'mainmenu' => 'agenda' ,
'url' => '/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine' ,
'langs' => 'agenda' ,
'position' => 112 ,
'perms' => '$user->hasRight("agenda", "myactions", "read")' ,
'enabled' => 'isModEnabled("agenda")' ,
'target' => '' ,
'user' => 2
2019-11-13 18:44:11 +01:00
);
2010-04-05 20:41:34 +02:00
$r ++ ;
2020-01-18 16:17:07 +01:00
$this -> menu [ $r ] = array (
2024-02-27 15:29:44 +01:00
'fk_menu' => 'r=8' ,
'type' => 'left' ,
'titre' => 'MenuToDoActions' ,
'mainmenu' => 'agenda' ,
'url' => '/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1' ,
'langs' => 'agenda' ,
'position' => 113 ,
'perms' => '$user->hasRight("agenda", "allactions", "read")' ,
'enabled' => 'isModEnabled("agenda")' ,
'target' => '' ,
'user' => 2
2019-11-13 18:44:11 +01:00
);
2010-04-05 20:41:34 +02:00
$r ++ ;
2020-01-18 16:17:07 +01:00
$this -> menu [ $r ] = array (
2024-02-27 15:29:44 +01:00
'fk_menu' => 'r=8' ,
'type' => 'left' ,
'titre' => 'MenuDoneActions' ,
'mainmenu' => 'agenda' ,
'url' => '/comm/action/list.php?mode=show_list&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1' ,
'langs' => 'agenda' ,
'position' => 114 ,
'perms' => '$user->hasRight("agenda", "allactions", "read")' ,
'enabled' => 'isModEnabled("agenda")' ,
'target' => '' ,
'user' => 2
2019-11-13 18:44:11 +01:00
);
2010-04-05 20:41:34 +02:00
$r ++ ;
// Reports
2020-01-18 16:17:07 +01:00
$this -> menu [ $r ] = array (
2024-02-27 15:29:44 +01:00
'fk_menu' => 'r=1' ,
'type' => 'left' ,
'titre' => 'Reportings' ,
'mainmenu' => 'agenda' ,
'url' => '/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda' ,
'langs' => 'agenda' ,
'position' => 160 ,
'perms' => '$user->hasRight("agenda", "allactions", "read")' ,
'enabled' => 'isModEnabled("agenda")' ,
'target' => '' ,
'user' => 2
2019-11-13 18:44:11 +01:00
);
$r ++ ;
// Categories
2020-01-18 16:17:07 +01:00
$this -> menu [ $r ] = array (
2019-11-13 18:44:11 +01:00
'fk_menu' => 'r=1' ,
'type' => 'left' ,
'titre' => 'Categories' ,
'mainmenu' => 'agenda' ,
2024-02-27 15:29:44 +01:00
'url' => '/categories/index.php?mainmenu=agenda&leftmenu=agenda&type=10' ,
2019-11-13 18:44:11 +01:00
'langs' => 'agenda' ,
'position' => 170 ,
2023-09-12 13:19:48 +02:00
'perms' => '$user->hasRight("agenda", "allactions", "read")' ,
2024-02-27 15:29:44 +01:00
'enabled' => 'isModEnabled("category")' ,
2019-11-13 18:44:11 +01:00
'target' => '' ,
'user' => 2
);
2010-04-05 20:41:34 +02:00
$r ++ ;
2008-01-14 21:54:15 +01:00
// Exports
2009-07-22 22:42:31 +02:00
//--------
2020-01-16 02:54:00 +01:00
$r = 0 ;
2008-01-08 09:14:20 +01:00
2013-03-25 18:26:35 +01:00
$r ++ ;
2020-01-16 02:54:00 +01:00
$this -> export_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> export_label [ $r ] = " ExportDataset_event1 " ;
$this -> export_permission [ $r ] = array ( array ( " agenda " , " export " ));
2024-02-27 15:29:44 +01:00
$this -> export_fields_array [ $r ] = array ( 'ac.id' => " IdAgenda " , 'ac.ref_ext' => " ExternalRef " , 'ac.ref' => " Ref " , 'ac.datec' => " DateCreation " , 'ac.datep' => " DateActionBegin " ,
'ac.datep2' => " DateActionEnd " , 'ac.location' => 'Location' , 'ac.label' => " Title " , 'ac.note' => " Note " , 'ac.percent' => " Percentage " , 'ac.durationp' => " Duration " ,
'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 " ,
'cac.libelle' => " ActionType " , 'cac.code' => " Code " ,
's.rowid' => " IdCompany " , 's.nom' => 'CompanyName' , 's.address' => 'Address' , 's.zip' => 'Zip' , 's.town' => 'Town' ,
'co.code' => 'CountryCode' , 's.phone' => 'Phone' , 's.siren' => 'ProfId1' , 's.siret' => 'ProfId2' , 's.ape' => 'ProfId3' , 's.idprof4' => 'ProfId4' , 's.idprof5' => 'ProfId5' , 's.idprof6' => 'ProfId6' ,
's.code_compta' => 'CustomerAccountancyCode' , 's.code_compta_fournisseur' => 'SupplierAccountancyCode' , 's.tva_intra' => 'VATIntra' ,
2020-01-07 10:56:46 +01:00
'p.ref' => 'ProjectRef' ,
);
2024-02-08 15:31:27 +01:00
// Add multicompany field
if ( getDolGlobalString ( 'MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED' )) {
$nbofallowedentities = count ( explode ( ',' , getEntity ( 'agenda' )));
if ( isModEnabled ( 'multicompany' ) && $nbofallowedentities > 1 ) {
$this -> export_fields_array [ $r ][ 'ac.entity' ] = 'Entity' ;
}
}
2024-02-27 15:29:44 +01:00
$this -> export_TypeFields_array [ $r ] = array ( 'ac.ref_ext' => " Text " , 'ac.ref' => " Text " , 'ac.datec' => " Date " , 'ac.datep' => " Date " ,
'ac.datep2' => " Date " , 'ac.location' => 'Text' , 'ac.label' => " Text " , 'ac.note' => " Text " , 'ac.percent' => " Numeric " ,
'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 " ,
'cac.libelle' => " List:c_actioncomm:libelle:libelle " , 'cac.code' => " Text " ,
's.nom' => 'Text' , 's.address' => 'Text' , 's.zip' => 'Text' , 's.town' => 'Text' ,
'co.code' => 'Text' , 's.phone' => 'Text' , 's.siren' => 'Text' , 's.siret' => 'Text' , 's.ape' => 'Text' , 's.idprof4' => 'Text' , 's.idprof5' => 'Text' , 's.idprof6' => 'Text' ,
's.code_compta' => 'Text' , 's.code_compta_fournisseur' => 'Text' , 's.tva_intra' => 'Text' ,
'p.ref' => 'Text' , 'ac.entity' => 'List:entity:label:rowid'
2024-02-08 15:31:27 +01:00
2020-01-07 10:56:46 +01:00
);
2024-02-27 15:29:44 +01:00
$this -> export_entities_array [ $r ] = array ( 'ac.id' => " action " , 'ac.ref_ext' => " action " , 'ac.ref' => " action " , 'ac.datec' => " action " , 'ac.datep' => " action " ,
'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 " ,
's.rowid' => " company " , 's.nom' => 'company' , 's.address' => 'company' , 's.zip' => 'company' , 's.town' => 'company' ,
'co.code' => 'company' , 's.phone' => 'company' , 's.siren' => 'company' , 's.siret' => 'company' , 's.ape' => 'company' , 's.idprof4' => 'company' , 's.idprof5' => 'company' , 's.idprof6' => 'company' ,
's.code_compta' => 'company' , 's.code_compta_fournisseur' => 'company' , 's.tva_intra' => 'company' ,
2020-01-07 10:56:46 +01:00
'p.ref' => 'project' ,
);
2013-03-25 18:26:35 +01:00
2023-12-04 12:07:31 +01:00
$keyforselect = 'actioncomm' ;
$keyforelement = 'action' ;
$keyforaliasextra = 'extra' ;
2021-04-16 10:26:35 +02:00
include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php' ;
2020-01-16 02:54:00 +01:00
$this -> export_sql_start [ $r ] = 'SELECT DISTINCT ' ;
$this -> export_sql_end [ $r ] = ' FROM ' . MAIN_DB_PREFIX . 'actioncomm as ac' ;
2021-04-16 10:26:35 +02:00
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'actioncomm_extrafields as extra ON ac.id = extra.fk_object' ;
2020-01-16 02:54:00 +01:00
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_actioncomm as cac on ac.fk_action = cac.id' ;
2023-06-23 12:12:58 +02:00
if ( ! empty ( $user ) && ! $user -> hasRight ( 'agenda' , 'allactions' , 'read' )) {
2021-02-23 22:03:23 +01:00
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'actioncomm_resources acr on ac.id = acr.fk_actioncomm' ;
}
2020-01-16 02:54:00 +01:00
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople as sp on ac.fk_contact = sp.rowid' ;
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s on ac.fk_soc = s.rowid' ;
2023-06-23 12:12:58 +02:00
if ( ! empty ( $user ) && ! $user -> hasRight ( 'societe' , 'client' , 'voir' )) {
2021-02-23 22:03:23 +01:00
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe_commerciaux as sc ON sc.fk_soc = s.rowid' ;
}
2024-02-08 15:31:27 +01:00
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'user as uc ON ac.fk_user_author = uc.rowid' ;
2020-01-16 02:54:00 +01:00
$this -> export_sql_end [ $r ] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as co on s.fk_pays = co.rowid' ;
$this -> export_sql_end [ $r ] .= " LEFT JOIN " . MAIN_DB_PREFIX . " projet as p ON p.rowid = ac.fk_project " ;
$this -> export_sql_end [ $r ] .= ' WHERE ac.entity IN (' . getEntity ( 'agenda' ) . ')' ;
2023-10-20 02:20:52 +02:00
if ( ! empty ( $user ) && ! $user -> hasRight ( 'societe' , 'client' , 'voir' )) {
2021-02-23 22:03:23 +01:00
$this -> export_sql_end [ $r ] .= ' AND (sc.fk_user = ' . ( empty ( $user ) ? 0 : $user -> id ) . ' OR ac.fk_soc IS NULL)' ;
}
2023-06-23 12:12:58 +02:00
if ( ! empty ( $user ) && ! $user -> hasRight ( 'agenda' , 'allactions' , 'read' )) {
2021-02-23 22:03:23 +01:00
$this -> export_sql_end [ $r ] .= ' AND acr.fk_element = ' . ( empty ( $user ) ? 0 : $user -> id );
}
2024-02-08 15:31:27 +01:00
$this -> export_sql_end [ $r ] .= ' AND ac.entity IN (' . getEntity ( 'agenda' ) . ')' ;
2020-01-16 02:54:00 +01:00
$this -> export_sql_order [ $r ] = ' ORDER BY ac.datep' ;
2024-02-08 15:31:27 +01:00
// Imports
$r = 0 ;
// Import Events
$r ++ ;
$this -> import_code [ $r ] = $this -> rights_class . '_' . $r ;
$this -> import_label [ $r ] = " ExportDataset_event1 " ;
$this -> import_icon [ $r ] = $this -> picto ;
$this -> import_entities_array [ $r ] = array ();
$this -> import_tables_array [ $r ] = array ( 'ac' => MAIN_DB_PREFIX . 'actioncomm' , 'extra' => MAIN_DB_PREFIX . 'actioncomm_extrafields' );
$this -> import_tables_creator_array [ $r ] = array ( 'ac' => 'fk_user_author' ); // Fields to store import user id
$this -> import_fields_array [ $r ] = array (
'ac.ref_ext' => 'ExternalRef' ,
'ac.ref' => 'Ref*' ,
'ac.datec' => 'DateCreation' ,
'ac.datep' => 'DateActionBegin' ,
'ac.datep2' => 'DateActionEnd' ,
'ac.location' => 'Location' ,
'ac.label' => 'Title*' ,
'ac.note' => 'Note' ,
'ac.percent' => 'Percentage*' ,
'ac.transparency' => 'Transparency' ,
'ac.priority' => 'Priority' ,
'ac.fk_action' => 'Code*' ,
'ac.fk_soc' => 'ThirdPartyName' ,
'ac.fk_project' => 'ProjectRef' ,
'ac.fk_user_mod' => 'ModifiedBy' ,
'ac.fk_user_action' => 'AffectedTo*' ,
'ac.fk_element' => 'ElementID' ,
'ac.elementtype' => 'ElementType' ,
);
$import_sample = array ();
// Add extra fields
$import_extrafield_sample = array ();
$sql = " SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . " extrafields WHERE elementtype = 'actioncomm' AND entity IN (0, " . $conf -> entity . " ) " ;
$resql = $this -> db -> query ( $sql );
if ( $resql ) {
while ( $obj = $this -> db -> fetch_object ( $resql )) {
$fieldname = 'extra.' . $obj -> name ;
$fieldlabel = ucfirst ( $obj -> label );
$this -> import_fields_array [ $r ][ $fieldname ] = $fieldlabel . ( $obj -> fieldrequired ? '*' : '' );
}
}
// End add extra fields
$this -> import_examplevalues_array [ $r ] = array_merge ( $import_sample , $import_extrafield_sample );
$this -> import_fieldshidden_array [ $r ] = array ( 'extra.fk_object' => 'lastrowid-' . MAIN_DB_PREFIX . 'actioncomm' );
2024-02-08 15:33:11 +01:00
//$this->import_updatekeys_array[$r] = array('ac.fk_user_creat' => 'User');
2024-02-08 15:31:27 +01:00
$this -> import_convertvalue_array [ $r ] = array (
'ac.fk_soc' => array (
'rule' => 'fetchidfromref' ,
'file' => '/societe/class/societe.class.php' ,
'class' => 'Societe' ,
'method' => 'fetch' ,
'element' => 'ThirdParty'
),
'ac.fk_user_action' => array (
'rule' => 'fetchidfromref' ,
'file' => '/user/class/user.class.php' ,
'class' => 'User' ,
'method' => 'fetch' ,
'element' => 'user'
),
'ac.fk_user_mod' => array (
'rule' => 'fetchidfromref' ,
'file' => '/user/class/user.class.php' ,
'class' => 'User' ,
'method' => 'fetch' ,
'element' => 'user'
),
'ac.fk_action' => array (
'rule' => 'fetchidfromcodeid' ,
'classfile' => '/comm/action/class/cactioncomm.class.php' ,
'class' => 'CActionComm' ,
'method' => 'fetch' ,
'dict' => 'DictionaryActions'
)
);
// Import Event Extra Fields
2024-05-30 13:37:17 +02:00
$keyforselect = 'actioncomm' ;
$keyforelement = 'action' ;
$keyforaliasextra = 'extra' ;
2024-02-08 15:31:27 +01:00
include DOL_DOCUMENT_ROOT . '/core/extrafieldsinexport.inc.php' ;
2009-07-22 22:42:31 +02:00
}
2024-08-13 01:59:00 +02:00
/**
* Function called when module is enabled .
* The init function add constants , boxes , permissions and menus ( defined in constructor ) into Dolibarr database .
* It also creates data directories
*
* @ param string $options Options when enabling module ( '' , 'newboxdefonly' , 'noboxes' )
* @ return int 1 if OK , 0 if KO
*/
public function init ( $options = '' )
{
// Permissions
$this -> remove ( $options );
2025-02-04 04:54:54 +01:00
$sql = array ();
2024-08-13 01:59:00 +02:00
return $this -> _init ( $sql , $options );
}
2008-01-08 09:14:20 +01:00
}