<?
ob_start();
session_start();

 	include("../include/db.inc.php"); 
	include("../include/bit_functions.inc.php");
 	include("../include/pager.php");	
   $db1=new db;
   $db1->open();
    mysql_query("SET NAMES 'utf8'");
   
   mysql_query("SET NAMES 'utf8'");
   if($_SESSION['uname']=='' || $_SESSION['pwd']=='')
		{
			header("location:login.php");
		}
		 
  if(isset($_GET['status'])) {
	$status=$_GET['status'];
	
	if ($status=='1')
	   $status='0';
	else
	   $status='1';   
	 $pid = $_GET['pid'];
	 $qu="Update t123go_product set status='$status' where pid='$pid'"; 
	mysql_query($qu);
	header("location:featured_product.php");
	exit();
	} 
	 if($_POST['product_order'] ) {
	
	 $product_order=$_POST['product_order'];
	 $pid = $_POST['pid'];
	 $qu="Update t123go_product set product_order='$product_order' where pid='$pid'"; 
	mysql_query($qu);
	header("location:featured_product.php");
	exit();
	} 
	if(isset($_GET['return'])){  
		
		   $return_query=mysql_query("select id,uid from t123go_bid where pid='".$_GET['return']."' and noti_status='0' order by uid");
		   while($return_user=mysql_fetch_array($return_query)){
		   $user_bid=mysql_fetch_array(mysql_query("select no_bids from user where id='".$return_user[uid]."'"));
		    $total_bid=$user_bid[no_bids]+1;
		   mysql_query("update user set no_bids='".$total_bid."' where id='".$return_user[uid]."'");
		   mysql_query("update t123go_bid set noti_status='1' where id='".$return_user[id]."' and noti_status='0'");
		   }
			
		}
     
		if($_GET['del']){  
		
		   $del_query=mysql_query("delete from t123go_product where pid=".$_GET['del']);
			
		}
		
	$select="select *,(select name from add_category where add_category.id=t123go_product.cid) as name from t123go_product where featured='1' order by pid ";
	$sel_query=mysql_query($select);
  $tot=mysql_num_rows($sel_query);
  ?>
<!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 | Admin Controls</title>
<link href="index.css" rel="stylesheet" type="text/css" />
<script language="JavaScript">
function veiws(pid){

		window.open('thumbnail.php?id='+pid,'','scrollbars,width=800,height=600,top=50,left=180');
	}
	function viewproduct(id){
		window.open('view_product.php?id='+id,'','scrollbars,width=920,height=700,top=5,left=180');		
	}
	function sendmail(id){
		window.open('send_mail.php?id='+id,'','scrollbars,width=800,height=500,top=50,left=180');		
	}
	
</script>
</head>
<body>
<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"><br />
<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>FEATURED PRODUCT</strong> </td>
                      <td width="54%">&nbsp;</td>
                      <td width="26%" align="right">
					  <a href="product_new.php?featured=1" class="link5">Add Product</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 width="100%" border="1" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF" style="border-collapse:collapse; border-color:#FED267">
                            <tr bgcolor="#FED267"> 
							<td width="50"  ><strong><font color="#FFFFFF" size="+1">S.No.</font></strong></td>
                              <td width="120" align="center" ><strong><font color="#FFFFFF" size="+1">Thumbnail</font></strong></td>
							   <td width="137" ><strong><font color="#FFFFFF" size="+1">Product Name</font></strong></td>
							    <td width="59"  ><strong><font color="#FFFFFF" size="+0">Auction Type</font></strong></td>
                              <td width="99"  ><strong><font color="#FFFFFF" size="+1">Return Bids</font></strong></td>
                              <td width="42"  ><strong><font color="#FFFFFF" size="+1">Email</font></strong></td>
							   <td width="42" align="center"><strong><font color="#FFFFFF" size="+1">Product Order</font></strong>
							   </td>
                              <td width="61" align="center"><strong><font color="#FFFFFF" size="+1">Status</font></strong></td>
								<td width="62"height="20" align="center"><strong><font color="#FFFFFF" size="+1">Edit</font></strong></td>
                              <td width="74" height="20" align="center"><strong><font color="#FFFFFF" size="+1">Delete</font></strong></td>
	                        </tr>
							<?  
								$i=1;	
							
                         while($myrow=mysql_fetch_array($sel_query)){  ?>
                            <tr onMouseOver="this.style.backgroundColor='#FFECBF'" onMouseOut="this.style.backgroundColor='#ffffff'"> 
							 <td ><?=$i;?></td>
                              <td align="center" valign="top"><a href="javascript:veiws('<?=$myrow['pid']?>')"><?=image_90($myrow['pid'])?></a>
                              </td>
                              <td ><? echo '<a href="javascript:viewproduct('.$myrow['pid'].')" class="link11">'.$myrow['pname'].'</a>'?></td>
							   <td >
								  <?
								  if($myrow[type1]==1){
								  
								  echo "Fixed Price";
								  }
								  else if($myrow[type1]==2){
								  
								  echo "Penny";
								  }
								  else if($myrow[type1]==3){
								  
								  echo "100% Off";
								  }
								  
								  
								  
								  ?>
							  
							  </td>
                              <td  align="center"><a href="featured_product.php?return=<?=$myrow['pid']?>">Return Bids</a></td>
                              <td ><? echo '<a href="javascript:sendmail('.$myrow['pid'].')" class="link11">send</a>'?>  </td>
							   <td align="center"> 
                               <form action="" method="post"  name="form1">
                               <input type="hidden" name="pid" value="<?=$myrow['pid']?>" />
							   <select name="product_order" style="width:44px" onChange="this.form.submit();">
							   <option value="1" <? if($myrow['product_order']==1){ echo "selected";}?>>1</option>
							    <option value="2" <? if($myrow['product_order']==2){ echo "selected";}?>>2</option>
								 <option value="3" <? if($myrow['product_order']==3){ echo "selected";}?>>3</option>
								  <option value="4" <? if($myrow['product_order']==4){ echo "selected";}?>>4</option>
								   <option value="5" <? if($myrow['product_order']==5){ echo "selected";}?>>5</option>
								    <option value="6" <? if($myrow['product_order']==6){ echo "selected";}?>>6</option>
									 <option value="7" <? if($myrow['product_order']==7){ echo "selected";}?>>7</option>
									  <option value="8" <? if($myrow['product_order']==8){ echo "selected";}?>>8</option>
									   <option value="9" <? if($myrow['product_order']==9){ echo "selected";}?>>9</option>
									    <option value="10" <? if($myrow['product_order']==10){ echo "selected";}?>>10</option>
							  </select>
							  </form> 
                        </td>
                               <td align="center"> 
                                 <? //echo mkchkbox('st'.$i,'status[]',$myrow['status'],$myrow['pid']);?>
                             <?  
                               if ($myrow['status']=='1')
						    {
							
							echo "Started";
                            
							}
						else
						   {
						   
							echo "Stopped";
                            
						   }	
						
						?>
                        </td>
								<td align="center" >
								<? $num_sold=mysql_num_rows(mysql_query("select id from t123go_product_sold where pid=".$myrow['pid']));
								
								if($num_sold > 0){
								echo "Sold";
								} else
								{
								?>
								<a href="edit_product.php?id=<?=$myrow['pid']?>&featured=1" class="link5" title="Click To Edit">Edit</a>
								| <a href="add_pimage.php?id=<?=$myrow['pid']?>&featured=1" class="link5" title="Click To New">New</a>
								<? }?> 
                              </td>
                              <td align="center">
                           <a href="featured_product.php?del=<?=$myrow['pid']?>" onClick="return confirm('Are you sure to delete this Product ?');">
						   <img src="../images/category/imgdelete.gif" border="0"></a>
                            </td>
                            </tr>
                                <?
				$i++;
			}	// end of while loop
		
			if(rightpaging()){	// if there are more than one pages then only display paging
		?>
				<tr>
					<td colspan="9" align="center"><br><? echo rightpaging(); ?></td>
				</tr>
		<?
			}	// end of paging display
		?>
                      </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>
            <br />
<br />

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

</html>
</div>
</body>
</html>
