<style type="text/css">
<!--
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
-->
</style>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
   
        <td width="38" align="left"><img src="img/showlist.jpg" width="38" height="35" /></td>
         <td width="323" align="left"><span class="head">CONTENT MANAGEMENT SYSTEM</span></td>
    
    
    <? if($_GET["action"]==""){?>
    <form action="index.php?option=ann-cms&cmsdisplay=<?=$_GET["cmsdisplay"]?>" method="post">
    <td align="right"><span class="search">
      <label for="keyword"></label>
      <input type="text" name="keyword" id="keyword" />
      &nbsp; 
      <label for="imageField"></label>
      <input type="image" name="imageField" id="imageField" width="20" height="20" src="images/search.jpeg" />
    </span></td>
    </form>
        <? }?>
  </tr>
    </table>
<br />
<?PHP
$option=$_GET["option"];
switch($_GET["action"])
{
case"editcms":{ 
 $sql="SELECT * FROM ann_cms_all WHERE cms_id='".$_GET["itemid"]."'";
 $result=mysql_query($sql) or die ($sql);
 $ROW=mysql_fetch_array($result);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
        <td width="7" height="5" valign="top"><img src="images/border_01.jpg" width="7" height="5" /></td>
        <td background="images/border_02.jpg" style="background-repeat:repeat-x"></td>
        <td width="6" height="5" valign="top"><img src="images/border_03.jpg" width="6" height="5" /></td>
      </tr>
      <tr>
        <td background="images/border_04.jpg" style="background-repeat:repeat-y"></td>
        <td align="center" valign="top">
<form action="index.php?postdb=cms_all_db" method="post" name="frmtypeadd" id="frmtypeadd" enctype="multipart/form-data">        
        <table width="85%" border="0" align="center" cellpadding="2" cellspacing="0" class="font">
  <tr>
    <th colspan="2" scope="col">&nbsp;</th>
  </tr>
  <tr>
    <td width="25%"><strong>CMS : </strong></td>
    <td width="75%"><strong><?=$ROW["cms_name"]?></strong></td>
  </tr>
 <!-- <tr>
    <td width="25%"><strong>TITLE (Thai): </strong></td>
    <td width="75%"><input type="text" name="cms_title" value="<?=$ROW["cms_title"]?>" style="width:99%"></td>
  </tr>
    <tr>
    <td width="25%"><strong>TITLE (English) : </strong></td>
    <td width="75%"><input type="text" name="cms_title_eng" value="<?=$ROW["cms_title_eng"] ?>" style="width:99%"></td>
  </tr>-->
   <tr>
    <td width="25%"><strong>CMS EDIT : </strong></td>
    <td width="75%"><textarea name="cms_content" id="cms_content"><?=$ROW["cms_content"]?></textarea>
   <?=editor("cms_content");?></td>
  </tr>
    <!--<tr>
    <td width="25%"><strong>CMS EDIT (English) : </strong></td>
    <td width="75%"><textarea name="cms_content_eng" id="cms_content_eng"><?=$ROW["cms_content_eng"]?></textarea>
   <?=editor("cms_content_eng");?></td>
  </tr>
    <tr>
    <td width="25%"><strong>BANNER UPLOAD (Thai): </strong></td>
    <td width="75%">
	  <? if($ROW["cms_banner"] !=="")
	{
	echo "<IMG SRC=\"../datacenter/banner/".$ROW["cms_banner"]."\" height=\"75\">";
	echo "<BR>";
	}
	?>
	<strong><input type="file" name="cms_banner"></strong></td>
  </tr>   <tr>
    <td width="25%"><strong>BANNER UPLOAD (English): </strong></td>
    <td width="75%"><strong>
	 <? if($ROW["cms_banner_eng"] !=="")
	{
	echo "<IMG SRC=\"../datacenter/banner/".$ROW["cms_banner_eng"]."\" height=\"75\">";
	echo "<BR>";
	}
	?>
<strong><input type="file" name="cms_banner_eng"></strong></td>
  </tr>-->
  <tr>
    <td><input name="subsection" type="hidden"  value="editcms">
	     <input name="cmsdisplay" type="hidden"  value="<?=$_GET["cmsdisplay"];?>">
		<input name="itemid" type="hidden"  value="<?=base64_encode($ROW["cms_id"])?>">
	</td>
    <td><input name="Submit" type="submit" value="Save">
       <input name="input2" type="button" onclick="window.location='index.php?option=<?=$option?>&cmsdisplay=<?=$_GET["cmsdisplay"]?>'" value="Cancle" class="button" /></td>
  </tr>
</table>
</form>
</td>
        <td background="images/border_06.jpg" style="background-repeat:repeat-y"></td>
      </tr>
      <tr>
        <td width="7" height="7" valign="top"><img src="images/border_07.jpg" width="7" height="7" /></td>
        <td background="images/border_08.jpg" style="background-repeat:repeat-x">&nbsp;</td>
        <td width="6" height="7" valign="top"><img src="images/border_09.jpg" width="6" height="7" /></td>
      </tr>
    </table>
<? break;}default:{ ?>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
        <td width="7" height="5" valign="top"><img src="images/border_01.jpg" width="7" height="5" /></td>
        <td background="images/border_02.jpg" style="background-repeat:repeat-x"></td>
        <td width="6" height="5" valign="top"><img src="images/border_03.jpg" width="6" height="5" /></td>
      </tr>
      <tr>
        <td background="images/border_04.jpg" style="background-repeat:repeat-y"></td>
        <td>
                  <?PHP
$cmsdisplay = $_GET["cmsdisplay"];

$limit="20";
if(empty($_GET["page"])) {
	$page = 1;
} else {
	$page = $_GET["page"];
}	

$keyword=$_POST["keyword"];
if($_POST["keyword"]==""){
$keyword=$_GET["keyword"];
}


if($keyword!=""){	 		
$sql="select  * from ann_cms_all where cms_name like '%".$keyword."%' and cms_display = '$cmsdisplay' order by cms_id desc";
} else{
$sql="select  * from ann_cms_all WHERE cms_display = '$cmsdisplay' order by cms_id desc";
}

$total = mysql_num_rows(mysql_query($sql));
$total=$total;
if($total % $limit) {
	$total_page = floor($total / $limit) + 1;	
} else {
	$total_page = floor($total / $limit);	
}
$start = (($page - 1) * $limit);
$sql = $sql." limit $start, $limit";
$query =mysql_query($sql)or die($sql);
$n = 1;
?>
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
            <td height="5" colspan="3" align="center" class="font"></td>
            </tr>
         <tr>
            <td height="20" colspan="3" align="right" class="font"><table width="300" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="220" align="right"><span class="font-menu">Page&nbsp;                    <?
$end_page = 2;
$start = $page - $end_page;
if($page <= $end_page) {
	$start = 1;
}
$stop = $page + $end_page;
if($stop >= $total_page) {
	$stop = $total_page;
}
for($i = $start; $i <= $stop; $i ++) {
	if($i == $page) {
?>
                    <span class='page-numbers current'>
                      [<?=$page?>]                      </span>
                    <? } else { ?>
<a class='page-numbers' href='index.php?option=<?=$option?>&page=<?=$i?>&keyword=<?=$keyword?>'>&nbsp;<?=$i?>&nbsp;</a><? }}?></span></td>
                <td width="80" align="right"><span class="font-menu"></span></td>
              </tr>
            </table></td>
            </tr>
          <tr>
            <td height="10" colspan="3" align="center" class="font"></td>
            </tr>
          <tr>
            <td width="5%" height="30" align="center" bgcolor="#bdd5f6" class="font"><strong>List</strong></td>
            <td align="center" bgcolor="#bdd5f6" class="font"><strong>Name</strong></td>
            <td width="10%" align="center" bgcolor="#bdd5f6" class="font"><strong>Process</strong></td>
        </tr>
<?
$start = (($page - 1) * $limit);
$bg="#d8e8fe";
while($Row = mysql_fetch_array($query)) {
	if($bg=="#d8e8fe"){
				$bg="#EDF4FE";
			}else if($bg=="#EDF4FE"){
				$bg="#d8e8fe";
			}				
				?>
          <tr class="font">
            <td align="center" bgcolor="<?=$bg;?>"><?=$start+$n++;?>.</td>
            <td bgcolor="<?=$bg;?>"> &nbsp;<?=$Row["cms_name"]?></td>
            <td align="center" bgcolor="<?=$bg;?>"><img src="images/faqseditconticon.gif" width="13" height="13" border="0"  style="cursor:pointer" onClick="window.location='index.php?option=ann-cms&action=editcms&itemid=<?=$Row["cms_id"]?>&cmsdisplay=<?=$cmsdisplay?>'">&nbsp;
		</td>
          </tr>
          <? }?>
                    <tr>
            <td height="10" colspan="3" align="center" class="font"></td>
            </tr>
          <tr>
            <td colspan="3" align="center" class="font"><span class="font-menu">      <? if($page <= $total_page) {
					 $prevpage = $page - 1; 
					 if($prevpage < "1")
						$prevpage="1";
					 ?>
      <a href='index.php?option=<?=$option?>&page=1&keyword=<?=$keyword?>'><span class="hproduct">First</span></a>&nbsp;  <a href='index.php?option=<?=$option?>&page=<?=$prevpage?>&keyword=<?=$keyword?>'><span class="hproduct">Back</span></a>
      <? } ?>&nbsp;Page&nbsp;             
                    <?
$end_page = 2;
$start = $page - $end_page;
if($page <= $end_page) {
	$start = 1;
}
$stop = $page + $end_page;
if($stop >= $total_page) {
	$stop = $total_page;
}
for($i = $start; $i <= $stop; $i ++) {
	if($i == $page) {
?>
                    <span class='page-numbers current'>
                      [<?=$page?>]                      </span>
                    <? } else { ?>
<a class='page-numbers' href='index.php?option=<?=$option?>&page=<?=$i?>&keyword=<?=$keyword?>'>&nbsp;<?=$i?>&nbsp;</a><? }}?>&nbsp;<? if($page <= $total_page) { 
						$nextpage = $page + 1; 
						if($nextpage > $total_page)
						$nextpage=$total_page;
						?>
      <a href='index.php?option=<?=$option?>&page=<?=$nextpage?>&keyword=<?=$keyword?>'><span class="hproduct">Next</span></a> <a href='index.php?option=<?=$option?>&page=<?=$total_page?>&keyword=<?=$keyword?>'><span class="hnews">&nbsp; End</span></a>
      <? } ?> &nbsp;&nbsp;&nbsp;Page <?=$page?> of <?=$total_page?> &nbsp;&nbsp;Total list &nbsp;<?=$total;?> list</td>
</tr>
                      <tr>
            <td height="5" colspan="3" align="center" class="font"></td>
            </tr>
        </table>
</td>
        <td background="images/border_06.jpg" style="background-repeat:repeat-y"></td>
      </tr>
      <tr>
        <td width="7" height="7" valign="top"><img src="images/border_07.jpg" width="7" height="7" /></td>
        <td background="images/border_08.jpg" style="background-repeat:repeat-x">&nbsp;</td>
        <td width="6" height="7" valign="top"><img src="images/border_09.jpg" width="6" height="7" /></td>
      </tr>
    </table>
    <? }}?>