tasks.php 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  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. $extrafieldsobjectkey = $taskstatic->table_element;
  150. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
  151. $arrayfields = dol_sort_array($arrayfields, 'position');
  152. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  153. /*
  154. * Actions
  155. */
  156. $parameters = array('id'=>$id);
  157. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  158. if ($reshook < 0) {
  159. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  160. }
  161. if (empty($reshook)) {
  162. // Selection of new fields
  163. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  164. // Purge search criteria
  165. 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
  166. $search_user_id = "";
  167. $search_taskref = '';
  168. $search_tasklabel = '';
  169. $search_dtstartday = '';
  170. $search_dtstartmonth = '';
  171. $search_dtstartyear = '';
  172. $search_dtendday = '';
  173. $search_dtendmonth = '';
  174. $search_dtendyear = '';
  175. $search_planedworkload = '';
  176. $search_timespend = '';
  177. $search_progresscalc = '';
  178. $search_progressdeclare = '';
  179. $search_task_budget_amount = '';
  180. $toselect = array();
  181. $search_array_options = array();
  182. $search_date_start_startmonth = "";
  183. $search_date_start_startyear = "";
  184. $search_date_start_startday = "";
  185. $search_date_start_start = "";
  186. $search_date_start_endmonth = "";
  187. $search_date_start_endyear = "";
  188. $search_date_start_endday = "";
  189. $search_date_start_end = "";
  190. $search_date_end_startmonth = "";
  191. $search_date_end_startyear = "";
  192. $search_date_end_startday = "";
  193. $search_date_end_start = "";
  194. $search_date_end_endmonth = "";
  195. $search_date_end_endyear = "";
  196. $search_date_end_endday = "";
  197. $search_date_end_end = "";
  198. }
  199. // Mass actions
  200. $objectclass = 'Task';
  201. $objectlabel = 'Tasks';
  202. $permissiontoread = $user->rights->projet->lire;
  203. $permissiontodelete = $user->rights->projet->supprimer;
  204. $uploaddir = $conf->projet->dir_output.'/tasks';
  205. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  206. }
  207. $morewherefilterarray = array();
  208. if (!empty($search_taskref)) {
  209. $morewherefilterarray[] = natural_search('t.ref', $search_taskref, 0, 1);
  210. }
  211. if (!empty($search_tasklabel)) {
  212. $morewherefilterarray[] = natural_search('t.label', $search_tasklabel, 0, 1);
  213. }
  214. $moresql = dolSqlDateFilter('t.dateo', $search_dtstartday, $search_dtstartmonth, $search_dtstartyear, 1);
  215. if ($moresql) {
  216. $morewherefilterarray[] = $moresql;
  217. }
  218. $moresql = dolSqlDateFilter('t.datee', $search_dtendday, $search_dtendmonth, $search_dtendyear, 1);
  219. if ($moresql) {
  220. $morewherefilterarray[] = $moresql;
  221. }
  222. if ($search_date_start_start) {
  223. $morewherefilterarray[] = " t.dateo >= '".$db->idate($search_date_start_start)."'";
  224. }
  225. if ($search_date_start_end) {
  226. $morewherefilterarray[] = " t.dateo <= '".$db->idate($search_date_start_end)."'";
  227. }
  228. if ($search_date_end_start) {
  229. $morewherefilterarray[] = " t.datee >= '".$db->idate($search_date_end_start)."'";
  230. }
  231. if ($search_date_end_end) {
  232. $morewherefilterarray[] = " t.datee <= '".$db->idate($search_date_end_end)."'";
  233. }
  234. if (!empty($search_planedworkload)) {
  235. $morewherefilterarray[] = natural_search('t.planned_workload', $search_planedworkload, 1, 1);
  236. }
  237. if (!empty($search_timespend)) {
  238. $morewherefilterarray[] = natural_search('t.duration_effective', $search_timespend, 1, 1);
  239. }
  240. if (!empty($search_progresscalc)) {
  241. $filterprogresscalc = 'if '.natural_search('round(100 * $line->duration / $line->planned_workload,2)', $search_progresscalc, 1, 1).'{return 1;} else {return 0;}';
  242. } else {
  243. $filterprogresscalc = '';
  244. }
  245. if (!empty($search_progressdeclare)) {
  246. $morewherefilterarray[] = natural_search('t.progress', $search_progressdeclare, 1, 1);
  247. }
  248. if ($search_task_budget_amount) {
  249. $morewherefilterarray[]= natural_search('t.budget_amount', $search_task_budget_amount, 1, 1);
  250. }
  251. $morewherefilter = '';
  252. if (count($morewherefilterarray) > 0) {
  253. $morewherefilter = ' AND '.implode(' AND ', $morewherefilterarray);
  254. }
  255. if ($action == 'createtask' && $user->rights->projet->creer) {
  256. $error = 0;
  257. // If we use user timezone, we must change also view/list to use user timezone everywhere
  258. $date_start = dol_mktime(GETPOST('dateohour', 'int'), GETPOST('dateomin', 'int'), 0, GETPOST('dateomonth', 'int'), GETPOST('dateoday', 'int'), GETPOST('dateoyear', 'int'));
  259. $date_end = dol_mktime(GETPOST('dateehour', 'int'), GETPOST('dateemin', 'int'), 0, GETPOST('dateemonth', 'int'), GETPOST('dateeday', 'int'), GETPOST('dateeyear', 'int'));
  260. if (!$cancel) {
  261. if (empty($taskref)) {
  262. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
  263. $action = 'create';
  264. $error++;
  265. }
  266. if (empty($label)) {
  267. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
  268. $action = 'create';
  269. $error++;
  270. } elseif (!GETPOST('task_parent')) {
  271. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ChildOfProjectTask")), null, 'errors');
  272. $action = 'create';
  273. $error++;
  274. }
  275. if (!$error) {
  276. $tmparray = explode('_', GETPOST('task_parent'));
  277. $projectid = $tmparray[0];
  278. if (empty($projectid)) {
  279. $projectid = $id; // If projectid is ''
  280. }
  281. $task_parent = $tmparray[1];
  282. if (empty($task_parent)) {
  283. $task_parent = 0; // If task_parent is ''
  284. }
  285. $task = new Task($db);
  286. $task->fk_project = $projectid;
  287. $task->ref = $taskref;
  288. $task->label = $label;
  289. $task->description = $description;
  290. $task->planned_workload = $planned_workload;
  291. $task->fk_task_parent = $task_parent;
  292. $task->date_c = dol_now();
  293. $task->date_start = $date_start;
  294. $task->date_end = $date_end;
  295. $task->progress = $progress;
  296. $task->budget_amount = $budget_amount;
  297. // Fill array 'array_options' with data from add form
  298. $ret = $extrafields->setOptionalsFromPost(null, $task);
  299. $taskid = $task->create($user);
  300. if ($taskid > 0) {
  301. $result = $task->add_contact(GETPOST("userid", 'int'), 'TASKEXECUTIVE', 'internal');
  302. } else {
  303. if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
  304. $langs->load("projects");
  305. setEventMessages($langs->trans('NewTaskRefSuggested'), '', 'warnings');
  306. $duplicate_code_error = true;
  307. } else {
  308. setEventMessages($task->error, $task->errors, 'errors');
  309. }
  310. $action = 'create';
  311. $error++;
  312. }
  313. }
  314. if (!$error) {
  315. if (!empty($backtopage)) {
  316. header("Location: ".$backtopage);
  317. exit;
  318. } elseif (empty($projectid)) {
  319. header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode));
  320. exit;
  321. }
  322. $id = $projectid;
  323. }
  324. } else {
  325. if (!empty($backtopage)) {
  326. header("Location: ".$backtopage);
  327. exit;
  328. } elseif (empty($id)) {
  329. // We go back on task list
  330. header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode));
  331. exit;
  332. }
  333. }
  334. }
  335. /*
  336. * View
  337. */
  338. $now = dol_now();
  339. $form = new Form($db);
  340. $formother = new FormOther($db);
  341. $socstatic = new Societe($db);
  342. $projectstatic = new Project($db);
  343. $taskstatic = new Task($db);
  344. $userstatic = new User($db);
  345. $title = $langs->trans("Project").' - '.$langs->trans("Tasks").' - '.$object->ref.' '.$object->name;
  346. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  347. $title = $object->ref.' '.$object->name.' - '.$langs->trans("Tasks");
  348. }
  349. $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  350. llxHeader("", $title, $help_url);
  351. if ($id > 0 || !empty($ref)) {
  352. $result = $object->fetch($id, $ref);
  353. if ($result < 0) {
  354. setEventMessages(null, $object->errors, 'errors');
  355. }
  356. $result = $object->fetch_thirdparty();
  357. if ($result < 0) {
  358. setEventMessages(null, $object->errors, 'errors');
  359. }
  360. $result = $object->fetch_optionals();
  361. if ($result < 0) {
  362. setEventMessages(null, $object->errors, 'errors');
  363. }
  364. // To verify role of users
  365. //$userAccess = $object->restrictedProjectArea($user,'read');
  366. $userWrite = $object->restrictedProjectArea($user, 'write');
  367. //$userDelete = $object->restrictedProjectArea($user,'delete');
  368. //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
  369. $tab = (GETPOSTISSET('tab') ? GETPOST('tab') : 'tasks');
  370. $head = project_prepare_head($object);
  371. print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
  372. $param = '&id='.$object->id;
  373. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  374. $param .= '&contextpage='.urlencode($contextpage);
  375. }
  376. if ($search_user_id) {
  377. $param .= '&search_user_id='.urlencode($search_user_id);
  378. }
  379. if ($search_taskref) {
  380. $param .= '&search_taskref='.urlencode($search_taskref);
  381. }
  382. if ($search_tasklabel) {
  383. $param .= '&search_tasklabel='.urlencode($search_tasklabel);
  384. }
  385. if ($search_taskdescription) {
  386. $param .= '&search_taskdescription='.urlencode($search_taskdescription);
  387. }
  388. if ($search_dtstartday) {
  389. $param .= '&search_dtstartday='.urlencode($search_dtstartday);
  390. }
  391. if ($search_dtstartmonth) {
  392. $param .= '&search_dtstartmonth='.urlencode($search_dtstartmonth);
  393. }
  394. if ($search_dtstartyear) {
  395. $param .= '&search_dtstartyear='.urlencode($search_dtstartyear);
  396. }
  397. if ($search_dtendday) {
  398. $param .= '&search_dtendday='.urlencode($search_dtendday);
  399. }
  400. if ($search_dtendmonth) {
  401. $param .= '&search_dtendmonth='.urlencode($search_dtendmonth);
  402. }
  403. if ($search_dtendyear) {
  404. $param .= '&search_dtendyear='.urlencode($search_dtendyear);
  405. }
  406. if ($search_date_start_startmonth) {
  407. $param .= '&search_date_start_startmonth='.urlencode($search_date_start_startmonth);
  408. }
  409. if ($search_date_start_startyear) {
  410. $param .= '&search_date_start_startyear='.urlencode($search_date_start_startyear);
  411. }
  412. if ($search_date_start_startday) {
  413. $param .= '&search_date_start_startday='.urlencode($search_date_start_startday);
  414. }
  415. if ($search_date_start_start) {
  416. $param .= '&search_date_start_start='.urlencode($search_date_start_start);
  417. }
  418. if ($search_date_start_endmonth) {
  419. $param .= '&search_date_start_endmonth='.urlencode($search_date_start_endmonth);
  420. }
  421. if ($search_date_start_endyear) {
  422. $param .= '&search_date_start_endyear='.urlencode($search_date_start_endyear);
  423. }
  424. if ($search_date_start_endday) {
  425. $param .= '&search_date_start_endday='.urlencode($search_date_start_endday);
  426. }
  427. if ($search_date_start_end) {
  428. $param .= '&search_date_start_end='.urlencode($search_date_start_end);
  429. }
  430. if ($search_date_end_startmonth) {
  431. $param .= '&search_date_end_startmonth='.urlencode($search_date_end_startmonth);
  432. }
  433. if ($search_date_end_startyear) {
  434. $param .= '&search_date_end_startyear='.urlencode($search_date_end_startyear);
  435. }
  436. if ($search_date_end_startday) {
  437. $param .= '&search_date_end_startday='.urlencode($search_date_end_startday);
  438. }
  439. if ($search_date_end_start) {
  440. $param .= '&search_date_end_start='.urlencode($search_date_end_start);
  441. }
  442. if ($search_date_end_endmonth) {
  443. $param .= '&search_date_end_endmonth='.urlencode($search_date_end_endmonth);
  444. }
  445. if ($search_date_end_endyear) {
  446. $param .= '&search_date_end_endyear='.urlencode($search_date_end_endyear);
  447. }
  448. if ($search_date_end_endday) {
  449. $param .= '&search_date_end_endday='.urlencode($search_date_end_endday);
  450. }
  451. if ($search_date_end_end) {
  452. $param .= '&search_date_end_end=' . urlencode($search_date_end_end);
  453. }
  454. if ($search_planedworkload) {
  455. $param .= '&search_planedworkload='.urlencode($search_planedworkload);
  456. }
  457. if ($search_timespend) {
  458. $param .= '&search_timespend='.urlencode($search_timespend);
  459. }
  460. if ($search_progresscalc) {
  461. $param .= '&search_progresscalc='.urlencode($search_progresscalc);
  462. }
  463. if ($search_progressdeclare) {
  464. $param .= '&search_progressdeclare='.urlencode($search_progressdeclare);
  465. }
  466. if ($search_task_budget_amount) {
  467. $param .= '&search_task_budget_amount='.urlencode($search_task_budget_amount);
  468. }
  469. if ($optioncss != '') {
  470. $param .= '&optioncss='.urlencode($optioncss);
  471. }
  472. // Add $param from extra fields
  473. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  474. // Project card
  475. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  476. $morehtmlref = '<div class="refidno">';
  477. // Title
  478. $morehtmlref .= $object->title;
  479. // Thirdparty
  480. if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
  481. $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
  482. }
  483. $morehtmlref .= '</div>';
  484. // Define a complementary filter for search of next/prev ref.
  485. if (empty($user->rights->projet->all->lire)) {
  486. $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
  487. $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
  488. }
  489. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  490. print '<div class="fichecenter">';
  491. print '<div class="fichehalfleft">';
  492. print '<div class="underbanner clearboth"></div>';
  493. print '<table class="border tableforfield centpercent">';
  494. // Usage
  495. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
  496. print '<tr><td class="tdtop">';
  497. print $langs->trans("Usage");
  498. print '</td>';
  499. print '<td>';
  500. if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
  501. print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> ';
  502. $htmltext = $langs->trans("ProjectFollowOpportunity");
  503. print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
  504. print '<br>';
  505. }
  506. if (empty($conf->global->PROJECT_HIDE_TASKS)) {
  507. print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> ';
  508. $htmltext = $langs->trans("ProjectFollowTasks");
  509. print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
  510. print '<br>';
  511. }
  512. if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
  513. 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"' : '')).'"> ';
  514. $htmltext = $langs->trans("ProjectBillTimeDescription");
  515. print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
  516. print '<br>';
  517. }
  518. if (!empty($conf->eventorganization->enabled)) {
  519. 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"' : '')).'"> ';
  520. $htmltext = $langs->trans("EventOrganizationDescriptionLong");
  521. print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
  522. }
  523. print '</td></tr>';
  524. }
  525. // Visibility
  526. print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
  527. if ($object->public) {
  528. print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
  529. print $langs->trans('SharedProject');
  530. } else {
  531. print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
  532. print $langs->trans('PrivateProject');
  533. }
  534. print '</td></tr>';
  535. // Date start - end
  536. print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
  537. $start = dol_print_date($object->date_start, 'day');
  538. print ($start ? $start : '?');
  539. $end = dol_print_date($object->date_end, 'day');
  540. print ' - ';
  541. print ($end ? $end : '?');
  542. if ($object->hasDelay()) {
  543. print img_warning("Late");
  544. }
  545. print '</td></tr>';
  546. // Budget
  547. print '<tr><td>'.$langs->trans("Budget").'</td><td>';
  548. if (strcmp($object->budget_amount, '')) {
  549. print '<span class="amount">'.price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency).'</span>';
  550. }
  551. print '</td></tr>';
  552. // Other attributes
  553. $cols = 2;
  554. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  555. print '</table>';
  556. print '</div>';
  557. print '<div class="fichehalfright">';
  558. print '<div class="underbanner clearboth"></div>';
  559. print '<table class="border tableforfield centpercent">';
  560. // Description
  561. print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
  562. print nl2br($object->description);
  563. print '</td></tr>';
  564. // Categories
  565. if ($conf->categorie->enabled) {
  566. print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
  567. print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
  568. print "</td></tr>";
  569. }
  570. print '</table>';
  571. print '</div>';
  572. print '</div>';
  573. print '<div class="clearboth"></div>';
  574. print dol_get_fiche_end();
  575. }
  576. if ($action == 'create' && $user->rights->projet->creer && (empty($object->thirdparty->id) || $userWrite > 0)) {
  577. if ($id > 0 || !empty($ref)) {
  578. print '<br>';
  579. }
  580. print load_fiche_titre($langs->trans("NewTask"), '', 'projecttask');
  581. if ($object->id > 0 && $object->statut == Project::STATUS_CLOSED) {
  582. print '<div class="warning">';
  583. $langs->load("errors");
  584. print $langs->trans("WarningProjectClosed");
  585. print '</div>';
  586. }
  587. if ($object->id > 0 && $object->statut == Project::STATUS_DRAFT) {
  588. print '<div class="warning">';
  589. $langs->load("errors");
  590. print $langs->trans("WarningProjectDraft");
  591. print '</div>';
  592. }
  593. print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
  594. print '<input type="hidden" name="token" value="'.newToken().'">';
  595. print '<input type="hidden" name="action" value="createtask">';
  596. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  597. if (!empty($object->id)) {
  598. print '<input type="hidden" name="id" value="'.$object->id.'">';
  599. }
  600. print dol_get_fiche_head('');
  601. print '<table class="border centpercent">';
  602. $defaultref = '';
  603. $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
  604. if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) {
  605. require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php';
  606. $modTask = new $obj;
  607. $defaultref = $modTask->getNextValue($object->thirdparty, null);
  608. }
  609. if (is_numeric($defaultref) && $defaultref <= 0) {
  610. $defaultref = '';
  611. }
  612. // Ref
  613. print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td>';
  614. if (empty($duplicate_code_error)) {
  615. print (GETPOSTISSET("ref") ? GETPOST("ref", 'alpha') : $defaultref);
  616. } else {
  617. print $defaultref;
  618. }
  619. print '<input type="hidden" name="taskref" value="'.(GETPOSTISSET("ref") ? GETPOST("ref", 'alpha') : $defaultref).'">';
  620. print '</td></tr>';
  621. // Label
  622. print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>';
  623. print '<input type="text" name="label" autofocus class="minwidth500 maxwidthonsmartphone" value="'.$label.'">';
  624. print '</td></tr>';
  625. // Project
  626. print '<tr><td class="fieldrequired">'.$langs->trans("ChildOfProjectTask").'</td><td>';
  627. print img_picto('', 'project');
  628. $formother->selectProjectTasks(GETPOST('task_parent'), !empty($projectid) ? $projectid : $object->id, 'task_parent', 0, 0, 1, 1, 0, '0,1', 'maxwidth500');
  629. print '</td></tr>';
  630. // Assigned to
  631. print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>';
  632. $contactsofproject = (!empty($object->id) ? $object->getListContactId('internal') : '');
  633. if (is_array($contactsofproject) && count($contactsofproject)) {
  634. print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300');
  635. } else {
  636. print '<span class="opacitymedium">'.$langs->trans("NoUserAssignedToTheProject").'</span>';
  637. }
  638. print '</td></tr>';
  639. // Date start
  640. print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
  641. print $form->selectDate((!empty($date_start) ? $date_start : ''), 'dateo', 1, 1, 0, '', 1, 1);
  642. print '</td></tr>';
  643. // Date end
  644. print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
  645. print $form->selectDate((!empty($date_end) ? $date_end : -1), 'datee', -1, 1, 0, '', 1, 1);
  646. print '</td></tr>';
  647. // Planned workload
  648. print '<tr><td>'.$langs->trans("PlannedWorkload").'</td><td>';
  649. print $form->select_duration('planned_workload', !empty($planned_workload) ? $planned_workload : 0, 0, 'text');
  650. print '</td></tr>';
  651. // Progress
  652. print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td colspan="3">';
  653. print $formother->select_percent($progress, 'progress', 0, 5, 0, 100, 1);
  654. print '</td></tr>';
  655. // Description
  656. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
  657. print '<td>';
  658. if (empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) {
  659. print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_4.'">'.$description.'</textarea>';
  660. } else {
  661. // WYSIWYG editor
  662. include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  663. $cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
  664. if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
  665. $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
  666. }
  667. $doleditor = new DolEditor('description', $object->description, '', 80, 'dolibarr_details', '', false, true, $cked_enabled, $nbrows);
  668. print $doleditor->Create();
  669. }
  670. print '</td></tr>';
  671. print '<tr><td>'.$langs->trans("Budget").'</td>';
  672. print '<td><input size="5" type="text" name="budget_amount" value="'.dol_escape_htmltag(GETPOSTISSET('budget_amount') ? GETPOST('budget_amount') : '').'"></td>';
  673. print '</tr>';
  674. // Other options
  675. $parameters = array();
  676. $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook
  677. print $hookmanager->resPrint;
  678. if (empty($reshook) && !empty($extrafields->attributes[$taskstatic->table_element]['label'])) {
  679. print $taskstatic->showOptionals($extrafields, 'edit'); // Do not use $object here that is object of project but use $taskstatic
  680. }
  681. print '</table>';
  682. print dol_get_fiche_end();
  683. print $form->buttonsSaveCancel("Add");
  684. print '</form>';
  685. } elseif ($id > 0 || !empty($ref)) {
  686. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  687. /*
  688. * Projet card in view mode
  689. */
  690. print '<br>';
  691. // Link to create task
  692. $linktocreatetaskParam = array();
  693. $linktocreatetaskUserRight = false;
  694. if ($user->rights->projet->all->creer || $user->rights->projet->creer) {
  695. if ($object->public || $userWrite > 0) {
  696. $linktocreatetaskUserRight = true;
  697. } else {
  698. $linktocreatetaskParam['attr']['title'] = $langs->trans("NotOwnerOfProject");
  699. }
  700. }
  701. $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);
  702. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
  703. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  704. print '<input type="hidden" name="token" value="'.newToken().'">';
  705. print '<input type="hidden" name="action" value="list">';
  706. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  707. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  708. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  709. print '<input type="hidden" name="page" value="'.$page.'">';
  710. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  711. $title = $langs->trans("ListOfTasks");
  712. $linktotasks = dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id, '', 1, array('morecss'=>'reposition btnTitleSelected'));
  713. $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'));
  714. //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'generic', 0, '', '', 0, 1);
  715. print load_fiche_titre($title, $linktotasks.' &nbsp; '.$linktocreatetask, 'projecttask');
  716. // Get list of tasks in tasksarray and taskarrayfiltered
  717. // 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).
  718. $filteronthirdpartyid = $socid;
  719. $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, $extrafields, 1, $search_array_options);
  720. // We load also tasks limited to a particular user
  721. $tmpuser = new User($db);
  722. if ($search_user_id > 0) {
  723. $tmpuser->fetch($search_user_id);
  724. }
  725. $tasksrole = ($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(0, $tmpuser, $object->id, 0) : '');
  726. //var_dump($tasksarray);
  727. //var_dump($tasksrole);
  728. if (!empty($conf->use_javascript_ajax)) {
  729. include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
  730. }
  731. // Filter on categories
  732. $moreforfilter = '';
  733. if (count($tasksarray) > 0) {
  734. $moreforfilter .= '<div class="divsearchfield">';
  735. $moreforfilter .= img_picto('', 'user', 'class="pictofixedwidth"');
  736. $moreforfilter .= $form->select_dolusers($tmpuser->id > 0 ? $tmpuser->id : '', 'search_user_id', $langs->trans("TasksAssignedTo"), null, 0, '', '');
  737. $moreforfilter .= '</div>';
  738. }
  739. if ($moreforfilter) {
  740. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  741. print $moreforfilter;
  742. print '</div>';
  743. }
  744. print '<div class="div-table-responsive">';
  745. print '<table id="tablelines" class="tagtable nobottom liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
  746. // Fields title search
  747. print '<tr class="liste_titre_filter">';
  748. if (!empty($arrayfields['t.ref']['checked'])) {
  749. print '<td class="liste_titre">';
  750. print '<input class="flat searchstring maxwidth50" type="text" name="search_taskref" value="'.dol_escape_htmltag($search_taskref).'">';
  751. print '</td>';
  752. }
  753. if (!empty($arrayfields['t.label']['checked'])) {
  754. print '<td class="liste_titre">';
  755. print '<input class="flat searchstring maxwidth100" type="text" name="search_tasklabel" value="'.dol_escape_htmltag($search_tasklabel).'">';
  756. print '</td>';
  757. }
  758. if (!empty($arrayfields['t.description']['checked'])) {
  759. print '<td class="liste_titre">';
  760. print '<input class="flat searchstring maxwidth100" type="text" name="search_taskdescription" value="'.dol_escape_htmltag($search_taskdescription).'">';
  761. print '</td>';
  762. }
  763. if (!empty($arrayfields['t.dateo']['checked'])) {
  764. print '<td class="liste_titre center">';
  765. /*print '<span class="nowraponall"><input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtstartday" value="'.$search_dtstartday.'">';
  766. print '<input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtstartmonth" value="'.$search_dtstartmonth.'"></span>';
  767. print $formother->selectyear($search_dtstartyear ? $search_dtstartyear : -1, 'search_dtstartyear', 1, 20, 5);*/
  768. print '<div class="nowrap">';
  769. 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'));
  770. print '</div>';
  771. print '<div class="nowrap">';
  772. 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'));
  773. print '</div>';
  774. print '</td>';
  775. }
  776. if (!empty($arrayfields['t.datee']['checked'])) {
  777. print '<td class="liste_titre center">';
  778. /*print '<span class="nowraponall"><input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtendday" value="'.$search_dtendday.'">';
  779. print '<input class="flat valignmiddle width20" type="text" maxlength="2" name="search_dtendmonth" value="'.$search_dtendmonth.'"></span>';
  780. print $formother->selectyear($search_dtendyear ? $search_dtendyear : -1, 'search_dtendyear', 1, 20, 5);*/
  781. print '<div class="nowrap">';
  782. 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'));
  783. print '</div>';
  784. print '<div class="nowrap">';
  785. 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'));
  786. print '</div>';
  787. print '</td>';
  788. }
  789. if (!empty($arrayfields['t.planned_workload']['checked'])) {
  790. print '<td class="liste_titre right">';
  791. print '<input class="flat" type="text" size="4" name="search_planedworkload" value="'.$search_planedworkload.'">';
  792. print '</td>';
  793. }
  794. if (!empty($arrayfields['t.duration_effective']['checked'])) {
  795. print '<td class="liste_titre right">';
  796. print '<input class="flat" type="text" size="4" name="search_timespend" value="'.$search_timespend.'">';
  797. print '</td>';
  798. }
  799. if (!empty($arrayfields['t.progress_calculated']['checked'])) {
  800. print '<td class="liste_titre right">';
  801. print '<input class="flat" type="text" size="4" name="search_progresscalc" value="'.$search_progresscalc.'">';
  802. print '</td>';
  803. }
  804. if (!empty($arrayfields['t.progress']['checked'])) {
  805. print '<td class="liste_titre right">';
  806. print '<input class="flat" type="text" size="4" name="search_progressdeclare" value="'.$search_progressdeclare.'">';
  807. print '</td>';
  808. }
  809. // progress resume not searchable
  810. print '<td class="liste_titre right"></td>';
  811. if ($object->usage_bill_time) {
  812. if (!empty($arrayfields['t.tobill']['checked'])) {
  813. print '<td class="liste_titre right">';
  814. print '</td>';
  815. }
  816. if (!empty($arrayfields['t.billed']['checked'])) {
  817. print '<td class="liste_titre right">';
  818. print '</td>';
  819. }
  820. }
  821. // Contacts of task, disabled because available by default jsut after
  822. /*
  823. if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) {
  824. print '<td class="liste_titre"></td>';
  825. }
  826. */
  827. if (!empty($arrayfields['t.budget_amount']['checked'])) {
  828. print '<td class="liste_titre center">';
  829. print '<input type="text" class="flat" name="search_task_budget_amount" value="'.$search_task_budget_amount.'" size="4">';
  830. print '</td>';
  831. }
  832. if (!empty($arrayfields['c.assigned']['checked'])) {
  833. print '<td class="liste_titre right">';
  834. print '</td>';
  835. }
  836. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  837. // Action column
  838. print '<td class="liste_titre maxwidthsearch">';
  839. $searchpicto = $form->showFilterButtons();
  840. print $searchpicto;
  841. print '</td>';
  842. print "</tr>\n";
  843. print '<tr class="liste_titre nodrag nodrop">';
  844. // print '<td>'.$langs->trans("Project").'</td>';
  845. if (!empty($arrayfields['t.ref']['checked'])) {
  846. print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '');
  847. }
  848. if (!empty($arrayfields['t.label']['checked'])) {
  849. print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, '');
  850. }
  851. if (!empty($arrayfields['t.description']['checked'])) {
  852. print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, '');
  853. }
  854. if (!empty($arrayfields['t.dateo']['checked'])) {
  855. print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ');
  856. }
  857. if (!empty($arrayfields['t.datee']['checked'])) {
  858. print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ');
  859. }
  860. if (!empty($arrayfields['t.planned_workload']['checked'])) {
  861. print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
  862. }
  863. if (!empty($arrayfields['t.duration_effective']['checked'])) {
  864. print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
  865. }
  866. if (!empty($arrayfields['t.progress_calculated']['checked'])) {
  867. print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
  868. }
  869. if (!empty($arrayfields['t.progress']['checked'])) {
  870. print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ', '', 1);
  871. }
  872. if (!empty($arrayfields['t.progress_summary']['checked'])) {
  873. print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '', 1);
  874. }
  875. if ($object->usage_bill_time) {
  876. if (!empty($arrayfields['t.tobill']['checked'])) {
  877. print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ');
  878. }
  879. if (!empty($arrayfields['t.billed']['checked'])) {
  880. print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ');
  881. }
  882. }
  883. // Contacts of task, disabled because available by default jsut after
  884. /*
  885. if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) {
  886. print_liste_field_titre("TaskRessourceLinks", $_SERVER["PHP_SELF"], '', '', $param, $sortfield, $sortorder);
  887. }
  888. */
  889. if (!empty($arrayfields['t.budget_amount']['checked'])) {
  890. print_liste_field_titre($arrayfields['t.budget_amount']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center ');
  891. }
  892. if (!empty($arrayfields['c.assigned']['checked'])) {
  893. print_liste_field_titre($arrayfields['c.assigned']['label'], $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ', '');
  894. }
  895. // Extra fields
  896. $disablesortlink = 1;
  897. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  898. // Hook fields
  899. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  900. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  901. print $hookmanager->resPrint;
  902. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  903. print "</tr>\n";
  904. if (count($tasksarray) > 0) {
  905. // Show all lines in taskarray (recursive function to go down on tree)
  906. $j = 0; $level = 0;
  907. $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields);
  908. } else {
  909. $colspan = 10;
  910. if ($object->usage_bill_time) {
  911. $colspan += 2;
  912. }
  913. print '<tr class="oddeven nobottom"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoTasks").'</span></td></tr>';
  914. }
  915. print "</table>";
  916. print '</div>';
  917. print '</form>';
  918. // Test if database is clean. If not we clean it.
  919. //print 'mode='.$_REQUEST["mode"].' $nboftaskshown='.$nboftaskshown.' count($tasksarray)='.count($tasksarray).' count($tasksrole)='.count($tasksrole).'<br>';
  920. 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)
  921. if ($search_user_id == $user->id) {
  922. if ($nboftaskshown < count($tasksrole)) {
  923. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  924. cleanCorruptedTree($db, 'projet_task', 'fk_task_parent');
  925. }
  926. } else {
  927. if ($nboftaskshown < count($tasksarray) && !GETPOST('search_user_id', 'int')) {
  928. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  929. cleanCorruptedTree($db, 'projet_task', 'fk_task_parent');
  930. }
  931. }
  932. }
  933. }
  934. // End of page
  935. llxFooter();
  936. $db->close();