tasks.php 47 KB

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