<?php 
require_once("header.php");
require_once("session_check.php");
require_once("../FCKeditor/fckeditor.php");

//CODE FOR UPDATE CONTENT
if(isset($_POST['edit']))
{
	$sql_update = "UPDATE `sc_contents` SET `content` = '".addslashes($_POST['content'])."' WHERE `content_id` = '4'";
	$exe_update = mysqli_query($connection,$sql_update);
	
	$_SESSION['save_succ_msg'] = 'Content updated successfully.';
	header("location: edit_cancel.php");
	exit;
}

//FETCH DATA FROM DATABASE
$fetch_record = mysqli_fetch_array(mysqli_query($connection,"SELECT * FROM `sc_contents` WHERE `content_id` = '4'"));
$content = stripslashes($fetch_record['content']);
?>

<script language="javascript" type="text/javascript">
function frm_validation()
{
	var editor = FCKeditorAPI.GetInstance('content');
	var fckContent=editor.GetXHTML(true);
	if(fckContent == '')
	{ 
	    alert('Please enter content');	
		editor.Focus();	
		return false; 
	}
}
</script>

<?php require_once("left_panel.php");?>
<div class="content">
	<div class="workplace">
		<?php if(isset($_SESSION['save_succ_msg'])) { ?>
		<div class="alert alert-success">                
		<b><?php echo $_SESSION['save_succ_msg'];?></b>
		</div> 
		<?php
		unset($_SESSION['save_succ_msg']);
		}
		?>
		<div class="row-fluid">
			<div class="span12">
				<div class="head clearfix">
					<div class="isw-documents"></div>
					<h1>Order Cancellation</h1>
				</div>
				<form action="" method="post" enctype="multipart/form-data" onsubmit="return frm_validation();">
				<div class="block-fluid">
					<div class="row-form clearfix">
						<div class="span3">Content <font color="#FF0000">*</font></div>
						<div class="span9">
						<?php 
						$oFCKeditor = new FCKeditor('content');
						$oFCKeditor->Height=400;
						$oFCKeditor->Width=700;
						$oFCKeditor->BasePath = '../FCKeditor/';
						$oFCKeditor->Value= $content;
						$oFCKeditor->Create(); 
					   ?>
					   </div>                            
					</div>
					<div class="row-form clearfix">
						<div class="span3">&nbsp;</div>
						<div class="span9">
						<button class="btn" type="submit" name="edit">Save</button>
						</div>
				   </div>
				</div>
				</form>
			</div>
		</div>
	</div>
</div>   

<?php require_once("footer.php"); ?>