php excel导出下载


<?php
global $_W, $_GPC;
set_time_limit(0);

header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=11.xls ");
header("Content-Transfer-Encoding: binary ");


header("Content-type:application/vnd.ms-excel");

$name =  '客服消息统计';

header("Content-Disposition:filename=".$name .TIMESTAMP.".xls");

$exstr="ID\t时间\t账号\t题目\t发送人数\t总充值金额\t当天点击人数\t点击率\t当天充值比\r";


$list = pdo_fetchall("SELECT * FROM " . tablename('xiaoshuo_custom'));


foreach($list as $key=>&$row){
//    $time  = date('Y-m-d',$row['search_date']);
    $dianji   = round($row['uv']/$row['send_num']*100,2) .'%';
    $chongzhibi   = round($row['recharge_money']/$row['uv'],2) ;
    if(($chongzhibi)> 0){
    }else{
        $chongzhibi = 0;
    }


    $exstr.=$row['id'];
    $exstr.="\t{$row['search_date']}";
    $exstr.="\t{$row['authorizer_nickname']}";
    $exstr.="\t{$row['title']}";
    $exstr.="\t{$row['send_num']}";
    $exstr.="\t{$row['recharge_money']}";
    $exstr.="\t{$row['uv']}";
    $exstr.="\t{$dianji}";
    $exstr.="\t{$chongzhibi}\r";
}


$exstr=iconv('UTF-8',"GB2312//IGNORE",$exstr);
exit($exstr);



?>


<?php
global $_W, $_GPC;
$action = $_GPC['op'];
$bi = 0.9;


//账号类型(必选)
$zhangtype_list = pdo_fetchall("SELECT * FROM ".tablename('xiaoka_xiaoshuo_zhangtype'));

//所属分站(必选)
$_webname_list = pdo_fetchall("SELECT * FROM ".tablename('xiaoka_xiaoshuo_webname'));

//账号渠道(必选)
$channel_list = pdo_fetchall("SELECT * FROM ".tablename('xiaoka_xiaoshuo_channel'));



if ($action == 'delete') {
    $logId = $_GPC['id'];
    $uniacid = $_GPC['uniacid'];
    $optionId = $logId;
    if ($logId > 0) {
        pdo_delete("kf_tpl_msg_options", array('id' => $logId));
        pdo_delete("kf_tpl_msg_thread_cache", array('option_id' => $logId));
    }
}



if ($action == 'add'  ||  $action == 'edit'){

    //添加



    if (checksubmit('submit')) {
        $id  =$_GPC['id'] ;
        $data = array(
            'gname' => $_GPC['gname'],
            'type' => $_GPC['type'],
            'web_id' => $_GPC['web_id'],
            'channel' => $_GPC['channel'],
            'spend' => $_GPC['spend'],
            'handover_time' => strtotime($_GPC['handover_time']),
            'sim_fans_price' => $_GPC['sim_fans_price'],
            'init_fans_num' => $_GPC['init_fans_num'],
            'curr_recharge' => $_GPC['curr_recharge'],
            'no_huiben' => $_GPC['spend'] - $_GPC['curr_recharge']* $bi,
            'total_huiben_rate' => round($_GPC['curr_recharge'] * $bi / $_GPC['spend'],2),
            'remark' => $_GPC['remark'],
            'user_id' => $_W['uid']
        );

        if (!empty($id)) {
            pdo_update('xiaoka_xiaoshuo_zhanginfo', $data, array('id' => $id));
            message('更新字段成功!', $this->createWebUrl('zhanginfo', array('op' => 'display')), 'success');
        } else {
            pdo_insert('xiaoka_xiaoshuo_zhanginfo', $data);
            message('添加成功!', $this->createWebUrl('zhanginfo', array('op' => 'display')), 'success');
        }
        die;

    }


    $poster = pdo_fetch("SELECT * FROM ".tablename('xiaoka_xiaoshuo_zhanginfo')." WHERE id = :id  ", array(':id' => $_GPC['id']));
//    print_r($_W);die;  $_W['uid']     $_W['username']



    include $this->template('add_zhanginfo');
    die;
}





$condition ='where 1=1';

if($_GPC['authorizer_nickname']){
    $gname = trim($_GPC['authorizer_nickname']);
    $condition .=" and authorizer_nickname like '%{$gname}%'";
}
if(!empty($_GPC['type'])){
    $type = trim($_GPC['type']);
    $condition.=" and type like '%{$type}%'";
}

if(!empty($_GPC['channel'])){
    $channel = trim($_GPC['channel']);
    $condition.=" and channel like '%{$channel}%'";
}


if(!empty($_GPC['is_time'])){
    $handover_time = ($_GPC['handover_time']);
    $starttime =  $handover_time['start'] ;
    $endtime =  $handover_time['end'] ;
    $ss =         strtotime($starttime);
    $ee =         strtotime($endtime);
    $condition.=" and  unix_timestamp(search_date) between $ss and  $ee";
}




$pageindex = max(intval($_GPC['page']), 1); // 当前页码
$pagesize = 20; // 设置分页大小
$where = " WHERE uniacid = '{$_W['uniacid']}' ";
$total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('xiaoshuo_custom') .$condition );

$sql = "SELECT * FROM " . tablename("xiaoshuo_custom") .  $condition ."   order by id desc limit "  . ($pageindex - 1) * $pagesize . "," . $pagesize;
$optionsList = pdo_fetchall($sql);
$pager = pagination($total, $pageindex, $pagesize);


//echo pdo_debug();



include $this->template('customlist');


//获取账号
function getuser($type){
    global $_W, $_GPC;
    $poster = pdo_fetch("SELECT * FROM ".tablename('users')." WHERE uid = :uid  ", array(':uid' => $type));
    return $poster['username'];
}



//获取账号类型
function getzhtype($type){
    global $_W, $_GPC;
    $poster = pdo_fetch("SELECT * FROM ".tablename('xiaoka_xiaoshuo_zhangtype')." WHERE id = :id  ", array(':id' => $type));
    return $poster['name'];
}


//获取分站名称
function getwebid($type){
    global $_W, $_GPC;
    $poster = pdo_fetch("SELECT * FROM ".tablename('xiaoka_xiaoshuo_webname')." WHERE id = :id  ", array(':id' => $type));
    return $poster['name'];
}

//获取账号渠道
function getzhchannel($type){
    global $_W, $_GPC;
    $poster = pdo_fetch("SELECT * FROM ".tablename('xiaoka_xiaoshuo_channel')." WHERE id = :id  ", array(':id' => $type));
    return $poster['name'];
}

    public function dowebexportlist(){
        global $_W, $_GPC;
            set_time_limit(0);
            header("Content-type:application/vnd.ms-excel");
            header("Content-Disposition:filename=".TIMESTAMP.".xls");

            $exstr="ID\t昵称\t头像\topenid\t订单号\t提交时间\r";

        $id   =  ($_GPC['id']);
        $list = pdo_fetchall("SELECT * FROM " . tablename('xiaoka_taobao_info') . " WHERE rid= :rid", array(":rid" => $id));


        foreach($list as $key=>&$row){
            $time  = date('Y-m-d H:m:s',$row['creatime']);

            $exstr.=$row['id'];
            $exstr.="\t{$row['nickname']}";
            $exstr.="\t{$row['headimgurl']}";
            $exstr.="\t{$row['openid']}";
            $exstr.="\t{$row['orderno']}";
            $exstr.="\t{$time}\r";
        }


            $exstr=iconv('UTF-8',"GB2312//IGNORE",$exstr);
            exit($exstr);

    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值