From 11cfcc792a4c3578abce0ef3f1b933f3858b5c1d Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Thu, 15 Feb 2018 19:17:03 +0000 Subject: [PATCH] Implemented a configurable punch in mode as per issue #53. --- WEB-INF/config.php.dist | 6 ------ WEB-INF/lib/ttUser.class.php | 5 +++++ WEB-INF/templates/profile_edit.tpl | 4 ++++ mobile/time.php | 2 +- mobile/time_edit.php | 2 +- profile_edit.php | 7 +++++++ time.php | 2 +- time_edit.php | 2 +- 8 files changed, 20 insertions(+), 10 deletions(-) diff --git a/WEB-INF/config.php.dist b/WEB-INF/config.php.dist index c0dd256d..ed00f3a5 100644 --- a/WEB-INF/config.php.dist +++ b/WEB-INF/config.php.dist @@ -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. diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 915d241f..697d541f 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -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; } } diff --git a/WEB-INF/templates/profile_edit.tpl b/WEB-INF/templates/profile_edit.tpl index 51d01cc2..f7bb8064 100644 --- a/WEB-INF/templates/profile_edit.tpl +++ b/WEB-INF/templates/profile_edit.tpl @@ -172,6 +172,10 @@ function handlePluginCheckboxes() { {$i18n.form.profile.record_type}: {$forms.profileForm.record_type.control} + + {$i18n.form.profile.punch_in_mode}: + {$forms.profileForm.punch_in_mode.control} {$i18n.label.what_is_it} + {$i18n.form.profile.allow_overlap}: {$forms.profileForm.allow_overlap.control} {$i18n.label.what_is_it} diff --git a/mobile/time.php b/mobile/time.php index 827eadca..0479f0cd 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -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); diff --git a/mobile/time_edit.php b/mobile/time_edit.php index 1e1a3897..06ea9091 100644 --- a/mobile/time_edit.php +++ b/mobile/time_edit.php @@ -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); diff --git a/profile_edit.php b/profile_edit.php index fc13d0c5..e9afa970 100644 --- a/profile_edit.php +++ b/profile_edit.php @@ -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) diff --git a/time.php b/time.php index 9fca8898..39bac801 100644 --- 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); diff --git a/time_edit.php b/time_edit.php index 60719971..5f135e45 100644 --- a/time_edit.php +++ b/time_edit.php @@ -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); -- 2.20.1