<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Programmer<programmer@armia.com>        		              |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com � 2005                |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
?>
<?php
include "includes/config.php";
include "includes/session.php";
include "includes/functions.php";
include "includes/arrays.inc.php";

if (get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE); 
} 

if(isset( $_SESSION["sess_userid"]) and $_SESSION["sess_userid"]!= ""){
	$userid = $_SESSION["sess_userid"];
}else{
	header("Location:login.php");
	exit;
}
$orderid=$_GET['orderid'];
$qry="select * from ".$tableprefix."settings ";
$rs_q=mysql_query($qry) or die(mysql_error());
$row=mysql_fetch_array($rs_q);


	 $sql="select o.billing_first_name,o.billing_last_name,o.billing_email ,o.order_id,a.artist_name,od.product_name,r.*
	 from ".$tableprefix."orders o ,".$tableprefix."artists a , ".$tableprefix."order_details od ,".$tableprefix."refunds r 
	 where ".$qryopt." o.order_id=r.order_id  AND od.user_refund_id=r.refund_id and od.product_id=r.product_id
	 and a.artist_id=r.seller_id and r.buyer_id=".$userid." GROUP BY r.refund_id ORDER BY r.refund_id DESC ";
    
	 		 
$result = mysql_query($sql);

$totalrows = mysql_num_rows($result);

$limit=getPaginationLimit();

if($limit==0)
{
	$limit=10;
}	

$page = isset($_GET['page'])? trim($_GET['page']):1;

if(empty($page))
	{
		$page = 1;
	}


$sql_qr=dopaging($sql,'',$limit);	



$result=mysql_query($sql_qr) or die(mysql_error());
/*display the active template*/

$active_template = displayTemplate();


include "includes/htmltop.php";

/* Top File Name */

include_once ("includes/".$active_template[0]);

?>
<script language="JavaScript" type="text/JavaScript">
function clickSearch()
{
	document.frmFeedbacks.submit();
}
function changeStatus(id){
	var frm = document.frmFeedbacks;
	if(Confirm('<?php echo CONFIRM_CHANGE_STATUS_TEXT;?>')){
		document.frmFeedbacks.submit();
	}
}

function checkConfirm()
{
var chks = document.frmresponse.elements['ids[]'];
var hasChecked = false;
for (var i=0;i<chks.length;i++){
if (chks[i].checked){
hasChecked = true;
break;
}
}
if (!hasChecked){
alert('<?php echo SELECT_CHECK_BOX_TEXT;?>');
chks[0].focus();
return false;
}

return true;

}

checked=false;
function checkedAll (frm1) {
	var aa= document.getElementById('frmresponse');
	 if (checked == false)
          {
           checked = true
          }
        else
          {
          checked = false
          }
	for (var i =0; i < aa.elements.length; i++) 
	{
	 aa.elements[i].checked = checked;
	}
      }
</script>


			<div align="left" class="main_body">
			
			<!--mainbody area start -->
			
		<!--center content area start-->		

		<form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post" name="frmresponse">
		
		<div align="left" id="item_details">
		<!--items display area start -->
		<div align="left" id="items_top_area">
				
				<div align="left" id="items_top_area_ttl"><?php echo RETURN_PAYMENTS_TEXT;?></div>
		</div>

		
		<div>
			<fieldset>
			<div class="order_listings">
			<table width="100%"  border="0" cellpadding="0" cellspacing="0" align="center">
				
				<tr>
					<td height="10" colspan="4" align="left"></td>
				</tr>
				<tr><td colspan="4">
				<?php if($totalrows>0)
					{
					?>
				<table width="99%" border="0" cellpadding="2" class="manage_table">
				
				<tr class="shopcart_heads"  >
				
				  <td width="7%"><strong><?php echo SL_NO_TEXT;?> </strong></td>
				  <td width="11%"><strong><?php echo REFUND_ID_TEXT;?></strong></td>
				  <td width="10%"><strong><?php echo ORDER_ID_TEXT;?> </strong></td>
				  <td width="21%"><strong><?php echo PRODUCT_NAME_TEXT1;?> </strong></td>
				  <td width="16%"><strong><?php echo REFUND_MODE_TEXT;?> </strong></td>
				  <td width="13%"><strong><?php echo QUANTITY_TEXT;?></strong></td>
				  <td width="22%"><strong><?php echo REFUND_STATUS_TEXT;?> </strong></td>
				</tr>
				
				<?php 
						$i=1;
						while($rr=mysql_fetch_array($result))
						{
						if($i%2==0)
						{
							$bgcolor="";
						}
						else
						{
							$bgcolor="";
						}	
						$st=$rr['Status'];	
						switch ($st){
							case 'Repair':$st=TEXT_REPAIR;
											break;
							case 'Replace':$st=TEXT_REPLACE;
											break;
							case 'Refund':$st=TEXT_REFUND;
											break;
						}
					?>
				<tr bgcolor="<?php echo $bgcolor;?>">
				  <td><?php echo $i;?></td>
				  <td><a href="myreturns_detail.php?id=<?php echo $rr['refund_id']?>"><?php echo $rr['refund_id'];?></a></td>
				  <td><a href="myreturns_detail.php?id=<?php echo $rr['refund_id']?>"><?php echo $rr['order_id'];?></a></td>
				  <td><a href="myreturns_detail.php?id=<?php echo $rr['refund_id']?>"><?php echo stripslashes($rr['product_name']);?> </a></td>
				  <td><a href="myreturns_detail.php?id=<?php echo $rr['refund_id']?>"><?php echo $rr['refund_mode'];?></a></td>
				  <td>
				  <?php echo $rr['quantity'];?>
			      </td>
				  <td align="left" class="text_information"><?php if($rr['Status']!=''){ echo $st; } else { echo AWAIT_RESPONSE_TEXT;} ?></td>
				  </tr>
				  <?php 
				  $i++;
				  } // end while ?>
				</table>
				  <?php 
				  
				  }  // end if 
				  
				  else
				  {
				  
				  ?>
				  <table width="100%" ><tr><td align="center" class="text_information"><?php echo NO_REFUND_REQUEST_TEXT;?></td>
				  </tr></table>
				  <?php } ?>
				                </td>
				</tr>
				
				
			<?php 
			if($totalrows>10)
			{
			
			?>	
								
								<tr>
									<td  colspan="4"><div  class="pagination"> <?php echo rightpaging();?></div></td>
									
								</tr>
			<?php } ?>					
							  	
								<tr>
									<td align="center" colspan="4"><input type="button" value="<?php echo ACCOUNT_BACK_BUTTON;?>" name="btnBack"  class="button" onClick="window.location.href='myaccount.php'">
									
									</td>
								</tr>
								
			</table>
			<div class="clear"></div>
			</div>
		  </fieldset>
							
							
						
																										
		</div>	
	
	
		<div align="left" class="float_clear1"></div>
					
					
		 <!--items display area end -->
		  </div>
		
			</form>
		<!--center content area end-->	


		<!--mainbody area end -->
        </div>
<?php
include "includes/".$active_template[2];	/* Bottom File Name */
?>																										
																										
																										
																									