<?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>
<?php echo $javascript->link('dropdownmenuhack.js'); ?>
<style type="text/css">

.selectbox
{
behavior:expression(window.dropdown_menu_hack!=null?window.dropdown_menu_hack(this):0);
}
</style>

<div align="center">
	<h2 class="title text-center mainhd">Product Refund Request</h2>
</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 -->
 <form name="frmreturn" id="frmreturn" action="" method="POST">
 
 <div class="table-responsive">
 <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="items_display_area_admin_table" class="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" class="btm-line">
         <td width="8%">&nbsp;</td>
		<td width="15%">Product Name</td>
        <td width="9%" align="center">SKU No.</td>
        <td width="18%" align="center">Combination</td>
        <td width="10%" align="center">Quantity</td>
        <td width="10%" align="center">Unit Price </td>
        <td width="11%" align="center">Additional Cost</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='';
  $dis_amnt=0;
  $odtp	=	"Non-digital"; 
  
  if(count($odr["OrderDetail"])>0)
  {
  $i = 0;
  foreach($odr["OrderDetail"] 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">
	  	<td  align="center"><input type="checkbox" name="chbx[<?php echo $i;?>]" class="chk" value="<?php echo $det["id"]; ?>"></td>
        <td align="center"><?php echo $det["Product"]; ?>
		<input type="hidden" name="orderdetid[<?php echo $i;?>]" value="<?php echo $det["id"]; ?>">
		<input type="hidden" name="productid[<?php echo $i;?>]" value="<?php echo $det["product_id"]; ?>">
		<input type="hidden" name="combid[<?php echo $i;?>]" value="<?php echo $det["combination_id"]; ?>">
		<input type="hidden" name="orderid[<?php echo $i;?>]" value="<?php echo $odr["Order"]["id"]; ?>">
		<input type="hidden" name="userid[<?php echo $i;?>]" value="<?php echo $odr["Order"]["user_id"]; ?>">
		</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">
		<select name="quantity[<?php echo $i;?>]" class="box2_admin" style="width:50px;">
		<?php for($op=1;$op <= $det["quantity"];$op++){?>
		<option value="<?php echo $op; ?>"><?php echo $op; ?></option>
		<?php } ?>
		</select>
		</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($det["discount_type"]=='per' && $det["discount"] > 0)
		$dis_amnt=($det["product_price"]*$det["discount"])/100;
		else if($det["discount_type"]=='amnt' && $det["discount"] > 0)
		$dis_amnt=$det["discount"];		
		echo $curlogo.number_format($dis_amnt,2,'.','');
		?>
		</td>
        <td align="center">
		<?php		
		  $combined_price=$det['product_price']+$det['extra_price'];  
		  if($det["discount_type"]=='per')
			 {		
				  if($det['discount'] > 0 && $det['discount'] <> '')
					{
						$discounted_price=($combined_price-(($combined_price * $det['discount'])/100));
						$price=($discounted_price)*($det['quantity']);							
						$amt+= $price;	
					}
					else
					$amt+=($combined_price)*($det['quantity']);		
			 }
			 else if($det["discount_type"]=='amnt')
			 {
			   	 if($det['discount'] > 0 && $det['discount'] <> '')
					{
						$discounted_price=($combined_price-$det['discount']);
						$price=($discounted_price)*($det['quantity']);	
						$amt+= $price;	
					}
					else
					$amt+=($combined_price)*($det['quantity']);					 
			 }		
			else
			{
				$price = ($combined_price)*($det['quantity']);
				$amt+= $price;	
			}      
		   echo $curlogo.number_format($price,2,'.','');		  
		  ?>
	</td>       
        <td align="center">
		<select name="returnreason[<?php echo $i;?>]" class="box2_admin" style="width:100px;" 
onfocus="window.dropdown_menu_hack(this)">
		<?php foreach($reason as $res){?>
		<option value="<?php echo $res; ?>"><?php echo $res; ?></option>
		<?php } ?>
		</select>
		</td>       
       
      </tr>
    
       <?php $i++; } } else { ?>	 
	    <tr align="left" valign="middle" id="list_admin">
        <td colspan="9" align="center">No Details Found.</td>     
        </tr>
	   <?php } ?>
        <input type="hidden" name="checked_arry" id="checked_arry" value="" />
    </table>
      <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="admin_bottom">
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table></td>
  </tr>
</table>
</div>
	
	
<div class="table-responsive">   
       <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="items_display_area_admin_table" class="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>Comments</td>
                   <td>	
				   <textarea name="customer_feedback" id="note" class="txt-style"></textarea></td>
                 </tr>
               </table>
               <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="admin_bottom">
                 <tr>
				 	<td style="width:82px ">&nbsp;</td>
                   <td align="left"><input type="submit" class="btn-usr01" value="Save" /></td>
                 </tr>
             </table></td>
         </tr>
       </table>
	   
	   </td>
     <td width="2%" align="left" valign="top">&nbsp;</td>
     <td width="51%" align="left" valign="top">
	  
	   </td>
   </tr>
 </table>
 </div>
     </form>

</div>

<div align="left" class="float_clear1"></div>
<script type="text/javascript">
var someGlobalArray = new Array;

$(".chk").click(function() {
    someGlobalArray=[];
    $('.chk:checked').each(function() {
        someGlobalArray.push($(this).val());
    });
    $("#checked_arry").val(someGlobalArray);
});

</script>