Merge pull request #1154 from AndreasK79/dok_station_logbooks

[DOK Award] Updated code to support station logbooks
pull/1168/head
Peter Goodhall 2021-09-10 18:37:58 +01:00 zatwierdzone przez GitHub
commit ff29a60ca9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 16 dodań i 13 usunięć

Wyświetl plik

@ -27,7 +27,6 @@ class Awards extends CI_Controller {
public function dok ()
{
//echo "Needs Developed";
$this->load->model('dok');
$data['doks'] = $this->dok->show_stats();
$data['worked_bands'] = $this->dok->get_worked_bands();
@ -226,7 +225,7 @@ class Awards extends CI_Controller {
$this->load->view('interface_assets/footer');
}
public function cq(){
public function cq() {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));

Wyświetl plik

@ -31,12 +31,14 @@ class DOK extends CI_Model {
function get_worked_bands() {
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$location_list = "'".implode("','",$logbooks_locations_array)."'";
// get all worked slots from database
$data = $this->db->query(
"SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `".$this->config->item('table_name')."` WHERE station_id = ".$station_id." AND COL_DARC_DOK IS NOT NULL AND COL_DARC_DOK != '' AND COL_DXCC = 230 "
"SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `".$this->config->item('table_name')."` WHERE station_id in (" . $location_list . ") AND COL_DARC_DOK IS NOT NULL AND COL_DARC_DOK != '' AND COL_DXCC = 230 "
);
$worked_slots = array();
foreach($data->result() as $row){
@ -49,19 +51,21 @@ class DOK extends CI_Model {
foreach(array_keys($this->bandslots) as $slot) {
if(in_array($slot, $worked_slots)) {
array_push($results, $slot);
}
}
}
return $results;
}
function show_stats(){
function show_stats() {
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
$location_list = "'".implode("','",$logbooks_locations_array)."'";
$data = $this->db->query(
"select upper(COL_DARC_DOK) as COL_DARC_DOK, COL_MODE, lcase(COL_BAND) as COL_BAND, count(COL_DARC_DOK) as cnt
from ".$this->config->item('table_name')." WHERE station_id = ".$station_id." AND COL_DARC_DOK IS NOT NULL AND COL_DARC_DOK != '' AND COL_DXCC = 230
from ".$this->config->item('table_name')." WHERE station_id in (" . $location_list . ") AND COL_DARC_DOK IS NOT NULL AND COL_DARC_DOK != '' AND COL_DXCC = 230
group by COL_DARC_DOK, COL_MODE, COL_BAND"
);
@ -76,14 +80,14 @@ class DOK extends CI_Model {
// update stats
if (!isset($results[$row->COL_DARC_DOK]))
$results[$row->COL_DARC_DOK] = [];
$results[$row->COL_DARC_DOK] = [];
if (!isset($results[$row->COL_DARC_DOK][$row->COL_BAND]))
$results[$row->COL_DARC_DOK][$row->COL_BAND] = 0;
$results[$row->COL_DARC_DOK][$row->COL_BAND] = 0;
$results[$row->COL_DARC_DOK][$row->COL_BAND] += $row->cnt;
}
return $results;
}