<!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 type="text/javascript" src="?act=jslang"></script>
  {script src="ajax,ecmall,ui.utils,validator,ui.calendar"}
  <script type="text/javascript">
  Event.observe(window, "load", function() {
   new ui.utils.tabForm("tab-form");
   Validator.run('theForm');
  });

  function duplicateName (obj, id) {
    Ajax.addVal('app', 'coupon');
    Ajax.addVal('act', 'duplicate_name');
    Ajax.addVal('coupon_id', id);
    Ajax.addVal('coupon_name', obj.value);
    var res = Ajax.call('admin.php', null, '', false);

    if (res.done)
      return true;
    else
      return res.msg;
  }
  </script>
 </head>
 <body align="center">
  <ul id="container">
    <li id="header">
      <h1>{$lang.coupon_add}</h1>
      <div class="link">[<a href="admin.php?app=coupon&amp;act=view">{$lang.coupon_view}</a>]</div>
      <div id="desc">{$lang.coupon_desc}</div>
    </li>
    <li>
      <form name="theForm" method="post">
      <div id="tab-form" class="tab-form">
        <ul class="tab-bar">
          <li>{$lang.general}</li>
        </ul>
        <div class="tab-page">
          <table class="form-table">
            <tr>
              <td class="label">{$lang.coupon_name}:</td><td><input type="text" name="coupon_name" value="{$coupon.coupon_name|escape}" maxlength="40" size="40" fun="duplicateName" funParam="{$coupon.coupon_id}"  /></td>
            </tr>
            <tr>
              <td class="label">{$lang.coupon_value}:</td><td><input type="text" name="coupon_value" size="20" dataType="int" required="true" value="{$coupon.coupon_value}"/></td>
            </tr>
            <tr>
              <td class="label">{$lang.max_times}:</td>
              <td>
                <input type="text" name="max_times" size="10" dataType="int" required="true" value="{$coupon.max_times}" />
                <span class="note">{$lang.max_times_notice}</span>
              </td>
            </tr>
            <tr>
              <td class="label">{$lang.start_time}:</td><td><input type="text" name="start_time" size="20" dataType="date" required="true" value="{$coupon.start_time}" /></td>
            </tr>
            <tr>
              <td class="label">{$lang.end_time}:</td><td><input type="text" name="end_time" size="20" dataType="date" value="{$coupon.end_time}" /><span class="note">{$lang.end_time_notice}</span></td>
            </tr>
            <tr>
              <td class="label">{$lang.min_amount}:</td>
              <td><input type="text" name="min_amount" size="10" value="{$coupon.min_amount}" dataType="int" required="true" /><span class="note">{$lang.min_amount_notice}</span>
              </td>
            </tr>
          </table>
        </div>
        <p class="submitlist">
          <input type="submit" value="{$lang.submit}" />
          <input type="reset" value="{$lang.reset}" />
          <input type="hidden" name="id" value="{$coupon.coupon_id}" />
        </p>
      </div>
      </form>
    </li>
    {include file="admin/templates/footer.html"}
  </ul>
 </body>
</html>
