list.php 88 KB

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