<?php
|
include_once "/Common/Logging.php";
|
include_once "/Account/User.php";
|
include_once "/language/lang.php";
|
include_once "/serverrep/report.php";
|
|
\Logging\CreateLogging("rep.dailyuser.php");
|
$Permission = \User\Permission::P_REP_DailyUser;
|
|
$alertMsg = "";
|
$channel = $_SESSION['spid'];
|
$UserAccount = $_SESSION['UserAccount'];
|
$user = new \User\User($UserAccount);
|
if (!$user->HavePermission($Permission)) {
|
exit;
|
}
|
|
$startDate = array_key_exists("startDate", $_POST) ? $_POST["startDate"] : date("Y-m-d", strtotime("-30 days"));
|
$endDate = array_key_exists("endDate", $_POST) ? $_POST["endDate"] : date("Y-m-d");
|
|
$reportDict = \Report\GetDailyReport($channel, $startDate, $endDate, true);
|
|
$showTime = strtotime($startDate);
|
$endTime = strtotime($endDate);
|
|
$showLabelInfo = array(
|
"活跃用户DAU" => "DAU",
|
"新增用户DNU" => "DNU",
|
"充值用户DPU" => "DPU",
|
"新增充值用户DNPU" => "DNPU",
|
);
|
$xLabels = array(); // x轴为日期
|
$dataArray = array();
|
|
$doCount = 0;
|
while ($showTime <= $endTime && $doCount < 1440) {
|
$doCount += 1;
|
$dateStr = date("Y-m-d", $showTime);
|
array_push($xLabels, $dateStr);
|
foreach ($showLabelInfo as $key => $value) {
|
if (!isset($dataArray[$key])) {
|
$dataArray[$key] = array();
|
}
|
$dataList = $dataArray[$key];
|
array_push($dataList, $reportDict[$dateStr] ? $reportDict[$dateStr][$value] : 0);
|
$dataArray[$key] = $dataList;
|
}
|
$showTime = strtotime("+1 day", $showTime);
|
}
|
?>
|
|
<!DOCTYPE html>
|
<html>
|
|
<head>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<title><?php echo \Lang\gettext("全服每日用户"); ?></title>
|
<link rel="gettext" type="application/x-po" href="../language/<?php echo \Lang\getLang(); ?>/LC_MESSAGES/<?php echo \Lang\getjspodomain(); ?>.po" />
|
</head>
|
|
<body>
|
<center>
|
<p><b><?php echo \Lang\gettext("全服每日用户"); ?></b></P>
|
</center>
|
<form method="post">
|
<?php echo \Lang\gettext("查询时间"); ?>:
|
<input type="text" name="startDate" id="startDate" onclick="new Calendar().show(this);" readonly value="<?php echo $startDate; ?>" size="8" />
|
~
|
<input type="text" name="endDate" id="endDate" onclick="new Calendar().show(this);" readonly value="<?php echo $endDate; ?>" size="8" />
|
<input type="submit" value="<?php echo \Lang\gettext("查询"); ?>" />
|
<hr />
|
<div id="MyChart"></div>
|
<hr />
|
</form>
|
</body>
|
<script type='text/javascript' src='/language/gettext.js'></script>
|
<script type='text/javascript' src="/js/calendar.js"></script>
|
<script type='text/javascript' src="/js/common.js"></script>
|
<script type='text/javascript' src="/js/chart.min.js"></script>
|
<script type="text/javascript">
|
window.onload = function() {
|
let chartID = "myChart0";
|
let insHtml = "";
|
// insHtml += "<hr />";
|
insHtml += "<canvas id=\"" + chartID + "\" ></canvas>"; // 插入画布
|
document.getElementById("MyChart").insertAdjacentHTML("beforeEnd", insHtml);
|
|
var xLabels = JSON.parse('<?php echo json_encode($xLabels); ?>');
|
var dataArray = JSON.parse('<?php echo json_encode($dataArray); ?>');
|
const chartText = "每日用户数";
|
const xText = "日期";
|
const yText = "人数";
|
drawChart_Line(chartID, chartText, xText, yText, xLabels, Object.values(dataArray), Object.keys(dataArray));
|
}
|
</script>
|
|
</html>
|