2011-08-21 15:19:26 +02:00
< ? php
2015-05-23 18:52:31 +02:00
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
* Copyright ( C ) 2003 Eric Seigne < erics @ rycks . com >
* Copyright ( C ) 2004 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2015-05-23 18:52:31 +02:00
* Copyright ( C ) 2013 - 2015 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
* Copyright ( C ) 2013 Cédric Salvador < csalvador @ gpcsolutions . fr >
2019-01-28 21:39:22 +01:00
* Copyright ( C ) 2013 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2015-05-23 18:52:31 +02:00
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
2018-04-18 11:31:10 +02:00
* Copyright ( C ) 2018 Nicolas ZABOURI < info @ inovea - conseil . com >
2018-04-17 10:43:25 +02:00
* Copyright ( C ) 2018 Juanjo Menent < jmenent @ 2 byte . es >
2019-02-14 21:26:39 +01:00
* Copyright ( C ) 2019 Frédéric France < frederic . france @ netlogic . fr >
2019-02-25 19:41:40 +01:00
* Copyright ( C ) 2019 Josep Lluís Amador < joseplluis @ lliuretic . cat >
2020-04-27 17:35:14 +02:00
* Copyright ( C ) 2020 Open - Dsi < support @ open - dsi . fr >
2011-08-21 15:19:26 +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:19:26 +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:19:26 +02:00
*/
/**
* \file htdocs / contact / list . php
* \ingroup societe
* \brief Page to list all contacts
*/
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
2018-06-28 14:06:23 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2013-07-16 21:04:58 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2019-09-03 17:04:42 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
2011-08-21 15:19:26 +02:00
2018-05-26 20:32:23 +02:00
// Load translation files required by the page
2018-12-11 13:25:09 +01:00
$langs -> loadLangs ( array ( " companies " , " suppliers " , " categories " ));
2017-05-23 00:13:07 +02:00
2019-10-01 20:51:49 +02:00
$socialnetworks = getArrayOfSocialNetworks ();
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2019-12-16 13:06:25 +01:00
$massaction = GETPOST ( 'massaction' , 'alpha' );
$show_files = GETPOST ( 'show_files' , 'int' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
2017-05-23 00:13:07 +02:00
$toselect = GETPOST ( 'toselect' , 'array' );
2019-12-16 13:06:25 +01:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'contactlist' ;
2011-08-21 15:19:26 +02:00
// Security check
2019-01-27 11:55:16 +01:00
$id = GETPOST ( 'id' , 'int' );
$contactid = GETPOST ( 'id' , 'int' );
2019-12-16 13:06:25 +01:00
$ref = '' ; // There is no ref for contacts
2021-02-23 21:16:15 +01:00
if ( $user -> socid ) {
$socid = $user -> socid ;
}
2019-01-27 11:55:16 +01:00
$result = restrictedArea ( $user , 'contact' , $contactid , '' );
2011-08-21 15:19:26 +02:00
2019-12-16 13:06:25 +01:00
$sall = trim (( GETPOST ( 'search_all' , 'alphanohtml' ) != '' ) ? GETPOST ( 'search_all' , 'alphanohtml' ) : GETPOST ( 'sall' , 'alphanohtml' ));
$search_cti = preg_replace ( '/^0+/' , '' , preg_replace ( '/[^0-9]/' , '' , GETPOST ( 'search_cti' , 'alphanohtml' ))); // Phone number without any special chars
$search_phone = GETPOST ( " search_phone " , 'alpha' );
2020-08-28 21:27:50 +02:00
$search_id = GETPOST ( " search_id " , " int " );
2019-12-16 13:06:25 +01:00
$search_firstlast_only = GETPOST ( " search_firstlast_only " , 'alpha' );
$search_lastname = GETPOST ( " search_lastname " , 'alpha' );
$search_firstname = GETPOST ( " search_firstname " , 'alpha' );
$search_societe = GETPOST ( " search_societe " , 'alpha' );
$search_poste = GETPOST ( " search_poste " , 'alpha' );
$search_phone_perso = GETPOST ( " search_phone_perso " , 'alpha' );
$search_phone_pro = GETPOST ( " search_phone_pro " , 'alpha' );
$search_phone_mobile = GETPOST ( " search_phone_mobile " , 'alpha' );
$search_fax = GETPOST ( " search_fax " , 'alpha' );
$search_email = GETPOST ( " search_email " , 'alpha' );
2021-11-16 13:31:51 +01:00
if ( ! empty ( $conf -> mailing -> enabled )) {
2021-11-28 16:49:13 +01:00
$search_no_email = GETPOSTISSET ( " search_no_email " ) ? GETPOST ( " search_no_email " , 'int' ) : - 1 ;
2021-11-16 13:31:51 +01:00
} else {
$search_no_email = - 1 ;
}
2019-12-16 13:06:25 +01:00
if ( ! empty ( $conf -> socialnetworks -> enabled )) {
2019-10-01 20:51:49 +02:00
foreach ( $socialnetworks as $key => $value ) {
if ( $value [ 'active' ]) {
2020-08-31 08:10:06 +02:00
$search_ [ $key ] = GETPOST ( " search_ " . $key , 'alpha' );
2019-10-01 20:51:49 +02:00
}
}
}
2019-12-16 13:06:25 +01:00
$search_priv = GETPOST ( " search_priv " , 'alpha' );
$search_categ = GETPOST ( " search_categ " , 'int' );
$search_categ_thirdparty = GETPOST ( " search_categ_thirdparty " , 'int' );
$search_categ_supplier = GETPOST ( " search_categ_supplier " , 'int' );
$search_status = GETPOST ( " search_status " , 'int' );
$search_type = GETPOST ( 'search_type' , 'alpha' );
2021-08-26 14:36:12 +02:00
$search_address = GETPOST ( 'search_address' , 'alpha' );
2019-12-16 13:06:25 +01:00
$search_zip = GETPOST ( 'search_zip' , 'alpha' );
$search_town = GETPOST ( 'search_town' , 'alpha' );
$search_import_key = GETPOST ( " search_import_key " , " alpha " );
$search_country = GETPOST ( " search_country " , 'intcomma' );
$search_roles = GETPOST ( " search_roles " , 'array' );
2020-04-27 17:48:05 +02:00
$search_level = GETPOST ( " search_level " , " array " );
2020-04-27 18:01:07 +02:00
$search_stcomm = GETPOST ( 'search_stcomm' , 'int' );
2017-12-21 12:01:30 +01:00
2021-12-08 18:21:20 +01:00
if ( $search_status === '' ) {
2021-02-23 21:16:15 +01:00
$search_status = 1 ; // always display active customer first
}
2021-12-08 18:21:20 +01:00
if ( $search_no_email === '' ) {
$search_no_email = - 1 ;
}
2015-10-16 22:21:26 +02:00
2019-01-27 11:55:16 +01:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2013-07-10 12:28:28 +02:00
2011-08-21 15:19:26 +02:00
2019-12-16 13:06:25 +01:00
$type = GETPOST ( " type " , 'aZ' );
$view = GETPOST ( " view " , 'alpha' );
2011-08-21 15:19:26 +02:00
2019-12-16 13:06:25 +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' );
2019-12-16 13:06:25 +01:00
$userid = GETPOST ( 'userid' , 'int' );
$begin = GETPOST ( 'begin' );
2021-02-23 21:16:15 +01:00
if ( ! $sortorder ) {
$sortorder = " ASC " ;
}
if ( ! $sortfield ) {
$sortfield = " p.lastname " ;
}
if ( empty ( $page ) || $page < 0 || GETPOST ( 'button_search' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) {
$page = 0 ;
}
2012-02-10 10:53:11 +01:00
$offset = $limit * $page ;
2011-08-21 15:19:26 +02:00
2022-05-23 11:56:39 +02:00
$title = ( ! empty ( $conf -> global -> SOCIETE_ADDRESSES_MANAGEMENT ) ? $langs -> trans ( " Contacts " ) : $langs -> trans ( " ContactsAddresses " ));
2021-02-23 21:16:15 +01:00
if ( $type == " p " ) {
if ( empty ( $contextpage ) || $contextpage == 'contactlist' ) {
$contextpage = 'contactprospectlist' ;
}
2022-05-23 11:56:39 +02:00
$title .= ' (' . $langs -> trans ( " ThirdPartyProspects " ) . ')' ;
2019-12-16 13:06:25 +01:00
$urlfiche = " card.php " ;
2014-10-03 12:15:21 +02:00
}
2021-02-23 21:16:15 +01:00
if ( $type == " c " ) {
if ( empty ( $contextpage ) || $contextpage == 'contactlist' ) {
$contextpage = 'contactcustomerlist' ;
}
2022-05-23 11:56:39 +02:00
$title .= ' (' . $langs -> trans ( " ThirdPartyCustomers " ) . ')' ;
2019-12-16 13:06:25 +01:00
$urlfiche = " card.php " ;
2021-02-23 21:16:15 +01:00
} elseif ( $type == " f " ) {
if ( empty ( $contextpage ) || $contextpage == 'contactlist' ) {
$contextpage = 'contactsupplierlist' ;
}
2022-05-23 11:56:39 +02:00
$title .= ' (' . $langs -> trans ( " ThirdPartySuppliers " ) . ')' ;
2019-12-16 13:06:25 +01:00
$urlfiche = " card.php " ;
2021-02-23 21:16:15 +01:00
} elseif ( $type == " o " ) {
if ( empty ( $contextpage ) || $contextpage == 'contactlist' ) {
$contextpage = 'contactotherlist' ;
}
2022-05-23 11:56:39 +02:00
$title .= ' (' . $langs -> trans ( " OthersNotLinkedToThirdParty " ) . ')' ;
2019-12-16 13:06:25 +01:00
$urlfiche = " " ;
2011-08-21 15:19:26 +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 Contact ( $db );
$hookmanager -> initHooks ( array ( 'contactlist' ));
2015-11-03 15:32:16 +01:00
$extrafields = new ExtraFields ( $db );
// 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_' );
2015-11-03 15:32:16 +01:00
// List of fields to search into when doing a "search in all"
2020-09-29 14:59:16 +02:00
$fieldstosearchall = array ();
2021-02-23 21:16:15 +01:00
foreach ( $object -> fields as $key => $val ) {
2020-09-29 14:59:16 +02:00
// don't allow search in private notes for external users when doing "search in all"
if ( ! empty ( $user -> socid ) && $key == " note_private " ) {
continue ;
}
if ( empty ( $val [ 'searchall' ])) {
continue ;
}
$fieldstosearchall [ 'p.' . $key ] = $val [ 'label' ];
}
// Add none object fields for "search in all"
2020-10-07 15:01:28 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_CONTACTS )) {
2020-09-30 11:45:29 +02:00
$fieldstosearchall [ 's.nom' ] = " ThirdParty " ;
2020-09-29 14:59:16 +02:00
}
2015-11-03 15:32:16 +01:00
2015-11-11 17:05:18 +01:00
// Definition of fields for list
2020-09-29 14:59:16 +02:00
$arrayfields = array ();
foreach ( $object -> fields as $key => $val ) {
// If $val['visible']==0, then we never show the field
if ( empty ( $val [ 'visible' ])) {
continue ;
}
$arrayfields [ 'p.' . $key ] = array (
'label' => $val [ 'label' ],
'checked' => (( $val [ 'visible' ] < 0 ) ? 0 : 1 ),
'enabled' => ( $val [ 'enabled' ] && ( $val [ 'visible' ] != 3 )),
'position' => $val [ 'position' ]);
}
// Add none object fields to fields for list
2022-07-29 12:52:27 +02:00
$arrayfields [ 'country.code_iso' ] = array ( 'label' => " Country " , 'position' => 66 , 'checked' => 0 );
2020-10-07 15:01:28 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_CONTACTS )) {
2022-07-29 12:52:27 +02:00
$arrayfields [ 's.nom' ] = array ( 'label' => " ThirdParty " , 'position' => 113 , 'checked' => 1 );
2020-08-02 22:30:23 +02:00
}
2021-10-26 13:52:00 +02:00
$arrayfields [ 'unsubscribed' ] = array (
'label' => 'No_Email' ,
'checked' => 0 ,
'enabled' => ( ! empty ( $conf -> mailing -> enabled )),
2022-07-29 12:52:27 +02:00
'position' => 111 );
2021-10-26 13:52:00 +02:00
2019-12-16 13:06:25 +01:00
if ( ! empty ( $conf -> socialnetworks -> enabled )) {
2019-10-01 20:51:49 +02:00
foreach ( $socialnetworks as $key => $value ) {
if ( $value [ 'active' ]) {
$arrayfields [ 'p.' . $key ] = array (
'label' => $value [ 'label' ],
'checked' => 0 ,
2019-12-20 11:14:16 +01:00
'position' => 300
2019-10-01 20:51:49 +02:00
);
}
}
}
2020-09-30 11:45:29 +02:00
2015-11-11 17:05:18 +01: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-06 12:19:45 +01:00
2019-10-22 17:08:37 +02:00
$object -> fields = dol_sort_array ( $object -> fields , 'position' );
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2015-11-11 17:05:18 +01:00
2021-02-23 21:16:15 +01:00
if (( $id > 0 || ! empty ( $ref )) && $action != 'add' ) {
2019-11-12 09:46:08 +01:00
$result = $object -> fetch ( $id , $ref );
2021-02-23 21:16:15 +01:00
if ( $result < 0 ) {
dol_print_error ( $db );
}
2015-12-17 14:01:22 +01:00
}
2015-11-03 15:32:16 +01:00
/*
* Actions
*/
2021-02-23 21:16:15 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
$action = 'list' ; $massaction = '' ;
}
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) {
$massaction = '' ;
}
2016-11-02 12:16:46 +01:00
2019-11-12 09:46:08 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-23 21:16:15 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2015-11-03 15:32:16 +01:00
2021-02-23 21:16:15 +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' ;
// Did we click on purge search criteria ?
2021-02-23 21:16:15 +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-12-16 13:06:25 +01:00
$sall = " " ;
$search_id = '' ;
$search_firstlast_only = " " ;
$search_lastname = " " ;
$search_firstname = " " ;
$search_societe = " " ;
$search_town = " " ;
2021-08-26 14:36:12 +02:00
$search_address = " " ;
2019-12-16 13:06:25 +01:00
$search_zip = " " ;
$search_country = " " ;
$search_poste = " " ;
$search_phone = " " ;
$search_phone_perso = " " ;
$search_phone_pro = " " ;
$search_phone_mobile = " " ;
$search_fax = " " ;
$search_email = " " ;
$search_no_email = - 1 ;
if ( ! empty ( $conf -> socialnetworks -> enabled )) {
2019-10-01 20:51:49 +02:00
foreach ( $socialnetworks as $key => $value ) {
if ( $value [ 'active' ]) {
2020-08-31 08:10:06 +02:00
$search_ [ $key ] = " " ;
2019-10-01 20:51:49 +02:00
}
}
}
2019-12-16 13:06:25 +01:00
$search_priv = " " ;
2020-09-07 10:18:17 +02:00
$search_stcomm = '' ;
$search_level = '' ;
2019-12-16 13:06:25 +01:00
$search_status = - 1 ;
$search_categ = '' ;
$search_categ_thirdparty = '' ;
$search_categ_supplier = '' ;
$search_import_key = '' ;
2020-12-23 23:44:38 +01:00
$toselect = array ();
2019-12-16 13:06:25 +01:00
$search_array_options = array ();
$search_roles = array ();
2017-10-13 13:28:26 +02:00
}
// Mass actions
2019-12-16 13:06:25 +01:00
$objectclass = 'Contact' ;
$objectlabel = 'Contact' ;
2019-11-04 15:33:49 +01:00
$permissiontoread = $user -> rights -> societe -> lire ;
$permissiontodelete = $user -> rights -> societe -> supprimer ;
2020-12-23 23:32:50 +01:00
$permissiontoadd = $user -> rights -> societe -> creer ;
2017-10-13 13:28:26 +02:00
$uploaddir = $conf -> societe -> dir_output ;
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
2020-04-27 17:35:14 +02:00
2021-02-23 21:16:15 +01:00
if ( $action == 'setstcomm' ) {
2020-04-27 17:35:14 +02:00
$object = new Contact ( $db );
2020-04-27 17:48:05 +02:00
$result = $object -> fetch ( GETPOST ( 'stcommcontactid' ));
$object -> stcomm_id = dol_getIdFromCode ( $db , GETPOST ( 'stcomm' , 'alpha' ), 'c_stcommcontact' );
$result = $object -> update ( $object -> id , $user );
2021-02-23 21:16:15 +01:00
if ( $result < 0 ) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2020-04-27 17:35:14 +02:00
2020-04-27 17:48:05 +02:00
$action = '' ;
2020-04-27 17:35:14 +02:00
}
2015-11-03 15:32:16 +01:00
}
2021-02-23 21:16:15 +01:00
if ( $search_priv < 0 ) {
$search_priv = '' ;
}
2011-08-21 15:19:26 +02:00
/*
* View
*/
2019-12-16 13:06:25 +01:00
$form = new Form ( $db );
$formother = new FormOther ( $db );
$formcompany = new FormCompany ( $db );
$contactstatic = new Contact ( $db );
2020-08-07 12:49:21 +02:00
2022-07-20 16:35:51 +02:00
$morejs = array ();
$morecss = array ();
2020-09-07 10:18:17 +02:00
if ( ! empty ( $conf -> global -> THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES )) {
2020-08-07 12:49:21 +02:00
$contactstatic -> loadCacheOfProspStatus ();
}
2015-11-03 15:32:16 +01:00
2019-12-16 13:06:25 +01:00
$title = ( ! empty ( $conf -> global -> SOCIETE_ADDRESSES_MANAGEMENT ) ? $langs -> trans ( " Contacts " ) : $langs -> trans ( " ContactsAddresses " ));
2011-08-21 15:19:26 +02:00
2020-04-27 17:35:14 +02:00
// Select every potentiels, and note each potentiels which fit in search parameters
$tab_level = array ();
$sql = " SELECT code, label, sortorder " ;
2020-09-07 10:18:17 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " c_prospectcontactlevel " ;
$sql .= " WHERE active > 0 " ;
$sql .= " ORDER BY sortorder " ;
2020-04-27 17:35:14 +02:00
$resql = $db -> query ( $sql );
2021-02-23 21:16:15 +01:00
if ( $resql ) {
while ( $obj = $db -> fetch_object ( $resql )) {
2020-04-27 17:35:14 +02:00
// Compute level text
2020-09-07 10:18:17 +02:00
$level = $langs -> trans ( $obj -> code );
2021-02-23 21:16:15 +01:00
if ( $level == $obj -> code ) {
$level = $langs -> trans ( $obj -> label );
}
2020-04-27 17:35:14 +02:00
$tab_level [ $obj -> code ] = $level ;
}
2021-02-23 21:16:15 +01:00
} else {
dol_print_error ( $db );
2020-04-27 17:35:14 +02:00
}
2012-02-01 00:24:16 +01:00
$sql = " SELECT s.rowid as socid, s.nom as name, " ;
2021-10-26 13:52:00 +02:00
$sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email, " ;
2020-02-10 12:56:08 +01:00
$sql .= " p.socialnetworks, p.photo, " ;
2019-12-16 13:06:25 +01:00
$sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update, " ;
2022-07-29 11:54:56 +02:00
$sql .= " p.import_key, " ;
2020-09-07 10:18:17 +02:00
$sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel, " ;
2019-12-16 13:06:25 +01:00
$sql .= " co.label as country, co.code as country_code " ;
2015-11-03 15:32:16 +01:00
// Add fields from extrafields
2019-12-16 13:06:25 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-23 21:16:15 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) {
2021-08-27 22:42:04 +02:00
$sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " , ef. " . $key . " as options_ " . $key : '' );
2021-02-23 21:16:15 +01:00
}
2019-10-16 03:34:32 +02:00
}
2021-10-26 13:52:00 +02:00
if ( ! empty ( $conf -> mailing -> enabled )) {
$sql .= " , (SELECT count(*) FROM " . MAIN_DB_PREFIX . " mailing_unsubscribe WHERE email = p.email) as unsubscribed " ;
}
2015-11-03 15:32:16 +01:00
// Add fields from hooks
2019-12-16 13:06:25 +01:00
$parameters = array ();
2022-03-22 10:10:42 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2019-12-16 13:06:25 +01:00
$sql .= $hookmanager -> resPrint ;
$sql .= " FROM " . MAIN_DB_PREFIX . " socpeople as p " ;
2021-09-02 18:48:46 +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-23 21:16:15 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object -> table_element . " _extrafields as ef on (p.rowid = ef.fk_object) " ;
}
2019-12-16 13:06:25 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_country as co ON co.rowid = p.fk_pays " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s ON s.rowid = p.fk_soc " ;
2020-09-07 10:18:17 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_stcommcontact as st ON st.id = p.fk_stcommcontact " ;
2021-06-17 03:37:52 +02:00
if ( ! empty ( $search_categ ) && $search_categ != '-1' ) {
2021-02-23 21:16:15 +01:00
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . " categorie_contact as cc ON p.rowid = cc.fk_socpeople " ; // We need this table joined to the select in order to filter by categ
}
2021-06-17 03:37:52 +02:00
if ( ! empty ( $search_categ_thirdparty ) && $search_categ_thirdparty != '-1' ) {
2021-02-23 21:16:15 +01:00
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . " categorie_societe as cs ON s.rowid = cs.fk_soc " ; // We need this table joined to the select in order to filter by categ
}
2021-06-17 03:37:52 +02:00
if ( ! empty ( $search_categ_supplier ) && $search_categ_supplier != '-1' ) {
2021-02-23 21:16:15 +01:00
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . " categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc " ; // We need this table joined to the select in order to filter by categ
}
2021-10-22 22:15:59 +02:00
if ( empty ( $user -> rights -> societe -> client -> voir ) && ! $socid ) {
2021-02-23 21:16:15 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe_commerciaux as sc ON s.rowid = sc.fk_soc " ;
}
2022-03-18 12:05:59 +01:00
$sql .= ' WHERE p.entity IN (' . getEntity ( 'contact' ) . ')' ;
2021-10-22 22:15:59 +02:00
if ( empty ( $user -> rights -> societe -> client -> voir ) && ! $socid ) { //restriction
2021-08-23 17:41:11 +02:00
$sql .= " AND (sc.fk_user = " . (( int ) $user -> id ) . " OR p.fk_soc IS NULL) " ;
2011-08-21 15:19:26 +02:00
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $userid )) { // propre au commercial
2021-06-09 15:36:47 +02:00
$sql .= " AND p.fk_user_creat= " . (( int ) $userid );
2011-08-21 15:19:26 +02:00
}
2021-02-23 21:16:15 +01:00
if ( $search_level ) {
$sql .= natural_search ( " p.fk_prospectcontactlevel " , join ( ',' , $search_level ), 3 );
}
if ( $search_stcomm != '' && $search_stcomm != - 2 ) {
$sql .= natural_search ( " p.fk_stcommcontact " , $search_stcomm , 2 );
}
2011-08-21 15:19:26 +02:00
// Filter to exclude not owned private contacts
2021-02-23 21:16:15 +01:00
if ( $search_priv != '0' && $search_priv != '1' ) {
2021-08-23 17:41:11 +02:00
$sql .= " AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat= " . (( int ) $user -> id ) . " )) " ;
2020-05-21 15:05:19 +02:00
} else {
2021-02-23 21:16:15 +01:00
if ( $search_priv == '0' ) {
$sql .= " AND p.priv='0' " ;
}
if ( $search_priv == '1' ) {
2021-08-23 17:41:11 +02:00
$sql .= " AND (p.priv='1' AND p.fk_user_creat= " . (( int ) $user -> id ) . " ) " ;
2021-02-23 21:16:15 +01:00
}
}
if ( $search_categ > 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND cc.fk_categorie = " . (( int ) $search_categ );
2021-02-23 21:16:15 +01:00
}
if ( $search_categ == - 2 ) {
$sql .= " AND cc.fk_categorie IS NULL " ;
}
if ( $search_categ_thirdparty > 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND cs.fk_categorie = " . (( int ) $search_categ_thirdparty );
2021-02-23 21:16:15 +01:00
}
if ( $search_categ_thirdparty == - 2 ) {
$sql .= " AND cs.fk_categorie IS NULL " ;
}
if ( $search_categ_supplier > 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND cs2.fk_categorie = " . (( int ) $search_categ_supplier );
2021-02-23 21:16:15 +01:00
}
if ( $search_categ_supplier == - 2 ) {
$sql .= " AND cs2.fk_categorie IS NULL " ;
}
if ( $sall ) {
$sql .= natural_search ( array_keys ( $fieldstosearchall ), $sall );
}
if ( strlen ( $search_phone )) {
$sql .= natural_search ( array ( 'p.phone' , 'p.phone_perso' , 'p.phone_mobile' ), $search_phone );
}
if ( strlen ( $search_cti )) {
$sql .= natural_search ( array ( 'p.phone' , 'p.phone_perso' , 'p.phone_mobile' ), $search_cti );
}
if ( strlen ( $search_firstlast_only )) {
$sql .= natural_search ( array ( 'p.lastname' , 'p.firstname' ), $search_firstlast_only );
}
if ( $search_id > 0 ) {
$sql .= natural_search ( 'p.rowid' , $search_id , 1 );
}
if ( $search_lastname ) {
$sql .= natural_search ( 'p.lastname' , $search_lastname );
}
if ( $search_firstname ) {
$sql .= natural_search ( 'p.firstname' , $search_firstname );
}
if ( $search_societe ) {
$sql .= natural_search ( empty ( $conf -> global -> SOCIETE_DISABLE_CONTACTS ) ? 's.nom' : 'p.fk_soc' , $search_societe );
}
if ( $search_country ) {
2021-03-22 11:30:18 +01:00
$sql .= " AND p.fk_pays IN ( " . $db -> sanitize ( $search_country ) . ')' ;
2021-02-23 21:16:15 +01:00
}
if ( strlen ( $search_poste )) {
$sql .= natural_search ( 'p.poste' , $search_poste );
}
if ( strlen ( $search_phone_perso )) {
$sql .= natural_search ( 'p.phone_perso' , $search_phone_perso );
}
if ( strlen ( $search_phone_pro )) {
$sql .= natural_search ( 'p.phone' , $search_phone_pro );
}
if ( strlen ( $search_phone_mobile )) {
$sql .= natural_search ( 'p.phone_mobile' , $search_phone_mobile );
}
if ( strlen ( $search_fax )) {
$sql .= natural_search ( 'p.fax' , $search_fax );
}
2019-12-16 13:06:25 +01:00
if ( ! empty ( $conf -> socialnetworks -> enabled )) {
2019-10-01 20:51:49 +02:00
foreach ( $socialnetworks as $key => $value ) {
2020-08-31 08:10:06 +02:00
if ( $value [ 'active' ] && strlen ( $search_ [ $key ])) {
2022-10-19 17:01:18 +02:00
$searchkeyinjsonformat = preg_replace ( '/"$/' , '' , preg_replace ( '/^"/' , '' , json_encode ( $search_ [ $key ])));
if ( in_array ( $db -> type , array ( 'mysql' , 'mysqli' ))) {
2022-11-21 03:58:22 +01:00
$sql .= " AND p.socialnetworks REGEXP ' \" " . $db -> escape ( $db -> escapeforlike ( $key )) . " \" : \" [^ \" ]* " . $db -> escape ( $db -> escapeforlike ( $searchkeyinjsonformat )) . " ' " ;
2022-10-19 17:01:18 +02:00
} elseif ( $db -> type == 'pgsql' ) {
2022-11-21 03:58:22 +01:00
$sql .= " AND p.socialnetworks ~ ' \" " . $db -> escape ( $db -> escapeforlike ( $key )) . " \" : \" [^ \" ]* " . $db -> escape ( $db -> escapeforlike ( $searchkeyinjsonformat )) . " ' " ;
2022-10-19 17:01:18 +02:00
} else {
// Works with all database but not reliable because search only for social network code starting with earched value
2022-11-21 03:58:22 +01:00
$sql .= " AND p.socialnetworks LIKE '% \" " . $db -> escape ( $db -> escapeforlike ( $key )) . " \" : \" " . $db -> escape ( $db -> escapeforlike ( $searchkeyinjsonformat )) . " %' " ;
2022-10-19 17:01:18 +02:00
}
2019-10-01 20:51:49 +02:00
}
}
}
2022-11-21 03:58:22 +01:00
//print $sql;
2021-02-23 21:16:15 +01:00
if ( strlen ( $search_email )) {
$sql .= natural_search ( 'p.email' , $search_email );
}
2021-08-26 14:36:12 +02:00
if ( strlen ( $search_address )) {
$sql .= natural_search ( " p.address " , $search_address );
}
2021-02-23 21:16:15 +01:00
if ( strlen ( $search_zip )) {
$sql .= natural_search ( " p.zip " , $search_zip );
}
if ( strlen ( $search_town )) {
$sql .= natural_search ( " p.town " , $search_town );
}
2019-12-16 13:06:25 +01:00
if ( count ( $search_roles ) > 0 ) {
2021-03-22 11:30:18 +01:00
$sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM " . MAIN_DB_PREFIX . " societe_contacts as sc WHERE sc.fk_c_type_contact IN ( " . $db -> sanitize ( implode ( ',' , $search_roles )) . " )) " ;
2019-09-02 22:01:48 +02:00
}
2021-10-26 13:52:00 +02:00
if ( $search_no_email != - 1 && $search_no_email > 0 ) {
$sql .= " AND (SELECT count(*) FROM " . MAIN_DB_PREFIX . " mailing_unsubscribe WHERE email = p.email) > 0 " ;
}
if ( $search_no_email != - 1 && $search_no_email == 0 ) {
$sql .= " AND (SELECT count(*) FROM " . MAIN_DB_PREFIX . " mailing_unsubscribe WHERE email = p.email) = 0 AND p.email IS NOT NULL AND p.email <> '' " ;
2021-02-23 21:16:15 +01:00
}
if ( $search_status != '' && $search_status >= 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND p.statut = " . (( int ) $search_status );
2021-02-23 21:16:15 +01:00
}
if ( $search_import_key ) {
$sql .= natural_search ( " p.import_key " , $search_import_key );
}
if ( $type == " o " ) { // filtre sur type
2017-10-13 13:28:26 +02:00
$sql .= " AND p.fk_soc IS NULL " ;
2021-02-23 21:16:15 +01:00
} elseif ( $type == " f " ) { // filtre sur type
2017-10-13 13:28:26 +02:00
$sql .= " AND s.fournisseur = 1 " ;
2021-02-23 21:16:15 +01:00
} elseif ( $type == " c " ) { // filtre sur type
2017-10-13 13:28:26 +02:00
$sql .= " AND s.client IN (1, 3) " ;
2021-02-23 21:16:15 +01:00
} elseif ( $type == " p " ) { // filtre sur type
2017-10-13 13:28:26 +02:00
$sql .= " AND s.client IN (2, 3) " ;
2011-08-21 15:19:26 +02:00
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $socid )) {
2021-04-24 20:18:11 +02:00
$sql .= " AND s.rowid = " . (( int ) $socid );
2011-08-21 15:19:26 +02:00
}
2015-11-03 15:32:16 +01:00
// Add where from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php' ;
2015-11-03 15:32:16 +01:00
// Add where from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
2022-03-22 10:10:42 +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 ;
2016-02-11 20:24:15 +01:00
// Add order
2021-02-23 21:16:15 +01:00
if ( $view == " recent " ) {
2019-11-12 09:46:08 +01:00
$sql .= $db -> order ( " p.datec " , " DESC " );
2020-05-21 15:05:19 +02:00
} else {
2019-11-12 09:46:08 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2016-02-11 20:24:15 +01:00
}
2022-10-19 17:01:18 +02:00
//print $sql;
2016-02-11 20:24:15 +01:00
2011-08-21 15:19:26 +02:00
// Count total nb of records
2017-01-15 20:49:20 +01:00
$nbtotalofrecords = '' ;
2021-02-23 21:16:15 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST )) {
2020-07-29 13:47:04 +02:00
$resql = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $resql );
2021-02-23 21:16:15 +01:00
if (( $page * $limit ) > $nbtotalofrecords ) { // if total resultset is smaller then paging size (filtering), goto and load page 0
2018-04-24 11:37:57 +02:00
$page = 0 ;
$offset = 0 ;
}
2011-08-21 15:19:26 +02:00
}
2015-11-03 15:32:16 +01:00
2019-11-12 09:46:08 +01:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2011-08-21 15:19:26 +02:00
2020-07-29 12:00:22 +02:00
$resql = $db -> query ( $sql );
2021-02-23 21:16:15 +01:00
if ( ! $resql ) {
2017-10-13 13:28:26 +02:00
dol_print_error ( $db );
exit ;
2016-11-02 12:16:46 +01:00
}
2011-08-21 15:19:26 +02:00
2020-07-29 13:47:04 +02:00
$num = $db -> num_rows ( $resql );
2016-02-10 23:37:34 +01:00
2019-11-12 09:46:08 +01:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2017-05-23 00:13:07 +02:00
2021-02-23 21:16:15 +01:00
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && ( $sall != '' || $search_cti != '' )) {
2017-10-13 13:28:26 +02:00
$obj = $db -> fetch_object ( $resql );
$id = $obj -> rowid ;
header ( " Location: " . DOL_URL_ROOT . '/contact/card.php?id=' . $id );
exit ;
2016-11-02 12:16:46 +01:00
}
2019-11-12 09:46:08 +01:00
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas' ;
2019-01-27 11:55:16 +01:00
llxHeader ( '' , $title , $help_url );
2016-11-02 12:16:46 +01:00
2019-11-12 09:46:08 +01:00
$param = '' ;
2021-02-23 21:16:15 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
2021-10-26 13:52:00 +02:00
$param .= '&contextpage=' . urlencode ( $contextpage );
2021-02-23 21:16:15 +01:00
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
2021-10-26 13:52:00 +02:00
$param .= '&limit=' . (( int ) $limit );
2021-02-23 21:16:15 +01:00
}
2021-10-26 13:52:00 +02:00
$param .= '&begin=' . urlencode ( $begin ) . '&userid=' . urlencode ( $userid ) . '&contactname=' . urlencode ( $sall );
$param .= '&type=' . urlencode ( $type ) . '&view=' . urlencode ( $view );
2021-09-27 11:38:34 +02:00
if ( ! empty ( $search_categ ) && $search_categ != '-1' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_categ=' . urlencode ( $search_categ );
2021-02-23 21:16:15 +01:00
}
2021-09-27 11:38:34 +02:00
if ( ! empty ( $search_categ_thirdparty ) && $search_categ_thirdparty != '-1' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_categ_thirdparty=' . urlencode ( $search_categ_thirdparty );
2021-02-23 21:16:15 +01:00
}
2021-09-27 11:38:34 +02:00
if ( ! empty ( $search_categ_supplier ) && $search_categ_supplier != '-1' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_categ_supplier=' . urlencode ( $search_categ_supplier );
2021-02-23 21:16:15 +01:00
}
if ( $sall != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&sall=' . urlencode ( $sall );
2021-02-23 21:16:15 +01:00
}
if ( $search_id > 0 ) {
2021-10-26 13:52:00 +02:00
$param .= " &search_id= " . urlencode ( $search_id );
2021-02-23 21:16:15 +01:00
}
if ( $search_lastname != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_lastname=' . urlencode ( $search_lastname );
2021-02-23 21:16:15 +01:00
}
if ( $search_firstname != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_firstname=' . urlencode ( $search_firstname );
2021-02-23 21:16:15 +01:00
}
if ( $search_societe != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_societe=' . urlencode ( $search_societe );
2021-02-23 21:16:15 +01:00
}
2021-08-26 14:36:12 +02:00
if ( $search_address != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_address=' . urlencode ( $search_address );
2021-08-26 14:36:12 +02:00
}
2021-02-23 21:16:15 +01:00
if ( $search_zip != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_zip=' . urlencode ( $search_zip );
2021-02-23 21:16:15 +01:00
}
if ( $search_town != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_town=' . urlencode ( $search_town );
2021-02-23 21:16:15 +01:00
}
if ( $search_country != '' ) {
$param .= " &search_country= " . urlencode ( $search_country );
}
if ( $search_poste != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_poste=' . urlencode ( $search_poste );
2021-02-23 21:16:15 +01:00
}
if ( $search_phone_pro != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_phone_pro=' . urlencode ( $search_phone_pro );
2021-02-23 21:16:15 +01:00
}
if ( $search_phone_perso != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_phone_perso=' . urlencode ( $search_phone_perso );
2021-02-23 21:16:15 +01:00
}
if ( $search_phone_mobile != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_phone_mobile=' . urlencode ( $search_phone_mobile );
2021-02-23 21:16:15 +01:00
}
if ( $search_fax != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_fax=' . urlencode ( $search_fax );
2021-02-23 21:16:15 +01:00
}
if ( $search_email != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_email=' . urlencode ( $search_email );
2021-02-23 21:16:15 +01:00
}
if ( $search_no_email != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_no_email=' . urlencode ( $search_no_email );
2021-02-23 21:16:15 +01:00
}
if ( $search_status != '' ) {
2021-10-26 13:52:00 +02:00
$param .= '&search_status=' . urlencode ( $search_status );
2021-02-23 21:16:15 +01:00
}
if ( $search_priv == '0' || $search_priv == '1' ) {
2021-10-26 13:52:00 +02:00
$param .= " &search_priv= " . urlencode ( $search_priv );
2021-02-23 21:16:15 +01:00
}
if ( $search_stcomm != '' ) {
$param .= '&search_stcomm=' . urlencode ( $search_stcomm );
}
2020-08-02 22:30:23 +02:00
if ( is_array ( $search_level ) && count ( $search_level )) {
2020-08-02 22:44:37 +02:00
foreach ( $search_level as $slevel ) {
2020-09-07 10:18:17 +02:00
$param .= '&search_level[]=' . urlencode ( $slevel );
2020-08-02 22:30:23 +02:00
}
}
2021-02-23 21:16:15 +01:00
if ( $search_import_key != '' ) {
$param .= '&search_import_key=' . urlencode ( $search_import_key );
}
if ( $optioncss != '' ) {
$param .= '&optioncss=' . urlencode ( $optioncss );
}
if ( count ( $search_roles ) > 0 ) {
$param .= implode ( '&search_roles[]=' , $search_roles );
}
2017-12-21 12:01:30 +01:00
2016-11-02 12:16:46 +01:00
// Add $param from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
2016-11-02 12:16:46 +01:00
2017-05-23 00:13:07 +02:00
// List of mass actions available
2019-11-12 09:46:08 +01:00
$arrayofmassactions = array (
2021-04-14 14:45:55 +02:00
// 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
// 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
2017-05-23 00:13:07 +02:00
);
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
2021-02-23 21:16:15 +01:00
if ( $user -> rights -> societe -> supprimer ) {
2021-04-14 12:28:01 +02:00
$arrayofmassactions [ 'predelete' ] = img_picto ( '' , 'delete' , 'class="pictofixedwidth"' ) . $langs -> trans ( " Delete " );
2021-02-23 21:16:15 +01:00
}
2022-09-23 11:46:55 +02:00
if ( isModEnabled ( 'category' ) && $user -> rights -> societe -> creer ) {
2021-04-14 12:33:53 +02:00
$arrayofmassactions [ 'preaffecttag' ] = img_picto ( '' , 'category' , 'class="pictofixedwidth"' ) . $langs -> trans ( " AffectTag " );
2021-02-23 21:16:15 +01:00
}
if ( in_array ( $massaction , array ( 'presend' , 'predelete' , 'preaffecttag' ))) {
$arrayofmassactions = array ();
}
2019-11-12 09:46:08 +01:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2017-05-23 00:13:07 +02:00
2020-09-18 11:48:53 +02:00
$newcardbutton = dolGetButtonTitle ( $langs -> trans ( 'NewContactAddress' ), '' , 'fa fa-plus-circle' , DOL_URL_ROOT . '/contact/card.php?action=create' , '' , $user -> rights -> societe -> contact -> creer );
2018-03-30 16:54:38 +02:00
2017-05-23 00:13:07 +02:00
print '<form method="post" action="' . $_SERVER [ " PHP_SELF " ] . '" name="formfilter">' ;
2021-02-23 21:16:15 +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 () . '">' ;
2016-11-02 12:16:46 +01:00
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
2020-03-17 03:24:24 +01:00
//print '<input type="hidden" name="page" value="'.$page.'">';
2018-06-23 12:06:17 +02:00
print '<input type="hidden" name="type" value="' . $type . '">' ;
2017-05-23 00:13:07 +02:00
print '<input type="hidden" name="view" value="' . dol_escape_htmltag ( $view ) . '">' ;
2016-11-02 12:16:46 +01:00
2022-05-23 11:56:39 +02:00
print_barre_liste ( $title , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'address' , 0 , $newcardbutton , '' , $limit , 0 , 0 , 1 );
2016-11-02 12:16:46 +01:00
2019-11-12 09:46:08 +01:00
$topicmail = " Information " ;
$modelmail = " contact " ;
$objecttmp = new Contact ( $db );
$trackid = 'ctc' . $object -> id ;
2017-11-11 16:03:22 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2021-02-23 21:16:15 +01:00
if ( $sall ) {
foreach ( $fieldstosearchall as $key => $val ) {
$fieldstosearchall [ $key ] = $langs -> trans ( $val );
}
2019-11-12 09:46:08 +01:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
2016-11-02 12:16:46 +01:00
}
2021-02-23 21:16:15 +01:00
if ( $search_firstlast_only ) {
2019-11-12 09:46:08 +01:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $search_firstlast_only ) . $langs -> trans ( " Lastname " ) . " , " . $langs -> trans ( " Firstname " ) . '</div>' ;
2016-11-02 12:16:46 +01:00
}
2019-11-12 09:46:08 +01:00
$moreforfilter = '' ;
2021-02-23 21:16:15 +01:00
if ( ! empty ( $conf -> categorie -> enabled ) && $user -> rights -> categorie -> lire ) {
2019-11-12 09:46:08 +01:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
$moreforfilter .= '<div class="divsearchfield">' ;
2021-03-27 12:45:57 +01:00
$tmptitle = $langs -> trans ( 'ContactCategoriesShort' );
$moreforfilter .= img_picto ( $tmptitle , 'category' , 'class="pictofixedwidth"' );
$moreforfilter .= $formother -> select_categories ( Categorie :: TYPE_CONTACT , $search_categ , 'search_categ' , 1 , $tmptitle );
2019-11-12 09:46:08 +01:00
$moreforfilter .= '</div>' ;
2021-02-23 21:16:15 +01:00
if ( empty ( $type ) || $type == 'c' || $type == 'p' ) {
2019-11-12 09:46:08 +01:00
$moreforfilter .= '<div class="divsearchfield">' ;
2021-03-27 12:45:57 +01:00
$tmptitle = '' ;
2021-02-23 21:16:15 +01:00
if ( $type == 'c' ) {
2021-03-27 12:45:57 +01:00
$tmptitle .= $langs -> trans ( 'CustomersCategoriesShort' );
2021-02-23 21:16:15 +01:00
} elseif ( $type == 'p' ) {
2021-03-27 12:45:57 +01:00
$tmptitle .= $langs -> trans ( 'ProspectsCategoriesShort' );
2021-02-23 21:16:15 +01:00
} else {
2021-03-27 12:45:57 +01:00
$tmptitle .= $langs -> trans ( 'CustomersProspectsCategoriesShort' );
2021-02-23 21:16:15 +01:00
}
2021-03-27 12:45:57 +01:00
$moreforfilter .= img_picto ( $tmptitle , 'category' , 'class="pictofixedwidth"' );
$moreforfilter .= $formother -> select_categories ( Categorie :: TYPE_CUSTOMER , $search_categ_thirdparty , 'search_categ_thirdparty' , 1 , $tmptitle );
2019-11-12 09:46:08 +01:00
$moreforfilter .= '</div>' ;
2016-11-02 12:16:46 +01:00
}
2021-04-22 17:21:09 +02:00
2021-04-22 17:23:37 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && ( empty ( $type ) || $type == 'f' )) {
2019-11-12 09:46:08 +01:00
$moreforfilter .= '<div class="divsearchfield">' ;
2021-03-27 12:45:57 +01:00
$tmptitle = $langs -> trans ( 'SuppliersCategoriesShort' );
$moreforfilter .= img_picto ( $tmptitle , 'category' , 'class="pictofixedwidth"' );
$moreforfilter .= $formother -> select_categories ( Categorie :: TYPE_SUPPLIER , $search_categ_supplier , 'search_categ_supplier' , 1 , $tmptitle );
2019-11-12 09:46:08 +01:00
$moreforfilter .= '</div>' ;
2015-11-03 15:32:16 +01:00
}
2016-11-02 12:16:46 +01:00
}
2020-09-28 10:42:49 +02:00
$moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= $langs -> trans ( 'Roles' ) . ': ' ;
$moreforfilter .= $formcompany -> showRoles ( " search_roles " , $objecttmp , 'edit' , $search_roles );
$moreforfilter .= '</div>' ;
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
$parameters = array ( 'type' => $type );
2022-03-22 10:10:42 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2020-09-28 10:42:49 +02:00
print $hookmanager -> resPrint ;
print '</div>' ;
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
2021-02-23 21:16:15 +01:00
if ( $massactionbutton ) {
$selectedfields .= $form -> showCheckAddButtons ( 'checkforselect' , 1 );
}
2016-11-02 12:16:46 +01:00
2016-11-27 13:49:46 +01:00
print '<div class="div-table-responsive">' ;
2019-11-12 09:46:08 +01:00
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2016-11-02 12:16:46 +01:00
// Lines for filter fields
2017-03-27 00:48:50 +02:00
print '<tr class="liste_titre_filter">' ;
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.rowid' ][ 'checked' ])) {
2017-07-27 02:05:11 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat searchstring" type="text" name="search_id" size="1" value="' . dol_escape_htmltag ( $search_id ) . '">' ;
print '</td>' ;
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.lastname' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_lastname" size="6" value="' . dol_escape_htmltag ( $search_lastname ) . '">' ;
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.firstname' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_firstname" size="6" value="' . dol_escape_htmltag ( $search_firstname ) . '">' ;
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.poste' ][ 'checked' ])) {
2018-06-28 14:06:23 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_poste" size="5" value="' . dol_escape_htmltag ( $search_poste ) . '">' ;
print '</td>' ;
}
2021-08-26 14:36:12 +02:00
if ( ! empty ( $arrayfields [ 'p.address' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_address" size="6" value="' . dol_escape_htmltag ( $search_address ) . '">' ;
print '</td>' ;
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.zip' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_zip" size="3" value="' . dol_escape_htmltag ( $search_zip ) . '">' ;
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.town' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_town" size="5" value="' . dol_escape_htmltag ( $search_town ) . '">' ;
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
2018-06-28 14:06:23 +02:00
// State
/* if ( ! empty ( $arrayfields [ 'state.nom' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '<input class="flat searchstring" size="4" type="text" name="search_state" value="' . dol_escape_htmltag ( $search_state ) . '">' ;
print '</td>' ;
}
// Region
if ( ! empty ( $arrayfields [ 'region.nom' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '<input class="flat searchstring" size="4" type="text" name="search_region" value="' . dol_escape_htmltag ( $search_region ) . '">' ;
print '</td>' ;
} */
// Country
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'country.code_iso' ][ 'checked' ])) {
2019-02-14 21:26:39 +01:00
print '<td class="liste_titre center">' ;
2019-03-02 12:57:07 +01:00
print $form -> select_country ( $search_country , 'search_country' , '' , 0 , 'minwidth100imp maxwidth100' );
2017-12-21 12:01:30 +01:00
print '</td>' ;
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.phone' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_phone_pro" size="6" value="' . dol_escape_htmltag ( $search_phone_pro ) . '">' ;
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.phone_perso' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_phone_perso" size="6" value="' . dol_escape_htmltag ( $search_phone_perso ) . '">' ;
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.phone_mobile' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_phone_mobile" size="6" value="' . dol_escape_htmltag ( $search_phone_mobile ) . '">' ;
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.fax' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_fax" size="6" value="' . dol_escape_htmltag ( $search_fax ) . '">' ;
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.email' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_email" size="6" value="' . dol_escape_htmltag ( $search_email ) . '">' ;
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
2021-10-26 13:52:00 +02:00
if ( ! empty ( $arrayfields [ 'unsubscribed' ][ 'checked' ])) {
2019-02-25 19:41:40 +01:00
print '<td class="liste_titre center">' ;
2019-02-27 04:18:25 +01:00
print $form -> selectarray ( 'search_no_email' , array ( '-1' => '' , '0' => $langs -> trans ( 'No' ), '1' => $langs -> trans ( 'Yes' )), $search_no_email );
2019-02-25 19:41:40 +01:00
print '</td>' ;
}
2019-12-16 13:06:25 +01:00
if ( ! empty ( $conf -> socialnetworks -> enabled )) {
2019-10-01 20:51:49 +02:00
foreach ( $socialnetworks as $key => $value ) {
if ( $value [ 'active' ]) {
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.' . $key ][ 'checked' ])) {
2019-10-01 20:51:49 +02:00
print '<td class="liste_titre">' ;
2020-08-31 08:10:06 +02:00
print '<input class="flat" type="text" name="search_' . $key . '" size="6" value="' . dol_escape_htmltag ( $search_ [ $key ]) . '">' ;
2019-10-01 20:51:49 +02:00
print '</td>' ;
}
}
}
2019-02-25 09:07:58 +01:00
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_soc' ][ 'checked' ]) || ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_societe" size="8" value="' . dol_escape_htmltag ( $search_societe ) . '">' ;
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.priv' ][ 'checked' ])) {
2019-02-14 21:26:39 +01:00
print '<td class="liste_titre center">' ;
2020-09-08 21:27:28 +02:00
$selectarray = array ( '0' => $langs -> trans ( " ContactPublic " ), '1' => $langs -> trans ( " ContactPrivate " ));
print $form -> selectarray ( 'search_priv' , $selectarray , $search_priv , 1 );
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
2020-04-27 17:35:14 +02:00
// Prospect level
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_prospectcontactlevel' ][ 'checked' ])) {
2020-04-27 17:35:14 +02:00
print '<td class="liste_titre center">' ;
print $form -> multiselectarray ( 'search_level' , $tab_level , $search_level , 0 , 0 , 'width75' , 0 , 0 , '' , '' , '' , 2 );
print '</td>' ;
}
// Prospect status
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_stcommcontact' ][ 'checked' ])) {
2020-04-27 17:35:14 +02:00
print '<td class="liste_titre maxwidthonsmartphone center">' ;
2020-09-07 10:18:17 +02:00
$arraystcomm = array ();
2021-02-23 21:16:15 +01:00
foreach ( $contactstatic -> cacheprospectstatus as $key => $val ) {
2020-09-07 10:18:17 +02:00
$arraystcomm [ $val [ 'id' ]] = ( $langs -> trans ( " StatusProspect " . $val [ 'id' ]) != " StatusProspect " . $val [ 'id' ] ? $langs -> trans ( " StatusProspect " . $val [ 'id' ]) : $val [ 'label' ]);
2020-04-27 17:35:14 +02:00
}
print $form -> selectarray ( 'search_stcomm' , $arraystcomm , $search_stcomm , - 2 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'nowrap ' );
print '</td>' ;
}
2016-11-02 12:16:46 +01:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
2016-11-02 12:16:46 +01:00
// Fields from hook
2019-11-12 09:46:08 +01:00
$parameters = array ( 'arrayfields' => $arrayfields );
2022-03-22 10:10:42 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2016-11-02 12:16:46 +01:00
print $hookmanager -> resPrint ;
// Date creation
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.datec' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
// Date modification
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.tms' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
2017-05-23 00:13:07 +02:00
// Status
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.statut' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre center">' ;
2019-11-12 09:46:08 +01:00
print $form -> selectarray ( 'search_status' , array ( '-1' => '' , '0' => $langs -> trans ( 'ActivityCeased' ), '1' => $langs -> trans ( 'InActivity' )), $search_status );
2017-10-13 13:28:26 +02:00
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.import_key' ][ 'checked' ])) {
2017-07-27 02:05:11 +02:00
print '<td class="liste_titre center">' ;
print '<input class="flat searchstring" type="text" name="search_import_key" size="3" value="' . dol_escape_htmltag ( $search_import_key ) . '">' ;
print '</td>' ;
}
2017-05-23 00:13:07 +02:00
// Action column
2019-05-19 13:51:47 +02:00
print '<td class="liste_titre maxwidthsearch">' ;
2019-11-12 09:46:08 +01:00
$searchpicto = $form -> showFilterAndCheckAddButtons ( 0 );
2017-05-23 00:13:07 +02:00
print $searchpicto ;
2016-11-02 12:16:46 +01:00
print '</td>' ;
print '</tr>' ;
2011-08-21 15:19:26 +02:00
2017-03-27 00:48:50 +02:00
// Ligne des titres
print '<tr class="liste_titre">' ;
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.rowid' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.rowid' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.rowid " , " " , $param , " " , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.lastname' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.lastname' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.lastname " , $begin , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.firstname' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.firstname' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.firstname " , $begin , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.poste' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.poste' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.poste " , $begin , $param , '' , $sortfield , $sortorder );
}
2021-08-26 14:36:12 +02:00
if ( ! empty ( $arrayfields [ 'p.address' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.address' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.address " , $begin , $param , '' , $sortfield , $sortorder );
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.zip' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.zip' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.zip " , $begin , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.town' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.town' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.town " , $begin , $param , '' , $sortfield , $sortorder );
}
2018-06-28 14:06:23 +02:00
//if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
//if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder);
2019-12-16 13:06:25 +01:00
if ( ! empty ( $arrayfields [ 'country.code_iso' ][ 'checked' ])) {
2020-09-08 21:27:28 +02:00
print_liste_field_titre ( $arrayfields [ 'country.code_iso' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " co.code_iso " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2019-02-24 14:30:02 +01:00
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.phone' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.phone' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.phone " , $begin , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.phone_perso' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.phone_perso' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.phone_perso " , $begin , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.phone_mobile' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.phone_mobile' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.phone_mobile " , $begin , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.fax' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.fax' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.fax " , $begin , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.email' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.email' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.email " , $begin , $param , '' , $sortfield , $sortorder );
}
2021-10-26 13:52:00 +02:00
if ( ! empty ( $arrayfields [ 'unsubscribed' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'unsubscribed' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " unsubscribed " , $begin , $param , '' , $sortfield , $sortorder , 'center ' );
2021-02-23 21:16:15 +01:00
}
2019-12-16 13:06:25 +01:00
if ( ! empty ( $conf -> socialnetworks -> enabled )) {
2019-10-01 20:51:49 +02:00
foreach ( $socialnetworks as $key => $value ) {
2019-12-16 13:06:25 +01:00
if ( $value [ 'active' ] && ! empty ( $arrayfields [ 'p.' . $key ][ 'checked' ])) {
2019-10-01 20:51:49 +02:00
print_liste_field_titre ( $arrayfields [ 'p.' . $key ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p. " . $key , $begin , $param , '' , $sortfield , $sortorder );
}
}
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_soc' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.fk_soc' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.fk_soc " , $begin , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 's.nom' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " s.nom " , $begin , $param , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'p.priv' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.priv' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.priv " , $begin , $param , '' , $sortfield , $sortorder , 'center ' );
}
if ( ! empty ( $arrayfields [ 'p.fk_prospectcontactlevel' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.fk_prospectcontactlevel' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.fk_prospectcontactlevel " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
}
if ( ! empty ( $arrayfields [ 'p.fk_stcommcontact' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.fk_stcommcontact' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.fk_stcommcontact " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
}
2017-03-27 00:48:50 +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-03-27 00:48:50 +02:00
// Hook fields
2019-02-24 14:30:02 +01:00
$parameters = array (
2020-09-08 21:27:28 +02:00
'arrayfields' => $arrayfields ,
'param' => $param ,
'sortfield' => $sortfield ,
'sortorder' => $sortorder ,
2019-02-24 14:30:02 +01:00
);
2022-03-22 10:10:42 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-03-27 00:48:50 +02:00
print $hookmanager -> resPrint ;
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.datec' ][ 'checked' ])) {
2020-09-08 21:27:28 +02:00
print_liste_field_titre ( $arrayfields [ 'p.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.datec " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
2019-02-24 14:30:02 +01:00
}
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.tms' ][ 'checked' ])) {
2020-09-08 21:27:28 +02:00
print_liste_field_titre ( $arrayfields [ 'p.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.tms " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
2019-02-24 14:30:02 +01:00
}
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.statut' ][ 'checked' ])) {
2020-09-08 21:27:28 +02:00
print_liste_field_titre ( $arrayfields [ 'p.statut' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.statut " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2019-02-24 14:30:02 +01:00
}
2019-11-12 09:46:08 +01:00
if ( ! empty ( $arrayfields [ 'p.import_key' ][ 'checked' ])) {
2020-09-08 21:27:28 +02:00
print_liste_field_titre ( $arrayfields [ 'p.import_key' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.import_key " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2019-02-24 14:30:02 +01:00
}
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' );
2017-03-27 00:48:50 +02:00
print " </tr> \n " ;
2016-11-02 12:16:46 +01:00
$i = 0 ;
2019-12-16 13:06:25 +01:00
$totalarray = array ();
2021-10-22 23:38:35 +02:00
$totalarray [ 'nbfield' ] = 0 ;
2021-02-23 21:16:15 +01:00
while ( $i < min ( $num , $limit )) {
2020-07-29 12:00:22 +02:00
$obj = $db -> fetch_object ( $resql );
2016-11-02 12:16:46 +01:00
2019-10-01 00:10:33 +02:00
$arraysocialnetworks = ( array ) json_decode ( $obj -> socialnetworks , true );
2019-12-16 13:06:25 +01:00
$contactstatic -> lastname = $obj -> lastname ;
$contactstatic -> firstname = '' ;
$contactstatic -> id = $obj -> rowid ;
$contactstatic -> statut = $obj -> statut ;
$contactstatic -> poste = $obj -> poste ;
$contactstatic -> email = $obj -> email ;
$contactstatic -> phone_pro = $obj -> phone_pro ;
$contactstatic -> phone_perso = $obj -> phone_perso ;
$contactstatic -> phone_mobile = $obj -> phone_mobile ;
2021-08-26 14:36:12 +02:00
$contactstatic -> address = $obj -> address ;
2019-12-16 13:06:25 +01:00
$contactstatic -> zip = $obj -> zip ;
$contactstatic -> town = $obj -> town ;
2019-10-01 00:10:33 +02:00
$contactstatic -> socialnetworks = $arraysocialnetworks ;
2019-10-27 20:06:16 +01:00
$contactstatic -> country = $obj -> country ;
$contactstatic -> country_code = $obj -> country_code ;
2020-02-10 12:56:08 +01:00
$contactstatic -> photo = $obj -> photo ;
2022-07-29 11:54:56 +02:00
$contactstatic -> import_key = $obj -> import_key ;
2020-02-10 12:56:08 +01:00
2020-09-07 10:18:17 +02:00
$contactstatic -> fk_prospectlevel = $obj -> fk_prospectcontactlevel ;
2020-04-27 17:35:14 +02:00
2020-02-10 12:56:08 +01:00
print '<tr class="oddeven">' ;
2017-01-23 12:20:44 +01:00
2017-07-27 02:05:11 +02:00
// ID
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.rowid' ][ 'checked' ])) {
2017-07-27 02:05:11 +02:00
print '<td class="tdoverflowmax50">' ;
2022-09-11 14:26:35 +02:00
print dol_escape_htmltag ( $obj -> rowid );
2017-07-27 02:05:11 +02:00
print " </td> \n " ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-07-27 02:05:11 +02:00
}
// Name
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.lastname' ][ 'checked' ])) {
2022-09-11 14:26:35 +02:00
print '<td class="middle tdoverflowmax150">' ;
2020-11-05 22:25:14 +01:00
print $contactstatic -> getNomUrl ( 1 );
2017-10-13 13:28:26 +02:00
print '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2016-11-02 12:16:46 +01:00
// Firstname
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.firstname' ][ 'checked' ])) {
2022-09-11 14:26:35 +02:00
print '<td class="tdoverflowmax150" title="' . dol_escape_htmltag ( $obj -> firstname ) . '">' . dol_escape_htmltag ( $obj -> firstname ) . '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2018-06-28 14:06:23 +02:00
// Job position
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.poste' ][ 'checked' ])) {
2022-09-11 14:26:35 +02:00
print '<td class="tdoverflowmax100">' . dol_escape_htmltag ( $obj -> poste ) . '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2018-06-28 14:06:23 +02:00
}
2021-08-26 14:36:12 +02:00
// Address
if ( ! empty ( $arrayfields [ 'p.address' ][ 'checked' ])) {
2022-09-11 14:26:35 +02:00
print '<td>' . dol_escape_htmltag ( $obj -> address ) . '</td>' ;
2021-08-26 14:36:12 +02:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
}
2016-11-02 12:16:46 +01:00
// Zip
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.zip' ][ 'checked' ])) {
2022-09-11 14:26:35 +02:00
print '<td>' . dol_escape_htmltag ( $obj -> zip ) . '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2016-11-02 12:16:46 +01:00
// Town
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.town' ][ 'checked' ])) {
2022-09-11 14:26:35 +02:00
print '<td class="tdoverflowmax100" title="' . dol_escape_htmltag ( $obj -> town ) . '">' . dol_escape_htmltag ( $obj -> town ) . '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2018-06-28 14:06:23 +02:00
// State
/* if ( ! empty ( $arrayfields [ 'state.nom' ][ 'checked' ]))
2017-10-13 13:28:26 +02:00
{
2018-06-28 14:06:23 +02:00
print " <td> " . $obj -> state_name . " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Region
if ( ! empty ( $arrayfields [ 'region.nom' ][ 'checked' ]))
{
print " <td> " . $obj -> region_name . " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
} */
// Country
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'country.code_iso' ][ 'checked' ])) {
2019-02-14 21:26:39 +01:00
print '<td class="center">' ;
2019-12-16 13:06:25 +01:00
$tmparray = getCountry ( $obj -> fk_pays , 'all' );
2022-09-11 14:26:35 +02:00
print dol_escape_htmltag ( $tmparray [ 'label' ]);
2018-06-28 14:06:23 +02:00
print '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
// Phone
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.phone' ][ 'checked' ])) {
2021-07-03 18:38:43 +02:00
print '<td class="nowraponall tdoverflowmax150">' . dol_print_phone ( $obj -> phone_pro , $obj -> country_code , $obj -> rowid , $obj -> socid , 'AC_TEL' , ' ' , 'phone' ) . '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
// Phone perso
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.phone_perso' ][ 'checked' ])) {
2021-07-03 18:38:43 +02:00
print '<td class="nowraponall tdoverflowmax150">' . dol_print_phone ( $obj -> phone_perso , $obj -> country_code , $obj -> rowid , $obj -> socid , 'AC_TEL' , ' ' , 'phone' ) . '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
// Phone mobile
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.phone_mobile' ][ 'checked' ])) {
2021-07-03 18:38:43 +02:00
print '<td class="nowraponall tdoverflowmax150">' . dol_print_phone ( $obj -> phone_mobile , $obj -> country_code , $obj -> rowid , $obj -> socid , 'AC_TEL' , ' ' , 'mobile' ) . '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
// Fax
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.fax' ][ 'checked' ])) {
2021-07-03 18:38:43 +02:00
print '<td class="nowraponall tdoverflowmax150">' . dol_print_phone ( $obj -> fax , $obj -> country_code , $obj -> rowid , $obj -> socid , 'AC_TEL' , ' ' , 'fax' ) . '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
// EMail
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.email' ][ 'checked' ])) {
2022-01-05 22:07:58 +01:00
print '<td class="nowraponall tdoverflowmax300">' . dol_print_email ( $obj -> email , $obj -> rowid , $obj -> socid , 'AC_EMAIL' , 18 , 0 , 1 ) . '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2019-02-25 19:41:40 +01:00
// No EMail
2021-10-26 13:52:00 +02:00
if ( ! empty ( $arrayfields [ 'unsubscribed' ][ 'checked' ])) {
print '<td class="center">' ;
if ( empty ( $obj -> email )) {
//print '<span class="opacitymedium">'.$langs->trans("NoEmail").'</span>';
} else {
print yn (( $obj -> unsubscribed > 0 ) ? 1 : 0 );
}
print '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2019-02-25 19:41:40 +01:00
}
2019-12-16 13:06:25 +01:00
if ( ! empty ( $conf -> socialnetworks -> enabled )) {
2019-10-01 20:51:49 +02:00
foreach ( $socialnetworks as $key => $value ) {
2019-12-16 13:06:25 +01:00
if ( $value [ 'active' ] && ! empty ( $arrayfields [ 'p.' . $key ][ 'checked' ])) {
2022-09-11 14:26:35 +02:00
print '<td class="tdoverflowmax100">' . dol_print_socialnetworks ( $arraysocialnetworks [ $key ], $obj -> rowid , $obj -> socid , $key , $socialnetworks ) . '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2019-10-01 20:51:49 +02:00
}
}
2018-10-12 11:02:03 +02:00
}
2020-09-08 21:27:28 +02:00
// Company
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_soc' ][ 'checked' ]) || ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
2021-03-27 12:45:57 +01:00
print '<td class="tdoverflowmax200">' ;
2021-02-23 21:16:15 +01:00
if ( $obj -> socid ) {
2020-09-08 21:27:28 +02:00
$objsoc = new Societe ( $db );
$objsoc -> fetch ( $obj -> socid );
print $objsoc -> getNomUrl ( 1 );
2021-02-23 21:16:15 +01:00
} else {
print ' ' ;
}
2017-10-13 13:28:26 +02:00
print '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
// Private/Public
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.priv' ][ 'checked' ])) {
2019-02-14 21:26:39 +01:00
print '<td class="center">' . $contactstatic -> LibPubPriv ( $obj -> priv ) . '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2016-11-02 12:16:46 +01:00
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_prospectcontactlevel' ][ 'checked' ])) {
2020-04-27 17:35:14 +02:00
// Prospect level
print '<td class="center">' ;
print $contactstatic -> getLibProspLevel ();
print " </td> " ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-04-27 17:35:14 +02:00
}
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_stcommcontact' ][ 'checked' ])) {
2020-04-27 17:35:14 +02:00
// Prospect status
print '<td class="center nowrap"><div class="nowrap">' ;
2020-09-07 10:18:17 +02:00
print '<div class="inline-block">' . $contactstatic -> libProspCommStatut ( $obj -> stcomm_id , 2 , $contactstatic -> cacheprospectstatus [ $obj -> stcomm_id ][ 'label' ], $obj -> stcomm_picto );
2020-04-27 17:35:14 +02:00
print '</div> - <div class="inline-block">' ;
2020-04-27 18:01:07 +02:00
foreach ( $contactstatic -> cacheprospectstatus as $key => $val ) {
$titlealt = 'default' ;
2021-02-23 21:16:15 +01:00
if ( ! empty ( $val [ 'code' ]) && ! in_array ( $val [ 'code' ], array ( 'ST_NO' , 'ST_NEVER' , 'ST_TODO' , 'ST_PEND' , 'ST_DONE' ))) {
$titlealt = $val [ 'label' ];
}
if ( $obj -> stcomm_id != $val [ 'id' ]) {
2021-09-19 18:03:38 +02:00
print '<a class="pictosubstatus" href="' . $_SERVER [ " PHP_SELF " ] . '?stcommcontactid=' . $obj -> rowid . '&stcomm=' . urlencode ( $val [ 'code' ]) . '&action=setstcomm&token=' . newToken () . $param . ( $page ? '&page=' . urlencode ( $page ) : '' ) . '">' . img_action ( $titlealt , $val [ 'code' ], $val [ 'picto' ]) . '</a>' ;
2021-02-23 21:16:15 +01:00
}
2020-04-27 17:35:14 +02:00
}
print '</div></div></td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2020-04-27 17:35:14 +02:00
}
2015-11-03 15:32:16 +01:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
2017-10-13 13:28:26 +02:00
// Fields from hook
2020-05-08 01:40:25 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj , 'i' => $i , 'totalarray' =>& $totalarray );
2022-03-22 10:10:42 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-10-13 13:28:26 +02:00
print $hookmanager -> resPrint ;
// Date creation
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.datec' ][ 'checked' ])) {
2022-09-11 14:26:35 +02:00
print '<td class="center nowraponall">' ;
2017-10-13 13:28:26 +02:00
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' , 'tzuser' );
print '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
// Date modification
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.tms' ][ 'checked' ])) {
2022-09-11 14:26:35 +02:00
print '<td class="center nowraponall">' ;
2017-10-13 13:28:26 +02:00
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' , 'tzuser' );
print '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
// Status
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.statut' ][ 'checked' ])) {
2019-10-24 16:38:06 +02:00
print '<td class="center">' . $contactstatic -> getLibStatut ( 5 ) . '</td>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
2022-07-29 11:54:56 +02:00
// Import key
2021-02-23 21:16:15 +01:00
if ( ! empty ( $arrayfields [ 'p.import_key' ][ 'checked' ])) {
2017-10-13 13:28:26 +02:00
print '<td class="tdoverflowmax100">' ;
2022-07-29 11:54:56 +02:00
print dol_escape_htmltag ( $obj -> import_key );
2017-10-13 13:28:26 +02:00
print " </td> \n " ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-13 13:28:26 +02:00
}
// Action column
2019-02-14 21:26:39 +01:00
print '<td class="nowrap center">' ;
2021-02-23 21:16:15 +01:00
if ( $massactionbutton || $massaction ) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
2019-11-12 09:46:08 +01:00
$selected = 0 ;
2021-02-23 21:16:15 +01:00
if ( in_array ( $obj -> rowid , $arrayofselected )) {
$selected = 1 ;
}
2019-11-12 09:46:08 +01: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>' ;
2021-02-23 21:16:15 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-06-08 12:21:41 +02:00
2017-10-13 13:28:26 +02:00
print " </tr> \n " ;
$i ++ ;
2016-11-02 12:16:46 +01:00
}
2011-08-21 15:19:26 +02:00
2022-05-10 11:38:56 +02:00
// Show total line
include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php' ;
// 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>' ;
}
2020-07-29 12:00:22 +02:00
$db -> free ( $resql );
2017-05-23 00:13:07 +02:00
2019-11-12 09:46:08 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'sql' => $sql );
2022-03-22 10:10:42 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-05-23 00:13:07 +02:00
print $hookmanager -> resPrint ;
2022-05-10 11:38:56 +02:00
print '</table>' . " \n " ;
print '</div>' . " \n " ;
2011-08-21 15:19:26 +02:00
2022-05-10 11:38:56 +02:00
print '</form>' . " \n " ;
2011-08-21 15:19:26 +02:00
2022-05-10 11:38:56 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-07-10 22:10:12 +02:00
$db -> close ();