From: Nik Okuntseff Date: Fri, 2 Nov 2018 17:36:47 +0000 (+0000) Subject: A bit more work in progress on subgroups. X-Git-Tag: timetracker_1.19-1~727 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=948617a6a0f129ba4090934ee8f544009dbcd935;p=timetracker.git A bit more work in progress on subgroups. --- diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index d28c3067..22362b5b 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -48,4 +48,18 @@ class ttGroupHelper { } return false; } + + // The getGroupName function returns group name. + static function getGroupName($group_id) { + $mdb2 = getConnection(); + + $sql = "select name from tt_groups where id = $group_id and (status = 1 or status = 0)"; + $res = $mdb2->query($sql); + + if (!is_a($res, 'PEAR_Error')) { + $val = $res->fetchRow(); + return $val['name']; + } + return false; + } } diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index e7fa3fa0..21cd19aa 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -155,7 +155,7 @@ class ttUser { // Set "on behalf" id and name (group). if (isset($_SESSION['behalf_group_id'])) { $this->behalf_group_id = $_SESSION['behalf_group_id']; - $this->behalf_group = $_SESSION['behalf_group']; + $this->behalf_group = $_SESSION['behalf_group_name']; } } } @@ -371,6 +371,7 @@ class ttUser { $mdb2 = getConnection(); $selected_group_id = ($this->behalf_group_id ? $this->behalf_group_id : $this->group_id); + $selected_group_name = ($this->behalf_group_id ? $this->behalf_group : $this->group); // Start with parent group. if ($selected_group_id != $this->org_id) { @@ -394,7 +395,6 @@ class ttUser { } // Add current group. - $selected_group_name = ($this->behalf_group_id ? $this->behalf_group : $this->group); $groups[] = array('id'=>$selected_group_id,'name'=>$selected_group_name); // Add subgroups. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index e635a977..3f32ac03 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.06.4350 | Copyright © Anuko | +  Anuko Time Tracker 1.18.06.4351 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/time.tpl b/WEB-INF/templates/time.tpl index f532be42..0e05f05b 100644 --- a/WEB-INF/templates/time.tpl +++ b/WEB-INF/templates/time.tpl @@ -18,6 +18,12 @@
+{if $on_behalf_group_control} + + + + +{/if} {if $on_behalf_control} diff --git a/time.php b/time.php index 98f6bbaf..5307d8b2 100644 --- a/time.php +++ b/time.php @@ -29,6 +29,7 @@ require_once('initialize.php'); import('form.Form'); import('ttUserHelper'); +import('ttGroupHelper'); import('ttTeamHelper'); import('ttClientHelper'); import('ttTimeHelper'); @@ -95,6 +96,7 @@ if ($user->isPluginEnabled('iv')) { $cl_billable = $_SESSION['billable']; } $on_behalf_id = $request->getParameter('onBehalfUser', (isset($_SESSION['behalf_id'])? $_SESSION['behalf_id'] : $user->id)); +$on_behalf_group_id = $request->getParameter('onBehalfGroup', (isset($_SESSION['behalf_group_id'])? $_SESSION['behalf_group_id'] : $user->group_id)); $cl_client = $request->getParameter('client', ($request->isPost() ? null : @$_SESSION['client'])); $_SESSION['client'] = $cl_client; $cl_project = $request->getParameter('project', ($request->isPost() ? null : @$_SESSION['project'])); @@ -105,6 +107,22 @@ $_SESSION['task'] = $cl_task; // Elements of timeRecordForm. $form = new Form('timeRecordForm'); +if (defined('SUBGROUP_DEBUG') && isTrue(SUBGROUP_DEBUG)) { +if ($user->can('manage_subgroups')) { + $groups = $user->getGroups(); + if (count($groups) > 1) { + $form->addInput(array('type'=>'combobox', + 'onchange'=>'this.form.submit();', + 'name'=>'onBehalfGroup', + 'style'=>'width: 250px;', + 'value'=>$on_behalf_group_id, + 'data'=>$groups, + 'datakeys'=>array('id','name'))); + $smarty->assign('on_behalf_group_control', 1); + } +} +} // SUBGROUP_DEBUG + if ($user->can('track_time')) { if ($user->can('track_own_time')) $options = array('status'=>ACTIVE,'max_rank'=>$user->rank-1,'include_self'=>true,'self_first'=>true); @@ -347,6 +365,19 @@ if ($request->isPost()) { exit(); } } + elseif ($request->getParameter('onBehalfGroup')) { + if($user->can('manage_subgroups')) { + unset($_SESSION['behalf_group_id']); + unset($_SESSION['behalf_group_name']); + + if($on_behalf_group_id != $user->group_id) { + $_SESSION['behalf_group_id'] = $on_behalf_group_id; + $_SESSION['behalf_group_name'] = ttGroupHelper::getGroupName($on_behalf_group_id); + } + header('Location: time.php'); + exit(); + } + } elseif ($request->getParameter('onBehalfUser')) { if($user->can('track_time')) { unset($_SESSION['behalf_id']);
{$i18n.label.group}:{$forms.timeRecordForm.onBehalfGroup.control}
{$i18n.label.user}: