<?
	session_start();
	ob_start();
	if($_SESSION['uname']=='' || $_SESSION['pwd']=='')
		{
			header("location:login.php");
		}
	include("../include/db.inc.php");
	include("../include/pager.php");	
	include("../include/functions.php");    
	$db1=new db;
    $db1->open();mysql_query("SET NAMES 'utf8'");

	
	$block=$_REQUEST['block'];
	if($block==1)
	{
		$u_id=$_REQUEST['id'];
		$do=$_REQUEST['do'];
		if($do==1)
			$sql_block="update t123go_news set blocked='0' where id='$u_id'";
		else
			$sql_block="update t123go_news set blocked='1' where id='$u_id'";
		mysql_query($sql_block) or die(mysql_error());
		header("location:shownews.php");
	} 

   if (isset($_REQUEST["del"]) && $_REQUEST["del"]==1)
      {
	     $rid=$_REQUEST['id'];
		 $sql_del="delete from t123go_news  where id='$rid'";
		 mysql_query($sql_del);
	  }
	  if(isset($_GET['status'])) {
	$status=$_GET['status'];
	
	if ($status=='1')
	   $status='0';
	else
	   $status='1';   
	 $id = $_GET['id'];
	 $qu="Update t123go_news set blocked='$status' where id='$id'"; 
	mysql_query($qu);
	header("location:shownews.php");
	exit();
	} 
	
	$sql_news="SELECT * FROM t123go_news order by submit_date DESC";
	$res_news=mysql_query(dopaging($sql_news,10));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>

<title>News List</title>
<link href="index.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function views(id){
window.open('view_news.php?nid='+id,'','width=600,height=400,top=50,left=280');
}
</script>

</head>

<body bgcolor="#ffffff">
<div class="admin_wrapper">
<div class="logo_show"><? include("minorlogout.php");?></div>
<div style="float:left; width:200px">
<div class="topg_links_show"><? include("left.php");	?></div>
<div class="top_links_show"><? include("belowleft1.php");	?></div></div>
<div style="float:left; width:800px">
<div class="maximum">
   <table  width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
        <tr> 
          <td width="15" valign="top">&nbsp;</td>
          <td valign="top"><br> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
              <tr> 
                <td width="33" valign="top"><img src="img/03.gif" width="33" height="23"></td>
                 <td background="img/bg01.gif">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="20%"><strong>NEWS LISTING</strong></td>
				<td width="22%" align="right"><a href="add_news.php?record=0" class="headerlinkred">Add News</a></td>
				</tr>
                  </table></td>
                <td width="35"><img src="img/04.gif" width="35" height="23"></td>
              </tr>
            </table>
            <table  width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
              <tr> 
                <td width="22" valign="top" background="img/tbl-left04.gif"><img src="img/tbl-left04.gif" width="22" height="13"></td>
                <td valign="top" align="center"><br> 
    	
			      <table align="center" width="90%" border="1" cellspacing="1" cellpadding="0" style="border-collapse:collapse; border-color:#FED267" >
			<tr bgcolor="#FED267">
			<th width="139" valign="top" class="normaltextnotbold"><font color="#FFFFFF">S.No.</font></th>
			<th width="375" valign="top" class="normaltextnotbold"><font color="#FFFFFF">Title</font></th>
			<th width="139" valign="top" class="normaltextnotbold"><font color="#FFFFFF">Status</font></th>
			<th width="316" valign="top" class="normaltextnotbold"><font color="#FFFFFF">Action</font></th>
			</tr>
			<?
			$i=1;
			while($row_news=mysql_fetch_object($res_news))
			{
			$iid=$row_news->id;		
			?>
				<tr <?php /*?><? if($i%2==0)echo 'bgcolor="#E6E4E3"';?><?php */?> onMouseOver="this.style.backgroundColor='#FFECBF'" onMouseOut="this.style.backgroundColor='#ffffff'">
					<td valign="top" class="normaltextblack" align="center"><? echo $i; ?></td>
					<td valign="top" align="center" class="normaltextblack">
					<a href="javascript:views('<?=$row_news->id;?>')"><? echo substr($row_news->title,0,50);?></a></td>
					<td align="center"> 
                                 <? //echo mkchkbox('st'.$i,'status[]',$myrow['status'],$myrow['pid']);?>
                             <?  
                               if ($row_news->blocked=='1')
						    {
							 ?>
							 <a href="shownews.php?status=<?=$row_news->blocked;?>&id=<?=$row_news->id?>">
							 <input  name="chk[]" type="checkbox" checked 
        onClick="window.location='shownews.php?status=<?=$row_news->blocked;?>&id=<?=$row_news->id?>'" ></a>
                             <?
							}
						else
						   {
						   ?>
							 <a href="shownews.php?status=<?=$row_news->blocked;?>&id=<?=$row_news->id?>">
							  <input  name="chk[]" type="checkbox" 
        onClick="window.location='shownews.php?status=<?=$row_news->blocked;?>&id=<?=$row_news->id?>'" ></a>
                             <?
						   }	
						
						?>
                        </td>
					   <td align="center" width="316" valign="top" class="normaltextblack">
					  <div align="center">
					 <a href="shownews.php?del=1&id=<? echo $row_news->id; ?>" class="headerlinkred" 
					 onClick="return confirm('Are you sure to delete this News ?');">Delete</a>&nbsp;
					</a>|
					 <a href="add_news.php?&record=<? echo $row_news->id; ?>" class="headerlinkred" >Edit</a>&nbsp;
									
					</a>
					  </div>
				</tr>
		<?
				$i++;
			}	// end of while loop
		
			if(rightpaging()){	// if there are more than one pages then only display paging
		?>
				<tr>
					<td colspan="6" align="center"><br><? echo rightpaging(); ?></td>
				</tr>
		<?
			}	// end of paging display
		?><tr><td></td>
	</tr>
	</table></td>
<td width="19" valign="top" background="img/tbl-right04.gif"><img src="img/tbl-right04.gif" width="19" height="9"></td>	
</tr></table>


 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
              <tr> 
                <td width="33"><img src="img/tbl-bot01.gif" width="33" height="12"></td>
                <td  width="709" align="right" background="img/tbl-bg.gif"></td>
                <td width="33"><img src="img/tbl-right05.gif" width="35" height="12"></td>
              </tr>
            </table>     
        </td>
	    <td valign="top" align="center">&nbsp;</td>
    </tr>
 
</table> 

<!-- End ImageReady Slices -->
</div></div>
<div class="bottom_links_show">
</html></div>
</html>
</div>
</body>
</html>
