From 57f7eb0666795f48f63f71eeb741af2eb7588427 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Fri, 7 Dec 2018 13:16:11 +0000 Subject: [PATCH] Resuming refactoring of invoices for subgroups. --- WEB-INF/lib/ttInvoiceHelper.class.php | 34 ++++++++++++++++++--------- WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/WEB-INF/lib/ttInvoiceHelper.class.php b/WEB-INF/lib/ttInvoiceHelper.class.php index 3e29e0e0..93d272b4 100644 --- a/WEB-INF/lib/ttInvoiceHelper.class.php +++ b/WEB-INF/lib/ttInvoiceHelper.class.php @@ -184,7 +184,7 @@ class ttInvoiceHelper { $dt = new DateAndTime(DB_DATEFORMAT); while ($val = $res->fetchRow()) { $dt->parseVal($val['date']); - $val['date'] = $dt->toString($user->date_format); + $val['date'] = $dt->toString($user->getDateFormat()); $result[] = $val; } } @@ -196,30 +196,42 @@ class ttInvoiceHelper { global $user; $mdb2 = getConnection(); + $group_id = $user->getGroup(); + $org_id = $user->org_id; + // Handle custom field log records. if ($delete_invoice_items) { - $sql = "update tt_custom_field_log set status = NULL where log_id in (select id from tt_log where invoice_id = $invoice_id and status = 1)"; + $sql = "update tt_custom_field_log set status = null". + " where log_id in". + " (select id from tt_log where invoice_id = $invoice_id and group_id = $group_id and org_id = $org_id and status = 1)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; } // Handle time records. - if ($delete_invoice_items) - $sql = "update tt_log set status = NULL where invoice_id = $invoice_id"; - else - $sql = "update tt_log set invoice_id = NULL where invoice_id = $invoice_id"; + if ($delete_invoice_items) { + $sql = "update tt_log set status = null". + " where invoice_id = $invoice_id and group_id = $group_id and org_id = $org_id"; + } else { + $sql = "update tt_log set invoice_id = null". + " where invoice_id = $invoice_id and group_id = $group_id and org_id = $org_id"; + } $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; // Handle expense items. - if ($delete_invoice_items) - $sql = "update tt_expense_items set status = NULL where invoice_id = $invoice_id"; - else - $sql = "update tt_expense_items set invoice_id = NULL where invoice_id = $invoice_id"; + if ($delete_invoice_items) { + $sql = "update tt_expense_items set status = null". + " where invoice_id = $invoice_id and group_id = $group_id and org_id = $org_id"; + } else { + $sql = "update tt_expense_items set invoice_id = null". + " where invoice_id = $invoice_id and group_id = $group_id and org_id = $org_id"; + } $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->getGroup(); + $sql = "update tt_invoices set status = null". + " where id = $invoice_id and group_id = $group_id and org_id = $org_id"; $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 e7823384..ffb82d9d 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.29.4601 | Copyright © Anuko | +  Anuko Time Tracker 1.18.29.4602 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1