<?php
	session_start();
	ob_start();
	if($_SESSION['uname']=='' || $_SESSION['pwd']=='')
		{
			header("location:login.php");
		}
	 include("../include/db.inc.php");
	 include("../include/pager.php");	
	 include("../include/bit_functions.inc.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_productnews set blocked='0' where id='$u_id'";
		else
			$sql_block="update t123go_productnews set blocked='1' where id='$u_id'";
		mysql_query($sql_block) or die(mysql_error());
		header("location:product_news.php");
	} 

   if (isset($_REQUEST["del"]) && $_REQUEST["del"]==1)
      {
	     $rid=$_REQUEST['id'];
		 $sql_del="delete from t123go_productnews  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_productnews set blocked='$status' where id='$id'"; 
	mysql_query($qu);
	header("location:product_news.php");
	exit();
	} 
	function mkchkbox($id,$chkname,$checked,$val){
		if($checked==1){$chk="checked";}
		if(strlen($val)>0){$value="value='".$val."'";}
		return '<input id="'.$id.'" name="'.$chkname.'" type="checkbox" '.$value.' '.$chk.'>';
	}
	$sql_news="SELECT * FROM t123go_productnews 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">
<head>

<title>News List</title>
<link href="../css/stylesheet.css" rel="stylesheet" type="text/css">
<script language="javascript">
function views(id){
window.open('view_productnews.php?nid='+id,'','height=600,top=20,left=280,');
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/back.jpg" style="background-position:top; background-repeat:repeat-x" onLoad="show5()">

<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="30%"><strong>PRODUCT NEWS LISTING</strong></td>
				<td width="22%" align="right"><a href="add_productnews.php?record=0" class="headerlinkred">Add Product 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="59" valign="top" class="normaltextnotbold"><font color="#FFFFFF">S.No.</font></th>
			<th width="175" valign="top" class="normaltextnotbold"><font color="#FFFFFF">Image</font></th>
			<th width="275" valign="top" class="normaltextnotbold"><font color="#FFFFFF">Title</font></th>
			<th width="100" valign="top" class="normaltextnotbold"><font color="#FFFFFF">Value</font></th>
			<th width="180" valign="top" class="normaltextnotbold"><font color="#FFFFFF">Launch Date</font></th>
			<th width="59" valign="top" class="normaltextnotbold"><font color="#FFFFFF">Status</font></th>
			<th width="60" 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" class="normaltextblack" align="center"><? echo get_product_image_admin($row_news->image,50,50)?></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 valign="top" align="center" class="normaltextblack">&pound;&nbsp;<? echo $row_news->news_value;?></td>
					<td valign="top" align="center" class="normaltextblack"><? echo $row_news->news_date;?></td>
					<td align="center"> 
                                 <? //echo mkchkbox('st'.$i,'status[]',$myrow['status'],$myrow['pid']);?>
                             <?  
                               if ($row_news->blocked=='1')
						    {
							 ?>
							 <a href="product_news.php?status=<?=$row_news->blocked;?>&id=<?=$row_news->id?>"><? echo mkchkbox('st'.$i,'blocked[]',$row_news->blocked,$row_news->id);?></a>
                             <?
							}
						else
						   {
						   ?>
							 <a href="product_news.php?status=<?=$row_news->blocked;?>&id=<?=$row_news->id?>"><? echo mkchkbox('st'.$i,'blocked[]',$row_news->blocked,$row_news->id);?></a>
                             <?
						   }	
						
						?>
                        </td>
					   <td align="center" width="316" valign="top" class="normaltextblack">
					  <div align="center">
					 <a href="product_news.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_productnews.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>
</div>


      
            <br />
<br />

</div></div>
<div class="bottom_links_show"><? include("footer.php");	?></div>


<!-- End ImageReady Slices -->
</body>
</html>
