2008-02-26 19:34:53 +01:00
< ? php
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2008-03-06 13:57:26 +01:00
* Copyright ( C ) 2003 Eric Seigne < erics @ rycks . com >
2016-06-04 00:52:55 +02:00
* Copyright ( C ) 2004 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2017-05-17 17:00:45 +02:00
* Copyright ( C ) 2017 Open - DSI < support @ open - dsi . fr >
2021-10-25 22:00:45 +02:00
* Copyright ( C ) 2018 - 2021 Frédéric France < frederic . france @ netlogic . fr >
2020-05-19 08:18:38 +02:00
* Copyright ( C ) 2020 Tobias Sekan < tobias . sekan @ startmail . com >
2008-02-26 19:34:53 +01:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2008-02-26 19:34:53 +01:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2008-02-26 19:34:53 +01:00
*/
/**
2019-10-15 20:11:15 +02:00
* \file htdocs / comm / action / list . php
2010-01-19 10:44:52 +01:00
* \ingroup agenda
2011-01-19 12:17:35 +01:00
* \brief Page to list actions
2010-01-19 10:44:52 +01:00
*/
2009-08-24 19:11:30 +02:00
2021-02-23 18:59:19 +01:00
if ( ! defined ( " NOREDIRECTBYMAINTOLOGIN " )) {
define ( 'NOREDIRECTBYMAINTOLOGIN' , 1 );
}
2018-04-30 14:39:12 +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 . '/contact/class/contact.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/agenda.lib.php' ;
2017-03-28 18:42:23 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php' ;
2018-04-30 14:39:12 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
2008-02-26 19:34:53 +01:00
2018-05-26 19:03:41 +02:00
// Load translation files required by the page
2020-12-08 20:16:41 +01:00
$langs -> loadLangs ( array ( " users " , " companies " , " agenda " , " commercial " , " other " , " orders " , " bills " ));
2019-11-12 09:46:08 +01:00
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2020-05-19 08:18:38 +02:00
$massaction = GETPOST ( 'massaction' , 'alpha' );
2019-11-12 09:46:08 +01:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'actioncommlist' ; // To manage different context of search
2021-12-11 13:17:31 +01:00
$mode = GETPOST ( 'mode' , 'aZ09' );
if ( empty ( $mode ) && preg_match ( '/show_/' , $action )) {
$mode = $action ; // For backward compatibility
}
2019-11-12 09:46:08 +01:00
$resourceid = GETPOST ( " search_resourceid " , " int " ) ? GETPOST ( " search_resourceid " , " int " ) : GETPOST ( " resourceid " , " int " );
$pid = GETPOST ( " search_projectid " , 'int' , 3 ) ? GETPOST ( " search_projectid " , 'int' , 3 ) : GETPOST ( " projectid " , 'int' , 3 );
2021-07-26 00:37:47 +02:00
$search_status = ( GETPOST ( " search_status " , 'aZ09' ) != '' ) ? GETPOST ( " search_status " , 'aZ09' ) : GETPOST ( " status " , 'aZ09' );
2019-11-12 09:46:08 +01:00
$type = GETPOST ( 'search_type' , 'alphanohtml' ) ? GETPOST ( 'search_type' , 'alphanohtml' ) : GETPOST ( 'type' , 'alphanohtml' );
2019-01-27 11:55:16 +01:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2019-11-12 09:46:08 +01:00
$year = GETPOST ( " year " , 'int' );
$month = GETPOST ( " month " , 'int' );
$day = GETPOST ( " day " , 'int' );
2020-05-19 08:18:38 +02:00
$toselect = GETPOST ( 'toselect' , 'array' );
2020-05-28 14:55:29 +02:00
$confirm = GETPOST ( 'confirm' , 'alpha' );
2020-05-19 08:18:38 +02:00
2016-01-14 14:15:14 +01:00
// Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
2021-02-23 18:59:19 +01:00
if ( GETPOST ( 'search_actioncode' , 'array' )) {
2020-10-31 14:32:18 +01:00
$actioncode = GETPOST ( 'search_actioncode' , 'array' , 3 );
2021-02-23 18:59:19 +01:00
if ( ! count ( $actioncode )) {
$actioncode = '0' ;
}
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +01:00
$actioncode = GETPOST ( " search_actioncode " , " alpha " , 3 ) ? GETPOST ( " search_actioncode " , " alpha " , 3 ) : ( GETPOST ( " search_actioncode " ) == '0' ? '0' : ( empty ( $conf -> global -> AGENDA_DEFAULT_FILTER_TYPE ) ? '' : $conf -> global -> AGENDA_DEFAULT_FILTER_TYPE ));
2015-12-04 20:51:34 +01:00
}
2021-02-23 18:59:19 +01:00
if ( $actioncode == '' && empty ( $actioncodearray )) {
$actioncode = ( empty ( $conf -> global -> AGENDA_DEFAULT_FILTER_TYPE ) ? '' : $conf -> global -> AGENDA_DEFAULT_FILTER_TYPE );
}
2019-11-12 09:46:08 +01:00
$search_id = GETPOST ( 'search_id' , 'alpha' );
$search_title = GETPOST ( 'search_title' , 'alpha' );
$search_note = GETPOST ( 'search_note' , 'alpha' );
2021-02-07 19:44:22 +01:00
$dateselect = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'dateselectmonth' , 'int' ), GETPOST ( 'dateselectday' , 'int' ), GETPOST ( 'dateselectyear' , 'int' ), 'tzuserrel' );
2021-10-06 16:23:11 +02:00
$datestart_dtstart = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'datestart_dtstartmonth' , 'int' ), GETPOST ( 'datestart_dtstartday' , 'int' ), GETPOST ( 'datestart_dtstartyear' , 'int' ), 'tzuserrel' );
$datestart_dtend = dol_mktime ( 23 , 59 , 59 , GETPOST ( 'datestart_dtendmonth' , 'int' ), GETPOST ( 'datestart_dtendday' , 'int' ), GETPOST ( 'datestart_dtendyear' , 'int' ), 'tzuserrel' );
$dateend_dtstart = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'dateend_dtstartmonth' , 'int' ), GETPOST ( 'dateend_dtstartday' , 'int' ), GETPOST ( 'dateend_dtstartyear' , 'int' ), 'tzuserrel' );
$dateend_dtend = dol_mktime ( 23 , 59 , 59 , GETPOST ( 'dateend_dtendmonth' , 'int' ), GETPOST ( 'dateend_dtendday' , 'int' ), GETPOST ( 'dateend_dtendyear' , 'int' ), 'tzuserrel' );
2021-02-23 18:59:19 +01:00
if ( $search_status == '' && ! GETPOSTISSET ( 'search_status' )) {
$search_status = ( empty ( $conf -> global -> AGENDA_DEFAULT_FILTER_STATUS ) ? '' : $conf -> global -> AGENDA_DEFAULT_FILTER_STATUS );
}
2021-12-11 13:17:31 +01:00
if ( empty ( $mode ) && ! GETPOSTISSET ( 'mode' )) {
$mode = ( empty ( $conf -> global -> AGENDA_DEFAULT_VIEW ) ? 'show_month' : $conf -> global -> AGENDA_DEFAULT_VIEW );
2021-02-23 18:59:19 +01:00
}
2019-11-12 09:46:08 +01:00
$filter = GETPOST ( " search_filter " , 'alpha' , 3 ) ? GETPOST ( " search_filter " , 'alpha' , 3 ) : GETPOST ( " filter " , 'alpha' , 3 );
$filtert = GETPOST ( " search_filtert " , " int " , 3 ) ? GETPOST ( " search_filtert " , " int " , 3 ) : GETPOST ( " filtert " , " int " , 3 );
$usergroup = GETPOST ( " search_usergroup " , " int " , 3 ) ? GETPOST ( " search_usergroup " , " int " , 3 ) : GETPOST ( " usergroup " , " int " , 3 );
$showbirthday = empty ( $conf -> use_javascript_ajax ) ? ( GETPOST ( " search_showbirthday " , " int " ) ? GETPOST ( " search_showbirthday " , " int " ) : GETPOST ( " showbirthday " , " int " )) : 1 ;
2008-03-01 02:26:41 +01:00
2018-11-07 12:49:17 +01:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new ActionComm ( $db );
$hookmanager -> initHooks ( array ( 'agendalist' ));
2017-11-11 18:41:35 +01:00
$extrafields = new ExtraFields ( $db );
2019-09-28 10:55:09 +02:00
2017-11-11 18:41:35 +01:00
// fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2019-09-28 10:55:09 +02:00
2019-11-12 09:46:08 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $object -> table_element , '' , 'search_' );
2014-10-09 17:05:57 +02:00
// If not choice done on calendar owner, we filter on user.
2021-02-23 18:59:19 +01:00
if ( empty ( $filtert ) && empty ( $conf -> global -> AGENDA_ALL_CALENDARS )) {
2019-11-12 09:46:08 +01:00
$filtert = $user -> id ;
2014-10-09 17:05:57 +02:00
}
2019-11-12 09:46:08 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2022-01-13 11:09:37 +01:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2021-06-10 00:00:49 +02:00
if ( empty ( $page ) || $page < 0 || GETPOST ( 'button_search' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) {
// If $page is not defined, or '' or -1 or if we click on clear filters
2021-02-23 18:59:19 +01:00
$page = 0 ;
}
2019-11-12 09:46:08 +01:00
$offset = $limit * $page ;
2021-02-23 18:59:19 +01:00
if ( ! $sortorder ) {
2019-11-12 09:46:08 +01:00
$sortorder = " DESC,DESC " ;
2021-02-23 18:59:19 +01:00
if ( $search_status == 'todo' ) {
$sortorder = " DESC,DESC " ;
}
2010-02-04 22:32:14 +01:00
}
2021-02-23 18:59:19 +01:00
if ( ! $sortfield ) {
2019-11-12 09:46:08 +01:00
$sortfield = " a.datep,a.id " ;
2021-02-23 18:59:19 +01:00
if ( $search_status == 'todo' ) {
$sortfield = " a.datep,a.id " ;
}
2010-02-04 22:32:14 +01:00
}
2008-03-02 19:47:42 +01:00
2008-02-26 19:34:53 +01:00
// Security check
2019-11-12 09:46:08 +01:00
$socid = GETPOST ( " search_socid " , 'int' ) ? GETPOST ( " search_socid " , 'int' ) : GETPOST ( " socid " , 'int' );
2021-02-23 18:59:19 +01:00
if ( $user -> socid ) {
$socid = $user -> socid ;
}
if ( $socid < 0 ) {
$socid = '' ;
}
2008-03-01 02:26:41 +01:00
2019-11-12 09:46:08 +01:00
$canedit = 1 ;
2021-10-23 07:04:13 +02:00
if ( empty ( $user -> rights -> agenda -> myactions -> read )) {
2021-02-23 18:59:19 +01:00
accessforbidden ();
}
2021-10-23 07:04:13 +02:00
if ( empty ( $user -> rights -> agenda -> allactions -> read )) {
2021-02-23 18:59:19 +01:00
$canedit = 0 ;
}
2021-10-23 07:04:13 +02:00
if ( empty ( $user -> rights -> agenda -> allactions -> read ) || $filter == 'mine' ) { // If no permission to see all, we show only affected to me
2019-11-12 09:46:08 +01:00
$filtert = $user -> id ;
2008-03-01 15:30:06 +01:00
}
2008-03-02 19:47:42 +01:00
2019-11-12 09:46:08 +01:00
$arrayfields = array (
2017-11-11 18:41:35 +01:00
'a.id' => array ( 'label' => " Ref " , 'checked' => 1 ),
2017-11-14 01:57:50 +01:00
'owner' => array ( 'label' => " Owner " , 'checked' => 1 ),
2017-11-11 18:41:35 +01:00
'c.libelle' => array ( 'label' => " Type " , 'checked' => 1 ),
2017-11-24 20:02:46 +01:00
'a.label' => array ( 'label' => " Title " , 'checked' => 1 ),
2019-01-09 11:54:03 +01:00
'a.note' => array ( 'label' => 'Description' , 'checked' => 0 ),
2017-11-11 18:41:35 +01:00
'a.datep' => array ( 'label' => " DateStart " , 'checked' => 1 ),
'a.datep2' => array ( 'label' => " DateEnd " , 'checked' => 1 ),
's.nom' => array ( 'label' => " ThirdParty " , 'checked' => 1 ),
2020-08-21 01:11:22 +02:00
'a.fk_contact' => array ( 'label' => " Contact " , 'checked' => 0 ),
'a.fk_element' => array ( 'label' => " LinkedObject " , 'checked' => 1 , 'enabled' => ( ! empty ( $conf -> global -> AGENDA_SHOW_LINKED_OBJECT ))),
2021-02-02 00:19:41 +01:00
'a.datec' => array ( 'label' => 'DateCreation' , 'checked' => 0 , 'position' => 510 ),
'a.tms' => array ( 'label' => 'DateModification' , 'checked' => 0 , 'position' => 520 ),
'a.percent' => array ( 'label' => " Status " , 'checked' => 1 , 'position' => 1000 )
2017-11-11 18:41:35 +01:00
);
// Extra fields
2020-12-23 19:14:47 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php' ;
2019-10-22 17:08:37 +02:00
$object -> fields = dol_sort_array ( $object -> fields , 'position' );
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2008-02-26 19:34:53 +01:00
2021-03-29 22:43:39 +02:00
$result = restrictedArea ( $user , 'agenda' , 0 , '' , 'myactions' );
if ( $user -> socid && $socid ) {
$result = restrictedArea ( $user , 'societe' , $socid );
}
2018-02-06 01:16:51 +01:00
2008-03-20 21:39:50 +01:00
/*
2010-02-04 22:32:14 +01:00
* Actions
*/
2014-10-09 17:05:57 +02:00
2021-02-23 18:59:19 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
2021-12-11 13:17:31 +01:00
$mode = 'list' ; $massaction = '' ;
2020-05-28 14:31:19 +02:00
}
2021-02-23 18:59:19 +01:00
if ( GETPOST ( " viewcal " ) || GETPOST ( " viewweek " ) || GETPOST ( " viewday " )) {
2019-11-12 09:46:08 +01:00
$param = '' ;
2021-02-23 18:59:19 +01:00
if ( is_array ( $_POST )) {
foreach ( $_POST as $key => $val ) {
2020-10-31 14:32:18 +01:00
$param .= '&' . $key . '=' . urlencode ( $val );
}
}
2008-03-20 21:39:50 +01:00
//print $param;
header ( " Location: " . DOL_URL_ROOT . '/comm/action/index.php?' . $param );
exit ;
}
2019-11-12 09:46:08 +01:00
$parameters = array ( 'id' => $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-10-18 12:16:12 +02:00
2017-11-11 18:41:35 +01:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
2016-10-18 12:16:12 +02:00
// Purge search criteria
2021-02-23 18:59:19 +01:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) { // All tests are required to be compatible with all browsers
2020-10-31 14:32:18 +01:00
//$actioncode='';
$search_id = '' ;
2019-11-12 09:46:08 +01:00
$search_title = '' ;
2020-10-31 14:32:18 +01:00
$search_note = '' ;
2021-10-06 16:23:11 +02:00
$datestart_dtstart = '' ;
$datestart_dtend = '' ;
$dateend_dtstart = '' ;
$dateend_dtend = '' ;
2020-10-31 14:32:18 +01:00
$search_status = '' ;
2020-05-19 08:18:38 +02:00
$toselect = '' ;
2020-10-31 14:32:18 +01:00
$search_array_options = array ();
2016-10-18 12:16:12 +02:00
}
2008-03-20 21:39:50 +01:00
2021-02-23 18:59:19 +01:00
if ( empty ( $reshook ) && ! empty ( $massaction )) {
2020-05-19 08:18:38 +02:00
unset ( $percent );
2021-02-23 18:59:19 +01:00
switch ( $massaction ) {
2020-05-19 08:18:38 +02:00
case 'set_all_events_to_todo' :
$percent = ActionComm :: EVENT_TODO ;
break ;
case 'set_all_events_to_in_progress' :
$percent = ActionComm :: EVENT_IN_PROGRESS ;
break ;
case 'set_all_events_to_finished' :
$percent = ActionComm :: EVENT_FINISHED ;
break ;
}
2021-02-23 18:59:19 +01:00
if ( isset ( $percent )) {
foreach ( $toselect as $toselectid ) {
2020-05-19 08:18:38 +02:00
$result = $object -> updatePercent ( $toselectid , $percent );
2021-02-23 18:59:19 +01:00
if ( $result < 0 ) {
2020-05-19 08:18:38 +02:00
dol_print_error ( $db );
break ;
}
}
}
}
2008-02-26 19:34:53 +01:00
2020-05-28 14:31:19 +02:00
// As mass deletion happens with a confirm step, $massaction is not use for the final step (deletion).
2021-02-23 18:59:19 +01:00
if ( empty ( $reshook )) {
2020-05-28 14:31:19 +02:00
$objectclass = 'ActionComm' ;
$objectlabel = 'Events' ;
$uploaddir = true ;
// Only users that can delete any event can remove records.
$permissiontodelete = $user -> rights -> agenda -> allactions -> delete ;
2020-12-24 14:35:40 +01:00
$permissiontoadd = $user -> rights -> agenda -> myactions -> create ;
2020-05-28 14:31:19 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
}
2008-02-26 19:34:53 +01:00
/*
2008-03-20 21:39:50 +01:00
* View
2008-02-26 19:34:53 +01:00
*/
2019-11-12 09:46:08 +01:00
$form = new Form ( $db );
$userstatic = new User ( $db );
$formactions = new FormActions ( $db );
2014-10-16 21:34:35 +02:00
2018-09-09 11:25:59 +02:00
$nav = '' ;
$nav .= $form -> selectDate ( $dateselect , 'dateselect' , 0 , 0 , 1 , '' , 1 , 0 );
2019-11-12 09:46:08 +01:00
$nav .= ' <input type="submit" name="submitdateselect" class="button" value="' . $langs -> trans ( " Refresh " ) . '">' ;
2014-10-16 21:34:35 +02:00
2019-11-12 09:46:08 +01:00
$now = dol_now ();
2011-06-06 19:31:16 +02:00
2019-11-12 09:46:08 +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 );
2009-08-24 19:11:30 +02:00
2012-01-22 20:16:11 +01:00
// Define list of all external calendars
2019-11-12 09:46:08 +01:00
$listofextcals = array ();
2012-01-22 20:16:11 +01:00
2019-11-12 09:46:08 +01:00
$param = '' ;
2021-02-23 18:59:19 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
$param .= '&limit=' . urlencode ( $limit );
}
2017-11-02 14:58:33 +01:00
if ( $actioncode != '' ) {
2019-11-12 09:46:08 +01:00
if ( is_array ( $actioncode )) {
2021-02-23 18:59:19 +01:00
foreach ( $actioncode as $str_action ) {
$param .= " &search_actioncode[]= " . urlencode ( $str_action );
}
} else {
$param .= " &search_actioncode= " . urlencode ( $actioncode );
}
}
if ( $resourceid > 0 ) {
$param .= " &search_resourceid= " . urlencode ( $resourceid );
}
if ( $search_status != '' && $search_status > - 1 ) {
$param .= " &search_status= " . urlencode ( $search_status );
}
if ( $filter ) {
$param .= " &search_filter= " . urlencode ( $filter );
}
if ( $filtert ) {
$param .= " &search_filtert= " . urlencode ( $filtert );
}
if ( $usergroup > 0 ) {
$param .= " &search_usergroup= " . urlencode ( $usergroup );
}
if ( $socid > 0 ) {
$param .= " &search_socid= " . urlencode ( $socid );
}
if ( $showbirthday ) {
$param .= " &search_showbirthday=1 " ;
}
if ( $pid ) {
$param .= " &search_projectid= " . urlencode ( $pid );
}
if ( $type ) {
$param .= " &search_type= " . urlencode ( $type );
}
if ( $search_id != '' ) {
$param .= '&search_title=' . urlencode ( $search_id );
}
if ( $search_title != '' ) {
$param .= '&search_title=' . urlencode ( $search_title );
}
if ( $search_note != '' ) {
2021-05-27 02:36:16 +02:00
$param .= '&search_note=' . urlencode ( $search_note );
2021-02-23 18:59:19 +01:00
}
2021-10-06 16:23:11 +02:00
if ( GETPOST ( 'datestartday_dtstart' , 'int' )) {
$param .= '&datestartday_dtstart=' . GETPOST ( 'datestartday_dtstart' , 'int' );
2021-02-23 18:59:19 +01:00
}
2021-10-06 16:23:11 +02:00
if ( GETPOST ( 'datestartmonth_dtstart' , 'int' )) {
$param .= '&datestartmonth_dtstart=' . GETPOST ( 'datestartmonth_dtstart' , 'int' );
2021-02-23 18:59:19 +01:00
}
2021-10-06 16:23:11 +02:00
if ( GETPOST ( 'datestartyear_dtstart' , 'int' )) {
$param .= '&datestartyear_dtstart=' . GETPOST ( 'datestartyear_dtstart' , 'int' );
2021-02-23 18:59:19 +01:00
}
2021-10-06 16:23:11 +02:00
if ( GETPOST ( 'datestartday_dtend' , 'int' )) {
$param .= '&datestartday_dtend=' . GETPOST ( 'datestartday_dtend' , 'int' );
2021-02-23 18:59:19 +01:00
}
2021-10-06 16:23:11 +02:00
if ( GETPOST ( 'datestartmonth_dtend' , 'int' )) {
$param .= '&datestartmonth_dtend=' . GETPOST ( 'datestartmonth_dtend' , 'int' );
2021-02-23 18:59:19 +01:00
}
2021-10-06 16:23:11 +02:00
if ( GETPOST ( 'datestartyear_dtend' , 'int' )) {
$param .= '&datestartyear_dtend=' . GETPOST ( 'datestartyear_dtend' , 'int' );
}
if ( GETPOST ( 'dateendday_dtstart' , 'int' )) {
$param .= '&dateendday_dtstart=' . GETPOST ( 'dateendday_dtstart' , 'int' );
}
if ( GETPOST ( 'dateendmonth_dtstart' , 'int' )) {
$param .= '&dateendmonth_dtstart=' . GETPOST ( 'dateendmonth_dtstart' , 'int' );
}
if ( GETPOST ( 'dateendyear_dtstart' , 'int' )) {
$param .= '&dateendyear_dtstart=' . GETPOST ( 'dateendyear_dtstart' , 'int' );
}
if ( GETPOST ( 'dateendday_dtend' , 'int' )) {
$param .= '&dateendday_dtend=' . GETPOST ( 'dateendday_dtend' , 'int' );
}
if ( GETPOST ( 'dateendmonth_dtend' , 'int' )) {
$param .= '&dateendmonth_dtend=' . GETPOST ( 'dateendmonth_dtend' , 'int' );
}
if ( GETPOST ( 'dateendyear_dtend' , 'int' )) {
$param .= '&dateendyear_dtend=' . GETPOST ( 'dateendyear_dtend' , 'int' );
2021-02-23 18:59:19 +01:00
}
if ( $optioncss != '' ) {
$param .= '&optioncss=' . urlencode ( $optioncss );
}
2017-11-11 18:41:35 +01:00
// Add $param from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
2010-01-19 10:44:52 +01:00
2021-02-18 16:35:38 +01:00
$paramnoactionodate = $param ;
2020-05-19 08:18:38 +02:00
// List of mass actions available
$arrayofmassactions = array (
'set_all_events_to_todo' => $langs -> trans ( " SetAllEventsToTodo " ),
'set_all_events_to_in_progress' => $langs -> trans ( " SetAllEventsToInProgress " ),
'set_all_events_to_finished' => $langs -> trans ( " SetAllEventsToFinished " ),
);
2021-02-23 18:59:19 +01:00
if ( $user -> rights -> agenda -> allactions -> delete ) {
2021-04-14 12:33:53 +02:00
$arrayofmassactions [ 'predelete' ] = img_picto ( '' , 'delete' , 'class="pictofixedwidth"' ) . $langs -> trans ( " Delete " );
2020-05-28 14:31:19 +02:00
}
2021-02-23 18:59:19 +01:00
if ( $user -> rights -> agenda -> myactions -> create ) {
2021-04-14 12:33:53 +02:00
$arrayofmassactions [ 'preaffecttag' ] = img_picto ( '' , 'category' , 'class="pictofixedwidth"' ) . $langs -> trans ( " AffectTag " );
2021-02-23 18:59:19 +01:00
}
if ( GETPOST ( 'nomassaction' , 'int' ) || in_array ( $massaction , array ( 'presend' , 'predelete' , 'preaffecttag' ))) {
$arrayofmassactions = array ();
}
2020-05-19 08:18:38 +02:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2015-01-15 02:06:04 +01:00
$sql = " SELECT " ;
2021-02-23 18:59:19 +01:00
if ( $usergroup > 0 ) {
$sql .= " DISTINCT " ;
}
2019-11-12 09:46:08 +01:00
$sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail, " ;
2020-05-07 22:52:32 +02:00
$sql .= " a.id, a.code, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location, " ;
2019-11-12 09:46:08 +01:00
$sql .= ' a.fk_user_author,a.fk_user_action,' ;
$sql .= " a.fk_contact, a.note, a.percent as percent, " ;
$sql .= " a.fk_element, a.elementtype, a.datec, a.tms as datem, " ;
2021-02-18 12:46:42 +01:00
$sql .= " c.code as type_code, c.libelle as type_label, c.color as type_color, c.type as type_type, c.picto as type_picto, " ;
2019-11-12 09:46:08 +01:00
$sql .= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id " ;
2019-01-08 11:41:58 +01:00
2017-11-11 18:41:35 +01:00
// Add fields from extrafields
2019-11-12 09:46:08 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-23 18:59:19 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) {
2021-08-27 22:42:04 +02:00
$sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " , ef. " . $key . " as options_ " . $key : '' );
2021-02-23 18:59:19 +01:00
}
2019-10-16 03:34:32 +02:00
}
2019-01-08 11:41:58 +01:00
// Add fields from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
2021-12-11 13:17:31 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2019-11-12 09:46:08 +01:00
$sql .= $hookmanager -> resPrint ;
$sql .= " FROM " . MAIN_DB_PREFIX . " actioncomm as a " ;
2021-06-22 10:44:49 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " actioncomm_extrafields as ef ON (a.id = ef.fk_object) " ;
2021-10-22 22:15:59 +02:00
if ( empty ( $user -> rights -> societe -> client -> voir ) && ! $socid ) {
2021-02-23 18:59:19 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe_commerciaux as sc ON a.fk_soc = sc.fk_soc " ;
}
2019-11-12 09:46:08 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s ON a.fk_soc = s.rowid " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " socpeople as sp ON a.fk_contact = sp.rowid " ;
$sql .= " , " . MAIN_DB_PREFIX . " c_actioncomm as c " ;
2016-06-06 13:05:36 +02:00
// We must filter on resource table
2021-02-23 18:59:19 +01:00
if ( $resourceid > 0 ) {
$sql .= " , " . MAIN_DB_PREFIX . " element_resources as r " ;
}
2015-01-15 02:06:04 +01:00
// We must filter on assignement table
2021-02-23 18:59:19 +01:00
if ( $filtert > 0 || $usergroup > 0 ) {
$sql .= " , " . MAIN_DB_PREFIX . " actioncomm_resources as ar " ;
}
if ( $usergroup > 0 ) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " usergroup_user as ugu ON ugu.fk_user = ar.fk_element " ;
}
2019-11-12 09:46:08 +01:00
$sql .= " WHERE c.id = a.fk_action " ;
$sql .= ' AND a.entity IN (' . getEntity ( 'agenda' ) . ')' ;
2016-11-08 12:58:07 +01:00
// Condition on actioncode
2021-02-23 18:59:19 +01:00
if ( ! empty ( $actioncode )) {
if ( empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE )) {
if ( $actioncode == 'AC_NON_AUTO' ) {
$sql .= " AND c.type != 'systemauto' " ;
} elseif ( $actioncode == 'AC_ALL_AUTO' ) {
$sql .= " AND c.type = 'systemauto' " ;
} else {
if ( $actioncode == 'AC_OTH' ) {
$sql .= " AND c.type != 'systemauto' " ;
}
if ( $actioncode == 'AC_OTH_AUTO' ) {
$sql .= " AND c.type = 'systemauto' " ;
}
2020-10-31 14:32:18 +01:00
}
} else {
2021-02-23 18:59:19 +01:00
if ( $actioncode == 'AC_NON_AUTO' ) {
$sql .= " AND c.type != 'systemauto' " ;
} elseif ( $actioncode == 'AC_ALL_AUTO' ) {
$sql .= " AND c.type = 'systemauto' " ;
} else {
if ( is_array ( $actioncode )) {
2021-03-23 03:44:50 +01:00
$sql .= " AND c.code IN ( " . $db -> sanitize ( " ' " . implode ( " ',' " , $actioncode ) . " ' " , 1 ) . " ) " ;
2020-10-31 14:32:18 +01:00
} else {
2021-03-23 03:44:50 +01:00
$sql .= " AND c.code IN ( " . $db -> sanitize ( " ' " . implode ( " ',' " , explode ( ',' , $actioncode )) . " ' " , 1 ) . " ) " ;
2020-10-31 14:32:18 +01:00
}
}
}
2016-11-08 12:58:07 +01:00
}
2021-02-23 18:59:19 +01:00
if ( $resourceid > 0 ) {
2021-03-23 03:44:50 +01:00
$sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = " . (( int ) $resourceid );
2021-02-23 18:59:19 +01:00
}
if ( $pid ) {
2021-03-23 03:44:50 +01:00
$sql .= " AND a.fk_project= " . (( int ) $pid );
2021-02-23 18:59:19 +01:00
}
2021-10-22 22:15:59 +02:00
if ( empty ( $user -> rights -> societe -> client -> voir ) && ! $socid ) {
2021-08-23 17:41:11 +02:00
$sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = " . (( int ) $user -> id ) . " ) " ;
2021-02-23 18:59:19 +01:00
}
if ( $socid > 0 ) {
2021-03-23 03:44:50 +01:00
$sql .= " AND s.rowid = " . (( int ) $socid );
2021-02-23 18:59:19 +01:00
}
2015-01-15 02:06:04 +01:00
// We must filter on assignement table
2021-02-23 18:59:19 +01:00
if ( $filtert > 0 || $usergroup > 0 ) {
$sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user' " ;
}
if ( $type ) {
2021-03-23 03:44:50 +01:00
$sql .= " AND c.id = " . (( int ) $type );
2021-02-23 18:59:19 +01:00
}
if ( $search_status == '0' ) {
$sql .= " AND a.percent = 0 " ;
}
if ( $search_status == 'na' ) {
$sql .= " AND a.percent = -1 " ;
} // Not applicable
if ( $search_status == '50' ) {
$sql .= " AND (a.percent > 0 AND a.percent < 100) " ;
} // Running already started
if ( $search_status == '100' ) {
$sql .= " AND a.percent = 100 " ;
}
if ( $search_status == 'done' ) {
$sql .= " AND (a.percent = 100) " ;
}
if ( $search_status == 'todo' ) {
$sql .= " AND (a.percent >= 0 AND a.percent < 100) " ;
}
if ( $search_id ) {
$sql .= natural_search ( " a.id " , $search_id , 1 );
}
if ( $search_title ) {
$sql .= natural_search ( " a.label " , $search_title );
}
if ( $search_note ) {
$sql .= natural_search ( 'a.note' , $search_note );
}
2015-01-15 02:06:04 +01:00
// We must filter on assignement table
2021-02-23 18:59:19 +01:00
if ( $filtert > 0 || $usergroup > 0 ) {
2020-10-31 14:32:18 +01:00
$sql .= " AND ( " ;
2021-02-23 18:59:19 +01:00
if ( $filtert > 0 ) {
2021-03-23 03:44:50 +01:00
$sql .= " (ar.fk_element = " . (( int ) $filtert ) . " OR (ar.fk_element IS NULL AND a.fk_user_action = " . (( int ) $filtert ) . " )) " ; // The OR is for backward compatibility
2021-02-23 18:59:19 +01:00
}
if ( $usergroup > 0 ) {
2021-03-23 03:44:50 +01:00
$sql .= ( $filtert > 0 ? " OR " : " " ) . " ugu.fk_usergroup = " . (( int ) $usergroup );
2021-02-23 18:59:19 +01:00
}
2020-10-31 14:32:18 +01:00
$sql .= " ) " ;
2008-03-01 15:30:06 +01:00
}
2015-01-15 02:06:04 +01:00
2015-01-06 20:58:23 +01:00
// The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case)
2021-02-23 18:59:19 +01:00
if ( $dateselect > 0 ) {
$sql .= " AND ((a.datep2 >= ' " . $db -> idate ( $dateselect ) . " ' AND a.datep <= ' " . $db -> idate ( $dateselect + 3600 * 24 - 1 ) . " ') OR (a.datep2 IS NULL AND a.datep > ' " . $db -> idate ( $dateselect - 3600 ) . " ' AND a.datep <= ' " . $db -> idate ( $dateselect + 3600 * 24 - 1 ) . " ')) " ;
}
2021-10-06 16:23:11 +02:00
if ( $datestart_dtstart > 0 ) {
$sql .= " AND a.datep >= ' " . $db -> idate ( $datestart_dtstart ) . " ' " ;
}
if ( $datestart_dtend > 0 ) {
$sql .= " AND a.datep <= ' " . $db -> idate ( $datestart_dtend ) . " ' " ;
}
if ( $dateend_dtstart > 0 ) {
$sql .= " AND a.datep2 >= ' " . $db -> idate ( $dateend_dtstart ) . " ' " ;
2021-02-23 18:59:19 +01:00
}
2021-10-06 16:23:11 +02:00
if ( $dateend_dtend > 0 ) {
$sql .= " AND a.datep2 <= ' " . $db -> idate ( $dateend_dtend ) . " ' " ;
2021-02-23 18:59:19 +01:00
}
2019-01-08 11:41:58 +01:00
2017-11-11 18:41:35 +01:00
// Add where from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php' ;
2019-01-08 11:41:58 +01:00
// Add where from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
2021-12-11 13:17:31 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2019-11-12 09:46:08 +01:00
$sql .= $hookmanager -> resPrint ;
2019-01-08 11:41:58 +01:00
2021-08-16 22:36:30 +02:00
// Count total nb of records
$nbtotalofrecords = '' ;
2021-02-23 18:59:19 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST )) {
2021-08-16 22:36:30 +02:00
/* This old and fast method to get and count full list returns all record so use a high amount of memory .
2021-08-16 22:01:58 +02:00
$resql = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $resql );
*/
2021-08-16 22:36:30 +02:00
/* The slow method does not consume memory on mysql (not tested on pgsql) */
/* $resql = $db -> query ( $sql , 0 , 'auto' , 1 );
2021-08-16 22:01:58 +02:00
while ( $db -> fetch_object ( $resql )) {
$nbtotalofrecords ++ ;
2021-08-16 22:36:30 +02:00
} */
2021-09-03 13:39:08 +02:00
/* The fast and low memory method to get and count full list converts the sql into a sql count */
2021-08-16 22:36:30 +02:00
$sqlforcount = preg_replace ( '/^SELECT[a-z0-9\._\s\(\),]+FROM/i' , 'SELECT COUNT(*) as nbtotalofrecords FROM' , $sql );
$resql = $db -> query ( $sqlforcount );
$objforcount = $db -> fetch_object ( $resql );
$nbtotalofrecords = $objforcount -> nbtotalofrecords ;
2021-02-23 18:59:19 +01:00
if (( $page * $limit ) > $nbtotalofrecords ) { // if total resultset is smaller then paging size (filtering), goto and load page 0
2020-10-31 14:32:18 +01:00
$page = 0 ;
$offset = 0 ;
}
2021-08-16 22:01:58 +02:00
$db -> free ( $resql );
2016-02-11 20:24:15 +01:00
}
2021-08-16 22:36:30 +02:00
// Complete request and execute it with limit
$sql .= $db -> order ( $sortfield , $sortorder );
if ( $limit ) {
$sql .= $db -> plimit ( $limit + 1 , $offset );
2021-08-16 22:01:58 +02:00
}
2008-02-26 19:34:53 +01:00
2019-11-12 09:46:08 +01:00
$resql = $db -> query ( $sql );
2021-08-16 22:36:30 +02:00
if ( ! $resql ) {
dol_print_error ( $db );
exit ;
}
2009-08-24 19:11:30 +02:00
2021-08-16 22:36:30 +02:00
$num = $db -> num_rows ( $resql );
2008-03-20 21:39:50 +01:00
2020-05-19 08:18:38 +02:00
2021-08-16 22:36:30 +02:00
$actionstatic = new ActionComm ( $db );
$societestatic = new Societe ( $db );
2009-08-24 19:11:30 +02:00
2021-08-16 22:36:30 +02:00
$num = $db -> num_rows ( $resql );
2009-08-24 19:11:30 +02:00
2021-08-16 22:36:30 +02:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2011-05-16 19:27:20 +02:00
2021-08-16 22:36:30 +02:00
// Local calendar
$newtitle = '<div class="nowrap clear inline-block minheight30 margintoponly">' ;
$newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs -> trans ( " LocalAgenda " ) . ' ' ;
$newtitle .= '</div>' ;
//$newtitle=$langs->trans($title);
2017-11-25 00:12:45 +01:00
2021-08-16 22:36:30 +02:00
$tabactive = 'cardlist' ;
2011-05-16 19:27:20 +02:00
2021-08-16 22:36:30 +02:00
$head = calendars_prepare_head ( $param );
2015-07-21 12:19:21 +02:00
2021-08-16 22:36:30 +02:00
print '<form method="POST" id="searchFormList" class="listactionsfilter" action="' . $_SERVER [ " PHP_SELF " ] . '">' . " \n " ;
2015-07-21 12:19:21 +02:00
2021-08-16 22:36:30 +02:00
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
print '<input type="hidden" name="type" value="' . $type . '">' ;
$nav = '' ;
2021-01-12 13:58:16 +01:00
2021-08-16 22:36:30 +02:00
if ( $filter ) {
$nav .= '<input type="hidden" name="search_filter" value="' . $filter . '">' ;
}
if ( $showbirthday ) {
$nav .= '<input type="hidden" name="search_showbirthday" value="1">' ;
}
print $nav ;
2017-07-08 00:19:30 +02:00
2021-08-16 22:36:30 +02:00
//print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
//print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
//print dol_get_fiche_end();
2017-06-27 10:37:00 +02:00
2021-08-16 22:36:30 +02:00
$s = $newtitle ;
// Calendars from hooks
2021-10-25 22:01:36 +02:00
$parameters = array ();
$object = null ;
2021-08-16 22:36:30 +02:00
$reshook = $hookmanager -> executeHooks ( 'addCalendarChoice' , $parameters , $object , $action );
if ( empty ( $reshook )) {
$s .= $hookmanager -> resPrint ;
} elseif ( $reshook > 1 ) {
$s = $hookmanager -> resPrint ;
}
2021-10-25 22:00:45 +02:00
$viewyear = is_object ( $object ) ? dol_print_date ( $object -> datep , '%Y' ) : '' ;
$viewmonth = is_object ( $object ) ? dol_print_date ( $object -> datep , '%m' ) : '' ;
$viewday = is_object ( $object ) ? dol_print_date ( $object -> datep , '%d' ) : '' ;
2021-08-16 22:36:30 +02:00
$viewmode = '' ;
2021-12-11 13:17:31 +01:00
$viewmode .= '<a class="btnTitle btnTitleSelected reposition" href="' . DOL_URL_ROOT . '/comm/action/list.php?mode=show_list&restore_lastsearch_values=1' . $paramnoactionodate . '">' ;
2021-08-16 22:36:30 +02:00
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
2021-10-17 13:30:13 +02:00
$viewmode .= img_picto ( $langs -> trans ( " List " ), 'object_list' , 'class="imgforviewmode pictoactionview block"' );
2021-08-16 22:36:30 +02:00
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">' . $langs -> trans ( " ViewList " ) . '</span></a>' ;
2021-12-11 13:17:31 +01:00
$viewmode .= '<a class="btnTitle reposition" href="' . DOL_URL_ROOT . '/comm/action/index.php?mode=show_month&year=' . $viewyear . '&month=' . $viewmonth . '&day=' . $viewday . $paramnoactionodate . '">' ;
2021-08-16 22:36:30 +02:00
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto ( $langs -> trans ( " ViewCal " ), 'object_calendarmonth' , 'class="pictoactionview block"' );
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">' . $langs -> trans ( " ViewCal " ) . '</span></a>' ;
2021-12-11 13:17:31 +01:00
$viewmode .= '<a class="btnTitle reposition" href="' . DOL_URL_ROOT . '/comm/action/index.php?mode=show_week&year=' . $viewyear . '&month=' . $viewmonth . '&day=' . $viewday . $paramnoactionodate . '">' ;
2021-08-16 22:36:30 +02:00
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto ( $langs -> trans ( " ViewWeek " ), 'object_calendarweek' , 'class="pictoactionview block"' );
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">' . $langs -> trans ( " ViewWeek " ) . '</span></a>' ;
2021-12-11 13:17:31 +01:00
$viewmode .= '<a class="btnTitle reposition" href="' . DOL_URL_ROOT . '/comm/action/index.php?mode=show_day&year=' . $viewyear . '&month=' . $viewmonth . '&day=' . $viewday . $paramnoactionodate . '">' ;
2021-08-16 22:36:30 +02:00
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto ( $langs -> trans ( " ViewDay " ), 'object_calendarday' , 'class="pictoactionview block"' );
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">' . $langs -> trans ( " ViewDay " ) . '</span></a>' ;
2021-12-11 13:17:31 +01:00
$viewmode .= '<a class="btnTitle reposition marginrightonly" href="' . DOL_URL_ROOT . '/comm/action/peruser.php?mode=show_peruser&year=' . $viewyear . '&month=' . $viewmonth . '&day=' . $viewday . $paramnoactionodate . '">' ;
2021-08-16 22:36:30 +02:00
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto ( $langs -> trans ( " ViewPerUser " ), 'object_calendarperuser' , 'class="pictoactionview block"' );
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">' . $langs -> trans ( " ViewPerUser " ) . '</span></a>' ;
$viewmode .= '<span class="marginrightonly"></span>' ;
// Add more views from hooks
2021-10-25 22:01:36 +02:00
$parameters = array ();
$object = null ;
2021-08-16 22:36:30 +02:00
$reshook = $hookmanager -> executeHooks ( 'addCalendarView' , $parameters , $object , $action );
if ( empty ( $reshook )) {
$viewmode .= $hookmanager -> resPrint ;
} elseif ( $reshook > 1 ) {
$viewmode = $hookmanager -> resPrint ;
}
2020-07-08 18:06:14 +02:00
2021-08-16 22:36:30 +02:00
$tmpforcreatebutton = dol_getdate ( dol_now (), true );
2020-09-18 11:48:53 +02:00
2021-10-25 22:04:19 +02:00
$newparam = '&month=' . str_pad ( $month , 2 , " 0 " , STR_PAD_LEFT ) . '&year=' . $tmpforcreatebutton [ 'year' ];
2020-09-18 11:48:53 +02:00
2021-08-16 22:36:30 +02:00
//$param='month='.$monthshown.'&year='.$year;
2022-02-11 15:15:50 +01:00
$hourminsec = dol_print_date ( dol_mktime ( 10 , 0 , 0 , 1 , 1 , 1970 , 'gmt' ), '%H' , 'gmt' ) . '0000' ; // Set $hourminsec to '100000' to auto set hour to 10:00 at creation
2020-07-08 18:06:14 +02:00
2021-08-16 22:36:30 +02:00
$url = DOL_URL_ROOT . '/comm/action/card.php?action=create' ;
$url .= '&datep=' . sprintf ( " %04d%02d%02d " , $tmpforcreatebutton [ 'year' ], $tmpforcreatebutton [ 'mon' ], $tmpforcreatebutton [ 'mday' ]) . $hourminsec ;
$url .= '&backtopage=' . urlencode ( $_SERVER [ " PHP_SELF " ] . ( $newparam ? '?' . $newparam : '' ));
2017-06-27 10:37:00 +02:00
2021-08-16 22:36:30 +02:00
$newcardbutton = dolGetButtonTitle ( $langs -> trans ( 'AddAction' ), '' , 'fa fa-plus-circle' , $url , '' , $user -> rights -> agenda -> myactions -> create || $user -> rights -> agenda -> allactions -> create );
2016-02-11 20:24:15 +01:00
2021-12-11 13:17:31 +01:00
$param .= '&mode=' . $mode ;
2020-05-28 14:31:19 +02:00
2021-08-16 22:36:30 +02:00
print_barre_liste ( $langs -> trans ( " Agenda " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , - 1 * $nbtotalofrecords , 'object_action' , 0 , $nav . $newcardbutton , '' , $limit , 0 , 0 , 1 , $viewmode );
2017-06-10 13:54:43 +02:00
2021-08-16 22:36:30 +02:00
print $s ;
2020-07-08 18:06:14 +02:00
2021-08-16 22:36:30 +02:00
$objecttmp = new ActionComm ( $db );
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2020-07-08 18:06:14 +02:00
2021-08-16 22:36:30 +02:00
$moreforfilter = '' ;
2016-11-27 13:49:46 +01:00
2021-08-16 22:36:30 +02:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
if ( $massactionbutton ) {
$selectedfields .= $form -> showCheckAddButtons ( 'checkforselect' , 1 );
}
$i = 0 ;
2017-11-27 15:24:29 +01:00
2021-08-16 22:36:30 +02:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print_actions_filter ( $form , $canedit , $search_status , $year , $month , $day , $showbirthday , 0 , $filtert , 0 , $pid , $socid , $action , - 1 , $actioncode , $usergroup , '' , $resourceid );
print '</div>' ;
2017-11-27 15:24:29 +01:00
2021-08-16 22:36:30 +02:00
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2017-11-11 18:41:35 +01:00
2021-08-16 22:36:30 +02:00
print '<tr class="liste_titre_filter">' ;
if ( ! empty ( $arrayfields [ 'a.id' ][ 'checked' ])) {
print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="' . $search_id . '"></td>' ;
}
if ( ! empty ( $arrayfields [ 'owner' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 'c.libelle' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 'a.label' ][ 'checked' ])) {
print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="' . $search_title . '"></td>' ;
}
if ( ! empty ( $arrayfields [ 'a.note' ][ 'checked' ])) {
print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="' . $search_note . '"></td>' ;
}
if ( ! empty ( $arrayfields [ 'a.datep' ][ 'checked' ])) {
print '<td class="liste_titre nowraponall" align="center">' ;
2021-10-06 16:23:11 +02:00
print '<div class="nowrap">' ;
print $form -> selectDate ( $datestart_dtstart , 'datestart_dtstart' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'From' ), 'tzuserrel' );
print '</div>' ;
print '<div class="nowrap">' ;
print $form -> selectDate ( $datestart_dtend , 'datestart_dtend' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'To' ), 'tzuserrel' );
print '</div>' ;
2016-04-23 16:51:22 +02:00
print '</td>' ;
2021-08-16 22:36:30 +02:00
}
if ( ! empty ( $arrayfields [ 'a.datep2' ][ 'checked' ])) {
print '<td class="liste_titre nowraponall" align="center">' ;
2021-10-06 16:23:11 +02:00
print '<div class="nowrap">' ;
print $form -> selectDate ( $dateend_dtstart , 'dateend_dtstart' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'From' ), 'tzuserrel' );
print '</div>' ;
print '<div class="nowrap">' ;
print $form -> selectDate ( $dateend_dtend , 'dateend_dtend' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'To' ), 'tzuserrel' );
print '</div>' ;
2021-08-16 22:36:30 +02:00
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 'a.fk_contact' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 'a.fk_element' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
2017-06-10 13:54:43 +02:00
2021-08-16 22:36:30 +02:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
2017-11-14 01:57:50 +01:00
2021-08-16 22:36:30 +02:00
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2017-11-27 15:24:29 +01:00
2021-08-16 22:36:30 +02:00
if ( ! empty ( $arrayfields [ 'a.datec' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 'a.tms' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 'a.percent' ][ 'checked' ])) {
print '<td class="liste_titre center">' ;
$formactions -> form_select_status_action ( 'formaction' , $search_status , 1 , 'search_status' , 1 , 2 , 'minwidth100imp maxwidth125' );
print ajax_combobox ( 'selectsearch_status' );
print '</td>' ;
}
// Action column
print '<td class="liste_titre" align="middle">' ;
$searchpicto = $form -> showFilterButtons ();
print $searchpicto ;
print '</td>' ;
print " </tr> \n " ;
2018-11-19 14:25:34 +01:00
2021-08-16 22:36:30 +02:00
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 'a.id' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'a.id' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " a.id " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'owner' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'owner' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'c.libelle' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'c.libelle' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " c.libelle " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'a.label' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'a.label' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " a.label " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'a.note' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'a.note' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " a.note " , $param , " " , " " , $sortfield , $sortorder );
}
//if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
if ( ! empty ( $arrayfields [ 'a.datep' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'a.datep' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " a.datep,a.id " , $param , '' , 'align="center"' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'a.datep2' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'a.datep2' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " a.datep2 " , $param , '' , 'align="center"' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 's.nom' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " s.nom " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'a.fk_contact' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'a.fk_contact' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , $param , " " , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'a.fk_element' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'a.fk_element' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , $param , " " , " " , $sortfield , $sortorder );
}
2018-11-19 14:25:34 +01:00
2021-08-16 22:36:30 +02:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
2014-09-09 12:28:35 +02:00
2021-08-16 22:36:30 +02:00
// Hook fields
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2009-08-24 19:11:30 +02:00
2021-08-16 22:36:30 +02:00
if ( ! empty ( $arrayfields [ 'a.datec' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'a.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " a.datec,a.id " , $param , " " , 'align="center"' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'a.tms' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'a.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " a.tms,a.id " , $param , " " , 'align="center"' , $sortfield , $sortorder );
}
2017-06-10 13:54:43 +02:00
2021-08-16 22:36:30 +02:00
if ( ! empty ( $arrayfields [ 'a.percent' ][ 'checked' ])) {
print_liste_field_titre ( " Status " , $_SERVER [ " PHP_SELF " ], " a.percent " , $param , " " , 'align="center"' , $sortfield , $sortorder );
}
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' );
print " </tr> \n " ;
2008-02-26 19:34:53 +01:00
2021-08-16 22:36:30 +02:00
$contactstatic = new Contact ( $db );
$now = dol_now ();
$delay_warning = $conf -> global -> MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60 ;
2014-10-20 12:29:35 +02:00
2021-08-16 22:36:30 +02:00
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/cactioncomm.class.php' ;
$caction = new CActionComm ( $db );
$arraylist = $caction -> liste_array ( 1 , 'code' , '' , ( empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ) ? 1 : 0 ), '' , 1 );
$contactListCache = array ();
2017-06-10 13:54:43 +02:00
2021-08-16 22:36:30 +02:00
while ( $i < min ( $num , $limit )) {
$obj = $db -> fetch_object ( $resql );
2016-10-17 17:52:58 +02:00
2021-08-16 22:36:30 +02:00
// Discard auto action if option is on
if ( ! empty ( $conf -> global -> AGENDA_ALWAYS_HIDE_AUTO ) && $obj -> type_code == 'AC_OTH_AUTO' ) {
$i ++ ;
continue ;
}
2016-10-17 17:52:58 +02:00
2021-08-16 22:36:30 +02:00
$actionstatic -> id = $obj -> id ;
$actionstatic -> ref = $obj -> id ;
$actionstatic -> code = $obj -> code ;
$actionstatic -> type_code = $obj -> type_code ;
$actionstatic -> type_label = $obj -> type_label ;
$actionstatic -> type_picto = $obj -> type_picto ;
$actionstatic -> type_color = $obj -> type_color ;
$actionstatic -> label = $obj -> label ;
$actionstatic -> location = $obj -> location ;
$actionstatic -> note_private = dol_htmlentitiesbr ( $obj -> note );
2022-01-07 16:00:19 +01:00
$actionstatic -> datep = $db -> jdate ( $obj -> dp );
$actionstatic -> percentage = $obj -> percent ;
2021-08-16 22:36:30 +02:00
// Initialize $this->userassigned && this->socpeopleassigned array && this->userownerid
// but only if we need it
if ( ! empty ( $arrayfields [ 'a.fk_contact' ][ 'checked' ])) {
$actionstatic -> fetchResources ();
}
print '<tr class="oddeven">' ;
// Ref
if ( ! empty ( $arrayfields [ 'a.id' ][ 'checked' ])) {
print '<td class="nowraponall">' ;
print $actionstatic -> getNomUrl ( 1 , - 1 );
print '</td>' ;
}
// User owner
if ( ! empty ( $arrayfields [ 'owner' ][ 'checked' ])) {
print '<td class="tdoverflowmax150">' ; // With edge and chrome the td overflow is not supported correctly when content is not full text.
if ( $obj -> fk_user_action > 0 ) {
$userstatic -> fetch ( $obj -> fk_user_action );
print $userstatic -> getNomUrl ( - 1 );
} else {
print ' ' ;
2017-09-16 00:49:46 +02:00
}
2021-08-16 22:36:30 +02:00
print '</td>' ;
}
2017-11-24 20:02:46 +01:00
2021-08-16 22:36:30 +02:00
// Type
if ( ! empty ( $arrayfields [ 'c.libelle' ][ 'checked' ])) {
print '<td class="nowraponall">' ;
print $actionstatic -> getTypePicto ();
$labeltype = $obj -> type_code ;
if ( empty ( $conf -> global -> AGENDA_USE_EVENT_TYPE ) && empty ( $arraylist [ $labeltype ])) {
$labeltype = 'AC_OTH' ;
}
if ( $actionstatic -> type_code == 'AC_OTH' && $actionstatic -> code == 'TICKET_MSG' ) {
$labeltype = $langs -> trans ( " Message " );
} else {
if ( ! empty ( $arraylist [ $labeltype ])) {
$labeltype = $arraylist [ $labeltype ];
2021-02-23 18:59:19 +01:00
}
2021-08-16 22:36:30 +02:00
if ( $obj -> type_code == 'AC_OTH_AUTO' && ( $obj -> type_code != $obj -> code ) && $labeltype && ! empty ( $arraylist [ $obj -> code ])) {
$labeltype .= ' - ' . $arraylist [ $obj -> code ]; // Use code in priority on type_code
2020-08-21 01:11:22 +02:00
}
2016-01-15 01:52:16 +01:00
}
2021-08-16 22:36:30 +02:00
print dol_trunc ( $labeltype , 28 );
print '</td>' ;
}
2017-11-24 20:02:46 +01:00
2021-08-16 22:36:30 +02:00
// Label
if ( ! empty ( $arrayfields [ 'a.label' ][ 'checked' ])) {
print '<td class="tdoverflowmax200" title="' . dol_escape_htmltag ( $actionstatic -> label ) . '">' ;
print $actionstatic -> label ;
print '</td>' ;
}
2019-01-09 11:54:03 +01:00
2021-08-16 22:36:30 +02:00
// Description
if ( ! empty ( $arrayfields [ 'a.note' ][ 'checked' ])) {
print '<td class="tdoverflowonsmartphone">' ;
2022-03-16 21:22:03 +01:00
$text = dolGetFirstLineOfText ( dol_string_nohtmltag ( $actionstatic -> note_private , 1 ));
print $form -> textwithtooltip ( dol_trunc ( $text , 48 ), $actionstatic -> note_private );
2021-08-16 22:36:30 +02:00
print '</td>' ;
}
2020-04-07 21:11:18 +02:00
2021-08-16 22:36:30 +02:00
$formatToUse = $obj -> fulldayevent ? 'day' : 'dayhour' ;
2020-08-21 01:11:22 +02:00
2021-08-16 22:36:30 +02:00
// Start date
if ( ! empty ( $arrayfields [ 'a.datep' ][ 'checked' ])) {
print '<td class="center nowraponall">' ;
2022-02-11 15:15:50 +01:00
if ( empty ( $obj -> fulldayevent )) {
print dol_print_date ( $db -> jdate ( $obj -> dp ), $formatToUse , 'tzuser' );
} else {
$tzforfullday = getDolGlobalString ( 'MAIN_STORE_FULL_EVENT_IN_GMT' );
print dol_print_date ( $db -> jdate ( $obj -> dp ), $formatToUse , ( $tzforfullday ? $tzforfullday : 'tzuser' ));
}
2021-08-16 22:36:30 +02:00
$late = 0 ;
2022-01-07 16:00:19 +01:00
if ( $actionstatic -> hasDelay () && $actionstatic -> percentage >= 0 && $actionstatic -> percentage < 100 ) {
2021-08-16 22:36:30 +02:00
$late = 1 ;
2017-11-11 18:41:35 +01:00
}
2021-08-16 22:36:30 +02:00
if ( $late ) {
print img_warning ( $langs -> trans ( " Late " )) . ' ' ;
}
print '</td>' ;
}
2017-11-25 00:12:45 +01:00
2021-08-16 22:36:30 +02:00
// End date
if ( ! empty ( $arrayfields [ 'a.datep2' ][ 'checked' ])) {
print '<td class="center nowraponall">' ;
2022-02-11 15:15:50 +01:00
if ( empty ( $obj -> fulldayevent )) {
print dol_print_date ( $db -> jdate ( $obj -> dp2 ), $formatToUse , 'tzuser' );
} else {
$tzforfullday = getDolGlobalString ( 'MAIN_STORE_FULL_EVENT_IN_GMT' );
print dol_print_date ( $db -> jdate ( $obj -> dp2 ), $formatToUse , ( $tzforfullday ? $tzforfullday : 'tzuser' ));
}
2021-08-16 22:36:30 +02:00
print '</td>' ;
}
2018-11-28 14:20:55 +01:00
2021-08-16 22:36:30 +02:00
// Third party
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
print '<td class="tdoverflowmax150">' ;
if ( $obj -> socid > 0 ) {
$societestatic -> id = $obj -> socid ;
$societestatic -> client = $obj -> client ;
$societestatic -> name = $obj -> societe ;
$societestatic -> email = $obj -> socemail ;
print $societestatic -> getNomUrl ( 1 , '' , 28 );
} else {
print ' ' ;
2017-11-11 18:41:35 +01:00
}
2021-08-16 22:36:30 +02:00
print '</td>' ;
}
2017-11-25 00:12:45 +01:00
2021-08-16 22:36:30 +02:00
// Contact
if ( ! empty ( $arrayfields [ 'a.fk_contact' ][ 'checked' ])) {
print '<td class="tdoverflowmax100">' ;
if ( ! empty ( $actionstatic -> socpeopleassigned )) {
$contactList = array ();
foreach ( $actionstatic -> socpeopleassigned as $socpeopleassigned ) {
if ( ! isset ( $contactListCache [ $socpeopleassigned [ 'id' ]])) {
// if no cache found we fetch it
$contact = new Contact ( $db );
if ( $contact -> fetch ( $socpeopleassigned [ 'id' ]) > 0 ) {
$contactListCache [ $socpeopleassigned [ 'id' ]] = $contact -> getNomUrl ( 1 , '' , 0 );
$contactList [] = $contact -> getNomUrl ( 1 , '' , 0 );
2020-10-31 14:32:18 +01:00
}
2021-08-16 22:36:30 +02:00
} else {
// use cache
$contactList [] = $contactListCache [ $socpeopleassigned [ 'id' ]];
2020-10-31 14:32:18 +01:00
}
2017-11-11 18:41:35 +01:00
}
2021-08-16 22:36:30 +02:00
if ( ! empty ( $contactList )) {
print implode ( ', ' , $contactList );
2020-10-31 14:32:18 +01:00
}
2021-08-16 22:36:30 +02:00
} elseif ( $obj -> fk_contact > 0 ) { //keep for retrocompatibility with faraway event
$contactstatic -> id = $obj -> fk_contact ;
$contactstatic -> email = $obj -> email ;
$contactstatic -> lastname = $obj -> lastname ;
$contactstatic -> firstname = $obj -> firstname ;
$contactstatic -> phone_pro = $obj -> phone_pro ;
$contactstatic -> phone_mobile = $obj -> phone_mobile ;
$contactstatic -> phone_perso = $obj -> phone_perso ;
$contactstatic -> country_id = $obj -> country_id ;
print $contactstatic -> getNomUrl ( 1 , '' , 0 );
} else {
print " " ;
2010-02-04 22:32:14 +01:00
}
2021-08-16 22:36:30 +02:00
print '</td>' ;
}
2017-11-25 00:12:45 +01:00
2021-08-16 22:36:30 +02:00
// Linked object
if ( ! empty ( $arrayfields [ 'a.fk_element' ][ 'checked' ])) {
print '<td class="tdoverflowmax150">' ;
//var_dump($obj->fkelement.' '.$obj->elementtype);
if ( $obj -> fk_element > 0 && ! empty ( $obj -> elementtype )) {
include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
print dolGetElementUrl ( $obj -> fk_element , $obj -> elementtype , 1 );
} else {
print " " ;
2020-05-19 08:18:38 +02:00
}
print '</td>' ;
2021-08-16 22:36:30 +02:00
}
2017-06-10 13:54:43 +02:00
2021-08-16 22:36:30 +02:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj , 'i' => $i , 'totalarray' =>& $totalarray );
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
// Date creation
if ( ! empty ( $arrayfields [ 'a.datec' ][ 'checked' ])) {
// Status/Percent
print '<td align="center" class="nowrap">' . dol_print_date ( $db -> jdate ( $obj -> datec ), 'dayhour' , 'tzuser' ) . '</td>' ;
2010-02-04 22:32:14 +01:00
}
2021-08-16 22:36:30 +02:00
// Date update
if ( ! empty ( $arrayfields [ 'a.tms' ][ 'checked' ])) {
print '<td align="center" class="nowrap">' . dol_print_date ( $db -> jdate ( $obj -> datem ), 'dayhour' , 'tzuser' ) . '</td>' ;
}
if ( ! empty ( $arrayfields [ 'a.percent' ][ 'checked' ])) {
// Status/Percent
$datep = $db -> jdate ( $obj -> dp );
print '<td align="center" class="nowrap">' . $actionstatic -> LibStatut ( $obj -> percent , 5 , 0 , $datep ) . '</td>' ;
}
// Action column
print '<td class="nowrap center">' ;
if ( $massactionbutton || $massaction ) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0 ;
if ( in_array ( $obj -> id , $arrayofselected )) {
$selected = 1 ;
}
print '<input id="cb' . $obj -> id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj -> id . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
}
print '</td>' ;
2014-09-09 12:28:35 +02:00
2021-08-16 22:36:30 +02:00
print " </tr> \n " ;
$i ++ ;
2008-02-26 19:34:53 +01:00
}
2021-08-16 22:36:30 +02:00
print " </table> " ;
print '</div>' ;
print '</form>' ;
$db -> free ( $resql );
2008-02-26 19:34:53 +01:00
2018-07-29 13:40:35 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2015-01-15 02:06:04 +01:00
$db -> close ();