list.php 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481
  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. require '../main.inc.php';
  31. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  35. if (!empty($conf->categorie->enabled)) {
  36. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  38. }
  39. // Load translation files required by the page
  40. $langs->loadLangs(array('projects', 'companies', 'commercial'));
  41. if (!empty($conf->eventorganization->enabled) && $conf->eventorganization->enabled) {
  42. $langs->loadLangs(array('eventorganization'));
  43. }
  44. $action = GETPOST('action', 'aZ09');
  45. $massaction = GETPOST('massaction', 'alpha');
  46. $show_files = GETPOST('show_files', 'int');
  47. $confirm = GETPOST('confirm', 'alpha');
  48. $toselect = GETPOST('toselect', 'array');
  49. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projectlist';
  50. $title = $langs->trans("Projects");
  51. // Security check
  52. $socid = GETPOST('socid', 'int');
  53. //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.
  54. if ($socid > 0) {
  55. $soc = new Societe($db);
  56. $soc->fetch($socid);
  57. $title .= ' (<a href="list.php">'.$soc->name.'</a>)';
  58. }
  59. if (!$user->rights->projet->lire) {
  60. accessforbidden();
  61. }
  62. $diroutputmassaction = $conf->projet->dir_output.'/temp/massgeneration/'.$user->id;
  63. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  64. $sortfield = GETPOST("sortfield", "aZ09comma");
  65. $sortorder = GETPOST("sortorder", 'aZ09comma');
  66. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  67. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  68. // If $page is not defined, or '' or -1 or if we click on clear filters
  69. $page = 0;
  70. }
  71. if (!$sortfield) {
  72. $sortfield = "p.ref";
  73. }
  74. if (!$sortorder) {
  75. $sortorder = "ASC";
  76. }
  77. $offset = $limit * $page;
  78. $pageprev = $page - 1;
  79. $pagenext = $page + 1;
  80. $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
  81. $search_ref = GETPOST("search_ref", 'alpha');
  82. $search_label = GETPOST("search_label", 'alpha');
  83. $search_societe = GETPOST("search_societe", 'alpha');
  84. $search_status = GETPOST("search_status", 'int');
  85. $search_opp_status = GETPOST("search_opp_status", 'alpha');
  86. $search_opp_percent = GETPOST("search_opp_percent", 'alpha');
  87. $search_opp_amount = GETPOST("search_opp_amount", 'alpha');
  88. $search_budget_amount = GETPOST("search_budget_amount", 'alpha');
  89. $search_public = GETPOST("search_public", 'int');
  90. $search_project_user = GETPOST('search_project_user', 'int');
  91. $search_sale = GETPOST('search_sale', 'int');
  92. $search_usage_opportunity = GETPOST('search_usage_opportunity', 'int');
  93. $search_usage_task = GETPOST('search_usage_task', 'int');
  94. $search_usage_bill_time = GETPOST('search_usage_bill_time', 'int');
  95. $search_usage_event_organization = GETPOST('search_usage_event_organization', 'int');
  96. $search_accept_conference_suggestions = GETPOST('search_accept_conference_suggestions', 'int');
  97. $search_accept_booth_suggestions = GETPOST('search_accept_booth_suggestions', 'int');
  98. $search_price_registration = GETPOST("search_price_registration", 'alpha');
  99. $search_price_booth = GETPOST("search_price_booth", 'alpha');
  100. $optioncss = GETPOST('optioncss', 'alpha');
  101. $mine = ((GETPOST('mode') == 'mine') ? 1 : 0);
  102. if ($mine) {
  103. $search_project_user = $user->id; $mine = 0;
  104. }
  105. $search_sday = GETPOST('search_sday', 'int');
  106. $search_smonth = GETPOST('search_smonth', 'int');
  107. $search_syear = GETPOST('search_syear', 'int');
  108. $search_eday = GETPOST('search_eday', 'int');
  109. $search_emonth = GETPOST('search_emonth', 'int');
  110. $search_eyear = GETPOST('search_eyear', 'int');
  111. $search_date_start_startmonth = GETPOST('search_date_start_startmonth', 'int');
  112. $search_date_start_startyear = GETPOST('search_date_start_startyear', 'int');
  113. $search_date_start_startday = GETPOST('search_date_start_startday', 'int');
  114. $search_date_start_start = dol_mktime(0, 0, 0, $search_date_start_startmonth, $search_date_start_startday, $search_date_start_startyear); // Use tzserver
  115. $search_date_start_endmonth = GETPOST('search_date_start_endmonth', 'int');
  116. $search_date_start_endyear = GETPOST('search_date_start_endyear', 'int');
  117. $search_date_start_endday = GETPOST('search_date_start_endday', 'int');
  118. $search_date_start_end = dol_mktime(23, 59, 59, $search_date_start_endmonth, $search_date_start_endday, $search_date_start_endyear); // Use tzserver
  119. $search_date_end_startmonth = GETPOST('search_date_end_startmonth', 'int');
  120. $search_date_end_startyear = GETPOST('search_date_end_startyear', 'int');
  121. $search_date_end_startday = GETPOST('search_date_end_startday', 'int');
  122. $search_date_end_start = dol_mktime(0, 0, 0, $search_date_end_startmonth, $search_date_end_startday, $search_date_end_startyear); // Use tzserver
  123. $search_date_end_endmonth = GETPOST('search_date_end_endmonth', 'int');
  124. $search_date_end_endyear = GETPOST('search_date_end_endyear', 'int');
  125. $search_date_end_endday = GETPOST('search_date_end_endday', 'int');
  126. $search_date_end_end = dol_mktime(23, 59, 59, $search_date_end_endmonth, $search_date_end_endday, $search_date_end_endyear); // Use tzserver
  127. if ($search_status == '') {
  128. $search_status = -1; // -1 or 1
  129. }
  130. if (!empty($conf->categorie->enabled)) {
  131. $search_category_array = GETPOST("search_category_".Categorie::TYPE_PROJECT."_list", "array");
  132. }
  133. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  134. $object = new Project($db);
  135. $hookmanager->initHooks(array('projectlist'));
  136. $extrafields = new ExtraFields($db);
  137. // fetch optionals attributes and labels
  138. $extrafields->fetch_name_optionals_label($object->table_element);
  139. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  140. // List of fields to search into when doing a "search in all"
  141. $fieldstosearchall = array();
  142. foreach ($object->fields as $key => $val) {
  143. if (empty($val['searchall'])) {
  144. continue;
  145. }
  146. // Don't allow search in private notes for external users when doing "search in all"
  147. if (!empty($user->socid) && $key == "note_private") {
  148. continue;
  149. }
  150. $fieldstosearchall['p.'.$key] = $val['label'];
  151. }
  152. // Add name object fields to "search in all"
  153. $fieldstosearchall['s.nom'] = "ThirdPartyName";
  154. // Definition of array of fields for columns
  155. $arrayfields = array();
  156. foreach ($object->fields as $key => $val) {
  157. // If $val['visible']==0, then we never show the field
  158. if (!empty($val['visible'])) {
  159. $visible = dol_eval($val['visible'], 1);
  160. $arrayfields['p.'.$key] = array(
  161. 'label'=>$val['label'],
  162. 'checked'=>(($visible < 0) ? 0 : 1),
  163. 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
  164. 'position'=>$val['position'],
  165. 'help'=> isset($val['help']) ? $val['help'] : ''
  166. );
  167. }
  168. }
  169. // Extra fields
  170. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  171. // Add non object fields to fields for list
  172. $arrayfields['s.nom'] = array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>21, 'enabled'=>(empty($conf->societe->enabled) ? 0 : 1));
  173. $arrayfields['commercial'] = array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0, 'position'=>23);
  174. $arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'position'=> 116, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106);
  175. // Force some fields according to search_usage filter...
  176. if (GETPOST('search_usage_opportunity')) {
  177. //$arrayfields['p.usage_opportunity']['visible'] = 1; // Not require, filter on search_opp_status is enough
  178. //$arrayfields['p.usage_opportunity']['checked'] = 1; // Not require, filter on search_opp_status is enough
  179. }
  180. if (GETPOST('search_usage_event_organization')) {
  181. $arrayfields['p.fk_opp_status']['enabled'] = 0;
  182. $arrayfields['p.opp_amount']['enabled'] = 0;
  183. $arrayfields['p.opp_percent']['enabled'] = 0;
  184. $arrayfields['opp_weighted_amount']['enabled'] = 0;
  185. $arrayfields['p.usage_organize_event']['visible'] = 1;
  186. $arrayfields['p.usage_organize_event']['checked'] = 1;
  187. }
  188. $object->fields = dol_sort_array($object->fields, 'position');
  189. $arrayfields = dol_sort_array($arrayfields, 'position');
  190. /*
  191. * Actions
  192. */
  193. if (GETPOST('cancel', 'alpha')) {
  194. $action = 'list'; $massaction = '';
  195. }
  196. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') {
  197. $massaction = '';
  198. }
  199. $parameters = array('socid'=>$socid);
  200. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  201. if ($reshook < 0) {
  202. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  203. }
  204. if (empty($reshook)) {
  205. // Selection of new fields
  206. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  207. // Purge search criteria
  208. 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
  209. $search_all = '';
  210. $search_ref = "";
  211. $search_label = "";
  212. $search_societe = "";
  213. $search_status = -1;
  214. $search_opp_status = -1;
  215. $search_opp_amount = '';
  216. $search_opp_percent = '';
  217. $search_budget_amount = '';
  218. $search_public = "";
  219. $search_sale = "";
  220. $search_project_user = '';
  221. $search_sday = "";
  222. $search_smonth = "";
  223. $search_syear = "";
  224. $search_eday = "";
  225. $search_emonth = "";
  226. $search_eyear = "";
  227. $search_date_start_startmonth = "";
  228. $search_date_start_startyear = "";
  229. $search_date_start_startday = "";
  230. $search_date_start_start = "";
  231. $search_date_start_endmonth = "";
  232. $search_date_start_endyear = "";
  233. $search_date_start_endday = "";
  234. $search_date_start_end = "";
  235. $search_date_end_startmonth = "";
  236. $search_date_end_startyear = "";
  237. $search_date_end_startday = "";
  238. $search_date_end_start = "";
  239. $search_date_end_endmonth = "";
  240. $search_date_end_endyear = "";
  241. $search_date_end_endday = "";
  242. $search_date_end_end = "";
  243. $search_usage_opportunity = '';
  244. $search_usage_task = '';
  245. $search_usage_bill_time = '';
  246. $search_usage_event_organization = '';
  247. $search_accept_conference_suggestions = '';
  248. $search_accept_booth_suggestions = '';
  249. $search_price_registration = '';
  250. $search_price_booth = '';
  251. $toselect = '';
  252. $search_array_options = array();
  253. $search_category_array = array();
  254. }
  255. // Mass actions
  256. $objectclass = 'Project';
  257. $objectlabel = 'Project';
  258. $permissiontoread = $user->rights->projet->lire;
  259. $permissiontodelete = $user->rights->projet->supprimer;
  260. $permissiontoadd = $user->rights->projet->creer;
  261. $uploaddir = $conf->projet->dir_output;
  262. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  263. // Close records
  264. if (!$error && $massaction == 'close' && $user->rights->projet->creer) {
  265. $db->begin();
  266. $objecttmp = new $objectclass($db);
  267. $nbok = 0;
  268. foreach ($toselect as $toselectid) {
  269. $result = $objecttmp->fetch($toselectid);
  270. if ($result > 0) {
  271. $userWrite = $object->restrictedProjectArea($user, 'write');
  272. if ($userWrite > 0 && $objecttmp->statut == 1) {
  273. $result = $objecttmp->setClose($user);
  274. if ($result <= 0) {
  275. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  276. $error++;
  277. break;
  278. } else {
  279. $nbok++;
  280. }
  281. } elseif ($userWrite <= 0) {
  282. setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings');
  283. } else {
  284. setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings');
  285. }
  286. } else {
  287. setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
  288. $error++;
  289. break;
  290. }
  291. }
  292. if (!$error) {
  293. if ($nbok > 1) {
  294. setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
  295. } else {
  296. setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
  297. }
  298. $db->commit();
  299. } else {
  300. $db->rollback();
  301. }
  302. }
  303. }
  304. /*
  305. * View
  306. */
  307. $companystatic = new Societe($db);
  308. $form = new Form($db);
  309. $formother = new FormOther($db);
  310. $formproject = new FormProjets($db);
  311. $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  312. $title = $langs->trans("Projects");
  313. // Get list of project id allowed to user (in a string list separated by comma)
  314. $projectsListId = '';
  315. if (empty($user->rights->projet->all->lire)) {
  316. $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $socid);
  317. }
  318. // Get id of types of contacts for projects (This list never contains a lot of elements)
  319. $listofprojectcontacttype = array();
  320. $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
  321. $sql .= " WHERE ctc.element = '".$db->escape($object->element)."'";
  322. $sql .= " AND ctc.source = 'internal'";
  323. $resql = $db->query($sql);
  324. if ($resql) {
  325. while ($obj = $db->fetch_object($resql)) {
  326. $listofprojectcontacttype[$obj->rowid] = $obj->code;
  327. }
  328. } else {
  329. dol_print_error($db);
  330. }
  331. if (count($listofprojectcontacttype) == 0) {
  332. $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found
  333. }
  334. $distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once.
  335. $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,";
  336. $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,";
  337. $sql .= " p.usage_opportunity, p.usage_task, p.usage_bill_time, p.usage_organize_event,";
  338. $sql .= " p.email_msgid,";
  339. $sql .= " accept_conference_suggestions, accept_booth_suggestions, price_registration, price_booth,";
  340. $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,";
  341. $sql .= " country.code as country_code,";
  342. $sql .= " cls.code as opp_status_code";
  343. // Add fields from extrafields
  344. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  345. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  346. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  347. }
  348. }
  349. // Add fields from hooks
  350. $parameters = array();
  351. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
  352. $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
  353. $sql = preg_replace('/,\s*$/', '', $sql);
  354. $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as p";
  355. if (!empty($conf->categorie->enabled)) {
  356. $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_PROJECT, "p.rowid");
  357. }
  358. if (!empty($extrafields->attributes[$object->table_element]['label']) &&is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  359. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
  360. }
  361. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
  362. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
  363. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid";
  364. // We'll need this table joined to the select in order to filter by sale
  365. // No check is done on company permission because readability is managed by public status of project and assignement.
  366. //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";
  367. if ($search_sale > 0) {
  368. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
  369. }
  370. if ($search_project_user > 0) {
  371. $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp";
  372. }
  373. $sql .= " WHERE p.entity IN (".getEntity('project').')';
  374. if (!empty($conf->categorie->enabled)) {
  375. $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_PROJECT, "p.rowid", $search_category_array);
  376. }
  377. if (empty($user->rights->projet->all->lire)) {
  378. $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId).")"; // public and assigned to, or restricted to company for external users
  379. }
  380. // No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser
  381. if ($socid > 0) {
  382. $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)
  383. }
  384. if ($search_ref) {
  385. $sql .= natural_search('p.ref', $search_ref);
  386. }
  387. if ($search_label) {
  388. $sql .= natural_search('p.title', $search_label);
  389. }
  390. if ($search_societe) {
  391. $sql .= natural_search('s.nom', $search_societe);
  392. }
  393. if ($search_opp_amount) {
  394. $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
  395. }
  396. if ($search_opp_percent) {
  397. $sql .= natural_search('p.opp_percent', $search_opp_percent, 1);
  398. }
  399. $sql .= dolSqlDateFilter('p.dateo', $search_sday, $search_smonth, $search_syear);
  400. $sql .= dolSqlDateFilter('p.datee', $search_eday, $search_emonth, $search_eyear);
  401. if ($search_date_start_start) {
  402. $sql .= " AND p.dateo >= '".$db->idate($search_date_start_start)."'";
  403. }
  404. if ($search_date_start_end) {
  405. $sql .= " AND p.dateo <= '".$db->idate($search_date_start_end)."'";
  406. }
  407. if ($search_date_end_start) {
  408. $sql .= " AND p.datee >= '".$db->idate($search_date_end_start)."'";
  409. }
  410. if ($search_date_end_end) {
  411. $sql .= " AND p.datee <= '".$db->idate($search_date_end_end)."'";
  412. }
  413. if ($search_all) {
  414. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  415. }
  416. if ($search_status >= 0) {
  417. if ($search_status == 99) {
  418. $sql .= " AND p.fk_statut <> 2";
  419. } else {
  420. $sql .= " AND p.fk_statut = ".((int) $search_status);
  421. }
  422. }
  423. if ($search_opp_status) {
  424. if (is_numeric($search_opp_status) && $search_opp_status > 0) {
  425. $sql .= " AND p.fk_opp_status = ".((int) $search_opp_status);
  426. }
  427. if ($search_opp_status == 'all') {
  428. $sql .= " AND (p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1)";
  429. }
  430. if ($search_opp_status == 'openedopp') {
  431. $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'))";
  432. }
  433. if ($search_opp_status == 'notopenedopp') {
  434. $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'))";
  435. }
  436. if ($search_opp_status == 'none') {
  437. $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1)";
  438. }
  439. }
  440. if ($search_public != '') {
  441. $sql .= " AND p.public = ".((int) $search_public);
  442. }
  443. // For external user, no check is done on company permission because readability is managed by public status of project and assignement.
  444. //if ($socid > 0) $sql.= " AND s.rowid = ".((int) $socid);
  445. if ($search_sale > 0) {
  446. $sql .= " AND sc.fk_user = ".((int) $search_sale);
  447. }
  448. // No check is done on company permission because readability is managed by public status of project and assignement.
  449. //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))";
  450. if ($search_project_user > 0) {
  451. $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);
  452. }
  453. if ($search_opp_amount != '') {
  454. $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
  455. }
  456. if ($search_budget_amount != '') {
  457. $sql .= natural_search('p.budget_amount', $search_budget_amount, 1);
  458. }
  459. if ($search_usage_opportunity != '' && $search_usage_opportunity >= 0) {
  460. $sql .= natural_search('p.usage_opportunity', $search_usage_opportunity, 2);
  461. }
  462. if ($search_usage_task != '' && $search_usage_task >= 0) {
  463. $sql .= natural_search('p.usage_task', $search_usage_task, 2);
  464. }
  465. if ($search_usage_bill_time != '' && $search_usage_bill_time >= 0) {
  466. $sql .= natural_search('p.usage_bill_time', $search_usage_bill_time, 2);
  467. }
  468. if ($search_usage_event_organization != '' && $search_usage_event_organization >= 0) {
  469. $sql .= natural_search('p.usage_organize_event', $search_usage_event_organization, 2);
  470. }
  471. if ($search_accept_conference_suggestions != '' && $search_accept_conference_suggestions >= 0) {
  472. $sql .= natural_search('p.accept_conference_suggestions', $search_accept_conference_suggestions, 2);
  473. }
  474. if ($search_accept_booth_suggestions != '' && $search_accept_booth_suggestions >= 0) {
  475. $sql .= natural_search('p.accept_booth_suggestions', $search_accept_booth_suggestions, 2);
  476. }
  477. if ($search_price_registration != '') {
  478. $sql .= natural_search('p.price_registration', $search_price_registration, 1);
  479. }
  480. if ($search_price_booth != '') {
  481. $sql .= natural_search('p.price_booth', $search_price_booth, 1);
  482. }
  483. // Add where from extra fields
  484. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  485. // Add where from hooks
  486. $parameters = array();
  487. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
  488. $sql .= $hookmanager->resPrint;
  489. $sql .= $db->order($sortfield, $sortorder);
  490. // Count total nb of records
  491. $nbtotalofrecords = '';
  492. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  493. $resql = $db->query($sql);
  494. $nbtotalofrecords = $db->num_rows($resql);
  495. if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
  496. $page = 0;
  497. $offset = 0;
  498. }
  499. }
  500. // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
  501. if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
  502. $num = $nbtotalofrecords;
  503. } else {
  504. if (!empty($limit)) {
  505. $sql .= $db->plimit($limit + 1, $offset);
  506. }
  507. $resql = $db->query($sql);
  508. if (!$resql) {
  509. dol_print_error($db);
  510. exit;
  511. }
  512. $num = $db->num_rows($resql);
  513. }
  514. // Direct jump if only one record found
  515. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
  516. $obj = $db->fetch_object($resql);
  517. header("Location: ".DOL_URL_ROOT.'/projet/card.php?id='.$obj->id);
  518. exit;
  519. }
  520. // Output page
  521. // --------------------------------------------------------------------
  522. dol_syslog("list allowed project", LOG_DEBUG);
  523. llxHeader('', $title, $help_url);
  524. $arrayofselected = is_array($toselect) ? $toselect : array();
  525. $param = '';
  526. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  527. $param .= '&contextpage='.urlencode($contextpage);
  528. }
  529. if ($limit > 0 && $limit != $conf->liste_limit) {
  530. $param .= '&limit='.urlencode($limit);
  531. }
  532. if ($search_all != '') {
  533. $param .= '&search_all='.urlencode($search_all);
  534. }
  535. if ($search_sday) {
  536. $param .= '&search_sday='.urlencode($search_sday);
  537. }
  538. if ($search_smonth) {
  539. $param .= '&search_smonth='.urlencode($search_smonth);
  540. }
  541. if ($search_syear) {
  542. $param .= '&search_syear='.urlencode($search_syear);
  543. }
  544. if ($search_eday) {
  545. $param .= '&search_eday='.urlencode($search_eday);
  546. }
  547. if ($search_emonth) {
  548. $param .= '&search_emonth='.urlencode($search_emonth);
  549. }
  550. if ($search_eyear) {
  551. $param .= '&search_eyear='.urlencode($search_eyear);
  552. }
  553. if ($search_date_start_startmonth) {
  554. $param .= '&search_date_start_startmonth='.urlencode($search_date_start_startmonth);
  555. }
  556. if ($search_date_start_startyear) {
  557. $param .= '&search_date_start_startyear='.urlencode($search_date_start_startyear);
  558. }
  559. if ($search_date_start_startday) {
  560. $param .= '&search_date_start_startday='.urlencode($search_date_start_startday);
  561. }
  562. if ($search_date_start_start) {
  563. $param .= '&search_date_start_start='.urlencode($search_date_start_start);
  564. }
  565. if ($search_date_start_endmonth) {
  566. $param .= '&search_date_start_endmonth='.urlencode($search_date_start_endmonth);
  567. }
  568. if ($search_date_start_endyear) {
  569. $param .= '&search_date_start_endyear='.urlencode($search_date_start_endyear);
  570. }
  571. if ($search_date_start_endday) {
  572. $param .= '&search_date_start_endday='.urlencode($search_date_start_endday);
  573. }
  574. if ($search_date_start_end) {
  575. $param .= '&search_date_start_end='.urlencode($search_date_start_end);
  576. }
  577. if ($search_date_end_startmonth) {
  578. $param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth);
  579. }
  580. if ($search_date_end_startyear) {
  581. $param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear);
  582. }
  583. if ($search_date_end_startday) {
  584. $param .= '&search_date_end_startday='.urlencode($search_date_end_startday);
  585. }
  586. if ($search_date_end_start) {
  587. $param .= '&search_date_end_start='.urlencode($search_date_end_start);
  588. }
  589. if ($search_date_end_endmonth) {
  590. $param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth);
  591. }
  592. if ($search_date_end_endyear) {
  593. $param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear);
  594. }
  595. if ($search_date_end_endday) {
  596. $param .= '&search_date_end_endday='.urlencode($search_date_end_endday);
  597. }
  598. if ($search_date_end_end) {
  599. $param .= '&search_date_end_end=' . urlencode($search_date_end_end);
  600. }
  601. if ($socid) {
  602. $param .= '&socid='.urlencode($socid);
  603. }
  604. if (!empty($search_categ)) {
  605. $param .= '&search_categ='.urlencode($search_categ);
  606. }
  607. if ($search_ref != '') {
  608. $param .= '&search_ref='.urlencode($search_ref);
  609. }
  610. if ($search_label != '') {
  611. $param .= '&search_label='.urlencode($search_label);
  612. }
  613. if ($search_societe != '') {
  614. $param .= '&search_societe='.urlencode($search_societe);
  615. }
  616. if ($search_status >= 0) {
  617. $param .= '&search_status='.urlencode($search_status);
  618. }
  619. if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'openedopp', 'notopenedopp', 'none'))) {
  620. $param .= '&search_opp_status='.urlencode($search_opp_status);
  621. }
  622. if ($search_opp_percent != '') {
  623. $param .= '&search_opp_percent='.urlencode($search_opp_percent);
  624. }
  625. if ($search_public != '') {
  626. $param .= '&search_public='.urlencode($search_public);
  627. }
  628. if ($search_project_user != '') {
  629. $param .= '&search_project_user='.urlencode($search_project_user);
  630. }
  631. if ($search_sale > 0) {
  632. $param .= '&search_sale='.urlencode($search_sale);
  633. }
  634. if ($search_opp_amount != '') {
  635. $param .= '&search_opp_amount='.urlencode($search_opp_amount);
  636. }
  637. if ($search_budget_amount != '') {
  638. $param .= '&search_budget_amount='.urlencode($search_budget_amount);
  639. }
  640. if ($search_usage_task != '') {
  641. $param .= '&search_usage_task='.urlencode($search_usage_task);
  642. }
  643. if ($search_usage_bill_time != '') {
  644. $param .= '&search_usage_opportunity='.urlencode($search_usage_bill_time);
  645. }
  646. if ($search_usage_event_organization != '') {
  647. $param .= '&search_usage_event_organization='.urlencode($search_usage_event_organization);
  648. }
  649. if ($search_accept_conference_suggestions != '') {
  650. $param .= '&search_accept_conference_suggestions='.urlencode($search_accept_conference_suggestions);
  651. }
  652. if ($search_accept_booth_suggestions != '') {
  653. $param .= '&search_accept_booth_suggestions='.urlencode($search_accept_booth_suggestions);
  654. }
  655. if ($search_price_registration != '') {
  656. $param .= '&search_price_registration='.urlencode($search_price_registration);
  657. }
  658. if ($search_price_booth != '') {
  659. $param .= '&search_price_booth='.urlencode($search_price_booth);
  660. }
  661. if ($optioncss != '') {
  662. $param .= '&optioncss='.urlencode($optioncss);
  663. }
  664. // Add $param from extra fields
  665. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  666. // List of mass actions available
  667. $arrayofmassactions = array(
  668. 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  669. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  670. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  671. );
  672. //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
  673. if ($user->rights->projet->creer) {
  674. $arrayofmassactions['close'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Close");
  675. }
  676. if ($user->rights->projet->supprimer) {
  677. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  678. }
  679. if ($user->rights->projet->creer) {
  680. $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
  681. }
  682. if (in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
  683. $arrayofmassactions = array();
  684. }
  685. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  686. $url = DOL_URL_ROOT.'/projet/card.php?action=create';
  687. if (!empty($socid)) {
  688. $url .= '&socid='.$socid;
  689. }
  690. $newcardbutton = dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->rights->projet->creer);
  691. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  692. if ($optioncss != '') {
  693. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  694. }
  695. print '<input type="hidden" name="token" value="'.newToken().'">';
  696. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  697. print '<input type="hidden" name="action" value="list">';
  698. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  699. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  700. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  701. // Show description of content
  702. $texthelp = '';
  703. if ($search_project_user == $user->id) {
  704. $texthelp .= $langs->trans("MyProjectsDesc");
  705. } else {
  706. if ($user->rights->projet->all->lire && !$socid) {
  707. $texthelp .= $langs->trans("ProjectsDesc");
  708. } else {
  709. $texthelp .= $langs->trans("ProjectsPublicDesc");
  710. }
  711. }
  712. print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit, 0, 0, 1);
  713. $topicmail = "Information";
  714. $modelmail = "project";
  715. $objecttmp = new Project($db);
  716. $trackid = 'proj'.$object->id;
  717. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  718. if ($search_all) {
  719. foreach ($fieldstosearchall as $key => $val) {
  720. $fieldstosearchall[$key] = $langs->trans($val);
  721. }
  722. print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
  723. }
  724. $moreforfilter = '';
  725. // If the user can view user other than himself
  726. $moreforfilter .= '<div class="divsearchfield">';
  727. $tmptitle = $langs->trans('ProjectsWithThisUserAsContact');
  728. //$includeonly = 'hierarchyme';
  729. $includeonly = '';
  730. if (empty($user->rights->user->user->lire)) {
  731. $includeonly = array($user->id);
  732. }
  733. $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');
  734. $moreforfilter .= '</div>';
  735. // If the user can view thirdparties other than his'
  736. if ($user->rights->societe->client->voir || $socid) {
  737. $langs->load("commercial");
  738. $moreforfilter .= '<div class="divsearchfield">';
  739. $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative');
  740. $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250');
  741. $moreforfilter .= '</div>';
  742. }
  743. // Filter on categories
  744. if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
  745. $formcategory = new FormCategory($db);
  746. $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array);
  747. }
  748. if (!empty($moreforfilter)) {
  749. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  750. print $moreforfilter;
  751. $parameters = array();
  752. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  753. print $hookmanager->resPrint;
  754. print '</div>';
  755. }
  756. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  757. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  758. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  759. print '<div class="div-table-responsive">';
  760. print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  761. // Fields title search
  762. // --------------------------------------------------------------------
  763. print '<tr class="liste_titre_filter">';
  764. // Project ref
  765. if (!empty($arrayfields['p.ref']['checked'])) {
  766. print '<td class="liste_titre">';
  767. print '<input type="text" class="flat" name="search_ref" value="'.dol_escape_htmltag($search_ref).'" size="6">';
  768. print '</td>';
  769. }
  770. // Project label
  771. if (!empty($arrayfields['p.title']['checked'])) {
  772. print '<td class="liste_titre">';
  773. print '<input type="text" class="flat" name="search_label" size="8" value="'.dol_escape_htmltag($search_label).'">';
  774. print '</td>';
  775. }
  776. // Third party
  777. if (!empty($arrayfields['s.nom']['checked'])) {
  778. print '<td class="liste_titre">';
  779. if ($socid > 0) {
  780. $tmpthirdparty = new Societe($db);
  781. $tmpthirdparty->fetch($socid);
  782. $search_societe = $tmpthirdparty->name;
  783. }
  784. print '<input type="text" class="flat" name="search_societe" size="8" value="'.dol_escape_htmltag($search_societe).'">';
  785. print '</td>';
  786. }
  787. // Sale representative
  788. if (!empty($arrayfields['commercial']['checked'])) {
  789. print '<td class="liste_titre">&nbsp;</td>';
  790. }
  791. // Start date
  792. if (!empty($arrayfields['p.dateo']['checked'])) {
  793. print '<td class="liste_titre center nowraponall">';
  794. /*if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
  795. print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_sday" value="'.dol_escape_htmltag($search_sday).'">';
  796. }
  797. print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_smonth" value="'.dol_escape_htmltag($search_smonth).'">';
  798. $formother->select_year($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');*/
  799. print '<div class="nowrap">';
  800. 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'));
  801. print '</div>';
  802. print '<div class="nowrap">';
  803. 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'));
  804. print '</div>';
  805. print '</td>';
  806. }
  807. // End date
  808. if (!empty($arrayfields['p.datee']['checked'])) {
  809. print '<td class="liste_titre center nowraponall">';
  810. /*if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
  811. print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_eday" value="'.dol_escape_htmltag($search_eday).'">';
  812. }
  813. print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_emonth" value="'.dol_escape_htmltag($search_emonth).'">';
  814. $formother->select_year($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');*/
  815. print '<div class="nowrap">';
  816. 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'));
  817. print '</div>';
  818. print '<div class="nowrap">';
  819. 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'));
  820. print '</div>';
  821. print '</td>';
  822. }
  823. if (!empty($arrayfields['p.public']['checked'])) {
  824. print '<td class="liste_titre">';
  825. $array = array(''=>'', 0 => $langs->trans("PrivateProject"), 1 => $langs->trans("SharedProject"));
  826. print $form->selectarray('search_public', $array, $search_public);
  827. print '</td>';
  828. }
  829. // Opp status
  830. if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
  831. print '<td class="liste_titre nowrap center">';
  832. print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth100');
  833. print '</td>';
  834. }
  835. if (!empty($arrayfields['p.opp_amount']['checked'])) {
  836. print '<td class="liste_titre nowrap right">';
  837. print '<input type="text" class="flat" name="search_opp_amount" size="3" value="'.$search_opp_amount.'">';
  838. print '</td>';
  839. }
  840. if (!empty($arrayfields['p.opp_percent']['checked'])) {
  841. print '<td class="liste_titre nowrap right">';
  842. print '<input type="text" class="flat" name="search_opp_percent" size="2" value="'.$search_opp_percent.'">';
  843. print '</td>';
  844. }
  845. if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
  846. print '<td class="liste_titre nowrap right">';
  847. print '</td>';
  848. }
  849. if (!empty($arrayfields['p.budget_amount']['checked'])) {
  850. print '<td class="liste_titre nowrap right">';
  851. print '<input type="text" class="flat" name="search_budget_amount" size="4" value="'.$search_budget_amount.'">';
  852. print '</td>';
  853. }
  854. if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
  855. print '<td class="liste_titre nowrap right">';
  856. print $form->selectyesno('search_usage_opportunity', $search_usage_opportunity, 1, false, 1);
  857. print '';
  858. print '</td>';
  859. }
  860. if (!empty($arrayfields['p.usage_task']['checked'])) {
  861. print '<td class="liste_titre nowrap right">';
  862. print $form->selectyesno('search_usage_task', $search_usage_task, 1, false, 1);
  863. print '</td>';
  864. }
  865. if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
  866. print '<td class="liste_titre nowrap right">';
  867. print $form->selectyesno('search_usage_bill_time', $search_usage_bill_time, 1, false, 1);
  868. print '</td>';
  869. }
  870. if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
  871. print '<td class="liste_titre nowrap right">';
  872. print $form->selectyesno('search_usage_event_organization', $search_usage_event_organization, 1, false, 1);
  873. print '</td>';
  874. }
  875. if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
  876. print '<td class="liste_titre nowrap right">';
  877. print $form->selectyesno('search_accept_conference_suggestions', $search_accept_conference_suggestions, 1, false, 1);
  878. print '</td>';
  879. }
  880. if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
  881. print '<td class="liste_titre nowrap right">';
  882. print $form->selectyesno('search_accept_booth_suggestions', $search_accept_booth_suggestions, 1, false, 1);
  883. print '</td>';
  884. }
  885. if (!empty($arrayfields['p.price_registration']['checked'])) {
  886. print '<td class="liste_titre nowrap right">';
  887. print '<input type="text" class="flat" name="search_price_registration" size="4" value="'.$search_price_registration.'">';
  888. print '</td>';
  889. }
  890. if (!empty($arrayfields['p.price_booth']['checked'])) {
  891. print '<td class="liste_titre nowrap right">';
  892. print '<input type="text" class="flat" name="search_price_booth" size="4" value="'.$search_price_booth.'">';
  893. print '</td>';
  894. }
  895. // Extra fields
  896. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  897. // Fields from hook
  898. $parameters = array('arrayfields'=>$arrayfields);
  899. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  900. print $hookmanager->resPrint;
  901. if (!empty($arrayfields['p.datec']['checked'])) {
  902. // Date creation
  903. print '<td class="liste_titre">';
  904. print '</td>';
  905. }
  906. if (!empty($arrayfields['p.tms']['checked'])) {
  907. // Date modification
  908. print '<td class="liste_titre">';
  909. print '</td>';
  910. }
  911. if (!empty($arrayfields['p.email_msgid']['checked'])) {
  912. // Email msg id
  913. print '<td class="liste_titre">';
  914. print '</td>';
  915. }
  916. if (!empty($arrayfields['p.fk_statut']['checked'])) {
  917. print '<td class="liste_titre nowrap right">';
  918. $arrayofstatus = array();
  919. foreach ($object->statuts_short as $key => $val) {
  920. $arrayofstatus[$key] = $langs->trans($val);
  921. }
  922. $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')';
  923. print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'minwidth75imp maxwidth150 selectarrowonleft');
  924. print ajax_combobox('search_status');
  925. print '</td>';
  926. }
  927. // Action column
  928. print '<td class="liste_titre maxwidthsearch">';
  929. $searchpicto = $form->showFilterButtons();
  930. print $searchpicto;
  931. print '</td>';
  932. print '</tr>'."\n";
  933. print '<tr class="liste_titre">';
  934. if (!empty($arrayfields['p.ref']['checked'])) {
  935. print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder);
  936. }
  937. if (!empty($arrayfields['p.title']['checked'])) {
  938. print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder);
  939. }
  940. if (!empty($arrayfields['s.nom']['checked'])) {
  941. print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
  942. }
  943. if (!empty($arrayfields['commercial']['checked'])) {
  944. print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder, 'tdoverflowmax100imp ');
  945. }
  946. if (!empty($arrayfields['p.dateo']['checked'])) {
  947. print_liste_field_titre($arrayfields['p.dateo']['label'], $_SERVER["PHP_SELF"], "p.dateo", "", $param, '', $sortfield, $sortorder, 'center ');
  948. }
  949. if (!empty($arrayfields['p.datee']['checked'])) {
  950. print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center ');
  951. }
  952. if (!empty($arrayfields['p.public']['checked'])) {
  953. print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder);
  954. }
  955. if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
  956. print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center ');
  957. }
  958. if (!empty($arrayfields['p.opp_amount']['checked'])) {
  959. print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right ');
  960. }
  961. if (!empty($arrayfields['p.opp_percent']['checked'])) {
  962. print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER['PHP_SELF'], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right ');
  963. }
  964. if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
  965. print_liste_field_titre($arrayfields['opp_weighted_amount']['label'], $_SERVER['PHP_SELF'], 'opp_weighted_amount', '', $param, '', $sortfield, $sortorder, 'right ');
  966. }
  967. if (!empty($arrayfields['p.budget_amount']['checked'])) {
  968. print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right ');
  969. }
  970. if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
  971. print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right ');
  972. }
  973. if (!empty($arrayfields['p.usage_task']['checked'])) {
  974. print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right ');
  975. }
  976. if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
  977. print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right ');
  978. }
  979. if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
  980. print_liste_field_titre($arrayfields['p.usage_organize_event']['label'], $_SERVER["PHP_SELF"], 'p.usage_organize_event', "", $param, '', $sortfield, $sortorder, 'right ');
  981. }
  982. if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
  983. print_liste_field_titre($arrayfields['p.accept_conference_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_conference_suggestions', "", $param, '', $sortfield, $sortorder, 'right ');
  984. }
  985. if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
  986. print_liste_field_titre($arrayfields['p.accept_booth_suggestions']['label'], $_SERVER["PHP_SELF"], 'p.accept_booth_suggestions', "", $param, '', $sortfield, $sortorder, 'right ');
  987. }
  988. if (!empty($arrayfields['p.price_registration']['checked'])) {
  989. print_liste_field_titre($arrayfields['p.price_registration']['label'], $_SERVER["PHP_SELF"], 'p.price_registration', "", $param, '', $sortfield, $sortorder, 'right ');
  990. }
  991. if (!empty($arrayfields['p.price_booth']['checked'])) {
  992. print_liste_field_titre($arrayfields['p.price_booth']['label'], $_SERVER["PHP_SELF"], 'p.price_booth', "", $param, '', $sortfield, $sortorder, 'right ');
  993. }
  994. // Extra fields
  995. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  996. // Hook fields
  997. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  998. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  999. print $hookmanager->resPrint;
  1000. if (!empty($arrayfields['p.datec']['checked'])) {
  1001. print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  1002. }
  1003. if (!empty($arrayfields['p.tms']['checked'])) {
  1004. print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
  1005. }
  1006. if (!empty($arrayfields['p.email_msgid']['checked'])) {
  1007. print_liste_field_titre($arrayfields['p.email_msgid']['label'], $_SERVER["PHP_SELF"], "p.email_msgid", "", $param, '', $sortfield, $sortorder, 'center ');
  1008. }
  1009. if (!empty($arrayfields['p.fk_statut']['checked'])) {
  1010. print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
  1011. }
  1012. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  1013. print "</tr>\n";
  1014. $i = 0;
  1015. $totalarray = array(
  1016. 'nbfield' => 0,
  1017. 'val' => array(),
  1018. );
  1019. while ($i < min($num, $limit)) {
  1020. $obj = $db->fetch_object($resql);
  1021. $object->id = $obj->id;
  1022. $object->user_author_id = $obj->fk_user_creat;
  1023. $object->public = $obj->public;
  1024. $object->ref = $obj->ref;
  1025. $object->datee = $db->jdate($obj->date_end);
  1026. $object->statut = $obj->status; // deprecated
  1027. $object->status = $obj->status;
  1028. $object->public = $obj->public;
  1029. $object->opp_status = $obj->fk_opp_status;
  1030. $object->title = $obj->title;
  1031. $userAccess = $object->restrictedProjectArea($user); // why this ?
  1032. if ($userAccess >= 0) {
  1033. $companystatic->id = $obj->socid;
  1034. $companystatic->name = $obj->name;
  1035. $companystatic->name_alias = $obj->alias;
  1036. $companystatic->client = $obj->client;
  1037. $companystatic->code_client = $obj->code_client;
  1038. $companystatic->email = $obj->email;
  1039. $companystatic->phone = $obj->phone;
  1040. $companystatic->address = $obj->address;
  1041. $companystatic->zip = $obj->zip;
  1042. $companystatic->town = $obj->town;
  1043. $companystatic->country_code = $obj->country_code;
  1044. print '<tr class="oddeven">';
  1045. // Project url
  1046. if (!empty($arrayfields['p.ref']['checked'])) {
  1047. print '<td class="nowraponall">';
  1048. print $object->getNomUrl(1, (!empty(GETPOST('search_usage_event_organization', 'int'))?'eventorganization':''));
  1049. if ($object->hasDelay()) {
  1050. print img_warning($langs->trans('Late'));
  1051. }
  1052. print '</td>';
  1053. if (!$i) {
  1054. $totalarray['nbfield']++;
  1055. }
  1056. }
  1057. // Title
  1058. if (!empty($arrayfields['p.title']['checked'])) {
  1059. print '<td class="tdoverflowmax200">';
  1060. print dol_trunc($obj->title, 80);
  1061. print '</td>';
  1062. if (!$i) {
  1063. $totalarray['nbfield']++;
  1064. }
  1065. }
  1066. // Company
  1067. if (!empty($arrayfields['s.nom']['checked'])) {
  1068. print '<td class="tdoverflowmax100">';
  1069. if ($obj->socid) {
  1070. print $companystatic->getNomUrl(1);
  1071. } else {
  1072. print '&nbsp;';
  1073. }
  1074. print '</td>';
  1075. if (!$i) {
  1076. $totalarray['nbfield']++;
  1077. }
  1078. }
  1079. // Sales Representatives
  1080. if (!empty($arrayfields['commercial']['checked'])) {
  1081. print '<td>';
  1082. if ($obj->socid) {
  1083. $companystatic->id = $obj->socid;
  1084. $companystatic->name = $obj->name;
  1085. $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
  1086. $nbofsalesrepresentative = count($listsalesrepresentatives);
  1087. if ($nbofsalesrepresentative > 6) {
  1088. // We print only number
  1089. print $nbofsalesrepresentative;
  1090. } elseif ($nbofsalesrepresentative > 0) {
  1091. $userstatic = new User($db);
  1092. $j = 0;
  1093. foreach ($listsalesrepresentatives as $val) {
  1094. $userstatic->id = $val['id'];
  1095. $userstatic->lastname = $val['lastname'];
  1096. $userstatic->firstname = $val['firstname'];
  1097. $userstatic->email = $val['email'];
  1098. $userstatic->statut = $val['statut'];
  1099. $userstatic->entity = $val['entity'];
  1100. $userstatic->photo = $val['photo'];
  1101. $userstatic->login = $val['login'];
  1102. $userstatic->office_phone = $val['office_phone'];
  1103. $userstatic->office_fax = $val['office_fax'];
  1104. $userstatic->user_mobile = $val['user_mobile'];
  1105. $userstatic->job = $val['job'];
  1106. $userstatic->gender = $val['gender'];
  1107. print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2);
  1108. $j++;
  1109. if ($j < $nbofsalesrepresentative) {
  1110. print ' ';
  1111. }
  1112. }
  1113. }
  1114. //else print $langs->trans("NoSalesRepresentativeAffected");
  1115. } else {
  1116. print '&nbsp;';
  1117. }
  1118. print '</td>';
  1119. if (!$i) {
  1120. $totalarray['nbfield']++;
  1121. }
  1122. }
  1123. // Date start
  1124. if (!empty($arrayfields['p.dateo']['checked'])) {
  1125. print '<td class="center">';
  1126. print dol_print_date($db->jdate($obj->date_start), 'day');
  1127. print '</td>';
  1128. if (!$i) {
  1129. $totalarray['nbfield']++;
  1130. }
  1131. }
  1132. // Date end
  1133. if (!empty($arrayfields['p.datee']['checked'])) {
  1134. print '<td class="center">';
  1135. print dol_print_date($db->jdate($obj->date_end), 'day');
  1136. print '</td>';
  1137. if (!$i) {
  1138. $totalarray['nbfield']++;
  1139. }
  1140. }
  1141. // Visibility
  1142. if (!empty($arrayfields['p.public']['checked'])) {
  1143. print '<td class="left">';
  1144. if ($obj->public) {
  1145. print $langs->trans('SharedProject');
  1146. } else {
  1147. print $langs->trans('PrivateProject');
  1148. }
  1149. print '</td>';
  1150. if (!$i) {
  1151. $totalarray['nbfield']++;
  1152. }
  1153. }
  1154. // Opp Status
  1155. if (!empty($arrayfields['p.fk_opp_status']['checked'])) {
  1156. print '<td class="center">';
  1157. if ($obj->opp_status_code) {
  1158. print $langs->trans("OppStatus".$obj->opp_status_code);
  1159. }
  1160. print '</td>';
  1161. if (!$i) {
  1162. $totalarray['nbfield']++;
  1163. }
  1164. }
  1165. // Opp Amount
  1166. if (!empty($arrayfields['p.opp_amount']['checked'])) {
  1167. print '<td class="right">';
  1168. //if ($obj->opp_status_code)
  1169. if (strcmp($obj->opp_amount, '')) {
  1170. print '<span class="amount">'.price($obj->opp_amount, 1, $langs, 1, -1, -1, '').'</span>';
  1171. $totalarray['val']['p.opp_amount'] += $obj->opp_amount;
  1172. }
  1173. print '</td>';
  1174. if (!$i) {
  1175. $totalarray['nbfield']++;
  1176. }
  1177. if (!$i) {
  1178. $totalarray['pos'][$totalarray['nbfield']] = 'p.opp_amount';
  1179. }
  1180. }
  1181. // Opp percent
  1182. if (!empty($arrayfields['p.opp_percent']['checked'])) {
  1183. print '<td class="right">';
  1184. if ($obj->opp_percent) {
  1185. print price($obj->opp_percent, 1, $langs, 1, 0).'%';
  1186. }
  1187. print '</td>';
  1188. if (!$i) {
  1189. $totalarray['nbfield']++;
  1190. }
  1191. }
  1192. // Opp weighted amount
  1193. if (!empty($arrayfields['opp_weighted_amount']['checked'])) {
  1194. if (!isset($totalarray['val']['opp_weighted_amount'])) {
  1195. $totalarray['val']['opp_weighted_amount'] = 0;
  1196. }
  1197. print '<td align="right">';
  1198. if ($obj->opp_weighted_amount) {
  1199. print '<span class="amount">'.price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '').'</span>';
  1200. $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount;
  1201. }
  1202. print '</td>';
  1203. if (!$i) {
  1204. $totalarray['nbfield']++;
  1205. }
  1206. if (!$i) {
  1207. $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount';
  1208. }
  1209. }
  1210. // Budget
  1211. if (!empty($arrayfields['p.budget_amount']['checked'])) {
  1212. print '<td class="right">';
  1213. if ($obj->budget_amount != '') {
  1214. print '<span class="amount">'.price($obj->budget_amount, 1, $langs, 1, -1, -1).'</span>';
  1215. $totalarray['val']['p.budget_amount'] += $obj->budget_amount;
  1216. }
  1217. print '</td>';
  1218. if (!$i) {
  1219. $totalarray['nbfield']++;
  1220. }
  1221. if (!$i) {
  1222. $totalarray['pos'][$totalarray['nbfield']] = 'p.budget_amount';
  1223. }
  1224. }
  1225. // Usage opportunity
  1226. if (!empty($arrayfields['p.usage_opportunity']['checked'])) {
  1227. print '<td class="right">';
  1228. if ($obj->usage_opportunity) {
  1229. print yn($obj->usage_opportunity);
  1230. }
  1231. print '</td>';
  1232. if (!$i) {
  1233. $totalarray['nbfield']++;
  1234. }
  1235. }
  1236. // Usage task
  1237. if (!empty($arrayfields['p.usage_task']['checked'])) {
  1238. print '<td class="right">';
  1239. if ($obj->usage_task) {
  1240. print yn($obj->usage_task);
  1241. }
  1242. print '</td>';
  1243. if (!$i) {
  1244. $totalarray['nbfield']++;
  1245. }
  1246. }
  1247. // Bill time
  1248. if (!empty($arrayfields['p.usage_bill_time']['checked'])) {
  1249. print '<td class="right">';
  1250. if ($obj->usage_bill_time) {
  1251. print yn($obj->usage_bill_time);
  1252. }
  1253. print '</td>';
  1254. if (!$i) {
  1255. $totalarray['nbfield']++;
  1256. }
  1257. }
  1258. // Event Organization
  1259. if (!empty($arrayfields['p.usage_organize_event']['checked'])) {
  1260. print '<td class="right">';
  1261. if ($obj->usage_organize_event) {
  1262. print yn($obj->usage_organize_event);
  1263. }
  1264. print '</td>';
  1265. if (!$i) {
  1266. $totalarray['nbfield']++;
  1267. }
  1268. }
  1269. // Allow unknown people to suggest conferences
  1270. if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) {
  1271. print '<td class="right">';
  1272. if ($obj->accept_conference_suggestions) {
  1273. print yn($obj->accept_conference_suggestions);
  1274. }
  1275. print '</td>';
  1276. if (!$i) {
  1277. $totalarray['nbfield']++;
  1278. }
  1279. }
  1280. // Allow unknown people to suggest booth
  1281. if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) {
  1282. print '<td class="right">';
  1283. if ($obj->accept_booth_suggestions) {
  1284. print yn($obj->accept_booth_suggestions);
  1285. }
  1286. print '</td>';
  1287. if (!$i) {
  1288. $totalarray['nbfield']++;
  1289. }
  1290. }
  1291. // Price of registration
  1292. if (!empty($arrayfields['p.price_registration']['checked'])) {
  1293. print '<td class="right">';
  1294. if ($obj->price_registration != '') {
  1295. print '<span class="amount">'.price($obj->price_registration, 1, $langs, 1, -1, -1).'</span>';
  1296. $totalarray['val']['p.price_registration'] += $obj->price_registration;
  1297. }
  1298. print '</td>';
  1299. if (!$i) {
  1300. $totalarray['nbfield']++;
  1301. }
  1302. if (!$i) {
  1303. $totalarray['pos'][$totalarray['nbfield']] = 'p.price_registration';
  1304. }
  1305. }
  1306. // Price of booth
  1307. if (!empty($arrayfields['p.price_booth']['checked'])) {
  1308. print '<td class="right">';
  1309. if ($obj->price_booth != '') {
  1310. print '<span class="amount">'.price($obj->price_booth, 1, $langs, 1, -1, -1).'</span>';
  1311. $totalarray['val']['p.price_booth'] += $obj->price_booth;
  1312. }
  1313. print '</td>';
  1314. if (!$i) {
  1315. $totalarray['nbfield']++;
  1316. }
  1317. if (!$i) {
  1318. $totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth';
  1319. }
  1320. }
  1321. // Extra fields
  1322. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
  1323. // Fields from hook
  1324. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  1325. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  1326. print $hookmanager->resPrint;
  1327. // Date creation
  1328. if (!empty($arrayfields['p.datec']['checked'])) {
  1329. print '<td class="center nowraponall">';
  1330. print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
  1331. print '</td>';
  1332. if (!$i) {
  1333. $totalarray['nbfield']++;
  1334. }
  1335. }
  1336. // Date modification
  1337. if (!empty($arrayfields['p.tms']['checked'])) {
  1338. print '<td class="center nowraponall">';
  1339. print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
  1340. print '</td>';
  1341. if (!$i) {
  1342. $totalarray['nbfield']++;
  1343. }
  1344. }
  1345. // Email MsgID
  1346. if (!empty($arrayfields['p.email_msgid']['checked'])) {
  1347. print '<td class="center">';
  1348. print $obj->email_msgid;
  1349. print '</td>';
  1350. if (!$i) $totalarray['nbfield']++;
  1351. }
  1352. // Status
  1353. if (!empty($arrayfields['p.fk_statut']['checked'])) {
  1354. print '<td class="right">'.$object->getLibStatut(5).'</td>';
  1355. if (!$i) {
  1356. $totalarray['nbfield']++;
  1357. }
  1358. }
  1359. // Action column
  1360. print '<td class="nowrap center">';
  1361. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1362. $selected = 0;
  1363. if (in_array($obj->id, $arrayofselected)) {
  1364. $selected = 1;
  1365. }
  1366. print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
  1367. }
  1368. print '</td>';
  1369. if (!$i) {
  1370. $totalarray['nbfield']++;
  1371. }
  1372. print "</tr>\n";
  1373. }
  1374. $i++;
  1375. }
  1376. // Show total line
  1377. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  1378. $db->free($resql);
  1379. $parameters = array('sql' => $sql);
  1380. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  1381. print $hookmanager->resPrint;
  1382. print "</table>\n";
  1383. print '</div>';
  1384. print "</form>\n";
  1385. // End of page
  1386. llxFooter();
  1387. $db->close();