customers.php 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271
  1. <?php
  2. /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 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 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. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 3 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. */
  26. /**
  27. * \file htdocs/takepos/customers.php
  28. * \ingroup societe
  29. * \brief Page to show list of third parties. TODO Merge with societe/list.php
  30. */
  31. require '../main.inc.php'; // Load $user and permissions
  32. include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
  37. $langs->loadLangs(array("companies", "commercial", "customers", "suppliers", "bills", "compta", "categories", "cashdesk"));
  38. $action=GETPOST('action','alpha');
  39. $massaction=GETPOST('massaction','alpha');
  40. $show_files=GETPOST('show_files','int');
  41. $confirm=GETPOST('confirm','alpha');
  42. $toselect = GETPOST('toselect', 'array');
  43. $idcustomer = GETPOST('idcustomer','int');
  44. $place = GETPOST('place','int');
  45. $_GET['optioncss'] = 'print';
  46. /*
  47. * Actions
  48. */
  49. if ($action=="change") {
  50. $sql="UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where facnumber='(PROV-POS-".$place.")'";
  51. $resql = $db->query($sql);
  52. ?>
  53. <script>
  54. parent.$("#poslines").load("invoice.php?place="+<?php print $place;?>, function() {
  55. parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
  56. parent.$.colorbox.close();
  57. });
  58. </script>
  59. <?php
  60. exit;
  61. }
  62. // Security check
  63. $socid = GETPOST('socid','int');
  64. if ($user->societe_id) $socid=$user->societe_id;
  65. $result = restrictedArea($user,'societe',$socid,'');
  66. $search_all=trim(GETPOST('search_all', 'alphanohtml')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
  67. $search_cti=preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars
  68. $search_id=trim(GETPOST("search_id","int"));
  69. $search_nom=trim(GETPOST("search_nom"));
  70. $search_alias=trim(GETPOST("search_alias"));
  71. $search_nom_only=trim(GETPOST("search_nom_only"));
  72. $search_barcode=trim(GETPOST("search_barcode"));
  73. $search_customer_code=trim(GETPOST('search_customer_code'));
  74. $search_supplier_code=trim(GETPOST('search_supplier_code'));
  75. $search_account_customer_code=trim(GETPOST('search_account_customer_code'));
  76. $search_account_supplier_code=trim(GETPOST('search_account_supplier_code'));
  77. $search_town=trim(GETPOST("search_town"));
  78. $search_zip=trim(GETPOST("search_zip"));
  79. $search_state=trim(GETPOST("search_state"));
  80. $search_region=trim(GETPOST("search_region"));
  81. $search_email=trim(GETPOST('search_email'));
  82. $search_phone=trim(GETPOST('search_phone'));
  83. $search_url=trim(GETPOST('search_url'));
  84. $search_idprof1=trim(GETPOST('search_idprof1'));
  85. $search_idprof2=trim(GETPOST('search_idprof2'));
  86. $search_idprof3=trim(GETPOST('search_idprof3'));
  87. $search_idprof4=trim(GETPOST('search_idprof4'));
  88. $search_idprof5=trim(GETPOST('search_idprof5'));
  89. $search_idprof6=trim(GETPOST('search_idprof6'));
  90. $search_vat=trim(GETPOST('search_vat'));
  91. $search_sale=trim(GETPOST("search_sale",'int'));
  92. $search_categ_cus=trim(GETPOST("search_categ_cus",'int'));
  93. $search_categ_sup=trim(GETPOST("search_categ_sup",'int'));
  94. $search_country=GETPOST("search_country",'intcomma');
  95. $search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
  96. $search_status=GETPOST("search_status",'int');
  97. $search_type=GETPOST('search_type','alpha');
  98. $search_level_from = GETPOST("search_level_from","alpha");
  99. $search_level_to = GETPOST("search_level_to","alpha");
  100. $search_stcomm=GETPOST('search_stcomm','int');
  101. $search_import_key = GETPOST("search_import_key","alpha");
  102. $type=GETPOST('type');
  103. $optioncss=GETPOST('optioncss','alpha');
  104. $mode=GETPOST("mode");
  105. $diroutputmassaction=$conf->societe->dir_output . '/temp/massgeneration/'.$user->id;
  106. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  107. $sortfield=GETPOST("sortfield",'alpha');
  108. $sortorder=GETPOST("sortorder",'alpha');
  109. $page=GETPOST("page",'int');
  110. if (! $sortorder) $sortorder="ASC";
  111. if (! $sortfield) $sortfield="s.nom";
  112. if (empty($page) || $page == -1) { $page = 0; }
  113. $offset = $limit * $page;
  114. $pageprev = $page - 1;
  115. $pagenext = $page + 1;
  116. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  117. $contextpage='thirdpartylist';
  118. /*if ($search_type == '1,3') { $contextpage='customerlist'; $type='c'; }
  119. if ($search_type == '2,3') { $contextpage='prospectlist'; $type='p'; }
  120. if ($search_type == '4') { $contextpage='supplierlist'; $type='f'; }
  121. */
  122. if ($type == 'c') { $contextpage='customerlist'; if ($search_type=='') $search_type='1,3'; }
  123. if ($type == 'p') { $contextpage='prospectlist'; if ($search_type=='') $search_type='2,3'; }
  124. if ($type == 'f') { $contextpage='supplierlist'; if ($search_type=='') $search_type='4'; }
  125. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  126. $hookmanager->initHooks(array($contextpage));
  127. $extrafields = new ExtraFields($db);
  128. // fetch optionals attributes and labels
  129. $extralabels = $extrafields->fetch_name_optionals_label('societe');
  130. $search_array_options=$extrafields->getOptionalsFromPost('societe','','search_');
  131. // List of fields to search into when doing a "search in all"
  132. $fieldstosearchall = array(
  133. 's.nom'=>"ThirdPartyName",
  134. 's.name_alias'=>"AliasNameShort",
  135. 's.code_client'=>"CustomerCode",
  136. 's.code_fournisseur'=>"SupplierCode",
  137. 's.code_compta'=>"CustomerAccountancyCodeShort",
  138. 's.code_compta_fournisseur'=>"SupplierAccountancyCodeShort",
  139. 's.email'=>"EMail",
  140. 's.url'=>"URL",
  141. 's.tva_intra'=>"VATIntra",
  142. 's.siren'=>"ProfId1",
  143. 's.siret'=>"ProfId2",
  144. 's.ape'=>"ProfId3",
  145. );
  146. if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4']='ProfId4';
  147. if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5']='ProfId5';
  148. if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof6']='ProfId6';
  149. if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode']='Gencod';
  150. // Define list of fields to show into list
  151. $checkedcustomercode=(in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist')) ? 1 : 0);
  152. $checkedsuppliercode=(in_array($contextpage, array('supplierlist')) ? 1 : 0);
  153. $checkedcustomeraccountcode=(in_array($contextpage, array('customerlist')) ? 1 : 0);
  154. $checkedsupplieraccountcode=(in_array($contextpage, array('supplierlist')) ? 1 : 0);
  155. $checkedtypetiers=1;
  156. $checkedprofid1=0;
  157. $checkedprofid2=0;
  158. $checkedprofid3=0;
  159. $checkedprofid4=0;
  160. $checkedprofid5=0;
  161. $checkedprofid6=0;
  162. //$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0);
  163. //$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0);
  164. //$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0);
  165. $checkprospectlevel=(in_array($contextpage, array('prospectlist')) ? 1 : 0);
  166. $checkstcomm=(in_array($contextpage, array('prospectlist')) ? 1 : 0);
  167. $arrayfields=array(
  168. 's.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0)),
  169. 's.nom'=>array('label'=>"ThirdPartyName", 'checked'=>1),
  170. 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1),
  171. 's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))),
  172. 's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>$checkedcustomercode),
  173. 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'checked'=>$checkedsuppliercode, 'enabled'=>(! empty($conf->fournisseur->enabled))),
  174. 's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'checked'=>$checkedcustomeraccountcode),
  175. 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(! empty($conf->fournisseur->enabled))),
  176. 's.town'=>array('label'=>"Town", 'checked'=>1),
  177. 's.zip'=>array('label'=>"Zip", 'checked'=>1),
  178. 'state.nom'=>array('label'=>"State", 'checked'=>0),
  179. 'region.nom'=>array('label'=>"Region", 'checked'=>0),
  180. 'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
  181. 's.email'=>array('label'=>"Email", 'checked'=>0),
  182. 's.url'=>array('label'=>"Url", 'checked'=>0),
  183. 's.phone'=>array('label'=>"Phone", 'checked'=>1),
  184. 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
  185. 's.siren'=>array('label'=>"ProfId1Short", 'checked'=>$checkedprofid1),
  186. 's.siret'=>array('label'=>"ProfId2Short", 'checked'=>$checkedprofid2),
  187. 's.ape'=>array('label'=>"ProfId3Short", 'checked'=>$checkedprofid3),
  188. 's.idprof4'=>array('label'=>"ProfId4Short", 'checked'=>$checkedprofid4),
  189. 's.idprof5'=>array('label'=>"ProfId5Short", 'checked'=>$checkedprofid5),
  190. 's.idprof6'=>array('label'=>"ProfId6Short", 'checked'=>$checkedprofid6),
  191. 's.tva_intra'=>array('label'=>"VATIntra", 'checked'=>0),
  192. 'customerorsupplier'=>array('label'=>'Nature', 'checked'=>1),
  193. 's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'checked'=>$checkprospectlevel),
  194. 's.fk_stcomm'=>array('label'=>"StatusProsp", 'checked'=>$checkstcomm),
  195. 's.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
  196. 's.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
  197. 's.status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
  198. 's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100),
  199. );
  200. // Extra fields
  201. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
  202. {
  203. foreach($extrafields->attribute_label as $key => $val)
  204. {
  205. if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
  206. }
  207. }
  208. $object = new Societe($db);
  209. /*
  210. * Actions
  211. */
  212. if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
  213. if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
  214. $parameters=array();
  215. $reshook=$hookmanager->executeHooks('doActions',$parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  216. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  217. if (empty($reshook))
  218. {
  219. // Selection of new fields
  220. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  221. // Did we click on purge search criteria ?
  222. 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
  223. {
  224. $search_id='';
  225. $search_nom='';
  226. $search_alias='';
  227. $search_categ_cus=0;
  228. $search_categ_sup=0;
  229. $search_sale='';
  230. $search_barcode="";
  231. $search_customer_code='';
  232. $search_supplier_code='';
  233. $search_account_customer_code='';
  234. $search_account_supplier_code='';
  235. $search_town="";
  236. $search_zip="";
  237. $search_state="";
  238. $search_country='';
  239. $search_email='';
  240. $search_phone='';
  241. $search_url='';
  242. $search_idprof1='';
  243. $search_idprof2='';
  244. $search_idprof3='';
  245. $search_idprof4='';
  246. $search_idprof5='';
  247. $search_idprof6='';
  248. $search_vat='';
  249. $search_type='';
  250. $search_type_thirdparty='';
  251. $search_status=-1;
  252. $search_stcomm='';
  253. $search_level_from='';
  254. $search_level_to='';
  255. $search_import_key='';
  256. $toselect='';
  257. $search_array_options=array();
  258. }
  259. // Mass actions
  260. $objectclass='Societe';
  261. $objectlabel='ThirdParty';
  262. $permtoread = $user->rights->societe->lire;
  263. $permtodelete = $user->rights->societe->supprimer;
  264. $uploaddir = $conf->societe->dir_output;
  265. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  266. if ($action == 'setstcomm')
  267. {
  268. $object = new Client($db);
  269. $result=$object->fetch(GETPOST('stcommsocid'));
  270. $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm');
  271. $result=$object->update($object->id, $user);
  272. if ($result < 0) setEventMessages($object->error,$object->errors,'errors');
  273. $action='';
  274. }
  275. }
  276. if ($search_status=='') $search_status=1; // always display active thirdparty first
  277. /*
  278. * View
  279. */
  280. /*
  281. REM: Rules on permissions to see thirdparties
  282. Internal or External user + No permission to see customers => See nothing
  283. Internal user socid=0 + Permission to see ALL customers => See all thirdparties
  284. Internal user socid=0 + No permission to see ALL customers => See only thirdparties linked to user that are sale representative
  285. External user socid=x + Permission to see ALL customers => Can see only himself
  286. External user socid=x + No permission to see ALL customers => Can see only himself
  287. */
  288. $form=new Form($db);
  289. $formother=new FormOther($db);
  290. $companystatic=new Societe($db);
  291. $formcompany=new FormCompany($db);
  292. $prospectstatic=new Client($db);
  293. $prospectstatic->client=2;
  294. $prospectstatic->loadCacheOfProspStatus();
  295. $title=$langs->trans("ListOfThirdParties");
  296. if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title=$langs->trans("ListOfCustomers");
  297. if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) $title=$langs->trans("ListOfProspects");
  298. if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) $title=$langs->trans("ListOfSuppliers");
  299. // If both parameters are set, search for everything BETWEEN them
  300. if ($search_level_from != '' && $search_level_to != '')
  301. {
  302. // Ensure that these parameters are numbers
  303. $search_level_from = (int) $search_level_from;
  304. $search_level_to = (int) $search_level_to;
  305. // If from is greater than to, reverse orders
  306. if ($search_level_from > $search_level_to)
  307. {
  308. $tmp = $search_level_to;
  309. $search_level_to = $search_level_from;
  310. $search_level_from = $tmp;
  311. }
  312. // Generate the SQL request
  313. $sortwhere = '(sortorder BETWEEN '.$search_level_from.' AND '.$search_level_to.') AS is_in_range';
  314. }
  315. // If only "from" parameter is set, search for everything GREATER THAN it
  316. else if ($search_level_from != '')
  317. {
  318. // Ensure that this parameter is a number
  319. $search_level_from = (int) $search_level_from;
  320. // Generate the SQL request
  321. $sortwhere = '(sortorder >= '.$search_level_from.') AS is_in_range';
  322. }
  323. // If only "to" parameter is set, search for everything LOWER THAN it
  324. else if ($search_level_to != '')
  325. {
  326. // Ensure that this parameter is a number
  327. $search_level_to = (int) $search_level_to;
  328. // Generate the SQL request
  329. $sortwhere = '(sortorder <= '.$search_level_to.') AS is_in_range';
  330. }
  331. // If no parameters are set, dont search for anything
  332. else
  333. {
  334. $sortwhere = '0 as is_in_range';
  335. }
  336. // Select every potentiels, and note each potentiels which fit in search parameters
  337. dol_syslog('societe/list.php',LOG_DEBUG);
  338. $sql = "SELECT code, label, sortorder, ".$sortwhere;
  339. $sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel";
  340. $sql.= " WHERE active > 0";
  341. $sql.= " ORDER BY sortorder";
  342. $resql = $db->query($sql);
  343. if ($resql)
  344. {
  345. $tab_level = array();
  346. $search_levels = array();
  347. while ($obj = $db->fetch_object($resql))
  348. {
  349. // Compute level text
  350. $level=$langs->trans($obj->code);
  351. if ($level == $obj->code) $level=$langs->trans($obj->label);
  352. // Put it in the array sorted by sortorder
  353. $tab_level[$obj->sortorder] = $level;
  354. // If this potentiel fit in parameters, add its code to the $search_levels array
  355. if ($obj->is_in_range == 1)
  356. {
  357. $search_levels[] = '"'.preg_replace('[^A-Za-z0-9_-]', '', $obj->code).'"';
  358. }
  359. }
  360. // Implode the $search_levels array so that it can be use in a "IN (...)" where clause.
  361. // If no paramters was set, $search_levels will be empty
  362. $search_levels = implode(',', $search_levels);
  363. }
  364. else dol_print_error($db);
  365. $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,";
  366. $sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,";
  367. $sql.= " s.email, s.phone, 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,";
  368. $sql.= " s.tms as date_update, s.datec as date_creation,";
  369. $sql.= " s.code_compta,s.code_compta_fournisseur,";
  370. $sql.= " typent.code as typent_code,";
  371. $sql.= " state.code_departement as state_code, state.nom as state_name,";
  372. $sql.= " region.code_region as region_code, region.nom as region_name";
  373. // We'll need these fields in order to filter by sale (including the case where the user can only see his prospects)
  374. if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user";
  375. // We'll need these fields in order to filter by categ
  376. if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
  377. if ($search_categ_sup) $sql .= ", cs.fk_categorie, cs.fk_soc";
  378. // Add fields from extrafields
  379. foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
  380. // Add fields from hooks
  381. $parameters=array();
  382. $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
  383. $sql.=$hookmanager->resPrint;
  384. $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
  385. if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef on (s.rowid = ef.fk_object)";
  386. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
  387. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
  388. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
  389. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region. code_region = state.fk_region)";
  390. // We'll need this table joined to the select in order to filter by categ
  391. if (! empty($search_categ_cus)) $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
  392. if (! empty($search_categ_sup)) $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
  393. $sql.= " ,".MAIN_DB_PREFIX."c_stcomm as st";
  394. // We'll need this table joined to the select in order to filter by sale
  395. if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
  396. $sql.= " WHERE s.fk_stcomm = st.id";
  397. $sql.= " AND s.entity IN (".getEntity('societe').")";
  398. if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
  399. if ($socid) $sql.= " AND s.rowid = ".$socid;
  400. if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
  401. if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
  402. if ($search_sale) $sql.= " AND sc.fk_user = ".$db->escape($search_sale);
  403. if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
  404. if ($search_categ_sup > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ_sup);
  405. if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL";
  406. if ($search_categ_sup == -2) $sql.= " AND cs.fk_categorie IS NULL";
  407. if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all);
  408. if (strlen($search_cti)) $sql.= natural_search('s.phone', $search_cti);
  409. if ($search_id > 0) $sql.= natural_search("s.rowid",$search_id,1);
  410. if ($search_nom) $sql.= natural_search("s.nom",$search_nom);
  411. if ($search_alias) $sql.= natural_search("s.name_alias",$search_alias);
  412. if ($search_nom_only) $sql.= natural_search("s.nom",$search_nom_only);
  413. if ($search_customer_code) $sql.= natural_search("s.code_client",$search_customer_code);
  414. if ($search_supplier_code) $sql.= natural_search("s.code_fournisseur",$search_supplier_code);
  415. if ($search_account_customer_code) $sql.= natural_search("s.code_compta",$search_account_customer_code);
  416. if ($search_account_supplier_code) $sql.= natural_search("s.code_compta_fournisseur",$search_account_supplier_code);
  417. if ($search_town) $sql.= natural_search("s.town",$search_town);
  418. if (strlen($search_zip)) $sql.= natural_search("s.zip",$search_zip);
  419. if ($search_state) $sql.= natural_search("state.nom",$search_state);
  420. if ($search_region) $sql.= natural_search("region.nom",$search_region);
  421. if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
  422. if ($search_email) $sql.= natural_search("s.email",$search_email);
  423. if (strlen($search_phone)) $sql.= natural_search("s.phone", $search_phone);
  424. if ($search_url) $sql.= natural_search("s.url",$search_url);
  425. if (strlen($search_idprof1)) $sql.= natural_search("s.siren",$search_idprof1);
  426. if (strlen($search_idprof2)) $sql.= natural_search("s.siret",$search_idprof2);
  427. if (strlen($search_idprof3)) $sql.= natural_search("s.ape",$search_idprof3);
  428. if (strlen($search_idprof4)) $sql.= natural_search("s.idprof4",$search_idprof4);
  429. if (strlen($search_idprof5)) $sql.= natural_search("s.idprof5",$search_idprof5);
  430. if (strlen($search_idprof6)) $sql.= natural_search("s.idprof6",$search_idprof6);
  431. if (strlen($search_vat)) $sql.= natural_search("s.tva_intra",$search_vat);
  432. // Filter on type of thirdparty
  433. if ($search_type > 0 && in_array($search_type,array('1,3','2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")";
  434. if ($search_type > 0 && in_array($search_type,array('4'))) $sql .= " AND s.fournisseur = 1";
  435. if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0";
  436. if ($search_status!='' && $search_status >= 0) $sql .= " AND s.status = ".$db->escape($search_status);
  437. if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= natural_search("s.barcode", $search_barcode);
  438. if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
  439. if ($search_levels) $sql .= " AND s.fk_prospectlevel IN (".$search_levels.')';
  440. if ($search_stcomm != '' && $search_stcomm != -2) $sql.= natural_search("s.fk_stcomm",$search_stcomm,2);
  441. if ($search_import_key) $sql.= natural_search("s.import_key",$search_import_key);
  442. // Add where from extra fields
  443. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  444. // Add where from hooks
  445. $parameters=array();
  446. $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
  447. $sql.=$hookmanager->resPrint;
  448. $sql.= $db->order($sortfield,$sortorder);
  449. // Count total nb of records
  450. $nbtotalofrecords = '';
  451. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  452. {
  453. $result = $db->query($sql);
  454. $nbtotalofrecords = $db->num_rows($result);
  455. }
  456. $sql.= $db->plimit($limit+1, $offset);
  457. $resql = $db->query($sql);
  458. if (! $resql)
  459. {
  460. dol_print_error($db);
  461. exit;
  462. }
  463. $num = $db->num_rows($resql);
  464. $arrayofselected=is_array($toselect)?$toselect:array();
  465. if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list')
  466. {
  467. $obj = $db->fetch_object($resql);
  468. $id = $obj->rowid;
  469. header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id);
  470. exit;
  471. }
  472. $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
  473. llxHeader('',$langs->trans("ThirdParty"),$help_url);
  474. $param='';
  475. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
  476. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
  477. if ($search_all != '') $param = "&sall=".urlencode($search_all);
  478. if ($sall != '') $param .= "&sall=".urlencode($sall);
  479. if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus);
  480. if ($search_categ_sup > 0) $param.='&search_categ_sup='.urlencode($search_categ_sup);
  481. if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale);
  482. if ($search_id > 0) $param.= "&search_id=".urlencode($search_id);
  483. if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom);
  484. if ($search_alias != '') $param.= "&search_alias=".urlencode($search_alias);
  485. if ($search_town != '') $param.= "&search_town=".urlencode($search_town);
  486. if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip);
  487. if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone);
  488. if ($search_email != '') $param.= "&search_email=".urlencode($search_email);
  489. if ($search_url != '') $param.= "&search_url=".urlencode($search_url);
  490. if ($search_state != '') $param.= "&search_state=".urlencode($search_state);
  491. if ($search_country != '') $param.= "&search_country=".urlencode($search_country);
  492. if ($search_customer_code != '') $param.= "&search_customer_code=".urlencode($search_customer_code);
  493. if ($search_supplier_code != '') $param.= "&search_supplier_code=".urlencode($search_supplier_code);
  494. if ($search_account_customer_code != '') $param.= "&search_account_customer_code=".urlencode($search_account_customer_code);
  495. if ($search_account_supplier_code != '') $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code);
  496. if ($search_barcode != '') $param.= "&search_barcode=".urlencode($search_barcode);
  497. if ($search_idprof1 != '') $param.= '&search_idprof1='.urlencode($search_idprof1);
  498. if ($search_idprof2 != '') $param.= '&search_idprof2='.urlencode($search_idprof2);
  499. if ($search_idprof3 != '') $param.= '&search_idprof3='.urlencode($search_idprof3);
  500. if ($search_idprof4 != '') $param.= '&search_idprof4='.urlencode($search_idprof4);
  501. if ($search_idprof5 != '') $param.= '&search_idprof5='.urlencode($search_idprof5);
  502. if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6);
  503. if ($search_vat != '') $param.= '&search_vat='.urlencode($search_vat);
  504. if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty);
  505. if ($search_type != '') $param.='&search_type='.urlencode($search_type);
  506. if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
  507. if ($search_status != '') $param.='&search_status='.urlencode($search_status);
  508. if ($search_stcomm != '') $param.='&search_stcomm='.urlencode($search_stcomm);
  509. if ($search_level_from != '') $param.='&search_level_from='.urlencode($search_level_from);
  510. if ($search_level_to != '') $param.='&search_level_to='.urlencode($search_level_to);
  511. if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key);
  512. if ($type != '') $param.='&type='.urlencode($type);
  513. // Add $param from extra fields
  514. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  515. // Show delete result message
  516. if (GETPOST('delsoc'))
  517. {
  518. setEventMessages($langs->trans("CompanyDeleted",GETPOST('delsoc')), null, 'mesgs');
  519. }
  520. // List of mass actions available
  521. $arrayofmassactions = array(
  522. 'presend'=>$langs->trans("SendByMail"),
  523. // 'builddoc'=>$langs->trans("PDFMerge"),
  524. );
  525. //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
  526. if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
  527. if (GETPOST('nomassaction','int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
  528. $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
  529. print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
  530. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  531. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  532. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  533. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  534. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  535. print '<input type="hidden" name="page" value="'.$page.'">';
  536. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit);
  537. $langs->load("other");
  538. $textprofid=array();
  539. foreach(array(1,2,3,4,5,6) as $key)
  540. {
  541. $label=$langs->transnoentities("ProfId".$key.$mysoc->country_code);
  542. $textprofid[$key]='';
  543. if ($label != "ProfId".$key.$mysoc->country_code)
  544. { // Get only text between ()
  545. if (preg_match('/\((.*)\)/i',$label,$reg)) $label=$reg[1];
  546. $textprofid[$key]=$langs->trans("ProfIdShortDesc",$key,$mysoc->country_code,$label);
  547. }
  548. }
  549. $topicmail="Information";
  550. $modelmail="thirdparty";
  551. $objecttmp=new Societe($db);
  552. $trackid='thi'.$object->id;
  553. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  554. if ($search_all)
  555. {
  556. foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
  557. print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall);
  558. }
  559. // Filter on categories
  560. $moreforfilter='';
  561. if (empty($type) || $type == 'c' || $type == 'p')
  562. {
  563. if (! empty($conf->categorie->enabled))
  564. {
  565. require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
  566. $moreforfilter.='<div class="divsearchfield">';
  567. $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': ';
  568. $moreforfilter.=$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('CustomersProspectsCategoriesShort'));
  569. $moreforfilter.='</div>';
  570. }
  571. }
  572. if (empty($type) || $type == 'f')
  573. {
  574. if (! empty($conf->categorie->enabled))
  575. {
  576. require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
  577. $moreforfilter.='<div class="divsearchfield">';
  578. $moreforfilter.=$langs->trans('SuppliersCategoriesShort').': ';
  579. $moreforfilter.=$formother->select_categories('supplier',$search_categ_sup,'search_categ_sup',1);
  580. $moreforfilter.='</div>';
  581. }
  582. }
  583. // If the user can view prospects other than his'
  584. if ($user->rights->societe->client->voir || $socid)
  585. {
  586. $moreforfilter.='<div class="divsearchfield">';
  587. $moreforfilter.=$langs->trans('SalesRepresentatives'). ': ';
  588. $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user, 0, 1, 'maxwidth300');
  589. $moreforfilter.='</div>';
  590. }
  591. if ($moreforfilter)
  592. {
  593. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  594. print $moreforfilter;
  595. $parameters=array('type'=>$type);
  596. $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
  597. print $hookmanager->resPrint;
  598. print '</div>';
  599. }
  600. $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
  601. $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  602. if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
  603. if (empty($arrayfields['customerorsupplier']['checked'])) print '<input type="hidden" name="type" value="'.$type.'">';
  604. print '<div class="div-table-responsive">';
  605. print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
  606. // Fields title search
  607. print '<tr class="liste_titre_filter">';
  608. if (! empty($arrayfields['s.rowid']['checked']))
  609. {
  610. print '<td class="liste_titre">';
  611. print '<input class="flat searchstring" type="text" name="search_id" size="1" value="'.dol_escape_htmltag($search_id).'">';
  612. print '</td>';
  613. }
  614. if (! empty($arrayfields['s.nom']['checked']))
  615. {
  616. print '<td class="liste_titre">';
  617. if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only;
  618. print '<input class="flat searchstring" type="text" name="search_nom" size="8" value="'.dol_escape_htmltag($search_nom).'">';
  619. print '</td>';
  620. }
  621. if (! empty($arrayfields['s.name_alias']['checked']))
  622. {
  623. print '<td class="liste_titre">';
  624. print '<input class="flat searchstring" type="text" name="search_alias" size="8" value="'.dol_escape_htmltag($search_alias).'">';
  625. print '</td>';
  626. }
  627. // Barcode
  628. if (! empty($arrayfields['s.barcode']['checked']))
  629. {
  630. print '<td class="liste_titre">';
  631. print '<input class="flat searchstring" type="text" name="search_barcode" size="6" value="'.dol_escape_htmltag($search_barcode).'">';
  632. print '</td>';
  633. }
  634. // Customer code
  635. if (! empty($arrayfields['s.code_client']['checked']))
  636. {
  637. print '<td class="liste_titre">';
  638. print '<input class="flat searchstring" size="8" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).'">';
  639. print '</td>';
  640. }
  641. // Supplier code
  642. if (! empty($arrayfields['s.code_fournisseur']['checked']))
  643. {
  644. print '<td class="liste_titre">';
  645. print '<input class="flat searchstring" size="8" type="text" name="search_supplier_code" value="'.dol_escape_htmltag($search_supplier_code).'">';
  646. print '</td>';
  647. }
  648. // Account Customer code
  649. if (! empty($arrayfields['s.code_compta']['checked']))
  650. {
  651. print '<td class="liste_titre">';
  652. print '<input class="flat searchstring" size="8" type="text" name="search_account_customer_code" value="'.dol_escape_htmltag($search_account_customer_code).'">';
  653. print '</td>';
  654. }
  655. // Account Supplier code
  656. if (! empty($arrayfields['s.code_compta_fournisseur']['checked']))
  657. {
  658. print '<td class="liste_titre">';
  659. print '<input class="flat" size="8" type="text" name="search_account_supplier_code" value="'.dol_escape_htmltag($search_account_supplier_code).'">';
  660. print '</td>';
  661. }
  662. // Town
  663. if (! empty($arrayfields['s.town']['checked']))
  664. {
  665. print '<td class="liste_titre">';
  666. print '<input class="flat searchstring" size="6" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).'">';
  667. print '</td>';
  668. }
  669. // Zip
  670. if (! empty($arrayfields['s.zip']['checked']))
  671. {
  672. print '<td class="liste_titre">';
  673. print '<input class="flat searchstring" size="4" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).'">';
  674. print '</td>';
  675. }
  676. // State
  677. if (! empty($arrayfields['state.nom']['checked']))
  678. {
  679. print '<td class="liste_titre">';
  680. print '<input class="flat searchstring" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).'">';
  681. print '</td>';
  682. }
  683. // Region
  684. if (! empty($arrayfields['region.nom']['checked']))
  685. {
  686. print '<td class="liste_titre">';
  687. print '<input class="flat searchstring" size="4" type="text" name="search_region" value="'.dol_escape_htmltag($search_region).'">';
  688. print '</td>';
  689. }
  690. // Country
  691. if (! empty($arrayfields['country.code_iso']['checked']))
  692. {
  693. print '<td class="liste_titre" align="center">';
  694. print $form->select_country($search_country,'search_country','',0,'maxwidth100');
  695. print '</td>';
  696. }
  697. // Company type
  698. if (! empty($arrayfields['typent.code']['checked']))
  699. {
  700. print '<td class="liste_titre maxwidthonsmartphone" align="center">';
  701. print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
  702. print '</td>';
  703. }
  704. if (! empty($arrayfields['s.email']['checked']))
  705. {
  706. // Email
  707. print '<td class="liste_titre">';
  708. print '<input class="flat searchemail" size="4" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'">';
  709. print '</td>';
  710. }
  711. if (! empty($arrayfields['s.phone']['checked']))
  712. {
  713. // Phone
  714. print '<td class="liste_titre">';
  715. print '<input class="flat searchstring" size="4" type="text" name="search_phone" value="'.dol_escape_htmltag($search_phone).'">';
  716. print '</td>';
  717. }
  718. if (! empty($arrayfields['s.url']['checked']))
  719. {
  720. // Url
  721. print '<td class="liste_titre">';
  722. print '<input class="flat searchstring" size="4" type="text" name="search_url" value="'.dol_escape_htmltag($search_url).'">';
  723. print '</td>';
  724. }
  725. if (! empty($arrayfields['s.siren']['checked']))
  726. {
  727. // IdProf1
  728. print '<td class="liste_titre">';
  729. print '<input class="flat searchstring" size="4" type="text" name="search_idprof1" value="'.dol_escape_htmltag($search_idprof1).'">';
  730. print '</td>';
  731. }
  732. if (! empty($arrayfields['s.siret']['checked']))
  733. {
  734. // IdProf2
  735. print '<td class="liste_titre">';
  736. print '<input class="flat searchstring" size="4" type="text" name="search_idprof2" value="'.dol_escape_htmltag($search_idprof2).'">';
  737. print '</td>';
  738. }
  739. if (! empty($arrayfields['s.ape']['checked']))
  740. {
  741. // IdProf3
  742. print '<td class="liste_titre">';
  743. print '<input class="flat searchstring" size="4" type="text" name="search_idprof3" value="'.dol_escape_htmltag($search_idprof3).'">';
  744. print '</td>';
  745. }
  746. if (! empty($arrayfields['s.idprof4']['checked']))
  747. {
  748. // IdProf4
  749. print '<td class="liste_titre">';
  750. print '<input class="flat searchstring" size="4" type="text" name="search_idprof4" value="'.dol_escape_htmltag($search_idprof4).'">';
  751. print '</td>';
  752. }
  753. if (! empty($arrayfields['s.idprof5']['checked']))
  754. {
  755. // IdProf5
  756. print '<td class="liste_titre">';
  757. print '<input class="flat searchstring" size="4" type="text" name="search_idprof5" value="'.dol_escape_htmltag($search_idprof5).'">';
  758. print '</td>';
  759. }
  760. if (! empty($arrayfields['s.idprof6']['checked']))
  761. {
  762. // IdProf6
  763. print '<td class="liste_titre">';
  764. print '<input class="flat searchstring" size="4" type="text" name="search_idprof6" value="'.dol_escape_htmltag($search_idprof6).'">';
  765. print '</td>';
  766. }
  767. if (! empty($arrayfields['s.tva_intra']['checked']))
  768. {
  769. // Vat number
  770. print '<td class="liste_titre">';
  771. print '<input class="flat searchstring" size="4" type="text" name="search_vat" value="'.dol_escape_htmltag($search_vat).'">';
  772. print '</td>';
  773. }
  774. // Type (customer/prospect/supplier)
  775. if (! empty($arrayfields['customerorsupplier']['checked']))
  776. {
  777. print '<td class="liste_titre maxwidthonsmartphone" align="middle">';
  778. if ($type != '') print '<input type="hidden" name="type" value="'.$type.'">';
  779. print '<select class="flat" name="search_type">';
  780. print '<option value="-1"'.($search_type==''?' selected':'').'>&nbsp;</option>';
  781. if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1,3"'.($search_type=='1,3'?' selected':'').'>'.$langs->trans('Customer').'</option>';
  782. if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2,3"'.($search_type=='2,3'?' selected':'').'>'.$langs->trans('Prospect').'</option>';
  783. //if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="3"'.($search_type=='3'?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
  784. print '<option value="4"'.($search_type=='4'?' selected':'').'>'.$langs->trans('Supplier').'</option>';
  785. print '<option value="0"'.($search_type=='0'?' selected':'').'>'.$langs->trans('Others').'</option>';
  786. print '</select></td>';
  787. }
  788. if (! empty($arrayfields['s.fk_prospectlevel']['checked']))
  789. {
  790. // Prospect level
  791. print '<td class="liste_titre" align="center">';
  792. $options_from = '<option value="">&nbsp;</option>'; // Generate in $options_from the list of each option sorted
  793. foreach ($tab_level as $tab_level_sortorder => $tab_level_label)
  794. {
  795. $options_from .= '<option value="'.$tab_level_sortorder.'"'.($search_level_from == $tab_level_sortorder ? ' selected':'').'>';
  796. $options_from .= $langs->trans($tab_level_label);
  797. $options_from .= '</option>';
  798. }
  799. array_reverse($tab_level, true); // Reverse the list
  800. $options_to = '<option value="">&nbsp;</option>'; // Generate in $options_to the list of each option sorted in the reversed order
  801. foreach ($tab_level as $tab_level_sortorder => $tab_level_label)
  802. {
  803. $options_to .= '<option value="'.$tab_level_sortorder.'"'.($search_level_to == $tab_level_sortorder ? ' selected':'').'>';
  804. $options_to .= $langs->trans($tab_level_label);
  805. $options_to .= '</option>';
  806. }
  807. // Print these two select
  808. print $langs->trans("From").' <select class="flat" name="search_level_from">'.$options_from.'</select>';
  809. print ' ';
  810. print $langs->trans("to").' <select class="flat" name="search_level_to">'.$options_to.'</select>';
  811. print '</td>';
  812. }
  813. if (! empty($arrayfields['s.fk_stcomm']['checked']))
  814. {
  815. // Prospect status
  816. print '<td class="liste_titre maxwidthonsmartphone" align="center">';
  817. $arraystcomm=array();
  818. foreach($prospectstatic->cacheprospectstatus as $key => $val)
  819. {
  820. $arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
  821. }
  822. print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2);
  823. print '</td>';
  824. }
  825. // Extra fields
  826. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  827. // Fields from hook
  828. $parameters=array('arrayfields'=>$arrayfields);
  829. $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
  830. print $hookmanager->resPrint;
  831. // Date creation
  832. if (! empty($arrayfields['s.datec']['checked']))
  833. {
  834. print '<td class="liste_titre">';
  835. print '</td>';
  836. }
  837. // Date modification
  838. if (! empty($arrayfields['s.tms']['checked']))
  839. {
  840. print '<td class="liste_titre">';
  841. print '</td>';
  842. }
  843. // Status
  844. if (! empty($arrayfields['s.status']['checked']))
  845. {
  846. print '<td class="liste_titre maxwidthonsmartphone center">';
  847. print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $search_status, 1);
  848. print '</td>';
  849. }
  850. if (! empty($arrayfields['s.import_key']['checked']))
  851. {
  852. print '<td class="liste_titre center">';
  853. print '<input class="flat searchstring" type="text" name="search_import_key" size="3" value="'.dol_escape_htmltag($search_import_key).'">';
  854. print '</td>';
  855. }
  856. // Action column
  857. print '<td class="liste_titre" align="right">';
  858. $searchpicto=$form->showFilterButtons();
  859. print $searchpicto;
  860. print '</td>';
  861. print "</tr>\n";
  862. print '<tr class="liste_titre">';
  863. if (! empty($arrayfields['s.rowid']['checked'])) print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder);
  864. if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
  865. if (! empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"],"s.name_alias","",$param,"",$sortfield,$sortorder);
  866. if (! empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder);
  867. if (! empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder);
  868. if (! empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder);
  869. if (! empty($arrayfields['s.code_compta']['checked'])) print_liste_field_titre($arrayfields['s.code_compta']['label'],$_SERVER["PHP_SELF"],"s.code_compta","",$param,'',$sortfield,$sortorder);
  870. if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder);
  871. if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder);
  872. if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder);
  873. if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
  874. if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder);
  875. if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
  876. if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
  877. if (! empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'],$_SERVER["PHP_SELF"],"s.email","",$param,'',$sortfield,$sortorder);
  878. if (! empty($arrayfields['s.phone']['checked'])) print_liste_field_titre($arrayfields['s.phone']['label'],$_SERVER["PHP_SELF"],"s.phone","",$param,'',$sortfield,$sortorder);
  879. if (! empty($arrayfields['s.url']['checked'])) print_liste_field_titre($arrayfields['s.url']['label'],$_SERVER["PHP_SELF"],"s.url","",$param,'',$sortfield,$sortorder);
  880. if (! empty($arrayfields['s.siren']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder);
  881. if (! empty($arrayfields['s.siret']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder);
  882. if (! empty($arrayfields['s.ape']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder);
  883. if (! empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder);
  884. if (! empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder);
  885. if (! empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder);
  886. if (! empty($arrayfields['s.tva_intra']['checked'])) print_liste_field_titre($arrayfields['s.tva_intra']['label'],$_SERVER["PHP_SELF"],"s.tva_intra","",$param,'class="nowrap"',$sortfield,$sortorder);
  887. if (! empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer
  888. if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder);
  889. if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder);
  890. // Extra fields
  891. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  892. // Hook fields
  893. $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
  894. $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
  895. print $hookmanager->resPrint;
  896. if (! empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($arrayfields['s.datec']['label'],$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  897. if (! empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($arrayfields['s.tms']['label'],$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
  898. if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($arrayfields['s.status']['label'],$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder);
  899. if (! empty($arrayfields['s.import_key']['checked'])) print_liste_field_titre($arrayfields['s.import_key']['label'],$_SERVER["PHP_SELF"],"s.import_key","",$param,'align="center"',$sortfield,$sortorder);
  900. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
  901. print "</tr>\n";
  902. $i = 0;
  903. $totalarray=array();
  904. while ($i < min($num, $limit))
  905. {
  906. $obj = $db->fetch_object($resql);
  907. $companystatic->id=$obj->rowid;
  908. $companystatic->name=$obj->name;
  909. $companystatic->name_alias=$obj->name_alias;
  910. $companystatic->logo=$obj->logo;
  911. $companystatic->canvas=$obj->canvas;
  912. $companystatic->client=$obj->client;
  913. $companystatic->status=$obj->status;
  914. $companystatic->email=$obj->email;
  915. $companystatic->fournisseur=$obj->fournisseur;
  916. $companystatic->code_client=$obj->code_client;
  917. $companystatic->code_fournisseur=$obj->code_fournisseur;
  918. $companystatic->code_compta_client=$obj->code_compta;
  919. $companystatic->code_compta_fournisseur=$obj->code_compta_fournisseur;
  920. $companystatic->fk_prospectlevel=$obj->fk_prospectlevel;
  921. print '<tr class="oddeven" onclick="location.href=\'customers.php?action=change&idcustomer='.$obj->rowid.'&place='.$place.'\'">';
  922. if (! empty($arrayfields['s.rowid']['checked']))
  923. {
  924. print '<td class="tdoverflowmax50">';
  925. print $obj->rowid;
  926. print "</td>\n";
  927. if (! $i) $totalarray['nbfield']++;
  928. }
  929. if (! empty($arrayfields['s.nom']['checked']))
  930. {
  931. $savalias = $obj->name_alias;
  932. if (! empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias='';
  933. print '<td class="tdoverflowmax200">';
  934. print $obj->name;
  935. print "</td>\n";
  936. if (! $i) $totalarray['nbfield']++;
  937. }
  938. if (! empty($arrayfields['s.name_alias']['checked']))
  939. {
  940. print '<td class="tdoverflowmax200">';
  941. print $companystatic->name_alias;
  942. print "</td>\n";
  943. if (! $i) $totalarray['nbfield']++;
  944. }
  945. // Barcode
  946. if (! empty($arrayfields['s.barcode']['checked']))
  947. {
  948. print '<td>'.$obj->barcode.'</td>';
  949. if (! $i) $totalarray['nbfield']++;
  950. }
  951. // Customer code
  952. if (! empty($arrayfields['s.code_client']['checked']))
  953. {
  954. print '<td>'.$obj->code_client.'</td>';
  955. if (! $i) $totalarray['nbfield']++;
  956. }
  957. // Supplier code
  958. if (! empty($arrayfields['s.code_fournisseur']['checked']))
  959. {
  960. print '<td>'.$obj->code_fournisseur.'</td>';
  961. if (! $i) $totalarray['nbfield']++;
  962. }
  963. // Account customer code
  964. if (! empty($arrayfields['s.code_compta']['checked']))
  965. {
  966. print '<td>'.$obj->code_compta.'</td>';
  967. if (! $i) $totalarray['nbfield']++;
  968. }
  969. // Account supplier code
  970. if (! empty($arrayfields['s.code_compta_fournisseur']['checked']))
  971. {
  972. print '<td>'.$obj->code_compta_fournisseur.'</td>';
  973. if (! $i) $totalarray['nbfield']++;
  974. }
  975. // Town
  976. if (! empty($arrayfields['s.town']['checked']))
  977. {
  978. print "<td>".$obj->town."</td>\n";
  979. if (! $i) $totalarray['nbfield']++;
  980. }
  981. // Zip
  982. if (! empty($arrayfields['s.zip']['checked']))
  983. {
  984. print "<td>".$obj->zip."</td>\n";
  985. if (! $i) $totalarray['nbfield']++;
  986. }
  987. // State
  988. if (! empty($arrayfields['state.nom']['checked']))
  989. {
  990. print "<td>".$obj->state_name."</td>\n";
  991. if (! $i) $totalarray['nbfield']++;
  992. }
  993. // Region
  994. if (! empty($arrayfields['region.nom']['checked']))
  995. {
  996. print "<td>".$obj->region_name."</td>\n";
  997. if (! $i) $totalarray['nbfield']++;
  998. }
  999. // Country
  1000. if (! empty($arrayfields['country.code_iso']['checked']))
  1001. {
  1002. print '<td align="center">';
  1003. $tmparray=getCountry($obj->fk_pays,'all');
  1004. print $tmparray['label'];
  1005. print '</td>';
  1006. if (! $i) $totalarray['nbfield']++;
  1007. }
  1008. // Type ent
  1009. if (! empty($arrayfields['typent.code']['checked']))
  1010. {
  1011. print '<td align="center">';
  1012. if (! is_array($typenArray) || count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
  1013. print $typenArray[$obj->typent_code];
  1014. print '</td>';
  1015. if (! $i) $totalarray['nbfield']++;
  1016. }
  1017. if (! empty($arrayfields['s.email']['checked']))
  1018. {
  1019. print "<td>".$obj->email."</td>\n";
  1020. if (! $i) $totalarray['nbfield']++;
  1021. }
  1022. if (! empty($arrayfields['s.phone']['checked']))
  1023. {
  1024. print "<td>".$obj->phone."</td>\n";
  1025. if (! $i) $totalarray['nbfield']++;
  1026. }
  1027. if (! empty($arrayfields['s.url']['checked']))
  1028. {
  1029. print "<td>".$obj->url."</td>\n";
  1030. if (! $i) $totalarray['nbfield']++;
  1031. }
  1032. if (! empty($arrayfields['s.siren']['checked']))
  1033. {
  1034. print "<td>".$obj->idprof1."</td>\n";
  1035. if (! $i) $totalarray['nbfield']++;
  1036. }
  1037. if (! empty($arrayfields['s.siret']['checked']))
  1038. {
  1039. print "<td>".$obj->idprof2."</td>\n";
  1040. if (! $i) $totalarray['nbfield']++;
  1041. }
  1042. if (! empty($arrayfields['s.ape']['checked']))
  1043. {
  1044. print "<td>".$obj->idprof3."</td>\n";
  1045. if (! $i) $totalarray['nbfield']++;
  1046. }
  1047. if (! empty($arrayfields['s.idprof4']['checked']))
  1048. {
  1049. print "<td>".$obj->idprof4."</td>\n";
  1050. if (! $i) $totalarray['nbfield']++;
  1051. }
  1052. if (! empty($arrayfields['s.idprof5']['checked']))
  1053. {
  1054. print "<td>".$obj->idprof5."</td>\n";
  1055. if (! $i) $totalarray['nbfield']++;
  1056. }
  1057. if (! empty($arrayfields['s.idprof6']['checked']))
  1058. {
  1059. print "<td>".$obj->idprof6."</td>\n";
  1060. if (! $i) $totalarray['nbfield']++;
  1061. }
  1062. if (! empty($arrayfields['s.tva_intra']['checked']))
  1063. {
  1064. print "<td>".$obj->tva_intra."</td>\n";
  1065. if (! $i) $totalarray['nbfield']++;
  1066. }
  1067. // Type
  1068. if (! empty($arrayfields['customerorsupplier']['checked']))
  1069. {
  1070. print '<td align="center">';
  1071. $s='';
  1072. if (($obj->client==1 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
  1073. {
  1074. $companystatic->name=$langs->trans("Customer");
  1075. $companystatic->name_alias='';
  1076. $s.=$companystatic->getNomUrl(0,'customer',0,1);
  1077. }
  1078. if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
  1079. {
  1080. if ($s) $s.=" / ";
  1081. $companystatic->name=$langs->trans("Prospect");
  1082. $companystatic->name_alias='';
  1083. $s.=$companystatic->getNomUrl(0,'prospect',0,1);
  1084. }
  1085. if (! empty($conf->fournisseur->enabled) && $obj->fournisseur)
  1086. {
  1087. if ($s) $s.=" / ";
  1088. $companystatic->name=$langs->trans("Supplier");
  1089. $companystatic->name_alias='';
  1090. $s.=$companystatic->getNomUrl(0,'supplier',0,1);
  1091. }
  1092. print $s;
  1093. print '</td>';
  1094. if (! $i) $totalarray['nbfield']++;
  1095. }
  1096. if (! empty($arrayfields['s.fk_prospectlevel']['checked']))
  1097. {
  1098. // Prospect level
  1099. print '<td align="center">';
  1100. print $companystatic->getLibProspLevel();
  1101. print "</td>";
  1102. if (! $i) $totalarray['nbfield']++;
  1103. }
  1104. if (! empty($arrayfields['s.fk_stcomm']['checked']))
  1105. {
  1106. // Prospect status
  1107. print '<td align="center" class="nowrap"><div class="nowrap">';
  1108. print '<div class="inline-block">'.$companystatic->LibProspCommStatut($obj->stcomm_id,2,$prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label']);
  1109. print '</div> - <div class="inline-block">';
  1110. foreach($prospectstatic->cacheprospectstatus as $key => $val)
  1111. {
  1112. $titlealt='default';
  1113. if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label'];
  1114. if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommsocid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page?'&page='.urlencode($page):'').'">'.img_action($titlealt,$val['code']).'</a>';
  1115. }
  1116. print '</div></div></td>';
  1117. if (! $i) $totalarray['nbfield']++;
  1118. }
  1119. // Extra fields
  1120. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  1121. // Fields from hook
  1122. $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
  1123. $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
  1124. print $hookmanager->resPrint;
  1125. // Date creation
  1126. if (! empty($arrayfields['s.datec']['checked']))
  1127. {
  1128. print '<td align="center" class="nowrap">';
  1129. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  1130. print '</td>';
  1131. if (! $i) $totalarray['nbfield']++;
  1132. }
  1133. // Date modification
  1134. if (! empty($arrayfields['s.tms']['checked']))
  1135. {
  1136. print '<td align="center" class="nowrap">';
  1137. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  1138. print '</td>';
  1139. if (! $i) $totalarray['nbfield']++;
  1140. }
  1141. // Status
  1142. if (! empty($arrayfields['s.status']['checked']))
  1143. {
  1144. print '<td align="center" class="nowrap">'.$companystatic->getLibStatut(3).'</td>';
  1145. if (! $i) $totalarray['nbfield']++;
  1146. }
  1147. if (! empty($arrayfields['s.import_key']['checked']))
  1148. {
  1149. print '<td class="tdoverflowmax100">';
  1150. print $obj->import_key;
  1151. print "</td>\n";
  1152. if (! $i) $totalarray['nbfield']++;
  1153. }
  1154. // Action column
  1155. print '<td class="nowrap" align="center">';
  1156. if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1157. {
  1158. $selected=0;
  1159. if (in_array($obj->rowid, $arrayofselected)) $selected=1;
  1160. print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
  1161. }
  1162. print '</td>';
  1163. if (! $i) $totalarray['nbfield']++;
  1164. print '</tr>'."\n";
  1165. $i++;
  1166. }
  1167. $db->free($resql);
  1168. $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  1169. $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
  1170. print $hookmanager->resPrint;
  1171. print "</table>";
  1172. print "</div>";
  1173. print '</form>';
  1174. llxFooter();
  1175. $db->close();