+// Determine user for whom we display this page.
+$notClient = !$user->isClient();
+if ($request->isPost() && $userChanged) {
+ $user_id = $request->getParameter('user');
+} else {
+ if ($notClient)
+ $user_id = $user->getUser();
+ else
+ $user_id = $users_for_client[0]['id']; // First found user for a client.
+}
+
+
+$group_id = $user->getGroup();
+
+// Elements of timesheetsForm.
+$form = new Form('timesheetsForm');
+
+if ($user->can('view_timesheets') || $user->can('view_all_timesheets') || $user->can('manage_timesheets') || $user->can('manage_all_timesheets')) {
+ $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.timesheetsForm.user_changed.value=1;document.timesheetsForm.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);
+ }
+}
+
+
+
+
+// TODO: fix this for client access.
+$active_timesheets = ttTimesheetHelper::getActiveTimesheets($user_id);
+$inactive_timesheets = ttTimesheetHelper::getInactiveTimesheets($user_id);
+$show_client = $user->isPluginEnabled('cl') && $notClient;