From: Nik Okuntseff Date: Sat, 17 Nov 2018 16:10:00 +0000 (+0000) Subject: A bit more refactoring towards subgroup support. X-Git-Tag: timetracker_1.19-1~631 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=07ee49d8208cc8308a167487f010e4b919555e03;p=timetracker.git A bit more refactoring towards subgroup support. --- diff --git a/WEB-INF/lib/ttPredefinedExpenseHelper.class.php b/WEB-INF/lib/ttPredefinedExpenseHelper.class.php index 2de4dfad..16826a9d 100644 --- a/WEB-INF/lib/ttPredefinedExpenseHelper.class.php +++ b/WEB-INF/lib/ttPredefinedExpenseHelper.class.php @@ -73,14 +73,15 @@ class ttPredefinedExpenseHelper { $mdb2 = getConnection(); - $group_id = (int) $fields['group_id']; + $group_id = $user->getActiveGroup(); + $org_id = $user->org_id; $name = $fields['name']; $cost = $fields['cost']; if ('.' != $user->decimal_mark) $cost = str_replace($user->decimal_mark, '.', $cost); - $sql = "insert into tt_predefined_expenses (group_id, name, cost) - values ($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($cost).")"; + $sql = "insert into tt_predefined_expenses (group_id, org_id, name, cost)". + " values ($group_id, $org_id, ".$mdb2->quote($name).", ".$mdb2->quote($cost).")"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -95,15 +96,16 @@ class ttPredefinedExpenseHelper { $mdb2 = getConnection(); + $group_id = $user->getActiveGroup(); + $org_id = $user->org_id; $predefined_expense_id = (int) $fields['id']; - $group_id = (int) $fields['group_id']; $name = $fields['name']; $cost = $fields['cost']; if ('.' != $user->decimal_mark) $cost = str_replace($user->decimal_mark, '.', $cost); $sql = "update tt_predefined_expenses set name = ".$mdb2->quote($name).", cost = ".$mdb2->quote($cost). - " where id = $predefined_expense_id and group_id = $group_id"; + " where id = $predefined_expense_id and group_id = $group_id"; // TODO: add org_id when possible. $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 60ca1c16..f5c80574 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.16.4440 | Copyright © Anuko | +  Anuko Time Tracker 1.18.16.4441 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/dbinstall.php b/dbinstall.php index 23eac730..8b7e8c5e 100644 --- a/dbinstall.php +++ b/dbinstall.php @@ -1002,6 +1002,7 @@ if ($_POST) { setChange("UPDATE `tt_site_config` SET param_value = '1.18.15', modified = now() where param_name = 'version_db' and param_value = '1.18.14'"); setChange("ALTER TABLE `tt_predefined_expenses` ADD `org_id` int(11) default NULL AFTER `group_id`"); setChange("UPDATE `tt_site_config` SET param_value = '1.18.16', modified = now() where param_name = 'version_db' and param_value = '1.18.15'"); + setChange("UPDATE `tt_predefined_expenses` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.16') set org_id = group_id where org_id is null"); // TODO: this does not work as we just introduced group_id and it is NULL. Same for tt_project_task_binds. Improve. // setChange("UPDATE `tt_user_project_binds` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.12') set org_id = group_id where org_id is null"); diff --git a/predefined_expense_add.php b/predefined_expense_add.php index e653192b..0bff7e05 100644 --- a/predefined_expense_add.php +++ b/predefined_expense_add.php @@ -56,7 +56,6 @@ if ($request->isPost()) { if (!ttValidFloat($cl_cost)) $err->add($i18n->get('error.field'), $i18n->get('label.cost')); if ($err->no()) { if (ttPredefinedExpenseHelper::insert(array( - 'group_id' => $user->group_id, 'name' => $cl_name, 'cost' => $cl_cost))) { header('Location: predefined_expenses.php'); diff --git a/predefined_expense_edit.php b/predefined_expense_edit.php index 9b3727bf..ab2299c0 100644 --- a/predefined_expense_edit.php +++ b/predefined_expense_edit.php @@ -64,7 +64,6 @@ if ($request->isPost()) { if ($err->no()) { if (ttPredefinedExpenseHelper::update(array( 'id' => $predefined_expense_id, - 'group_id' => $user->group_id, 'name' => $cl_name, 'cost' => $cl_cost))) { header('Location: predefined_expenses.php');