list.php 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005 Marc Bariley / Ocebo <marc@ocebo.com>
  5. * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  7. * Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
  8. * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
  9. * Copyright (C) 2019 Juanjo Menent <jmenent@2byte.es>
  10. * Copyright (C) 2020 Tobias Sean <tobias.sekan@startmail.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  24. */
  25. /**
  26. * \file htdocs/projet/list.php
  27. * \ingroup project
  28. * \brief Page to list projects
  29. */
  30. // Load Dolibarr environment
  31. require '../main.inc.php';
  32. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
  38. if (isModEnabled('categorie')) {
  39. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
  40. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  41. }
  42. // Load translation files required by the page
  43. $langs->loadLangs(array('projects', 'companies', 'commercial'));
  44. if (isModEnabled('eventorganization') && $conf->eventorganization->enabled) {
  45. $langs->loadLangs(array('eventorganization'));
  46. }
  47. $action = GETPOST('action', 'aZ09');
  48. $massaction = GETPOST('massaction', 'alpha');
  49. $show_files = GETPOST('show_files', 'int');
  50. $confirm = GETPOST('confirm', 'alpha');
  51. $toselect = GETPOST('toselect', 'array');
  52. $optioncss = GETPOST('optioncss', 'alpha');
  53. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projectlist';
  54. $title = $langs->trans("Projects");
  55. // Security check
  56. $socid = GETPOST('socid', 'int');
  57. //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
  58. if ($socid > 0) {
  59. $soc = new Societe($db);
  60. $soc->fetch($socid);
  61. $title .= ' (<a href="list.php">'.$soc->name.'</a>)';
  62. }
  63. if (!$user->rights->projet->lire) {
  64. accessforbidden();
  65. }
  66. $diroutputmassaction = $conf->project->dir_output.'/temp/massgeneration/'.$user->id;
  67. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  68. $sortfield = GETPOST('sortfield', 'aZ09comma');
  69. $sortorder = GETPOST('sortorder', 'aZ09comma');
  70. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  71. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  72. // If $page is not defined, or '' or -1 or if we click on clear filters
  73. $page = 0;
  74. }
  75. if (!$sortfield) {
  76. $sortfield = "p.ref";
  77. }
  78. if (!$sortorder) {
  79. $sortorder = "ASC";
  80. }
  81. $offset = $limit * $page;
  82. $pageprev = $page - 1;
  83. $pagenext = $page + 1;
  84. $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
  85. $search_ref = GETPOST("search_ref", 'alpha');
  86. $search_label = GETPOST("search_label", 'alpha');
  87. $search_societe = GETPOST("search_societe", 'alpha');
  88. $search_societe_alias = GETPOST("search_societe_alias", 'alpha');
  89. $search_status = GETPOST("search_status", 'int');
  90. $search_opp_status = GETPOST("search_opp_status", 'alpha');
  91. $search_opp_percent = GETPOST("search_opp_percent", 'alpha');
  92. $search_opp_amount = GETPOST("search_opp_amount", 'alpha');
  93. $search_budget_amount = GETPOST("search_budget_amount", 'alpha');
  94. $search_public = GETPOST("search_public", 'int');
  95. $search_project_user = GETPOST('search_project_user', 'int');
  96. $search_project_contact = GETPOST('search_project_contact', 'int');
  97. $search_sale = GETPOST('search_sale', 'int');
  98. $search_usage_opportunity = GETPOST('search_usage_opportunity', 'int');
  99. $search_usage_task = GETPOST('search_usage_task', 'int');
  100. $search_usage_bill_time = GETPOST('search_usage_bill_time', 'int');
  101. $search_usage_event_organization = GETPOST('search_usage_event_organization', 'int');
  102. $search_accept_conference_suggestions = GETPOST('search_accept_conference_suggestions', 'int');
  103. $search_accept_booth_suggestions = GETPOST('search_accept_booth_suggestions', 'int');
  104. $search_price_registration = GETPOST("search_price_registration", 'alpha');
  105. $search_price_booth = GETPOST("search_price_booth", 'alpha');
  106. $search_login = GETPOST('search_login', 'alpha');
  107. $search_import_key = GETPOST('search_import_key', 'alpha');
  108. $searchCategoryCustomerOperator = 0;
  109. if (GETPOSTISSET('formfilteraction')) {
  110. $searchCategoryCustomerOperator = GETPOST('search_category_customer_operator', 'int');
  111. } elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
  112. $searchCategoryCustomerOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
  113. }
  114. $searchCategoryCustomerList = GETPOST('search_category_customer_list', 'array');
  115. $mine = ((GETPOST('mode') == 'mine') ? 1 : 0);
  116. if ($mine) {
  117. $search_project_user = $user->id; $mine = 0;
  118. }
  119. $search_sday = GETPOST('search_sday', 'int');
  120. $search_smonth = GETPOST('search_smonth', 'int');
  121. $search_syear = GETPOST('search_syear', 'int');
  122. $search_eday = GETPOST('search_eday', 'int');
  123. $search_emonth = GETPOST('search_emonth', 'int');
  124. $search_eyear = GETPOST('search_eyear', 'int');
  125. $search_date_start_startmonth = GETPOST('search_date_start_startmonth', 'int');
  126. $search_date_start_startyear = GETPOST('search_date_start_startyear', 'int');
  127. $search_date_start_startday = GETPOST('search_date_start_startday', 'int');
  128. $search_date_start_start = dol_mktime(0, 0, 0, $search_date_start_startmonth, $search_date_start_startday, $search_date_start_startyear); // Use tzserver
  129. $search_date_start_endmonth = GETPOST('search_date_start_endmonth', 'int');
  130. $search_date_start_endyear = GETPOST('search_date_start_endyear', 'int');
  131. $search_date_start_endday = GETPOST('search_date_start_endday', 'int');
  132. $search_date_start_end = dol_mktime(23, 59, 59, $search_date_start_endmonth, $search_date_start_endday, $search_date_start_endyear); // Use tzserver
  133. $search_date_end_startmonth = GETPOST('search_date_end_startmonth', 'int');
  134. $search_date_end_startyear = GETPOST('search_date_end_startyear', 'int');
  135. $search_date_end_startday = GETPOST('search_date_end_startday', 'int');
  136. $search_date_end_start = dol_mktime(0, 0, 0, $search_date_end_startmonth, $search_date_end_startday, $search_date_end_startyear); // Use tzserver
  137. $search_date_end_endmonth = GETPOST('search_date_end_endmonth', 'int');
  138. $search_date_end_endyear = GETPOST('search_date_end_endyear', 'int');
  139. $search_date_end_endday = GETPOST('search_date_end_endday', 'int');
  140. $search_date_end_end = dol_mktime(23, 59, 59, $search_date_end_endmonth, $search_date_end_endday, $search_date_end_endyear); // Use tzserver
  141. if (isModEnabled('categorie')) {
  142. $search_category_array = GETPOST("search_category_".Categorie::TYPE_PROJECT."_list", "array");
  143. }
  144. if ($search_status == '') {
  145. $search_status = -1; // -1 or 1
  146. }
  147. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  148. $object = new Project($db);
  149. $hookmanager->initHooks(array('projectlist'));
  150. $extrafields = new ExtraFields($db);
  151. // fetch optionals attributes and labels
  152. $extrafields->fetch_name_optionals_label($object->table_element);
  153. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  154. // List of fields to search into when doing a "search in all"
  155. $fieldstosearchall = array();
  156. foreach ($object->fields as $key => $val) {
  157. if (empty($val['searchall'])) {
  158. continue;
  159. }
  160. // Don't allow search in private notes for external users when doing "search in all"
  161. if (!empty($user->socid) && $key == "note_private") {
  162. continue;
  163. }
  164. $fieldstosearchall['p.'.$key] = $val['label'];
  165. }
  166. // Add name object fields to "search in all"
  167. $fieldstosearchall['s.nom'] = "ThirdPartyName";
  168. // Definition of array of fields for columns
  169. $arrayfields = array();
  170. foreach ($object->fields as $key => $val) {
  171. // If $val['visible']==0, then we never show the field
  172. if (!empty($val['visible'])) {
  173. $visible = dol_eval($val['visible'], 1, 1, '1');
  174. $arrayfields['p.'.$key] = array(
  175. 'label'=>$val['label'],
  176. 'checked'=>(($visible < 0) ? 0 : 1),
  177. 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
  178. 'position'=>$val['position'],
  179. 'help'=> isset($val['help']) ? $val['help'] : ''
  180. );
  181. }
  182. }
  183. // Extra fields
  184. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  185. // Add non object fields to fields for list
  186. $arrayfields['s.nom'] = array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>21, 'enabled'=>(!isModEnabled('societe') ? 0 : 1));
  187. $arrayfields['s.name_alias'] = array('label'=>"AliasNameShort", 'checked'=>0, 'position'=>22);
  188. $arrayfields['commercial'] = array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0, 'position'=>23);
  189. $arrayfields['c.assigned'] = array('label'=>$langs->trans("AssignedTo"), 'checked'=>1, 'position'=>120);
  190. $arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106);
  191. $arrayfields['u.login'] = array('label'=>"Author", 'checked'=>-1, 'position'=>165);
  192. // Force some fields according to search_usage filter...
  193. if (GETPOST('search_usage_opportunity')) {
  194. //$arrayfields['p.usage_opportunity']['visible'] = 1; // Not require, filter on search_opp_status is enough
  195. //$arrayfields['p.usage_opportunity']['checked'] = 1; // Not require, filter on search_opp_status is enough
  196. }
  197. if (GETPOST('search_usage_event_organization')) {
  198. $arrayfields['p.fk_opp_status']['enabled'] = 0;
  199. $arrayfields['p.opp_amount']['enabled'] = 0;
  200. $arrayfields['p.opp_percent']['enabled'] = 0;
  201. $arrayfields['opp_weighted_amount']['enabled'] = 0;
  202. $arrayfields['p.usage_organize_event']['visible'] = 1;
  203. $arrayfields['p.usage_organize_event']['checked'] = 1;
  204. }
  205. $object->fields = dol_sort_array($object->fields, 'position');
  206. $arrayfields = dol_sort_array($arrayfields, 'position');
  207. /*
  208. * Actions
  209. */
  210. if (GETPOST('cancel', 'alpha')) {
  211. $action = 'list';
  212. $massaction = '';
  213. }
  214. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  215. $massaction = '';
  216. }
  217. $parameters = array('socid'=>$socid);
  218. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  219. if ($reshook < 0) {
  220. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  221. }
  222. if (empty($reshook)) {
  223. // Selection of new fields
  224. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  225. // Purge search criteria
  226. 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
  227. $search_all = '';
  228. $search_ref = "";
  229. $search_label = "";
  230. $search_societe = "";
  231. $search_societe_alias = '';
  232. $search_status = -1;
  233. $search_opp_status = -1;
  234. $search_opp_amount = '';
  235. $search_opp_percent = '';
  236. $search_budget_amount = '';
  237. $search_public = "";
  238. $search_sale = "";
  239. $search_project_user = '';
  240. $search_project_contact = '';
  241. $search_sday = "";
  242. $search_smonth = "";
  243. $search_syear = "";
  244. $search_eday = "";
  245. $search_emonth = "";
  246. $search_eyear = "";
  247. $search_date_start_startmonth = "";
  248. $search_date_start_startyear = "";
  249. $search_date_start_startday = "";
  250. $search_date_start_start = "";
  251. $search_date_start_endmonth = "";
  252. $search_date_start_endyear = "";
  253. $search_date_start_endday = "";
  254. $search_date_start_end = "";
  255. $search_date_end_startmonth = "";
  256. $search_date_end_startyear = "";
  257. $search_date_end_startday = "";
  258. $search_date_end_start = "";
  259. $search_date_end_endmonth = "";
  260. $search_date_end_endyear = "";
  261. $search_date_end_endday = "";
  262. $search_date_end_end = "";
  263. $search_usage_opportunity = '';
  264. $search_usage_task = '';
  265. $search_usage_bill_time = '';
  266. $search_usage_event_organization = '';
  267. $search_accept_conference_suggestions = '';
  268. $search_accept_booth_suggestions = '';
  269. $search_price_registration = '';
  270. $search_price_booth = '';
  271. $search_login = '';
  272. $search_import_key = '';
  273. $toselect = array();
  274. $search_array_options = array();
  275. $search_category_array = array();
  276. }
  277. // Mass actions
  278. $objectclass = 'Project';
  279. $objectlabel = 'Project';
  280. $permissiontoread = $user->rights->projet->lire;
  281. $permissiontodelete = $user->rights->projet->supprimer;
  282. $permissiontoadd = $user->rights->projet->creer;
  283. $uploaddir = $conf->project->dir_output;
  284. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  285. // Close records
  286. if (!$error && $massaction == 'close' && $user->rights->projet->creer) {
  287. $db->begin();
  288. $objecttmp = new $objectclass($db);
  289. $nbok = 0;
  290. foreach ($toselect as $toselectid) {
  291. $result = $objecttmp->fetch($toselectid);
  292. if ($result > 0) {
  293. $userWrite = $object->restrictedProjectArea($user, 'write');
  294. if ($userWrite > 0 && $objecttmp->statut == 1) {
  295. $result = $objecttmp->setClose($user);
  296. if ($result <= 0) {
  297. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  298. $error++;
  299. break;
  300. } else {
  301. $nbok++;
  302. }
  303. } elseif ($userWrite <= 0) {
  304. setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings');
  305. } else {
  306. setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings');
  307. }
  308. } else {
  309. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  310. $error++;
  311. break;
  312. }
  313. }
  314. if (!$error) {
  315. if ($nbok > 1) {
  316. setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
  317. } else {
  318. setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
  319. }
  320. $db->commit();
  321. } else {
  322. $db->rollback();
  323. }
  324. }
  325. }
  326. /*
  327. * View
  328. */
  329. $form = new Form($db);
  330. $formcompany = new FormCompany($db);
  331. $now = dol_now();
  332. $companystatic = new Societe($db);
  333. $taskstatic = new Task($db);
  334. $formother = new FormOther($db);
  335. $formproject = new FormProjets($db);
  336. $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  337. $title = $langs->trans("LeadsOrProjects");
  338. if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  339. $title = $langs->trans("Projects");
  340. }
  341. if (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only
  342. $title = $langs->trans("Leads");
  343. }
  344. $morejs = array();
  345. $morecss = array();
  346. // Get list of project id allowed to user (in a string list separated by comma)
  347. $projectsListId = '';
  348. if (empty($user->rights->projet->all->lire)) {
  349. $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $socid);
  350. }
  351. // Get id of types of contacts for projects (This list never contains a lot of elements)
  352. $listofprojectcontacttype = array();
  353. $listofprojectcontacttypeexternal = array();
  354. $sql = "SELECT ctc.rowid, ctc.code, ctc.source FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
  355. $sql .= " WHERE ctc.element = '".$db->escape($object->element)."'";
  356. $resql = $db->query($sql);
  357. if ($resql) {
  358. while ($obj = $db->fetch_object($resql)) {
  359. if ($obj->source == 'internal') $listofprojectcontacttype[$obj->rowid] = $obj->code;
  360. else $listofprojectcontacttypeexternal[$obj->rowid] = $obj->code;
  361. }
  362. } else {
  363. dol_print_error($db);
  364. }
  365. if (count($listofprojectcontacttype) == 0) {
  366. $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found
  367. }
  368. if (count($listofprojectcontacttypeexternal) == 0) {
  369. $listofprojectcontacttypeexternal[0] = '0'; // To avoid sql syntax error if not found
  370. }
  371. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  372. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  373. $distinct = 'DISTINCT'; // We add distinct until we have added a protection to be sure a contact of a project and task is only once.
  374. $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut as status, p.fk_opp_status, p.public, p.fk_user_creat,";
  375. $sql .= " p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, (p.opp_amount*p.opp_percent/100) as opp_weighted_amount, p.tms as date_update, p.budget_amount,";
  376. $sql .= " p.usage_opportunity, p.usage_task, p.usage_bill_time, p.usage_organize_event,";
  377. $sql .= " p.email_msgid, p.import_key,";
  378. $sql .= " p.accept_conference_suggestions, p.accept_booth_suggestions, p.price_registration, p.price_booth,";
  379. $sql .= " s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.code_client,";
  380. $sql .= " country.code as country_code,";
  381. $sql .= " cls.code as opp_status_code,";
  382. $sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender';
  383. // Add fields from extrafields
  384. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  385. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  386. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  387. }
  388. }
  389. // Add fields from hooks
  390. $parameters = array();
  391. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
  392. $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
  393. $sql = preg_replace('/,\s*$/', '', $sql);
  394. $sqlfields = $sql; // $sql fields to remove for count total
  395. $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as p";
  396. if (!empty($extrafields->attributes[$object->table_element]['label']) &&is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  397. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
  398. }
  399. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
  400. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
  401. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid";
  402. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON p.fk_user_creat = u.rowid';
  403. // We'll need this table joined to the select in order to filter by sale
  404. // No check is done on company permission because readability is managed by public status of project and assignement.
  405. //if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
  406. if ($search_sale > 0) {
  407. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
  408. }
  409. if ($search_project_user > 0) {
  410. $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp";
  411. }
  412. if ($search_project_contact > 0) {
  413. $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp_contact";
  414. }
  415. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
  416. $sql .= $hookmanager->resPrint;
  417. $sql .= " WHERE p.entity IN (".getEntity('project').')';
  418. if (empty($user->rights->projet->all->lire)) {
  419. $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users
  420. }
  421. // No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser
  422. if ($socid > 0) {
  423. $sql .= " AND (p.fk_soc = ".((int) $socid).")"; // This filter if when we use a hard coded filter on company on url (not related to filter for external users)
  424. }
  425. if ($search_ref) {
  426. $sql .= natural_search('p.ref', $search_ref);
  427. }
  428. if ($search_label) {
  429. $sql .= natural_search('p.title', $search_label);
  430. }
  431. if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) {
  432. $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe);
  433. } else {
  434. if ($search_societe) {
  435. $sql .= natural_search('s.nom', $search_societe);
  436. }
  437. if ($search_societe_alias) {
  438. $sql .= natural_search('s.name_alias', $search_societe_alias);
  439. }
  440. }
  441. if ($search_opp_amount) {
  442. $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
  443. }
  444. if ($search_opp_percent) {
  445. $sql .= natural_search('p.opp_percent', $search_opp_percent, 1);
  446. }
  447. $sql .= dolSqlDateFilter('p.dateo', $search_sday, $search_smonth, $search_syear);
  448. $sql .= dolSqlDateFilter('p.datee', $search_eday, $search_emonth, $search_eyear);
  449. if ($search_date_start_start) {
  450. $sql .= " AND p.dateo >= '".$db->idate($search_date_start_start)."'";
  451. }
  452. if ($search_date_start_end) {
  453. $sql .= " AND p.dateo <= '".$db->idate($search_date_start_end)."'";
  454. }
  455. if ($search_date_end_start) {
  456. $sql .= " AND p.datee >= '".$db->idate($search_date_end_start)."'";
  457. }
  458. if ($search_date_end_end) {
  459. $sql .= " AND p.datee <= '".$db->idate($search_date_end_end)."'";
  460. }
  461. if ($search_all) {
  462. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  463. }
  464. if ($search_status >= 0) {
  465. if ($search_status == 99) {
  466. $sql .= " AND p.fk_statut <> 2";
  467. } else {
  468. $sql .= " AND p.fk_statut = ".((int) $search_status);
  469. }
  470. }
  471. if ($search_opp_status) {
  472. if (is_numeric($search_opp_status) && $search_opp_status > 0) {
  473. $sql .= " AND p.fk_opp_status = ".((int) $search_opp_status);
  474. }
  475. if ($search_opp_status == 'all') {
  476. $sql .= " AND (p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1)";
  477. }
  478. if ($search_opp_status == 'openedopp') {
  479. $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1 AND p.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON','LOST'))";
  480. }
  481. if ($search_opp_status == 'notopenedopp') {
  482. $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1 OR p.fk_opp_status IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code = 'WON'))";
  483. }
  484. if ($search_opp_status == 'none') {
  485. $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1)";
  486. }
  487. }
  488. if ($search_public != '') {
  489. $sql .= " AND p.public = ".((int) $search_public);
  490. }
  491. // For external user, no check is done on company permission because readability is managed by public status of project and assignement.
  492. //if ($socid > 0) $sql.= " AND s.rowid = ".((int) $socid);
  493. if ($search_sale > 0) {
  494. $sql .= " AND sc.fk_user = ".((int) $search_sale);
  495. }
  496. // No check is done on company permission because readability is managed by public status of project and assignement.
  497. //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id).") OR (s.rowid IS NULL))";
  498. if ($search_project_user > 0) {
  499. // TODO Replace this with a EXISTS and remove the link to table + DISTINCT
  500. $sql .= " AND ecp.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttype))).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".((int) $search_project_user);
  501. }
  502. if ($search_project_contact > 0) {
  503. // TODO Replace this with a EXISTS and remove the link to table + DISTINCT
  504. $sql .= " AND ecp_contact.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttypeexternal))).") AND ecp_contact.element_id = p.rowid AND ecp_contact.fk_socpeople = ".((int) $search_project_contact);
  505. }
  506. if ($search_opp_amount != '') {
  507. $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
  508. }
  509. if ($search_budget_amount != '') {
  510. $sql .= natural_search('p.budget_amount', $search_budget_amount, 1);
  511. }
  512. if ($search_usage_opportunity != '' && $search_usage_opportunity >= 0) {
  513. $sql .= natural_search('p.usage_opportunity', $search_usage_opportunity, 2);
  514. }
  515. if ($search_usage_task != '' && $search_usage_task >= 0) {
  516. $sql .= natural_search('p.usage_task', $search_usage_task, 2);
  517. }
  518. if ($search_usage_bill_time != '' && $search_usage_bill_time >= 0) {
  519. $sql .= natural_search('p.usage_bill_time', $search_usage_bill_time, 2);
  520. }
  521. if ($search_usage_event_organization != '' && $search_usage_event_organization >= 0) {
  522. $sql .= natural_search('p.usage_organize_event', $search_usage_event_organization, 2);
  523. }
  524. if ($search_accept_conference_suggestions != '' && $search_accept_conference_suggestions >= 0) {
  525. $sql .= natural_search('p.accept_conference_suggestions', $search_accept_conference_suggestions, 2);
  526. }
  527. if ($search_accept_booth_suggestions != '' && $search_accept_booth_suggestions >= 0) {
  528. $sql .= natural_search('p.accept_booth_suggestions', $search_accept_booth_suggestions, 2);
  529. }
  530. if ($search_price_registration != '') {
  531. $sql .= natural_search('p.price_registration', $search_price_registration, 1);
  532. }
  533. if ($search_price_booth != '') {
  534. $sql .= natural_search('p.price_booth', $search_price_booth, 1);
  535. }
  536. if ($search_login) {
  537. $sql .= natural_search(array('u.login', 'u.firstname', 'u.lastname'), $search_login);
  538. }
  539. if ($search_import_key) {
  540. $sql .= natural_search(array('p.import_key'), $search_import_key);
  541. }
  542. // Search for tag/category ($searchCategoryProjectList is an array of ID)
  543. $searchCategoryProjectList = $search_category_array;
  544. $searchCategoryProjectOperator = 0;
  545. if (!empty($searchCategoryProjectList)) {
  546. $searchCategoryProjectSqlList = array();
  547. $listofcategoryid = '';
  548. foreach ($searchCategoryProjectList as $searchCategoryProject) {
  549. if (intval($searchCategoryProject) == -2) {
  550. $searchCategoryProjectSqlList[] = "NOT EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project)";
  551. } elseif (intval($searchCategoryProject) > 0) {
  552. if ($searchCategoryProjectOperator == 0) {
  553. $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie = ".((int) $searchCategoryProject).")";
  554. } else {
  555. $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject);
  556. }
  557. }
  558. }
  559. if ($listofcategoryid) {
  560. $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
  561. }
  562. if ($searchCategoryProjectOperator == 1) {
  563. if (!empty($searchCategoryProjectSqlList)) {
  564. $sql .= " AND (".implode(' OR ', $searchCategoryProjectSqlList).")";
  565. }
  566. } else {
  567. if (!empty($searchCategoryProjectSqlList)) {
  568. $sql .= " AND (".implode(' AND ', $searchCategoryProjectSqlList).")";
  569. }
  570. }
  571. }
  572. $searchCategoryCustomerSqlList = array();
  573. if ($searchCategoryCustomerOperator == 1) {
  574. $existsCategoryCustomerList = array();
  575. foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
  576. if (intval($searchCategoryCustomer) == -2) {
  577. $sqlCategoryCustomerNotExists = " NOT EXISTS (";
  578. $sqlCategoryCustomerNotExists .= " SELECT cat_cus.fk_soc";
  579. $sqlCategoryCustomerNotExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
  580. $sqlCategoryCustomerNotExists .= " WHERE cat_cus.fk_soc = p.fk_soc";
  581. $sqlCategoryCustomerNotExists .= " )";
  582. $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
  583. } elseif (intval($searchCategoryCustomer) > 0) {
  584. $existsCategoryCustomerList[] = $db->escape($searchCategoryCustomer);
  585. }
  586. }
  587. if (!empty($existsCategoryCustomerList)) {
  588. $sqlCategoryCustomerExists = " EXISTS (";
  589. $sqlCategoryCustomerExists .= " SELECT cat_cus.fk_soc";
  590. $sqlCategoryCustomerExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
  591. $sqlCategoryCustomerExists .= " WHERE cat_cus.fk_soc = p.fk_soc";
  592. $sqlCategoryCustomerExists .= " AND cat_cus.fk_categorie IN (".$db->sanitize(implode(',', $existsCategoryCustomerList)).")";
  593. $sqlCategoryCustomerExists .= " )";
  594. $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerExists;
  595. }
  596. if (!empty($searchCategoryCustomerSqlList)) {
  597. $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
  598. }
  599. } else {
  600. foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
  601. if (intval($searchCategoryCustomer) == -2) {
  602. $sqlCategoryCustomerNotExists = " NOT EXISTS (";
  603. $sqlCategoryCustomerNotExists .= " SELECT cat_cus.fk_soc";
  604. $sqlCategoryCustomerNotExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus";
  605. $sqlCategoryCustomerNotExists .= " WHERE cat_cus.fk_soc = p.fk_soc";
  606. $sqlCategoryCustomerNotExists .= " )";
  607. $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
  608. } elseif (intval($searchCategoryCustomer) > 0) {
  609. $searchCategoryCustomerSqlList[] = "p.fk_soc IN (SELECT fk_soc FROM ".$db->prefix()."categorie_societe WHERE fk_categorie = ".((int) $searchCategoryCustomer).")";
  610. }
  611. }
  612. if (!empty($searchCategoryCustomerSqlList)) {
  613. $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
  614. }
  615. }
  616. // Add where from extra fields
  617. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  618. // Add where from hooks
  619. $parameters = array();
  620. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
  621. $sql .= $hookmanager->resPrint;
  622. //print $sql;
  623. // Count total nb of records
  624. $nbtotalofrecords = '';
  625. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  626. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  627. $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
  628. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  629. $resql = $db->query($sqlforcount);
  630. if ($resql) {
  631. $objforcount = $db->fetch_object($resql);
  632. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  633. } else {
  634. dol_print_error($db);
  635. }
  636. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  637. $page = 0;
  638. $offset = 0;
  639. }
  640. $db->free($resql);
  641. }
  642. // Complete request and execute it with limit
  643. $sql .= $db->order($sortfield, $sortorder);
  644. if ($limit) {
  645. $sql .= $db->plimit($limit + 1, $offset);
  646. }
  647. $resql = $db->query($sql);
  648. if (!$resql) {
  649. dol_print_error($db);
  650. exit;
  651. }
  652. $num = $db->num_rows($resql);
  653. // Direct jump if only one record found
  654. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
  655. $obj = $db->fetch_object($resql);
  656. header("Location: ".DOL_URL_ROOT.'/projet/card.php?id='.$obj->id);
  657. exit;
  658. }
  659. // Output page
  660. // --------------------------------------------------------------------
  661. llxHeader('', $title, $help_url);
  662. $arrayofselected = is_array($toselect) ? $toselect : array();
  663. $param = '';
  664. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  665. $param .= '&contextpage='.urlencode($contextpage);
  666. }
  667. if ($limit > 0 && $limit != $conf->liste_limit) {
  668. $param .= '&limit='.urlencode($limit);
  669. }
  670. if ($search_all != '') {
  671. $param .= '&search_all='.urlencode($search_all);
  672. }
  673. if ($search_sday) {
  674. $param .= '&search_sday='.urlencode($search_sday);
  675. }
  676. if ($search_smonth) {
  677. $param .= '&search_smonth='.urlencode($search_smonth);
  678. }
  679. if ($search_syear) {
  680. $param .= '&search_syear='.urlencode($search_syear);
  681. }
  682. if ($search_eday) {
  683. $param .= '&search_eday='.urlencode($search_eday);
  684. }
  685. if ($search_emonth) {
  686. $param .= '&search_emonth='.urlencode($search_emonth);
  687. }
  688. if ($search_eyear) {
  689. $param .= '&search_eyear='.urlencode($search_eyear);
  690. }
  691. if ($search_date_start_startmonth) {
  692. $param .= '&search_date_start_startmonth='.urlencode($search_date_start_startmonth);
  693. }
  694. if ($search_date_start_startyear) {
  695. $param .= '&search_date_start_startyear='.urlencode($search_date_start_startyear);
  696. }
  697. if ($search_date_start_startday) {
  698. $param .= '&search_date_start_startday='.urlencode($search_date_start_startday);
  699. }
  700. if ($search_date_start_start) {
  701. $param .= '&search_date_start_start='.urlencode($search_date_start_start);
  702. }
  703. if ($search_date_start_endmonth) {
  704. $param .= '&search_date_start_endmonth='.urlencode($search_date_start_endmonth);
  705. }
  706. if ($search_date_start_endyear) {
  707. $param .= '&search_date_start_endyear='.urlencode($search_date_start_endyear);
  708. }
  709. if ($search_date_start_endday) {
  710. $param .= '&search_date_start_endday='.urlencode($search_date_start_endday);
  711. }
  712. if ($search_date_start_end) {
  713. $param .= '&search_date_start_end='.urlencode($search_date_start_end);
  714. }
  715. if ($search_date_end_startmonth) {
  716. $param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth);
  717. }
  718. if ($search_date_end_startyear) {
  719. $param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear);
  720. }
  721. if ($search_date_end_startday) {
  722. $param .= '&search_date_end_startday='.urlencode($search_date_end_startday);
  723. }
  724. if ($search_date_end_start) {
  725. $param .= '&search_date_end_start='.urlencode($search_date_end_start);
  726. }
  727. if ($search_date_end_endmonth) {
  728. $param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth);
  729. }
  730. if ($search_date_end_endyear) {
  731. $param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear);
  732. }
  733. if ($search_date_end_endday) {
  734. $param .= '&search_date_end_endday='.urlencode($search_date_end_endday);
  735. }
  736. if ($search_date_end_end) {
  737. $param .= '&search_date_end_end=' . urlencode($search_date_end_end);
  738. }
  739. if ($socid) {
  740. $param .= '&socid='.urlencode($socid);
  741. }
  742. if (!empty($search_categ)) {
  743. $param .= '&search_categ='.urlencode($search_categ);
  744. }
  745. if ($search_ref != '') {
  746. $param .= '&search_ref='.urlencode($search_ref);
  747. }
  748. if ($search_label != '') {
  749. $param .= '&search_label='.urlencode($search_label);
  750. }
  751. if ($search_societe != '') {
  752. $param .= '&search_societe='.urlencode($search_societe);
  753. }
  754. if ($search_societe_alias != '') {
  755. $param .= '&search_societe_alias='.urlencode($search_societe_alias);
  756. }
  757. if ($search_status >= 0) {
  758. $param .= '&search_status='.urlencode($search_status);
  759. }
  760. if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'openedopp', 'notopenedopp', 'none'))) {
  761. $param .= '&search_opp_status='.urlencode($search_opp_status);
  762. }
  763. if ($search_opp_percent != '') {
  764. $param .= '&search_opp_percent='.urlencode($search_opp_percent);
  765. }
  766. if ($search_public != '') {
  767. $param .= '&search_public='.urlencode($search_public);
  768. }
  769. if ($search_project_user > 0) {
  770. $param .= '&search_project_user='.urlencode($search_project_user);
  771. }
  772. if ($search_project_contact != '') {
  773. $param .= '&search_project_contact='.urlencode($search_project_contact);
  774. }
  775. if ($search_sale > 0) {
  776. $param .= '&search_sale='.urlencode($search_sale);
  777. }
  778. if ($search_opp_amount != '') {
  779. $param .= '&search_opp_amount='.urlencode($search_opp_amount);
  780. }
  781. if ($search_budget_amount != '') {
  782. $param .= '&search_budget_amount='.urlencode($search_budget_amount);
  783. }
  784. if ($search_usage_task != '') {
  785. $param .= '&search_usage_task='.urlencode($search_usage_task);
  786. }
  787. if ($search_usage_bill_time != '') {
  788. $param .= '&search_usage_opportunity='.urlencode($search_usage_bill_time);
  789. }
  790. if ($search_usage_event_organization != '') {
  791. $param .= '&search_usage_event_organization='.urlencode($search_usage_event_organization);
  792. }
  793. if ($search_accept_conference_suggestions != '') {
  794. $param .= '&search_accept_conference_suggestions='.urlencode($search_accept_conference_suggestions);
  795. }
  796. if ($search_accept_booth_suggestions != '') {
  797. $param .= '&search_accept_booth_suggestions='.urlencode($search_accept_booth_suggestions);
  798. }
  799. if ($search_price_registration != '') {
  800. $param .= '&search_price_registration='.urlencode($search_price_registration);
  801. }
  802. if ($search_price_booth != '') {
  803. $param .= '&search_price_booth='.urlencode($search_price_booth);
  804. }
  805. if ($search_login) {
  806. $param .= '&search_login='.urlencode($search_login);
  807. }
  808. if ($search_import_key) {
  809. $param .= '&search_import_key='.urlencode($search_import_key);
  810. }
  811. if ($optioncss != '') {
  812. $param .= '&optioncss='.urlencode($optioncss);
  813. }
  814. foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
  815. $param .= "&search_category_customer_list[]=".urlencode($searchCategoryCustomer);
  816. }
  817. // Add $param from extra fields
  818. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  819. // List of mass actions available
  820. $arrayofmassactions = array(
  821. 'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
  822. 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  823. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  824. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  825. );
  826. //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
  827. if ($user->rights->projet->creer) {
  828. $arrayofmassactions['close'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Close");
  829. $arrayofmassactions['preaffectuser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("AffectUser");
  830. }
  831. if ($user->rights->projet->supprimer) {
  832. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  833. }
  834. if (isModEnabled('category') && $user->rights->projet->creer) {
  835. $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
  836. }
  837. if (in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preaffectuser'))) {
  838. $arrayofmassactions = array();
  839. }
  840. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  841. $url = DOL_URL_ROOT.'/projet/card.php?action=create';
  842. if (!empty($socid)) {
  843. $url .= '&socid='.$socid;
  844. }
  845. if ($search_usage_event_organization == 1) {
  846. $url .= '&usage_organize_event=1';
  847. }
  848. $newcardbutton = dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->rights->projet->creer);
  849. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  850. if ($optioncss != '') {
  851. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  852. }
  853. print '<input type="hidden" name="token" value="'.newToken().'">';
  854. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  855. print '<input type="hidden" name="action" value="list">';
  856. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  857. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  858. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  859. // Show description of content
  860. $texthelp = '';
  861. if ($search_project_user == $user->id) {
  862. $texthelp .= $langs->trans("MyProjectsDesc");
  863. } else {
  864. if ($user->rights->projet->all->lire && !$socid) {
  865. $texthelp .= $langs->trans("ProjectsDesc");
  866. } else {
  867. $texthelp .= $langs->trans("ProjectsPublicDesc");
  868. }
  869. }
  870. print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit, 0, 0, 1);
  871. $topicmail = "Information";
  872. $modelmail = "project";
  873. $objecttmp = new Project($db);
  874. $trackid = 'proj'.$object->id;
  875. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  876. if ($search_all) {
  877. foreach ($fieldstosearchall as $key => $val) {
  878. $fieldstosearchall[$key] = $langs->trans($val);
  879. }
  880. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
  881. }
  882. $moreforfilter = '';
  883. // If the user can view user other than himself
  884. $moreforfilter .= '<div class="divsearchfield">';
  885. $tmptitle = $langs->trans('ProjectsWithThisUserAsContact');
  886. //$includeonly = 'hierarchyme';
  887. $includeonly = '';
  888. if (empty($user->rights->user->user->lire)) {
  889. $includeonly = array($user->id);
  890. }
  891. $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
  892. $moreforfilter .= '</div>';
  893. $moreforfilter .= '<div class="divsearchfield">';
  894. $tmptitle = $langs->trans('ProjectsWithThisContact');
  895. $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->selectcontacts(0, $search_project_contact ? $search_project_contact : '', 'search_project_contact', $tmptitle, '', '', 0, 'maxwidth250 widthcentpercentminusx');
  896. $moreforfilter .= '</div>';
  897. // If the user can view thirdparties other than his'
  898. if ($user->rights->user->user->lire) {
  899. $langs->load("commercial");
  900. $moreforfilter .= '<div class="divsearchfield">';
  901. $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
  902. $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx');
  903. $moreforfilter .= '</div>';
  904. }
  905. // Filter on categories
  906. if (isModEnabled('categorie') && $user->rights->categorie->lire) {
  907. $formcategory = new FormCategory($db);
  908. $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array);
  909. }
  910. // Filter on customer categories
  911. if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST) && !empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
  912. $moreforfilter .= '<div class="divsearchfield">';
  913. $tmptitle = $langs->transnoentities('CustomersProspectsCategoriesShort');
  914. $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
  915. $categoriesArr = $form->select_all_categories(Categorie::TYPE_CUSTOMER, '', '', 64, 0, 1);
  916. $categoriesArr[-2] = '- '.$langs->trans('NotCategorized').' -';
  917. $moreforfilter .= Form::multiselectarray('search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0, 'minwidth300', 0, 0, '', 'category', $tmptitle);
  918. $moreforfilter .= ' <input type="checkbox" class="valignmiddle" id="search_category_customer_operator" name="search_category_customer_operator" value="1"'.($searchCategoryCustomerOperator == 1 ? ' checked="checked"' : '').'/>';
  919. $moreforfilter .= $form->textwithpicto('', $langs->trans('UseOrOperatorForCategories') . ' : ' . $tmptitle, 1, 'help', '', 0, 2, 'tooltip_cat_cus'); // Tooltip on click
  920. $moreforfilter .= '</div>';
  921. }
  922. if (!empty($moreforfilter)) {
  923. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  924. print $moreforfilter;
  925. $parameters = array();
  926. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  927. print $hookmanager->resPrint;
  928. print '</div>';
  929. }
  930. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  931. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
  932. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  933. print '<div class="div-table-responsive">';
  934. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  935. // Fields title search
  936. // --------------------------------------------------------------------
  937. print '<tr class="liste_titre_filter">';
  938. // Action column
  939. if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
  940. print '<td class="liste_titre maxwidthsearch">';
  941. $searchpicto = $form->showFilterButtons('left');
  942. print $searchpicto;
  943. print '</td>';
  944. }
  945. // Project ref
  946. if (!empty($arrayfields['p.ref']['checked'])) {
  947. print '<td class="liste_titre">';
  948. print '<input type="text" class="flat" name="search_ref" value="'.dol_escape_htmltag($search_ref).'" size="6">';
  949. print '</td>';
  950. }
  951. // Project label
  952. if (!empty($arrayfields['p.title']['checked'])) {
  953. print '<td class="liste_titre">';
  954. print '<input type="text" class="flat" name="search_label" size="8" value="'.dol_escape_htmltag($search_label).'">';
  955. print '</td>';
  956. }
  957. // Third party
  958. if (!empty($arrayfields['s.nom']['checked'])) {
  959. print '<td class="liste_titre">';
  960. if ($socid > 0) {
  961. $tmpthirdparty = new Societe($db);
  962. $tmpthirdparty->fetch($socid);
  963. $search_societe = $tmpthirdparty->name;
  964. }
  965. print '<input type="text" class="flat" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).'">';
  966. print '</td>';
  967. }
  968. // Alias
  969. if (!empty($arrayfields['s.name_alias']['checked'])) {
  970. print '<td class="liste_titre">';
  971. if ($socid > 0) {
  972. $tmpthirdparty = new Societe($db);
  973. $tmpthirdparty->fetch($socid);
  974. $search_societe_alias = $tmpthirdparty->name_alias;
  975. }
  976. print '<input type="text" class="flat" name="search_societe_alias" size="8" value="'.dol_escape_htmltag($search_societe_alias).'">';
  977. print '</td>';
  978. }
  979. // Sale representative
  980. if (!empty($arrayfields['commercial']['checked'])) {
  981. print '<td class="liste_titre">&nbsp;</td>';
  982. }
  983. // Start date
  984. if (!empty($arrayfields['p.dateo']['checked'])) {
  985. print '<td class="liste_titre center nowraponall">';
  986. /*if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
  987. print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_sday" value="'.dol_escape_htmltag($search_sday).'">';
  988. }
  989. print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_smonth" value="'.dol_escape_htmltag($search_smonth).'">';
  990. print $formother->selectyear($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');*/
  991. print '<div class="nowrap">';
  992. print $form->selectDate($search_date_start_start ? $search_date_start_start : -1, 'search_date_start_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  993. print '</div>';
  994. print '<div class="nowrap">';
  995. print $form->selectDate($search_date_start_end ? $search_date_start_end : -1, 'search_date_start_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  996. print '</div>';
  997. print '</td>';
  998. }
  999. // End date
  1000. if (!empty($arrayfields['p.datee']['checked'])) {
  1001. print '<td class="liste_titre center nowraponall">';
  1002. /*if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
  1003. print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_eday" value="'.dol_escape_htmltag($search_eday).'">';
  1004. }
  1005. print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_emonth" value="'.dol_escape_htmltag($search_emonth).'">';
  1006. print $formother->selectyear($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');*/
  1007. print '<div class="nowrap">';
  1008. print $form->selectDate($search_date_end_start ? $search_date_end_start : -1, 'search_date_end_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  1009. print '</div>';
  1010. print '<div class="nowrap">';
  1011. print $form->selectDate($search_date_end_end ? $search_date_end_end : -1, 'search_date_end_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  1012. print '</div>';
  1013. print '</td>';
  1014. }
  1015. // Visibility
  1016. if (!empty($arrayfields['p.public']['checked'])) {
  1017. print '<td class="liste_titre center">';
  1018. $array = array(''=>'', 0 => $langs->trans("PrivateProject"), 1 => $langs->trans("SharedProject"));
  1019. print $form->selectarray('search_public', $array, $search_public, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth75');
  1020. print '</td>';
  1021. }
  1022. if (!empty($arrayfields['c.assigned']['checked'])) {
  1023. print '<td class="liste_titre center">';
  1024. print '</td>';
  1025. }
  1026. // Opp status
  1027. if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
  1028. print '<td class="liste_titre nowrap center">';
  1029. print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 1, 1, 0, 'maxwidth125 nowrapoption', 1, 1);
  1030. print '</td>';
  1031. }
  1032. if (!empty($arrayfields['p.opp_amount']['checked'])) {
  1033. print '<td class="liste_titre nowrap right">';
  1034. print '<input type="text" class="flat" name="search_opp_amount" size="3" value="'.$search_opp_amount.'">';
  1035. print '</td>';
  1036. }
  1037. if (!empty($arrayfields['p.opp_percent']['checked'])) {
  1038. print '<td class="liste_titre nowrap right">';
  1039. print '<input type="text" class="flat" name="search_opp_percent" size="2" value="'.$search_opp_percent.'">';
  1040. print '</td>';
  1041. }
  1042. if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
  1043. print '<td class="liste_titre nowrap right">';
  1044. print '</td>';
  1045. }
  1046. if (!empty($arrayfields['p.budget_amount']['checked'])) {
  1047. print '<td class="liste_titre nowrap right">';
  1048. print '<input type="text" class="flat" name="search_budget_amount" size="4" value="'.$search_budget_amount.'">';
  1049. print '</td>';
  1050. }
  1051. if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
  1052. print '<td class="liste_titre nowrap right">';
  1053. print $form->selectyesno('search_usage_opportunity', $search_usage_opportunity, 1, false, 1);
  1054. print '';
  1055. print '</td>';
  1056. }
  1057. if (!empty($arrayfields['p.usage_task']['checked'])) {
  1058. print '<td class="liste_titre nowrap right">';
  1059. print $form->selectyesno('search_usage_task', $search_usage_task, 1, false, 1);
  1060. print '</td>';
  1061. }
  1062. if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
  1063. print '<td class="liste_titre nowrap right">';
  1064. print $form->selectyesno('search_usage_bill_time', $search_usage_bill_time, 1, false, 1);
  1065. print '</td>';
  1066. }
  1067. if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
  1068. print '<td class="liste_titre nowrap right">';
  1069. print $form->selectyesno('search_usage_event_organization', $search_usage_event_organization, 1, false, 1);
  1070. print '</td>';
  1071. }
  1072. if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
  1073. print '<td class="liste_titre nowrap right">';
  1074. print $form->selectyesno('search_accept_conference_suggestions', $search_accept_conference_suggestions, 1, false, 1);
  1075. print '</td>';
  1076. }
  1077. if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
  1078. print '<td class="liste_titre nowrap right">';
  1079. print $form->selectyesno('search_accept_booth_suggestions', $search_accept_booth_suggestions, 1, false, 1);
  1080. print '</td>';
  1081. }
  1082. if (!empty($arrayfields['p.price_registration']['checked'])) {
  1083. print '<td class="liste_titre nowrap right">';
  1084. print '<input type="text" class="flat" name="search_price_registration" size="4" value="'.$search_price_registration.'">';
  1085. print '</td>';
  1086. }
  1087. if (!empty($arrayfields['p.price_booth']['checked'])) {
  1088. print '<td class="liste_titre nowrap right">';
  1089. print '<input type="text" class="flat" name="search_price_booth" size="4" value="'.$search_price_booth.'">';
  1090. print '</td>';
  1091. }
  1092. if (!empty($arrayfields['u.login']['checked'])) {
  1093. // Author
  1094. print '<td class="liste_titre" align="center">';
  1095. print '<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'">';
  1096. print '</td>';
  1097. }
  1098. // Extra fields
  1099. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  1100. // Fields from hook
  1101. $parameters = array('arrayfields'=>$arrayfields);
  1102. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  1103. print $hookmanager->resPrint;
  1104. if (!empty($arrayfields['p.datec']['checked'])) {
  1105. // Date creation
  1106. print '<td class="liste_titre">';
  1107. print '</td>';
  1108. }
  1109. if (!empty($arrayfields['p.tms']['checked'])) {
  1110. // Date modification
  1111. print '<td class="liste_titre">';
  1112. print '</td>';
  1113. }
  1114. if (!empty($arrayfields['p.email_msgid']['checked'])) {
  1115. // Email msg id
  1116. print '<td class="liste_titre">';
  1117. print '</td>';
  1118. }
  1119. if (!empty($arrayfields['p.import_key']['checked'])) {
  1120. // Import key
  1121. print '<td class="liste_titre">';
  1122. print '<input class="flat width75" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
  1123. print '</td>';
  1124. }
  1125. if (!empty($arrayfields['p.fk_statut']['checked'])) {
  1126. print '<td class="liste_titre center parentonrightofpage">';
  1127. $arrayofstatus = array();
  1128. foreach ($object->statuts_short as $key => $val) {
  1129. $arrayofstatus[$key] = $langs->trans($val);
  1130. }
  1131. $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')';
  1132. print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1);
  1133. print '</td>';
  1134. }
  1135. // Action column
  1136. if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
  1137. print '<td class="liste_titre maxwidthsearch">';
  1138. $searchpicto = $form->showFilterButtons();
  1139. print $searchpicto;
  1140. print '</td>';
  1141. }
  1142. print '</tr>'."\n";
  1143. print '<tr class="liste_titre">';
  1144. if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
  1145. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  1146. }
  1147. if (!empty($arrayfields['p.ref']['checked'])) {
  1148. print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder);
  1149. }
  1150. if (!empty($arrayfields['p.title']['checked'])) {
  1151. print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder);
  1152. }
  1153. if (!empty($arrayfields['s.nom']['checked'])) {
  1154. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
  1155. }
  1156. if (!empty($arrayfields['s.name_alias']['checked'])) {
  1157. print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder);
  1158. }
  1159. if (!empty($arrayfields['commercial']['checked'])) {
  1160. print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder, 'tdoverflowmax100imp ');
  1161. }
  1162. if (!empty($arrayfields['p.dateo']['checked'])) {
  1163. print_liste_field_titre($arrayfields['p.dateo']['label'], $_SERVER["PHP_SELF"], "p.dateo", "", $param, '', $sortfield, $sortorder, 'center ');
  1164. }
  1165. if (!empty($arrayfields['p.datee']['checked'])) {
  1166. print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center ');
  1167. }
  1168. if (!empty($arrayfields['p.public']['checked'])) {
  1169. print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder, 'center ');
  1170. }
  1171. if (!empty($arrayfields['c.assigned']['checked'])) {
  1172. print_liste_field_titre($arrayfields['c.assigned']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '');
  1173. }
  1174. if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
  1175. print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
  1176. }
  1177. if (!empty($arrayfields['p.opp_amount']['checked'])) {
  1178. print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
  1179. }
  1180. if (!empty($arrayfields['p.opp_percent']['checked'])) {
  1181. print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER['PHP_SELF'], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
  1182. }
  1183. if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
  1184. print_liste_field_titre($arrayfields['opp_weighted_amount']['label'], $_SERVER['PHP_SELF'], 'opp_weighted_amount', '', $param, '', $sortfield, $sortorder, 'right ');
  1185. }
  1186. if (!empty($arrayfields['p.budget_amount']['checked'])) {
  1187. print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
  1188. }
  1189. if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
  1190. print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right ');
  1191. }
  1192. if (!empty($arrayfields['p.usage_task']['checked'])) {
  1193. print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right ');
  1194. }
  1195. if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
  1196. print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right ');
  1197. }
  1198. if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
  1199. print_liste_field_titre($arrayfields['p.usage_organize_event']['label'], $_SERVER["PHP_SELF"], 'p.usage_organize_event', "", $param, '', $sortfield, $sortorder, 'right ');
  1200. }
  1201. if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
  1202. print_liste_field_titre($arrayfields['p.accept_conference_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_conference_suggestions', "", $param, '', $sortfield, $sortorder, 'right ');
  1203. }
  1204. if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
  1205. print_liste_field_titre($arrayfields['p.accept_booth_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_booth_suggestions', "", $param, '', $sortfield, $sortorder, 'right ');
  1206. }
  1207. if (!empty($arrayfields['p.price_registration']['checked'])) {
  1208. print_liste_field_titre($arrayfields['p.price_registration']['label'], $_SERVER["PHP_SELF"], 'p.price_registration', "", $param, '', $sortfield, $sortorder, 'right ');
  1209. }
  1210. if (!empty($arrayfields['p.price_booth']['checked'])) {
  1211. print_liste_field_titre($arrayfields['p.price_booth']['label'], $_SERVER["PHP_SELF"], 'p.price_booth', "", $param, '', $sortfield, $sortorder, 'right ');
  1212. }
  1213. if (!empty($arrayfields['u.login']['checked'])) {
  1214. print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder);
  1215. }
  1216. // Extra fields
  1217. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  1218. // Hook fields
  1219. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  1220. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  1221. print $hookmanager->resPrint;
  1222. if (!empty($arrayfields['p.datec']['checked'])) {
  1223. print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  1224. }
  1225. if (!empty($arrayfields['p.tms']['checked'])) {
  1226. print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  1227. }
  1228. if (!empty($arrayfields['p.email_msgid']['checked'])) {
  1229. print_liste_field_titre($arrayfields['p.email_msgid']['label'], $_SERVER["PHP_SELF"], "p.email_msgid", "", $param, '', $sortfield, $sortorder, 'center ');
  1230. }
  1231. if (!empty($arrayfields['p.import_key']['checked'])) {
  1232. print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, '');
  1233. }
  1234. if (!empty($arrayfields['p.fk_statut']['checked'])) {
  1235. print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
  1236. }
  1237. if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
  1238. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  1239. }
  1240. print "</tr>\n";
  1241. $userstatic = new User($db);
  1242. $i = 0;
  1243. $totalarray = array(
  1244. 'nbfield' => 0,
  1245. 'val' => array(),
  1246. );
  1247. $imaxinloop = ($limit ? min($num, $limit) : $num);
  1248. while ($i < $imaxinloop) {
  1249. $obj = $db->fetch_object($resql);
  1250. if (empty($obj)) {
  1251. break; // Should not happen
  1252. }
  1253. $object->id = $obj->id;
  1254. $object->user_author_id = $obj->fk_user_creat;
  1255. $object->public = $obj->public;
  1256. $object->ref = $obj->ref;
  1257. $object->datee = $db->jdate($obj->date_end);
  1258. $object->statut = $obj->status; // deprecated
  1259. $object->status = $obj->status;
  1260. $object->public = $obj->public;
  1261. $object->opp_status = $obj->fk_opp_status;
  1262. $object->title = $obj->title;
  1263. $userAccess = $object->restrictedProjectArea($user); // why this ?
  1264. if ($userAccess >= 0) {
  1265. // Thirdparty
  1266. $companystatic->id = $obj->socid;
  1267. $companystatic->name = $obj->name;
  1268. $companystatic->name_alias = $obj->alias;
  1269. $companystatic->client = $obj->client;
  1270. $companystatic->code_client = $obj->code_client;
  1271. $companystatic->email = $obj->email;
  1272. $companystatic->phone = $obj->phone;
  1273. $companystatic->address = $obj->address;
  1274. $companystatic->zip = $obj->zip;
  1275. $companystatic->town = $obj->town;
  1276. $companystatic->country_code = $obj->country_code;
  1277. // Author
  1278. $userstatic->id = $obj->fk_user_creat;
  1279. $userstatic->login = $obj->login;
  1280. $userstatic->lastname = $obj->lastname;
  1281. $userstatic->firstname = $obj->firstname;
  1282. $userstatic->email = $obj->user_email;
  1283. $userstatic->statut = $obj->user_statut;
  1284. $userstatic->entity = $obj->entity;
  1285. $userstatic->photo = $obj->photo;
  1286. $userstatic->office_phone = $obj->office_phone;
  1287. $userstatic->office_fax = $obj->office_fax;
  1288. $userstatic->user_mobile = $obj->user_mobile;
  1289. $userstatic->job = $obj->job;
  1290. $userstatic->gender = $obj->gender;
  1291. print '<tr class="oddeven">';
  1292. // Action column
  1293. if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
  1294. print '<td class="nowrap center">';
  1295. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1296. $selected = 0;
  1297. if (in_array($obj->id, $arrayofselected)) {
  1298. $selected = 1;
  1299. }
  1300. print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
  1301. }
  1302. print '</td>';
  1303. if (!$i) {
  1304. $totalarray['nbfield']++;
  1305. }
  1306. }
  1307. // Project url
  1308. if (!empty($arrayfields['p.ref']['checked'])) {
  1309. print '<td class="nowraponall">';
  1310. print $object->getNomUrl(1, (!empty(GETPOST('search_usage_event_organization', 'int'))?'eventorganization':''));
  1311. if ($object->hasDelay()) {
  1312. print img_warning($langs->trans('Late'));
  1313. }
  1314. print '</td>';
  1315. if (!$i) {
  1316. $totalarray['nbfield']++;
  1317. }
  1318. }
  1319. // Title
  1320. if (!empty($arrayfields['p.title']['checked'])) {
  1321. print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).'">';
  1322. print $obj->title;
  1323. print '</td>';
  1324. if (!$i) {
  1325. $totalarray['nbfield']++;
  1326. }
  1327. }
  1328. // Company
  1329. if (!empty($arrayfields['s.nom']['checked'])) {
  1330. print '<td class="tdoverflowmax100">';
  1331. if ($obj->socid) {
  1332. print $companystatic->getNomUrl(1, '', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1);
  1333. } else {
  1334. print '&nbsp;';
  1335. }
  1336. print '</td>';
  1337. if (!$i) {
  1338. $totalarray['nbfield']++;
  1339. }
  1340. }
  1341. // Alias
  1342. if (!empty($arrayfields['s.name_alias']['checked'])) {
  1343. print '<td class="tdoverflowmax100">';
  1344. if ($obj->socid) {
  1345. print $companystatic->name_alias;
  1346. } else {
  1347. print '&nbsp;';
  1348. }
  1349. print '</td>';
  1350. if (!$i) {
  1351. $totalarray['nbfield']++;
  1352. }
  1353. }
  1354. // Sales Representatives
  1355. if (!empty($arrayfields['commercial']['checked'])) {
  1356. print '<td class="tdoverflowmax150">';
  1357. if ($obj->socid) {
  1358. $companystatic->id = $obj->socid;
  1359. $companystatic->name = $obj->name;
  1360. $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
  1361. $nbofsalesrepresentative = count($listsalesrepresentatives);
  1362. if ($nbofsalesrepresentative > 6) {
  1363. // We print only number
  1364. print $nbofsalesrepresentative;
  1365. } elseif ($nbofsalesrepresentative > 0) {
  1366. $userstatic = new User($db);
  1367. $j = 0;
  1368. foreach ($listsalesrepresentatives as $val) {
  1369. $userstatic->id = $val['id'];
  1370. $userstatic->lastname = $val['lastname'];
  1371. $userstatic->firstname = $val['firstname'];
  1372. $userstatic->email = $val['email'];
  1373. $userstatic->statut = $val['statut'];
  1374. $userstatic->entity = $val['entity'];
  1375. $userstatic->photo = $val['photo'];
  1376. $userstatic->login = $val['login'];
  1377. $userstatic->office_phone = $val['office_phone'];
  1378. $userstatic->office_fax = $val['office_fax'];
  1379. $userstatic->user_mobile = $val['user_mobile'];
  1380. $userstatic->job = $val['job'];
  1381. $userstatic->gender = $val['gender'];
  1382. print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
  1383. $j++;
  1384. if ($j < $nbofsalesrepresentative) {
  1385. print ' ';
  1386. }
  1387. }
  1388. }
  1389. //else print $langs->trans("NoSalesRepresentativeAffected");
  1390. } else {
  1391. print '&nbsp;';
  1392. }
  1393. print '</td>';
  1394. if (!$i) {
  1395. $totalarray['nbfield']++;
  1396. }
  1397. }
  1398. // Date start project
  1399. if (!empty($arrayfields['p.dateo']['checked'])) {
  1400. print '<td class="center">';
  1401. print dol_print_date($db->jdate($obj->date_start), 'day');
  1402. print '</td>';
  1403. if (!$i) {
  1404. $totalarray['nbfield']++;
  1405. }
  1406. }
  1407. // Date end project
  1408. if (!empty($arrayfields['p.datee']['checked'])) {
  1409. print '<td class="center">';
  1410. print dol_print_date($db->jdate($obj->date_end), 'day');
  1411. print '</td>';
  1412. if (!$i) {
  1413. $totalarray['nbfield']++;
  1414. }
  1415. }
  1416. // Visibility
  1417. if (!empty($arrayfields['p.public']['checked'])) {
  1418. print '<td class="center">';
  1419. if ($obj->public) {
  1420. print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
  1421. //print $langs->trans('SharedProject');
  1422. } else {
  1423. print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
  1424. //print $langs->trans('PrivateProject');
  1425. }
  1426. print '</td>';
  1427. if (!$i) {
  1428. $totalarray['nbfield']++;
  1429. }
  1430. }
  1431. // Contacts of project
  1432. if (!empty($arrayfields['c.assigned']['checked'])) {
  1433. print '<td class="center nowraponall tdoverflowmax200">';
  1434. $ifisrt = 1;
  1435. foreach (array('internal', 'external') as $source) {
  1436. $tab = $object->liste_contact(-1, $source, 0, '', 1);
  1437. $numcontact = count($tab);
  1438. if (!empty($numcontact)) {
  1439. foreach ($tab as $contactproject) {
  1440. //var_dump($contacttask);
  1441. $cid = $contactproject['id'];
  1442. if ($source == 'internal') {
  1443. if (empty($conf->cache['user'][$cid])) {
  1444. $c = new User($db);
  1445. $c->fetch($cid);
  1446. $conf->cache['user'][$cid] = $c;
  1447. } else {
  1448. $c = $conf->cache['user'][$cid];
  1449. }
  1450. } else {
  1451. if (empty($conf->cache['contact'][$cid])) {
  1452. $c = new Contact($db);
  1453. $c->fetch($cid);
  1454. $conf->cache['contact'][$cid] = $c;
  1455. } else {
  1456. $c = $conf->cache['contact'][$cid];
  1457. }
  1458. }
  1459. if (!empty($c->photo)) {
  1460. if (get_class($c) == 'User') {
  1461. print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
  1462. } else {
  1463. print $c->getNomUrl(-2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst'));
  1464. }
  1465. } else {
  1466. if (get_class($c) == 'User') {
  1467. print $c->getNomUrl(2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst'));
  1468. } else {
  1469. print $c->getNomUrl(2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst'));
  1470. }
  1471. }
  1472. $ifisrt = 0;
  1473. }
  1474. }
  1475. }
  1476. print '</td>';
  1477. if (!$i) {
  1478. $totalarray['nbfield']++;
  1479. }
  1480. }
  1481. // Opp Status
  1482. if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
  1483. print '<td class="center">';
  1484. if ($obj->opp_status_code) {
  1485. print $langs->trans("OppStatus".$obj->opp_status_code);
  1486. }
  1487. print '</td>';
  1488. if (!$i) {
  1489. $totalarray['nbfield']++;
  1490. }
  1491. }
  1492. // Opp Amount
  1493. if (!empty($arrayfields['p.opp_amount']['checked'])) {
  1494. print '<td class="right">';
  1495. //if ($obj->opp_status_code)
  1496. if (strcmp($obj->opp_amount, '')) {
  1497. print '<span class="amount">'.price($obj->opp_amount, 1, $langs, 1, -1, -1, '').'</span>';
  1498. if (empty($totalarray['val']['p.opp_amount'])) {
  1499. $totalarray['val']['p.opp_amount'] = $obj->opp_amount;
  1500. } else {
  1501. $totalarray['val']['p.opp_amount'] += $obj->opp_amount;
  1502. }
  1503. }
  1504. print '</td>';
  1505. if (!$i) {
  1506. $totalarray['nbfield']++;
  1507. }
  1508. if (!$i) {
  1509. $totalarray['pos'][$totalarray['nbfield']] = 'p.opp_amount';
  1510. }
  1511. }
  1512. // Opp percent
  1513. if (!empty($arrayfields['p.opp_percent']['checked'])) {
  1514. print '<td class="right">';
  1515. if ($obj->opp_percent) {
  1516. print price($obj->opp_percent, 1, $langs, 1, 0).'%';
  1517. }
  1518. print '</td>';
  1519. if (!$i) {
  1520. $totalarray['nbfield']++;
  1521. }
  1522. }
  1523. // Opp weighted amount
  1524. if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
  1525. if (!isset($totalarray['val']['opp_weighted_amount'])) {
  1526. $totalarray['val']['opp_weighted_amount'] = 0;
  1527. }
  1528. print '<td align="right">';
  1529. if ($obj->opp_weighted_amount) {
  1530. print '<span class="amount">'.price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '').'</span>';
  1531. if (empty($totalarray['val']['opp_weighted_amount'])) {
  1532. $totalarray['val']['opp_weighted_amount'] = $obj->opp_weighted_amount;
  1533. } else {
  1534. $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount;
  1535. }
  1536. }
  1537. print '</td>';
  1538. if (!$i) {
  1539. $totalarray['nbfield']++;
  1540. }
  1541. if (!$i) {
  1542. $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount';
  1543. }
  1544. }
  1545. // Budget
  1546. if (!empty($arrayfields['p.budget_amount']['checked'])) {
  1547. print '<td class="right">';
  1548. if ($obj->budget_amount != '') {
  1549. print '<span class="amount">'.price($obj->budget_amount, 1, $langs, 1, -1, -1).'</span>';
  1550. if (empty($totalarray['val']['p.budget_amount'])) {
  1551. $totalarray['val']['p.budget_amount'] = $obj->budget_amount;
  1552. } else {
  1553. $totalarray['val']['p.budget_amount'] += $obj->budget_amount;
  1554. }
  1555. }
  1556. print '</td>';
  1557. if (!$i) {
  1558. $totalarray['nbfield']++;
  1559. }
  1560. if (!$i) {
  1561. $totalarray['pos'][$totalarray['nbfield']] = 'p.budget_amount';
  1562. }
  1563. }
  1564. // Usage opportunity
  1565. if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
  1566. print '<td class="right">';
  1567. if ($obj->usage_opportunity) {
  1568. print yn($obj->usage_opportunity);
  1569. }
  1570. print '</td>';
  1571. if (!$i) {
  1572. $totalarray['nbfield']++;
  1573. }
  1574. }
  1575. // Usage task
  1576. if (!empty($arrayfields['p.usage_task']['checked'])) {
  1577. print '<td class="right">';
  1578. if ($obj->usage_task) {
  1579. print yn($obj->usage_task);
  1580. }
  1581. print '</td>';
  1582. if (!$i) {
  1583. $totalarray['nbfield']++;
  1584. }
  1585. }
  1586. // Bill time
  1587. if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
  1588. print '<td class="right">';
  1589. if ($obj->usage_bill_time) {
  1590. print yn($obj->usage_bill_time);
  1591. }
  1592. print '</td>';
  1593. if (!$i) {
  1594. $totalarray['nbfield']++;
  1595. }
  1596. }
  1597. // Event Organization
  1598. if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
  1599. print '<td class="right">';
  1600. if ($obj->usage_organize_event) {
  1601. print yn($obj->usage_organize_event);
  1602. }
  1603. print '</td>';
  1604. if (!$i) {
  1605. $totalarray['nbfield']++;
  1606. }
  1607. }
  1608. // Allow unknown people to suggest conferences
  1609. if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
  1610. print '<td class="right">';
  1611. if ($obj->accept_conference_suggestions) {
  1612. print yn($obj->accept_conference_suggestions);
  1613. }
  1614. print '</td>';
  1615. if (!$i) {
  1616. $totalarray['nbfield']++;
  1617. }
  1618. }
  1619. // Allow unknown people to suggest booth
  1620. if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
  1621. print '<td class="right">';
  1622. if ($obj->accept_booth_suggestions) {
  1623. print yn($obj->accept_booth_suggestions);
  1624. }
  1625. print '</td>';
  1626. if (!$i) {
  1627. $totalarray['nbfield']++;
  1628. }
  1629. }
  1630. // Price of registration
  1631. if (!empty($arrayfields['p.price_registration']['checked'])) {
  1632. print '<td class="right">';
  1633. if ($obj->price_registration != '') {
  1634. print '<span class="amount">'.price($obj->price_registration, 1, $langs, 1, -1, -1).'</span>';
  1635. $totalarray['val']['p.price_registration'] += $obj->price_registration;
  1636. }
  1637. print '</td>';
  1638. if (!$i) {
  1639. $totalarray['nbfield']++;
  1640. }
  1641. if (!$i) {
  1642. $totalarray['pos'][$totalarray['nbfield']] = 'p.price_registration';
  1643. }
  1644. }
  1645. // Price of booth
  1646. if (!empty($arrayfields['p.price_booth']['checked'])) {
  1647. print '<td class="right">';
  1648. if ($obj->price_booth != '') {
  1649. print '<span class="amount">'.price($obj->price_booth, 1, $langs, 1, -1, -1).'</span>';
  1650. $totalarray['val']['p.price_booth'] += $obj->price_booth;
  1651. }
  1652. print '</td>';
  1653. if (!$i) {
  1654. $totalarray['nbfield']++;
  1655. }
  1656. if (!$i) {
  1657. $totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth';
  1658. }
  1659. }
  1660. if (!empty($arrayfields['u.login']['checked'])) {
  1661. print '<td class="center tdoverflowmax150">';
  1662. if ($userstatic->id) {
  1663. print $userstatic->getNomUrl(-1);
  1664. } else {
  1665. print '&nbsp;';
  1666. }
  1667. print "</td>\n";
  1668. if (!$i) {
  1669. $totalarray['nbfield']++;
  1670. }
  1671. }
  1672. // Extra fields
  1673. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  1674. // Fields from hook
  1675. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  1676. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  1677. print $hookmanager->resPrint;
  1678. // Date creation
  1679. if (!empty($arrayfields['p.datec']['checked'])) {
  1680. print '<td class="center nowraponall">';
  1681. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  1682. print '</td>';
  1683. if (!$i) {
  1684. $totalarray['nbfield']++;
  1685. }
  1686. }
  1687. // Date modification
  1688. if (!empty($arrayfields['p.tms']['checked'])) {
  1689. print '<td class="center nowraponall">';
  1690. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  1691. print '</td>';
  1692. if (!$i) {
  1693. $totalarray['nbfield']++;
  1694. }
  1695. }
  1696. // Email MsgID
  1697. if (!empty($arrayfields['p.email_msgid']['checked'])) {
  1698. print '<td class="center">';
  1699. print $obj->email_msgid;
  1700. print '</td>';
  1701. if (!$i) $totalarray['nbfield']++;
  1702. }
  1703. // Import key
  1704. if (!empty($arrayfields['p.import_key']['checked'])) {
  1705. print '<td class="right">'.dol_escape_htmltag($obj->import_key).'</td>';
  1706. if (!$i) {
  1707. $totalarray['nbfield']++;
  1708. }
  1709. }
  1710. // Status
  1711. if (!empty($arrayfields['p.fk_statut']['checked'])) {
  1712. print '<td class="center">'.$object->getLibStatut(5).'</td>';
  1713. if (!$i) {
  1714. $totalarray['nbfield']++;
  1715. }
  1716. }
  1717. // Action column
  1718. if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
  1719. print '<td class="nowrap center">';
  1720. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1721. $selected = 0;
  1722. if (in_array($obj->id, $arrayofselected)) {
  1723. $selected = 1;
  1724. }
  1725. print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
  1726. }
  1727. print '</td>';
  1728. if (!$i) {
  1729. $totalarray['nbfield']++;
  1730. }
  1731. }
  1732. print "</tr>\n";
  1733. }
  1734. $i++;
  1735. }
  1736. // Show total line
  1737. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  1738. // If no record found
  1739. if ($num == 0) {
  1740. $colspan = 1;
  1741. foreach ($arrayfields as $key => $val) {
  1742. if (!empty($val['checked'])) {
  1743. $colspan++;
  1744. }
  1745. }
  1746. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  1747. }
  1748. $db->free($resql);
  1749. $parameters = array('arrayfields'=>$arrayfields, 'sql' => $sql);
  1750. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  1751. print $hookmanager->resPrint;
  1752. print "</table>\n";
  1753. print '</div>';
  1754. print "</form>\n";
  1755. // End of page
  1756. llxFooter();
  1757. $db->close();