X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttGroupHelper.class.php;h=762fffb69f91df0a5367d3740e2f6ce5d7f59893;hb=5897ea0d3efe16a50706bcf1bde8d33044b5cf5f;hp=fb895c460fbbf1d848da35c6694d03201065e253;hpb=fafb0ae8f7098ffafa6799627891bd40f4811a52;p=timetracker.git 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; + } }