showmessage("发送成功!");
    exit;
}
if ($today["mday"] == 10 || $today["mday"] == 11 || $today["mday"] == 25 || $theLastDayOfMonth) {
    if ($today['mon'] == 1 && ($today['mday'] == 10 || $today['mday'] == 11)) {
        $year = $today['year'] - 1;
        $month = '12月份';
    } else {
        $year = $today['year'];
        if ($today['mday'] == 10 || $today['mday'] == 11) {
            $month = $today['mon'] - 1 . '月份';
        } else {
            $month = $today['mon'] . '月份';
        }
    }
    $tongji = array('171' => fillarray('SSL'), '220' => fillarray('UED'), '170' => fillarray('APM'), '169' => fillarray('AD'), '168' => fillarray('AF'), '167' => fillarray('AC'), '172' => fillarray('WOC'), '182' => fillarray('测试中心'), '173' => fillarray('ACT'), '174' => fillarray('AFT'), '175' => fillarray('ADT'), '176' => fillarray('APMT'), '177' => fillarray('SSLT'), '178' => fillarray('WOCT'), '179' => fillarray('ATT'), '180' => fillarray('PR'), '181' => fillarray('IRD'), '183' => fillarray('RDM & SQA'), '384' => fillarray('wnst'), '389' => fillarray('VTT'), '392' => fillarray('北研平台'), '393' => fillarray('北研安全攻防'), '394' => fillarray('VT'), '395' => fillarray('无线'));
    $query = $_SGLOBAL['db']->query("select * from " . tname('creativeconfig'));
    while ($value = $_SGLOBAL['db']->fetch_array($query)) {
        if ($value['catid'] != 0) {
            $tongji[$value['catid']]['emails'] = $value['emails'];
            $tongji[$value['catid']]['neednum'] = round($value['personnum'] * $value['scale']);
        } else {
            $emailsall = $value['emails'];
        }
    }
    $sqlquerystr = 'select * from ' . tname('creativeitems') . ' i,' . tname('creativemessage') . ' m' . ' where i.itemid=m.itemid and m.month="' . $month . '"  and i.year=' . $year;
    $query = $_SGLOBAL["db"]->query($sqlquerystr);
    while ($i = $_SGLOBAL['db']->fetch_array($query)) {
        $tongji[$i["catid"]]["finishednum"]++;
        $tongji[$i["catid"]]["msg"] = $tongji[$i["catid"]]["msg"] . '<tr><td>' . $i["itemid"] . '</td><td>' . $i["subject"] . '</td><td>' . $tongji[$i["catid"]]["id"] . '</td><td>' . $i["username"] . '</td><td>' . date('Y-m-d', $i['dateline']) . '</td><td>' . $gradearr[$i["grade"]] . '</td><td>' . $i["month"] . '</td><td>' . (empty($i["shenhezhe"]) ? '未审核' : $i["shenhezhe"]) . '</td></tr>';
        if (!empty($i['shenhezhe'])) {
function fillarray($nr, $famid)
{
    global $dbh, $db_functions, $maxperson;
    global $treeid, $pers_var, $fam_var, $indexnr;
    if ($nr >= $maxperson) {
        return;
    }
    if ($famid) {
        @($personmnDb = $db_functions->get_person($famid));
        $man_cls = new person_cls();
        $man_cls->construct($personmnDb);
        $man_privacy = $man_cls->privacy;
        $name = $man_cls->person_name($personmnDb);
        $treeid[$nr][0] = $name["standard_name"];
        // *** Privacy filter ***
        if ($man_privacy == '') {
            if ($personmnDb->pers_birth_date) {
                $treeid[$nr][1] = $personmnDb->pers_birth_date;
            } else {
                $treeid[$nr][1] = $personmnDb->pers_bapt_date;
            }
            if ($personmnDb->pers_death_date) {
                $treeid[$nr][4] = $personmnDb->pers_death_date;
            } else {
                $treeid[$nr][4] = $personmnDb->pers_buried_date;
            }
        } else {
            $treeid[$nr][1] = '';
            $treeid[$nr][4] = '';
        }
        //NEW
        if ($nr == 1) {
            $indexnr = $personmnDb->pers_indexnr;
        }
        // need this for desc chart at bottom, if selected
        $pos = strpos($personmnDb->pers_fams, ";");
        if ($pos === false) {
            $treeid[$nr][2] = $personmnDb->pers_fams;
        } else {
            $treeid[$nr][2] = substr($personmnDb->pers_fams, 0, $pos);
        }
        $treeid[$nr][3] = $famid;
        $treeid[$nr][5] = $personmnDb->pers_sexe;
        if ($personmnDb->pers_famc) {
            @($record_family = $db_functions->get_family($personmnDb->pers_famc));
            if ($record_family->fam_man) {
                fillarray($nr * 2, $record_family->fam_man);
            }
            if ($record_family->fam_woman) {
                fillarray($nr * 2 + 1, $record_family->fam_woman);
            }
        }
    }
}