perweek.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  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. $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd');
  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. $arrayfields = array();
  100. /*$arrayfields=array(
  101. // Project
  102. 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103),
  103. 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>104),
  104. 'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>105),
  105. 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110),
  106. 'p.usage_bill_time'=>array('label'=>$langs->trans("BillTimeShort"), 'checked'=>0, 'position'=>115),
  107. );*/
  108. $arrayfields['t.planned_workload'] = array('label'=>'PlannedWorkload', 'checked'=>1, 'enabled'=>1, 'position'=>5);
  109. $arrayfields['t.progress'] = array('label'=>'ProgressDeclared', 'checked'=>1, 'enabled'=>1, 'position'=>10);
  110. $arrayfields['timeconsumed'] = array('label'=>'TimeConsumed', 'checked'=>1, 'enabled'=>1, 'position'=>15);
  111. /*foreach($object->fields as $key => $val)
  112. {
  113. // If $val['visible']==0, then we never show the field
  114. if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
  115. }*/
  116. // Definition of fields for list
  117. // Extra fields
  118. if (!empty($extrafields->attributes['projet_task']['label']) && is_array($extrafields->attributes['projet_task']['label']) && count($extrafields->attributes['projet_task']['label']) > 0) {
  119. foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) {
  120. if (!empty($extrafields->attributes['projet_task']['list'][$key])) {
  121. $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]));
  122. }
  123. }
  124. }
  125. $arrayfields = dol_sort_array($arrayfields, 'position');
  126. $search_array_options = array();
  127. $search_array_options_project = $extrafields->getOptionalsFromPost('projet', '', 'search_');
  128. $search_array_options_task = $extrafields->getOptionalsFromPost('projet_task', '', 'search_task_');
  129. /*
  130. * Actions
  131. */
  132. $parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid);
  133. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  134. if ($reshook < 0) {
  135. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  136. }
  137. // Purge criteria
  138. 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
  139. $action = '';
  140. //$search_categ = '';
  141. $search_usertoprocessid = $user->id;
  142. $search_task_ref = '';
  143. $search_task_label = '';
  144. $search_project_ref = '';
  145. $search_thirdparty = '';
  146. $search_declared_progress = '';
  147. $search_array_options_project = array();
  148. $search_array_options_task = array();
  149. // We redefine $usertoprocess
  150. $usertoprocess = $user;
  151. }
  152. if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) {
  153. $action = '';
  154. }
  155. if (GETPOST('submitdateselect')) {
  156. if (GETPOST('remonth', 'int') && GETPOST('reday', 'int') && GETPOST('reyear', 'int')) {
  157. $daytoparse = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
  158. }
  159. $action = '';
  160. }
  161. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  162. if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') && GETPOST('formfilteraction') != 'listafterchangingselectedfields') {
  163. $action = 'assigntask';
  164. if ($taskid > 0) {
  165. $result = $object->fetch($taskid, $ref);
  166. if ($result < 0) {
  167. $error++;
  168. }
  169. } else {
  170. setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors');
  171. $error++;
  172. }
  173. if (!GETPOST('type')) {
  174. setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors');
  175. $error++;
  176. }
  177. if (!$error) {
  178. $idfortaskuser = $usertoprocess->id;
  179. $result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal');
  180. if ($result >= 0 || $result == -2) { // Contact add ok or already contact of task
  181. // 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)
  182. $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';
  183. $sql .= ' AND ec.fk_socpeople = '.((int) $idfortaskuser)." AND ec.element_id = ".((int) $object->fk_project)." AND tc.element = 'project' AND source = 'internal'";
  184. $resql = $db->query($sql);
  185. if ($resql) {
  186. $obj = $db->fetch_object($resql);
  187. if (!$obj) { // User is not already linked to project, so we will create link to first type
  188. $project = new Project($db);
  189. $project->fetch($object->fk_project);
  190. // Get type
  191. $listofprojcontact = $project->liste_type_contact('internal');
  192. if (count($listofprojcontact)) {
  193. $typeforprojectcontact = reset(array_keys($listofprojcontact));
  194. $result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal');
  195. }
  196. }
  197. } else {
  198. dol_print_error($db);
  199. }
  200. }
  201. }
  202. if ($result < 0) {
  203. $error++;
  204. if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
  205. $langs->load("errors");
  206. setEventMessages($langs->trans("ErrorTaskAlreadyAssigned"), null, 'warnings');
  207. } else {
  208. setEventMessages($object->error, $object->errors, 'errors');
  209. }
  210. }
  211. if (!$error) {
  212. setEventMessages("TaskAssignedToEnterTime", null);
  213. $taskid = 0;
  214. }
  215. $action = '';
  216. }
  217. if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') {
  218. $timetoadd = GETPOST('task');
  219. if (empty($timetoadd)) {
  220. setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors');
  221. } else {
  222. foreach ($timetoadd as $taskid => $value) { // Loop on each task
  223. $updateoftaskdone = 0;
  224. foreach ($value as $key => $val) { // Loop on each day
  225. $amountoadd = $timetoadd[$taskid][$key];
  226. if (!empty($amountoadd)) {
  227. $tmpduration = explode(':', $amountoadd);
  228. $newduration = 0;
  229. if (!empty($tmpduration[0])) {
  230. $newduration += ($tmpduration[0] * 3600);
  231. }
  232. if (!empty($tmpduration[1])) {
  233. $newduration += ($tmpduration[1] * 60);
  234. }
  235. if (!empty($tmpduration[2])) {
  236. $newduration += ($tmpduration[2]);
  237. }
  238. if ($newduration > 0) {
  239. $object->fetch($taskid);
  240. if (GETPOSTISSET($taskid.'progress')) {
  241. $object->progress = GETPOST($taskid.'progress', 'int');
  242. } else {
  243. unset($object->progress);
  244. }
  245. $object->timespent_duration = $newduration;
  246. $object->timespent_fk_user = $usertoprocess->id;
  247. $object->timespent_date = dol_time_plus_duree($firstdaytoshow, $key, 'd');
  248. $object->timespent_datehour = $object->timespent_date;
  249. $object->timespent_note = $object->description;
  250. $result = $object->addTimeSpent($user);
  251. if ($result < 0) {
  252. setEventMessages($object->error, $object->errors, 'errors');
  253. $error++;
  254. break;
  255. }
  256. $updateoftaskdone++;
  257. }
  258. }
  259. }
  260. if (!$updateoftaskdone) { // Check to update progress if no update were done on task.
  261. $object->fetch($taskid);
  262. //var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit;
  263. if ($object->progress != GETPOST($taskid.'progress', 'int')) {
  264. $object->progress = GETPOST($taskid.'progress', 'int');
  265. $result = $object->update($user);
  266. if ($result < 0) {
  267. setEventMessages($object->error, $object->errors, 'errors');
  268. $error++;
  269. break;
  270. }
  271. }
  272. }
  273. }
  274. if (!$error) {
  275. setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
  276. $param = '';
  277. $param .= ($mode ? '&mode='.urlencode($mode) : '');
  278. $param .= ($projectid ? 'id='.urlencode($projectid) : '');
  279. $param .= ($search_usertoprocessid ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : '');
  280. $param .= ($day ? '&day='.urlencode($day) : '').($month ? '&month='.urlencode($month) : '').($year ? '&year='.urlencode($year) : '');
  281. $param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : '');
  282. $param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : '');
  283. $param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : '');
  284. $param .= ($search_declared_progress ? '&search_declared_progress='.urlencode($search_declared_progress) : '');
  285. $param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : '');
  286. $param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : '');
  287. /*$search_array_options=$search_array_options_project;
  288. $search_options_pattern='search_options_';
  289. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  290. */
  291. $search_array_options = $search_array_options_task;
  292. $search_options_pattern = 'search_task_options_';
  293. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  294. // Redirect to avoid submit twice on back
  295. header('Location: '.$_SERVER["PHP_SELF"].'?'.$param);
  296. exit;
  297. }
  298. }
  299. }
  300. /*
  301. * View
  302. */
  303. $form = new Form($db);
  304. $formother = new FormOther($db);
  305. $formcompany = new FormCompany($db);
  306. $formproject = new FormProjets($db);
  307. $projectstatic = new Project($db);
  308. $project = new Project($db);
  309. $taskstatic = new Task($db);
  310. $thirdpartystatic = new Societe($db);
  311. $holiday = new Holiday($db);
  312. $title = $langs->trans("TimeSpent");
  313. $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
  314. //var_dump($projectsListId);
  315. if ($id) {
  316. $project->fetch($id);
  317. $project->fetch_thirdparty();
  318. }
  319. $onlyopenedproject = 1; // or -1
  320. $morewherefilter = '';
  321. if ($search_project_ref) {
  322. $morewherefilter .= natural_search(array("p.ref", "p.title"), $search_project_ref);
  323. }
  324. if ($search_task_ref) {
  325. $morewherefilter .= natural_search("t.ref", $search_task_ref);
  326. }
  327. if ($search_task_label) {
  328. $morewherefilter .= natural_search(array("t.ref", "t.label"), $search_task_label);
  329. }
  330. if ($search_thirdparty) {
  331. $morewherefilter .= natural_search("s.nom", $search_thirdparty);
  332. }
  333. if ($search_declared_progress) {
  334. $morewherefilter .= natural_search("t.progress", $search_declared_progress, 1);
  335. }
  336. $sql = &$morewherefilter;
  337. /*$search_array_options = $search_array_options_project;
  338. $extrafieldsobjectprefix='efp.';
  339. $search_options_pattern='search_options_';
  340. $extrafieldsobjectkey='projet';
  341. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  342. */
  343. $search_array_options = $search_array_options_task;
  344. $extrafieldsobjectprefix = 'efpt.';
  345. $search_options_pattern = 'search_task_options_';
  346. $extrafieldsobjectkey = 'projet_task';
  347. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
  348. $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.
  349. if ($morewherefilter) { // Get all task without any filter, so we can show total of time spent for not visible tasks
  350. $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.
  351. }
  352. $projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id ? $project->id : 0), 0, $onlyopenedproject);
  353. $tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id ? $project->id : 0), 0, $onlyopenedproject);
  354. //var_dump($tasksarray);
  355. //var_dump($projectsrole);
  356. //var_dump($taskrole);
  357. llxHeader("", $title, "", '', '', '', array('/core/js/timesheet.js'));
  358. //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'project');
  359. $param = '';
  360. $param .= ($mode ? '&mode='.urlencode($mode) : '');
  361. $param .= ($search_project_ref ? '&search_project_ref='.urlencode($search_project_ref) : '');
  362. $param .= ($search_usertoprocessid > 0 ? '&search_usertoprocessid='.urlencode($search_usertoprocessid) : '');
  363. $param .= ($search_thirdparty ? '&search_thirdparty='.urlencode($search_thirdparty) : '');
  364. $param .= ($search_task_ref ? '&search_task_ref='.urlencode($search_task_ref) : '');
  365. $param .= ($search_task_label ? '&search_task_label='.urlencode($search_task_label) : '');
  366. $search_array_options = $search_array_options_project;
  367. $search_options_pattern = 'search_options_';
  368. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  369. $search_array_options = $search_array_options_task;
  370. $search_options_pattern = 'search_task_options_';
  371. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  372. // Show navigation bar
  373. $nav = '<a class="inline-block valignmiddle" href="?year='.$prev_year."&month=".$prev_month."&day=".$prev_day.$param.'">'.img_previous($langs->trans("Previous"))."</a>\n";
  374. $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";
  375. $nav .= '<a class="inline-block valignmiddle" href="?year='.$next_year."&month=".$next_month."&day=".$next_day.$param.'">'.img_next($langs->trans("Next"))."</a>\n";
  376. $nav .= ' '.$form->selectDate(-1, '', 0, 0, 2, "addtime", 1, 1).' ';
  377. $nav .= ' <button type="submit" name="submitdateselect" value="x" class="bordertransp"><span class="fa fa-search"></span></button>';
  378. $picto = 'clock';
  379. print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  380. print '<input type="hidden" name="token" value="'.newToken().'">';
  381. print '<input type="hidden" name="action" value="addtime">';
  382. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  383. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  384. print '<input type="hidden" name="mode" value="'.$mode.'">';
  385. print '<input type="hidden" name="day" value="'.$day.'">';
  386. print '<input type="hidden" name="month" value="'.$month.'">';
  387. print '<input type="hidden" name="year" value="'.$year.'">';
  388. $head = project_timesheet_prepare_head($mode, $usertoprocess);
  389. print dol_get_fiche_head($head, 'inputperweek', $langs->trans('TimeSpent'), -1, $picto);
  390. // Show description of content
  391. print '<div class="hideonsmartphone opacitymedium">';
  392. if ($mine || ($usertoprocess->id == $user->id)) {
  393. print $langs->trans("MyTasksDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>';
  394. } else {
  395. if (empty($usertoprocess->id) || $usertoprocess->id < 0) {
  396. if ($user->rights->projet->all->lire && !$socid) {
  397. print $langs->trans("ProjectsDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>';
  398. } else {
  399. print $langs->trans("ProjectsPublicTaskDesc").'.'.($onlyopenedproject ? ' '.$langs->trans("OnlyOpenedProject") : '').'<br>';
  400. }
  401. }
  402. }
  403. if ($mine || ($usertoprocess->id == $user->id)) {
  404. print $langs->trans("OnlyYourTaskAreVisible").'<br>';
  405. } else {
  406. print $langs->trans("AllTaskVisibleButEditIfYouAreAssigned").'<br>';
  407. }
  408. print '</div>';
  409. print dol_get_fiche_end();
  410. 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.
  411. print '<div class="colorbacktimesheet float valignmiddle">';
  412. $titleassigntask = $langs->transnoentities("AssignTaskToMe");
  413. if ($usertoprocess->id != $user->id) {
  414. $titleassigntask = $langs->transnoentities("AssignTaskToUser", $usertoprocess->getFullName($langs));
  415. }
  416. print '<div class="taskiddiv inline-block">';
  417. print img_picto('', 'projecttask', 'class="pictofixedwidth"');
  418. $formproject->selectTasks($socid ? $socid : -1, $taskid, 'taskid', 32, 0, '-- '.$langs->trans("ChooseANotYetAssignedTask").' --', 1, 0, 0, '', '', 'all', $usertoprocess);
  419. print '</div>';
  420. print ' ';
  421. print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone');
  422. print '<input type="submit" class="button valignmiddle smallonsmartphone" name="assigntask" value="'.dol_escape_htmltag($titleassigntask).'">';
  423. print '</div>';
  424. print '<div class="clearboth" style="padding-bottom: 20px;"></div>';
  425. $startday = dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']);
  426. $numendworkingday = 0;
  427. $numstartworkingday = 0;
  428. // Get if user is available or not for each day
  429. $isavailable = array();
  430. if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) {
  431. $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS);
  432. if (count($tmparray) >= 2) {
  433. $numstartworkingday = $tmparray[0];
  434. $numendworkingday = $tmparray[1];
  435. }
  436. }
  437. for ($idw = 0; $idw < 7; $idw++) {
  438. $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0
  439. // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow
  440. //$tmparray = dol_getdate($dayinloop);
  441. //$dayinloopwithouthours=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']);
  442. //print dol_print_date($dayinloop, 'dayhour').' ';
  443. //print dol_print_date($dayinloopwithouthours, 'dayhour').' ';
  444. //print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour').'<br>';
  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($dayinloopfromfirstdaytoshow, $dayinloopfromfirstdaytoshow + 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. //var_dump($isavailable);
  454. $moreforfilter = '';
  455. // Filter on categories
  456. /*
  457. if (! empty($conf->categorie->enabled))
  458. {
  459. require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
  460. $moreforfilter.='<div class="divsearchfield">';
  461. $moreforfilter.=$langs->trans('ProjectCategories'). ': ';
  462. $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300');
  463. $moreforfilter.='</div>';
  464. }*/
  465. // If the user can view user other than himself
  466. $moreforfilter .= '<div class="divsearchfield">';
  467. $moreforfilter .= '<div class="inline-block hideonsmartphone"></div>';
  468. $includeonly = 'hierarchyme';
  469. if (empty($user->rights->user->user->lire)) {
  470. $includeonly = array($user->id);
  471. }
  472. $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');
  473. $moreforfilter .= '</div>';
  474. if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
  475. $moreforfilter .= '<div class="divsearchfield">';
  476. $moreforfilter .= '<div class="inline-block"></div>';
  477. $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).'">';
  478. $moreforfilter .= '</div>';
  479. $moreforfilter .= '<div class="divsearchfield">';
  480. $moreforfilter .= '<div class="inline-block"></div>';
  481. $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).'">';
  482. $moreforfilter .= '</div>';
  483. }
  484. if (!empty($moreforfilter)) {
  485. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  486. print $moreforfilter;
  487. $parameters = array();
  488. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  489. print $hookmanager->resPrint;
  490. print '</div>';
  491. }
  492. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  493. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  494. // This must be after the $selectedfields
  495. $addcolspan = 0;
  496. if (!empty($arrayfields['t.planned_workload']['checked'])) {
  497. $addcolspan++;
  498. }
  499. if (!empty($arrayfields['t.progress']['checked'])) {
  500. $addcolspan++;
  501. }
  502. foreach ($arrayfields as $key => $val) {
  503. if ($val['checked'] && substr($key, 0, 5) == 'efpt.') {
  504. $addcolspan++;
  505. }
  506. }
  507. print '<div class="div-table-responsive">';
  508. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">'."\n";
  509. print '<tr class="liste_titre_filter">';
  510. if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
  511. print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
  512. }
  513. if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
  514. print '<td class="liste_titre"><input type="text" size="4" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).'"></td>';
  515. }
  516. print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>';
  517. // TASK fields
  518. $search_options_pattern = 'search_task_options_';
  519. $extrafieldsobjectkey = 'projet_task';
  520. $extrafieldsobjectprefix = 'efpt.';
  521. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  522. if (!empty($arrayfields['t.planned_workload']['checked'])) {
  523. print '<td class="liste_titre"></td>';
  524. }
  525. if (!empty($arrayfields['t.progress']['checked'])) {
  526. print '<td class="liste_titre right"><input type="text" size="4" name="search_declared_progress" value="'.dol_escape_htmltag($search_declared_progress).'"></td>';
  527. }
  528. if (!empty($arrayfields['timeconsumed']['checked'])) {
  529. print '<td class="liste_titre"></td>';
  530. print '<td class="liste_titre"></td>';
  531. }
  532. for ($idw = 0; $idw < 7; $idw++) {
  533. print '<td class="liste_titre"></td>';
  534. }
  535. // Action column
  536. print '<td class="liste_titre nowrap right">';
  537. $searchpicto = $form->showFilterAndCheckAddButtons(0);
  538. print $searchpicto;
  539. print '</td>';
  540. print "</tr>\n";
  541. print '<tr class="liste_titre">';
  542. if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
  543. print '<th>'.$langs->trans("Project").'</th>';
  544. }
  545. if (!empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) {
  546. print '<th>'.$langs->trans("ThirdParty").'</th>';
  547. }
  548. print '<th>'.$langs->trans("Task").'</th>';
  549. // TASK fields
  550. $extrafieldsobjectkey = 'projet_task';
  551. $extrafieldsobjectprefix = 'efpt.';
  552. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  553. if (!empty($arrayfields['t.planned_workload']['checked'])) {
  554. print '<th class="right leftborder plannedworkload maxwidth75 right">'.$langs->trans("PlannedWorkload").'</th>';
  555. }
  556. if (!empty($arrayfields['t.progress']['checked'])) {
  557. print '<th class="maxwidth75 right">'.$langs->trans("ProgressDeclared").'</th>';
  558. }
  559. if (!empty($arrayfields['timeconsumed']['checked'])) {
  560. print '<th class="right maxwidth100">'.$langs->trans("TimeSpent").'<br>';
  561. print '<span class="nowraponall">';
  562. print '<span class="opacitymedium nopadding userimg"><img alt="Photo" class="photouserphoto userphoto" src="'.DOL_URL_ROOT.'/theme/common/everybody.png"></span>';
  563. print '<span class="opacitymedium paddingleft">'.$langs->trans("Everybody").'</span>';
  564. print '</span>';
  565. print '</th>';
  566. print '<th class="maxwidth75 right">'.$langs->trans("TimeSpent").($usertoprocess->firstname ? '<br><span class="nowraponall">'.$usertoprocess->getNomUrl(-2).'<span class="opacitymedium paddingleft">'.dol_trunc($usertoprocess->firstname, 10).'</span></span>' : '').'</th>';
  567. }
  568. for ($idw = 0; $idw < 7; $idw++) {
  569. $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0
  570. $dayinloop = dol_time_plus_duree($startday, $idw, 'd');
  571. /*print $dayinloopfromfirstdaytoshow;
  572. print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour', 'gmt');
  573. print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour');
  574. print dol_print_date($dayinloopfromfirstdaytoshow, '%a', 'gmt');
  575. print dol_print_date($dayinloopfromfirstdaytoshow, '%a');
  576. print '<br>';*/
  577. $cssweekend = '';
  578. 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.
  579. $cssweekend = 'weekend';
  580. }
  581. $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
  582. $cssonholiday = '';
  583. if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
  584. $cssonholiday .= 'onholidayallday ';
  585. } elseif (!$isavailable[$tmpday]['morning']) {
  586. $cssonholiday .= 'onholidaymorning ';
  587. } elseif (!$isavailable[$tmpday]['afternoon']) {
  588. $cssonholiday .= 'onholidayafternoon ';
  589. }
  590. print '<th width="6%" align="center" class="bold hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'">';
  591. print dol_print_date($dayinloopfromfirstdaytoshow, '%a');
  592. print '<br>'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'</th>';
  593. }
  594. //print '<td></td>';
  595. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  596. print "</tr>\n";
  597. $colspan = 1 + (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : 2);
  598. if ($conf->use_javascript_ajax) {
  599. print '<tr class="liste_total">';
  600. print '<td class="liste_total" colspan="'.($colspan + $addcolspan).'">';
  601. print $langs->trans("Total");
  602. print '<span class="opacitymediumbycolor"> - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong></span>';
  603. print '</td>';
  604. if (!empty($arrayfields['timeconsumed']['checked'])) {
  605. print '<td class="liste_total"></td>';
  606. print '<td class="liste_total"></td>';
  607. }
  608. for ($idw = 0; $idw < 7; $idw++) {
  609. $cssweekend = '';
  610. 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.
  611. $cssweekend = 'weekend';
  612. }
  613. $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
  614. $cssonholiday = '';
  615. if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
  616. $cssonholiday .= 'onholidayallday ';
  617. } elseif (!$isavailable[$tmpday]['morning']) {
  618. $cssonholiday .= 'onholidaymorning ';
  619. } elseif (!$isavailable[$tmpday]['afternoon']) {
  620. $cssonholiday .= 'onholidayafternoon ';
  621. }
  622. print '<td class="liste_total hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'" align="center"><div class="totalDay'.$idw.'">&nbsp;</div></td>';
  623. }
  624. print '<td class="liste_total center"><div class="totalDayAll">&nbsp;</div></td>';
  625. print '</tr>';
  626. }
  627. // By default, we can edit only tasks we are assigned to
  628. $restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED);
  629. if (count($tasksarray) > 0) {
  630. //var_dump($tasksarray); // contains only selected tasks
  631. //var_dump($tasksarraywithoutfilter); // contains all tasks (if there is a filter, not defined if no filter)
  632. //var_dump($tasksrole);
  633. $j = 0;
  634. $level = 0;
  635. $totalforvisibletasks = projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable, 0, $arrayfields, $extrafields);
  636. //var_dump($totalforvisibletasks);
  637. // Show total for all other tasks
  638. // Calculate total for all tasks
  639. $listofdistinctprojectid = array(); // List of all distinct projects
  640. if (is_array($tasksarraywithoutfilter) && count($tasksarraywithoutfilter)) {
  641. foreach ($tasksarraywithoutfilter as $tmptask) {
  642. $listofdistinctprojectid[$tmptask->fk_project] = $tmptask->fk_project;
  643. }
  644. }
  645. //var_dump($listofdistinctprojectid);
  646. $totalforeachday = array();
  647. foreach ($listofdistinctprojectid as $tmpprojectid) {
  648. $projectstatic->id = $tmpprojectid;
  649. $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
  650. for ($idw = 0; $idw < 7; $idw++) {
  651. $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
  652. $totalforeachday[$tmpday] += $projectstatic->weekWorkLoad[$tmpday];
  653. }
  654. }
  655. //var_dump($totalforeachday);
  656. //var_dump($totalforvisibletasks);
  657. // Is there a diff between selected/filtered tasks and all tasks ?
  658. $isdiff = 0;
  659. if (count($totalforeachday)) {
  660. for ($idw = 0; $idw < 7; $idw++) {
  661. $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
  662. $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]);
  663. if ($timeonothertasks) {
  664. $isdiff = 1;
  665. break;
  666. }
  667. }
  668. }
  669. // 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
  670. if ($isdiff) {
  671. print '<tr class="oddeven othertaskwithtime">';
  672. print '<td colspan="'.($colspan + $addcolspan).'" class="opacitymedium">';
  673. print $langs->trans("OtherFilteredTasks");
  674. print '</td>';
  675. if (!empty($arrayfields['timeconsumed']['checked'])) {
  676. print '<td class="liste_total"></td>';
  677. print '<td class="liste_total"></td>';
  678. }
  679. for ($idw = 0; $idw < 7; $idw++) {
  680. $cssweekend = '';
  681. 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.
  682. $cssweekend = 'weekend';
  683. }
  684. print '<td class="center hide'.$idw.' '.($cssweekend ? ' '.$cssweekend : '').'">';
  685. $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
  686. $timeonothertasks = ($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]);
  687. if ($timeonothertasks) {
  688. print '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled="" id="timespent[-1]['.$idw.']" name="task[-1]['.$idw.']" value="';
  689. print convertSecondToTime($timeonothertasks, 'allhourmin');
  690. print '"></span>';
  691. }
  692. print '</td>';
  693. }
  694. print ' <td class="liste_total"></td>';
  695. print '</tr>';
  696. }
  697. if ($conf->use_javascript_ajax) {
  698. print '<tr class="liste_total">';
  699. print '<td class="liste_total" colspan="'.($colspan + $addcolspan).'">';
  700. print $langs->trans("Total");
  701. print '<span class="opacitymediumbycolor"> - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong></span>';
  702. print '</td>';
  703. if (!empty($arrayfields['timeconsumed']['checked'])) {
  704. print '<td class="liste_total"></td>';
  705. print '<td class="liste_total"></td>';
  706. }
  707. for ($idw = 0; $idw < 7; $idw++) {
  708. $cssweekend = '';
  709. 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.
  710. $cssweekend = 'weekend';
  711. }
  712. $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd');
  713. $cssonholiday = '';
  714. if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) {
  715. $cssonholiday .= 'onholidayallday ';
  716. } elseif (!$isavailable[$tmpday]['morning']) {
  717. $cssonholiday .= 'onholidaymorning ';
  718. } elseif (!$isavailable[$tmpday]['afternoon']) {
  719. $cssonholiday .= 'onholidayafternoon ';
  720. }
  721. print '<td class="liste_total hide'.$idw.($cssonholiday ? ' '.$cssonholiday : '').($cssweekend ? ' '.$cssweekend : '').'" align="center"><div class="totalDay'.$idw.'">&nbsp;</div></td>';
  722. }
  723. print '<td class="liste_total center"><div class="totalDayAll">&nbsp;</div></td>';
  724. print '</tr>';
  725. }
  726. } else {
  727. print '<tr><td colspan="15"><span class="opacitymedium">'.$langs->trans("NoAssignedTasks").'</span></td></tr>';
  728. }
  729. print "</table>";
  730. print '</div>';
  731. print '<input type="hidden" id="numberOfLines" name="numberOfLines" value="'.count($tasksarray).'"/>'."\n";
  732. print $form->buttonsSaveCancel("Save", '');
  733. print '</form>'."\n\n";
  734. $modeinput = 'hours';
  735. if ($conf->use_javascript_ajax) {
  736. print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n";
  737. print '<script type="text/javascript">'."\n";
  738. print "jQuery(document).ready(function () {\n";
  739. print ' jQuery(".timesheetalreadyrecorded").tooltip({
  740. show: { collision: "flipfit", effect:\'toggle\', delay:50 },
  741. hide: { effect:\'toggle\', delay: 50 },
  742. tooltipClass: "mytooltip",
  743. content: function () {
  744. return \''.dol_escape_js($langs->trans("TimeAlreadyRecorded", $usertoprocess->getFullName($langs))).'\';
  745. }
  746. });'."\n";
  747. $idw = 0;
  748. while ($idw < 7) {
  749. print ' updateTotal('.$idw.',\''.$modeinput.'\');';
  750. $idw++;
  751. }
  752. print "\n});\n";
  753. print '</script>';
  754. }
  755. // End of page
  756. llxFooter();
  757. $db->close();