1<?php 2/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net> 4 * Copyright (C) 2005-2019 Regis Houssin <regis.houssin@inodbox.com> 5 * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com> 6 * Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> 7 * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro> 8 * Copyright (C) 2016-2018 Josep Lluis Amador <joseplluis@lliuretic.cat> 9 * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es> 10 * Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com> 11 * Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es> 12 * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com> 13 * Copyright (C) 2020 Open-Dsi <support@open-dsi.fr> 14 * Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr> 15 * 16 * This program is free software; you can redistribute it and/or modify 17 * it under the terms of the GNU General Public License as published by 18 * the Free Software Foundation; either version 3 of the License, or 19 * (at your option) any later version. 20 * 21 * This program is distributed in the hope that it will be useful, 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * GNU General Public License for more details. 25 * 26 * You should have received a copy of the GNU General Public License 27 * along with this program. If not, see <https://www.gnu.org/licenses/>. 28 */ 29 30/** 31 * \file htdocs/societe/list.php 32 * \ingroup societe 33 * \brief Page to show list of third parties 34 */ 35 36require_once '../main.inc.php'; 37include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; 38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; 39require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; 40require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; 41require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; 42require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; 43 44$langs->loadLangs(array("companies", "commercial", "customers", "suppliers", "bills", "compta", "categories", "cashdesk")); 45 46$action = GETPOST('action', 'aZ09'); 47$massaction = GETPOST('massaction', 'alpha'); 48$show_files = GETPOST('show_files', 'int'); 49$confirm = GETPOST('confirm', 'alpha'); 50$toselect = GETPOST('toselect', 'array'); 51$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thirdpartylist'; 52 53if ($contextpage == 'poslist') { 54 $_GET['optioncss'] = 'print'; 55} 56 57// Security check 58$socid = GETPOST('socid', 'int'); 59if ($user->socid) { 60 $socid = $user->socid; 61} 62$result = restrictedArea($user, 'societe', $socid, ''); 63 64$search_all = trim(GETPOST('search_all', 'alphanohtml') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); 65$search_cti = preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars 66 67$search_id = trim(GETPOST("search_id", "int")); 68$search_nom = trim(GETPOST("search_nom", 'restricthtml')); 69$search_alias = trim(GETPOST("search_alias", 'restricthtml')); 70$search_nom_only = trim(GETPOST("search_nom_only", 'restricthtml')); 71$search_barcode = trim(GETPOST("search_barcode", 'alpha')); 72$search_customer_code = trim(GETPOST('search_customer_code', 'alpha')); 73$search_supplier_code = trim(GETPOST('search_supplier_code', 'alpha')); 74$search_account_customer_code = trim(GETPOST('search_account_customer_code', 'alpha')); 75$search_account_supplier_code = trim(GETPOST('search_account_supplier_code', 'alpha')); 76$search_address = trim(GETPOST('search_address', 'alpha')); 77$search_town = trim(GETPOST("search_town", 'alpha')); 78$search_zip = trim(GETPOST("search_zip", 'alpha')); 79$search_state = trim(GETPOST("search_state", 'alpha')); 80$search_region = trim(GETPOST("search_region", 'alpha')); 81$search_email = trim(GETPOST('search_email', 'alpha')); 82$search_phone = trim(GETPOST('search_phone', 'alpha')); 83$search_fax = trim(GETPOST('search_fax', 'alpha')); 84$search_url = trim(GETPOST('search_url', 'alpha')); 85$search_idprof1 = trim(GETPOST('search_idprof1', 'alpha')); 86$search_idprof2 = trim(GETPOST('search_idprof2', 'alpha')); 87$search_idprof3 = trim(GETPOST('search_idprof3', 'alpha')); 88$search_idprof4 = trim(GETPOST('search_idprof4', 'alpha')); 89$search_idprof5 = trim(GETPOST('search_idprof5', 'alpha')); 90$search_idprof6 = trim(GETPOST('search_idprof6', 'alpha')); 91$search_vat = trim(GETPOST('search_vat', 'alpha')); 92$search_sale = GETPOST("search_sale", 'int'); 93$search_categ_cus = GETPOST("search_categ_cus", 'int'); 94$search_categ_sup = GETPOST("search_categ_sup", 'int'); 95$search_country = GETPOST("search_country", 'intcomma'); 96$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); 97$search_price_level = GETPOST('search_price_level', 'int'); 98$search_staff = GETPOST("search_staff", 'int'); 99$search_status = GETPOST("search_status", 'int'); 100$search_type = GETPOST('search_type', 'alpha'); 101$search_level = GETPOST("search_level", "array"); 102$search_stcomm = GETPOST('search_stcomm', 'int'); 103$search_import_key = trim(GETPOST("search_import_key", "alpha")); 104$search_parent_name = trim(GETPOST('search_parent_name', 'alpha')); 105 106$type = GETPOST('type', 'alpha'); 107$optioncss = GETPOST('optioncss', 'alpha'); 108$mode = GETPOST("mode", 'alpha'); 109$place = GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'; // $place is string id of table for Bar or Restaurant 110 111$diroutputmassaction = $conf->societe->dir_output.'/temp/massgeneration/'.$user->id; 112 113$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; 114$sortfield = GETPOST("sortfield", 'alpha'); 115$sortorder = GETPOST("sortorder", 'alpha'); 116$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); 117if (!$sortorder) { 118 $sortorder = "ASC"; 119} 120if (!$sortfield) { 121 $sortfield = "s.nom"; 122} 123if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { 124 $page = 0; 125} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action 126$offset = $limit * $page; 127$pageprev = $page - 1; 128$pagenext = $page + 1; 129 130if ($type == 'c') { 131 if (empty($contextpage) || $contextpage == 'thirdpartylist') { 132 $contextpage = 'customerlist'; 133 } if ($search_type == '') { 134 $search_type = '1,3'; 135 } 136} 137if ($type == 'p') { 138 if (empty($contextpage) || $contextpage == 'thirdpartylist') { 139 $contextpage = 'prospectlist'; 140 } if ($search_type == '') { 141 $search_type = '2,3'; 142 } 143} 144if ($type == 't') { 145 if (empty($contextpage) || $contextpage == 'poslist') { 146 $contextpage = 'poslist'; 147 } if ($search_type == '') { 148 $search_type = '1,2,3'; 149 } 150} 151if ($type == 'f') { 152 if (empty($contextpage) || $contextpage == 'thirdpartylist') { 153 $contextpage = 'supplierlist'; 154 } if ($search_type == '') { 155 $search_type = '4'; 156 } 157} 158 159// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context 160$object = new Societe($db); 161$hookmanager->initHooks(array('thirdpartylist')); 162$extrafields = new ExtraFields($db); 163 164// fetch optionals attributes and labels 165$extrafields->fetch_name_optionals_label($object->table_element); 166 167$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); 168 169// List of fields to search into when doing a "search in all" 170$fieldstosearchall = array( 171 's.nom'=>"ThirdPartyName", 172 's.name_alias'=>"AliasNameShort", 173 's.code_client'=>"CustomerCode", 174 's.code_fournisseur'=>"SupplierCode", 175 's.code_compta'=>"CustomerAccountancyCodeShort", 176 's.code_compta_fournisseur'=>"SupplierAccountancyCodeShort", 177 's.zip'=>"Zip", 178 's.town'=>"Town", 179 's.email'=>"EMail", 180 's.url'=>"URL", 181 's.tva_intra'=>"VATIntra", 182 's.siren'=>"ProfId1", 183 's.siret'=>"ProfId2", 184 's.ape'=>"ProfId3", 185 's.phone'=>"Phone", 186 's.fax'=>"Fax", 187); 188if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') { 189 $fieldstosearchall['s.idprof4'] = 'ProfId4'; 190} 191if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') { 192 $fieldstosearchall['s.idprof5'] = 'ProfId5'; 193} 194if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') { 195 $fieldstosearchall['s.idprof6'] = 'ProfId6'; 196} 197if (!empty($conf->barcode->enabled)) { 198 $fieldstosearchall['s.barcode'] = 'Gencod'; 199} 200// Personalized search criterias. Example: $conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS = 's.nom=ThirdPartyName;s.name_alias=AliasNameShort;s.code_client=CustomerCode' 201if (!empty($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS)) { 202 $fieldstosearchall = dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS); 203} 204 205 206// Define list of fields to show into list 207$checkedcustomercode = (in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist', 'poslist')) ? 1 : 0); 208$checkedsuppliercode = (in_array($contextpage, array('supplierlist')) ? 1 : 0); 209$checkedcustomeraccountcode = (in_array($contextpage, array('customerlist')) ? 1 : 0); 210$checkedsupplieraccountcode = (in_array($contextpage, array('supplierlist')) ? 1 : 0); 211$checkedtypetiers = 1; 212$checkedprofid1 = 0; 213$checkedprofid2 = 0; 214$checkedprofid3 = 0; 215$checkedprofid4 = 0; 216$checkedprofid5 = 0; 217$checkedprofid6 = 0; 218//$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0); 219//$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0); 220//$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0); 221$checkprospectlevel = (in_array($contextpage, array('prospectlist')) ? 1 : 0); 222$checkstcomm = (in_array($contextpage, array('prospectlist')) ? 1 : 0); 223$arrayfields = array( 224 's.rowid'=>array('label'=>"TechnicalID", 'position'=>1, 'checked'=>(!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)), 'enabled'=>(!empty($conf->global->MAIN_SHOW_TECHNICAL_ID))), 225 's.nom'=>array('label'=>"ThirdPartyName", 'position'=>2, 'checked'=>1), 226 's.name_alias'=>array('label'=>"AliasNameShort", 'position'=>3, 'checked'=>1), 227 's.barcode'=>array('label'=>"Gencod", 'position'=>5, 'checked'=>1, 'enabled'=>(!empty($conf->barcode->enabled))), 228 's.code_client'=>array('label'=>"CustomerCodeShort", 'position'=>10, 'checked'=>$checkedcustomercode), 229 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'position'=>11, 'checked'=>$checkedsuppliercode, 'enabled'=>((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), 230 's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'position'=>13, 'checked'=>$checkedcustomeraccountcode), 231 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'position'=>14, 'checked'=>$checkedsupplieraccountcode, 'enabled'=>((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), 232 's.address'=>array('label'=>"Address", 'position'=>19, 'checked'=>0), 233 's.zip'=>array('label'=>"Zip", 'position'=>20, 'checked'=>1), 234 's.town'=>array('label'=>"Town", 'position'=>21, 'checked'=>0), 235 'state.nom'=>array('label'=>"State", 'position'=>22, 'checked'=>0), 236 'region.nom'=>array('label'=>"Region", 'position'=>23, 'checked'=>0), 237 'country.code_iso'=>array('label'=>"Country", 'position'=>24, 'checked'=>0), 238 's.email'=>array('label'=>"Email", 'position'=>25, 'checked'=>0), 239 's.url'=>array('label'=>"Url", 'position'=>26, 'checked'=>0), 240 's.phone'=>array('label'=>"Phone", 'position'=>27, 'checked'=>1), 241 's.fax'=>array('label'=>"Fax", 'position'=>28, 'checked'=>0), 242 'typent.code'=>array('label'=>"ThirdPartyType", 'position'=>29, 'checked'=>$checkedtypetiers), 243 'staff.code'=>array('label'=>"Staff", 'position'=>31, 'checked'=>0), 244 's.siren'=>array('label'=>"ProfId1Short", 'position'=>40, 'checked'=>$checkedprofid1), 245 's.siret'=>array('label'=>"ProfId2Short", 'position'=>41, 'checked'=>$checkedprofid2), 246 's.ape'=>array('label'=>"ProfId3Short", 'position'=>42, 'checked'=>$checkedprofid3), 247 's.idprof4'=>array('label'=>"ProfId4Short", 'position'=>43, 'checked'=>$checkedprofid4), 248 's.idprof5'=>array('label'=>"ProfId5Short", 'position'=>44, 'checked'=>$checkedprofid5), 249 's.idprof6'=>array('label'=>"ProfId6Short", 'position'=>45, 'checked'=>$checkedprofid6), 250 's.tva_intra'=>array('label'=>"VATIntraShort", 'position'=>50, 'checked'=>0), 251 'customerorsupplier'=>array('label'=>'NatureOfThirdParty', 'position'=>61, 'checked'=>1), 252 's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'position'=>62, 'checked'=>$checkprospectlevel), 253 's.fk_stcomm'=>array('label'=>"StatusProsp", 'position'=>63, 'checked'=>$checkstcomm), 254 's2.nom'=>array('label'=>'ParentCompany', 'position'=>64, 'checked'=>0), 255 's.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 256 's.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 257 's.status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 258 's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), 259); 260if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { 261 $arrayfields['s.price_level'] =array('label'=>"PriceLevel", 'position'=>30, 'checked'=>0); 262} 263 264// Extra fields 265include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; 266 267$object->fields = dol_sort_array($object->fields, 'position'); 268$arrayfields = dol_sort_array($arrayfields, 'position'); 269 270 271/* 272 * Actions 273 */ 274 275if ($action == "change") { // Change customer for TakePOS 276 $idcustomer = GETPOST('idcustomer', 'int'); 277 278 // Check if draft invoice already exists, if not create it 279 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' AND entity IN (".getEntity('invoice').")"; 280 $result = $db->query($sql); 281 $num_lines = $db->num_rows($result); 282 if ($num_lines == 0) { 283 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; 284 $invoice = new Facture($db); 285 $constforthirdpartyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; 286 $invoice->socid = $conf->global->$constforthirdpartyid; 287 $invoice->date = dol_now(); 288 $invoice->module_source = 'takepos'; 289 $invoice->pos_source = $_SESSION["takeposterminal"]; 290 $placeid = $invoice->create($user); 291 $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid = ".((int) $placeid); 292 $db->query($sql); 293 } 294 295 $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".((int) $idcustomer)." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; 296 $resql = $db->query($sql); 297 ?> 298 <script> 299 console.log("Reload page invoice.php with place=<?php print $place; ?>"); 300 parent.$("#poslines").load("invoice.php?place=<?php print $place; ?>", function() { 301 //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight); 302 <?php if (!$resql) { ?> 303 alert('Error failed to update customer on draft invoice.'); 304 <?php } ?> 305 parent.$.colorbox.close(); /* Close the popup */ 306 }); 307 </script> 308 <?php 309 exit; 310} 311 312if (GETPOST('cancel', 'alpha')) { 313 $action = 'list'; $massaction = ''; 314} 315if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { 316 $massaction = ''; 317} 318 319$parameters = array(); 320$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks 321if ($reshook < 0) { 322 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 323} 324 325if (empty($reshook)) { 326 // Selection of new fields 327 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; 328 329 // Did we click on purge search criteria ? 330 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 331 $search_id = ''; 332 $search_nom = ''; 333 $search_alias = ''; 334 $search_categ_cus = 0; 335 $search_categ_sup = 0; 336 $search_sale = ''; 337 $search_barcode = ""; 338 $search_customer_code = ''; 339 $search_supplier_code = ''; 340 $search_account_customer_code = ''; 341 $search_account_supplier_code = ''; 342 $search_address = ''; 343 $search_town = ""; 344 $search_zip = ""; 345 $search_state = ""; 346 $search_country = ''; 347 $search_email = ''; 348 $search_phone = ''; 349 $search_fax = ''; 350 $search_url = ''; 351 $search_idprof1 = ''; 352 $search_idprof2 = ''; 353 $search_idprof3 = ''; 354 $search_idprof4 = ''; 355 $search_idprof5 = ''; 356 $search_idprof6 = ''; 357 $search_vat = ''; 358 $search_type = ''; 359 $search_price_level = ''; 360 $search_type_thirdparty = ''; 361 $search_staff = ''; 362 $search_status = -1; 363 $search_stcomm = ''; 364 $search_level = ''; 365 $search_parent_name = ''; 366 $search_import_key = ''; 367 $toselect = ''; 368 $search_array_options = array(); 369 } 370 371 // Mass actions 372 $objectclass = 'Societe'; 373 $objectlabel = 'ThirdParty'; 374 $permissiontoread = $user->rights->societe->lire; 375 $permissiontodelete = $user->rights->societe->supprimer; 376 $permissiontoadd = $user->rights->societe->creer; 377 $uploaddir = $conf->societe->dir_output; 378 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; 379 380 if ($action == 'setstcomm') { 381 $object = new Client($db); 382 $result = $object->fetch(GETPOST('stcommsocid')); 383 $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm'); 384 $result = $object->update($object->id, $user); 385 if ($result < 0) { 386 setEventMessages($object->error, $object->errors, 'errors'); 387 } 388 389 $action = ''; 390 } 391} 392 393if ($search_status == '') { 394 $search_status = 1; // always display active thirdparty first 395} 396 397 398 399/* 400 * View 401 */ 402 403/* 404 REM: Rules on permissions to see thirdparties 405 Internal or External user + No permission to see customers => See nothing 406 Internal user socid=0 + Permission to see ALL customers => See all thirdparties 407 Internal user socid=0 + No permission to see ALL customers => See only thirdparties linked to user that are sale representative 408 External user socid=x + Permission to see ALL customers => Can see only himself 409 External user socid=x + No permission to see ALL customers => Can see only himself 410 */ 411 412$form = new Form($db); 413$formother = new FormOther($db); 414$companystatic = new Societe($db); 415$companyparent = new Societe($db); 416$formcompany = new FormCompany($db); 417$prospectstatic = new Client($db); 418$prospectstatic->client = 2; 419$prospectstatic->loadCacheOfProspStatus(); 420 421 422$title = $langs->trans("ListOfThirdParties"); 423if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) { 424 $title = $langs->trans("ListOfCustomers"); 425} 426if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) { 427 $title = $langs->trans("ListOfProspects"); 428} 429if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) { 430 $title = $langs->trans("ListOfSuppliers"); 431} 432 433// Select every potentiels, and note each potentiels which fit in search parameters 434$tab_level = array(); 435$sql = "SELECT code, label, sortorder"; 436$sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; 437$sql .= " WHERE active > 0"; 438$sql .= " ORDER BY sortorder"; 439$resql = $db->query($sql); 440if ($resql) { 441 while ($obj = $db->fetch_object($resql)) { 442 // Compute level text 443 $level = $langs->trans($obj->code); 444 if ($level == $obj->code) { 445 $level = $langs->trans($obj->label); 446 } 447 $tab_level[$obj->code] = $level; 448 } 449} else { 450 dol_print_error($db); 451} 452 453$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.address, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,"; 454$sql .= " s.entity,"; 455$sql .= " st.libelle as stcomm, st.picto as stcomm_picto, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; 456$sql .= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,"; 457$sql .= " s.tms as date_update, s.datec as date_creation, s.import_key,"; 458$sql .= " s.code_compta, s.code_compta_fournisseur, s.parent as fk_parent,s.price_level,"; 459$sql .= " s2.nom as name2,"; 460$sql .= " typent.code as typent_code,"; 461$sql .= " staff.code as staff_code,"; 462$sql .= " country.code as country_code, country.label as country_label,"; 463$sql .= " state.code_departement as state_code, state.nom as state_name,"; 464$sql .= " region.code_region as region_code, region.nom as region_name"; 465// We'll need these fields in order to filter by sale (including the case where the user can only see his prospects) 466if ($search_sale && $search_sale != '-1') { 467 $sql .= ", sc.fk_soc, sc.fk_user"; 468} 469// We'll need these fields in order to filter by categ 470if ($search_categ_cus && $search_categ_cus!=-1) { 471 $sql .= ", cc.fk_categorie, cc.fk_soc"; 472} 473if ($search_categ_sup && $search_categ_sup!=-1) { 474 $sql .= ", cs.fk_categorie, cs.fk_soc"; 475} 476// Add fields from extrafields 477if (!empty($extrafields->attributes[$object->table_element]['label'])) { 478 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { 479 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); 480 } 481} 482// Add fields from hooks 483$parameters = array(); 484$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook 485$sql .= $hookmanager->resPrint; 486$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; 487$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s.parent = s2.rowid"; 488if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { 489 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (s.rowid = ef.fk_object)"; 490} 491$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; 492$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; 493$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_effectif)"; 494$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; 495$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region. code_region = state.fk_region)"; 496// We'll need this table joined to the select in order to filter by categ 497if (!empty($search_categ_cus) && $search_categ_cus != '-1') { 498 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ 499} 500if (!empty($search_categ_sup) && $search_categ_sup != '-1') { 501 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ 502} 503$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id"; 504// We'll need this table joined to the select in order to filter by sale 505if ($search_sale == -2) { 506 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; 507 //elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; 508} elseif (!empty($search_sale) && $search_sale != '-1' || (empty($user->rights->societe->client->voir) && !$socid)) { 509 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; 510} 511// Add table from hooks 512$parameters = array(); 513$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook 514$sql .= $hookmanager->resPrint; 515$sql .= " WHERE s.entity IN (".getEntity('societe').")"; 516//if (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); 517if (empty($user->rights->societe->client->voir) && !$socid) { 518 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); 519} 520if ($search_sale && $search_sale != '-1' && $search_sale != '-2') { 521 $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale 522} 523if (!$user->rights->fournisseur->lire) { 524 $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible 525} 526if ($search_sale == -2) { 527 $sql .= " AND sc.fk_user IS NULL"; 528} elseif ($search_sale > 0) { 529 $sql .= " AND sc.fk_user = ".((int) $search_sale); 530} 531if ($search_categ_cus > 0) { 532 $sql .= " AND cc.fk_categorie = ".((int) $search_categ_cus); 533} 534if ($search_categ_sup > 0) { 535 $sql .= " AND cs.fk_categorie = ".((int) $search_categ_sup); 536} 537if ($search_categ_cus == -2) { 538 $sql .= " AND cc.fk_categorie IS NULL"; 539} 540if ($search_categ_sup == -2) { 541 $sql .= " AND cs.fk_categorie IS NULL"; 542} 543 544if ($search_all) { 545 $sql .= natural_search(array_keys($fieldstosearchall), $search_all); 546} 547if (strlen($search_cti)) { 548 $sql .= natural_search('s.phone', $search_cti); 549} 550 551if ($search_id > 0) { 552 $sql .= natural_search("s.rowid", $search_id, 1); 553} 554if ($search_nom) { 555 $sql .= natural_search("s.nom", $search_nom); 556} 557if ($search_alias) { 558 $sql .= natural_search("s.name_alias", $search_alias); 559} 560if ($search_nom_only) { 561 $sql .= natural_search("s.nom", $search_nom_only); 562} 563if ($search_customer_code) { 564 $sql .= natural_search("s.code_client", $search_customer_code); 565} 566if ($search_supplier_code) { 567 $sql .= natural_search("s.code_fournisseur", $search_supplier_code); 568} 569if ($search_account_customer_code) { 570 $sql .= natural_search("s.code_compta", $search_account_customer_code); 571} 572if ($search_account_supplier_code) { 573 $sql .= natural_search("s.code_compta_fournisseur", $search_account_supplier_code); 574} 575if ($search_address) { 576 $sql.= natural_search('s.address', $search_address); 577} 578if ($search_town) { 579 $sql .= natural_search("s.town", $search_town); 580} 581if (strlen($search_zip)) { 582 $sql .= natural_search("s.zip", $search_zip); 583} 584if ($search_state) { 585 $sql .= natural_search("state.nom", $search_state); 586} 587if ($search_region) { 588 $sql .= natural_search("region.nom", $search_region); 589} 590if ($search_country && $search_country != '-1') { 591 $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')'; 592} 593if ($search_email) { 594 $sql .= natural_search("s.email", $search_email); 595} 596if (strlen($search_phone)) { 597 $sql .= natural_search("s.phone", $search_phone); 598} 599if (strlen($search_fax)) { 600 $sql .= natural_search("s.fax", $search_fax); 601} 602if ($search_url) { 603 $sql .= natural_search("s.url", $search_url); 604} 605if (strlen($search_idprof1)) { 606 $sql .= natural_search("s.siren", $search_idprof1); 607} 608if (strlen($search_idprof2)) { 609 $sql .= natural_search("s.siret", $search_idprof2); 610} 611if (strlen($search_idprof3)) { 612 $sql .= natural_search("s.ape", $search_idprof3); 613} 614if (strlen($search_idprof4)) { 615 $sql .= natural_search("s.idprof4", $search_idprof4); 616} 617if (strlen($search_idprof5)) { 618 $sql .= natural_search("s.idprof5", $search_idprof5); 619} 620if (strlen($search_idprof6)) { 621 $sql .= natural_search("s.idprof6", $search_idprof6); 622} 623if (strlen($search_vat)) { 624 $sql .= natural_search("s.tva_intra", $search_vat); 625} 626// Filter on type of thirdparty 627if ($search_type > 0 && in_array($search_type, array('1,3', '1,2,3', '2,3'))) { 628 $sql .= " AND s.client IN (".$db->sanitize($search_type).")"; 629} 630if ($search_type > 0 && in_array($search_type, array('4'))) { 631 $sql .= " AND s.fournisseur = 1"; 632} 633if ($search_type == '0') { 634 $sql .= " AND s.client = 0 AND s.fournisseur = 0"; 635} 636if ($search_status != '' && $search_status >= 0) { 637 $sql .= natural_search("s.status", $search_status, 2); 638} 639if (!empty($conf->barcode->enabled) && $search_barcode) { 640 $sql .= natural_search("s.barcode", $search_barcode); 641} 642if ($search_price_level && $search_price_level != '-1') { 643 $sql .= natural_search("s.price_level", $search_price_level, 2); 644} 645if ($search_type_thirdparty && $search_type_thirdparty > 0) { 646 $sql .= natural_search("s.fk_typent", $search_type_thirdparty, 2); 647} 648if (!empty($search_staff) && $search_staff != '-1') { 649 $sql .= natural_search("s.fk_effectif", $search_staff, 2); 650} 651if ($search_level) { 652 $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3); 653} 654if ($search_parent_name) { 655 $sql .= natural_search("s2.nom", $search_parent_name); 656} 657if ($search_stcomm != '' && $search_stcomm != '-2') { // -2 is not filter 658 $sql .= natural_search("s.fk_stcomm", $search_stcomm, 1); 659} 660if ($search_import_key) { 661 $sql .= natural_search("s.import_key", $search_import_key); 662} 663// Add where from extra fields 664include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; 665// Add where from hooks 666$parameters = array('socid' => $socid); 667$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook 668if (empty($reshook)) { 669 if ($socid) { 670 $sql .= " AND s.rowid = ".((int) $socid); 671 } 672} 673$sql .= $hookmanager->resPrint; 674// Add GroupBy from hooks 675$parameters = array('all' => $all, 'fieldstosearchall' => $fieldstosearchall); 676$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook 677$sql .= $hookmanager->resPrint; 678 679$sql .= $db->order($sortfield, $sortorder); 680 681// Count total nb of records 682$nbtotalofrecords = ''; 683if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { 684 $result = $db->query($sql); 685 $nbtotalofrecords = $db->num_rows($result); 686 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 687 $page = 0; 688 $offset = 0; 689 } 690} 691 692$sql .= $db->plimit($limit + 1, $offset); 693 694$resql = $db->query($sql); 695if (!$resql) { 696 dol_print_error($db); 697 exit; 698} 699 700$num = $db->num_rows($resql); 701 702$arrayofselected = is_array($toselect) ? $toselect : array(); 703 704if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list') { 705 $obj = $db->fetch_object($resql); 706 $id = $obj->rowid; 707 if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)) { 708 if ($obj->client > 0) { 709 header("Location: ".DOL_URL_ROOT.'/comm/card.php?socid='.$id); 710 exit; 711 } 712 if ($obj->fournisseur > 0) { 713 header("Location: ".DOL_URL_ROOT.'/fourn/card.php?socid='.$id); 714 exit; 715 } 716 } 717 718 header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id); 719 exit; 720} 721 722$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; 723llxHeader('', $langs->trans("ThirdParty"), $help_url); 724 725$param = ''; 726if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { 727 $param .= '&contextpage='.urlencode($contextpage); 728} 729if ($limit > 0 && $limit != $conf->liste_limit) { 730 $param .= '&limit='.urlencode($limit); 731} 732if ($search_all != '') { 733 $param = "&sall=".urlencode($search_all); 734} 735if ($search_categ_cus > 0) { 736 $param .= '&search_categ_cus='.urlencode($search_categ_cus); 737} 738if ($search_categ_sup > 0) { 739 $param .= '&search_categ_sup='.urlencode($search_categ_sup); 740} 741if ($search_sale > 0) { 742 $param .= '&search_sale='.urlencode($search_sale); 743} 744if ($search_id > 0) { 745 $param .= "&search_id=".urlencode($search_id); 746} 747if ($search_nom != '') { 748 $param .= "&search_nom=".urlencode($search_nom); 749} 750if ($search_alias != '') { 751 $param .= "&search_alias=".urlencode($search_alias); 752} 753if ($search_address != '') { 754 $param .= '&search_address=' . urlencode($search_address); 755} 756if ($search_town != '') { 757 $param .= "&search_town=".urlencode($search_town); 758} 759if ($search_zip != '') { 760 $param .= "&search_zip=".urlencode($search_zip); 761} 762if ($search_phone != '') { 763 $param .= "&search_phone=".urlencode($search_phone); 764} 765if ($search_fax != '') { 766 $param .= "&search_fax=".urlencode($search_fax); 767} 768if ($search_email != '') { 769 $param .= "&search_email=".urlencode($search_email); 770} 771if ($search_url != '') { 772 $param .= "&search_url=".urlencode($search_url); 773} 774if ($search_state != '') { 775 $param .= "&search_state=".urlencode($search_state); 776} 777if ($search_country != '') { 778 $param .= "&search_country=".urlencode($search_country); 779} 780if ($search_customer_code != '') { 781 $param .= "&search_customer_code=".urlencode($search_customer_code); 782} 783if ($search_supplier_code != '') { 784 $param .= "&search_supplier_code=".urlencode($search_supplier_code); 785} 786if ($search_account_customer_code != '') { 787 $param .= "&search_account_customer_code=".urlencode($search_account_customer_code); 788} 789if ($search_account_supplier_code != '') { 790 $param .= "&search_account_supplier_code=".urlencode($search_account_supplier_code); 791} 792if ($search_barcode != '') { 793 $param .= "&search_barcode=".urlencode($search_barcode); 794} 795if ($search_idprof1 != '') { 796 $param .= '&search_idprof1='.urlencode($search_idprof1); 797} 798if ($search_idprof2 != '') { 799 $param .= '&search_idprof2='.urlencode($search_idprof2); 800} 801if ($search_idprof3 != '') { 802 $param .= '&search_idprof3='.urlencode($search_idprof3); 803} 804if ($search_idprof4 != '') { 805 $param .= '&search_idprof4='.urlencode($search_idprof4); 806} 807if ($search_idprof5 != '') { 808 $param .= '&search_idprof5='.urlencode($search_idprof5); 809} 810if ($search_idprof6 != '') { 811 $param .= '&search_idprof6='.urlencode($search_idprof6); 812} 813if ($search_vat != '') { 814 $param .= '&search_vat='.urlencode($search_vat); 815} 816if ($search_price_level != '') { 817 $param .= '&search_price_level='.urlencode($search_price_level); 818} 819if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { 820 $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); 821} 822if ($search_type != '') { 823 $param .= '&search_type='.urlencode($search_type); 824} 825if (is_array($search_level) && count($search_level)) { 826 foreach ($search_level as $slevel) { 827 $param .= '&search_level[]='.urlencode($slevel); 828 } 829} 830if ($search_status != '') { 831 $param .= '&search_status='.urlencode($search_status); 832} 833if ($search_stcomm != '' && $search_stcomm != '-2') { // -2 is no filter 834 $param .= '&search_stcomm='.urlencode($search_stcomm); 835} 836if ($search_parent_name != '') { 837 $param .= '&search_parent_name='.urlencode($search_parent_name); 838} 839if ($search_import_key != '') { 840 $param .= '&search_import_key='.urlencode($search_import_key); 841} 842if ($type != '') { 843 $param .= '&type='.urlencode($type); 844} 845if ($optioncss != '') { 846 $param .= '&optioncss='.urlencode($optioncss); 847} 848// Add $param from extra fields 849include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; 850 851// Show delete result message 852if (GETPOST('delsoc')) { 853 setEventMessages($langs->trans("CompanyDeleted", GETPOST('delsoc')), null, 'mesgs'); 854} 855 856// List of mass actions available 857$arrayofmassactions = array( 858'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), 859// 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), 860); 861//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); 862if ($user->rights->societe->supprimer) { 863 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); 864} 865if ($user->rights->societe->creer) { 866 $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); 867} 868if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) { 869 $arrayofmassactions = array(); 870} 871$massactionbutton = $form->selectMassAction('', $arrayofmassactions); 872 873$typefilter = ''; 874$label = 'MenuNewThirdParty'; 875 876if (!empty($type)) { 877 $typefilter = '&type='.$type; 878 if ($type == 'p') { 879 $label = 'MenuNewProspect'; 880 } 881 if ($type == 'c') { 882 $label = 'MenuNewCustomer'; 883 } 884 if ($type == 'f') { 885 $label = 'NewSupplier'; 886 } 887} 888 889if ($contextpage == 'poslist' && $type == 't' && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) { 890 print get_htmloutput_mesg(img_warning('default').' '.$langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), '', 'warning', 1); 891} 892 893// Show the new button only when this page is not opend from the Extended POS (pop-up window) 894// but allow it too, when a user has the rights to create a new customer 895if ($contextpage != 'poslist') { 896 $url = DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter; 897 if (!empty($socid)) { 898 $url .= '&socid='.$socid; 899 } 900 $newcardbutton = dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->rights->societe->creer); 901} elseif ($user->rights->societe->creer) { 902 $url = DOL_URL_ROOT.'/societe/card.php?action=create&type=t&contextpage=poslist&optioncss=print&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type=t&contextpage=poslist&nomassaction=1&optioncss=print&place='.$place); 903 $label = 'MenuNewCustomer'; 904 $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url); 905} 906 907print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'" name="formfilter" autocomplete="off">'; 908if ($optioncss != '') { 909 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; 910} 911print '<input type="hidden" name="token" value="'.newToken().'">'; 912print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; 913print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; 914print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; 915//print '<input type="hidden" name="page" value="'.$page.'">'; 916print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; 917 918print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'building', 0, $newcardbutton, '', $limit, 0, 0, 1); 919 920$langs->load("other"); 921$textprofid = array(); 922foreach (array(1, 2, 3, 4, 5, 6) as $key) { 923 $label = $langs->transnoentities("ProfId".$key.$mysoc->country_code); 924 $textprofid[$key] = ''; 925 if ($label != "ProfId".$key.$mysoc->country_code) { // Get only text between () 926 if (preg_match('/\((.*)\)/i', $label, $reg)) { 927 $label = $reg[1]; 928 } 929 $textprofid[$key] = $langs->trans("ProfIdShortDesc", $key, $mysoc->country_code, $label); 930 } 931} 932 933$topicmail = "Information"; 934$modelmail = "thirdparty"; 935$objecttmp = new Societe($db); 936$trackid = 'thi'.$object->id; 937include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; 938 939if ($search_all) { 940 foreach ($fieldstosearchall as $key => $val) { 941 $fieldstosearchall[$key] = $langs->trans($val); 942 } 943 print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; 944} 945 946// Filter on categories 947$moreforfilter = ''; 948if (empty($type) || $type == 'c' || $type == 'p') { 949 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { 950 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; 951 $moreforfilter .= '<div class="divsearchfield">'; 952 $tmptitle = $langs->trans('Categories'); 953 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); 954 $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort')); 955 $moreforfilter .= '</div>'; 956 } 957} 958 959if (empty($type) || $type == 'f') { 960 if (!empty($conf->fournisseur->enabled) && !empty($conf->categorie->enabled) && $user->rights->categorie->lire) { 961 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; 962 $moreforfilter .= '<div class="divsearchfield">'; 963 $tmptitle = $langs->trans('Categories'); 964 $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); 965 $moreforfilter .= $formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1, $langs->trans('SuppliersCategoriesShort')); 966 $moreforfilter .= '</div>'; 967 } 968} 969 970// If the user can view prospects other than his' 971if ($user->rights->societe->client->voir || $socid) { 972 $moreforfilter .= '<div class="divsearchfield">'; 973 $tmptitle = $langs->trans('SalesRepresentatives'); 974 $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"'); 975 $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $langs->trans('SalesRepresentatives'), ($conf->dol_optimize_smallscreen ? 'maxwidth200' : 'maxwidth300'), 1); 976 $moreforfilter .= '</div>'; 977} 978if ($moreforfilter) { 979 print '<div class="liste_titre liste_titre_bydiv centpercent">'; 980 print $moreforfilter; 981 $parameters = array('type'=>$type); 982 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook 983 print $hookmanager->resPrint; 984 print '</div>'; 985} 986 987$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; 988$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields 989// Show the massaction checkboxes only when this page is not opend from the Extended POS 990if ($massactionbutton && $contextpage != 'poslist') { 991 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); 992} 993 994if (empty($arrayfields['customerorsupplier']['checked'])) { 995 print '<input type="hidden" name="type" value="'.$type.'">'; 996} 997 998print '<div class="div-table-responsive">'; 999print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; 1000 1001// Fields title search 1002print '<tr class="liste_titre_filter">'; 1003if (!empty($arrayfields['s.rowid']['checked'])) { 1004 print '<td class="liste_titre">'; 1005 print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">'; 1006 print '</td>'; 1007} 1008if (!empty($arrayfields['s.nom']['checked'])) { 1009 print '<td class="liste_titre">'; 1010 if (!empty($search_nom_only) && empty($search_nom)) { 1011 $search_nom = $search_nom_only; 1012 } 1013 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_nom" value="'.dol_escape_htmltag($search_nom).'">'; 1014 print '</td>'; 1015} 1016if (!empty($arrayfields['s.name_alias']['checked'])) { 1017 print '<td class="liste_titre">'; 1018 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_alias" value="'.dol_escape_htmltag($search_alias).'">'; 1019 print '</td>'; 1020} 1021// Barcode 1022if (!empty($arrayfields['s.barcode']['checked'])) { 1023 print '<td class="liste_titre">'; 1024 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_barcode" value="'.dol_escape_htmltag($search_barcode).'">'; 1025 print '</td>'; 1026} 1027// Customer code 1028if (!empty($arrayfields['s.code_client']['checked'])) { 1029 print '<td class="liste_titre">'; 1030 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).'">'; 1031 print '</td>'; 1032} 1033// Supplier code 1034if (!empty($arrayfields['s.code_fournisseur']['checked'])) { 1035 print '<td class="liste_titre">'; 1036 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_supplier_code" value="'.dol_escape_htmltag($search_supplier_code).'">'; 1037 print '</td>'; 1038} 1039// Account Customer code 1040if (!empty($arrayfields['s.code_compta']['checked'])) { 1041 print '<td class="liste_titre">'; 1042 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_account_customer_code" value="'.dol_escape_htmltag($search_account_customer_code).'">'; 1043 print '</td>'; 1044} 1045// Account Supplier code 1046if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) { 1047 print '<td class="liste_titre">'; 1048 print '<input class="flat maxwidth75imp" type="text" name="search_account_supplier_code" value="'.dol_escape_htmltag($search_account_supplier_code).'">'; 1049 print '</td>'; 1050} 1051// Address 1052if (!empty($arrayfields['s.address']['checked'])) { 1053 print '<td class="liste_titre">'; 1054 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_address" value="'.dol_escape_htmltag($search_address).'">'; 1055 print '</td>'; 1056} 1057// Zip 1058if (!empty($arrayfields['s.zip']['checked'])) { 1059 print '<td class="liste_titre">'; 1060 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">'; 1061 print '</td>'; 1062} 1063// Town 1064if (!empty($arrayfields['s.town']['checked'])) { 1065 print '<td class="liste_titre">'; 1066 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">'; 1067 print '</td>'; 1068} 1069// State 1070if (!empty($arrayfields['state.nom']['checked'])) { 1071 print '<td class="liste_titre">'; 1072 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">'; 1073 print '</td>'; 1074} 1075// Region 1076if (!empty($arrayfields['region.nom']['checked'])) { 1077 print '<td class="liste_titre">'; 1078 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_region" value="'.dol_escape_htmltag($search_region).'">'; 1079 print '</td>'; 1080} 1081// Country 1082if (!empty($arrayfields['country.code_iso']['checked'])) { 1083 print '<td class="liste_titre center">'; 1084 print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); 1085 print '</td>'; 1086} 1087// Company type 1088if (!empty($arrayfields['typent.code']['checked'])) { 1089 print '<td class="liste_titre maxwidthonsmartphone center">'; 1090 // We use showempty=0 here because there is already an unknown value into dictionary. 1091 print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), 'minwidth50 maxwidth100', 1); 1092 print '</td>'; 1093} 1094// Multiprice level 1095if (!empty($arrayfields['s.price_level']['checked'])) { 1096 print '<td class="liste_titre">'; 1097 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_price_level" value="'.dol_escape_htmltag($search_price_level).'">'; 1098 print '</td>'; 1099} 1100// Staff 1101if (!empty($arrayfields['staff.code']['checked'])) { 1102 print '<td class="liste_titre maxwidthonsmartphone center">'; 1103 print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100', 1); 1104 print '</td>'; 1105} 1106if (!empty($arrayfields['s.email']['checked'])) { 1107 // Email 1108 print '<td class="liste_titre">'; 1109 print '<input class="flat searchemail maxwidth50imp" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">'; 1110 print '</td>'; 1111} 1112if (!empty($arrayfields['s.phone']['checked'])) { 1113 // Phone 1114 print '<td class="liste_titre">'; 1115 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'">'; 1116 print '</td>'; 1117} 1118if (!empty($arrayfields['s.fax']['checked'])) { 1119 // Fax 1120 print '<td class="liste_titre">'; 1121 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_fax" value="'.dol_escape_htmltag($search_fax).'">'; 1122 print '</td>'; 1123} 1124if (!empty($arrayfields['s.url']['checked'])) { 1125 // Url 1126 print '<td class="liste_titre">'; 1127 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_url" value="'.dol_escape_htmltag($search_url).'">'; 1128 print '</td>'; 1129} 1130if (!empty($arrayfields['s.siren']['checked'])) { 1131 // IdProf1 1132 print '<td class="liste_titre">'; 1133 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof1" value="'.dol_escape_htmltag($search_idprof1).'">'; 1134 print '</td>'; 1135} 1136if (!empty($arrayfields['s.siret']['checked'])) { 1137 // IdProf2 1138 print '<td class="liste_titre">'; 1139 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof2" value="'.dol_escape_htmltag($search_idprof2).'">'; 1140 print '</td>'; 1141} 1142if (!empty($arrayfields['s.ape']['checked'])) { 1143 // IdProf3 1144 print '<td class="liste_titre">'; 1145 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof3" value="'.dol_escape_htmltag($search_idprof3).'">'; 1146 print '</td>'; 1147} 1148if (!empty($arrayfields['s.idprof4']['checked'])) { 1149 // IdProf4 1150 print '<td class="liste_titre">'; 1151 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof4" value="'.dol_escape_htmltag($search_idprof4).'">'; 1152 print '</td>'; 1153} 1154if (!empty($arrayfields['s.idprof5']['checked'])) { 1155 // IdProf5 1156 print '<td class="liste_titre">'; 1157 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof5" value="'.dol_escape_htmltag($search_idprof5).'">'; 1158 print '</td>'; 1159} 1160if (!empty($arrayfields['s.idprof6']['checked'])) { 1161 // IdProf6 1162 print '<td class="liste_titre">'; 1163 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof6" value="'.dol_escape_htmltag($search_idprof6).'">'; 1164 print '</td>'; 1165} 1166if (!empty($arrayfields['s.tva_intra']['checked'])) { 1167 // Vat number 1168 print '<td class="liste_titre">'; 1169 print '<input class="flat searchstring maxwidth50imp" type="text" name="search_vat" value="'.dol_escape_htmltag($search_vat).'">'; 1170 print '</td>'; 1171} 1172 1173// Nature (customer/prospect/supplier) 1174if (!empty($arrayfields['customerorsupplier']['checked'])) { 1175 print '<td class="liste_titre maxwidthonsmartphone center">'; 1176 if ($type != '') { 1177 print '<input type="hidden" name="type" value="'.$type.'">'; 1178 } 1179 print $formcompany->selectProspectCustomerType($search_type, 'search_type', 'search_type', 'list'); 1180 print '</select></td>'; 1181} 1182// Prospect level 1183if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) { 1184 print '<td class="liste_titre center">'; 1185 print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2); 1186 print '</td>'; 1187} 1188// Prospect status 1189if (!empty($arrayfields['s.fk_stcomm']['checked'])) { 1190 print '<td class="liste_titre maxwidthonsmartphone center">'; 1191 $arraystcomm = array(); 1192 foreach ($prospectstatic->cacheprospectstatus as $key => $val) { 1193 $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); 1194 } 1195 print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', '', 1); 1196 print '</td>'; 1197} 1198if (!empty($arrayfields['s2.nom']['checked'])) { 1199 print '<td class="liste_titre center">'; 1200 print '<input class="flat searchstring maxwidth75imp" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).'">'; 1201 print '</td>'; 1202} 1203// Extra fields 1204include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; 1205 1206// Fields from hook 1207$parameters = array('arrayfields'=>$arrayfields); 1208$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook 1209print $hookmanager->resPrint; 1210// Date creation 1211if (!empty($arrayfields['s.datec']['checked'])) { 1212 print '<td class="liste_titre">'; 1213 print '</td>'; 1214} 1215// Date modification 1216if (!empty($arrayfields['s.tms']['checked'])) { 1217 print '<td class="liste_titre">'; 1218 print '</td>'; 1219} 1220// Status 1221if (!empty($arrayfields['s.status']['checked'])) { 1222 print '<td class="liste_titre center minwidth75imp">'; 1223 print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1); 1224 print '</td>'; 1225} 1226if (!empty($arrayfields['s.import_key']['checked'])) { 1227 print '<td class="liste_titre center">'; 1228 print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">'; 1229 print '</td>'; 1230} 1231// Action column 1232print '<td class="liste_titre center">'; 1233$searchpicto = $form->showFilterButtons(); 1234print $searchpicto; 1235print '</td>'; 1236 1237print "</tr>\n"; 1238print '<tr class="liste_titre">'; 1239if (!empty($arrayfields['s.rowid']['checked'])) { 1240 print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); 1241} 1242if (!empty($arrayfields['s.nom']['checked'])) { 1243 print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); 1244} 1245if (!empty($arrayfields['s.name_alias']['checked'])) { 1246 print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder); 1247} 1248if (!empty($arrayfields['s.barcode']['checked'])) { 1249 print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode", $param, '', '', $sortfield, $sortorder); 1250} 1251if (!empty($arrayfields['s.code_client']['checked'])) { 1252 print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER["PHP_SELF"], "s.code_client", "", $param, '', $sortfield, $sortorder); 1253} 1254if (!empty($arrayfields['s.code_fournisseur']['checked'])) { 1255 print_liste_field_titre($arrayfields['s.code_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $param, '', $sortfield, $sortorder); 1256} 1257if (!empty($arrayfields['s.code_compta']['checked'])) { 1258 print_liste_field_titre($arrayfields['s.code_compta']['label'], $_SERVER["PHP_SELF"], "s.code_compta", "", $param, '', $sortfield, $sortorder); 1259} 1260if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) { 1261 print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_compta_fournisseur", "", $param, '', $sortfield, $sortorder); 1262} 1263if (!empty($arrayfields['s.address']['checked'])) { 1264 print_liste_field_titre($arrayfields['s.address']['label'], $_SERVER['PHP_SELF'], 's.address', '', $param, '', $sortfield, $sortorder); 1265} 1266if (!empty($arrayfields['s.zip']['checked'])) { 1267 print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], "s.zip", "", $param, '', $sortfield, $sortorder); 1268} 1269if (!empty($arrayfields['s.town']['checked'])) { 1270 print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], "s.town", "", $param, '', $sortfield, $sortorder); 1271} 1272if (!empty($arrayfields['state.nom']['checked'])) { 1273 print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); 1274} 1275if (!empty($arrayfields['region.nom']['checked'])) { 1276 print_liste_field_titre($arrayfields['region.nom']['label'], $_SERVER["PHP_SELF"], "region.nom", "", $param, '', $sortfield, $sortorder); 1277} 1278if (!empty($arrayfields['country.code_iso']['checked'])) { 1279 print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); 1280} 1281if (!empty($arrayfields['typent.code']['checked'])) { 1282 print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, "", $sortfield, $sortorder, 'center '); 1283} 1284if (!empty($arrayfields['staff.code']['checked'])) { 1285 print_liste_field_titre($arrayfields['staff.code']['label'], $_SERVER["PHP_SELF"], "staff.code", "", $param, '', $sortfield, $sortorder, 'center '); 1286} 1287if (!empty($arrayfields['s.price_level']['checked'])) { 1288 print_liste_field_titre($arrayfields['s.price_level']['label'], $_SERVER["PHP_SELF"], "s.price_level", "", $param, '', $sortfield, $sortorder); 1289} 1290if (!empty($arrayfields['s.email']['checked'])) { 1291 print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder); 1292} 1293if (!empty($arrayfields['s.phone']['checked'])) { 1294 print_liste_field_titre($arrayfields['s.phone']['label'], $_SERVER["PHP_SELF"], "s.phone", "", $param, '', $sortfield, $sortorder); 1295} 1296if (!empty($arrayfields['s.fax']['checked'])) { 1297 print_liste_field_titre($arrayfields['s.fax']['label'], $_SERVER["PHP_SELF"], "s.fax", "", $param, '', $sortfield, $sortorder); 1298} 1299if (!empty($arrayfields['s.url']['checked'])) { 1300 print_liste_field_titre($arrayfields['s.url']['label'], $_SERVER["PHP_SELF"], "s.url", "", $param, '', $sortfield, $sortorder); 1301} 1302if (!empty($arrayfields['s.siren']['checked'])) { 1303 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"), $textprofid[1], 1, 0), $_SERVER["PHP_SELF"], "s.siren", "", $param, '', $sortfield, $sortorder, 'nowrap '); 1304} 1305if (!empty($arrayfields['s.siret']['checked'])) { 1306 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"), $textprofid[2], 1, 0), $_SERVER["PHP_SELF"], "s.siret", "", $param, '', $sortfield, $sortorder, 'nowrap '); 1307} 1308if (!empty($arrayfields['s.ape']['checked'])) { 1309 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"), $textprofid[3], 1, 0), $_SERVER["PHP_SELF"], "s.ape", "", $param, '', $sortfield, $sortorder, 'nowrap '); 1310} 1311if (!empty($arrayfields['s.idprof4']['checked'])) { 1312 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof4", "", $param, '', $sortfield, $sortorder, 'nowrap '); 1313} 1314if (!empty($arrayfields['s.idprof5']['checked'])) { 1315 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof5", "", $param, '', $sortfield, $sortorder, 'nowrap '); 1316} 1317if (!empty($arrayfields['s.idprof6']['checked'])) { 1318 print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof6", "", $param, '', $sortfield, $sortorder, 'nowrap '); 1319} 1320if (!empty($arrayfields['s.tva_intra']['checked'])) { 1321 print_liste_field_titre($arrayfields['s.tva_intra']['label'], $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder, 'nowrap '); 1322} 1323if (!empty($arrayfields['customerorsupplier']['checked'])) { 1324 print_liste_field_titre(''); // type of customer 1325} 1326if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) { 1327 print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "s.fk_prospectlevel", "", $param, '', $sortfield, $sortorder, 'center '); 1328} 1329if (!empty($arrayfields['s.fk_stcomm']['checked'])) { 1330 print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, '', $sortfield, $sortorder, 'center '); 1331} 1332if (!empty($arrayfields['s2.nom']['checked'])) { 1333 print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER["PHP_SELF"], "s2.nom", "", $param, '', $sortfield, $sortorder, 'center '); 1334} 1335 1336// Extra fields 1337include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; 1338// Hook fields 1339$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); 1340$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook 1341print $hookmanager->resPrint; 1342if (!empty($arrayfields['s.datec']['checked'])) { 1343 print_liste_field_titre($arrayfields['s.datec']['label'], $_SERVER["PHP_SELF"], "s.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); 1344} 1345if (!empty($arrayfields['s.tms']['checked'])) { 1346 print_liste_field_titre($arrayfields['s.tms']['label'], $_SERVER["PHP_SELF"], "s.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); 1347} 1348if (!empty($arrayfields['s.status']['checked'])) { 1349 print_liste_field_titre($arrayfields['s.status']['label'], $_SERVER["PHP_SELF"], "s.status", "", $param, '', $sortfield, $sortorder, 'center '); 1350} 1351if (!empty($arrayfields['s.import_key']['checked'])) { 1352 print_liste_field_titre($arrayfields['s.import_key']['label'], $_SERVER["PHP_SELF"], "s.import_key", "", $param, '', $sortfield, $sortorder, 'center '); 1353} 1354print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); 1355print "</tr>\n"; 1356 1357 1358$i = 0; 1359$totalarray = array(); 1360while ($i < min($num, $limit)) { 1361 $obj = $db->fetch_object($resql); 1362 1363 $companystatic->id = $obj->rowid; 1364 $companystatic->name = $obj->name; 1365 $companystatic->name_alias = $obj->name_alias; 1366 $companystatic->logo = $obj->logo; 1367 $companystatic->canvas = $obj->canvas; 1368 $companystatic->client = $obj->client; 1369 $companystatic->status = $obj->status; 1370 $companystatic->email = $obj->email; 1371 $companystatic->fournisseur = $obj->fournisseur; 1372 $companystatic->code_client = $obj->code_client; 1373 $companystatic->code_fournisseur = $obj->code_fournisseur; 1374 $companystatic->tva_intra = $obj->tva_intra; 1375 $companystatic->country_code = $obj->country_code; 1376 1377 $companystatic->code_compta_client = $obj->code_compta; 1378 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; 1379 1380 $companystatic->fk_prospectlevel = $obj->fk_prospectlevel; 1381 $companystatic->fk_parent = $obj->fk_parent; 1382 $companystatic->entity = $obj->entity; 1383 1384 print '<tr class="oddeven"'; 1385 if ($contextpage == 'poslist') { 1386 print ' onclick="location.href=\'list.php?action=change&contextpage=poslist&idcustomer='.$obj->rowid.'&place='.urlencode($place).'\'"'; 1387 } 1388 print '>'; 1389 if (!empty($arrayfields['s.rowid']['checked'])) { 1390 print '<td class="tdoverflowmax50">'; 1391 print $obj->rowid; 1392 print "</td>\n"; 1393 if (!$i) { 1394 $totalarray['nbfield']++; 1395 } 1396 } 1397 if (!empty($arrayfields['s.nom']['checked'])) { 1398 $savalias = $obj->name_alias; 1399 if (!empty($arrayfields['s.name_alias']['checked'])) { 1400 $companystatic->name_alias = ''; 1401 } 1402 print '<td'.(empty($conf->global->MAIN_SOCIETE_SHOW_COMPLETE_NAME) ? ' class="tdoverflowmax200"' : '').'>'; 1403 if ($contextpage == 'poslist') { 1404 print $obj->name; 1405 } else { 1406 print $companystatic->getNomUrl(1, '', 100, 0, 1); 1407 } 1408 print "</td>\n"; 1409 $companystatic->name_alias = $savalias; 1410 if (!$i) { 1411 $totalarray['nbfield']++; 1412 } 1413 } 1414 if (!empty($arrayfields['s.name_alias']['checked'])) { 1415 print '<td class="tdoverflowmax200">'; 1416 print dol_escape_htmltag($companystatic->name_alias); 1417 print "</td>\n"; 1418 if (!$i) { 1419 $totalarray['nbfield']++; 1420 } 1421 } 1422 // Barcode 1423 if (!empty($arrayfields['s.barcode']['checked'])) { 1424 print '<td>'.dol_escape_htmltag($obj->barcode).'</td>'; 1425 if (!$i) { 1426 $totalarray['nbfield']++; 1427 } 1428 } 1429 // Customer code 1430 if (!empty($arrayfields['s.code_client']['checked'])) { 1431 print '<td class="nowraponall">'.dol_escape_htmltag($obj->code_client).'</td>'; 1432 if (!$i) { 1433 $totalarray['nbfield']++; 1434 } 1435 } 1436 // Supplier code 1437 if (!empty($arrayfields['s.code_fournisseur']['checked'])) { 1438 print '<td class="nowraponall">'.dol_escape_htmltag($obj->code_fournisseur).'</td>'; 1439 if (!$i) { 1440 $totalarray['nbfield']++; 1441 } 1442 } 1443 // Account customer code 1444 if (!empty($arrayfields['s.code_compta']['checked'])) { 1445 print '<td>'.dol_escape_htmltag($obj->code_compta).'</td>'; 1446 if (!$i) { 1447 $totalarray['nbfield']++; 1448 } 1449 } 1450 // Account supplier code 1451 if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) { 1452 print '<td>'.dol_escape_htmltag($obj->code_compta_fournisseur).'</td>'; 1453 if (!$i) { 1454 $totalarray['nbfield']++; 1455 } 1456 } 1457 // Address 1458 if (!empty($arrayfields['s.address']['checked'])) { 1459 print '<td>'.dol_escape_htmltag($obj->address).'</td>'; 1460 if (!$i) { 1461 $totalarray['nbfield']++; 1462 } 1463 } 1464 // Zip 1465 if (!empty($arrayfields['s.zip']['checked'])) { 1466 print "<td>".dol_escape_htmltag($obj->zip)."</td>\n"; 1467 if (!$i) { 1468 $totalarray['nbfield']++; 1469 } 1470 } 1471 // Town 1472 if (!empty($arrayfields['s.town']['checked'])) { 1473 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->town).'">'.dol_escape_htmltag($obj->town)."</td>\n"; 1474 if (!$i) { 1475 $totalarray['nbfield']++; 1476 } 1477 } 1478 // State 1479 if (!empty($arrayfields['state.nom']['checked'])) { 1480 print "<td>".dol_escape_htmltag($obj->state_name)."</td>\n"; 1481 if (!$i) { 1482 $totalarray['nbfield']++; 1483 } 1484 } 1485 // Region 1486 if (!empty($arrayfields['region.nom']['checked'])) { 1487 print "<td>".dol_escape_htmltag($obj->region_name)."</td>\n"; 1488 if (!$i) { 1489 $totalarray['nbfield']++; 1490 } 1491 } 1492 // Country 1493 if (!empty($arrayfields['country.code_iso']['checked'])) { 1494 print '<td class="center tdoverflowmax100">'; 1495 $labelcountry = ($obj->country_code && ($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code)) ? $langs->trans("Country".$obj->country_code) : $obj->country_label; 1496 print $labelcountry; 1497 print '</td>'; 1498 if (!$i) { 1499 $totalarray['nbfield']++; 1500 } 1501 } 1502 // Type ent 1503 if (!empty($arrayfields['typent.code']['checked'])) { 1504 print '<td class="center">'; 1505 if (!is_array($typenArray) || count($typenArray) == 0) { 1506 $typenArray = $formcompany->typent_array(1); 1507 } 1508 print $typenArray[$obj->typent_code]; 1509 print '</td>'; 1510 if (!$i) { 1511 $totalarray['nbfield']++; 1512 } 1513 } 1514 // Multiprice level 1515 if (!empty($arrayfields['s.price_level']['checked'])) { 1516 print '<td class="center">'.$obj->price_level."</td>\n"; 1517 if (!$i) { 1518 $totalarray['nbfield']++; 1519 } 1520 } 1521 // Staff 1522 if (!empty($arrayfields['staff.code']['checked'])) { 1523 print '<td class="center">'; 1524 if (!is_array($staffArray) || count($staffArray) == 0) { 1525 $staffArray = $formcompany->effectif_array(1); 1526 } 1527 print $staffArray[$obj->staff_code]; 1528 print '</td>'; 1529 if (!$i) { 1530 $totalarray['nbfield']++; 1531 } 1532 } 1533 if (!empty($arrayfields['s.email']['checked'])) { 1534 print '<td class="tdoverflowmax150">'.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 0, 0, 1)."</td>\n"; 1535 if (!$i) { 1536 $totalarray['nbfield']++; 1537 } 1538 } 1539 if (!empty($arrayfields['s.phone']['checked'])) { 1540 print '<td class="nowraponall">'.dol_print_phone($obj->phone, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."</td>\n"; 1541 if (!$i) { 1542 $totalarray['nbfield']++; 1543 } 1544 } 1545 if (!empty($arrayfields['s.fax']['checked'])) { 1546 print '<td class="nowraponall">'.dol_print_phone($obj->fax, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'fax')."</td>\n"; 1547 if (!$i) { 1548 $totalarray['nbfield']++; 1549 } 1550 } 1551 if (!empty($arrayfields['s.url']['checked'])) { 1552 print "<td>".dol_print_url($obj->url, '', '', 1)."</td>\n"; 1553 if (!$i) { 1554 $totalarray['nbfield']++; 1555 } 1556 } 1557 if (!empty($arrayfields['s.siren']['checked'])) { 1558 print "<td>".$obj->idprof1."</td>\n"; 1559 if (!$i) { 1560 $totalarray['nbfield']++; 1561 } 1562 } 1563 if (!empty($arrayfields['s.siret']['checked'])) { 1564 print "<td>".$obj->idprof2."</td>\n"; 1565 if (!$i) { 1566 $totalarray['nbfield']++; 1567 } 1568 } 1569 if (!empty($arrayfields['s.ape']['checked'])) { 1570 print "<td>".$obj->idprof3."</td>\n"; 1571 if (!$i) { 1572 $totalarray['nbfield']++; 1573 } 1574 } 1575 if (!empty($arrayfields['s.idprof4']['checked'])) { 1576 print "<td>".$obj->idprof4."</td>\n"; 1577 if (!$i) { 1578 $totalarray['nbfield']++; 1579 } 1580 } 1581 if (!empty($arrayfields['s.idprof5']['checked'])) { 1582 print "<td>".$obj->idprof5."</td>\n"; 1583 if (!$i) { 1584 $totalarray['nbfield']++; 1585 } 1586 } 1587 if (!empty($arrayfields['s.idprof6']['checked'])) { 1588 print "<td>".$obj->idprof6."</td>\n"; 1589 if (!$i) { 1590 $totalarray['nbfield']++; 1591 } 1592 } 1593 // VAT 1594 if (!empty($arrayfields['s.tva_intra']['checked'])) { 1595 print "<td>"; 1596 print $obj->tva_intra; 1597 if ($obj->tva_intra && !isValidVATID($companystatic)) { 1598 print img_warning("BadVATNumber", '', ''); 1599 } 1600 print "</td>\n"; 1601 if (!$i) { 1602 $totalarray['nbfield']++; 1603 } 1604 } 1605 // Type 1606 if (!empty($arrayfields['customerorsupplier']['checked'])) { 1607 print '<td class="center">'; 1608 print $companystatic->getTypeUrl(1); 1609 print '</td>'; 1610 if (!$i) { 1611 $totalarray['nbfield']++; 1612 } 1613 } 1614 1615 if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) { 1616 // Prospect level 1617 print '<td class="center">'; 1618 print $companystatic->getLibProspLevel(); 1619 print "</td>"; 1620 if (!$i) { 1621 $totalarray['nbfield']++; 1622 } 1623 } 1624 1625 if (!empty($arrayfields['s.fk_stcomm']['checked'])) { 1626 // Prospect status 1627 print '<td class="center nowrap"><div class="nowrap">'; 1628 print '<div class="inline-block">'.$companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); 1629 print '</div> - <div class="inline-block">'; 1630 foreach ($prospectstatic->cacheprospectstatus as $key => $val) { 1631 $titlealt = 'default'; 1632 if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { 1633 $titlealt = $val['label']; 1634 } 1635 if ($obj->stcomm_id != $val['id']) { 1636 print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommsocid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm&token='.newToken().$param.($page ? '&page='.urlencode($page) : '').'">'.img_action($titlealt, $val['code'], $val['picto']).'</a>'; 1637 } 1638 } 1639 print '</div></div></td>'; 1640 if (!$i) { 1641 $totalarray['nbfield']++; 1642 } 1643 } 1644 // Parent company 1645 if (!empty($arrayfields['s2.nom']['checked'])) { 1646 print '<td class="center tdoverflowmax100">'; 1647 if ($companystatic->fk_parent > 0) { 1648 $companyparent->fetch($companystatic->fk_parent); 1649 print $companyparent->getNomUrl(1); 1650 } 1651 print "</td>"; 1652 if (!$i) { 1653 $totalarray['nbfield']++; 1654 } 1655 } 1656 // Extra fields 1657 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; 1658 // Fields from hook 1659 $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); 1660 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook 1661 print $hookmanager->resPrint; 1662 // Date creation 1663 if (!empty($arrayfields['s.datec']['checked'])) { 1664 print '<td class="center nowrap">'; 1665 print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); 1666 print '</td>'; 1667 if (!$i) { 1668 $totalarray['nbfield']++; 1669 } 1670 } 1671 // Date modification 1672 if (!empty($arrayfields['s.tms']['checked'])) { 1673 print '<td class="center nowrap">'; 1674 print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); 1675 print '</td>'; 1676 if (!$i) { 1677 $totalarray['nbfield']++; 1678 } 1679 } 1680 // Status 1681 if (!empty($arrayfields['s.status']['checked'])) { 1682 print '<td class="center nowrap">'.$companystatic->getLibStatut(5).'</td>'; 1683 if (!$i) { 1684 $totalarray['nbfield']++; 1685 } 1686 } 1687 if (!empty($arrayfields['s.import_key']['checked'])) { 1688 print '<td class="tdoverflowmax100">'; 1689 print $obj->import_key; 1690 print "</td>\n"; 1691 if (!$i) { 1692 $totalarray['nbfield']++; 1693 } 1694 } 1695 1696 // Action column (Show the massaction button only when this page is not opend from the Extended POS) 1697 print '<td class="nowrap center">'; 1698 if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined 1699 $selected = 0; 1700 if (in_array($obj->rowid, $arrayofselected)) { 1701 $selected = 1; 1702 } 1703 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; 1704 } 1705 print '</td>'; 1706 if (!$i) { 1707 $totalarray['nbfield']++; 1708 } 1709 1710 print '</tr>'."\n"; 1711 $i++; 1712} 1713 1714// If no record found 1715if ($num == 0) { 1716 $colspan = 1; 1717 foreach ($arrayfields as $key => $val) { 1718 if (!empty($val['checked'])) { 1719 $colspan++; 1720 } 1721 } 1722 print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; 1723} 1724 1725$db->free($resql); 1726 1727$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); 1728$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook 1729print $hookmanager->resPrint; 1730 1731print "</table>"; 1732print "</div>"; 1733 1734print '</form>'; 1735 1736// End of page 1737llxFooter(); 1738$db->close(); 1739