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 >
2013-04-21 17:56:29 +02:00
* Copyright ( C ) 2004 - 2013 Laurent Destailleur < eldy @ users . sourceforge . net >
2005-09-06 09:11:19 +02:00
* Copyright ( C ) 2005 Simon TOSSER < simon @ kornog - computing . com >
2012-12-30 15:11:07 +01:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2014-02-26 16:50:38 +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 >
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
2011-08-01 00:21:57 +02:00
* along with this program . If not , see < http :// 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
/**
2008-10-06 23:31:05 +02:00
* \file htdocs / comm / action / fiche . php
* \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' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
2013-06-14 22:33:01 +02:00
if ( ! empty ( $conf -> projet -> enabled )) {
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
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' ;
2004-10-30 04:01:06 +02:00
$langs -> load ( " companies " );
$langs -> load ( " commercial " );
$langs -> load ( " other " );
2005-04-24 04:11:50 +02:00
$langs -> load ( " bills " );
2006-06-10 18:48:54 +02:00
$langs -> load ( " orders " );
2008-04-15 10:34:36 +02:00
$langs -> load ( " agenda " );
2002-05-09 16:57:48 +02:00
2012-02-27 17:02:56 +01:00
$action = GETPOST ( 'action' , 'alpha' );
2012-07-13 11:40:06 +02:00
$cancel = GETPOST ( 'cancel' , 'alpha' );
2012-02-27 17:02:56 +01:00
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
2012-07-13 11:40:06 +02:00
$contactid = GETPOST ( 'contactid' , 'int' );
2013-08-27 15:51:06 +02:00
$origin = GETPOST ( 'origin' , 'alpha' );
$originid = GETPOST ( 'originid' , 'int' );
2009-08-28 03:14:35 +02:00
2008-04-16 03:04:12 +02:00
// Security check
2012-02-27 17:02:56 +01:00
$socid = GETPOST ( 'socid' , 'int' );
$id = GETPOST ( 'id' , 'int' );
2009-04-29 08:22:37 +02:00
if ( $user -> societe_id ) $socid = $user -> societe_id ;
2013-09-23 19:53:55 +02:00
$result = restrictedArea ( $user , 'agenda' , $id , 'actioncomm&societe' , 'myactions&allactions' , 'fk_soc' , 'id' );
2013-09-18 11:56:42 +02:00
if ( $user -> societe_id && $socid ) $result = restrictedArea ( $user , 'societe' , $socid );
2009-04-29 08:22:37 +02:00
2012-02-13 01:43:35 +01:00
$error = GETPOST ( " error " );
2012-07-13 11:40:06 +02:00
$mesg = '' ;
2005-07-08 00:47:02 +02:00
2008-04-15 10:34:36 +02:00
$cactioncomm = new CActionComm ( $db );
$actioncomm = new ActionComm ( $db );
$contact = new Contact ( $db );
2012-12-08 12:49:20 +01:00
$extrafields = new ExtraFields ( $db );
2013-04-01 19:43:26 +02:00
// fetch optionals attributes and labels
2013-04-26 10:29:14 +02:00
$extralabels = $extrafields -> fetch_name_optionals_label ( $actioncomm -> table_element );
2013-04-01 19:43:26 +02:00
2011-04-09 13:52:11 +02:00
//var_dump($_POST);
2009-08-28 03:14:35 +02:00
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
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager -> initHooks ( array ( 'actioncard' ));
2011-08-24 14:19:32 +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
*/
2013-09-25 21:26:06 +02:00
// Add action
2011-04-09 13:52:11 +02:00
if ( $action == 'add_action' )
2002-12-19 19:59:23 +01:00
{
2011-11-07 17:31:03 +01:00
$error = 0 ;
2012-01-04 21:23:50 +01:00
2012-02-27 17:02:56 +01:00
if ( empty ( $backtopage ))
2010-12-13 18:06:04 +01:00
{
2011-03-27 03:20:10 +02:00
if ( $socid > 0 ) $backtopage = DOL_URL_ROOT . '/societe/agenda.php?socid=' . $socid ;
2010-12-13 18:06:04 +01:00
else $backtopage = DOL_URL_ROOT . '/comm/action/index.php' ;
}
2012-07-13 11:40:06 +02:00
if ( $contactid )
2009-03-03 01:20:21 +01:00
{
2012-07-13 11:40:06 +02:00
$result = $contact -> fetch ( $contactid );
2009-03-03 01:20:21 +01:00
}
2009-02-04 21:43:18 +01:00
2012-07-13 11:40:06 +02:00
if ( $cancel )
2008-01-26 14:18:47 +01:00
{
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
}
2012-08-20 11:04:56 +02:00
$fulldayevent = GETPOST ( 'fullday' );
2012-09-07 17:23:16 +02:00
$percentage = in_array ( GETPOST ( 'status' ), array ( - 1 , 100 )) ? GETPOST ( 'status' ) : GETPOST ( " percentage " ); // If status is -1 or 100, percentage is not defined and we must use status
2010-11-18 23:17:44 +01:00
// Clean parameters
2012-01-04 21:23:50 +01:00
$datep = dol_mktime ( $fulldayevent ? '00' : $_POST [ " aphour " ], $fulldayevent ? '00' : $_POST [ " apmin " ], 0 , $_POST [ " apmonth " ], $_POST [ " apday " ], $_POST [ " apyear " ]);
$datef = dol_mktime ( $fulldayevent ? '23' : $_POST [ " p2hour " ], $fulldayevent ? '59' : $_POST [ " p2min " ], $fulldayevent ? '59' : '0' , $_POST [ " p2month " ], $_POST [ " p2day " ], $_POST [ " p2year " ]);
2010-01-05 00:33:23 +01:00
2010-02-21 15:06:41 +01:00
// Check parameters
2012-09-02 14:26:40 +02:00
if ( ! $datef && $percentage == 100 )
2008-10-06 23:31:05 +02:00
{
2011-11-07 17:31:03 +01:00
$error ++ ;
2011-04-09 13:52:11 +02:00
$action = 'create' ;
2014-03-01 10:16:03 +01:00
$mesg = '<div class="error">' . $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " DateEnd " )) . '</div>' ;
2008-10-06 23:31:05 +02:00
}
2009-02-04 21:43:18 +01:00
2012-12-01 15:45:05 +01:00
if ( empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ) && ! GETPOST ( 'label' ))
{
$error ++ ;
$action = 'create' ;
2014-03-01 10:16:03 +01:00
$mesg = '<div class="error">' . $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Title " )) . '</div>' ;
2012-12-01 15:45:05 +01:00
}
2008-04-15 10:34:36 +02:00
// Initialisation objet cactioncomm
2012-08-20 11:04:56 +02:00
if ( ! GETPOST ( 'actioncode' ))
2009-03-03 01:20:21 +01:00
{
2011-11-07 17:31:03 +01:00
$error ++ ;
2011-04-09 13:52:11 +02:00
$action = 'create' ;
2014-03-01 10:16:03 +01:00
$mesg = '<div class="error">' . $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Type " )) . '</div>' ;
2009-03-03 01:20:21 +01:00
}
2009-02-04 21:43:18 +01:00
else
2008-04-15 10:34:36 +02:00
{
2012-08-20 11:04:56 +02:00
$result = $cactioncomm -> fetch ( GETPOST ( 'actioncode' ));
2008-04-15 10:34:36 +02:00
}
2009-02-04 21:43:18 +01:00
2008-04-15 10:34:36 +02:00
// Initialisation objet actioncomm
$actioncomm -> type_id = $cactioncomm -> id ;
$actioncomm -> type_code = $cactioncomm -> code ;
2012-12-01 15:45:05 +01:00
$actioncomm -> priority = GETPOST ( " priority " ) ? GETPOST ( " priority " ) : 0 ;
2012-08-20 11:04:56 +02:00
$actioncomm -> fulldayevent = ( ! empty ( $fulldayevent ) ? 1 : 0 );
2012-12-01 15:45:05 +01:00
$actioncomm -> location = GETPOST ( " location " );
2013-04-06 17:39:31 +02:00
$actioncomm -> transparency = ( GETPOST ( " transparency " ) == 'on' ? 1 : 0 );
2012-12-01 15:45:05 +01:00
$actioncomm -> label = trim ( GETPOST ( 'label' ));
2013-08-27 15:51:06 +02:00
$actioncomm -> fk_element = GETPOST ( " fk_element " );
$actioncomm -> elementtype = GETPOST ( " elementtype " );
2012-12-01 15:45:05 +01:00
if ( ! GETPOST ( 'label' ))
2008-04-15 10:34:36 +02:00
{
2012-12-01 15:45:05 +01:00
if ( GETPOST ( 'actioncode' ) == 'AC_RDV' && $contact -> getFullName ( $langs ))
2008-04-15 10:34:36 +02:00
{
2009-08-11 14:51:33 +02:00
$actioncomm -> label = $langs -> transnoentitiesnoconv ( " TaskRDVWith " , $contact -> getFullName ( $langs ));
2008-04-15 10:34:36 +02:00
}
else
{
if ( $langs -> trans ( " Action " . $actioncomm -> type_code ) != " Action " . $actioncomm -> type_code )
{
2009-08-11 14:51:33 +02:00
$actioncomm -> label = $langs -> transnoentitiesnoconv ( " Action " . $actioncomm -> type_code ) . " \n " ;
2008-04-15 10:34:36 +02:00
}
2008-04-15 18:44:21 +02:00
else $actioncomm -> label = $cactioncomm -> libelle ;
2008-04-15 10:34:36 +02:00
}
}
2010-01-05 00:33:23 +01:00
$actioncomm -> fk_project = isset ( $_POST [ " projectid " ]) ? $_POST [ " projectid " ] : 0 ;
2008-04-15 10:34:36 +02:00
$actioncomm -> datep = $datep ;
2011-07-18 10:59:42 +02:00
$actioncomm -> datef = $datef ;
2012-09-02 14:26:40 +02:00
$actioncomm -> percentage = $percentage ;
2014-02-06 16:57:45 +01:00
$actioncomm -> duree = (( float ) ( GETPOST ( 'dureehour' ) * 60 ) + ( float ) GETPOST ( 'dureemin' )) * 60 ;
2006-09-16 02:14:11 +02:00
2010-05-02 20:02:43 +02:00
$usertodo = new User ( $db );
2008-07-28 23:20:23 +02:00
if ( $_POST [ " affectedto " ] > 0 )
2008-04-15 10:34:36 +02:00
{
2010-05-02 20:02:43 +02:00
$usertodo -> fetch ( $_POST [ " affectedto " ]);
2008-04-15 10:34:36 +02:00
}
$actioncomm -> usertodo = $usertodo ;
2010-05-02 20:02:43 +02:00
$userdone = new User ( $db );
2008-07-28 23:20:23 +02:00
if ( $_POST [ " doneby " ] > 0 )
2008-04-15 10:34:36 +02:00
{
2010-05-02 20:02:43 +02:00
$userdone -> fetch ( $_POST [ " doneby " ]);
2008-04-15 10:34:36 +02:00
}
$actioncomm -> userdone = $userdone ;
2009-02-04 21:43:18 +01:00
2008-04-15 10:34:36 +02:00
$actioncomm -> note = trim ( $_POST [ " note " ]);
if ( isset ( $_POST [ " contactid " ])) $actioncomm -> contact = $contact ;
2012-02-27 22:26:22 +01:00
if ( GETPOST ( 'socid' , 'int' ) > 0 )
2008-04-15 10:34:36 +02:00
{
$societe = new Societe ( $db );
2012-02-27 22:26:22 +01:00
$societe -> fetch ( GETPOST ( 'socid' , 'int' ));
2008-04-15 10:34:36 +02:00
$actioncomm -> societe = $societe ;
}
2008-05-07 02:50:24 +02:00
// Special for module webcal and phenix
2013-12-15 14:26:27 +01:00
// TODO external modules
2012-08-20 11:04:56 +02:00
if ( ! empty ( $conf -> webcalendar -> enabled ) && GETPOST ( 'add_webcal' ) == 'on' ) $actioncomm -> use_webcal = 1 ;
if ( ! empty ( $conf -> phenix -> enabled ) && GETPOST ( 'add_phenix' ) == 'on' ) $actioncomm -> use_phenix = 1 ;
2008-04-15 10:34:36 +02:00
2008-09-09 19:57:12 +02:00
// Check parameters
2013-02-12 15:01:16 +01:00
if ( $actioncomm -> type_code == 'AC_RDV' && ( $datep == '' || ( $datef == '' && empty ( $fulldayevent ))))
2008-09-09 19:57:12 +02:00
{
2011-11-07 17:31:03 +01:00
$error ++ ;
2011-04-09 13:52:11 +02:00
$action = 'create' ;
2009-08-11 14:51:33 +02:00
$mesg = '<div class="error">' . $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " DateEnd " )) . '</div>' ;
2008-09-09 19:57:12 +02:00
}
2012-08-20 11:04:56 +02:00
if ( ! empty ( $datea ) && GETPOST ( 'percentage' ) == 0 )
2006-09-16 02:14:11 +02:00
{
2011-11-07 17:31:03 +01:00
$error ++ ;
2011-04-09 13:52:11 +02:00
$action = 'create' ;
2009-03-03 01:20:21 +01:00
$mesg = '<div class="error">' . $langs -> trans ( " ErrorStatusCantBeZeroIfStarted " ) . '</div>' ;
2006-09-16 02:14:11 +02:00
}
2009-02-04 21:43:18 +01:00
2012-08-20 11:04:56 +02:00
if ( ! GETPOST ( 'apyear' ) && ! GETPOST ( 'adyear' ))
2009-03-03 01:20:21 +01:00
{
2011-11-07 17:31:03 +01:00
$error ++ ;
2011-04-09 13:52:11 +02:00
$action = 'create' ;
2009-08-11 14:51:33 +02:00
$mesg = '<div class="error">' . $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentitiesnoconv ( " Date " )) . '</div>' ;
2009-03-03 01:20:21 +01:00
}
2013-04-01 19:43:26 +02:00
// Fill array 'array_options' with data from add form
$ret = $extrafields -> setOptionalsFromPost ( $extralabels , $actioncomm );
2012-12-08 12:49:20 +01:00
2009-03-03 01:20:21 +01:00
if ( ! $error )
{
$db -> begin ();
// On cree l'action
$idaction = $actioncomm -> add ( $user );
if ( $idaction > 0 )
{
if ( ! $actioncomm -> error )
{
$db -> commit ();
2010-12-13 18:06:04 +01:00
if ( ! empty ( $backtopage ))
2009-03-03 01:20:21 +01:00
{
2010-12-13 18:06:04 +01:00
dol_syslog ( " Back to " . $backtopage );
2012-08-31 05:58:38 +02:00
header ( " Location: " . $backtopage );
2009-03-03 01:20:21 +01:00
}
elseif ( $idaction )
{
2012-08-31 05:58:38 +02:00
header ( " Location: " . DOL_URL_ROOT . '/comm/action/fiche.php?id=' . $idaction );
2009-03-03 01:20:21 +01:00
}
else
{
2012-08-31 05:58:38 +02:00
header ( " Location: " . DOL_URL_ROOT . '/comm/action/index.php' );
2009-03-03 01:20:21 +01:00
}
exit ;
}
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 " );
2009-03-03 01:20:21 +01:00
$error = $langs -> trans ( $actioncomm -> error );
2013-05-17 14:45:54 +02:00
setEventMessage ( $error , 'errors' );
2012-12-30 13:49:37 +01:00
$action = 'create' ;
2009-03-03 01:20:21 +01:00
}
}
else
{
$db -> rollback ();
2009-01-07 14:40:07 +01:00
$langs -> load ( " errors " );
2014-02-14 13:05:04 +01:00
if ( ! empty ( $actioncomm -> error )) setEventMessage ( $langs -> trans ( $actioncomm -> error ), 'errors' );
if ( count ( $actioncomm -> errors )) setEventMessage ( $actioncomm -> errors , 'errors' );
2012-12-30 13:49:37 +01:00
$action = 'create' ;
2009-03-03 01:20:21 +01:00
}
}
2002-04-29 20:01:16 +02:00
}
2002-05-09 16:57:48 +02:00
2004-10-02 16:24:43 +02:00
/*
* Action suppression de l ' action
*/
2011-04-09 13:52:11 +02:00
if ( $action == 'confirm_delete' && GETPOST ( " confirm " ) == 'yes' )
2003-08-03 14:18:29 +02:00
{
2009-03-03 01:20:21 +01:00
$actioncomm = new ActionComm ( $db );
2010-09-12 22:59:38 +02:00
$actioncomm -> fetch ( $id );
2006-09-16 02:14:11 +02:00
2009-11-13 05:10:59 +01:00
if ( $user -> rights -> agenda -> myactions -> delete
|| $user -> rights -> agenda -> allactions -> delete )
2009-03-03 01:20:21 +01:00
{
2009-07-22 22:41:50 +02:00
$result = $actioncomm -> delete ();
if ( $result >= 0 )
{
2012-08-31 05:58:38 +02:00
header ( " Location: index.php " );
2009-07-22 22:41:50 +02:00
exit ;
}
else
{
$mesg = $actioncomm -> error ;
2013-05-17 14:45:54 +02:00
setEventMessage ( $mesg , 'errors' );
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
*/
2011-04-09 13:52:11 +02:00
if ( $action == 'update' )
2003-08-03 19:26:19 +02:00
{
2012-08-20 11:04:56 +02:00
if ( empty ( $cancel ))
2009-03-03 01:20:21 +01:00
{
2012-08-20 11:04:56 +02:00
$fulldayevent = GETPOST ( 'fullday' );
$aphour = GETPOST ( 'aphour' );
$apmin = GETPOST ( 'apmin' );
$p2hour = GETPOST ( 'p2hour' );
$p2min = GETPOST ( 'p2min' );
2012-09-02 14:10:51 +02:00
$percentage = in_array ( GETPOST ( 'status' ), array ( - 1 , 100 )) ? GETPOST ( 'status' ) : GETPOST ( " percentage " ); // If status is -1 or 100, percentage is not defined and we must use status
2010-11-18 23:17:44 +01:00
// Clean parameters
2012-08-20 11:04:56 +02: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
2009-03-03 01:20:21 +01:00
$actioncomm = new Actioncomm ( $db );
2010-09-12 23:07:45 +02:00
$actioncomm -> fetch ( $id );
2006-09-10 15:46:25 +02:00
2012-08-20 11:04:56 +02:00
$datep = dol_mktime ( $fulldayevent ? '00' : $aphour , $fulldayevent ? '00' : $apmin , 0 , $_POST [ " apmonth " ], $_POST [ " apday " ], $_POST [ " apyear " ]);
$datef = dol_mktime ( $fulldayevent ? '23' : $p2hour , $fulldayevent ? '59' : $p2min , $fulldayevent ? '59' : '0' , $_POST [ " p2month " ], $_POST [ " p2day " ], $_POST [ " p2year " ]);
2011-08-24 14:19:32 +02:00
2013-02-27 19:43:40 +01:00
$actioncomm -> fk_action = dol_getIdFromCode ( $db , $_POST [ " actioncode " ], 'c_actioncomm' );
2009-03-03 01:20:21 +01:00
$actioncomm -> label = $_POST [ " label " ];
2008-07-28 23:20:23 +02:00
$actioncomm -> datep = $datep ;
2011-07-18 10:59:42 +02:00
$actioncomm -> datef = $datef ;
2012-09-02 14:10:51 +02:00
$actioncomm -> percentage = $percentage ;
2009-03-03 01:20:21 +01:00
$actioncomm -> priority = $_POST [ " priority " ];
2010-11-18 23:17:44 +01:00
$actioncomm -> fulldayevent = $_POST [ " fullday " ] ? 1 : 0 ;
2013-04-06 17:39:31 +02:00
$actioncomm -> location = GETPOST ( 'location' );
2009-03-03 01:20:21 +01:00
$actioncomm -> societe -> id = $_POST [ " socid " ];
$actioncomm -> contact -> id = $_POST [ " contactid " ];
2010-01-05 00:33:23 +01:00
$actioncomm -> fk_project = $_POST [ " projectid " ];
2009-03-03 01:20:21 +01:00
$actioncomm -> note = $_POST [ " note " ];
2010-01-05 00:33:23 +01:00
$actioncomm -> pnote = $_POST [ " note " ];
2013-08-27 15:51:06 +02:00
$actioncomm -> fk_element = $_POST [ " fk_element " ];
$actioncomm -> elementtype = $_POST [ " elementtype " ];
2012-09-02 14:10:51 +02:00
if ( ! $datef && $percentage == 100 )
2009-03-03 01:20:21 +01:00
{
$error = $langs -> trans ( " ErrorFieldRequired " , $langs -> trans ( " DateEnd " ));
2011-04-09 13:52:11 +02:00
$action = 'edit' ;
2009-03-03 01:20:21 +01:00
}
2008-02-11 16:51:03 +01:00
// Users
2010-05-02 20:02:43 +02:00
$usertodo = new User ( $db );
2009-03-03 01:20:21 +01:00
if ( $_POST [ " affectedto " ])
2008-02-11 16:51:03 +01:00
{
2010-05-02 20:02:43 +02:00
$usertodo -> fetch ( $_POST [ " affectedto " ]);
2008-02-11 16:51:03 +01:00
}
$actioncomm -> usertodo = $usertodo ;
2013-04-06 17:39:31 +02:00
$actioncomm -> transparency = ( GETPOST ( " transparency " ) == 'on' ? 1 : 0 );
2010-05-02 20:02:43 +02:00
$userdone = new User ( $db );
2009-03-03 01:20:21 +01:00
if ( $_POST [ " doneby " ])
2008-02-11 16:51:03 +01:00
{
2010-05-02 20:02:43 +02:00
$userdone -> fetch ( $_POST [ " doneby " ]);
2008-02-11 16:51:03 +01:00
}
$actioncomm -> userdone = $userdone ;
2013-04-01 19:43:26 +02:00
// Fill array 'array_options' with data from add form
$ret = $extrafields -> setOptionalsFromPost ( $extralabels , $actioncomm );
2012-12-21 17:56:40 +01:00
2008-04-16 03:04:12 +02:00
if ( ! $error )
{
$db -> begin ();
2009-01-04 23:19:25 +01:00
2008-04-16 03:04:12 +02:00
$result = $actioncomm -> update ( $user );
2009-02-04 21:43:18 +01:00
2008-04-16 03:04:12 +02:00
if ( $result > 0 )
{
$db -> commit ();
}
else
{
$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
2009-03-03 01:20:21 +01:00
if ( $result < 0 )
{
2012-10-17 18:47:18 +02:00
setEventMessage ( $actioncomm -> error , 'errors' );
setEventMessage ( $actioncomm -> errors , 'errors' );
2009-03-03 01:20:21 +01:00
}
else
{
2012-02-27 17:02:56 +01:00
if ( ! empty ( $backtopage ))
2010-12-13 18:06:04 +01:00
{
2012-02-27 17:02:56 +01:00
header ( " Location: " . $backtopage );
2010-12-13 18:06:04 +01:00
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
2011-04-09 13:52:11 +02:00
2008-10-06 23:31:05 +02:00
/*
* View
*/
2009-08-24 19:11:30 +02:00
$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda' ;
llxHeader ( '' , $langs -> trans ( " Agenda " ), $help_url );
2004-08-07 01:39:54 +02:00
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2008-10-25 19:27:15 +02:00
$htmlactions = new FormActions ( $db );
2004-08-07 01:39:54 +02:00
2011-04-09 13:52:11 +02:00
if ( $action == 'create' )
2003-08-03 19:26:19 +02:00
{
2009-03-07 02:19:28 +01:00
$contact = new Contact ( $db );
2010-09-12 22:59:38 +02:00
if ( GETPOST ( " contactid " ))
2006-09-05 01:55:19 +02:00
{
2010-08-29 20:23:56 +02:00
$result = $contact -> fetch ( GETPOST ( " contactid " ));
2009-03-07 02:19:28 +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
2012-07-13 11:40:06 +02:00
if ( ! empty ( $conf -> use_javascript_ajax ))
2010-08-29 20:23:56 +02:00
{
2012-11-13 16:20:15 +01:00
print " \n " . '<script type="text/javascript">' ;
print ' $ ( document ) . ready ( function () {
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 {
$ ( " .fulldaystarthour " ) . attr ( " disabled " , " disabled " ) . val ( " 00 " );
$ ( " .fulldaystartmin " ) . attr ( " disabled " , " disabled " ) . val ( " 00 " );
$ ( " .fulldayendhour " ) . attr ( " disabled " , " disabled " ) . val ( " 23 " );
$ ( " .fulldayendmin " ) . attr ( " disabled " , " disabled " ) . val ( " 59 " );
2013-04-04 19:57:16 +02:00
$ ( " #p2 " ) . removeAttr ( " disabled " );
2012-11-13 16:20:15 +01:00
}
}
2010-11-18 23:17:44 +01:00
setdatefields ();
2012-11-13 16:20:15 +01:00
$ ( " #fullday " ) . change ( function () {
2010-11-18 23:17:44 +01:00
setdatefields ();
2010-08-29 20:23:56 +02:00
});
2012-11-13 16:20:15 +01:00
$ ( " #selectcomplete " ) . change ( function () {
if ( $ ( " #selectcomplete " ) . val () == 100 )
2011-03-19 20:06:15 +01:00
{
2012-11-13 16:20:15 +01:00
if ( $ ( " #doneby " ) . val () <= 0 ) $ ( " #doneby " ) . val ( \ '' . $user -> id . ' \ ' );
2011-03-19 20:06:15 +01:00
}
2012-11-13 16:20:15 +01:00
if ( $ ( " #selectcomplete " ) . val () == 0 )
2011-03-19 20:06:15 +01:00
{
2012-11-13 16:20:15 +01:00
$ ( " #doneby " ) . val ( - 1 );
2011-03-19 20:06:15 +01:00
}
});
2012-11-13 16:20:15 +01:00
$ ( " #actioncode " ) . change ( function () {
if ( $ ( " #actioncode " ) . val () == \ ' AC_RDV\ ' ) $ ( " #dateend " ) . addClass ( " fieldrequired " );
else $ ( " #dateend " ) . removeClass ( " fieldrequired " );
2011-04-09 13:52:11 +02:00
});
2010-08-29 20:23:56 +02:00
}) ' ;
print '</script>' . " \n " ;
}
2012-11-13 16:20:15 +01:00
print '<form name="formaction" action="' . $_SERVER [ 'PHP_SELF' ] . '" method="POST">' ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2006-09-05 01:55:19 +02:00
print '<input type="hidden" name="action" value="add_action">' ;
2012-05-12 15:53:57 +02:00
if ( $backtopage ) print '<input type="hidden" name="backtopage" value="' . ( $backtopage != '1' ? $backtopage : $_SERVER [ " HTTP_REFERER " ]) . '">' ;
2002-05-09 16:57:48 +02:00
2012-01-08 00:15:36 +01:00
if ( GETPOST ( " actioncode " ) == 'AC_RDV' ) print_fiche_titre ( $langs -> trans ( " AddActionRendezVous " ));
else print_fiche_titre ( $langs -> trans ( " AddAnAction " ));
2004-08-07 01:39:54 +02:00
2011-07-18 03:44:15 +02:00
dol_htmloutput_mesg ( $mesg );
2009-02-04 21:43:18 +01:00
2008-04-16 03:04:12 +02:00
print '<table class="border" width="100%">' ;
2009-02-04 21:43:18 +01:00
2008-04-16 03:04:12 +02:00
// Type d'action actifs
2012-12-01 15:45:05 +01:00
if ( ! empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ))
2008-04-16 03:04:12 +02:00
{
2012-12-01 15:45:05 +01:00
print '<tr><td width="30%"><span class="fieldrequired">' . $langs -> trans ( " Type " ) . '</span></b></td><td>' ;
2013-02-27 19:43:40 +01:00
$htmlactions -> select_type_actions ( GETPOST ( " actioncode " ) ? GETPOST ( " actioncode " ) : $actioncomm -> type_code , " actioncode " , " systemauto " );
2012-12-01 15:45:05 +01:00
print '</td></tr>' ;
2008-04-16 03:04:12 +02:00
}
2012-12-01 15:45:05 +01:00
else print '<input type="hidden" name="actioncode" value="AC_OTH">' ;
2005-02-09 22:15:28 +01:00
2008-09-09 19:57:12 +02:00
// Title
2013-02-19 13:24:32 +01:00
print '<tr><td' . ( empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ) ? ' class="fieldrequired"' : '' ) . '>' . $langs -> trans ( " Title " ) . '</td><td><input type="text" id="label" name="label" size="60" value="' . GETPOST ( 'label' ) . '"></td></tr>' ;
2009-02-04 21:43:18 +01:00
2010-11-18 23:17:44 +01:00
// Full day
2012-08-20 14:14:01 +02:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " EventOnFullDay " ) . '</td><td><input type="checkbox" id="fullday" name="fullday" ' . ( GETPOST ( 'fullday' ) ? ' checked="checked"' : '' ) . '></td></tr>' ;
2013-12-15 14:26:27 +01:00
2010-11-08 02:25:36 +01:00
// Date start
2010-11-21 17:11:52 +01:00
$datep = $actioncomm -> datep ;
if ( GETPOST ( 'datep' , 'int' , 1 )) $datep = dol_stringtotime ( GETPOST ( 'datep' , 'int' , 1 ), 0 );
2013-04-25 01:13:13 +02:00
print '<tr><td width="30%" class="nowrap"><span class="fieldrequired">' . $langs -> trans ( " DateActionStart " ) . '</span></td><td>' ;
2011-11-08 10:18:45 +01:00
if ( GETPOST ( " afaire " ) == 1 ) $form -> select_date ( $datep , 'ap' , 1 , 1 , 0 , " action " , 1 , 1 , 0 , 0 , 'fulldayend' );
else if ( GETPOST ( " afaire " ) == 2 ) $form -> select_date ( $datep , 'ap' , 1 , 1 , 1 , " action " , 1 , 1 , 0 , 0 , 'fulldayend' );
else $form -> select_date ( $datep , 'ap' , 1 , 1 , 1 , " action " , 1 , 1 , 0 , 0 , 'fulldaystart' );
2010-11-08 02:25:36 +01:00
print '</td></tr>' ;
// Date end
2010-11-21 17:11:52 +01:00
$datef = $actioncomm -> datef ;
if ( GETPOST ( 'datef' , 'int' , 1 )) $datef = dol_stringtotime ( GETPOST ( 'datef' , 'int' , 1 ), 0 );
2011-04-09 13:52:11 +02:00
print '<tr><td><span id="dateend"' . ( GETPOST ( " actioncode " ) == 'AC_RDV' ? ' class="fieldrequired"' : '' ) . '>' . $langs -> trans ( " DateActionEnd " ) . '</span></td><td>' ;
2011-11-08 10:18:45 +01:00
if ( GETPOST ( " afaire " ) == 1 ) $form -> select_date ( $datef , 'p2' , 1 , 1 , 1 , " action " , 1 , 1 , 0 , 0 , 'fulldayend' );
else if ( GETPOST ( " afaire " ) == 2 ) $form -> select_date ( $datef , 'p2' , 1 , 1 , 1 , " action " , 1 , 1 , 0 , 0 , 'fulldayend' );
else $form -> select_date ( $datef , 'p2' , 1 , 1 , 1 , " action " , 1 , 1 , 0 , 0 , 'fulldayend' );
2010-11-08 02:25:36 +01:00
print '</td></tr>' ;
2010-11-20 19:41:09 +01:00
// Status
2010-11-08 02:25:36 +01:00
print '<tr><td width="10%">' . $langs -> trans ( " Status " ) . ' / ' . $langs -> trans ( " Percentage " ) . '</td>' ;
print '<td>' ;
2011-03-19 20:06:15 +01:00
$percent =- 1 ;
2013-06-08 01:33:16 +02:00
if ( isset ( $_GET [ 'status' ]) || isset ( $_POST [ 'status' ]))
{
$percent = GETPOST ( 'status' );
}
else if ( isset ( $_GET [ 'percentage' ]) || isset ( $_POST [ 'percentage' ]))
2010-11-08 02:25:36 +01:00
{
$percent = GETPOST ( 'percentage' );
}
else
{
if ( GETPOST ( " afaire " ) == 1 ) $percent = 0 ;
2012-08-20 10:38:48 +02:00
else if ( GETPOST ( " afaire " ) == 2 ) $percent = 100 ;
2010-11-08 02:25:36 +01:00
}
2013-11-07 21:02:21 +01:00
$htmlactions -> form_select_status_action ( 'formaction' , $percent , 1 , 'complete' );
2010-11-08 02:25:36 +01:00
print '</td></tr>' ;
2010-11-20 19:41:09 +01:00
// Location
2012-07-13 11:40:06 +02:00
print '<tr><td>' . $langs -> trans ( " Location " ) . '</td><td colspan="3"><input type="text" name="location" size="50" value="' . $actioncomm -> location . '"></td></tr>' ;
2010-11-20 19:41:09 +01:00
2010-11-08 02:25:36 +01:00
print '</table>' ;
2010-11-20 19:41:09 +01:00
2012-02-13 02:24:17 +01:00
print '<br><br>' ;
2010-11-20 19:41:09 +01:00
2010-11-08 02:25:36 +01:00
print '<table class="border" width="100%">' ;
2013-04-06 17:39:31 +02:00
// Assigned to
2012-02-13 02:13:17 +01:00
$var = false ;
2013-04-25 01:13:13 +02:00
print '<tr><td width="30%" class="nowrap">' . $langs -> trans ( " ActionAffectedTo " ) . '</td><td>' ;
2012-07-13 11:40:06 +02:00
$form -> select_users ( GETPOST ( " affectedto " ) ? GETPOST ( " affectedto " ) : ( ! empty ( $actioncomm -> usertodo -> id ) && $actioncomm -> usertodo -> id > 0 ? $actioncomm -> usertodo -> id : $user -> id ), 'affectedto' , 1 );
2010-11-08 02:25:36 +01:00
print '</td></tr>' ;
2013-04-06 17:39:31 +02:00
// Busy
2013-04-25 01:13:13 +02:00
print '<tr><td width="30%" class="nowrap">' . $langs -> trans ( " Busy " ) . '</td><td>' ;
2014-03-25 13:05:29 +01:00
print '<input id="transparency" type="checkbox" name="transparency"' . ( $actioncomm -> transparency ? ' checked="checked"' : '' ) . '>' ;
2013-06-05 16:24:32 +02:00
print '</td></tr>' ;
2013-04-06 17:39:31 +02:00
2010-11-08 02:25:36 +01:00
// Realised by
2013-04-06 17:39:31 +02:00
if ( $conf -> global -> AGENDA_ENABLE_DONEBY )
{
2013-07-19 14:23:42 +02:00
print '<tr><td class="nowrap">' . $langs -> trans ( " ActionDoneBy " ) . '</td><td>' ;
2013-04-06 17:39:31 +02:00
$form -> select_users ( GETPOST ( " doneby " ) ? GETPOST ( " doneby " ) : ( ! empty ( $actioncomm -> userdone -> id ) && $percent == 100 ? $actioncomm -> userdone -> id : 0 ), 'doneby' , 1 );
print '</td></tr>' ;
}
2010-11-08 02:25:36 +01:00
print '</table>' ;
2012-02-13 02:24:17 +01:00
print '<br><br>' ;
2010-11-08 02:25:36 +01:00
print '<table class="border" width="100%">' ;
2009-02-04 21:43:18 +01:00
2008-04-16 03:04:12 +02:00
// Societe, contact
2013-04-25 01:13:13 +02:00
print '<tr><td width="30%" class="nowrap">' . $langs -> trans ( " ActionOnCompany " ) . '</td><td>' ;
2012-02-27 22:26:22 +01:00
if ( GETPOST ( 'socid' , 'int' ) > 0 )
2008-04-16 03:04:12 +02:00
{
$societe = new Societe ( $db );
2012-02-27 22:26:22 +01:00
$societe -> fetch ( GETPOST ( 'socid' , 'int' ));
2008-04-16 03:04:12 +02:00
print $societe -> getNomUrl ( 1 );
2012-02-27 22:26:22 +01:00
print '<input type="hidden" name="socid" value="' . GETPOST ( 'socid' , 'int' ) . '">' ;
2008-04-16 03:04:12 +02:00
}
else
{
2013-12-15 14:26:27 +01:00
2013-10-01 18:11:53 +02:00
$events = array ();
$events [] = array ( 'method' => 'getContacts' , 'url' => dol_buildpath ( '/core/ajax/contacts.php' , 1 ), 'htmlname' => 'contactid' , 'params' => array ( 'add-customer-contact' => 'disabled' ));
2013-01-09 20:34:36 +01:00
//For external user force the company to user company
if ( ! empty ( $user -> societe_id )) {
2013-10-01 18:11:53 +02:00
print $form -> select_company ( $user -> societe_id , 'socid' , '' , 1 , 1 , 0 , $events );
2013-01-09 20:34:36 +01:00
} else {
2013-10-01 18:11:53 +02:00
print $form -> select_company ( '' , 'socid' , '' , 1 , 1 , 0 , $events );
2013-01-09 20:34:36 +01:00
}
2013-02-12 15:01:16 +01:00
2008-04-16 03:04:12 +02:00
}
print '</td></tr>' ;
2006-09-16 02:14:11 +02:00
2013-10-01 18:11:53 +02:00
print '<tr><td class="nowrap">' . $langs -> trans ( " ActionOnContact " ) . '</td><td>' ;
$form -> select_contacts ( GETPOST ( 'socid' , 'int' ), GETPOST ( 'contactid' ), 'contactid' , 1 );
print '</td></tr>' ;
2013-12-15 14:26:27 +01:00
2006-09-05 01:55:19 +02:00
2010-01-05 00:33:23 +01:00
// Project
2012-07-13 11:40:06 +02:00
if ( ! empty ( $conf -> projet -> enabled ))
2010-01-05 00:33:23 +01:00
{
2013-06-14 22:33:01 +02:00
$formproject = new FormProjets ( $db );
2013-06-16 23:15:20 +02:00
2010-01-05 00:33:23 +01:00
// Projet associe
2014-01-26 18:43:30 +01:00
$langs -> load ( " projects " );
2010-01-05 00:33:23 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " Project " ) . '</td><td>' ;
2013-06-16 23:15:20 +02:00
2013-06-14 22:33:01 +02:00
$numproject = $formproject -> select_projects (( ! empty ( $societe -> id ) ? $societe -> id : 0 ), GETPOST ( " projectid " ) ? GETPOST ( " projectid " ) : '' , 'projectid' );
2010-03-11 15:31:16 +01:00
if ( $numproject == 0 )
2010-01-05 00:33:23 +01:00
{
2013-03-22 17:10:17 +01:00
print ' <a href="' . DOL_URL_ROOT . '/projet/fiche.php?socid=' . $societe -> id . '&action=create">' . $langs -> trans ( " AddProject " ) . '</a>' ;
2010-01-05 00:33:23 +01:00
}
print '</td></tr>' ;
}
2013-08-27 15:51:06 +02:00
if ( ! empty ( $origin ) && ! empty ( $originid ))
{
print '<input type="hidden" name="fk_element" size="10" value="' . GETPOST ( 'originid' ) . '">' ;
print '<input type="hidden" name="elementtype" size="10" value="' . GETPOST ( 'origin' ) . '">' ;
}
2010-01-05 00:33:23 +01:00
2010-08-29 20:23:56 +02: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 ))
2008-04-16 03:04:12 +02:00
{
2009-02-20 23:53:15 +01:00
$actioncomm -> 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
2013-07-19 14:23:42 +02:00
print '<tr><td class="nowrap">' . $langs -> trans ( " Priority " ) . '</td><td colspan="3">' ;
2012-07-13 11:40:06 +02:00
print '<input type="text" name="priority" value="' . ( GETPOST ( 'priority' ) ? GETPOST ( 'priority' ) : ( $actioncomm -> priority ? $actioncomm -> priority : '' )) . '" size="5">' ;
2008-10-06 23:31:05 +02:00
print '</td></tr>' ;
2004-10-02 16:24:43 +02:00
2010-11-20 19:41:09 +01:00
// Description
print '<tr><td valign="top">' . $langs -> trans ( " Description " ) . '</td><td>' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2013-04-21 11:59:15 +02:00
$doleditor = new DolEditor ( 'note' ,( GETPOST ( 'note' ) ? GETPOST ( 'note' ) : $actioncomm -> note ), '' , 240 , 'dolibarr_notes' , 'In' , true , true , $conf -> fckeditor -> enabled , ROWS_7 , 90 );
2010-11-20 19:41:09 +01:00
$doleditor -> Create ();
print '</td></tr>' ;
2013-12-15 14:26:27 +01:00
2005-09-07 00:37:37 +02:00
2012-12-08 12:49:20 +01:00
// Other attributes
2014-01-22 03:20:18 +01:00
$parameters = array ( 'id' => $actioncomm -> id );
2012-12-08 12:49:20 +01:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $actioncomm , $action ); // Note that $action and $object may have been modified by hook
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
2010-02-25 22:28:17 +01:00
2012-12-08 12:49:20 +01:00
if ( empty ( $reshook ) && ! empty ( $extrafields -> attribute_label ))
{
2013-04-01 19:43:26 +02:00
print $actioncomm -> showOptionals ( $extrafields , 'edit' );
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
2010-02-25 22:28:17 +01:00
print '<center><br>' ;
2008-04-16 03:04:12 +02:00
print '<input type="submit" class="button" value="' . $langs -> trans ( " Add " ) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2010-02-25 22:28:17 +01:00
print '</center>' ;
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
2012-12-30 13:49:37 +01:00
if ( $id > 0 )
2002-12-19 19:59:23 +01:00
{
2009-03-03 01:20:21 +01:00
if ( $error )
{
2011-12-14 09:28:08 +01:00
dol_htmloutput_errors ( $error );
2009-03-03 01:20:21 +01:00
}
if ( $mesg )
{
2011-12-14 09:28:08 +01:00
dol_htmloutput_mesg ( $mesg );
2009-03-03 01:20:21 +01:00
}
$act = new ActionComm ( $db );
2010-09-12 22:59:38 +02:00
$result = $act -> fetch ( $id );
2012-12-08 12:49:20 +01:00
$act -> fetch_optionals ( $id , $extralabels );
2012-12-21 17:56:40 +01:00
2010-05-07 21:33:17 +02:00
if ( $result < 0 )
{
dol_print_error ( $db , $act -> error );
exit ;
}
2009-02-04 21:43:18 +01:00
2008-04-27 17:51:01 +02:00
$societe = new Societe ( $db );
if ( $act -> societe -> id )
{
$result = $societe -> fetch ( $act -> societe -> id );
}
$act -> societe = $societe ;
2010-04-28 09:31:34 +02:00
if ( $act -> author -> id > 0 ) { $tmpuser = new User ( $db ); $res = $tmpuser -> fetch ( $act -> author -> id ); $act -> author = $tmpuser ; }
if ( $act -> usermod -> id > 0 ) { $tmpuser = new User ( $db ); $res = $tmpuser -> fetch ( $act -> usermod -> id ); $act -> usermod = $tmpuser ; }
if ( $act -> usertodo -> id > 0 ) { $tmpuser = new User ( $db ); $res = $tmpuser -> fetch ( $act -> usertodo -> id ); $act -> usertodo = $tmpuser ; }
if ( $act -> userdone -> id > 0 ) { $tmpuser = new User ( $db ); $res = $tmpuser -> fetch ( $act -> userdone -> id ); $act -> userdone = $tmpuser ; }
2008-02-11 16:51:03 +01:00
2008-04-27 17:51:01 +02:00
$contact = new Contact ( $db );
if ( $act -> contact -> id )
{
$result = $contact -> fetch ( $act -> contact -> id , $user );
}
2009-03-03 01:20:21 +01:00
$act -> contact = $contact ;
2004-10-02 16:24:43 +02:00
2009-03-03 01:20:21 +01:00
/*
* Affichage onglets
*/
2004-10-02 16:24:43 +02:00
2010-09-12 23:07:45 +02:00
$head = actions_prepare_head ( $act );
2004-10-02 16:24:43 +02:00
2010-06-09 20:25:20 +02:00
$now = dol_now ();
2009-01-07 16:21:16 +01:00
$delay_warning = $conf -> global -> MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60 ;
2009-02-04 21:43:18 +01:00
2009-03-03 01:20:21 +01:00
// Confirmation suppression action
2011-04-09 13:52:11 +02:00
if ( $action == 'delete' )
2009-03-03 01:20:21 +01:00
{
2013-09-06 11:51:24 +02:00
print $form -> formconfirm ( " fiche.php?id= " . $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
2011-04-09 13:52:11 +02:00
if ( $action == 'edit' )
2009-03-03 01:20:21 +01:00
{
2012-11-13 16:20:15 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ))
2010-11-18 23:17:44 +01:00
{
2012-11-13 16:20:15 +01:00
print " \n " . '<script type="text/javascript">' ;
print ' $ ( document ) . ready ( function () {
function setdatefields ()
{
if ( $ ( " #fullday:checked " ) . val () == null ) {
$ ( " .fulldaystarthour " ) . removeAttr ( " disabled " );
$ ( " .fulldaystartmin " ) . removeAttr ( " disabled " );
$ ( " .fulldayendhour " ) . removeAttr ( " disabled " );
$ ( " .fulldayendmin " ) . removeAttr ( " disabled " );
} else {
$ ( " .fulldaystarthour " ) . attr ( " disabled " , " disabled " ) . val ( " 00 " );
$ ( " .fulldaystartmin " ) . attr ( " disabled " , " disabled " ) . val ( " 00 " );
$ ( " .fulldayendhour " ) . attr ( " disabled " , " disabled " ) . val ( " 23 " );
$ ( " .fulldayendmin " ) . attr ( " disabled " , " disabled " ) . val ( " 59 " );
}
}
setdatefields ();
$ ( " #fullday " ) . change ( function () {
setdatefields ();
});
2010-11-18 23:17:44 +01:00
}) ' ;
print '</script>' . " \n " ;
}
// Fiche action en mode edition
2012-11-13 16:20:15 +01:00
print '<form name="formaction" action="' . $_SERVER [ 'PHP_SELF' ] . '" method="POST">' ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ '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 . '">' ;
2011-11-01 15:05:42 +01:00
print '<input type="hidden" name="ref_ext" value="' . $act -> ref_ext . '">' ;
2012-05-12 15:53:57 +02:00
if ( $backtopage ) print '<input type="hidden" name="backtopage" value="' . ( $backtopage != '1' ? $backtopage : $_SERVER [ " HTTP_REFERER " ]) . '">' ;
2004-08-07 01:39:54 +02:00
2013-04-21 17:56:29 +02:00
dol_fiche_head ( $head , 'card' , $langs -> trans ( " Action " ), 0 , 'action' );
2013-04-25 01:13:13 +02:00
2009-03-03 01:20:21 +01:00
print '<table class="border" width="100%">' ;
2008-09-09 19:57:12 +02:00
2009-03-03 01:20:21 +01:00
// Ref
print '<tr><td width="30%">' . $langs -> trans ( " Ref " ) . '</td><td colspan="3">' . $act -> id . '</td></tr>' ;
2009-02-04 21:43:18 +01:00
2009-03-03 01:20:21 +01:00
// Type
2012-12-01 15:45:05 +01:00
if ( ! empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ))
{
2013-02-27 19:43:40 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Type " ) . '</td><td colspan="3">' ;
$htmlactions -> select_type_actions ( GETPOST ( " actioncode " ) ? GETPOST ( " actioncode " ) : $act -> type_code , " actioncode " , " systemauto " );
print '</td></tr>' ;
2012-12-01 15:45:05 +01:00
}
2009-02-04 21:43:18 +01:00
2009-03-03 01:20:21 +01:00
// Title
2012-12-01 15:45:05 +01:00
print '<tr><td' . ( empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ) ? ' class="fieldrequired"' : '' ) . '>' . $langs -> trans ( " Title " ) . '</td><td colspan="3"><input type="text" name="label" size="50" value="' . $act -> label . '"></td></tr>' ;
2009-02-04 21:43:18 +01:00
2010-11-18 23:17:44 +01:00
// Full day event
2012-08-20 14:14:01 +02:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " EventOnFullDay " ) . '</td><td colspan="3"><input type="checkbox" id="fullday" name="fullday" ' . ( $act -> fulldayevent ? ' checked="checked"' : '' ) . '></td></tr>' ;
2010-11-18 23:17:44 +01:00
2010-11-08 02:25:36 +01:00
// Date start
2013-04-25 01:13:13 +02:00
print '<tr><td class="nowrap"><span class="fieldrequired">' . $langs -> trans ( " DateActionStart " ) . '</span></td><td colspan="3">' ;
2011-11-08 10:18:45 +01:00
if ( GETPOST ( " afaire " ) == 1 ) $form -> select_date ( $act -> datep , 'ap' , 1 , 1 , 0 , " action " , 1 , 1 , 0 , 0 , 'fulldaystart' );
else if ( GETPOST ( " afaire " ) == 2 ) $form -> select_date ( $act -> datep , 'ap' , 1 , 1 , 1 , " action " , 1 , 1 , 0 , 0 , 'fulldaystart' );
else $form -> select_date ( $act -> datep , 'ap' , 1 , 1 , 1 , " action " , 1 , 1 , 0 , 0 , 'fulldaystart' );
2010-11-08 02:25:36 +01:00
print '</td></tr>' ;
// Date end
print '<tr><td>' . $langs -> trans ( " DateActionEnd " ) . '</td><td colspan="3">' ;
2011-11-08 10:18:45 +01:00
if ( GETPOST ( " afaire " ) == 1 ) $form -> select_date ( $act -> datef , 'p2' , 1 , 1 , 1 , " action " , 1 , 1 , 0 , 0 , 'fulldayend' );
else if ( GETPOST ( " afaire " ) == 2 ) $form -> select_date ( $act -> datef , 'p2' , 1 , 1 , 1 , " action " , 1 , 1 , 0 , 0 , 'fulldayend' );
else $form -> select_date ( $act -> datef , 'p2' , 1 , 1 , 1 , " action " , 1 , 1 , 0 , 0 , 'fulldayend' );
2010-11-08 02:25:36 +01:00
print '</td></tr>' ;
// Status
2013-04-25 01:13:13 +02:00
print '<tr><td class="nowrap">' . $langs -> trans ( " Status " ) . ' / ' . $langs -> trans ( " Percentage " ) . '</td><td colspan="3">' ;
2010-11-08 02:25:36 +01:00
$percent = GETPOST ( " percentage " ) ? GETPOST ( " percentage " ) : $act -> percentage ;
2013-11-07 21:02:21 +01:00
$htmlactions -> form_select_status_action ( 'formaction' , $percent , 1 );
2010-11-08 02:25:36 +01:00
print '</td></tr>' ;
2010-11-20 19:41:09 +01:00
// Location
print '<tr><td>' . $langs -> trans ( " Location " ) . '</td><td colspan="3"><input type="text" name="location" size="50" value="' . $act -> location . '"></td></tr>' ;
2012-02-13 02:24:17 +01:00
print '</table><br><br><table class="border" width="100%">' ;
2010-11-08 02:25:36 +01:00
2013-04-06 17:39:31 +02:00
// Assigned to
2013-04-25 01:13:13 +02:00
print '<tr><td width="30%" class="nowrap">' . $langs -> trans ( " ActionAffectedTo " ) . '</td><td colspan="3">' ;
2011-11-08 10:18:45 +01:00
print $form -> select_dolusers ( $act -> usertodo -> id > 0 ? $act -> usertodo -> id :- 1 , 'affectedto' , 1 );
2010-11-08 02:25:36 +01:00
print '</td></tr>' ;
2013-04-06 17:39:31 +02:00
// Busy
2013-06-05 16:24:32 +02:00
print '<tr><td class="nowrap">' . $langs -> trans ( " Busy " ) . '</td><td>' ;
2013-04-06 17:39:31 +02:00
print '<input id="transparency" type="checkbox" name="transparency"' . ( $act -> transparency ? ' checked="checked"' : '' ) . '">' ;
2013-06-05 16:24:32 +02:00
print '</td></tr>' ;
2010-11-08 02:25:36 +01:00
// Realised by
2013-06-05 16:24:32 +02:00
if ( $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">' ;
2013-04-06 17:39:31 +02:00
print $form -> select_dolusers ( $act -> userdone -> id > 0 ? $act -> userdone -> id :- 1 , 'doneby' , 1 );
print '</td></tr>' ;
}
2010-11-08 02:25:36 +01:00
2012-02-13 02:24:17 +01:00
print '</table><br><br>' ;
2010-11-08 02:25:36 +01:00
print '<table class="border" width="100%">' ;
2012-12-21 17:56:40 +01:00
// Thirdparty - Contact
if ( $conf -> societe -> enabled )
{
print '<tr><td width="30%">' . $langs -> trans ( " ActionOnCompany " ) . '</td>' ;
print '<td>' ;
2013-10-01 18:11:53 +02:00
$events = array ();
$events [] = array ( 'method' => 'getContacts' , 'url' => dol_buildpath ( '/core/ajax/contacts.php' , 1 ), 'htmlname' => 'contactid' , 'params' => array ( 'add-customer-contact' => 'disabled' ));
print $form -> select_company ( $act -> societe -> id , 'socid' , '' , 1 , 1 , 0 , $events );
2012-12-21 17:56:40 +01:00
print '</td>' ;
// Contact
print '<td>' . $langs -> trans ( " Contact " ) . '</td><td width="30%">' ;
2013-10-01 18:11:53 +02:00
$form -> select_contacts ( $act -> societe -> id , $act -> contact -> id , 'contactid' , 1 );
2012-12-21 17:56:40 +01:00
print '</td></tr>' ;
}
2005-10-01 16:25:34 +02:00
2010-01-05 00:33:23 +01:00
// Project
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> projet -> enabled ))
2010-01-05 00:33:23 +01:00
{
2013-06-16 23:15:20 +02:00
2013-06-14 22:33:01 +02:00
$formproject = new FormProjets ( $db );
2013-06-16 23:15:20 +02:00
2010-01-05 00:33:23 +01:00
// Projet associe
$langs -> load ( " project " );
2012-12-21 17:56:40 +01:00
print '<tr><td width="30%" valign="top">' . $langs -> trans ( " Project " ) . '</td><td colspan="3">' ;
2013-06-14 22:33:01 +02:00
$numprojet = $formproject -> select_projects ( $act -> societe -> id , $act -> fk_project , 'projectid' );
2010-01-05 00:33:23 +01:00
if ( $numprojet == 0 )
{
print ' <a href="../../projet/fiche.php?socid=' . $societe -> id . '&action=create">' . $langs -> trans ( " AddProject " ) . '</a>' ;
}
print '</td></tr>' ;
}
2008-10-06 23:31:05 +02:00
// Priority
2012-12-21 17:56:40 +01:00
print '<tr><td nowrap width="30%">' . $langs -> trans ( " Priority " ) . '</td><td colspan="3">' ;
2011-11-01 15:05:42 +01:00
print '<input type="text" name="priority" value="' . ( $act -> priority ? $act -> priority : '' ) . '" size="5">' ;
2008-04-24 22:59:29 +02:00
print '</td></tr>' ;
2009-03-03 01:20:21 +01:00
// Object linked
2011-06-04 15:12:44 +02:00
if ( ! empty ( $act -> fk_element ) && ! empty ( $act -> elementtype ))
2009-03-03 01:20:21 +01:00
{
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>' ;
2013-06-16 23:15:20 +02:00
print '<td colspan="3">' . dolGetElementUrl ( $act -> fk_element , $act -> elementtype , 1 ) . '</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
print '<tr><td valign="top">' . $langs -> trans ( " Description " ) . '</td><td colspan="3">' ;
// Editeur wysiwyg
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2011-02-02 17:56:55 +01:00
$doleditor = new DolEditor ( 'note' , $act -> note , '' , 240 , 'dolibarr_notes' , 'In' , true , true , $conf -> fckeditor -> enabled , ROWS_5 , 90 );
2010-11-20 19:41:09 +01:00
$doleditor -> Create ();
print '</td></tr>' ;
2005-10-01 16:25:34 +02:00
2012-12-08 12:49:20 +01:00
// Other attributes
2014-01-22 03:20:18 +01:00
$parameters = array ( 'colspan' => ' colspan="3"' , 'colspanvalue' => '3' , 'id' => $act -> id );
2012-12-08 12:49:20 +01:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $act , $action ); // Note that $action and $object may have been modified by hook
if ( empty ( $reshook ) && ! empty ( $extrafields -> attribute_label ))
{
2014-02-26 16:50:38 +01:00
print $act -> showOptionals ( $extrafields , 'edit' );
2013-04-01 19:43:26 +02:00
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
2013-04-21 17:56:29 +02:00
dol_fiche_end ();
2013-04-25 01:13:13 +02:00
2013-04-21 17:56:29 +02:00
print '<center><input type="submit" class="button" name="edit" value="' . $langs -> trans ( " Save " ) . '">' ;
2009-03-03 01:20:21 +01:00
print ' <input type="submit" class="button" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2010-02-25 22:28:17 +01:00
print '</center>' ;
2005-07-10 04:05:09 +02:00
2010-02-25 22:28:17 +01:00
print '</form>' ;
2009-03-03 01:20:21 +01:00
}
else
{
2013-04-21 17:56:29 +02:00
dol_fiche_head ( $head , 'card' , $langs -> trans ( " Action " ), 0 , 'action' );
2013-04-25 01:13:13 +02:00
2009-03-03 01:20:21 +01:00
// Affichage fiche action en mode visu
print '<table class="border" width="100%">' ;
2006-09-10 15:53:20 +02:00
2012-08-31 19:07:47 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/comm/action/listactions.php">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2012-07-28 21:49:47 +02:00
2006-09-10 15:53:20 +02:00
// Ref
2010-06-09 20:25:20 +02:00
print '<tr><td width="30%">' . $langs -> trans ( " Ref " ) . '</td><td colspan="3">' ;
2012-07-28 21:49:47 +02:00
print $form -> showrefnav ( $act , 'id' , $linkback , ( $user -> societe_id ? 0 : 1 ), 'id' , 'ref' , '' );
2010-06-09 20:25:20 +02:00
print '</td></tr>' ;
2006-09-10 15:53:20 +02:00
// Type
2012-12-01 15:45:05 +01:00
if ( ! empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ))
{
print '<tr><td>' . $langs -> trans ( " Type " ) . '</td><td colspan="3">' . $act -> type . '</td></tr>' ;
}
2006-09-10 15:53:20 +02:00
2008-09-09 19:57:12 +02:00
// Title
2009-03-03 01:20:21 +01:00
print '<tr><td>' . $langs -> trans ( " Title " ) . '</td><td colspan="3">' . $act -> label . '</td></tr>' ;
2009-02-04 21:43:18 +01:00
2010-11-18 23:17:44 +01:00
// Full day event
print '<tr><td>' . $langs -> trans ( " EventOnFullDay " ) . '</td><td colspan="3">' . yn ( $act -> fulldayevent ) . '</td></tr>' ;
2010-11-20 19:41:09 +01:00
// Date start
print '<tr><td width="30%">' . $langs -> trans ( " DateActionStart " ) . '</td><td colspan="2">' ;
2010-11-20 00:50:27 +01:00
if ( ! $act -> fulldayevent ) print dol_print_date ( $act -> datep , 'dayhour' );
else print dol_print_date ( $act -> datep , 'day' );
2010-11-08 02:25:36 +01:00
if ( $act -> percentage == 0 && $act -> datep && $act -> datep < ( $now - $delay_warning )) print img_warning ( $langs -> trans ( " Late " ));
2010-11-20 19:41:09 +01:00
print '</td>' ;
2012-03-26 00:36:50 +02:00
print '<td rowspan="4" align="center" valign="middle" width="180">' . " \n " ;
2011-03-20 15:38:54 +01:00
print '<form name="listactionsfiltermonth" action="' . DOL_URL_ROOT . '/comm/action/index.php" method="POST">' ;
2010-11-20 19:41:09 +01:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2011-03-20 15:38:54 +01:00
print '<input type="hidden" name="action" value="show_month">' ;
2010-11-20 19:41:09 +01:00
print '<input type="hidden" name="year" value="' . dol_print_date ( $act -> datep , '%Y' ) . '">' ;
print '<input type="hidden" name="month" value="' . dol_print_date ( $act -> datep , '%m' ) . '">' ;
2011-03-20 15:38:54 +01:00
print '<input type="hidden" name="day" value="' . dol_print_date ( $act -> datep , '%d' ) . '">' ;
2010-11-20 19:41:09 +01:00
//print '<input type="hidden" name="day" value="'.dol_print_date($act->datep,'%d').'">';
2013-06-01 02:03:19 +02:00
print img_picto ( $langs -> trans ( " ViewCal " ), 'object_calendar' , 'class="hideonsmartphone"' ) . ' <input type="submit" style="min-width: 120px" class="button" name="viewcal" value="' . $langs -> trans ( " ViewCal " ) . '">' ;
2010-11-20 19:41:09 +01:00
print '</form>' . " \n " ;
2011-03-20 15:38:54 +01:00
print '<form name="listactionsfilterweek" action="' . DOL_URL_ROOT . '/comm/action/index.php" method="POST">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="show_week">' ;
print '<input type="hidden" name="year" value="' . dol_print_date ( $act -> datep , '%Y' ) . '">' ;
print '<input type="hidden" name="month" value="' . dol_print_date ( $act -> datep , '%m' ) . '">' ;
print '<input type="hidden" name="day" value="' . dol_print_date ( $act -> datep , '%d' ) . '">' ;
//print '<input type="hidden" name="day" value="'.dol_print_date($act->datep,'%d').'">';
2013-06-01 02:03:19 +02:00
print img_picto ( $langs -> trans ( " ViewCal " ), 'object_calendarweek' , 'class="hideonsmartphone"' ) . ' <input type="submit" style="min-width: 120px" class="button" name="viewweek" value="' . $langs -> trans ( " ViewWeek " ) . '">' ;
2011-03-20 15:38:54 +01:00
print '</form>' . " \n " ;
print '<form name="listactionsfilterday" action="' . DOL_URL_ROOT . '/comm/action/index.php" method="POST">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="show_day">' ;
print '<input type="hidden" name="year" value="' . dol_print_date ( $act -> datep , '%Y' ) . '">' ;
print '<input type="hidden" name="month" value="' . dol_print_date ( $act -> datep , '%m' ) . '">' ;
print '<input type="hidden" name="day" value="' . dol_print_date ( $act -> datep , '%d' ) . '">' ;
//print '<input type="hidden" name="day" value="'.dol_print_date($act->datep,'%d').'">';
2013-06-01 02:03:19 +02:00
print img_picto ( $langs -> trans ( " ViewCal " ), 'object_calendarday' , 'class="hideonsmartphone"' ) . ' <input type="submit" style="min-width: 120px" class="button" name="viewday" value="' . $langs -> trans ( " ViewDay " ) . '">' ;
2011-03-20 15:38:54 +01:00
print '</form>' . " \n " ;
print '</td>' ;
2010-11-20 19:41:09 +01:00
print '</tr>' ;
2010-11-08 02:25:36 +01:00
2010-11-20 19:41:09 +01:00
// Date end
print '<tr><td>' . $langs -> trans ( " DateActionEnd " ) . '</td><td colspan="2">' ;
2010-11-20 00:50:27 +01:00
if ( ! $act -> fulldayevent ) print dol_print_date ( $act -> datef , 'dayhour' );
else print dol_print_date ( $act -> datef , 'day' );
2010-11-08 02:25:36 +01:00
if ( $act -> percentage > 0 && $act -> percentage < 100 && $act -> datef && $act -> datef < ( $now - $delay_warning )) print img_warning ( $langs -> trans ( " Late " ));
print '</td></tr>' ;
2011-03-20 15:38:54 +01:00
// Status
2013-04-25 01:13:13 +02:00
print '<tr><td class="nowrap">' . $langs -> trans ( " Status " ) . ' / ' . $langs -> trans ( " Percentage " ) . '</td><td colspan="2">' ;
2010-11-08 02:25:36 +01:00
print $act -> getLibStatut ( 4 );
print '</td></tr>' ;
2010-11-20 19:41:09 +01:00
// Location
2012-03-26 00:36:50 +02:00
print '<tr><td>' . $langs -> trans ( " Location " ) . '</td><td colspan="2">' . $act -> location . '</td></tr>' ;
2010-11-20 19:41:09 +01:00
2012-02-13 02:24:17 +01:00
print '</table><br><br><table class="border" width="100%">' ;
2010-11-08 02:25:36 +01:00
2013-04-06 17:39:31 +02:00
// Assigned to
2013-04-25 01:13:13 +02:00
print '<tr><td width="30%" class="nowrap">' . $langs -> trans ( " ActionAffectedTo " ) . '</td><td colspan="3">' ;
2013-04-06 17:39:31 +02:00
if ( $act -> usertodo -> id > 0 ) print $act -> usertodo -> getNomUrl ( 1 );
2010-11-08 02:25:36 +01:00
print '</td></tr>' ;
2013-04-06 17:39:31 +02:00
// Busy
2013-04-25 01:13:13 +02:00
print '<tr><td class="nowrap">' . $langs -> trans ( " Busy " ) . '</td><td colspan="3">' ;
2013-05-14 02:46:00 +02:00
if ( $act -> usertodo -> id > 0 ) print yn (( $act -> transparency > 0 ) ? 1 : 0 ); // We show nothing if event is assigned to nobody
2010-11-08 02:25:36 +01:00
print '</td></tr>' ;
2010-11-20 00:50:27 +01:00
// Done by
2013-04-06 17:39:31 +02:00
if ( $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">' ;
2013-04-06 17:39:31 +02:00
if ( $act -> userdone -> id > 0 ) print $act -> userdone -> getNomUrl ( 1 );
print '</td></tr>' ;
}
2010-11-08 02:25:36 +01:00
2012-02-13 02:24:17 +01:00
print '</table><br><br><table class="border" width="100%">' ;
2010-11-08 02:25:36 +01:00
2010-11-20 19:41:09 +01:00
// Third party - Contact
2013-01-10 08:27:12 +01:00
if ( $conf -> societe -> enabled )
{
2012-12-21 17:56:40 +01:00
print '<tr><td width="30%">' . $langs -> trans ( " ActionOnCompany " ) . '</td><td>' . ( $act -> societe -> id ? $act -> societe -> getNomUrl ( 1 ) : $langs -> trans ( " None " ));
if ( $act -> societe -> id && $act -> type_code == 'AC_TEL' )
2008-12-02 19:41:17 +01:00
{
2012-12-21 17:56:40 +01:00
if ( $act -> societe -> fetch ( $act -> societe -> id ))
{
2013-09-25 19:58:22 +02:00
print " <br> " . dol_print_phone ( $act -> societe -> phone );
2012-12-21 17:56:40 +01:00
}
2008-12-02 19:41:17 +01:00
}
2012-12-21 17:56:40 +01:00
print '</td>' ;
print '<td>' . $langs -> trans ( " Contact " ) . '</td>' ;
print '<td>' ;
if ( $act -> contact -> id > 0 )
2008-12-02 19:41:17 +01:00
{
2012-12-21 17:56:40 +01:00
print $act -> contact -> getNomUrl ( 1 );
if ( $act -> contact -> id && $act -> type_code == 'AC_TEL' )
2008-12-02 19:41:17 +01:00
{
2012-12-21 17:56:40 +01:00
if ( $act -> contact -> fetch ( $act -> contact -> id ))
{
print " <br> " . dol_print_phone ( $act -> contact -> phone_pro );
}
2008-12-02 19:41:17 +01:00
}
2009-02-04 21:43:18 +01:00
}
2012-12-21 17:56:40 +01:00
else
{
print $langs -> trans ( " None " );
}
print '</td></tr>' ;
2009-03-03 01:20:21 +01:00
}
2005-10-01 16:25:34 +02:00
2010-01-05 00:33:23 +01:00
// Project
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> projet -> enabled ))
2010-01-05 00:33:23 +01:00
{
2012-12-21 17:56:40 +01:00
print '<tr><td width="30%" valign="top">' . $langs -> trans ( " Project " ) . '</td><td colspan="3">' ;
2010-01-05 00:33:23 +01:00
if ( $act -> fk_project )
{
$project = new Project ( $db );
$project -> fetch ( $act -> fk_project );
2013-09-22 21:02:42 +02:00
print $project -> getNomUrl ( 1 , '' , 1 );
2010-01-05 00:33:23 +01:00
}
print '</td></tr>' ;
}
2008-10-06 23:31:05 +02:00
// Priority
2012-12-21 17:56:40 +01:00
print '<tr><td nowrap width="30%">' . $langs -> trans ( " Priority " ) . '</td><td colspan="3">' ;
2011-11-01 15:05:42 +01:00
print ( $act -> priority ? $act -> priority : '' );
2008-10-06 23:31:05 +02:00
print '</td></tr>' ;
2011-06-04 15:12:44 +02:00
// Object linked
if ( ! empty ( $act -> fk_element ) && ! empty ( $act -> elementtype ))
2009-03-03 01:20:21 +01:00
{
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>' ;
2013-06-16 23:15:20 +02:00
print '<td colspan="3">' . dolGetElementUrl ( $act -> fk_element , $act -> elementtype , 1 ) . '</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
print '<tr><td valign="top">' . $langs -> trans ( " Description " ) . '</td><td colspan="3">' ;
2008-03-31 05:31:08 +02:00
print dol_htmlentitiesbr ( $act -> note );
2009-03-03 01:20:21 +01:00
print '</td></tr>' ;
2005-10-01 16:25:34 +02:00
2012-12-08 12:49:20 +01:00
// Other attributes
2014-01-22 03:20:18 +01:00
$parameters = array ( 'colspan' => ' colspan="3"' , 'colspanvalue' => '3' , 'id' => $act -> id );
2012-12-08 12:49:20 +01:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $act , $action ); // Note that $action and $object may have been modified by hook
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
2009-03-03 01:20:21 +01:00
print '</table>' ;
2012-12-21 17:56:40 +01:00
2012-12-08 12:49:20 +01:00
//Extra field
if ( empty ( $reshook ) && ! empty ( $extrafields -> attribute_label ))
2012-12-21 17:56:40 +01:00
{
2012-12-08 12:49:20 +01:00
print '<br><br><table class="border" width="100%">' ;
foreach ( $extrafields -> attribute_label as $key => $label )
{
$value = ( isset ( $_POST [ " options_ " . $key ]) ? $_POST [ " options_ " . $key ] : ( isset ( $act -> array_options [ 'options_' . $key ]) ? $act -> array_options [ 'options_' . $key ] : '' ));
print '<tr><td width="30%">' . $label . '</td><td>' ;
print $extrafields -> showOutputField ( $key , $value );
print " </td></tr> \n " ;
}
print '</table><br><br>' ;
}
2005-10-01 16:25:34 +02:00
2013-04-21 17:56:29 +02:00
dol_fiche_end ();
}
2004-03-02 11:57:44 +01:00
2004-10-02 16:24:43 +02:00
2009-11-10 13:36:30 +01:00
/*
2009-03-03 01:20:21 +01:00
* Barre d ' actions
*/
2004-10-02 16:24:43 +02:00
2009-03-03 01:20:21 +01:00
print '<div class="tabsAction">' ;
2005-10-01 16:25:34 +02:00
2011-04-09 13:52:11 +02:00
if ( $action != 'edit' )
2009-03-03 01:20:21 +01:00
{
2009-11-29 21:13:12 +01:00
if ( $user -> rights -> agenda -> allactions -> create ||
(( $act -> author -> id == $user -> id || $act -> usertodo -> id == $user -> id ) && $user -> rights -> agenda -> myactions -> create ))
2009-03-03 01:20:21 +01:00
{
2013-04-03 18:37:54 +02:00
print '<div class="inline-block divButAction"><a class="butAction" href="fiche.php?action=edit&id=' . $act -> id . '">' . $langs -> trans ( " Modify " ) . '</a></div>' ;
2009-03-03 01:20:21 +01:00
}
else
{
2013-04-03 18:37:54 +02:00
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs -> trans ( " NotAllowed " ) . '">' . $langs -> trans ( " Modify " ) . '</a></div>' ;
2009-03-03 01:20:21 +01:00
}
2005-10-01 16:25:34 +02:00
2009-11-13 05:10:59 +01:00
if ( $user -> rights -> agenda -> allactions -> delete ||
(( $act -> author -> id == $user -> id || $act -> usertodo -> id == $user -> id ) && $user -> rights -> agenda -> myactions -> delete ))
2009-03-03 01:20:21 +01:00
{
2013-04-03 18:37:54 +02:00
print '<div class="inline-block divButAction"><a class="butActionDelete" href="fiche.php?action=delete&id=' . $act -> id . '">' . $langs -> trans ( " Delete " ) . '</a></div>' ;
2009-03-03 01:20:21 +01:00
}
else
{
2013-04-03 18:37:54 +02:00
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs -> trans ( " NotAllowed " ) . '">' . $langs -> trans ( " Delete " ) . '</a></div>' ;
2009-03-03 01:20:21 +01:00
}
}
2005-10-01 16:25:34 +02:00
2009-03-03 01:20:21 +01:00
print '</div>' ;
2002-04-29 20:01:16 +02:00
}
2013-04-11 09:15:41 +02:00
2011-08-27 16:24:16 +02:00
llxFooter ();
2004-12-25 20:54:16 +01:00
2013-04-03 18:37:54 +02:00
$db -> close ();
2002-04-29 20:01:16 +02:00
?>