Added audit info for template create and modify events.
[timetracker.git] / time.php
index 5a9b521..4f0d591 100644 (file)
--- a/time.php
+++ b/time.php
@@ -56,7 +56,7 @@ if ($request->isPost()) {
 }
 // End of access checks.
 
-// Determine user for which we display this page.
+// Determine user for whom we display this page.
 if ($request->isPost() && $userChanged) {
   $user_id = $request->getParameter('user');
   $user->setOnBehalfUser($user_id);
@@ -131,9 +131,9 @@ $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);
+    $options = array('status'=>ACTIVE,'max_rank'=>$rank,'include_self'=>true,'self_first'=>true);
   else
-    $options = array('group_id'=>$group_id,'status'=>ACTIVE,'max_rank'=>$rank);
+    $options = array('status'=>ACTIVE,'max_rank'=>$rank);
   $user_list = $user->getUsers($options);
   if (count($user_list) >= 1) {
     $form->addInput(array('type'=>'combobox',
@@ -249,6 +249,22 @@ if ($custom_fields && $custom_fields->fields[0]) {
   }
 }
 
+// If we have templates, add a dropdown to select one.
+if ($user->isPluginEnabled('tp')){
+  $templates = ttGroupHelper::getActiveTemplates();
+  if (count($templates) >= 1) {
+    $form->addInput(array('type'=>'combobox',
+      'onchange'=>'fillNote(this.value);',
+      'name'=>'template',
+      'style'=>'width: 250px;',
+      'data'=>$templates,
+      'datakeys'=>array('id','name'),
+      'empty'=>array(''=>$i18n->get('dropdown.select'))));
+    $smarty->assign('template_dropdown', 1);
+    $smarty->assign('templates', $templates);
+  }
+}
+
 // Submit.
 if ($request->isPost()) {
   if ($request->getParameter('btn_submit')) {
@@ -288,6 +304,10 @@ if ($request->isPost()) {
         $err->add($i18n->get('error.field'), $i18n->get('label.duration'));
     }
     if (!ttValidString($cl_note, true)) $err->add($i18n->get('error.field'), $i18n->get('label.note'));
+    if ($user->isPluginEnabled('tp') && strpos($cl_note, '%req%') !== false) {
+      // A %req% element is found in note. They have to be replaced by user.
+      $err->add($i18n->get('error.field'), $i18n->get('label.note'));
+    }
     if (!ttTimeHelper::canAdd()) $err->add($i18n->get('error.expired'));
     // Finished validating user input.
 
@@ -347,7 +367,7 @@ if ($request->isPost()) {
   } elseif ($request->getParameter('btn_stop')) {
     // Stop button pressed to finish an uncompleted record.
     $record_id = $request->getParameter('record_id');
-    $record = ttTimeHelper::getRecord($record_id, $user_id);
+    $record = ttTimeHelper::getRecord($record_id);
     $browser_date = $request->getParameter('browser_date');
     $browser_time = $request->getParameter('browser_time');