2017-05-10 13:30:35 +02:00
< ? php
2024-11-04 23:53:20 +01:00
/* Copyright ( C ) 2007 - 2017 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2024 Frédéric France < frederic . france @ free . fr >
2024-08-18 18:16:08 +02:00
* Copyright ( C ) --- Replace with your own copyright and developer email ---
2017-05-10 13:30:35 +02:00
*
2017-05-27 13:46:34 +02:00
* This program is free software ; you can redistribute it and / or modify
2017-05-10 13:30:35 +02:00
* it under the terms of the GNU General Public License as published by
2017-05-27 13:46:34 +02:00
* the Free Software Foundation ; either version 3 of the License , or
2017-05-10 13:30: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 />.
2017-05-10 13:30:35 +02:00
*/
/**
2017-05-27 13:46:34 +02:00
* \file htdocs / modulebuilder / template / myobject_list . php
2017-07-25 00:00:08 +02:00
* \ingroup mymodule
2017-07-25 01:21:20 +02:00
* \brief List page for myobject
2017-05-10 13:30:35 +02:00
*/
2023-09-09 12:38:56 +02:00
// General defined Options
//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
//if (! defined('MAIN_AUTHENTICATION_MODE')) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
//if (! defined('MAIN_LANG_DEFAULT')) define('MAIN_LANG_DEFAULT', 'auto'); // Force LANG (language) to a particular value
//if (! defined('MAIN_SECURITY_FORCECSP')) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
//if (! defined('NOLOGIN')) define('NOLOGIN', '1'); // Do not use login - if this page is public (can be called outside logged session). This includes the NOIPCHECK too.
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // Do not load html.form.class.php
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // Do not load and show top and left menu
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
//if (! defined('NOSESSION')) define('NOSESSION', '1'); // On CLI mode, no need to use web sessions
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
2017-05-10 13:30:35 +02:00
2017-06-23 20:03:15 +02:00
// Load Dolibarr environment
2019-11-12 09:46:08 +01:00
$res = 0 ;
2017-06-23 20:03:15 +02:00
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
2021-02-26 18:26:44 +01:00
if ( ! $res && ! empty ( $_SERVER [ " CONTEXT_DOCUMENT_ROOT " ])) {
$res = @ include $_SERVER [ " CONTEXT_DOCUMENT_ROOT " ] . " /main.inc.php " ;
}
2018-05-23 17:16:58 +02:00
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
2024-08-18 18:16:08 +02:00
$tmp = empty ( $_SERVER [ 'SCRIPT_FILENAME' ]) ? '' : $_SERVER [ 'SCRIPT_FILENAME' ];
$tmp2 = realpath ( __FILE__ );
$i = strlen ( $tmp ) - 1 ;
$j = strlen ( $tmp2 ) - 1 ;
2021-02-26 18:26:44 +01:00
while ( $i > 0 && $j > 0 && isset ( $tmp [ $i ]) && isset ( $tmp2 [ $j ]) && $tmp [ $i ] == $tmp2 [ $j ]) {
2022-07-31 20:12:22 +02:00
$i -- ;
$j -- ;
2021-02-26 18:26:44 +01:00
}
if ( ! $res && $i > 0 && file_exists ( substr ( $tmp , 0 , ( $i + 1 )) . " /main.inc.php " )) {
$res = @ include substr ( $tmp , 0 , ( $i + 1 )) . " /main.inc.php " ;
}
if ( ! $res && $i > 0 && file_exists ( dirname ( substr ( $tmp , 0 , ( $i + 1 ))) . " /main.inc.php " )) {
$res = @ include dirname ( substr ( $tmp , 0 , ( $i + 1 ))) . " /main.inc.php " ;
}
2017-06-23 20:03:15 +02:00
// Try main.inc.php using relative path
2021-02-26 18:26:44 +01:00
if ( ! $res && file_exists ( " ../main.inc.php " )) {
$res = @ include " ../main.inc.php " ;
}
if ( ! $res && file_exists ( " ../../main.inc.php " )) {
$res = @ include " ../../main.inc.php " ;
}
if ( ! $res && file_exists ( " ../../../main.inc.php " )) {
$res = @ include " ../../../main.inc.php " ;
}
if ( ! $res ) {
die ( " Include of main fails " );
}
2017-06-23 20:03:15 +02:00
2018-07-26 11:50:54 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
2017-05-10 13:30:35 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2017-05-27 13:46:34 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2023-03-05 15:29:41 +01:00
// load module libraries
2019-11-12 09:46:08 +01:00
require_once __DIR__ . '/class/myobject.class.php' ;
2019-04-18 09:33:47 +02:00
// for other modules
//dol_include_once('/othermodule/class/otherobject.class.php');
2017-05-10 13:30:35 +02:00
2024-11-04 23:53:20 +01:00
/**
* @ var Conf $conf
* @ var DoliDB $db
* @ var HookManager $hookmanager
* @ var Translate $langs
* @ var User $user
*/
2018-05-26 17:57:30 +02:00
// Load translation files required by the page
2019-11-12 09:46:08 +01:00
$langs -> loadLangs ( array ( " mymodule@mymodule " , " other " ));
2017-05-10 13:30:35 +02:00
2023-08-31 23:26:07 +02:00
// Get parameters
2023-01-14 11:43:47 +01:00
$action = GETPOST ( 'action' , 'aZ09' ) ? GETPOST ( 'action' , 'aZ09' ) : 'view' ; // The action 'create'/'add', 'edit'/'update', 'view', ...
2019-11-12 09:46:08 +01:00
$massaction = GETPOST ( 'massaction' , 'alpha' ); // The bulk action (combo box choice into lists)
2024-08-18 18:16:08 +02:00
$show_files = GETPOSTINT ( 'show_files' ); // Show files area generated by bulk actions ?
2019-11-12 09:46:08 +01:00
$confirm = GETPOST ( 'confirm' , 'alpha' ); // Result of a confirmation
$cancel = GETPOST ( 'cancel' , 'alpha' ); // We click on a Cancel button
2024-05-08 00:23:25 +02:00
$toselect = GETPOST ( 'toselect' , 'array:int' ); // Array of ids of elements selected into a list
2022-07-07 17:14:21 +02:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : str_replace ( '_' , '' , basename ( dirname ( __FILE__ )) . basename ( __FILE__ , '.php' )); // To manage different context of search
2019-11-12 09:46:08 +01:00
$backtopage = GETPOST ( 'backtopage' , 'alpha' ); // Go back to a dedicated page
2022-02-09 13:22:23 +01:00
$optioncss = GETPOST ( 'optioncss' , 'aZ' ); // Option for the css output (always '' except when 'print')
2024-07-02 18:46:20 +02:00
$mode = GETPOST ( 'mode' , 'aZ' ); // The display mode ('list', 'kanban', 'hierarchy', 'calendar', 'gantt', ...)
$groupby = GETPOST ( 'groupby' , 'aZ09' ); // Example: $groupby = 'p.fk_opp_status' or $groupby = 'p.fk_statut'
2017-05-10 13:30:35 +02:00
2024-06-19 02:58:06 +02:00
$id = GETPOSTINT ( 'id' );
2022-07-31 20:12:22 +02:00
$ref = GETPOST ( 'ref' , 'alpha' );
2017-05-10 13:30:35 +02:00
// Load variable for pagination
2024-03-16 11:41:00 +01:00
$limit = GETPOSTINT ( 'limit' ) ? GETPOSTINT ( 'limit' ) : $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' );
2024-02-19 16:58:59 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOSTINT ( 'pageplusone' ) - 1 ) : GETPOSTINT ( 'page' );
2021-01-06 20:54:20 +01:00
if ( empty ( $page ) || $page < 0 || GETPOST ( 'button_search' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) {
2021-06-10 00:00:49 +02:00
// If $page is not defined, or '' or -1 or if we click on clear filters
2021-01-06 20:54:20 +01:00
$page = 0 ;
2021-06-10 00:00:49 +02:00
}
2017-05-10 13:30:35 +02:00
$offset = $limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2017-07-11 20:47:49 +02:00
2024-09-25 19:30:37 +02:00
// Initialize technical objects
2019-01-03 11:47:27 +01:00
$object = new MyObject ( $db );
2017-07-12 13:25:18 +02:00
$extrafields = new ExtraFields ( $db );
2019-11-12 09:46:08 +01:00
$diroutputmassaction = $conf -> mymodule -> dir_output . '/temp/massgeneration/' . $user -> id ;
2023-01-25 15:27:10 +01:00
$hookmanager -> initHooks ( array ( $contextpage )); // Note that conf->hooks_modules contains array of activated contexes
2019-09-28 10:55:09 +02:00
2017-07-12 13:25:18 +02:00
// Fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
//$extrafields->fetch_name_optionals_label($object->table_element_line);
2019-09-28 10:55:09 +02:00
2019-01-27 11:55:16 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $object -> table_element , '' , 'search_' );
2017-07-12 01:55:07 +02:00
// Default sort order (if not yet defined by previous GETPOST)
2021-01-06 20:54:20 +01:00
if ( ! $sortfield ) {
2021-01-22 13:40:00 +01:00
reset ( $object -> fields ); // Reset is required to avoid key() to return null.
2021-01-06 20:54:20 +01:00
$sortfield = " t. " . key ( $object -> fields ); // Set here default search field. By default 1st field in definition.
}
if ( ! $sortorder ) {
$sortorder = " ASC " ;
}
2017-05-10 13:30:35 +02:00
2024-01-12 18:06:50 +01:00
// Initialize array of search criteria
2023-08-16 18:28:51 +02:00
$search_all = trim ( GETPOST ( 'search_all' , 'alphanohtml' ));
2020-04-10 10:59:32 +02:00
$search = array ();
2021-01-06 20:54:20 +01:00
foreach ( $object -> fields as $key => $val ) {
if ( GETPOST ( 'search_' . $key , 'alpha' ) !== '' ) {
$search [ $key ] = GETPOST ( 'search_' . $key , 'alpha' );
}
2020-11-17 13:14:16 +01:00
if ( preg_match ( '/^(date|timestamp|datetime)/' , $val [ 'type' ])) {
2024-03-16 10:45:32 +01:00
$search [ $key . '_dtstart' ] = dol_mktime ( 0 , 0 , 0 , GETPOSTINT ( 'search_' . $key . '_dtstartmonth' ), GETPOSTINT ( 'search_' . $key . '_dtstartday' ), GETPOSTINT ( 'search_' . $key . '_dtstartyear' ));
$search [ $key . '_dtend' ] = dol_mktime ( 23 , 59 , 59 , GETPOSTINT ( 'search_' . $key . '_dtendmonth' ), GETPOSTINT ( 'search_' . $key . '_dtendday' ), GETPOSTINT ( 'search_' . $key . '_dtendyear' ));
2020-11-17 13:14:16 +01:00
}
2017-07-11 20:47:49 +02:00
}
2017-05-10 13:30:35 +02:00
2024-01-03 16:16:44 +01:00
$fieldstosearchall = array ();
2017-05-27 13:46:34 +02:00
// List of fields to search into when doing a "search in all"
2023-06-05 16:15:52 +02:00
// foreach ($object->fields as $key => $val) {
// if (!empty($val['searchall'])) {
// $fieldstosearchall['t.'.$key] = $val['label'];
// }
// }
// $parameters = array('fieldstosearchall'=>$fieldstosearchall);
// $reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// if ($reshook > 0) {
// $fieldstosearchall = empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall'];
// } elseif ($reshook == 0) {
// $fieldstosearchall = array_merge($fieldstosearchall, empty($hookmanager->resArray['fieldstosearchall']) ? array() : $hookmanager->resArray['fieldstosearchall']);
// }
2017-05-27 13:46:34 +02:00
2020-09-11 16:16:04 +02:00
// Definition of array of fields for columns
2024-09-25 19:30:37 +02:00
$tableprefix = 't' ;
2020-04-10 10:59:32 +02:00
$arrayfields = array ();
2020-12-17 22:52:42 +01:00
foreach ( $object -> fields as $key => $val ) {
2017-07-22 01:00:43 +02:00
// If $val['visible']==0, then we never show the field
2020-07-26 20:45:54 +02:00
if ( ! empty ( $val [ 'visible' ])) {
2024-09-05 16:05:37 +02:00
$visible = ( int ) dol_eval (( string ) $val [ 'visible' ], 1 );
2024-09-25 19:30:37 +02:00
$arrayfields [ $tableprefix . '.' . $key ] = array (
2024-07-09 17:26:49 +02:00
'label' => $val [ 'label' ],
'checked' => (( $visible < 0 ) ? 0 : 1 ),
'enabled' => ( abs ( $visible ) != 3 && ( bool ) dol_eval ( $val [ 'enabled' ], 1 )),
'position' => $val [ 'position' ],
'help' => isset ( $val [ 'help' ]) ? $val [ 'help' ] : ''
2020-07-26 20:45:54 +02:00
);
}
2017-07-12 01:55:07 +02:00
}
2017-05-27 13:46:34 +02:00
// Extra fields
2020-12-01 02:41:19 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php' ;
2020-11-09 08:51:11 +01:00
2018-01-15 18:11:56 +01:00
$object -> fields = dol_sort_array ( $object -> fields , 'position' );
2022-02-09 13:22:23 +01:00
//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
2018-01-15 18:11:56 +01:00
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2017-05-10 13:30:35 +02:00
2022-03-11 10:55:28 +01:00
// There is several ways to check permission.
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
2024-11-28 11:15:56 +01:00
$enablepermissioncheck = getDolGlobalInt ( 'MYMODULE_ENABLE_PERMISSION_CHECK' );
2022-03-11 10:55:28 +01:00
if ( $enablepermissioncheck ) {
2023-01-14 11:43:47 +01:00
$permissiontoread = $user -> hasRight ( 'mymodule' , 'myobject' , 'read' );
$permissiontoadd = $user -> hasRight ( 'mymodule' , 'myobject' , 'write' );
$permissiontodelete = $user -> hasRight ( 'mymodule' , 'myobject' , 'delete' );
2022-03-11 10:55:28 +01:00
} else {
$permissiontoread = 1 ;
$permissiontoadd = 1 ;
$permissiontodelete = 1 ;
2021-02-26 18:26:44 +01:00
}
2021-04-29 12:10:55 +02:00
// Security check (enable the most restrictive one)
2023-12-04 13:46:42 +01:00
if ( $user -> socid > 0 ) {
accessforbidden ();
}
2021-04-29 12:10:55 +02:00
//if ($user->socid > 0) accessforbidden();
//$socid = 0; if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
2022-12-05 03:08:57 +01:00
//restrictedArea($user, $object->module, 0, $object->table_element, $object->element, 'fk_soc', 'rowid', $isdraft);
2022-09-08 16:19:11 +02:00
if ( ! isModEnabled ( " mymodule " )) {
2022-10-20 22:56:07 +02:00
accessforbidden ( 'Module mymodule not enabled' );
2022-09-08 16:19:11 +02:00
}
2023-12-04 13:46:42 +01:00
if ( ! $permissiontoread ) {
accessforbidden ();
}
2020-04-19 15:34:53 +02:00
2017-05-27 13:46:34 +02:00
2017-05-10 13:30:35 +02:00
/*
2017-11-25 18:52:47 +01:00
* Actions
2017-05-10 13:30:35 +02:00
*/
2021-01-06 20:54:20 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
$action = 'list' ;
$massaction = '' ;
}
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) {
$massaction = '' ;
}
2017-05-10 13:30:35 +02:00
2024-09-25 14:04:24 +02:00
$parameters = array ( 'arrayfields' => & $arrayfields );
2019-11-12 09:46:08 +01:00
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-01-06 20:54:20 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2017-05-10 13:30:35 +02:00
2021-01-06 20:54:20 +01:00
if ( empty ( $reshook )) {
2017-10-13 13:28:26 +02:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
2021-01-06 20:54:20 +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-12-17 22:52:42 +01:00
foreach ( $object -> fields as $key => $val ) {
2019-11-12 09:46:08 +01:00
$search [ $key ] = '' ;
2020-11-17 13:14:16 +01:00
if ( preg_match ( '/^(date|timestamp|datetime)/' , $val [ 'type' ])) {
$search [ $key . '_dtstart' ] = '' ;
$search [ $key . '_dtend' ] = '' ;
}
2017-10-13 13:28:26 +02:00
}
2024-03-08 19:39:33 +01:00
$search_all = '' ;
2021-06-24 09:54:30 +02:00
$toselect = array ();
2019-11-12 09:46:08 +01:00
$search_array_options = array ();
2017-10-13 13:28:26 +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-01-06 20:54:20 +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-13 13:28:26 +02:00
}
// Mass actions
2019-11-12 09:46:08 +01:00
$objectclass = 'MyObject' ;
$objectlabel = 'MyObject' ;
2017-10-13 13:28:26 +02:00
$uploaddir = $conf -> mymodule -> dir_output ;
2024-11-28 11:15:56 +01:00
global $error ;
2017-10-13 13:28:26 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
2023-02-20 00:16:02 +01:00
// You can add more action here
// if ($action == 'xxx' && $permissiontoxxx) ...
2017-05-10 13:30:35 +02:00
}
2017-05-27 13:46:34 +02:00
2017-05-10 13:30:35 +02:00
/*
2017-11-25 18:52:47 +01:00
* View
2017-05-10 13:30:35 +02:00
*/
2019-11-12 09:46:08 +01:00
$form = new Form ( $db );
2017-05-27 13:46:34 +02:00
2019-11-12 09:46:08 +01:00
$now = dol_now ();
2017-07-12 11:52:07 +02:00
2023-03-07 20:03:04 +01:00
$title = $langs -> trans ( " MyObjects " );
2022-03-31 18:06:39 +02:00
//$help_url = "EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
2019-11-12 09:46:08 +01:00
$help_url = '' ;
2021-02-16 11:15:42 +01:00
$morejs = array ();
$morecss = array ();
2017-05-10 13:30:35 +02:00
2017-07-12 11:52:07 +02:00
// Build and execute select
// --------------------------------------------------------------------
2024-09-25 19:30:37 +02:00
$sql = " SELECT " ;
$sql .= " " . $object -> getFieldList ( 't' );
2017-05-27 13:46:34 +02:00
// Add fields from extrafields
2019-11-12 09:46:08 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-01-06 20:54:20 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) {
2024-06-19 02:58:06 +02:00
$sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " , ef. " . $key . " as options_ " . $key : " " );
2021-01-06 20:54:20 +01:00
}
2019-10-12 12:31:35 +02:00
}
2017-05-27 13:46:34 +02:00
// Add fields from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
2023-02-18 15:45:07 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2023-03-16 14:58:44 +01:00
$sql .= $hookmanager -> resPrint ;
2019-11-12 09:46:08 +01:00
$sql = preg_replace ( '/,\s*$/' , '' , $sql );
2022-11-26 00:54:49 +01:00
$sqlfields = $sql ; // $sql fields to remove for count total
2025-01-15 08:42:14 +01:00
$sql .= " FROM " . $db -> prefix () . $object -> table_element . " as t " ;
//$sql .= " LEFT JOIN ".$db->prefix()."anothertable as rc ON rc.parent = t.rowid";
2021-06-14 01:55:58 +02:00
if ( isset ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && is_array ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2025-01-15 08:42:14 +01:00
$sql .= " LEFT JOIN " . $db -> prefix () . $object -> table_element . " _extrafields as ef on (t.rowid = ef.fk_object) " ;
2021-01-06 20:54:20 +01:00
}
2020-10-02 15:00:39 +02:00
// Add table from hooks
$parameters = array ();
2023-03-05 19:14:57 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListFrom' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2020-10-02 15:00:39 +02:00
$sql .= $hookmanager -> resPrint ;
2021-02-26 18:26:44 +01:00
if ( $object -> ismultientitymanaged == 1 ) {
2024-08-18 18:16:08 +02:00
$sql .= " WHERE t.entity IN ( " . getEntity ( $object -> element , ( GETPOSTINT ( 'search_current_entity' ) ? 0 : 1 )) . " ) " ;
2021-02-26 18:26:44 +01:00
} else {
$sql .= " WHERE 1 = 1 " ;
}
2021-01-06 20:54:20 +01:00
foreach ( $search as $key => $val ) {
2021-03-15 20:20:53 +01:00
if ( array_key_exists ( $key , $object -> fields )) {
2021-02-26 18:26:44 +01:00
if ( $key == 'status' && $search [ $key ] == - 1 ) {
continue ;
}
2025-02-05 22:59:37 +01:00
$field_spec = $object -> fields [ $key ];
if ( $field_spec === null ) {
continue ;
}
$mode_search = (( $object -> isInt ( $field_spec ) || $object -> isFloat ( $field_spec )) ? 1 : 0 );
if (( strpos ( $field_spec [ 'type' ], 'integer:' ) === 0 ) || ( strpos ( $field_spec [ 'type' ], 'sellist:' ) === 0 ) || ! empty ( $field_spec [ 'arrayofkeyval' ])) {
if ( $search [ $key ] == '-1' || ( $search [ $key ] === '0' && ( empty ( $field_spec [ 'arrayofkeyval' ]) || ! array_key_exists ( '0' , $field_spec [ 'arrayofkeyval' ])))) {
2021-02-26 18:26:44 +01:00
$search [ $key ] = '' ;
}
2020-11-17 13:14:16 +01:00
$mode_search = 2 ;
}
2025-02-05 22:59:37 +01:00
if ( empty ( $field_spec [ 'searchmulti' ])) {
2024-12-11 14:05:28 +01:00
if ( ! is_array ( $search [ $key ]) && $search [ $key ] != '' ) {
$sql .= natural_search ( " t. " . $db -> escape ( $key ), $search [ $key ], (( $key == 'status' ) ? 2 : $mode_search ));
}
} else {
if ( is_array ( $search [ $key ]) && ! empty ( $search [ $key ])) {
$sql .= natural_search ( " t. " . $db -> escape ( $key ), implode ( ',' , $search [ $key ]), (( $key == 'status' ) ? 2 : $mode_search ));
}
2021-01-06 20:54:20 +01:00
}
2020-11-17 13:14:16 +01:00
} else {
2020-11-17 13:18:27 +01:00
if ( preg_match ( '/(_dtstart|_dtend)$/' , $key ) && $search [ $key ] != '' ) {
2021-08-17 02:09:38 +02:00
$columnName = preg_replace ( '/(_dtstart|_dtend)$/' , '' , $key );
2020-11-17 13:14:16 +01:00
if ( preg_match ( '/^(date|timestamp|datetime)/' , $object -> fields [ $columnName ][ 'type' ])) {
if ( preg_match ( '/_dtstart$/' , $key )) {
2024-05-30 14:43:16 +02:00
$sql .= " AND t. " . $db -> sanitize ( $columnName ) . " >= ' " . $db -> idate ( $search [ $key ]) . " ' " ;
2020-11-17 13:14:16 +01:00
}
if ( preg_match ( '/_dtend$/' , $key )) {
2024-05-30 14:43:16 +02:00
$sql .= " AND t. " . $db -> sanitize ( $columnName ) . " <= ' " . $db -> idate ( $search [ $key ]) . " ' " ;
2020-11-17 13:14:16 +01:00
}
}
}
2020-01-09 22:14:39 +01:00
}
2017-07-12 01:55:07 +02:00
}
2021-01-06 20:54:20 +01:00
if ( $search_all ) {
$sql .= natural_search ( array_keys ( $fieldstosearchall ), $search_all );
}
2024-01-09 13:08:22 +01:00
/*
// If the internal user must only see his customers, force searching by him
$search_sale = 0 ;
if ( ! $user -> hasRight ( 'societe' , 'client' , 'voir' )) {
$search_sale = $user -> id ;
}
// Search on sale representative
if ( $search_sale && $search_sale != '-1' ) {
if ( $search_sale == - 2 ) {
2025-01-15 08:42:14 +01:00
$sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM " . $db -> prefix () . " societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc) " ;
2024-01-09 13:08:22 +01:00
} elseif ( $search_sale > 0 ) {
2025-01-15 08:42:14 +01:00
$sql .= " AND EXISTS (SELECT sc.fk_soc FROM " . $db -> prefix () . " societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = " . (( int ) $search_sale ) . " ) " ;
2024-01-09 13:08:22 +01:00
}
}
// Search on socid
if ( $socid ) {
$sql .= " AND t.fk_soc = " . (( int ) $socid );
}
*/
2019-09-28 12:36:09 +02:00
//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
2017-05-27 13:46:34 +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-05-27 13:46:34 +02:00
// Add where from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
2023-02-19 02:18:46 +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 ;
2017-09-18 15:48:04 +02:00
/* If a group by is required
2021-07-23 00:02:14 +02:00
$sql .= " GROUP BY " ;
foreach ( $object -> fields as $key => $val ) {
2024-05-30 14:43:16 +02:00
$sql .= " t. " . $db -> sanitize ( $key ) . " , " ;
2017-09-18 15:48:04 +02:00
}
// Add fields from extrafields
2021-07-23 00:02:14 +02:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-07-04 20:08:34 +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-09 22:14:39 +01:00
}
2023-05-11 11:03:26 +02:00
// Add groupby from hooks
2021-07-23 00:02:14 +02:00
$parameters = array ();
2023-05-09 16:08:43 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListGroupBy' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2021-07-23 00:02:14 +02:00
$sql .= $hookmanager -> resPrint ;
$sql = preg_replace ( '/,\s*$/' , '' , $sql );
2017-09-18 15:48:04 +02:00
*/
2021-08-27 23:36:06 +02:00
// Add HAVING from hooks
/*
$parameters = array ();
2023-05-16 12:56:03 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListHaving' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2021-12-09 17:19:31 +01:00
$sql .= empty ( $hookmanager -> resPrint ) ? " " : " HAVING 1=1 " . $hookmanager -> resPrint ;
2021-08-27 23:36:06 +02:00
*/
2017-05-27 13:46:34 +02:00
// Count total nb of records
$nbtotalofrecords = '' ;
2023-04-28 16:05:25 +02:00
if ( ! getDolGlobalInt ( 'MAIN_DISABLE_FULL_SCANLIST' )) {
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 */
2022-11-26 00:54:49 +01:00
$sqlforcount = preg_replace ( '/^' . preg_quote ( $sqlfields , '/' ) . '/' , 'SELECT COUNT(*) as nbtotalofrecords' , $sql );
$sqlforcount = preg_replace ( '/GROUP BY .*$/' , '' , $sqlforcount );
2023-11-18 12:40:10 +01:00
2021-08-16 22:36:30 +02:00
$resql = $db -> query ( $sqlforcount );
2022-05-01 17:44:26 +02:00
if ( $resql ) {
$objforcount = $db -> fetch_object ( $resql );
$nbtotalofrecords = $objforcount -> nbtotalofrecords ;
} else {
dol_print_error ( $db );
}
2022-02-09 13:22:23 +01:00
2023-02-21 02:12:20 +01:00
if (( $page * $limit ) > $nbtotalofrecords ) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
2018-04-24 11:37:57 +02:00
$page = 0 ;
$offset = 0 ;
}
2021-08-16 22:01:58 +02:00
$db -> free ( $resql );
2017-06-07 16:44:04 +02:00
}
2017-05-27 13:46:34 +02: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 );
}
2018-02-04 12:59:02 +01:00
2021-08-16 22:36:30 +02:00
$resql = $db -> query ( $sql );
if ( ! $resql ) {
dol_print_error ( $db );
exit ;
2018-02-04 12:59:02 +01:00
}
2017-05-27 13:46:34 +02:00
2021-08-16 22:36:30 +02:00
$num = $db -> num_rows ( $resql );
2017-05-27 13:46:34 +02:00
// Direct jump if only one record found
2023-08-16 11:59:14 +02:00
if ( $num == 1 && getDolGlobalInt ( 'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE' ) && $search_all && ! $page ) {
2017-10-13 13:28:26 +02:00
$obj = $db -> fetch_object ( $resql );
$id = $obj -> rowid ;
2023-07-12 15:23:14 +02:00
header ( " Location: " . dol_buildpath ( '/mymodule/myobject_card.php' , 1 ) . '?id=' . (( int ) $id ));
2017-10-13 13:28:26 +02:00
exit ;
2017-05-27 13:46:34 +02:00
}
2017-07-12 11:52:07 +02:00
// Output page
// --------------------------------------------------------------------
2024-11-05 15:22:55 +01:00
llxHeader ( '' , $title , $help_url , '' , 0 , 0 , $morejs , $morecss , '' , 'mod-mymodule page-list bodyforlist' ); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for a horizontal scroll in the table instead of page
2017-05-27 13:46:34 +02:00
2017-07-12 11:52:07 +02:00
// Example : Adding jquery code
2021-11-29 15:09:18 +01:00
// print '<script type="text/javascript">
2021-06-26 21:10:59 +02:00
// jQuery(document).ready(function() {
// function init_myfunc()
// {
// jQuery("#myid").removeAttr(\'disabled\');
// jQuery("#myid").attr(\'disabled\',\'disabled\');
// }
// init_myfunc();
// jQuery("#mybutton").click(function() {
// init_myfunc();
// });
// });
// </script>';
2017-07-12 11:52:07 +02:00
2019-11-12 09:46:08 +01:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2017-05-27 13:46:34 +02:00
2019-11-12 09:46:08 +01:00
$param = '' ;
2022-02-09 13:22:23 +01:00
if ( ! empty ( $mode )) {
$param .= '&mode=' . urlencode ( $mode );
}
2021-01-06 20:54:20 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
2023-03-05 19:14:57 +01:00
$param .= '&limit=' . (( int ) $limit );
2021-01-06 20:54:20 +01:00
}
2023-05-09 16:08:43 +02:00
if ( $optioncss != '' ) {
$param .= '&optioncss=' . urlencode ( $optioncss );
}
2024-07-02 18:46:20 +02:00
if ( $groupby != '' ) {
$param .= '&groupby=' . urlencode ( $groupby );
}
2021-01-06 20:54:20 +01:00
foreach ( $search as $key => $val ) {
2022-09-01 11:18:46 +02:00
if ( is_array ( $search [ $key ])) {
2021-01-06 20:54:20 +01:00
foreach ( $search [ $key ] as $skey ) {
2021-09-16 20:56:14 +02:00
if ( $skey != '' ) {
$param .= '&search_' . $key . '[]=' . urlencode ( $skey );
}
2021-01-06 20:54:20 +01:00
}
2022-09-07 00:34:22 +02:00
} elseif ( preg_match ( '/(_dtstart|_dtend)$/' , $key ) && ! empty ( $val )) {
2024-08-18 18:16:08 +02:00
$param .= '&search_' . $key . 'month=' . GETPOSTINT ( 'search_' . $key . 'month' );
$param .= '&search_' . $key . 'day=' . GETPOSTINT ( 'search_' . $key . 'day' );
$param .= '&search_' . $key . 'year=' . GETPOSTINT ( 'search_' . $key . 'year' );
2021-09-16 20:56:14 +02:00
} elseif ( $search [ $key ] != '' ) {
2021-01-06 20:54:20 +01:00
$param .= '&search_' . $key . '=' . urlencode ( $search [ $key ]);
}
}
2017-05-27 13:46:34 +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' ;
2020-10-02 15:00:39 +02:00
// Add $param from hooks
2024-05-23 14:41:56 +02:00
$parameters = array ( 'param' => & $param );
2023-03-07 13:41:01 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListSearchParam' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2020-10-02 15:00:39 +02:00
$param .= $hookmanager -> resPrint ;
2017-05-27 13:46:34 +02:00
2017-07-25 01:22:06 +02:00
// List of mass actions available
2019-11-12 09:46:08 +01:00
$arrayofmassactions = array (
2021-04-14 12:28:01 +02:00
//'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
//'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
2017-05-27 13:46:34 +02:00
);
2022-05-28 12:24:11 +02:00
if ( ! empty ( $permissiontodelete )) {
2021-04-14 12:28:01 +02:00
$arrayofmassactions [ 'predelete' ] = img_picto ( '' , 'delete' , 'class="pictofixedwidth"' ) . $langs -> trans ( " Delete " );
2021-01-06 20:54:20 +01:00
}
2024-03-16 10:45:32 +01:00
if ( GETPOSTINT ( 'nomassaction' ) || in_array ( $massaction , array ( 'presend' , 'predelete' ))) {
2021-01-06 20:54:20 +01:00
$arrayofmassactions = array ();
}
2019-11-12 09:46:08 +01:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2017-05-27 13:46:34 +02:00
2020-01-13 13:35:29 +01:00
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' . " \n " ;
2021-01-06 20:54:20 +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-05-27 13:46:34 +02:00
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
2021-07-04 19:23:04 +02:00
print '<input type="hidden" name="page" value="' . $page . '">' ;
2017-05-27 13:46:34 +02:00
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2023-01-14 15:11:15 +01:00
print '<input type="hidden" name="page_y" value="">' ;
2022-02-09 13:22:23 +01:00
print '<input type="hidden" name="mode" value="' . $mode . '">' ;
2017-05-27 13:46:34 +02:00
2022-02-09 13:22:23 +01:00
$newcardbutton = '' ;
2024-08-18 18:16:08 +02:00
$newcardbutton .= dolGetButtonTitle ( $langs -> trans ( 'ViewList' ), '' , 'fa fa-bars imgforviewmode' , $_SERVER [ " PHP_SELF " ] . '?mode=common' . preg_replace ( '/(&|\?)*mode=[^&]+/' , '' , $param ), '' , (( empty ( $mode ) || $mode == 'common' ) ? 2 : 1 ), array ( 'morecss' => 'reposition' ));
$newcardbutton .= dolGetButtonTitle ( $langs -> trans ( 'ViewKanban' ), '' , 'fa fa-th-list imgforviewmode' , $_SERVER [ " PHP_SELF " ] . '?mode=kanban' . preg_replace ( '/(&|\?)*mode=[^&]+/' , '' , $param ), '' , ( $mode == 'kanban' ? 2 : 1 ), array ( 'morecss' => 'reposition' ));
2022-02-09 13:22:23 +01:00
$newcardbutton .= dolGetButtonTitleSeparator ();
$newcardbutton .= dolGetButtonTitle ( $langs -> trans ( 'New' ), '' , 'fa fa-plus-circle' , dol_buildpath ( '/mymodule/myobject_card.php' , 1 ) . '?action=create&backtopage=' . urlencode ( $_SERVER [ 'PHP_SELF' ]), '' , $permissiontoadd );
2018-04-15 17:37:49 +02:00
2024-10-15 10:48:00 +02:00
print_barre_liste ( $title , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , $object -> picto , 0 , $newcardbutton , '' , $limit , 0 , 0 , 1 );
2017-05-27 13:46:34 +02:00
2017-11-11 16:03:22 +01:00
// Add code for pre mass action (confirmation or email presend form)
2019-11-12 09:46:08 +01:00
$topicmail = " SendMyObjectRef " ;
$modelmail = " myobject " ;
$objecttmp = new MyObject ( $db );
$trackid = 'xxxx' . $object -> id ;
2017-11-11 16:03:22 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2021-01-06 20:54:20 +01:00
if ( $search_all ) {
2022-05-12 14:28:17 +02:00
$setupstring = '' ;
2024-08-18 18:16:08 +02:00
// @phan-suppress-next-line PhanEmptyForeach
2021-01-06 20:54:20 +01:00
foreach ( $fieldstosearchall as $key => $val ) {
$fieldstosearchall [ $key ] = $langs -> trans ( $val );
2022-05-12 14:28:17 +02:00
$setupstring .= $key . " = " . $val . " ; " ;
2021-01-06 20:54:20 +01:00
}
2023-01-25 14:55:05 +01:00
print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = ' . $setupstring . ' -->' . " \n " ;
2024-08-17 23:59:08 +02:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $search_all ) . implode ( ', ' , $fieldstosearchall ) . '</div>' . " \n " ;
2017-05-27 13:46:34 +02:00
}
$moreforfilter = '' ;
2017-10-20 23:48:42 +02:00
/* $moreforfilter .= '<div class="divsearchfield">' ;
2017-05-27 13:46:34 +02:00
$moreforfilter .= $langs -> trans ( 'MyFilter' ) . ': <input type="text" name="search_myfield" value="' . dol_escape_htmltag ( $search_myfield ) . '">' ;
2017-10-20 23:48:42 +02:00
$moreforfilter .= '</div>' ; */
2017-05-27 13:46:34 +02:00
2019-11-12 09:46:08 +01:00
$parameters = array ();
2023-01-25 14:48:41 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2021-01-06 20:54:20 +01:00
if ( empty ( $reshook )) {
$moreforfilter .= $hookmanager -> resPrint ;
} else {
$moreforfilter = $hookmanager -> resPrint ;
}
2024-09-25 19:30:37 +02:00
$parameters = array (
'arrayfields' => & $arrayfields ,
);
2017-05-27 13:46:34 +02:00
2021-01-06 20:54:20 +01:00
if ( ! empty ( $moreforfilter )) {
2017-05-27 13:46:34 +02:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
2017-10-13 13:28:26 +02:00
print '</div>' ;
2017-05-27 13:46:34 +02:00
}
2019-11-12 09:46:08 +01:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
2025-02-04 23:58:14 +01:00
$htmlofselectarray = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage , $conf -> main_checkbox_left_column ? 'left' : '' ); // This also change content of $arrayfields with user setup
2024-04-30 09:45:28 +02:00
$selectedfields = ( $mode != 'kanban' ? $htmlofselectarray : '' );
2022-05-18 16:55:03 +02:00
$selectedfields .= ( count ( $arrayofmassactions ) ? $form -> showCheckAddButtons ( 'checkforselect' , 1 ) : '' );
2017-05-10 13:30:35 +02:00
2024-01-12 18:06:50 +01:00
print '<div class="div-table-responsive">' ; // You can use div-table-responsive-no-min if you don't need reserved height for your table
2024-10-25 16:37:24 +02:00
print '<table class="tagtable nobottomiftotal noborder liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2017-05-10 13:30:35 +02:00
2017-05-27 13:46:34 +02:00
// Fields title search
2017-07-12 11:52:07 +02:00
// --------------------------------------------------------------------
2023-02-19 02:18:46 +01:00
print '<tr class="liste_titre_filter">' ;
2022-04-15 11:21:02 +02:00
// Action column
2024-07-26 05:01:26 +02:00
if ( $conf -> main_checkbox_left_column ) {
2023-03-07 13:41:01 +01:00
print '<td class="liste_titre center maxwidthsearch">' ;
2022-04-15 15:19:14 +02:00
$searchpicto = $form -> showFilterButtons ( 'left' );
print $searchpicto ;
print '</td>' ;
}
2021-01-06 20:54:20 +01:00
foreach ( $object -> fields as $key => $val ) {
2024-03-12 03:37:21 +01:00
//$searchkey = empty($search[$key]) ? '' : $search[$key];
2022-06-20 02:10:27 +02:00
$cssforfield = ( empty ( $val [ 'csslist' ]) ? ( empty ( $val [ 'css' ]) ? '' : $val [ 'css' ]) : $val [ 'csslist' ]);
2021-01-06 20:54:20 +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' ;
2023-07-12 15:02:34 +02:00
} elseif ( in_array ( $val [ 'type' ], array ( 'double(24,8)' , 'double(6,3)' , 'integer' , 'real' , 'price' )) && ! in_array ( $key , array ( 'id' , 'rowid' , 'ref' , 'status' )) && $val [ 'label' ] != 'TechnicalID' && empty ( $val [ 'arrayofkeyval' ])) {
2021-01-06 20:54:20 +01:00
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'right' ;
}
if ( ! empty ( $arrayfields [ 't.' . $key ][ 'checked' ])) {
2023-01-05 04:04:16 +01:00
print '<td class="liste_titre' . ( $cssforfield ? ' ' . $cssforfield : '' ) . ( $key == 'status' ? ' parentonrightofpage' : '' ) . '">' ;
2021-01-06 20:54:20 +01:00
if ( ! empty ( $val [ 'arrayofkeyval' ]) && is_array ( $val [ 'arrayofkeyval' ])) {
2024-12-11 14:05:28 +01:00
if ( empty ( $val [ 'searchmulti' ])) {
print $form -> selectarray ( 'search_' . $key , $val [ 'arrayofkeyval' ], ( isset ( $search [ $key ]) ? $search [ $key ] : '' ), 1 , 0 , 0 , '' , 1 , 0 , 0 , '' , 'maxwidth100' . ( $key == 'status' ? ' search_status width100 onrightofpage' : '' ), 1 );
} else {
print $form -> multiselectarray ( 'search_' . $key , $val [ 'arrayofkeyval' ], ( isset ( $search [ $key ]) ? $search [ $key ] : '' ), 0 , 0 , 'maxwidth100' . ( $key == 'status' ? ' search_status width100 onrightofpage' : '' ), 1 );
}
2021-06-24 09:54:30 +02:00
} elseif (( strpos ( $val [ 'type' ], 'integer:' ) === 0 ) || ( strpos ( $val [ 'type' ], 'sellist:' ) === 0 )) {
2022-05-05 21:56:59 +02:00
print $object -> showInputField ( $val , $key , ( isset ( $search [ $key ]) ? $search [ $key ] : '' ), '' , '' , 'search_' , $cssforfield . ' maxwidth250' , 1 );
2020-11-17 13:15:50 +01:00
} elseif ( preg_match ( '/^(date|timestamp|datetime)/' , $val [ 'type' ])) {
2020-11-17 13:14:16 +01:00
print '<div class="nowrap">' ;
print $form -> selectDate ( $search [ $key . '_dtstart' ] ? $search [ $key . '_dtstart' ] : '' , " search_ " . $key . " _dtstart " , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'From' ));
print '</div>' ;
print '<div class="nowrap">' ;
print $form -> selectDate ( $search [ $key . '_dtend' ] ? $search [ $key . '_dtend' ] : '' , " search_ " . $key . " _dtend " , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'to' ));
print '</div>' ;
2021-09-07 14:10:26 +02:00
} elseif ( $key == 'lang' ) {
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php' ;
$formadmin = new FormAdmin ( $db );
2024-08-18 00:01:45 +02:00
print $formadmin -> select_language (( isset ( $search [ $key ]) ? $search [ $key ] : '' ), 'search_lang' , 0 , array (), 1 , 0 , 0 , 'minwidth100imp maxwidth125' , 2 );
2021-09-07 14:10:26 +02:00
} else {
2024-11-05 15:22:55 +01:00
print '<input type="text" class="flat maxwidth' . ( in_array ( $val [ 'type' ], array ( 'integer' , 'price' )) ? '50' : '75' ) . '" name="search_' . $key . '" value="' . dol_escape_htmltag ( isset ( $search [ $key ]) ? $search [ $key ] : '' ) . '">' ;
2020-11-17 13:14:16 +01:00
}
2019-05-22 19:21:55 +02:00
print '</td>' ;
}
2017-07-12 11:52:07 +02:00
}
2017-05-27 13:46:34 +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-05-27 13:46:34 +02:00
// Fields from hook
2024-08-18 18:16:08 +02:00
$parameters = array ( 'arrayfields' => $arrayfields );
2023-02-18 15:45:07 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-05-27 13:46:34 +02:00
print $hookmanager -> resPrint ;
2022-02-09 13:22:23 +01:00
/* if ( ! empty ( $arrayfields [ 'anotherfield' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
} */
2017-05-27 13:46:34 +02:00
// Action column
2024-07-26 05:01:26 +02:00
if ( ! $conf -> main_checkbox_left_column ) {
2023-02-19 02:18:46 +01:00
print '<td class="liste_titre center maxwidthsearch">' ;
2022-04-15 15:19:14 +02:00
$searchpicto = $form -> showFilterButtons ();
print $searchpicto ;
print '</td>' ;
}
2017-05-27 13:46:34 +02:00
print '</tr>' . " \n " ;
2017-06-07 16:44:04 +02:00
2022-02-09 13:22:23 +01:00
$totalarray = array ();
$totalarray [ 'nbfield' ] = 0 ;
2017-07-12 11:52:07 +02:00
// Fields title label
// --------------------------------------------------------------------
2017-06-07 16:44:04 +02:00
print '<tr class="liste_titre">' ;
2023-04-01 12:05:29 +02:00
// Action column
2024-07-26 05:01:26 +02:00
if ( $conf -> main_checkbox_left_column ) {
2023-03-13 09:45:47 +01:00
print getTitleFieldOfList ( $selectedfields , 0 , $_SERVER [ " PHP_SELF " ], '' , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' ) . " \n " ;
2023-02-20 00:16:02 +01:00
$totalarray [ 'nbfield' ] ++ ;
2022-04-15 15:19:14 +02:00
}
2021-01-06 20:54:20 +01:00
foreach ( $object -> fields as $key => $val ) {
2020-11-03 04:19:04 +01:00
$cssforfield = ( empty ( $val [ 'csslist' ]) ? ( empty ( $val [ 'css' ]) ? '' : $val [ 'css' ]) : $val [ 'csslist' ]);
2021-01-06 20:54:20 +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' ;
2023-07-12 15:02:34 +02:00
} elseif ( in_array ( $val [ 'type' ], array ( 'double(24,8)' , 'double(6,3)' , 'integer' , 'real' , 'price' )) && ! in_array ( $key , array ( 'id' , 'rowid' , 'ref' , 'status' )) && $val [ 'label' ] != 'TechnicalID' && empty ( $val [ 'arrayofkeyval' ])) {
2021-01-06 20:54:20 +01:00
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'right' ;
}
2022-05-05 18:29:36 +02:00
$cssforfield = preg_replace ( '/small\s*/' , '' , $cssforfield ); // the 'small' css must not be used for the title label
2021-01-06 20:54:20 +01:00
if ( ! empty ( $arrayfields [ 't.' . $key ][ 'checked' ])) {
2023-01-21 12:24:54 +01:00
print getTitleFieldOfList ( $arrayfields [ 't.' . $key ][ 'label' ], 0 , $_SERVER [ 'PHP_SELF' ], 't.' . $key , '' , $param , ( $cssforfield ? 'class="' . $cssforfield . '"' : '' ), $sortfield , $sortorder , ( $cssforfield ? $cssforfield . ' ' : '' ), 0 , ( empty ( $val [ 'helplist' ]) ? '' : $val [ 'helplist' ])) . " \n " ;
2022-02-09 13:22:23 +01:00
$totalarray [ 'nbfield' ] ++ ;
2018-11-11 15:06:08 +01:00
}
2017-07-12 11:52:07 +02:00
}
2017-06-07 16:44:04 +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-06-07 16:44:04 +02:00
// Hook fields
2024-05-30 14:43:16 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder , 'totalarray' => & $totalarray );
2023-02-18 15:45:07 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-06-07 16:44:04 +02:00
print $hookmanager -> resPrint ;
2022-02-09 13:22:23 +01:00
/* if ( ! empty ( $arrayfields [ 'anotherfield' ][ 'checked' ])) {
print '<th class="liste_titre right">' . $langs -> trans ( " AnotherField " ) . '</th>' ;
$totalarray [ 'nbfield' ] ++ ;
} */
2019-01-28 01:46:59 +01:00
// Action column
2024-07-26 05:01:26 +02:00
if ( ! $conf -> main_checkbox_left_column ) {
2023-03-13 09:45:47 +01:00
print getTitleFieldOfList ( $selectedfields , 0 , $_SERVER [ " PHP_SELF " ], '' , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' ) . " \n " ;
2023-02-20 00:16:02 +01:00
$totalarray [ 'nbfield' ] ++ ;
2022-04-15 15:19:14 +02:00
}
2017-06-07 16:44:04 +02:00
print '</tr>' . " \n " ;
2017-05-27 13:46:34 +02:00
// Detect if we need a fetch on each output line
2019-11-12 09:46:08 +01:00
$needToFetchEachLine = 0 ;
2021-06-14 01:55:58 +02:00
if ( isset ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ]) && is_array ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ]) > 0 ) {
2021-01-06 20:54:20 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'computed' ] as $key => $val ) {
2023-06-28 14:52:44 +02:00
if ( ! is_null ( $val ) && preg_match ( '/\$object/' , $val )) {
2021-02-26 18:26:44 +01:00
$needToFetchEachLine ++ ; // There is at least one compute field that use $object
}
2018-04-13 17:54:27 +02:00
}
2017-05-27 13:46:34 +02:00
}
2017-05-10 13:30:35 +02:00
2017-07-12 11:52:07 +02:00
// Loop on record
// --------------------------------------------------------------------
2019-11-12 09:46:08 +01:00
$i = 0 ;
2022-02-09 13:22:23 +01:00
$savnbfield = $totalarray [ 'nbfield' ];
2022-05-31 10:35:36 +02:00
$totalarray = array ();
2021-06-14 01:55:58 +02:00
$totalarray [ 'nbfield' ] = 0 ;
2022-02-09 13:22:23 +01:00
$imaxinloop = ( $limit ? min ( $num , $limit ) : $num );
while ( $i < $imaxinloop ) {
2017-10-13 13:28:26 +02:00
$obj = $db -> fetch_object ( $resql );
2021-01-06 20:54:20 +01:00
if ( empty ( $obj )) {
break ; // Should not happen
}
2017-09-21 18:35:47 +02:00
2017-10-13 13:28:26 +02:00
// Store properties in $object
2020-01-09 22:14:39 +01:00
$object -> setVarsFromFetchObj ( $obj );
2017-09-21 18:35:47 +02:00
2023-09-15 15:58:43 +02:00
/*
$object -> thirdparty = null ;
if ( $obj -> fk_soc > 0 ) {
if ( ! empty ( $conf -> cache [ 'thirdparty' ][ $obj -> fk_soc ])) {
$companyobj = $conf -> cache [ 'thirdparty' ][ $obj -> fk_soc ];
} else {
$companyobj = new Societe ( $db );
$companyobj -> fetch ( $obj -> fk_soc );
$conf -> cache [ 'thirdparty' ][ $obj -> fk_soc ] = $companyobj ;
}
$object -> thirdparty = $companyobj ;
} */
2022-02-09 13:22:23 +01:00
if ( $mode == 'kanban' ) {
if ( $i == 0 ) {
2023-06-28 11:50:28 +02:00
print '<tr class="trkanban"><td colspan="' . $savnbfield . '">' ;
2023-02-19 02:39:39 +01:00
print '<div class="box-flex-container kanban">' ;
2021-01-06 20:54:20 +01:00
}
2022-02-09 13:22:23 +01:00
// Output Kanban
2023-06-16 03:50:24 +02:00
$selected = - 1 ;
2023-03-05 15:29:41 +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
$selected = 0 ;
if ( in_array ( $object -> id , $arrayofselected )) {
$selected = 1 ;
}
}
2023-09-15 15:58:43 +02:00
//print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
2023-06-16 03:50:24 +02:00
print $object -> getKanbanView ( '' , array ( 'selected' => $selected ));
2022-02-09 13:22:23 +01:00
if ( $i == ( $imaxinloop - 1 )) {
print '</div>' ;
print '</td></tr>' ;
2021-01-06 20:54:20 +01:00
}
2022-02-09 13:22:23 +01:00
} else {
2023-05-09 16:08:43 +02:00
// Show line of result
2022-02-09 13:22:23 +01:00
$j = 0 ;
2022-03-31 18:06:39 +02:00
print '<tr data-rowid="' . $object -> id . '" class="oddeven">' ;
2023-04-24 18:09:18 +02:00
2022-04-15 11:21:02 +02:00
// Action column
2024-07-26 05:01:26 +02:00
if ( $conf -> main_checkbox_left_column ) {
2022-04-15 15:19:14 +02:00
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 ( $object -> id , $arrayofselected )) {
$selected = 1 ;
}
print '<input id="cb' . $object -> id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $object -> id . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
2022-04-15 11:21:02 +02:00
}
2022-04-15 15:19:14 +02:00
print '</td>' ;
2023-01-31 01:13:57 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2022-04-15 11:21:02 +02:00
}
2024-06-19 02:58:06 +02:00
// Fields
2022-02-09 13:22:23 +01:00
foreach ( $object -> fields as $key => $val ) {
$cssforfield = ( empty ( $val [ 'csslist' ]) ? ( empty ( $val [ 'css' ]) ? '' : $val [ 'css' ]) : $val [ 'csslist' ]);
if ( in_array ( $val [ 'type' ], array ( 'date' , 'datetime' , 'timestamp' ))) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'center' ;
} elseif ( $key == 'status' ) {
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'center' ;
}
2019-01-11 17:05:50 +01:00
2022-02-09 13:22:23 +01:00
if ( in_array ( $val [ 'type' ], array ( 'timestamp' ))) {
2023-04-07 23:51:41 +02:00
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'nowraponall' ;
2022-02-09 13:22:23 +01:00
} elseif ( $key == 'ref' ) {
2023-04-07 23:51:41 +02:00
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'nowraponall' ;
2021-01-06 20:54:20 +01:00
}
2022-02-09 13:22:23 +01:00
2023-07-12 15:02:34 +02:00
if ( in_array ( $val [ 'type' ], array ( 'double(24,8)' , 'double(6,3)' , 'integer' , 'real' , 'price' )) && ! in_array ( $key , array ( 'id' , 'rowid' , 'ref' , 'status' )) && empty ( $val [ 'arrayofkeyval' ])) {
2022-02-09 13:22:23 +01:00
$cssforfield .= ( $cssforfield ? ' ' : '' ) . 'right' ;
2021-01-06 20:54:20 +01:00
}
2022-02-09 13:22:23 +01:00
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
if ( ! empty ( $arrayfields [ 't.' . $key ][ 'checked' ])) {
2024-03-12 03:46:00 +01:00
print '<td' . ( $cssforfield ? ' class="' . $cssforfield . (( preg_match ( '/tdoverflow/' , $cssforfield ) && ! in_array ( $val [ 'type' ], array ( 'ip' , 'url' )) && ! is_numeric ( $object -> $key )) ? ' classfortooltip' : '' ) . '"' : '' );
2024-10-15 10:48:00 +02:00
if ( preg_match ( '/tdoverflow/' , $cssforfield ) && ! in_array ( $val [ 'type' ], array ( 'ip' , 'url' )) && ! is_numeric ( $object -> $key ) && ! in_array ( $key , array ( 'ref' ))) {
2025-02-05 22:59:37 +01:00
print ' title="' . dol_escape_htmltag (( string ) $object -> $key ) . '"' ;
2022-05-05 18:29:36 +02:00
}
print '>' ;
2022-02-09 13:22:23 +01:00
if ( $key == 'status' ) {
print $object -> getLibStatut ( 5 );
} elseif ( $key == 'rowid' ) {
2025-02-05 22:59:37 +01:00
print $object -> showOutputField ( $val , $key , ( string ) $object -> id , '' );
2022-02-09 13:22:23 +01:00
} else {
2025-02-05 22:59:37 +01:00
print $object -> showOutputField ( $val , $key , ( string ) $object -> $key , '' );
2021-01-06 20:54:20 +01:00
}
2022-02-09 13:22:23 +01:00
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
2021-06-14 01:55:58 +02:00
}
2022-02-09 13:22:23 +01:00
if ( ! empty ( $val [ 'isameasure' ]) && $val [ 'isameasure' ] == 1 ) {
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 't.' . $key ;
}
if ( ! isset ( $totalarray [ 'val' ])) {
$totalarray [ 'val' ] = array ();
}
if ( ! isset ( $totalarray [ 'val' ][ 't.' . $key ])) {
$totalarray [ 'val' ][ 't.' . $key ] = 0 ;
}
$totalarray [ 'val' ][ 't.' . $key ] += $object -> $key ;
2021-06-14 01:55:58 +02:00
}
2017-10-13 13:28:26 +02:00
}
2017-11-24 15:47:38 +01:00
}
2022-02-09 13:22:23 +01:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
// Fields from hook
2024-05-30 14:43:16 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'object' => $object , 'obj' => $obj , 'i' => $i , 'totalarray' => & $totalarray );
2023-02-21 00:54:00 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2022-02-09 13:22:23 +01:00
print $hookmanager -> resPrint ;
2023-07-21 14:44:22 +02:00
2022-02-09 13:22:23 +01:00
/* if ( ! empty ( $arrayfields [ 'anotherfield' ][ 'checked' ])) {
print '<td class="right">' . $obj -> anotherfield . '</td>' ;
} */
2023-07-19 02:51:51 +02:00
2022-02-09 13:22:23 +01:00
// Action column
2024-08-17 18:42:37 +02:00
if ( empty ( $conf -> main_checkbox_left_column )) {
2022-04-15 15:19:14 +02:00
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 ( $object -> id , $arrayofselected )) {
$selected = 1 ;
}
print '<input id="cb' . $object -> id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $object -> id . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
2022-02-09 13:22:23 +01:00
}
2022-04-15 15:19:14 +02:00
print '</td>' ;
2023-01-31 01:13:57 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-26 18:26:44 +01:00
}
2017-09-21 18:35:47 +02:00
2022-02-09 13:22:23 +01:00
print '</tr>' . " \n " ;
}
2017-09-21 18:35:47 +02:00
2017-10-13 13:28:26 +02:00
$i ++ ;
2017-05-27 13:46:34 +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-05-27 13:46:34 +02:00
2017-06-22 15:22:44 +02:00
// If no record found
2021-01-06 20:54:20 +01:00
if ( $num == 0 ) {
2019-11-12 09:46:08 +01:00
$colspan = 1 ;
2021-01-06 20:54:20 +01:00
foreach ( $arrayfields as $key => $val ) {
if ( ! empty ( $val [ 'checked' ])) {
$colspan ++ ;
}
}
2022-01-02 18:22:18 +01:00
print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs -> trans ( " NoRecordFound " ) . '</span></td></tr>' ;
2017-06-22 15:22:44 +02:00
}
2017-05-27 13:46:34 +02:00
$db -> free ( $resql );
2023-05-09 16:08:43 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'sql' => $sql );
2022-05-10 11:38:56 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-05-27 13:46:34 +02:00
print $hookmanager -> resPrint ;
print '</table>' . " \n " ;
print '</div>' . " \n " ;
print '</form>' . " \n " ;
2023-12-08 02:05:51 +01:00
if ( in_array ( 'builddoc' , array_keys ( $arrayofmassactions )) && ( $nbtotalofrecords === '' || $nbtotalofrecords )) {
2019-11-12 09:46:08 +01:00
$hidegeneratedfilelistifempty = 1 ;
2021-01-06 20:54:20 +01:00
if ( $massaction == 'builddoc' || $action == 'remove_file' || $show_files ) {
$hidegeneratedfilelistifempty = 0 ;
}
2017-10-13 13:28:26 +02:00
2018-07-26 11:57:25 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
2018-02-21 11:02:45 +01:00
$formfile = new FormFile ( $db );
2017-10-13 13:28:26 +02:00
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-13 13:28:26 +02:00
2019-11-12 09:46:08 +01:00
$filedir = $diroutputmassaction ;
$genallowed = $permissiontoread ;
$delallowed = $permissiontoadd ;
2018-02-21 11:02:45 +01:00
2023-04-07 23:51:41 +02:00
print $formfile -> showdocuments ( 'massfilesarea_' . $object -> module , '' , $filedir , $urlsource , 0 , $delallowed , '' , 1 , 1 , 0 , 48 , 1 , $param , $title , '' , '' , '' , null , $hidegeneratedfilelistifempty );
2017-05-27 13:46:34 +02:00
}
2017-05-10 13:30:35 +02:00
// End of page
llxFooter ();
2017-05-27 13:46:34 +02:00
$db -> close ();