From: Nik Okuntseff Date: Wed, 25 Jul 2018 01:25:03 +0000 (+0000) Subject: Introduced totals only option for work units. X-Git-Tag: timetracker_1.19-1~808 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=6dbcf228dba9d1175ffd0c177f0739c58ce0f199;p=timetracker.git Introduced totals only option for work units. --- diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index 0900f7f9..4da47ec0 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -277,8 +277,12 @@ class ttReportHelper { if ($bean->getAttribute('chduration')) array_push($fields, "TIME_FORMAT(l.duration, '%k:%i') as duration"); // Add work units. - if ($bean->getAttribute('chunits')) - array_push($fields, "if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit)) as units"); + if ($bean->getAttribute('chunits')) { + if ($user->unit_totals_only) + array_push($fields, "null as units"); + else + array_push($fields, "if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit)) as units"); + } // Add note. if ($bean->getAttribute('chnote')) array_push($fields, 'l.comment as note'); @@ -363,6 +367,9 @@ class ttReportHelper { array_push($fields, 'null'); // null for finish. if ($bean->getAttribute('chduration')) array_push($fields, 'null'); // null for duration. + // Add work units. + if ($bean->getAttribute('chunits')) + array_push($fields, 'null as units'); // null for work units. // Use the note field to print item name. if ($bean->getAttribute('chnote')) array_push($fields, 'ei.name as note'); @@ -383,10 +390,6 @@ class ttReportHelper { if (($canViewReports || $isClient) && $bean->getAttribute('chinvoice')) array_push($fields, 'i.name as invoice'); - // Add work units. - if ($bean->getAttribute('chunits')) - array_push($fields, 'null'); // null for work units. - // Prepare sql query part for left joins. $left_joins = null; if ($canViewReports || $isClient) @@ -549,8 +552,12 @@ class ttReportHelper { if ($report['show_duration']) array_push($fields, "TIME_FORMAT(l.duration, '%k:%i') as duration"); // Add work units. - if ($report['show_work_units']) - array_push($fields, "if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit)) as units"); + if ($report['show_work_units']) { + if ($user->unit_totals_only) + array_push($fields, "null as units"); + else + array_push($fields, "if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit)) as units"); + } // Add note. if ($report['show_note']) @@ -636,7 +643,7 @@ class ttReportHelper { if ($report['show_duration']) array_push($fields, 'null'); // null for duration. if ($report['show_work_units']) - array_push($fields, 'null'); // null for work units. + array_push($fields, 'null as units'); // null for work units. // Use the note field to print item name. if ($report['show_note']) array_push($fields, 'ei.name as note'); @@ -782,24 +789,39 @@ class ttReportHelper { if (MODE_TIME == $user->tracking_mode) { if ($group_by_option != 'user') $left_join = 'left join tt_users u on (l.user_id = u.id)'; - $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time, - sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units, - sum(cast(l.billable * coalesce(u.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10, 2))) as cost, + $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time"; + if ($bean->getAttribute('chunits')) { + if ($user->unit_totals_only) + $sql .= ", if (sum(l.billable * time_to_sec(l.duration)/60) < $user->first_unit_threshold, 0, ceil(sum(l.billable * time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + else + $sql .= ", sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + } + $sql .= ", sum(cast(l.billable * coalesce(u.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10, 2))) as cost, null as expenses from tt_log l $group_join $left_join $where group by $group_field"; } else { // If we are including cost and tracking projects, our query (the same as above) needs to join the tt_user_project_binds table. - $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time, - sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units, - sum(cast(l.billable * coalesce(upb.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10,2))) as cost, + $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time"; + if ($bean->getAttribute('chunits')) { + if ($user->unit_totals_only) + $sql .= ", if (sum(l.billable * time_to_sec(l.duration)/60) < $user->first_unit_threshold, 0, ceil(sum(l.billable * time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + else + $sql .= ", sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + } + $sql .= ", sum(cast(l.billable * coalesce(upb.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10,2))) as cost, null as expenses from tt_log l $group_join left join tt_user_project_binds upb on (l.user_id = upb.user_id and l.project_id = upb.project_id) $where group by $group_field"; } } else { - $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time, - sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units, - null as expenses from tt_log l + $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time"; + if ($bean->getAttribute('chunits')) { + if ($user->unit_totals_only) + $sql .= ", if (sum(l.billable * time_to_sec(l.duration)/60) < $user->first_unit_threshold, 0, ceil(sum(l.billable * time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + else + $sql .= ", sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + } + $sql .= ", null as expenses from tt_log l $group_join $where group by $group_field"; } // By now we have sql for time items. @@ -830,13 +852,17 @@ class ttReportHelper { } $where = ttReportHelper::getExpenseWhere($bean); - $sql_for_expenses = "select $group_field as group_field, null as time, null as units, sum(ei.cost) as cost, sum(ei.cost) as expenses from tt_expense_items ei - $group_join $where"; + $sql_for_expenses = "select $group_field as group_field, null as time"; + if ($bean->getAttribute('chunits')) $sql_for_expenses .= ", null as units"; + $sql_for_expenses .= ", sum(ei.cost) as cost, sum(ei.cost) as expenses from tt_expense_items ei $group_join $where"; // Add a "group by" clause if we are grouping. if ('null' != $group_field) $sql_for_expenses .= " group by $group_field"; // Create a combined query. - $sql = "select group_field, sum(time) as time, sum(units) as units, sum(cost) as cost, sum(expenses) as expenses from (($sql) union all ($sql_for_expenses)) t group by group_field"; + $combined = "select group_field, sum(time) as time"; + if ($bean->getAttribute('chunits')) $combined .= ", sum(units) as units"; + $combined .= ", sum(cost) as cost, sum(expenses) as expenses from (($sql) union all ($sql_for_expenses)) t group by group_field"; + $sql = $combined; } // Execute query. @@ -914,24 +940,40 @@ class ttReportHelper { if (MODE_TIME == $user->tracking_mode) { if ($group_by_option != 'user') $left_join = 'left join tt_users u on (l.user_id = u.id)'; - $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time, - sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units, - sum(cast(l.billable * coalesce(u.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10, 2))) as cost, + $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time"; + if ($report['show_work_units']) { + if ($user->unit_totals_only) + $sql .= ", if (sum(l.billable * time_to_sec(l.duration)/60) < $user->first_unit_threshold, 0, ceil(sum(l.billable * time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + else + $sql .= ", sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + } + $sql .= ", sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + $sql .= ", sum(cast(l.billable * coalesce(u.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10, 2))) as cost, null as expenses from tt_log l $group_join $left_join $where group by $group_field"; } else { // If we are including cost and tracking projects, our query (the same as above) needs to join the tt_user_project_binds table. - $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time, - sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units, - sum(cast(l.billable * coalesce(upb.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10,2))) as cost, + $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time"; + if ($report['show_work_units']) { + if ($user->unit_totals_only) + $sql .= ", if (sum(l.billable * time_to_sec(l.duration)/60) < $user->first_unit_threshold, 0, ceil(sum(l.billable * time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + else + $sql .= ", sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + } + $sql .= ", sum(cast(l.billable * coalesce(upb.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10,2))) as cost, null as expenses from tt_log l $group_join left join tt_user_project_binds upb on (l.user_id = upb.user_id and l.project_id = upb.project_id) $where group by $group_field"; } } else { - $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time, - sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units, - null as expenses from tt_log l + $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time"; + if ($report['show_work_units']) { + if ($user->unit_totals_only) + $sql .= ", if (sum(l.billable * time_to_sec(l.duration)/60) < $user->first_unit_threshold, 0, ceil(sum(l.billable * time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + else + $sql .= ", sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + } + $sql .= ", null as expenses from tt_log l $group_join $where group by $group_field"; } // By now we have sql for time items. @@ -962,13 +1004,17 @@ class ttReportHelper { } $where = ttReportHelper::getFavExpenseWhere($report); - $sql_for_expenses = "select $group_field as group_field, null as time, null as units, sum(ei.cost) as cost, sum(ei.cost) as expenses from tt_expense_items ei - $group_join $where"; + $sql_for_expenses = "select $group_field as group_field, null as time"; + if ($report['show_work_units']) $sql_for_expenses .= ", null as units"; + $sql_for_expenses .= ", sum(ei.cost) as cost, sum(ei.cost) as expenses from tt_expense_items ei $group_join $where"; // Add a "group by" clause if we are grouping. if ('null' != $group_field) $sql_for_expenses .= " group by $group_field"; // Create a combined query. - $sql = "select group_field, sum(time) as time, sum(units) as units, sum(cost) as cost, sum(expenses) as expenses from (($sql) union all ($sql_for_expenses)) t group by group_field"; + $combined = "select group_field, sum(time) as time"; + if ($report['show_work_units']) $combined .= ", sum(units) as units"; + $combined .= ", sum(cost) as cost, sum(expenses) as expenses from (($sql) union all ($sql_for_expenses)) t group by group_field"; + $sql = $combined; } // Execute query. @@ -1005,37 +1051,41 @@ class ttReportHelper { $where = ttReportHelper::getWhere($bean); - // TODO: build query in parts so the work units inclusion is conditional. - - // Start with a query for time items. + // Prepare parts. + $time_part = "sum(time_to_sec(l.duration)) as time"; + if ($bean->getAttribute('chunits')) { + $units_part = $user->unit_totals_only ? ", null as units" : ", sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + } + if ($bean->getAttribute('chcost')) { + if (MODE_TIME == $user->tracking_mode) + $cost_part = ", sum(cast(l.billable * coalesce(u.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10,2))) as cost, null as expenses"; + else + $cost_part = ", sum(cast(l.billable * coalesce(upb.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10,2))) as cost, null as expenses"; + } else { + $cost_part = ", null as cost, null as expenses"; + } if ($bean->getAttribute('chcost')) { if (MODE_TIME == $user->tracking_mode) { - $sql = "select sum(time_to_sec(l.duration)) as time, - sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units, - sum(cast(l.billable * coalesce(u.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10,2))) as cost, - null as expenses - from tt_log l - left join tt_users u on (l.user_id = u.id) $where"; + $left_joins = "left join tt_users u on (l.user_id = u.id)"; } else { - $sql = "select sum(time_to_sec(l.duration)) as time, - sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units, - sum(cast(l.billable * coalesce(upb.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10,2))) as cost, - null as expenses - from tt_log l - left join tt_user_project_binds upb on (l.user_id = upb.user_id and l.project_id = upb.project_id) $where"; + $left_joins = "left join tt_user_project_binds upb on (l.user_id = upb.user_id and l.project_id = upb.project_id)"; } - } else - $sql = "select sum(time_to_sec(l.duration)) as time," - ." sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units," - ." null as cost, null as expenses from tt_log l $where"; + } + // Prepare a query for time items. + $sql = "select $time_part $units_part $cost_part from tt_log l $left_joins $where"; // If we have expenses, query becomes a bit more complex. if ($bean->getAttribute('chcost') && $user->isPluginEnabled('ex')) { $where = ttReportHelper::getExpenseWhere($bean); - $sql_for_expenses = "select null as time, null as units, sum(cost) as cost, sum(cost) as expenses from tt_expense_items ei $where"; + $sql_for_expenses = "select null as time"; + if ($bean->getAttribute('chunits')) $sql_for_expenses .= ", null as units"; + $sql_for_expenses .= ", sum(cost) as cost, sum(cost) as expenses from tt_expense_items ei $where"; // Create a combined query. - $sql = "select sum(time) as time, sum(units) as units, sum(cost) as cost, sum(expenses) as expenses from (($sql) union all ($sql_for_expenses)) t"; + $combined = "select sum(time) as time"; + if ($bean->getAttribute('chunits')) $combined .= ", sum(units) as units"; + $combined .= ", sum(cost) as cost, sum(expenses) as expenses from (($sql) union all ($sql_for_expenses)) t"; + $sql = $combined; } // Execute query. @@ -1083,34 +1133,41 @@ class ttReportHelper { $where = ttReportHelper::getFavWhere($report); - // Start with a query for time items. + // Prepare parts. + $time_part = "sum(time_to_sec(l.duration)) as time"; + if ($report['show_work_units']) { + $units_part = $user->unit_totals_only ? ", null as units" : ", sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + } + if ($report['show_cost']) { + if (MODE_TIME == $user->tracking_mode) + $cost_part = ", sum(cast(l.billable * coalesce(u.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10,2))) as cost, null as expenses"; + else + $cost_part = ", sum(cast(l.billable * coalesce(upb.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10,2))) as cost, null as expenses"; + } else { + $cost_part = ", null as cost, null as expenses"; + } if ($report['show_cost']) { if (MODE_TIME == $user->tracking_mode) { - $sql = "select sum(time_to_sec(l.duration)) as time, - sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units, - sum(cast(l.billable * coalesce(u.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10,2))) as cost, - null as expenses - from tt_log l - left join tt_users u on (l.user_id = u.id) $where"; + $left_joins = "left join tt_users u on (l.user_id = u.id)"; } else { - $sql = "select sum(time_to_sec(l.duration)) as time, - sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units, - sum(cast(l.billable * coalesce(upb.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10,2))) as cost, - null as expenses - from tt_log l - left join tt_user_project_binds upb on (l.user_id = upb.user_id and l.project_id = upb.project_id) $where"; + $left_joins = "left join tt_user_project_binds upb on (l.user_id = upb.user_id and l.project_id = upb.project_id)"; } - } else - $sql = "select sum(time_to_sec(l.duration)) as time, - sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units, - null as cost, null as expenses from tt_log l $where"; + } + // Prepare a query for time items. + $sql = "select $time_part $units_part $cost_part from tt_log l $left_joins $where"; // If we have expenses, query becomes a bit more complex. if ($report['show_cost'] && $user->isPluginEnabled('ex')) { $where = ttReportHelper::getFavExpenseWhere($report); - $sql_for_expenses = "select null as time, null as units, sum(cost) as cost, sum(cost) as expenses from tt_expense_items ei $where"; + $sql_for_expenses = "select null as time"; + if ($report['show_work_units']) $sql_for_expenses .= ", null as units"; + $sql_for_expenses .= ", sum(cost) as cost, sum(cost) as expenses from tt_expense_items ei $where"; + // Create a combined query. - $sql = "select sum(time) as time, sum(units) as units, sum(cost) as cost, sum(expenses) as expenses from (($sql) union all ($sql_for_expenses)) t"; + $combined = "select sum(time) as time"; + if ($report['show_work_units']) $combined .= ", sum(units) as units"; + $combined .= ", sum(cost) as cost, sum(expenses) as expenses from (($sql) union all ($sql_for_expenses)) t"; + $sql = $combined; } // Execute query. diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 28165931..e498cde0 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -68,6 +68,7 @@ class ttUser { var $is_client = false; // Whether user is a client as determined by missing 'track_own_time' right. var $minutes_in_unit = 15; // Number of minutes in unit for Work units plugin. var $first_unit_threshold = 0;// Threshold for 1st unit for Work units plugin. + var $unit_totals_only = 0; // Totlas only option for the Work units plugin. // Constructor. function __construct($login, $id = null) { @@ -139,6 +140,7 @@ class ttUser { if ($minutes_in_unit) $this->minutes_in_unit = $minutes_in_unit; $first_unit_threshold = $config->getIntValue('1st_unit_threshold'); if ($first_unit_threshold) $this->first_unit_threshold = $first_unit_threshold; + $this->unit_totals_only = $config->getDefinedValue('unit_totals_only'); } // Set "on behalf" id and name. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index c2010946..6b39e764 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.92.4284 | Copyright © Anuko | +  Anuko Time Tracker 1.17.93.4285 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/group_edit.php b/group_edit.php index 8c7012a5..01d2ecdc 100644 --- a/group_edit.php +++ b/group_edit.php @@ -30,6 +30,7 @@ require_once('initialize.php'); import('form.Form'); import('ttUserHelper'); import('ttRoleHelper'); +import('ttConfigHelper'); // Access checks. if (!(ttAccessAllowed('manage_basic_settings') || ttAccessAllowed('manage_advanced_settings'))) { @@ -38,6 +39,8 @@ if (!(ttAccessAllowed('manage_basic_settings') || ttAccessAllowed('manage_advanc } // End of access checks. +$config = new ttConfigHelper($user->config); + $advanced_settings = $user->can('manage_advanced_settings'); if (!defined('CURRENCY_DEFAULT')) define('CURRENCY_DEFAULT', '$'); @@ -271,18 +274,12 @@ if ($request->isPost()) { $plugins = trim($plugins, ','); - // Prepare config string. - if ($cl_show_holidays) - $config .= ',show_holidays'; - if ($cl_punch_mode) - $config .= ',punch_mode'; - if ($cl_allow_overlap) - $config .= ',allow_overlap'; - if ($cl_future_entries) - $config .= ',future_entries'; - if ($cl_uncompleted_indicators) - $config .= ',uncompleted_indicators'; - $config = trim($config, ','); + // Update config. + $config->setDefinedValue('show_holidays', $cl_show_holidays); + $config->setDefinedValue('punch_mode', $cl_punch_mode); + $config->setDefinedValue('allow_overlap', $cl_allow_overlap); + $config->setDefinedValue('future_entries', $cl_future_entries); + $config->setDefinedValue('uncompleted_indicators', $cl_uncompleted_indicators); if ($user->updateGroup(array( 'name' => $cl_group, @@ -300,7 +297,7 @@ if ($request->isPost()) { 'bcc_email' => $cl_bcc_email, 'allow_ip' => $cl_allow_ip, 'plugins' => $plugins, - 'config' => $config))) { + 'config' => $config->getConfig()))) { header('Location: time.php'); exit(); } else diff --git a/work_units.php b/work_units.php index 32b2616b..b2373ada 100644 --- a/work_units.php +++ b/work_units.php @@ -45,9 +45,11 @@ $config = new ttConfigHelper($user->config); if ($request->isPost()) { $cl_minutes_in_unit = $request->getParameter('minutes_in_unit'); $cl_1st_unit_threshold = $request->getParameter('1st_unit_threshold'); + $cl_totals_only = $request->getParameter('totals_only'); } else { $cl_minutes_in_unit = $user->minutes_in_unit; $cl_1st_unit_threshold = $user->first_unit_threshold; + $cl_totals_only = $user->unit_totals_only; } $form = new Form('workUnitsForm'); @@ -65,6 +67,7 @@ if ($request->isPost()){ if ($err->no()) { $config->setIntValue('minutes_in_unit', $cl_minutes_in_unit); $config->setIntValue('1st_unit_threshold', $cl_1st_unit_threshold); + $config->setDefinedValue('unit_totals_only', $cl_totals_only); if (!$user->updateGroup(array('config' => $config->getConfig()))) { $err->add($i18n->get('error.db')); }