diff --git a/Application/Admin/Controller/MendController.class.php b/Application/Admin/Controller/MendController.class.php index eca3e177a..d345b94d4 100644 --- a/Application/Admin/Controller/MendController.class.php +++ b/Application/Admin/Controller/MendController.class.php @@ -34,9 +34,10 @@ class MendController extends ThinkController { /** * 补链记录 * @param integer $p 分页 + * @param booble IS_POST post请求时为下一页ajax请求 * @return void */ - public function recordList($p=1) + public function recordList($p=1,$export=false) { $page = intval($p); $page = $page ? $page : 1; @@ -52,18 +53,24 @@ class MendController extends ThinkController { $map['user_account']=array('like','%'.$_REQUEST['account'].'%'); unset($_REQUEST['account']); } - - $data = M("Mend","tab_") - ->field("id,user_account,promote_account,promote_account_to,op_account,order_time,create_time,remark") + $data = M("Mend","tab_") + ->field("user_account,promote_account,promote_account_to,order_time,create_time,op_account,remark") ->where($map) - ->order("create_time desc") - ->page($page, $row) - ->select(); + ->order("create_time desc"); + + if($export){ + $data = $data->select(); + }else{ + $data = $data->page($page, $row)->select(); + } //格式化信息 foreach ($data as $key => $value) { $data[$key]['create_time'] = date("Y-m-d H:i:s",$value['create_time']); $data[$key]['order_time'] = date("Y-m-d",$value['order_time']); } + + if($export) db2csv($data,"推广员管理_推广补链_补链记录",["玩家账号","补链前渠道","补链后渠道","切分时间","补链时间","操作人员","备注"]); + if(IS_POST){ $page = set_pagination($_REQUEST['row_count'],$row); $this->ajaxReturn(array( @@ -83,6 +90,7 @@ class MendController extends ThinkController { $this->display(); // parent::lists("Mend",$p,$map); } + public function edit($id = null) { diff --git a/Application/Admin/View/Mend/recordList.html b/Application/Admin/View/Mend/recordList.html index 23c383825..f0d226878 100644 --- a/Application/Admin/View/Mend/recordList.html +++ b/Application/Admin/View/Mend/recordList.html @@ -85,7 +85,7 @@
- 导出 + 导出
{$_page|default=''}
diff --git a/Application/Common/Common/extend.php b/Application/Common/Common/extend.php index 29e2fe24f..708c10f63 100644 --- a/Application/Common/Common/extend.php +++ b/Application/Common/Common/extend.php @@ -2910,3 +2910,24 @@ function encryption($string) { return substr($string, 0, $strLen) . $hideChar . substr($string, $orderLen-$strLen); } +//导出csv +function db2csv(&$data,$title,$header=false){ + set_time_limit(0); + $filename = $title .'.csv'; + $fp = fopen($filename, 'w'); //生成临时文件 + fwrite($fp, chr(0xEF).chr(0xBB).chr(0xBF));//转码,防止乱码 + if($header) fputcsv($fp, $header); + + foreach ($data as $a) { + fputcsv($fp, $a); + } + fclose($fp); //每生成一个文件关闭 + //下载 + header('Content-Type: application/vnd.ms-excel;charset=utf-8'); + header('Content-Disposition: attachment;filename="' . $title . '.csv"'); + header('Cache-Control: max-age=0'); + header('Content-Length: ' . filesize($filename)); + readfile($filename); + unlink($filename); + die(); +} \ No newline at end of file