A bit more refactoring on time entry pages.
authorNik Okuntseff <support@anuko.com>
Wed, 28 Nov 2018 14:59:19 +0000 (14:59 +0000)
committerNik Okuntseff <support@anuko.com>
Wed, 28 Nov 2018 14:59:19 +0000 (14:59 +0000)
WEB-INF/templates/footer.tpl
mobile/time.php
mobile/time_delete.php
mobile/time_edit.php
time_delete.php
time_edit.php

index 312131d..ae1e68c 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.18.28.4533 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.18.28.4534 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
index 6aa9733..2b8e01f 100644 (file)
@@ -41,6 +41,8 @@ if (!ttAccessAllowed('track_own_time')) {
 }
 // End of access checks.
 
+$user_id = $user->getUser();
+
 // Initialize and store date in session.
 $cl_date = $request->getParameter('date', @$_SESSION['date']);
 $selected_date = new DateAndTime(DB_DATEFORMAT, $cl_date);
@@ -238,20 +240,20 @@ if ($request->isPost()) {
 
     // Prohibit creating another uncompleted record.
     if ($err->no()) {
-      if (($not_completed_rec = ttTimeHelper::getUncompleted($user->getUser())) && (($cl_finish == '') && ($cl_duration == '')))
+      if (($not_completed_rec = ttTimeHelper::getUncompleted($user_id)) && (($cl_finish == '') && ($cl_duration == '')))
         $err->add($i18n->get('error.uncompleted_exists')." <a href = 'time_edit.php?id=".$not_completed_rec['id']."'>".$i18n->get('error.goto_uncompleted')."</a>");
     }
 
     // Prohibit creating an overlapping record.
     if ($err->no()) {
-      if (ttTimeHelper::overlaps($user->getUser(), $cl_date, $cl_start, $cl_finish))
+      if (ttTimeHelper::overlaps($user_id, $cl_date, $cl_start, $cl_finish))
         $err->add($i18n->get('error.overlap'));
     }
 
     if ($err->no()) {
       $id = ttTimeHelper::insert(array(
         'date' => $cl_date,
-        'user_id' => $user->getUser(),
+        'user_id' => $user_id,
         'group_id' => $user->getGroup(),
         'org_id' => $user->org_id,
         'client' => $cl_client,
@@ -283,8 +285,8 @@ if ($request->isPost()) {
 
 $smarty->assign('next_date', $next_date);
 $smarty->assign('prev_date', $prev_date);
-$smarty->assign('time_records', ttTimeHelper::getRecords($user->getUser(), $cl_date));
-$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user->getUser(), $cl_date));
+$smarty->assign('time_records', ttTimeHelper::getRecords($user_id, $cl_date));
+$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user_id, $cl_date));
 $smarty->assign('client_list', $client_list);
 $smarty->assign('project_list', $project_list);
 $smarty->assign('task_list', $task_list);
index 55bdffe..f5305bc 100644 (file)
@@ -38,7 +38,8 @@ if (!ttAccessAllowed('track_own_time')) {
   exit();
 }
 $cl_id = (int)$request->getParameter('id');
-$time_rec = ttTimeHelper::getRecord($cl_id, $user->getUser());
+$user_id = $user->getUser();
+$time_rec = ttTimeHelper::getRecord($cl_id, $user_id);
 if (!$time_rec || $time_rec['invoice_id']) {
   // Prohibit deleting not ours or invoiced records.
   header('Location: access_denied.php');
@@ -62,11 +63,8 @@ if ($request->isPost()) {
       $err->add($i18n->get('error.range_locked'));
 
     if ($err->no()) {
-
       // Delete the record.
-      $result = ttTimeHelper::delete($cl_id, $user->getUser());
-
-      if ($result) {
+      if (ttTimeHelper::delete($cl_id, $user_id)) {
         header('Location: time.php');
         exit();
       } else {
index 56d373f..b2655e8 100644 (file)
@@ -40,7 +40,8 @@ if (!ttAccessAllowed('track_own_time')) {
   exit();
 }
 $cl_id = (int)$request->getParameter('id');
-$time_rec = ttTimeHelper::getRecord($cl_id, $user->getUser());
+$user_id = $user->getUser();
+$time_rec = ttTimeHelper::getRecord($cl_id, $user_id);
 if (!$time_rec || $time_rec['invoice_id']) {
   // Prohibit editing not ours or invoiced records.
   header('Location: access_denied.php');
@@ -279,7 +280,7 @@ if ($request->isPost()) {
       // 3) Prohibit saving uncompleted unlocked entries when another uncompleted entry exists.
       $uncompleted = ($cl_finish == '' && $cl_duration == '');
       if ($uncompleted) {
-        $not_completed_rec = ttTimeHelper::getUncompleted($user->getUser());
+        $not_completed_rec = ttTimeHelper::getUncompleted($user_id);
         if ($not_completed_rec && ($time_rec['id'] <> $not_completed_rec['id'])) {
           // We have another not completed record.
           $err->add($i18n->get('error.uncompleted_exists')." <a href = 'time_edit.php?id=".$not_completed_rec['id']."'>".$i18n->get('error.goto_uncompleted')."</a>");
@@ -289,7 +290,7 @@ if ($request->isPost()) {
 
     // Prohibit creating an overlapping record.
     if ($err->no()) {
-      if (ttTimeHelper::overlaps($user->getUser(), $new_date->toString(DB_DATEFORMAT), $cl_start, $cl_finish, $cl_id))
+      if (ttTimeHelper::overlaps($user_id, $new_date->toString(DB_DATEFORMAT), $cl_start, $cl_finish, $cl_id))
         $err->add($i18n->get('error.overlap'));
     }
 
@@ -298,7 +299,7 @@ if ($request->isPost()) {
       $res = ttTimeHelper::update(array(
           'id'=>$cl_id,  
           'date'=>$new_date->toString(DB_DATEFORMAT),
-          'user_id'=>$user->getUser(),
+          'user_id'=>$user_id,
           'client'=>$cl_client,
           'project'=>$cl_project,
           'task'=>$cl_task,
index 4e368df..385e4f1 100644 (file)
@@ -38,7 +38,8 @@ if (!(ttAccessAllowed('track_own_time') || ttAccessAllowed('track_time'))) {
   exit();
 }
 $cl_id = (int)$request->getParameter('id');
-$time_rec = ttTimeHelper::getRecord($cl_id, $user->getUser());
+$user_id = $user->getUser();
+$time_rec = ttTimeHelper::getRecord($cl_id, $user_id);
 if (!$time_rec || $time_rec['invoice_id']) {
   // Prohibit deleting not ours or invoiced records.
   header('Location: access_denied.php');
@@ -62,11 +63,8 @@ if ($request->isPost()) {
       $err->add($i18n->get('error.range_locked'));
 
     if ($err->no()) {
-
       // Delete the record.
-      $result = ttTimeHelper::delete($cl_id, $user->getUser());
-
-      if ($result) {
+      if (ttTimeHelper::delete($cl_id, $user_id)) {
         header('Location: time.php');
         exit();
       } else {
index 9911009..5670f19 100644 (file)
@@ -40,7 +40,8 @@ if (!(ttAccessAllowed('track_own_time') || ttAccessAllowed('track_time'))) {
   exit();
 }
 $cl_id = (int)$request->getParameter('id');
-$time_rec = ttTimeHelper::getRecord($cl_id, $user->getUser());
+$user_id = $user->getUser();
+$time_rec = ttTimeHelper::getRecord($cl_id, $user_id);
 if (!$time_rec || $time_rec['invoice_id']) {
   // Prohibit editing not ours or invoiced records.
   header('Location: access_denied.php');
@@ -285,7 +286,7 @@ if ($request->isPost()) {
       // 3) Prohibit saving uncompleted unlocked entries when another uncompleted entry exists.
       $uncompleted = ($cl_finish == '' && $cl_duration == '');
       if ($uncompleted) {
-        $not_completed_rec = ttTimeHelper::getUncompleted($user->getUser());
+        $not_completed_rec = ttTimeHelper::getUncompleted($user_id);
         if ($not_completed_rec && ($time_rec['id'] <> $not_completed_rec['id'])) {
           // We have another not completed record.
           $err->add($i18n->get('error.uncompleted_exists')." <a href = 'time_edit.php?id=".$not_completed_rec['id']."'>".$i18n->get('error.goto_uncompleted')."</a>");
@@ -295,7 +296,7 @@ if ($request->isPost()) {
 
     // Prohibit creating an overlapping record.
     if ($err->no()) {
-      if (ttTimeHelper::overlaps($user->getUser(), $new_date->toString(DB_DATEFORMAT), $cl_start, $cl_finish, $cl_id))
+      if (ttTimeHelper::overlaps($user_id, $new_date->toString(DB_DATEFORMAT), $cl_start, $cl_finish, $cl_id))
         $err->add($i18n->get('error.overlap'));
     }
 
@@ -304,7 +305,7 @@ if ($request->isPost()) {
       $res = ttTimeHelper::update(array(
         'id'=>$cl_id,
         'date'=>$new_date->toString(DB_DATEFORMAT),
-        'user_id'=>$user->getUser(),
+        'user_id'=>$user_id,
         'client'=>$cl_client,
         'project'=>$cl_project,
         'task'=>$cl_task,
@@ -345,7 +346,7 @@ if ($request->isPost()) {
       // 2) Prohibit saving uncompleted unlocked entries when another uncompleted entry exists.
       $uncompleted = ($cl_finish == '' && $cl_duration == '');
       if ($uncompleted) {
-        $not_completed_rec = ttTimeHelper::getUncompleted($user->getUser());
+        $not_completed_rec = ttTimeHelper::getUncompleted($user_id);
         if ($not_completed_rec) {
           // We have another not completed record.
           $err->add($i18n->get('error.uncompleted_exists')." <a href = 'time_edit.php?id=".$not_completed_rec['id']."'>".$i18n->get('error.goto_uncompleted')."</a>");
@@ -355,7 +356,7 @@ if ($request->isPost()) {
 
     // Prohibit creating an overlapping record.
     if ($err->no()) {
-      if (ttTimeHelper::overlaps($user->getUser(), $new_date->toString(DB_DATEFORMAT), $cl_start, $cl_finish))
+      if (ttTimeHelper::overlaps($user_id, $new_date->toString(DB_DATEFORMAT), $cl_start, $cl_finish))
         $err->add($i18n->get('error.overlap'));
     }
 
@@ -364,7 +365,7 @@ if ($request->isPost()) {
 
       $id = ttTimeHelper::insert(array(
         'date'=>$new_date->toString(DB_DATEFORMAT),
-        'user_id'=>$user->getUser(),
+        'user_id'=>$user_id,
         'group_id'=>$user->getGroup(),
         'org_id' => $user->org_id,
         'client'=>$cl_client,