// 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'];
}
}
}
$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) {
}
// 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.
require_once('initialize.php');
import('form.Form');
import('ttUserHelper');
+import('ttGroupHelper');
import('ttTeamHelper');
import('ttClientHelper');
import('ttTimeHelper');
$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']));
// 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);
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']);