kopia lustrzana https://github.com/magicbug/Cloudlog
Merge pull request #1154 from AndreasK79/dok_station_logbooks
[DOK Award] Updated code to support station logbookspull/1168/head
commit
ff29a60ca9
|
@ -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'));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue