<?php
$conf_basedir	= "../../";	//相对主目录的位置
$conf_where		= "admin";	//选择调用相应模块
//$directory		= basename(dirname(__FILE__));	//定义当前所在的目录，引入模块公用函数
include_once($conf_basedir."base.inc.php");
checkAuth('41');	//判断登录和权限
$title = "图片质量监控";

$dateline = date("Ym1", strtotime("-1 month"));

if($action == 'exportcsv')
{
	$dateline1 = date("Ym1");
	$sql = "select dateline,from_device_num,write_list_num,in_num,surface_num,pass_num,del_num,frez_num,in_sort0_num,in_sort1_num,in_sort2_num from admin_pic_total_stat where (dateline >= '".$dateline."' and dateline < '".$dateline1."') order by id asc limit 31";
}
else
{
	$dateline1 = date("Ymd");
	$sql = "select dateline,from_device_num,write_list_num,in_num,surface_num,pass_num,del_num,frez_num from admin_pic_total_stat where (dateline >= '".$dateline."' and dateline < '".$dateline1."') order by id desc limit 62";
}
$data_arr = $dbback->GetAll($sql);

$data_info = array();
if($data_arr)
{
	$temp = 0;
	foreach($data_arr as $key=>$val)
	{
		$data_info[$key]['dateline'] = $val['dateline'];
		$data_info[$key]['totalnum'] = $val['from_device_num'] + $val['write_list_num'] + $val['in_num'] + $val['surface_num'];
		$data_info[$key]['from_device_num'] = $val['from_device_num'];
		$data_info[$key]['write_list_num'] = $val['write_list_num'];
		$data_info[$key]['in_num'] = $val['in_num'] + $val['surface_num'];

		$total_deal_num = $val['pass_num'] + $val['del_num'] + $val['frez_num'];
		$total_deal_num = $total_deal_num == 0 ? 1 : $total_deal_num;

		$data_info[$key]['pass_num'] = $val['pass_num'];
		$data_info[$key]['pass_num_p'] = $val['pass_num'] / $total_deal_num * 100;
		$data_info[$key]['pass_num_p'] = number_format($data_info[$key]['pass_num_p'], 2, '.', '')."%";

		$data_info[$key]['del_num'] = $val['del_num'];
		$data_info[$key]['del_num_p'] = $val['del_num'] / $total_deal_num * 100;
		$data_info[$key]['del_num_p'] = number_format($data_info[$key]['del_num_p'], 2, '.', '')."%";

		$data_info[$key]['frez_num'] = $val['frez_num'];
		$data_info[$key]['frez_num_p'] = $val['frez_num'] / $total_deal_num * 100;
		$data_info[$key]['frez_num_p'] = number_format($data_info[$key]['frez_num_p'], 2, '.', '')."%";
	}
}


//引用模版文件
include_once(Template("header"));
include_once(Template("house_statistic/pic_audit"));
include_once(Template("footer"));
?>