From 5d31520faffb897f925bee681fa230e12c018fc7 Mon Sep 17 00:00:00 2001 From: Kim Huebel Date: Mon, 17 Jun 2019 10:10:55 +0200 Subject: [PATCH] Make Awards - DXCC to show only worked band-slots --- application/controllers/Awards.php | 1 + application/models/Dxcc.php | 63 +++++++++++++++++-------- application/views/awards/dxcc/index.php | 39 +++++---------- 3 files changed, 56 insertions(+), 47 deletions(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 47eb3278..b132649f 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -22,6 +22,7 @@ class Awards extends CI_Controller { //echo "Needs Developed"; $this->load->model('dxcc'); $data['dxcc'] = $this->dxcc->show_stats(); + $data['worked_bands'] = $this->dxcc->get_worked_bands(); // Render Page $data['page_title'] = "Awards - DXCC"; diff --git a/application/models/Dxcc.php b/application/models/Dxcc.php index 1b83b70c..94bcdbe4 100644 --- a/application/models/Dxcc.php +++ b/application/models/Dxcc.php @@ -2,12 +2,54 @@ class DXCC extends CI_Model { + public $bandslots = array("160m"=>0, + "80m"=>0, + "60m"=>0, + "40m"=>0, + "30m"=>0, + "20m"=>0, + "17m"=>0, + "15m"=>0, + "12m"=>0, + "10m"=>0, + "6m" =>0, + "4m" =>0, + "2m" =>0, + "70cm"=>0, + "23cm"=>0, + "13cm"=>0, + "9cm"=>0, + "6cm"=>0, + "3cm"=>0, + "1.25cm"=>0); + function __construct() { // Call the Model constructor parent::__construct(); } + function get_worked_bands() { + // get all worked slots from database + $data = $this->db->query( + "SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `TABLE_HRD_CONTACTS_V01`" + ); + $worked_slots = array(); + foreach($data->result() as $row){ + array_push($worked_slots, $row->COL_BAND); + } + + + // bring worked-slots in order of defined $bandslots + $results = array(); + foreach(array_keys($this->bandslots) as $slot) { + if(in_array($slot, $worked_slots)) { + array_push($results, $slot); + } + } + return $results; + } + function show_stats(){ $data = $this->db->query( @@ -21,26 +63,7 @@ class DXCC extends CI_Model { foreach($data->result() as $row){ if ($last_country != $row->COL_COUNTRY){ // new row - $results[$row->COL_COUNTRY] = array("160m"=>0, - "80m"=>0, - "60m"=>0, - "40m"=>0, - "30m"=>0, - "20m"=>0, - "17m"=>0, - "15m"=>0, - "12m"=>0, - "10m"=>0, - "6m" =>0, - "4m" =>0, - "2m" =>0, - "70cm"=>0, - "23cm"=>0, - "13cm"=>0, - "9cm"=>0, - "6cm"=>0, - "3cm"=>0, - "1.25cm"=>0); + $results[$row->COL_COUNTRY] = $this->bandslots; $last_country = $row->COL_COUNTRY; } diff --git a/application/views/awards/dxcc/index.php b/application/views/awards/dxcc/index.php index 20e7b151..573f8fdf 100644 --- a/application/views/awards/dxcc/index.php +++ b/application/views/awards/dxcc/index.php @@ -6,44 +6,29 @@ load->view("awards/nav_bar")?> - - - - - - - - - - - - - - - - - - - - - + $slot\n"; + } + ?> $val){ print(""); foreach($val as $band=>$count){ - if ($count == 0){ - print(""); - }else{ - printf("", str_replace("&", "%26", $country), $band, $count); - } + if (in_array($band, $worked_bands)) { + if ($count == 0){ + print(""); + }else{ + printf("", str_replace("&", "%26", $country), $band, $count); + } + } } print(""); }
Country ()160m80m60m40m30m20m17m15m12m10m6m4m2m70cm23cm13cm9cm6cm3cm1.25cm
$country %d %d