list.php 61 KB

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