From 42e2c55af8fc840fdbde16cfc8de4a1b01a02d29 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Thu, 3 Nov 2016 20:13:59 +0000
Subject: [PATCH] Orphaned Tasks on Dept. Deletion

Move orphaned tasks on department deletion to the default department
---
 include/class.dept.php | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/class.dept.php b/include/class.dept.php
index 36ffd2ffb..3c2e442e3 100644
--- a/include/class.dept.php
+++ b/include/class.dept.php
@@ -388,6 +388,11 @@ implements TemplateVariable {
                 ->filter(array('dept_id' => $id))
                 ->update(array('dept_id' => $cfg->getDefaultDeptId()));
 
+            // Move tasks
+            Task::objects()
+                ->filter(array('dept_id' => $id))
+                ->update(array('dept_id' => $cfg->getDefaultDeptId()));
+
             //Move Dept members: This should never happen..since delete should be issued only to empty Depts...but check it anyways
             Staff::objects()
                 ->filter(array('dept_id' => $id))
-- 
GitLab