<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title> ECMall </title>
  <meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
  <link href="admin/styles/general.css" rel="stylesheet" type="text/css" />
  {script src="ecmall,ajax,validator,ui.utils"}
  <script type="text/javascript" src="admin.php?app=order&act=jslang"></script>
  <script type="text/javascript">
  Event.observe(window, 'load', function(){
   new ui.utils.tabForm("tab-form");
    Validator.run('theForm');
  });
  var goods_amount = Number({$order.goods_amount});
  var coupon_value = Number({$order.coupon_value});
  //var points_value = Number({$order.points_value});
  function recount(){
    var inv_fee = 0;
    var shipping_fee = Number($('shipping_fee').value);
    var discount     = Number($('discount').value);
    var pay_fee      = Number($('pay_fee').value);
    <!--{if $inv_enable}-->
    inv_fee      = Number($('inv_fee').value);
    <!--{/if}-->
    $('shipping_fee_span').innerHTML = price_format(shipping_fee);
    $('discount_span').innerHTML = price_format(discount);
    $('pay_fee_span').innerHTML = price_format(pay_fee);
    <!--{if $inv_enable}-->
    $('inv_fee_span').innerHTML = price_format(inv_fee);
    <!--{/if}-->
    $('order_payable').innerHTML = price_format(goods_amount + shipping_fee + pay_fee + inv_fee - discount - coupon_value);
  }

  function price_format(s){
      s = s.toString();
      if(/[^0-9\.\-]/.test(s))
        return "invalid value";
      s=s.replace(/^(\d*)$/,"$1.");
      s=(s+"00").replace(/(\d*\.\d\d)\d*/,"$1");
      s=s.replace(".",",");
      var re=/(\d)(\d{3},)/;
      while(re.test(s)){
          s=s.replace(re,"$1,$2");
      }
      s=s.replace(/,(\d\d)$/,".$1");
      return lang.coin_flag + s.replace(/^\./,"0.") + lang.coin_name;
  }
  </script>
  <style type="text/css">
    .price-item { margin-right:10px;font-weight:normal;font-size:normal; }
    .price { font-weight:bold; }
  </style>
 </head>
 <body align="center">
  <ul id="container">
   <li id="header">
      <h1>{$lang.edit_charge_info}</h1>
      <div class="link">[<a href="admin.php?app=order&amp;act=view">{$lang.view_order}</a>]&nbsp;&nbsp;[<a href="admin.php?app=order&amp;act=change_status&amp;order_id={$order.order_id}">{$lang.change_status}</a>]</div>
      <div id="desc">{$lang.edit_charge_info_desc}</div>
    </li>
    <li id="wrapper">
      <form name="theForm" method="post">
      <div id="tab-form" class="tab-form">
        <ul class="tab-bar">
          <li>{$lang.order_charge_info}</li>
        </ul>
        <div class="tab-page">
          <table class="form-table">
            <tr>
              <td class="label">{$lang.order_discount}:</td>
              <td><input type="text" name="discount" id="discount" onchange="recount();" dataType="float" value="{$order.discount}" /><span class="note">{$lang.number_only}</span></td>
            </tr>
            {if $inv_enable}
            <tr>
              <td class="label">{$lang.order_inv_fee}:</td>
              <td><input type="text" name="inv_fee" id="inv_fee" onchange="recount();" dataType="float" value="{$order.inv_fee}" /><span class="note">{$lang.number_only}</span></td>
            </tr>
            {/if}
            <tr>
              <td class="label">{$lang.order_shipping_fee}:</td>
              <td><input type="text" name="shipping_fee" id="shipping_fee" onchange="recount();" dataType="float" value="{$order.shipping_fee}" /><span class="note">{$lang.number_only}</span></td>
            </tr>
            <tr>
              <td class="label">{$lang.order_pay_fee}:</td>
              <td><input type="text" name="pay_fee" id="pay_fee" onchange="recount();" dataType="float" value="{$order.pay_fee}" /><span class="note">{$lang.number_only}</span></td>
            </tr>
            <tr>
              <td class="label">{$lang.remark}:</td>
              <td>
                <textarea name="remark" cols="60" rows="5"></textarea>
              </td>
            </tr>
            <tr>
              <td class="label">{$lang.order_charge_info}</td>
              <td>
                  +&nbsp;&nbsp;<span class="price-item">{$lang.goods_amount}:<span id="goods_amount_span" class="price">{$order.goods_amount|price}</span></span>
                  <br />
                  +&nbsp;&nbsp;<span class="price-item">{$lang.order_shipping_fee}:<span id="shipping_fee_span" class="price">{$order.shipping_fee|price}</span></span><br />
                  <!--{if $inv_enable}-->
                  +&nbsp;&nbsp;<span class="price-item">{$lang.order_inv_fee}:<span id="inv_fee_span" class="price">{$order.inv_fee|price}</span></span><br />
                  <!--{/if}-->
                  +&nbsp;&nbsp;<span class="price-item">{$lang.order_pay_fee}:<span id="pay_fee_span" class="price">{$order.pay_fee|price}</span></span><br />
                  -&nbsp;&nbsp;<span class="price-item">{$lang.order_discount}:<span id="discount_span" class="price">{$order.discount|price}</span></span><br />
                  -&nbsp;&nbsp;<span class="price-item">{$lang.coupon_value}:<span class="price">{$order.coupon_value|price}</span></span><br /> =&nbsp;&nbsp;<span class="price-item">{$lang.order_payable}:<span id="order_payable" class="price">{$order.payable|price}</span></span>
              </td>
            </tr>
          </table>
        </div>
        <p class="submitlist">
          <input type="hidden" name="order_id" value="{$order.order_id}" />
          <button type="submit">{$lang.submit_order}</button>
          <button type="reset">{$lang.reset}</button>
        </p>
      </div>
      </form>
    </li>
    {include file="admin/templates/footer.html"}
  </ul>
 </body>
</html>
