From: Nik Okuntseff Date: Tue, 11 Dec 2018 15:00:07 +0000 (+0000) Subject: Fixed saving fav report in a subgroup. X-Git-Tag: timetracker_1.19-1~432 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=b8d9247f09f3dfbd35a724ba5ac1b8e433dc1fd1;p=timetracker.git Fixed saving fav report in a subgroup. --- diff --git a/WEB-INF/lib/ttFavReportHelper.class.php b/WEB-INF/lib/ttFavReportHelper.class.php index b056bd81..d3783009 100644 --- a/WEB-INF/lib/ttFavReportHelper.class.php +++ b/WEB-INF/lib/ttFavReportHelper.class.php @@ -181,8 +181,9 @@ class ttFavReportHelper { } // saveReport - saves report options in the database. - static function saveReport($user_id, $bean) { + static function saveReport($bean) { global $user; + $user_id = $user->getUser(); // Set default value of 0 for not set checkboxes (in bean). // Later in this function we use it to construct $fields array to update database. @@ -206,11 +207,11 @@ class ttFavReportHelper { $users = join(',', $users_in_bean); } if ($bean->getAttribute('start_date')) { - $dt = new DateAndTime($user->date_format, $bean->getAttribute('start_date')); + $dt = new DateAndTime($user->getDateFormat(), $bean->getAttribute('start_date')); $from = $dt->toString(DB_DATEFORMAT); } if ($bean->getAttribute('end_date')) { - $dt = new DateAndTime($user->date_format, $bean->getAttribute('end_date')); + $dt = new DateAndTime($user->getDateFormat(), $bean->getAttribute('end_date')); $to = $dt->toString(DB_DATEFORMAT); } @@ -268,8 +269,9 @@ class ttFavReportHelper { } // loadReport - loads report options from database into a bean. - static function loadReport($user_id, &$bean) { + static function loadReport(&$bean) { global $user; + $user_id = $user->getUser(); $val = ttFavReportHelper::getReport($bean->getAttribute('favorite_report')); if ($val) { @@ -284,11 +286,11 @@ class ttFavReportHelper { $bean->setAttribute('period', $val['period']); if ($val['period_start']) { $dt = new DateAndTime(DB_DATEFORMAT, $val['period_start']); - $bean->setAttribute('start_date', $dt->toString($user->date_format)); + $bean->setAttribute('start_date', $dt->toString($user->getDateFormat())); } if ($val['period_end']) { $dt = new DateAndTime(DB_DATEFORMAT, $val['period_end']); - $bean->setAttribute('end_date', $dt->toString($user->date_format)); + $bean->setAttribute('end_date', $dt->toString($user->getDateFormat())); } $bean->setAttribute('chclient', $val['show_client']); $bean->setAttribute('chinvoice', $val['show_invoice']); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 9f603c43..c49c2e56 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.29.4632 | Copyright © Anuko | +  Anuko Time Tracker 1.18.29.4633 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/reports.php b/reports.php index e6334f9b..7c7ac011 100644 --- a/reports.php +++ b/reports.php @@ -290,7 +290,7 @@ if ($request->isPost()) { // User changed favorite report. We need to load new values into the form. if ($bean->getAttribute('favorite_report')) { // This loads new favorite report options into the bean (into our form). - ttFavReportHelper::loadReport($user->getUser(), $bean); + ttFavReportHelper::loadReport($bean); // If user selected no favorite report - mark all user checkboxes (most probable scenario). if ($bean->getAttribute('favorite_report') == -1) @@ -306,7 +306,7 @@ if ($request->isPost()) { if (!ttValidString($bean->getAttribute('new_fav_report'))) $err->add($i18n->get('error.field'), $i18n->get('form.reports.save_as_favorite')); if ($err->no()) { - $id = ttFavReportHelper::saveReport($user->id, $bean); // TODO: review "on behalf" situations (both user and group), redesign if needed. + $id = ttFavReportHelper::saveReport($bean); if (!$id) $err->add($i18n->get('error.db')); if ($err->no()) { @@ -323,7 +323,7 @@ if ($request->isPost()) { // Load default report. $bean->setAttribute('favorite_report',''); $bean->setAttribute('new_fav_report', $report_list[0]['name']); - ttFavReportHelper::loadReport($user->id, $bean); + ttFavReportHelper::loadReport($bean); $form->setValueByElement('users', array_keys($user_list)); $bean->saveBean(); header('Location: reports.php');