2004-10-19 22:19:58 +02:00
< ? php
2005-01-04 10:00:29 +01:00
/* Copyright ( C ) 2001 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2018-08-15 14:42:03 +02:00
* Copyright ( C ) 2004 - 2018 Laurent Destailleur < eldy @ users . sourceforge . net >
2005-09-06 09:11:19 +02:00
* Copyright ( C ) 2005 Simon TOSSER < simon @ kornog - computing . com >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2017 Regis Houssin < regis . houssin @ inodbox . com >
2014-02-26 16:55:42 +01:00
* Copyright ( C ) 2010 - 2013 Juanjo Menent < jmenent @ 2 byte . es >
2013-06-14 22:33:01 +02:00
* Copyright ( C ) 2013 Florian Henry < florian . henry @ open - concept . pro >
2014-08-08 14:25:14 +02:00
* Copyright ( C ) 2014 Cedric GROSS < c . gross @ kreiz - it . fr >
2020-07-24 11:53:44 +02:00
* Copyright ( C ) 2015 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2021-03-12 17:05:11 +01:00
* Copyright ( C ) 2018 - 2021 Frédéric France < frederic . france @ netlogic . fr >
2019-07-03 13:12:41 +02:00
* Copyright ( C ) 2019 Ferran Marcet < fmarcet @ 2 byte . es >
2002-04-29 20:01:16 +02: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
2002-04-29 20:01:16 +02: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 />.
2002-04-29 20:01:16 +02:00
*/
2006-09-16 02:14:11 +02:00
2004-12-25 20:54:16 +01:00
/**
2014-09-18 21:18:25 +02:00
* \file htdocs / comm / action / card . php
2008-10-06 23:31:05 +02:00
* \ingroup agenda
2011-02-02 14:29:54 +01:00
* \brief Page for event card
2008-10-06 23:31:05 +02:00
*/
2006-09-16 02:14:11 +02:00
2012-08-22 23:24:21 +02:00
require '../../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/agenda.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/cactioncomm.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php' ;
2020-08-26 12:48:12 +02:00
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncommreminder.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
2014-11-04 16:08:07 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
2015-06-08 12:39:25 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php' ;
2017-07-29 02:11:45 +02:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
2018-09-20 10:08:40 +02:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php' ;
2017-07-29 02:11:45 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php' ;
2012-12-08 12:49:20 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
2019-11-13 21:18:34 +01:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2004-10-30 04:01:06 +02:00
2018-05-26 19:03:41 +02:00
// Load translation files required by the page
2020-09-24 12:31:28 +02:00
$langs -> loadLangs ( array ( " companies " , " other " , " commercial " , " bills " , " orders " , " agenda " , " mails " ));
2002-05-09 16:57:48 +02:00
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2020-04-10 10:59:32 +02:00
$cancel = GETPOST ( 'cancel' , 'alpha' );
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
$socpeopleassigned = GETPOST ( 'socpeopleassigned' , 'array' );
$origin = GETPOST ( 'origin' , 'alpha' );
$originid = GETPOST ( 'originid' , 'int' );
2015-06-08 12:39:25 +02:00
$confirm = GETPOST ( 'confirm' , 'alpha' );
2009-08-28 03:14:35 +02:00
2020-09-04 14:18:48 +02:00
$fulldayevent = GETPOST ( 'fullday' , 'alpha' );
2016-06-28 13:25:47 +02:00
2020-09-04 14:18:48 +02:00
$aphour = GETPOST ( 'aphour' , 'int' );
$apmin = GETPOST ( 'apmin' , 'int' );
$p2hour = GETPOST ( 'p2hour' , 'int' );
$p2min = GETPOST ( 'p2min' , 'int' );
2016-06-28 13:25:47 +02:00
2020-09-04 14:18:48 +02:00
$addreminder = GETPOST ( 'addreminder' , 'alpha' );
$offsetvalue = GETPOST ( 'offsetvalue' , 'int' );
$offsetunit = GETPOST ( 'offsetunittype_duration' , 'aZ09' );
$remindertype = GETPOST ( 'selectremindertype' , 'aZ09' );
$modelmail = GETPOST ( 'actioncommsendmodel_mail' , 'int' );
2021-09-01 17:10:26 +02:00
$complete = GETPOST ( 'complete' , 'alpha' ); // 'na' must be allowed
2022-10-14 09:54:47 +02:00
$private = GETPOST ( 'private' , 'alphanohtml' );
2021-09-01 17:10:26 +02:00
if ( $complete == 'na' || $complete == - 2 ) {
$complete = - 1 ;
}
2020-08-25 12:40:29 +02:00
2021-10-16 20:06:58 +02:00
if ( $fulldayevent ) {
2022-02-11 15:15:50 +01:00
$tzforfullday = getDolGlobalString ( 'MAIN_STORE_FULL_EVENT_IN_GMT' );
// For "full day" events, we must store date in GMT (It must be viewed as same moment everywhere)
$datep = dol_mktime ( '00' , '00' , 0 , GETPOST ( " apmonth " , 'int' ), GETPOST ( " apday " , 'int' ), GETPOST ( " apyear " , 'int' ), $tzforfullday ? $tzforfullday : 'tzuserrel' );
$datef = dol_mktime ( '23' , '59' , '59' , GETPOST ( " p2month " , 'int' ), GETPOST ( " p2day " , 'int' ), GETPOST ( " p2year " , 'int' ), $tzforfullday ? $tzforfullday : 'tzuserrel' );
//print $db->idate($datep); exit;
2021-10-16 20:06:58 +02:00
} else {
2022-02-11 15:15:50 +01:00
$datep = dol_mktime ( $aphour , $apmin , 0 , GETPOST ( " apmonth " , 'int' ), GETPOST ( " apday " , 'int' ), GETPOST ( " apyear " , 'int' ), 'tzuserrel' );
$datef = dol_mktime ( $p2hour , $p2min , '59' , GETPOST ( " p2month " , 'int' ), GETPOST ( " p2day " , 'int' ), GETPOST ( " p2year " , 'int' ), 'tzuserrel' );
2021-10-16 20:06:58 +02:00
}
2014-09-09 14:38:10 +02:00
2008-04-16 03:04:12 +02:00
// Security check
2019-01-27 11:55:16 +01:00
$socid = GETPOST ( 'socid' , 'int' );
$id = GETPOST ( 'id' , 'int' );
2023-03-13 08:45:29 +01:00
if ( $user -> socid && ( $socid != $user -> socid )) {
accessforbidden ();
2021-02-23 18:59:19 +01:00
}
2009-04-29 08:22:37 +02:00
2020-04-10 10:59:32 +02:00
$error = GETPOST ( " error " );
$donotclearsession = GETPOST ( 'donotclearsession' ) ? GETPOST ( 'donotclearsession' ) : 0 ;
2005-07-08 00:47:02 +02:00
2014-01-30 00:40:00 +01:00
$object = new ActionComm ( $db );
2021-03-29 22:43:39 +02:00
$cactioncomm = new CActionComm ( $db );
2008-04-15 10:34:36 +02:00
$contact = new Contact ( $db );
2012-12-08 12:49:20 +01:00
$extrafields = new ExtraFields ( $db );
2014-10-27 10:54:50 +01:00
$formfile = new FormFile ( $db );
2012-12-08 12:49:20 +01:00
2015-06-08 12:39:25 +02:00
$form = new Form ( $db );
$formfile = new FormFile ( $db );
$formactions = new FormActions ( $db );
2019-09-17 08:15:01 +02:00
// Load object
2019-11-13 19:35:39 +01:00
if ( $id > 0 && $action != 'add' ) {
2020-10-31 14:32:18 +01:00
$ret = $object -> fetch ( $id );
if ( $ret > 0 ) {
$ret = $object -> fetch_optionals ();
$ret1 = $object -> fetch_userassigned ();
}
if ( $ret < 0 || $ret1 < 0 ) {
dol_print_error ( '' , $object -> error );
}
2019-09-17 08:15:01 +02:00
}
2013-04-01 19:43:26 +02:00
// fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2013-04-01 19:43:26 +02:00
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2019-11-13 19:35:39 +01:00
$hookmanager -> initHooks ( array ( 'actioncard' , 'globalcard' ));
Add: hooks and triggers for a lot of core modules (action/calendrier, deplacement, dons, tva, contact/tiers, contrat, product lines, expedition, fournisseur commandes et factures, fiche intervention, projet et taches)
Signed-off-by: Stephen L. <lrq3000@gmail.com>
2012-08-14 15:50:45 +02:00
2019-09-17 08:15:01 +02:00
$parameters = array ( 'socid' => $socid );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-23 18:59:19 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2016-09-19 10:43:30 +02:00
2020-09-14 20:53:42 +02:00
$TRemindTypes = array ();
2021-02-23 18:59:19 +01:00
if ( ! empty ( $conf -> global -> AGENDA_REMINDER_BROWSER )) {
$TRemindTypes [ 'browser' ] = array ( 'label' => $langs -> trans ( 'BrowserPush' ), 'disabled' => ( empty ( $conf -> global -> AGENDA_REMINDER_BROWSER ) ? 1 : 0 ));
}
if ( ! empty ( $conf -> global -> AGENDA_REMINDER_EMAIL )) {
$TRemindTypes [ 'email' ] = array ( 'label' => $langs -> trans ( 'EMail' ), 'disabled' => ( empty ( $conf -> global -> AGENDA_REMINDER_EMAIL ) ? 1 : 0 ));
}
2020-09-14 20:53:42 +02:00
$TDurationTypes = array ( 'y' => $langs -> trans ( 'Years' ), 'm' => $langs -> trans ( 'Month' ), 'w' => $langs -> trans ( 'Weeks' ), 'd' => $langs -> trans ( 'Days' ), 'h' => $langs -> trans ( 'Hours' ), 'i' => $langs -> trans ( 'Minutes' ));
2021-03-29 22:43:39 +02:00
$result = restrictedArea ( $user , 'agenda' , $object -> id , 'actioncomm&societe' , 'myactions|allactions' , 'fk_soc' , 'id' );
2020-07-06 16:52:28 +02:00
2002-04-29 20:01:16 +02:00
/*
2013-09-25 21:26:06 +02:00
* Actions
2002-04-29 20:01:16 +02:00
*/
2016-09-19 10:43:30 +02:00
2015-11-05 11:11:03 +01:00
$listUserAssignedUpdated = false ;
2014-09-20 00:57:29 +02:00
// Remove user to assigned list
2021-02-23 18:59:19 +01:00
if ( empty ( $reshook ) && ( GETPOST ( 'removedassigned' ) || GETPOST ( 'removedassigned' ) == '0' )) {
2019-11-13 19:35:39 +01:00
$idtoremove = GETPOST ( 'removedassigned' );
2014-10-03 18:04:13 +02:00
2021-02-23 18:59:19 +01:00
if ( ! empty ( $_SESSION [ 'assignedtouser' ])) {
$tmpassigneduserids = json_decode ( $_SESSION [ 'assignedtouser' ], 1 );
} else {
$tmpassigneduserids = array ();
}
2014-10-03 18:04:13 +02:00
2021-02-23 18:59:19 +01:00
foreach ( $tmpassigneduserids as $key => $val ) {
if ( $val [ 'id' ] == $idtoremove || $val [ 'id' ] == - 1 ) {
unset ( $tmpassigneduserids [ $key ]);
}
2014-09-23 16:15:15 +02:00
}
2020-10-17 19:52:23 +02:00
2019-11-13 19:35:39 +01:00
$_SESSION [ 'assignedtouser' ] = json_encode ( $tmpassigneduserids );
$donotclearsession = 1 ;
2021-02-23 18:59:19 +01:00
if ( $action == 'add' ) {
$action = 'create' ;
}
if ( $action == 'update' ) {
$action = 'edit' ;
}
2017-06-07 16:44:04 +02:00
2015-11-05 11:11:03 +01:00
$listUserAssignedUpdated = true ;
2014-09-20 00:57:29 +02:00
}
// Add user to assigned list
2021-02-23 18:59:19 +01:00
if ( empty ( $reshook ) && ( GETPOST ( 'addassignedtouser' ) || GETPOST ( 'updateassignedtouser' ))) {
2014-09-09 14:38:10 +02:00
// Add a new user
2021-02-23 18:59:19 +01:00
if ( GETPOST ( 'assignedtouser' ) > 0 ) {
2019-11-13 19:35:39 +01:00
$assignedtouser = array ();
2021-02-23 18:59:19 +01:00
if ( ! empty ( $_SESSION [ 'assignedtouser' ])) {
2019-11-13 19:35:39 +01:00
$assignedtouser = json_decode ( $_SESSION [ 'assignedtouser' ], true );
2014-09-23 16:15:15 +02:00
}
2019-11-13 19:35:39 +01:00
$assignedtouser [ GETPOST ( 'assignedtouser' )] = array ( 'id' => GETPOST ( 'assignedtouser' ), 'transparency' => GETPOST ( 'transparency' ), 'mandatory' => 1 );
$_SESSION [ 'assignedtouser' ] = json_encode ( $assignedtouser );
2014-09-09 14:38:10 +02:00
}
2019-11-13 19:35:39 +01:00
$donotclearsession = 1 ;
2021-02-23 18:59:19 +01:00
if ( $action == 'add' ) {
$action = 'create' ;
}
if ( $action == 'update' ) {
$action = 'edit' ;
}
2015-11-05 22:13:08 +01:00
2015-11-05 11:11:03 +01:00
$listUserAssignedUpdated = true ;
2014-09-09 14:38:10 +02:00
}
2014-09-20 00:57:29 +02:00
2017-02-22 17:46:54 +01:00
// Link to a project
2019-09-17 08:15:01 +02:00
if ( empty ( $reshook ) && $action == 'classin' && ( $user -> rights -> agenda -> allactions -> create ||
2021-02-23 18:59:19 +01:00
(( $object -> authorid == $user -> id || $object -> userownerid == $user -> id ) && $user -> rights -> agenda -> myactions -> create ))) {
2020-10-31 14:32:18 +01:00
//$object->fetch($id);
$object -> setProject ( GETPOST ( 'projectid' , 'int' ));
2017-02-22 17:46:54 +01:00
}
2015-06-08 12:39:25 +02:00
// Action clone object
2021-02-23 18:59:19 +01:00
if ( empty ( $reshook ) && $action == 'confirm_clone' && $confirm == 'yes' ) {
if ( 1 == 0 && ! GETPOST ( 'clone_content' ) && ! GETPOST ( 'clone_receivers' )) {
2015-10-31 17:21:48 +01:00
setEventMessages ( $langs -> trans ( " NoCloneOptionsSpecified " ), null , 'errors' );
2020-05-21 15:05:19 +02:00
} else {
2015-06-08 12:39:25 +02:00
if ( $id > 0 ) {
2019-09-17 08:15:01 +02:00
//$object->fetch($id);
2020-10-31 14:32:18 +01:00
if ( ! empty ( $object -> socpeopleassigned )) {
reset ( $object -> socpeopleassigned );
$object -> contact_id = key ( $object -> socpeopleassigned );
}
2019-09-06 10:36:49 +02:00
$result = $object -> createFromClone ( $user , GETPOST ( 'socid' , 'int' ));
2015-06-08 12:39:25 +02:00
if ( $result > 0 ) {
2019-11-13 19:35:39 +01:00
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . '?id=' . $result );
2015-06-08 12:39:25 +02:00
exit ();
} else {
2015-10-31 17:21:48 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2015-06-08 12:39:25 +02:00
$action = '' ;
}
}
}
}
2014-09-20 00:57:29 +02:00
// Add event
2021-02-23 18:59:19 +01:00
if ( empty ( $reshook ) && $action == 'add' ) {
2019-11-13 19:35:39 +01:00
$error = 0 ;
2012-01-04 21:23:50 +01:00
2021-02-23 18:59:19 +01:00
if ( empty ( $backtopage )) {
if ( $socid > 0 ) {
$backtopage = DOL_URL_ROOT . '/societe/agenda.php?socid=' . $socid ;
} else {
$backtopage = DOL_URL_ROOT . '/comm/action/index.php' ;
}
2020-10-31 14:32:18 +01:00
}
2010-12-13 18:06:04 +01:00
2021-02-23 18:59:19 +01:00
if ( ! empty ( $socpeopleassigned [ 0 ])) {
2019-11-13 19:35:39 +01:00
$result = $contact -> fetch ( $socpeopleassigned [ 0 ]);
2009-03-03 01:20:21 +01:00
}
2009-02-04 21:43:18 +01:00
2021-02-23 18:59:19 +01:00
if ( $cancel ) {
2008-04-17 14:15:20 +02:00
header ( " Location: " . $backtopage );
2009-02-04 21:43:18 +01:00
exit ;
2008-01-26 14:18:47 +01:00
}
2021-09-01 17:10:26 +02:00
$percentage = in_array ( GETPOST ( 'status' ), array ( - 1 , 100 )) ? GETPOST ( 'status' ) : ( in_array ( $complete , array ( - 1 , 100 )) ? $complete : GETPOST ( " percentage " , 'int' )); // If status is -1 or 100, percentage is not defined and we must use status
2010-11-18 23:17:44 +01:00
2020-10-31 14:32:18 +01:00
// Clean parameters
2022-02-11 15:15:50 +01:00
if ( $fulldayevent ) {
$tzforfullday = getDolGlobalString ( 'MAIN_STORE_FULL_EVENT_IN_GMT' );
// For "full day" events, we must store date in GMT (It must be viewed as same moment everywhere)
$datep = dol_mktime ( $fulldayevent ? '00' : GETPOST ( " aphour " , 'int' ), $fulldayevent ? '00' : GETPOST ( " apmin " , 'int' ), $fulldayevent ? '00' : GETPOST ( " apsec " , 'int' ), GETPOST ( " apmonth " , 'int' ), GETPOST ( " apday " , 'int' ), GETPOST ( " apyear " , 'int' ), $tzforfullday ? $tzforfullday : 'tzuser' );
$datef = dol_mktime ( $fulldayevent ? '23' : GETPOST ( " p2hour " , 'int' ), $fulldayevent ? '59' : GETPOST ( " p2min " , 'int' ), $fulldayevent ? '59' : GETPOST ( " apsec " , 'int' ), GETPOST ( " p2month " , 'int' ), GETPOST ( " p2day " , 'int' ), GETPOST ( " p2year " , 'int' ), $tzforfullday ? $tzforfullday : 'tzuser' );
} else {
$datep = dol_mktime ( $fulldayevent ? '00' : GETPOST ( " aphour " , 'int' ), $fulldayevent ? '00' : GETPOST ( " apmin " , 'int' ), $fulldayevent ? '00' : GETPOST ( " apsec " , 'int' ), GETPOST ( " apmonth " , 'int' ), GETPOST ( " apday " , 'int' ), GETPOST ( " apyear " , 'int' ), 'tzuser' );
$datef = dol_mktime ( $fulldayevent ? '23' : GETPOST ( " p2hour " , 'int' ), $fulldayevent ? '59' : GETPOST ( " p2min " , 'int' ), $fulldayevent ? '59' : GETPOST ( " apsec " , 'int' ), GETPOST ( " p2month " , 'int' ), GETPOST ( " p2day " , 'int' ), GETPOST ( " p2year " , 'int' ), 'tzuser' );
}
2010-01-05 00:33:23 +01:00
2010-02-21 15:06:41 +01:00
// Check parameters
2021-02-23 18:59:19 +01:00
if ( ! $datef && $percentage == 100 ) {
2019-11-13 19:35:39 +01:00
$error ++ ; $donotclearsession = 1 ;
2011-04-09 13:52:11 +02:00
$action = 'create' ;
2015-10-17 16:18:33 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " DateEnd " )), null , 'errors' );
2008-10-06 23:31:05 +02:00
}
2009-02-04 21:43:18 +01:00
2021-02-23 18:59:19 +01:00
if ( empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ) && ! GETPOST ( 'label' )) {
2019-11-13 19:35:39 +01:00
$error ++ ; $donotclearsession = 1 ;
2012-12-01 15:45:05 +01:00
$action = 'create' ;
2015-10-17 16:18:33 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Title " )), null , 'errors' );
2012-12-01 15:45:05 +01:00
}
2008-04-15 10:34:36 +02:00
// Initialisation objet cactioncomm
2021-02-23 18:59:19 +01:00
if ( GETPOSTISSET ( 'actioncode' ) && ! GETPOST ( 'actioncode' , 'aZ09' )) { // actioncode is '0'
2019-11-13 19:35:39 +01:00
$error ++ ; $donotclearsession = 1 ;
2011-04-09 13:52:11 +02:00
$action = 'create' ;
2015-10-17 16:18:33 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Type " )), null , 'errors' );
2020-05-21 15:05:19 +02:00
} else {
2019-09-11 17:51:50 +02:00
$object -> type_code = GETPOST ( 'actioncode' , 'aZ09' );
2008-04-15 10:34:36 +02:00
}
2009-02-04 21:43:18 +01:00
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
2014-10-05 04:51:34 +02:00
// Initialisation objet actioncomm
2020-08-29 06:17:26 +02:00
$object -> priority = GETPOSTISSET ( " priority " ) ? GETPOST ( " priority " , " int " ) : 0 ;
2022-01-29 00:39:20 +01:00
$object -> fulldayevent = ( $fulldayevent ? 1 : 0 );
2020-08-28 21:27:50 +02:00
$object -> location = GETPOST ( " location " , 'alphanohtml' );
$object -> label = GETPOST ( 'label' , 'alphanohtml' );
2021-09-19 00:50:23 +02:00
if ( GETPOST ( " elementtype " , 'alpha' )) {
$modulecodetouseforpermissioncheck = GETPOST ( " elementtype " , 'alpha' );
$hasPermissionOnLinkedObject = 0 ;
if ( $user -> hasRight ( $modulecodetouseforpermissioncheck , 'read' )) {
$hasPermissionOnLinkedObject = 1 ;
}
if ( $hasPermissionOnLinkedObject ) {
$object -> fk_element = GETPOST ( " fk_element " , 'int' );
$object -> elementtype = GETPOST ( " elementtype " , 'alpha' );
}
}
2021-02-23 18:59:19 +01:00
if ( ! GETPOST ( 'label' )) {
if ( GETPOST ( 'actioncode' , 'aZ09' ) == 'AC_RDV' && $contact -> getFullName ( $langs )) {
2019-01-27 11:55:16 +01:00
$object -> label = $langs -> transnoentitiesnoconv ( " TaskRDVWith " , $contact -> getFullName ( $langs ));
2020-05-21 15:05:19 +02:00
} else {
2021-02-23 18:59:19 +01:00
if ( $langs -> trans ( " Action " . $object -> type_code ) != " Action " . $object -> type_code ) {
2014-10-05 04:51:34 +02:00
$object -> label = $langs -> transnoentitiesnoconv ( " Action " . $object -> type_code ) . " \n " ;
2020-05-21 15:05:19 +02:00
} else {
2019-07-03 13:12:41 +02:00
$cactioncomm -> fetch ( $object -> type_code );
$object -> label = $cactioncomm -> label ;
}
2008-04-15 10:34:36 +02:00
}
}
2020-11-30 14:47:07 +01:00
$object -> fk_project = GETPOSTISSET ( " projectid " ) ? GETPOST ( " projectid " , 'int' ) : 0 ;
2018-11-11 14:36:35 +01:00
2019-01-27 11:55:16 +01:00
$taskid = GETPOST ( 'taskid' , 'int' );
2020-04-10 10:59:32 +02:00
if ( ! empty ( $taskid )) {
2020-10-31 14:32:18 +01:00
$taskProject = new Task ( $db );
if ( $taskProject -> fetch ( $taskid ) > 0 ) {
$object -> fk_project = $taskProject -> fk_project ;
}
2018-11-11 14:36:35 +01:00
2020-10-31 14:32:18 +01:00
$object -> fk_element = $taskid ;
$object -> elementtype = 'task' ;
2018-09-20 10:08:40 +02:00
}
2018-11-11 14:36:35 +01:00
2014-10-05 04:51:34 +02:00
$object -> datep = $datep ;
$object -> datef = $datef ;
$object -> percentage = $percentage ;
2019-11-13 19:35:39 +01:00
$object -> duree = ((( int ) GETPOST ( 'dureehour' ) * 60 ) + ( int ) GETPOST ( 'dureemin' )) * 60 ;
2006-09-16 02:14:11 +02:00
2019-11-13 19:35:39 +01:00
$transparency = ( GETPOST ( " transparency " ) == 'on' ? 1 : 0 );
2015-08-14 13:01:20 +02:00
2019-11-13 19:35:39 +01:00
$listofuserid = array ();
2021-02-23 18:59:19 +01:00
if ( ! empty ( $_SESSION [ 'assignedtouser' ])) {
$listofuserid = json_decode ( $_SESSION [ 'assignedtouser' ], true );
}
2019-11-13 19:35:39 +01:00
$i = 0 ;
2021-02-23 18:59:19 +01:00
foreach ( $listofuserid as $key => $value ) {
if ( $i == 0 ) { // First entry
if ( $value [ 'id' ] > 0 ) {
$object -> userownerid = $value [ 'id' ];
}
2015-08-14 13:01:20 +02:00
$object -> transparency = $transparency ;
2014-09-20 00:57:29 +02:00
}
2019-11-13 19:35:39 +01:00
$object -> userassigned [ $value [ 'id' ]] = array ( 'id' => $value [ 'id' ], 'transparency' => $transparency );
2014-09-20 00:57:29 +02:00
2014-10-05 04:51:34 +02:00
$i ++ ;
}
2008-04-15 10:34:36 +02:00
}
2014-09-20 00:57:29 +02:00
2021-02-23 18:59:19 +01:00
if ( ! $error && ! empty ( $conf -> global -> AGENDA_ENABLE_DONEBY )) {
if ( GETPOST ( " doneby " ) > 0 ) {
$object -> userdoneid = GETPOST ( " doneby " , " int " );
}
2008-04-15 10:34:36 +02:00
}
2009-02-04 21:43:18 +01:00
2020-09-18 01:29:17 +02:00
$object -> note_private = trim ( GETPOST ( " note " , " restricthtml " ));
2014-09-24 01:35:29 +02:00
2021-02-23 18:59:19 +01:00
if ( GETPOSTISSET ( " contactid " )) {
$object -> contact = $contact ;
}
2014-09-24 01:35:29 +02:00
2021-02-23 18:59:19 +01:00
if ( GETPOST ( 'socid' , 'int' ) > 0 ) {
2019-11-13 19:35:39 +01:00
$object -> socid = GETPOST ( 'socid' , 'int' );
2014-10-05 04:51:34 +02:00
$object -> fetch_thirdparty ();
2019-11-13 19:35:39 +01:00
$object -> societe = $object -> thirdparty ; // For backward compatibility
2008-04-15 10:34:36 +02:00
}
2008-05-07 02:50:24 +02:00
2008-09-09 19:57:12 +02:00
// Check parameters
2021-02-23 18:59:19 +01:00
if ( empty ( $object -> userownerid ) && empty ( $_SESSION [ 'assignedtouser' ])) {
2019-11-13 19:35:39 +01:00
$error ++ ; $donotclearsession = 1 ;
2014-09-20 00:57:29 +02:00
$action = 'create' ;
2015-10-17 16:18:33 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " ActionsOwnedBy " )), null , 'errors' );
2014-09-20 00:57:29 +02:00
}
2021-02-23 18:59:19 +01:00
if ( $object -> type_code == 'AC_RDV' && ( $datep == '' || ( $datef == '' && empty ( $fulldayevent )))) {
2019-11-13 19:35:39 +01:00
$error ++ ; $donotclearsession = 1 ;
2011-04-09 13:52:11 +02:00
$action = 'create' ;
2015-10-17 16:18:33 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " DateEnd " )), null , 'errors' );
2008-09-09 19:57:12 +02:00
}
2009-02-04 21:43:18 +01:00
2021-02-23 18:59:19 +01:00
if ( ! GETPOST ( 'apyear' ) && ! GETPOST ( 'adyear' )) {
2019-11-13 19:35:39 +01:00
$error ++ ; $donotclearsession = 1 ;
2011-04-09 13:52:11 +02:00
$action = 'create' ;
2015-10-17 16:18:33 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Date " )), null , 'errors' );
2009-03-03 01:20:21 +01:00
}
2021-02-23 18:59:19 +01:00
foreach ( $socpeopleassigned as $cid ) {
2017-11-18 12:36:03 +01:00
$object -> socpeopleassigned [ $cid ] = array ( 'id' => $cid );
}
2021-02-23 18:59:19 +01:00
if ( ! empty ( $object -> socpeopleassigned )) {
2017-11-18 12:36:03 +01:00
reset ( $object -> socpeopleassigned );
2020-06-25 12:17:47 +02:00
$object -> contact_id = key ( $object -> socpeopleassigned );
2017-11-18 12:36:03 +01:00
}
2017-11-22 14:42:47 +01:00
2013-04-01 19:43:26 +02:00
// Fill array 'array_options' with data from add form
2019-10-06 14:41:52 +02:00
$ret = $extrafields -> setOptionalsFromPost ( null , $object );
2021-02-23 18:59:19 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2012-12-08 12:49:20 +01:00
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
2009-03-03 01:20:21 +01:00
$db -> begin ();
2019-06-12 19:32:29 +02:00
// Creation of action/event
2019-11-13 19:35:39 +01:00
$idaction = $object -> create ( $user );
2009-03-03 01:20:21 +01:00
2021-02-23 18:59:19 +01:00
if ( $idaction > 0 ) {
if ( ! $object -> error ) {
2019-11-13 21:18:34 +01:00
// Category association
$categories = GETPOST ( 'categories' , 'array' );
$object -> setCategories ( $categories );
2014-09-23 16:15:15 +02:00
unset ( $_SESSION [ 'assignedtouser' ]);
2019-11-13 19:35:39 +01:00
$moreparam = '' ;
2021-02-23 18:59:19 +01:00
if ( $user -> id != $object -> userownerid ) {
$moreparam = " filtert=-1 " ; // We force to remove filter so created record is visible when going back to per user view.
}
2014-10-13 17:45:52 +02:00
2020-10-17 21:14:19 +02:00
// Create reminders
2020-10-31 18:51:30 +01:00
if ( $addreminder == 'on' ) {
$actionCommReminder = new ActionCommReminder ( $db );
2020-08-26 12:48:12 +02:00
2020-10-31 18:51:30 +01:00
$dateremind = dol_time_plus_duree ( $datep , - $offsetvalue , $offsetunit );
2020-08-26 15:12:08 +02:00
2020-10-31 18:51:30 +01:00
$actionCommReminder -> dateremind = $dateremind ;
$actionCommReminder -> typeremind = $remindertype ;
$actionCommReminder -> offsetunit = $offsetunit ;
$actionCommReminder -> offsetvalue = $offsetvalue ;
$actionCommReminder -> status = $actionCommReminder :: STATUS_TODO ;
$actionCommReminder -> fk_actioncomm = $object -> id ;
2021-02-23 18:59:19 +01:00
if ( $remindertype == 'email' ) {
$actionCommReminder -> fk_email_template = $modelmail ;
}
2020-08-26 15:12:08 +02:00
2020-10-31 18:51:30 +01:00
// the notification must be created for every user assigned to the event
2021-02-23 18:59:19 +01:00
foreach ( $object -> userassigned as $userassigned ) {
2020-09-24 12:31:28 +02:00
$actionCommReminder -> fk_user = $userassigned [ 'id' ];
$res = $actionCommReminder -> create ( $user );
2020-10-31 14:32:18 +01:00
if ( $res <= 0 ) {
2020-09-24 12:31:28 +02:00
// If error
$db -> rollback ();
$langs -> load ( " errors " );
$error = $langs -> trans ( 'ErrorReminderActionCommCreation' );
setEventMessages ( $error , null , 'errors' );
$action = 'create' ; $donotclearsession = 1 ;
break ;
}
}
2020-10-31 14:32:18 +01:00
}
2020-08-26 12:48:12 +02:00
2022-05-19 10:31:01 +02:00
// Modify $moreparam so we are sure to see the event we have just created, whatever are the default value of filter on next page.
/* $moreparam .= ( $moreparam ? '&' : '' ) . 'search_actioncode=0' ;
$moreparam .= ( $moreparam ? '&' : '' ) . 'search_status=-1' ;
$moreparam .= ( $moreparam ? '&' : '' ) . 'search_filtert=' . $object -> userownerid ;
*/
$moreparam .= ( $moreparam ? '&' : '' ) . 'disabledefaultvalues=1' ;
2020-10-31 14:32:18 +01:00
if ( $error ) {
$db -> rollback ();
} else {
2020-09-04 14:18:48 +02:00
$db -> commit ();
2020-10-31 14:32:18 +01:00
}
2020-09-04 14:18:48 +02:00
2021-02-23 18:59:19 +01:00
if ( ! empty ( $backtopage )) {
2019-11-13 19:35:39 +01:00
dol_syslog ( " Back to " . $backtopage . ( $moreparam ? ( preg_match ( '/\?/' , $backtopage ) ? '&' . $moreparam : '?' . $moreparam ) : '' ));
header ( " Location: " . $backtopage . ( $moreparam ? ( preg_match ( '/\?/' , $backtopage ) ? '&' . $moreparam : '?' . $moreparam ) : '' ));
2021-02-23 18:59:19 +01:00
} elseif ( $idaction ) {
2019-11-13 19:35:39 +01:00
header ( " Location: " . DOL_URL_ROOT . '/comm/action/card.php?id=' . $idaction . ( $moreparam ? '&' . $moreparam : '' ));
2020-05-21 15:05:19 +02:00
} else {
2019-11-13 19:35:39 +01:00
header ( " Location: " . DOL_URL_ROOT . '/comm/action/index.php' . ( $moreparam ? '?' . $moreparam : '' ));
2009-03-03 01:20:21 +01:00
}
exit ;
2020-05-21 15:05:19 +02:00
} else {
2012-12-30 13:49:37 +01:00
// If error
2009-03-03 01:20:21 +01:00
$db -> rollback ();
2009-01-07 14:40:07 +01:00
$langs -> load ( " errors " );
2019-11-13 19:35:39 +01:00
$error = $langs -> trans ( $object -> error );
2015-10-31 17:21:48 +01:00
setEventMessages ( $error , null , 'errors' );
2019-11-13 19:35:39 +01:00
$action = 'create' ; $donotclearsession = 1 ;
2009-03-03 01:20:21 +01:00
}
2020-05-21 15:05:19 +02:00
} else {
2009-03-03 01:20:21 +01:00
$db -> rollback ();
2014-09-20 00:57:29 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2019-11-13 19:35:39 +01:00
$action = 'create' ; $donotclearsession = 1 ;
2009-07-22 22:41:50 +02:00
}
2009-03-03 01:20:21 +01:00
}
2003-08-03 14:18:29 +02:00
}
2004-10-02 16:24:43 +02:00
/*
2012-09-02 14:10:51 +02:00
* Action update event
2004-10-02 16:24:43 +02:00
*/
2021-02-23 18:59:19 +01:00
if ( empty ( $reshook ) && $action == 'update' ) {
if ( empty ( $cancel )) {
2020-10-31 14:32:18 +01:00
$fulldayevent = GETPOST ( 'fullday' );
2021-01-03 18:42:45 +01:00
$aphour = GETPOST ( 'aphour' , 'int' );
$apmin = GETPOST ( 'apmin' , 'int' );
$p2hour = GETPOST ( 'p2hour' , 'int' );
$p2min = GETPOST ( 'p2min' , 'int' );
2021-09-01 17:10:26 +02:00
$percentage = in_array ( GETPOST ( 'status' ), array ( - 1 , 100 )) ? GETPOST ( 'status' ) : ( in_array ( $complete , array ( - 1 , 100 )) ? $complete : GETPOST ( " percentage " , 'int' )); // If status is -1 or 100, percentage is not defined and we must use status
2010-11-18 23:17:44 +01:00
2020-10-31 14:32:18 +01:00
// Clean parameters
2021-02-23 18:59:19 +01:00
if ( $aphour == - 1 ) {
$aphour = '0' ;
}
if ( $apmin == - 1 ) {
$apmin = '0' ;
}
if ( $p2hour == - 1 ) {
$p2hour = '0' ;
}
if ( $p2min == - 1 ) {
$p2min = '0' ;
}
2006-09-16 02:14:11 +02:00
2014-01-30 00:40:00 +01:00
$object -> fetch ( $id );
2019-09-27 14:45:09 +02:00
$object -> fetch_optionals ();
2014-09-23 16:15:15 +02:00
$object -> fetch_userassigned ();
2019-09-27 14:45:09 +02:00
$object -> oldcopy = clone $object ;
2006-09-10 15:46:25 +02:00
2022-02-11 15:15:50 +01:00
// Clean parameters
if ( $fulldayevent ) {
$tzforfullday = getDolGlobalString ( 'MAIN_STORE_FULL_EVENT_IN_GMT' );
// For "full day" events, we must store date in GMT (It must be viewed as same moment everywhere)
$datep = dol_mktime ( $fulldayevent ? '00' : GETPOST ( " aphour " , 'int' ), $fulldayevent ? '00' : GETPOST ( " apmin " , 'int' ), $fulldayevent ? '00' : GETPOST ( " apsec " , 'int' ), GETPOST ( " apmonth " , 'int' ), GETPOST ( " apday " , 'int' ), GETPOST ( " apyear " , 'int' ), $tzforfullday ? $tzforfullday : 'tzuser' );
$datef = dol_mktime ( $fulldayevent ? '23' : GETPOST ( " p2hour " , 'int' ), $fulldayevent ? '59' : GETPOST ( " p2min " , 'int' ), $fulldayevent ? '59' : GETPOST ( " apsec " , 'int' ), GETPOST ( " p2month " , 'int' ), GETPOST ( " p2day " , 'int' ), GETPOST ( " p2year " , 'int' ), $tzforfullday ? $tzforfullday : 'tzuser' );
} else {
$datep = dol_mktime ( $fulldayevent ? '00' : GETPOST ( " aphour " , 'int' ), $fulldayevent ? '00' : GETPOST ( " apmin " , 'int' ), $fulldayevent ? '00' : GETPOST ( " apsec " , 'int' ), GETPOST ( " apmonth " , 'int' ), GETPOST ( " apday " , 'int' ), GETPOST ( " apyear " , 'int' ), 'tzuser' );
$datef = dol_mktime ( $fulldayevent ? '23' : GETPOST ( " p2hour " , 'int' ), $fulldayevent ? '59' : GETPOST ( " p2min " , 'int' ), $fulldayevent ? '59' : GETPOST ( " apsec " , 'int' ), GETPOST ( " p2month " , 'int' ), GETPOST ( " p2day " , 'int' ), GETPOST ( " p2year " , 'int' ), 'tzuser' );
}
2011-08-24 14:19:32 +02:00
2022-10-15 13:52:57 +02:00
if ( $object -> elementtype == 'ticket' ) {
if ( $private ) {
2022-10-14 09:54:47 +02:00
$object -> type_code = 'TICKET_MSG_PRIVATE' ;
} else {
$object -> type_id = dol_getIdFromCode ( $db , 'AC_EMAIL' , 'c_actioncomm' );
}
2022-10-13 12:18:25 +02:00
} else {
$object -> type_id = dol_getIdFromCode ( $db , GETPOST ( " actioncode " , 'aZ09' ), 'c_actioncomm' );
2022-11-29 14:38:25 +01:00
$object -> type_code = GETPOST ( " actioncode " , 'aZ09' );
2022-10-13 12:18:25 +02:00
}
2022-11-29 14:38:25 +01:00
2019-09-11 17:51:50 +02:00
$object -> label = GETPOST ( " label " , " alphanohtml " );
2014-01-30 00:40:00 +01:00
$object -> datep = $datep ;
$object -> datef = $datef ;
$object -> percentage = $percentage ;
2020-08-29 06:17:26 +02:00
$object -> priority = GETPOST ( " priority " , " int " );
2020-10-31 18:51:30 +01:00
$object -> fulldayevent = GETPOST ( " fullday " ) ? 1 : 0 ;
$object -> location = GETPOST ( 'location' , " alphanohtml " );
2019-09-11 17:51:50 +02:00
$object -> socid = GETPOST ( " socid " , " int " );
2019-01-27 11:55:16 +01:00
$socpeopleassigned = GETPOST ( " socpeopleassigned " , 'array' );
2018-05-24 13:32:13 +02:00
$object -> socpeopleassigned = array ();
2021-02-23 18:59:19 +01:00
foreach ( $socpeopleassigned as $cid ) {
$object -> socpeopleassigned [ $cid ] = array ( 'id' => $cid );
}
2020-10-31 14:32:18 +01:00
$object -> contact_id = GETPOST ( " contactid " , 'int' );
2020-10-31 18:51:30 +01:00
if ( empty ( $object -> contact_id ) && ! empty ( $object -> socpeopleassigned )) {
reset ( $object -> socpeopleassigned );
$object -> contact_id = key ( $object -> socpeopleassigned );
}
2019-01-27 11:55:16 +01:00
$object -> fk_project = GETPOST ( " projectid " , 'int' );
2020-09-18 01:29:17 +02:00
$object -> note_private = trim ( GETPOST ( " note " , " restricthtml " ));
2021-09-19 00:50:23 +02:00
if ( GETPOST ( " elementtype " , 'alpha' )) {
$modulecodetouseforpermissioncheck = GETPOST ( " elementtype " , 'alpha' );
$hasPermissionOnLinkedObject = 0 ;
if ( $user -> hasRight ( $modulecodetouseforpermissioncheck , 'read' )) {
$hasPermissionOnLinkedObject = 1 ;
}
if ( $hasPermissionOnLinkedObject ) {
$object -> fk_element = GETPOST ( " fk_element " , 'int' );
$object -> elementtype = GETPOST ( " elementtype " , 'alpha' );
}
}
2021-02-23 18:59:19 +01:00
if ( ! $datef && $percentage == 100 ) {
2019-11-13 19:35:39 +01:00
$error ++ ; $donotclearsession = 1 ;
2019-01-27 11:55:16 +01:00
setEventMessages ( $langs -> transnoentitiesnoconv ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " DateEnd " )), $object -> errors , 'errors' );
2011-04-09 13:52:11 +02:00
$action = 'edit' ;
2009-03-03 01:20:21 +01:00
}
2014-09-29 13:21:03 +02:00
2019-11-13 19:35:39 +01:00
$transparency = ( GETPOST ( " transparency " ) == 'on' ? 1 : 0 );
2014-09-29 13:21:03 +02:00
2008-02-11 16:51:03 +01:00
// Users
2019-11-13 19:35:39 +01:00
$listofuserid = array ();
2021-02-23 18:59:19 +01:00
if ( ! empty ( $_SESSION [ 'assignedtouser' ])) { // Now concat assigned users
2014-09-23 16:15:15 +02:00
// Restore array with key with same value than param 'id'
2019-11-13 19:35:39 +01:00
$tmplist1 = json_decode ( $_SESSION [ 'assignedtouser' ], true );
2021-02-23 18:59:19 +01:00
foreach ( $tmplist1 as $key => $val ) {
if ( $val [ 'id' ] > 0 && $val [ 'id' ] != $assignedtouser ) {
$listofuserid [ $val [ 'id' ]] = $val ;
}
2014-09-20 00:57:29 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2019-11-13 19:35:39 +01:00
$assignedtouser = ( ! empty ( $object -> userownerid ) && $object -> userownerid > 0 ? $object -> userownerid : 0 );
2021-02-23 18:59:19 +01:00
if ( $assignedtouser ) {
$listofuserid [ $assignedtouser ] = array ( 'id' => $assignedtouser , 'mandatory' => 0 , 'transparency' => ( $user -> id == $assignedtouser ? $transparency : '' )); // Owner first
}
2014-10-14 00:27:23 +02:00
}
2019-11-13 19:35:39 +01:00
$object -> userassigned = array (); $object -> userownerid = 0 ; // Clear old content
$i = 0 ;
2021-02-23 18:59:19 +01:00
foreach ( $listofuserid as $key => $val ) {
if ( $i == 0 ) {
$object -> userownerid = $val [ 'id' ];
}
2019-11-13 19:35:39 +01:00
$object -> userassigned [ $val [ 'id' ]] = array ( 'id' => $val [ 'id' ], 'mandatory' => 0 , 'transparency' => ( $user -> id == $val [ 'id' ] ? $transparency : '' ));
2014-10-14 00:27:23 +02:00
$i ++ ;
2008-02-11 16:51:03 +01:00
}
2013-04-06 17:39:31 +02:00
2019-11-13 19:35:39 +01:00
$object -> transparency = $transparency ; // We set transparency on event (even if we can also store it on each user, standard says this property is for event)
2017-11-24 20:02:46 +01:00
// TODO store also transparency on owner user
2015-08-14 13:01:20 +02:00
2021-02-23 18:59:19 +01:00
if ( ! empty ( $conf -> global -> AGENDA_ENABLE_DONEBY )) {
if ( GETPOST ( " doneby " )) {
$object -> userdoneid = GETPOST ( " doneby " , " int " );
}
2014-09-20 00:57:29 +02:00
}
// Check parameters
2021-02-23 18:59:19 +01:00
if ( GETPOSTISSET ( 'actioncode' ) && ! GETPOST ( 'actioncode' , 'aZ09' )) { // actioncode is '0'
2019-11-13 19:35:39 +01:00
$error ++ ; $donotclearsession = 1 ;
2014-09-20 00:57:29 +02:00
$action = 'edit' ;
2015-10-17 16:18:33 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Type " )), null , 'errors' );
2020-05-21 15:05:19 +02:00
} else {
2019-11-13 19:35:39 +01:00
$result = $cactioncomm -> fetch ( GETPOST ( 'actioncode' , 'aZ09' ));
2014-09-20 00:57:29 +02:00
}
2021-02-23 18:59:19 +01:00
if ( empty ( $object -> userownerid )) {
2019-11-13 19:35:39 +01:00
$error ++ ; $donotclearsession = 1 ;
2014-09-20 00:57:29 +02:00
$action = 'edit' ;
2015-10-17 16:18:33 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " ActionsOwnedBy " )), null , 'errors' );
2008-02-11 16:51:03 +01:00
}
2013-04-01 19:43:26 +02:00
// Fill array 'array_options' with data from add form
2021-12-06 11:19:12 +01:00
$ret = $extrafields -> setOptionalsFromPost ( null , $object , '@GETPOSTISSET' );
2021-02-23 18:59:19 +01:00
if ( $ret < 0 ) {
$error ++ ;
}
2012-12-21 17:56:40 +01:00
2020-10-31 14:32:18 +01:00
if ( ! $error ) {
// check if an event resource is already in use
if ( ! empty ( $conf -> global -> RESOURCE_USED_IN_EVENT_CHECK ) && $object -> element == 'action' ) {
$eventDateStart = $object -> datep ;
$eventDateEnd = $object -> datef ;
$sql = " SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " element_resources as er " ;
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . " resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource' " ;
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . " actioncomm as ac ON ac.id = er.element_id AND er.element_type = ' " . $db -> escape ( $object -> element ) . " ' " ;
2021-08-27 16:33:03 +02:00
$sql .= " WHERE ac.id <> " . (( int ) $object -> id );
2020-10-31 14:32:18 +01:00
$sql .= " AND er.resource_id IN ( " ;
$sql .= " SELECT resource_id FROM " . MAIN_DB_PREFIX . " element_resources " ;
2021-08-27 16:33:03 +02:00
$sql .= " WHERE element_id = " . (( int ) $object -> id );
2020-10-31 14:32:18 +01:00
$sql .= " AND element_type = ' " . $db -> escape ( $object -> element ) . " ' " ;
$sql .= " AND busy = 1 " ;
$sql .= " ) " ;
$sql .= " AND er.busy = 1 " ;
$sql .= " AND ( " ;
// event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end)
$sql .= " (ac.datep <= ' " . $db -> idate ( $eventDateStart ) . " ' AND (ac.datep2 IS NULL OR ac.datep2 >= ' " . $db -> idate ( $eventDateStart ) . " ')) " ;
// event date end between ac.datep and ac.datep2
if ( ! empty ( $eventDateEnd )) {
$sql .= " OR (ac.datep <= ' " . $db -> idate ( $eventDateEnd ) . " ' AND (ac.datep2 >= ' " . $db -> idate ( $eventDateEnd ) . " ')) " ;
}
// event date start before ac.datep and event date end after ac.datep2
$sql .= " OR ( " ;
$sql .= " ac.datep >= ' " . $db -> idate ( $eventDateStart ) . " ' " ;
if ( ! empty ( $eventDateEnd )) {
$sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= ' " . $db -> idate ( $eventDateEnd ) . " ') " ;
}
$sql .= " ) " ;
$sql .= " ) " ;
$resql = $db -> query ( $sql );
if ( ! $resql ) {
$error ++ ;
$object -> error = $db -> lasterror ();
$object -> errors [] = $object -> error ;
} else {
if ( $db -> num_rows ( $resql ) > 0 ) {
2022-05-19 09:36:47 +02:00
// Resource already in use
2020-10-31 14:32:18 +01:00
$error ++ ;
$object -> error = $langs -> trans ( 'ErrorResourcesAlreadyInUse' ) . ' : ' ;
while ( $obj = $db -> fetch_object ( $resql )) {
$object -> error .= '<br> - ' . $langs -> trans ( 'ErrorResourceUseInEvent' , $obj -> r_ref , $obj -> ac_label . ' [' . $obj -> ac_id . ']' );
}
$object -> errors [] = $object -> error ;
}
$db -> free ( $resql );
}
if ( $error ) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
}
2019-09-04 15:14:16 +02:00
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
2008-04-16 03:04:12 +02:00
$db -> begin ();
2009-01-04 23:19:25 +01:00
2019-11-13 19:35:39 +01:00
$result = $object -> update ( $user );
2009-02-04 21:43:18 +01:00
2021-02-23 18:59:19 +01:00
if ( $result > 0 ) {
2019-11-13 21:18:34 +01:00
// Category association
$categories = GETPOST ( 'categories' , 'array' );
$object -> setCategories ( $categories );
2022-04-01 13:20:40 +02:00
$object -> loadReminders ( $remindertype , 0 , false );
2021-02-23 18:59:19 +01:00
if ( ! empty ( $object -> reminders ) && $object -> datep > dol_now ()) {
foreach ( $object -> reminders as $reminder ) {
2020-09-29 14:08:49 +02:00
$reminder -> delete ( $user );
}
$object -> reminders = array ();
}
//Create reminders
2020-10-31 14:32:18 +01:00
if ( $addreminder == 'on' && $object -> datep > dol_now ()) {
2020-09-29 14:08:49 +02:00
$actionCommReminder = new ActionCommReminder ( $db );
$dateremind = dol_time_plus_duree ( $datep , - $offsetvalue , $offsetunit );
$actionCommReminder -> dateremind = $dateremind ;
$actionCommReminder -> typeremind = $remindertype ;
$actionCommReminder -> offsetunit = $offsetunit ;
$actionCommReminder -> offsetvalue = $offsetvalue ;
$actionCommReminder -> status = $actionCommReminder :: STATUS_TODO ;
$actionCommReminder -> fk_actioncomm = $object -> id ;
2021-02-23 18:59:19 +01:00
if ( $remindertype == 'email' ) {
$actionCommReminder -> fk_email_template = $modelmail ;
}
2020-09-29 14:08:49 +02:00
// the notification must be created for every user assigned to the event
2021-02-23 18:59:19 +01:00
foreach ( $object -> userassigned as $userassigned ) {
2020-09-29 14:08:49 +02:00
$actionCommReminder -> fk_user = $userassigned [ 'id' ];
$res = $actionCommReminder -> create ( $user );
2020-10-31 14:32:18 +01:00
if ( $res <= 0 ) {
2020-09-29 14:08:49 +02:00
// If error
$langs -> load ( " errors " );
$error = $langs -> trans ( 'ErrorReminderActionCommCreation' );
setEventMessages ( $error , null , 'errors' );
$action = 'create' ; $donotclearsession = 1 ;
break ;
}
}
}
2014-09-23 16:15:15 +02:00
unset ( $_SESSION [ 'assignedtouser' ]);
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
$db -> commit ();
} else {
$db -> rollback ();
}
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2008-04-16 03:04:12 +02:00
$db -> rollback ();
2009-02-04 21:43:18 +01:00
}
2008-04-16 03:04:12 +02:00
}
2009-03-03 01:20:21 +01:00
}
2006-09-16 02:14:11 +02:00
2021-02-23 18:59:19 +01:00
if ( ! $error ) {
if ( ! empty ( $backtopage )) {
2020-10-31 14:32:18 +01:00
unset ( $_SESSION [ 'assignedtouser' ]);
header ( " Location: " . $backtopage );
exit ;
}
2009-03-03 01:20:21 +01:00
}
2003-08-03 19:26:19 +02:00
}
2003-08-03 14:18:29 +02:00
2014-09-20 00:57:29 +02:00
/*
* delete event
*/
2021-02-23 18:59:19 +01:00
if ( empty ( $reshook ) && $action == 'confirm_delete' && GETPOST ( " confirm " ) == 'yes' ) {
2019-12-10 21:11:52 +01:00
$object -> fetch ( $id );
2020-10-31 14:32:18 +01:00
$object -> fetch_optionals ();
$object -> fetch_userassigned ();
$object -> oldcopy = clone $object ;
2014-09-20 00:57:29 +02:00
if ( $user -> rights -> agenda -> myactions -> delete
2021-02-23 18:59:19 +01:00
|| $user -> rights -> agenda -> allactions -> delete ) {
2019-11-13 19:35:39 +01:00
$result = $object -> delete ();
2014-09-20 00:57:29 +02:00
2021-02-23 18:59:19 +01:00
if ( $result >= 0 ) {
2014-09-20 00:57:29 +02:00
header ( " Location: index.php " );
exit ;
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2014-09-20 00:57:29 +02:00
}
}
}
2014-08-08 14:25:14 +02:00
/*
* Action move update , used when user move an event in calendar by drag ' n drop
2017-11-25 00:12:45 +01:00
* TODO Move this into page comm / action / index that trigger this call by the drag and drop of event .
2014-08-08 14:25:14 +02:00
*/
2021-02-23 18:59:19 +01:00
if ( empty ( $reshook ) && GETPOST ( 'actionmove' , 'alpha' ) == 'mupdate' ) {
2020-10-31 14:32:18 +01:00
$error = 0 ;
2014-09-23 16:15:15 +02:00
2021-02-18 15:41:52 +01:00
$shour = dol_print_date ( $object -> datep , " %H " , 'tzuserrel' ); // We take the date visible by user $newdate is also date visible by user.
$smin = dol_print_date ( $object -> datep , " %M " , 'tzuserrel' );
2014-09-07 19:56:17 +02:00
2020-10-31 14:32:18 +01:00
$newdate = GETPOST ( 'newdate' , 'alpha' );
2021-02-23 18:59:19 +01:00
if ( empty ( $newdate ) || strpos ( $newdate , 'dayevent_' ) != 0 ) {
2020-10-31 14:32:18 +01:00
header ( " Location: " . $backtopage );
exit ;
}
2011-04-09 13:52:11 +02:00
2021-02-18 15:41:52 +01:00
$datep = dol_mktime ( $shour , $smin , 0 , substr ( $newdate , 13 , 2 ), substr ( $newdate , 15 , 2 ), substr ( $newdate , 9 , 4 ), 'tzuserrel' );
//print dol_print_date($datep, 'dayhour');exit;
2021-02-23 18:59:19 +01:00
if ( $datep != $object -> datep ) {
if ( ! empty ( $object -> datef )) {
2020-10-31 14:32:18 +01:00
$object -> datef += $datep - $object -> datep ;
}
$object -> datep = $datep ;
2019-09-17 16:43:36 +02:00
2020-10-31 14:32:18 +01:00
if ( ! $error ) {
// check if an event resource is already in use
if ( ! empty ( $conf -> global -> RESOURCE_USED_IN_EVENT_CHECK ) && $object -> element == 'action' ) {
$eventDateStart = $object -> datep ;
$eventDateEnd = $object -> datef ;
$sql = " SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " element_resources as er " ;
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . " resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource' " ;
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . " actioncomm as ac ON ac.id = er.element_id AND er.element_type = ' " . $db -> escape ( $object -> element ) . " ' " ;
2021-08-27 16:33:03 +02:00
$sql .= " WHERE ac.id <> " . (( int ) $object -> id );
2020-10-31 14:32:18 +01:00
$sql .= " AND er.resource_id IN ( " ;
$sql .= " SELECT resource_id FROM " . MAIN_DB_PREFIX . " element_resources " ;
2021-08-27 16:33:03 +02:00
$sql .= " WHERE element_id = " . (( int ) $object -> id );
2020-10-31 14:32:18 +01:00
$sql .= " AND element_type = ' " . $db -> escape ( $object -> element ) . " ' " ;
$sql .= " AND busy = 1 " ;
$sql .= " ) " ;
$sql .= " AND er.busy = 1 " ;
$sql .= " AND ( " ;
// event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end)
$sql .= " (ac.datep <= ' " . $db -> idate ( $eventDateStart ) . " ' AND (ac.datep2 IS NULL OR ac.datep2 >= ' " . $db -> idate ( $eventDateStart ) . " ')) " ;
// event date end between ac.datep and ac.datep2
if ( ! empty ( $eventDateEnd )) {
$sql .= " OR (ac.datep <= ' " . $db -> idate ( $eventDateEnd ) . " ' AND (ac.datep2 >= ' " . $db -> idate ( $eventDateEnd ) . " ')) " ;
}
// event date start before ac.datep and event date end after ac.datep2
$sql .= " OR ( " ;
$sql .= " ac.datep >= ' " . $db -> idate ( $eventDateStart ) . " ' " ;
if ( ! empty ( $eventDateEnd )) {
$sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= ' " . $db -> idate ( $eventDateEnd ) . " ') " ;
}
$sql .= " ) " ;
$sql .= " ) " ;
$resql = $db -> query ( $sql );
if ( ! $resql ) {
$error ++ ;
$object -> error = $db -> lasterror ();
$object -> errors [] = $object -> error ;
} else {
if ( $db -> num_rows ( $resql ) > 0 ) {
2022-05-19 09:36:47 +02:00
// Resource already in use
2020-10-31 14:32:18 +01:00
$error ++ ;
$object -> error = $langs -> trans ( 'ErrorResourcesAlreadyInUse' ) . ' : ' ;
while ( $obj = $db -> fetch_object ( $resql )) {
$object -> error .= '<br> - ' . $langs -> trans ( 'ErrorResourceUseInEvent' , $obj -> r_ref , $obj -> ac_label . ' [' . $obj -> ac_id . ']' );
}
$object -> errors [] = $object -> error ;
}
$db -> free ( $resql );
}
if ( $error ) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
}
if ( ! $error ) {
$db -> begin ();
$result = $object -> update ( $user );
if ( $result < 0 ) {
$error ++ ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
$db -> rollback ();
} else {
$db -> commit ();
}
}
}
2021-02-23 18:59:19 +01:00
if ( ! empty ( $backtopage )) {
2020-10-31 14:32:18 +01:00
header ( " Location: " . $backtopage );
exit ;
} else {
$action = '' ;
}
2014-08-08 14:25:14 +02:00
}
2014-09-07 19:56:17 +02:00
2017-08-22 18:33:00 +02:00
// Actions to delete doc
$upload_dir = $conf -> agenda -> dir_output . '/' . dol_sanitizeFileName ( $object -> ref );
2019-11-05 19:41:30 +01:00
$permissiontoadd = ( $user -> rights -> agenda -> allactions -> create || (( $object -> authorid == $user -> id || $object -> userownerid == $user -> id ) && $user -> rights -> agenda -> myactions -> read ));
2019-09-17 08:18:01 +02:00
if ( empty ( $reshook )) {
2020-10-31 14:32:18 +01:00
include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php' ;
2019-09-17 08:15:01 +02:00
}
2017-08-22 18:33:00 +02:00
2014-09-07 19:56:17 +02:00
2020-09-14 20:53:42 +02:00
2008-10-06 23:31:05 +02:00
/*
* View
*/
2019-11-13 19:35:39 +01:00
$form = new Form ( $db );
$formproject = new FormProjets ( $db );
2017-07-29 02:11:45 +02:00
2020-09-14 20:53:42 +02:00
$arrayrecurrulefreq = array (
'no' => $langs -> trans ( " OnceOnly " ),
'MONTHLY' => $langs -> trans ( " EveryMonth " ),
'WEEKLY' => $langs -> trans ( " EveryWeek " ),
//'DAYLY'=>$langs->trans("EveryDay")
);
2019-11-13 19:35:39 +01:00
$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda' ;
2019-01-27 11:55:16 +01:00
llxHeader ( '' , $langs -> trans ( " Agenda " ), $help_url );
2004-08-07 01:39:54 +02:00
2022-07-11 00:05:50 +02:00
if ( $action == 'create' ) {
2009-03-07 02:19:28 +01:00
$contact = new Contact ( $db );
2017-11-18 12:36:03 +01:00
$socpeopleassigned = GETPOST ( " socpeopleassigned " , 'array' );
2021-02-23 18:59:19 +01:00
if ( ! empty ( $socpeopleassigned [ 0 ])) {
2019-11-13 19:35:39 +01:00
$result = $contact -> fetch ( $socpeopleassigned [ 0 ]);
2021-02-23 18:59:19 +01:00
if ( $result < 0 ) {
dol_print_error ( $db , $contact -> error );
}
2006-09-05 01:55:19 +02:00
}
2003-08-29 22:22:27 +02:00
2013-02-19 13:24:32 +01:00
dol_set_focus ( " #label " );
2013-04-03 18:37:54 +02:00
2021-02-23 18:59:19 +01:00
if ( ! empty ( $conf -> use_javascript_ajax )) {
2020-10-31 14:32:18 +01:00
print " \n " . '<script type="text/javascript">' ;
print ' $ ( document ) . ready ( function () {
2012-11-13 16:20:15 +01:00
function setdatefields ()
{
if ( $ ( " #fullday:checked " ) . val () == null ) {
$ ( " .fulldaystarthour " ) . removeAttr ( " disabled " );
$ ( " .fulldaystartmin " ) . removeAttr ( " disabled " );
$ ( " .fulldayendhour " ) . removeAttr ( " disabled " );
$ ( " .fulldayendmin " ) . removeAttr ( " disabled " );
2012-12-01 15:45:05 +01:00
$ ( " #p2 " ) . removeAttr ( " disabled " );
2012-11-13 16:20:15 +01:00
} else {
2015-05-12 14:47:33 +02:00
$ ( " .fulldaystarthour " ) . prop ( " disabled " , true ) . val ( " 00 " );
$ ( " .fulldaystartmin " ) . prop ( " disabled " , true ) . val ( " 00 " );
$ ( " .fulldayendhour " ) . prop ( " disabled " , true ) . val ( " 23 " );
$ ( " .fulldayendmin " ) . prop ( " disabled " , true ) . val ( " 59 " );
$ ( " #p2 " ) . removeAttr ( " disabled " );
2012-11-13 16:20:15 +01:00
}
}
$ ( " #fullday " ) . change ( function () {
2020-06-26 17:17:13 +02:00
console . log ( " setdatefields " );
2010-11-18 23:17:44 +01:00
setdatefields ();
2010-08-29 20:23:56 +02:00
});
2022-05-19 10:31:01 +02:00
2012-11-13 16:20:15 +01:00
$ ( " #selectcomplete " ) . change ( function () {
2022-05-19 10:31:01 +02:00
console . log ( " we change the complete status - set the doneby " );
if ( $ ( " #selectcomplete " ) . val () == 100 ) {
2022-01-17 22:52:56 +01:00
if ( $ ( " #doneby " ) . val () <= 0 ) $ ( " #doneby " ) . val ( \ '' . (( int ) $user -> id ) . ' \ ' );
2011-03-19 20:06:15 +01:00
}
2022-05-19 10:31:01 +02:00
if ( $ ( " #selectcomplete " ) . val () == 0 ) {
2012-11-13 16:20:15 +01:00
$ ( " #doneby " ) . val ( - 1 );
2011-03-19 20:06:15 +01:00
}
2020-08-29 06:05:52 +02:00
});
2022-05-19 10:31:01 +02:00
2020-08-29 06:05:52 +02:00
$ ( " #actioncode " ) . change ( function () {
2012-11-13 16:20:15 +01:00
if ( $ ( " #actioncode " ) . val () == \ ' AC_RDV\ ' ) $ ( " #dateend " ) . addClass ( " fieldrequired " );
else $ ( " #dateend " ) . removeClass ( " fieldrequired " );
2020-08-29 06:05:52 +02:00
});
$ ( " #aphour,#apmin " ) . change ( function () {
if ( $ ( " #actioncode " ) . val () == \ ' AC_RDV\ ' ) {
console . log ( " Start date was changed, we modify end date " + ( parseInt ( $ ( " #aphour " ) . val ())) + " " + $ ( " #apmin " ) . val () + " -> " + ( " 00 " + ( parseInt ( $ ( " #aphour " ) . val ()) + 1 )) . substr ( - 2 , 2 ));
$ ( " #p2hour " ) . val (( " 00 " + ( parseInt ( $ ( " #aphour " ) . val ()) + 1 )) . substr ( - 2 , 2 ));
$ ( " #p2min " ) . val ( $ ( " #apmin " ) . val ());
$ ( " #p2day " ) . val ( $ ( " #apday " ) . val ());
$ ( " #p2month " ) . val ( $ ( " #apmonth " ) . val ());
$ ( " #p2year " ) . val ( $ ( " #apyear " ) . val ());
$ ( " #p2 " ) . val ( $ ( " #ap " ) . val ());
}
});
if ( $ ( " #actioncode " ) . val () == \ ' AC_RDV\ ' ) $ ( " #dateend " ) . addClass ( " fieldrequired " );
else $ ( " #dateend " ) . removeClass ( " fieldrequired " );
setdatefields ();
2010-08-29 20:23:56 +02:00
}) ' ;
2020-10-31 14:32:18 +01:00
print '</script>' . " \n " ;
}
2010-08-29 20:23:56 +02:00
2012-11-13 16:20:15 +01:00
print '<form name="formaction" action="' . $_SERVER [ 'PHP_SELF' ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2014-09-15 19:04:30 +02:00
print '<input type="hidden" name="action" value="add">' ;
2014-10-03 15:58:08 +02:00
print '<input type="hidden" name="donotclearsession" value="1">' ;
2021-05-19 13:56:13 +02:00
print '<input type="hidden" name="page_y" value="">' ;
2021-02-23 18:59:19 +01:00
if ( $backtopage ) {
2021-10-27 16:39:34 +02:00
print '<input type="hidden" name="backtopage" value="' . ( $backtopage != '1' ? $backtopage : dol_htmlentities ( $_SERVER [ " HTTP_REFERER " ])) . '">' ;
2021-02-23 18:59:19 +01:00
}
if ( empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE )) {
print '<input type="hidden" name="actioncode" value="' . dol_getIdFromCode ( $db , 'AC_OTH' , 'c_actioncomm' ) . '">' ;
}
2002-05-09 16:57:48 +02:00
2021-02-23 18:59:19 +01:00
if ( GETPOST ( " actioncode " , 'aZ09' ) == 'AC_RDV' ) {
print load_fiche_titre ( $langs -> trans ( " AddActionRendezVous " ), '' , 'title_agenda' );
} else {
print load_fiche_titre ( $langs -> trans ( " AddAnAction " ), '' , 'title_agenda' );
}
2004-08-07 01:39:54 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ();
2015-05-20 21:50:38 +02:00
2019-06-12 19:03:22 +02:00
print '<table class="border centpercent">' ;
2009-02-04 21:43:18 +01:00
2014-10-03 18:04:13 +02:00
// Type of event
2021-02-23 18:59:19 +01:00
if ( ! empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE )) {
2016-04-04 15:20:21 +02:00
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs -> trans ( " Type " ) . '</span></b></td><td>' ;
2020-08-29 06:05:52 +02:00
$default = ( empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE_DEFAULT ) ? 'AC_RDV' : $conf -> global -> AGENDA_USE_EVENT_TYPE_DEFAULT );
2022-01-17 22:52:56 +01:00
print img_picto ( $langs -> trans ( " ActionType " ), 'square' , 'class="fawidth30 inline-block" style="color: #ddd;"' );
2022-01-17 23:47:23 +01:00
print $formactions -> select_type_actions ( GETPOSTISSET ( " actioncode " ) ? GETPOST ( " actioncode " , 'aZ09' ) : ( $object -> type_code ? $object -> type_code : $default ), " actioncode " , " systemauto " , 0 , - 1 , 0 , 1 ); // TODO Replace 0 with -2 in onlyautoornot
2012-12-01 15:45:05 +01:00
print '</td></tr>' ;
2008-04-16 03:04:12 +02:00
}
2005-02-09 22:15:28 +01:00
2008-09-09 19:57:12 +02:00
// Title
2019-11-13 19:35:39 +01:00
print '<tr><td' . ( empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ) ? ' class="fieldrequired titlefieldcreate"' : '' ) . '>' . $langs -> trans ( " Label " ) . '</td><td><input type="text" id="label" name="label" class="soixantepercent" value="' . GETPOST ( 'label' ) . '"></td></tr>' ;
2009-02-04 21:43:18 +01:00
2020-10-31 18:51:30 +01:00
// Full day
2022-05-19 10:31:01 +02:00
print '<tr><td><span class="fieldrequired">' . $langs -> trans ( " Date " ) . '</span></td><td class="valignmiddle height30 small"><input type="checkbox" id="fullday" name="fullday" ' . ( GETPOST ( 'fullday' ) ? ' checked' : '' ) . '><label for="fullday">' . $langs -> trans ( " EventOnFullDay " ) . '</label>' ;
2020-09-01 23:04:29 +02:00
2022-05-19 10:31:01 +02:00
// Recurring event
2019-11-13 19:35:39 +01:00
$userepeatevent = ( $conf -> global -> MAIN_FEATURES_LEVEL == 2 ? 1 : 0 );
2022-07-11 20:05:49 +02:00
if ( $userepeatevent ) {
2017-11-22 14:42:47 +01:00
// Repeat
2022-05-19 10:31:01 +02:00
//print '<tr><td></td><td colspan="3" class="opacitymedium">';
print ' <div class="opacitymedium inline-block">' ;
print img_picto ( $langs -> trans ( " Recurrence " ), 'recurring' , 'class="paddingright2"' );
2022-07-11 20:05:49 +02:00
print '<input type="hidden" name="recurid" value="' . ( empty ( $object -> recurid ) ? '' : $object -> recurid ) . '">' ;
2019-11-13 19:35:39 +01:00
$selectedrecurrulefreq = 'no' ;
$selectedrecurrulebymonthday = '' ;
$selectedrecurrulebyday = '' ;
2022-07-11 20:05:49 +02:00
$reg = array ();
2021-02-23 18:59:19 +01:00
if ( $object -> recurrule && preg_match ( '/FREQ=([A-Z]+)/i' , $object -> recurrule , $reg )) {
$selectedrecurrulefreq = $reg [ 1 ];
}
if ( $object -> recurrule && preg_match ( '/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i' , $object -> recurrule , $reg )) {
$selectedrecurrulebymonthday = $reg [ 1 ];
}
if ( $object -> recurrule && preg_match ( '/FREQ=WEEKLY.*BYDAY(\d+)/i' , $object -> recurrule , $reg )) {
$selectedrecurrulebyday = $reg [ 1 ];
}
2017-11-22 14:42:47 +01:00
print $form -> selectarray ( 'recurrulefreq' , $arrayrecurrulefreq , $selectedrecurrulefreq , 0 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'marginrightonly' );
// If recurrulefreq is MONTHLY
print '<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">' ;
print $langs -> trans ( " DayOfMonth " ) . ': <input type="input" size="2" name="BYMONTHDAY" value="' . $selectedrecurrulebymonthday . '">' ;
print '</div>' ;
// If recurrulefreq is WEEKLY
print '<div class="hidden marginrightonly inline-block repeateventBYDAY">' ;
print $langs -> trans ( " DayOfWeek " ) . ': <input type="input" size="4" name="BYDAY" value="' . $selectedrecurrulebyday . '">' ;
print '</div>' ;
2021-11-29 15:09:18 +01:00
print ' < script type = " text/javascript " >
2017-11-22 14:42:47 +01:00
jQuery ( document ) . ready ( function () {
function init_repeat ()
{
if ( jQuery ( " #recurrulefreq " ) . val () == \ ' MONTHLY\ ' )
{
jQuery ( " .repeateventBYMONTHDAY " ) . css ( " display " , " inline-block " ); /* use this instead of show because we want inline-block and not block */
jQuery ( " .repeateventBYDAY " ) . hide ();
}
else if ( jQuery ( " #recurrulefreq " ) . val () == \ ' WEEKLY\ ' )
{
jQuery ( " .repeateventBYMONTHDAY " ) . hide ();
jQuery ( " .repeateventBYDAY " ) . css ( " display " , " inline-block " ); /* use this instead of show because we want inline-block and not block */
}
else
{
jQuery ( " .repeateventBYMONTHDAY " ) . hide ();
jQuery ( " .repeateventBYDAY " ) . hide ();
}
}
init_repeat ();
jQuery ( " #recurrulefreq " ) . change ( function () {
init_repeat ();
});
});
</ script > ' ;
2022-05-19 10:31:01 +02:00
print '</div>' ;
//print '</td></tr>';
2017-11-22 14:42:47 +01:00
}
2022-05-19 10:31:01 +02:00
print '</td></tr>' ;
$datep = ( $datep ? $datep : ( is_null ( $object -> datep ) ? '' : $object -> datep ));
if ( GETPOST ( 'datep' , 'int' , 1 )) {
$datep = dol_stringtotime ( GETPOST ( 'datep' , 'int' , 1 ), 'tzuser' );
}
$datef = ( $datef ? $datef : $object -> datef );
if ( GETPOST ( 'datef' , 'int' , 1 )) {
$datef = dol_stringtotime ( GETPOST ( 'datef' , 'int' , 1 ), 'tzuser' );
}
if ( empty ( $datef ) && ! empty ( $datep )) {
if ( GETPOST ( " actioncode " , 'aZ09' ) == 'AC_RDV' || empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE_DEFAULT )) {
$datef = dol_time_plus_duree ( $datep , ( empty ( $conf -> global -> AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS ) ? 1 : $conf -> global -> AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS ), 'h' );
2021-02-23 18:59:19 +01:00
}
2010-11-08 02:25:36 +01:00
}
2022-05-19 10:31:01 +02:00
// Date start
print '<tr><td class="nowrap">' ;
/*
print '<span class="fieldrequired">' . $langs -> trans ( " DateActionStart " ) . '</span>' ;
print ' - ' ;
print '<span id="dateend"' . ( GETPOST ( " actioncode " , 'aZ09' ) == 'AC_RDV' ? ' class="fieldrequired"' : '' ) . '>' . $langs -> trans ( " DateActionEnd " ) . '</span>' ;
*/
print '</td><td>' ;
if ( GETPOST ( " afaire " ) == 1 ) {
print $form -> selectDate ( $datep , 'ap' , 1 , 1 , 0 , " action " , 1 , 2 , 0 , 'fulldaystart' , '' , '' , '' , 1 , '' , '' , 'tzuserrel' ); // Empty value not allowed for start date and hours if "todo"
} else {
print $form -> selectDate ( $datep , 'ap' , 1 , 1 , 1 , " action " , 1 , 2 , 0 , 'fulldaystart' , '' , '' , '' , 1 , '' , '' , 'tzuserrel' );
2020-10-31 14:32:18 +01:00
}
2022-05-19 10:31:01 +02:00
print ' <span class="hideonsmartphone"> - </span> ' ;
if ( GETPOST ( " afaire " ) == 1 ) {
print $form -> selectDate ( $datef , 'p2' , 1 , 1 , 1 , " action " , 1 , 0 , 0 , 'fulldayend' , '' , '' , '' , 1 , '' , '' , 'tzuserrel' );
} else {
print $form -> selectDate ( $datef , 'p2' , 1 , 1 , 1 , " action " , 1 , 0 , 0 , 'fulldayend' , '' , '' , '' , 1 , '' , '' , 'tzuserrel' );
}
print '</td></tr>' ;
print '<tr><td class=""> </td><td></td></tr>' ;
2010-11-20 19:41:09 +01:00
2014-08-03 23:32:36 +02:00
// Assigned to
2022-05-19 10:31:01 +02:00
print '<tr><td class="tdtop nowrap"><span class="fieldrequired">' . $langs -> trans ( " ActionAffectedTo " ) . '</span></td><td>' ;
2019-11-13 19:35:39 +01:00
$listofuserid = array ();
2020-10-13 10:05:47 +02:00
$listofcontactid = array ();
$listofotherid = array ();
2020-10-17 19:52:23 +02:00
2021-02-23 18:59:19 +01:00
if ( empty ( $donotclearsession )) {
2019-11-13 19:35:39 +01:00
$assignedtouser = GETPOST ( " assignedtouser " ) ? GETPOST ( " assignedtouser " ) : ( ! empty ( $object -> userownerid ) && $object -> userownerid > 0 ? $object -> userownerid : $user -> id );
2021-02-23 18:59:19 +01:00
if ( $assignedtouser ) {
$listofuserid [ $assignedtouser ] = array ( 'id' => $assignedtouser , 'mandatory' => 0 , 'transparency' => $object -> transparency ); // Owner first
}
2020-10-17 19:52:23 +02:00
//$listofuserid[$user->id] = array('id'=>$user->id, 'mandatory'=>0, 'transparency'=>(GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1)); // 1 by default at first init
$listofuserid [ $assignedtouser ][ 'transparency' ] = ( GETPOSTISSET ( 'transparency' ) ? GETPOST ( 'transparency' , 'alpha' ) : 1 ); // 1 by default at first init
2019-11-13 19:35:39 +01:00
$_SESSION [ 'assignedtouser' ] = json_encode ( $listofuserid );
2020-05-21 15:05:19 +02:00
} else {
2021-02-23 18:59:19 +01:00
if ( ! empty ( $_SESSION [ 'assignedtouser' ])) {
2019-11-13 19:35:39 +01:00
$listofuserid = json_decode ( $_SESSION [ 'assignedtouser' ], true );
2014-10-05 03:44:20 +02:00
}
2020-10-17 19:52:23 +02:00
$firstelem = reset ( $listofuserid );
2021-02-23 18:59:19 +01:00
if ( isset ( $listofuserid [ $firstelem [ 'id' ]])) {
$listofuserid [ $firstelem [ 'id' ]][ 'transparency' ] = ( GETPOSTISSET ( 'transparency' ) ? GETPOST ( 'transparency' , 'alpha' ) : 0 ); // 0 by default when refreshing
}
2014-10-05 03:44:20 +02:00
}
2015-11-22 12:33:56 +01:00
print '<div class="assignedtouser">' ;
2019-11-13 19:35:39 +01:00
print $form -> select_dolusers_forevent (( $action == 'create' ? 'add' : 'update' ), 'assignedtouser' , 1 , '' , 0 , '' , '' , 0 , 0 , 0 , 'AND u.statut != 0' , 1 , $listofuserid , $listofcontactid , $listofotherid );
2015-11-22 12:33:56 +01:00
print '</div>' ;
2013-06-05 16:24:32 +02:00
print '</td></tr>' ;
2013-04-06 17:39:31 +02:00
2020-09-12 03:02:08 +02:00
// Done by
2021-02-23 18:59:19 +01:00
if ( ! empty ( $conf -> global -> AGENDA_ENABLE_DONEBY )) {
2013-07-19 14:23:42 +02:00
print '<tr><td class="nowrap">' . $langs -> trans ( " ActionDoneBy " ) . '</td><td>' ;
2020-10-18 14:00:47 +02:00
print $form -> select_dolusers ( GETPOSTISSET ( " doneby " ) ? GETPOST ( " doneby " , 'int' ) : ( ! empty ( $object -> userdoneid ) && $percent == 100 ? $object -> userdoneid : 0 ), 'doneby' , 1 );
2013-04-06 17:39:31 +02:00
print '</td></tr>' ;
}
2010-11-08 02:25:36 +01:00
2022-05-19 10:31:01 +02:00
// Location
if ( empty ( $conf -> global -> AGENDA_DISABLE_LOCATION )) {
print '<tr><td>' . $langs -> trans ( " Location " ) . '</td><td><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="' . ( GETPOST ( 'location' ) ? GETPOST ( 'location' ) : $object -> location ) . '"></td></tr>' ;
}
// Status
print '<tr><td>' . $langs -> trans ( " Status " ) . ' / ' . $langs -> trans ( " Percentage " ) . '</td>' ;
print '<td>' ;
$percent = $complete !== '' ? $complete : - 1 ;
if ( GETPOSTISSET ( 'status' )) {
$percent = GETPOST ( 'status' );
} elseif ( GETPOSTISSET ( 'percentage' )) {
$percent = GETPOST ( 'percentage' , 'int' );
} else {
if ( $complete == '0' || GETPOST ( " afaire " ) == 1 ) {
$percent = '0' ;
} elseif ( $complete == 100 || GETPOST ( " afaire " ) == 2 ) {
$percent = 100 ;
}
}
$formactions -> form_select_status_action ( 'formaction' , $percent , 1 , 'complete' , 0 , 0 , 'maxwidth200' );
print '</td></tr>' ;
2022-05-27 16:30:26 +02:00
if ( ! empty ( $conf -> categorie -> enabled )) {
2019-11-13 21:18:34 +01:00
// Categories
2020-10-13 10:05:47 +02:00
print '<tr><td>' . $langs -> trans ( " Categories " ) . '</td><td>' ;
2019-11-13 21:18:34 +01:00
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_ACTIONCOMM , '' , 'parent' , 64 , 0 , 1 );
2020-12-03 14:34:15 +01:00
print img_picto ( '' , 'category' ) . $form -> multiselectarray ( 'categories' , $cate_arbo , GETPOST ( 'categories' , 'array' ), '' , 0 , 'minwidth300 quatrevingtpercent widthcentpercentminusx' , 0 , 0 );
2019-11-13 21:18:34 +01:00
print " </td></tr> " ;
}
2010-11-08 02:25:36 +01:00
print '</table>' ;
2017-11-22 14:42:47 +01:00
print '<br><hr><br>' ;
2017-06-07 16:44:04 +02:00
2019-06-12 19:32:29 +02:00
print '<table class="border centpercent">' ;
2009-02-04 21:43:18 +01:00
2022-05-27 16:30:26 +02:00
if ( ! empty ( $conf -> societe -> enabled )) {
2017-11-22 14:42:47 +01:00
// Related company
print '<tr><td class="titlefieldcreate nowrap">' . $langs -> trans ( " ActionOnCompany " ) . '</td><td>' ;
2020-10-17 15:53:31 +02:00
if ( GETPOST ( 'socid' , 'int' ) > 0 ) {
2017-11-22 14:42:47 +01:00
$societe = new Societe ( $db );
2019-01-27 11:55:16 +01:00
$societe -> fetch ( GETPOST ( 'socid' , 'int' ));
2017-11-22 14:42:47 +01:00
print $societe -> getNomUrl ( 1 );
2019-01-27 11:55:16 +01:00
print '<input type="hidden" id="socid" name="socid" value="' . GETPOST ( 'socid' , 'int' ) . '">' ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-13 19:35:39 +01:00
$events = array ();
$events [] = array ( 'method' => 'getContacts' , 'url' => dol_buildpath ( '/core/ajax/contacts.php?showempty=1' , 1 ), 'htmlname' => 'contactid' , 'params' => array ( 'add-customer-contact' => 'disabled' ));
2017-11-22 14:42:47 +01:00
//For external user force the company to user company
2019-10-31 20:46:31 +01:00
if ( ! empty ( $user -> socid )) {
2020-09-14 20:53:42 +02:00
print img_picto ( '' , 'company' , 'class="paddingrightonly"' ) . $form -> select_company ( $user -> socid , 'socid' , '' , 1 , 1 , 0 , $events , 0 , 'minwidth300' );
2017-11-22 14:42:47 +01:00
} else {
2020-09-14 20:53:42 +02:00
print img_picto ( '' , 'company' , 'class="paddingrightonly"' ) . $form -> select_company ( '' , 'socid' , '' , 'SelectThirdParty' , 1 , 0 , $events , 0 , 'minwidth300' );
2017-11-22 14:42:47 +01:00
}
}
print '</td></tr>' ;
2013-12-15 14:26:27 +01:00
2017-11-22 14:42:47 +01:00
// Related contact
print '<tr><td class="nowrap">' . $langs -> trans ( " ActionOnContact " ) . '</td><td>' ;
2019-11-13 19:35:39 +01:00
$preselectedids = GETPOST ( 'socpeopleassigned' , 'array' );
2021-02-23 18:59:19 +01:00
if ( GETPOST ( 'contactid' , 'int' )) {
$preselectedids [ GETPOST ( 'contactid' , 'int' )] = GETPOST ( 'contactid' , 'int' );
}
2021-05-03 18:08:49 +02:00
if ( $origin == 'contact' ) $preselectedids [ GETPOST ( 'originid' , 'int' )] = GETPOST ( 'originid' , 'int' );
2020-10-13 10:05:47 +02:00
print img_picto ( '' , 'contact' , 'class="paddingrightonly"' );
print $form -> selectcontacts ( GETPOST ( 'socid' , 'int' ), $preselectedids , 'socpeopleassigned[]' , 1 , '' , '' , 0 , 'minwidth300 quatrevingtpercent' , false , 0 , array (), false , 'multiple' , 'contactid' );
2017-11-22 14:42:47 +01:00
print '</td></tr>' ;
}
2006-09-05 01:55:19 +02:00
2010-01-05 00:33:23 +01:00
// Project
2022-06-14 17:53:17 +02:00
if ( ! empty ( $conf -> project -> enabled )) {
2014-01-26 18:43:30 +01:00
$langs -> load ( " projects " );
2018-11-11 14:36:35 +01:00
2018-09-20 10:08:40 +02:00
$projectid = GETPOST ( 'projectid' , 'int' );
2010-01-05 00:33:23 +01:00
2021-03-12 17:05:11 +01:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " Project " ) . '</td><td id="project-input-container">' ;
2021-05-19 13:56:13 +02:00
print img_picto ( '' , 'project' , 'class="pictofixedwidth"' );
2022-05-21 01:23:39 +02:00
print $formproject -> select_projects (( $object -> socid > 0 ? $object -> socid : - 1 ), $projectid , 'projectid' , 0 , 0 , 1 , 1 , 0 , 0 , 0 , '' , 1 , 0 , 'maxwidth500 widthcentpercentminusxx' );
2018-11-11 14:36:35 +01:00
2021-09-19 00:50:23 +02:00
print ' <a href="' . DOL_URL_ROOT . '/projet/card.php?socid=' . ( empty ( $societe -> id ) ? '' : $societe -> id ) . '&action=create&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?action=create' ) . '">' ;
2021-03-12 17:05:11 +01:00
print '<span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs -> trans ( " AddProject " ) . '"></span></a>' ;
2020-02-18 11:18:00 +01:00
$urloption = '?action=create&donotclearsession=1' ;
2019-01-27 11:55:16 +01:00
$url = dol_buildpath ( 'comm/action/card.php' , 2 ) . $urloption ;
2018-11-11 14:36:35 +01:00
2018-09-20 10:08:40 +02:00
// update task list
print " \n " . '<script type="text/javascript">' ;
print ' $ ( document ) . ready ( function () {
$ ( " #projectid " ) . change ( function () {
2023-03-03 12:00:24 +01:00
var url = " '.DOL_URL_ROOT.'/projet/ajax/projects.php?mode=gettasks&socid= " + $ ( " #search_socid " ) . val () + " &projectid= " + $ ( " #projectid " ) . val ();
2020-10-17 21:14:19 +02:00
console . log ( " Call url to get new list of tasks: " + url );
2018-09-20 10:08:40 +02:00
$ . get ( url , function ( data ) {
2020-10-17 21:14:19 +02:00
console . log ( data );
if ( data ) $ ( " #taskid " ) . html ( data ) . select2 ();
2018-09-20 10:08:40 +02:00
})
});
}) ' ;
print '</script>' . " \n " ;
2018-11-11 14:36:35 +01:00
2018-09-20 10:08:40 +02:00
print '</td></tr>' ;
2018-11-11 14:36:35 +01:00
2018-09-20 10:08:40 +02:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " Task " ) . '</td><td id="project-task-input-container" >' ;
2020-09-14 20:53:42 +02:00
print img_picto ( '' , 'projecttask' , 'class="paddingrightonly"' );
2019-11-13 19:35:39 +01:00
$projectsListId = false ;
2021-02-23 18:59:19 +01:00
if ( ! empty ( $projectid )) {
$projectsListId = $projectid ;
}
2021-11-19 23:13:32 +01:00
2021-09-19 00:50:23 +02:00
$tid = GETPOSTISSET ( " projecttaskid " ) ? GETPOST ( " projecttaskid " , 'int' ) : ( GETPOSTISSET ( " taskid " ) ? GETPOST ( " taskid " , 'int' ) : '' );
2021-11-19 23:13:32 +01:00
2019-11-13 19:35:39 +01:00
$formproject -> selectTasks (( ! empty ( $societe -> id ) ? $societe -> id : - 1 ), $tid , 'taskid' , 24 , 0 , '1' , 1 , 0 , 0 , 'maxwidth500' , $projectsListId );
2010-01-05 00:33:23 +01:00
print '</td></tr>' ;
}
2019-10-12 12:31:35 +02:00
// Object linked
2021-02-23 18:59:19 +01:00
if ( ! empty ( $origin ) && ! empty ( $originid )) {
2015-04-23 15:54:49 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
2021-09-19 00:50:23 +02:00
$hasPermissionOnLinkedObject = 0 ;
if ( $user -> hasRight ( $origin , 'read' )) {
$hasPermissionOnLinkedObject = 1 ;
}
2021-12-19 03:54:04 +01:00
//var_dump('origin='.$origin.' originid='.$originid.' hasPermissionOnLinkedObject='.$hasPermissionOnLinkedObject);
2021-09-19 00:50:23 +02:00
if ( ! in_array ( $origin , array ( 'societe' , 'project' , 'task' , 'user' ))) {
// We do not use link for object that already contains a hard coded field to make links with agenda events
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " LinkedObject " ) . '</td>' ;
print '<td colspan="3">' ;
if ( $hasPermissionOnLinkedObject ) {
print dolGetElementUrl ( $originid , $origin , 1 );
print '<input type="hidden" name="fk_element" value="' . $originid . '">' ;
print '<input type="hidden" name="elementtype" value="' . $origin . '">' ;
print '<input type="hidden" name="originid" value="' . $originid . '">' ;
print '<input type="hidden" name="origin" value="' . $origin . '">' ;
} else {
print '<!-- no permission on object to link ' . $origin . ' id ' . $originid . ' -->' ;
}
print '</td></tr>' ;
}
2013-08-27 15:51:06 +02:00
}
2010-01-05 00:33:23 +01:00
2020-07-24 11:53:44 +02:00
$reg = array ();
2021-02-23 18:59:19 +01:00
if ( GETPOST ( " datep " ) && preg_match ( '/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/' , GETPOST ( " datep " ), $reg )) {
2019-11-13 19:35:39 +01:00
$object -> datep = dol_mktime ( 0 , 0 , 0 , $reg [ 2 ], $reg [ 3 ], $reg [ 1 ]);
2003-08-03 19:26:19 +02:00
}
2006-09-05 01:55:19 +02:00
2008-10-06 23:31:05 +02:00
// Priority
2020-10-31 14:32:18 +01:00
if ( ! empty ( $conf -> global -> AGENDA_SUPPORT_PRIORITY_IN_EVENTS )) {
2020-08-29 06:17:26 +02:00
print '<tr><td class="titlefieldcreate nowrap">' . $langs -> trans ( " Priority " ) . '</td><td colspan="3">' ;
print '<input type="text" name="priority" value="' . ( GETPOSTISSET ( 'priority' ) ? GETPOST ( 'priority' , 'int' ) : ( $object -> priority ? $object -> priority : '' )) . '" size="5">' ;
print '</td></tr>' ;
}
2004-10-02 16:24:43 +02:00
2020-10-31 14:32:18 +01:00
// Description
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2022-08-26 11:08:39 +02:00
$doleditor = new DolEditor ( 'note' , ( GETPOSTISSET ( 'note' ) ? GETPOST ( 'note' , 'restricthtml' ) : $object -> note_private ), '' , 120 , 'dolibarr_notes' , 'In' , true , true , isModEnabled ( 'fckeditor' ), ROWS_4 , '90%' );
2020-10-31 14:32:18 +01:00
$doleditor -> Create ();
print '</td></tr>' ;
2013-12-15 14:26:27 +01:00
2020-10-31 14:32:18 +01:00
// Other attributes
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2021-02-23 18:59:19 +01:00
if ( empty ( $reshook )) {
2021-10-08 15:58:08 +02:00
print $object -> showOptionals ( $extrafields , 'create' , $parameters );
2012-12-08 12:49:20 +01:00
}
2013-04-03 18:37:54 +02:00
2013-04-01 19:43:26 +02:00
print '</table>' ;
2012-12-08 12:49:20 +01:00
2020-08-25 12:40:29 +02:00
2022-01-17 17:51:03 +01:00
if ( getDolGlobalString ( 'AGENDA_REMINDER_EMAIL' ) || getDolGlobalString ( 'AGENDA_REMINDER_BROWSER' )) {
2020-10-31 14:32:18 +01:00
//checkbox create reminder
print '<hr>' ;
print '<br>' ;
2022-01-02 13:51:30 +01:00
print '<label for="addreminder">' . img_picto ( '' , 'bell' , 'class="pictofixedwidth"' ) . $langs -> trans ( " AddReminder " ) . '</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>' ;
2020-08-26 11:19:14 +02:00
2020-10-31 14:32:18 +01:00
print '<div class="reminderparameters" style="display: none;">' ;
2020-08-26 11:19:14 +02:00
2020-10-31 14:32:18 +01:00
//print '<hr>';
//print load_fiche_titre($langs->trans("AddReminder"), '', '');
2020-08-25 12:40:29 +02:00
2020-10-31 14:32:18 +01:00
print '<table class="border centpercent">' ;
2020-08-25 12:40:29 +02:00
2020-10-31 14:32:18 +01:00
//Reminder
print '<tr><td class="titlefieldcreate nowrap">' . $langs -> trans ( " ReminderTime " ) . '</td><td colspan="3">' ;
2020-12-11 02:23:43 +01:00
print '<input class="width50" type="number" name="offsetvalue" value="' . ( GETPOSTISSET ( 'offsetvalue' ) ? GETPOST ( 'offsetvalue' , 'int' ) : '15' ) . '"> ' ;
print $form -> selectTypeDuration ( 'offsetunit' , 'i' , array ( 'y' , 'm' ));
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
2020-08-25 12:57:36 +02:00
2020-10-31 14:32:18 +01:00
//Reminder Type
print '<tr><td class="titlefieldcreate nowrap">' . $langs -> trans ( " ReminderType " ) . '</td><td colspan="3">' ;
2022-01-02 13:51:30 +01:00
print $form -> selectarray ( 'selectremindertype' , $TRemindTypes , '' , 0 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'minwidth200 maxwidth500' , 1 );
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
2020-08-25 12:40:29 +02:00
2020-10-31 14:32:18 +01:00
//Mail Model
2022-01-17 17:51:03 +01:00
if ( getDolGlobalString ( 'AGENDA_REMINDER_EMAIL' )) {
print '<tr><td class="titlefieldcreate nowrap">' . $langs -> trans ( " EMailTemplates " ) . '</td><td colspan="3">' ;
print $form -> selectModelMail ( 'actioncommsend' , 'actioncomm_send' , 1 , 1 );
print '</td></tr>' ;
}
2020-08-25 17:26:32 +02:00
2020-10-31 14:32:18 +01:00
print '</table>' ;
print '</div>' ;
2020-08-26 11:36:32 +02:00
2020-10-31 14:32:18 +01:00
print " \n " . '<script type="text/javascript">' ;
print ' $ ( document ) . ready ( function () {
2020-08-26 11:36:32 +02:00
$ ( " #addreminder " ) . click ( function (){
2022-01-02 13:51:30 +01:00
console . log ( " Click on addreminder " );
2020-08-26 11:36:32 +02:00
if ( this . checked ) {
2022-01-02 13:51:30 +01:00
$ ( " .reminderparameters " ) . show ();
2020-08-26 11:36:32 +02:00
} else {
2022-01-02 13:51:30 +01:00
$ ( " .reminderparameters " ) . hide ();
2020-08-26 11:36:32 +02:00
}
2022-01-02 13:51:30 +01:00
$ ( " #selectremindertype " ) . select2 ( " destroy " );
$ ( " #selectremindertype " ) . select2 ();
2022-01-02 15:08:46 +01:00
$ ( " #select_offsetunittype_duration " ) . select2 ( " destroy " );
$ ( " #select_offsetunittype_duration " ) . select2 ();
2020-08-26 11:36:32 +02:00
});
2020-08-29 06:05:52 +02:00
2020-09-24 12:31:28 +02:00
$ ( " #selectremindertype " ) . change ( function (){
2022-01-02 13:51:30 +01:00
console . log ( " Change on selectremindertype " );
2020-08-26 12:48:12 +02:00
var selected_option = $ ( " #selectremindertype option:selected " ) . val ();
if ( selected_option == " email " ) {
2020-08-27 11:15:08 +02:00
$ ( " #select_actioncommsendmodel_mail " ) . closest ( " tr " ) . show ();
2020-08-26 11:36:32 +02:00
} else {
2020-08-27 11:15:08 +02:00
$ ( " #select_actioncommsendmodel_mail " ) . closest ( " tr " ) . hide ();
2020-08-26 11:36:32 +02:00
};
2020-08-29 06:05:52 +02:00
});
2020-08-26 11:36:32 +02:00
}) ' ;
2020-10-31 14:32:18 +01:00
print '</script>' . " \n " ;
}
2020-08-25 12:40:29 +02:00
2020-10-31 14:32:18 +01:00
print dol_get_fiche_end ();
2015-05-20 21:50:38 +02:00
2021-08-20 14:41:30 +02:00
print $form -> buttonsSaveCancel ( " Add " );
2003-05-25 18:32:02 +02:00
2006-09-05 01:55:19 +02:00
print " </form> " ;
2002-04-29 20:01:16 +02:00
}
2004-08-07 01:39:54 +02:00
2010-11-18 23:17:44 +01:00
// View or edit
2021-02-23 18:59:19 +01:00
if ( $id > 0 ) {
2019-11-13 19:35:39 +01:00
$result1 = $object -> fetch ( $id );
2021-02-23 18:59:19 +01:00
if ( $result1 <= 0 ) {
2018-08-15 14:42:03 +02:00
$langs -> load ( " errors " );
print $langs -> trans ( " ErrorRecordNotFound " );
llxFooter ();
exit ;
}
2019-11-13 19:35:39 +01:00
$result2 = $object -> fetch_thirdparty ();
$result2 = $object -> fetch_projet ();
$result3 = $object -> fetch_contact ();
$result4 = $object -> fetch_userassigned ();
$result5 = $object -> fetch_optionals ();
2017-06-07 16:44:04 +02:00
2021-02-23 18:59:19 +01:00
if ( $listUserAssignedUpdated || $donotclearsession ) {
2021-09-01 17:10:26 +02:00
$percentage = in_array ( GETPOST ( 'status' ), array ( - 1 , 100 )) ? GETPOST ( 'status' ) : ( in_array ( $complete , array ( - 1 , 100 )) ? $complete : GETPOST ( " percentage " , 'int' )); // If status is -1 or 100, percentage is not defined and we must use status
2017-06-07 16:44:04 +02:00
2021-02-02 00:19:41 +01:00
$datep = dol_mktime ( $fulldayevent ? '00' : $aphour , $fulldayevent ? '00' : $apmin , 0 , GETPOST ( " apmonth " , 'int' ), GETPOST ( " apday " , 'int' ), GETPOST ( " apyear " , 'int' ), 'tzuser' );
$datef = dol_mktime ( $fulldayevent ? '23' : $p2hour , $fulldayevent ? '59' : $p2min , $fulldayevent ? '59' : '0' , GETPOST ( " p2month " , 'int' ), GETPOST ( " p2day " , 'int' ), GETPOST ( " p2year " , 'int' ), 'tzuser' );
2015-11-05 11:11:03 +01:00
2019-09-11 17:51:50 +02:00
$object -> type_id = dol_getIdFromCode ( $db , GETPOST ( " actioncode " , 'aZ09' ), 'c_actioncomm' );
$object -> label = GETPOST ( " label " , " alphanohtml " );
2015-11-05 11:11:03 +01:00
$object -> datep = $datep ;
$object -> datef = $datef ;
$object -> percentage = $percentage ;
2019-09-11 17:51:50 +02:00
$object -> priority = GETPOST ( " priority " , " alphanohtml " );
2020-10-31 14:32:18 +01:00
$object -> fulldayevent = GETPOST ( " fullday " ) ? 1 : 0 ;
2019-09-11 17:51:50 +02:00
$object -> location = GETPOST ( 'location' , " alpanohtml " );
$object -> socid = GETPOST ( " socid " , " int " );
2019-01-27 11:55:16 +01:00
$socpeopleassigned = GETPOST ( " socpeopleassigned " , 'array' );
2021-02-23 18:59:19 +01:00
foreach ( $socpeopleassigned as $tmpid ) {
$object -> socpeopleassigned [ $id ] = array ( 'id' => $tmpid );
}
2020-06-25 12:17:47 +02:00
$object -> contact_id = GETPOST ( " contactid " , 'int' );
2019-01-27 11:55:16 +01:00
$object -> fk_project = GETPOST ( " projectid " , 'int' );
2017-06-07 16:44:04 +02:00
2020-10-17 21:14:19 +02:00
$object -> note_private = GETPOST ( " note " , 'restricthtml' );
2015-11-05 11:11:03 +01:00
}
2021-02-23 18:59:19 +01:00
if ( $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0 ) {
2019-01-27 11:55:16 +01:00
dol_print_error ( $db , $object -> error );
2010-05-07 21:33:17 +02:00
exit ;
}
2009-02-04 21:43:18 +01:00
2021-02-23 18:59:19 +01:00
if ( $object -> authorid > 0 ) {
$tmpuser = new User ( $db ); $res = $tmpuser -> fetch ( $object -> authorid ); $object -> author = $tmpuser ;
}
if ( $object -> usermodid > 0 ) {
$tmpuser = new User ( $db ); $res = $tmpuser -> fetch ( $object -> usermodid ); $object -> usermod = $tmpuser ;
}
2014-09-29 13:21:03 +02:00
2004-10-02 16:24:43 +02:00
2009-03-03 01:20:21 +01:00
/*
2014-09-29 13:21:03 +02:00
* Show tabs
2009-03-03 01:20:21 +01:00
*/
2004-10-02 16:24:43 +02:00
2019-11-13 19:35:39 +01:00
$head = actions_prepare_head ( $object );
2004-10-02 16:24:43 +02:00
2019-11-13 19:35:39 +01:00
$now = dol_now ();
$delay_warning = $conf -> global -> MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60 ;
2009-02-04 21:43:18 +01:00
2021-02-14 20:12:43 +01:00
2009-03-03 01:20:21 +01:00
// Confirmation suppression action
2021-02-23 18:59:19 +01:00
if ( $action == 'delete' ) {
2021-04-25 15:55:36 +02:00
print $form -> formconfirm ( " card.php?id= " . urlencode ( $id ), $langs -> trans ( " DeleteAction " ), $langs -> trans ( " ConfirmDeleteAction " ), " confirm_delete " , '' , '' , 1 );
2009-03-03 01:20:21 +01:00
}
2005-10-01 16:25:34 +02:00
2021-02-23 18:59:19 +01:00
if ( $action == 'edit' ) {
if ( ! empty ( $conf -> use_javascript_ajax )) {
2020-10-31 14:32:18 +01:00
print " \n " . '<script type="text/javascript">' ;
print ' $ ( document ) . ready ( function () {
2012-11-13 16:20:15 +01:00
function setdatefields ()
{
if ( $ ( " #fullday:checked " ) . val () == null ) {
$ ( " .fulldaystarthour " ) . removeAttr ( " disabled " );
$ ( " .fulldaystartmin " ) . removeAttr ( " disabled " );
$ ( " .fulldayendhour " ) . removeAttr ( " disabled " );
$ ( " .fulldayendmin " ) . removeAttr ( " disabled " );
} else {
2015-05-12 14:47:33 +02:00
$ ( " .fulldaystarthour " ) . prop ( " disabled " , true ) . val ( " 00 " );
$ ( " .fulldaystartmin " ) . prop ( " disabled " , true ) . val ( " 00 " );
$ ( " .fulldayendhour " ) . prop ( " disabled " , true ) . val ( " 23 " );
$ ( " .fulldayendmin " ) . prop ( " disabled " , true ) . val ( " 59 " );
2012-11-13 16:20:15 +01:00
}
}
setdatefields ();
$ ( " #fullday " ) . change ( function () {
setdatefields ();
});
2022-03-04 11:58:52 +01:00
$ ( " #actioncode " ) . change ( function () {
if ( $ ( " #actioncode " ) . val () == \ ' AC_RDV\ ' ) $ ( " #dateend " ) . addClass ( " fieldrequired " );
else $ ( " #dateend " ) . removeClass ( " fieldrequired " );
});
2010-11-18 23:17:44 +01:00
}) ' ;
2020-10-31 14:32:18 +01:00
print '</script>' . " \n " ;
}
2010-11-18 23:17:44 +01:00
2012-11-13 16:20:15 +01:00
print '<form name="formaction" action="' . $_SERVER [ 'PHP_SELF' ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2009-03-03 01:20:21 +01:00
print '<input type="hidden" name="action" value="update">' ;
2010-09-12 22:59:38 +02:00
print '<input type="hidden" name="id" value="' . $id . '">' ;
2014-01-30 00:40:00 +01:00
print '<input type="hidden" name="ref_ext" value="' . $object -> ref_ext . '">' ;
2021-05-19 13:56:13 +02:00
print '<input type="hidden" name="page_y" value="">' ;
2021-02-23 18:59:19 +01:00
if ( $backtopage ) {
2021-11-01 10:33:54 +01:00
print '<input type="hidden" name="backtopage" value="' . ( $backtopage != '1' ? $backtopage : dol_htmlentities ( $_SERVER [ " HTTP_REFERER " ])) . '">' ;
2021-02-23 18:59:19 +01:00
}
2022-10-13 12:18:25 +02:00
if ( empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ) && $object -> code != " TICKET_MSG_PRIVATE " ) {
2021-02-23 18:59:19 +01:00
print '<input type="hidden" name="actioncode" value="' . $object -> type_code . '">' ;
}
2004-08-07 01:39:54 +02:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'card' , $langs -> trans ( " Action " ), 0 , 'action' );
2013-04-25 01:13:13 +02:00
2019-03-05 12:18:36 +01:00
print '<table class="border tableforfield" width="100%">' ;
2008-09-09 19:57:12 +02:00
2009-03-03 01:20:21 +01:00
// Ref
2016-04-23 16:51:22 +02:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " Ref " ) . '</td><td colspan="3">' . $object -> id . '</td></tr>' ;
2009-02-04 21:43:18 +01:00
2014-10-03 18:04:13 +02:00
// Type of event
2022-10-14 09:54:47 +02:00
if ( ! empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ) && $object -> elementtype != " ticket " ) {
2020-10-31 14:32:18 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Type " ) . '</td><td colspan="3">' ;
2021-02-23 18:59:19 +01:00
if ( $object -> type_code != 'AC_OTH_AUTO' ) {
2022-05-19 10:31:01 +02:00
print img_picto ( $langs -> trans ( " ActionType " ), 'square' , 'class="fawidth30 inline-block" style="color: #ddd;"' );
2021-02-14 20:12:43 +01:00
print $formactions -> select_type_actions ( GETPOST ( " actioncode " , 'aZ09' ) ? GETPOST ( " actioncode " , 'aZ09' ) : $object -> type_code , " actioncode " , " systemauto " , 0 , 0 , 0 , 1 );
2020-10-31 14:32:18 +01:00
} else {
2021-02-14 20:12:43 +01:00
print '<input type="hidden" name="actioncode" value="' . $object -> type_code . '">' ;
print $object -> getTypePicto ();
print $langs -> trans ( " Action " . $object -> type_code );
2020-10-31 14:32:18 +01:00
}
2013-02-27 19:43:40 +01:00
print '</td></tr>' ;
2012-12-01 15:45:05 +01:00
}
2009-02-04 21:43:18 +01:00
2022-10-14 09:54:47 +02:00
// Private
2022-10-15 13:52:57 +02:00
if ( $object -> elementtype == 'ticket' ) print '<tr><td>' . $langs -> trans ( " PrivateEventMessage " ) . '</td><td colspan="3"><input type="checkbox" id="private" name="private" ' . (( $object -> code == 'TICKET_MSG_PRIVATE' ) ? ' checked' : '' ) . '></td></tr>' ;
2022-10-14 09:54:47 +02:00
2009-03-03 01:20:21 +01:00
// Title
2022-05-19 10:31:01 +02:00
print '<tr><td' . ( empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ) ? ' class="fieldrequired titlefieldcreate"' : '' ) . '>' . $langs -> trans ( " Title " ) . '</td><td colspan="3"><input type="text" name="label" class="soixantepercent" value="' . $object -> label . '"></td></tr>' ;
2009-02-04 21:43:18 +01:00
2020-10-31 14:32:18 +01:00
// Full day event
2022-05-19 10:31:01 +02:00
print '<tr><td><span class="fieldrequired">' . $langs -> trans ( " Date " ) . '</span></td><td colspan="3" class="valignmiddle height30 small"><input type="checkbox" id="fullday" name="fullday" ' . ( $object -> fulldayevent ? ' checked' : '' ) . '>' ;
print '<label for="fullday">' . $langs -> trans ( " EventOnFullDay " ) . '</label>' ;
2010-11-08 02:25:36 +01:00
2022-05-19 10:31:01 +02:00
// Recurring event
2019-11-13 19:35:39 +01:00
$userepeatevent = ( $conf -> global -> MAIN_FEATURES_LEVEL == 2 ? 1 : 0 );
2021-02-23 18:59:19 +01:00
if ( $userepeatevent ) {
2015-06-30 21:50:24 +02:00
// Repeat
2022-05-19 10:31:01 +02:00
//print '<tr><td></td><td colspan="3">';
print ' <div class="opacitymedium inline-block">' ;
print img_picto ( $langs -> trans ( " Recurrence " ), 'recurring' , 'class="paddingright2"' );
2015-06-30 21:50:24 +02:00
print '<input type="hidden" name="recurid" value="' . $object -> recurid . '">' ;
2019-11-13 19:35:39 +01:00
$selectedrecurrulefreq = 'no' ;
$selectedrecurrulebymonthday = '' ;
$selectedrecurrulebyday = '' ;
2021-02-23 18:59:19 +01:00
if ( $object -> recurrule && preg_match ( '/FREQ=([A-Z]+)/i' , $object -> recurrule , $reg )) {
$selectedrecurrulefreq = $reg [ 1 ];
}
if ( $object -> recurrule && preg_match ( '/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i' , $object -> recurrule , $reg )) {
$selectedrecurrulebymonthday = $reg [ 1 ];
}
if ( $object -> recurrule && preg_match ( '/FREQ=WEEKLY.*BYDAY(\d+)/i' , $object -> recurrule , $reg )) {
$selectedrecurrulebyday = $reg [ 1 ];
}
2017-11-22 14:42:47 +01:00
print $form -> selectarray ( 'recurrulefreq' , $arrayrecurrulefreq , $selectedrecurrulefreq , 0 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'marginrightonly' );
2015-06-30 21:50:24 +02:00
// If recurrulefreq is MONTHLY
2017-11-22 14:42:47 +01:00
print '<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">' ;
2015-06-30 21:50:24 +02:00
print $langs -> trans ( " DayOfMonth " ) . ': <input type="input" size="2" name="BYMONTHDAY" value="' . $selectedrecurrulebymonthday . '">' ;
print '</div>' ;
// If recurrulefreq is WEEKLY
2017-11-22 14:42:47 +01:00
print '<div class="hidden marginrightonly inline-block repeateventBYDAY">' ;
2015-06-30 21:50:24 +02:00
print $langs -> trans ( " DayOfWeek " ) . ': <input type="input" size="4" name="BYDAY" value="' . $selectedrecurrulebyday . '">' ;
print '</div>' ;
2021-11-29 15:09:18 +01:00
print ' < script type = " text/javascript " >
2015-06-30 21:50:24 +02:00
jQuery ( document ) . ready ( function () {
function init_repeat ()
{
if ( jQuery ( " #recurrulefreq " ) . val () == \ ' MONTHLY\ ' )
{
2017-11-22 14:42:47 +01:00
jQuery ( " .repeateventBYMONTHDAY " ) . css ( " display " , " inline-block " ); /* use this instead of show because we want inline-block and not block */
2015-06-30 21:50:24 +02:00
jQuery ( " .repeateventBYDAY " ) . hide ();
}
else if ( jQuery ( " #recurrulefreq " ) . val () == \ ' WEEKLY\ ' )
{
jQuery ( " .repeateventBYMONTHDAY " ) . hide ();
2017-11-22 14:42:47 +01:00
jQuery ( " .repeateventBYDAY " ) . css ( " display " , " inline-block " ); /* use this instead of show because we want inline-block and not block */
2015-06-30 21:50:24 +02:00
}
else
{
jQuery ( " .repeateventBYMONTHDAY " ) . hide ();
jQuery ( " .repeateventBYDAY " ) . hide ();
}
}
init_repeat ();
jQuery ( " #recurrulefreq " ) . change ( function () {
init_repeat ();
});
});
2015-08-14 13:01:20 +02:00
</ script > ' ;
2022-05-19 10:31:01 +02:00
print '</div>' ;
//print '</td></tr>';
2015-06-30 21:50:24 +02:00
}
2010-11-08 02:25:36 +01:00
print '</td></tr>' ;
2022-05-19 10:31:01 +02:00
// Date start - end
print '<tr><td class="nowrap">' ;
/* print '<span class="fieldrequired">' . $langs -> trans ( " DateActionStart " ) . '</span>' ;
print ' - ' ;
print '<span id="dateend"' . ( $object -> type_code == 'AC_RDV' ? ' class="fieldrequired"' : '' ) . '>' . $langs -> trans ( " DateActionEnd " ) . '</span>' ;
*/
print '</td><td td colspan="3">' ;
$tzforfullday = getDolGlobalString ( 'MAIN_STORE_FULL_EVENT_IN_GMT' );
if ( GETPOST ( " afaire " ) == 1 ) {
print $form -> selectDate ( $datep ? $datep : $object -> datep , 'ap' , 1 , 1 , 0 , " action " , 1 , 1 , 0 , 'fulldaystart' , '' , '' , '' , 1 , '' , '' , $object -> fulldayevent ? ( $tzforfullday ? $tzforfullday : 'tzuserrel' ) : 'tzuserrel' );
} elseif ( GETPOST ( " afaire " ) == 2 ) {
print $form -> selectDate ( $datep ? $datep : $object -> datep , 'ap' , 1 , 1 , 1 , " action " , 1 , 1 , 0 , 'fulldaystart' , '' , '' , '' , 1 , '' , '' , $object -> fulldayevent ? ( $tzforfullday ? $tzforfullday : 'tzuserrel' ) : 'tzuserrel' );
} else {
print $form -> selectDate ( $datep ? $datep : $object -> datep , 'ap' , 1 , 1 , 1 , " action " , 1 , 1 , 0 , 'fulldaystart' , '' , '' , '' , 1 , '' , '' , $object -> fulldayevent ? ( $tzforfullday ? $tzforfullday : 'tzuserrel' ) : 'tzuserrel' );
2020-10-31 14:32:18 +01:00
}
2022-05-19 10:31:01 +02:00
print ' <span class="hideonsmartphone"> - </span> ' ;
if ( GETPOST ( " afaire " ) == 1 ) {
print $form -> selectDate ( $datef ? $datef : $object -> datef , 'p2' , 1 , 1 , 1 , " action " , 1 , 0 , 0 , 'fulldayend' , '' , '' , '' , 1 , '' , '' , $object -> fulldayevent ? ( $tzforfullday ? $tzforfullday : 'tzuserrel' ) : 'tzuserrel' );
} elseif ( GETPOST ( " afaire " ) == 2 ) {
print $form -> selectDate ( $datef ? $datef : $object -> datef , 'p2' , 1 , 1 , 1 , " action " , 1 , 0 , 0 , 'fulldayend' , '' , '' , '' , 1 , '' , '' , $object -> fulldayevent ? ( $tzforfullday ? $tzforfullday : 'tzuserrel' ) : 'tzuserrel' );
} else {
print $form -> selectDate ( $datef ? $datef : $object -> datef , 'p2' , 1 , 1 , 1 , " action " , 1 , 0 , 0 , 'fulldayend' , '' , '' , '' , 1 , '' , '' , $object -> fulldayevent ? ( $tzforfullday ? $tzforfullday : 'tzuserrel' ) : 'tzuserrel' );
}
print '</td></tr>' ;
print '<tr><td class=""> </td><td></td></tr>' ;
2010-11-20 19:41:09 +01:00
2013-04-06 17:39:31 +02:00
// Assigned to
2020-10-31 14:32:18 +01:00
$listofuserid = array (); // User assigned
2021-02-23 18:59:19 +01:00
if ( empty ( $donotclearsession )) {
if ( $object -> userownerid > 0 ) {
2020-10-31 14:32:18 +01:00
$listofuserid [ $object -> userownerid ] = array (
'id' => $object -> userownerid ,
'type' => 'user' ,
//'transparency'=>$object->userassigned[$user->id]['transparency'],
'transparency' => $object -> transparency , // Force transparency on ownerfrom event
'answer_status' => $object -> userassigned [ $object -> userownerid ][ 'answer_status' ],
'mandatory' => $object -> userassigned [ $object -> userownerid ][ 'mandatory' ]
);
}
2021-02-23 18:59:19 +01:00
if ( ! empty ( $object -> userassigned )) { // Now concat assigned users
2020-10-31 14:32:18 +01:00
// Restore array with key with same value than param 'id'
$tmplist1 = $object -> userassigned ;
2021-02-23 18:59:19 +01:00
foreach ( $tmplist1 as $key => $val ) {
if ( $val [ 'id' ] && $val [ 'id' ] != $object -> userownerid ) {
2020-10-31 14:32:18 +01:00
$listofuserid [ $val [ 'id' ]] = $val ;
}
}
}
$_SESSION [ 'assignedtouser' ] = json_encode ( $listofuserid );
} else {
2021-02-23 18:59:19 +01:00
if ( ! empty ( $_SESSION [ 'assignedtouser' ])) {
2020-10-31 14:32:18 +01:00
$listofuserid = json_decode ( $_SESSION [ 'assignedtouser' ], true );
}
}
$listofcontactid = $object -> socpeopleassigned ; // Contact assigned
$listofotherid = $object -> otherassigned ; // Other undefined email (not used yet)
print '<tr><td class="tdtop nowrap fieldrequired">' . $langs -> trans ( " ActionAssignedTo " ) . '</td><td colspan="3">' ;
2015-11-22 12:33:56 +01:00
print '<div class="assignedtouser">' ;
2019-11-13 19:35:39 +01:00
print $form -> select_dolusers_forevent (( $action == 'create' ? 'add' : 'update' ), 'assignedtouser' , 1 , '' , 0 , '' , '' , 0 , 0 , 0 , 'AND u.statut != 0' , 1 , $listofuserid , $listofcontactid , $listofotherid );
2015-11-22 12:33:56 +01:00
print '</div>' ;
2017-11-22 14:42:47 +01:00
/* if ( in_array ( $user -> id , array_keys ( $listofuserid )))
2015-11-22 12:33:56 +01:00
{
print '<div class="myavailability">' ;
print $langs -> trans ( " MyAvailability " ) . ': <input id="transparency" type="checkbox" name="transparency"' . ( $listofuserid [ $user -> id ][ 'transparency' ] ? ' checked' : '' ) . '>' . $langs -> trans ( " Busy " );
print '</div>' ;
2017-11-22 14:42:47 +01:00
} */
2013-06-05 16:24:32 +02:00
print '</td></tr>' ;
2010-11-08 02:25:36 +01:00
// Realised by
2021-02-23 18:59:19 +01:00
if ( ! empty ( $conf -> global -> AGENDA_ENABLE_DONEBY )) {
2013-04-25 01:13:13 +02:00
print '<tr><td class="nowrap">' . $langs -> trans ( " ActionDoneBy " ) . '</td><td colspan="3">' ;
2019-11-13 19:35:39 +01:00
print $form -> select_dolusers ( $object -> userdoneid > 0 ? $object -> userdoneid : - 1 , 'doneby' , 1 );
2013-04-06 17:39:31 +02:00
print '</td></tr>' ;
}
2022-05-19 10:31:01 +02:00
// Location
if ( empty ( $conf -> global -> AGENDA_DISABLE_LOCATION )) {
print '<tr><td>' . $langs -> trans ( " Location " ) . '</td><td colspan="3"><input type="text" name="location" class="width500" value="' . $object -> location . '"></td></tr>' ;
}
// Status
print '<tr><td class="nowrap">' . $langs -> trans ( " Status " ) . ' / ' . $langs -> trans ( " Percentage " ) . '</td><td colspan="3">' ;
$percent = GETPOSTISSET ( " percentage " ) ? GETPOST ( " percentage " , " int " ) : $object -> percentage ;
$formactions -> form_select_status_action ( 'formaction' , $percent , 1 , 'complete' , 0 , 0 , 'maxwidth200' );
print '</td></tr>' ;
2019-11-13 21:18:34 +01:00
// Tags-Categories
2022-05-27 16:30:26 +02:00
if ( ! empty ( $conf -> categorie -> enabled )) {
2019-11-13 21:18:34 +01:00
print '<tr><td>' . $langs -> trans ( " Categories " ) . '</td><td colspan="3">' ;
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_ACTIONCOMM , '' , 'parent' , 64 , 0 , 1 );
$c = new Categorie ( $db );
$cats = $c -> containing ( $object -> id , Categorie :: TYPE_ACTIONCOMM );
$arrayselected = array ();
foreach ( $cats as $cat ) {
$arrayselected [] = $cat -> id ;
}
2020-12-03 14:34:15 +01:00
print img_picto ( '' , 'category' ) . $form -> multiselectarray ( 'categories' , $cate_arbo , $arrayselected , '' , 0 , 'quatrevingtpercent widthcentpercentminusx' , 0 , 0 );
2019-11-13 21:18:34 +01:00
print " </td></tr> " ;
}
2010-11-08 02:25:36 +01:00
2014-09-29 13:21:03 +02:00
print '</table>' ;
2017-06-07 16:44:04 +02:00
2017-11-22 14:42:47 +01:00
print '<br><hr><br>' ;
2010-11-08 02:25:36 +01:00
2017-06-07 16:44:04 +02:00
2020-09-14 20:53:42 +02:00
print '<table class="border tableforfield centpercent">' ;
2010-11-08 02:25:36 +01:00
2022-05-27 16:30:26 +02:00
if ( ! empty ( $conf -> societe -> enabled )) {
2017-11-22 14:42:47 +01:00
// Related company
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " ActionOnCompany " ) . '</td>' ;
2012-12-21 17:56:40 +01:00
print '<td>' ;
2016-04-03 19:04:03 +02:00
print '<div class="maxwidth200onsmartphone">' ;
2019-11-13 19:35:39 +01:00
$events = array (); // 'method'=parameter action of url, 'url'=url to call that return new list of contacts
$events [] = array ( 'method' => 'getContacts' , 'url' => dol_buildpath ( '/core/ajax/contacts.php?showempty=1' , 1 ), 'htmlname' => 'contactid' , 'params' => array ( 'add-customer-contact' => 'disabled' ));
2016-10-17 17:52:58 +02:00
// TODO Refresh also list of project if $conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY not defined with list linked to socid ?
// FIXME If we change company, we may get a project that does not match
2020-09-14 20:53:42 +02:00
print img_picto ( '' , 'company' , 'class="paddingrightonly"' ) . $form -> select_company ( $object -> socid , 'socid' , '' , 'SelectThirdParty' , 1 , 0 , $events , 0 , 'minwidth200' );
2016-04-03 19:04:03 +02:00
print '</div>' ;
print '</td></tr>' ;
2012-12-21 17:56:40 +01:00
2017-02-22 17:46:54 +01:00
// related contact
print '<tr><td>' . $langs -> trans ( " ActionOnContact " ) . '</td><td>' ;
2016-04-03 19:04:03 +02:00
print '<div class="maxwidth200onsmartphone">' ;
2020-09-14 20:53:42 +02:00
print img_picto ( '' , 'contact' , 'class="paddingrightonly"' ) . $form -> selectcontacts ( $object -> socid , array_keys ( $object -> socpeopleassigned ), 'socpeopleassigned[]' , 1 , '' , '' , 1 , 'quatrevingtpercent' , false , 0 , 0 , array (), 'multiple' , 'contactid' );
2016-04-03 19:04:03 +02:00
print '</div>' ;
print '</td>' ;
print '</tr>' ;
2012-12-21 17:56:40 +01:00
}
2005-10-01 16:25:34 +02:00
2010-01-05 00:33:23 +01:00
// Project
2022-06-14 17:53:17 +02:00
if ( ! empty ( $conf -> project -> enabled )) {
2016-04-03 19:04:03 +02:00
$langs -> load ( " projects " );
2010-01-05 00:33:23 +01:00
2016-10-17 17:52:58 +02:00
print '<tr><td class="titlefieldcreate">' . $langs -> trans ( " Project " ) . '</td><td>' ;
2020-09-14 20:53:42 +02:00
print img_picto ( '' , 'project' , 'class="paddingrightonly"' );
2020-02-10 13:34:09 +01:00
$numprojet = $formproject -> select_projects (( $object -> socid > 0 ? $object -> socid : - 1 ), $object -> fk_project , 'projectid' , 0 , 0 , 1 , 0 , 0 , 0 , 0 , '' , 0 , 0 , 'maxwidth500' );
2021-02-23 18:59:19 +01:00
if ( $numprojet == 0 ) {
2021-09-27 12:24:01 +02:00
print ' <a href="' . DOL_URL_ROOT . '/projet/card.php?socid=' . $object -> socid . '&action=create&token=' . newToken () . '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=edit' ) . '"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs -> trans ( " AddProject " ) . '"></span></a>' ;
2010-01-05 00:33:23 +01:00
}
print '</td></tr>' ;
}
2008-10-06 23:31:05 +02:00
// Priority
2020-10-31 14:32:18 +01:00
if ( ! empty ( $conf -> global -> AGENDA_SUPPORT_PRIORITY_IN_EVENTS )) {
2020-09-01 04:29:57 +02:00
print '<tr><td class="titlefieldcreate nowrap">' . $langs -> trans ( " Priority " ) . '</td><td>' ;
print '<input type="text" name="priority" value="' . ( $object -> priority ? $object -> priority : '' ) . '" size="5">' ;
print '</td></tr>' ;
}
2020-01-07 20:28:21 +01:00
2009-03-03 01:20:21 +01:00
// Object linked
2021-02-23 18:59:19 +01:00
if ( ! empty ( $object -> fk_element ) && ! empty ( $object -> elementtype )) {
2013-06-16 23:15:20 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
2020-10-31 14:32:18 +01:00
print '<tr>' ;
2018-08-24 09:29:17 +02:00
print '<td>' . $langs -> trans ( " LinkedObject " ) . '</td>' ;
2018-11-11 14:36:35 +01:00
2022-06-14 17:53:17 +02:00
if ( $object -> elementtype == 'task' && ! empty ( $conf -> project -> enabled )) {
2020-10-31 14:32:18 +01:00
print '<td id="project-task-input-container" >' ;
2018-11-11 14:36:35 +01:00
2020-02-18 11:18:00 +01:00
$urloption = '?action=create&donotclearsession=1' ; // we use create not edit for more flexibility
2020-10-31 14:32:18 +01:00
$url = DOL_URL_ROOT . '/comm/action/card.php' . $urloption ;
2018-11-11 14:36:35 +01:00
2020-10-31 14:32:18 +01:00
// update task list
print " \n " . '<script type="text/javascript" >' ;
print ' $ ( document ) . ready ( function () {
2018-09-20 10:08:40 +02:00
$ ( " #projectid " ) . change ( function () {
var url = " '. $url .'&projectid= " + $ ( " #projectid " ) . val ();
$ . get ( url , function ( data ) {
console . log ( $ ( data ) . find ( " #fk_element " ) . html ());
if ( data ) $ ( " #fk_element " ) . html ( $ ( data ) . find ( " #taskid " ) . html () ) . select2 ();
})
});
}) ' ;
2020-10-31 14:32:18 +01:00
print '</script>' . " \n " ;
2018-11-11 14:36:35 +01:00
2020-10-31 14:32:18 +01:00
$formproject -> selectTasks (( ! empty ( $societe -> id ) ? $societe -> id : - 1 ), $object -> fk_element , 'fk_element' , 24 , 0 , 0 , 1 , 0 , 0 , 'maxwidth500' , $object -> fk_project );
print '<input type="hidden" name="elementtype" value="' . $object -> elementtype . '">' ;
2018-11-11 14:36:35 +01:00
2020-10-31 14:32:18 +01:00
print '</td>' ;
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +01:00
print '<td>' ;
print dolGetElementUrl ( $object -> fk_element , $object -> elementtype , 1 );
print '<input type="hidden" name="fk_element" value="' . $object -> fk_element . '">' ;
print '<input type="hidden" name="elementtype" value="' . $object -> elementtype . '">' ;
print '</td>' ;
2018-09-20 10:08:40 +02:00
}
2018-11-11 14:36:35 +01:00
2018-08-24 09:29:17 +02:00
print '</tr>' ;
2009-03-03 01:20:21 +01:00
}
2005-10-01 16:25:34 +02:00
2020-10-31 14:32:18 +01:00
// Description
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' ;
// Editeur wysiwyg
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2022-05-19 10:31:01 +02:00
$doleditor = new DolEditor ( 'note' , $object -> note_private , '' , 120 , 'dolibarr_notes' , 'In' , true , true , $conf -> fckeditor -> enabled , ROWS_4 , '90%' );
2020-10-31 14:32:18 +01:00
$doleditor -> Create ();
print '</td></tr>' ;
// Other attributes
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2021-02-23 18:59:19 +01:00
if ( empty ( $reshook )) {
2019-11-16 14:38:05 +01:00
print $object -> showOptionals ( $extrafields , 'edit' , $parameters );
2012-12-08 12:49:20 +01:00
}
2012-12-21 17:56:40 +01:00
2013-04-01 19:43:26 +02:00
print '</table>' ;
2012-12-08 12:49:20 +01:00
2020-09-14 20:53:42 +02:00
// Reminders
2021-02-23 18:59:19 +01:00
if ( $conf -> global -> AGENDA_REMINDER_EMAIL || $conf -> global -> AGENDA_REMINDER_BROWSER ) {
2020-10-02 01:14:43 +02:00
$filteruserid = $user -> id ;
2021-02-23 18:59:19 +01:00
if ( $user -> rights -> agenda -> allactions -> read ) {
$filteruserid = 0 ;
}
2020-09-24 15:30:29 +02:00
$object -> loadReminders ( '' , $filteruserid , false );
2020-09-14 20:53:42 +02:00
2020-09-14 21:09:48 +02:00
print '<hr>' ;
2020-09-14 20:53:42 +02:00
2020-09-29 14:08:49 +02:00
if ( count ( $object -> reminders ) > 0 ) {
$checked = 'checked' ;
$keys = array_keys ( $object -> reminders );
$firstreminderId = array_shift ( $keys );
2020-09-14 20:53:42 +02:00
2020-09-29 14:08:49 +02:00
$actionCommReminder = $object -> reminders [ $firstreminderId ];
2020-10-02 01:14:43 +02:00
} else {
2020-09-29 14:08:49 +02:00
$checked = '' ;
$actionCommReminder = new ActionCommReminder ( $db );
$actionCommReminder -> offsetvalue = 10 ;
$actionCommReminder -> offsetunit = 'i' ;
$actionCommReminder -> typeremind = 'email' ;
}
2020-12-08 20:32:37 +01:00
print '<label for="addreminder">' . $langs -> trans ( " AddReminder " ) . '</label> <input type="checkbox" id="addreminder" name="addreminder" ' . $checked . '><br>' ;
2020-09-29 14:08:49 +02:00
print '<div class="reminderparameters" ' . ( empty ( $checked ) ? 'style="display: none;"' : '' ) . '>' ;
2020-12-08 20:32:37 +01:00
print '<br>' ;
2020-09-29 14:08:49 +02:00
print '<table class="border centpercent">' ;
2020-11-21 14:14:53 +01:00
// Reminder
2020-09-29 14:08:49 +02:00
print '<tr><td class="titlefieldcreate nowrap">' . $langs -> trans ( " ReminderTime " ) . '</td><td colspan="3">' ;
2020-12-11 02:23:43 +01:00
print '<input type="number" name="offsetvalue" class="width50" value="' . $actionCommReminder -> offsetvalue . '"> ' ;
print $form -> selectTypeDuration ( 'offsetunit' , $actionCommReminder -> offsetunit , array ( 'y' , 'm' ));
2020-09-29 14:08:49 +02:00
print '</td></tr>' ;
2020-09-14 20:53:42 +02:00
2020-11-21 14:14:53 +01:00
// Reminder Type
2020-09-29 14:08:49 +02:00
print '<tr><td class="titlefieldcreate nowrap">' . $langs -> trans ( " ReminderType " ) . '</td><td colspan="3">' ;
2020-12-08 20:32:37 +01:00
print $form -> selectarray ( 'selectremindertype' , $TRemindTypes , $actionCommReminder -> typeremind , 0 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'minwidth200' , 1 );
2020-09-29 14:08:49 +02:00
print '</td></tr>' ;
$hide = '' ;
2021-02-23 18:59:19 +01:00
if ( $actionCommReminder -> typeremind == 'browser' ) {
$hide = 'style="display:none;"' ;
}
2020-09-29 14:08:49 +02:00
2020-11-21 14:14:53 +01:00
// Mail Model
2020-09-29 14:08:49 +02:00
print '<tr ' . $hide . '><td class="titlefieldcreate nowrap">' . $langs -> trans ( " EMailTemplates " ) . '</td><td colspan="3">' ;
2020-12-08 20:32:37 +01:00
print $form -> selectModelMail ( 'actioncommsend' , 'actioncomm_send' , 1 , 1 );
2020-09-14 21:09:48 +02:00
print '</td></tr>' ;
2020-09-14 20:53:42 +02:00
2020-09-14 21:09:48 +02:00
print '</table>' ;
2020-09-29 14:08:49 +02:00
print " \n " . '<script type="text/javascript">' ;
print ' $ ( document ) . ready ( function () {
$ ( " #addreminder " ) . click ( function (){
if ( this . checked ) {
$ ( " .reminderparameters " ) . show ();
} else {
$ ( " .reminderparameters " ) . hide ();
}
});
$ ( " #selectremindertype " ) . change ( function (){
var selected_option = $ ( " #selectremindertype option:selected " ) . val ();
if ( selected_option == " email " ) {
$ ( " #select_actioncommsendmodel_mail " ) . closest ( " tr " ) . show ();
} else {
$ ( " #select_actioncommsendmodel_mail " ) . closest ( " tr " ) . hide ();
};
});
}) ' ;
print '</script>' . " \n " ;
2020-12-08 20:32:37 +01:00
print '</div>' ; // End of div for reminderparameters
2020-09-14 20:53:42 +02:00
}
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2013-04-25 01:13:13 +02:00
2021-08-20 14:41:30 +02:00
print $form -> buttonsSaveCancel ();
2005-07-10 04:05:09 +02:00
2010-02-25 22:28:17 +01:00
print '</form>' ;
2020-05-21 15:05:19 +02:00
} else {
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'card' , $langs -> trans ( " Action " ), - 1 , 'action' );
2013-04-25 01:13:13 +02:00
2015-06-08 12:39:25 +02:00
// Clone event
2021-02-23 18:59:19 +01:00
if ( $action == 'clone' ) {
2020-04-10 10:59:32 +02:00
$formconfirm = $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . GETPOST ( 'id' ), $langs -> trans ( 'ToClone' ), $langs -> trans ( 'ConfirmCloneEvent' , $object -> label ), 'confirm_clone' , $formquestion , 'yes' , 1 );
2015-06-30 01:34:17 +02:00
2015-06-08 12:39:25 +02:00
print $formconfirm ;
}
2020-04-10 10:59:32 +02:00
$linkback = '' ;
2016-09-19 10:43:30 +02:00
// Link to other agenda views
2022-01-02 12:49:15 +01:00
$linkback .= '<a href="' . DOL_URL_ROOT . '/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">' ;
2022-06-07 18:03:58 +02:00
$linkback .= img_picto ( $langs -> trans ( " BackToList " ), 'object_calendarlist' , 'class="pictoactionview pictofixedwidth"' );
2022-01-02 12:49:15 +01:00
$linkback .= '<span class="hideonsmartphone">' . $langs -> trans ( " BackToList " ) . '</span>' ;
$linkback .= '</a>' ;
2020-04-10 10:59:32 +02:00
$linkback .= '</li>' ;
$linkback .= '<li class="noborder litext">' ;
2022-01-02 12:49:15 +01:00
$linkback .= '<a href="' . DOL_URL_ROOT . '/comm/action/index.php?mode=show_month&year=' . dol_print_date ( $object -> datep , '%Y' ) . '&month=' . dol_print_date ( $object -> datep , '%m' ) . '&day=' . dol_print_date ( $object -> datep , '%d' ) . '">' ;
$linkback .= img_picto ( $langs -> trans ( " ViewCal " ), 'object_calendar' , 'class="pictoactionview pictofixedwidth"' );
$linkback .= '<span class="hideonsmartphone">' . $langs -> trans ( " ViewCal " ) . '</span>' ;
$linkback .= '</a>' ;
2020-04-10 10:59:32 +02:00
$linkback .= '</li>' ;
$linkback .= '<li class="noborder litext">' ;
2022-01-02 12:49:15 +01:00
$linkback .= '<a href="' . DOL_URL_ROOT . '/comm/action/index.php?mode=show_week&year=' . dol_print_date ( $object -> datep , '%Y' ) . '&month=' . dol_print_date ( $object -> datep , '%m' ) . '&day=' . dol_print_date ( $object -> datep , '%d' ) . '">' ;
$linkback .= img_picto ( $langs -> trans ( " ViewWeek " ), 'object_calendarweek' , 'class="pictoactionview pictofixedwidth"' );
$linkback .= '<span class="hideonsmartphone">' . $langs -> trans ( " ViewWeek " ) . '</span>' ;
$linkback .= '</a>' ;
2020-04-10 10:59:32 +02:00
$linkback .= '</li>' ;
$linkback .= '<li class="noborder litext">' ;
2022-01-02 12:49:15 +01:00
$linkback .= '<a href="' . DOL_URL_ROOT . '/comm/action/index.php?mode=show_day&year=' . dol_print_date ( $object -> datep , '%Y' ) . '&month=' . dol_print_date ( $object -> datep , '%m' ) . '&day=' . dol_print_date ( $object -> datep , '%d' ) . '">' ;
$linkback .= img_picto ( $langs -> trans ( " ViewDay " ), 'object_calendarday' , 'class="pictoactionview pictofixedwidth"' );
$linkback .= '<span class="hideonsmartphone">' . $langs -> trans ( " ViewDay " ) . '</span>' ;
$linkback .= '</a>' ;
2020-04-10 10:59:32 +02:00
$linkback .= '</li>' ;
$linkback .= '<li class="noborder litext">' ;
2022-01-02 12:49:15 +01:00
$linkback .= '<a href="' . DOL_URL_ROOT . '/comm/action/peruser.php?mode=show_peruser&year=' . dol_print_date ( $object -> datep , '%Y' ) . '&month=' . dol_print_date ( $object -> datep , '%m' ) . '&day=' . dol_print_date ( $object -> datep , '%d' ) . '">' ;
$linkback .= img_picto ( $langs -> trans ( " ViewPerUser " ), 'object_calendarperuser' , 'class="pictoactionview pictofixedwidth"' );
$linkback .= '<span class="hideonsmartphone">' . $langs -> trans ( " ViewPerUser " ) . '</span>' ;
$linkback .= '</a>' ;
2019-09-30 17:08:57 +02:00
//$linkback.=$out;
2017-06-07 16:44:04 +02:00
2020-04-10 10:59:32 +02:00
$morehtmlref = '<div class="refidno">' ;
2017-02-22 17:46:54 +01:00
// Thirdparty
//$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
2022-06-14 17:53:17 +02:00
if ( ! empty ( $conf -> project -> enabled )) {
2020-10-31 14:32:18 +01:00
$langs -> load ( " projects " );
//$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
$morehtmlref .= $langs -> trans ( 'Project' ) . ' ' ;
if ( $user -> rights -> agenda -> allactions -> create ||
2021-02-23 18:59:19 +01:00
(( $object -> authorid == $user -> id || $object -> userownerid == $user -> id ) && $user -> rights -> agenda -> myactions -> create )) {
2020-10-31 14:32:18 +01:00
if ( $action != 'classify' ) {
2021-09-18 22:09:55 +02:00
$morehtmlref .= '<a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=classify&token=' . newToken () . '&id=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'SetProject' )) . '</a> : ' ;
2020-10-31 14:32:18 +01:00
}
if ( $action == 'classify' ) {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '">' ;
$morehtmlref .= '<input type="hidden" name="action" value="classin">' ;
$morehtmlref .= '<input type="hidden" name="token" value="' . newToken () . '">' ;
$morehtmlref .= $formproject -> select_projects ( $object -> socid , $object -> fk_project , 'projectid' , $maxlength , 0 , 1 , 0 , 1 , 0 , 0 , '' , 1 );
2021-08-24 17:04:17 +02:00
$morehtmlref .= '<input type="submit" class="button button-save valignmiddle" value="' . $langs -> trans ( " Modify " ) . '">' ;
2020-10-31 14:32:18 +01:00
$morehtmlref .= '</form>' ;
} else {
$morehtmlref .= $form -> form_project ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> socid , $object -> fk_project , 'none' , 0 , 0 , 0 , 1 );
}
} else {
if ( ! empty ( $object -> fk_project )) {
$proj = new Project ( $db );
$proj -> fetch ( $object -> fk_project );
2021-10-29 09:40:38 +02:00
$morehtmlref .= ' : ' . $proj -> getNomUrl ( 1 );
2021-02-23 18:59:19 +01:00
if ( $proj -> title ) {
$morehtmlref .= ' - ' . $proj -> title ;
}
2020-10-31 14:32:18 +01:00
} else {
$morehtmlref .= '' ;
}
}
2017-02-22 17:46:54 +01:00
}
2020-04-10 10:59:32 +02:00
$morehtmlref .= '</div>' ;
2017-06-07 16:44:04 +02:00
2020-04-10 10:59:32 +02:00
dol_banner_tab ( $object , 'id' , $linkback , ( $user -> socid ? 0 : 1 ), 'id' , 'ref' , $morehtmlref );
2017-06-07 16:44:04 +02:00
2020-10-31 14:32:18 +01:00
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
2017-06-07 16:44:04 +02:00
2016-09-19 10:43:30 +02:00
print '<div class="underbanner clearboth"></div>' ;
2017-06-07 16:44:04 +02:00
2009-03-03 01:20:21 +01:00
// Affichage fiche action en mode visu
2019-03-05 12:18:36 +01:00
print '<table class="border tableforfield" width="100%">' ;
2006-09-10 15:53:20 +02:00
// Type
2022-10-14 09:54:47 +02:00
if ( ! empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ) && $object -> elementtype != 'ticket' ) {
2021-02-14 20:12:43 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Type " ) . '</td><td>' ;
print $object -> getTypePicto ();
2021-03-23 03:20:23 +01:00
print $langs -> trans ( " Action " . $object -> type_code );
print '</td></tr>' ;
2012-12-01 15:45:05 +01:00
}
2006-09-10 15:53:20 +02:00
2022-10-14 09:54:47 +02:00
// Private
2022-10-15 13:52:57 +02:00
if ( $object -> elementtype == 'ticket' ) print '<tr><td class="titlefield">' . $langs -> trans ( " PrivateEventMessage " ) . '</td><td>' . yn (( $object -> code == 'TICKET_MSG_PRIVATE' ) ? 1 : 0 , 3 ) . '</td></tr>' ;
2022-10-14 09:54:47 +02:00
2020-10-31 14:32:18 +01:00
// Full day event
2022-01-29 00:39:20 +01:00
print '<tr><td class="titlefield">' . $langs -> trans ( " EventOnFullDay " ) . '</td><td>' . yn ( $object -> fulldayevent ? 1 : 0 , 3 ) . '</td></tr>' ;
2010-11-18 23:17:44 +01:00
2019-11-13 19:35:39 +01:00
$rowspan = 4 ;
2021-02-23 18:59:19 +01:00
if ( empty ( $conf -> global -> AGENDA_DISABLE_LOCATION )) {
$rowspan ++ ;
}
2014-09-22 20:16:58 +02:00
2010-11-20 19:41:09 +01:00
// Date start
2020-09-14 20:53:42 +02:00
print '<tr><td>' . $langs -> trans ( " DateActionStart " ) . '</td><td>' ;
2022-03-20 16:33:35 +01:00
// Test a date before the 27 march and one after
//print dol_print_date($object->datep, 'dayhour', 'gmt');
//print dol_print_date($object->datep, 'dayhour', 'tzuser');
//print dol_print_date($object->datep, 'dayhour', 'tzuserrel');
2022-01-29 00:39:20 +01:00
if ( empty ( $object -> fulldayevent )) {
2022-03-20 16:33:35 +01:00
print dol_print_date ( $object -> datep , 'dayhour' , 'tzuserrel' );
2021-02-23 18:59:19 +01:00
} else {
2022-02-11 15:15:50 +01:00
$tzforfullday = getDolGlobalString ( 'MAIN_STORE_FULL_EVENT_IN_GMT' );
2022-03-20 16:33:35 +01:00
print dol_print_date ( $object -> datep , 'day' , ( $tzforfullday ? $tzforfullday : 'tzuserrel' ));
2021-02-23 18:59:19 +01:00
}
if ( $object -> percentage == 0 && $object -> datep && $object -> datep < ( $now - $delay_warning )) {
print img_warning ( $langs -> trans ( " Late " ));
}
2010-11-20 19:41:09 +01:00
print '</td>' ;
print '</tr>' ;
2010-11-08 02:25:36 +01:00
2010-11-20 19:41:09 +01:00
// Date end
2020-09-14 20:53:42 +02:00
print '<tr><td>' . $langs -> trans ( " DateActionEnd " ) . '</td><td>' ;
2022-01-29 00:39:20 +01:00
if ( empty ( $object -> fulldayevent )) {
2022-03-20 16:33:35 +01:00
print dol_print_date ( $object -> datef , 'dayhour' , 'tzuserrel' );
2021-02-23 18:59:19 +01:00
} else {
2022-02-11 15:15:50 +01:00
$tzforfullday = getDolGlobalString ( 'MAIN_STORE_FULL_EVENT_IN_GMT' );
2022-03-20 16:33:35 +01:00
print dol_print_date ( $object -> datef , 'day' , ( $tzforfullday ? $tzforfullday : 'tzuserrel' ));
2021-02-23 18:59:19 +01:00
}
if ( $object -> percentage > 0 && $object -> percentage < 100 && $object -> datef && $object -> datef < ( $now - $delay_warning )) {
print img_warning ( $langs -> trans ( " Late " ));
}
2010-11-08 02:25:36 +01:00
print '</td></tr>' ;
2020-10-31 14:32:18 +01:00
// Location
2021-02-23 18:59:19 +01:00
if ( empty ( $conf -> global -> AGENDA_DISABLE_LOCATION )) {
2020-09-14 20:53:42 +02:00
print '<tr><td>' . $langs -> trans ( " Location " ) . '</td><td>' . $object -> location . '</td></tr>' ;
2020-10-31 14:32:18 +01:00
}
2010-11-20 19:41:09 +01:00
2013-04-06 17:39:31 +02:00
// Assigned to
2020-10-31 14:32:18 +01:00
print '<tr><td class="nowrap">' . $langs -> trans ( " ActionAssignedTo " ) . '</td><td>' ;
2019-11-13 19:35:39 +01:00
$listofuserid = array ();
2021-02-23 18:59:19 +01:00
if ( empty ( $donotclearsession )) {
if ( $object -> userownerid > 0 ) {
2019-11-13 19:35:39 +01:00
$listofuserid [ $object -> userownerid ] = array (
2017-11-24 20:02:46 +01:00
'id' => $object -> userownerid ,
2019-11-13 19:35:39 +01:00
'transparency' => $object -> transparency , // Force transparency on onwer from preoperty of event
2017-11-24 20:02:46 +01:00
'answer_status' => $object -> userassigned [ $object -> userownerid ][ 'answer_status' ],
'mandatory' => $object -> userassigned [ $object -> userownerid ][ 'mandatory' ]
);
}
2021-02-23 18:59:19 +01:00
if ( ! empty ( $object -> userassigned )) { // Now concat assigned users
2014-09-29 13:21:03 +02:00
// Restore array with key with same value than param 'id'
2019-11-13 19:35:39 +01:00
$tmplist1 = $object -> userassigned ;
2021-02-23 18:59:19 +01:00
foreach ( $tmplist1 as $key => $val ) {
if ( $val [ 'id' ] && $val [ 'id' ] != $object -> userownerid ) {
$listofuserid [ $val [ 'id' ]] = $val ;
}
2014-09-29 13:21:03 +02:00
}
}
2019-11-13 19:35:39 +01:00
$_SESSION [ 'assignedtouser' ] = json_encode ( $listofuserid );
2020-05-21 15:05:19 +02:00
} else {
2021-02-23 18:59:19 +01:00
if ( ! empty ( $_SESSION [ 'assignedtouser' ])) {
2019-11-13 19:35:39 +01:00
$listofuserid = json_decode ( $_SESSION [ 'assignedtouser' ], true );
2014-10-05 03:44:20 +02:00
}
}
2017-11-24 20:02:46 +01:00
2019-11-13 19:35:39 +01:00
$listofcontactid = array (); // not used yet
$listofotherid = array (); // not used yet
2015-11-22 12:33:56 +01:00
print '<div class="assignedtouser">' ;
2019-11-13 19:35:39 +01:00
print $form -> select_dolusers_forevent ( 'view' , 'assignedtouser' , 1 , '' , 0 , '' , '' , 0 , 0 , 0 , '' , ( $object -> datep != $object -> datef ) ? 1 : 0 , $listofuserid , $listofcontactid , $listofotherid );
2015-11-22 12:33:56 +01:00
print '</div>' ;
2017-11-22 14:42:47 +01:00
/*
2017-06-07 16:44:04 +02:00
if ( $object -> datep != $object -> datef && in_array ( $user -> id , array_keys ( $listofuserid )))
2015-11-22 12:33:56 +01:00
{
print '<div class="myavailability">' ;
print $langs -> trans ( " MyAvailability " ) . ': ' . (( $object -> userassigned [ $user -> id ][ 'transparency' ] > 0 ) ? $langs -> trans ( " Busy " ) : $langs -> trans ( " Available " )); // We show nothing if event is assigned to nobody
print '</div>' ;
}
2017-11-22 14:42:47 +01:00
*/
2014-09-29 13:21:03 +02:00
print ' </td></tr>' ;
2010-11-08 02:25:36 +01:00
2010-11-20 00:50:27 +01:00
// Done by
2021-05-25 22:24:46 +02:00
if ( ! empty ( $conf -> global -> AGENDA_ENABLE_DONEBY )) {
2020-09-14 20:53:42 +02:00
print '<tr><td class="nowrap">' . $langs -> trans ( " ActionDoneBy " ) . '</td><td>' ;
2021-02-23 18:59:19 +01:00
if ( $object -> userdoneid > 0 ) {
2019-11-13 19:35:39 +01:00
$tmpuser = new User ( $db );
2014-10-11 15:04:42 +02:00
$tmpuser -> fetch ( $object -> userdoneid );
print $tmpuser -> getNomUrl ( 1 );
}
2013-04-06 17:39:31 +02:00
print '</td></tr>' ;
}
2020-08-23 02:38:56 +02:00
2019-11-13 21:18:34 +01:00
// Categories
2022-05-27 16:30:26 +02:00
if ( ! empty ( $conf -> categorie -> enabled )) {
2020-09-14 20:53:42 +02:00
print '<tr><td class="valignmiddle">' . $langs -> trans ( " Categories " ) . '</td><td>' ;
2019-11-14 08:07:16 +01:00
print $form -> showCategories ( $object -> id , Categorie :: TYPE_ACTIONCOMM , 1 );
2019-11-13 21:18:34 +01:00
print " </td></tr> " ;
}
2010-11-08 02:25:36 +01:00
2014-09-29 13:21:03 +02:00
print '</table>' ;
2020-09-14 20:53:42 +02:00
print '</div>' ;
print '<div class="fichehalfright">' ;
2014-09-29 13:21:03 +02:00
2017-03-31 14:21:51 +02:00
print '<div class="underbanner clearboth"></div>' ;
2019-03-05 12:18:36 +01:00
print '<table class="border tableforfield centpercent">' ;
2010-11-08 02:25:36 +01:00
2022-05-27 16:30:26 +02:00
if ( ! empty ( $conf -> societe -> enabled )) {
2020-10-31 14:32:18 +01:00
// Related company
print '<tr><td class="titlefield">' . $langs -> trans ( " ActionOnCompany " ) . '</td><td>' . ( $object -> thirdparty -> id ? $object -> thirdparty -> getNomUrl ( 1 ) : ( '<span class="opacitymedium">' . $langs -> trans ( " None " ) . '</span>' ));
2021-02-23 18:59:19 +01:00
if ( is_object ( $object -> thirdparty ) && $object -> thirdparty -> id > 0 && $object -> type_code == 'AC_TEL' ) {
if ( $object -> thirdparty -> fetch ( $object -> thirdparty -> id )) {
2014-09-24 01:35:29 +02:00
print " <br> " . dol_print_phone ( $object -> thirdparty -> phone );
2012-12-21 17:56:40 +01:00
}
2008-12-02 19:41:17 +01:00
}
2017-02-22 17:46:54 +01:00
print '</td></tr>' ;
2017-06-07 16:44:04 +02:00
2017-02-22 17:46:54 +01:00
// Related contact
print '<tr><td>' . $langs -> trans ( " ActionOnContact " ) . '</td>' ;
2020-09-14 20:53:42 +02:00
print '<td>' ;
2017-11-22 14:42:47 +01:00
2021-02-23 18:59:19 +01:00
if ( ! empty ( $object -> socpeopleassigned )) {
foreach ( $object -> socpeopleassigned as $cid => $Tab ) {
2017-06-06 17:43:22 +02:00
$contact = new Contact ( $db );
$result = $contact -> fetch ( $cid );
2017-11-22 14:42:47 +01:00
2021-02-23 18:59:19 +01:00
if ( $result < 0 ) {
dol_print_error ( $db , $contact -> error );
}
2017-11-22 14:42:47 +01:00
2021-02-23 18:59:19 +01:00
if ( $result > 0 ) {
2017-11-22 14:42:47 +01:00
print $contact -> getNomUrl ( 1 );
2021-02-23 18:59:19 +01:00
if ( $object -> type_code == 'AC_TEL' ) {
if ( ! empty ( $contact -> phone_pro )) {
print '(' . dol_print_phone ( $contact -> phone_pro ) . ')' ;
}
2017-06-06 17:43:22 +02:00
}
2017-11-22 14:42:47 +01:00
print '<div class="paddingright"></div>' ;
2012-12-21 17:56:40 +01:00
}
2008-12-02 19:41:17 +01:00
}
2020-05-21 15:05:19 +02:00
} else {
2017-11-22 14:42:47 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " None " ) . '</span>' ;
2012-12-21 17:56:40 +01:00
}
print '</td></tr>' ;
2009-03-03 01:20:21 +01:00
}
2017-06-07 16:44:04 +02:00
2008-10-06 23:31:05 +02:00
// Priority
2020-09-14 20:53:42 +02:00
print '<tr><td class="nowrap" class="titlefield">' . $langs -> trans ( " Priority " ) . '</td><td>' ;
2019-11-13 19:35:39 +01:00
print ( $object -> priority ? $object -> priority : '' );
2008-10-06 23:31:05 +02:00
print '</td></tr>' ;
2018-11-19 14:38:30 +01:00
// Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
// for such objects because there is already a dedicated field into table llx_actioncomm.
2021-02-23 18:59:19 +01:00
if ( ! empty ( $object -> fk_element ) && ! empty ( $object -> elementtype ) && ! in_array ( $object -> elementtype , array ( 'societe' , 'contact' , 'project' ))) {
2013-06-16 23:15:20 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
2009-03-03 01:20:21 +01:00
print '<tr><td>' . $langs -> trans ( " LinkedObject " ) . '</td>' ;
2019-11-13 19:35:39 +01:00
$link = dolGetElementUrl ( $object -> fk_element , $object -> elementtype , 1 );
2020-09-14 20:53:42 +02:00
print '<td>' ;
2021-02-23 18:59:19 +01:00
if ( empty ( $link )) {
print '<span class="opacitymedium">' . $langs -> trans ( " ObjectDeleted " ) . '</span>' ;
} else {
print $link ;
}
2017-05-19 17:24:15 +02:00
print '</td></tr>' ;
2009-03-03 01:20:21 +01:00
}
2005-10-01 16:25:34 +02:00
2010-11-20 19:41:09 +01:00
// Description
2020-09-14 20:53:42 +02:00
print '<tr><td class="tdtop">' . $langs -> trans ( " Description " ) . '</td><td class="wordbreak">' ;
2020-02-09 18:28:34 +01:00
print dol_string_onlythesehtmltags ( dol_htmlentitiesbr ( $object -> note_private ));
2009-03-03 01:20:21 +01:00
print '</td></tr>' ;
2005-10-01 16:25:34 +02:00
2020-10-31 14:32:18 +01:00
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
// Reminders
2021-05-25 22:24:46 +02:00
if ( ! empty ( $conf -> global -> AGENDA_REMINDER_EMAIL ) || ! empty ( $conf -> global -> AGENDA_REMINDER_BROWSER )) {
$filteruserid = $user -> id ;
2021-02-23 18:59:19 +01:00
if ( $user -> rights -> agenda -> allactions -> read ) {
2021-05-25 22:24:46 +02:00
$filteruserid = 0 ;
2021-02-23 18:59:19 +01:00
}
2020-10-31 14:32:18 +01:00
$object -> loadReminders ( '' , $filteruserid , false );
print '<tr><td class="titlefieldcreate nowrap">' . $langs -> trans ( " Reminders " ) . '</td><td>' ;
if ( count ( $object -> reminders ) > 0 ) {
$tmpuserstatic = new User ( $db );
foreach ( $object -> reminders as $actioncommreminderid => $actioncommreminder ) {
2023-01-09 15:50:55 +01:00
print $TRemindTypes [ $actioncommreminder -> typeremind ][ 'label' ];
2020-10-31 14:32:18 +01:00
if ( $actioncommreminder -> fk_user > 0 ) {
$tmpuserstatic -> fetch ( $actioncommreminder -> fk_user );
print ' (' . $tmpuserstatic -> getNomUrl ( 0 , '' , 0 , 0 , 16 ) . ')' ;
}
print ' - ' . $actioncommreminder -> offsetvalue . ' ' . $TDurationTypes [ $actioncommreminder -> offsetunit ];
if ( $actioncommreminder -> status == $actioncommreminder :: STATUS_TODO ) {
print ' - <span class="opacitymedium">' ;
print $langs -> trans ( " NotSent " );
print ' </span>' ;
} elseif ( $actioncommreminder -> status == $actioncommreminder :: STATUS_DONE ) {
print ' - <span class="opacitymedium">' ;
print $langs -> trans ( " Done " );
print ' </span>' ;
}
print '<br>' ;
}
}
print '</td></tr>' ;
}
2020-09-14 20:53:42 +02:00
2009-03-03 01:20:21 +01:00
print '</table>' ;
2012-12-21 17:56:40 +01:00
2017-03-31 14:21:51 +02:00
print '</div>' ;
2020-09-14 20:53:42 +02:00
print '</div>' ;
print '<div class="clearboth"></div>' ;
2017-06-07 16:44:04 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2013-04-21 17:56:29 +02:00
}
2004-03-02 11:57:44 +01:00
2004-10-02 16:24:43 +02:00
2009-11-10 13:36:30 +01:00
/*
2021-03-16 04:22:55 +01:00
* Action bar
2009-03-03 01:20:21 +01:00
*/
print '<div class="tabsAction">' ;
2005-10-01 16:25:34 +02:00
2019-11-13 19:35:39 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2021-02-23 18:59:19 +01:00
if ( empty ( $reshook )) {
if ( $action != 'edit' ) {
2014-01-24 11:15:25 +01:00
if ( $user -> rights -> agenda -> allactions -> create ||
2021-02-23 18:59:19 +01:00
(( $object -> authorid == $user -> id || $object -> userownerid == $user -> id ) && $user -> rights -> agenda -> myactions -> create )) {
2021-09-27 12:24:01 +02:00
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token=' . newToken () . '&id=' . $object -> id . '">' . $langs -> trans ( " Modify " ) . '</a></div>' ;
2020-05-21 15:05:19 +02:00
} else {
2018-11-13 21:40:17 +01:00
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " NotAllowed " ) . '">' . $langs -> trans ( " Modify " ) . '</a></div>' ;
2014-01-24 11:15:25 +01:00
}
2015-06-30 01:34:17 +02:00
2015-06-08 12:39:25 +02:00
if ( $user -> rights -> agenda -> allactions -> create ||
2021-02-23 18:59:19 +01:00
(( $object -> authorid == $user -> id || $object -> userownerid == $user -> id ) && $user -> rights -> agenda -> myactions -> create )) {
2015-06-08 12:39:25 +02:00
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=clone&object=' . $object -> element . '&id=' . $object -> id . '">' . $langs -> trans ( " ToClone " ) . '</a></div>' ;
2020-05-21 15:05:19 +02:00
} else {
2018-11-13 21:40:17 +01:00
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " NotAllowed " ) . '">' . $langs -> trans ( " ToClone " ) . '</a></div>' ;
2015-06-08 12:39:25 +02:00
}
2015-06-30 01:34:17 +02:00
2014-01-24 11:15:25 +01:00
if ( $user -> rights -> agenda -> allactions -> delete ||
2021-02-23 18:59:19 +01:00
(( $object -> authorid == $user -> id || $object -> userownerid == $user -> id ) && $user -> rights -> agenda -> myactions -> delete )) {
2020-10-01 10:50:54 +02:00
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token=' . newToken () . '&id=' . $object -> id . '">' . $langs -> trans ( " Delete " ) . '</a></div>' ;
2020-05-21 15:05:19 +02:00
} else {
2018-11-13 21:40:17 +01:00
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . $langs -> trans ( " NotAllowed " ) . '">' . $langs -> trans ( " Delete " ) . '</a></div>' ;
2014-01-24 11:15:25 +01:00
}
2009-03-03 01:20:21 +01:00
}
}
2014-01-30 00:40:00 +01:00
2009-03-03 01:20:21 +01:00
print '</div>' ;
2014-09-29 13:21:03 +02:00
2021-02-23 18:59:19 +01:00
if ( $action != 'edit' ) {
if ( empty ( $conf -> global -> AGENDA_DISABLE_BUILDDOC )) {
2017-05-05 20:41:44 +02:00
print '<div style="clear:both;"></div><div class="fichecenter"><div class="fichehalfleft">' ;
2020-10-31 14:32:18 +01:00
print '<a name="builddoc"></a>' ; // ancre
2014-12-01 00:52:38 +01:00
2020-10-31 14:32:18 +01:00
/*
2021-03-16 04:04:18 +01:00
* Generated documents
2021-02-23 18:59:19 +01:00
*/
2014-12-01 00:52:38 +01:00
2020-10-31 14:32:18 +01:00
$filedir = $conf -> agenda -> multidir_output [ $conf -> entity ] . '/' . $object -> id ;
$urlsource = $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id ;
2014-12-01 00:52:38 +01:00
2020-10-31 14:32:18 +01:00
$genallowed = $user -> rights -> agenda -> myactions -> read ;
$delallowed = $user -> rights -> agenda -> myactions -> create ;
2014-12-01 00:52:38 +01:00
2021-10-22 23:38:35 +02:00
print $formfile -> showdocuments ( 'actions' , $object -> id , $filedir , $urlsource , $genallowed , $delallowed , '' , 0 , 0 , 0 , 0 , 0 , '' , '' , '' , $langs -> getDefaultLang ());
2014-12-01 00:52:38 +01:00
2021-10-23 17:18:35 +02:00
print '</div><div class="fichehalfright">' ;
2014-12-01 00:52:38 +01:00
2021-10-23 17:18:35 +02:00
print '</div></div>' ;
2020-10-31 14:32:18 +01:00
}
2014-10-09 17:05:57 +02:00
}
2002-04-29 20:01:16 +02:00
}
2018-07-29 13:40:35 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2013-04-03 18:37:54 +02:00
$db -> close ();