From: Nik Okuntseff Date: Mon, 26 Mar 2018 16:19:03 +0000 (+0000) Subject: Improved ttClientHelper::delete() function. X-Git-Tag: timetracker_1.19-1~930 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=3c5c333f6d7a4a3f54fb711547dbd48403912c3a;p=timetracker.git Improved ttClientHelper::delete() function. --- diff --git a/WEB-INF/lib/ttClientHelper.class.php b/WEB-INF/lib/ttClientHelper.class.php index 14788ae4..288cd45b 100644 --- a/WEB-INF/lib/ttClientHelper.class.php +++ b/WEB-INF/lib/ttClientHelper.class.php @@ -120,8 +120,9 @@ class ttClientHelper { } // Handle time records. + $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$mdb2->quote($user->id); if ($delete_client_entries) { - $sql = "update tt_log set status = NULL where client_id = $id"; + $sql = 'update tt_log set status = NULL'.$modified_part." where client_id = $id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -129,7 +130,7 @@ class ttClientHelper { // Handle expense items. if ($delete_client_entries) { - $sql = "update tt_expense_items set status = NULL where client_id = $id"; + $sql = 'update tt_expense_items set status = NULL'.$modified_part." where client_id = $id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -137,7 +138,7 @@ class ttClientHelper { // Handle invoices. if ($delete_client_entries) { - $sql = "update tt_invoices set status = NULL where client_id = $id"; + $sql = "update tt_invoices set status = NULL where client_id = $id and team_id = $user->team_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -149,7 +150,14 @@ class ttClientHelper { if (is_a($affected, 'PEAR_Error')) return false; - $sql = "update tt_clients set status = NULL where id = $id and team_id = ".$user->team_id; + // Handle users for client. + $sql = 'update tt_users set status = NULL'.$modified_part." where client_id = $id and team_id = $user->team_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) + return false; + + // Mark client deleted. + $sql = "update tt_clients set status = NULL where id = $id and team_id = $user->team_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 c7c23da3..3e9eb18d 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.73.4176 | Copyright © Anuko | +  Anuko Time Tracker 1.17.73.4177 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve}