list.php 73 KB

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