Added statistics for number of days qrv each year.

pull/475/head
AndreasK79 2020-04-24 23:29:01 +02:00
rodzic 93b7100c51
commit 6dcdcca0bf
5 zmienionych plików z 141 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,38 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Dayswithqso extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->model('user_model');
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
}
public function index()
{
$this->load->model('dayswithqso_model');
// Render Page
$data['page_title'] = "Number of days with QSOs each year";
$data['result'] = $this->dayswithqso_model->getDaysWithQso();
$this->load->view('interface_assets/header', $data);
$this->load->view('dayswithqso/index');
$this->load->view('interface_assets/footer');
}
public function get_days(){
//load model
$this->load->model('dayswithqso_model');
// get data
$data = $this->dayswithqso_model->getDaysWithQso();
header('Content-Type: application/json');
echo json_encode($data);
}
}

Wyświetl plik

@ -0,0 +1,27 @@
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Dayswithqso_model extends CI_Model
{
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function getDaysWithQso()
{
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
$sql = "select year(col_qso_date) Year, count(distinct col_qso_date) Days from "
.$this->config->item('table_name'). " thcv
where station_id = " . $station_id . " and col_qso_date is not null group by year";
$query = $this->db->query($sql);
return $query->result();
}
}

Wyświetl plik

@ -0,0 +1,33 @@
<div class="container">
<br>
<h2><?php echo $page_title; ?></h2>
<?php
if (is_array($result)) {
echo '<div id="diffDays" class="table-responsive"><table class="qsotable table table-bordered table-hover table-striped table-condensed">';
echo '<tr>';
echo '<th style=\'text-align: center\'>Year</th>';
foreach ($result as $master) {
echo '<td style=\'text-align: center\'>' . $master->Year . '</td>';
}
echo '</tr>';
echo '<tr>';
echo '<th style=\'text-align: center\'>Days</th>';
foreach ($result as $master) {
echo '<td style=\'text-align: center\'>' . $master->Days . '</td>';
}
echo '</tr>';
echo '</table></div>';
}
?>
<canvas id="myChartDiff" width="400" height="150"></canvas>
</div>

Wyświetl plik

@ -1013,6 +1013,47 @@ $(document).ready(function(){
</script>
<?php } ?>
<?php if ($this->uri->segment(1) == "dayswithqso") { ?>
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
<script>
var baseURL= "<?php echo base_url();?>";
$.ajax({
url: baseURL+'index.php/dayswithqso/get_days',
success: function(data) {
var labels = [];
var dataDxcc = [];
$.each(data, function(){
labels.push(this.Year);
dataDxcc.push(this.Days);
});
var ctx = document.getElementById("myChartDiff").getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: labels,
datasets: [{
label: 'Days with QSOs',
data: dataDxcc,
backgroundColor: 'rgba(54, 162, 235, 0.2)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 2
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
},
}
});
}
});
</script>
<?php } ?>
<?php if ($this->uri->segment(1) == "distances") { ?>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script>

Wyświetl plik

@ -70,6 +70,8 @@
<a class="dropdown-item" href="<?php echo site_url('gridsquares');?>" title="Gridsquares">Gridsquares</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('distances');?>" title="Distances">Distances worked</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('dayswithqso');?>" title="Distances">Days with QSOs</a>
</div>
</li>