list.php 78 KB

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