<?php
    session_start();          
    if(empty($_SESSION['p0B_c0ff33'])) header('location:login.php?goto=index');
	include "../db_function.php";

    if(empty($_GET['p'])){
        $_GET['p']="footer";
    }

	include('templates/header.php'); 
	include('templates/menu.php'); 
?>

<!-- start content-outer -->
<div id="content-outer">
<!-- start content -->
<div id="content">

<div id="page-heading">
  <h1>Website Footer</h1>
</div>

<?php
if (isset($_GET['msg']) && $_GET['msg'] == 1) {
	echo '<div id="message-green">
		<table border="0" width="100%" cellpadding="0" cellspacing="0">
		<tr>
			<td class="green-left">Footer content saved successfully!</td>
			<td class="green-right"><a class="close-green"><img src="images/table/icon_close_green.gif" alt="" /></a></td>
		</tr>
		</table>
	</div>';
}
?>
  
<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
<tr>
	<th rowspan="3" class="sized"><img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
	<th class="topleft"></th>
	<td id="tbl-border-top">&nbsp;</td>
	<th class="topright"></th>
	<th rowspan="3" class="sized"><img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
</tr>
<tr>
	<td id="tbl-border-left"></td>
	<td>
		<div id="content-table-inner">

		<table border="0" width="100%" cellpadding="3" cellspacing="1" class="tb">
		<tr>
			<th width="5%">No</th>
			<th>Section</th>
			<th>Content Preview</th>
			<th width="12%">Action</th>
		</tr>

		<?php
		// Row 1: Copyright headline (editable via tbltext page='footer_copyright')
		$res_copy = mysql_query("SELECT * FROM tbltext WHERE page='footer_copyright'");
		$copy_row = ($res_copy && mysql_num_rows($res_copy) > 0) ? mysql_fetch_array($res_copy) : array();
		$copy_text = (isset($copy_row['detail']) && !empty($copy_row['detail'])) 
			? $copy_row['detail'] 
			: 'រក្សាសិទ្ធិគ្រប់យ៉ាងនៅឆ្នាំ ២០១៣ ដោយ LoveWedding <em style="color:#999;">(default)</em>';

		// Row 2: Footer Left Address (editable via tbltext page='address')
		$res_addr = mysql_query("SELECT * FROM tbltext WHERE page='address'");
		$addr_row = ($res_addr && mysql_num_rows($res_addr) > 0) ? mysql_fetch_array($res_addr) : array();
		$addr_text = isset($addr_row['detail']) ? $addr_row['detail'] : '';
		$addr_preview = mb_strlen(strip_tags($addr_text), 'UTF-8') > 80 ? mb_substr(strip_tags($addr_text), 0, 80, 'UTF-8') . '...' : strip_tags($addr_text);
		?>
		<tr class="tb_data">
			<td align="center">1</td>
			<td><strong>Copyright Text</strong><br /><small>Footer headline / copyright line</small></td>
			<td><?php echo $copy_text; ?></td>
			<td align="center"><a href="afooter.php?p=footer" style="color: #0033cc;">Edit</a></td>
		</tr>
		<tr class="tb_data">
			<td align="center">2</td>
			<td><strong>Footer Left</strong><br /><small>Address / Contact Info</small></td>
			<td><?php echo htmlspecialchars($addr_preview ? $addr_preview : '(empty - click Edit to add)'); ?></td>
			<td align="center"><a href="afooter.php?p=footer" style="color: #0033cc;">Edit</a></td>
		</tr>
		<tr class="tb_data">
			<td align="center">3</td>
			<td><strong>Footer Right</strong><br /><small>Copyright &amp; Design Credit</small></td>
			<td>រចនាដោយ CITA | Advertise with us</td>
			<td align="center"><span style="color:#999; font-size:11px;">Fixed</span></td>
		</tr>
		</table>

		<div style="margin-top: 14px;">
			<a href="afooter.php?p=footer" style="display:inline-block; padding:7px 16px; background:#27ae60; color:#fff; border-radius:4px; text-decoration:none; font-weight:bold;">&#9998; Edit Footer Content</a>
		</div>

		<div class="clear"></div>
		</div>
	</td>
	<td id="tbl-border-right"></td>
</tr>
<tr>
	<th class="sized bottomleft"></th>
	<td id="tbl-border-bottom">&nbsp;</td>
	<th class="sized bottomright"></th>
</tr>
</table>
<div class="clear">&nbsp;</div>

</div>
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer -->

<div class="clear">&nbsp;</div>

<?php include('templates/footer.php'); ?>
