list.php 88 KB

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