<?php
session_start();

	if(!isset($_SESSION['latcsuperloginsesion']))
	{
		header('Location: index.php');
		return;
	}
	include("connect.php");
	$mumid=$_SESSION['latcmumid'];
	$eve = "select * from res_suggestion_master where smid=".$_GET['id'];
	$re = mysqli_query($conn, $eve);
	
	if(mysqli_num_rows($re) > 0)
	{
		while($rt = mysqli_fetch_assoc($re))
		{
			if($rt['sstatus']=='Pending')
			{
				$eve2 = "update res_suggestion_master set sstatus='Completed' where smid=".$_GET['id'];
				if ($conn->query($eve2) === TRUE)
				{
					$_SESSION['msg'] = "Status Changed";
				}
				else{
						$_SESSION['msg1'] = "Error";
					}
			}
			else
			{		
				$eve3 = "update res_suggestion_master set sstatus='Pending' where smid=".$_GET['id'];
				if ($conn->query($eve3) === TRUE)
				{
					$_SESSION['msg'] = "Status Changed";
				}
				else{
						$_SESSION['msg1'] = "Error";
					}
			}
		}
	}else{
		$_SESSION['msg1'] = "Error";

	}
	header('Location: suggestion.php');
?>