diff --git a/js/main.js b/js/main.js
index 7fd4c4efe9ffca2dcd3c41875b0e176b8407f8df..b56a24f93af5c469f26bb3ae4781244d61dfea19 100644
--- a/js/main.js
+++ b/js/main.js
@@ -493,6 +493,7 @@ function deleteSubtask(subtask_ID, task_ID)
 	$.post('../admin/helper/delete-subtask.php',
 		{
 			"subtask_ID": subtask_ID,
+            "task_ID": task_ID
 
 		}, function(data, error)
 		{
diff --git a/php/admin/helper/delete-subtask.php b/php/admin/helper/delete-subtask.php
index 4775bda106ebefa56a5f59a3ba27dea535f6c5c4..fc66551a5dbcbc64647159e8e123e4bd410b98fc 100644
--- a/php/admin/helper/delete-subtask.php
+++ b/php/admin/helper/delete-subtask.php
@@ -9,10 +9,16 @@ if($_SERVER['REQUEST_METHOD'] == 'POST')
 		exit;
 	}
 
+    if(!isset($_POST['task_ID']))
+    {
+        echo "error";
+        exit;
+    }
+
 	$db = new DB();
 	$db->createTables();
 
-	if($db->deleteSubtask($_POST['subtask_ID']) == false)
+	if($db->deleteSubtask($_POST['subtask_ID'], $_POST['task_ID']) == false)
 	{
 		echo "error";
 		exit;
diff --git a/php/index.php b/php/index.php
index d27c5102f28bebe3510e97039578fb206f9267e4..df0e0b86b458f2b644d4277ffbb74ba538a2652e 100644
--- a/php/index.php
+++ b/php/index.php
@@ -490,17 +490,17 @@ function printMilestoneDoneWithTasks($color, $currentMilestone, $isFirstMileston
 			if($numberOfOpenSubtasks != false)
 			{
 				$numberOfOpenSubtasks = $numberOfOpenSubtasks['count'];
-				if($numberOfOpenSubtasks == sizeof($subtasks))
+				if($numberOfOpenSubtasks == 0)
 				{
 					echo '<li>' .
-						'<div class="collapsible-header bold"><i class="material-icons green-text">check</i>Layout<span class="right">' . $numberOfOpenSubtasks . '/' . sizeof($subtasks) . '</span></div>' .
+						'<div class="collapsible-header bold"><i class="material-icons green-text">check</i>Layout<span class="right">' . sizeof($subtasks) . '/' . sizeof($subtasks) . '</span></div>' .
 						'<div class="collapsible-body">' .
 						'<ul class="collapsible white margin-left-and-right no-shadow margin-top-and-bottom" data-collapsible="accordion">';
 				}
 				else
 				{
 					echo '<li>' .
-						'<div class="collapsible-header bold"><i class="material-icons red-text">build</i>Layout<span class="right">' . $numberOfOpenSubtasks . '/' . sizeof($subtasks) . '</span></div>' .
+						'<div class="collapsible-header bold"><i class="material-icons red-text">build</i>Layout<span class="right">' . (sizeof($subtasks) - $numberOfOpenSubtasks) . '/' . sizeof($subtasks) . '</span></div>' .
 						'<div class="collapsible-body">' .
 						'<ul class="collapsible white margin-left-and-right no-shadow margin-top-and-bottom" data-collapsible="accordion">';
 				}
diff --git a/php/mysql.php b/php/mysql.php
index 25773cb0cb7becb53bbb4d28fb8221286211ff1f..5c436f40d2313e7c2f7671728a3f395b0ffb28ce 100644
--- a/php/mysql.php
+++ b/php/mysql.php
@@ -105,8 +105,11 @@ class DB
 		$statement->bindParam("title", $title);
 		$statement->bindParam("description", $description);
 		$statement->bindParam("status", $status);
+        $success = $statement->execute();
 
-		return $statement->execute();
+        $this->checkParentTask($taskID);
+
+		return $success;
 	}
 
 	//========================================
@@ -129,6 +132,14 @@ class DB
 		return $statement->execute();
 	}
 
+    function reopenTask($taskID)
+    {
+        $statement = self::$db->prepare("UPDATE tasks SET status='0' WHERE ID = :taskID;");
+        $statement->bindParam("taskID", $taskID);
+
+        return $statement->execute();
+    }
+
 	function finishSubTask($subtaskID)
 	{
 		$statement = self::$db->prepare("UPDATE subtasks SET status='1' WHERE ID = :subtaskID;");
@@ -185,9 +196,35 @@ class DB
 		$statement->bindParam("description", $description);
 		$statement->bindParam("status", $status);
 
-		return $statement->execute();
+        $success = $statement->execute();
+        $this->checkParentTask($taskID);
+
+		return $success;
 	}
 
+	function checkParentTask($taskID)
+    {
+        $subTasks = $this->getSubtasks($taskID);
+        $counter = 0;
+        for($m = 0; $m < sizeof($subTasks); $m++)
+        {
+            $currentSubTask = $subTasks[$m];
+            if ($currentSubTask['Status'] == 1)
+            {
+                $counter = $counter + 1;
+            }
+        }
+
+        if($counter == sizeof($subTasks))
+        {
+            $this->finishTask($taskID);
+        }
+        else
+        {
+            $this->reopenTask($taskID);
+        }
+    }
+
 	//========================================
 	//----------------- get ------------------
 	//========================================
@@ -295,13 +332,13 @@ class DB
 	//--------------- delete -----------------
 	//========================================
 
-	function deleteRoadmap($roadmapID)
-	{
-		$statement = self::$db->prepare("DELETE FROM roadmaps WHERE roadmaps.ID=:roadmapID;");
-		$statement->bindParam("roadmapID", $roadmapID);
-		$statement->execute();
+    function deleteRoadmap($roadmapID)
+    {
+        $statement = self::$db->prepare("DELETE FROM roadmaps WHERE roadmaps.ID=:roadmapID;");
+        $statement->bindParam("roadmapID", $roadmapID);
+        $statement->execute();
 
-		return $statement->execute();
+        return $statement->execute();
 	}
 
 	function deleteMilestone($milestoneID)
@@ -322,12 +359,14 @@ class DB
 		return $statement->execute();
 	}
 
-	function deleteSubtask($subtaskID)
+	function deleteSubtask($subtaskID, $taskID)
 	{
 		$statement = self::$db->prepare("DELETE FROM subtasks WHERE subtasks.ID=:subtaskID;");
 		$statement->bindParam("subtaskID", $subtaskID);
-		$statement->execute();
+		$success = $statement->execute();
 
-		return $statement->execute();
+        $this->checkParentTask($taskID);
+
+		return $success;
 	}
 }
\ No newline at end of file