2023-10-30 12:15:08 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
class Setup_model extends CI_Model {
|
|
|
|
|
|
|
|
|
|
function getCountryCount() {
|
2023-10-31 08:29:12 +01:00
|
|
|
$sql = 'select count(*) as count from dxcc_entities';
|
|
|
|
|
$query = $this->db->query($sql);
|
2023-10-30 12:15:08 +01:00
|
|
|
|
2023-10-31 08:29:12 +01:00
|
|
|
return $query->row()->count;
|
2023-10-30 12:15:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getLogbookCount() {
|
|
|
|
|
$userid = xss_clean($this->session->userdata('user_id'));
|
2025-12-20 21:50:21 +00:00
|
|
|
// Count logbooks the user owns OR has been granted permissions to
|
|
|
|
|
$sql = "SELECT COUNT(DISTINCT sl.logbook_id) AS count
|
|
|
|
|
FROM station_logbooks sl
|
|
|
|
|
LEFT JOIN station_logbooks_permissions slp
|
|
|
|
|
ON slp.logbook_id = sl.logbook_id AND slp.user_id = {$userid}
|
|
|
|
|
WHERE sl.user_id = {$userid} OR slp.user_id = {$userid}";
|
2023-10-31 08:29:12 +01:00
|
|
|
$query = $this->db->query($sql);
|
2023-10-30 12:15:08 +01:00
|
|
|
|
2023-10-31 08:29:12 +01:00
|
|
|
return $query->row()->count;
|
2023-10-30 12:15:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getLocationCount() {
|
|
|
|
|
$userid = xss_clean($this->session->userdata('user_id'));
|
2023-10-31 08:29:12 +01:00
|
|
|
$sql = 'select count(*) as count from station_profile where user_id =' . $userid;
|
|
|
|
|
$query = $this->db->query($sql);
|
2023-10-30 12:15:08 +01:00
|
|
|
|
2023-10-31 08:29:12 +01:00
|
|
|
return $query->row()->count;
|
2023-10-30 12:15:08 +01:00
|
|
|
}
|
2025-08-09 21:24:35 +01:00
|
|
|
|
|
|
|
|
// Consolidated method to get all setup counts in one query
|
|
|
|
|
function getAllSetupCounts() {
|
|
|
|
|
$userid = xss_clean($this->session->userdata('user_id'));
|
|
|
|
|
|
|
|
|
|
$sql = "SELECT
|
|
|
|
|
(SELECT COUNT(*) FROM dxcc_entities) as country_count,
|
2025-12-20 21:50:21 +00:00
|
|
|
(SELECT COUNT(DISTINCT sl.logbook_id) FROM station_logbooks sl
|
|
|
|
|
LEFT JOIN station_logbooks_permissions slp
|
|
|
|
|
ON slp.logbook_id = sl.logbook_id AND slp.user_id = {$userid}
|
|
|
|
|
WHERE sl.user_id = {$userid} OR slp.user_id = {$userid}) as logbook_count,
|
2025-08-09 21:24:35 +01:00
|
|
|
(SELECT COUNT(*) FROM station_profile WHERE user_id = {$userid}) as location_count";
|
|
|
|
|
|
|
|
|
|
$query = $this->db->query($sql);
|
|
|
|
|
$row = $query->row();
|
|
|
|
|
|
|
|
|
|
return array(
|
|
|
|
|
'country_count' => $row->country_count,
|
|
|
|
|
'logbook_count' => $row->logbook_count,
|
|
|
|
|
'location_count' => $row->location_count
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-10-30 12:15:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|