From e73ed25068a87e7a70f634aed888acafda5139aa Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 6 Nov 2018 18:22:57 +0000 Subject: [PATCH] A bit more refactoring for subgroups. --- WEB-INF/lib/ttInvoiceHelper.class.php | 12 +++++++----- WEB-INF/lib/ttNotificationHelper.class.php | 4 ++-- WEB-INF/lib/ttPredefinedExpenseHelper.class.php | 4 ++-- WEB-INF/templates/footer.tpl | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/WEB-INF/lib/ttInvoiceHelper.class.php b/WEB-INF/lib/ttInvoiceHelper.class.php index d35aa348..5c5d7141 100644 --- a/WEB-INF/lib/ttInvoiceHelper.class.php +++ b/WEB-INF/lib/ttInvoiceHelper.class.php @@ -71,7 +71,8 @@ class ttInvoiceHelper { if ($user->isClient()) $client_part = " and client_id = $user->client_id"; - $sql = "select * from tt_invoices where id = $invoice_id and group_id = $user->group_id $client_part and status = 1"; + $sql = "select * from tt_invoices where id = $invoice_id and group_id = ". + $user->getActiveGroup()."$client_part and status = 1"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { if ($val = $res->fetchRow()) @@ -86,7 +87,8 @@ class ttInvoiceHelper { $mdb2 = getConnection(); global $user; - $sql = "select id from tt_invoices where group_id = $user->group_id and name = ".$mdb2->quote($invoice_name)." and status = 1"; + $sql = "select id from tt_invoices where group_id = ". + $user->getActiveGroup()." and name = ".$mdb2->quote($invoice_name)." and status = 1"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); @@ -233,7 +235,7 @@ class ttInvoiceHelper { $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; - $sql = "update tt_invoices set status = NULL where id = $invoice_id and group_id = $user->group_id"; + $sql = "update tt_invoices set status = NULL where id = $invoice_id and group_id = ".$user->getActiveGroup(); $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } @@ -328,8 +330,8 @@ class ttInvoiceHelper { if (isset($fields['project_id'])) $project_id = (int) $fields['project_id']; // Create a new invoice record. - $sql = "insert into tt_invoices (group_id, name, date, client_id) - values($user->group_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id)"; + $sql = "insert into tt_invoices (group_id, name, date, client_id) values(". + $user->getActiveGroup().", ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; diff --git a/WEB-INF/lib/ttNotificationHelper.class.php b/WEB-INF/lib/ttNotificationHelper.class.php index 35a96970..af1bcd3c 100644 --- a/WEB-INF/lib/ttNotificationHelper.class.php +++ b/WEB-INF/lib/ttNotificationHelper.class.php @@ -38,7 +38,7 @@ class ttNotificationHelper { $sql = "select c.id, c.cron_spec, c.report_id, c.email, c.cc, c.subject, c.report_condition, c.status, fr.name from tt_cron c left join tt_fav_reports fr on (fr.id = c.report_id) - where c.id = $id and c.group_id = $user->group_id"; + where c.id = $id and c.group_id = ".$user->getActiveGroup(); $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); @@ -54,7 +54,7 @@ class ttNotificationHelper { $mdb2 = getConnection(); - $sql = "delete from tt_cron where id = $id and group_id = $user->group_id"; + $sql = "delete from tt_cron where id = $id and group_id = ".$user->getActiveGroup(); $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; diff --git a/WEB-INF/lib/ttPredefinedExpenseHelper.class.php b/WEB-INF/lib/ttPredefinedExpenseHelper.class.php index c292870f..2de4dfad 100644 --- a/WEB-INF/lib/ttPredefinedExpenseHelper.class.php +++ b/WEB-INF/lib/ttPredefinedExpenseHelper.class.php @@ -39,7 +39,7 @@ class ttPredefinedExpenseHelper { $mdb2 = getConnection(); $sql = "select id, name, cost from tt_predefined_expenses - where id = $id and group_id = $user->group_id"; + where id = $id and group_id = ".$user->getActiveGroup(); $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); @@ -58,7 +58,7 @@ class ttPredefinedExpenseHelper { $mdb2 = getConnection(); - $sql = "delete from tt_predefined_expenses where id = $id and group_id = $user->group_id"; + $sql = "delete from tt_predefined_expenses where id = $id and group_id = ".$user->getActiveGroup(); $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 53e4ad54..760672f7 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.08.4376 | Copyright © Anuko | +  Anuko Time Tracker 1.18.08.4377 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1