用excel导出ecshop订阅邮件
该功能比较实用,应用在ecshop订阅用户上,做营销客户分析很棒。这里ecshop模板堂提供相应的修改方法:
1.在email_list.php 找到
/*------------------------------------------------------ */
//-- 批量退订
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'batch_exit') {
if (!isset ($_POST['checkboxes']) || !is_array($_POST['checkboxes'])) {
sys_msg($_LANG['no_sel ect_email'], 1);
}
$sql = "UPDATE " . $ecs->table('email_list') .
" SET stat = 2 WHERE stat <> 2 AND id " . db_create_in(join(',', $_POST['checkboxes']));
$db->query($sql);
$lnk[] = array (
'text' => $_LANG['back_list'],
'href' => 'email_list.php?act=list'
);
sys_msg(sprintf($_LANG['batch_exit_succeed'], $db->affected_rows()), 0, $lnk);
}
在其后面加上这段代码
/*------------------------------------------------------ */
//-- 导出线下发放的信息 zuimoban 2012 0925
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'zuimoban_excel') {
@ set_time_limit(0);
$date = local_date('Y-m-d', time());
/* 文件名称 */
$bonus_filename = 'subscribe_' . "$date";
if (EC_CHARSET != 'gbk') {
$bonus_filename = ecs_iconv('UTF8', 'GB2312', $bonus_filename);
}
header("Content-type: application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=$bonus_filename.xls");
/* 文件标题 */
if (EC_CHARSET != 'gbk') {
echo ecs_iconv('UTF8', 'GB2312', "邮件订阅列表") . "\t\n";
echo ecs_iconv('UTF8', 'GB2312', 'Id') . "\t";
echo ecs_iconv('UTF8', 'GB2312', 'Email') . "\t";
echo ecs_iconv('UTF8', 'GB2312', '状态') . "\t\n";
} else {
echo "邮件订阅列表\t\n";
echo "Id" . "\t";
echo "Email" . "\t";
echo "状态" . "\t\n";
}
$val = array ();
$sql = "SELECT bt.id,bt.email,bt.stat " .
"FROM " . $ecs->table('email_list') . " AS bt ";
$res = $db->query($sql);
$code_table = array ();
while ($val = $db->fetchRow($res)) {
echo $val['id'] . "\t";
echo $val['email'] . "\t";
if ($val['stat'] == "0") {
echo ecs_iconv('UTF8', 'GB2312', '未确认') . "\t";
} else {
echo ecs_iconv('UTF8', 'GB2312', '已确认') . "\t";
};
echo "\t\n";
}
}
----------------------------------------------------------------------------------------------------------------------------------
2.在模板文件里找到email_list.htm
<div class="form-div">
<input type="button" name="export" value="{$lang.export}" onclick="location.href='email_list.php?act=export';" class="button" />
</div>
将其修改为
<div class="form-div">
<input type="button" name="export" value="{$lang.export}" onclick="location.href='email_list.php?act=zuimoban_excel';" class="button" />
</div>