<?
session_start();ob_start();
include("../include/db.inc.php");
	include("../include/bit_functions.inc.php");
	include("../include/pager.php");
	$db1=new db;
	$db1->open();
	
		if(isset($_POST['sub_btn']))
		{	
				
				
		foreach($_POST['st'] as $frn)
		{			
			$q="update zb_banners set status=0 where bid='$frn'";
			mysql_query($q) or die(mysql_error());				
		}	
		foreach($_POST['status'] as $arr)
		{
			$q="update zb_banners set status=1 where bid='$arr'";
			mysql_query($q) or die(mysql_error());					
		}		
		
		header("Location: banners.php");	
		}
	//$filter=mkfilter("banner_location+".$_GET['blocation']); // pass value to make fileter string for fitering		
		$qry="select * from zb_banners ";
		$tot_found=mysql_num_rows(mysql_query($qry));	
		$rst=mysql_query(dopaging($qry,10));			
		
	if($_GET['del'])
	{  
		   $del_query=mysql_query("delete from zb_banners where bid=".$_GET['del']);
		}
		
		 if(isset($_GET['status']))
{
$blocked=$_GET['status'];

if($blocked==1)
$blocked=0;
else
$blocked=1;
$bid=$_GET['bid'];
$sql="update zb_banners set status='$blocked' where bid='$bid'";
mysql_query($sql);
header("location:banners.php");
exit();
}
		function mkchkbox($id,$chkname,$checked,$val){
		if($checked==0){$chk="checked";}
		if(strlen($val)>0){$value="value='".$val."'";}
		return '<input id="'.$id.'" name="'.$chkname.'" type="checkbox" '.$value.' '.$chk.'>';
	}
	
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Money-Auctions Administion Console</title>
<link href="index.css" rel="stylesheet" type="text/css" />

<script language="JavaScript" src="../include/common.js"></script>
<script language="JavaScript">
	function filter(){
		document.form3.submit();
	}
	function veiwimage(url){				
		window.open(url,'','width=600,height=670,top=5,left=180');		
	}	
</script>

<link href="<?=_BASEURL_?>/css/style.css" rel="stylesheet" type="text/css" >
<link href="../include/stylesheet.css" rel="stylesheet" type="text/css">
<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:750px">
<div class="maximum">

<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::header starts:::::::::::::::::::::::::::::::::::::::::::::::::::::-->


<div style="margin-top:5px">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" style="border-collapse:collapse; border-color:#404193">
  <tr height="417">
<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::left starts:::::::::::::::::::::::::::::::::::::::::::::::::::::-->   
    <td width="15%"  valign="top">
		<!--Start Left Panel-->
		<?
			include("left.php");
		?>
		<!--End Left Panel-->
		</td>
<td width="95%" bgcolor="#FFFFFF" valign="top">	
	<!--Start Main Body-->		
<table width="100%" border="0" cellpadding="0" cellspacing="0" >
  <tr>    
    <td align="center" valign="top"><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 ><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td width="29%"><strong>&nbsp;BANNER LIST</strong></td>
                      <td width="61%">&nbsp;</td>
                      <td width="20%" align="right"><a href="new_banner.php" class="link5">New Banner</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" > <br> <form action="" method="get" name="form3">
                    <table width="300" border="0" cellspacing="2" cellpadding="0">
                      <tr> 
                        <td width="77"><strong>Filter By</strong></td>
                        <td width="165"> <select name="location" class="inp" onChange="filter()">
                            <option value="">All</option>                        
                          </select> </td>
                      </tr>
                    </table>
                  </form>
                  <? if(!$tot_found){echo "<br><br><h4>No record found</h4><br>";}else{?>
                  <form action="" method="post">
                    <table width="100%" border="0" cellspacing="1" cellpadding="0">
                      <tr bgcolor="#003366"> 
                       
                        <td width="24%" height="20"><strong><font color="#99CCFF" style="padding-left:5px;">Title</font></strong></td>
                        <td width="9%"><strong><font color="#99CCFF" style="padding-left:5px;">Image</font></strong></td>
                        <td width="11%"><strong><font color="#99CCFF" style="padding-left:5px;">Page</font></strong></td>
                        <td width="11%"><strong><font color="#99CCFF" style="padding-left:5px;">Location</font></strong></td>
                        <td width="6%"><strong><font color="#99CCFF" style="padding-left:5px;">Action</font></strong></td>
                        <td width="6%" align="center"><strong><font color="#99CCFF" style="padding-left:5px;">Status</font></strong></td>
                        <td width="6%" height="20" align="center" ><strong><font color="#99CCFF" style="padding-left:5px;">Delete</font></strong></td>
                      </tr>
                      <? $i=0;
				while($myrow=mysql_fetch_array($rst)){// echo"the banner list";
					if($i%2==0){$col='#E6F2FF';}else{$col='#F0F8FF';}
			?>
                      <tr bgcolor="<?=$col?>"> 
                       <?php /*?> <td style="padding-left:5px"> 
                          <? if($myrow['banner_type']==1){echo 'Image';}else if($myrow['banner_type']==2){echo 'Text';}?>
                        </td><?php */?>
                        <td style="padding-left:5px;"> <a class="link1" title="Banner View" href="javascript:popwin('banner_view.php?bid=<?=$myrow['bid']?>')" > 
                          <?=substr($myrow['banner_title'],0,40)?>
                          
                          </a> </td>
                        <td> 
                          <?
						  if($myrow['banner_image']){
						  	echo '<a href="javascript:veiwimage(\'../images/banners/'.$myrow['banner_image'].'\')"><img src="../images/banners/'.$myrow['banner_image'].'" width="50" height="50" border="0"></a>';
						  }
						  ?>
                        </td>
                        <td style="padding-left:5px;">  
						<?=substr($myrow['pagename'],0,40)?>
                        </td>
                        <td>                          
						  <?=substr($myrow['banner_location'],0,40)?>					  
                        </td>
                        <td align="center"><a href="edit_banner.php?id=<?=$myrow['bid']?>" class="link">Edit</a></td>
                        <td align="center"> 
                         
						 <?
						if($myrow['status']=='0')
						{
						?>
		<a href="banners.php?status=<?=$myrow['status'];?>&bid=<?=$myrow['bid']?>">
		<? echo mkchkbox('st'.$i,'status[]',$myrow['status'],$myrow['bid']);?></a>
		                 <?
                            }
						else
						
						   {
						   ?>
		<a href="banners.php?status=<?=$myrow['status'];?>&bid=<?=$myrow['bid']?>">
		<? echo mkchkbox('st'.$i,'blocked[]',$myrow['status'],$myrow['bid']);?></a>
                             <?
						   }	
						
						?>
                          
                        </td>
                        <td align="center"><a href="banners.php?del=<?=$myrow['bid']?>"class="link">Delete</a></td>
                      </tr>
                      <? $i++;}?>
                    </table>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr bgcolor="#95CAFF"> 
                        <td align="center"><input name="sub_btn" type="submit" value="Update" class="inp"></td>
                      </tr>
                      
		<tr>
			<td colspan="6" align="center"><? echo rightpaging(); ?></td>
		</tr>
<?
	}	// end of paging display
?>
					  					  
                    </table>
                  </form>
                 
                  <br> </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 align="right" background="img/tbl-bg.gif"><img src="img/tbl-right05.gif" width="35" height="12"></td> -->
              </tr>
            </table>
          </td>
          <td width="15" valign="top">&nbsp;</td>
        </tr>
      </table></td>
  </tr>
</table>
		   <!--End Main Body-->
		</td>
  </tr>
</table>
</div>


</div>
<div class="bottom_links_show"><? include("footer.php");	?></div>
</div>
<!--::::::::::::::::::::::::::::::::::::::::::::::::::::::::::footer ends:::::::::::::::::::::::::::::::::::::::::::::::::::::-->
</body>
</html>
