dolibarr  13.0.2
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 
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 
36 require_once '../main.inc.php';
37 include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
42 require_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 
53 if ($contextpage == 'poslist')
54 {
55  $_GET['optioncss'] = 'print';
56 }
57 
58 // Security check
59 $socid = GETPOST('socid', 'int');
60 if ($user->socid) $socid = $user->socid;
61 $result = restrictedArea($user, 'societe', $socid, '');
62 
63 $search_all = trim(GETPOST('search_all', 'alphanohtml') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
64 $search_cti = preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars
65 
66 $search_id = trim(GETPOST("search_id", "int"));
67 $search_nom = trim(GETPOST("search_nom", 'restricthtml'));
68 $search_alias = trim(GETPOST("search_alias", 'restricthtml'));
69 $search_nom_only = trim(GETPOST("search_nom_only", 'restricthtml'));
70 $search_barcode = trim(GETPOST("search_barcode", 'alpha'));
71 $search_customer_code = trim(GETPOST('search_customer_code', 'alpha'));
72 $search_supplier_code = trim(GETPOST('search_supplier_code', 'alpha'));
73 $search_account_customer_code = trim(GETPOST('search_account_customer_code', 'alpha'));
74 $search_account_supplier_code = trim(GETPOST('search_account_supplier_code', 'alpha'));
75 $search_address = trim(GETPOST('search_address', 'alpha'));
76 $search_town = trim(GETPOST("search_town", 'alpha'));
77 $search_zip = trim(GETPOST("search_zip", 'alpha'));
78 $search_state = trim(GETPOST("search_state", 'alpha'));
79 $search_region = trim(GETPOST("search_region", 'alpha'));
80 $search_email = trim(GETPOST('search_email', 'alpha'));
81 $search_phone = trim(GETPOST('search_phone', 'alpha'));
82 $search_fax = trim(GETPOST('search_fax', 'alpha'));
83 $search_url = trim(GETPOST('search_url', 'alpha'));
84 $search_idprof1 = trim(GETPOST('search_idprof1', 'alpha'));
85 $search_idprof2 = trim(GETPOST('search_idprof2', 'alpha'));
86 $search_idprof3 = trim(GETPOST('search_idprof3', 'alpha'));
87 $search_idprof4 = trim(GETPOST('search_idprof4', 'alpha'));
88 $search_idprof5 = trim(GETPOST('search_idprof5', 'alpha'));
89 $search_idprof6 = trim(GETPOST('search_idprof6', 'alpha'));
90 $search_vat = trim(GETPOST('search_vat', 'alpha'));
91 $search_sale = trim(GETPOST("search_sale", 'int'));
92 $search_categ_cus = trim(GETPOST("search_categ_cus", 'int'));
93 $search_categ_sup = trim(GETPOST("search_categ_sup", 'int'));
94 $search_country = GETPOST("search_country", 'intcomma');
95 $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
96 $search_staff = GETPOST("search_staff", 'int');
97 $search_status = GETPOST("search_status", 'int');
98 $search_type = GETPOST('search_type', 'alpha');
99 $search_level = GETPOST("search_level", "array");
100 $search_stcomm = GETPOST('search_stcomm', 'int');
101 $search_import_key = GETPOST("search_import_key", "alpha");
102 $search_parent_name = GETPOST('search_parent_name', 'alpha');
103 
104 $type = GETPOST('type', 'alpha');
105 $optioncss = GETPOST('optioncss', 'alpha');
106 $mode = GETPOST("mode", 'alpha');
107 $place = GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'; // $place is string id of table for Bar or Restaurant
108 
109 $diroutputmassaction = $conf->societe->dir_output.'/temp/massgeneration/'.$user->id;
110 
111 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
112 $sortfield = GETPOST("sortfield", 'alpha');
113 $sortorder = GETPOST("sortorder", 'alpha');
114 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
115 if (!$sortorder) $sortorder = "ASC";
116 if (!$sortfield) $sortfield = "s.nom";
117 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
118 $offset = $limit * $page;
119 $pageprev = $page - 1;
120 $pagenext = $page + 1;
121 
122 if ($type == 'c') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'customerlist'; if ($search_type == '') $search_type = '1,3'; }
123 if ($type == 'p') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'prospectlist'; if ($search_type == '') $search_type = '2,3'; }
124 if ($type == 't') { if (empty($contextpage) || $contextpage == 'poslist') $contextpage = 'poslist'; if ($search_type == '') $search_type = '1,2,3'; }
125 if ($type == 'f') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'supplierlist'; if ($search_type == '') $search_type = '4'; }
126 
127 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
128 $object = new Societe($db);
129 $hookmanager->initHooks(array('thirdpartylist'));
130 $extrafields = new ExtraFields($db);
131 
132 // fetch optionals attributes and labels
133 $extrafields->fetch_name_optionals_label($object->table_element);
134 
135 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
136 
137 // List of fields to search into when doing a "search in all"
138 $fieldstosearchall = array(
139  's.nom'=>"ThirdPartyName",
140  's.name_alias'=>"AliasNameShort",
141  's.code_client'=>"CustomerCode",
142  's.code_fournisseur'=>"SupplierCode",
143  's.code_compta'=>"CustomerAccountancyCodeShort",
144  's.code_compta_fournisseur'=>"SupplierAccountancyCodeShort",
145  's.zip'=>"Zip",
146  's.town'=>"Town",
147  's.email'=>"EMail",
148  's.url'=>"URL",
149  's.tva_intra'=>"VATIntra",
150  's.siren'=>"ProfId1",
151  's.siret'=>"ProfId2",
152  's.ape'=>"ProfId3",
153  's.phone'=>"Phone",
154  's.fax'=>"Fax",
155 );
156 if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4'] = 'ProfId4';
157 if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5'] = 'ProfId5';
158 if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof6'] = 'ProfId6';
159 if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode'] = 'Gencod';
160 // Personalized search criterias. Example: $conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS = 's.nom=ThirdPartyName;s.name_alias=AliasNameShort;s.code_client=CustomerCode'
161 if (!empty($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall = dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS);
162 
163 
164 // Define list of fields to show into list
165 $checkedcustomercode = (in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist', 'poslist')) ? 1 : 0);
166 $checkedsuppliercode = (in_array($contextpage, array('supplierlist')) ? 1 : 0);
167 $checkedcustomeraccountcode = (in_array($contextpage, array('customerlist')) ? 1 : 0);
168 $checkedsupplieraccountcode = (in_array($contextpage, array('supplierlist')) ? 1 : 0);
169 $checkedtypetiers = 1;
170 $checkedprofid1 = 0;
171 $checkedprofid2 = 0;
172 $checkedprofid3 = 0;
173 $checkedprofid4 = 0;
174 $checkedprofid5 = 0;
175 $checkedprofid6 = 0;
176 //$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0);
177 //$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0);
178 //$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0);
179 $checkprospectlevel = (in_array($contextpage, array('prospectlist')) ? 1 : 0);
180 $checkstcomm = (in_array($contextpage, array('prospectlist')) ? 1 : 0);
181 $arrayfields = array(
182  's.rowid'=>array('label'=>"TechnicalID", 'position'=>1, 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0)),
183  's.nom'=>array('label'=>"ThirdPartyName", 'position'=>2, 'checked'=>1),
184  's.name_alias'=>array('label'=>"AliasNameShort", 'position'=>3, 'checked'=>1),
185  's.barcode'=>array('label'=>"Gencod", 'position'=>5, 'checked'=>1, 'enabled'=>(!empty($conf->barcode->enabled))),
186  's.code_client'=>array('label'=>"CustomerCodeShort", 'position'=>10, 'checked'=>$checkedcustomercode),
187  '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))),
188  's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'position'=>13, 'checked'=>$checkedcustomeraccountcode),
189  '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))),
190  's.address'=>array('label'=>"Address", 'position'=>19, 'checked'=>0),
191  's.town'=>array('label'=>"Town", 'position'=>20, 'checked'=>0),
192  's.zip'=>array('label'=>"Zip", 'position'=>21, 'checked'=>1),
193  'state.nom'=>array('label'=>"State", 'position'=>22, 'checked'=>0),
194  'region.nom'=>array('label'=>"Region", 'position'=>23, 'checked'=>0),
195  'country.code_iso'=>array('label'=>"Country", 'position'=>24, 'checked'=>0),
196  's.email'=>array('label'=>"Email", 'position'=>25, 'checked'=>0),
197  's.url'=>array('label'=>"Url", 'position'=>26, 'checked'=>0),
198  's.phone'=>array('label'=>"Phone", 'position'=>27, 'checked'=>1),
199  's.fax'=>array('label'=>"Fax", 'position'=>28, 'checked'=>0),
200  'typent.code'=>array('label'=>"ThirdPartyType", 'position'=>29, 'checked'=>$checkedtypetiers),
201  'staff.code'=>array('label'=>"Staff", 'position'=>30, 'checked'=>0),
202  's.siren'=>array('label'=>"ProfId1Short", 'position'=>40, 'checked'=>$checkedprofid1),
203  's.siret'=>array('label'=>"ProfId2Short", 'position'=>41, 'checked'=>$checkedprofid2),
204  's.ape'=>array('label'=>"ProfId3Short", 'position'=>42, 'checked'=>$checkedprofid3),
205  's.idprof4'=>array('label'=>"ProfId4Short", 'position'=>43, 'checked'=>$checkedprofid4),
206  's.idprof5'=>array('label'=>"ProfId5Short", 'position'=>44, 'checked'=>$checkedprofid5),
207  's.idprof6'=>array('label'=>"ProfId6Short", 'position'=>45, 'checked'=>$checkedprofid6),
208  's.tva_intra'=>array('label'=>"VATIntraShort", 'position'=>50, 'checked'=>0),
209  'customerorsupplier'=>array('label'=>'NatureOfThirdParty', 'position'=>61, 'checked'=>1),
210  's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'position'=>62, 'checked'=>$checkprospectlevel),
211  's.fk_stcomm'=>array('label'=>"StatusProsp", 'position'=>63, 'checked'=>$checkstcomm),
212  's2.nom'=>array('label'=>'ParentCompany', 'position'=>64, 'checked'=>0),
213  's.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
214  's.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
215  's.status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
216  's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100),
217 );
218 // Extra fields
219 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
220 
221 $object->fields = dol_sort_array($object->fields, 'position');
222 $arrayfields = dol_sort_array($arrayfields, 'position');
223 
224 
225 /*
226  * Actions
227  */
228 
229 if ($action == "change") // Change customer for TakePOS
230 {
231  $idcustomer = GETPOST('idcustomer', 'int');
232 
233  // Check if draft invoice already exists, if not create it
234  $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' AND entity IN (".getEntity('invoice').")";
235  $result = $db->query($sql);
236  $num_lines = $db->num_rows($result);
237  if ($num_lines == 0)
238  {
239  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
240  $invoice = new Facture($db);
241  $constforthirdpartyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
242  $invoice->socid = $conf->global->$constforthirdpartyid;
243  $invoice->date = dol_now();
244  $invoice->module_source = 'takepos';
245  $invoice->pos_source = $_SESSION["takeposterminal"];
246  $placeid = $invoice->create($user);
247  $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid;
248  $db->query($sql);
249  }
250 
251  $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
252  $resql = $db->query($sql);
253  ?>
254  <script>
255  console.log("Reload page invoice.php with place=<?php print $place; ?>");
256  parent.$("#poslines").load("invoice.php?place=<?php print $place; ?>", function() {
257  //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
258  <?php if (!$resql) { ?>
259  alert('Error failed to update customer on draft invoice.');
260  <?php } ?>
261  parent.$.colorbox.close(); /* Close the popup */
262  });
263  </script>
264  <?php
265  exit;
266 }
267 
268 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
269 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
270 
271 $parameters = array();
272 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
273 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
274 
275 if (empty($reshook))
276 {
277  // Selection of new fields
278  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
279 
280  // Did we click on purge search criteria ?
281  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
282  {
283  $search_id = '';
284  $search_nom = '';
285  $search_alias = '';
286  $search_categ_cus = 0;
287  $search_categ_sup = 0;
288  $search_sale = '';
289  $search_barcode = "";
290  $search_customer_code = '';
291  $search_supplier_code = '';
292  $search_account_customer_code = '';
293  $search_account_supplier_code = '';
294  $search_address = '';
295  $search_town = "";
296  $search_zip = "";
297  $search_state = "";
298  $search_country = '';
299  $search_email = '';
300  $search_phone = '';
301  $search_fax = '';
302  $search_url = '';
303  $search_idprof1 = '';
304  $search_idprof2 = '';
305  $search_idprof3 = '';
306  $search_idprof4 = '';
307  $search_idprof5 = '';
308  $search_idprof6 = '';
309  $search_vat = '';
310  $search_type = '';
311  $search_type_thirdparty = '';
312  $search_staff = '';
313  $search_status = -1;
314  $search_stcomm = '';
315  $search_level = '';
316  $search_parent_name = '';
317  $search_import_key = '';
318  $toselect = '';
319  $search_array_options = array();
320  }
321 
322  // Mass actions
323  $objectclass = 'Societe';
324  $objectlabel = 'ThirdParty';
325  $permissiontoread = $user->rights->societe->lire;
326  $permissiontodelete = $user->rights->societe->supprimer;
327  $uploaddir = $conf->societe->dir_output;
328  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
329 
330  if ($action == 'setstcomm')
331  {
332  $object = new Client($db);
333  $result = $object->fetch(GETPOST('stcommsocid'));
334  $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcomm');
335  $result = $object->update($object->id, $user);
336  if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
337 
338  $action = '';
339  }
340 }
341 
342 if ($search_status == '') $search_status = 1; // always display active thirdparty first
343 
344 
345 
346 /*
347  * View
348  */
349 
350 /*
351  REM: Rules on permissions to see thirdparties
352  Internal or External user + No permission to see customers => See nothing
353  Internal user socid=0 + Permission to see ALL customers => See all thirdparties
354  Internal user socid=0 + No permission to see ALL customers => See only thirdparties linked to user that are sale representative
355  External user socid=x + Permission to see ALL customers => Can see only himself
356  External user socid=x + No permission to see ALL customers => Can see only himself
357  */
358 
359 $form = new Form($db);
360 $formother = new FormOther($db);
361 $companystatic = new Societe($db);
362 $companyparent = new Societe($db);
363 $formcompany = new FormCompany($db);
364 $prospectstatic = new Client($db);
365 $prospectstatic->client = 2;
366 $prospectstatic->loadCacheOfProspStatus();
367 
368 
369 $title = $langs->trans("ListOfThirdParties");
370 if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title = $langs->trans("ListOfCustomers");
371 if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) $title = $langs->trans("ListOfProspects");
372 if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) $title = $langs->trans("ListOfSuppliers");
373 
374 // Select every potentiels, and note each potentiels which fit in search parameters
375 $tab_level = array();
376 $sql = "SELECT code, label, sortorder";
377 $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
378 $sql .= " WHERE active > 0";
379 $sql .= " ORDER BY sortorder";
380 $resql = $db->query($sql);
381 if ($resql)
382 {
383  while ($obj = $db->fetch_object($resql))
384  {
385  // Compute level text
386  $level = $langs->trans($obj->code);
387  if ($level == $obj->code) $level = $langs->trans($obj->label);
388  $tab_level[$obj->code] = $level;
389  }
390 } else dol_print_error($db);
391 
392 $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,";
393 $sql .= " s.entity,";
394 $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,";
395 $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,";
396 $sql .= " s.tms as date_update, s.datec as date_creation,";
397 $sql .= " s.code_compta, s.code_compta_fournisseur, s.parent as fk_parent,";
398 $sql .= " s2.nom as name2,";
399 $sql .= " typent.code as typent_code,";
400 $sql .= " staff.code as staff_code,";
401 $sql .= " country.code as country_code, country.label as country_label,";
402 $sql .= " state.code_departement as state_code, state.nom as state_name,";
403 $sql .= " region.code_region as region_code, region.nom as region_name";
404 // We'll need these fields in order to filter by sale (including the case where the user can only see his prospects)
405 if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user";
406 // We'll need these fields in order to filter by categ
407 if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
408 if ($search_categ_sup) $sql .= ", cs.fk_categorie, cs.fk_soc";
409 // Add fields from extrafields
410 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
411  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
412 }
413 // Add fields from hooks
414 $parameters = array();
415 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
416 $sql .= $hookmanager->resPrint;
417 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
418 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s.parent = s2.rowid";
419 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (s.rowid = ef.fk_object)";
420 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
421 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
422 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_effectif)";
423 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
424 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region. code_region = state.fk_region)";
425 // We'll need this table joined to the select in order to filter by categ
426 if (!empty($search_categ_cus)) $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
427 if (!empty($search_categ_sup)) $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
428 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id";
429 // We'll need this table joined to the select in order to filter by sale
430 if ($search_sale == -2) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
431 elseif ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
432 $sql .= " WHERE s.entity IN (".getEntity('societe').")";
433 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
434 if ($search_sale && $search_sale != -2) $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
435 if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
436 if ($search_sale == -2) $sql .= " AND sc.fk_user IS NULL";
437 elseif ($search_sale) $sql .= " AND sc.fk_user = ".$db->escape($search_sale);
438 if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
439 if ($search_categ_sup > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ_sup);
440 if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL";
441 if ($search_categ_sup == -2) $sql .= " AND cs.fk_categorie IS NULL";
442 
443 if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
444 if (strlen($search_cti)) $sql .= natural_search('s.phone', $search_cti);
445 
446 if ($search_id > 0) $sql .= natural_search("s.rowid", $search_id, 1);
447 if ($search_nom) $sql .= natural_search("s.nom", $search_nom);
448 if ($search_alias) $sql .= natural_search("s.name_alias", $search_alias);
449 if ($search_nom_only) $sql .= natural_search("s.nom", $search_nom_only);
450 if ($search_customer_code) $sql .= natural_search("s.code_client", $search_customer_code);
451 if ($search_supplier_code) $sql .= natural_search("s.code_fournisseur", $search_supplier_code);
452 if ($search_account_customer_code) $sql .= natural_search("s.code_compta", $search_account_customer_code);
453 if ($search_account_supplier_code) $sql .= natural_search("s.code_compta_fournisseur", $search_account_supplier_code);
454 if ($search_address) $sql.= natural_search('s.address', $search_address);
455 if ($search_town) $sql .= natural_search("s.town", $search_town);
456 if (strlen($search_zip)) $sql .= natural_search("s.zip", $search_zip);
457 if ($search_state) $sql .= natural_search("state.nom", $search_state);
458 if ($search_region) $sql .= natural_search("region.nom", $search_region);
459 if ($search_country && $search_country != '-1') $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
460 if ($search_email) $sql .= natural_search("s.email", $search_email);
461 if (strlen($search_phone)) $sql .= natural_search("s.phone", $search_phone);
462 if (strlen($search_fax)) $sql .= natural_search("s.fax", $search_fax);
463 if ($search_url) $sql .= natural_search("s.url", $search_url);
464 if (strlen($search_idprof1)) $sql .= natural_search("s.siren", $search_idprof1);
465 if (strlen($search_idprof2)) $sql .= natural_search("s.siret", $search_idprof2);
466 if (strlen($search_idprof3)) $sql .= natural_search("s.ape", $search_idprof3);
467 if (strlen($search_idprof4)) $sql .= natural_search("s.idprof4", $search_idprof4);
468 if (strlen($search_idprof5)) $sql .= natural_search("s.idprof5", $search_idprof5);
469 if (strlen($search_idprof6)) $sql .= natural_search("s.idprof6", $search_idprof6);
470 if (strlen($search_vat)) $sql .= natural_search("s.tva_intra", $search_vat);
471 // Filter on type of thirdparty
472 if ($search_type > 0 && in_array($search_type, array('1,3', '1,2,3', '2,3'))) $sql .= " AND s.client IN (".$db->sanitize($db->escape($search_type)).")";
473 if ($search_type > 0 && in_array($search_type, array('4'))) $sql .= " AND s.fournisseur = 1";
474 if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0";
475 if ($search_status != '' && $search_status >= 0) $sql .= natural_search("s.status", $search_status, 2);
476 if (!empty($conf->barcode->enabled) && $search_barcode) $sql .= natural_search("s.barcode", $search_barcode);
477 if ($search_type_thirdparty && $search_type_thirdparty != '-1') $sql .= natural_search("s.fk_typent", $search_type_thirdparty, 2);
478 if (!empty($search_staff) && $search_staff != '-1') $sql .= natural_search("s.fk_effectif", $search_staff, 2);
479 if ($search_level) $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3);
480 if ($search_parent_name) $sql .= natural_search("s2.nom", $search_parent_name);
481 if ($search_stcomm != '' && $search_stcomm != -2) $sql .= natural_search("s.fk_stcomm", $search_stcomm, 2);
482 if ($search_import_key) $sql .= natural_search("s.import_key", $search_import_key);
483 // Add where from extra fields
484 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
485 // Add where from hooks
486 $parameters = array('socid' => $socid);
487 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
488 if (empty($reshook)) {
489  if ($socid) $sql .= " AND s.rowid = ".$socid;
490 }
491 $sql .= $hookmanager->resPrint;
492 
493 $sql .= $db->order($sortfield, $sortorder);
494 
495 // Count total nb of records
496 $nbtotalofrecords = '';
497 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
498 {
499  $result = $db->query($sql);
500  $nbtotalofrecords = $db->num_rows($result);
501  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
502  {
503  $page = 0;
504  $offset = 0;
505  }
506 }
507 
508 $sql .= $db->plimit($limit + 1, $offset);
509 
510 $resql = $db->query($sql);
511 if (!$resql)
512 {
513  dol_print_error($db);
514  exit;
515 }
516 
517 $num = $db->num_rows($resql);
518 
519 $arrayofselected = is_array($toselect) ? $toselect : array();
520 
521 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list') {
522  $obj = $db->fetch_object($resql);
523  $id = $obj->rowid;
524  if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)) {
525  if ($obj->client > 0) {
526  header("Location: ".DOL_URL_ROOT.'/comm/card.php?socid='.$id);
527  exit;
528  }
529  if ($obj->fournisseur > 0) {
530  header("Location: ".DOL_URL_ROOT.'/fourn/card.php?socid='.$id);
531  exit;
532  }
533  }
534 
535  header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id);
536  exit;
537 }
538 
539 $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
540 llxHeader('', $langs->trans("ThirdParty"), $help_url);
541 
542 $param = '';
543 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
544 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
545 if ($search_all != '') $param = "&sall=".urlencode($search_all);
546 if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus);
547 if ($search_categ_sup > 0) $param .= '&search_categ_sup='.urlencode($search_categ_sup);
548 if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale);
549 if ($search_id > 0) $param .= "&search_id=".urlencode($search_id);
550 if ($search_nom != '') $param .= "&search_nom=".urlencode($search_nom);
551 if ($search_alias != '') $param .= "&search_alias=".urlencode($search_alias);
552 if ($search_address != '') $param .= '&search_address=' . urlencode($search_address);
553 if ($search_town != '') $param .= "&search_town=".urlencode($search_town);
554 if ($search_zip != '') $param .= "&search_zip=".urlencode($search_zip);
555 if ($search_phone != '') $param .= "&search_phone=".urlencode($search_phone);
556 if ($search_fax != '') $param .= "&search_fax=".urlencode($search_fax);
557 if ($search_email != '') $param .= "&search_email=".urlencode($search_email);
558 if ($search_url != '') $param .= "&search_url=".urlencode($search_url);
559 if ($search_state != '') $param .= "&search_state=".urlencode($search_state);
560 if ($search_country != '') $param .= "&search_country=".urlencode($search_country);
561 if ($search_customer_code != '') $param .= "&search_customer_code=".urlencode($search_customer_code);
562 if ($search_supplier_code != '') $param .= "&search_supplier_code=".urlencode($search_supplier_code);
563 if ($search_account_customer_code != '') $param .= "&search_account_customer_code=".urlencode($search_account_customer_code);
564 if ($search_account_supplier_code != '') $param .= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
565 if ($search_barcode != '') $param .= "&search_barcode=".urlencode($search_barcode);
566 if ($search_idprof1 != '') $param .= '&search_idprof1='.urlencode($search_idprof1);
567 if ($search_idprof2 != '') $param .= '&search_idprof2='.urlencode($search_idprof2);
568 if ($search_idprof3 != '') $param .= '&search_idprof3='.urlencode($search_idprof3);
569 if ($search_idprof4 != '') $param .= '&search_idprof4='.urlencode($search_idprof4);
570 if ($search_idprof5 != '') $param .= '&search_idprof5='.urlencode($search_idprof5);
571 if ($search_idprof6 != '') $param .= '&search_idprof6='.urlencode($search_idprof6);
572 if ($search_vat != '') $param .= '&search_vat='.urlencode($search_vat);
573 if ($search_type_thirdparty != '') $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
574 if ($search_type != '') $param .= '&search_type='.urlencode($search_type);
575 if (is_array($search_level) && count($search_level)) foreach ($search_level as $slevel) $param .= '&search_level[]='.urlencode($slevel);
576 if ($search_status != '') $param .= '&search_status='.urlencode($search_status);
577 if ($search_stcomm != '') $param .= '&search_stcomm='.urlencode($search_stcomm);
578 if ($search_parent_name != '') $param .= '&search_parent_name='.urlencode($search_parent_name);
579 if ($search_import_key != '') $param .= '&search_import_key='.urlencode($search_import_key);
580 if ($type != '') $param .= '&type='.urlencode($type);
581 if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
582 // Add $param from extra fields
583 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
584 
585 // Show delete result message
586 if (GETPOST('delsoc'))
587 {
588  setEventMessages($langs->trans("CompanyDeleted", GETPOST('delsoc')), null, 'mesgs');
589 }
590 
591 // List of mass actions available
592 $arrayofmassactions = array(
593  'presend'=>$langs->trans("SendByMail"),
594 // 'builddoc'=>$langs->trans("PDFMerge"),
595 );
596 //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
597 if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
598 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
599 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
600 
601 $typefilter = '';
602 $label = 'MenuNewThirdParty';
603 
604 if (!empty($type))
605 {
606  $typefilter = '&amp;type='.$type;
607  if ($type == 'p') $label = 'MenuNewProspect';
608  if ($type == 'c') $label = 'MenuNewCustomer';
609  if ($type == 'f') $label = 'NewSupplier';
610 }
611 
612 if ($contextpage == 'poslist' && $type == 't' && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) {
613  print get_htmloutput_mesg(img_warning('default').' '.$langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), '', 'warning', 1);
614 }
615 
616 // Show the new button only when this page is not opend from the Extended POS (pop-up window)
617 // but allow it too, when a user has the rights to create a new customer
618 if ($contextpage != 'poslist') {
619  $url = DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter;
620  if (!empty($socid)) $url .= '&socid='.$socid;
621  $newcardbutton = dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->rights->societe->creer);
622 } elseif ($user->rights->societe->creer) {
623  $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);
624  $label = 'MenuNewCustomer';
625  $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url);
626 }
627 
628 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'" name="formfilter" autocomplete="off">';
629 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
630 print '<input type="hidden" name="token" value="'.newToken().'">';
631 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
632 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
633 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
634 //print '<input type="hidden" name="page" value="'.$page.'">';
635 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
636 
637 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'building', 0, $newcardbutton, '', $limit, 0, 0, 1);
638 
639 $langs->load("other");
640 $textprofid = array();
641 foreach (array(1, 2, 3, 4, 5, 6) as $key)
642 {
643  $label = $langs->transnoentities("ProfId".$key.$mysoc->country_code);
644  $textprofid[$key] = '';
645  if ($label != "ProfId".$key.$mysoc->country_code)
646  { // Get only text between ()
647  if (preg_match('/\((.*)\)/i', $label, $reg)) $label = $reg[1];
648  $textprofid[$key] = $langs->trans("ProfIdShortDesc", $key, $mysoc->country_code, $label);
649  }
650 }
651 
652 $topicmail = "Information";
653 $modelmail = "thirdparty";
654 $objecttmp = new Societe($db);
655 $trackid = 'thi'.$object->id;
656 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
657 
658 if ($search_all)
659 {
660  foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
661  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
662 }
663 
664 // Filter on categories
665 $moreforfilter = '';
666 if (empty($type) || $type == 'c' || $type == 'p')
667 {
668  if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire)
669  {
670  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
671  $moreforfilter .= '<div class="divsearchfield">';
672  $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': ';
673  $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort'));
674  $moreforfilter .= '</div>';
675  }
676 }
677 if (empty($type) || $type == 'f')
678 {
679  if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire)
680  {
681  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
682  $moreforfilter .= '<div class="divsearchfield">';
683  $moreforfilter .= $langs->trans('SuppliersCategoriesShort').': ';
684  $moreforfilter .= $formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1);
685  $moreforfilter .= '</div>';
686  }
687 }
688 
689 // If the user can view prospects other than his'
690 if ($user->rights->societe->client->voir || $socid)
691 {
692  $moreforfilter .= '<div class="divsearchfield">';
693  $moreforfilter .= $langs->trans('SalesRepresentatives').': ';
694  $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300', 1);
695  $moreforfilter .= '</div>';
696 }
697 if ($moreforfilter)
698 {
699  print '<div class="liste_titre liste_titre_bydiv centpercent">';
700  print $moreforfilter;
701  $parameters = array('type'=>$type);
702  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
703  print $hookmanager->resPrint;
704  print '</div>';
705 }
706 
707 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
708 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
709 // Show the massaction checkboxes only when this page is not opend from the Extended POS
710 if ($massactionbutton && $contextpage != 'poslist') $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
711 
712 if (empty($arrayfields['customerorsupplier']['checked'])) print '<input type="hidden" name="type" value="'.$type.'">';
713 
714 print '<div class="div-table-responsive">';
715 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
716 
717 // Fields title search
718 print '<tr class="liste_titre_filter">';
719 if (!empty($arrayfields['s.rowid']['checked']))
720 {
721  print '<td class="liste_titre">';
722  print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
723  print '</td>';
724 }
725 if (!empty($arrayfields['s.nom']['checked']))
726 {
727  print '<td class="liste_titre">';
728  if (!empty($search_nom_only) && empty($search_nom)) $search_nom = $search_nom_only;
729  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_nom" value="'.dol_escape_htmltag($search_nom).'">';
730  print '</td>';
731 }
732 if (!empty($arrayfields['s.name_alias']['checked']))
733 {
734  print '<td class="liste_titre">';
735  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_alias" value="'.dol_escape_htmltag($search_alias).'">';
736  print '</td>';
737 }
738 // Barcode
739 if (!empty($arrayfields['s.barcode']['checked']))
740 {
741  print '<td class="liste_titre">';
742  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_barcode" value="'.dol_escape_htmltag($search_barcode).'">';
743  print '</td>';
744 }
745 // Customer code
746 if (!empty($arrayfields['s.code_client']['checked']))
747 {
748  print '<td class="liste_titre">';
749  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).'">';
750  print '</td>';
751 }
752 // Supplier code
753 if (!empty($arrayfields['s.code_fournisseur']['checked']))
754 {
755  print '<td class="liste_titre">';
756  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_supplier_code" value="'.dol_escape_htmltag($search_supplier_code).'">';
757  print '</td>';
758 }
759 // Account Customer code
760 if (!empty($arrayfields['s.code_compta']['checked']))
761 {
762  print '<td class="liste_titre">';
763  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_account_customer_code" value="'.dol_escape_htmltag($search_account_customer_code).'">';
764  print '</td>';
765 }
766 // Account Supplier code
767 if (!empty($arrayfields['s.code_compta_fournisseur']['checked']))
768 {
769  print '<td class="liste_titre">';
770  print '<input class="flat maxwidth75imp" type="text" name="search_account_supplier_code" value="'.dol_escape_htmltag($search_account_supplier_code).'">';
771  print '</td>';
772 }
773 // Address
774 if (!empty($arrayfields['s.address']['checked']))
775 {
776  print '<td class="liste_titre">';
777  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_address" value="'.dol_escape_htmltag($search_address).'">';
778  print '</td>';
779 }
780 // Town
781 if (!empty($arrayfields['s.town']['checked']))
782 {
783  print '<td class="liste_titre">';
784  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
785  print '</td>';
786 }
787 // Zip
788 if (!empty($arrayfields['s.zip']['checked']))
789 {
790  print '<td class="liste_titre">';
791  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
792  print '</td>';
793 }
794 // State
795 if (!empty($arrayfields['state.nom']['checked']))
796 {
797  print '<td class="liste_titre">';
798  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
799  print '</td>';
800 }
801 // Region
802 if (!empty($arrayfields['region.nom']['checked']))
803 {
804  print '<td class="liste_titre">';
805  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_region" value="'.dol_escape_htmltag($search_region).'">';
806  print '</td>';
807 }
808 // Country
809 if (!empty($arrayfields['country.code_iso']['checked']))
810 {
811  print '<td class="liste_titre center">';
812  print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
813  print '</td>';
814 }
815 // Company type
816 if (!empty($arrayfields['typent.code']['checked']))
817 {
818  print '<td class="liste_titre maxwidthonsmartphone center">';
819  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), 'maxwidth75', 1);
820  print '</td>';
821 }
822 // Staff
823 if (!empty($arrayfields['staff.code']['checked']))
824 {
825  print '<td class="liste_titre maxwidthonsmartphone center">';
826  print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100', 1);
827  print '</td>';
828 }
829 if (!empty($arrayfields['s.email']['checked']))
830 {
831  // Email
832  print '<td class="liste_titre">';
833  print '<input class="flat searchemail maxwidth50imp" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
834  print '</td>';
835 }
836 if (!empty($arrayfields['s.phone']['checked']))
837 {
838  // Phone
839  print '<td class="liste_titre">';
840  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'">';
841  print '</td>';
842 }
843 if (!empty($arrayfields['s.fax']['checked']))
844 {
845  // Fax
846  print '<td class="liste_titre">';
847  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_fax" value="'.dol_escape_htmltag($search_fax).'">';
848  print '</td>';
849 }
850 if (!empty($arrayfields['s.url']['checked']))
851 {
852  // Url
853  print '<td class="liste_titre">';
854  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_url" value="'.dol_escape_htmltag($search_url).'">';
855  print '</td>';
856 }
857 if (!empty($arrayfields['s.siren']['checked']))
858 {
859  // IdProf1
860  print '<td class="liste_titre">';
861  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof1" value="'.dol_escape_htmltag($search_idprof1).'">';
862  print '</td>';
863 }
864 if (!empty($arrayfields['s.siret']['checked']))
865 {
866  // IdProf2
867  print '<td class="liste_titre">';
868  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof2" value="'.dol_escape_htmltag($search_idprof2).'">';
869  print '</td>';
870 }
871 if (!empty($arrayfields['s.ape']['checked']))
872 {
873  // IdProf3
874  print '<td class="liste_titre">';
875  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof3" value="'.dol_escape_htmltag($search_idprof3).'">';
876  print '</td>';
877 }
878 if (!empty($arrayfields['s.idprof4']['checked']))
879 {
880  // IdProf4
881  print '<td class="liste_titre">';
882  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof4" value="'.dol_escape_htmltag($search_idprof4).'">';
883  print '</td>';
884 }
885 if (!empty($arrayfields['s.idprof5']['checked']))
886 {
887  // IdProf5
888  print '<td class="liste_titre">';
889  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof5" value="'.dol_escape_htmltag($search_idprof5).'">';
890  print '</td>';
891 }
892 if (!empty($arrayfields['s.idprof6']['checked']))
893 {
894  // IdProf6
895  print '<td class="liste_titre">';
896  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_idprof6" value="'.dol_escape_htmltag($search_idprof6).'">';
897  print '</td>';
898 }
899 if (!empty($arrayfields['s.tva_intra']['checked']))
900 {
901  // Vat number
902  print '<td class="liste_titre">';
903  print '<input class="flat searchstring maxwidth50imp" type="text" name="search_vat" value="'.dol_escape_htmltag($search_vat).'">';
904  print '</td>';
905 }
906 
907 // Type (customer/prospect/supplier)
908 if (!empty($arrayfields['customerorsupplier']['checked']))
909 {
910  print '<td class="liste_titre maxwidthonsmartphone center">';
911  if ($type != '') print '<input type="hidden" name="type" value="'.$type.'">';
912  print $formcompany->selectProspectCustomerType($search_type, 'search_type', 'search_type', 'list');
913  print '</select></td>';
914 }
915 // Prospect level
916 if (!empty($arrayfields['s.fk_prospectlevel']['checked']))
917 {
918  print '<td class="liste_titre center">';
919  print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
920  print '</td>';
921 }
922 // Prospect status
923 if (!empty($arrayfields['s.fk_stcomm']['checked']))
924 {
925  print '<td class="liste_titre maxwidthonsmartphone center">';
926  $arraystcomm = array();
927  foreach ($prospectstatic->cacheprospectstatus as $key => $val)
928  {
929  $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
930  }
931  print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', '', 1);
932  print '</td>';
933 }
934 if (!empty($arrayfields['s2.nom']['checked']))
935 {
936  print '<td class="liste_titre center">';
937  print '<input class="flat searchstring maxwidth75imp" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).'">';
938  print '</td>';
939 }
940 // Extra fields
941 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
942 
943 // Fields from hook
944 $parameters = array('arrayfields'=>$arrayfields);
945 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
946 print $hookmanager->resPrint;
947 // Date creation
948 if (!empty($arrayfields['s.datec']['checked']))
949 {
950  print '<td class="liste_titre">';
951  print '</td>';
952 }
953 // Date modification
954 if (!empty($arrayfields['s.tms']['checked']))
955 {
956  print '<td class="liste_titre">';
957  print '</td>';
958 }
959 // Status
960 if (!empty($arrayfields['s.status']['checked']))
961 {
962  print '<td class="liste_titre center minwidth75imp">';
963  print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1);
964  print '</td>';
965 }
966 if (!empty($arrayfields['s.import_key']['checked']))
967 {
968  print '<td class="liste_titre center">';
969  print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
970  print '</td>';
971 }
972 // Action column
973 print '<td class="liste_titre center">';
974 $searchpicto = $form->showFilterButtons();
975 print $searchpicto;
976 print '</td>';
977 
978 print "</tr>\n";
979 
980 print '<tr class="liste_titre">';
981 if (!empty($arrayfields['s.rowid']['checked'])) print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder);
982 if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
983 if (!empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder);
984 if (!empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode", $param, '', '', $sortfield, $sortorder);
985 if (!empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER["PHP_SELF"], "s.code_client", "", $param, '', $sortfield, $sortorder);
986 if (!empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $param, '', $sortfield, $sortorder);
987 if (!empty($arrayfields['s.code_compta']['checked'])) print_liste_field_titre($arrayfields['s.code_compta']['label'], $_SERVER["PHP_SELF"], "s.code_compta", "", $param, '', $sortfield, $sortorder);
988 if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_compta_fournisseur", "", $param, '', $sortfield, $sortorder);
989 if (!empty($arrayfields['s.address']['checked'])) print_liste_field_titre($arrayfields['s.address']['label'], $_SERVER['PHP_SELF'], 's.address', '', $param, '', $sortfield, $sortorder);
990 if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], "s.town", "", $param, '', $sortfield, $sortorder);
991 if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], "s.zip", "", $param, '', $sortfield, $sortorder);
992 if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
993 if (!empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'], $_SERVER["PHP_SELF"], "region.nom", "", $param, '', $sortfield, $sortorder);
994 if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
995 if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
996 if (!empty($arrayfields['staff.code']['checked'])) print_liste_field_titre($arrayfields['staff.code']['label'], $_SERVER["PHP_SELF"], "staff.code", "", $param, '', $sortfield, $sortorder, 'center ');
997 if (!empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder);
998 if (!empty($arrayfields['s.phone']['checked'])) print_liste_field_titre($arrayfields['s.phone']['label'], $_SERVER["PHP_SELF"], "s.phone", "", $param, '', $sortfield, $sortorder);
999 if (!empty($arrayfields['s.fax']['checked'])) print_liste_field_titre($arrayfields['s.fax']['label'], $_SERVER["PHP_SELF"], "s.fax", "", $param, '', $sortfield, $sortorder);
1000 if (!empty($arrayfields['s.url']['checked'])) print_liste_field_titre($arrayfields['s.url']['label'], $_SERVER["PHP_SELF"], "s.url", "", $param, '', $sortfield, $sortorder);
1001 if (!empty($arrayfields['s.siren']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"), $textprofid[1], 1, 0), $_SERVER["PHP_SELF"], "s.siren", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1002 if (!empty($arrayfields['s.siret']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"), $textprofid[2], 1, 0), $_SERVER["PHP_SELF"], "s.siret", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1003 if (!empty($arrayfields['s.ape']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"), $textprofid[3], 1, 0), $_SERVER["PHP_SELF"], "s.ape", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1004 if (!empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof4", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1005 if (!empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof5", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1006 if (!empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof6", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1007 if (!empty($arrayfields['s.tva_intra']['checked'])) print_liste_field_titre($arrayfields['s.tva_intra']['label'], $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder, 'nowrap ');
1008 if (!empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer
1009 if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "s.fk_prospectlevel", "", $param, '', $sortfield, $sortorder, 'center ');
1010 if (!empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, '', $sortfield, $sortorder, 'center ');
1011 if (!empty($arrayfields['s2.nom']['checked'])) print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER["PHP_SELF"], "s2.nom", "", $param, '', $sortfield, $sortorder, 'center ');
1012 // Extra fields
1013 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
1014 // Hook fields
1015 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
1016 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
1017 print $hookmanager->resPrint;
1018 if (!empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($arrayfields['s.datec']['label'], $_SERVER["PHP_SELF"], "s.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1019 if (!empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($arrayfields['s.tms']['label'], $_SERVER["PHP_SELF"], "s.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
1020 if (!empty($arrayfields['s.status']['checked'])) print_liste_field_titre($arrayfields['s.status']['label'], $_SERVER["PHP_SELF"], "s.status", "", $param, '', $sortfield, $sortorder, 'center ');
1021 if (!empty($arrayfields['s.import_key']['checked'])) print_liste_field_titre($arrayfields['s.import_key']['label'], $_SERVER["PHP_SELF"], "s.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
1022 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
1023 print "</tr>\n";
1024 
1025 
1026 $i = 0;
1027 $totalarray = array();
1028 while ($i < min($num, $limit))
1029 {
1030  $obj = $db->fetch_object($resql);
1031 
1032  $companystatic->id = $obj->rowid;
1033  $companystatic->name = $obj->name;
1034  $companystatic->name_alias = $obj->name_alias;
1035  $companystatic->logo = $obj->logo;
1036  $companystatic->canvas = $obj->canvas;
1037  $companystatic->client = $obj->client;
1038  $companystatic->status = $obj->status;
1039  $companystatic->email = $obj->email;
1040  $companystatic->fournisseur = $obj->fournisseur;
1041  $companystatic->code_client = $obj->code_client;
1042  $companystatic->code_fournisseur = $obj->code_fournisseur;
1043  $companystatic->tva_intra = $obj->tva_intra;
1044  $companystatic->country_code = $obj->country_code;
1045 
1046  $companystatic->code_compta_client = $obj->code_compta;
1047  $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
1048 
1049  $companystatic->fk_prospectlevel = $obj->fk_prospectlevel;
1050  $companystatic->fk_parent = $obj->fk_parent;
1051  $companystatic->entity = $obj->entity;
1052 
1053  print '<tr class="oddeven"';
1054  if ($contextpage == 'poslist')
1055  {
1056  print ' onclick="location.href=\'list.php?action=change&contextpage=poslist&idcustomer='.$obj->rowid.'&place='.urlencode($place).'\'"';
1057  }
1058  print '>';
1059  if (!empty($arrayfields['s.rowid']['checked']))
1060  {
1061  print '<td class="tdoverflowmax50">';
1062  print $obj->rowid;
1063  print "</td>\n";
1064  if (!$i) $totalarray['nbfield']++;
1065  }
1066  if (!empty($arrayfields['s.nom']['checked']))
1067  {
1068  $savalias = $obj->name_alias;
1069  if (!empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias = '';
1070  print '<td'.(empty($conf->global->MAIN_SOCIETE_SHOW_COMPLETE_NAME) ? ' class="tdoverflowmax200"' : '').'>';
1071  if ($contextpage == 'poslist')
1072  {
1073  print $obj->name;
1074  } else {
1075  print $companystatic->getNomUrl(1, '', 100, 0, 1);
1076  }
1077  print "</td>\n";
1078  $companystatic->name_alias = $savalias;
1079  if (!$i) $totalarray['nbfield']++;
1080  }
1081  if (!empty($arrayfields['s.name_alias']['checked']))
1082  {
1083  print '<td class="tdoverflowmax200">';
1084  print $companystatic->name_alias;
1085  print "</td>\n";
1086  if (!$i) $totalarray['nbfield']++;
1087  }
1088  // Barcode
1089  if (!empty($arrayfields['s.barcode']['checked']))
1090  {
1091  print '<td>'.$obj->barcode.'</td>';
1092  if (!$i) $totalarray['nbfield']++;
1093  }
1094  // Customer code
1095  if (!empty($arrayfields['s.code_client']['checked']))
1096  {
1097  print '<td class="nowraponall">'.$obj->code_client.'</td>';
1098  if (!$i) $totalarray['nbfield']++;
1099  }
1100  // Supplier code
1101  if (!empty($arrayfields['s.code_fournisseur']['checked']))
1102  {
1103  print '<td class="nowraponall">'.$obj->code_fournisseur.'</td>';
1104  if (!$i) $totalarray['nbfield']++;
1105  }
1106  // Account customer code
1107  if (!empty($arrayfields['s.code_compta']['checked']))
1108  {
1109  print '<td>'.$obj->code_compta.'</td>';
1110  if (!$i) $totalarray['nbfield']++;
1111  }
1112  // Account supplier code
1113  if (!empty($arrayfields['s.code_compta_fournisseur']['checked']))
1114  {
1115  print '<td>'.$obj->code_compta_fournisseur.'</td>';
1116  if (!$i) $totalarray['nbfield']++;
1117  }
1118  // Address
1119  if (!empty($arrayfields['s.address']['checked']))
1120  {
1121  print '<td>'.$obj->address.'</td>';
1122  if (!$i) $totalarray['nbfield']++;
1123  }
1124  // Town
1125  if (!empty($arrayfields['s.town']['checked']))
1126  {
1127  print "<td>".$obj->town."</td>\n";
1128  if (!$i) $totalarray['nbfield']++;
1129  }
1130  // Zip
1131  if (!empty($arrayfields['s.zip']['checked']))
1132  {
1133  print "<td>".$obj->zip."</td>\n";
1134  if (!$i) $totalarray['nbfield']++;
1135  }
1136  // State
1137  if (!empty($arrayfields['state.nom']['checked']))
1138  {
1139  print "<td>".$obj->state_name."</td>\n";
1140  if (!$i) $totalarray['nbfield']++;
1141  }
1142  // Region
1143  if (!empty($arrayfields['region.nom']['checked']))
1144  {
1145  print "<td>".$obj->region_name."</td>\n";
1146  if (!$i) $totalarray['nbfield']++;
1147  }
1148  // Country
1149  if (!empty($arrayfields['country.code_iso']['checked']))
1150  {
1151  print '<td class="center tdoverflowmax100">';
1152  $labelcountry = ($obj->country_code && ($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code)) ? $langs->trans("Country".$obj->country_code) : $obj->country_label;
1153  print $labelcountry;
1154  print '</td>';
1155  if (!$i) $totalarray['nbfield']++;
1156  }
1157  // Type ent
1158  if (!empty($arrayfields['typent.code']['checked']))
1159  {
1160  print '<td class="center">';
1161  if (!is_array($typenArray) || count($typenArray) == 0) $typenArray = $formcompany->typent_array(1);
1162  print $typenArray[$obj->typent_code];
1163  print '</td>';
1164  if (!$i) $totalarray['nbfield']++;
1165  }
1166  // Staff
1167  if (!empty($arrayfields['staff.code']['checked']))
1168  {
1169  print '<td class="center">';
1170  if (!is_array($staffArray) || count($staffArray) == 0) $staffArray = $formcompany->effectif_array(1);
1171  print $staffArray[$obj->staff_code];
1172  print '</td>';
1173  if (!$i) $totalarray['nbfield']++;
1174  }
1175  if (!empty($arrayfields['s.email']['checked']))
1176  {
1177  print '<td class="tdoverflowmax150">'.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 0, 0, 1)."</td>\n";
1178  if (!$i) $totalarray['nbfield']++;
1179  }
1180  if (!empty($arrayfields['s.phone']['checked']))
1181  {
1182  print "<td>".dol_print_phone($obj->phone, $obj->country_code, 0, $obj->rowid, 'AC_TEL')."</td>\n";
1183  if (!$i) $totalarray['nbfield']++;
1184  }
1185  if (!empty($arrayfields['s.fax']['checked']))
1186  {
1187  print "<td>".dol_print_phone($obj->fax, $obj->country_code, 0, $obj->rowid, 'AC_TEL')."</td>\n";
1188  if (!$i) $totalarray['nbfield']++;
1189  }
1190  if (!empty($arrayfields['s.url']['checked']))
1191  {
1192  print "<td>".$obj->url."</td>\n";
1193  if (!$i) $totalarray['nbfield']++;
1194  }
1195  if (!empty($arrayfields['s.siren']['checked']))
1196  {
1197  print "<td>".$obj->idprof1."</td>\n";
1198  if (!$i) $totalarray['nbfield']++;
1199  }
1200  if (!empty($arrayfields['s.siret']['checked']))
1201  {
1202  print "<td>".$obj->idprof2."</td>\n";
1203  if (!$i) $totalarray['nbfield']++;
1204  }
1205  if (!empty($arrayfields['s.ape']['checked']))
1206  {
1207  print "<td>".$obj->idprof3."</td>\n";
1208  if (!$i) $totalarray['nbfield']++;
1209  }
1210  if (!empty($arrayfields['s.idprof4']['checked']))
1211  {
1212  print "<td>".$obj->idprof4."</td>\n";
1213  if (!$i) $totalarray['nbfield']++;
1214  }
1215  if (!empty($arrayfields['s.idprof5']['checked']))
1216  {
1217  print "<td>".$obj->idprof5."</td>\n";
1218  if (!$i) $totalarray['nbfield']++;
1219  }
1220  if (!empty($arrayfields['s.idprof6']['checked']))
1221  {
1222  print "<td>".$obj->idprof6."</td>\n";
1223  if (!$i) $totalarray['nbfield']++;
1224  }
1225  // VAT
1226  if (!empty($arrayfields['s.tva_intra']['checked']))
1227  {
1228  print "<td>";
1229  print $obj->tva_intra;
1230  if ($obj->tva_intra && !isValidVATID($companystatic))
1231  {
1232  print img_warning("BadVATNumber", '', '');
1233  }
1234  print "</td>\n";
1235  if (!$i) $totalarray['nbfield']++;
1236  }
1237  // Type
1238  if (!empty($arrayfields['customerorsupplier']['checked']))
1239  {
1240  print '<td class="center">';
1241  $s = '';
1242  if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
1243  {
1244  $s .= '<a class="customer-back opacitymedium" title="'.$langs->trans("Prospect").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Prospect"), 0, 1).'</a>';
1245  }
1246  if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
1247  {
1248  $s .= '<a class="customer-back" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Customer"), 0, 1).'</a>';
1249  }
1250  if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur)
1251  {
1252  $s .= '<a class="vendor-back" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$companystatic->id.'">'.dol_substr($langs->trans("Supplier"), 0, 1).'</a>';
1253  }
1254  print $s;
1255  print '</td>';
1256  if (!$i) $totalarray['nbfield']++;
1257  }
1258 
1259  if (!empty($arrayfields['s.fk_prospectlevel']['checked']))
1260  {
1261  // Prospect level
1262  print '<td class="center">';
1263  print $companystatic->getLibProspLevel();
1264  print "</td>";
1265  if (!$i) $totalarray['nbfield']++;
1266  }
1267 
1268  if (!empty($arrayfields['s.fk_stcomm']['checked']))
1269  {
1270  // Prospect status
1271  print '<td class="center nowrap"><div class="nowrap">';
1272  print '<div class="inline-block">'.$companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto);
1273  print '</div> - <div class="inline-block">';
1274  foreach ($prospectstatic->cacheprospectstatus as $key => $val)
1275  {
1276  $titlealt = 'default';
1277  if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label'];
1278  if ($obj->stcomm_id != $val['id']) 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>';
1279  }
1280  print '</div></div></td>';
1281  if (!$i) $totalarray['nbfield']++;
1282  }
1283  // Parent company
1284  if (!empty($arrayfields['s2.nom']['checked']))
1285  {
1286  print '<td class="center tdoverflowmax100">';
1287  if ($companystatic->fk_parent > 0)
1288  {
1289  $companyparent->fetch($companystatic->fk_parent);
1290  print $companyparent->getNomUrl(1);
1291  }
1292  print "</td>";
1293  if (!$i) $totalarray['nbfield']++;
1294  }
1295  // Extra fields
1296  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
1297  // Fields from hook
1298  $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
1299  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
1300  print $hookmanager->resPrint;
1301  // Date creation
1302  if (!empty($arrayfields['s.datec']['checked']))
1303  {
1304  print '<td class="center nowrap">';
1305  print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
1306  print '</td>';
1307  if (!$i) $totalarray['nbfield']++;
1308  }
1309  // Date modification
1310  if (!empty($arrayfields['s.tms']['checked']))
1311  {
1312  print '<td class="center nowrap">';
1313  print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
1314  print '</td>';
1315  if (!$i) $totalarray['nbfield']++;
1316  }
1317  // Status
1318  if (!empty($arrayfields['s.status']['checked']))
1319  {
1320  print '<td class="center nowrap">'.$companystatic->getLibStatut(5).'</td>';
1321  if (!$i) $totalarray['nbfield']++;
1322  }
1323  if (!empty($arrayfields['s.import_key']['checked']))
1324  {
1325  print '<td class="tdoverflowmax100">';
1326  print $obj->import_key;
1327  print "</td>\n";
1328  if (!$i) $totalarray['nbfield']++;
1329  }
1330 
1331  // Action column (Show the massaction button only when this page is not opend from the Extended POS)
1332  print '<td class="nowrap center">';
1333  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
1334  {
1335  $selected = 0;
1336  if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
1337  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1338  }
1339  print '</td>';
1340  if (!$i) $totalarray['nbfield']++;
1341 
1342  print '</tr>'."\n";
1343  $i++;
1344 }
1345 
1346 // If no record found
1347 if ($num == 0)
1348 {
1349  $colspan = 1;
1350  foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
1351  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
1352 }
1353 
1354 $db->free($resql);
1355 
1356 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
1357 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
1358 print $hookmanager->resPrint;
1359 
1360 print "</table>";
1361 print "</div>";
1362 
1363 print '</form>';
1364 
1365 // End of page
1366 llxFooter();
1367 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'] country if(!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'] typent code
Definition: list.php:566
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.
</td >< tdcolspan="3">< spanclass="opacitymedium"></span ></td ></tr >< trclass="liste_total"> CREANCES DETTES< tdcolspan="3"class="right"></td >< tdcolspan="3"class="right"></td ></tr > CREANCES DETTES RECETTES DEPENSES trips CREANCES DETTES Y m expensereport p date_valid Y m expensereport pe datep $db idate($date_start)."' AND $column < p rowid
dol_now($mode= 'auto')
Return date for now.
Class to manage customers or prospects.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to build HTML component for third parties management Only common components are here...
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
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.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
get_htmloutput_mesg($mesgstring= '', $mesgarray= '', $style= 'ok', $keepembedded=0)
Get formated messages to output (Used to show messages on html output).
if(!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'] s nom
Definition: list.php:560
Classe permettant la generation de composants html autre Only common components are here...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
dolExplodeIntoArray($string, $delimiter= ';', $kv= '=')
Split a string with 2 keys into key array.
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...
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print $_SERVER["PHP_SELF"] n
Edit parameters.
Definition: categories.php:101
Class to manage invoices.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.