<?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();
	}
        function submitpayment(){
		document.py.submit();
	}
</script>
<div align="center" class="subheading">
 <div align="left">ORDER DETAILS</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">Order Details </td>
      </tr>
    </table>
    <table width="100%"  border="0" cellspacing="1" cellpadding="6">
      <tr align="left" valign="middle" id="list_admin_top">
        <td width="48%">Order Status </td>
        <td width="15%">Order Date</td>
        <td width="24%">User Name</td>
        <td width="13%" align="center">Currency</td>
        </tr>
      <tr align="left" valign="middle" id="list_admin">
        <td><form name="sts" id="sts" action="<?php echo '../change_status/'.$odr["Order"]["id"];?>" method="POST">
			<select name="order_status" id="order_status" onChange="submi();">
			<?php
			foreach($osts as $field => $val){
			?>
			<option value="<?php echo $field; ?>" <?php if($field == $odr["Order"]["order_status_id"]){ echo "selected"; }?> > <?php echo $val; ?></option>
			<?php }
			?>
			</select>
			</form></td>
        <td><?php
			$dt	= strtotime($odr["Order"]['date']);
			$edt = strtotime($odr["Order"]['exp_time']);
			echo date("m-d-Y",$dt );
			 ?></td>
        <td><?php echo $odr["User"]["uname"]; ?></td>
        <td align="center"><?php echo $odr["Order"]["currency_type"]; ?></td>
        </tr>
    </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">Items Details </td>
      </tr>
    </table>
    <table width="100%"  border="0" cellspacing="1" cellpadding="6">
      <tr align="left" valign="middle" id="list_admin_top">
        <td width="13%">Product Name</td>
        <td width="8%" align="center">SKU No. </td>
        <td width="14%" align="center">Combination</td>
        <td width="8%" align="center">Quantity</td>
        <td width="8%" align="center">Unit </td>
        <td width="9%" align="center">Additional Cost </td>
		 <td width="11%" align="center">Discount</td>
         <td width="9%" align="center">Price </td>   
		  <?php  if($ptype_flag == 'Digital') { ?>    
        <td width="8%">Download </td>      
        <td width="12%">Expiry Time</td>
		<?php } ?>
      </tr>

 <?php 
  $amt=0;
  $dis_str='';  
  $odtp	=	"Non-digital";  
  if(count($odr["OrderDetail"])>0)
  {       
  foreach($odr["OrderDetail"] as $det){  
 
    $price=0;
	$dis_amnt=0;
		
  	if($det["prodtype"] == "Digital"){
	 	$odtp	=	"Digital";
	?>	
      <tr align="left" valign="middle" id="list_admin">
        <td align="center"><?php echo $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($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"];		
		$dis_amnt=($dis_amnt)*($det["quantity"]);			
		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']);	
					  $price+=($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']);	
					  $price+=($combined_price)*($det['quantity']);	
					} 				 
			 }		
			else
			{
				$price = ($combined_price)*($det['quantity']);
				$amt+= $price;	
			}      
		   echo $curlogo.number_format($price,2,'.','');		  
		  ?>
	</td>       
         <?php if(trim($det["prodtype"]) == "Digital" && trim($det["type"]) <> 'G'){ $odtp	=	"Digital";?>
        <td align="center">		
		<a href='<?php echo FULL_BASE_URL. $cnfg["sitebasefolder"]."/Orders/pdctdownload/".$det["order_id"]."/".$det['product_id']."/" ;?> '>Download Now</a>		
		</td>       
        <td align="center"><?php echo date('m-d-Y H:i:s',$edt ); ?></td>
		<?php } else{?>
		 <td align="center">N/A</td>
		 <td align="center">N/A</td>
		<?php } ?>
      </tr>
        <?php }else{ ?>
		
      <tr align="left" valign="middle" id="list_admin">
	     
        <td><?php echo $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($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"];		
		$dis_amnt=($dis_amnt)*($det["quantity"]);			
		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']);	
					  $price+=($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']);	
					  $price+=($combined_price)*($det['quantity']);	
					} 	 
			 }		
			else
			{
				$price = ($combined_price)*($det['quantity']);
				$amt+= $price;	
			}      
		   echo $curlogo.number_format($price,2,'.','');		  
		  ?>
		</td>     
		 <?php  if($ptype_flag == 'Digital') { ?>         
		<td align="center">N/A</td>     
        <td align="center">N/A</td>
		<?php } ?>
      </tr>
       <?php } } } else { ?>	 
	    <tr align="left" valign="middle" id="list_admin">
        <td colspan="10" 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">
   <tr>
     <td width="47%" align="left" valign="top"><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">Transaction Details </td>
             </tr>
           </table>
		   <table width="100%"  border="0" cellspacing="1" cellpadding="6">
               <?php if($odtp <> "Digital"){ ?>
			   
			     <tr align="left" valign="middle" id="list_admin">
                 <td>Shipping Method </td>
                 <td><?php echo $odr["Order"]["shipping_method"]; ?></td>
               </tr>
               <tr align="left" valign="middle" id="list_admin_top">
                 <td>Shipping Service</td>
                 <td><?php echo $odr["Order"]["shipping_service"]; ?></td>
               </tr>
			    <?php } ?>
               <tr align="left" valign="middle" id="list_admin">
                 <td>Payment Method </td>
                 <td><?php echo $odr["Order"]["payment_method"]; ?></td>
               </tr>
               <?php if(isset($odr["Order"]["transaction_id"]) && $odr["Order"]["transaction_id"] <> 0 && $odr["Order"]["transaction_id"] <>'') { ?>
               <tr align="left" valign="middle" id="list_admin">
                 <td>Transaction Id</td>
                 <td><?php  echo $odr["Order"]["transaction_id"]; ?></td>
               </tr>
			   <?php } ?>
			    <?php if(isset($odr["Coupon"]["id"]) && $odr["Coupon"]["id"] <> 0 && isset($odr["Coupon"]["code"]) && $odr["Coupon"]["code"] <> ''){ ?>
               <tr align="left" valign="middle" id="list_admin">
                 <td>Promo Code </td>
                 <td><?php echo $odr["Coupon"]["code"]; ?></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 />
	    <?php if($odtp <> "Digital" && $odr["Order"]["ship_fname"] <> ''){ ?>
       <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">Shipping Address</td>
             </tr>
           </table>
             <table width="100%"  border="0" cellspacing="1" cellpadding="6">
               <tr align="left" valign="middle" id="list_admin">
                 <td>
				 <?php echo $odr["Order"]["ship_fname"]."&nbsp;&nbsp; ".$odr["Order"]["ship_lname"]; ?><br />
				 <?php echo $odr["Order"]["ship_address"]; ?><br />
				 <?php echo $odr["Order"]["ship_city"]."&nbsp;&nbsp;".$odr["Order"]["ship_state"]."&nbsp;&nbsp;".$odr["Order"]["ship_zip"]; ?><br />
				 <?php echo $odr["Order"]["ship_country"]; ?><br />
				 <strong>Phone &nbsp; : </strong>&nbsp;<?php echo $odr["Order"]["ship_phone"]; ?><br />
				 <strong>Mobile &nbsp; : &nbsp;</strong><?php echo $odr["Order"]["ship_mobile"]; ?><br />
				 <strong>Fax &nbsp; : &nbsp;</strong><?php echo $odr["Order"]["ship_fax"]; ?><br />
				 </td>
                </tr>               
             </table>
             <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="admin_bottom">
               <tr>
                 <td>&nbsp;</td>
               </tr>
           </table></td>
       </tr>
     </table>
	 <?php }else{ ?>
       <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">Reset Download Expiry Date</td>
               </tr>
             </table>
               <table width="100%"  border="0" cellspacing="1" cellpadding="6">
                 <tr align="left" valign="middle" id="list_admin">
                   <td colspan="2"><a href='<?php echo FULL_BASE_URL. $cnfg["sitebasefolder"]."/Orders/reset_exp_date/".$odr["Order"]["id"]."/";?> '>Reset Now</a></td>
                 </tr>
               </table>
               <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="admin_bottom">
                 <tr>
                   <td>&nbsp;</td>
                 </tr>
             </table></td>
         </tr>
       </table>
       <br />
	   <?php } ?>
	    <form name="not" id="not" action="<?php echo '../addnote/'.$odr["Order"]["id"];?>" method="POST">
       <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">Remarks</td>
               </tr>
             </table>
			
               <table width="100%"  border="0" cellspacing="1" cellpadding="6">
                 <tr align="left" valign="middle" id="list_admin">
                   <td width="31%">Order note </td>
                   <td width="69%">	
				   <textarea name="note" id="note" class="box2_admin"><?php echo $odr["Order"]["note"]; ?></textarea></td>
                 </tr>
               </table>
               <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="admin_bottom">
                 <tr>
                   <td align="left">&nbsp;&nbsp;&nbsp;<input name="Submit" 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"><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">Price Details</td>
             </tr>
           </table>
             <table width="100%"  border="0" cellspacing="1" cellpadding="6">
               <tr align="left" valign="middle" id="list_admin">
                 <td width="44%">Total Price</td>
                 <td width="56%"><?php echo $curlogo;?><?php echo number_format($amt,2,'.',''); ?></td>
               </tr>
			    <?php if($odtp <> "Digital" && $odr["Order"]["shipping_price"] <> ''){ ?>
               <tr align="left" valign="middle" id="list_admin">
                 <td>Shipping Price</td>
                 <td><?php echo $curlogo;?><?php echo $odr["Order"]["shipping_price"]; ?></td>
               </tr>
			   <?php } ?>
               <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 Price : </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 
				 if($odr["Order"]["discount"] > $amt)				
				 echo number_format($amt,2,'.','');
				 else
				 echo number_format($odr["Order"]["discount"],2,'.',''); ?></td>
               </tr>            
             </table>
             <table width="100%"  border="0" cellspacing="0" cellpadding="3" id="admin_bottom">
               <tr>
                 <td width="44%">Grand Total</td>
                 <td width="55%" class="toplinks"><?php echo $curlogo;?><?php echo $odr["Order"]["total_price"]; ?></td>
               </tr>
           </table></td>
       </tr>
     </table>
       <br />
	   
	    <?php if($odr["Order"]["bill_fname"] <> ''){ ?>
       <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">Billing Address</td>
               </tr>
             </table>
               <table width="100%"  border="0" cellspacing="1" cellpadding="6">
                 <tr align="left" valign="middle" id="list_admin">
                   <td>
		   <?php echo $odr["Order"]["bill_fname"]."&nbsp;&nbsp;".$odr["Order"]["bill_lname"]; ?><br />
            <?php echo $odr["Order"]["bill_address"]; ?><br />
            <?php echo $odr["Order"]["bill_city"]."&nbsp;&nbsp;".$odr["Order"]["bill_state"]."&nbsp;&nbsp;".$odr["Order"]["bill_zip"]; ?><br />
           <?php echo $odr["Order"]["bill_country"]; ?><br />
            <strong>Phone :</strong> <?php echo $odr["Order"]["bill_phone"]; ?><br />
           <strong> Mobile :</strong> <?php echo $odr["Order"]["bill_mobile"]; ?><br />
            <strong>Fax :</strong> <?php echo $odr["Order"]["bill_fax"]; ?></td>
                 </tr>
               </table>
               <table width="100%"  border="0" cellspacing="0" cellpadding="3" id="admin_bottom">
                 <tr>
                   <td>&nbsp;</td>
                 </tr>
             </table></td>
         </tr>
       </table>
	   <?php } ?>
	   <br />
	   <form name="not" id="not" action="<?php echo '../addcomment/'.$odr["Order"]["id"];?>" method="POST">
       <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">Comments For Customer</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="comment" id="comment" class="box2_admin"><?php echo $odr["Order"]["comments"]; ?></textarea></td>
                 </tr>
               </table>
               <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="admin_bottom">
                 <tr>
                   <td align="left">&nbsp;&nbsp;&nbsp;<input name="Submit" type="submit" class="buttn_admin" value="Save" /></td>
                 </tr>
             </table></td>
         </tr>
       </table>
	   </form>
	   
	   </td>
   </tr>
 </table>
 <table width="100%"  border="0" cellspacing="0" cellpadding="0">
   <tr>
     <td align="left" style="padding-left:10px;"><input name="button" type="button" class="buttn_admin" onClick="javascript:history.go(-1);" value="Back" /></td>
   </tr>
 </table>
 <br /></div>
<div align="left" class="float_clear1"></div>