I'll try to do some renaming after this merge.
$record_type_v = '';
}
+ $uncompleted_entries = $fields['uncompleted_entries'];
+ if ($uncompleted_entries !== null) {
+ $uncompleted_entries_f = ', uncompleted_entries';
+ $uncompleted_entries_v = ', ' . (int)$uncompleted_entries;
+ } else {
+ $uncompleted_entries_f = '';
+ $uncompleted_entries_v = '';
+ }
+
$workday_hours = $fields['workday_hours'];
if ($workday_hours !== null) {
$workday_hours_f = ', workday_hours';
$workday_hours_v = '';
}
- $sql = "insert into tt_teams (name, address, currency $lockspec_f, lang $decimal_mark_f $date_format_f $time_format_f $week_start_f $plugins_f $tracking_mode_f $record_type_f $workday_hours_f)
+ $sql = "insert into tt_teams (name, address, currency $lockspec_f, lang $decimal_mark_f $date_format_f $time_format_f $week_start_f $plugins_f $tracking_mode_f $record_type_f $uncompleted_entries_f $workday_hours_f)
values(".$mdb2->quote(trim($fields['name'])).
", ".$mdb2->quote(trim($fields['address'])).
", ".$mdb2->quote(trim($fields['currency']))." $lockspec_v, ".$mdb2->quote($lang).
- "$decimal_mark_v $date_format_v $time_format_v $week_start_v $plugins_v $tracking_mode_v $record_type_v $workday_hours_v)";
+ "$decimal_mark_v $date_format_v $time_format_v $week_start_v $plugins_v $tracking_mode_v $record_type_v $uncompleted_entries_v $workday_hours_v)";
$affected = $mdb2->exec($sql);
if (!is_a($affected, 'PEAR_Error')) {
$week_start_part = '';
$tracking_mode_part = '';
$record_type_part = '';
+ $uncompleted_entries_part = '';
$plugins_part = '';
$lock_spec_part = '';
$workday_hours_part = '';
if (isset($fields['week_start'])) $week_start_part = ', week_start = '.intval($fields['week_start']);
if (isset($fields['tracking_mode'])) $tracking_mode_part = ', tracking_mode = '.intval($fields['tracking_mode']);
if (isset($fields['record_type'])) $record_type_part = ', record_type = '.intval($fields['record_type']);
+ if (isset($fields['uncompleted_entries'])) $uncompleted_entries_part = ', uncompleted_entries = '.intval($fields['uncompleted_entries']);
if (isset($fields['plugins'])) $plugins_part = ', plugins = '.$mdb2->quote($fields['plugins']);
if (isset($fields['lock_spec'])) $lock_spec_part = ', lock_spec = '.$mdb2->quote($fields['lock_spec']);
if (isset($fields['workday_hours'])) $workday_hours_part = ', workday_hours = '.$mdb2->quote($fields['workday_hours']);
$sql = "update tt_teams set $name_part $addr_part $currency_part $lang_part $decimal_mark_part
$date_format_part $time_format_part $week_start_part $tracking_mode_part $record_type_part
- $plugins_part $lock_spec_part $workday_hours_part where id = $team_id";
+ $uncompleted_entries_part $plugins_part $lock_spec_part $workday_hours_part where id = $team_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// +----------------------------------------------------------------------+
class ttUser {
- var $login = null; // User login.
- var $name = null; // User name.
- var $id = null; // User id.
- var $team_id = null; // Team id.
- var $role = null; // User role (user, client, comanager, manager, admin).
- var $client_id = null; // Client id for client user role.
- var $behalf_id = null; // User id, on behalf of whom we are working.
- var $behalf_name = null; // User name, on behalf of whom we are working.
- var $email = null; // User email.
- var $lang = null; // Language.
- var $decimal_mark = null; // Decimal separator.
- var $date_format = null; // Date format.
- var $time_format = null; // Time format.
- var $week_start = 0; // Week start day.
- var $tracking_mode = 0; // Tracking mode.
- var $record_type = 0; // Record type (duration vs start and finish, or both).
- var $currency = null; // Currency.
- var $plugins = null; // Comma-separated list of enabled plugins.
- var $team = null; // Team name.
- var $custom_logo = 0; // Whether to use a custom logo for team.
- var $address = null; // Address for invoices.
- var $lock_spec = null; // Cron specification for record locking.
- var $workday_hours = 8; // Number of work hours in a regular day.
- var $rights = 0; // A mask of user rights.
+ var $login = null; // User login.
+ var $name = null; // User name.
+ var $id = null; // User id.
+ var $team_id = null; // Team id.
+ var $role = null; // User role (user, client, comanager, manager, admin).
+ var $client_id = null; // Client id for client user role.
+ var $behalf_id = null; // User id, on behalf of whom we are working.
+ var $behalf_name = null; // User name, on behalf of whom we are working.
+ var $email = null; // User email.
+ var $lang = null; // Language.
+ var $decimal_mark = null; // Decimal separator.
+ var $date_format = null; // Date format.
+ var $time_format = null; // Time format.
+ var $week_start = 0; // Week start day.
+ var $tracking_mode = 0; // Tracking mode.
+ var $record_type = 0; // Record type (duration vs start and finish, or both).
+ var $uncompleted_entries = 0; // Uncompleted entries (show nowhere or on users page).
+ var $currency = null; // Currency.
+ var $plugins = null; // Comma-separated list of enabled plugins.
+ var $team = null; // Team name.
+ var $custom_logo = 0; // Whether to use a custom logo for team.
+ var $address = null; // Address for invoices.
+ var $lock_spec = null; // Cron specification for record locking.
+ var $workday_hours = 8; // Number of work hours in a regular day.
+ var $rights = 0; // A mask of user rights.
// Constructor.
function ttUser($login, $id = null) {
$sql = "SELECT u.id, u.login, u.name, u.team_id, u.role, u.client_id, u.email, t.name as team_name,
t.address, t.currency, t.lang, t.decimal_mark, t.date_format, t.time_format, t.week_start,
- t.tracking_mode, t.record_type, t.plugins, t.lock_spec, t.workday_hours, t.custom_logo
+ t.tracking_mode, t.record_type, t.uncompleted_entries, t.plugins, t.lock_spec, t.workday_hours, t.custom_logo
FROM tt_users u LEFT JOIN tt_teams t ON (u.team_id = t.id) WHERE ";
if ($id)
$sql .= "u.id = $id";
$this->week_start = $val['week_start'];
$this->tracking_mode = $val['tracking_mode'];
$this->record_type = $val['record_type'];
+ $this->uncompleted_entries = $val['uncompleted_entries'];
$this->team = $val['team_name'];
$this->address = $val['address'];
$this->currency = $val['currency'];
'form.profile.mode_projects' => 'projects',
'form.profile.mode_projects_and_tasks' => 'projects and tasks',
'form.profile.record_type' => 'Record type',
+'form.profile.uncompleted_entries' => 'Uncompleted entries',
+'form.profile.entries_none' => 'Do not show',
+'form.profile.entries_users_page' => 'Show on Users page',
'form.profile.type_all' => 'all',
'form.profile.type_start_finish' => 'start and finish',
'form.profile.type_duration' => 'duration',
'form.profile.mode_projects' => 'Projekt',
'form.profile.mode_projects_and_tasks' => 'Projekt och arbetsuppgifter',
'form.profile.record_type' => 'Typ av tidsregistrering',
+'form.profile.uncompleted_entries' => 'Oavslutade tidsregistreringar',
+'form.profile.entries_none' => 'Visa inte',
+'form.profile.entries_users_page' => 'Visa på sidan Användare',
'form.profile.type_all' => 'Alla',
'form.profile.type_start_finish' => 'Starttid och sluttid',
'form.profile.type_duration' => 'Varaktighet',
{foreach $active_users as $u}
<tr bgcolor="{cycle values="#f5f5f5,#dedee5"}">
<td>
- <span class="uncompleted-entry{if $u.has_uncompleted_entry} active{/if}"{if $u.has_uncompleted_entry} title="{$i18n.form.users.uncompleted_entry}"{/if}></span>
+ {if $smarty.const.ENTRIES_USERS_PAGE == $user->uncompleted_entries}
+ <span class="uncompleted-entry{if $u.has_uncompleted_entry} active{/if}"{if $u.has_uncompleted_entry} title="{$i18n.form.users.uncompleted_entry}"{/if}></span>
+ {/if}
{if $user->isManager()}
<a href="user_edit.php?id={$u.id}">{$u.name|escape:'html'}</a>
{else}
<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.uncompleted_entries}:</td>
+ <td>{$forms.profileForm.uncompleted_entries.control}</td>
+ </tr>
{* initialize preview text *}
<script>
{foreach $active_users as $u}
<tr bgcolor="{cycle values="#f5f5f5,#dedee5"}">
<td>
+ {if $smarty.const.ENTRIES_USERS_PAGE == $user->uncompleted_entries}
<span class="uncompleted-entry{if $u.has_uncompleted_entry} active{/if}"{if $u.has_uncompleted_entry} title="{$i18n.form.users.uncompleted_entry}"{/if}></span>
+ {/if}
{$u.name|escape:'html'}
</td>
<td>{$u.login|escape:'html'}</td>
setChange("ALTER TABLE `tt_teams` ADD `workday_hours` SMALLINT NULL DEFAULT '8' AFTER `lock_spec`");
setChange("RENAME TABLE tt_monthly_quota TO tt_monthly_quotas");
setChange("ALTER TABLE tt_expense_items modify `name` text NOT NULL");
+ setChange("ALTER TABLE `tt_teams` ADD `uncompleted_entries` SMALLINT(2) NOT NULL DEFAULT '0' AFTER `record_type`");
}
// The update_clients function updates projects field in tt_clients table.
define('TYPE_START_FINISH', 1); // Time record has start and finish times.
define('TYPE_DURATION', 2); // Time record has only duration, no start and finish times.
+// Definitions of types for uncompleted time entries.
+define('ENTRIES_NONE', 0); // Do not show uncompleted time entries anywhere.
+define('ENTRIES_USERS_PAGE', 1); // Show uncompleted time entries on the users page.
+
// User access rights - bits that collectively define an access mask to the system (a role).
// We'll have some bits here (1,2, etc...) reserved for future use.
define('right_data_entry', 4); // Right to enter work hours and expenses.
$inactive_users = ttTeamHelper::getInactiveUsers($user->team_id, true);
}
-// Check each active user if they have an uncompleted time entry.
-foreach ($active_users as $key => $user) {
- $active_users[$key]['has_uncompleted_entry'] = (bool) ttTimeHelper::getUncompleted($user['id']);
+// Check if the user wants to show uncompleted time entries.
+if (ENTRIES_USERS_PAGE == $user->uncompleted_entries) {
+ // Check each active user if they have an uncompleted time entry.
+ foreach ($active_users as $key => $user) {
+ $active_users[$key]['has_uncompleted_entry'] = (bool) ttTimeHelper::getUncompleted($user['id']);
+ }
}
$smarty->assign('active_users', $active_users);
# This table stores settings common to all team members such as language, week start day, etc.
#
CREATE TABLE `tt_teams` (
- `id` int(11) NOT NULL auto_increment, # team id
- `timestamp` timestamp NOT NULL, # modification timestamp
- `name` varchar(80) default NULL, # team name
- `address` varchar(255) default NULL, # team address, used in invoices
- `currency` varchar(7) default NULL, # team currency symbol
- `decimal_mark` char(1) NOT NULL default '.', # separator in decimals
- `lang` varchar(10) NOT NULL default 'en', # language
- `date_format` varchar(20) NOT NULL default '%Y-%m-%d', # date format
- `time_format` varchar(20) NOT NULL default '%H:%M', # time format
- `week_start` smallint(2) NOT NULL DEFAULT '0', # Week start day, 0 == Sunday.
- `tracking_mode` smallint(2) NOT NULL DEFAULT '1', # tracking mode ("projects" or "projects and tasks")
- `record_type` smallint(2) NOT NULL DEFAULT '0', # time record type ("start and finish", "duration", or both)
- `plugins` varchar(255) default NULL, # a list of enabled plugins for team
- `lock_spec` varchar(255) default NULL, # Cron specification for record locking,
- # for example: "0 10 * * 1" for "weekly on Mon at 10:00".
- `workday_hours` smallint(6) DEFAULT '8', # number of work hours in a regular day
- `custom_logo` tinyint(4) default '0', # whether to use a custom logo or not
- `status` tinyint(4) default '1', # team status
+ `id` int(11) NOT NULL auto_increment, # team id
+ `timestamp` timestamp NOT NULL, # modification timestamp
+ `name` varchar(80) default NULL, # team name
+ `address` varchar(255) default NULL, # team address, used in invoices
+ `currency` varchar(7) default NULL, # team currency symbol
+ `decimal_mark` char(1) NOT NULL default '.', # separator in decimals
+ `lang` varchar(10) NOT NULL default 'en', # language
+ `date_format` varchar(20) NOT NULL default '%Y-%m-%d', # date format
+ `time_format` varchar(20) NOT NULL default '%H:%M', # time format
+ `week_start` smallint(2) NOT NULL DEFAULT '0', # Week start day, 0 == Sunday.
+ `tracking_mode` smallint(2) NOT NULL DEFAULT '1', # tracking mode ("projects" or "projects and tasks")
+ `record_type` smallint(2) NOT NULL DEFAULT '0', # time record type ("start and finish", "duration", or both)
+ `uncompleted_entries` smallint(2) NOT NULL DEFAULT '0', # show indicator next to users with uncompleted time entries
+ # ("dont show", "on users page")
+ `plugins` varchar(255) default NULL, # a list of enabled plugins for team
+ `lock_spec` varchar(255) default NULL, # Cron specification for record locking,
+ # for example: "0 10 * * 1" for "weekly on Mon at 10:00".
+ `workday_hours` smallint(6) DEFAULT '8', # number of work hours in a regular day
+ `custom_logo` tinyint(4) default '0', # whether to use a custom logo or not
+ `status` tinyint(4) default '1', # team status
PRIMARY KEY (`id`)
);
$cl_start_week = $request->getParameter('start_week');
$cl_tracking_mode = $request->getParameter('tracking_mode');
$cl_record_type = $request->getParameter('record_type');
+ $cl_uncompleted_entries = $request->getParameter('uncompleted_entries');
$cl_charts = $request->getParameter('charts');
$cl_clients = $request->getParameter('clients');
$cl_client_required = $request->getParameter('client_required');
$cl_start_week = $user->week_start;
$cl_tracking_mode = $user->tracking_mode;
$cl_record_type = $user->record_type;
+ $cl_uncompleted_entries = $user->uncompleted_entries;
// Which plugins do we have enabled?
$plugins = explode(',', $user->plugins);
$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));
+ // Prepare uncompleted entries choices.
+ $uncompleted_entries_options = array();
+ $uncompleted_entries_options[ENTRIES_NONE] = $i18n->getKey('form.profile.entries_none');
+ $uncompleted_entries_options[ENTRIES_USERS_PAGE] = $i18n->getKey('form.profile.entries_users_page');
+ $form->addInput(array('type'=>'combobox','name'=>'uncompleted_entries','style'=>'width: 150px;','data'=>$uncompleted_entries_options,'value'=>$cl_uncompleted_entries));
+
$form->addInput(array('type'=>'checkbox','name'=>'charts','data'=>1,'value'=>$cl_charts));
$form->addInput(array('type'=>'checkbox','name'=>'clients','data'=>1,'value'=>$cl_clients,'onchange'=>'handlePluginCheckboxes()'));
$form->addInput(array('type'=>'checkbox','name'=>'client_required','data'=>1,'value'=>$cl_client_required));
'week_start' => $cl_start_week,
'tracking_mode' => $cl_tracking_mode,
'record_type' => $cl_record_type,
+ 'uncompleted_entries' => $cl_uncompleted_entries,
'plugins' => $plugins));
}
if ($update_result) {
$inactive_users = ttTeamHelper::getInactiveUsers($user->team_id, true);
}
-// Check each active user if they have an uncompleted time entry.
-foreach ($active_users as $key => $user) {
- $active_users[$key]['has_uncompleted_entry'] = (bool) ttTimeHelper::getUncompleted($user['id']);
+// Check if the user wants to show uncompleted time entries.
+if (ENTRIES_USERS_PAGE == $user->uncompleted_entries) {
+ // Check each active user if they have an uncompleted time entry.
+ foreach ($active_users as $key => $user) {
+ $active_users[$key]['has_uncompleted_entry'] = (bool) ttTimeHelper::getUncompleted($user['id']);
+ }
}
$smarty->assign('active_users', $active_users);