list.php 73 KB

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