Implemented a configurable punch in mode as per issue #53.
authorNik Okuntseff <support@anuko.com>
Thu, 15 Feb 2018 19:17:03 +0000 (19:17 +0000)
committerNik Okuntseff <support@anuko.com>
Thu, 15 Feb 2018 19:17:38 +0000 (19:17 +0000)
WEB-INF/config.php.dist
WEB-INF/lib/ttUser.class.php
WEB-INF/templates/profile_edit.tpl
mobile/time.php
mobile/time_edit.php
profile_edit.php
time.php
time_edit.php

index c0dd256..ed00f3a 100644 (file)
@@ -75,12 +75,6 @@ define('APP_NAME', '');
 define('COST_ON_REPORTS', true);
 
 
-// READONLY_START_FINISH - defines whether the start and finish fields on time entry pages are read-only.
-// This applies to regular users only. Manager and co-managers can edit these values.
-//
-// define('READONLY_START_FINISH', false);
-
-
 // WEEKEND_START_DAY
 //
 // This option defines which days are highlighted with weekend color.
index 915d241..697d541 100644 (file)
@@ -46,6 +46,7 @@ class ttUser {
   var $project_required = 0;    // Whether project selection is required on time entires.
   var $task_required = 0;       // Whether task selection is required on time entires.
   var $record_type = 0;         // Record type (duration vs start and finish, or both).
+  var $punch_in_mode = 0;       // Whether punch in mode is enabled for user.
   var $allow_overlap = 0;       // Whether to allow overlapping time entries.
   var $future_entries = 0;      // Whether to allow creating future entries.
   var $uncompleted_indicators = 0; // Uncompleted time entry indicators (show nowhere or on users page).
@@ -115,6 +116,7 @@ class ttUser {
 
       // Set user config options.
       $this->show_holidays = in_array('show_holidays', $config_array);
+      $this->punch_in_mode = in_array('punch_in_mode', $config_array);
       $this->allow_overlap = in_array('allow_overlap', $config_array);
       $this->future_entries = in_array('future_entries', $config_array);
       $this->uncompleted_indicators = in_array('uncompleted_indicators', $config_array);
@@ -137,6 +139,9 @@ class ttUser {
       } elseif ($this->role == ROLE_SITE_ADMIN) {
         $this->rights = right_administer_site;
       }
+
+      // Adjust punch_in_mode for managers as they are allowed to overwrite start and end times.
+      if ($this->canManageTeam()) $this->punch_in_mode = 0;
     }
   }
 
index 51d01cc..f7bb806 100644 (file)
@@ -172,6 +172,10 @@ function handlePluginCheckboxes() {
             <td align="right" nowrap>{$i18n.form.profile.record_type}:</td>
             <td>{$forms.profileForm.record_type.control}</td>
           </tr>
+          <tr>
+            <td align="right" nowrap>{$i18n.form.profile.punch_in_mode}:</td>
+            <td>{$forms.profileForm.punch_in_mode.control} <a href="https://www.anuko.com/lp/tt_18.htm" target="_blank">{$i18n.label.what_is_it}</a></td>
+          </tr>
           <tr>
             <td align="right" nowrap>{$i18n.form.profile.allow_overlap}:</td>
             <td>{$forms.profileForm.allow_overlap.control} <a href="https://www.anuko.com/lp/tt_16.htm" target="_blank">{$i18n.label.what_is_it}</a></td>
index 827eadc..0479f0c 100644 (file)
@@ -155,7 +155,7 @@ if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
 if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type)) {
   $form->addInput(array('type'=>'text','name'=>'start','value'=>$cl_start,'onchange'=>"formDisable('start');"));
   $form->addInput(array('type'=>'text','name'=>'finish','value'=>$cl_finish,'onchange'=>"formDisable('finish');"));
-  if (!$user->canManageTeam() && defined('READONLY_START_FINISH') && isTrue(READONLY_START_FINISH)) {
+  if ($user->punch_in_mode) {
     // Make the start and finish fields read-only.
     $form->getElement('start')->setEnabled(false);
     $form->getElement('finish')->setEnabled(false);
index 1e1a389..06ea909 100644 (file)
@@ -175,7 +175,7 @@ if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
 if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type)) {
   $form->addInput(array('type'=>'text','name'=>'start','value'=>$cl_start,'onchange'=>"formDisable('start');"));
   $form->addInput(array('type'=>'text','name'=>'finish','value'=>$cl_finish,'onchange'=>"formDisable('finish');"));
-  if (!$user->canManageTeam() && defined('READONLY_START_FINISH') && isTrue(READONLY_START_FINISH)) {
+  if ($user->punch_in_mode) {
     // Make the start and finish fields read-only.
     $form->getElement('start')->setEnabled(false);
     $form->getElement('finish')->setEnabled(false);
index fc13d0c..e9afa97 100644 (file)
@@ -62,6 +62,7 @@ if ($request->isPost()) {
     $cl_project_required = $request->getParameter('project_required');
     $cl_task_required = $request->getParameter('task_required');
     $cl_record_type = $request->getParameter('record_type');
+    $cl_punch_in_mode = $request->getParameter('punch_in_mode');
     $cl_allow_overlap = $request->getParameter('allow_overlap');
     $cl_future_entries = $request->getParameter('future_entries');
     $cl_uncompleted_indicators = $request->getParameter('uncompleted_indicators');
@@ -98,6 +99,7 @@ if ($request->isPost()) {
     $cl_project_required = $user->project_required;
     $cl_task_required = $user->task_required;
     $cl_record_type = $user->record_type;
+    $cl_punch_in_mode = $user->punch_in_mode;
     $cl_allow_overlap = $user->allow_overlap;
     $cl_future_entries = $user->future_entries;
     $cl_uncompleted_indicators = $user->uncompleted_indicators;
@@ -193,6 +195,9 @@ if ($user->canManageTeam()) {
   $record_type_options[TYPE_DURATION] = $i18n->getKey('form.profile.type_duration');
   $form->addInput(array('type'=>'combobox','name'=>'record_type','style'=>'width: 150px;','data'=>$record_type_options,'value'=>$cl_record_type));
 
+  // Punch in mode checkbox.
+  $form->addInput(array('type'=>'checkbox','name'=>'punch_in_mode','value'=>$cl_punch_in_mode));
+
   // Allow overlap checkbox.
   $form->addInput(array('type'=>'checkbox','name'=>'allow_overlap','value'=>$cl_allow_overlap));
 
@@ -293,6 +298,8 @@ if ($request->isPost()) {
       // Prepare config string.
       if ($cl_show_holidays)
         $config .= ',show_holidays';
+      if ($cl_punch_in_mode)
+        $config .= ',punch_in_mode';
       if ($cl_allow_overlap)
         $config .= ',allow_overlap';
       if ($cl_future_entries)
index 9fca889..39bac80 100644 (file)
--- a/time.php
+++ b/time.php
@@ -187,7 +187,7 @@ if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
 if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type)) {
   $form->addInput(array('type'=>'text','name'=>'start','value'=>$cl_start,'onchange'=>"formDisable('start');"));
   $form->addInput(array('type'=>'text','name'=>'finish','value'=>$cl_finish,'onchange'=>"formDisable('finish');"));
-  if (!$user->canManageTeam() && defined('READONLY_START_FINISH') && isTrue(READONLY_START_FINISH)) {
+  if ($user->punch_in_mode) {
     // Make the start and finish fields read-only.
     $form->getElement('start')->setEnabled(false);
     $form->getElement('finish')->setEnabled(false);
index 6071997..5f135e4 100644 (file)
@@ -178,7 +178,7 @@ if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
 if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type)) {
   $form->addInput(array('type'=>'text','name'=>'start','value'=>$cl_start,'onchange'=>"formDisable('start');"));
   $form->addInput(array('type'=>'text','name'=>'finish','value'=>$cl_finish,'onchange'=>"formDisable('finish');"));
-  if (!$user->canManageTeam() && defined('READONLY_START_FINISH') && isTrue(READONLY_START_FINISH)) {
+  if ($user->punch_in_mode) {
     // Make the start and finish fields read-only.
     $form->getElement('start')->setEnabled(false);
     $form->getElement('finish')->setEnabled(false);