时间:2021-07-01 10:21:17 帮助过:29人阅读
- <br><!--?php <BR-->class reportFormAction extends CommonAction{ <br><br>public function index(){ <br>if($_POST){ <br>//@param $data array 需要导出的数据 <br>//@param $field string 导出csv文件的列名 <br>//@param $filename string 需要导出csv文件的名字 <br>$where = '1'; <br>$order = 'creative_id desc'; <br>if($_POST['crea_wh'] == 1) $order .= ""; <br>if($_POST['crea_wh'] == 2) $order .= "creative_time desc"; <br>$star = strtotime($_POST['control_star']); <br>$end = strtotime($_POST['control_end']); <br>if($star && $end) $where .= " and (create_time between $star and $end)"; <br>if($_POST['creative_type'] == 1) $where .= " and creative_type =1"; <br>if($_POST['creative_type'] == 2) $where .= " and creative_type =2"; <br>if($_POST['creative_type'] == 3) $where .= " and creative_type =3"; <br>if($_POST['sort_name'] == 1) $where .= " and sort_name = '技术类'"; <br>if($_POST['sort_name'] == 2) $where .= " and sort_name = '包装类'"; <br>if($_POST['sort_name'] == 3) $where .= " and sort_name = '产品类'"; <br>if($_POST['sort_name'] == 4) $where .= " and sort_name = '营销类'"; <br>if($_POST['sort_name'] == 5) $where .= " and sort_name = '其他类'"; <br>if($_POST['two_status']==0) {$where .= " and two_status=0"; $fenlei1="一句话创意";} <br>if($_POST['two_status']==1) {$where .= " and two_status=1"; $fenlei2="标准创意";} <br>$csv = ''; <br>$lists = M('creative')->where($where)->order($order)->select(); <br>if(is_array($lists) && count($lists)>0) { <br><br><br>if(empty($filename)) { <br>$filename = date('Y-m-d',time()).'.csv'; <br>} <br>header('Content-type:application/vnd.ms-excel'); <br>header('Content-Disposition:attachment;filename='.$filename); <br>header('Pragma:no-cache'); <br>header('Expires:0'); <br>if($_POST['two_status']==0){ <br>$csv= '分类,创意ID,创意类型,创意标签,创意标题,创意描述,评论数, 收藏数,投票数,提交人,作者'."\n"; <br>}elseif($_POST['two_status']==1){ <br>$csv= '分类,创意ID,创意类型,创意标签,创意标题,创意描述,评论数, 收藏数,投票数,提交人,作者,合作者,核心创新点说明,市场计划,已有类似商业化案例,相关专利状况,实现方式讨论,发表时间'."\n"; <br>}else{ <br>$csv= '分类,创意ID,创意类型,创意标签,创意标题,创意描述,评论数, 收藏数,投票数,提交人,作者,合作者,核心创新点说明,市场计划,已有类似商业化案例,相关专利状况,实现方式讨论,发表时间'."\n"; <br>} <br>foreach($lists as $list =>$v) { <br>if($v['creative_type'] == 1){ <br>$type = '问题'; <br>}elseif($v['creative_type'] == 2){ <br>$type = '解决方式'; <br>}elseif($v['creative_type'] == 3){ <br>$type = '新创意'; <br>} <br>if($v['two_status']==0) $fenlei="一句话创意"; <br>if($v['two_status']==1) $fenlei="标准创意"; <br>if($_POST['two_status']==0){ //一句话 <br>$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"; <br>}elseif($_POST['two_status']==1){ //标准 <br>$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"; <br>}else{ //全部 <br>$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"; <br>} <br>} <br>echo mb_convert_encoding($csv,"CP936","UTF-8"); <br><br>}else{ <br>$this->assign("msg",$msg); <br>} <br>exit; <br>} <br><br><br><br><br>$this->display(); <br>} <br><br><br>public function votecount(){ <br>if($_POST){ <br>//@param $data array 需要导出的数据 <br>//@param $field string 导出csv文件的列名 <br>//@param $filename string 需要导出csv文件的名字 <br>$where = '1'; <br>if($_POST['crea_order'] == 1) $order = " c.vote_num desc"; <br>$star = strtotime($_POST['control_star']); <br>$end = strtotime($_POST['control_end']); <br>if($star && $end) $where .= " and (c.vote_start_time between $star and $end) and (c.vote_end_time between $star and $end)"; <br>$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 "; <br>$lists = M()->query($sql); <br>$csv = ''; <br>if(is_array($lists) && count($lists)>0) { <br><br><br>if(empty($filename)) { <br>$filename = date('Y-m-d',time()).'.csv'; <br>} <br>header('Content-type:application/vnd.ms-excel'); <br>header('Content-Disposition:attachment;filename='.$filename); <br>header('Pragma:no-cache'); <br>header('Expires:0'); <br><br><br>$csv = '创意标签,提交者,创意分类,创意标题,创意简述,得票数,评论数, 收藏数,上传时间'."\n"; <br>foreach($lists as $list =>$v) { <br>if($v['creative_type'] == 1){ <br>$type = '问题'; <br>}elseif($v['creative_type'] == 2){ <br>$type = '解决方式'; <br>}elseif($v['creative_type'] == 3){ <br>$type = '新创意'; <br>} <br>$time = date("Y-m-d H:i:s",$v['create_time']); <br>$csv .= $v['sort_name'].','.$v['username'].','.$type.','.$v['creative_name'].','.$v['creative_description'].','.$v['vote_num'].','.$v['comment_num'].','.$v['collect_num'].','.$time."\n"; <br>} <br>echo mb_convert_encoding($csv,"CP936","UTF-8"); <br><br>}else{ <br>$this->assign("msg",$msg); <br>} <br>exit; <br>} <br><br>$this->display(); <br>} <br>} <br>?>