<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 			*/
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2010 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts EasyCart                      |
// +----------------------------------------------------------------------+
// | Authors: Jipson<jipson.thomas@armiasystems.com>             		  |
// +----------------------------------------------------------------------+
?>
<script language="javascript" type="text/javascript">
	function submi(){
		document.sts.submit();
	}
</script>
<div align="center" class="subheading">
 <div align="left">Request For A refund</div>
</div>
<br />
<div align="left" id="item_details_admin">
<?php if($session->check('Message.flash')) { ?><div id="okbox"><font color="#446423"><?php $session->flash(); ?></font></div><?php } ?>
<!--items display area start -->
 
 <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="items_display_area_admin_table">
  <tr>
    <td align="left" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="5">
      <tr>
        <td class="boxtopheader">Products to return </td>
      </tr>
    </table>
    <table width="100%"  border="0" cellspacing="1" cellpadding="6">
      <tr align="left" valign="middle" id="list_admin_top">
		<td width="15%">ProductName</td>
        <td width="9%" align="center">Skuno</td>
        <td width="18%" align="center">Combination</td>
        <td width="10%" align="center">Quantity</td>
		<td width="11%" align="center">Unit Price</td>	
        <td width="10%" align="center">Extra Price </td>
		<td width="11%" align="center">Discount</td>
        <td width="11%" align="center">Price</td>		       
        <td width="9%">Reason </td>      
        
      </tr>

 <?php 
  $amt=0;
  $dis_str='';
  $product_id = '';
  if(count($odr["Refundproducts"])>0)
  {
  $i = 0;
  foreach($odr["Refundproducts"] as $det){   	
	 if(isset($det["discount_type"])) {
		if($det["discount_type"]=='per')
		$dis_str='(%)';
		else if($det["discount_type"]=='amnt')
		$dis_str='($)'; }
               
		
	?>	
      <tr align="left" valign="middle" id="list_admin">
	  <?php $product_id .= $det["product_id"].',' ?>	
        <td align="center"><?php echo stripslashes($det["Product"]); ?>
		</td>
        <td align="center"><?php if(isset($det["skuno"])) echo $det["skuno"]; else echo "-"; ?> </td>
        <td align="center"><?php if(isset($det["combinations"])) echo $det["combinations"]; else echo "-";?></td>
        <td align="center">
		<?php echo $det["quantity"];?>
		</td>
        <td align="center"><?php echo $curlogo;?><?php echo $det["product_price"]; ?></td>
        <td align="center"><?php echo $curlogo;?><?php echo $det["extra_price"]; ?></td>
		<td align="center"><?php 
		if(isset($det["discount"]) && $det["discount"] <> '')
		echo ($det["discount"])*($det["quantity"]); 
		else
		echo '-';
		?></td>
        <td align="center">
		<?php
		$price=0;
		  $combined_price=0;
		  $dis_str='';	
                 
			$combined_price=($det["product_price"] + $det["extra_price"]);			
			 if(isset($det["discount_type"]) && $det["discount_type"] <> '')
			  { 
				if($det["discount_type"]=='per')
				 {
				  if(isset($det["discount"]) && $det["discount"] <> '' && $det["discount"] > 0)
					{
					  $amt = $amt + (($det['discount']+$det['extra_price'])*$det['quantity']);
					  $discounted_price=($combined_price-(($combined_price * $det["discount"])/100));
					  $price=($discounted_price)*$det["quantity"];
					  $dis_str='(%)';
					}											 
				 }
				 else if($det["discount_type"]=='amnt')
				 {	 
				     if(isset($det["discount"]) && $det["discount"] <> '' && $det["discount"] > 0)
					 {
						$amt = $amt + (($det['discount']+$det['extra_price'])*$det['quantity']);
						$price=(($combined_price)-$det["discount"])*$det["quantity"];	
						$dis_str='($)';					
					 }			
				}
			  }
			 else
			 {
			  $price=($det["product_price"] + $det["extra_price"])*$det["quantity"];			 	
			 }			
		$price=number_format($price,2,".",""); 
		  echo $curlogo.$price;?>
	</td>       
        <td align="center">
		<?php echo stripslashes($det["return_reason"]); ?>
		</td>       
       
      </tr>
    
       <?php $i++; } } else { ?>	 
	    <tr align="left" valign="middle" id="list_admin">
        <td colspan="8" align="center">No Details Found.</td>     
        </tr>
	   <?php } ?>
    </table>
      <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="admin_bottom">
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table></td>
  </tr>
</table>
<br>

<table width="100%"  border="0" cellspacing="0" cellpadding="0" id="items_display_area_admin_table">
       <tr>
         <td align="left" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="5">
             <tr>
               <td class="boxtopheader">Order Price Details</td>
             </tr>
           </table>
             <table width="100%"  border="0" cellspacing="1" cellpadding="6">
              
               <tr align="left" valign="middle" id="list_admin">
                 <td>Shipping</td>
                 <td><?php echo $curlogo;?><?php echo $odr["Order"]["shipping_price"]; ?></td>
               </tr>
               <tr align="left" valign="middle" id="list_admin">
                 <td>Tax Name </td>
                 <td><?php echo $odr["Order"]["tax_name"]; ?></td>
               </tr>


               <tr align="left" valign="middle" id="list_admin">
                 <td>Tax</td>
                 <td><?php echo $curlogo;?><?php echo $odr["Order"]["tax_price"]; ?></td>
               </tr>
               <tr align="left" valign="middle" id="list_admin">
                 <td>Discount </td>
                 <td><?php echo $curlogo;?><?php echo $odr["Order"]["discount"]; ?></td>
               </tr>            
             </table>
             <table width="100%"  border="0" cellspacing="0" cellpadding="3" id="admin_bottom">
               <tr>
                 <td width="44%">Order Total</td>
                 <td width="55%" class="toplinks"><?php echo  $curlogo.$odr["Order"]["total_price"]; ?></td>
               </tr>
           </table></td>
       </tr>
     </table>
	 <br />
	 
	   
       <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="items_display_area_admin_table">
         <tr>
           <td align="left" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="5">
               <tr>
                 <td class="boxtopheader">Customer Remarks</td>
               </tr>
             </table>
			
               <table width="100%"  border="0" cellspacing="1" cellpadding="6">
                 <tr align="left" valign="middle" id="list_admin">
                   <td width="31%">Comments</td>
                   <td width="69%">	
				   <textarea name="customer_feedback" id="note" class="box2_admin" readonly="readonly"><?php echo stripslashes($odr["Refund"]["customer_feedback"]); ?></textarea></td>
                 </tr>
               </table>
               </td>
         </tr>
       </table>
	    <br />
	
	   <form name="frmreturn" id="frmreturn" action="" method="POST">
               
              
               <input type="hidden" name="productId" value="<?php echo $product_id; ?>" />
               <input type="hidden" name="uname" value="<?php echo $odr["User"]["uname"]; ?>" />
               <input type="hidden" name="user_id" value="<?php echo $odr["User"]["id"]; ?>" />
               <input type="hidden" name="user_email" value="<?php echo $odr["User"]["email"]; ?>" />
       <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="items_display_area_admin_table">
         <tr>
           <td align="left" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="5">
               <tr>
                 <td class="boxtopheader">Administrator Remarks<input type="hidden" name="id" value="<?php echo $odr["Refund"]["id"]; ?>"></td>
               </tr>
             </table>
			
               <table width="100%"  border="0" cellspacing="1" cellpadding="6">
                 <tr align="left" valign="middle" id="list_admin">
                   <td width="31%">Comments</td>
                   <td width="69%">	
				   <textarea name="additional_info" id="additional_info" class="box2_admin" > <?php echo stripslashes($odr["Refund"]["additional_info"]); ?></textarea></td>
                 </tr>
				 <tr align="left" valign="middle" id="list_admin">
                   <td width="31%">Refund Option</td>
                   <td width="69%">	
				   <select name="refund_mode" class="box2_admin">
				   <?php foreach($refundoptions as $opt){?>
				   <option value="<?php echo $opt;?>"<?php if($opt == $odr["Refund"]["refund_mode"]){?> selected <?php } ?>><?php echo $opt;?></option>
				   <?php } ?>
				   </select>
				   </td>
                 </tr>
				  <tr align="left" valign="middle" id="list_admin">
                   <td width="31%">Refund Status</td>
                   <td width="69%">	
				   <select name="status" class="box2_admin">
				   <?php foreach($refundstatus as $sts){?>
				   <option value="<?php echo $sts;?>"<?php if($sts == $odr["Refund"]["status"]){?> selected <?php } ?>><?php echo $sts;?></option>
				   <?php } ?>
				   </select>
				   </td>
                 </tr>
				 <tr align="left" valign="middle" id="list_admin">
                   <td width="31%">Reference number</td>
                   <td width="69%">	
				   <input type="text" name="reference_number" id="reference_number" class="box2_admin" value="<?php echo $odr["Refund"]["reference_number"]; ?>" ></td>
                 </tr>
               </table>
               <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="admin_bottom">
                 <tr>
                   <td align="left">&nbsp;&nbsp;&nbsp;<input type="submit" class="buttn_admin" value="Save" /></td>
                 </tr>
             </table></td>
         </tr>
       </table></form>
	   </td>
     <td width="2%" align="left" valign="top">&nbsp;</td>
     <td width="51%" align="left" valign="top">
	  
	   </td>
   </tr>
 </table>
 
 <br /></div>
<div align="left" class="float_clear1"></div>
