<!--<?php
include_once PrintEot('left');
if(empty($action)){
if($resume){
$j_url = EncodeUrl("$basename&action=erase");
print <<<EOT
-->
<div class="admin_table mb10">
<table width="100%" cellspacing="0" cellpadding="0">
	<tr class="tr1">
		<td class="td2">	存在未完成的郵件群發任務，最後發送時間為<span class="s2">$pwSendmail[lasttime]</span>
	[<a href="$basename&action=confirm">查看</a>]　[<a href="$j_url">刪除</a>]</td>
	</tr>
</table>
</div>
<!--
EOT;
}print <<<EOT
-->
<script type="text/javascript" src="js/wind_editor.js"></script>
<form name='FORM' action="$basename" method="post" onsubmit="return checkpost(document.FORM);">
<h2 class="h1">郵件群發</h2>
<div class="admin_table mb10">
<table width="100%" cellspacing="0" cellpadding="0">
	<tr class="tr1 vt">
		<td class="td1">&nbsp;</td>
		<td class="td2">
			<ul class="list_A" id="radioby">
				<li><input type='radio' name='by' value='0' onclick="sendtype(0)" checked>按用戶組</li>
				<li><input type='radio' name='by' id="online" value='1' onclick="sendtype(1)">在線用戶</li>
				<li><input type='radio' name='by' id="byRegName" value='2' onclick="sendtype(2)">按注冊時間</li>
				<li><input type='radio' name='by' id="byLoginTime" value='3' onclick="sendtype(3)">按最後登錄時間</li>       
                <li><input type='radio' name='by' value='4' onclick="sendtype(4)">按用戶名</li>
			</ul>
		</td>
	</tr>
	<tbody id="group_0">
		<tr class="tr1 vt">
			<td class="td1">接收用戶 <span class="s1">*</span></td>
			<td class="td2">
				<ul class="list_A list_120 cc mb10" style="width:480px;">
<!--
EOT;
$num=0;
foreach($ltitle as $key=>$value){
if($key=='1' || $key=='2' || isset($lneed[$key]))continue;
$num++;
print <<<EOT
-->
					<li><input type='checkbox' name='sendto[]' value='$key'>$value</li>
<!--
EOT;
}print <<<EOT
-->
					<li><input type='checkbox' name='sendto[]' value='-1'>普通會員</li>
				</ul>
				<span class="bt2"><span><button onclick="ChecksAll(this.form)" value="全 選" name="chkall" onfocus="blur();" type="button">全 選</button></span></span>
			</td>
		</tr>
	</tbody>
	<tbody id="group_2" style="display:none">
		<tr class="tr1 vt">
			<td class="td1">按注冊時間 </td>
			<td class="td2"><div class="input_img fl"><i onclick="this.nextSibling.onclick()" class="input_time" title="選擇時間"></i><input name="starttime" id="starttime" value="" onclick="ShowCalendar(this.id);" type="text"></div><span class="p_lr_10 fl">至</span><div class="input_img fl"><i class="input_time" title="選擇時間"></i><input name="endtime" id="endtime" value="" onclick="ShowCalendar(this.id);" type="text"></div>
			<div class="help_a" style="display: block;">&nbsp;格式:yyyy-mm-dd，會員注冊時間範圍</div></td>
		</tr>
	</tbody>
	<tbody id="group_3" style="display:none">
		<tr class="tr1 vt">
			<td class="td1">按最後登錄時間</td>
			<td class="td2"><div class="input_img fl"><i onclick="this.nextSibling.onclick()" class="input_time" title="選擇時間"></i><input name="loginstarttime" id="loginstarttime" value="" onclick="ShowCalendar(this.id);" type="text"></div><span class="p_lr_10 fl">至</span><div class="input_img fl"><i class="input_time" title="選擇時間"></i><input name="loginendtime" id="loginendtime" value="" onclick="ShowCalendar(this.id);" type="text"></div>
			<div class="help_a" style="display: block;">&nbsp;格式:yyyy-mm-dd，會員最後登錄時間範圍</div></td>
		</tr>
	</tbody>
		<tbody id="group_4" style="display:none">
			<tr class="tr1 vt">
				<td class="td1">用戶名 <span class="s1">*</span></td>
				<td class="td2"><input type="text" name="touser" class="input input_wb fl mr10" /><span class="help_a">多個用戶名用,分開</span></td>
			</tr>
		</tbody>
	<tr class="tr1 vt">
		<td class="td1">每批發送個數</td>
		<td class="td2"><input class="input input_wa" type="text" name="percount" /></td>
	</tr>
	<tr class="tr1 vt">
		<td class="td1">主題 <span class="s1">*</span></td>
		<td class="td2"><input type="text" class="input input_wb" name="subject" /></td>
	</tr>
	<tr class="tr1 vt" valign="top">
		<td class="td1">內容 <span class="s1">*</span></td>
		<td class="td2"><textarea name="atc_content" class="textarea fl mr10" style="height:150px;"></textarea><div class="fl p10 mr10" style="border:1px solid #ccc;background:#fff;width:200px;height:136px;">\$email:表示用戶的電子郵件地址<br />\$windid:表示用戶名<br />\$winduid:表示用戶UID</div></td>
	</tr>
</table>
</div>
<input type="hidden" name="action" value="send">
<div class="tac mb10">
	<span class="btn"><span><button type="submit">提 交</button></span></span>
	<span class="bt"><span><button type="reset">重 置</button></span></span>
</div>
</form>

<script type="text/javascript" src="js/date.js"></script>
<script type="text/javascript">
function ChecksAll(form,match) {
	for (var i = 0,j = form.elements.length; i < j; i++) {
		var e = form.elements[i];
		if (e.type == 'checkbox' && (typeof match == 'undefined' || e.name.match(match))) {
			e.checked = ifcheck;
		}
	}
	ifcheck = ifcheck == true ? false : true;
}
function sendtype(ID){
	for(var i=0;i<5;i++){
		try{
		if(i==ID) getObj("group_"+ID).style.display = "";
		else getObj("group_"+i).style.display = "none";
		}catch(e){}
	}
}
function checkpost(obj) {
	var online = document.getElementById("online"); 
	var userobj = document.getElementsByName("sendto[]"); 
	var check=0; 
	for(var i=0;i <userobj.length;i++){ 
		if(userobj[i].checked){ 
			check=1; 
		} 
	} 
	if (getObj('byRegName').checked == true && (getObj('starttime').value == '' || getObj('endtime').value == '')) {
		obj.touser.setAttribute("hasError", 1);
		showDialog("error","注冊時間範圍不能為空",2);
		obj.subject.focus();
		return false;
	} 
	if (getObj('byLoginTime').checked == true && (getObj('loginstarttime').value == '' || getObj('loginendtime').value == '')) {
		obj.touser.setAttribute("hasError", 1);
		showDialog("error","最後登錄時間範圍不能為空",2);
		obj.subject.focus();
		return false;
	} 
	if (check == 0 && getObj('byRegName').checked == false && getObj('byLoginTime').checked == false && obj.touser.value == "" && online.checked == false) {
		obj.touser.setAttribute("hasError", 1);
		showDialog("error","接收用戶不能為空",2);
		obj.subject.focus();
		return false;
	} 
	if (obj.subject.value == "") {
		obj.subject.setAttribute("hasError", 1);
		showDialog("error","主題不能為空",2);
		obj.subject.focus();
		return false;
	} 
	if (obj.atc_content.value == "") {
		obj.atc_content.setAttribute("hasError", 1);
		showDialog("error","內容不能為空",2);
		obj.atc_content.focus();
		return false;
	} 
}
var rds = getObj('radioby').getElementsByTagName("input");
for (var i=0;i<=4;i++){
   if(rds[i].checked){
      sendtype(i)
      }
}
</script>
<!--
EOT;
} elseif ($action == 'send' || $action == 'confirm') {print <<<EOT
-->
<h2 class="h1">郵件群發確認</h2>
<div class="admin_table mb10">
<table width="100%" cellspacing="0" cellpadding="0">
	<tr class="tr1 vt">
		<td class="td1">接收用戶總數</td>
		<td class="td2"><span class="s3">$pwSendmail[count]</span>　人</td>
	</tr>
	<tr class="tr1 vt">
		<td class="td1">每批發送</td>
		<td class="td2">$pwSendmail[num]　封</td>
	</tr>
<!--
EOT;
if ($action != 'send') {print <<<EOT
-->
	<tr class="tr1 vt">
		<td class="td1">已完成發送</td>
		<td class="td2">$pwSendmail[sent]　封</td>
	</tr>
	<tr class="tr1 vt">
		<td class="td1">最後發送時間</td>
		<td class="td2">$pwSendmail[lasttime]</td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
	<tr class="tr1 vt">
		<td class="td1">郵件接收用戶</td>
		<td class="td2">
<!--
EOT;
if($pwSendmail[by]==0){
foreach($pwSendmail[info] as $value){
print <<<EOT
-->
&nbsp;$ltitle[$value]
<!--
EOT;
}}elseif($pwSendmail[by]==1){print <<<EOT
-->
當前在線的會員
<!--
EOT;
}elseif($pwSendmail[by]==2){
$stime=get_date($pwSendmail[info][stime],'Y-m-d');
$etime=get_date($pwSendmail[info][etime],'Y-m-d');
print <<<EOT
-->
注冊時間在 {$stime}　至　{$etime} 之間的會員
<!--
EOT;
}elseif($pwSendmail[by]==3){
$stime=get_date($pwSendmail[info][lostime],'Y-m-d');
$etime=get_date($pwSendmail[info][loetime],'Y-m-d');
print <<<EOT
-->
最後登錄時間在 {$stime}　至　{$etime} 之間的會員
<!--
EOT;
}elseif($pwSendmail[by]==4){
foreach($pwSendmail[usernames] as $usernames){
print <<<EOT
-->
$usernames
<!--
EOT;
}}print <<<EOT
-->
		</td>
	</tr>
	<tr class="tr1 vt">
		<td class="td1">郵件標題</td>
		<td class="td2">$pwSendmail[subject]</td></tr>
	<tr class="tr1 vt">
		<td class="td1">郵件內容</td>
		<td class="td2"><textarea class="textarea" disabled>$pwSendmail[content]</textarea></td>
	</tr>

</table>
</div>
<div class="tac mb10">
<!--
EOT;
$j_url = EncodeUrl("$basename&action=erase");
if ($action == 'send') {print <<<EOT
-->
	<span class="btn"><span><button type="button" onClick="javascript:window.location='$basename&action=groupsend'">開始發送</button></span></span>
	[<a href="$j_url">取消</a>]　[<a href="javascript:history.go(-1)">返回</a>]
<!--
EOT;
}else{print <<<EOT
-->
	<span class="btn"><span><button type="button" onClick="javascript:window.location='$basename&action=groupsend'">繼續發送</button></span></span>
	[<a href="$j_url">取消</a>]　[<a href="javascript:history.go(-1)">返回</a>]
<!--
EOT;
}print <<<EOT
-->
</div>
<!--
EOT;
}include_once PrintEot('adminbottom');
?>-->