<!-- $Id: user_info.htm 16854 2009-12-07 06:20:09Z sxc_shop $ -->
<?php echo $this->fetch('pageheader.htm'); ?>
<!-- Magnific Popup core CSS file -->
<link rel="stylesheet" href="styles/jquery-ui.min.css">
<script src="js/jquery-ui.min.js"></script>
<script src="js/clipboard.min.js"></script>
 <script>
	function openwindow(url,name,iWidth,iHeight)
	{
	  var url;     //網頁位置;
	  var name;    //網頁名稱;
	  var iWidth;  //視窗的寬度;
	  var iHeight; //視窗的高度;
	  var iTop = (window.screen.availHeight-30-iHeight)/2;  //視窗的垂直位置;
	  var iLeft = (window.screen.availWidth-10-iWidth)/2;   //視窗的水平位置;
	  window.open(url,name,'height='+iHeight+',innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft);
	}
  </script>
<div class="main-div">
<form method="post" action="users.php" name="theForm" onsubmit="return validate()" enctype="multipart/form-data">
<table width="100%" >
  <tr>
    <td class="label"><?php echo $this->_var['lang']['username']; ?>:</td>
    <td><?php if ($this->_var['form_action'] == "update"): ?><?php echo $this->_var['user']['user_name']; ?><input type="hidden" name="username" value="<?php echo $this->_var['user']['user_name']; ?>" /><?php else: ?><input type="text" name="username" maxlength="60" value="<?php echo $this->_var['user']['user_name']; ?>" /><?php echo $this->_var['lang']['require_field']; ?><?php endif; ?></td>
  </tr>
  <?php if ($this->_var['form_action'] == "insert"): ?>
  <tr>
    <td class="label"><?php echo $this->_var['lang']['password']; ?>:</td>
    <td><input type="password" name="password" maxlength="20" size="20" /><?php echo $this->_var['lang']['require_field']; ?></td>
  </tr>
  <tr>
    <td class="label"><?php echo $this->_var['lang']['confirm_password']; ?>:</td>
    <td><input type="password" name="confirm_password" maxlength="20" size="20" /><?php echo $this->_var['lang']['require_field']; ?></td>
  </tr>
  <?php elseif ($this->_var['form_action'] == "update"): ?>
  <tr>
    <td class="label"><?php echo $this->_var['lang']['newpass']; ?>:</td>
    <td><input type="password" name="password" maxlength="20" size="20" /></td>
  </tr>
  <tr>
    <td class="label"><?php echo $this->_var['lang']['confirm_password']; ?>:</td>
    <td><input type="password" name="confirm_password" maxlength="20" size="20" /></td>
  </tr>
  <?php endif; ?>
  <tr>
    <td class="label">名稱:</td>
    <td><input type="text" id="name" name="name" maxlength="60" size="40" value="<?php echo $this->_var['user']['name']; ?>" /><?php echo $this->_var['lang']['require_field']; ?></td>
  </tr>
  <tr>
    <td class="label">電話:</td>
    <td><input type="text" id="tel" name="tel" size="40" value="<?php echo $this->_var['user']['tel']; ?>" /></td>
  </tr>
  <tr>
    <td class="label">Email:</td>
    <td><input type="text" id="email" name="email" size="40" value="<?php echo $this->_var['user']['email']; ?>" /></td>
  </tr>
  <tr>
    <td class="label">地址:</td>
    <td><input type="text" id="address" name="address"  size="40" value="<?php echo $this->_var['user']['address']; ?>" /></td>
  </tr>
  <?php if ($this->_var['form_action'] == "update"): ?>
  <tr>
  	<td class="label">狀態:</td>
    <td>
    	<select name="status">
        	<option value="0" <?php if ($this->_var['user']['status'] == 0): ?> selected="selected"<?php endif; ?>>上架</option>
            <option value="1" <?php if ($this->_var['user']['status'] == 1): ?> selected="selected"<?php endif; ?>>下架</option>
     	</select>
    </td>
  </tr>
  <tr>
  	<td class="label"><?php echo $this->_var['lang']['note']; ?>:</td>
    <td>
    	<textarea name="note" cols="50" rows="5"><?php echo $this->_var['user']['note']; ?></textarea>
    </td>
  </tr>
  <?php endif; ?>
  <?php if ($this->_var['user']['parent_id']): ?>
  <tr>
    <td class="label"><?php echo $this->_var['lang']['parent_user']; ?>:</td>
    <td><a href="users.php?act=edit&id=<?php echo $this->_var['user']['parent_id']; ?>"><?php echo $this->_var['user']['parent_id']; ?></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="users.php?act=remove_parent&id=<?php echo $this->_var['user']['user_id']; ?>"><?php echo $this->_var['lang']['parent_remove']; ?></a></td>
  </tr>
  <?php endif; ?>
  <?php if ($this->_var['affiliate']['on'] == 1 && $this->_var['affdb']): ?>
  <tr>
    <td class="label"><?php echo $this->_var['lang']['affiliate_user']; ?>:</td>
    <td>[<a href="users.php?act=aff_list&auid=<?php echo $this->_var['user']['user_id']; ?>"><?php echo $this->_var['lang']['show_affiliate_users']; ?></a>][<a href="affiliate_ck.php?act=list&auid=<?php echo $this->_var['user']['user_id']; ?>"><?php echo $this->_var['lang']['show_affiliate_orders']; ?></a>]</td>
  </tr>
  <tr>
    <td></td>
    <td>   
    <table border="0" cellspacing="1" style="background: #dddddd; width:30%;">
    <tr>
    <td bgcolor="#ffffff"><?php echo $this->_var['lang']['affiliate_lever']; ?></td>
    <?php $_from = $this->_var['affdb']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('level', 'val0');if (count($_from)):
    foreach ($_from AS $this->_var['level'] => $this->_var['val0']):
?>
    <td bgcolor="#ffffff"><?php echo $this->_var['level']; ?></td>
    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
    </tr>
    <tr>
    <td bgcolor="#ffffff"><?php echo $this->_var['lang']['affiliate_num']; ?></td>
    <?php $_from = $this->_var['affdb']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'val');if (count($_from)):
    foreach ($_from AS $this->_var['val']):
?>
    <td bgcolor="#ffffff"><?php echo $this->_var['val']['num']; ?></td>
    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
    </tr>
    </table>
    </td>
  </tr>
  <?php endif; ?>
  <tr>
    <td colspan="2" align="center">
      <input type="submit" value="<?php echo $this->_var['lang']['button_submit']; ?>" class="button" />
      <input type="reset" value="<?php echo $this->_var['lang']['button_reset']; ?>" class="button" />
      <input type="hidden" name="oldstatus" value="<?php echo $this->_var['user']['status']; ?>" />
      <input type="hidden" name="act" value="<?php echo $this->_var['form_action']; ?>" />
      <input type="hidden" name="id" value="<?php echo $this->_var['user']['user_id']; ?>" />    </td>
  </tr>
</table>
</form>
</div>
<?php echo $this->smarty_insert_scripts(array('files'=>'../js/utils.js,validator.js')); ?>

<script language="JavaScript">
<!--

if (document.forms['theForm'].elements['act'].value == "insert")
{
  document.forms['theForm'].elements['username'].focus();
}
else
{
  document.forms['theForm'].elements['email'].focus();
}

//onload = function()
/{
    // 开始检查订单
//    startCheckOrder();
//}

/**
 * 检查表单输入的数据
 */
function validate()
{
    validator = new Validator("theForm");
    validator.isMobile("mobile_phone", invalid_mobile_phone, true);

    if (document.forms['theForm'].elements['act'].value == "insert")
    {
        validator.required("username",  no_username);
        validator.required("password", no_password);
        validator.required("confirm_password", no_confirm_password);
//        validator.required("mobile_phone", no_mobile_phone);
				validator.eqaul("password", "confirm_password", password_not_same);

        var password_value = document.forms['theForm'].elements['password'].value;
        if (password_value.length < 6)
        {
          validator.addErrorMsg(less_password);
        }
        if (/ /.test(password_value) == true)
        {
          validator.addErrorMsg(passwd_balnk);
        }
    }
    else if (document.forms['theForm'].elements['act'].value == "update")
    {
        var newpass = document.forms['theForm'].elements['password'];
        var confirm_password = document.forms['theForm'].elements['confirm_password'];
        if(newpass.value.length > 0 || confirm_password.value.length)
        {
          if(newpass.value.length >= 6 || confirm_password.value.length >= 6)
          {
            validator.eqaul("password", "confirm_password", password_not_same);
          }
          else
          {
            validator.addErrorMsg(password_len_err);
          }
        }
    }

    return validator.passed();
}

//-->
</script>

<?php echo $this->fetch('pagefooter.htm'); ?>
