2010-05-03 10:22:35 +02:00
< ? php
2012-01-27 15:17:36 +01:00
/* Copyright ( c ) 2008 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2010 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2018-02-22 10:16:53 +01:00
* Copyright ( C ) 2010 - 2018 Juanjo Menent < jmenent @ 2 byte . es >
2024-09-05 16:05:37 +02:00
* Copyright ( C ) 2024 Frédéric France < frederic . france @ free . fr >
2024-10-25 21:00:02 +02:00
* Copyright ( C ) 2024 MDW < mdeweerd @ users . noreply . github . com >
2010-05-03 10:22:35 +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
2010-05-03 10:22:35 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2010-05-03 10:22:35 +02:00
*/
/**
2010-11-22 10:18:53 +01:00
* \file htdocs / core / class / html . formactions . class . php
* \ingroup core
2021-02-19 22:00:44 +01:00
* \brief File of class with predefined functions and HTML components
2010-11-22 10:18:53 +01:00
*/
2010-05-03 10:22:35 +02:00
/**
2012-01-27 15:17:36 +01:00
* Class to manage building of HTML components
2010-11-22 10:18:53 +01:00
*/
2010-05-03 10:22:35 +02:00
class FormActions
{
2020-09-07 10:18:17 +02:00
/**
* @ var DoliDB Database handler .
*/
public $db ;
2018-09-02 23:01:14 +02:00
2020-09-07 10:18:17 +02:00
/**
2018-08-22 10:37:16 +02:00
* @ var string Error code ( or message )
*/
2019-11-13 19:35:39 +01:00
public $error = '' ;
2010-11-22 10:18:53 +01:00
2020-09-07 10:18:17 +02:00
/**
2011-09-11 20:35:38 +02:00
* Constructor
*
2020-09-07 10:18:17 +02:00
* @ param DoliDB $db Database handler
*/
public function __construct ( $db )
{
$this -> db = $db ;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Show list of action status
*
* @ param string $formname Name of form where select is included
* @ param string $selected Preselected value ( - 1. . 100 )
* @ param int $canedit 1 = can edit , 0 = read only
* @ param string $htmlname Name of html prefix for html fields ( selectX and valX )
* @ param integer $showempty Show an empty line if select is used
* @ param integer $onlyselect 0 = Standard , 1 = Hide percent of completion and force usage of a select list , 2 = Same than 1 and add " Incomplete (Todo+Running)
* @ param string $morecss More css on select field
* @ return void
*/
public function form_select_status_action ( $formname , $selected , $canedit = 1 , $htmlname = 'complete' , $showempty = 0 , $onlyselect = 0 , $morecss = 'maxwidth100' )
{
// phpcs:enable
global $langs , $conf ;
$listofstatus = array (
2021-01-28 19:38:47 +01:00
'na' => $langs -> trans ( " ActionNotApplicable " ),
2020-09-07 10:18:17 +02:00
'0' => $langs -> trans ( " ActionsToDoShort " ),
'50' => $langs -> trans ( " ActionRunningShort " ),
'100' => $langs -> trans ( " ActionDoneShort " )
);
2014-06-26 20:24:00 +02:00
// +ActionUncomplete
2010-11-22 10:18:53 +01:00
2024-06-24 15:55:45 +02:00
if ( ! empty ( $conf -> use_javascript_ajax ) || $onlyselect ) {
//var_dump($selected);
if ( $selected == 'done' ) {
$selected = '100' ;
}
print '<select ' . ( $canedit ? '' : 'disabled ' ) . 'name="' . $htmlname . '" id="select' . $htmlname . '" class="flat' . ( $morecss ? ' ' . $morecss : '' ) . '">' ;
if ( $showempty ) {
print '<option value="-1"' . ( $selected == '' ? ' selected' : '' ) . '> </option>' ;
}
foreach ( $listofstatus as $key => $val ) {
print '<option value="' . $key . '"' . (( $selected == $key && strlen ( $selected ) == strlen ( $key )) || (( $selected > 0 && $selected < 100 ) && $key == '50' ) ? ' selected' : '' ) . '>' . $val . '</option>' ;
if ( $key == '50' && $onlyselect == 2 ) {
print '<option value="todo"' . ( $selected == 'todo' ? ' selected' : '' ) . '>' . $langs -> trans ( " ActionUncomplete " ) . ' (' . $langs -> trans ( " ActionsToDoShort " ) . " + " . $langs -> trans ( " ActionRunningShort " ) . ')</option>' ;
}
}
print '</select>' ;
if ( $selected == 0 || $selected == 100 ) {
$canedit = 0 ;
}
print ajax_combobox ( 'select' . $htmlname , array (), 0 , 0 , 'resolve' , '-1' , $morecss );
if ( empty ( $onlyselect )) {
print ' <input type="text" id="val' . $htmlname . '" name="percentage" class="flat hideifna" value="' . ( $selected >= 0 ? $selected : '' ) . '" size="2"' . ( $canedit && ( $selected >= 0 ) ? '' : ' disabled' ) . '>' ;
print '<span class="hideonsmartphone hideifna">%</span>' ;
}
} else {
print ' <input type="text" id="val' . $htmlname . '" name="percentage" class="flat" value="' . ( $selected >= 0 ? $selected : '' ) . '" size="2"' . ( $canedit ? '' : ' disabled' ) . '>%' ;
}
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> use_javascript_ajax )) {
2020-09-07 10:18:17 +02:00
print " \n " ;
2023-02-18 15:10:05 +01:00
print '<script nonce="' . getNonce () . '" type="text/javascript">' ;
print "
2024-06-24 15:55:45 +02:00
var htmlname = '".dol_escape_js($htmlname)."' ;
2012-08-20 02:42:56 +02:00
2012-08-20 09:40:59 +02:00
$ ( document ) . ready ( function () {
select_status ();
$ ( '#select' + htmlname ) . change ( function () {
2022-05-19 10:31:01 +02:00
console . log ( 'We change field select ' + htmlname );
2012-08-20 02:42:56 +02:00
select_status ();
});
});
function select_status () {
2012-08-20 10:38:48 +02:00
var defaultvalue = $ ( '#select' + htmlname ) . val ();
2022-05-19 10:31:01 +02:00
console . log ( 'val=' + defaultvalue );
2012-08-20 09:40:59 +02:00
var percentage = $ ( 'input[name=percentage]' );
2021-07-26 00:37:47 +02:00
var selected = '".(isset($selected) ? dol_escape_js($selected) : ' ')."' ;
2012-08-20 10:38:48 +02:00
var value = ( selected > 0 ? selected : ( defaultvalue >= 0 ? defaultvalue : '' ));
percentage . val ( value );
2022-05-19 10:31:01 +02:00
if ( defaultvalue == 'na' || defaultvalue == - 1 ) {
2015-05-12 14:47:33 +02:00
percentage . prop ( 'disabled' , true );
2012-08-20 09:40:59 +02:00
$ ( '.hideifna' ) . hide ();
2012-08-20 02:42:56 +02:00
}
2012-08-20 10:38:48 +02:00
else if ( defaultvalue == 0 ) {
2012-09-02 14:11:07 +02:00
percentage . val ( 0 );
2016-10-30 12:39:51 +01:00
percentage . removeAttr ( 'disabled' ); /* Not disabled, we want to change it to higher value */
2012-08-20 09:40:59 +02:00
$ ( '.hideifna' ) . show ();
2012-08-20 02:42:56 +02:00
}
2012-08-20 10:38:48 +02:00
else if ( defaultvalue == 100 ) {
2012-09-02 14:11:07 +02:00
percentage . val ( 100 );
2015-05-12 14:47:33 +02:00
percentage . prop ( 'disabled' , true );
2012-08-20 09:40:59 +02:00
$ ( '.hideifna' ) . show ();
2012-08-20 02:42:56 +02:00
}
else {
2022-12-30 18:43:43 +01:00
if ( defaultvalue == 50 && ( percentage . val () == 0 || percentage . val () == 100 )) { percentage . val ( 50 ); }
2012-09-02 14:11:07 +02:00
percentage . removeAttr ( 'disabled' );
2012-08-20 09:40:59 +02:00
$ ( '.hideifna' ) . show ();
2012-08-20 02:42:56 +02:00
}
}
</ script > \n " ;
2020-09-07 10:18:17 +02:00
}
}
2017-09-23 12:59:49 +02:00
2020-05-07 22:52:32 +02:00
2020-09-07 10:18:17 +02:00
/**
* Show list of actions for element
*
* @ param Object $object Object
* @ param string $typeelement 'invoice' , 'propal' , 'order' , 'invoice_supplier' , 'order_supplier' , 'fichinter'
* @ param int $socid Socid of user
* @ param int $forceshowtitle Show title even if there is no actions to show
* @ param string $morecss More css on table
* @ param int $max Max number of record
* @ param string $moreparambacktopage More param for the backtopage
* @ param string $morehtmlcenter More html text on center of title line
2022-10-21 16:18:25 +02:00
* @ param int $assignedtouser Assign event by default to this user id ( will be ignored if not enough permissions )
2023-12-06 15:46:39 +01:00
* @ return int Return integer < 0 if KO , >= 0 if OK
2020-09-07 10:18:17 +02:00
*/
2022-10-21 16:18:25 +02:00
public function showactions ( $object , $typeelement , $socid = 0 , $forceshowtitle = 0 , $morecss = 'listactions' , $max = 0 , $moreparambacktopage = '' , $morehtmlcenter = '' , $assignedtouser = 0 )
2020-09-07 10:18:17 +02:00
{
2024-07-23 11:49:06 +02:00
global $langs , $user , $hookmanager ;
2011-07-07 23:56:20 +02:00
2020-09-07 10:18:17 +02:00
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php' ;
2017-06-10 13:54:43 +02:00
2020-09-07 10:18:17 +02:00
$sortfield = 'a.datep,a.id' ;
$sortorder = 'DESC,DESC' ;
2011-06-20 12:40:25 +02:00
2021-09-27 15:41:58 +02:00
$actioncomm = new ActionComm ( $this -> db );
$listofactions = $actioncomm -> getActions ( $socid , $object -> id , $typeelement , '' , $sortfield , $sortorder , ( $max ? ( $max + 1 ) : 0 ));
2021-02-23 22:03:23 +01:00
if ( ! is_array ( $listofactions )) {
dol_print_error ( $this -> db , 'FailedToGetActions' );
}
2019-06-13 22:48:31 +02:00
2020-09-07 10:18:17 +02:00
$num = count ( $listofactions );
2021-02-23 22:03:23 +01:00
if ( $num || $forceshowtitle ) {
2023-10-20 12:44:08 +02:00
$title = $langs -> trans ( " LatestLinkedEvents " , $max ? $max : '' );
2020-09-07 10:18:17 +02:00
$urlbacktopage = $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . ( $moreparambacktopage ? '&' . $moreparambacktopage : '' );
$projectid = $object -> fk_project ;
2021-02-23 22:03:23 +01:00
if ( $typeelement == 'project' ) {
$projectid = $object -> id ;
}
2021-09-23 12:05:55 +02:00
$taskid = 0 ;
2021-09-19 00:50:23 +02:00
if ( $typeelement == 'task' ) {
$taskid = $object -> id ;
}
2020-09-07 10:18:17 +02:00
2022-10-21 16:18:25 +02:00
$usercanaddaction = 0 ;
if ( empty ( $assignedtouser ) || $assignedtouser == $user -> id ) {
$usercanaddaction = $user -> hasRight ( 'agenda' , 'myactions' , 'create' );
$assignedtouser = 0 ;
} else {
$usercanaddaction = $user -> hasRight ( 'agenda' , 'allactions' , 'create' );
}
2024-04-21 02:29:47 +02:00
$url = '' ;
$morehtmlright = '' ;
2022-10-21 16:18:25 +02:00
if ( isModEnabled ( 'agenda' ) && $usercanaddaction ) {
$url = DOL_URL_ROOT . '/comm/action/card.php?action=create&token=' . newToken () . '&datep=' . urlencode ( dol_print_date ( dol_now (), 'dayhourlog' , 'tzuser' ));
$url .= '&origin=' . urlencode ( $typeelement ) . '&originid=' . (( int ) $object -> id ) . (( ! empty ( $object -> socid ) && $object -> socid > 0 ) ? '&socid=' . (( int ) $object -> socid ) : (( ! empty ( $socid ) && $socid > 0 ) ? '&socid=' . (( int ) $socid ) : '' ));
$url .= ( $projectid > 0 ? '&projectid=' . (( int ) $projectid ) : '' ) . ( $taskid > 0 ? '&taskid=' . (( int ) $taskid ) : '' );
2024-08-13 04:37:19 +02:00
$url .= ( $assignedtouser > 0 ? '&assignedtouser=' . (( int ) $assignedtouser ) : '' );
2022-10-21 16:18:25 +02:00
$url .= '&backtopage=' . urlencode ( $urlbacktopage );
2024-08-24 13:41:20 +02:00
if ( $typeelement == 'invoice_supplier' ) {
$messagingUrl = DOL_URL_ROOT . '/fourn/facture/messaging.php?id=' . $object -> id ;
$morehtmlright .= dolGetButtonTitle ( $langs -> trans ( 'ShowAsConversation' ), '' , 'fa fa-comments imgforviewmode' , $messagingUrl , '' , 1 );
$messagingUrl = DOL_URL_ROOT . '/fourn/facture/agenda.php?id=' . $object -> id ;
$morehtmlright .= dolGetButtonTitle ( $langs -> trans ( 'MessageListViewType' ), '' , 'fa fa-bars imgforviewmode' , $messagingUrl , '' , 2 );
}
2024-04-21 02:29:47 +02:00
$morehtmlright .= dolGetButtonTitle ( $langs -> trans ( " AddEvent " ), '' , 'fa fa-plus-circle' , $url );
2020-09-07 10:18:17 +02:00
}
2024-04-21 02:29:47 +02:00
$parameters = array (
'title' => & $title ,
'morehtmlright' => & $morehtmlright ,
'morehtmlcenter' => & $morehtmlcenter ,
'usercanaddaction' => $usercanaddaction ,
'url' => & $url ,
'typeelement' => $typeelement ,
'projectid' => $projectid ,
'assignedtouser' => $assignedtouser ,
'taskid' => $taskid ,
'urlbacktopage' => $urlbacktopage
);
$reshook = $hookmanager -> executeHooks ( 'showActionsLoadFicheTitre' , $parameters , $object );
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
$error = 0 ;
if ( empty ( $reshook )) {
print '<!-- formactions->showactions -->' . " \n " ;
2024-09-05 16:05:37 +02:00
print load_fiche_titre ( $title , $morehtmlright , '' , 0 , '' , '' , $morehtmlcenter );
2024-04-21 02:29:47 +02:00
}
2020-09-07 10:18:17 +02:00
2021-03-01 20:37:16 +01:00
$page = 0 ;
$param = '' ;
2020-09-07 10:18:17 +02:00
print '<div class="div-table-responsive-no-min">' ;
print '<table class="centpercent noborder' . ( $morecss ? ' ' . $morecss : '' ) . '">' ;
print '<tr class="liste_titre">' ;
2024-09-05 16:05:37 +02:00
print getTitleFieldOfList ( 'Ref' , 0 , $_SERVER [ " PHP_SELF " ], '' , ( string ) $page , $param , '' , $sortfield , $sortorder , '' , 1 );
print getTitleFieldOfList ( 'Date' , 0 , $_SERVER [ " PHP_SELF " ], 'a.datep' , ( string ) $page , $param , '' , $sortfield , $sortorder , 'center ' , 1 );
print getTitleFieldOfList ( 'By' , 0 , $_SERVER [ " PHP_SELF " ], '' , ( string ) $page , $param , '' , $sortfield , $sortorder , '' , 1 );
print getTitleFieldOfList ( 'Type' , 0 , $_SERVER [ " PHP_SELF " ], '' , ( string ) $page , $param , '' , $sortfield , $sortorder , '' , 1 );
print getTitleFieldOfList ( 'Title' , 0 , $_SERVER [ " PHP_SELF " ], '' , ( string ) $page , $param , '' , $sortfield , $sortorder , '' , 1 );
print getTitleFieldOfList ( '' , 0 , $_SERVER [ " PHP_SELF " ], '' , ( string ) $page , $param , '' , $sortfield , $sortorder , 'right ' , 1 );
2020-09-07 10:18:17 +02:00
print '</tr>' ;
print " \n " ;
2021-02-23 22:03:23 +01:00
if ( is_array ( $listofactions ) && count ( $listofactions )) {
2020-09-07 10:18:17 +02:00
$cacheusers = array ();
2017-09-23 12:59:49 +02:00
2020-09-07 10:18:17 +02:00
$cursorevent = 0 ;
2021-02-23 22:03:23 +01:00
foreach ( $listofactions as $actioncomm ) {
if ( $max && $cursorevent >= $max ) {
break ;
}
2017-09-23 12:59:49 +02:00
2020-09-07 10:18:17 +02:00
print '<tr class="oddeven">' ;
2020-11-22 13:23:56 +01:00
2020-09-07 10:18:17 +02:00
// Ref
2024-07-22 16:36:24 +02:00
print '<td class="nowraponall nopaddingrightimp">' . $actioncomm -> getNomUrl ( 1 , - 1 ) . '</td>' ;
2020-11-22 13:23:56 +01:00
2024-05-29 23:23:20 +02:00
// Date
2024-07-22 16:36:24 +02:00
print '<td class="center nowraponall">' . dol_print_date ( $actioncomm -> datep , 'dayhourreduceformat' , 'tzuserrel' );
2024-05-29 23:23:20 +02:00
if ( $actioncomm -> datef ) {
$tmpa = dol_getdate ( $actioncomm -> datep );
$tmpb = dol_getdate ( $actioncomm -> datef );
if ( $tmpa [ 'mday' ] == $tmpb [ 'mday' ] && $tmpa [ 'mon' ] == $tmpb [ 'mon' ] && $tmpa [ 'year' ] == $tmpb [ 'year' ]) {
if ( $tmpa [ 'hours' ] != $tmpb [ 'hours' ] || $tmpa [ 'minutes' ] != $tmpb [ 'minutes' ]) {
print '-' . dol_print_date ( $actioncomm -> datef , 'hour' , 'tzuserrel' );
}
} else {
2024-07-22 16:36:24 +02:00
print '-' . dol_print_date ( $actioncomm -> datef , 'dayhourreduceformat' , 'tzuserrel' );
2024-05-29 23:23:20 +02:00
}
}
print '</td>' ;
2024-01-13 19:48:20 +01:00
// Owner
2024-07-22 16:36:24 +02:00
print '<td class="nowraponall tdoverflowmax100">' ;
2021-02-23 22:03:23 +01:00
if ( ! empty ( $actioncomm -> userownerid )) {
if ( isset ( $cacheusers [ $actioncomm -> userownerid ]) && is_object ( $cacheusers [ $actioncomm -> userownerid ])) {
2020-09-07 10:18:17 +02:00
$tmpuser = $cacheusers [ $actioncomm -> userownerid ];
} else {
$tmpuser = new User ( $this -> db );
$tmpuser -> fetch ( $actioncomm -> userownerid );
$cacheusers [ $actioncomm -> userownerid ] = $tmpuser ;
}
2021-02-23 22:03:23 +01:00
if ( $tmpuser -> id > 0 ) {
2020-09-07 10:18:17 +02:00
print $tmpuser -> getNomUrl ( - 1 , '' , 0 , 0 , 16 , 0 , 'firstelselast' , '' );
}
}
print '</td>' ;
2020-05-07 22:52:32 +02:00
2022-11-25 10:42:33 +01:00
// Example: Email sent from invoice card
//$actionstatic->code = 'AC_BILL_SENTBYMAIL
//$actionstatic->type_code = 'AC_OTHER_AUTO'
2017-11-25 16:21:44 +01:00
// Type
2024-07-23 11:49:06 +02:00
$labeltype = $actioncomm -> getTypeLabel ( 0 );
2022-11-23 11:57:53 +01:00
print '<td class="tdoverflowmax100" title="' . dol_escape_htmltag ( $labeltype ) . '">' ;
2021-03-17 11:34:19 +01:00
print $actioncomm -> getTypePicto ();
print $labeltype ;
2020-09-07 10:18:17 +02:00
print '</td>' ;
2020-11-22 13:23:56 +01:00
2020-09-07 10:18:17 +02:00
// Label
2024-07-22 16:36:24 +02:00
print '<td class="tdoverflowmax250">' ;
2023-12-10 13:51:14 +01:00
print $actioncomm -> getNomUrl ( 0 );
print '</td>' ;
2020-11-22 13:23:56 +01:00
2024-05-29 23:23:20 +02:00
// Status
2020-09-07 10:18:17 +02:00
print '<td class="right">' ;
print $actioncomm -> getLibStatut ( 3 );
print '</td>' ;
print '</tr>' ;
$cursorevent ++ ;
}
} else {
2022-07-28 18:36:50 +02:00
print '<tr class="oddeven"><td colspan="6"><span class="opacitymedium">' . $langs -> trans ( " None " ) . '</span></td></tr>' ;
2020-09-07 10:18:17 +02:00
}
2021-02-23 22:03:23 +01:00
if ( $max && $num > $max ) {
2022-07-28 18:36:50 +02:00
print '<tr class="oddeven"><td colspan="6"><span class="opacitymedium">' . $langs -> trans ( " More " ) . '...</span></td></tr>' ;
2020-09-07 10:18:17 +02:00
}
print '</table>' ;
print '</div>' ;
}
return $num ;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Output html select list of type of event
*
2024-10-25 21:00:02 +02:00
* @ param string [] | string $selected Type pre - selected ( can be 'manual' , 'auto' or 'AC_xxx' ) . Can be an array too .
2020-09-07 10:18:17 +02:00
* @ param string $htmlname Name of select field
* @ param string $excludetype A type to exclude ( 'systemauto' , 'system' , '' )
2024-10-25 21:00:02 +02:00
* @ param int <- 2 , 1 > $onlyautoornot 1 = Group all type AC_XXX into 1 line AC_MANUAL . 0 = Keep details of type , - 1 = Keep details and add a combined line " All manual " , - 2 = Combined line is disabled ( not implemented yet )
* @ param int <- 1 , 1 > $hideinfohelp 1 = Do not show info help , 0 = Show , - 1 = Show + Add info to tell how to set default value
* @ param int < 0 , 1 > $multiselect 1 = Allow multiselect of action type
* @ param int < 0 , 1 > $nooutput 1 = No output
2020-09-07 10:18:17 +02:00
* @ param string $morecss More css to add to SELECT component .
2024-09-25 02:35:56 +02:00
* @ param int < 0 , 1 >| string $showempty 0 or 1 or 'Placeholder string'
2020-09-07 10:18:17 +02:00
* @ return string
*/
2024-09-25 02:35:56 +02:00
public function select_type_actions ( $selected = '' , $htmlname = 'actioncode' , $excludetype = '' , $onlyautoornot = 0 , $hideinfohelp = 0 , $multiselect = 0 , $nooutput = 0 , $morecss = 'minwidth300' , $showempty = 0 )
2020-09-07 10:18:17 +02:00
{
// phpcs:enable
2024-04-29 19:38:02 +02:00
global $langs , $user , $form ;
2020-09-07 10:18:17 +02:00
2021-02-23 22:03:23 +01:00
if ( ! is_object ( $form )) {
$form = new Form ( $this -> db );
}
2020-09-07 10:18:17 +02:00
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/cactioncomm.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php' ;
$caction = new CActionComm ( $this -> db );
// Suggest a list with manual events or all auto events
2022-01-17 22:52:56 +01:00
$arraylist = $caction -> liste_array ( 1 , 'code' , $excludetype , $onlyautoornot , '' , 0 ); // If we use param 'all' instead of 'code', there is no group by include in answer but the key 'type' of answer array contains the key for the group by.
2020-09-07 10:18:17 +02:00
2021-02-23 22:03:23 +01:00
if ( $selected == 'manual' ) {
$selected = 'AC_OTH' ;
}
if ( $selected == 'auto' ) {
$selected = 'AC_OTH_AUTO' ;
}
2020-09-07 10:18:17 +02:00
2024-10-25 21:00:02 +02:00
if ( array_key_exists ( 'AC_OTH_AUTO' , $arraylist ) && getDolGlobalString ( 'AGENDA_ALWAYS_HIDE_AUTO' )) {
2021-02-23 22:03:23 +01:00
unset ( $arraylist [ 'AC_OTH_AUTO' ]);
}
2020-09-07 10:18:17 +02:00
2021-02-23 22:03:23 +01:00
$out = '' ;
2017-06-10 13:54:43 +02:00
2024-04-29 19:38:02 +02:00
// Reformat the array
$newarraylist = array ();
foreach ( $arraylist as $key => $value ) {
$disabled = '' ;
if ( strpos ( $key , 'AC_ALL_' ) !== false && strpos ( $key , 'AC_ALL_AUTO' ) === false ) {
$disabled = 'disabled' ;
}
2024-10-17 22:20:39 +02:00
2024-04-29 19:38:02 +02:00
$newarraylist [ $key ] = array ( 'id' => $key , 'label' => $value , 'disabled' => $disabled );
}
2021-02-23 22:03:23 +01:00
if ( ! empty ( $multiselect )) {
if ( ! is_array ( $selected ) && ! empty ( $selected )) {
$selected = explode ( ',' , $selected );
}
2024-09-25 02:35:56 +02:00
$out .= $form -> multiselectarray ( $htmlname , $newarraylist , $selected , 0 , 0 , 'centpercent' , 0 , 0 , '' , '' , ( is_numeric ( $showempty ) ? '' : $showempty ));
2020-05-21 15:05:19 +02:00
} else {
2024-09-25 02:35:56 +02:00
$out .= $form -> selectarray ( $htmlname , $newarraylist , $selected , $showempty , 0 , 0 , '' , 0 , 0 , 0 , '' , $morecss , 1 );
2015-11-09 17:18:23 +01:00
}
2017-06-10 13:54:43 +02:00
2021-02-23 22:03:23 +01:00
if ( $user -> admin && empty ( $onlyautoornot ) && $hideinfohelp <= 0 ) {
2020-09-07 10:18:17 +02:00
$out .= info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ) . ( $hideinfohelp == - 1 ? " . " . $langs -> trans ( " YouCanSetDefaultValueInModuleSetup " ) : '' ), 1 );
}
2017-06-10 13:54:43 +02:00
2021-02-23 22:03:23 +01:00
if ( $nooutput ) {
return $out ;
} else {
print $out ;
}
2020-09-07 10:18:17 +02:00
return '' ;
}
2010-05-03 10:22:35 +02:00
}