<link rel="stylesheet" type="text/css" href="catalog/template/beststoreitems/css/cart.css">
<script type="text/javascript">
function confirm_billing_addr() 
{
	return true;
//return confirm("Please confirm whether the country and state of your billing address are correct? incorrect country and state will result in payment failed, you can click on [change] button to modify it.");
}

function check_payment_setting()
{
	<?php  if($payment_setting['status']==0){?>
		alert("<?php echo $payment_setting["description"]?>");
		return false;
	<?php }elseif ($payment_setting['status']==1){?>
	     <?php if(!empty($payment_setting['description'])){?>
	          alert("<?php echo $payment_setting["description"]?>");
	          return true;
	     <?php }else {?>
	        return true;
	     <?php }?>
	<?php }?>
}
</script>

<script>
    window.onload=function()
	{	   	   
	     var payment_code=document.getElementById('payment_method_code').value; 
//			alert($("#ApplyMoney").val());
//			alert($("#ApplyUSD").val());
		 
	   if (payment_code.search(/amopay/i)>-1) {
		   
			var SubmitTime = $("#SubmitTime").val();

		    var _CompanyID='10017';
			var _NetSourceID='5589';
			var _Key='c70808029e887c78b6c056937291116c';			
			
			var AttachDetails=$("#MerchantOrderID").val()+'-'+$("#ApplyMoney").val()+$("#Currency").val();
			var PostSecure = _CompanyID + $("#MerchantOrderID").val() + $("#ApplyMoney").val() + $("#SubmitTime").val() + encodeURI(AttachDetails) + _NetSourceID + _Key;
			var PostSecureUsd = _CompanyID + $("#MerchantOrderID").val() + $("#ApplyUSD").val() + $("#SubmitTime").val() + encodeURI(AttachDetails) + _NetSourceID + _Key;
			
			$("#Post_AttachDetails").val(AttachDetails);
			$("#Post_PostSecure").val(PostSecure);
			$("#Post_SecureHash").val(calcMD5(PostSecure));	 			
			$("#Post_SecureHashUsd").val(calcMD5(PostSecureUsd));
           		
	   }	 
	}
             
</script>

<div class="main container">
    <div class="row" id="cart">
    	<div class="col-md-24">
        	<div class="page-title clearfix">
                <h1><?php echo $heading_title; ?></h1>
            </div>
            <div id="checkout">    
            
            
              <div class="a">    
            
            
                <table>    
            
            
                  <tr>    
            
            
                    <td><?php if ($shipping_method) { ?>
            
            
            
                      <b><?php echo $text_shipping_method; ?></b><br />
            
            
            
                      <?php echo $shipping_method; ?><br />
            
                      
                      <input type="button" style="padding:0 18px;" onclick='document.location.href="<?php echo $checkout_shipping; ?>"' class="btn_button btn_orange" value="Change"><br />    
            
            
                      <br />    
            
            
                      <?php } ?>    
            
            
                      <b><?php echo $text_payment_method; ?></b><br />
            
            
            
                      <?php echo $payment_method; ?><br /><br />
                      
                      <input type="button" style="padding:0 18px;" onclick='document.location.href="<?php echo $checkout_payment; ?>"' class="btn_button btn_orange" value="Change"></td>
            
            
            
                    <td><div class="a-address"><?php if ($shipping_address) { ?>
            
            
            
                      <b><?php echo $text_shipping_address; ?></b><br />
            
            
            
                      <?php echo $shipping_address; ?><br /><br>
                      
                      <input type="button" style="padding:0 18px;" onclick='document.location.href="<?php echo $checkout_shipping_address; ?>"' class="btn_button btn_orange" value="Change" />
            
                      <?php } ?></div></td>    
            
            
                    <td class="hidden-xs"><div class="a-address"><b><?php echo $text_payment_address; ?></b><br />    
            
            
                      <?php echo $payment_address; ?><br /><br />
                      
                      <input type="button" style="padding:0 18px;" onclick='document.location.href="<?php echo $checkout_payment_address; ?>"' class="btn_button btn_orange" value="Change" />
            
                  </div></tr>    
            
            
                </table>   
            
            
              </div>
            
              <div class="b" style="padding:0; border:none;">   
            
            
                <table class="c" id="shopping-cart-table">   
            
            
                  <tr class="highlight2">
                    <th class="center" colspan="2">Item</th>   
                    <th class="center"><?php echo $text_price; ?></th>    
                    <th class="center"><?php echo $text_quantity; ?></th>  
                    <th class="center"><?php echo $text_total; ?></th>       
                  </tr>    
                   
            
                  <?php foreach ($products as $product) {?>
            
            
            
                  <tr  class="highlight1">
                  
                    <td align="center" colspan="2">
                    
                    <div class="crt-product clearfix">
                        <a class="crt-product_img" href="<?php echo $product['href']; ?>" target="_blank"><img src="<?php echo $product['thumb']; ?>"></a>
                        <div class="crt-product_right">
                            <h2 class="product-name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></h2>
                            <div>
                                <?php foreach ($product['option'] as $option) { ?>
                                  <small style="color:#ff0000;"> - <?php echo $option['name']; ?> <?php echo $option['value']; ?></small><br />
                                  <?php } ?>
                          </div>
                          <div class="visible-xs">Quantity: <?php echo $product['quantity']; ?></div>
                        </div>
                       </div>       
                   </td>
            
                    <td class="center">
                        <div class="crt-product_price"> 
                            <span class="cart-price">
                              <span class="price">
                              		<?php if (!$product['discount']) { ?>
                                      <?php echo $product['price']; ?>
                                      <?php } else { ?>
                                      <span class="price_old"><?php echo $product['price']; ?></span><br />
                                      <span class="price_new"><?php echo $product['discount']; ?></span>
                                      <?php } ?>
                              </span>							
                            </span>
                        </div>
					</td>
                    <td class="center hidden-xs"><?php echo $product['quantity']; ?></td>
                    <td class="center">
                    	<div class="crt-product_price"> 
                            <span class="cart-price">
                              <span class="price"><?php echo $product['total']; ?></span>							
                            </span>
                        </div>
                    </td>
                  </tr>
            
                  <?php } ?>
            
                </table>
            
                <br />
            
                <div class="f clearfix" style="position:relative;">
                  <table style="line-height:150%;float:right;">
                    <?php 
                    $color_index = 0;
            
                    $color_stock = array('#FF6600','#BE1F24','#0000FF','#407AA9');
            
                    foreach ($totals as $total) { ?>
                    <tr>
                      <td class="right" colspan="4" style="padding-right:5px;"><?php echo $total['title']; ?></td>
                      <td class="right"><b><font color="<?php echo $color_stock[$color_index];?>"><?php echo $total['text']; ?></font></b></td>
                    </tr>    
                    <?php $color_index=$color_index+1;} ?>
                    <?php if (strcasecmp($payment_method_code, "aliexpress")==0 && $Currency!='USD') { ?>  
                    <tr>
                        <td class="right" colspan="4" style="padding-right:5px;"><font color="#FF0000">(1 USD=<?php echo round($ApplyMoney/$ApplyUSD,2)?> <?php echo $Currency?>)</font>You need pay:</td>
                        <td class="right"><b><font color="#FF0000">US$<?php echo $ApplyUSD?></font></b></td>
                    </tr>   
                  <?php }?>
                  </table>
            
                  <span style=" position:absolute;top:30px;right:190px;color:#0033FF;"><a target="_blank" href="index.php?controller=knowledge_base&knowledge_id=6">What is our vip policy?</a></span>
            
                </div>
            
              </div>
            
              <?php if ($comment) { ?>
            
              <div class="d"><b><?php echo $text_your_comments; ?></b></div>
            
              <div class="e"><?php echo $comment; ?></div>
            
              <?php } ?>
              <div class="e">
                <form action="index.php?controller=checkout_confirm&apply_coupon=1" method="post" enctype="multipart/form-data">
                 
                    <table width="100%">
                    <tr>
                    <td class="right" width="1"><input type="hidden" name="reference" value="<?php echo $reference; ?>" /></td> 
                     <td class="right"><font style="color:#0000FF; font-size:14px;">(Please input your coupon code in the textbox, then click APPLY CODE button)</font> Coupon: </td>
                      <td class="right" width="1"><input type="text" name="coupon" value="<?php echo $coupon; ?>" /></td>
                      <td class="right" width="1"><input type="image" src="https://www.beststoreitems.com/catalog/template/beststoreitems/image/applycode.gif" style="width:57px; height:20px;" value="<?php echo $button_update; ?>" /></td>
                    </tr>
                  </table>
                </form>
              </div>
            </div>
       <form onsubmit="return check_payment_setting();" name="checkout_form" id="checkout_form" action="<?php echo $payment_url; ?>" method="post" enctype="multipart/form-data">
       <input type="hidden" id="payment_method_code" name="checkout_submit" value="<?php echo $payment_method_code?>" />
       <input type="hidden" id="reference" name="reference" value="<?php echo $reference?>" />         
            <input type="hidden" id="ApplyUSD" name="ApplyUSD" value="<?php echo $ApplyUSD?>" />
            <input type="hidden" id="ApplyMoney" name="ApplyMoney" value="<?php echo $ApplyMoney?>" />  	
            <input type="hidden" id="Currency" name="Currency" value="<?php echo $Currency?>" /> 
       <?php if ((strcasecmp($payment_method_code, "visa")==0)||(strcasecmp($payment_method_code, "master")==0)) { ?>
  			<textarea id="alipay_js_return" name="alipay_js_return" style="display:none;"></textarea>  
       <?php } ?>          
       <?php if (strcasecmp($payment_method_code, "amopay")==0) { ?>     		
            <input type="hidden" id="MerchantOrderID" name="MerchantOrderID" value="<?php echo $MerchantOrderID?>" />            		
            <input type="hidden" id="SubmitTime" name="SubmitTime" value="<?php echo $SubmitTime?>" />                        
            <textarea id="Post_AttachDetails" name="AttachDetails" style="display:none;"></textarea>
            <textarea id="Post_PostSecure" name="PostSecure" style="display:none;"></textarea>            
            <textarea id="Post_SecureHash" name="SecureHash" style="display:none;"></textarea>  	
            <textarea id="Post_SecureHashUsd" name="SecureHashUsd" style="display:none;"></textarea>  
     <?php } ?>
<div class="buttons cart_btn">
	<a class="btn_button btn_gray hidden-xs" onclick="window.history.back(-1)" style="vertical-align:bottom;"><i class="icon-back"></i>Back</a>
        <span><a style="text-decoration:underline;" href="index.php?controller=checkout_confirm&action=paylater&reference=<?php echo $reference?>"><strong>Click here to place an order first, then pay later</strong></a></span>
        <button class="btn_button btn_orange" type="submit"><i class="icon_safety"></i>Proceed to pay</button>
    </div>    
    </form> 
    </div>
</div>
</div>



