Make Awards - DXCC to show only worked band-slots

这个提交包含在:
Kim Huebel 2019-06-17 10:10:55 +02:00
父节点 9fb7d82702
当前提交 5d31520faf
共有 3 个文件被更改,包括 56 次插入47 次删除

查看文件

@ -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";

查看文件

@ -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;
}

查看文件

@ -6,44 +6,29 @@
<?php $this->load->view("awards/nav_bar")?>
<table class="table table-striped table-hover">
<thead>
<tr>
<td style="width:225px">Country (<?php echo count($dxcc)?>)</td>
<td>160m</td>
<td>80m</td>
<td>60m</td>
<td>40m</td>
<td>30m</td>
<td>20m</td>
<td>17m</td>
<td>15m</td>
<td>12m</td>
<td>10m</td>
<td>6m</td>
<td>4m</td>
<td>2m</td>
<td>70cm</td>
<td>23cm</td>
<td>13cm</td>
<td>9cm</td>
<td>6cm</td>
<td>3cm</td>
<td>1.25cm</td>
<?php
foreach ($worked_bands as $slot) {
echo " <td>$slot</td>\n";
}
?>
</tr>
</thead>
<tbody>
<?php
foreach($dxcc as $country=>$val){
print("<tr><td>$country</td>");
foreach($val as $band=>$count){
if ($count == 0){
print("<td>&nbsp;</td>");
}else{
printf("<td><a href='dxcc_details?Country=\"%s\"&Band=\"%s\"'>%d</a></td>", str_replace("&", "%26", $country), $band, $count);
}
if (in_array($band, $worked_bands)) {
if ($count == 0){
print("<td>&nbsp;</td>");
}else{
printf("<td><a href='dxcc_details?Country=\"%s\"&Band=\"%s\"'>%d</a></td>", str_replace("&", "%26", $country), $band, $count);
}
}
}
print("</tr>");
}