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