From 4ff1ce890c1945706a6eab49c2f707821704007e Mon Sep 17 00:00:00 2001 From: Phyks Date: Sat, 14 Sep 2013 23:36:19 +0200 Subject: [PATCH] Delete paybacks and users in when deleting an invoice --- index.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.php b/index.php index dd76c9c..db1ef6e 100644 --- a/index.php +++ b/index.php @@ -495,6 +495,16 @@ if($current_user->getAdmin() || $invoice->getBuyer() == $current_user->getId()) { $invoice->delete(); + // Delete related paybacks + $paybacks = new Payback(); + $paybacks = $paybacks->load(array('invoice_id'=>(int) $_GET['id'])); + + if($paybacks !== false) { + foreach($paybacks as $payback) { + $payback->delete(); + } + } + // Clear the cache array_map("unlink", glob(raintpl::$cache_dir."*.rtpl.php"));