<?php
require '../webhead.php';
include_dev_model('weijinci.php');
//$end_date =gp('end');
$start_date=gp('start_date');
$end_date =gp('end_date');
if(!empty($start_date)&&!empty($end_date)){
$start=' and unix_timestamp(pub_date) >= '.strtotime($start_date).'';
$end=' and unix_timestamp(pub_date) < '.strtotime($end_date).'' ;
$start1=' and create_time>='.strtotime($start_date).'';
$end1=' and create_time <= '.strtotime($end_date).'' ;
$kong=' ';
}else{
$start=' ';
$end=' ';
$start1=' ';
$end1=' ';
$kong='and admin_user_id is null';
}
$sql_douyin_aweme_patch = "select * from douyin_aweme_patch where 1=1 "."$start"."$end"."$kong"." and check_status=3 order by admin_user_id asc";
$sql_douyin_aweme = "select * from douyin_aweme where company_id=1 and digg_count>=200 "."$start1"."$end1"."$kong"." and is_ad=1 order by admin_user_id asc";
/*print $sql_douyin_aweme_patch;
print $sql_douyin_aweme;*/
$request_douyin_aweme_patch = weijinci::select($sql_douyin_aweme_patch,'weijinci');
$request_douyin_aweme = weijinci::select($sql_douyin_aweme,'weijinci');
/*foreach($request_douyin_aweme as $k=>$row) {
$author_short_id = $row['author_short_id'];
$admin_user_id = $row['admin_user_id'];
$author_name = '-';
$admin_user_name = '-';
$author_info = weijinci::select("select * from douyin_user where short_id=" . $author_short_id,'weijinci');
foreach($author_info as $k=>$r):
if (!empty($author_info)) {
$author_name = $r['nickname'];
}
endforeach;
$admin_user_info = weijinci::select("select * from pub_user where id=" . $admin_user_id,'weijinci');
foreach($admin_user_info as $k=>$r):
if(!empty($admin_user_info)){
$admin_user_name = $r['user_name'];
}
endforeach;
}*/
$action = gp('act');
if($action == 'download'){
include_vendor_file('Excel/PHPExcel.php');
$objPHPExcel = new PHPExcel();
$objPHPExcel
->getProperties() //获得文件属性对象,给下文提供设置资源
->setCreator( "Maarten Balliauw") //设置文件的创建者
->setLastModifiedBy( "Maarten Balliauw") //设置最后修改者
->setTitle( "Office 2007 XLSX Test Document" ) //设置标题
->setSubject( "Office 2007 XLSX Test Document" ) //设置主题
->setDescription( "Test document for Office 2007 XLSX, generated using PHP classes.") //设置备注
->setKeywords( "office 2007 openxml php") //设置标记
->setCategory( "Test result file");
$objPHPExcel->setActiveSheetIndex(0) //设置第一个内置表(一个xls文件里可以有多个表)为活动的
->setCellValue( 'A1', '抖音ID' ) //给表的单元格设置数据
->setCellValue( 'B1', '抖音名称' ) //数据格式可以为字符串
->setCellValue( 'C1', '员工ID') //数字型
->setCellValue( 'D1', '员工姓名') //
->setCellValue( 'E1', '点赞量' ) //
->setCellValue( 'F1', '视频ID' ) //
->setCellValue( 'G1', '发布日期');
$objPHPExcel->getActiveSheet()->getStyle('E')->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
$objPHPExcel->getActiveSheet()->getStyle('F')->getNumberFormat()
->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
$num = 0;
//$sql_douyin_aweme = "select * from douyin_aweme where company_id=1 and digg_count>=200 and create_time>=".strtotime($start_date)." and create_time <= ".strtotime($end_date)." and is_ad=1 order by admin_user_id asc";
// $res = mysqli_query($conn,$sql);
$step_num = 2;
foreach($request_douyin_aweme as $k=>$row){
//while($row = mysqli_fetch_assoc($res)){
$author_short_id = $row['author_short_id'];
$admin_user_id = $row['admin_user_id'];
$author_name = '-';
$admin_user_name = '-';
$author_info = weijinci::select("select * from douyin_user where short_id=" . $author_short_id,'weijinci');
if (!empty($author_info)) {
foreach($author_info as $k=>$r):
$author_name = $r['nickname'];
$sql3="'select * from pub_user where id=' . $admin_user_id";
print $sql3;
$admin_user_info = weijinci::select("select * from pub_user where id=" . $admin_user_id,'weijinci');
print $admin_user_info;
if(!empty($admin_user_info)){
foreach($admin_user_info as $k=>$r1):
$admin_user_name = $r1['user_name'];
/*$log_s = $author_short_id."@@".$author_name."@@".$admin_user_id.'@@'.$admin_user_name.'@@'.$row['digg_count'].'@@'.$row['aweme_id']."@@".date("Y-m-d H:i:s",$row['create_time'])."\n";
file_put_contents("money_stat.txt",$log_s,FILE_APPEND);*/
$num++;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( 'A'.$step_num,$author_short_id);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( 'B'.$step_num,$author_name);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( 'C'.$step_num,$admin_user_id);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( 'D'.$step_num,$admin_user_name);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( 'E'.$step_num,$row['digg_count']);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( 'F'.$step_num,$row['aweme_id'],PHPExcel_Cell_DataType::TYPE_STRING);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( 'G'.$step_num,date("Y-m-d H:i:s",$row['create_time']));
endforeach;}
endforeach;}
}
foreach($request_douyin_aweme_patch as $k=>$row){
$step_num++;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( 'A'.$step_num,$row['douyin_id']);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( 'B'.$step_num,$row['douyin_name']);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( 'C'.$step_num,$row['admin_user_id']);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( 'D'.$step_num,$row['admin_user_name']);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( 'E'.$step_num,$row['dianzan']);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( 'F'.$step_num,$row['id'],PHPExcel_Cell_DataType::TYPE_STRING);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( 'G'.$step_num,$row['pub_date']);
$step_num++;
}
$objActSheet = $objPHPExcel->getActiveSheet()->setTitle('抖音、快手、火山、微视、小红书');
$file_name = 'a2.xlsx';
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="'.$file_name.'"');
header('Cache-Control: max-age=0');
// $objWriter = PHPExcel_IOFactory:: createWriter($objPHPExcel, 'Excel2007');
$objWriter = PHPExcel_IOFactory:: createWriter($objPHPExcel, 'Excel5');
$objWriter->save( 'php://output');
exit;
echo $num."\n";
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>显示 <?php echo $last_date;?> 数据 - 抖音数据平台</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="yes" name="apple-touch-fullscreen">
<link rel="stylesheet" type="text/css" media="all" href="/static/css/back.css?v=6"/>
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/jquery.form.js"></script>
<style type="text/css">
td.u_do a{font-size:16px;}
.footer{width: 90%;margin: 0px auto;text-align: center;padding: 30px 0;}
.dy_img_gif{width:100px;}
p.top1{color:red;}
p.top2{color:blue;}
p.top3{color:green;}
.company_info_class{padding-top:10px;}
.company_info_class span{padding-right:10px;font-weight:bold;font-size: 16px;}
.button2 {
display: inline-block;
position: relative;
padding: 0 20px;
text-align: center;
text-decoration: none;
font: bold 12px/25px Arial, sans-serif;
}
input{height:auto;}
.show_num{font-size:16px;font-weight:bold;color:red;}
</style>
<script type="text/javascript">
function save_nm() {
$("#uploadform").ajaxSubmit(function(message) {
var h = eval('(' + message + ')');
if(h.code == 1 || h.code == 2){
alert(h.msg);
location.href = '/douyin/day_report.php?reload';
}else if(h.code > 0){
alert(h.msg);
}else{
alert(h.msg);
}
});
return false;
}
</script>
</head>
<body>
<?php include(dirname(__FILE__).'/_block_header.php');?>
<div style="margin:20px;font-size:16px;">
<a style="padding:5px 20px;font-size:16px;" href="/paiming/examine1.php?act=download&start_date=<?php echo $start_date;?>&end_date=<?php echo $end_date;?>" target="_blank">点此下载数据</a>
<br />
</div>
<form action="#" method="get" style="margin-left: 1200px; "><!--表单-->
<input type="date" name="start_date" />至 <input type="date" name="end_date" />
<input type="submit" value="搜索"/>
</form>
<table width="95%" style="margin:10px 20px;">
<tr>
<th>抖音ID</th>
<th>抖音名称</th>
<th>员工id</th>
<th>员工姓名</th>
<th>点赞量</th>
<th>视频id</th>
<th>发布日期</th>
</tr>
<!--sql1-->
<?php foreach($request_douyin_aweme as $k=>$row):
$author_short_id = $row['author_short_id'];
$admin_user_id = $row['admin_user_id'];
$author_name = '-';
$admin_user_name = '-';
$author_info = weijinci::select("select * from douyin_user where short_id=" . $author_short_id,'weijinci');
if (!empty($author_info)) {
foreach($author_info as $k=>$r):
$author_name = $r['nickname'];
endforeach;
}
$admin_user_info = weijinci::select("select * from pub_user where id=" . $admin_user_id,'weijinci');
if(!empty($admin_user_info)){
foreach($admin_user_info as $k=>$r):
$admin_user_name = $r['user_name'];
endforeach;
}
//$log_s = $author_short_id."@@".$author_name."@@".$admin_user_id.'@@'.$admin_user_name.'@@'.$row['digg_count'].'@@'.$row['aweme_id']."@@".date("Y-m-d H:i:s",$row['create_time'])."\n";
// file_put_contents("money_stat.txt",$log_s,FILE_APPEND);
?>
<tr <?php echo $k%2!=0?'style="background-color:#CDE2F8"':'';?>>
<td><?php echo $author_short_id;?></td><!--抖音id-->
<td><?php echo $author_name;?></td><!--抖音名称-->
<td><?php echo $admin_user_id;?></td><!--员工id-->
<td><?php echo $admin_user_name;?></td><!--员工姓名-->
<td> <?php echo $row['digg_count'];?> </td><!--点赞量-->
<td> <?php echo $row['aweme_id'];?> </td><!--视频id-->
<td><?php echo date("Y-m-d H:i",$row['create_time']);?></td><!--发布日期-->
</tr>
<?php endforeach;?>
<?php foreach($request_douyin_aweme_patch as $k=>$v):
?>
<tr <?php echo $k%2!=0?'style="background-color:#CDE2F8"':'';?>>
<td><?php echo $v['douyin_id'];?></td><!--抖音id-->
<td><?php echo $v['douyin_name'];?></td><!--抖音名称-->
<td><?php echo $v['admin_user_id'];?></td><!--员工id-->
<td><?php echo $v['admin_user_name'];?></td><!--员工姓名-->
<td> <?php echo $v['dianzan'];?> </td><!--点赞量-->
<td> <?php echo $v['id'];?> </td><!--视频id-->
<td><?php echo date("Y-m-d H:i",$v['pub_date']);?></td><!--发布日期-->
</tr>
<?php endforeach;?>
</table>
<div class="footer">
<a href="/">首页</a> |
<a href="javascript:alert('天天出爆文!')">关于我们</a> |
<a href="/pub/account_edit.php">修改密码</a>
</div>
<?php include(dirname(__FILE__).'/_block_footer.php');?>
</body></html>
php生成exl
最新推荐文章于 2021-04-10 00:57:03 发布