<?php
include("../../session.php");
include("../../connect.php");

$user=$_SESSION['company'];
$send=$_POST["send"];
$title=$_POST["title"];
$content=$_POST["content"];

if($title==""){
	$title="(No Description)";
}
//--------------------Max of inbox--------------------------//
		$str = "SELECT Max(inboxID) FROM inbox";
	
		$result2 = mysql_query ($str,$login);
		list($result2)=mysql_fetch_array($result2);
		$number = ++$result2;
			
		if($number == "1")
		{
			$number = "I0000001";
		}
		
//--------------------Max of send--------------------------//
		$str2 = "SELECT Max(sendID) FROM send";
	
		$result3 = mysql_query ($str2,$login);
		list($result3)=mysql_fetch_array($result3);
		$number2 = ++$result3;
			
		if($number2 == "1")
		{
			 $number2 = "S0000001";
		}

date_default_timezone_set ("Singapore"); 
		$ldate=date("d-m-Y", time());
		$ltime=date("h:i:sa", time());
		
mysql_query("insert into inbox(inboxID,companyID,date,time,title,content,sendBy,status)
		values('$number','$send','$ldate','$ltime','$title','$content','$user','unread')");
mysql_query("insert into send(sendID,sendBy,sendTo,date,time,title,content)
		values('$number','$user','$send','$ldate','$ltime','$title','$content')");



	
echo "<script language=javascript>alert('Send message successful!!');
		window.location='cFeedback.php'</script>"; 	

?>