mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
[QSOs] Added QSOs per month
This commit is contained in:
@@ -48,4 +48,14 @@ class Dayswithqso extends CI_Controller {
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
public function get_months() {
|
||||
//load model
|
||||
$this->load->model('dayswithqso_model');
|
||||
|
||||
// get data
|
||||
$data = $this->dayswithqso_model->getMonthsOfYear();
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -200,4 +200,31 @@ class Dayswithqso_model extends CI_Model
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the total number of QSOs made for each day of the week (Monday to Sunday)
|
||||
*/
|
||||
function getMonthsOfYear() {
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
if (!$logbooks_locations_array) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||
|
||||
$sql = "SELECT MONTHNAME(col_time_off) AS month, COUNT(*) AS qsos
|
||||
FROM " . $this->config->item('table_name') . "
|
||||
WHERE MONTH(col_time_off) BETWEEN 1 AND 12
|
||||
AND station_id IN (" . $location_list . ")
|
||||
GROUP BY month
|
||||
ORDER BY FIELD(month, 'January', 'February', 'March', 'April', 'May', 'June',
|
||||
'July', 'August', 'September', 'October', 'November', 'December')";
|
||||
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="daysofweek-tab" data-bs-toggle="tab" href="#daysofweek" role="tab" aria-controls="daysofweek" aria-selected="false"><?= __("Days of the week"); ?></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="monthsofyear-tab" data-bs-toggle="tab" href="#monthsofyear" role="tab" aria-controls="monthsofyear" aria-selected="false"><?= __("Months of the year"); ?></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="streaks-tab" data-bs-toggle="tab" href="#streaks" role="tab" aria-controls="streaks" aria-selected="false"><?= __("Streaks"); ?></a>
|
||||
</li>
|
||||
@@ -61,6 +64,12 @@
|
||||
<canvas id="weekdaysChart" width="400" height="150"></canvas>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="monthsofyear" role="tabpanel" aria-labelledby="monthsofyear-tab">
|
||||
<br/>
|
||||
<h3><?= __('QSOs breakdown by month of the year'); ?></h3>
|
||||
<canvas id="monthChart" width="400" height="150"></canvas>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="streaks" role="tabpanel" aria-labelledby="streaks-tab">
|
||||
<br/>
|
||||
<h2><?= __("Longest streak with QSOs in the log"); ?></h2>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
daysPerYear();
|
||||
weekDays();
|
||||
months();
|
||||
|
||||
function daysPerYear() {
|
||||
$.ajax({
|
||||
@@ -108,3 +109,57 @@ function weekDays() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function months() {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/dayswithqso/get_months',
|
||||
success: function (data) {
|
||||
if ($.trim(data)) {
|
||||
var labels = [];
|
||||
var dataDays = [];
|
||||
$.each(data, function () {
|
||||
labels.push(this.month);
|
||||
dataDays.push(this.qsos);
|
||||
});
|
||||
var ctx = document.getElementById("monthChart").getContext('2d');
|
||||
var color = ifDarkModeThemeReturn('white', 'grey');
|
||||
var myChart = new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: lang_qsos_this_weekday,
|
||||
data: dataDays,
|
||||
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
||||
borderColor: 'rgba(54, 162, 235, 1)',
|
||||
borderWidth: 2,
|
||||
color: color
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
y: {
|
||||
ticks: {
|
||||
beginAtZero: true,
|
||||
color: color
|
||||
}
|
||||
},
|
||||
x: {
|
||||
ticks: {
|
||||
color: color
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
legend: {
|
||||
labels: {
|
||||
color: color
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user