PageRenderTime 46ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 1ms

/htdocs/projet/tasks.php

http://github.com/Dolibarr/dolibarr
PHP | 1083 lines | 816 code | 156 blank | 111 comment | 192 complexity | b187d35fbe9795c4b4973a4fd95595a9 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-3.0, LGPL-2.0, CC-BY-SA-4.0, BSD-3-Clause, MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, LGPL-2.1, MIT
  1. <?php
  2. /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/projet/tasks.php
  21. * \ingroup project
  22. * \brief List all tasks of a project
  23. */
  24. require "../main.inc.php";
  25. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  32. if (!empty($conf->categorie->enabled)) {
  33. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  34. }
  35. // Load translation files required by the page
  36. $langsLoad=array('projects', 'users', 'companies');
  37. if (!empty($conf->eventorganization->enabled)) {
  38. $langsLoad[]='eventorganization';
  39. }
  40. $langs->loadLangs($langsLoad);
  41. $action = GETPOST('action', 'aZ09');
  42. $massaction = GETPOST('massaction', 'alpha');
  43. $show_files = GETPOST('show_files', 'int');
  44. $confirm = GETPOST('confirm', 'alpha');
  45. $toselect = GETPOST('toselect', 'array');
  46. $id = GETPOST('id', 'int');
  47. $ref = GETPOST('ref', 'alpha');
  48. $taskref = GETPOST('taskref', 'alpha');
  49. // Load variable for pagination
  50. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  51. $sortfield = GETPOST('sortfield', 'aZ09comma');
  52. $sortorder = GETPOST('sortorder', 'aZ09comma');
  53. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  54. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  55. $page = 0;
  56. } // If $page is not defined, or '' or -1 or if we click on clear filters
  57. $offset = $limit * $page;
  58. $pageprev = $page - 1;
  59. $pagenext = $page + 1;
  60. $backtopage = GETPOST('backtopage', 'alpha');
  61. $cancel = GETPOST('cancel', 'alpha');
  62. $search_user_id = GETPOST('search_user_id', 'int');
  63. $search_taskref = GETPOST('search_taskref');
  64. $search_tasklabel = GETPOST('search_tasklabel');
  65. $search_taskdescription = GETPOST('search_taskdescription');
  66. $search_dtstartday = GETPOST('search_dtstartday');
  67. $search_dtstartmonth = GETPOST('search_dtstartmonth');
  68. $search_dtstartyear = GETPOST('search_dtstartyear');
  69. $search_dtendday = GETPOST('search_dtendday');
  70. $search_dtendmonth = GETPOST('search_dtendmonth');
  71. $search_dtendyear = GETPOST('search_dtendyear');
  72. $search_planedworkload = GETPOST('search_planedworkload');
  73. $search_timespend = GETPOST('search_timespend');
  74. $search_progresscalc = GETPOST('search_progresscalc');
  75. $search_progressdeclare = GETPOST('search_progressdeclare');
  76. $search_task_budget_amount = GETPOST('search_task_budget_amount');
  77. $search_date_start_startmonth = GETPOST('search_date_start_startmonth', 'int');
  78. $search_date_start_startyear = GETPOST('search_date_start_startyear', 'int');
  79. $search_date_start_startday = GETPOST('search_date_start_startday', 'int');
  80. $search_date_start_start = dol_mktime(0, 0, 0, $search_date_start_startmonth, $search_date_start_startday, $search_date_start_startyear); // Use tzserver
  81. $search_date_start_endmonth = GETPOST('search_date_start_endmonth', 'int');
  82. $search_date_start_endyear = GETPOST('search_date_start_endyear', 'int');
  83. $search_date_start_endday = GETPOST('search_date_start_endday', 'int');
  84. $search_date_start_end = dol_mktime(23, 59, 59, $search_date_start_endmonth, $search_date_start_endday, $search_date_start_endyear); // Use tzserver
  85. $search_date_end_startmonth = GETPOST('search_date_end_startmonth', 'int');
  86. $search_date_end_startyear = GETPOST('search_date_end_startyear', 'int');
  87. $search_date_end_startday = GETPOST('search_date_end_startday', 'int');
  88. $search_date_end_start = dol_mktime(0, 0, 0, $search_date_end_startmonth, $search_date_end_startday, $search_date_end_startyear); // Use tzserver
  89. $search_date_end_endmonth = GETPOST('search_date_end_endmonth', 'int');
  90. $search_date_end_endyear = GETPOST('search_date_end_endyear', 'int');
  91. $search_date_end_endday = GETPOST('search_date_end_endday', 'int');
  92. $search_date_end_end = dol_mktime(23, 59, 59, $search_date_end_endmonth, $search_date_end_endday, $search_date_end_endyear); // Use tzserver
  93. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projecttasklist';
  94. //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
  95. $object = new Project($db);
  96. $taskstatic = new Task($db);
  97. $extrafields = new ExtraFields($db);
  98. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
  99. if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) {
  100. $object->fetchComments();
  101. }
  102. if ($id > 0 || !empty($ref)) {
  103. // fetch optionals attributes and labels
  104. $extrafields->fetch_name_optionals_label($object->table_element);
  105. }
  106. $extrafields->fetch_name_optionals_label($taskstatic->table_element);
  107. $search_array_options = $extrafields->getOptionalsFromPost($taskstatic->table_element, '', 'search_');
  108. // Default sort order (if not yet defined by previous GETPOST)
  109. if (!$sortfield) {
  110. reset($object->fields); $sortfield="t.".key($object->fields);
  111. } // Set here default search field. By default 1st field in definition. Reset is required to avoid key() to return null.
  112. if (!$sortorder) {
  113. $sortorder = "ASC";
  114. }
  115. // Security check
  116. $socid = 0;
  117. //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.
  118. $result = restrictedArea($user, 'projet', $id, 'projet&project');
  119. $diroutputmassaction = $conf->projet->dir_output.'/tasks/temp/massgeneration/'.$user->id;
  120. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  121. $hookmanager->initHooks(array('projecttaskscard', 'globalcard'));
  122. $progress = GETPOST('progress', 'int');
  123. $budget_amount = GETPOST('budget_amount', 'int');
  124. $label = GETPOST('label', 'alpha');
  125. $description = GETPOST('description', 'restricthtml');
  126. $planned_workloadhour = (GETPOST('planned_workloadhour', 'int') ?GETPOST('planned_workloadhour', 'int') : 0);
  127. $planned_workloadmin = (GETPOST('planned_workloadmin', 'int') ?GETPOST('planned_workloadmin', 'int') : 0);
  128. $planned_workload = $planned_workloadhour * 3600 + $planned_workloadmin * 60;
  129. // Definition of fields for list
  130. $arrayfields = array(
  131. 't.ref'=>array('label'=>$langs->trans("RefTask"), 'checked'=>1, 'position'=>1),
  132. 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>2),
  133. 't.description'=>array('label'=>$langs->trans("Description"), 'checked'=>0, 'position'=>3),
  134. 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>4),
  135. 't.datee'=>array('label'=>$langs->trans("Deadline"), 'checked'=>1, 'position'=>5),
  136. 't.planned_workload'=>array('label'=>$langs->trans("PlannedWorkload"), 'checked'=>1, 'position'=>6),
  137. 't.duration_effective'=>array('label'=>$langs->trans("TimeSpent"), 'checked'=>1, 'position'=>7),
  138. 't.progress_calculated'=>array('label'=>$langs->trans("ProgressCalculated"), 'checked'=>1, 'position'=>8),
  139. 't.progress'=>array('label'=>$langs->trans("ProgressDeclared"), 'checked'=>1, 'position'=>9),
  140. 't.progress_summary'=>array('label'=>$langs->trans("TaskProgressSummary"), 'checked'=>1, 'position'=>10),
  141. 't.budget_amount'=>array('label'=>"Budget", 'checked'=>1, 'position'=>11),
  142. 'c.assigned'=>array('label'=>$langs->trans("TaskRessourceLinks"), 'checked'=>1, 'position'=>12),
  143. );
  144. if ($object->usage_bill_time) {
  145. $arrayfields['t.tobill'] = array('label'=>$langs->trans("TimeToBill"), 'checked'=>0, 'position'=>11);
  146. $arrayfields['t.billed'] = array('label'=>$langs->trans("TimeBilled"), 'checked'=>0, 'position'=>12);
  147. }
  148. // Extra fields
  149. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  150. $arrayfields = dol_sort_array($arrayfields, 'position');
  151. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  152. /*
  153. * Actions
  154. */
  155. $parameters = array('id'=>$id);
  156. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  157. if ($reshook < 0) {
  158. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  159. }
  160. if (empty($reshook)) {
  161. // Selection of new fields
  162. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  163. // Purge search criteria
  164. 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
  165. $search_user_id = "";
  166. $search_taskref = '';
  167. $search_tasklabel = '';
  168. $search_dtstartday = '';
  169. $search_dtstartmonth = '';
  170. $search_dtstartyear = '';
  171. $search_dtendday = '';
  172. $search_dtendmonth = '';
  173. $search_dtendyear = '';
  174. $search_planedworkload = '';
  175. $search_timespend = '';
  176. $search_progresscalc = '';
  177. $search_progressdeclare = '';
  178. $search_task_budget_amount = '';
  179. $toselect = '';
  180. $search_array_options = array();
  181. $search_date_start_startmonth = "";
  182. $search_date_start_startyear = "";
  183. $search_date_start_startday = "";
  184. $search_date_start_start = "";
  185. $search_date_start_endmonth = "";
  186. $search_date_start_endyear = "";
  187. $search_date_start_endday = "";
  188. $search_date_start_end = "";
  189. $search_date_end_startmonth = "";
  190. $search_date_end_startyear = "";
  191. $search_date_end_startday = "";
  192. $search_date_end_start = "";
  193. $search_date_end_endmonth = "";
  194. $search_date_end_endyear = "";
  195. $search_date_end_endday = "";
  196. $search_date_end_end = "";
  197. }
  198. // Mass actions
  199. $objectclass = 'Task';
  200. $objectlabel = 'Tasks';
  201. $permissiontoread = $user->rights->projet->lire;
  202. $permissiontodelete = $user->rights->projet->supprimer;
  203. $uploaddir = $conf->projet->dir_output.'/tasks';
  204. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  205. }
  206. $morewherefilterarray = array();
  207. if (!empty($search_taskref)) {
  208. $morewherefilterarray[] = natural_search('t.ref', $search_taskref, 0, 1);
  209. }
  210. if (!empty($search_tasklabel)) {
  211. $morewherefilterarray[] = natural_search('t.label', $search_tasklabel, 0, 1);
  212. }
  213. $moresql = dolSqlDateFilter('t.dateo', $search_dtstartday, $search_dtstartmonth, $search_dtstartyear, 1);
  214. if ($moresql) {
  215. $morewherefilterarray[] = $moresql;
  216. }
  217. $moresql = dolSqlDateFilter('t.datee', $search_dtendday, $search_dtendmonth, $search_dtendyear, 1);
  218. if ($moresql) {
  219. $morewherefilterarray[] = $moresql;
  220. }
  221. if ($search_date_start_start) {
  222. $morewherefilterarray[] = " t.dateo >= '".$db->idate($search_date_start_start)."'";
  223. }
  224. if ($search_date_start_end) {
  225. $morewherefilterarray[] = " t.dateo <= '".$db->idate($search_date_start_end)."'";
  226. }
  227. if ($search_date_end_start) {
  228. $morewherefilterarray[] = " t.datee >= '".$db->idate($search_date_end_start)."'";
  229. }
  230. if ($search_date_end_end) {
  231. $morewherefilterarray[] = " t.datee <= '".$db->idate($search_date_end_end)."'";
  232. }
  233. if (!empty($search_planedworkload)) {
  234. $morewherefilterarray[] = natural_search('t.planned_workload', $search_planedworkload, 1, 1);
  235. }
  236. if (!empty($search_timespend)) {
  237. $morewherefilterarray[] = natural_search('t.duration_effective', $search_timespend, 1, 1);
  238. }
  239. if (!empty($search_progresscalc)) {
  240. $filterprogresscalc = 'if '.natural_search('round(100 * $line->duration / $line->planned_workload,2)', $search_progresscalc, 1, 1).'{return 1;} else {return 0;}';
  241. } else {
  242. $filterprogresscalc = '';
  243. }
  244. if (!empty($search_progressdeclare)) {
  245. $morewherefilterarray[] = natural_search('t.progress', $search_progressdeclare, 1, 1);
  246. }
  247. if ($search_task_budget_amount) {
  248. $morewherefilterarray[]= natural_search('t.budget_amount', $search_task_budget_amount, 1, 1);
  249. }
  250. $morewherefilter = '';
  251. if (count($morewherefilterarray) > 0) {
  252. $morewherefilter = ' AND '.implode(' AND ', $morewherefilterarray);
  253. }
  254. if ($action == 'createtask' && $user->rights->projet->creer) {
  255. $error = 0;
  256. // If we use user timezone, we must change also view/list to use user timezone everywhere
  257. //$date_start = dol_mktime($_POST['dateohour'],$_POST['dateomin'],0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear'],'user');
  258. //$date_end = dol_mktime($_POST['dateehour'],$_POST['dateemin'],0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear'],'user');
  259. $date_start = dol_mktime(GETPOST('dateohour', 'int'), GETPOST('dateomin', 'int'), 0, GETPOST('dateomonth', 'int'), GETPOST('dateoday', 'int'), GETPOST('dateoyear', 'int'));
  260. $date_end = dol_mktime(GETPOST('dateehour', 'int'), GETPOST('dateemin', 'int'), 0, GETPOST('dateemonth', 'int'), GETPOST('dateeday', 'int'), GETPOST('dateeyear', 'int'));
  261. if (!$cancel) {
  262. if (empty($taskref)) {
  263. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
  264. $action = 'create';
  265. $error++;
  266. }
  267. if (empty($label)) {
  268. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
  269. $action = 'create';
  270. $error++;
  271. } elseif (empty($_POST['task_parent'])) {
  272. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ChildOfProjectTask")), null, 'errors');
  273. $action = 'create';
  274. $error++;
  275. }
  276. if (!$error) {
  277. $tmparray = explode('_', GETPOST('task_parent'));
  278. $projectid = $tmparray[0];
  279. if (empty($projectid)) {
  280. $projectid = $id; // If projectid is ''
  281. }
  282. $task_parent = $tmparray[1];
  283. if (empty($task_parent)) {
  284. $task_parent = 0; // If task_parent is ''
  285. }
  286. $task = new Task($db);
  287. $task->fk_project = $projectid;
  288. $task->ref = $taskref;
  289. $task->label = $label;
  290. $task->description = $description;
  291. $task->planned_workload = $planned_workload;
  292. $task->fk_task_parent = $task_parent;
  293. $task->date_c = dol_now();
  294. $task->date_start = $date_start;
  295. $task->date_end = $date_end;
  296. $task->progress = $progress;
  297. $task->budget_amount = $budget_amount;
  298. // Fill array 'array_options' with data from add form
  299. $ret = $extrafields->setOptionalsFromPost(null, $task);
  300. $taskid = $task->create($user);
  301. if ($taskid > 0) {
  302. $result = $task->add_contact(GETPOST("userid", 'int'), 'TASKEXECUTIVE', 'internal');
  303. } else {
  304. if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
  305. $langs->load("projects");
  306. setEventMessages($langs->trans('NewTaskRefSuggested'), '', 'warnings');
  307. $duplicate_code_error = true;
  308. } else {
  309. setEventMessages($task->error, $task->errors, 'errors');
  310. }
  311. $action = 'create';
  312. $error++;
  313. }
  314. }
  315. if (!$error) {
  316. if (!empty($backtopage)) {
  317. header("Location: ".$backtopage);
  318. exit;
  319. } elseif (empty($projectid)) {
  320. header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode));
  321. exit;
  322. }
  323. $id = $projectid;
  324. }
  325. } else {
  326. if (!empty($backtopage)) {
  327. header("Location: ".$backtopage);
  328. exit;
  329. } elseif (empty($id)) {
  330. // We go back on task list
  331. header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode));
  332. exit;
  333. }
  334. }
  335. }
  336. /*
  337. * View
  338. */
  339. $now = dol_now();
  340. $form = new Form($db);
  341. $formother = new FormOther($db);
  342. $socstatic = new Societe($db);
  343. $projectstatic = new Project($db);
  344. $taskstatic = new Task($db);
  345. $userstatic = new User($db);
  346. $title = $langs->trans("Project").' - '.$langs->trans("Tasks").' - '.$object->ref.' '.$object->name;
  347. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  348. $title = $object->ref.' '.$object->name.' - '.$langs->trans("Tasks");
  349. }
  350. $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  351. llxHeader("", $title, $help_url);
  352. if ($id > 0 || !empty($ref)) {
  353. $result = $object->fetch($id, $ref);
  354. if ($result < 0) {
  355. setEventMessages(null, $object->errors, 'errors');
  356. }
  357. $result = $object->fetch_thirdparty();
  358. if ($result < 0) {
  359. setEventMessages(null, $object->errors, 'errors');
  360. }
  361. $result = $object->fetch_optionals();
  362. if ($result < 0) {
  363. setEventMessages(null, $object->errors, 'errors');
  364. }
  365. // To verify role of users
  366. //$userAccess = $object->restrictedProjectArea($user,'read');
  367. $userWrite = $object->restrictedProjectArea($user, 'write');
  368. //$userDelete = $object->restrictedProjectArea($user,'delete');
  369. //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
  370. $tab = (GETPOSTISSET('tab') ? GETPOST('tab') : 'tasks');
  371. $head = project_prepare_head($object);
  372. print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
  373. $param = '&id='.$object->id;
  374. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  375. $param .= '&contextpage='.urlencode($contextpage);
  376. }
  377. if ($search_user_id) {
  378. $param .= '&search_user_id='.urlencode($search_user_id);
  379. }
  380. if ($search_taskref) {
  381. $param .= '&search_taskref='.urlencode($search_taskref);
  382. }
  383. if ($search_tasklabel) {
  384. $param .= '&search_tasklabel='.urlencode($search_tasklabel);
  385. }
  386. if ($search_taskdescription) {
  387. $param .= '&search_taskdescription='.urlencode($search_taskdescription);
  388. }
  389. if ($search_dtstartday) {
  390. $param .= '&search_dtstartday='.urlencode($search_dtstartday);
  391. }
  392. if ($search_dtstartmonth) {
  393. $param .= '&search_dtstartmonth='.urlencode($search_dtstartmonth);
  394. }
  395. if ($search_dtstartyear) {
  396. $param .= '&search_dtstartyear='.urlencode($search_dtstartyear);
  397. }
  398. if ($search_dtendday) {
  399. $param .= '&search_dtendday='.urlencode($search_dtendday);
  400. }
  401. if ($search_dtendmonth) {
  402. $param .= '&search_dtendmonth='.urlencode($search_dtendmonth);
  403. }
  404. if ($search_dtendyear) {
  405. $param .= '&search_dtendyear='.urlencode($search_dtendyear);
  406. }
  407. if ($search_date_start_startmonth) {
  408. $param .= '&search_date_start_startmonth='.urlencode($search_date_start_startmonth);
  409. }
  410. if ($search_date_start_startyear) {
  411. $param .= '&search_date_start_startyear='.urlencode($search_date_start_startyear);
  412. }
  413. if ($search_date_start_startday) {
  414. $param .= '&search_date_start_startday='.urlencode($search_date_start_startday);
  415. }
  416. if ($search_date_start_start) {
  417. $param .= '&search_date_start_start='.urlencode($search_date_start_start);
  418. }
  419. if ($search_date_start_endmonth) {
  420. $param .= '&search_date_start_endmonth='.urlencode($search_date_start_endmonth);
  421. }
  422. if ($search_date_start_endyear) {
  423. $param .= '&search_date_start_endyear='.urlencode($search_date_start_endyear);
  424. }
  425. if ($search_date_start_endday) {
  426. $param .= '&search_date_start_endday='.urlencode($search_date_start_endday);
  427. }
  428. if ($search_date_start_end) {
  429. $param .= '&search_date_start_end='.urlencode($search_date_start_end);
  430. }
  431. if ($search_date_end_startmonth) {
  432. $param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth);
  433. }
  434. if ($search_date_end_startyear) {
  435. $param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear);
  436. }
  437. if ($search_date_end_startday) {
  438. $param .= '&search_date_end_startday='.urlencode($search_date_end_startday);
  439. }
  440. if ($search_date_end_start) {
  441. $param .= '&search_date_end_start='.urlencode($search_date_end_start);
  442. }
  443. if ($search_date_end_endmonth) {
  444. $param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth);
  445. }
  446. if ($search_date_end_endyear) {
  447. $param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear);
  448. }
  449. if ($search_date_end_endday) {
  450. $param .= '&search_date_end_endday='.urlencode($search_date_end_endday);
  451. }
  452. if ($search_date_end_end) {
  453. $param .= '&search_date_end_end=' . urlencode($search_date_end_end);
  454. }
  455. if ($search_planedworkload) {
  456. $param .= '&search_planedworkload='.urlencode($search_planedworkload);
  457. }
  458. if ($search_timespend) {
  459. $param .= '&search_timespend='.urlencode($search_timespend);
  460. }
  461. if ($search_progresscalc) {
  462. $param .= '&search_progresscalc='.urlencode($search_progresscalc);
  463. }
  464. if ($search_progressdeclare) {
  465. $param .= '&search_progressdeclare='.urlencode($search_progressdeclare);
  466. }
  467. if ($search_task_budget_amount) {
  468. $param .= '&search_task_budget_amount='.urlencode($search_task_budget_amount);
  469. }
  470. if ($optioncss != '') {
  471. $param .= '&optioncss='.urlencode($optioncss);
  472. }
  473. // Add $param from extra fields
  474. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  475. // Project card
  476. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  477. $morehtmlref = '<div class="refidno">';
  478. // Title
  479. $morehtmlref .= $object->title;
  480. // Thirdparty
  481. if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
  482. $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
  483. }
  484. $morehtmlref .= '</div>';
  485. // Define a complementary filter for search of next/prev ref.
  486. if (empty($user->rights->projet->all->lire)) {
  487. $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
  488. $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
  489. }
  490. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  491. print '<div class="fichecenter">';
  492. print '<div class="fichehalfleft">';
  493. print '<div class="underbanner clearboth"></div>';
  494. print '<table class="border tableforfield centpercent">';
  495. // Usage
  496. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
  497. print '<tr><td class="tdtop">';
  498. print $langs->trans("Usage");
  499. print '</td>';
  500. print '<td>';
  501. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  502. print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> ';
  503. $htmltext = $langs->trans("ProjectFollowOpportunity");
  504. print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
  505. print '<br>';
  506. }
  507. if (empty($conf->global->PROJECT_HIDE_TASKS)) {
  508. print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> ';
  509. $htmltext = $langs->trans("ProjectFollowTasks");
  510. print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
  511. print '<br>';
  512. }
  513. if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
  514. print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> ';
  515. $htmltext = $langs->trans("ProjectBillTimeDescription");
  516. print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
  517. print '<br>';
  518. }
  519. if (!empty($conf->eventorganization->enabled)) {
  520. print '<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_organize_event ? ' checked="checked"' : '')).'"> ';
  521. $htmltext = $langs->trans("EventOrganizationDescriptionLong");
  522. print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
  523. }
  524. print '</td></tr>';
  525. }
  526. // Visibility
  527. print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
  528. if ($object->public) {
  529. print $langs->trans('SharedProject');
  530. } else {
  531. print $langs->trans('PrivateProject');
  532. }
  533. print '</td></tr>';
  534. // Date start - end
  535. print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
  536. $start = dol_print_date($object->date_start, 'day');
  537. print ($start ? $start : '?');
  538. $end = dol_print_date($object->date_end, 'day');
  539. print ' - ';
  540. print ($end ? $end : '?');
  541. if ($object->hasDelay()) {
  542. print img_warning("Late");
  543. }
  544. print '</td></tr>';
  545. // Budget
  546. print '<tr><td>'.$langs->trans("Budget").'</td><td>';
  547. if (strcmp($object->budget_amount, '')) {
  548. print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
  549. }
  550. print '</td></tr>';
  551. // Other attributes
  552. $cols = 2;
  553. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  554. print '</table>';
  555. print '</div>';
  556. print '<div class="fichehalfright">';
  557. print '<div class="underbanner clearboth"></div>';
  558. print '<table class="border tableforfield centpercent">';
  559. // Description
  560. print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
  561. print nl2br($object->description);
  562. print '</td></tr>';
  563. // Categories
  564. if ($conf->categorie->enabled) {
  565. print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
  566. print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
  567. print "</td></tr>";
  568. }
  569. print '</table>';
  570. print '</div>';
  571. print '</div>';
  572. print '<div class="clearboth"></div>';
  573. print dol_get_fiche_end();
  574. }
  575. if ($action == 'create' && $user->rights->projet->creer && (empty($object->thirdparty->id) || $userWrite > 0)) {
  576. if ($id > 0 || !empty($ref)) {
  577. print '<br>';
  578. }
  579. print load_fiche_titre($langs->trans("NewTask"), '', 'projecttask');
  580. if ($object->id > 0 && $object->statut == Project::STATUS_CLOSED) {
  581. print '<div class="warning">';
  582. $langs->load("errors");
  583. print $langs->trans("WarningProjectClosed");
  584. print '</div>';
  585. }
  586. if ($object->id > 0 && $object->statut == Project::STATUS_DRAFT) {
  587. print '<div class="warning">';
  588. $langs->load("errors");
  589. print $langs->trans("WarningProjectDraft");
  590. print '</div>';
  591. }
  592. print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
  593. print '<input type="hidden" name="token" value="'.newToken().'">';
  594. print '<input type="hidden" name="action" value="createtask">';
  595. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  596. if (!empty($object->id)) {
  597. print '<input type="hidden" name="id" value="'.$object->id.'">';
  598. }
  599. print dol_get_fiche_head('');
  600. print '<table class="border centpercent">';
  601. $defaultref = '';
  602. $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
  603. if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) {
  604. require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php';
  605. $modTask = new $obj;
  606. $defaultref = $modTask->getNextValue($object->thirdparty, null);
  607. }
  608. if (is_numeric($defaultref) && $defaultref <= 0) {
  609. $defaultref = '';
  610. }
  611. // Ref
  612. print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td>';
  613. if (empty($duplicate_code_error)) {
  614. print (GETPOSTISSET("ref") ? GETPOST("ref", 'alpha') : $defaultref);
  615. } else {
  616. print $defaultref;
  617. }
  618. print '<input type="hidden" name="taskref" value="'.(GETPOSTISSET("ref") ? GETPOST("ref", 'alpha') : $defaultref).'">';
  619. print '</td></tr>';
  620. // Label
  621. print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>';
  622. print '<input type="text" name="label" autofocus class="minwidth500 maxwidthonsmartphone" value="'.$label.'">';
  623. print '</td></tr>';
  624. // Project
  625. print '<tr><td class="fieldrequired">'.$langs->trans("ChildOfProjectTask").'</td><td>';
  626. print img_picto('', 'project');
  627. $formother->selectProjectTasks(GETPOST('task_parent'), !empty($projectid) ? $projectid : $object->id, 'task_parent', 0, 0, 1, 1, 0, '0,1', 'maxwidth500');
  628. print '</td></tr>';
  629. // Assigned to
  630. print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>';
  631. $contactsofproject = (!empty($object->id) ? $object->getListContactId('internal') : '');
  632. if (is_array($contactsofproject) && count($contactsofproject)) {
  633. print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300');
  634. } else {
  635. print '<span class="opacitymedium">'.$langs->trans("NoUserAssignedToTheProject").'</span>';
  636. }
  637. print '</td></tr>';
  638. // Date start
  639. print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
  640. print $form->selectDate((!empty($date_start) ? $date_start : ''), 'dateo', 1, 1, 0, '', 1, 1);
  641. print '</td></tr>';
  642. // Date end
  643. print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
  644. print $form->selectDate((!empty($date_end) ? $date_end : -1), 'datee', -1, 1, 0, '', 1, 1);
  645. print '</td></tr>';
  646. // Planned workload
  647. print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>';
  648. print $form->select_duration('planned_workload', !empty($planned_workload) ? $planned_workload : 0, 0, 'text');
  649. print '</td></tr>';
  650. // Progress
  651. print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">';
  652. print $formother->select_percent($progress, 'progress', 0, 5, 0, 100, 1);
  653. print '</td></tr>';
  654. // Description
  655. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
  656. print '<td>';
  657. print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_4.'">'.$description.'</textarea>';
  658. print '</td></tr>';
  659. print '<tr><td>'.$langs->trans("Budget").'</td>';
  660. print '<td><input size="5" type="text" name="budget_amount" value="'.dol_escape_htmltag(GETPOSTISSET('budget_amount') ? GETPOST('budget_amount') : '').'"></td>';
  661. print '</tr>';
  662. // Other options
  663. $parameters = array();
  664. $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook
  665. print $hookmanager->resPrint;
  666. if (empty($reshook) && !empty($extrafields->attributes[$taskstatic->table_element]['label'])) {
  667. print $taskstatic->showOptionals($extrafields, 'edit'); // Do not use $object here that is object of project but use $taskstatic
  668. }
  669. print '</table>';
  670. print dol_get_fiche_end();
  671. print $form->buttonsSaveCancel("Add");
  672. print '</form>';
  673. } elseif ($id > 0 || !empty($ref)) {
  674. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  675. /*
  676. * Projet card in view mode
  677. */
  678. print '<br>';
  679. // Link to create task
  680. $linktocreatetaskParam = array();
  681. $linktocreatetaskUserRight = false;
  682. if ($user->rights->projet->all->creer || $user->rights->projet->creer) {
  683. if ($object->public || $userWrite > 0) {
  684. $linktocreatetaskUserRight = true;
  685. } else {
  686. $linktocreatetaskParam['attr']['title'] = $langs->trans("NotOwnerOfProject");
  687. }
  688. }
  689. $linktocreatetask = dolGetButtonTitle($langs->trans('AddTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id), '', $linktocreatetaskUserRight, $linktocreatetaskParam);
  690. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
  691. if ($optioncss != '') {
  692. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  693. }
  694. print '<input type="hidden" name="token" value="'.newToken().'">';
  695. print '<input type="hidden" name="action" value="list">';
  696. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  697. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  698. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  699. print '<input type="hidden" name="page" value="'.$page.'">';
  700. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  701. $title = $langs->trans("ListOfTasks");
  702. $linktotasks = dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id, '', 1, array('morecss'=>'reposition btnTitleSelected'));
  703. $linktotasks .= dolGetButtonTitle($langs->trans('ViewGantt'), '', 'fa fa-stream imgforviewmode', DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id.'&withproject=1', '', 1, array('morecss'=>'reposition marginleftonly'));
  704. //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'generic', 0, '', '', 0, 1);
  705. print load_fiche_titre($title, $linktotasks.' &nbsp; '.$linktocreatetask, 'projecttask');
  706. // Get list of tasks in tasksarray and taskarrayfiltered
  707. // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him).
  708. $filteronthirdpartyid = $socid;
  709. $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, $extrafields, 1, $search_array_options);
  710. // We load also tasks limited to a particular user
  711. $tmpuser = new User($db);
  712. if ($search_user_id > 0) {
  713. $tmpuser->fetch($search_user_id);
  714. }
  715. $tasksrole = ($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(0, $tmpuser, $object->id, 0) : '');
  716. //var_dump($tasksarray);
  717. //var_dump($tasksrole);
  718. if (!empty($conf->use_javascript_ajax)) {
  719. include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
  720. }
  721. // Filter on categories
  722. $moreforfilter = '';
  723. if (count($tasksarray) > 0) {
  724. $moreforfilter .= '<div class="divsearchfield">';
  725. $moreforfilter .= $langs->trans("TasksAssignedTo").': ';
  726. $moreforfilter .= $form->select_dolusers($tmpuser->id > 0 ? $tmpuser->id : '', 'search_user_id', 1);
  727. $moreforfilter .= '</div>';
  728. }
  729. if ($moreforfilter) {
  730. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  731. print $moreforfilter;
  732. print '</div>';
  733. }
  734. print '<div class="div-table-responsive">';
  735. print '<table id="tablelines" class="tagtable nobottom liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
  736. // Fields title search
  737. print '<tr class="liste_titre_filter">';
  738. if (!empty($arrayfields['t.ref']['checked'])) {
  739. print '<td class="liste_titre">';
  740. print '<input class="flat searchstring maxwidth50" type="text" name="search_taskref" value="'.dol_escape_htmltag($search_taskref).'">';
  741. print '</td>';
  742. }
  743. if (!empty($arrayfields['t.label']['checked'])) {
  744. print '<td class="liste_titre">';
  745. print '<input class="flat searchstring maxwidth100" type="text" name="search_tasklabel" value="'.dol_escape_htmltag($search_tasklabel).'">';
  746. print '</td>';
  747. }
  748. if (!empty($arrayfields['t.description']['checked'])) {
  749. print '<td class="liste_titre">';
  750. print '<input class="flat searchstring maxwidth100" type="text" name="search_taskdescription" value="'.dol_escape_htmltag($search_taskdescription).'">';
  751. print '</td>';
  752. }
  753. if (!empty($arrayfields['t.dateo']['checked'])) {
  754. print '<td class="liste_titre center">';
  755. /*print '<span class="nowraponall"><input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtstartday" value="'.$search_dtstartday.'">';
  756. print '<input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtstartmonth" value="'.$search_dtstartmonth.'"></span>';
  757. $formother->select_year($search_dtstartyear ? $search_dtstartyear : -1, 'search_dtstartyear', 1, 20, 5);*/
  758. print '<div class="nowrap">';
  759. 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'));
  760. print '</div>';
  761. print '<div class="nowrap">';
  762. 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'));
  763. print '</div>';
  764. print '</td>';
  765. }
  766. if (!empty($arrayfields['t.datee']['checked'])) {
  767. print '<td class="liste_titre center">';
  768. /*print '<span class="nowraponall"><input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtendday" value="'.$search_dtendday.'">';
  769. print '<input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtendmonth" value="'.$search_dtendmonth.'"></span>';
  770. $formother->select_year($search_dtendyear ? $search_dtendyear : -1, 'search_dtendyear', 1, 20, 5);*/
  771. print '<div class="nowrap">';
  772. 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'));
  773. print '</div>';
  774. print '<div class="nowrap">';
  775. 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'));
  776. print '</div>';
  777. print '</td>';
  778. }
  779. if (!empty($arrayfields['t.planned_workload']['checked'])) {
  780. print '<td class="liste_titre right">';
  781. print '<input class="flat" type="text" size="4" name="search_planedworkload" value="'.$search_planedworkload.'">';
  782. print '</td>';
  783. }
  784. if (!empty($arrayfields['t.duration_effective']['checked'])) {
  785. print '<td class="liste_titre right">';
  786. print '<input class="flat" type="text" size="4" name="search_timespend" value="'.$search_timespend.'">';
  787. print '</td>';
  788. }
  789. if (!empty($arrayfields['t.progress_calculated']['checked'])) {
  790. print '<td class="liste_titre right">';
  791. print '<input class="flat" type="text" size="4" name="search_progresscalc" value="'.$search_progresscalc.'">';
  792. print '</td>';
  793. }
  794. if (!empty($arrayfields['t.progress']['checked'])) {
  795. print '<td class="liste_titre right">';
  796. print '<input class="flat" type="text" size="4" name="search_progressdeclare" value="'.$search_progressdeclare.'">';
  797. print '</td>';
  798. }
  799. // progress resume not searchable
  800. print '<td class="liste_titre right"></td>';
  801. if ($object->usage_bill_time) {
  802. if (!empty($arrayfields['t.tobill']['checked'])) {
  803. print '<td class="liste_titre right">';
  804. print '</td>';
  805. }
  806. if (!empty($arrayfields['t.billed']['checked'])) {
  807. print '<td class="liste_titre right">';
  808. print '</td>';
  809. }
  810. }
  811. // Contacts of task, disabled because available by default jsut after
  812. /*
  813. if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) {
  814. print '<td class="liste_titre"></td>';
  815. }
  816. */
  817. if (!empty($arrayfields['t.budget_amount']['checked'])) {
  818. print '<td class="liste_titre center">';
  819. print '<input type="text" class="flat" name="search_task_budget_amount" value="'.$search_task_budget_amount.'" size="4">';
  820. print '</td>';
  821. }
  822. if (!empty($arrayfields['c.assigned']['checked'])) {
  823. print '<td class="liste_titre right">';
  824. print '</td>';
  825. }
  826. $extrafieldsobjectkey = $taskstatic->table_element;
  827. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  828. // Action column
  829. print '<td class="liste_titre maxwidthsearch">';
  830. $searchpicto = $form->showFilterButtons();
  831. print $searchpicto;
  832. print '</td>';
  833. print "</tr>\n";
  834. print '<tr class="liste_titre nodrag nodrop">';
  835. // print '<td>'.$langs->trans("Project").'</td>';
  836. if (!empty($arrayfields['t.ref']['checked'])) {
  837. print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '');
  838. }
  839. if (!empty($arrayfields['t.label']['checked'])) {
  840. print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, '');
  841. }
  842. if (!empty($arrayfields['t.description']['checked'])) {
  843. print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, '');
  844. }
  845. if (!empty($arrayfields['t.dateo']['checked'])) {
  846. print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ');
  847. }
  848. if (!empty($arrayfields['t.datee']['checked'])) {
  849. print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ');
  850. }
  851. if (!empty($arrayfields['t.planned_workload']['checked'])) {
  852. print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
  853. }
  854. if (!empty($arrayfields['t.duration_effective']['checked'])) {
  855. print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
  856. }
  857. if (!empty($arrayfields['t.progress_calculated']['checked'])) {
  858. print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
  859. }
  860. if (!empty($arrayfields['t.progress']['checked'])) {
  861. print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
  862. }
  863. if (!empty($arrayfields['t.progress_summary']['checked'])) {
  864. print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '', 1);
  865. }
  866. if ($object->usage_bill_time) {
  867. if (!empty($arrayfields['t.tobill']['checked'])) {
  868. print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ');
  869. }
  870. if (!empty($arrayfields['t.billed']['checked'])) {
  871. print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ');
  872. }
  873. }
  874. // Contacts of task, disabled because available by default jsut after
  875. /*
  876. if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) {
  877. print_liste_field_titre("TaskRessourceLinks", $_SERVER["PHP_SELF"], '', '', $param, $sortfield, $sortorder);
  878. }
  879. */
  880. if (!empty($arrayfields['t.budget_amount']['checked'])) {
  881. print_liste_field_titre($arrayfields['t.budget_amount']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center ');
  882. }
  883. if (!empty($arrayfields['c.assigned']['checked'])) {
  884. print_liste_field_titre($arrayfields['c.assigned']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '');
  885. }
  886. // Extra fields
  887. $disablesortlink = 1;
  888. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  889. // Hook fields
  890. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  891. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  892. print $hookmanager->resPrint;
  893. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  894. print "</tr>\n";
  895. if (count($tasksarray) > 0) {
  896. // Show all lines in taskarray (recursive function to go down on tree)
  897. $j = 0; $level = 0;
  898. $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields);
  899. } else {
  900. $colspan = 10;
  901. if ($object->usage_bill_time) {
  902. $colspan += 2;
  903. }
  904. print '<tr class="oddeven nobottom"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoTasks").'</span></td></tr>';
  905. }
  906. print "</table>";
  907. print '</div>';
  908. print '</form>';
  909. // Test if database is clean. If not we clean it.
  910. //print 'mode='.$_REQUEST["mode"].' $nboftaskshown='.$nboftaskshown.' count($tasksarray)='.count($tasksarray).' count($tasksrole)='.count($tasksrole).'<br>';
  911. if (!empty($user->rights->projet->all->lire)) { // We make test to clean only if user has permission to see all (test may report false positive otherwise)
  912. if ($search_user_id == $user->id) {
  913. if ($nboftaskshown < count($tasksrole)) {
  914. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  915. cleanCorruptedTree($db, 'projet_task', 'fk_task_parent');
  916. }
  917. } else {
  918. if ($nboftaskshown < count($tasksarray) && !GETPOST('search_user_id', 'int')) {
  919. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  920. cleanCorruptedTree($db, 'projet_task', 'fk_task_parent');
  921. }
  922. }
  923. }
  924. }
  925. // End of page
  926. llxFooter();
  927. $db->close();