Improvements to the Dashboard

pull/106/merge
Peter Goodhall 2011-09-21 22:17:24 +01:00
rodzic 5c8fd2ddfe
commit 376874bee7
4 zmienionych plików z 191 dodań i 78 usunięć

Wyświetl plik

@ -35,6 +35,11 @@ class Dashboard extends CI_Controller {
$data['total_fm'] = $this->logbook_model->total_fm();
$data['total_digi'] = $this->logbook_model->total_digi();
$data['total_countrys'] = $this->logbook_model->total_countrys();
$data['total_qsl_sent'] = $this->logbook_model->total_qsl_sent();
$data['total_qsl_recv'] = $this->logbook_model->total_qsl_recv();
$data['total_bands'] = $this->logbook_model->total_bands();
$data['last_five_qsos'] = $this->logbook_model->get_last_qsos('9');
@ -45,6 +50,45 @@ class Dashboard extends CI_Controller {
$this->load->view('layout/footer');
}
function map() {
$this->load->model('logbook_model');
//echo date('Y-m-d')
$raw = strtotime('Monday last week');
$mon = date('Y-m-d', $raw);
$sun = date('Y-m-d', strtotime('Sunday this week'));
$qsos = $this->logbook_model->map_week_qsos($mon, $sun);
echo "{\"markers\": [";
foreach ($qsos->result() as $row) {
//print_r($row);
if($row->COL_GRIDSQUARE != null) {
$stn_loc = qra2latlong($row->COL_GRIDSQUARE);
echo "{\"point\":new GLatLng(".$stn_loc[0].",".$stn_loc[1]."), \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"},";
} else {
$query = $this->db->query('
SELECT *
FROM dxcc
WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) )
ORDER BY LENGTH( prefix ) DESC
LIMIT 1
');
foreach ($query->result() as $dxcc) {
echo "{\"point\":new GLatLng(".$dxcc->lat.",".$dxcc->long."), \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"},";
}
}
}
echo "]";
echo "}";
}
function todays_map() {
$this->load->model('logbook_model');
@ -78,6 +122,7 @@ class Dashboard extends CI_Controller {
echo "}";
}
}
function distance($lat1, $lon1, $lat2, $lon2, $unit = 'M') {

Wyświetl plik

@ -199,10 +199,11 @@ class Logbook_model extends CI_Model {
}
}
function get_this_weeks_qsos() {
$morning = date('Y/m/d',time()+(date('w'))*24*3600);
$night = date('Y/m/d',time()+( 7 - date('w'))*24*3600);
$query = $this->db->query('SELECT * FROM '.$this->config->item('table_name').' WHERE COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\'');
function map_week_qsos($start, $end) {
$this->db->where("COL_TIME_ON BETWEEN '".$start."' AND '".$end."'");
$this->db->order_by("COL_TIME_ON", "ASC");
$query = $this->db->get($this->config->item('table_name'));
return $query;
}
@ -299,6 +300,36 @@ class Logbook_model extends CI_Model {
return $query;
}
function total_qsl_sent() {
$query = $this->db->query('SELECT DISTINCT (COL_QSL_SENT) AS band, count(COL_QSL_SENT) AS count FROM '.$this->config->item('table_name').' WHERE COL_QSL_SENT = "Y" GROUP BY band');
$row = $query->row();
if($row == null) {
return 0;
} else {
return $row->count;
}
}
function total_qsl_recv() {
$query = $this->db->query('SELECT DISTINCT (COL_QSL_RCVD) AS band, count(COL_QSL_RCVD) AS count FROM '.$this->config->item('table_name').' WHERE COL_QSL_RCVD = "Y" GROUP BY band');
$row = $query->row();
if($row == null) {
return 0;
} else {
return $row->count;
}
}
function total_countrys() {
$query = $this->db->query('SELECT DISTINCT (COL_COUNTRY) FROM '.$this->config->item('table_name').'');
return $query->num_rows();
}
function api_search_query($query) {
$time_start = microtime(true);

Wyświetl plik

@ -49,7 +49,7 @@
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('modechart_div'));
chart.draw(data, {width: 310, height: 240});
chart.draw(data, {width: 280, height: 240, title: 'Total QSOs by Mode'});
}
function drawBandChart() {
@ -68,7 +68,7 @@
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('bandchart_div'));
chart.draw(data, {width: 310, height: 240});
chart.draw(data, {width: 280, height: 240, title: 'Total QSOs by Band'});
}
</script>
@ -79,50 +79,99 @@
</div>
<?php } ?>
<h2>Dashboard</h2>
<div class="wrap_content">
<div class="wrap_content dashboard">
<div id="map" style="width: 100%; height: 300px"></div>
<div id="dashboard_container">
<div class="dashboard_top">
<div class="dashboard_log">
<table class="logbook" width="100%">
<tr class="log_title titles">
<td>Date</td>
<td>Time</td>
<td>Call</td>
<td>Mode</td>
<td>Sent</td>
<td>Recv</td>
<td>Band</td>
</tr>
<?php $i = 0;
foreach ($last_five_qsos->result() as $row) { ?>
<?php echo '<tr class="tr'.($i & 1).'">'; ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('d/m/y', $timestamp); ?></td>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td>
<td><a class="qsobox" href="<?php echo site_url('logbook/view')."/".$row->COL_PRIMARY_KEY; ?>"><?php echo strtoupper($row->COL_CALL); ?></a></td>
<td><?php echo $row->COL_MODE; ?></td>
<td><?php echo $row->COL_RST_SENT; ?></td>
<td><?php echo $row->COL_RST_RCVD; ?></td>
<?php if($row->COL_SAT_NAME != null) { ?>
<td>SAT</td>
<?php } else { ?>
<td><?php echo $row->COL_BAND; ?></td>
<?php } ?>
</tr>
<?php $i++; } ?>
</table>
</div>
<div class="dashboard_breakdown">
<table width="100%">
<tr class="dashboard_tr">
<td class="item">Total QSOs</td>
<td class="item"><?php echo $total_qsos; ?></td>
</tr>
<tr class="dashboard_tr">
<td class="item">QSOs This Year</td>
<td class="item"><?php echo $year_qsos; ?></td>
</tr>
<tr class="dashboard_tr">
<td class="item">QSOs This Month</td>
<td class="item"><?php echo $month_qsos; ?></td>
</tr>
<tr class="dashboard_tr">
<td class="item"> </td>
<td class="item"></td>
</tr>
<tr class="dashboard_tr">
<td class="item">Countrys Worked</td>
<td class="item"><?php echo $total_countrys; ?></td>
</tr>
<tr class="dashboard_tr">
<td class="item"> </td>
<td class="item"></td>
</tr>
<tr class="dashboard_tr">
<td class="item">QSL Cards Sent</td>
<td class="item"><?php echo $total_qsl_sent; ?></td>
</tr>
<tr class="dashboard_tr">
<td class="item">QSL Cards Received</td>
<td class="item"><?php echo $total_qsl_recv; ?></td>
</tr>
</table>
</div>
<div class="clear"></div>
</div>
<!-- <div class="dashboard_bottom">
<div class="chart" id="modechart_div"></div>
<div class="chart" id="bandchart_div"></div>
</div> -->
</div>
<div class="clear"></div>
<div class="dash_left">
<h3>Latest QSOs</h3>
<table class="logbook" width="100%">
<tr class="log_title titles">
<td>Date</td>
<td>Time</td>
<td>Call</td>
<td>Mode</td>
<td>Sent</td>
<td>Recv</td>
<td>Band</td>
</tr>
<?php $i = 0;
foreach ($last_five_qsos->result() as $row) { ?>
<?php echo '<tr class="tr'.($i & 1).'">'; ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('d/m/y', $timestamp); ?></td>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td>
<td><a class="qsobox" href="<?php echo site_url('logbook/view')."/".$row->COL_PRIMARY_KEY; ?>"><?php echo strtoupper($row->COL_CALL); ?></a></td>
<td><?php echo $row->COL_MODE; ?></td>
<td><?php echo $row->COL_RST_SENT; ?></td>
<td><?php echo $row->COL_RST_RCVD; ?></td>
<?php if($row->COL_SAT_NAME != null) { ?>
<td>SAT</td>
<?php } else { ?>
<td><?php echo $row->COL_BAND; ?></td>
<?php } ?>
</tr>
<?php $i++; } ?>
</table>
<h3>Todays QSOs</h3>
<div id="map" style="width: 420px; height: 300px"></div>
<noscript><b>JavaScript must be enabled in order for you to use Google Maps.</b>
However, it seems JavaScript is either disabled or not supported by your browser.
To view Google Maps, enable JavaScript by changing your browser options, and then
try again.
</noscript>
<script type="text/javascript">
@ -132,7 +181,7 @@
var map = new GMap(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(33.137551,0.703125),1);
map.setCenter(new GLatLng(33.137551,0.703125),2);
// arrays to hold copies of the markers and html used by the side_bar
// because the function closure trick doesnt work there
@ -184,7 +233,7 @@
// ================================================================
// === Fetch the JSON data file ====
GDownloadUrl("<?php echo site_url('/dashboard/todays_map'); ?>", process_it);
GDownloadUrl("<?php echo site_url('/dashboard/map'); ?>", process_it);
// ================================================================
}
@ -202,30 +251,7 @@
</script>
</div>
<div class="dash_sidebar">
<h3>Overview of QSOs</h3>
<table width="100%">
<tr>
<td>Total QSOs</td>
<td><?php echo $total_qsos; ?></td>
</tr>
<tr>
<td>QSOs This Month</td>
<td><?php echo $month_qsos; ?></td>
</tr>
<tr>
<td>QSOs This Year</td>
<td><?php echo $year_qsos; ?></td>
</tr>
</table>
<h3>QSOs by Mode</h3>
<div id="modechart_div"></div>
<h3>QSOs by Band</h3>
<div id="bandchart_div"></div>
</div>
<div class="clear"></div>
</div>

Wyświetl plik

@ -82,7 +82,7 @@ ul#user li { float: left; margin: 2px 2px 0 3px; height:43px; border-bottom: non
#message p { line-height: 1.7; margin: 0px 0; }
.clear { clear: both; }
h2 { margin: 0 auto; width: 780px; font-weight: bold; font-size: 23px; margin-top: 5px; margin-bottom: 10px; }
h3 { font-weight: bold; font-size: 16px; margin: 5px; }
h3 { font-weight: bold; font-size: 16px; margin: 5px; margin-left: 0px; }
table .titles { font-weight: bold; }
#tabs { margin: 5px; }
@ -99,8 +99,6 @@ table .titles { font-weight: bold; }
#name { width: 145px; }
#comment { width: 89.5%; }
.dash_left { float: left; width: 440px; }
.dash_sidebar { float: right; width: 310px; }
.note { padding: 5px; }
.auth { padding: 5px; }
#notes_add { padding: 5px; }
@ -138,9 +136,22 @@ border-radius: 10px;
.contest_qso_box table {
width: 695px;
}
td.item {
padding-bottom: 5px;
}
.dashboard {
padding: 5px;
}
.dashboard_top { margin-top: 5px; }
.dashboard_log { float: left; width: 440px; }
.dashboard_breakdown { float: right; width: 310px; }
.dashboard_bottom .chart { float: left; }
</style>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo $this->config->item('google_maps_api'); ?>&sensor=true"
<script src="http://maps.google.com/maps?file=api&amp;v=3&amp;key=<?php echo $this->config->item('google_maps_api'); ?>&sensor=true"
type="text/javascript"></script>
</head>