<!-- $Id: bonus_by_user.htm 6988 2007-03-13 09:42:08Z liry $ -->
{include file="pageheader.htm"}
{insert_scripts files="../js/utils.js"}

<div class="main-div">
<form action="bonus.php" method="post" name="theForm2" onsubmit="return validate2()">
  <table width="100%">
  <tr>
    <td class="label">{$lang.senduserrank}:</td>
    <td>
      <select name="rank_id">
      <option value="0">{$lang.select_rank}</option>
      {html_options options=$ranklist selected=$smarty.get.rank_id}
      </select>&nbsp;&nbsp;&nbsp;
      <input type="submit" name="send_rank" value="{$lang.confirm_send_bonus}" class="button" />
    </td>
  </tr>
</table>
<input type="hidden" name="act" value="send_by_user" />
<input type="hidden" name="id" value="{$id}" />
</form>
</div>

<div class="main-div">
<form name="theForm" action="bonus.php" method="post" onsubmit="return validate();">
<table>
  <tr>
    <td class="label">
    <img src="images/icon_search.gif" border="0" alt="SEARCH" />{$lang.keywords}
    </td>
    <td>
      <input type="text" name="keyword" size="30" />
      <input type="button" name="search" value="{$lang.button_search}" onclick="searchUser();" />
    </td>
  </tr>
  <tr>
    <td class="label">{$lang.userlist}</td>
    <td>
      <select name="user[]" size="15" multiple="true" style="width:260px"></select>
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
      <input type="hidden" name="id" value="{$id}" />
      <input type="hidden" name="act" value="send_by_user" />
      <input type="submit" name="send_user" value="{$lang.confirm_send_bonus}" class="button" />
    </td>
  </tr>
</table>
</form>
</div>

{literal}
<script language="JavaScript">
<!--
document.forms['theForm'].elements['keyword'].focus();
onload = function()
{
    // 开始检查订单
    startCheckOrder();
}
/**
* 按用户名搜索用户
*/
function searchUser()
{
  var eles = document.forms['theForm'].elements;

  /* 填充列表 */
  var keywords = Utils.trim(eles['keyword'].value);
  if (keywords != '')
  {
    Ajax.call('bonus.php?is_ajax=1&act=search_users', 'keywords=' + keywords, searchUserResponse, "GET", "JSON");
  }
}

function searchUserResponse(result)
{
  var eles = document.forms['theForm'].elements;
  eles['user[]'].length = 0;

  if (result.error == 0)
  {
    for (i = 0; i < result.content.length; i++)
    {
      var opt = document.createElement('OPTION');
      opt.value = result.content[i].user_id;
      opt.text  = result.content[i].user_name;
      eles['user[]'].options.add(opt);
    }
  }
}

function validate2()
{
    var user_rank = document['theForm2'].elements['rank_id'].value;

    if (user_rank == 0)
    {
        alert(user_rank_empty);
        return false;
    }
    return true;
}

function validate()
{
    var eles = document.forms['theForm'].elements;

    if (eles['user[]'].options.length == 0)
    {
        alert(user_name_empty);
        return false;
    }
}
//-->
</script>
{/literal}
{include file="pagefooter.htm"}