tasks.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954
  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 ($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. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projecttasklist';
  77. //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
  78. $object = new Project($db);
  79. $taskstatic = new Task($db);
  80. $extrafields = new ExtraFields($db);
  81. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
  82. if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) {
  83. $object->fetchComments();
  84. }
  85. if ($id > 0 || !empty($ref)) {
  86. // fetch optionals attributes and labels
  87. $extrafields->fetch_name_optionals_label($object->table_element);
  88. }
  89. $extrafields->fetch_name_optionals_label($taskstatic->table_element);
  90. $search_array_options = $extrafields->getOptionalsFromPost($taskstatic->table_element, '', 'search_');
  91. // Default sort order (if not yet defined by previous GETPOST)
  92. if (!$sortfield) {
  93. reset($object->fields); $sortfield="t.".key($object->fields);
  94. } // Set here default search field. By default 1st field in definition. Reset is required to avoid key() to return null.
  95. if (!$sortorder) {
  96. $sortorder = "ASC";
  97. }
  98. // Security check
  99. $socid = 0;
  100. //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.
  101. $result = restrictedArea($user, 'projet', $id, 'projet&project');
  102. $diroutputmassaction = $conf->projet->dir_output.'/tasks/temp/massgeneration/'.$user->id;
  103. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  104. $hookmanager->initHooks(array('projecttaskscard', 'globalcard'));
  105. $progress = GETPOST('progress', 'int');
  106. $label = GETPOST('label', 'alpha');
  107. $description = GETPOST('description', 'restricthtml');
  108. $planned_workloadhour = (GETPOST('planned_workloadhour', 'int') ?GETPOST('planned_workloadhour', 'int') : 0);
  109. $planned_workloadmin = (GETPOST('planned_workloadmin', 'int') ?GETPOST('planned_workloadmin', 'int') : 0);
  110. $planned_workload = $planned_workloadhour * 3600 + $planned_workloadmin * 60;
  111. // Definition of fields for list
  112. $arrayfields = array(
  113. 't.ref'=>array('label'=>$langs->trans("RefTask"), 'checked'=>1, 'position'=>1),
  114. 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>2),
  115. 't.description'=>array('label'=>$langs->trans("Description"), 'checked'=>0, 'position'=>3),
  116. 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>4),
  117. 't.datee'=>array('label'=>$langs->trans("Deadline"), 'checked'=>1, 'position'=>5),
  118. 't.planned_workload'=>array('label'=>$langs->trans("PlannedWorkload"), 'checked'=>1, 'position'=>6),
  119. 't.duration_effective'=>array('label'=>$langs->trans("TimeSpent"), 'checked'=>1, 'position'=>7),
  120. 't.progress_calculated'=>array('label'=>$langs->trans("ProgressCalculated"), 'checked'=>1, 'position'=>8),
  121. 't.progress'=>array('label'=>$langs->trans("ProgressDeclared"), 'checked'=>1, 'position'=>9),
  122. 't.progress_summary'=>array('label'=>$langs->trans("TaskProgressSummary"), 'checked'=>1, 'position'=>10),
  123. 'c.assigned'=>array('label'=>$langs->trans("TaskRessourceLinks"), 'checked'=>1, 'position'=>11),
  124. );
  125. if ($object->usage_bill_time) {
  126. $arrayfields['t.tobill'] = array('label'=>$langs->trans("TimeToBill"), 'checked'=>0, 'position'=>11);
  127. $arrayfields['t.billed'] = array('label'=>$langs->trans("TimeBilled"), 'checked'=>0, 'position'=>12);
  128. }
  129. // Extra fields
  130. $extrafieldsobjectkey = $taskstatic->table_element;
  131. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  132. $arrayfields = dol_sort_array($arrayfields, 'position');
  133. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  134. /*
  135. * Actions
  136. */
  137. $parameters = array('id'=>$id);
  138. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  139. if ($reshook < 0) {
  140. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  141. }
  142. if (empty($reshook)) {
  143. // Selection of new fields
  144. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  145. // Purge search criteria
  146. 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
  147. $search_user_id = "";
  148. $search_taskref = '';
  149. $search_tasklabel = '';
  150. $search_dtstartday = '';
  151. $search_dtstartmonth = '';
  152. $search_dtstartyear = '';
  153. $search_dtendday = '';
  154. $search_dtendmonth = '';
  155. $search_dtendyear = '';
  156. $search_planedworkload = '';
  157. $search_timespend = '';
  158. $search_progresscalc = '';
  159. $search_progressdeclare = '';
  160. $toselect = '';
  161. $search_array_options = array();
  162. }
  163. // Mass actions
  164. $objectclass = 'Task';
  165. $objectlabel = 'Tasks';
  166. $permissiontoread = $user->rights->projet->lire;
  167. $permissiontodelete = $user->rights->projet->supprimer;
  168. $uploaddir = $conf->projet->dir_output.'/tasks';
  169. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  170. }
  171. $morewherefilterarray = array();
  172. if (!empty($search_taskref)) {
  173. $morewherefilterarray[] = natural_search('t.ref', $search_taskref, 0, 1);
  174. }
  175. if (!empty($search_tasklabel)) {
  176. $morewherefilterarray[] = natural_search('t.label', $search_tasklabel, 0, 1);
  177. }
  178. $moresql = dolSqlDateFilter('t.dateo', $search_dtstartday, $search_dtstartmonth, $search_dtstartyear, 1);
  179. if ($moresql) {
  180. $morewherefilterarray[] = $moresql;
  181. }
  182. $moresql = dolSqlDateFilter('t.datee', $search_dtendday, $search_dtendmonth, $search_dtendyear, 1);
  183. if ($moresql) {
  184. $morewherefilterarray[] = $moresql;
  185. }
  186. if (!empty($search_planedworkload)) {
  187. $morewherefilterarray[] = natural_search('t.planned_workload', $search_planedworkload, 1, 1);
  188. }
  189. if (!empty($search_timespend)) {
  190. $morewherefilterarray[] = natural_search('t.duration_effective', $search_timespend, 1, 1);
  191. }
  192. if (!empty($search_progresscalc)) {
  193. $filterprogresscalc = 'if '.natural_search('round(100 * $line->duration / $line->planned_workload,2)', $search_progresscalc, 1, 1).'{return 1;} else {return 0;}';
  194. } else {
  195. $filterprogresscalc = '';
  196. }
  197. if (!empty($search_progressdeclare)) {
  198. $morewherefilterarray[] = natural_search('t.progress', $search_progressdeclare, 1, 1);
  199. }
  200. $morewherefilter = '';
  201. if (count($morewherefilterarray) > 0) {
  202. $morewherefilter = ' AND '.implode(' AND ', $morewherefilterarray);
  203. }
  204. if ($action == 'createtask' && $user->rights->projet->creer) {
  205. $error = 0;
  206. // If we use user timezone, we must change also view/list to use user timezone everywhere
  207. //$date_start = dol_mktime($_POST['dateohour'],$_POST['dateomin'],0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear'],'user');
  208. //$date_end = dol_mktime($_POST['dateehour'],$_POST['dateemin'],0,$_POST['dateemonth'],$_POST['dateeday'],$_POST['dateeyear'],'user');
  209. $date_start = dol_mktime(GETPOST('dateohour', 'int'), GETPOST('dateomin', 'int'), 0, GETPOST('dateomonth', 'int'), GETPOST('dateoday', 'int'), GETPOST('dateoyear', 'int'));
  210. $date_end = dol_mktime(GETPOST('dateehour', 'int'), GETPOST('dateemin', 'int'), 0, GETPOST('dateemonth', 'int'), GETPOST('dateeday', 'int'), GETPOST('dateeyear', 'int'));
  211. if (!$cancel) {
  212. if (empty($taskref)) {
  213. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
  214. $action = 'create';
  215. $error++;
  216. }
  217. if (empty($label)) {
  218. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
  219. $action = 'create';
  220. $error++;
  221. } elseif (empty($_POST['task_parent'])) {
  222. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ChildOfProjectTask")), null, 'errors');
  223. $action = 'create';
  224. $error++;
  225. }
  226. if (!$error) {
  227. $tmparray = explode('_', GETPOST('task_parent'));
  228. $projectid = $tmparray[0];
  229. if (empty($projectid)) {
  230. $projectid = $id; // If projectid is ''
  231. }
  232. $task_parent = $tmparray[1];
  233. if (empty($task_parent)) {
  234. $task_parent = 0; // If task_parent is ''
  235. }
  236. $task = new Task($db);
  237. $task->fk_project = $projectid;
  238. $task->ref = $taskref;
  239. $task->label = $label;
  240. $task->description = $description;
  241. $task->planned_workload = $planned_workload;
  242. $task->fk_task_parent = $task_parent;
  243. $task->date_c = dol_now();
  244. $task->date_start = $date_start;
  245. $task->date_end = $date_end;
  246. $task->progress = $progress;
  247. // Fill array 'array_options' with data from add form
  248. $ret = $extrafields->setOptionalsFromPost(null, $task);
  249. $taskid = $task->create($user);
  250. if ($taskid > 0) {
  251. $result = $task->add_contact(GETPOST("userid", 'int'), 'TASKEXECUTIVE', 'internal');
  252. } else {
  253. if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
  254. $langs->load("projects");
  255. setEventMessages($langs->trans('NewTaskRefSuggested'), '', 'warnings');
  256. $duplicate_code_error = true;
  257. } else {
  258. setEventMessages($task->error, $task->errors, 'errors');
  259. }
  260. $action = 'create';
  261. $error++;
  262. }
  263. }
  264. if (!$error) {
  265. if (!empty($backtopage)) {
  266. header("Location: ".$backtopage);
  267. exit;
  268. } elseif (empty($projectid)) {
  269. header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode));
  270. exit;
  271. }
  272. $id = $projectid;
  273. }
  274. } else {
  275. if (!empty($backtopage)) {
  276. header("Location: ".$backtopage);
  277. exit;
  278. } elseif (empty($id)) {
  279. // We go back on task list
  280. header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode));
  281. exit;
  282. }
  283. }
  284. }
  285. /*
  286. * View
  287. */
  288. $now = dol_now();
  289. $form = new Form($db);
  290. $formother = new FormOther($db);
  291. $socstatic = new Societe($db);
  292. $projectstatic = new Project($db);
  293. $taskstatic = new Task($db);
  294. $userstatic = new User($db);
  295. $title = $langs->trans("Project").' - '.$langs->trans("Tasks").' - '.$object->ref.' '.$object->name;
  296. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  297. $title = $object->ref.' '.$object->name.' - '.$langs->trans("Tasks");
  298. }
  299. $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  300. llxHeader("", $title, $help_url);
  301. if ($id > 0 || !empty($ref)) {
  302. $result = $object->fetch($id, $ref);
  303. if ($result < 0) {
  304. setEventMessages(null, $object->errors, 'errors');
  305. }
  306. $result = $object->fetch_thirdparty();
  307. if ($result < 0) {
  308. setEventMessages(null, $object->errors, 'errors');
  309. }
  310. $result = $object->fetch_optionals();
  311. if ($result < 0) {
  312. setEventMessages(null, $object->errors, 'errors');
  313. }
  314. // To verify role of users
  315. //$userAccess = $object->restrictedProjectArea($user,'read');
  316. $userWrite = $object->restrictedProjectArea($user, 'write');
  317. //$userDelete = $object->restrictedProjectArea($user,'delete');
  318. //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
  319. $tab = (GETPOSTISSET('tab') ? GETPOST('tab') : 'tasks');
  320. $head = project_prepare_head($object);
  321. print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
  322. $param = '&id='.$object->id;
  323. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  324. $param .= '&contextpage='.urlencode($contextpage);
  325. }
  326. if ($search_user_id) {
  327. $param .= '&search_user_id='.urlencode($search_user_id);
  328. }
  329. if ($search_taskref) {
  330. $param .= '&search_taskref='.urlencode($search_taskref);
  331. }
  332. if ($search_tasklabel) {
  333. $param .= '&search_tasklabel='.urlencode($search_tasklabel);
  334. }
  335. if ($search_taskdescription) {
  336. $param .= '&search_taskdescription='.urlencode($search_taskdescription);
  337. }
  338. if ($search_dtstartday) {
  339. $param .= '&search_dtstartday='.urlencode($search_dtstartday);
  340. }
  341. if ($search_dtstartmonth) {
  342. $param .= '&search_dtstartmonth='.urlencode($search_dtstartmonth);
  343. }
  344. if ($search_dtstartyear) {
  345. $param .= '&search_dtstartyear='.urlencode($search_dtstartyear);
  346. }
  347. if ($search_dtendday) {
  348. $param .= '&search_dtendday='.urlencode($search_dtendday);
  349. }
  350. if ($search_dtendmonth) {
  351. $param .= '&search_dtendmonth='.urlencode($search_dtendmonth);
  352. }
  353. if ($search_dtendyear) {
  354. $param .= '&search_dtendyear='.urlencode($search_dtendyear);
  355. }
  356. if ($search_planedworkload) {
  357. $param .= '&search_planedworkload='.urlencode($search_planedworkload);
  358. }
  359. if ($search_timespend) {
  360. $param .= '&search_timespend='.urlencode($search_timespend);
  361. }
  362. if ($search_progresscalc) {
  363. $param .= '&search_progresscalc='.urlencode($search_progresscalc);
  364. }
  365. if ($search_progressdeclare) {
  366. $param .= '&search_progressdeclare='.urlencode($search_progressdeclare);
  367. }
  368. if ($optioncss != '') {
  369. $param .= '&optioncss='.urlencode($optioncss);
  370. }
  371. // Add $param from extra fields
  372. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  373. // Project card
  374. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  375. $morehtmlref = '<div class="refidno">';
  376. // Title
  377. $morehtmlref .= $object->title;
  378. // Thirdparty
  379. if ($object->thirdparty->id > 0) {
  380. $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
  381. }
  382. $morehtmlref .= '</div>';
  383. // Define a complementary filter for search of next/prev ref.
  384. if (!$user->rights->projet->all->lire) {
  385. $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
  386. $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
  387. }
  388. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  389. print '<div class="fichecenter">';
  390. print '<div class="fichehalfleft">';
  391. print '<div class="underbanner clearboth"></div>';
  392. print '<table class="border tableforfield centpercent">';
  393. // Usage
  394. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
  395. print '<tr><td class="tdtop">';
  396. print $langs->trans("Usage");
  397. print '</td>';
  398. print '<td>';
  399. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  400. print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> ';
  401. $htmltext = $langs->trans("ProjectFollowOpportunity");
  402. print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
  403. print '<br>';
  404. }
  405. if (empty($conf->global->PROJECT_HIDE_TASKS)) {
  406. print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> ';
  407. $htmltext = $langs->trans("ProjectFollowTasks");
  408. print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
  409. print '<br>';
  410. }
  411. if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
  412. 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"' : '')).'"> ';
  413. $htmltext = $langs->trans("ProjectBillTimeDescription");
  414. print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
  415. print '<br>';
  416. }
  417. if (!empty($conf->eventorganization->enabled)) {
  418. 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"' : '')).'"> ';
  419. $htmltext = $langs->trans("EventOrganizationDescriptionLong");
  420. print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
  421. }
  422. print '</td></tr>';
  423. }
  424. // Visibility
  425. print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
  426. if ($object->public) {
  427. print $langs->trans('SharedProject');
  428. } else {
  429. print $langs->trans('PrivateProject');
  430. }
  431. print '</td></tr>';
  432. // Date start - end
  433. print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
  434. $start = dol_print_date($object->date_start, 'day');
  435. print ($start ? $start : '?');
  436. $end = dol_print_date($object->date_end, 'day');
  437. print ' - ';
  438. print ($end ? $end : '?');
  439. if ($object->hasDelay()) {
  440. print img_warning("Late");
  441. }
  442. print '</td></tr>';
  443. // Budget
  444. print '<tr><td>'.$langs->trans("Budget").'</td><td>';
  445. if (strcmp($object->budget_amount, '')) {
  446. print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
  447. }
  448. print '</td></tr>';
  449. // Other attributes
  450. $cols = 2;
  451. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  452. print '</table>';
  453. print '</div>';
  454. print '<div class="fichehalfright">';
  455. print '<div class="ficheaddleft">';
  456. print '<div class="underbanner clearboth"></div>';
  457. print '<table class="border tableforfield centpercent">';
  458. // Description
  459. print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
  460. print nl2br($object->description);
  461. print '</td></tr>';
  462. // Categories
  463. if ($conf->categorie->enabled) {
  464. print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
  465. print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
  466. print "</td></tr>";
  467. }
  468. print '</table>';
  469. print '</div>';
  470. print '</div>';
  471. print '</div>';
  472. print '<div class="clearboth"></div>';
  473. print dol_get_fiche_end();
  474. }
  475. if ($action == 'create' && $user->rights->projet->creer && (empty($object->thirdparty->id) || $userWrite > 0)) {
  476. if ($id > 0 || !empty($ref)) {
  477. print '<br>';
  478. }
  479. print load_fiche_titre($langs->trans("NewTask"), '', 'projecttask');
  480. if ($object->id > 0 && $object->statut == Project::STATUS_CLOSED) {
  481. print '<div class="warning">';
  482. $langs->load("errors");
  483. print $langs->trans("WarningProjectClosed");
  484. print '</div>';
  485. }
  486. if ($object->id > 0 && $object->statut == Project::STATUS_DRAFT) {
  487. print '<div class="warning">';
  488. $langs->load("errors");
  489. print $langs->trans("WarningProjectDraft");
  490. print '</div>';
  491. }
  492. print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
  493. print '<input type="hidden" name="token" value="'.newToken().'">';
  494. print '<input type="hidden" name="action" value="createtask">';
  495. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  496. if (!empty($object->id)) {
  497. print '<input type="hidden" name="id" value="'.$object->id.'">';
  498. }
  499. print dol_get_fiche_head('');
  500. print '<table class="border centpercent">';
  501. $defaultref = '';
  502. $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
  503. if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) {
  504. require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php';
  505. $modTask = new $obj;
  506. $defaultref = $modTask->getNextValue($object->thirdparty, null);
  507. }
  508. if (is_numeric($defaultref) && $defaultref <= 0) {
  509. $defaultref = '';
  510. }
  511. // Ref
  512. print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td>';
  513. if (empty($duplicate_code_error)) {
  514. print (GETPOSTISSET("ref") ? GETPOST("ref", 'alpha') : $defaultref);
  515. } else {
  516. print $defaultref;
  517. }
  518. print '<input type="hidden" name="taskref" value="'.(GETPOSTISSET("ref") ? GETPOST("ref", 'alpha') : $defaultref).'">';
  519. print '</td></tr>';
  520. // Label
  521. print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>';
  522. print '<input type="text" name="label" autofocus class="minwidth500 maxwidthonsmartphone" value="'.$label.'">';
  523. print '</td></tr>';
  524. // Project
  525. print '<tr><td class="fieldrequired">'.$langs->trans("ChildOfProjectTask").'</td><td>';
  526. print img_picto('', 'project');
  527. $formother->selectProjectTasks(GETPOST('task_parent'), $projectid ? $projectid : $object->id, 'task_parent', 0, 0, 1, 1, 0, '0,1', 'maxwidth500');
  528. print '</td></tr>';
  529. // Assigned to
  530. print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>';
  531. $contactsofproject = (!empty($object->id) ? $object->getListContactId('internal') : '');
  532. if (is_array($contactsofproject) && count($contactsofproject)) {
  533. print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300');
  534. } else {
  535. print '<span class="opacitymedium">'.$langs->trans("NoUserAssignedToTheProject").'</span>';
  536. }
  537. print '</td></tr>';
  538. // Date start
  539. print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
  540. print $form->selectDate(($date_start ? $date_start : ''), 'dateo', 1, 1, 0, '', 1, 1);
  541. print '</td></tr>';
  542. // Date end
  543. print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
  544. print $form->selectDate(($date_end ? $date_end : -1), 'datee', -1, 1, 0, '', 1, 1);
  545. print '</td></tr>';
  546. // Planned workload
  547. print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>';
  548. print $form->select_duration('planned_workload', $planned_workload ? $planned_workload : 0, 0, 'text');
  549. print '</td></tr>';
  550. // Progress
  551. print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">';
  552. print $formother->select_percent($progress, 'progress', 0, 5, 0, 100, 1);
  553. print '</td></tr>';
  554. // Description
  555. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
  556. print '<td>';
  557. print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_4.'">'.$description.'</textarea>';
  558. print '</td></tr>';
  559. // Other options
  560. $parameters = array();
  561. $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook
  562. print $hookmanager->resPrint;
  563. if (empty($reshook) && !empty($extrafields->attributes[$taskstatic->table_element]['label'])) {
  564. print $taskstatic->showOptionals($extrafields, 'edit'); // Do not use $object here that is object of project but use $taskstatic
  565. }
  566. print '</table>';
  567. print dol_get_fiche_end();
  568. print '<div class="center">';
  569. print '<input type="submit" class="button" name="add" value="'.$langs->trans("Add").'">';
  570. print ' &nbsp; &nbsp; ';
  571. print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
  572. print '</div>';
  573. print '</form>';
  574. } elseif ($id > 0 || !empty($ref)) {
  575. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  576. /*
  577. * Projet card in view mode
  578. */
  579. print '<br>';
  580. // Link to create task
  581. $linktocreatetaskParam = array();
  582. $linktocreatetaskUserRight = false;
  583. if ($user->rights->projet->all->creer || $user->rights->projet->creer) {
  584. if ($object->public || $userWrite > 0) {
  585. $linktocreatetaskUserRight = true;
  586. } else {
  587. $linktocreatetaskParam['attr']['title'] = $langs->trans("NotOwnerOfProject");
  588. }
  589. }
  590. $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);
  591. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
  592. if ($optioncss != '') {
  593. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  594. }
  595. print '<input type="hidden" name="token" value="'.newToken().'">';
  596. print '<input type="hidden" name="action" value="list">';
  597. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  598. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  599. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  600. print '<input type="hidden" name="page" value="'.$page.'">';
  601. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  602. $title = $langs->trans("ListOfTasks");
  603. $linktotasks = dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id, '', 1, array('morecss'=>'reposition btnTitleSelected'));
  604. $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'));
  605. //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'generic', 0, '', '', 0, 1);
  606. print load_fiche_titre($title, $linktotasks.' &nbsp; '.$linktocreatetask, 'projecttask');
  607. // Get list of tasks in tasksarray and taskarrayfiltered
  608. // 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).
  609. $filteronthirdpartyid = $socid;
  610. $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, $extrafields, 1, $search_array_options);
  611. // We load also tasks limited to a particular user
  612. $tmpuser = new User($db);
  613. if ($search_user_id > 0) {
  614. $tmpuser->fetch($search_user_id);
  615. }
  616. $tasksrole = ($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(0, $tmpuser, $object->id, 0) : '');
  617. //var_dump($tasksarray);
  618. //var_dump($tasksrole);
  619. if (!empty($conf->use_javascript_ajax)) {
  620. include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
  621. }
  622. // Filter on categories
  623. $moreforfilter = '';
  624. if (count($tasksarray) > 0) {
  625. $moreforfilter .= '<div class="divsearchfield">';
  626. $moreforfilter .= $langs->trans("TasksAssignedTo").': ';
  627. $moreforfilter .= $form->select_dolusers($tmpuser->id > 0 ? $tmpuser->id : '', 'search_user_id', 1);
  628. $moreforfilter .= '</div>';
  629. }
  630. if ($moreforfilter) {
  631. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  632. print $moreforfilter;
  633. print '</div>';
  634. }
  635. print '<div class="div-table-responsive">';
  636. print '<table id="tablelines" class="tagtable nobottom liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
  637. // Fields title search
  638. print '<tr class="liste_titre_filter">';
  639. if (!empty($arrayfields['t.ref']['checked'])) {
  640. print '<td class="liste_titre">';
  641. print '<input class="flat searchstring maxwidth50" type="text" name="search_taskref" value="'.dol_escape_htmltag($search_taskref).'">';
  642. print '</td>';
  643. }
  644. if (!empty($arrayfields['t.label']['checked'])) {
  645. print '<td class="liste_titre">';
  646. print '<input class="flat searchstring maxwidth100" type="text" name="search_tasklabel" value="'.dol_escape_htmltag($search_tasklabel).'">';
  647. print '</td>';
  648. }
  649. if (!empty($arrayfields['t.description']['checked'])) {
  650. print '<td class="liste_titre">';
  651. print '<input class="flat searchstring maxwidth100" type="text" name="search_taskdescription" value="'.dol_escape_htmltag($search_taskdescription).'">';
  652. print '</td>';
  653. }
  654. if (!empty($arrayfields['t.dateo']['checked'])) {
  655. print '<td class="liste_titre center">';
  656. print '<span class="nowraponall"><input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtstartday" value="'.$search_dtstartday.'">';
  657. print '<input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtstartmonth" value="'.$search_dtstartmonth.'"></span>';
  658. $formother->select_year($search_dtstartyear ? $search_dtstartyear : -1, 'search_dtstartyear', 1, 20, 5);
  659. print '</td>';
  660. }
  661. if (!empty($arrayfields['t.datee']['checked'])) {
  662. print '<td class="liste_titre center">';
  663. print '<span class="nowraponall"><input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtendday" value="'.$search_dtendday.'">';
  664. print '<input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtendmonth" value="'.$search_dtendmonth.'"></span>';
  665. $formother->select_year($search_dtendyear ? $search_dtendyear : -1, 'search_dtendyear', 1, 20, 5);
  666. print '</td>';
  667. }
  668. if (!empty($arrayfields['t.planned_workload']['checked'])) {
  669. print '<td class="liste_titre right">';
  670. print '<input class="flat" type="text" size="4" name="search_planedworkload" value="'.$search_planedworkload.'">';
  671. print '</td>';
  672. }
  673. if (!empty($arrayfields['t.duration_effective']['checked'])) {
  674. print '<td class="liste_titre right">';
  675. print '<input class="flat" type="text" size="4" name="search_timespend" value="'.$search_timespend.'">';
  676. print '</td>';
  677. }
  678. if (!empty($arrayfields['t.progress_calculated']['checked'])) {
  679. print '<td class="liste_titre right">';
  680. print '<input class="flat" type="text" size="4" name="search_progresscalc" value="'.$search_progresscalc.'">';
  681. print '</td>';
  682. }
  683. if (!empty($arrayfields['t.progress']['checked'])) {
  684. print '<td class="liste_titre right">';
  685. print '<input class="flat" type="text" size="4" name="search_progressdeclare" value="'.$search_progressdeclare.'">';
  686. print '</td>';
  687. }
  688. // progress resume not searchable
  689. print '<td class="liste_titre right"></td>';
  690. if ($object->usage_bill_time) {
  691. if (!empty($arrayfields['t.tobill']['checked'])) {
  692. print '<td class="liste_titre right">';
  693. print '</td>';
  694. }
  695. if (!empty($arrayfields['t.billed']['checked'])) {
  696. print '<td class="liste_titre right">';
  697. print '</td>';
  698. }
  699. }
  700. // Contacts of task, disabled because available by default jsut after
  701. /*
  702. if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) {
  703. print '<td class="liste_titre"></td>';
  704. }
  705. */
  706. if (!empty($arrayfields['c.assigned']['checked'])) {
  707. print '<td class="liste_titre right">';
  708. print '</td>';
  709. }
  710. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  711. // Action column
  712. print '<td class="liste_titre maxwidthsearch">';
  713. $searchpicto = $form->showFilterButtons();
  714. print $searchpicto;
  715. print '</td>';
  716. print "</tr>\n";
  717. print '<tr class="liste_titre nodrag nodrop">';
  718. // print '<td>'.$langs->trans("Project").'</td>';
  719. if (!empty($arrayfields['t.ref']['checked'])) {
  720. print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '');
  721. }
  722. if (!empty($arrayfields['t.label']['checked'])) {
  723. print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, '');
  724. }
  725. if (!empty($arrayfields['t.description']['checked'])) {
  726. print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, '');
  727. }
  728. if (!empty($arrayfields['t.dateo']['checked'])) {
  729. print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ');
  730. }
  731. if (!empty($arrayfields['t.datee']['checked'])) {
  732. print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ');
  733. }
  734. if (!empty($arrayfields['t.planned_workload']['checked'])) {
  735. print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
  736. }
  737. if (!empty($arrayfields['t.duration_effective']['checked'])) {
  738. print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
  739. }
  740. if (!empty($arrayfields['t.progress_calculated']['checked'])) {
  741. print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
  742. }
  743. if (!empty($arrayfields['t.progress']['checked'])) {
  744. print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
  745. }
  746. if (!empty($arrayfields['t.progress_summary']['checked'])) {
  747. print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '', 1);
  748. }
  749. if ($object->usage_bill_time) {
  750. if (!empty($arrayfields['t.tobill']['checked'])) {
  751. print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ');
  752. }
  753. if (!empty($arrayfields['t.billed']['checked'])) {
  754. print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ');
  755. }
  756. }
  757. // Contacts of task, disabled because available by default jsut after
  758. /*
  759. if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) {
  760. print_liste_field_titre("TaskRessourceLinks", $_SERVER["PHP_SELF"], '', '', $param, $sortfield, $sortorder);
  761. }
  762. */
  763. if (!empty($arrayfields['c.assigned']['checked'])) {
  764. print_liste_field_titre($arrayfields['c.assigned']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '');
  765. }
  766. // Extra fields
  767. $disablesortlink = 1;
  768. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  769. // Hook fields
  770. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  771. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  772. print $hookmanager->resPrint;
  773. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  774. print "</tr>\n";
  775. if (count($tasksarray) > 0) {
  776. // Show all lines in taskarray (recursive function to go down on tree)
  777. $j = 0; $level = 0;
  778. $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields);
  779. } else {
  780. $colspan = 10;
  781. if ($object->usage_bill_time) {
  782. $colspan += 2;
  783. }
  784. print '<tr class="oddeven nobottom"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoTasks").'</span></td></tr>';
  785. }
  786. print "</table>";
  787. print '</div>';
  788. print '</form>';
  789. // Test if database is clean. If not we clean it.
  790. //print 'mode='.$_REQUEST["mode"].' $nboftaskshown='.$nboftaskshown.' count($tasksarray)='.count($tasksarray).' count($tasksrole)='.count($tasksrole).'<br>';
  791. 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)
  792. if ($search_user_id == $user->id) {
  793. if ($nboftaskshown < count($tasksrole)) {
  794. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  795. cleanCorruptedTree($db, 'projet_task', 'fk_task_parent');
  796. }
  797. } else {
  798. if ($nboftaskshown < count($tasksarray) && !GETPOST('search_user_id', 'int')) {
  799. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  800. cleanCorruptedTree($db, 'projet_task', 'fk_task_parent');
  801. }
  802. }
  803. }
  804. }
  805. // End of page
  806. llxFooter();
  807. $db->close();