]> wagnertech.de Git - timetracker.git/commitdiff
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 c0dd256d5ef85b11f6156c4332ceda5c04fc8e9c..ed00f3a501cee01d51b3bcbc8cb900377b5b5e69 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 915d241f292ca329ae0944e89b803016c46b1eb8..697d541fc78b44efffaeaeb92ac1013dcdfdacd4 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 51d01cc2b6a183e6d193ba3c4230195619b76753..f7bb80640f192b07f913bb7655824fe9c2a09d6c 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 827eadcaeaa8dfefb0efb3ccbd40629c83a43380..0479f0cdbdd14060e4e19aa4d7a7368531385b92 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 1e1a3897d662e920608d8001124e807090d9d709..06ea90919e69b0a43cb75ce86d798e290565ec15 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 fc13d0c5f97abc962a862d37f0d686bba0257df3..e9afa970554547978673472c47d7d7dd4266f8a8 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 9fca8898a9a54d87f5bc6db04650c35618ec9823..39bac8015fe360993806a5a39b9a5ce593dd1683 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 6071997147ed27e5660537da4d8f9343122c1ed6..5f135e45a6b5e465870158e5728f10f42fa2afb9 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);