复制代码 代码如下:
<?php
class reportFormAction extends CommonAction{
public function index(){
if($_POST){
//@param $data array 需要导出的数据
//@param $field string 导出csv文件的列名
//@param $filename string 需要导出csv文件的名字
$where = '1';
$order = 'creative_id desc';
if($_POST['crea_wh'] == 1) $order .= "";
if($_POST['crea_wh'] == 2) $order .= "creative_time desc";
$star = strtotime($_POST['control_star']);
$end = strtotime($_POST['control_end']);
if($star && $end) $where .= " and (create_time between $star and $end)";
if($_POST['creative_type'] == 1) $where .= " and creative_type =1";
if($_POST['creative_type'] == 2) $where .= " and creative_type =2";
if($_POST['creative_type'] == 3) $where .= " and creative_type =3";
if($_POST['sort_name'] == 1) $where .= " and sort_name = '技术类'";
if($_POST['sort_name'] == 2) $where .= " and sort_name = '包装类'";
if($_POST['sort_name'] == 3) $where .= " and sort_name = '产品类'";
if($_POST['sort_name'] == 4) $where .= " and sort_name = '营销类'";
if($_POST['sort_name'] == 5) $where .= " and sort_name = '其他类'";
if($_POST['two_status']==0) {$where .= " and two_status=0"; $fenlei1="一句话创意";}
if($_POST['two_status']==1) {$where .= " and two_status=1"; $fenlei2="标准创意";}
$csv = '';
$lists = M('creative')->where($where)->order($order)->select();
if(is_array($lists) && count($lists)>0) {
if(empty($filename)) {
$filename = date('Y-m-d',time()).'.csv';
}
header('Content-type:application/vnd.ms-excel');
header('Content-Disposition:attachment;filename='.$filename);
header('Pragma:no-cache');
header('Expires:0');
if($_POST['two_status']==0){
$csv= '分类,创意ID,创意类型,创意标签,创意标题,创意描述,评论数, 收藏数,投票数,提交人,作者'."\n";
}elseif($_POST['two_status']==1){
$csv= '分类,创意ID,创意类型,创意标签,创意标题,创意描述,评论数, 收藏数,投票数,提交人,作者,合作者,核心创新点说明,市场计划,已有类似商业化案例,相关专利状况,实现方式讨论,发表时间'."\n";
}else{
$csv= '分类,创意ID,创意类型,创意标签,创意标题,创意描述,评论数, 收藏数,投票数,提交人,作者,合作者,核心创新点说明,市场计划,已有类似商业化案例,相关专利状况,实现方式讨论,发表时间'."\n";
}
foreach($lists as $list =>$v) {
if($v['creative_type'] == 1){
$type = '问题';
}elseif($v['creative_type'] == 2){
$type = '解决方式';
}elseif($v['creative_type'] == 3){
$type = '新创意';
}
if($v['two_status']==0) $fenlei="一句话创意";
if($v['two_status']==1) $fenlei="标准创意";
if($_POST['two_status']==0){ //一句话
$csv .= $fenlei1.','.$v['creative_id'].",".$v['sort_name'].','.$type.','.$v['creative_name'].','.$v['creative_description'].','.$v['comment_num'].','.$v['collect_num'].','.$v['vote_num'].','.$v['submitter'].','.$v['author']."\n";
}elseif($_POST['two_status']==1){ //标准
$csv .= $fenlei2.','.$v['creative_id'].",".$v['sort_name'].','.$type.','.$v['creative_name'].','.$v['creative_description'].','.$v['comment_num'].','.$v['collect_num'].','.$v['vote_num'].','.$v['submitter'].','.$v['author'].','.$v['collaborator'].','.$v['innovation_description'].','.$v['marketing_plan'].','.$v['business_case'].','.$v['patent_situation'].','.$v['discuss_ways'].','.strtotime($v['create_time'])."\n";
}else{ //全部
$csv .= $fenlei.','.$v['creative_id'].",".$v['sort_name'].','.$type.','.$v['creative_name'].','.$v['creative_description'].','.$v['comment_num'].','.$v['collect_num'].','.$v['vote_num'].','.$v['submitter'].','.$v['author'].','.$v['collaborator'].','.$v['innovation_description'].','.$v['marketing_plan'].','.$v['business_case'].','.$v['patent_situation'].','.$v['discuss_ways'].','.strtotime($v['create_time'])."\n";
}
}
echo mb_convert_encoding($csv,"CP936","UTF-8");
}else{
$this->assign("msg",$msg);
}
exit;
}
$this->display();
}
public function votecount(){
if($_POST){
//@param $data array 需要导出的数据
//@param $field string 导出csv文件的列名
//@param $filename string 需要导出csv文件的名字
$where = '1';
if($_POST['crea_order'] == 1) $order = " c.vote_num desc";
$star = strtotime($_POST['control_star']);
$end = strtotime($_POST['control_end']);
if($star && $end) $where .= " and (c.vote_start_time between $star and $end) and (c.vote_end_time between $star and $end)";
$sql ="select c.sort_name,c.creative_id,c.creative_type,c.creative_name,c.creative_description,c.vote_num,c.comment_num,c.collect_num,c.create_time, u.username from cofco_creative as c left join cofco_userinfo as u on c.uid = u.uid where $where order by $order ";
$lists = M()->query($sql);
$csv = '';
if(is_array($lists) && count($lists)>0) {
if(empty($filename)) {
$filename = date('Y-m-d',time()).'.csv';
}
header('Content-type:application/vnd.ms-excel');
header('Content-Disposition:attachment;filename='.$filename);
header('Pragma:no-cache');
header('Expires:0');
$csv = '创意标签,提交者,创意分类,创意标题,创意简述,得票数,评论数, 收藏数,上传时间'."\n";
foreach($lists as $list =>$v) {
if($v['creative_type'] == 1){
$type = '问题';
}elseif($v['creative_type'] == 2){
$type = '解决方式';
}elseif($v['creative_type'] == 3){
$type = '新创意';
}
$time = date("Y-m-d H:i:s",$v['create_time']);
$csv .= $v['sort_name'].','.$v['username'].','.$type.','.$v['creative_name'].','.$v['creative_description'].','.$v['vote_num'].','.$v['comment_num'].','.$v['collect_num'].','.$time."\n";
}
echo mb_convert_encoding($csv,"CP936","UTF-8");
}else{
$this->assign("msg",$msg);
}
exit;
}
$this->display();
}
}
?>
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 黄乙玲1988-无稳定的爱心肝乱糟糟[日本东芝1M版][WAV+CUE]
- 群星《我们的歌第六季 第3期》[320K/MP3][70.68MB]
- 群星《我们的歌第六季 第3期》[FLAC/分轨][369.48MB]
- 群星《燃!沙排少女 影视原声带》[320K/MP3][175.61MB]
- 乱斗海盗瞎6胜卡组推荐一览 深暗领域乱斗海盗瞎卡组分享
- 炉石传说乱斗6胜卡组分享一览 深暗领域乱斗6胜卡组代码推荐
- 炉石传说乱斗本周卡组合集 乱斗模式卡组最新推荐
- 佟妍.2015-七窍玲珑心【万马旦】【WAV+CUE】
- 叶振棠陈晓慧.1986-龙的心·俘虏你(2006复黑限量版)【永恒】【WAV+CUE】
- 陈慧琳.1998-爱我不爱(国)【福茂】【WAV+CUE】
- 咪咕快游豪礼放送,百元京东卡、海量欢乐豆就在咪咕咪粉节!
- 双11百吋大屏焕新“热”,海信AI画质电视成最大赢家
- 海信电视E8N Ultra:真正的百吋,不止是大!
- 曾庆瑜1990-曾庆瑜历年精选[派森][WAV+CUE]
- 叶玉卿1999-深情之选[飞图][WAV+CUE]