2017-10-11 19:41:45 +02:00
< ? php
/* Copyright ( C ) 2007 - 2017 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-04-20 10:38:16 +02:00
* Copyright ( C ) 2018 Ferran Marcet < fmarcet @ 2 byte . es >
2017-10-11 19:41:45 +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
* the Free Software Foundation ; either version 3 of the License , or
* ( 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 />.
2017-10-11 19:41:45 +02:00
*/
/**
2017-10-13 12:02:26 +02:00
* \file htdocs / admin / mails_senderprofile_list . php
* \ingroup core
* \brief Page to adminsiter email sender profiles
2017-10-11 19:41:45 +02:00
*/
2017-10-13 12:02:26 +02:00
require '../main.inc.php' ;
2018-07-26 11:57:25 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
2017-10-13 12:02:26 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
2017-10-11 19:41:45 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2017-10-13 12:02:26 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/emailsenderprofile.class.php' ;
2017-10-11 19:41:45 +02:00
2018-05-26 18:41:16 +02:00
// Load translation files required by the page
2019-11-12 09:46:08 +01:00
$langs -> loadLangs ( array ( " errors " , " admin " , " mails " , " languages " ));
2017-10-11 19:41:45 +02:00
2019-11-14 11:00:49 +01:00
$action = GETPOST ( 'action' , 'aZ09' ) ? GETPOST ( 'action' , 'aZ09' ) : 'view' ; // The action 'add', 'create', 'edit', 'update', 'view', ...
2019-11-12 09:46:08 +01:00
$massaction = GETPOST ( 'massaction' , 'alpha' ); // The bulk action (combo box choice into lists)
$show_files = GETPOST ( 'show_files' , 'int' ); // Show files area generated by bulk actions ?
$confirm = GETPOST ( 'confirm' , 'alpha' ); // Result of a confirmation
$cancel = GETPOST ( 'cancel' , 'alpha' ); // We click on a Cancel button
$toselect = GETPOST ( 'toselect' , 'array' ); // Array of ids of elements selected into a list
2020-01-20 18:38:53 +01:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'emailsenderprofilelist' ; // To manage different context of search
2019-11-12 09:46:08 +01:00
$backtopage = GETPOST ( 'backtopage' , 'alpha' ); // Go back to a dedicated page
$optioncss = GETPOST ( 'optioncss' , 'aZ' ); // Option for the css output (always '' except when 'print')
2017-10-11 19:41:45 +02:00
2019-11-12 09:46:08 +01:00
$id = GETPOST ( 'id' , 'int' );
2020-08-25 19:40:17 +02:00
$rowid = GETPOST ( 'rowid' , 'alpha' );
2017-10-11 19:41:45 +02:00
// Load variable for pagination
2020-01-20 18:38:53 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2020-09-18 17:13:01 +02:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
2020-09-17 14:31:25 +02:00
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2021-02-26 22:04:03 +01:00
if ( empty ( $page ) || $page == - 1 || GETPOST ( 'button_search' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' ) || ( empty ( $toselect ) && $massaction === '0' )) {
$page = 0 ;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
2017-10-11 19:41:45 +02:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
// Initialize technical objects
2019-11-12 09:46:08 +01:00
$object = new EmailSenderProfile ( $db );
2017-10-11 19:41:45 +02:00
$extrafields = new ExtraFields ( $db );
2019-11-12 09:46:08 +01:00
$diroutputmassaction = $conf -> admin -> dir_output . '/temp/massgeneration/' . $user -> id ;
$hookmanager -> initHooks ( array ( 'emailsenderprofilelist' )); // Note that conf->hooks_modules contains array
2019-09-28 10:55:09 +02:00
2017-10-11 19:41:45 +02: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_' );
2017-10-11 19:41:45 +02:00
// Default sort order (if not yet defined by previous GETPOST)
2021-02-26 22:04:03 +01:00
if ( ! $sortfield ) {
$sortfield = " t. " . key ( $object -> fields ); // Set here default search field. By default 1st field in definition.
}
if ( ! $sortorder ) {
$sortorder = " ASC " ;
}
2017-10-11 19:41:45 +02:00
// Initialize array of search criterias
2020-08-28 21:27:50 +02:00
$search_all = GETPOST ( " search_all " , 'alpha' );
2019-11-12 09:46:08 +01:00
$search = array ();
2021-02-26 22:04:03 +01:00
foreach ( $object -> fields as $key => $val ) {
if ( GETPOST ( 'search_' . $key , 'alpha' )) {
$search [ $key ] = GETPOST ( 'search_' . $key , 'alpha' );
}
2017-10-11 19:41:45 +02:00
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array ();
2021-02-26 22:04:03 +01:00
foreach ( $object -> fields as $key => $val ) {
2021-04-13 16:32:19 +02:00
if ( ! empty ( $val [ 'searchall' ])) {
2021-02-26 22:04:03 +01:00
$fieldstosearchall [ 't.' . $key ] = $val [ 'label' ];
}
2017-10-11 19:41:45 +02:00
}
// Definition of fields for list
2019-11-12 09:46:08 +01:00
$arrayfields = array ();
2021-02-26 22:04:03 +01:00
foreach ( $object -> fields as $key => $val ) {
2017-10-11 19:41:45 +02:00
// If $val['visible']==0, then we never show the field
2021-02-26 22:04:03 +01:00
if ( ! empty ( $val [ 'visible' ])) {
$arrayfields [ 't.' . $key ] = array ( 'label' => $val [ 'label' ], 'checked' => (( $val [ 'visible' ] < 0 ) ? 0 : 1 ), 'enabled' => ( $val [ 'enabled' ] && ( $val [ 'visible' ] != 3 )), 'position' => $val [ 'position' ]);
}
2017-10-11 19:41:45 +02:00
}
// Extra fields
2021-04-13 16:32:19 +02:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && is_array ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) > 0 ) {
2021-02-26 22:04:03 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) {
2019-11-14 11:00:49 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'list' ][ $key ])) {
$arrayfields [ " ef. " . $key ] = array (
'label' => $extrafields -> attributes [ $object -> table_element ][ 'label' ][ $key ],
2020-01-30 01:48:28 +01:00
'checked' => (( $extrafields -> attributes [ $object -> table_element ][ 'list' ][ $key ] < 0 ) ? 0 : 1 ),
2019-11-14 11:00:49 +01:00
'position' => $extrafields -> attributes [ $object -> table_element ][ 'pos' ][ $key ],
2020-01-30 01:48:28 +01:00
'enabled' => ( abs ( $extrafields -> attributes [ $object -> table_element ][ 'list' ][ $key ]) != 3 && $extrafields -> attributes [ $object -> table_element ][ 'perms' ][ $key ])
2019-11-14 11:00:49 +01:00
);
}
2017-10-16 08:47:05 +02:00
}
2017-10-11 19:41:45 +02:00
}
2019-09-02 03:58:00 +02:00
$object -> fields = dol_sort_array ( $object -> fields , 'position' );
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2017-10-11 19:41:45 +02:00
2019-11-14 11:00:49 +01:00
$permissiontoread = $user -> admin ;
$permissiontoadd = $user -> admin ;
$permissiontodelete = $user -> admin ;
2017-10-11 19:41:45 +02:00
2020-08-25 19:40:17 +02:00
if ( $id > 0 ) {
$object -> fetch ( $id );
}
2021-03-19 13:25:58 +01:00
// Security check
$socid = 0 ;
if ( $user -> socid > 0 ) { // Protection if external user
//$socid = $user->socid;
accessforbidden ();
}
// A non admin user can see profiles but limited to its own user
if ( ! $user -> admin ) {
2021-03-19 13:28:04 +01:00
if ( $object -> id > 0 && $object -> private != $user -> id ) {
2021-03-19 13:25:58 +01:00
accessforbidden ();
}
}
2017-10-11 19:41:45 +02:00
/*
2017-10-13 12:02:26 +02:00
* Actions
2017-10-11 19:41:45 +02:00
*/
2021-02-26 22:04:03 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
$action = 'list' ; $massaction = '' ;
}
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) {
$massaction = '' ;
}
2017-10-11 19:41:45 +02:00
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 22:04:03 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2017-10-11 19:41:45 +02:00
2021-02-26 22:04:03 +01:00
if ( empty ( $reshook )) {
2019-11-22 12:22:27 +01:00
// Actions cancel, add, update, delete or clone
$backurlforlist = $_SERVER [ " PHP_SELF " ] . '?action=list' ;
include DOL_DOCUMENT_ROOT . '/core/actions_addupdatedelete.inc.php' ;
2017-10-16 08:47:05 +02:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
2021-02-26 22:04:03 +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
foreach ( $object -> fields as $key => $val ) {
2019-11-12 09:46:08 +01:00
$search [ $key ] = '' ;
2017-10-16 08:47:05 +02:00
}
2022-05-08 18:25:22 +02:00
$toselect = array ();
2019-11-12 09:46:08 +01:00
$search_array_options = array ();
2017-10-16 08:47:05 +02:00
}
2019-01-27 11:55:16 +01:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )
2021-02-26 22:04:03 +01:00
|| GETPOST ( 'button_search_x' , 'alpha' ) || GETPOST ( 'button_search.x' , 'alpha' ) || GETPOST ( 'button_search' , 'alpha' )) {
2019-11-12 09:46:08 +01:00
$massaction = '' ; // Protection to avoid mass action if we force a new search during a mass action confirmation
2017-10-16 08:47:05 +02:00
}
// Mass actions
2019-11-12 09:46:08 +01:00
$objectclass = 'EmailSenderProfile' ;
$objectlabel = 'EmailSenderProfile' ;
2017-10-16 08:47:05 +02:00
$uploaddir = $conf -> admin -> dir_output . '/senderprofiles' ;
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
2019-11-14 11:00:49 +01:00
2021-02-26 22:04:03 +01:00
if ( $action == 'delete' ) {
2019-11-14 11:00:49 +01:00
$sql = " DELETE FROM " . MAIN_DB_PREFIX . " c_email_senderprofile WHERE rowid = " . GETPOST ( 'id' , 'int' );
$resql = $db -> query ( $sql );
if ( $resql ) {
setEventMessages ( $langs -> trans ( " RecordDeleted " ), null , 'mesgs' );
2020-05-21 09:35:30 +02:00
} else {
2019-11-14 11:00:49 +01:00
setEventMessages ( $langs -> trans ( " Error " ) . ' ' . $db -> lasterror (), null , 'errors' );
}
}
2017-10-11 19:41:45 +02:00
}
/*
2017-10-13 12:02:26 +02:00
* View
2017-10-11 19:41:45 +02:00
*/
2019-11-12 09:46:08 +01:00
$form = new Form ( $db );
2017-10-11 19:41:45 +02:00
2019-11-12 09:46:08 +01:00
$now = dol_now ();
2017-10-11 19:41:45 +02:00
//$help_url="EN:Module_EmailSenderProfile|FR:Module_EmailSenderProfile_FR|ES:Módulo_EmailSenderProfile";
2019-11-12 09:46:08 +01:00
$help_url = '' ;
2019-11-14 11:00:49 +01:00
$title = $langs -> trans ( " EMailsSetup " );
2017-10-11 19:41:45 +02:00
2020-01-20 18:38:53 +01:00
llxHeader ( '' , $title );
2017-10-13 12:02:26 +02:00
2019-11-12 09:46:08 +01:00
$linkback = '' ;
$titlepicto = 'title_setup' ;
2017-10-13 12:02:26 +02:00
2019-11-14 11:00:49 +01:00
print load_fiche_titre ( $title , $linkback , $titlepicto );
2017-10-13 12:02:26 +02:00
$head = email_admin_prepare_head ();
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'senderprofiles' , '' , - 1 );
2017-10-13 12:02:26 +02:00
2019-11-14 11:00:49 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " EMailsSenderProfileDesc " ) . " </span><br> \n " ;
print " <br> \n " ;
2017-10-11 19:41:45 +02:00
// Build and execute select
// --------------------------------------------------------------------
$sql = 'SELECT ' ;
2021-02-26 22:04:03 +01:00
foreach ( $object -> fields as $key => $val ) {
2021-08-27 22:42:04 +02:00
$sql .= " t. " . $key . " , " ;
2017-10-11 19:41:45 +02:00
}
// Add fields from extrafields
2019-11-14 11:00:49 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-26 22:04:03 +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-26 22:04:03 +01:00
}
2019-11-14 11:00:49 +01:00
}
2017-10-11 19:41:45 +02:00
// Add fields from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2019-11-14 11:00:49 +01:00
$sql .= preg_replace ( '/^,/' , '' , $hookmanager -> resPrint );
2019-11-12 09:46:08 +01:00
$sql = preg_replace ( '/,\s*$/' , '' , $sql );
$sql .= " FROM " . MAIN_DB_PREFIX . $object -> table_element . " as t " ;
2021-04-13 16:32:19 +02:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && is_array ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-26 22:04:03 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object -> table_element . " _extrafields as ef on (t.rowid = ef.fk_object) " ;
}
if ( $object -> ismultientitymanaged == 1 ) {
$sql .= " WHERE t.entity IN ( " . getEntity ( $object -> element ) . " ) " ;
} else {
$sql .= " WHERE 1 = 1 " ;
}
foreach ( $search as $key => $val ) {
if ( $key == 'status' && $search [ $key ] == - 1 ) {
continue ;
}
2019-11-12 09:46:08 +01:00
$mode_search = (( $object -> isInt ( $object -> fields [ $key ]) || $object -> isFloat ( $object -> fields [ $key ])) ? 1 : 0 );
2020-08-25 19:40:17 +02:00
if ( strpos ( $object -> fields [ $key ][ 'type' ], 'integer:' ) === 0 || $key == 'active' ) {
2021-02-26 22:04:03 +01:00
if ( $search [ $key ] == '-1' ) {
$search [ $key ] = '' ;
}
2020-01-20 18:38:53 +01:00
$mode_search = 2 ;
}
2021-02-26 22:04:03 +01:00
if ( $search [ $key ] != '' ) {
$sql .= natural_search ( $key , $search [ $key ], (( $key == 'status' ) ? 2 : $mode_search ));
}
}
if ( $search_all ) {
$sql .= natural_search ( array_keys ( $fieldstosearchall ), $search_all );
2017-10-11 19:41:45 +02:00
}
2021-03-19 13:25:58 +01:00
// If non admin, restrict list to itself
if ( empty ( $user -> admin )) {
$sql .= " AND private = " . (( int ) $user -> id );
}
2019-11-14 11:00:49 +01:00
//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
2017-10-11 19:41:45 +02: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' ;
2017-10-11 19:41:45 +02:00
// Add where from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters , $object ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2017-10-11 19:41:45 +02:00
/* If a group by is required
$sql .= " GROUP BY "
foreach ( $object -> fields as $key => $val )
{
2021-08-27 22:42:04 +02:00
$sql .= " t. " . $key . " , " ;
2017-10-11 19:41:45 +02:00
}
// Add fields from extrafields
2022-08-31 22:14:20 +02:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2019-10-08 09:28:50 +02:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) $sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " ef. " . $key . ', ' : '' );
2020-01-20 18:38:53 +01:00
}
2017-10-11 19:41:45 +02:00
// Add where from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListGroupBy' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2019-11-14 11:00:49 +01:00
$sql = preg_replace ( '/,\s*$/' , '' , $sql );
2017-10-11 19:41:45 +02:00
*/
2019-11-12 09:46:08 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2017-10-11 19:41:45 +02:00
// Count total nb of records
$nbtotalofrecords = '' ;
2021-02-26 22:04:03 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST )) {
2019-11-14 11:00:49 +01:00
$resql = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $resql );
2021-02-26 22:04:03 +01:00
if (( $page * $limit ) > $nbtotalofrecords ) { // if total of record found is smaller than page * limit, goto and load page 0
2018-04-24 11:37:57 +02:00
$page = 0 ;
$offset = 0 ;
}
2017-10-11 19:41:45 +02:00
}
2019-11-14 11:00:49 +01:00
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
2021-02-26 22:04:03 +01:00
if ( is_numeric ( $nbtotalofrecords ) && ( $limit > $nbtotalofrecords || empty ( $limit ))) {
2019-11-14 11:00:49 +01:00
$num = $nbtotalofrecords ;
2020-05-21 09:35:30 +02:00
} else {
2021-02-26 22:04:03 +01:00
if ( $limit ) {
$sql .= $db -> plimit ( $limit + 1 , $offset );
}
2019-11-14 11:00:49 +01:00
$resql = $db -> query ( $sql );
2021-02-26 22:04:03 +01:00
if ( ! $resql ) {
2019-11-14 11:00:49 +01:00
dol_print_error ( $db );
exit ;
}
2017-10-11 19:41:45 +02:00
2019-11-14 11:00:49 +01:00
$num = $db -> num_rows ( $resql );
}
2017-10-11 19:41:45 +02:00
2019-11-14 11:00:49 +01:00
// Output page
// --------------------------------------------------------------------
2017-10-11 19:41:45 +02:00
2019-11-12 09:46:08 +01:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2017-10-11 19:41:45 +02:00
2019-11-12 09:46:08 +01:00
$param = '' ;
2021-02-26 22:04:03 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
$param .= '&limit=' . urlencode ( $limit );
}
foreach ( $search as $key => $val ) {
if ( is_array ( $search [ $key ]) && count ( $search [ $key ])) {
foreach ( $search [ $key ] as $skey ) {
$param .= '&search_' . $key . '[]=' . urlencode ( $skey );
}
} else {
$param .= '&search_' . $key . '=' . urlencode ( $search [ $key ]);
}
}
if ( $optioncss != '' ) {
$param .= '&optioncss=' . urlencode ( $optioncss );
2017-10-11 19:41:45 +02: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' ;
2017-10-11 19:41:45 +02:00
// List of mass actions available
2019-11-12 09:46:08 +01:00
$arrayofmassactions = array (
2021-04-14 14:45:55 +02:00
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
2017-10-11 19:41:45 +02:00
);
2021-04-14 14:45:55 +02:00
//if ($permissiontodelete) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
2019-11-14 11:00:49 +01:00
//if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
2019-11-12 09:46:08 +01:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2017-10-11 19:41:45 +02:00
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2021-02-26 22:04:03 +01:00
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-11 19:41:45 +02:00
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
2020-08-25 19:40:17 +02:00
print '<input type="hidden" name="action" value="' . ( $action == 'create' ? 'add' : ( $action == 'edit' ? 'update' : 'list' )) . '">' ;
2017-10-11 19:41:45 +02:00
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
print '<input type="hidden" name="page" value="' . $page . '">' ;
2020-08-25 19:40:17 +02:00
print '<input type="hidden" name="id" value="' . $id . '">' ;
2017-10-11 19:41:45 +02:00
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2019-11-14 11:00:49 +01:00
$newcardbutton = '' ;
2019-11-14 11:53:28 +01:00
if ( $action != 'create' ) {
$newcardbutton = dolGetButtonTitle ( $langs -> trans ( 'New' ), '' , 'fa fa-plus-circle' , $_SERVER [ 'PHP_SELF' ] . '?action=create' , '' , $permissiontoadd );
2020-08-25 19:40:17 +02:00
if ( $action == 'edit' ) {
print '<table class="border centpercent tableforfield">' ;
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Label " ) . '</td><td><input type="text" name="label" value="' . ( GETPOSTISSET ( 'label' ) ? GETPOST ( 'label' , 'alphanohtml' ) : $object -> label ) . '"></td></tr>' ;
print '<tr><td>' . $langs -> trans ( " Email " ) . '</td><td><input type="text" name="email" value="' . ( GETPOSTISSET ( 'email' ) ? GETPOST ( 'email' , 'alphanohtml' ) : $object -> email ) . '"></td></tr>' ;
print '<tr><td>' . $langs -> trans ( " Signature " ) . '</td><td>' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
$doleditor = new DolEditor ( 'signature' , ( GETPOSTISSET ( 'signature' ) ? GETPOST ( 'signature' , 'restricthtml' ) : $object -> signature ), '' , 138 , 'dolibarr_notes' , 'In' , true , true , empty ( $conf -> global -> FCKEDITOR_ENABLE_USERSIGN ) ? 0 : 1 , ROWS_4 , '90%' );
print $doleditor -> Create ( 1 );
print '</td></tr>' ;
print '<tr><td>' . $langs -> trans ( " User " ) . '</td><td>' ;
print $form -> select_dolusers (( GETPOSTISSET ( 'private' ) ? GETPOST ( 'private' , 'int' ) : $object -> private ), 'private' , 1 , null , 0 , ( $user -> admin ? '' : $user -> id ));
print '</td></tr>' ;
print '<tr><td>' . $langs -> trans ( " Position " ) . '</td><td><input type="text" name="position" class="maxwidth50" value="' . ( GETPOSTISSET ( 'position' ) ? GETPOST ( 'position' , 'int' ) : $object -> position ) . '"></td></tr>' ;
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td><td>' ;
print $form -> selectarray ( 'active' , $object -> fields [ 'active' ][ 'arrayofkeyval' ], ( GETPOSTISSET ( 'active' ) ? GETPOST ( 'active' , 'int' ) : $object -> active ), 0 , 0 , 0 , '' , 1 );
print '</td></tr>' ;
print '</table>' ;
2021-08-20 14:41:30 +02:00
print $form -> buttonsSaveCancel ();
2020-08-25 19:40:17 +02:00
}
2019-11-14 11:53:28 +01:00
} else {
2019-11-22 12:40:17 +01:00
/* print '<form method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2019-11-14 11:53:28 +01:00
if ( $optioncss != '' ) print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-11-14 11:53:28 +01:00
print '<input type="hidden" name="action" value="add">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
print '<input type="hidden" name="page" value="' . $page . '">' ;
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2019-11-22 12:40:17 +01:00
*/
2019-11-14 11:53:28 +01:00
print '<table class="border centpercent tableforfield">' ;
2021-07-11 20:04:16 +02:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Label " ) . '</td><td><input type="text" name="label" value="' . GETPOST ( 'label' , 'alphanohtml' ) . '" autofocus></td></tr>' ;
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Email " ) . '</td><td><input type="text" name="email" value="' . GETPOST ( 'email' , 'alphanohtml' ) . '"></td></tr>' ;
2019-11-22 12:22:27 +01:00
print '<tr><td>' . $langs -> trans ( " Signature " ) . '</td><td>' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
$doleditor = new DolEditor ( 'signature' , GETPOST ( 'signature' ), '' , 138 , 'dolibarr_notes' , 'In' , true , true , empty ( $conf -> global -> FCKEDITOR_ENABLE_USERSIGN ) ? 0 : 1 , ROWS_4 , '90%' );
print $doleditor -> Create ( 1 );
print '</td></tr>' ;
2020-01-20 18:38:53 +01:00
print '<tr><td>' . $langs -> trans ( " User " ) . '</td><td>' ;
print $form -> select_dolusers (( GETPOSTISSET ( 'private' ) ? GETPOST ( 'private' , 'int' ) : - 1 ), 'private' , 1 , null , 0 , ( $user -> admin ? '' : $user -> id ));
print '</td></tr>' ;
2019-11-22 12:40:17 +01:00
print '<tr><td>' . $langs -> trans ( " Position " ) . '</td><td><input type="text" name="position" class="maxwidth50" value="' . GETPOST ( 'position' , 'int' ) . '"></td></tr>' ;
2019-11-14 11:53:28 +01:00
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td><td>' ;
2020-01-20 23:58:01 +01:00
print $form -> selectarray ( 'active' , $object -> fields [ 'active' ][ 'arrayofkeyval' ], GETPOST ( 'active' , 'int' ), 0 );
2019-11-14 11:53:28 +01:00
print '</td></tr>' ;
print '</table>' ;
2021-08-20 14:41:30 +02:00
print $form -> buttonsSaveCancel ();
2019-11-22 12:40:17 +01:00
//print '</form>';
2019-11-14 11:53:28 +01:00
}
2019-11-14 11:00:49 +01:00
print_barre_liste ( '' , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'title_companies' , 0 , $newcardbutton , '' , $limit );
2017-10-13 12:02:26 +02:00
//print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit);
2017-10-11 19:41:45 +02:00
2019-11-12 09:46:08 +01:00
$topicmail = " Information " ;
2017-11-15 11:39:11 +01:00
//$modelmail="subscription";
2019-11-12 09:46:08 +01:00
$objecttmp = new EmailSenderProfile ( $db );
2020-11-08 14:39:20 +01:00
//$trackid = (($action == 'testhtml') ? "testhtml" : "test");
2017-11-15 11:39:11 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2021-02-26 22:04:03 +01:00
if ( $search_all ) {
foreach ( $fieldstosearchall as $key => $val ) {
$fieldstosearchall [ $key ] = $langs -> trans ( $val );
}
2019-11-14 11:00:49 +01:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $search_all ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
}
2017-10-11 19:41:45 +02:00
$moreforfilter = '' ;
2017-10-13 12:02:26 +02:00
/* $moreforfilter .= '<div class="divsearchfield">' ;
2017-10-11 19:41:45 +02:00
$moreforfilter .= $langs -> trans ( 'MyFilter' ) . ': <input type="text" name="search_myfield" value="' . dol_escape_htmltag ( $search_myfield ) . '">' ;
2017-10-13 12:02:26 +02:00
$moreforfilter .= '</div>' ; */
2017-10-11 19:41:45 +02:00
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2021-02-26 22:04:03 +01:00
if ( empty ( $reshook )) {
$moreforfilter .= $hookmanager -> resPrint ;
} else {
$moreforfilter = $hookmanager -> resPrint ;
}
2017-10-11 19:41:45 +02:00
2021-02-26 22:04:03 +01:00
if ( ! empty ( $moreforfilter )) {
2017-10-11 19:41:45 +02:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
2017-10-16 08:47:05 +02:00
print '</div>' ;
2017-10-11 19:41:45 +02:00
}
2019-11-12 09:46:08 +01:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
$selectedfields .= ( count ( $arrayofmassactions ) ? $form -> showCheckAddButtons ( 'checkforselect' , 1 ) : '' );
2017-10-11 19:41:45 +02:00
2019-11-12 09:46:08 +01:00
print '<div class="div-table-responsive">' ; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2017-10-11 19:41:45 +02:00
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre">' ;
2021-02-26 22:04:03 +01:00
foreach ( $object -> fields as $key => $val ) {
2019-11-14 11:00:49 +01:00
$cssforfield = ( empty ( $val [ 'css' ]) ? '' : $val [ 'css' ]);
2021-02-26 22:04:03 +01:00
if ( $key == 'status' ) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'center' ;
} elseif ( in_array ( $val [ 'type' ], array ( 'date' , 'datetime' , 'timestamp' ))) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'center' ;
} elseif ( in_array ( $val [ 'type' ], array ( 'timestamp' ))) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'nowrap' ;
} elseif ( in_array ( $val [ 'type' ], array ( 'double(24,8)' , 'double(6,3)' , 'integer' , 'real' , 'price' )) && $val [ 'label' ] != 'TechnicalID' ) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'right' ;
}
if ( ! empty ( $arrayfields [ 't.' . $key ][ 'checked' ])) {
2019-11-14 11:00:49 +01:00
print '<td class="liste_titre' . ( $cssforfield ? ' ' . $cssforfield : '' ) . '">' ;
2021-02-26 22:04:03 +01:00
if ( ! empty ( $val [ 'arrayofkeyval' ]) && is_array ( $val [ 'arrayofkeyval' ])) {
2021-04-13 16:32:19 +02:00
print $form -> selectarray ( 'search_' . $key , $val [ 'arrayofkeyval' ], empty ( $search [ $key ]) ? '' : $search [ $key ], $val [ 'notnull' ], 0 , 0 , '' , 1 , 0 , 0 , '' , 'maxwidth100' , 1 );
2021-02-26 22:04:03 +01:00
} elseif ( strpos ( $val [ 'type' ], 'integer:' ) === 0 ) {
2021-07-08 12:17:32 +02:00
print $object -> showInputField ( $val , $key , empty ( $search [ $key ]) ? '' : $search [ $key ], '' , '' , 'search_' , 'maxwidth150' , 1 );
2021-02-26 22:04:03 +01:00
} elseif ( ! preg_match ( '/^(date|timestamp)/' , $val [ 'type' ])) {
2021-04-13 16:32:19 +02:00
print '<input type="text" class="flat maxwidth75" name="search_' . $key . '" value="' . dol_escape_htmltag ( empty ( $search [ $key ]) ? '' : $search [ $key ]) . '">' ;
2021-02-26 22:04:03 +01:00
}
2019-11-14 11:00:49 +01:00
print '</td>' ;
}
2017-10-11 19:41:45 +02:00
}
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
2017-10-11 19:41:45 +02:00
// Fields from hook
2019-11-12 09:46:08 +01:00
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2017-10-11 19:41:45 +02:00
print $hookmanager -> resPrint ;
// Action column
2019-05-19 13:51:47 +02:00
print '<td class="liste_titre maxwidthsearch">' ;
2019-11-12 09:46:08 +01:00
$searchpicto = $form -> showFilterButtons ();
2017-10-11 19:41:45 +02:00
print $searchpicto ;
print '</td>' ;
print '</tr>' . " \n " ;
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">' ;
2021-02-26 22:04:03 +01:00
foreach ( $object -> fields as $key => $val ) {
2019-11-14 11:00:49 +01:00
$cssforfield = ( empty ( $val [ 'css' ]) ? '' : $val [ 'css' ]);
2021-02-26 22:04:03 +01:00
if ( $key == 'status' ) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'center' ;
} elseif ( in_array ( $val [ 'type' ], array ( 'date' , 'datetime' , 'timestamp' ))) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'center' ;
} elseif ( in_array ( $val [ 'type' ], array ( 'timestamp' ))) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'nowrap' ;
} elseif ( in_array ( $val [ 'type' ], array ( 'double(24,8)' , 'double(6,3)' , 'integer' , 'real' , 'price' )) && $val [ 'label' ] != 'TechnicalID' ) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'right' ;
}
if ( ! empty ( $arrayfields [ 't.' . $key ][ 'checked' ])) {
2019-11-14 11:00:49 +01:00
print getTitleFieldOfList ( $arrayfields [ 't.' . $key ][ 'label' ], 0 , $_SERVER [ 'PHP_SELF' ], 't.' . $key , '' , $param , ( $cssforfield ? 'class="' . $cssforfield . '"' : '' ), $sortfield , $sortorder , ( $cssforfield ? $cssforfield . ' ' : '' )) . " \n " ;
}
2017-10-11 19:41:45 +02:00
}
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
2017-10-11 19:41:45 +02:00
// Hook fields
2019-11-12 09:46:08 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2017-10-11 19:41:45 +02:00
print $hookmanager -> resPrint ;
2019-11-14 11:00:49 +01:00
// Action column
print getTitleFieldOfList ( $selectedfields , 0 , $_SERVER [ " PHP_SELF " ], '' , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' ) . " \n " ;
2017-10-11 19:41:45 +02:00
print '</tr>' . " \n " ;
// Detect if we need a fetch on each output line
2019-11-12 09:46:08 +01:00
$needToFetchEachLine = 0 ;
2021-04-13 16:32:19 +02:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ]) && is_array ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ]) > 0 ) {
2021-02-26 22:04:03 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ] as $key => $val ) {
if ( preg_match ( '/\$object/' , $val )) {
$needToFetchEachLine ++ ; // There is at least one compute field that use $object
}
2019-11-14 11:00:49 +01:00
}
2017-10-11 19:41:45 +02:00
}
// Loop on record
// --------------------------------------------------------------------
2019-11-12 09:46:08 +01:00
$i = 0 ;
$totalarray = array ();
2022-08-10 14:29:13 +02:00
$totalarray [ 'nbfield' ] = 0 ;
2021-02-26 22:04:03 +01:00
while ( $i < ( $limit ? min ( $num , $limit ) : $num )) {
2017-10-16 08:47:05 +02:00
$obj = $db -> fetch_object ( $resql );
2021-02-26 22:04:03 +01:00
if ( empty ( $obj )) {
break ; // Should not happen
}
2017-10-11 19:41:45 +02:00
2017-10-16 08:47:05 +02:00
// Store properties in $object
2020-01-20 18:38:53 +01:00
$object -> setVarsFromFetchObj ( $obj );
2017-10-11 19:41:45 +02:00
2017-10-16 08:47:05 +02:00
// Show here line of result
print '<tr class="oddeven">' ;
2021-02-26 22:04:03 +01:00
foreach ( $object -> fields as $key => $val ) {
2019-11-14 11:00:49 +01:00
$cssforfield = ( empty ( $val [ 'css' ]) ? '' : $val [ 'css' ]);
2021-02-26 22:04:03 +01:00
if ( in_array ( $val [ 'type' ], array ( 'date' , 'datetime' , 'timestamp' ))) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'center' ;
} elseif ( $key == 'status' ) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'center' ;
}
2019-11-14 11:00:49 +01:00
2021-02-26 22:04:03 +01:00
if ( in_array ( $val [ 'type' ], array ( 'timestamp' ))) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'nowrap' ;
} elseif ( $key == 'ref' ) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'nowrap' ;
}
2019-11-14 11:00:49 +01:00
2021-02-26 22:04:03 +01:00
if ( in_array ( $val [ 'type' ], array ( 'double(24,8)' , 'double(6,3)' , 'integer' , 'real' , 'price' )) && $key != 'status' ) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'right' ;
}
2019-11-14 11:00:49 +01:00
2021-02-26 22:04:03 +01:00
if ( ! empty ( $arrayfields [ 't.' . $key ][ 'checked' ])) {
2019-11-14 11:00:49 +01:00
print '<td' . ( $cssforfield ? ' class="' . $cssforfield . '"' : '' ) . '>' ;
2021-02-26 22:04:03 +01:00
if ( $key == 'status' || $key == 'active' ) {
print $object -> getLibStatut ( 5 );
} else {
print $object -> showOutputField ( $val , $key , $object -> $key , '' );
}
2017-11-25 18:52:47 +01:00
print '</td>' ;
2021-02-26 22:04:03 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-10-19 16:26:43 +02:00
if ( ! empty ( $val [ 'isameasure' ]) && $val [ 'isameasure' ] == 1 ) {
2021-02-26 22:04:03 +01:00
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 't.' . $key ;
}
2021-06-14 01:55:58 +02:00
if ( ! isset ( $totalarray [ 'val' ])) {
$totalarray [ 'val' ] = array ();
}
if ( ! isset ( $totalarray [ 'val' ][ 't.' . $key ])) {
$totalarray [ 'val' ][ 't.' . $key ] = 0 ;
}
2020-01-20 18:38:53 +01:00
$totalarray [ 'val' ][ 't.' . $key ] += $object -> $key ;
2017-10-16 08:47:05 +02:00
}
2017-11-25 18:52:47 +01:00
}
2017-10-16 08:47:05 +02:00
}
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
2017-10-16 08:47:05 +02:00
// Fields from hook
2020-01-20 18:38:53 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'object' => $object , 'obj' => $obj , 'i' => $i , 'totalarray' =>& $totalarray );
2019-11-12 09:46:08 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2017-10-16 08:47:05 +02:00
print $hookmanager -> resPrint ;
// Action column
2019-11-14 11:00:49 +01:00
print '<td class="nowrap center">' ;
2020-08-25 19:40:17 +02:00
$url = $_SERVER [ " PHP_SELF " ] . '?id=' . $obj -> rowid ;
2021-02-26 22:04:03 +01:00
if ( $limit ) {
$url .= '&limit=' . urlencode ( $limit );
}
if ( $page ) {
$url .= '&page=' . urlencode ( $page );
}
if ( $sortfield ) {
$url .= '&sortfield=' . urlencode ( $sortfield );
}
if ( $sortorder ) {
$url .= '&page=' . urlencode ( $sortorder );
}
2021-09-27 12:24:01 +02:00
print '<a class="editfielda reposition marginrightonly marginleftonly" href="' . $url . '&action=edit&token=' . newToken () . '&rowid=' . $obj -> rowid . '">' . img_edit () . '</a>' ;
2019-11-14 11:00:49 +01:00
//print ' ';
2020-10-01 10:50:54 +02:00
print '<a class=" marginrightonly marginleftonly" href="' . $url . '&action=delete&token=' . newToken () . '">' . img_delete () . '</a> ' ;
2021-02-26 22:04:03 +01:00
if ( $massactionbutton || $massaction ) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2019-11-12 09:46:08 +01:00
$selected = 0 ;
2021-02-26 22:04:03 +01:00
if ( in_array ( $object -> id , $arrayofselected )) {
$selected = 1 ;
}
2020-01-20 18:38:53 +01:00
print '<input id="cb' . $object -> id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $object -> rowid . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
2017-10-16 08:47:05 +02:00
}
2017-10-11 19:41:45 +02:00
print '</td>' ;
2021-02-26 22:04:03 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-11 19:41:45 +02:00
2019-11-14 11:00:49 +01:00
print '</tr>' . " \n " ;
2017-10-11 19:41:45 +02:00
2017-10-16 08:47:05 +02:00
$i ++ ;
2017-10-11 19:41:45 +02:00
}
// Show total line
2019-11-05 12:47:38 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php' ;
2017-10-11 19:41:45 +02:00
// If no record found
2021-02-26 22:04:03 +01:00
if ( $num == 0 ) {
2019-11-12 09:46:08 +01:00
$colspan = 1 ;
2021-02-26 22:04:03 +01:00
foreach ( $arrayfields as $key => $val ) {
if ( ! empty ( $val [ 'checked' ])) {
$colspan ++ ;
}
}
2017-10-16 08:47:05 +02:00
print '<tr><td colspan="' . $colspan . '" class="opacitymedium">' . $langs -> trans ( " NoRecordFound " ) . '</td></tr>' ;
2017-10-11 19:41:45 +02:00
}
$db -> free ( $resql );
2019-11-12 09:46:08 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2017-10-11 19:41:45 +02:00
print $hookmanager -> resPrint ;
print '</table>' . " \n " ;
print '</div>' . " \n " ;
print '</form>' . " \n " ;
2021-02-26 22:04:03 +01:00
if ( in_array ( 'builddoc' , $arrayofmassactions ) && ( $nbtotalofrecords === '' || $nbtotalofrecords )) {
2019-11-12 09:46:08 +01:00
$hidegeneratedfilelistifempty = 1 ;
2021-02-26 22:04:03 +01:00
if ( $massaction == 'builddoc' || $action == 'remove_file' || $show_files ) {
$hidegeneratedfilelistifempty = 0 ;
}
2017-10-16 08:47:05 +02:00
2019-11-14 11:00:49 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
$formfile = new FormFile ( $db );
2018-02-21 11:02:45 +01:00
// Show list of available documents
2019-11-12 09:46:08 +01:00
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder ;
$urlsource .= str_replace ( '&' , '&' , $param );
2017-10-16 08:47:05 +02:00
2019-11-12 09:46:08 +01:00
$filedir = $diroutputmassaction ;
2019-11-14 11:00:49 +01:00
$genallowed = $permissiontoread ;
$delallowed = $permissiontoadd ;
2018-02-21 11:02:45 +01:00
2019-11-14 11:00:49 +01:00
print $formfile -> showdocuments ( 'massfilesarea_emailsenderprofile' , '' , $filedir , $urlsource , 0 , $delallowed , '' , 1 , 1 , 0 , 48 , 1 , $param , $title , '' , '' , '' , null , $hidegeneratedfilelistifempty );
2017-10-11 19:41:45 +02:00
}
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2017-10-13 12:02:26 +02:00
2017-10-11 19:41:45 +02:00
// End of page
llxFooter ();
$db -> close ();