From: Nik Okuntseff Date: Sun, 30 Dec 2018 21:50:21 +0000 (+0000) Subject: Added user selector on mobile time.php. X-Git-Tag: timetracker_1.19-1~366 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=41bb577927a2b54d6a2cbc97ccc63e2935f7604b;p=timetracker.git Added user selector on mobile time.php. --- diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 645a8c46..1354a1e3 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.36.4697 | Copyright © Anuko | +  Anuko Time Tracker 1.18.36.4698 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/mobile/time.tpl b/WEB-INF/templates/mobile/time.tpl index 3b8b0f8b..35242e2f 100644 --- a/WEB-INF/templates/mobile/time.tpl +++ b/WEB-INF/templates/mobile/time.tpl @@ -48,12 +48,16 @@
+{if $user_dropdown} + + +{/if} {if $user->isPluginEnabled('cl')} - - + + {/if} {if $user->isPluginEnabled('iv')} - + {/if} {if ($custom_fields && $custom_fields->fields[0])} diff --git a/mobile/time.php b/mobile/time.php index 80049a9c..107a72c7 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -39,9 +39,32 @@ if (!ttAccessAllowed('track_own_time')) { header('Location: access_denied.php'); exit(); } +if ($user->behalf_id && (!$user->can('track_time') || !$user->checkBehalfId())) { + header('Location: access_denied.php'); // Trying on behalf, but no right or wrong user. + exit(); +} +if (!$user->behalf_id && !$user->can('track_own_time') && !$user->adjustBehalfId()) { + header('Location: access_denied.php'); // Trying as self, but no right for self, and noone to work on behalf. + exit(); +} +if ($request->isPost()) { + $userChanged = $request->getParameter('user_changed'); // Reused in multiple places below. + if ($userChanged && !($user->can('track_time') && $user->isUserValid($request->getParameter('user')))) { + header('Location: access_denied.php'); // Group changed, but no rght or wrong user id. + exit(); + } +} // End of access checks. -$user_id = $user->getUser(); +// Determine user for which we display this page. +if ($request->isPost() && $userChanged) { + $user_id = $request->getParameter('user'); + $user->setOnBehalfUser($user_id); +} else { + $user_id = $user->getUser(); +} + +$group_id = $user->getGroup(); // Initialize and store date in session. $cl_date = $request->getParameter('date', @$_SESSION['date']); @@ -89,9 +112,28 @@ $_SESSION['task'] = $cl_task; // Elements of timeRecordForm. $form = new Form('timeRecordForm'); +if ($user->can('track_time')) { + $rank = $user->getMaxRankForGroup($group_id); + if ($user->can('track_own_time')) + $options = array('group_id'=>$group_id,'status'=>ACTIVE,'max_rank'=>$rank,'include_self'=>true,'self_first'=>true); + else + $options = array('group_id'=>$group_id,'status'=>ACTIVE,'max_rank'=>$rank); + $user_list = $user->getUsers($options); + if (count($user_list) >= 1) { + $form->addInput(array('type'=>'combobox', + 'onchange'=>'document.timeRecordForm.user_changed.value=1;document.timeRecordForm.submit();', + 'name'=>'user', + 'style'=>'width: 250px;', + 'value'=>$user_id, + 'data'=>$user_list, + 'datakeys'=>array('id','name'))); + $form->addInput(array('type'=>'hidden','name'=>'user_changed')); + $smarty->assign('user_dropdown', 1); + } +} // Dropdown for clients in MODE_TIME. Use all active clients. -if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { +if (MODE_TIME == $user->getTrackingMode() && $user->isPluginEnabled('cl')) { $active_clients = ttGroupHelper::getActiveClients(true); $form->addInput(array('type'=>'combobox', 'onchange'=>'fillProjectDropdown(this.value);', @@ -104,7 +146,7 @@ if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) { // Note: in other modes the client list is filtered to relevant clients only. See below. } -if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { +if (MODE_PROJECTS == $user->getTrackingMode() || MODE_PROJECTS_AND_TASKS == $user->getTrackingMode()) { // Dropdown for projects assigned to user. $project_list = $user->getAssignedProjects(); $form->addInput(array('type'=>'combobox', @@ -145,7 +187,7 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t } } -if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { +if (MODE_PROJECTS_AND_TASKS == $user->getTrackingMode()) { $task_list = ttGroupHelper::getActiveTasks(); $form->addInput(array('type'=>'combobox', 'name'=>'task', @@ -155,7 +197,7 @@ if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { 'datakeys'=>array('id','name'), 'empty'=>array(''=>$i18n->get('dropdown.select')))); } -if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type)) { +if ((TYPE_START_FINISH == $user->getRecordType()) || (TYPE_ALL == $user->getRecordType())) { $form->addInput(array('type'=>'text','name'=>'start','value'=>$cl_start,'onchange'=>"formDisable('start');")); $form->addInput(array('type'=>'text','name'=>'finish','value'=>$cl_finish,'onchange'=>"formDisable('finish');")); if ($user->punch_mode && !$user->canOverridePunchMode()) { @@ -164,7 +206,7 @@ if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type $form->getElement('finish')->setEnabled(false); } } -if ((TYPE_DURATION == $user->record_type) || (TYPE_ALL == $user->record_type)) +if ((TYPE_DURATION == $user->getRecordType()) || (TYPE_ALL == $user->getRecordType())) $form->addInput(array('type'=>'text','name'=>'duration','value'=>$cl_duration,'onchange'=>"formDisable('duration');")); $form->addInput(array('type'=>'textarea','name'=>'note','style'=>'width: 250px; height: 60px;','value'=>$cl_note)); if ($user->isPluginEnabled('iv')) @@ -196,10 +238,10 @@ if ($request->isPost()) { if ($custom_fields) { if (!ttValidString($cl_cf_1, !$custom_fields->fields[0]['required'])) $err->add($i18n->get('error.field'), $custom_fields->fields[0]['label']); } - if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { + if (MODE_PROJECTS == $user->getTrackingMode() || MODE_PROJECTS_AND_TASKS == $user->getTrackingMode()) { if (!$cl_project) $err->add($i18n->get('error.project')); } - if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode && $user->task_required) { + if (MODE_PROJECTS_AND_TASKS == $user->getTrackingMode() && $user->task_required) { if (!$cl_task) $err->add($i18n->get('error.task')); } if (strlen($cl_duration) == 0) { @@ -213,11 +255,11 @@ if ($request->isPost()) { $err->add($i18n->get('error.interval'), $i18n->get('label.finish'), $i18n->get('label.start')); } } else { - if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type)) { + if ((TYPE_START_FINISH == $user->getRecordType()) || (TYPE_ALL == $user->getRecordType())) { $err->add($i18n->get('error.empty'), $i18n->get('label.start')); $err->add($i18n->get('error.empty'), $i18n->get('label.finish')); } - if ((TYPE_DURATION == $user->record_type) || (TYPE_ALL == $user->record_type)) + if ((TYPE_DURATION == $user->getRecordType()) || (TYPE_ALL == $user->getRecordType())) $err->add($i18n->get('error.empty'), $i18n->get('label.duration')); } } else { @@ -254,7 +296,7 @@ if ($request->isPost()) { $id = ttTimeHelper::insert(array( 'date' => $cl_date, 'user_id' => $user_id, - 'group_id' => $user->getGroup(), + 'group_id' => $group_id, 'org_id' => $user->org_id, 'client' => $cl_client, 'project' => $cl_project, @@ -292,7 +334,7 @@ $smarty->assign('project_list', $project_list); $smarty->assign('task_list', $task_list); $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('onload', 'onLoad="fillDropdowns()"'); -$smarty->assign('timestring', $selected_date->toString($user->date_format)); +$smarty->assign('timestring', $selected_date->toString($user->getDateFormat())); $smarty->assign('title', $i18n->get('title.time')); $smarty->assign('content_page_name', 'mobile/time.tpl'); $smarty->display('mobile/index.tpl'); diff --git a/time.php b/time.php index 7252f476..0431c2be 100644 --- a/time.php +++ b/time.php @@ -259,10 +259,10 @@ if ($request->isPost()) { if ($custom_fields) { if (!ttValidString($cl_cf_1, !$custom_fields->fields[0]['required'])) $err->add($i18n->get('error.field'), $custom_fields->fields[0]['label']); } - if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) { + if (MODE_PROJECTS == $user->getTrackingMode() || MODE_PROJECTS_AND_TASKS == $user->getTrackingMode()) { if (!$cl_project) $err->add($i18n->get('error.project')); } - if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode && $user->task_required) { + if (MODE_PROJECTS_AND_TASKS == $user->getTrackingMode() && $user->task_required) { if (!$cl_task) $err->add($i18n->get('error.task')); } if (strlen($cl_duration) == 0) { @@ -276,11 +276,11 @@ if ($request->isPost()) { $err->add($i18n->get('error.interval'), $i18n->get('label.finish'), $i18n->get('label.start')); } } else { - if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type)) { + if ((TYPE_START_FINISH == $user->getRecordType()) || (TYPE_ALL == $user->getRecordType())) { $err->add($i18n->get('error.empty'), $i18n->get('label.start')); $err->add($i18n->get('error.empty'), $i18n->get('label.finish')); } - if ((TYPE_DURATION == $user->record_type) || (TYPE_ALL == $user->record_type)) + if ((TYPE_DURATION == $user->getRecordType()) || (TYPE_ALL == $user->getRecordType())) $err->add($i18n->get('error.empty'), $i18n->get('label.duration')); } } else {
{$i18n.label.user}:
{$forms.timeRecordForm.user.control}
{$i18n.label.client}:
{$forms.timeRecordForm.client.control}
{$i18n.label.client}:
{$forms.timeRecordForm.client.control}
{$custom_fields->fields[0]['label']|escape}: