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 >
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
* Copyright ( C ) 2013 - 2015 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
* Copyright ( C ) 2013 Cédric Salvador < csalvador @ gpcsolutions . fr >
2015-07-15 20:30:33 +02:00
* Copyright ( C ) 2013 Alexandre Spangaro < aspangaro . dolibarr @ gmail . com >
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 >
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
* along with this program . If not , see < http :// www . gnu . org / licenses />.
*/
/**
* \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' ;
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
$action = GETPOST ( 'action' , 'alpha' );
$massaction = GETPOST ( 'massaction' , 'alpha' );
$show_files = GETPOST ( 'show_files' , 'int' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$toselect = GETPOST ( 'toselect' , 'array' );
2018-06-23 12:06:17 +02:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'contactlist' ;
2011-08-21 15:19:26 +02:00
// Security check
2015-12-17 14:01:22 +01:00
$id = GETPOST ( 'id' , 'int' );
2012-07-10 22:10:12 +02:00
$contactid = GETPOST ( 'id' , 'int' );
2015-12-17 14:01:22 +01:00
$ref = '' ; // There is no ref for contacts
2011-08-21 15:19:26 +02:00
if ( $user -> societe_id ) $socid = $user -> societe_id ;
$result = restrictedArea ( $user , 'contact' , $contactid , '' );
2017-12-12 11:31:30 +01:00
$sall = trim (( GETPOST ( 'search_all' , 'alphanohtml' ) != '' ) ? GETPOST ( 'search_all' , 'alphanohtml' ) : GETPOST ( 'sall' , 'alphanohtml' ));
2017-07-26 20:33:25 +02:00
$search_cti = preg_replace ( '/^0+/' , '' , preg_replace ( '/[^0-9]/' , '' , GETPOST ( 'search_cti' , 'alphanohtml' ))); // Phone number without any special chars
2017-12-28 09:56:40 +01:00
$search_phone = GETPOST ( " search_phone " , 'alpha' );
2017-07-26 20:33:25 +02:00
2017-07-27 02:05:11 +02:00
$search_id = trim ( GETPOST ( " search_id " , " int " ));
2017-12-28 09:56:40 +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' );
$search_skype = GETPOST ( " search_skype " , 'alpha' );
$search_priv = GETPOST ( " search_priv " , 'alpha' );
2014-10-03 12:15:21 +02:00
$search_categ = GETPOST ( " search_categ " , 'int' );
2016-07-13 12:02:45 +02:00
$search_categ_thirdparty = GETPOST ( " search_categ_thirdparty " , 'int' );
$search_categ_supplier = GETPOST ( " search_categ_supplier " , 'int' );
2014-11-17 23:49:39 +01:00
$search_status = GETPOST ( " search_status " , 'int' );
2015-11-03 15:32:16 +01:00
$search_type = GETPOST ( 'search_type' , 'alpha' );
2017-12-21 12:01:30 +01:00
$search_zip = GETPOST ( 'search_zip' , 'alpha' );
$search_town = GETPOST ( 'search_town' , 'alpha' );
2017-12-28 09:56:40 +01:00
$search_import_key = GETPOST ( " search_import_key " , " alpha " );
2018-06-28 14:06:23 +02:00
$search_country = GETPOST ( " search_country " , 'intcomma' );
2017-12-21 12:01:30 +01:00
2013-11-12 15:40:00 +01:00
if ( $search_status == '' ) $search_status = 1 ; // always display activ customer first
2015-10-16 22:21:26 +02:00
2015-10-04 10:45:57 +02:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2013-07-10 12:28:28 +02:00
2011-08-21 15:19:26 +02:00
2018-06-23 12:06:17 +02:00
$type = GETPOST ( " type " , 'aZ' );
$view = GETPOST ( " view " , 'alpha' );
2011-08-21 15:19:26 +02:00
2017-06-08 14:55:12 +02:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2012-10-13 10:39:16 +02:00
$sortfield = GETPOST ( 'sortfield' , 'alpha' );
$sortorder = GETPOST ( 'sortorder' , 'alpha' );
$page = GETPOST ( 'page' , 'int' );
$userid = GETPOST ( 'userid' , 'int' );
2012-07-10 22:10:12 +02:00
$begin = GETPOST ( 'begin' );
2011-08-21 15:19:26 +02:00
if ( ! $sortorder ) $sortorder = " ASC " ;
2013-03-01 18:11:34 +01:00
if ( ! $sortfield ) $sortfield = " p.lastname " ;
2017-01-23 12:20:44 +01:00
if ( empty ( $page ) || $page < 0 ) { $page = 0 ; }
2012-02-10 10:53:11 +01:00
$offset = $limit * $page ;
2011-08-21 15:19:26 +02:00
2012-03-14 15:32:48 +01:00
$titre = ( ! empty ( $conf -> global -> SOCIETE_ADDRESSES_MANAGEMENT ) ? $langs -> trans ( " ListOfContacts " ) : $langs -> trans ( " ListOfContactsAddresses " ));
2014-10-03 12:15:21 +02:00
if ( $type == " p " )
{
2018-06-23 12:06:17 +02:00
if ( empty ( $contextpage ) || $contextpage == 'contactlist' ) $contextpage = 'contactprospectlist' ;
2014-10-03 12:15:21 +02:00
$titre .= ' (' . $langs -> trans ( " ThirdPartyProspects " ) . ')' ;
$urlfiche = " card.php " ;
}
if ( $type == " c " )
2011-08-21 15:19:26 +02:00
{
2018-06-23 12:06:17 +02:00
if ( empty ( $contextpage ) || $contextpage == 'contactlist' ) $contextpage = 'contactcustomerlist' ;
2012-03-14 15:32:48 +01:00
$titre .= ' (' . $langs -> trans ( " ThirdPartyCustomers " ) . ')' ;
2014-09-18 21:18:25 +02:00
$urlfiche = " card.php " ;
2011-08-21 15:19:26 +02:00
}
2012-03-14 15:32:48 +01:00
else if ( $type == " f " )
{
2018-06-23 12:06:17 +02:00
if ( empty ( $contextpage ) || $contextpage == 'contactlist' ) $contextpage = 'contactsupplierlist' ;
2012-03-14 15:32:48 +01:00
$titre .= ' (' . $langs -> trans ( " ThirdPartySuppliers " ) . ')' ;
2014-09-18 21:18:25 +02:00
$urlfiche = " card.php " ;
2011-08-21 15:19:26 +02:00
}
2012-03-14 15:32:48 +01:00
else if ( $type == " o " )
{
2018-06-23 12:06:17 +02:00
if ( empty ( $contextpage ) || $contextpage == 'contactlist' ) $contextpage = 'contactotherlist' ;
2012-03-14 15:32:48 +01:00
$titre .= ' (' . $langs -> trans ( " OthersNotLinkedToThirdParty " ) . ')' ;
2011-08-21 15:19:26 +02:00
$urlfiche = " " ;
}
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
$extralabels = $extrafields -> fetch_name_optionals_label ( 'contact' );
$search_array_options = $extrafields -> getOptionalsFromPost ( $extralabels , '' , 'search_' );
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array (
2017-10-13 13:28:26 +02:00
'p.lastname' => 'Lastname' ,
'p.firstname' => 'Firstname' ,
'p.email' => 'EMail' ,
's.nom' => " ThirdParty " ,
2018-03-09 23:48:50 +01:00
'p.phone' => " Phone " ,
2015-11-03 15:32:16 +01:00
);
2015-11-11 17:05:18 +01:00
// Definition of fields for list
$arrayfields = array (
2017-07-27 02:05:11 +02:00
'p.rowid' => array ( 'label' => " TechnicalID " , 'checked' => ( $conf -> global -> MAIN_SHOW_TECHNICAL_ID ? 1 : 0 ), 'enabled' => ( $conf -> global -> MAIN_SHOW_TECHNICAL_ID ? 1 : 0 )),
'p.lastname' => array ( 'label' => " Lastname " , 'checked' => 1 ),
2017-10-13 13:28:26 +02:00
'p.firstname' => array ( 'label' => " Firstname " , 'checked' => 1 ),
'p.poste' => array ( 'label' => " PostOrFunction " , 'checked' => 1 ),
'p.town' => array ( 'label' => " Town " , 'checked' => 0 ),
'p.zip' => array ( 'label' => " Zip " , 'checked' => 0 ),
2018-06-28 14:06:23 +02:00
'country.code_iso' => array ( 'label' => " Country " , 'checked' => 0 ),
2017-10-13 13:28:26 +02:00
'p.phone' => array ( 'label' => " Phone " , 'checked' => 1 ),
'p.phone_perso' => array ( 'label' => " PhonePerso " , 'checked' => 0 ),
'p.phone_mobile' => array ( 'label' => " PhoneMobile " , 'checked' => 1 ),
2018-09-04 09:48:30 +02:00
'p.fax' => array ( 'label' => " Fax " , 'checked' => 0 ),
2017-10-13 13:28:26 +02:00
'p.email' => array ( 'label' => " EMail " , 'checked' => 1 ),
'p.skype' => array ( 'label' => " Skype " , 'checked' => 1 , 'enabled' => ( ! empty ( $conf -> skype -> enabled ))),
'p.thirdparty' => array ( 'label' => " ThirdParty " , 'checked' => 1 , 'enabled' => empty ( $conf -> global -> SOCIETE_DISABLE_CONTACTS )),
'p.priv' => array ( 'label' => " ContactVisibility " , 'checked' => 1 , 'position' => 200 ),
'p.datec' => array ( 'label' => " DateCreationShort " , 'checked' => 0 , 'position' => 500 ),
'p.tms' => array ( 'label' => " DateModificationShort " , 'checked' => 0 , 'position' => 500 ),
'p.statut' => array ( 'label' => " Status " , 'checked' => 1 , 'position' => 1000 ),
2017-07-27 02:05:11 +02:00
'p.import_key' => array ( 'label' => " ImportId " , 'checked' => 0 , 'position' => 1100 ),
2015-11-11 17:05:18 +01:00
);
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
2017-01-23 12:20:44 +01:00
foreach ( $extrafields -> attribute_label as $key => $val )
2015-11-11 17:05:18 +01:00
{
2017-10-29 11:00:02 +01:00
if ( ! empty ( $extrafields -> attribute_list [ $key ])) $arrayfields [ " ef. " . $key ] = array ( 'label' => $extrafields -> attribute_label [ $key ], 'checked' => (( $extrafields -> attribute_list [ $key ] < 0 ) ? 0 : 1 ), 'position' => $extrafields -> attribute_pos [ $key ], 'enabled' => ( abs ( $extrafields -> attribute_list [ $key ]) != 3 && $extrafields -> attribute_perms [ $key ]));
2015-11-11 17:05:18 +01:00
}
}
2015-12-17 14:01:22 +01:00
$object = new Contact ( $db );
if (( $id > 0 || ! empty ( $ref )) && $action != 'add' )
{
2017-10-13 13:28:26 +02:00
$result = $object -> fetch ( $id , $ref );
if ( $result < 0 ) dol_print_error ( $db );
2015-12-17 14:01:22 +01:00
}
2015-11-03 15:32:16 +01:00
/*
* Actions
*/
2017-09-15 10:50:50 +02: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
2015-11-03 15:32:16 +01:00
$parameters = array ();
2015-12-17 14:01:22 +01:00
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2015-11-03 15:32:16 +01:00
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
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 ?
if ( GETPOST ( 'button_removefilter_x' ) || GETPOST ( 'button_removefilter.x' ) || GETPOST ( 'button_removefilter' )) // All tests are required to be compatible with all browsers
{
$sall = " " ;
$search_id = '' ;
$search_firstlast_only = " " ;
$search_lastname = " " ;
$search_firstname = " " ;
$search_societe = " " ;
2018-06-28 14:06:23 +02:00
$search_town = " " ;
$search_zip = " " ;
$search_country = " " ;
2017-10-13 13:28:26 +02:00
$search_poste = " " ;
$search_phone = " " ;
$search_phone_perso = " " ;
$search_phone_pro = " " ;
$search_phone_mobile = " " ;
$search_fax = " " ;
$search_email = " " ;
$search_skype = " " ;
$search_priv = " " ;
$search_status =- 1 ;
$search_categ = '' ;
$search_categ_thirdparty = '' ;
$search_categ_supplier = '' ;
$search_import_key = '' ;
$toselect = '' ;
$search_array_options = array ();
}
// Mass actions
$objectclass = 'Contact' ;
$objectlabel = 'Contact' ;
$permtoread = $user -> rights -> societe -> lire ;
$permtodelete = $user -> rights -> societe -> supprimer ;
$uploaddir = $conf -> societe -> dir_output ;
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
2015-11-03 15:32:16 +01:00
}
2011-08-21 15:19:26 +02:00
if ( $search_priv < 0 ) $search_priv = '' ;
/*
* View
*/
$form = new Form ( $db );
2013-07-16 21:04:58 +02:00
$formother = new FormOther ( $db );
2015-11-03 15:32:16 +01:00
$contactstatic = new Contact ( $db );
$title = ( ! empty ( $conf -> global -> SOCIETE_ADDRESSES_MANAGEMENT ) ? $langs -> trans ( " Contacts " ) : $langs -> trans ( " ContactsAddresses " ));
2011-08-21 15:19:26 +02:00
2012-02-01 00:24:16 +01:00
$sql = " SELECT s.rowid as socid, s.nom as name, " ;
2017-05-23 00:13:07 +02:00
$sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.skype, " ;
2015-11-03 15:32:16 +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, " ;
2014-08-10 13:37:39 +02:00
$sql .= " co.code as country_code " ;
2015-11-03 15:32:16 +01:00
// Add fields from extrafields
2016-03-18 13:58:06 +01:00
foreach ( $extrafields -> attribute_label as $key => $val ) $sql .= ( $extrafields -> attribute_type [ $key ] != 'separate' ? " ,ef. " . $key . ' as options_' . $key : '' );
2015-11-03 15:32:16 +01:00
// Add fields from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2011-08-21 15:19:26 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " socpeople as p " ;
2016-02-03 22:53:15 +01:00
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " socpeople_extrafields as ef on (p.rowid = ef.fk_object) " ;
2014-08-10 13:37:39 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_country as co ON co.rowid = p.fk_pays " ;
2011-08-21 15:19:26 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s ON s.rowid = p.fk_soc " ;
2016-07-13 12:02:45 +02:00
if ( ! empty ( $search_categ )) $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
if ( ! empty ( $search_categ_thirdparty )) $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
if ( ! empty ( $search_categ_supplier )) $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
2011-08-21 15:19:26 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe_commerciaux as sc ON s.rowid = sc.fk_soc " ;
2018-04-27 10:42:10 +02:00
$sql .= ' WHERE p.entity IN (' . getEntity ( 'socpeople' ) . ')' ;
2011-08-21 15:19:26 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) //restriction
{
$sql .= " AND (sc.fk_user = " . $user -> id . " OR p.fk_soc IS NULL) " ;
}
2012-10-13 10:39:16 +02:00
if ( ! empty ( $userid )) // propre au commercial
2011-08-21 15:19:26 +02:00
{
2017-10-13 13:28:26 +02:00
$sql .= " AND p.fk_user_creat= " . $db -> escape ( $userid );
2011-08-21 15:19:26 +02:00
}
// Filter to exclude not owned private contacts
if ( $search_priv != '0' && $search_priv != '1' )
{
$sql .= " AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat= " . $user -> id . " )) " ;
}
else
{
if ( $search_priv == '0' ) $sql .= " AND p.priv='0' " ;
if ( $search_priv == '1' ) $sql .= " AND (p.priv='1' AND p.fk_user_creat= " . $user -> id . " ) " ;
}
2016-07-13 12:02:45 +02:00
if ( $search_categ > 0 ) $sql .= " AND cc.fk_categorie = " . $db -> escape ( $search_categ );
if ( $search_categ == - 2 ) $sql .= " AND cc.fk_categorie IS NULL " ;
if ( $search_categ_thirdparty > 0 ) $sql .= " AND cs.fk_categorie = " . $db -> escape ( $search_categ_thirdparty );
if ( $search_categ_thirdparty == - 2 ) $sql .= " AND cs.fk_categorie IS NULL " ;
2017-07-26 20:33:25 +02:00
if ( $search_categ_supplier > 0 ) $sql .= " AND cs2.fk_categorie = " . $db -> escape ( $search_categ_supplier );
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 );
2017-07-27 02:09:40 +02:00
if ( $search_id > 0 ) $sql .= natural_search ( " p.rowid " , $search_id , 1 );
2017-07-26 20:33:25 +02:00
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 ( 's.nom' , $search_societe );
2018-06-28 14:06:23 +02:00
if ( $search_country ) $sql .= " AND p.fk_pays IN ( " . $search_country . ')' ;
2017-07-26 20:33:25 +02: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 );
2018-09-05 14:26:12 +02:00
if ( strlen ( $search_phone_pro )) $sql .= natural_search ( 'p.phone' , $search_phone_pro );
2017-07-26 20:33:25 +02:00
if ( strlen ( $search_phone_mobile )) $sql .= natural_search ( 'p.phone_mobile' , $search_phone_mobile );
2017-12-21 12:01:30 +01:00
if ( strlen ( $search_fax )) $sql .= natural_search ( 'p.fax' , $search_fax );
2017-07-26 20:33:25 +02:00
if ( strlen ( $search_skype )) $sql .= natural_search ( 'p.skype' , $search_skype );
if ( strlen ( $search_email )) $sql .= natural_search ( 'p.email' , $search_email );
2018-04-17 10:43:25 +02:00
if ( strlen ( $search_zip )) $sql .= natural_search ( " p.zip " , $search_zip );
2018-12-01 17:01:11 +01:00
if ( strlen ( $search_town )) $sql .= natural_search ( " p.town " , $search_town );
2017-07-26 20:33:25 +02:00
if ( $search_status != '' && $search_status >= 0 ) $sql .= " AND p.statut = " . $db -> escape ( $search_status );
2017-07-27 02:09:40 +02:00
if ( $search_import_key ) $sql .= natural_search ( " p.import_key " , $search_import_key );
2011-08-21 15:19:26 +02:00
if ( $type == " o " ) // filtre sur type
{
2017-10-13 13:28:26 +02:00
$sql .= " AND p.fk_soc IS NULL " ;
2011-08-21 15:19:26 +02:00
}
2012-01-10 17:16:17 +01:00
else if ( $type == " f " ) // filtre sur type
2011-08-21 15:19:26 +02:00
{
2017-10-13 13:28:26 +02:00
$sql .= " AND s.fournisseur = 1 " ;
2011-08-21 15:19:26 +02:00
}
2012-01-10 17:16:17 +01:00
else if ( $type == " c " ) // filtre sur type
2011-08-21 15:19:26 +02:00
{
2017-10-13 13:28:26 +02:00
$sql .= " AND s.client IN (1, 3) " ;
2011-08-21 15:19:26 +02:00
}
2012-01-10 17:16:17 +01:00
else if ( $type == " p " ) // filtre sur type
2011-08-21 15:19:26 +02:00
{
2017-10-13 13:28:26 +02:00
$sql .= " AND s.client IN (2, 3) " ;
2011-08-21 15:19:26 +02:00
}
2012-07-10 22:10:12 +02:00
if ( ! empty ( $socid ))
2011-08-21 15:19:26 +02:00
{
2017-10-13 13:28:26 +02:00
$sql .= " AND s.rowid = " . $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
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2016-02-11 20:24:15 +01:00
// Add order
2016-07-13 12:02:45 +02:00
if ( $view == " recent " )
2016-02-11 20:24:15 +01:00
{
2017-10-13 13:28:26 +02:00
$sql .= $db -> order ( " p.datec " , " DESC " );
2016-02-11 20:24:15 +01:00
}
else
{
2017-10-13 13:28:26 +02:00
$sql .= $db -> order ( $sortfield , $sortorder );
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 = '' ;
2011-08-21 15:19:26 +02:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
{
2017-10-13 13:28:26 +02:00
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
2018-04-24 11:37:57 +02:00
if (( $page * $limit ) > $nbtotalofrecords ) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0 ;
$offset = 0 ;
}
2011-08-21 15:19:26 +02:00
}
2015-11-03 15:32:16 +01:00
2016-07-13 12:02:45 +02:00
$sql .= $db -> plimit ( $limit + 1 , $offset );
2011-08-21 15:19:26 +02:00
$result = $db -> query ( $sql );
2016-11-02 12:16:46 +01:00
if ( ! $result )
{
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
2016-11-02 12:16:46 +01:00
$num = $db -> num_rows ( $result );
2016-02-10 23:37:34 +01:00
2017-05-23 00:13:07 +02:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2017-07-26 20:33:25 +02:00
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && ( $sall != '' || $seearch_cti != '' ))
2016-11-02 12:16:46 +01:00
{
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
}
2017-05-23 00:13:07 +02:00
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas' ;
llxHeader ( '' , $title , $help_url );
2016-11-02 12:16:46 +01:00
$param = '' ;
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . $contextpage ;
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
$param .= '&begin=' . urlencode ( $begin ) . '&view=' . urlencode ( $view ) . '&userid=' . urlencode ( $userid ) . '&contactname=' . urlencode ( $sall );
$param .= '&type=' . urlencode ( $type ) . '&view=' . urlencode ( $view );
if ( ! empty ( $search_categ )) $param .= '&search_categ=' . urlencode ( $search_categ );
if ( ! empty ( $search_categ_thirdparty )) $param .= '&search_categ_thirdparty=' . urlencode ( $search_categ_thirdparty );
if ( ! empty ( $search_categ_supplier )) $param .= '&search_categ_supplier=' . urlencode ( $search_categ_supplier );
if ( $sall != '' ) $param .= '&sall=' . urlencode ( $sall );
2017-07-27 02:05:11 +02:00
if ( $search_id > 0 ) $param .= " &search_id= " . urlencode ( $search_id );
2016-11-02 12:16:46 +01:00
if ( $search_lastname != '' ) $param .= '&search_lastname=' . urlencode ( $search_lastname );
if ( $search_firstname != '' ) $param .= '&search_firstname=' . urlencode ( $search_firstname );
if ( $search_societe != '' ) $param .= '&search_societe=' . urlencode ( $search_societe );
if ( $search_zip != '' ) $param .= '&search_zip=' . urlencode ( $search_zip );
if ( $search_town != '' ) $param .= '&search_town=' . urlencode ( $search_town );
2018-06-28 14:06:23 +02:00
if ( $search_country != '' ) $param .= " &search_country= " . urlencode ( $search_country );
2016-11-02 12:16:46 +01:00
if ( $search_job != '' ) $param .= '&search_job=' . urlencode ( $search_job );
if ( $search_phone_pro != '' ) $param .= '&search_phone_pro=' . urlencode ( $search_phone_pro );
if ( $search_phone_perso != '' ) $param .= '&search_phone_perso=' . urlencode ( $search_phone_perso );
if ( $search_phone_mobile != '' ) $param .= '&search_phone_mobile=' . urlencode ( $search_phone_mobile );
if ( $search_fax != '' ) $param .= '&search_fax=' . urlencode ( $search_fax );
if ( $search_email != '' ) $param .= '&search_email=' . urlencode ( $search_email );
if ( $search_status != '' ) $param .= '&search_status=' . urlencode ( $search_status );
if ( $search_priv == '0' || $search_priv == '1' ) $param .= " &search_priv= " . urlencode ( $search_priv );
2017-07-27 02:05:11 +02:00
if ( $search_import_key != '' ) $param .= '&search_import_key=' . urlencode ( $search_import_key );
2016-11-02 12:16:46 +01:00
if ( $optioncss != '' ) $param .= '&optioncss=' . $optioncss ;
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
$arrayofmassactions = array (
// 'presend'=>$langs->trans("SendByMail"),
// 'builddoc'=>$langs->trans("PDFMerge"),
);
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
2017-11-11 16:03:22 +01:00
if ( $user -> rights -> societe -> supprimer ) $arrayofmassactions [ 'predelete' ] = $langs -> trans ( " Delete " );
if ( in_array ( $massaction , array ( 'presend' , 'predelete' ))) $arrayofmassactions = array ();
2017-05-23 00:13:07 +02:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2018-03-30 16:54:38 +02:00
$newcardbutton = '' ;
if ( $user -> rights -> societe -> contact -> creer )
{
2018-06-13 22:57:41 +02:00
$newcardbutton = '<a class="butActionNew" href="' . DOL_URL_ROOT . '/contact/card.php?action=create"><span class="valignmiddle">' . $langs -> trans ( 'NewContactAddress' ) . '</span>' ;
2018-04-18 03:26:15 +02:00
$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>' ;
$newcardbutton .= '</a>' ;
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">' ;
2016-11-02 12:16:46 +01:00
if ( $optioncss != '' ) print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
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 . '">' ;
2017-05-21 02:43:51 +02: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
2018-03-30 16:54:38 +02:00
print_barre_liste ( $titre , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'title_companies.png' , 0 , $newcardbutton , '' , $limit );
2016-11-02 12:16:46 +01:00
2017-11-11 16:03:22 +01:00
$topicmail = " Information " ;
$modelmail = " contact " ;
$objecttmp = new Contact ( $db );
$trackid = 'ctc' . $object -> id ;
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2016-11-02 12:16:46 +01:00
if ( $sall )
{
2017-10-13 13:28:26 +02:00
foreach ( $fieldstosearchall as $key => $val ) $fieldstosearchall [ $key ] = $langs -> trans ( $val );
2018-06-22 22:53:53 +02:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
2016-11-02 12:16:46 +01:00
}
if ( $search_firstlast_only )
{
2018-06-22 22:53:53 +02: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
}
2017-05-23 00:13:07 +02:00
$moreforfilter = '' ;
2016-11-02 12:16:46 +01:00
if ( ! empty ( $conf -> categorie -> enabled ))
{
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2017-10-13 13:28:26 +02:00
$moreforfilter .= '<div class="divsearchfield">' ;
2016-11-02 12:16:46 +01:00
$moreforfilter .= $langs -> trans ( 'Categories' ) . ': ' ;
$moreforfilter .= $formother -> select_categories ( Categorie :: TYPE_CONTACT , $search_categ , 'search_categ' , 1 );
$moreforfilter .= '</div>' ;
if ( empty ( $type ) || $type == 'c' || $type == 'p' )
2015-10-06 01:03:31 +02:00
{
2017-10-13 13:28:26 +02:00
$moreforfilter .= '<div class="divsearchfield">' ;
if ( $type == 'c' ) $moreforfilter .= $langs -> trans ( 'CustomersCategoriesShort' ) . ': ' ;
else if ( $type == 'p' ) $moreforfilter .= $langs -> trans ( 'ProspectsCategoriesShort' ) . ': ' ;
else $moreforfilter .= $langs -> trans ( 'CustomersProspectsCategoriesShort' ) . ': ' ;
$moreforfilter .= $formother -> select_categories ( Categorie :: TYPE_CUSTOMER , $search_categ_thirdparty , 'search_categ_thirdparty' , 1 );
$moreforfilter .= '</div>' ;
2016-11-02 12:16:46 +01:00
}
if ( empty ( $type ) || $type == 'f' )
2015-11-03 15:32:16 +01:00
{
2017-10-13 13:28:26 +02:00
$moreforfilter .= '<div class="divsearchfield">' ;
2016-11-02 12:16:46 +01:00
$moreforfilter .= $langs -> trans ( 'SuppliersCategoriesShort' ) . ': ' ;
2017-10-13 13:28:26 +02:00
$moreforfilter .= $formother -> select_categories ( Categorie :: TYPE_SUPPLIER , $search_categ_supplier , 'search_categ_supplier' , 1 );
$moreforfilter .= '</div>' ;
2015-11-03 15:32:16 +01:00
}
2016-11-02 12:16:46 +01:00
}
if ( $moreforfilter )
{
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
$parameters = array ( 'type' => $type );
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
2017-10-13 13:28:26 +02:00
print $hookmanager -> resPrint ;
2016-11-02 12:16:46 +01:00
print '</div>' ;
}
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2017-05-23 00:13:07 +02: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">' ;
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">' ;
2017-07-27 02:05:11 +02:00
if ( ! empty ( $arrayfields [ 'p.rowid' ][ 'checked' ]))
{
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>' ;
}
2016-11-02 12:16:46 +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
}
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
}
2018-06-28 14:06:23 +02:00
if ( ! empty ( $arrayfields [ 'p.poste' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_poste" size="5" value="' . dol_escape_htmltag ( $search_poste ) . '">' ;
print '</td>' ;
}
2016-11-02 12:16:46 +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
}
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
if ( ! empty ( $arrayfields [ 'country.code_iso' ][ 'checked' ]))
2017-12-21 12:01:30 +01:00
{
2018-06-28 14:06:23 +02:00
print '<td class="liste_titre" align="center">' ;
print $form -> select_country ( $search_country , 'search_country' , '' , 0 , 'maxwidth100' );
2017-12-21 12:01:30 +01:00
print '</td>' ;
}
2017-01-23 12:20:44 +01:00
if ( ! empty ( $arrayfields [ 'p.phone' ][ 'checked' ]))
2016-11-02 12:16:46 +01:00
{
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
}
2017-01-23 12:20:44 +01:00
if ( ! empty ( $arrayfields [ 'p.phone_perso' ][ 'checked' ]))
2016-11-02 12:16:46 +01:00
{
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
}
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
}
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
}
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
}
if ( ! empty ( $arrayfields [ 'p.skype' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre">' ;
print '<input class="flat" type="text" name="search_skype" size="6" value="' . dol_escape_htmltag ( $search_skype ) . '">' ;
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
if ( ! empty ( $arrayfields [ 'p.thirdparty' ][ '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
}
if ( ! empty ( $arrayfields [ 'p.priv' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre" align="center">' ;
2016-11-02 12:16:46 +01:00
$selectarray = array ( '0' => $langs -> trans ( " ContactPublic " ), '1' => $langs -> trans ( " ContactPrivate " ));
print $form -> selectarray ( 'search_priv' , $selectarray , $search_priv , 1 );
print '</td>' ;
}
// 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
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
// Date creation
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
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
2016-11-02 12:16:46 +01:00
if ( ! empty ( $arrayfields [ 'p.statut' ][ 'checked' ]))
{
2017-10-13 13:28:26 +02:00
print '<td class="liste_titre center">' ;
print $form -> selectarray ( 'search_status' , array ( '-1' => '' , '0' => $langs -> trans ( 'ActivityCeased' ), '1' => $langs -> trans ( 'InActivity' )), $search_status );
print '</td>' ;
2016-11-02 12:16:46 +01:00
}
2017-07-27 02:05:11 +02:00
if ( ! empty ( $arrayfields [ 'p.import_key' ][ 'checked' ]))
{
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
2016-11-02 12:16:46 +01:00
print '<td class="liste_titre" align="right">' ;
2017-05-23 00:13:07 +02:00
$searchpicto = $form -> showFilterButtons ();
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">' ;
2017-07-27 02:05:11 +02: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 );
2018-06-28 14:06:23 +02:00
if ( ! empty ( $arrayfields [ 'p.poste' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.poste' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.poste " , $begin , $param , '' , $sortfield , $sortorder );
2017-07-27 02:05:11 +02: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);
if ( ! empty ( $arrayfields [ 'country.code_iso' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'country.code_iso' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " co.code_iso " , " " , $param , 'align="center"' , $sortfield , $sortorder );
2017-07-27 02:05:11 +02: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 );
if ( ! empty ( $arrayfields [ 'p.skype' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.skype' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.skype " , $begin , $param , '' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.thirdparty' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.thirdparty' ][ '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 , 'align="center"' , $sortfield , $sortorder );
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
2017-09-09 09:46:21 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
2017-03-27 00:48:50 +02:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2017-08-02 17:56:09 +02:00
if ( ! empty ( $arrayfields [ 'p.datec' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.datec " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.tms' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.tms " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.statut' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.statut' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.statut " , " " , $param , 'align="center"' , $sortfield , $sortorder );
2017-07-27 02:05:11 +02:00
if ( ! empty ( $arrayfields [ 'p.import_key' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.import_key' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.import_key " , " " , $param , 'align="center"' , $sortfield , $sortorder );
2017-04-07 14:18:04 +02:00
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' );
2017-03-27 00:48:50 +02:00
print " </tr> \n " ;
2016-11-02 12:16:46 +01:00
$i = 0 ;
2017-06-08 12:21:41 +02:00
$totalarray = array ();
2016-11-02 12:16:46 +01:00
while ( $i < min ( $num , $limit ))
{
2017-10-13 13:28:26 +02:00
$obj = $db -> fetch_object ( $result );
2016-11-02 12:16:46 +01:00
2017-10-13 13:28:26 +02:00
print '<tr class="oddeven">' ;
2016-11-02 12:16:46 +01:00
$contactstatic -> lastname = $obj -> lastname ;
$contactstatic -> firstname = '' ;
2017-05-23 00:13:07 +02:00
$contactstatic -> id = $obj -> rowid ;
2016-11-02 12:16:46 +01:00
$contactstatic -> statut = $obj -> statut ;
$contactstatic -> poste = $obj -> poste ;
2017-02-15 01:22:20 +01:00
$contactstatic -> email = $obj -> email ;
2016-11-02 12:16:46 +01:00
$contactstatic -> phone_pro = $obj -> phone_pro ;
$contactstatic -> phone_perso = $obj -> phone_perso ;
$contactstatic -> phone_mobile = $obj -> phone_mobile ;
$contactstatic -> zip = $obj -> zip ;
$contactstatic -> town = $obj -> town ;
2017-01-23 12:20:44 +01:00
2017-07-27 02:05:11 +02:00
// ID
if ( ! empty ( $arrayfields [ 'p.rowid' ][ 'checked' ]))
{
print '<td class="tdoverflowmax50">' ;
print $obj -> rowid ;
print " </td> \n " ;
2017-10-13 13:28:26 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2017-07-27 02:05:11 +02:00
}
// Name
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'p.lastname' ][ 'checked' ]))
{
print '<td valign="middle">' ;
print $contactstatic -> getNomUrl ( 1 , '' , 0 );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:16:46 +01:00
// Firstname
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'p.firstname' ][ 'checked' ]))
{
print '<td>' . $obj -> firstname . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2018-06-28 14:06:23 +02:00
// Job position
if ( ! empty ( $arrayfields [ 'p.poste' ][ 'checked' ]))
{
2018-09-25 12:54:24 +02:00
print '<td class="tdoverflowmax100">' . $obj -> poste . '</td>' ;
2018-06-28 14:06:23 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:16:46 +01:00
// Zip
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'p.zip' ][ 'checked' ]))
{
print '<td>' . $obj -> zip . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:16:46 +01:00
// Town
2017-10-13 13:28:26 +02:00
if ( ! empty ( $arrayfields [ 'p.town' ][ 'checked' ]))
{
print '<td>' . $obj -> town . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
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
if ( ! empty ( $arrayfields [ 'country.code_iso' ][ 'checked' ]))
{
print '<td align="center">' ;
$tmparray = getCountry ( $obj -> fk_pays , 'all' );
print $tmparray [ 'label' ];
print '</td>' ;
2017-10-13 13:28:26 +02:00
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Phone
if ( ! empty ( $arrayfields [ 'p.phone' ][ 'checked' ]))
{
print '<td>' . dol_print_phone ( $obj -> phone_pro , $obj -> country_code , $obj -> rowid , $obj -> socid , 'AC_TEL' ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Phone perso
if ( ! empty ( $arrayfields [ 'p.phone_perso' ][ 'checked' ]))
{
print '<td>' . dol_print_phone ( $obj -> phone_perso , $obj -> country_code , $obj -> rowid , $obj -> socid , 'AC_TEL' ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Phone mobile
if ( ! empty ( $arrayfields [ 'p.phone_mobile' ][ 'checked' ]))
{
print '<td>' . dol_print_phone ( $obj -> phone_mobile , $obj -> country_code , $obj -> rowid , $obj -> socid , 'AC_TEL' ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Fax
if ( ! empty ( $arrayfields [ 'p.fax' ][ 'checked' ]))
{
print '<td>' . dol_print_phone ( $obj -> fax , $obj -> country_code , $obj -> rowid , $obj -> socid , 'AC_TEL' ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// EMail
if ( ! empty ( $arrayfields [ 'p.email' ][ 'checked' ]))
{
print '<td>' . dol_print_email ( $obj -> email , $obj -> rowid , $obj -> socid , 'AC_EMAIL' , 18 ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Skype
if ( ! empty ( $arrayfields [ 'p.skype' ][ 'checked' ]))
{
if ( ! empty ( $conf -> skype -> enabled )) { print '<td>' . dol_print_skype ( $obj -> skype , $obj -> rowid , $obj -> socid , 'AC_SKYPE' , 18 ) . '</td>' ; }
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Company
if ( ! empty ( $arrayfields [ 'p.thirdparty' ][ 'checked' ]))
{
2016-11-02 12:16:46 +01:00
print '<td>' ;
2017-10-13 13:28:26 +02:00
if ( $obj -> socid )
{
2016-11-02 12:16:46 +01:00
$objsoc = new Societe ( $db );
$objsoc -> fetch ( $obj -> socid );
print $objsoc -> getNomUrl ( 1 );
2017-10-13 13:28:26 +02:00
}
else
print ' ' ;
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Private/Public
if ( ! empty ( $arrayfields [ 'p.priv' ][ 'checked' ]))
{
print '<td align="center">' . $contactstatic -> LibPubPriv ( $obj -> priv ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:16:46 +01: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
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj );
2016-11-02 12:16:46 +01:00
$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 ;
// Date creation
if ( ! empty ( $arrayfields [ 'p.datec' ][ 'checked' ]))
{
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' , 'tzuser' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Date modification
if ( ! empty ( $arrayfields [ 'p.tms' ][ 'checked' ]))
{
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' , 'tzuser' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Status
if ( ! empty ( $arrayfields [ 'p.statut' ][ 'checked' ]))
{
print '<td align="center">' . $contactstatic -> getLibStatut ( 3 ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
if ( ! empty ( $arrayfields [ 'p.import_key' ][ 'checked' ]))
{
print '<td class="tdoverflowmax100">' ;
print $obj -> import_key ;
print " </td> \n " ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Action column
print '<td class="nowrap" align="center">' ;
if ( $massactionbutton || $massaction ) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0 ;
2017-05-23 00:13:07 +02:00
if ( in_array ( $obj -> rowid , $arrayofselected )) $selected = 1 ;
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>' ;
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
2017-05-23 00:13:07 +02:00
$db -> free ( $result );
$parameters = array ( 'arrayfields' => $arrayfields , 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2016-11-02 12:16:46 +01:00
print " </table> " ;
2016-11-27 13:49:46 +01:00
print " </div> " ;
2011-08-21 15:19:26 +02:00
2017-05-23 00:13:07 +02:00
//if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit, 1);
2011-08-21 15:19:26 +02:00
2016-11-02 12:16:46 +01:00
print '</form>' ;
2011-08-21 15:19:26 +02:00
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-07-10 22:10:12 +02:00
$db -> close ();