list.php 72 KB

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