2011-08-21 15:01:34 +02:00
< ? php
2012-08-16 19:18:24 +02:00
/* Copyright ( C ) 2002 - 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2014-08-15 23:20:31 +02:00
* Copyright ( C ) 2004 - 2014 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2012-08-16 19:18:24 +02:00
* Copyright ( C ) 2011 - 2012 Juanjo Menent < jmenent @ 2 byte . es >
2013-09-10 16:43:06 +02:00
* Copyright ( C ) 2013 Cédric Salvador < csalvador @ gpcsolutions . fr >
2016-07-06 10:28:34 +02:00
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
2019-06-25 13:23:19 +02:00
* Copyright ( C ) 2018 Ferran Marcet < fmarcet @ 2 byte . es >
2021-06-24 20:30:11 +02:00
* Copyright ( C ) 2021 Frédéric France < frederic . france @ netlogic . fr >
2022-02-05 12:10:57 +01:00
* Copyright ( C ) 2022 Charlène Benke < charlene @ patas - monkey . com >
2011-08-21 15:01:34 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2011-08-21 15:01:34 +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 />.
2011-08-21 15:01:34 +02:00
*/
/**
* \file htdocs / fichinter / list . php
* \brief List of all interventions
* \ingroup ficheinter
*/
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2016-08-23 15:43:48 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinter.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2022-08-31 22:29:00 +02:00
if ( isModEnabled ( 'project' )) {
2021-02-25 23:00:32 +01:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
}
2022-08-31 22:02:31 +02:00
if ( isModEnabled ( 'contrat' )) {
2021-02-25 23:00:32 +01:00
require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php' ;
}
2011-08-21 15:01:34 +02:00
2018-05-26 17:57:30 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'companies' , 'bills' , 'interventions' ));
2022-08-31 22:29:00 +02:00
if ( isModEnabled ( 'project' )) {
2021-02-25 23:00:32 +01:00
$langs -> load ( " projects " );
}
2022-08-31 22:02:31 +02:00
if ( isModEnabled ( 'contrat' )) {
2021-02-25 23:00:32 +01:00
$langs -> load ( " contracts " );
}
2011-08-21 15:01:34 +02:00
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2019-11-12 09:46:08 +01:00
$massaction = GETPOST ( 'massaction' , 'alpha' );
$show_files = GETPOST ( 'show_files' , 'int' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
2017-04-09 14:31:56 +02:00
$toselect = GETPOST ( 'toselect' , 'array' );
2019-11-12 09:46:08 +01:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'interventionlist' ;
$search_ref = GETPOST ( 'search_ref' ) ? GETPOST ( 'search_ref' , 'alpha' ) : GETPOST ( 'search_inter' , 'alpha' );
2022-05-17 12:53:50 +02:00
$search_ref_client = GETPOST ( 'search_ref_client' , 'alpha' );
2019-11-12 09:46:08 +01:00
$search_company = GETPOST ( 'search_company' , 'alpha' );
$search_desc = GETPOST ( 'search_desc' , 'alpha' );
$search_projet_ref = GETPOST ( 'search_projet_ref' , 'alpha' );
$search_contrat_ref = GETPOST ( 'search_contrat_ref' , 'alpha' );
$search_status = GETPOST ( 'search_status' , 'alpha' );
$sall = trim (( GETPOST ( 'search_all' , 'alphanohtml' ) != '' ) ? GETPOST ( 'search_all' , 'alphanohtml' ) : GETPOST ( 'sall' , 'alphanohtml' ));
2019-01-27 11:55:16 +01:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2019-11-12 09:46:08 +01:00
$socid = GETPOST ( 'socid' , 'int' );
2011-08-21 15:01:34 +02:00
2019-11-12 09:46:08 +01:00
$diroutputmassaction = $conf -> ficheinter -> dir_output . '/temp/massgeneration/' . $user -> id ;
2011-08-21 15:01:34 +02:00
2022-06-10 09:17:48 +02:00
// Load variable for pagination
2019-11-12 09:46:08 +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' );
2022-06-10 09:17:48 +02:00
if ( empty ( $page ) || $page < 0 || GETPOST ( 'button_search' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) {
// If $page is not defined, or '' or -1 or if we click on clear filters
2021-02-25 23:00:32 +01:00
$page = 0 ;
2022-06-10 09:17:48 +02:00
}
2015-12-16 19:38:40 +01:00
$offset = $limit * $page ;
2012-06-01 10:52:39 +02:00
$pageprev = $page - 1 ;
2012-03-05 11:16:30 +01:00
$pagenext = $page + 1 ;
2021-02-25 23:00:32 +01:00
if ( ! $sortorder ) {
$sortorder = " DESC " ;
}
if ( ! $sortfield ) {
$sortfield = " f.ref " ;
2014-10-17 13:09:18 +02:00
}
2011-08-21 15:01:34 +02:00
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2018-03-31 18:48:27 +02:00
$object = new Fichinter ( $db );
$hookmanager -> initHooks ( array ( 'interventionlist' ));
2019-10-06 14:41:52 +02:00
2016-07-06 10:28:34 +02:00
$extrafields = new ExtraFields ( $db );
2022-06-10 09:17:48 +02:00
// Fetch optionals attributes and labels
2020-08-04 12:47:09 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2019-10-06 14:41:52 +02:00
2019-11-12 09:46:08 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $object -> table_element , '' , 'search_' );
2011-08-21 15:01:34 +02:00
2015-10-17 00:52:35 +02:00
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array (
2017-10-13 13:28:26 +02:00
'f.ref' => 'Ref' ,
's.nom' => " ThirdParty " ,
'f.description' => 'Description' ,
'f.note_public' => 'NotePublic' ,
2020-09-23 09:51:16 +02:00
'fd.description' => 'DescriptionOfLine' ,
2015-10-17 00:52:35 +02:00
);
2021-02-25 23:00:32 +01:00
if ( empty ( $user -> socid )) {
$fieldstosearchall [ " f.note_private " ] = " NotePrivate " ;
}
if ( ! empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS )) {
unset ( $fieldstosearchall [ 'fd.description' ]);
}
2015-10-17 00:52:35 +02:00
2016-07-06 10:28:34 +02:00
// Definition of fields for list
2019-11-12 09:46:08 +01:00
$arrayfields = array (
2019-02-01 17:00:04 +01:00
'f.ref' => array ( 'label' => 'Ref' , 'checked' => 1 ),
2022-05-17 12:53:50 +02:00
'f.ref_client' => array ( 'label' => 'RefCustomer' , 'checked' => 1 ),
2019-02-01 17:00:04 +01:00
's.nom' => array ( 'label' => 'ThirdParty' , 'checked' => 1 ),
2022-08-31 22:29:00 +02:00
'pr.ref' => array ( 'label' => 'Project' , 'checked' => 1 , 'enabled' => ( ! isModEnabled ( 'project' ) ? 0 : 1 )),
2019-11-12 09:46:08 +01:00
'c.ref' => array ( 'label' => 'Contract' , 'checked' => 1 , 'enabled' => ( empty ( $conf -> contrat -> enabled ) ? 0 : 1 )),
2019-02-01 17:00:04 +01:00
'f.description' => array ( 'label' => 'Description' , 'checked' => 1 ),
'f.datec' => array ( 'label' => 'DateCreation' , 'checked' => 0 , 'position' => 500 ),
'f.tms' => array ( 'label' => 'DateModificationShort' , 'checked' => 0 , 'position' => 500 ),
2020-09-30 11:58:40 +02:00
'f.note_public' => array ( 'label' => 'NotePublic' , 'checked' => 0 , 'position' => 510 , 'enabled' => ( empty ( $conf -> global -> MAIN_LIST_ALLOW_PUBLIC_NOTES ))),
'f.note_private' => array ( 'label' => 'NotePrivate' , 'checked' => 0 , 'position' => 511 , 'enabled' => ( empty ( $conf -> global -> MAIN_LIST_ALLOW_PRIVATE_NOTES ))),
2019-02-01 17:00:04 +01:00
'f.fk_statut' => array ( 'label' => 'Status' , 'checked' => 1 , 'position' => 1000 ),
2019-11-12 09:46:08 +01:00
'fd.description' => array ( 'label' => " DescriptionOfLine " , 'checked' => 1 , 'enabled' => empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS ) ? 1 : 0 ),
'fd.date' => array ( 'label' => 'DateOfLine' , 'checked' => 1 , 'enabled' => empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS ) ? 1 : 0 ),
2022-05-21 16:25:47 +02:00
'fd.duree' => array ( 'label' => 'DurationOfLine' , 'type' => 'duration' , 'checked' => 1 , 'enabled' => empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS ) ? 1 : 0 ), //type duration is here because in database, column 'duree' is double
2016-07-06 10:28:34 +02:00
);
// Extra fields
2020-12-23 19:14:47 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php' ;
2019-10-22 17:08:37 +02:00
$object -> fields = dol_sort_array ( $object -> fields , 'position' );
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2016-07-06 10:28:34 +02:00
2022-06-10 09:17:48 +02:00
// Security check
$id = GETPOST ( 'id' , 'int' );
if ( $user -> socid ) {
$socid = $user -> socid ;
}
$result = restrictedArea ( $user , 'ficheinter' , $id , 'fichinter' );
$permissiontoread = $user -> rights -> ficheinter -> lire ;
$permissiontodelete = $user -> rights -> ficheinter -> supprimer ;
2016-07-06 10:28:34 +02:00
/*
2017-04-09 14:31:56 +02:00
* Actions
2016-07-06 10:28:34 +02:00
*/
2021-02-25 23:00:32 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
2022-06-10 09:17:48 +02:00
$action = 'list' ;
$massaction = '' ;
2021-02-25 23:00:32 +01:00
}
2022-04-25 14:28:57 +02:00
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) {
2021-02-25 23:00:32 +01:00
$massaction = '' ;
}
2016-07-06 10:28:34 +02:00
2019-11-12 09:46:08 +01:00
$parameters = array ( 'socid' => $socid );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-25 23:00:32 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2016-07-06 10:28:34 +02:00
2021-02-25 23:00:32 +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' ;
2017-04-09 14:31:56 +02:00
2017-10-13 13:28:26 +02:00
// Purge search criteria
2021-02-25 23:00:32 +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
2019-11-12 09:46:08 +01:00
$search_ref = " " ;
2022-05-17 12:53:50 +02:00
$search_ref_client = " " ;
2019-11-12 09:46:08 +01:00
$search_company = " " ;
$search_projet_ref = " " ;
$search_contrat_ref = " " ;
$search_desc = " " ;
$search_status = " " ;
2022-05-08 18:25:22 +02:00
$toselect = array ();
2019-11-12 09:46:08 +01:00
$search_array_options = array ();
2017-04-09 14:31:56 +02:00
}
// Mass actions
2019-11-12 09:46:08 +01:00
$objectclass = 'Fichinter' ;
$objectlabel = 'Interventions' ;
2017-04-09 14:31:56 +02:00
$uploaddir = $conf -> ficheinter -> dir_output ;
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
2016-07-06 10:28:34 +02:00
}
2015-10-17 00:52:35 +02:00
2011-08-21 15:01:34 +02:00
/*
* View
*/
2017-04-09 14:31:56 +02:00
2014-09-06 19:10:59 +02:00
$form = new Form ( $db );
2016-08-23 15:43:48 +02:00
$formfile = new FormFile ( $db );
2019-11-12 09:46:08 +01:00
$objectstatic = new Fichinter ( $db );
$companystatic = new Societe ( $db );
2022-08-31 22:29:00 +02:00
if ( isModEnabled ( 'project' )) {
2020-10-31 14:32:18 +01:00
$projetstatic = new Project ( $db );
2019-03-29 17:03:23 +01:00
}
2022-08-31 22:02:31 +02:00
if ( isModEnabled ( 'contrat' )) {
2020-10-31 14:32:18 +01:00
$contratstatic = new Contrat ( $db );
2019-03-29 17:03:23 +01:00
}
2017-03-28 18:42:23 +02:00
2022-06-10 09:17:48 +02:00
$now = dol_now ();
$help_url = '' ;
2019-11-12 09:46:08 +01:00
$title = $langs -> trans ( " ListOfInterventions " );
2022-06-10 09:17:48 +02:00
$morejs = array ();
$morecss = array ();
2011-08-21 15:01:34 +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
2019-02-01 17:00:04 +01:00
2019-11-12 09:46:08 +01:00
$atleastonefieldinlines = 0 ;
2021-02-25 23:00:32 +01:00
foreach ( $arrayfields as $tmpkey => $tmpval ) {
if ( preg_match ( '/^fd\./' , $tmpkey ) && ! empty ( $arrayfields [ $tmpkey ][ 'checked' ])) {
2020-10-31 14:32:18 +01:00
$atleastonefieldinlines ++ ;
break ;
}
2019-02-01 17:00:04 +01:00
}
2011-08-21 15:01:34 +02:00
$sql = " SELECT " ;
2022-05-17 12:53:50 +02:00
$sql .= " f.ref, f.ref_client, f.rowid, f.fk_statut as status, f.description, f.datec as date_creation, f.tms as date_update, f.note_public, f.note_private, " ;
2021-02-25 23:00:32 +01:00
if ( empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS ) && $atleastonefieldinlines ) {
$sql .= " fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree, " ;
}
2020-02-24 05:23:34 +01:00
$sql .= " s.nom as name, s.rowid as socid, s.client, s.fournisseur, s.email, s.status as thirdpartystatus " ;
2022-08-31 22:29:00 +02:00
if ( isModEnabled ( 'project' )) {
2020-10-31 14:32:18 +01:00
$sql .= " , pr.rowid as projet_id, pr.ref as projet_ref, pr.title as projet_title " ;
2019-03-29 17:03:23 +01:00
}
2022-08-31 22:02:31 +02:00
if ( isModEnabled ( 'contrat' )) {
2021-06-24 20:30:11 +02:00
$sql .= " , c.rowid as contrat_id, c.ref as contrat_ref, c.ref_customer as contrat_ref_customer, c.ref_supplier as contrat_ref_supplier " ;
2019-03-29 17:03:23 +01:00
}
2016-07-06 10:28:34 +02:00
// Add fields from extrafields
2019-11-12 09:46:08 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-25 23:00:32 +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-25 23:00:32 +01:00
}
2019-10-16 03:34:32 +02:00
}
2016-07-06 10:28:34 +02:00
// Add fields from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
$sql .= " FROM " . MAIN_DB_PREFIX . " fichinter as f " ;
2022-08-31 22:29:00 +02:00
if ( isModEnabled ( 'project' )) {
2020-10-31 14:32:18 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " projet as pr on f.fk_projet = pr.rowid " ;
2019-03-29 17:03:23 +01:00
}
2022-08-31 22:02:31 +02:00
if ( isModEnabled ( 'contrat' )) {
2020-10-31 14:32:18 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " contrat as c on f.fk_contrat = c.rowid " ;
2019-03-29 17:03:23 +01:00
}
2022-04-30 19:50:20 +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' ])) {
2021-02-25 23:00:32 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object -> table_element . " _extrafields as ef on (f.rowid = ef.fk_object) " ;
}
if ( empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS ) && $atleastonefieldinlines ) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " fichinterdet as fd ON fd.fk_fichinter = f.rowid " ;
}
2021-04-20 09:44:24 +02:00
2021-04-19 10:20:51 +02:00
// Add table from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListFrom' , $parameters , $object ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2021-04-20 09:44:24 +02:00
2021-10-22 22:15:59 +02:00
if ( empty ( $user -> rights -> societe -> client -> voir ) && empty ( $socid )) {
2021-02-25 23:00:32 +01:00
$sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
}
2019-11-12 09:46:08 +01:00
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
$sql .= " WHERE f.entity IN ( " . getEntity ( 'intervention' ) . " ) " ;
$sql .= " AND f.fk_soc = s.rowid " ;
2013-09-10 16:43:06 +02:00
if ( $search_ref ) {
2017-10-13 13:28:26 +02:00
$sql .= natural_search ( 'f.ref' , $search_ref );
2013-09-10 16:43:06 +02:00
}
2022-05-17 12:53:50 +02:00
if ( $search_ref_client ) {
$sql .= natural_search ( 'f.ref_client' , $search_ref_client );
}
2013-09-10 16:43:06 +02:00
if ( $search_company ) {
2017-10-13 13:28:26 +02:00
$sql .= natural_search ( 's.nom' , $search_company );
2013-09-10 16:43:06 +02:00
}
2019-03-29 17:03:23 +01:00
if ( $search_projet_ref ) {
2020-10-31 14:32:18 +01:00
$sql .= natural_search ( 'pr.ref' , $search_projet_ref );
2019-03-29 17:03:23 +01:00
}
if ( $search_contrat_ref ) {
2020-10-31 14:32:18 +01:00
$sql .= natural_search ( 'c.ref' , $search_contrat_ref );
2019-03-29 17:03:23 +01:00
}
2013-09-10 16:43:06 +02:00
if ( $search_desc ) {
2021-02-25 23:00:32 +01:00
if ( empty ( $conf -> global -> FICHINTER_DISABLE_DETAILS ) && $atleastonefieldinlines ) {
$sql .= natural_search ( array ( 'f.description' , 'fd.description' ), $search_desc );
} else {
$sql .= natural_search ( array ( 'f.description' ), $search_desc );
}
2013-09-10 16:43:06 +02:00
}
2014-09-06 19:10:59 +02:00
if ( $search_status != '' && $search_status >= 0 ) {
2020-04-20 03:10:26 +02:00
$sql .= ' AND f.fk_statut = ' . urlencode ( $search_status );
2014-09-06 19:10:59 +02:00
}
2021-10-22 22:15:59 +02:00
if ( empty ( $user -> rights -> societe -> client -> voir ) && empty ( $socid )) {
2021-08-23 17:41:11 +02:00
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . (( int ) $user -> id );
2021-02-25 23:00:32 +01:00
}
if ( $socid ) {
2021-05-18 09:01:55 +02:00
$sql .= " AND s.rowid = " . (( int ) $socid );
2021-02-25 23:00:32 +01:00
}
2014-11-03 17:48:10 +01:00
if ( $sall ) {
2015-10-17 00:52:35 +02:00
$sql .= natural_search ( array_keys ( $fieldstosearchall ), $sall );
2014-11-03 17:48:10 +01:00
}
2016-07-06 10:28: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' ;
2016-07-06 10:28:34 +02:00
// Add where from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
2022-06-10 09:17:48 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2019-11-12 09:46:08 +01:00
$sql .= $hookmanager -> resPrint ;
2021-04-14 21:27:53 +02:00
// Add GroupBy from hooks
2022-07-28 18:06:37 +02:00
$parameters = array ( 'search_all' => $sall , 'fieldstosearchall' => $fieldstosearchall );
2021-04-14 21:27:53 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListGroupBy' , $parameters , $object ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2016-02-11 20:40:33 +01:00
2017-04-09 14:31:56 +02:00
// Count total nb of records
$nbtotalofrecords = '' ;
2021-02-25 23:00:32 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST )) {
2022-06-10 09:17:48 +02:00
/* This old and fast method to get and count full list returns all record so use a high amount of memory. */
$resql = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $resql );
/* The fast and low memory method to get and count full list converts the sql into a sql count */
/* $sqlforcount = preg_replace ( '/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/' , 'SELECT COUNT(*) as nbtotalofrecords FROM' , $sql );
$resql = $db -> query ( $sqlforcount );
if ( $resql ) {
$objforcount = $db -> fetch_object ( $resql );
$nbtotalofrecords = $objforcount -> nbtotalofrecords ;
} else {
dol_print_error ( $db );
} */
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 ;
}
2022-06-10 09:17:48 +02:00
$db -> free ( $resql );
2015-12-28 00:20:48 +01:00
}
2016-02-11 20:40:33 +01:00
2022-06-10 09:17:48 +02:00
// Complete request and execute it with limit
$sql .= $db -> order ( $sortfield , $sortorder );
if ( $limit ) {
$sql .= $db -> plimit ( $limit + 1 , $offset );
}
2011-08-21 15:01:34 +02:00
2019-11-12 09:46:08 +01:00
$resql = $db -> query ( $sql );
2022-06-10 09:17:48 +02:00
if ( ! $resql ) {
dol_print_error ( $db );
exit ;
}
2011-08-21 15:01:34 +02:00
2022-06-10 09:17:48 +02:00
$num = $db -> num_rows ( $resql );
2017-06-19 14:31:08 +02:00
2017-07-23 19:09:00 +02:00
2022-06-10 09:17:48 +02:00
// Direct jump if only one record found
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && $search_all && ! $page ) {
$obj = $db -> fetch_object ( $resql );
$id = $obj -> rowid ;
header ( " Location: " . dol_buildpath ( '/mymodule/myobject_card.php' , 1 ) . '?id=' . $id );
exit ;
}
2017-06-19 14:31:08 +02:00
2020-09-18 10:36:40 +02:00
2022-06-10 09:17:48 +02:00
// Output page
// --------------------------------------------------------------------
2018-03-30 16:54:38 +02:00
2022-06-10 09:17:48 +02:00
llxHeader ( '' , $title , $help_url , '' , 0 , 0 , $morejs , $morecss , '' , 'bodyforlist' );
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
if ( $socid > 0 ) {
$soc = new Societe ( $db );
$soc -> fetch ( $socid );
if ( empty ( $search_company )) {
$search_company = $soc -> name ;
2017-10-13 13:28:26 +02:00
}
2022-06-10 09:17:48 +02:00
}
$param = '' ;
if ( ! empty ( $mode )) {
$param .= '&mode=' . urlencode ( $mode );
}
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
$param .= '&limit=' . urlencode ( $limit );
}
if ( $sall ) {
$param .= " &sall= " . urlencode ( $sall );
}
if ( $socid ) {
$param .= " &socid= " . urlencode ( $socid );
}
if ( $search_ref ) {
$param .= " &search_ref= " . urlencode ( $search_ref );
}
if ( $search_ref_client ) {
$param .= " &search_ref_client= " . urlencode ( $search_ref_client );
}
if ( $search_company ) {
$param .= " &search_company= " . urlencode ( $search_company );
}
if ( $search_desc ) {
$param .= " &search_desc= " . urlencode ( $search_desc );
}
if ( $search_status != '' && $search_status > - 1 ) {
$param .= " &search_status= " . urlencode ( $search_status );
}
if ( $show_files ) {
$param .= '&show_files=' . urlencode ( $show_files );
}
if ( $optioncss != '' ) {
$param .= '&optioncss=' . urlencode ( $optioncss );
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
// Add $param from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSearchParam' , $parameters , $object ); // Note that $action and $object may have been modified by hook
$param .= $hookmanager -> resPrint ;
// List of mass actions available
$arrayofmassactions = array (
'generate_doc' => img_picto ( '' , 'pdf' , 'class="pictofixedwidth"' ) . $langs -> trans ( " ReGeneratePDF " ),
'builddoc' => img_picto ( '' , 'pdf' , 'class="pictofixedwidth"' ) . $langs -> trans ( " PDFMerge " ),
//'presend'=>$langs->trans("SendByMail"),
);
if ( ! empty ( $permissiontodelete )) {
$arrayofmassactions [ 'predelete' ] = img_picto ( '' , 'delete' , 'class="pictofixedwidth"' ) . $langs -> trans ( " Delete " );
}
if ( GETPOST ( 'nomassaction' , 'int' ) || in_array ( $massaction , array ( 'presend' , 'predelete' ))) {
$arrayofmassactions = array ();
}
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2011-08-21 15:01:34 +02:00
2017-06-19 14:31:08 +02:00
2022-06-10 09:17:48 +02:00
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' . " \n " ;
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
$newcardbutton = '' ;
$url = DOL_URL_ROOT . '/fichinter/card.php?action=create' ;
if ( ! empty ( $socid )) {
$url .= '&socid=' . $socid ;
}
$newcardbutton = dolGetButtonTitle ( $langs -> trans ( 'NewIntervention' ), '' , 'fa fa-plus-circle' , $url , '' , $user -> rights -> ficheinter -> creer );
print_barre_liste ( $title , $page , $_SERVER [ 'PHP_SELF' ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'object_' . $object -> picto , 0 , $newcardbutton , '' , $limit , 0 , 0 , 1 );
$topicmail = " Information " ;
$modelmail = " intervention " ;
$objecttmp = new Fichinter ( $db );
$trackid = 'int' . $object -> id ;
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
if ( $sall ) {
foreach ( $fieldstosearchall as $key => $val ) {
$fieldstosearchall [ $key ] = $langs -> trans ( $val );
2021-02-25 23:00:32 +01:00
}
2022-06-10 09:17:48 +02:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
}
$moreforfilter = '' ;
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters , $object ); // Note that $action and $object may have been modified by hook
if ( empty ( $reshook )) {
$moreforfilter .= $hookmanager -> resPrint ;
} else {
$moreforfilter = $hookmanager -> resPrint ;
}
if ( ! empty ( $moreforfilter )) {
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
print '</div>' ;
}
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage , getDolGlobalString ( 'MAIN_CHECKBOX_LEFT_COLUMN' , '' )); // This also change content of $arrayfields
$selectedfields .= ( count ( $arrayofmassactions ) ? $form -> showCheckAddButtons ( 'checkforselect' , 1 ) : '' );
2017-06-19 14:31:08 +02:00
2022-06-10 09:17:48 +02:00
print '<div class="div-table-responsive">' ;
print '<table class="tagtable nobottomiftotal liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre_filter">' ;
// Action column
if ( ! empty ( $conf -> global -> MAIN_CHECKBOX_LEFT_COLUMN )) {
print '<td class="liste_titre maxwidthsearch">' ;
$searchpicto = $form -> showFilterButtons ( 'left' );
print $searchpicto ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'f.ref' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_ref" value="' . $search_ref . '" size="8">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'f.ref_client' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_ref_client" value="' . $search_ref_client . '" size="8">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_company" value="' . $search_company . '" size="10">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'pr.ref' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_projet_ref" value="' . $search_projet_ref . '" size="8">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'c.ref' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_contrat_ref" value="' . $search_contrat_ref . '" size="8">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'f.description' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_desc" value="' . $search_desc . '" size="12">' ;
print '</td>' ;
}
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters , $object ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
if ( ! empty ( $arrayfields [ 'f.datec' ][ 'checked' ])) {
// Date creation
print '<td class="liste_titre">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'f.tms' ][ 'checked' ])) {
// Date modification
print '<td class="liste_titre">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'f.note_public' ][ 'checked' ])) {
// Note public
print '<td class="liste_titre">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'f.note_private' ][ 'checked' ])) {
// Note private
print '<td class="liste_titre">' ;
print '</td>' ;
}
// Status
if ( ! empty ( $arrayfields [ 'f.fk_statut' ][ 'checked' ])) {
print '<td class="liste_titre right">' ;
$tmp = $objectstatic -> LibStatut ( 0 ); // To load $this->statuts_short
$liststatus = $objectstatic -> statuts_short ;
if ( empty ( $conf -> global -> FICHINTER_CLASSIFY_BILLED )) {
unset ( $liststatus [ 2 ]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
2017-10-13 13:28:26 +02:00
}
2022-06-10 09:17:48 +02:00
print $form -> selectarray ( 'search_status' , $liststatus , $search_status , 1 , 0 , 0 , '' , 1 );
print '</td>' ;
}
// Fields of detail line
if ( ! empty ( $arrayfields [ 'fd.description' ][ 'checked' ])) {
print '<td class="liste_titre"> </td>' ;
}
if ( ! empty ( $arrayfields [ 'fd.date' ][ 'checked' ])) {
print '<td class="liste_titre"> </td>' ;
}
if ( ! empty ( $arrayfields [ 'fd.duree' ][ 'checked' ])) {
print '<td class="liste_titre"> </td>' ;
}
// Action column
if ( empty ( $conf -> global -> MAIN_CHECKBOX_LEFT_COLUMN )) {
print '<td class="liste_titre maxwidthsearch">' ;
$searchpicto = $form -> showFilterButtons ();
print $searchpicto ;
print '</td>' ;
}
print '</tr>' . " \n " ;
$totalarray = array ();
$totalarray [ 'nbfield' ] = 0 ;
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 'f.ref' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'f.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " f.ref " , " " , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'f.ref_client' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'f.ref_client' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " f.ref_client " , " " , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 's.nom' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " s.nom " , " " , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'pr.ref' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'pr.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " pr.ref " , " " , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'c.ref' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'c.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " c.ref " , " " , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'f.description' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'f.description' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " f.description " , " " , $param , '' , $sortfield , $sortorder );
}
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
// Hook fields
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
if ( ! empty ( $arrayfields [ 'f.datec' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'f.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " f.datec " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
if ( ! empty ( $arrayfields [ 'f.tms' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'f.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " f.tms " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
if ( ! empty ( $arrayfields [ 'f.note_public' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'f.note_public' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " f.note_public " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
if ( ! empty ( $arrayfields [ 'f.note_private' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'f.note_private' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " f.note_private " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
if ( ! empty ( $arrayfields [ 'f.fk_statut' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'f.fk_statut' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " f.fk_statut " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'fd.description' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'fd.description' ][ 'label' ], $_SERVER [ " PHP_SELF " ], '' );
}
if ( ! empty ( $arrayfields [ 'fd.date' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'fd.date' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " fd.date " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
}
if ( ! empty ( $arrayfields [ 'fd.duree' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'fd.duree' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " fd.duree " , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' );
print " </tr> \n " ;
2017-06-19 14:31:08 +02:00
2022-06-10 09:17:48 +02:00
// Loop on record
// --------------------------------------------------------------------
$total = 0 ;
$i = 0 ;
$savnbfield = $totalarray [ 'nbfield' ];
$totalarray = array ();
$totalarray [ 'nbfield' ] = 0 ;
$totalarray [ 'val' ] = array ();
$totalarray [ 'val' ][ 'fd.duree' ] = 0 ;
$imaxinloop = ( $limit ? min ( $num , $limit ) : $num );
while ( $i < $imaxinloop ) {
$obj = $db -> fetch_object ( $resql );
if ( empty ( $obj )) {
break ; // Should not happen
2021-02-25 23:00:32 +01:00
}
2017-06-19 14:31:08 +02:00
2022-06-10 09:17:48 +02:00
// Store properties in $object
//$object->setVarsFromFetchObj($obj);
$objectstatic -> id = $obj -> rowid ;
$objectstatic -> ref = $obj -> ref ;
$objectstatic -> ref_client = $obj -> ref_client ;
$objectstatic -> statut = $obj -> status ;
$objectstatic -> status = $obj -> status ;
$companystatic -> name = $obj -> name ;
$companystatic -> id = $obj -> socid ;
$companystatic -> client = $obj -> client ;
$companystatic -> fournisseur = $obj -> fournisseur ;
$companystatic -> email = $obj -> email ;
$companystatic -> status = $obj -> thirdpartystatus ;
print '<tr class="oddeven">' ;
2011-08-21 15:01:34 +02:00
2021-02-25 23:00:32 +01:00
if ( ! empty ( $arrayfields [ 'f.ref' ][ 'checked' ])) {
2022-06-10 09:17:48 +02:00
print " <td> " ;
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
// Picto + Ref
2022-07-28 18:06:37 +02:00
print '<td class="nobordernopadding nowraponall">' ;
2022-06-10 09:17:48 +02:00
print $objectstatic -> getNomUrl ( 1 );
2016-07-06 10:28:34 +02:00
print '</td>' ;
2022-06-10 09:17:48 +02:00
// Warning
$warnornote = '' ;
//if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late"));
if ( ! empty ( $obj -> note_private )) {
$warnornote .= ( $warnornote ? ' ' : '' );
$warnornote .= '<span class="note">' ;
$warnornote .= '<a href="note.php?id=' . $obj -> rowid . '">' . img_picto ( $langs -> trans ( " ViewPrivateNote " ), 'object_generic' ) . '</a>' ;
$warnornote .= '</span>' ;
}
if ( $warnornote ) {
print '<td style="min-width: 20px" class="nobordernopadding nowrap">' ;
print $warnornote ;
print '</td>' ;
}
// Other picto tool
print '<td width="16" class="right nobordernopadding hideonsmartphone">' ;
$filename = dol_sanitizeFileName ( $obj -> ref );
$filedir = $conf -> ficheinter -> dir_output . '/' . dol_sanitizeFileName ( $obj -> ref );
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?id=' . $obj -> rowid ;
print $formfile -> getDocumentsLink ( $objectstatic -> element , $filename , $filedir );
print '</td></tr></table>' ;
print " </td> \n " ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2022-05-17 12:53:50 +02:00
if ( ! empty ( $arrayfields [ 'f.ref_client' ][ 'checked' ])) {
2022-06-10 09:17:48 +02:00
// Customer ref
print '<td class="nowrap tdoverflowmax200">' ;
2022-07-28 18:06:37 +02:00
print dol_escape_htmltag ( $obj -> ref_client );
2022-05-17 12:53:50 +02:00
print '</td>' ;
2022-06-10 09:17:48 +02:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2022-05-17 12:53:50 +02:00
}
2021-02-25 23:00:32 +01:00
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
2022-06-10 09:17:48 +02:00
print '<td>' ;
print $companystatic -> getNomUrl ( 1 , '' , 44 );
2016-07-06 10:28:34 +02:00
print '</td>' ;
2022-06-10 09:17:48 +02:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2021-02-25 23:00:32 +01:00
if ( ! empty ( $arrayfields [ 'pr.ref' ][ 'checked' ])) {
2022-06-10 09:17:48 +02:00
print '<td>' ;
$projetstatic -> id = $obj -> projet_id ;
$projetstatic -> ref = $obj -> projet_ref ;
$projetstatic -> title = $obj -> projet_title ;
if ( $projetstatic -> id > 0 ) {
print $projetstatic -> getNomUrl ( 1 , '' );
}
2020-10-31 14:32:18 +01:00
print '</td>' ;
2022-06-10 09:17:48 +02:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-10-31 14:32:18 +01:00
}
2021-02-25 23:00:32 +01:00
if ( ! empty ( $arrayfields [ 'c.ref' ][ 'checked' ])) {
2022-06-10 09:17:48 +02:00
print '<td>' ;
$contratstatic -> id = $obj -> contrat_id ;
$contratstatic -> ref = $obj -> contrat_ref ;
$contratstatic -> ref_customer = $obj -> contrat_ref_customer ;
$contratstatic -> ref_supplier = $obj -> contrat_ref_supplier ;
if ( $contratstatic -> id > 0 ) {
print $contratstatic -> getNomUrl ( 1 , '' );
print '</td>' ;
}
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-10-31 14:32:18 +01:00
}
2021-02-25 23:00:32 +01:00
if ( ! empty ( $arrayfields [ 'f.description' ][ 'checked' ])) {
2022-06-10 09:17:48 +02:00
print '<td>' . dol_trunc ( dolGetFirstLineOfText ( dol_string_nohtmltag ( $obj -> description , 1 )), 48 ) . '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2017-11-27 15:24:29 +01:00
2022-06-10 09:17:48 +02:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
2017-10-13 13:28:26 +02:00
// Fields from hook
2022-06-10 09:17:48 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj , 'i' => $i , 'totalarray' =>& $totalarray );
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
2017-10-13 13:28:26 +02:00
print $hookmanager -> resPrint ;
2022-06-10 09:17:48 +02:00
// Date creation
2021-02-25 23:00:32 +01:00
if ( ! empty ( $arrayfields [ 'f.datec' ][ 'checked' ])) {
2022-06-10 09:17:48 +02:00
print '<td class="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' , 'tzuser' );
2017-10-13 13:28:26 +02:00
print '</td>' ;
2022-06-10 09:17:48 +02:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2022-06-10 09:17:48 +02:00
// Date modification
2021-02-25 23:00:32 +01:00
if ( ! empty ( $arrayfields [ 'f.tms' ][ 'checked' ])) {
2022-06-10 09:17:48 +02:00
print '<td class="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' , 'tzuser' );
2017-10-13 13:28:26 +02:00
print '</td>' ;
2022-06-10 09:17:48 +02:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2022-06-10 09:17:48 +02:00
// Note public
2021-02-25 23:00:32 +01:00
if ( ! empty ( $arrayfields [ 'f.note_public' ][ 'checked' ])) {
2022-06-10 09:17:48 +02:00
print '<td class="center">' ;
print dol_escape_htmltag ( $obj -> note_public );
2020-09-30 11:58:40 +02:00
print '</td>' ;
2022-06-10 09:17:48 +02:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-09-30 11:58:40 +02:00
}
2022-06-10 09:17:48 +02:00
// Note private
2021-02-25 23:00:32 +01:00
if ( ! empty ( $arrayfields [ 'f.note_private' ][ 'checked' ])) {
2022-06-10 09:17:48 +02:00
print '<td class="center">' ;
print dol_escape_htmltag ( $obj -> note_private );
2020-09-30 11:58:40 +02:00
print '</td>' ;
2022-06-10 09:17:48 +02:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-09-30 11:58:40 +02:00
}
2017-10-13 13:28:26 +02:00
// Status
2021-02-25 23:00:32 +01:00
if ( ! empty ( $arrayfields [ 'f.fk_statut' ][ 'checked' ])) {
2022-06-10 09:17:48 +02:00
print '<td class="right">' . $objectstatic -> getLibStatut ( 5 ) . '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
2021-02-25 23:00:32 +01:00
}
2017-10-13 13:28:26 +02:00
}
2022-06-10 09:17:48 +02:00
// Fields of detail of line
2021-02-25 23:00:32 +01:00
if ( ! empty ( $arrayfields [ 'fd.description' ][ 'checked' ])) {
2022-06-10 09:17:48 +02:00
print '<td>' . dol_trunc ( dolGetFirstLineOfText ( dol_string_nohtmltag ( $obj -> descriptiondetail , 1 )), 48 ) . '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-25 23:00:32 +01:00
}
if ( ! empty ( $arrayfields [ 'fd.date' ][ 'checked' ])) {
2022-06-10 09:17:48 +02:00
print '<td class="center">' . dol_print_date ( $db -> jdate ( $obj -> dp ), 'dayhour' ) . " </td> \n " ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-25 23:00:32 +01:00
}
if ( ! empty ( $arrayfields [ 'fd.duree' ][ 'checked' ])) {
2022-06-10 09:17:48 +02:00
print '<td class="right">' . convertSecondToTime ( $obj -> duree , 'allhourmin' ) . '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
2019-02-01 17:00:04 +01:00
}
2022-06-10 09:17:48 +02:00
if ( ! $i ) {
$totalarray [ 'type' ][ $totalarray [ 'nbfield' ]] = 'duration' ;
2019-02-01 17:00:04 +01:00
}
2022-06-10 09:17:48 +02:00
$totalarray [ 'val' ][ 'fd.duree' ] += $obj -> duree ;
}
// Action column
if ( empty ( $conf -> global -> MAIN_CHECKBOX_LEFT_COLUMN )) {
2019-03-07 21:29:15 +01:00
print '<td class="nowrap center">' ;
2021-02-25 23:00:32 +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
2020-04-10 10:59:32 +02:00
$selected = 0 ;
2021-02-25 23:00:32 +01:00
if ( in_array ( $obj -> rowid , $arrayofselected )) {
$selected = 1 ;
}
2020-04-10 10:59:32 +02:00
print '<input id="cb' . $obj -> rowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj -> rowid . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
2017-10-13 13:28:26 +02:00
}
print '</td>' ;
2022-06-10 09:17:48 +02:00
}
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-06-19 14:31:08 +02:00
2022-06-10 09:17:48 +02:00
print '</tr>' . " \n " ;
2011-08-21 15:01:34 +02:00
2022-06-10 09:17:48 +02:00
$total += $obj -> duree ;
$i ++ ;
}
2016-07-06 10:28:34 +02:00
2022-05-21 16:25:47 +02:00
2022-06-10 09:17:48 +02:00
// Show total line
include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php' ;
2022-05-21 16:25:47 +02:00
2022-06-10 09:17:48 +02:00
// If no record found
if ( $num == 0 ) {
$colspan = 1 ;
foreach ( $arrayfields as $key => $val ) {
if ( ! empty ( $val [ 'checked' ])) {
$colspan ++ ;
}
}
print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs -> trans ( " NoRecordFound " ) . '</span></td></tr>' ;
}
2014-12-23 18:00:14 +01:00
2022-06-10 09:17:48 +02:00
$db -> free ( $resql );
2017-06-19 14:31:08 +02:00
2022-06-10 09:17:48 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2017-06-19 14:31:08 +02:00
2022-06-10 09:17:48 +02:00
print '</table>' . " \n " ;
print '</div>' . " \n " ;
2017-06-19 14:31:08 +02:00
2022-06-10 09:17:48 +02:00
print '</form>' . " \n " ;
2017-04-09 14:31:56 +02:00
2022-06-10 09:17:48 +02:00
if ( in_array ( 'builddoc' , $arrayofmassactions ) && ( $nbtotalofrecords === '' || $nbtotalofrecords )) {
2019-11-12 09:46:08 +01:00
$hidegeneratedfilelistifempty = 1 ;
2021-02-25 23:00:32 +01:00
if ( $massaction == 'builddoc' || $action == 'remove_file' || $show_files ) {
$hidegeneratedfilelistifempty = 0 ;
}
2017-06-19 14:31:08 +02:00
2022-06-10 09:17:48 +02: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-06-19 14:31:08 +02:00
2019-11-12 09:46:08 +01:00
$filedir = $diroutputmassaction ;
$genallowed = $user -> rights -> ficheinter -> lire ;
$delallowed = $user -> rights -> ficheinter -> creer ;
2017-06-19 14:31:08 +02:00
2019-01-27 11:55:16 +01:00
print $formfile -> showdocuments ( 'massfilesarea_interventions' , '' , $filedir , $urlsource , 0 , $delallowed , '' , 1 , 1 , 0 , 48 , 1 , $param , $title , '' , '' , '' , null , $hidegeneratedfilelistifempty );
2011-08-21 15:01:34 +02:00
}
2022-06-10 09:17:48 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2016-07-06 10:28:34 +02:00
$db -> close ();