forked from kkaiser1952/NCM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNCMStatsTT.php
74 lines (65 loc) · 2.24 KB
/
NCMStatsTT.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
function convertSecToTime($sec)
{
$date1 = new DateTime("@0");
$date2 = new DateTime("@$sec");
$interval = date_diff($date1, $date2);
$parts = ['years' => 'y', 'months' => 'm', 'days' => 'd', 'hours' => 'h', 'min.' => 'i', 'sec.' => 's'];
$formatted = [];
foreach($parts as $i => $part)
{
$value = $interval->$part;
if ($value !== 0)
{
if ($value == 1){
$i = substr($i, 0, -1);
}
$formatted[] = "$value $i";
}
}
if (count($formatted) == 1)
{
return $formatted[0];
}
else
{
$str = implode(', ', array_slice($formatted, 0, -1));
$str.= ' and ' . $formatted[count($formatted) - 1];
return $str;
}
}
//echo convertSecToTime( 175926108);
require_once "dbConnectDtls.php";
// Logins 10519 newb 559 netCnt 709 allCnt 283940 TOD 838:59:59
$stmt = $db_found->prepare("
SELECT COUNT( DISTINCT callsign ) AS cscount
,COUNT( callsign ) AS callsigns
,COUNT( IF(comments LIKE '%first log in%',1,NULL) ) AS newb
,COUNT( DISTINCT netID ) AS netCnt
,COUNT( DISTINCT grid ) AS gridCnt
,COUNT( DISTINCT county ) AS countyCnt
,COUNT( DISTINCT state ) AS stateCnt
,max(recordID) AS records
,SUM(timeonduty) AS TOD
FROM NetLog
WHERE netID <> 0
AND activity NOT LIKE '%TEST%'
";
$stmt->execute();
$result = $stmt->fetch();
$callsigns = $result[callsigns];
$newb = $result[newb];
$netCnt = $result[netCnt];
$records = $result[records];
$cscount = $result[cscount];
$gridcount = $result[gridCnt];
$countycount= $result[countyCnt];
$statecount = $result[stateCnt];
$tod = $result[TOD];
$volHours = convertSecToTime($tod);
$sql3 = "SELECT count(DISTINCT org) as orgCnt FROM `NetKind`";
$stmt = $db_found->prepare($sql3);
$stmt -> execute();
$orgCnt = $stmt->fetchColumn(0);
// echo "$cscount Stations, $netCnt Nets, $records Logins, $volHours of Volunteer Time";
?>