<!--{include file="<!--{$oetplpath}-->block_head.tpl"}-->

<div class="oemarry_layout">
  <div class="oe_top_nav"><i></i>我的帐号</div>
  <div class="oe_content">
    <div class="oe_tools_bar clearfix">
	  <a class="icon-home<!--{if $a=='run'}--> cur<!--{/if}-->" href="<!--{$oefile}-->&c=<!--{$c}-->">我的资料</a>
	  <a class="icon-info<!--{if $a=='editinfo'}--> cur<!--{/if}-->" href="<!--{$oefile}-->&c=<!--{$c}-->&a=editinfo">修改资料</a>
	  <a class="icon-key<!--{if $a=='editpass'}--> cur<!--{/if}-->" href="<!--{$oefile}-->&c=<!--{$c}-->&a=editpass">修改密码</a>
	  <a class="icon-switch<!--{if $a=='power'}--> cur<!--{/if}-->" href="<!--{$oefile}-->&c=<!--{$c}-->&a=power">我的权限</a>
	  <a class="icon-globe<!--{if $a=='subordinate'}--> cur<!--{/if}-->" href="<!--{$oefile}-->&c=<!--{$c}-->&a=subordinate">我的下属</a>
    </div>

    <!--{if $a == "run"}-->
	<h6>我的资料</h6>
	<table class="oe_table_wrap">
	  <tr>
	    <th width="15%">登录帐号：</th>
		<td width="35%"><!--{$cplogin.loginname}--></td>
		<th width="15%">角色：</th>
		<td width="35%">
		<!--{if $cplogin.super == '1'}-->
		系统管理员
		<!--{else}-->
		<!--{$cplogin.rolename}-->
		<!--{/if}-->
		</td>
	  </tr>
	  <tr>
	    <th>姓名：</th>
		<td><!--{$cplogin.lastname}--></td>
		<th>座机：</th>
		<td><!--{$cplogin.tel}--></td>
	  </tr>
	  <tr>
	    <th>手机：</th>
		<td><!--{$cplogin.mobile}--></td>
		<th>邮箱：</th>
		<td><!--{$cplogin.email}--></td>
	  </tr>
	  <tr>
	    <th>QQ：</th>
		<td><!--{$cplogin.qq}--></td>
		<th>微信：</th>
		<td><!--{$cplogin.weixin}--></td>
	  </tr>
	  <tr>
	    <th>创建时间：</th>
		<td><!--{$cplogin.addtime|date_format:"%Y-%m-%d %H:%M:%S"}--></td>
		<th>最后登录：</th>
		<td><!--{$cplogin.logintime|date_format:"%Y-%m-%d %H:%M:%S"}--></td>
	  </tr>
	  <tr>
	    <th>登录次数：</th>
		<td><!--{$cplogin.logintimes}--></td>
		<th>登录IP：</th>
		<td><!--{$cplogin.loginip}--></td>
	  </tr>
	</table>
	<!--{/if}-->


    <!--{if $a == "editinfo"}-->
	<h6>修改资料</h6>
	<form id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->" method="post">
	<input type="hidden" name="a" id="a" value="saveinfo" />
	<table class="oe_table_wrap">
	  <tr>
	    <th width="15%">登录帐号：</th>
		<td width="35%"><!--{$cplogin.loginname}--></td>
		<th width="15%">角色：</th>
		<td width="35%">
		<!--{if $cplogin.super == '1'}-->
		系统管理员
		<!--{else}-->
		<!--{$cplogin.rolename}-->
		<!--{/if}-->
		</td>
	  </tr>
	  <tr>
	    <th>姓名：</th>
		<td><input type="text" name="lastname" id="lastname" class="input-150" value="<!--{$cplogin.lastname}-->" /></td>
		<th>座机：</th>
		<td><input type="text" name="tel" id="tel" class="input-150" value="<!--{$cplogin.tel}-->" /></td>
	  </tr>
	  <tr>
	    <th>手机：</th>
		<td><input type="text" name="mobile" id="mobile" class="input-150" value="<!--{$cplogin.mobile}-->" /></td>
		<th>邮箱：</th>
		<td><input type="text" name="email" id="email" class="input-150" value="<!--{$cplogin.email}-->" /></td>
	  </tr>
	  <tr>
	    <th>QQ：</th>
		<td><input type="text" name="qq" id="qq" class="input-150" value="<!--{$cplogin.qq}-->" /></td>
		<th>微信：</th>
		<td><input type="text" name="weixin" id="weixin" class="input-150" value="<!--{$cplogin.weixin}-->" /></td>
	  </tr>
	  <tr>
	    <th>头像/照片：</th>
		<td colspan="3">
		  <div class="oe_img_upload">
		    <label class="_uploadbtn">上传头像<input type="file" name="img" id="img" value="" /></label>
		    <label class="_uploading" id="img_loading">
			  <img src="<!--{$urlpath}-->tpl/admin/images/loading.gif" />上传中...
		    </label>
		    <input type="hidden" id="img_thumb" name="img_thumb" value="" />
		    <input type="hidden" id="img_url" name="headimg" value="<!--{$cplogin.headimg}-->" />
		  </div>
		  <script type="text/javascript">
		  $(function(){
			  $("#img").live("change", function(){
				oemarryUploadImg("img", "<!--{$oefile}-->&c=index&a=uploadimg&module=upload");
			  });
		  });
		  </script>
		</td>
	  </tr>
	  <tr>
	    <th>头像预览：</th>
	    <td>
		<!--{if !empty($cplogin.headimg)}-->
		<img src="<!--{$urlpath}--><!--{$cplogin.headimg}-->" width="60px" height="60px" id="img_preview" />
		<!--{else}-->
		<img src="<!--{$urlpath}-->tpl/static/images/nopic.jpg" width="60px" height="60px" id="img_preview" />
		<!--{/if}-->
		</td>
	  </tr>
	</table>
	</form>

	<div class="oe_button_layout">
	  <input type="button" class="button_2" id="btn_save" value="编辑保存" /> 
	  <span id="submit_tips" class="error"></span>
	</div>

	<script type="text/javascript">
	$(function(){
		$("#btn_save").bind("click", function(){
			if ($("#lastname").val().length == 0) {
				ToastShow("请填写姓名");
				return false;
			}
			$("#myform").submit();
		});
	});
	</script>
	<!--{/if}-->

	<!--{if $a == "editpass"}-->
	<h6>修改密码</h6>
	<table class="oe_table_wrap">
	  <tr>
	    <th width="15%">旧密码：</th>
		<td width="85%">
		<input type="password" name="oldpassword" id="oldpassword" maxlength="16" class="input-150" />
		<font color="gray">（输入旧密码）</font>
		</td>
	  </tr>
	  <tr>
	    <th>新密码：</th>
		<td>
		  <input type="password" name="newpassword" id="newpassword" maxlength="16" class="input-150" />
		  <font color="gray">（密码长度6~16个字符）</font>
		</td>
	  </tr>
	  <tr>
	    <th>确认密码：</th>
		<td>
		  <input type="password" name="confirmpassword" id="confirmpassword" maxlength="16" class="input-150" />
		  <font color="gray">（再次输入新密码）</font>
		</td>
	  </tr>
	  <tr>
	    <td></td>
		<td><input type="button" id="btn_save" class="button_2" value="确定修改" /> </td>
	  </tr>
	</table>
	<script type="text/javascript">
	$(function(){
		$("#btn_save").bind("click", function(){
			$oldpassword = $("#oldpassword").val();
			$newpassword = $("#newpassword").val();
			$confirmpassword = $("#confirmpassword").val();

			if ($oldpassword.length == 0) {
				ToastShow("请输入旧密码");
				return false;
			}
			if ($newpassword.length == 0) {
				ToastShow("请输入新密码");
				return false;
			}
			if ($newpassword.length <6 || $newpassword > 16) {
				ToastShow("密码长度不正确");
				return false;
			}
			if ($confirmpassword != $newpassword) {
				ToastShow("确认密码不正确");
				return false;
			}
			$.ajax({
				type: "POST",
				url: "<!--{$oefile}-->&c=<!--{$c}-->",
				cache: false,
				data: {a:"savepass", oldpassword:$oldpassword, newpassword:$newpassword, confirmpassword:$confirmpassword, r:get_rndnum(8)},
				dataType: "json",
				success: function(data) {
					$json = eval(data);
					$response = $json.response;
					$result = $json.result;
					if ($response == '1') {
						ToastShow("修改成功，请记住新密码。");
						setTimeout(function(){
							window.location.reload()
						}, 800);
					}
					else {
						if ($result.length > 0) {
							ToastShow($result);
						}
						else {
							ToastShow("修改失败");
						}
					}
				},
				error: function() {
					ToastShow("提交失败，请检查网络...");
				}
			});
		});
	});
	</script>
	<!--{/if}-->


	<!--{if $a == "power"}-->
	<h6>我的权限</h6>
	<table class='oe_table_trap'>
	  <tr>
	    <td>
		  <table cellpadding='1' cellspacing='1' class='oe_table_trap table-border'>
			<tr>
			  <td class='hback_1' align="center" width='20%'>模块</td>
			  <td class='hback_1' align="center" width='10%'>查看</td>
			  <td class='hback_1' align="center" width='10%'>添加</td>
			  <td class='hback_1' align="center" width='10%'>修改</td>
			  <td class='hback_1' align="center" width="10%">删除</td>
			  <td class='hback_1' align="center" width="10%">审批</td>
			  <td class='hback_1' align="center">其他操作</td>
			</tr>
			<!--{$myroles}-->
		  </table>
		</td>
	  </tr>
    </table>
	<!--{/if}-->


	<!--{if $a == "subordinate"}-->
	<h6>我的下属</h6>
	<table class='oe_table_trap'>
	  <!--{if empty($roles)}-->
	  <tr>
	    <td class="text_center">No data!</td>
	  </tr>
	  <!--{else}-->
	  <!--{foreach $roles as $volist}-->
	  <tr>
	    <td>
			<!--{$volist.tree_node}--> <font color="blue">（
			<!--{if $login.roleid == $volist.roleid}-->
			  <!--{$login.lastname}-->
			<!--{else}-->
			  <!--{hook mod='admin' item='lastname' type='multi' value=$volist.roleid}-->
			<!--{/if}-->
			）</font>
		</td>
	  </tr>
	  <!--{/foreach}-->
	  <!--{/if}-->
    </table>
	<!--{/if}-->
  
  </div>
</div>
</body>
</html>