forked from kkaiser1952/NCM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetTimeLog.php
77 lines (63 loc) · 2.35 KB
/
getTimeLog.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
75
76
77
<?php
// This PHP only reads whats in the TimeLog table it does
// not write to it. TimeLog is written to by save.php, in
// this case when the comments column is modified.
require_once "dbConnectDtls.php";
$q = intval($_GET['q']);
//$q = 1932;
/*
$header = '<table class="sortable2" id="pretimeline" style="width:100%;">
<thead>
<tr>
<th>Date Time</th>
<th>ID</th>
<th>Callsign</th>
<th style="width:1400px; max-width:1400px;">Report</th>
</tr>
</thead>
<tbody>';
*/
try { // Get the start time of the net
$sql = $db_found->prepare("SELECT min(logdate) as minTime from NetLog where netID = '$q' limit 1" );
$sql->execute();
$ts = $sql->fetchColumn();
// Now get the specifics from the Time Log
$sql = $db_found->prepare("SELECT count(*) as maxCount FROM TimeLog WHERE netID = '$q' limit 1" );
$sql->execute();
$maxCount = $sql->fetchColumn()+1;
//echo "$maxCount";
// Creating the tbody here allows us to count down from the max to 0 at the bottom of the time line display
$tbody = "<tbody style=\"counter-reset: sortabletablescope $maxCount;\">";
//echo "$tbody";
$header = '<table class="sortable2" id="pretimeline" style="width:100%;">
<thead>
<tr>
<th>Date Time</th>
<th>ID</th>
<th>Callsign</th>
<th style="width:1400px; max-width:1400px;">Report</th>
</tr>
</thead> ';
$sql = "SELECT timestamp, ID, callsign, comment from TimeLog where netID = '$q' ORDER BY timestamp DESC";
echo ("$header");
echo ("$tbody");
foreach($db_found->query($sql) as $row) {
// To make the comments <td> scrollable but still stay at the default height if is not needed
// this code checks if there are commets and changes the class name, a simple solution.
$class = empty($row[comments]) ? 'nonscrollable' : 'scrollable' ;
$class = strlen($row[comments]) < 300 ? 'nonscrollable' : 'scrollable' ;
echo ("<tr>");
echo ("<td nowrap>$row[timestamp]</td>");
echo ("<td>$row[ID]</td>");
echo ("<td>$row[callsign]</td>");
echo ("<td><div class='$class'>$row[comment]</div></td>");
echo ("</tr>");
}
echo ("<tr><td>$ts</td>");
echo ("<td>$id</td> <td>$cs1</td> <td>Start of Net</td>");
echo ("</tr></tbody></table>");
}
catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
?>