{include file="header.tpl" page_name=$page_name sys_name=$sys_name}
<div align="center">
{$admin_nav}
{if $do==''}
{literal}
<script type="text/javascript" src="http://wms.com/js/jquery.form.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		var attr = $("#is_use_smtp").attr("checked");
		if(attr){
			$('.smtp').show();	
		}else{
			$('.smtp').hide();	
		}
		$("#test_send_mail_click").click(function(){
			$("#show_test_mail").show();
		})
	})
	function hideSmtp(obj){
		$(obj).find('input').attr({"checked":"checked"});
		$(".smtp").hide().addClass('smtp_append');	
	}
	function showSmtp(obj){
		$(obj).find('input').attr({"checked":"checked"});
		$(".smtp").show();		
	}
	function test_send_email(){
		var v = $("#test_mail_val").val();
		if($.trim(v)==''){
			$("#test_mail_val").css({"border":"2px solid #F00"});
			return false;
		}
		$("#test_hiden_val").val('test');
		$("#show_send_msg").show().html('loading...');
		var options = {
				mail_send_type:$("input:checked").val(),
				sender:$("input[name='sender']").val(),
				smtp_host:$("input[name='smtp_host']").val(),
				smtp_port:$("input[name='smtp_port']").val(),
				smtp_pass:$("input[name='smtp_pass']").val(),
				smtp_user:$("input[name='smtp_user']").val(),
				test_email:v,
				test:'test'
			}
		$.ajax({type:'POST',url:'admincp.php?action=mail_set',data:options,success:function(callback){
			$("#show_send_msg").html(callback);
		}})
	}
</script>
{/literal}
<form action="admincp.php?action=mail_set" method="post" id="send_email_cfg" autocomplete="off">
  <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="tableborder"  style="margin-top:10px;">

<tr class="header">
<td colspan="3">邮件服务器设置</td>
</tr>
<tr>
	<td width="16%" class="one">邮件发送方式</td>
    <td width="46%">
    	<div onclick="hideSmtp(this);" style=" padding:3px;cursor:pointer;"><input type="radio" checked="checked"   value="mail" name="mail_send_type" />使用mail发信</div>
        <div onclick="hideSmtp(this);" style="padding:3px;cursor:pointer;"><input type="radio" value="sendmail" onclick="hideSmtp();"  {if $mail_config.mail_send_type eq 'sendmail'} checked="checked"{/if} name="mail_send_type" />使用sendmail发送,具体请检查服务器的sendmail设置(限linux等非win服务器使用)</div>
        <div onclick="showSmtp(this);"  id="smtp_check" style="padding:3px;cursor:pointer;"><input type="radio" value="smtp"  {if $mail_config.mail_send_type eq 'smtp'} checked="checked"{/if} name="mail_send_type"  id="is_use_smtp"/>使用外部SMTP发送</div>
    </td>
     <td width="38%"></td>
</tr>
  <tr>
        <td class="one" align="right" style="text-align:right;" >发送人邮件：</td>
        <td><input type="text" value="{$mail_config.sender}"   class="w_200"  name="sender"/></td>
        <td></td>
    </tr>
     <tr class="smtp">
        <td class="one" align="right" style="text-align:right;">smtp服务器地址：</td>
        <td><input type="text" value="{$mail_config.smtp_host}"  class="w_200"  name="smtp_host"/></td>
         <td>比如163的smtp服务器地址为smtp.163.com</td>
    </tr>

     <tr class="smtp">
        <td class="one" align="right" style="text-align:right;">smtp服务器端口：</td>
        <td><input type="text" value="{if $mail_confg.smtp_port}{$mail_config.smtp_port}{else}25{/if}"  class="w_200" name="smtp_port"/></td>
        <td>一般都为25</td>
    </tr>
        <tr class="smtp">
        <td class="one" align="right" style="text-align:right;">smtp用户名：</td>

        <td><input type="text" value="{$mail_config.smtp_user}"  class="w_200"  name="smtp_user"/></td>
        <td>一般为您邮箱的全称比如xxx@163.com</td>
    </tr>
        <tr class="smtp">
        <td class="one" align="right" style="text-align:right;">smtp密码：</td>
        <td><input  type="password"  value="{$mail_config.smtp_pass}" class="w_200" name="smtp_pass"/></td>
        <td>您邮箱的密码</td>
    </tr>

<tr id="show_test_mail" style="display:none;">
	<td class="one">测试收信邮箱地址:</td>
    <td>
	<input type="text" value="" name="test_email" id="test_mail_val" /> <input type="button" style="cursor:pointer;" onclick="test_send_email(this);" value="发送测试信" />
    </td>
    <td>
    	<div style=" display:none;color:#F00; font-size:13px;" id="show_send_msg"></div>
    </td>
</tr>
</table>
</form>
<div style="text-align:center;">
<input  type="hidden" value="pub" id="test_hiden_val" name="test" />&nbsp;&nbsp;
  <input type="submit" name="Submit" value="保 存" />&nbsp;&nbsp;<input type="button" style="cursor:pointer;" id="test_send_mail_click" value="测试发信" />
</div>
{/if}

{if $action eq 'mail_tpl'}
  <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="tableborder tableborder_line"  style="margin-top:10px;">
<tr class="header">
<td>模板主题</td>
<td>模板标题</td>
<td align="center">是否开启</td>
<td>操作</td>
</tr>
{foreach from=$mail_list item=list}
<tr>
	<td>{$list.tpl_subject}</td>
    <td>{$list.mail_tile}</td>
    <td align="center">{if $list.tpl_open eq '1'}<font color="#FF0000">是</font>{else}否{/if}</td>
    <td><a href="admincp.php?action=mail_set&do=edit_tpl&id={$list.tpl_id}">编辑</a></td>
</tr>
{/foreach}
</table>

{/if}


{if $task eq 'edit_tpl'}
<form  method="post" action="admincp.php?action=mail_set&do=edit_tpl" autocomplete="off">
  <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="tableborder"  style="margin-top:10px;">
<tr class="header">
<td colspan="2" >编辑邮件模板</td>
</tr>
<tr>
	<td>参数设置:</td>
    <td>{$data.tpl_desc}</td>
</tr>
<tr>
	<td>开启状态</td>
    <td><input type="checkbox" value="1" {if $data.tpl_open eq '1'} checked="checked"{/if} name="tpl_open"/></td>
</tr>
<tr>
	<td>主题:</td>
    <td>{$data.tpl_subject}</td>
</tr>

<tr>
	<td>标题</td>
    <td><input type="text" value="{$data.mail_tile}" name="mail_title" /></td>
</tr>
<tr>
	<td>内容</td>
    <td>
    <input type="hidden" value="{$data.tpl_id}" name="tpl_id" />
    <textarea name="mail_content" style="width:500px; height:200px;">{$data.mail_content}</textarea>
    </td>
</tr>
<tr>
	<td colspan="3" align="center"><input type="submit" value="保存" /></td>
</tr>
</table>
</form>
{/if}
{if $do=='mail_send'}
{literal}
<script type="text/javascript">
	$(document).ready(function(){
		$("#my_forms").submit(function(){
			$("#sub").attr({"disabled":"disabled"});
		})
	})
</script>
{/literal}
  <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="tableborder"  style="margin-top:10px;">
<form action="admincp.php?action=mail_set&do=mail_send" method="post" id="my_forms" name="myform" autocomplete="off">
<tr class="header">
<td colspan="2">在线发邮件</td>
</tr>
<tr>
  <td>标&nbsp;&nbsp;&nbsp;&nbsp;题：    </td>
  <td><input name="subject" value="{$se.subject}" type="text" id="subject" size="50" /> <font color="#FF0000"> * </font></td>
</tr>
<tr>
  <td>收件人：        </td>
  <td><input name="reciver"  value="{$se.reciver}" type="text" id="touser" size="50" /><font color="#FF0000">  *  </font>
</td>
</tr>
<tr>
  <td>邮件内容：</td>
  <td><textarea name="content" cols="100" rows="20" id="content">{$se.content}</textarea> <font color="#FF0000"> * </font> </td>
</tr>
{$m}
<tr><td colspan="2" align="center" ><div align="center">
  <input type="submit" name="Submit" id="sub" value=" 发 送 " />
</div></td>
  </tr>
</form>
</table>
{/if}
</div>
{include file="footer.tpl"}