From: Nik Okuntseff Date: Sat, 17 Nov 2018 18:24:14 +0000 (+0000) Subject: Started to populate org_id during import of expense items. X-Git-Tag: timetracker_1.19-1~628 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=2352b1096ea3b8301f06d3e5b072022ae08a2f73;p=timetracker.git Started to populate org_id during import of expense items. --- diff --git a/WEB-INF/lib/ttOrgImportHelper.class.php b/WEB-INF/lib/ttOrgImportHelper.class.php index 9f5dd788..6764ba53 100644 --- a/WEB-INF/lib/ttOrgImportHelper.class.php +++ b/WEB-INF/lib/ttOrgImportHelper.class.php @@ -415,11 +415,11 @@ class ttOrgImportHelper { if ($name == 'EXPENSE_ITEM') { // We get here when processing tags for the current group. - $expense_item_id = ttExpenseHelper::insert(array( + $expense_item_id = $this->insertExpense(array( 'date' => $attrs['DATE'], 'user_id' => $this->currentGroupUserMap[$attrs['USER_ID']], 'group_id' => $this->current_group_id, - // 'org_id' => $this->org_id, TODO: add this when org_id field is added to the table. + 'org_id' => $this->org_id, 'client_id' => $this->currentGroupClientMap[$attrs['CLIENT_ID']], 'project_id' => $this->currentGroupProjectMap[$attrs['PROJECT_ID']], 'name' => $attrs['NAME'], @@ -679,4 +679,30 @@ class ttOrgImportHelper { $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } + + // insertExpense - a helper function to insert an expense item. + private function insertExpense($fields) { + global $user; + $mdb2 = getConnection(); + + $group_id = (int) $fields['group_id']; + $org_id = (int) $fields['org_id']; + $date = $fields['date']; + $user_id = (int) $fields['user_id']; + $client_id = $fields['client_id']; + $project_id = $fields['project_id']; + $name = $fields['name']; + $cost = str_replace(',', '.', $fields['cost']); + $invoice_id = $fields['invoice_id']; + $status = $fields['status']; + $paid = (int) $fields['paid']; + $created = ', now(), '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', '.$mdb2->quote($user->id); + + $sql = "insert into tt_expense_items". + " (date, user_id, group_id, org_id, client_id, project_id, name, cost, invoice_id, paid, created, created_ip, created_by, status)". + " values (".$mdb2->quote($date).", $user_id, $group_id, $org_id, ".$mdb2->quote($client_id).", ".$mdb2->quote($project_id). + ", ".$mdb2->quote($name).", ".$mdb2->quote($cost).", ".$mdb2->quote($invoice_id).", $paid $created, ".$mdb2->quote($status).")"; + $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 09117895..58b036ca 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.17.4443 | Copyright © Anuko | +  Anuko Time Tracker 1.18.17.4444 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve}