list.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932
  1. <?php
  2. /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Eric Seigne <erics@rycks.com>
  4. * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
  7. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  8. * Copyright (C) 2013 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
  9. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  10. * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
  11. * Copyright (C) 2018 Juanjo Menent <jmenent@2byte.es>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 3 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. */
  26. /**
  27. * \file htdocs/contact/list.php
  28. * \ingroup societe
  29. * \brief Page to list all contacts
  30. */
  31. require '../main.inc.php';
  32. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  35. // Load translation files required by the page
  36. $langs->loadLangs(array("companies", "suppliers", "categories"));
  37. $action=GETPOST('action','alpha');
  38. $massaction=GETPOST('massaction','alpha');
  39. $show_files=GETPOST('show_files','int');
  40. $confirm=GETPOST('confirm','alpha');
  41. $toselect = GETPOST('toselect', 'array');
  42. $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'contactlist';
  43. // Security check
  44. $id = GETPOST('id','int');
  45. $contactid = GETPOST('id','int');
  46. $ref = ''; // There is no ref for contacts
  47. if ($user->societe_id) $socid=$user->societe_id;
  48. $result = restrictedArea($user, 'contact', $contactid,'');
  49. $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
  50. $search_cti=preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars
  51. $search_phone=GETPOST("search_phone",'alpha');
  52. $search_id=trim(GETPOST("search_id","int"));
  53. $search_firstlast_only=GETPOST("search_firstlast_only",'alpha');
  54. $search_lastname=GETPOST("search_lastname",'alpha');
  55. $search_firstname=GETPOST("search_firstname",'alpha');
  56. $search_societe=GETPOST("search_societe",'alpha');
  57. $search_poste=GETPOST("search_poste",'alpha');
  58. $search_phone_perso=GETPOST("search_phone_perso",'alpha');
  59. $search_phone_pro=GETPOST("search_phone_pro",'alpha');
  60. $search_phone_mobile=GETPOST("search_phone_mobile",'alpha');
  61. $search_fax=GETPOST("search_fax",'alpha');
  62. $search_email=GETPOST("search_email",'alpha');
  63. $search_skype=GETPOST("search_skype",'alpha');
  64. $search_twitter=GETPOST("search_twitter",'alpha');
  65. $search_facebook=GETPOST("search_facebook",'alpha');
  66. $search_priv=GETPOST("search_priv",'alpha');
  67. $search_categ=GETPOST("search_categ",'int');
  68. $search_categ_thirdparty=GETPOST("search_categ_thirdparty",'int');
  69. $search_categ_supplier=GETPOST("search_categ_supplier",'int');
  70. $search_status=GETPOST("search_status",'int');
  71. $search_type=GETPOST('search_type','alpha');
  72. $search_zip=GETPOST('search_zip','alpha');
  73. $search_town=GETPOST('search_town','alpha');
  74. $search_import_key=GETPOST("search_import_key","alpha");
  75. $search_country=GETPOST("search_country",'intcomma');
  76. if ($search_status=='') $search_status=1; // always display activ customer first
  77. $optioncss = GETPOST('optioncss','alpha');
  78. $type=GETPOST("type",'aZ');
  79. $view=GETPOST("view",'alpha');
  80. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  81. $sortfield = GETPOST('sortfield', 'alpha');
  82. $sortorder = GETPOST('sortorder', 'alpha');
  83. $page = GETPOST('page', 'int');
  84. $userid=GETPOST('userid','int');
  85. $begin=GETPOST('begin');
  86. if (! $sortorder) $sortorder="ASC";
  87. if (! $sortfield) $sortfield="p.lastname";
  88. if (empty($page) || $page < 0) { $page = 0; }
  89. $offset = $limit * $page;
  90. $titre = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses"));
  91. if ($type == "p")
  92. {
  93. if (empty($contextpage) || $contextpage == 'contactlist') $contextpage='contactprospectlist';
  94. $titre.=' ('.$langs->trans("ThirdPartyProspects").')';
  95. $urlfiche="card.php";
  96. }
  97. if ($type == "c")
  98. {
  99. if (empty($contextpage) || $contextpage == 'contactlist') $contextpage='contactcustomerlist';
  100. $titre.=' ('.$langs->trans("ThirdPartyCustomers").')';
  101. $urlfiche="card.php";
  102. }
  103. else if ($type == "f")
  104. {
  105. if (empty($contextpage) || $contextpage == 'contactlist') $contextpage='contactsupplierlist';
  106. $titre.=' ('.$langs->trans("ThirdPartySuppliers").')';
  107. $urlfiche="card.php";
  108. }
  109. else if ($type == "o")
  110. {
  111. if (empty($contextpage) || $contextpage == 'contactlist') $contextpage='contactotherlist';
  112. $titre.=' ('.$langs->trans("OthersNotLinkedToThirdParty").')';
  113. $urlfiche="";
  114. }
  115. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  116. $object = new Contact($db);
  117. $hookmanager->initHooks(array('contactlist'));
  118. $extrafields = new ExtraFields($db);
  119. // fetch optionals attributes and labels
  120. $extralabels = $extrafields->fetch_name_optionals_label('contact');
  121. $search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_');
  122. // List of fields to search into when doing a "search in all"
  123. $fieldstosearchall = array(
  124. 'p.lastname'=>'Lastname',
  125. 'p.firstname'=>'Firstname',
  126. 'p.email'=>'EMail',
  127. 's.nom'=>"ThirdParty",
  128. 'p.phone'=>"Phone",
  129. );
  130. // Definition of fields for list
  131. $arrayfields=array(
  132. 'p.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0)),
  133. 'p.lastname'=>array('label'=>"Lastname", 'checked'=>1),
  134. 'p.firstname'=>array('label'=>"Firstname", 'checked'=>1),
  135. 'p.poste'=>array('label'=>"PostOrFunction", 'checked'=>1),
  136. 'p.town'=>array('label'=>"Town", 'checked'=>0),
  137. 'p.zip'=>array('label'=>"Zip", 'checked'=>0),
  138. 'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
  139. 'p.phone'=>array('label'=>"Phone", 'checked'=>1),
  140. 'p.phone_perso'=>array('label'=>"PhonePerso", 'checked'=>0),
  141. 'p.phone_mobile'=>array('label'=>"PhoneMobile", 'checked'=>1),
  142. 'p.fax'=>array('label'=>"Fax", 'checked'=>0),
  143. 'p.email'=>array('label'=>"EMail", 'checked'=>1),
  144. 'p.skype'=>array('label'=>"Skype", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))),
  145. 'p.twitter'=>array('label'=>"Twitter", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))),
  146. 'p.facebook'=>array('label'=>"Facebook", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))),
  147. 'p.thirdparty'=>array('label'=>"ThirdParty", 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)),
  148. 'p.priv'=>array('label'=>"ContactVisibility", 'checked'=>1, 'position'=>200),
  149. 'p.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500),
  150. 'p.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
  151. 'p.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
  152. 'p.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100),
  153. );
  154. // Extra fields
  155. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  156. {
  157. foreach($extrafields->attribute_label as $key => $val)
  158. {
  159. 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]));
  160. }
  161. }
  162. $object=new Contact($db);
  163. if (($id > 0 || ! empty($ref)) && $action != 'add')
  164. {
  165. $result=$object->fetch($id,$ref);
  166. if ($result < 0) dol_print_error($db);
  167. }
  168. /*
  169. * Actions
  170. */
  171. if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
  172. if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
  173. $parameters=array();
  174. $reshook=$hookmanager->executeHooks('doActions',$parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  175. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  176. if (empty($reshook))
  177. {
  178. // Selection of new fields
  179. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  180. // Did we click on purge search criteria ?
  181. 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
  182. {
  183. $sall="";
  184. $search_id='';
  185. $search_firstlast_only="";
  186. $search_lastname="";
  187. $search_firstname="";
  188. $search_societe="";
  189. $search_town="";
  190. $search_zip="";
  191. $search_country="";
  192. $search_poste="";
  193. $search_phone="";
  194. $search_phone_perso="";
  195. $search_phone_pro="";
  196. $search_phone_mobile="";
  197. $search_fax="";
  198. $search_email="";
  199. $search_skype="";
  200. $search_twitter="";
  201. $search_facebook="";
  202. $search_priv="";
  203. $search_status=-1;
  204. $search_categ='';
  205. $search_categ_thirdparty='';
  206. $search_categ_supplier='';
  207. $search_import_key='';
  208. $toselect='';
  209. $search_array_options=array();
  210. }
  211. // Mass actions
  212. $objectclass='Contact';
  213. $objectlabel='Contact';
  214. $permtoread = $user->rights->societe->lire;
  215. $permtodelete = $user->rights->societe->supprimer;
  216. $uploaddir = $conf->societe->dir_output;
  217. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  218. }
  219. if ($search_priv < 0) $search_priv='';
  220. /*
  221. * View
  222. */
  223. $form=new Form($db);
  224. $formother=new FormOther($db);
  225. $contactstatic=new Contact($db);
  226. $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
  227. $sql = "SELECT s.rowid as socid, s.nom as name,";
  228. $sql.= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.skype,";
  229. $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,";
  230. $sql.= " co.code as country_code";
  231. // Add fields from extrafields
  232. foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
  233. // Add fields from hooks
  234. $parameters=array();
  235. $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
  236. $sql.=$hookmanager->resPrint;
  237. $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p";
  238. 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)";
  239. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays";
  240. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
  241. 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
  242. 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
  243. 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
  244. if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
  245. $sql.= ' WHERE p.entity IN ('.getEntity('socpeople').')';
  246. if (!$user->rights->societe->client->voir && !$socid) //restriction
  247. {
  248. $sql .= " AND (sc.fk_user = " .$user->id." OR p.fk_soc IS NULL)";
  249. }
  250. if (! empty($userid)) // propre au commercial
  251. {
  252. $sql .= " AND p.fk_user_creat=".$db->escape($userid);
  253. }
  254. // Filter to exclude not owned private contacts
  255. if ($search_priv != '0' && $search_priv != '1')
  256. {
  257. $sql .= " AND (p.priv='0' OR (p.priv='1' AND p.fk_user_creat=".$user->id."))";
  258. }
  259. else
  260. {
  261. if ($search_priv == '0') $sql .= " AND p.priv='0'";
  262. if ($search_priv == '1') $sql .= " AND (p.priv='1' AND p.fk_user_creat=".$user->id.")";
  263. }
  264. if ($search_categ > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ);
  265. if ($search_categ == -2) $sql.= " AND cc.fk_categorie IS NULL";
  266. if ($search_categ_thirdparty > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ_thirdparty);
  267. if ($search_categ_thirdparty == -2) $sql.= " AND cs.fk_categorie IS NULL";
  268. if ($search_categ_supplier > 0) $sql.= " AND cs2.fk_categorie = ".$db->escape($search_categ_supplier);
  269. if ($search_categ_supplier == -2) $sql.= " AND cs2.fk_categorie IS NULL";
  270. if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall);
  271. if (strlen($search_phone)) $sql.= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_phone);
  272. if (strlen($search_cti)) $sql.= natural_search(array('p.phone', 'p.phone_perso', 'p.phone_mobile'), $search_cti);
  273. if (strlen($search_firstlast_only)) $sql.= natural_search(array('p.lastname', 'p.firstname'), $search_firstlast_only);
  274. if ($search_id > 0) $sql.= natural_search("p.rowid",$search_id,1);
  275. if ($search_lastname) $sql.= natural_search('p.lastname', $search_lastname);
  276. if ($search_firstname) $sql.= natural_search('p.firstname', $search_firstname);
  277. if ($search_societe) $sql.= natural_search('s.nom', $search_societe);
  278. if ($search_country) $sql .= " AND p.fk_pays IN (".$search_country.')';
  279. if (strlen($search_poste)) $sql.= natural_search('p.poste', $search_poste);
  280. if (strlen($search_phone_perso)) $sql.= natural_search('p.phone_perso', $search_phone_perso);
  281. if (strlen($search_phone_pro)) $sql.= natural_search('p.phone', $search_phone_pro);
  282. if (strlen($search_phone_mobile)) $sql.= natural_search('p.phone_mobile', $search_phone_mobile);
  283. if (strlen($search_fax)) $sql.= natural_search('p.fax', $search_fax);
  284. if (strlen($search_skype)) $sql.= natural_search('p.skype', $search_skype);
  285. if (strlen($search_twitter)) $sql.= natural_search('p.twitter', $search_twitter);
  286. if (strlen($search_facebook)) $sql.= natural_search('p.facebook', $search_facebook);
  287. if (strlen($search_email)) $sql.= natural_search('p.email', $search_email);
  288. if (strlen($search_zip)) $sql.= natural_search("p.zip",$search_zip);
  289. if (strlen($search_town)) $sql.= natural_search("p.town",$search_town);
  290. if ($search_status != '' && $search_status >= 0) $sql.= " AND p.statut = ".$db->escape($search_status);
  291. if ($search_import_key) $sql.= natural_search("p.import_key",$search_import_key);
  292. if ($type == "o") // filtre sur type
  293. {
  294. $sql .= " AND p.fk_soc IS NULL";
  295. }
  296. else if ($type == "f") // filtre sur type
  297. {
  298. $sql .= " AND s.fournisseur = 1";
  299. }
  300. else if ($type == "c") // filtre sur type
  301. {
  302. $sql .= " AND s.client IN (1, 3)";
  303. }
  304. else if ($type == "p") // filtre sur type
  305. {
  306. $sql .= " AND s.client IN (2, 3)";
  307. }
  308. if (! empty($socid))
  309. {
  310. $sql .= " AND s.rowid = ".$socid;
  311. }
  312. // Add where from extra fields
  313. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  314. // Add where from hooks
  315. $parameters=array();
  316. $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
  317. $sql.=$hookmanager->resPrint;
  318. // Add order
  319. if ($view == "recent")
  320. {
  321. $sql.= $db->order("p.datec","DESC");
  322. }
  323. else
  324. {
  325. $sql.= $db->order($sortfield,$sortorder);
  326. }
  327. // Count total nb of records
  328. $nbtotalofrecords = '';
  329. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  330. {
  331. $result = $db->query($sql);
  332. $nbtotalofrecords = $db->num_rows($result);
  333. if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
  334. {
  335. $page = 0;
  336. $offset = 0;
  337. }
  338. }
  339. $sql.= $db->plimit($limit+1, $offset);
  340. $result = $db->query($sql);
  341. if (! $result)
  342. {
  343. dol_print_error($db);
  344. exit;
  345. }
  346. $num = $db->num_rows($result);
  347. $arrayofselected=is_array($toselect)?$toselect:array();
  348. if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall != '' || $seearch_cti != ''))
  349. {
  350. $obj = $db->fetch_object($resql);
  351. $id = $obj->rowid;
  352. header("Location: ".DOL_URL_ROOT.'/contact/card.php?id='.$id);
  353. exit;
  354. }
  355. $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Empresas';
  356. llxHeader('',$title,$help_url);
  357. $param='';
  358. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
  359. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
  360. $param.='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall);
  361. $param.='&type='.urlencode($type).'&view='.urlencode($view);
  362. if (!empty($search_categ)) $param.='&search_categ='.urlencode($search_categ);
  363. if (!empty($search_categ_thirdparty)) $param.='&search_categ_thirdparty='.urlencode($search_categ_thirdparty);
  364. if (!empty($search_categ_supplier)) $param.='&search_categ_supplier='.urlencode($search_categ_supplier);
  365. if ($sall != '') $param.='&amp;sall='.urlencode($sall);
  366. if ($search_id > 0) $param.= "&search_id=".urlencode($search_id);
  367. if ($search_lastname != '') $param.='&amp;search_lastname='.urlencode($search_lastname);
  368. if ($search_firstname != '') $param.='&amp;search_firstname='.urlencode($search_firstname);
  369. if ($search_societe != '') $param.='&amp;search_societe='.urlencode($search_societe);
  370. if ($search_zip != '') $param.='&amp;search_zip='.urlencode($search_zip);
  371. if ($search_town != '') $param.='&amp;search_town='.urlencode($search_town);
  372. if ($search_country != '') $param.= "&search_country=".urlencode($search_country);
  373. if ($search_job != '') $param.='&amp;search_job='.urlencode($search_job);
  374. if ($search_phone_pro != '') $param.='&amp;search_phone_pro='.urlencode($search_phone_pro);
  375. if ($search_phone_perso != '') $param.='&amp;search_phone_perso='.urlencode($search_phone_perso);
  376. if ($search_phone_mobile != '') $param.='&amp;search_phone_mobile='.urlencode($search_phone_mobile);
  377. if ($search_fax != '') $param.='&amp;search_fax='.urlencode($search_fax);
  378. if ($search_email != '') $param.='&amp;search_email='.urlencode($search_email);
  379. if ($search_status != '') $param.='&amp;search_status='.urlencode($search_status);
  380. if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv);
  381. if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key);
  382. if ($optioncss != '') $param.='&optioncss='.$optioncss;
  383. // Add $param from extra fields
  384. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  385. // List of mass actions available
  386. $arrayofmassactions = array(
  387. // 'presend'=>$langs->trans("SendByMail"),
  388. // 'builddoc'=>$langs->trans("PDFMerge"),
  389. );
  390. //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
  391. if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
  392. if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
  393. $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
  394. $newcardbutton='';
  395. if ($user->rights->societe->contact->creer)
  396. {
  397. $newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/contact/card.php?action=create"><span class="valignmiddle">'.$langs->trans('NewContactAddress').'</span>';
  398. $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
  399. $newcardbutton.= '</a>';
  400. }
  401. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
  402. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  403. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  404. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  405. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  406. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  407. print '<input type="hidden" name="page" value="'.$page.'">';
  408. print '<input type="hidden" name="type" value="'.$type.'">';
  409. print '<input type="hidden" name="view" value="'.dol_escape_htmltag($view).'">';
  410. print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies.png', 0, $newcardbutton, '', $limit);
  411. $topicmail="Information";
  412. $modelmail="contact";
  413. $objecttmp=new Contact($db);
  414. $trackid='ctc'.$object->id;
  415. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  416. if ($sall)
  417. {
  418. foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
  419. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
  420. }
  421. if ($search_firstlast_only)
  422. {
  423. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_firstlast_only) . $langs->trans("Lastname").", ".$langs->trans("Firstname").'</div>';
  424. }
  425. $moreforfilter='';
  426. if (! empty($conf->categorie->enabled))
  427. {
  428. require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
  429. $moreforfilter.='<div class="divsearchfield">';
  430. $moreforfilter.=$langs->trans('Categories'). ': ';
  431. $moreforfilter.=$formother->select_categories(Categorie::TYPE_CONTACT,$search_categ,'search_categ',1);
  432. $moreforfilter.='</div>';
  433. if (empty($type) || $type == 'c' || $type == 'p')
  434. {
  435. $moreforfilter.='<div class="divsearchfield">';
  436. if ($type == 'c') $moreforfilter.=$langs->trans('CustomersCategoriesShort'). ': ';
  437. else if ($type == 'p') $moreforfilter.=$langs->trans('ProspectsCategoriesShort'). ': ';
  438. else $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort'). ': ';
  439. $moreforfilter.=$formother->select_categories(Categorie::TYPE_CUSTOMER,$search_categ_thirdparty,'search_categ_thirdparty',1);
  440. $moreforfilter.='</div>';
  441. }
  442. if (empty($type) || $type == 'f')
  443. {
  444. $moreforfilter.='<div class="divsearchfield">';
  445. $moreforfilter.=$langs->trans('SuppliersCategoriesShort'). ': ';
  446. $moreforfilter.=$formother->select_categories(Categorie::TYPE_SUPPLIER,$search_categ_supplier,'search_categ_supplier',1);
  447. $moreforfilter.='</div>';
  448. }
  449. }
  450. if ($moreforfilter)
  451. {
  452. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  453. print $moreforfilter;
  454. $parameters=array('type'=>$type);
  455. $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
  456. print $hookmanager->resPrint;
  457. print '</div>';
  458. }
  459. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  460. $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  461. if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
  462. print '<div class="div-table-responsive">';
  463. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  464. // Lines for filter fields
  465. print '<tr class="liste_titre_filter">';
  466. if (! empty($arrayfields['p.rowid']['checked']))
  467. {
  468. print '<td class="liste_titre">';
  469. print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
  470. print '</td>';
  471. }
  472. if (! empty($arrayfields['p.lastname']['checked']))
  473. {
  474. print '<td class="liste_titre">';
  475. print '<input class="flat" type="text" name="search_lastname" size="6" value="'.dol_escape_htmltag($search_lastname).'">';
  476. print '</td>';
  477. }
  478. if (! empty($arrayfields['p.firstname']['checked']))
  479. {
  480. print '<td class="liste_titre">';
  481. print '<input class="flat" type="text" name="search_firstname" size="6" value="'.dol_escape_htmltag($search_firstname).'">';
  482. print '</td>';
  483. }
  484. if (! empty($arrayfields['p.poste']['checked']))
  485. {
  486. print '<td class="liste_titre">';
  487. print '<input class="flat" type="text" name="search_poste" size="5" value="'.dol_escape_htmltag($search_poste).'">';
  488. print '</td>';
  489. }
  490. if (! empty($arrayfields['p.zip']['checked']))
  491. {
  492. print '<td class="liste_titre">';
  493. print '<input class="flat" type="text" name="search_zip" size="3" value="'.dol_escape_htmltag($search_zip).'">';
  494. print '</td>';
  495. }
  496. if (! empty($arrayfields['p.town']['checked']))
  497. {
  498. print '<td class="liste_titre">';
  499. print '<input class="flat" type="text" name="search_town" size="5" value="'.dol_escape_htmltag($search_town).'">';
  500. print '</td>';
  501. }
  502. // State
  503. /*if (! empty($arrayfields['state.nom']['checked']))
  504. {
  505. print '<td class="liste_titre">';
  506. print '<input class="flat searchstring" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
  507. print '</td>';
  508. }
  509. // Region
  510. if (! empty($arrayfields['region.nom']['checked']))
  511. {
  512. print '<td class="liste_titre">';
  513. print '<input class="flat searchstring" size="4" type="text" name="search_region" value="'.dol_escape_htmltag($search_region).'">';
  514. print '</td>';
  515. }*/
  516. // Country
  517. if (! empty($arrayfields['country.code_iso']['checked']))
  518. {
  519. print '<td class="liste_titre" align="center">';
  520. print $form->select_country($search_country,'search_country','',0,'maxwidth100');
  521. print '</td>';
  522. }
  523. if (! empty($arrayfields['p.phone']['checked']))
  524. {
  525. print '<td class="liste_titre">';
  526. print '<input class="flat" type="text" name="search_phone_pro" size="6" value="'.dol_escape_htmltag($search_phone_pro).'">';
  527. print '</td>';
  528. }
  529. if (! empty($arrayfields['p.phone_perso']['checked']))
  530. {
  531. print '<td class="liste_titre">';
  532. print '<input class="flat" type="text" name="search_phone_perso" size="6" value="'.dol_escape_htmltag($search_phone_perso).'">';
  533. print '</td>';
  534. }
  535. if (! empty($arrayfields['p.phone_mobile']['checked']))
  536. {
  537. print '<td class="liste_titre">';
  538. print '<input class="flat" type="text" name="search_phone_mobile" size="6" value="'.dol_escape_htmltag($search_phone_mobile).'">';
  539. print '</td>';
  540. }
  541. if (! empty($arrayfields['p.fax']['checked']))
  542. {
  543. print '<td class="liste_titre">';
  544. print '<input class="flat" type="text" name="search_fax" size="6" value="'.dol_escape_htmltag($search_fax).'">';
  545. print '</td>';
  546. }
  547. if (! empty($arrayfields['p.email']['checked']))
  548. {
  549. print '<td class="liste_titre">';
  550. print '<input class="flat" type="text" name="search_email" size="6" value="'.dol_escape_htmltag($search_email).'">';
  551. print '</td>';
  552. }
  553. if (! empty($arrayfields['p.skype']['checked']))
  554. {
  555. print '<td class="liste_titre">';
  556. print '<input class="flat" type="text" name="search_skype" size="6" value="'.dol_escape_htmltag($search_skype).'">';
  557. print '</td>';
  558. }
  559. if (! empty($arrayfields['p.twitter']['checked']))
  560. {
  561. print '<td class="liste_titre">';
  562. print '<input class="flat" type="text" name="search_twitter" size="6" value="'.dol_escape_htmltag($search_twitter).'">';
  563. print '</td>';
  564. }
  565. if (! empty($arrayfields['p.facebook']['checked']))
  566. {
  567. print '<td class="liste_titre">';
  568. print '<input class="flat" type="text" name="search_facebook" size="6" value="'.dol_escape_htmltag($search_facebook).'">';
  569. print '</td>';
  570. }
  571. if (! empty($arrayfields['p.thirdparty']['checked']))
  572. {
  573. print '<td class="liste_titre">';
  574. print '<input class="flat" type="text" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).'">';
  575. print '</td>';
  576. }
  577. if (! empty($arrayfields['p.priv']['checked']))
  578. {
  579. print '<td class="liste_titre" align="center">';
  580. $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate"));
  581. print $form->selectarray('search_priv',$selectarray,$search_priv,1);
  582. print '</td>';
  583. }
  584. // Extra fields
  585. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  586. // Fields from hook
  587. $parameters=array('arrayfields'=>$arrayfields);
  588. $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
  589. print $hookmanager->resPrint;
  590. // Date creation
  591. if (! empty($arrayfields['p.datec']['checked']))
  592. {
  593. print '<td class="liste_titre">';
  594. print '</td>';
  595. }
  596. // Date modification
  597. if (! empty($arrayfields['p.tms']['checked']))
  598. {
  599. print '<td class="liste_titre">';
  600. print '</td>';
  601. }
  602. // Status
  603. if (! empty($arrayfields['p.statut']['checked']))
  604. {
  605. print '<td class="liste_titre center">';
  606. print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status);
  607. print '</td>';
  608. }
  609. if (! empty($arrayfields['p.import_key']['checked']))
  610. {
  611. print '<td class="liste_titre center">';
  612. print '<input class="flat searchstring" type="text" name="search_import_key" size="3" value="'.dol_escape_htmltag($search_import_key).'">';
  613. print '</td>';
  614. }
  615. // Action column
  616. print '<td class="liste_titre" align="right">';
  617. $searchpicto=$form->showFilterButtons();
  618. print $searchpicto;
  619. print '</td>';
  620. print '</tr>';
  621. // Ligne des titres
  622. print '<tr class="liste_titre">';
  623. if (! empty($arrayfields['p.rowid']['checked'])) print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"],"p.rowid","",$param,"",$sortfield,$sortorder);
  624. if (! empty($arrayfields['p.lastname']['checked'])) print_liste_field_titre($arrayfields['p.lastname']['label'],$_SERVER["PHP_SELF"],"p.lastname", $begin, $param, '', $sortfield,$sortorder);
  625. if (! empty($arrayfields['p.firstname']['checked'])) print_liste_field_titre($arrayfields['p.firstname']['label'],$_SERVER["PHP_SELF"],"p.firstname", $begin, $param, '', $sortfield,$sortorder);
  626. if (! empty($arrayfields['p.poste']['checked'])) print_liste_field_titre($arrayfields['p.poste']['label'],$_SERVER["PHP_SELF"],"p.poste", $begin, $param, '', $sortfield,$sortorder);
  627. if (! empty($arrayfields['p.zip']['checked'])) print_liste_field_titre($arrayfields['p.zip']['label'],$_SERVER["PHP_SELF"],"p.zip", $begin, $param, '', $sortfield,$sortorder);
  628. if (! empty($arrayfields['p.town']['checked'])) print_liste_field_titre($arrayfields['p.town']['label'],$_SERVER["PHP_SELF"],"p.town", $begin, $param, '', $sortfield,$sortorder);
  629. //if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
  630. //if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder);
  631. 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);
  632. if (! empty($arrayfields['p.phone']['checked'])) print_liste_field_titre($arrayfields['p.phone']['label'],$_SERVER["PHP_SELF"],"p.phone", $begin, $param, '', $sortfield,$sortorder);
  633. 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);
  634. 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);
  635. if (! empty($arrayfields['p.fax']['checked'])) print_liste_field_titre($arrayfields['p.fax']['label'],$_SERVER["PHP_SELF"],"p.fax", $begin, $param, '', $sortfield,$sortorder);
  636. if (! empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'],$_SERVER["PHP_SELF"],"p.email", $begin, $param, '', $sortfield,$sortorder);
  637. if (! empty($arrayfields['p.skype']['checked'])) print_liste_field_titre($arrayfields['p.skype']['label'],$_SERVER["PHP_SELF"],"p.skype", $begin, $param, '', $sortfield,$sortorder);
  638. if (! empty($arrayfields['p.twitter']['checked'])) print_liste_field_titre($arrayfields['p.twitter']['label'],$_SERVER["PHP_SELF"],"p.twitter", $begin, $param, '', $sortfield,$sortorder);
  639. if (! empty($arrayfields['p.facebook']['checked'])) print_liste_field_titre($arrayfields['p.facebook']['label'],$_SERVER["PHP_SELF"],"p.facebook", $begin, $param, '', $sortfield,$sortorder);
  640. if (! empty($arrayfields['p.thirdparty']['checked'])) print_liste_field_titre($arrayfields['p.thirdparty']['label'],$_SERVER["PHP_SELF"],"s.nom", $begin, $param, '', $sortfield,$sortorder);
  641. 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);
  642. // Extra fields
  643. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  644. // Hook fields
  645. $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
  646. $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
  647. print $hookmanager->resPrint;
  648. 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);
  649. 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);
  650. if (! empty($arrayfields['p.statut']['checked'])) print_liste_field_titre($arrayfields['p.statut']['label'],$_SERVER["PHP_SELF"],"p.statut","",$param,'align="center"',$sortfield,$sortorder);
  651. 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);
  652. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
  653. print "</tr>\n";
  654. $i = 0;
  655. $totalarray=array();
  656. while ($i < min($num,$limit))
  657. {
  658. $obj = $db->fetch_object($result);
  659. print '<tr class="oddeven">';
  660. $contactstatic->lastname=$obj->lastname;
  661. $contactstatic->firstname='';
  662. $contactstatic->id=$obj->rowid;
  663. $contactstatic->statut=$obj->statut;
  664. $contactstatic->poste=$obj->poste;
  665. $contactstatic->email=$obj->email;
  666. $contactstatic->phone_pro=$obj->phone_pro;
  667. $contactstatic->phone_perso=$obj->phone_perso;
  668. $contactstatic->phone_mobile=$obj->phone_mobile;
  669. $contactstatic->zip=$obj->zip;
  670. $contactstatic->town=$obj->town;
  671. // ID
  672. if (! empty($arrayfields['p.rowid']['checked']))
  673. {
  674. print '<td class="tdoverflowmax50">';
  675. print $obj->rowid;
  676. print "</td>\n";
  677. if (! $i) $totalarray['nbfield']++;
  678. }
  679. // Name
  680. if (! empty($arrayfields['p.lastname']['checked']))
  681. {
  682. print '<td valign="middle">';
  683. print $contactstatic->getNomUrl(1,'',0);
  684. print '</td>';
  685. if (! $i) $totalarray['nbfield']++;
  686. }
  687. // Firstname
  688. if (! empty($arrayfields['p.firstname']['checked']))
  689. {
  690. print '<td>'.$obj->firstname.'</td>';
  691. if (! $i) $totalarray['nbfield']++;
  692. }
  693. // Job position
  694. if (! empty($arrayfields['p.poste']['checked']))
  695. {
  696. print '<td class="tdoverflowmax100">'.$obj->poste.'</td>';
  697. if (! $i) $totalarray['nbfield']++;
  698. }
  699. // Zip
  700. if (! empty($arrayfields['p.zip']['checked']))
  701. {
  702. print '<td>'.$obj->zip.'</td>';
  703. if (! $i) $totalarray['nbfield']++;
  704. }
  705. // Town
  706. if (! empty($arrayfields['p.town']['checked']))
  707. {
  708. print '<td>'.$obj->town.'</td>';
  709. if (! $i) $totalarray['nbfield']++;
  710. }
  711. // State
  712. /*if (! empty($arrayfields['state.nom']['checked']))
  713. {
  714. print "<td>".$obj->state_name."</td>\n";
  715. if (! $i) $totalarray['nbfield']++;
  716. }
  717. // Region
  718. if (! empty($arrayfields['region.nom']['checked']))
  719. {
  720. print "<td>".$obj->region_name."</td>\n";
  721. if (! $i) $totalarray['nbfield']++;
  722. }*/
  723. // Country
  724. if (! empty($arrayfields['country.code_iso']['checked']))
  725. {
  726. print '<td align="center">';
  727. $tmparray=getCountry($obj->fk_pays,'all');
  728. print $tmparray['label'];
  729. print '</td>';
  730. if (! $i) $totalarray['nbfield']++;
  731. }
  732. // Phone
  733. if (! empty($arrayfields['p.phone']['checked']))
  734. {
  735. print '<td>'.dol_print_phone($obj->phone_pro,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').'</td>';
  736. if (! $i) $totalarray['nbfield']++;
  737. }
  738. // Phone perso
  739. if (! empty($arrayfields['p.phone_perso']['checked']))
  740. {
  741. print '<td>'.dol_print_phone($obj->phone_perso,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').'</td>';
  742. if (! $i) $totalarray['nbfield']++;
  743. }
  744. // Phone mobile
  745. if (! empty($arrayfields['p.phone_mobile']['checked']))
  746. {
  747. print '<td>'.dol_print_phone($obj->phone_mobile,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').'</td>';
  748. if (! $i) $totalarray['nbfield']++;
  749. }
  750. // Fax
  751. if (! empty($arrayfields['p.fax']['checked']))
  752. {
  753. print '<td>'.dol_print_phone($obj->fax,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').'</td>';
  754. if (! $i) $totalarray['nbfield']++;
  755. }
  756. // EMail
  757. if (! empty($arrayfields['p.email']['checked']))
  758. {
  759. print '<td>'.dol_print_email($obj->email,$obj->rowid,$obj->socid,'AC_EMAIL',18).'</td>';
  760. if (! $i) $totalarray['nbfield']++;
  761. }
  762. // Skype
  763. if (! empty($arrayfields['p.skype']['checked']))
  764. {
  765. if (! empty($conf->socialnetworks->enabled)) { print '<td>'.dol_print_socialnetworks($obj->skype,$obj->rowid,$obj->socid,'skype').'</td>'; }
  766. if (! $i) $totalarray['nbfield']++;
  767. }
  768. // Twitter
  769. if (! empty($arrayfields['p.twitter']['checked']))
  770. {
  771. if (! empty($conf->socialnetworks->enabled)) { print '<td>'.dol_print_socialnetworks($obj->twitter,$obj->rowid,$obj->socid,'twitter').'</td>'; }
  772. if (! $i) $totalarray['nbfield']++;
  773. }
  774. // Facebook
  775. if (! empty($arrayfields['p.facebook']['checked']))
  776. {
  777. if (! empty($conf->socialnetworks->enabled)) { print '<td>'.dol_print_socialnetworks($obj->facebook,$obj->rowid,$obj->socid,'facebook').'</td>'; }
  778. if (! $i) $totalarray['nbfield']++;
  779. }
  780. // Company
  781. if (! empty($arrayfields['p.thirdparty']['checked']))
  782. {
  783. print '<td>';
  784. if ($obj->socid)
  785. {
  786. $objsoc = new Societe($db);
  787. $objsoc->fetch($obj->socid);
  788. print $objsoc->getNomUrl(1);
  789. }
  790. else
  791. print '&nbsp;';
  792. print '</td>';
  793. if (! $i) $totalarray['nbfield']++;
  794. }
  795. // Private/Public
  796. if (! empty($arrayfields['p.priv']['checked']))
  797. {
  798. print '<td align="center">'.$contactstatic->LibPubPriv($obj->priv).'</td>';
  799. if (! $i) $totalarray['nbfield']++;
  800. }
  801. // Extra fields
  802. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  803. // Fields from hook
  804. $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
  805. $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
  806. print $hookmanager->resPrint;
  807. // Date creation
  808. if (! empty($arrayfields['p.datec']['checked']))
  809. {
  810. print '<td align="center">';
  811. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  812. print '</td>';
  813. if (! $i) $totalarray['nbfield']++;
  814. }
  815. // Date modification
  816. if (! empty($arrayfields['p.tms']['checked']))
  817. {
  818. print '<td align="center">';
  819. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  820. print '</td>';
  821. if (! $i) $totalarray['nbfield']++;
  822. }
  823. // Status
  824. if (! empty($arrayfields['p.statut']['checked']))
  825. {
  826. print '<td align="center">'.$contactstatic->getLibStatut(3).'</td>';
  827. if (! $i) $totalarray['nbfield']++;
  828. }
  829. if (! empty($arrayfields['p.import_key']['checked']))
  830. {
  831. print '<td class="tdoverflowmax100">';
  832. print $obj->import_key;
  833. print "</td>\n";
  834. if (! $i) $totalarray['nbfield']++;
  835. }
  836. // Action column
  837. print '<td class="nowrap" align="center">';
  838. if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  839. {
  840. $selected=0;
  841. if (in_array($obj->rowid, $arrayofselected)) $selected=1;
  842. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
  843. }
  844. print '</td>';
  845. if (! $i) $totalarray['nbfield']++;
  846. print "</tr>\n";
  847. $i++;
  848. }
  849. $db->free($result);
  850. $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  851. $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
  852. print $hookmanager->resPrint;
  853. print "</table>";
  854. print "</div>";
  855. //if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit, 1);
  856. print '</form>';
  857. llxFooter();
  858. $db->close();