X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=WEB-INF%2Flib%2FttInvoiceHelper.class.php;h=042acd821c23bfc62a7473a1bed8df3577272e90;hb=d368d8cfe50268648a7c9f94a031c9aa8f0f4549;hp=0867ee1ebc0ebbc5d186bf9efb72961570159c3f;hpb=c30bd94928988ff03ade10ca872968681456e12c;p=timetracker.git diff --git a/WEB-INF/lib/ttInvoiceHelper.class.php b/WEB-INF/lib/ttInvoiceHelper.class.php index 0867ee1e..042acd82 100644 --- a/WEB-INF/lib/ttInvoiceHelper.class.php +++ b/WEB-INF/lib/ttInvoiceHelper.class.php @@ -32,34 +32,6 @@ import('DateAndTime'); // Class ttInvoiceHelper is used for help with invoices. class ttInvoiceHelper { - // insert - inserts an invoice in database. - static function insert($fields) - { - $mdb2 = getConnection(); - - $group_id = (int) $fields['group_id']; - $org_id = (int) $fields['org_id']; - $name = $fields['name']; - if (!$name) return false; - - $client_id = (int) $fields['client_id']; - $date = $fields['date']; - if (array_key_exists('status', $fields)) { // Key exists and may be NULL during migration of data. - $status_f = ', status'; - $status_v = ', '.$mdb2->quote($fields['status']); - } - - // Insert a new invoice record. - $sql = "insert into tt_invoices (group_id, org_id, name, date, client_id $status_f)". - " values($group_id, $org_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id $status_v)"; - $affected = $mdb2->exec($sql); - - if (is_a($affected, 'PEAR_Error')) return false; - - $last_id = $mdb2->lastInsertID('tt_invoices', 'id'); - return $last_id; - } - // getInvoice - obtains invoice data from the database. static function getInvoice($invoice_id) { global $user; @@ -285,18 +257,20 @@ class ttInvoiceHelper { } } - // sql part for project id. - if ($project_id) $project_part = " and ei.project_id = $project_id"; - - $sql = "select count(*) as num from tt_expense_items ei - where ei.client_id = $client_id $project_part and ei.invoice_id is NULL - and ei.date >= ".$mdb2->quote($start)." and ei.date <= ".$mdb2->quote($end)." - and ei.cost <> 0 and ei.status = 1"; - $res = $mdb2->query($sql); - if (!is_a($res, 'PEAR_Error')) { - $val = $res->fetchRow(); - if ($val['num']) { - return true; + if ($user->isPluginEnabled('ex')) { + // sql part for project id. + if ($project_id) $project_part = " and ei.project_id = $project_id"; + + $sql = "select count(*) as num from tt_expense_items ei + where ei.client_id = $client_id $project_part and ei.invoice_id is NULL + and ei.date >= ".$mdb2->quote($start)." and ei.date <= ".$mdb2->quote($end)." + and ei.cost <> 0 and ei.status = 1"; + $res = $mdb2->query($sql); + if (!is_a($res, 'PEAR_Error')) { + $val = $res->fetchRow(); + if ($val['num']) { + return true; + } } }