tasks.php 44 KB

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