perweek.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  1. <?php
  2. /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2010 François Legastelois <flegastelois@teclib.com>
  6. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/projet/activity/perweek.php
  23. * \ingroup projet
  24. * \brief List activities of tasks (per week entry)
  25. */
  26. require "../../main.inc.php";
  27. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
  35. // Load translation files required by the page
  36. $langs->loadLangs(array('projects', 'users', 'companies'));
  37. $action = GETPOST('action', 'aZ09');
  38. $mode = GETPOST("mode", 'alpha');
  39. $id = GETPOST('id', 'int');
  40. $taskid = GETPOST('taskid', 'int');
  41. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'perweekcard';
  42. $mine = 0;
  43. if ($mode == 'mine') {
  44. $mine = 1;
  45. }
  46. $projectid = GETPOSTISSET("id") ? GETPOST("id", "int", 1) : GETPOST("projectid", "int");
  47. $hookmanager->initHooks(array('timesheetperweekcard'));
  48. // Security check
  49. $socid = 0;
  50. // For external user, no check is done on company because readability is managed by public status of project and assignement.
  51. // if ($user->socid > 0) $socid=$user->socid;
  52. $result = restrictedArea($user, 'projet', $projectid);
  53. $now = dol_now();
  54. $year = GETPOST('reyear', 'int') ?GETPOST('reyear', 'int') : (GETPOST("year", 'int') ?GETPOST("year", "int") : date("Y"));
  55. $month = GETPOST('remonth', 'int') ?GETPOST('remonth', 'int') : (GETPOST("month", 'int') ?GETPOST("month", "int") : date("m"));
  56. $day = GETPOST('reday', 'int') ?GETPOST('reday', 'int') : (GETPOST("day", 'int') ?GETPOST("day", "int") : date("d"));
  57. $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W");
  58. $day = (int) $day;
  59. //$search_categ = GETPOST("search_categ", 'alpha');
  60. $search_usertoprocessid = GETPOST('search_usertoprocessid', 'int');
  61. $search_task_ref = GETPOST('search_task_ref', 'alpha');
  62. $search_task_label = GETPOST('search_task_label', 'alpha');
  63. $search_project_ref = GETPOST('search_project_ref', 'alpha');
  64. $search_thirdparty = GETPOST('search_thirdparty', 'alpha');
  65. $search_declared_progress = GETPOST('search_declared_progress', 'alpha');
  66. $sortfield = GETPOST('sortfield', 'aZ09comma');
  67. $sortorder = GETPOST('sortorder', 'aZ09comma');
  68. $startdayarray = dol_get_first_day_week($day, $month, $year);
  69. $prev = $startdayarray;
  70. $prev_year = $prev['prev_year'];
  71. $prev_month = $prev['prev_month'];
  72. $prev_day = $prev['prev_day'];
  73. $first_day = $prev['first_day'];
  74. $first_month = $prev['first_month'];
  75. $first_year = $prev['first_year'];
  76. $week = $prev['week'];
  77. $next = dol_get_next_week($first_day, $week, $first_month, $first_year);
  78. $next_year = $next['year'];
  79. $next_month = $next['month'];
  80. $next_day = $next['day'];
  81. // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
  82. $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year);
  83. $firstdaytoshowgmt = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt');
  84. if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) {
  85. $usertoprocess = $user;
  86. $search_usertoprocessid = $usertoprocess->id;
  87. } elseif ($search_usertoprocessid > 0) {
  88. $usertoprocess = new User($db);
  89. $usertoprocess->fetch($search_usertoprocessid);
  90. $search_usertoprocessid = $usertoprocess->id;
  91. } else {
  92. $usertoprocess = new User($db);
  93. }
  94. $object = new Task($db);
  95. // Extra fields
  96. $extrafields = new ExtraFields($db);
  97. // fetch optionals attributes and labels
  98. $extrafields->fetch_name_optionals_label($object->table_element);
  99. // Definition of fields for list
  100. $arrayfields = array();
  101. /*$arrayfields=array(
  102. // Project
  103. 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103),
  104. 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>104),
  105. 'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>105),
  106. 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110),
  107. 'p.usage_bill_time'=>array('label'=>$langs->trans("BillTimeShort"), 'checked'=>0, 'position'=>115),
  108. );*/
  109. $arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>5);
  110. $arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>10);
  111. $arrayfields['timeconsumed'] = array('label'=>'TimeConsumed', 'checked'=>1, 'enabled'=>1, 'position'=>15);
  112. /*foreach($object->fields as $key => $val)
  113. {
  114. // If $val['visible']==0, then we never show the field
  115. if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
  116. }*/
  117. // Definition of fields for list
  118. // Extra fields
  119. if (!empty($extrafields->attributes['projet_task']['label']) && is_array($extrafields->attributes['projet_task']['label']) && count($extrafields->attributes['projet_task']['label']) > 0) {
  120. foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) {
  121. if (!empty($extrafields->attributes['projet_task']['list'][$key])) {
  122. $arrayfields["efpt.".$key] = array('label'=>$extrafields->attributes['projet_task']['label'][$key], 'checked'=>(($extrafields->attributes['projet_task']['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes['projet_task']['pos'][$key], 'enabled'=>(abs((int) $extrafields->attributes['projet_task']['list'][$key]) != 3 && $extrafields->attributes['projet_task']['perms'][$key]));
  123. }
  124. }
  125. }
  126. $arrayfields = dol_sort_array($arrayfields, 'position');
  127. $search_array_options = array();
  128. $search_array_options_project = $extrafields->getOptionalsFromPost('projet', '', 'search_');
  129. $search_array_options_task = $extrafields->getOptionalsFromPost('projet_task', '', 'search_task_');
  130. /*
  131. * Actions
  132. */
  133. $parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid);
  134. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  135. if ($reshook < 0) {
  136. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  137. }
  138. // Purge criteria
  139. 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
  140. $action = '';
  141. //$search_categ = '';
  142. $search_usertoprocessid = $user->id;
  143. $search_task_ref = '';
  144. $search_task_label = '';
  145. $search_project_ref = '';
  146. $search_thirdparty = '';
  147. $search_declared_progress = '';
  148. $search_array_options_project = array();
  149. $search_array_options_task = array();
  150. // We redefine $usertoprocess
  151. $usertoprocess = $user;
  152. }
  153. if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) {
  154. $action = '';
  155. }
  156. if (GETPOST('submitdateselect')) {
  157. if (GETPOST('remonth', 'int') && GETPOST('reday', 'int') && GETPOST('reyear', 'int')) {
  158. $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
  159. }
  160. $action = '';
  161. }
  162. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  163. if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') && GETPOST('formfilteraction') != 'listafterchangingselectedfields') {
  164. $action = 'assigntask';
  165. if ($taskid > 0) {
  166. $result = $object->fetch($taskid, $ref);
  167. if ($result < 0) {
  168. $error++;
  169. }
  170. } else {
  171. setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors');
  172. $error++;
  173. }
  174. if (!GETPOST('type')) {
  175. setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors');
  176. $error++;
  177. }
  178. if (!$error) {
  179. $idfortaskuser = $usertoprocess->id;
  180. $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal');
  181. if ($result >= 0 || $result == -2) { // Contact add ok or already contact of task
  182. // Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project)
  183. $sql = 'SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact';
  184. $sql .= ' AND ec.fk_socpeople = '.((int) $idfortaskuser)." AND ec.element_id = ".((int) $object->fk_project)." AND tc.element = 'project' AND source = 'internal'";
  185. $resql = $db->query($sql);
  186. if ($resql) {
  187. $obj = $db->fetch_object($resql);
  188. if (!$obj) { // User is not already linked to project, so we will create link to first type
  189. $project = new Project($db);
  190. $project->fetch($object->fk_project);
  191. // Get type
  192. $listofprojcontact = $project->liste_type_contact('internal');
  193. if (count($listofprojcontact)) {
  194. $typeforprojectcontact = reset(array_keys($listofprojcontact));
  195. $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal');
  196. }
  197. }
  198. } else {
  199. dol_print_error($db);
  200. }
  201. }
  202. }
  203. if ($result < 0) {
  204. $error++;
  205. if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
  206. $langs->load("errors");
  207. setEventMessages($langs->trans("ErrorTaskAlreadyAssigned"), null, 'warnings');
  208. } else {
  209. setEventMessages($object->error, $object->errors, 'errors');
  210. }
  211. }
  212. if (!$error) {
  213. setEventMessages("TaskAssignedToEnterTime", null);
  214. $taskid = 0;
  215. }
  216. $action = '';
  217. }
  218. if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') {
  219. $timetoadd = GETPOST('task');
  220. if (empty($timetoadd)) {
  221. setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors');
  222. } else {
  223. foreach ($timetoadd as $taskid => $value) { // Loop on each task
  224. $updateoftaskdone = 0;
  225. foreach ($value as $key => $val) { // Loop on each day
  226. $amountoadd = $timetoadd[$taskid][$key];
  227. if (!empty($amountoadd)) {
  228. $tmpduration = explode(':', $amountoadd);
  229. $newduration = 0;
  230. if (!empty($tmpduration[0])) {
  231. $newduration += ($tmpduration[0] * 3600);
  232. }
  233. if (!empty($tmpduration[1])) {
  234. $newduration += ($tmpduration[1] * 60);
  235. }
  236. if (!empty($tmpduration[2])) {
  237. $newduration += ($tmpduration[2]);
  238. }
  239. if ($newduration > 0) {
  240. $object->fetch($taskid);
  241. if (GETPOSTISSET($taskid.'progress')) {
  242. $object->progress = GETPOST($taskid.'progress', 'int');
  243. } else {
  244. unset($object->progress);
  245. }
  246. $object->timespent_duration = $newduration;
  247. $object->timespent_fk_user = $usertoprocess->id;
  248. $object->timespent_date = dol_time_plus_duree($firstdaytoshow, $key, 'd');
  249. $object->timespent_datehour = $object->timespent_date;
  250. $object->timespent_note = $object->description;
  251. $result = $object->addTimeSpent($user);
  252. if ($result < 0) {
  253. setEventMessages($object->error, $object->errors, 'errors');
  254. $error++;
  255. break;
  256. }
  257. $updateoftaskdone++;
  258. }
  259. }
  260. }
  261. if (!$updateoftaskdone) { // Check to update progress if no update were done on task.
  262. $object->fetch($taskid);
  263. //var_dump($object->progress);
  264. //var_dump(GETPOST($taskid . 'progress', 'int')); exit;
  265. if ($object->progress != GETPOST($taskid.'progress', 'int')) {
  266. $object->progress = GETPOST($taskid.'progress', 'int');
  267. $result = $object->update($user);
  268. if ($result < 0) {
  269. setEventMessages($object->error, $object->errors, 'errors');
  270. $error++;
  271. break;
  272. }
  273. }
  274. }
  275. }
  276. if (!$error) {
  277. setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
  278. $param = '';
  279. $param .= ($mode ? '&mode='.urlencode($mode) : '');
  280. $param .= ($projectid ? 'id='.urlencode($projectid) : '');
  281. $param .= ($search_usertoprocessid ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : '');
  282. $param .= ($day ? '&day='.urlencode($day) : '').($month ? '&month='.urlencode($month) : '').($year ? '&year='.urlencode($year) : '');
  283. $param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : '');
  284. $param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : '');
  285. $param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : '');
  286. $param .= ($search_declared_progress ? '&search_declared_progress='.urlencode($search_declared_progress) : '');
  287. $param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : '');
  288. $param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : '');
  289. /*$search_array_options=$search_array_options_project;
  290. $search_options_pattern='search_options_';
  291. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  292. */
  293. $search_array_options = $search_array_options_task;
  294. $search_options_pattern = 'search_task_options_';
  295. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  296. // Redirect to avoid submit twice on back
  297. header('Location: '.$_SERVER["PHP_SELF"].'?'.$param);
  298. exit;
  299. }
  300. }
  301. }
  302. /*
  303. * View
  304. */
  305. $form = new Form($db);
  306. $formother = new FormOther($db);
  307. $formcompany = new FormCompany($db);
  308. $formproject = new FormProjets($db);
  309. $projectstatic = new Project($db);
  310. $project = new Project($db);
  311. $taskstatic = new Task($db);
  312. $thirdpartystatic = new Societe($db);
  313. $holiday = new Holiday($db);
  314. $title = $langs->trans("TimeSpent");
  315. $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id) ? 2 : 0), 1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project
  316. //var_dump($projectsListId);
  317. if ($id) {
  318. $project->fetch($id);
  319. $project->fetch_thirdparty();
  320. }
  321. $onlyopenedproject = 1; // or -1
  322. $morewherefilter = '';
  323. if ($search_project_ref) {
  324. $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref);
  325. }
  326. if ($search_task_ref) {
  327. $morewherefilter .= natural_search("t.ref", $search_task_ref);
  328. }
  329. if ($search_task_label) {
  330. $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label);
  331. }
  332. if ($search_thirdparty) {
  333. $morewherefilter .= natural_search("s.nom", $search_thirdparty);
  334. }
  335. if ($search_declared_progress) {
  336. $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1);
  337. }
  338. $sql = &$morewherefilter;
  339. /*$search_array_options = $search_array_options_project;
  340. $extrafieldsobjectprefix='efp.';
  341. $search_options_pattern='search_options_';
  342. $extrafieldsobjectkey='projet';
  343. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  344. */
  345. $search_array_options = $search_array_options_task;
  346. $extrafieldsobjectprefix = 'efpt.';
  347. $search_options_pattern = 'search_task_options_';
  348. $extrafieldsobjectkey = 'projet_task';
  349. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  350. $tasksarray = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid ? $search_usertoprocessid : 0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later.
  351. if ($morewherefilter) { // Get all task without any filter, so we can show total of time spent for not visible tasks
  352. $tasksarraywithoutfilter = $taskstatic->getTasksArray(0, 0, ($project->id ? $project->id : 0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid ? $search_usertoprocessid : 0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later.
  353. }
  354. $projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id ? $project->id : 0), 0, $onlyopenedproject);
  355. $tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject);
  356. //var_dump($tasksarray);
  357. //var_dump($projectsrole);
  358. //var_dump($taskrole);
  359. llxHeader("", $title, "", '', '', '', array('/core/js/timesheet.js'));
  360. //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'project');
  361. $param = '';
  362. $param .= ($mode ? '&mode='.urlencode($mode) : '');
  363. $param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : '');
  364. $param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : '');
  365. $param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : '');
  366. $param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : '');
  367. $param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : '');
  368. $search_array_options = $search_array_options_project;
  369. $search_options_pattern = 'search_options_';
  370. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  371. $search_array_options = $search_array_options_task;
  372. $search_options_pattern = 'search_task_options_';
  373. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  374. // Show navigation bar
  375. $nav = '<a class="inline-block valignmiddle" href="?year='.$prev_year."&month=".$prev_month."&day=".$prev_day.$param.'">'.img_previous($langs->trans("Previous"))."</a>\n";
  376. $nav .= ' <span id="month_name">'.dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("WeekShort")." ".$week." </span>\n";
  377. $nav .= '<a class="inline-block valignmiddle" href="?year='.$next_year."&month=".$next_month."&day=".$next_day.$param.'">'.img_next($langs->trans("Next"))."</a>\n";
  378. $nav .= ' '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 1).' ';
  379. $nav .= ' <button type="submit" name="submitdateselect" value="x" class="bordertransp"><span class="fa fa-search"></span></button>';
  380. $picto = 'clock';
  381. print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  382. print '<input type="hidden" name="token" value="'.newToken().'">';
  383. print '<input type="hidden" name="action" value="addtime">';
  384. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  385. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  386. print '<input type="hidden" name="mode" value="'.$mode.'">';
  387. print '<input type="hidden" name="day" value="'.$day.'">';
  388. print '<input type="hidden" name="month" value="'.$month.'">';
  389. print '<input type="hidden" name="year" value="'.$year.'">';
  390. $head = project_timesheet_prepare_head($mode, $usertoprocess);
  391. print dol_get_fiche_head($head, 'inputperweek', $langs->trans('TimeSpent'), -1, $picto);
  392. // Show description of content
  393. print '<div class="hideonsmartphone opacitymedium">';
  394. if ($mine || ($usertoprocess->id == $user->id)) {
  395. print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>';
  396. } else {
  397. if (empty($usertoprocess->id) || $usertoprocess->id < 0) {
  398. if ($user->rights->projet->all->lire && !$socid) {
  399. print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>';
  400. } else {
  401. print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>';
  402. }
  403. }
  404. }
  405. if ($mine || ($usertoprocess->id == $user->id)) {
  406. print $langs->trans("OnlyYourTaskAreVisible").'<br>';
  407. } else {
  408. print $langs->trans("AllTaskVisibleButEditIfYouAreAssigned").'<br>';
  409. }
  410. print '</div>';
  411. print dol_get_fiche_end();
  412. print '<div class="floatright right'.($conf->dol_optimize_smallscreen ? ' centpercent' : '').'">'.$nav.'</div>'; // We move this before the assign to components so, the default submit button is not the assign to.
  413. print '<div class="colorbacktimesheet float valignmiddle">';
  414. $titleassigntask = $langs->transnoentities("AssignTaskToMe");
  415. if ($usertoprocess->id != $user->id) {
  416. $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs));
  417. }
  418. print '<div class="taskiddiv inline-block">';
  419. print img_picto('', 'projecttask', 'class="pictofixedwidth"');
  420. $formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1, 0, 0, '', '', 'all', $usertoprocess);
  421. print '</div>';
  422. print ' ';
  423. print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone');
  424. print '<input type="submit" class="button valignmiddle smallonsmartphone" name="assigntask" value="'.dol_escape_htmltag($titleassigntask).'">';
  425. print '</div>';
  426. print '<div class="clearboth" style="padding-bottom: 20px;"></div>';
  427. $startday = dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']);
  428. $numendworkingday = 0;
  429. $numstartworkingday = 0;
  430. // Get if user is available or not for each day
  431. $isavailable = array();
  432. // Assume from Monday to Friday if conf empty or badly formed
  433. $numstartworkingday = 1;
  434. $numendworkingday = 5;
  435. if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) {
  436. $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS);
  437. if (count($tmparray) >= 2) {
  438. $numstartworkingday = $tmparray[0];
  439. $numendworkingday = $tmparray[1];
  440. }
  441. }
  442. for ($idw = 0; $idw < 7; $idw++) {
  443. $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0
  444. $dayinloopfromfirstdaytoshowgmt = dol_time_plus_duree($firstdaytoshowgmt, $idw, 'd'); // $firstdaytoshow is a date with hours = 0
  445. $statusofholidaytocheck = Holiday::STATUS_APPROVED;
  446. $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, $statusofholidaytocheck);
  447. $isavailable[$dayinloopfromfirstdaytoshow] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day
  448. $test = num_public_holiday($dayinloopfromfirstdaytoshowgmt, $dayinloopfromfirstdaytoshowgmt + 86400, $mysoc->country_code);
  449. if ($test) {
  450. $isavailable[$dayinloopfromfirstdaytoshow] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday');
  451. }
  452. }
  453. $moreforfilter = '';
  454. // Filter on categories
  455. /*
  456. if (! empty($conf->categorie->enabled))
  457. {
  458. require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
  459. $moreforfilter.='<div class="divsearchfield">';
  460. $moreforfilter.=$langs->trans('ProjectCategories'). ': ';
  461. $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300');
  462. $moreforfilter.='</div>';
  463. }*/
  464. // If the user can view user other than himself
  465. $moreforfilter .= '<div class="divsearchfield">';
  466. $moreforfilter .= '<div class="inline-block hideonsmartphone"></div>';
  467. $includeonly = 'hierarchyme';
  468. if (empty($user->rights->user->user->lire)) {
  469. $includeonly = array($user->id);
  470. }
  471. $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('User'), 'user', 'class="paddingright pictofixedwidth"').$form->select_dolusers($search_usertoprocessid ? $search_usertoprocessid : $usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire ? 0 : 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200');
  472. $moreforfilter .= '</div>';
  473. if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
  474. $moreforfilter .= '<div class="divsearchfield">';
  475. $moreforfilter .= '<div class="inline-block"></div>';
  476. $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('Project'), 'project', 'class="paddingright pictofixedwidth"').'<input type="text" name="search_project_ref" class="maxwidth100" value="'.dol_escape_htmltag($search_project_ref).'">';
  477. $moreforfilter .= '</div>';
  478. $moreforfilter .= '<div class="divsearchfield">';
  479. $moreforfilter .= '<div class="inline-block"></div>';
  480. $moreforfilter .= img_picto($langs->trans('Filter').' '.$langs->trans('ThirdParty'), 'company', 'class="paddingright pictofixedwidth"').'<input type="text" name="search_thirdparty" class="maxwidth100" value="'.dol_escape_htmltag($search_thirdparty).'">';
  481. $moreforfilter .= '</div>';
  482. }
  483. if (!empty($moreforfilter)) {
  484. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  485. print $moreforfilter;
  486. $parameters = array();
  487. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  488. print $hookmanager->resPrint;
  489. print '</div>';
  490. }
  491. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  492. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  493. // This must be after the $selectedfields
  494. $addcolspan = 0;
  495. if (!empty($arrayfields['t.planned_workload']['checked'])) {
  496. $addcolspan++;
  497. }
  498. if (!empty($arrayfields['t.progress']['checked'])) {
  499. $addcolspan++;
  500. }
  501. foreach ($arrayfields as $key => $val) {
  502. if ($val['checked'] && substr($key, 0, 5) == 'efpt.') {
  503. $addcolspan++;
  504. }
  505. }
  506. print '<div class="div-table-responsive">';
  507. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">'."\n";
  508. print '<tr class="liste_titre_filter">';
  509. if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
  510. print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
  511. }
  512. if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
  513. print '<td class="liste_titre"><input type="text" size="4" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).'"></td>';
  514. }
  515. print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>';
  516. // TASK fields
  517. $search_options_pattern = 'search_task_options_';
  518. $extrafieldsobjectkey = 'projet_task';
  519. $extrafieldsobjectprefix = 'efpt.';
  520. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  521. if (!empty($arrayfields['t.planned_workload']['checked'])) {
  522. print '<td class="liste_titre"></td>';
  523. }
  524. if (!empty($arrayfields['t.progress']['checked'])) {
  525. print '<td class="liste_titre right"><input type="text" size="4" name="search_declared_progress" value="'.dol_escape_htmltag($search_declared_progress).'"></td>';
  526. }
  527. if (!empty($arrayfields['timeconsumed']['checked'])) {
  528. print '<td class="liste_titre"></td>';
  529. print '<td class="liste_titre"></td>';
  530. }
  531. for ($idw = 0; $idw < 7; $idw++) {
  532. print '<td class="liste_titre"></td>';
  533. }
  534. // Action column
  535. print '<td class="liste_titre nowrap right">';
  536. $searchpicto = $form->showFilterAndCheckAddButtons(0);
  537. print $searchpicto;
  538. print '</td>';
  539. print "</tr>\n";
  540. print '<tr class="liste_titre">';
  541. if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
  542. print '<th>'.$langs->trans("Project").'</th>';
  543. }
  544. if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
  545. print '<th>'.$langs->trans("ThirdParty").'</th>';
  546. }
  547. print '<th>'.$langs->trans("Task").'</th>';
  548. // TASK fields
  549. $extrafieldsobjectkey = 'projet_task';
  550. $extrafieldsobjectprefix = 'efpt.';
  551. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  552. if (!empty($arrayfields['t.planned_workload']['checked'])) {
  553. print '<th class="leftborder plannedworkload minwidth75 maxwidth100 right" title="'.dol_escape_htmltag($langs->trans("PlannedWorkload")).'">'.$langs->trans("PlannedWorkload").'</th>';
  554. }
  555. if (!empty($arrayfields['t.progress']['checked'])) {
  556. print '<th class="right minwidth75 maxwidth100" title="'.dol_escape_htmltag($langs->trans("ProgressDeclared")).'">'.$langs->trans("ProgressDeclared").'</th>';
  557. }
  558. if (!empty($arrayfields['timeconsumed']['checked'])) {
  559. print '<th class="right maxwidth100">'.$langs->trans("TimeSpent").'<br>';
  560. print '<span class="nowraponall">';
  561. print '<span class="opacitymedium nopadding userimg"><img alt="Photo" class="photouserphoto userphoto" src="'.DOL_URL_ROOT.'/theme/common/everybody.png"></span>';
  562. print '<span class="opacitymedium paddingleft">'.$langs->trans("Everybody").'</span>';
  563. print '</span>';
  564. print '</th>';
  565. print '<th class="right maxwidth75 maxwidth100">'.$langs->trans("TimeSpent").($usertoprocess->firstname ? '<br><span class="nowraponall">'.$usertoprocess->getNomUrl(-2).'<span class="opacitymedium paddingleft">'.dol_trunc($usertoprocess->firstname, 10).'</span></span>' : '').'</th>';
  566. }
  567. for ($idw = 0; $idw < 7; $idw++) {
  568. $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0
  569. $cssweekend = '';
  570. if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css.
  571. $cssweekend = 'weekend';
  572. }
  573. $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
  574. $cssonholiday = '';
  575. if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
  576. $cssonholiday .= 'onholidayallday ';
  577. } elseif (!$isavailable[$tmpday]['morning']) {
  578. $cssonholiday .= 'onholidaymorning ';
  579. } elseif (!$isavailable[$tmpday]['afternoon']) {
  580. $cssonholiday .= 'onholidayafternoon ';
  581. }
  582. print '<th width="6%" class="center bold hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">';
  583. print dol_print_date($dayinloopfromfirstdaytoshow, '%a');
  584. print '<br>'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'</th>';
  585. }
  586. //print '<td></td>';
  587. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  588. print "</tr>\n";
  589. $colspan = 1 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2);
  590. if ($conf->use_javascript_ajax) {
  591. print '<tr class="liste_total">';
  592. print '<td class="liste_total" colspan="'.($colspan + $addcolspan).'">';
  593. print $langs->trans("Total");
  594. print '<span class="opacitymediumbycolor"> - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong></span>';
  595. print '</td>';
  596. if (!empty($arrayfields['timeconsumed']['checked'])) {
  597. print '<td class="liste_total"></td>';
  598. print '<td class="liste_total"></td>';
  599. }
  600. for ($idw = 0; $idw < 7; $idw++) {
  601. $cssweekend = '';
  602. if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css.
  603. $cssweekend = 'weekend';
  604. }
  605. $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
  606. $cssonholiday = '';
  607. if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
  608. $cssonholiday .= 'onholidayallday ';
  609. } elseif (!$isavailable[$tmpday]['morning']) {
  610. $cssonholiday .= 'onholidaymorning ';
  611. } elseif (!$isavailable[$tmpday]['afternoon']) {
  612. $cssonholiday .= 'onholidayafternoon ';
  613. }
  614. print '<td class="liste_total hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'" align="center"><div class="totalDay'.$idw.'">&nbsp;</div></td>';
  615. }
  616. print '<td class="liste_total center"><div class="totalDayAll">&nbsp;</div></td>';
  617. print '</tr>';
  618. }
  619. // By default, we can edit only tasks we are assigned to
  620. $restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED);
  621. if (count($tasksarray) > 0) {
  622. //var_dump($tasksarray); // contains only selected tasks
  623. //var_dump($tasksarraywithoutfilter); // contains all tasks (if there is a filter, not defined if no filter)
  624. //var_dump($tasksrole);
  625. $j = 0;
  626. $level = 0;
  627. $totalforvisibletasks = projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable, 0, $arrayfields, $extrafields);
  628. //var_dump($totalforvisibletasks);
  629. // Show total for all other tasks
  630. // Calculate total for all tasks
  631. $listofdistinctprojectid = array(); // List of all distinct projects
  632. if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
  633. foreach ($tasksarraywithoutfilter as $tmptask) {
  634. $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project;
  635. }
  636. }
  637. //var_dump($listofdistinctprojectid);
  638. $totalforeachday = array();
  639. foreach ($listofdistinctprojectid as $tmpprojectid) {
  640. $projectstatic->id = $tmpprojectid;
  641. $projectstatic->loadTimeSpent($firstdaytoshow, 0, $usertoprocess->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
  642. for ($idw = 0; $idw < 7; $idw++) {
  643. $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
  644. $totalforeachday[$tmpday] += $projectstatic->weekWorkLoad[$tmpday];
  645. }
  646. }
  647. //var_dump($totalforeachday);
  648. //var_dump($totalforvisibletasks);
  649. // Is there a diff between selected/filtered tasks and all tasks ?
  650. $isdiff = 0;
  651. if (count($totalforeachday)) {
  652. for ($idw = 0; $idw < 7; $idw++) {
  653. $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
  654. $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]);
  655. if ($timeonothertasks) {
  656. $isdiff = 1;
  657. break;
  658. }
  659. }
  660. }
  661. // There is a diff between total shown on screen and total spent by user, so we add a line with all other cumulated time of user
  662. if ($isdiff) {
  663. print '<tr class="oddeven othertaskwithtime">';
  664. print '<td colspan="'.($colspan + $addcolspan).'" class="opacitymedium">';
  665. print $langs->trans("OtherFilteredTasks");
  666. print '</td>';
  667. if (!empty($arrayfields['timeconsumed']['checked'])) {
  668. print '<td class="liste_total"></td>';
  669. print '<td class="liste_total"></td>';
  670. }
  671. for ($idw = 0; $idw < 7; $idw++) {
  672. $cssweekend = '';
  673. if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css.
  674. $cssweekend = 'weekend';
  675. }
  676. print '<td class="center hide'.$idw.' '.($cssweekend ? ' '.$cssweekend : '').'">';
  677. $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
  678. $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]);
  679. if ($timeonothertasks) {
  680. print '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled="" id="timespent[-1]['.$idw.']" name="task[-1]['.$idw.']" value="';
  681. print convertSecondToTime($timeonothertasks, 'allhourmin');
  682. print '"></span>';
  683. }
  684. print '</td>';
  685. }
  686. print ' <td class="liste_total"></td>';
  687. print '</tr>';
  688. }
  689. if ($conf->use_javascript_ajax) {
  690. print '<tr class="liste_total">';
  691. print '<td class="liste_total" colspan="'.($colspan + $addcolspan).'">';
  692. print $langs->trans("Total");
  693. print '<span class="opacitymediumbycolor"> - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong></span>';
  694. print '</td>';
  695. if (!empty($arrayfields['timeconsumed']['checked'])) {
  696. print '<td class="liste_total"></td>';
  697. print '<td class="liste_total"></td>';
  698. }
  699. for ($idw = 0; $idw < 7; $idw++) {
  700. $cssweekend = '';
  701. if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css.
  702. $cssweekend = 'weekend';
  703. }
  704. $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
  705. $cssonholiday = '';
  706. if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
  707. $cssonholiday .= 'onholidayallday ';
  708. } elseif (!$isavailable[$tmpday]['morning']) {
  709. $cssonholiday .= 'onholidaymorning ';
  710. } elseif (!$isavailable[$tmpday]['afternoon']) {
  711. $cssonholiday .= 'onholidayafternoon ';
  712. }
  713. print '<td class="liste_total hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'" align="center"><div class="totalDay'.$idw.'">&nbsp;</div></td>';
  714. }
  715. print '<td class="liste_total center"><div class="totalDayAll">&nbsp;</div></td>';
  716. print '</tr>';
  717. }
  718. } else {
  719. print '<tr><td colspan="15"><span class="opacitymedium">'.$langs->trans("NoAssignedTasks").'</span></td></tr>';
  720. }
  721. print "</table>";
  722. print '</div>';
  723. print '<input type="hidden" id="numberOfLines" name="numberOfLines" value="'.count($tasksarray).'"/>'."\n";
  724. print $form->buttonsSaveCancel("Save", '');
  725. print '</form>'."\n\n";
  726. $modeinput = 'hours';
  727. if ($conf->use_javascript_ajax) {
  728. print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n";
  729. print '<script type="text/javascript">'."\n";
  730. print "jQuery(document).ready(function () {\n";
  731. print ' jQuery(".timesheetalreadyrecorded").tooltip({
  732. show: { collision: "flipfit", effect:\'toggle\', delay:50 },
  733. hide: { effect:\'toggle\', delay: 50 },
  734. tooltipClass: "mytooltip",
  735. content: function () {
  736. return \''.dol_escape_js($langs->trans("TimeAlreadyRecorded", $usertoprocess->getFullName($langs))).'\';
  737. }
  738. });'."\n";
  739. $idw = 0;
  740. while ($idw < 7) {
  741. print ' updateTotal('.$idw.',\''.$modeinput.'\');';
  742. $idw++;
  743. }
  744. print "\n});\n";
  745. print '</script>';
  746. }
  747. // End of page
  748. llxFooter();
  749. $db->close();