<?
$sub_menu = "200300";
include_once("./_common.php");

if (!$config[cf_email_use])
    alert("基本设定中\'开启群发邮件\'功能后才可以使用");

auth_check($auth[$sub_menu], "r");

$sql = "select * from $g4[mail_table] where ma_id = '$ma_id' ";
$ma = sql_fetch($sql);
if (!$ma[ma_id])
    alert("请选择需要发送的内容");

// 所有会员
$sql = "select COUNT(*) as cnt from $g4[member_table] ";
$row = sql_fetch($sql);
$tot_cnt = $row[cnt];

// 等待确认的注销会员
$sql = "select COUNT(*) as cnt from $g4[member_table] where mb_leave_date <> '' ";
$row = sql_fetch($sql);
$finish_cnt = $row[cnt];

$last_option = explode("||", $ma[ma_last_option]);
for ($i=0; $i<count($last_option); $i++) {
    $option = explode("=", $last_option[$i]);
    // 变量
    $var = $option[0];
    $$var = $option[1];
}

if (!isset($mb_id1)) $mb_id1 = 1;
if (!isset($mb_level_from)) $mb_level_from = 1;
if (!isset($mb_level_to)) $mb_level_to = 10;
if (!isset($mb_mailling)) $mb_mailling = 1;
if (!isset($mb_sex)) $mb_sex = 1;
if (!isset($mb_area)) $mb_area = 1;

$g4[title] = "群发邮件";
include_once("./admin.head.php");
?>


<table width=700 align=center>
<tr>
    <td class='right'>全部会员: <?=number_format($tot_cnt)?> 个 , 注销会员 : <?=number_format($finish_cnt)?> 个 , <b>正常会员 : <?=number_format($tot_cnt - $finish_cnt)?> 个</b></td>
</tr>
<tr>
    <td>
        <table cellpadding=0 cellspacing=0 width=100%>
        <form name=frmsendmailselectform method=post action="./mail_select_list.php" autocomplete="off">
        <input type=hidden name=ma_id value='<? echo $ma_id ?>'>
        <colgroup width=20% class='col1 pad1 bold right'>
        <colgroup width=80% class='col2 pad2'>
        <tr>
            <td></td>
            
        </tr>
        <tr><td colspan='2' class='line1'></td></tr>
        <tr class='ht'>
            <td>会员ID</td>
            <td>
                <input type=radio name='mb_id1' value='1' onclick="mb_id1_click(1);" <?=$mb_id1?"checked":"";?>> 全部
                <input type=radio name='mb_id1' value='0' onclick="mb_id1_click(0);" <?=!$mb_id1?"checked":"";?>> 选择
                <br>
                <input type=text class=ed id=mb_id1_from name=mb_id1_from value="<?=$mb_id1_from?>"> 开始 
                <input type=text class=ed id=mb_id1_to name=mb_id1_to value="<?=$mb_id1_to?>"> 截至

                <script language="JavaScript">
                function mb_id1_click(num)
                {
                    if (num == 1) {
                        document.getElementById('mb_id1_from').disabled = true;
                        document.getElementById('mb_id1_from').style.backgroundColor = '#EEEEEE';
                        document.getElementById('mb_id1_to').disabled = true;
                        document.getElementById('mb_id1_to').style.backgroundColor = '#EEEEEE';
                    } else {
                        document.getElementById('mb_id1_from').disabled = false;
                        document.getElementById('mb_id1_from').style.backgroundColor = '#FFFFFF';
                        document.getElementById('mb_id1_to').disabled = false;
                        document.getElementById('mb_id1_to').style.backgroundColor = '#FFFFFF';
                    }
                }
                document.onLoad=mb_id1_click(<?=(int)$mb_id1?>);
                </script>
            </td>
        </tr>
        <tr class='ht'>
            <td>生日</td>
            <td>
                <input type=text name='mb_birth_from' size=4 maxlength=4 class=ed value="<?=$mb_birth_from?>"> 开始 
                <input type=text name='mb_birth_to' size=4 maxlength=4 class=ed value="<?=$mb_birth_to?>"> 截至 (例 : 5月5日时输入 0505 必须输入开始及截至日期)</td>
        </tr>
        <tr class='ht'>
            <td>E-mail地址中包含指定内容</td>
            <td><input type=text name='mb_email' class=ed value="<?=$mb_email?>"> 举例：@163.com)</td>
        </tr>
        <tr class='ht'>
            <td>性别</td>
            <td>
                <select id=mb_sex name=mb_sex>
                    <option value=''>全部
                    <option value='F'>美女
                    <option value='M'>帅哥
                </select>
                <script language="JavaScript"> document.getElementById('mb_sex').value = "<?=$mb_sex?>"; </script>
            </td>
        </tr>
        <tr class='ht'>
            <td>地区</td>
            <td>
                <select id=mb_area name=mb_area>
                    <option value=''>全部
                    <option value='北京'>北京
                    <option value='天津'>天津
                    <option value='上海'>上海
                    <option value='重庆'>重庆
                    <option value='江苏'>江苏
                    <option value='广东'>广东
                    <option value='福建'>福建
                    <option value='河北'>河北
                    <option value='山东'>山东
                    <option value='广西'>广西
                    <option value='江西'>江西
                    <option value='浙江'>浙江
                    <option value='安徽'>安徽
                    <option value='湖南'>湖南
                    <option value='山西'>山西
                    <option value='辽宁'>辽宁
                    <option value='河南'>河南
                    <option value='湖北'>湖北
                    <option value='宁夏'>宁夏
                    <option value='黑龙江'>黑龙江
                    <option value='新疆'>新疆
                    <option value='内蒙古'>内蒙古
                    <option value='海南'>海南
                    <option value='四川'>四川
                    <option value='吉林'>吉林
                    <option value='贵州'>贵州
                    <option value='云南'>云南
                    <option value='西藏'>西藏
                    <option value='陕西'>陕西
                    <option value='甘肃'>甘肃
                    <option value='青海'>青海
                    <option value='香港'>香港
                    <option value='澳门'>澳门
                    <option value='台湾'>台湾
                    <option value='海外'>海外
                </select>
                <script language="JavaScript"> document.getElementById('mb_area').value = "<?=$mb_area?>"; </script>
            </td>
        </tr> 
        <tr class='ht'>
            <td>邮件地址</td>
            <td>
                <select id=mb_mailling name=mb_mailling>
                    <option value='1'>仅限同意接受邮件会员
                    <option value=''>全部
                </select>
                <script language="JavaScript"> document.getElementById('mb_mailling').value = "<?=$mb_mailling?>"; </script>
            </td>
        </tr>
        <tr class='ht'>
            <td>权限</td>
            <td>
                <select id=mb_level_from name=mb_level_from>
                <? for ($i=1; $i<=10; $i++) { ?>
                    <option value='<? echo $i ?>'><? echo $i ?>
                <? } ?>
                </select> 开始 
                <select id=mb_level_to name=mb_level_to>
                <? for ($i=1; $i<=10; $i++) { ?>
                    <option value='<? echo $i ?>'><? echo $i ?>
                <? } ?>
                </select> 截至
                <script language="JavaScript"> document.getElementById('mb_level_from').value = "<?=$mb_level_from?>"; </script>
                <script language="JavaScript"> document.getElementById('mb_level_to').value = "<?=$mb_level_to?>"; </script>
            </td>
        </tr>
        <tr class='ht'>
            <td>论坛版块会员</td>
            <td>
                <select id=gr_id name=gr_id>
                <option value=''>全部
                <?
                $sql = " select gr_id, gr_subject from $g4[group_table] order by gr_subject ";
                $result = sql_query($sql);
                for ($i=0; $row=sql_fetch_array($result); $i++)
                {
                    echo "<option value='$row[gr_id]'>$row[gr_subject]";
                }
                ?>
                </select>
                <script language="JavaScript"> document.getElementById('gr_id').value = "<?=$gr_id?>"; </script>
            </td>
        </tr>
        <tr><td colspan='2' class='line2'></td></tr>
        </table>

        <p align=center>
            <input type=submit class=btn1 value='  确    定  '>&nbsp;
            <input type=button class=btn1 value='  目  录  ' onclick="document.location.href='./mail_list.php';">
        </form>
    </td>
</tr></table>


<?
include_once("./admin.tail.php");
?>
