]> wagnertech.de Git - timetracker.git/blobdiff - timesheet_add.php
A bit of refactoring.
[timetracker.git] / timesheet_add.php
index e8eb5659109efe7599932c1de3e1165a4a728c9f..294886be754ece683846bd8441d0c54bdddf51f0 100644 (file)
@@ -31,7 +31,7 @@ import('form.Form');
 import('ttTimesheetHelper');
 
 // Access checks.
-if (!(ttAccessAllowed('manage_own_timesheets') || ttAccessAllowed('manage_timesheets') || ttAccessAllowed('manage_all_timesheets'))) {
+if (!(ttAccessAllowed('track_own_time') || ttAccessAllowed('track_time'))) {
   header('Location: access_denied.php');
   exit();
 }
@@ -89,18 +89,13 @@ if ($request->isPost()) {
   if ($err->no() && !ttTimesheetHelper::timesheetItemsExist($fields)) $err->add($i18n->get('error.no_records'));
   // Finished validating user input.
 
-  /*
   if ($err->no()) {
-    // TODO: use $fields.
-    if (ttTimesheetHelper::insert(array('user_id' => $user_id,
-        'client_id' => $bean->getAttribute('client'),
-        'name' => $cl_name,
-        'comment' => $cl_comment))) {
-          header('Location: timesheets.php');
-          exit();
-        } else
-          $err->add($i18n->get('error.db'));
-    } */
+    if (ttTimesheetHelper::createTimesheet($fields)) {
+      header('Location: timesheets.php');
+      exit();
+    } else
+      $err->add($i18n->get('error.db'));
+  }
 } // isPost
 
 $smarty->assign('forms', array($form->getName()=>$form->toArray()));