<?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";

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_artistid"]) and $_SESSION["sess_artistid"]!= ""){
	$artistid = $_SESSION["sess_artistid"];
}else{
	header("Location:login.php");
	exit;
}

if(checkArtistExpired($artistid)){
	header("Location:seller_plan_upgrade.php?sellerid=".$artistid);
	exit;
}

$refund_id=$_REQUEST['refund_id'];
$qry="select * from ".$tableprefix."settings ";
$rs_q=mysql_query($qry) or die(mysql_error());
$rr_settings=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.status,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.order_id=r.order_id and od.product_id=r.product_id 
	 and a.artist_id=r.seller_id and r.seller_id=".$artistid."   and r.refund_id= '".$refund_id."'";
	 
		 
$result=mysql_query($sql) or die(mysql_error());
$rr=mysql_fetch_array($result);
include "../includes/htmltop.php";
?>
		<body>
		<center>
		<div align="left" id="layout">
				<!--header area start -->
<?php

	include_once("../includes/topheader_seller.php")

?>
				<!--header area end -->
				<div align="left" class="main_body">
				<!--main body start -->
<?php
		include_once("../includes/artisttopmenu.php")
?>		
																					
								
					<div align="left" class="content_area">
					
					<!--content area start -->
							
					<div align="left" class="page_title"><?php echo TEXT_REF_SETTL;?></div>
					<div align="center" class="text_information grey_tr"><?php echo $message?></div>
            		<br>
											
					<div align="left">																			
						<form name="frmrefund" action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST">
							<table cellpadding="4" cellspacing="4" align="center" class="manage_table" width="100%">
								<tr>
								  <td><?php echo TEXT_BUYER_NAME;?></td>
								  <td>:</td>
								  <td>&nbsp;<?php echo htmlentities($rr['billing_first_name'] . " " . $rr['billing_last_name']);?></td>
							  </tr>
							  <tr>
								  <td width="35%"><?php echo TEXT_BUYER_EMAIL;?></td>
								  <td width="1%">:</td>
								  <td width="64%"><?php echo htmlentities($rr['billing_email']);?></td>
								</tr>
								<tr>
								  <td width="35%"><?php echo TEXT_PRODUCT;?> <?php echo TEXT_NAME;?></td>
								  <td width="1%">:</td>
								  <td width="64%"><?php echo htmlentities(stripslashes($rr['product_name']));?></td>
								</tr>
								<tr>
								  <td><?php echo TEXT_RET_REASON;?></td>
								  <td>:</td>
								  <td><?php echo htmlentities(stripslashes($rr['return_reason']));?></td>
							  </tr>
							  <tr>
								  <td><?php echo TEXT_BUYER_COMMENTS;?> </td>
								  <td>:</td>
								  <td><?php echo htmlentities(stripslashes($rr['Additional_info']));?></td>
							  </tr>
							   <tr>
								  <td><?php echo TEXT_REF_REQ_DT;?></td>
								  <td>:</td>
								  <td><?php echo dateFormat($rr["date"], "Y-m-d", "m/d/Y");?></td>
							  </tr>
							    <tr>
								  <td><?php echo TEXT_QUANTITY;?></td>
								  <td>:</td>
								  <td><?php echo htmlentities($rr['quantity']);?></td>
							  </tr>
							  <!-- <tr>
								  <td>Quantity</td>
								  <td>:</td>
								  <td><?php echo htmlentities($rr['quantity']);?></td>
							  </tr>-->
							  
							  <?php if($rr['quantity']!='')
							  {
							  ?>
							   <tr>
								  <td><?php echo TEXT_SELLER_REMARKS;?></td>
								  <td>:</td>
								  <td><?php echo htmlentities($rr['Customer_Feedback']);?></td>
							  </tr>
							  
							  <?php } // end if ?>
								<tr>
								  <td colspan="3">
								  <div id="refundmode" style="display:none;"><table width="100%" cellpadding="5" cellspacing="5">
								  <tr>
								    <td width="34%"><?php echo TEXT_REF_MODE;?> </td>
								    <td width="2%">:</td>
								    <td width="64%"><select name="rmode" class="textbox">
									<option value=""><?php echo TEXT_SEL_ONE;?><?php echo TEXT_REF_MODE;?></option>
									<option value="Cash">Cash</option>
									<option value="Cheque"><?php echo TEXT_CHEQ;?></option>
									<option value="Cheque"><?php echo TEXT_DEM_DRAFT;?></option>
							        </select></td>
								  </tr>
								  <tr>
								    <td><?php echo TEXT_REF_NO;?></td>
								    <td>:</td>
								    <td><input name="refno" type="text" id="refno" class="textbox"></td>
								    </tr>
								  </table></div>
								  </td>
							  </tr>
								
							  <tr align="center">
							    <td colspan="3"><input type="button" name="btnBack" value="<?php echo BTN_BACK_REF_REQ;?>" class="button" onClick="window.location.href='list_refunds.php'">							    </td>
							  </tr>
						  </table> 
						</form>
				
				</div>
										
				<!--content area end-->
								
				</div>
				
								
					<div align="left" class="clear_float"><img src="<?php echo $imagefolder;?>/clear.gif" alt="" width="1" height="1" /></div>
				<!--main body end -->
				</div>
				
				
<?php
	include "../includes/footer.php";
?>
<script language="javascript">

function validation()
{
	var aa =document.frmrefund.rma_action.value;
	if(document.frmrefund.feedback.value=="")
	{
		alert("<?php echo ALERT_ENTER_FEEDBK;?>");
		document.frmrefund.feedback.focus();
		return false;
		
	}
	if(aa=="Refund")
	{
		if(document.frmrefund.rmode.value=="")
		{
		
			alert("<?php echo ALERT_SEL_REF_MODE;?>");
			document.frmrefund.rmode.focus();
			return false;
		}	
		
		if(document.frmrefund.rmode.value=="Cheque" || document.frmrefund.rmode.value=="Demand Draft")
		{
			if(document.frmrefund.refno.value=="")
			{
			alert("<?php ALERT_ENTER_REF_NO;?>");
			document.frmrefund.rmode.focus();
			return false;
			}
		}	
		
		
	}
	
	return true;
}

function displayDiv()
	{
		
		var aa =document.frmrefund.rma_action.value;
		if(aa=="Refund")
		{
		document.getElementById("refundmode").style.display="";
		}
		else
		{
			document.getElementById("refundmode").style.display="none";
		}
		
	
	}
</script>