From ff088165333067ad603805039778e9bc56671b89 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Wed, 12 Dec 2018 19:35:53 +0000 Subject: [PATCH] Refactored getRecentInvoices and moved to another class. --- WEB-INF/lib/ttGroupHelper.class.php | 23 +++++++++++++++++++++++ WEB-INF/lib/ttTeamHelper.class.php | 23 ----------------------- WEB-INF/templates/footer.tpl | 2 +- report.php | 4 ++-- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index fb895c46..762fffb6 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -598,4 +598,27 @@ class ttGroupHelper { } return $user_list; } + + // The getRecentInvoices returns an array of recent invoices (max 3) for a client. + static function getRecentInvoices($client_id) { + global $user; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + $sql = "select i.id, i.name from tt_invoices i". + " left join tt_clients c on (c.id = i.client_id)". + " where i.group_id = $group_id and i.org_id = $org_id and i.status = 1 and c.id = $client_id". + " order by i.id desc limit 3"; + $res = $mdb2->query($sql); + $result = array(); + if (!is_a($res, 'PEAR_Error')) { + $dt = new DateAndTime(DB_DATEFORMAT); + while ($val = $res->fetchRow()) { + $result[] = $val; + } + } + return $result; + } } diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index 72070877..6c058c5d 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -255,29 +255,6 @@ class ttTeamHelper { return $result; } - // The getRecentInvoices returns an array of recent invoices (max 3) for a client. - static function getRecentInvoices($group_id, $client_id) - { - global $user; - - $result = array(); - $mdb2 = getConnection(); - - $sql = "select i.id, i.name from tt_invoices i - left join tt_clients c on (c.id = i.client_id) - where i.group_id = $group_id and i.status = 1 and c.id = $client_id - order by i.id desc limit 3"; - $res = $mdb2->query($sql); - $result = array(); - if (!is_a($res, 'PEAR_Error')) { - $dt = new DateAndTime(DB_DATEFORMAT); - while ($val = $res->fetchRow()) { - $result[] = $val; - } - } - return $result; - } - // getUserToProjectBinds - obtains all user to project binds for a group. static function getUserToProjectBinds($group_id) { $mdb2 = getConnection(); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 51675b02..2a14a1fa 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.29.4638 | Copyright © Anuko | +  Anuko Time Tracker 1.18.29.4639 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/report.php b/report.php index 1a8ce63c..924c7801 100644 --- a/report.php +++ b/report.php @@ -30,7 +30,7 @@ require_once('initialize.php'); import('form.Form'); import('form.ActionForm'); import('ttReportHelper'); -import('ttTeamHelper'); +import('ttGroupHelper'); // Access check. if (!(ttAccessAllowed('view_own_reports') || ttAccessAllowed('view_reports') || ttAccessAllowed('view_all_reports'))) { @@ -94,7 +94,7 @@ if ($user->can('manage_invoices') && $bean->getAttribute('chpaid')) { if ($user->can('manage_invoices') && ($client_id && $bean->getAttribute('chinvoice') && ('no_grouping' == $bean->getAttribute('group_by1')) && !$user->isClient())) { // Client is selected and we are displaying the invoice column. - $recent_invoices = ttTeamHelper::getRecentInvoices($user->group_id, $client_id); + $recent_invoices = ttGroupHelper::getRecentInvoices($client_id); if ($recent_invoices) { $assign_invoice_select_options = array('1'=>$i18n->get('dropdown.all'),'2'=>$i18n->get('dropdown.select')); $form->addInput(array('type'=>'combobox', -- 2.20.1