Merge pull request #580 from AndreasK79/award_was_summary

Add summary table to WAS Awards area
这个提交包含在:
Peter Goodhall 2020-08-24 22:24:43 +01:00 提交者 GitHub
当前提交 a6d780a1d3
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有 3 个文件被更改,包括 93 次插入1 次删除

查看文件

@ -347,6 +347,7 @@ class Awards extends CI_Controller {
}
$data['was_array'] = $this->was->get_was_array($bands, $postdata);
$data['was_summary'] = $this->was->get_was_summary($bands);
// Render Page
$data['page_title'] = "Awards - WAS (Worked all states)";

查看文件

@ -132,6 +132,67 @@ class was extends CI_Model {
}
}
/*
* Function gets worked and confirmed summary on each band on the active stationprofile
*/
function get_was_summary($bands)
{
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
foreach ($bands as $band) {
$worked = $this->getSummaryByBand($band, $station_id);
$confirmed = $this->getSummaryByBandConfirmed($band, $station_id);
$wasSummary['worked'][$band] = $worked[0]->count;
$wasSummary['confirmed'][$band] = $confirmed[0]->count;
}
return $wasSummary;
}
function getSummaryByBand($band, $station_id)
{
$sql = "SELECT count(distinct thcv.col_state) as count FROM " . $this->config->item('table_name') . " thcv";
$sql .= " where station_id = " . $station_id;
if ($band == 'SAT') {
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
} else {
$sql .= " and thcv.col_prop_mode !='SAT'";
$sql .= " and thcv.col_band ='" . $band . "'";
}
$sql .= $this->addStateToQuery();
$query = $this->db->query($sql);
return $query->result();
}
function getSummaryByBandConfirmed($band, $station_id)
{
$sql = "SELECT count(distinct thcv.col_state) as count FROM " . $this->config->item('table_name') . " thcv";
$sql .= " where station_id = " . $station_id;
if ($band == 'SAT') {
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
} else {
$sql .= " and thcv.col_prop_mode !='SAT'";
$sql .= " and thcv.col_band ='" . $band . "'";
}
$sql .= $this->addStateToQuery();
$sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
$query = $this->db->query($sql);
return $query->result();
}
/*
* Function returns all worked, but not confirmed states
* $postdata contains data from the form, in this case Lotw or QSL are used

查看文件

@ -92,8 +92,38 @@
}
echo '</tr>';
}
echo '</tfoot></table></div>';
echo '</table>
<h1>Summary</h1>
<table class="table table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr><td></td>';
foreach($bands as $band) {
echo '<td>' . $band . '</td>';
}
echo '</tr>';
echo '</tr>
</thead>
<tbody>
<tr><td>Total worked</td>';
foreach ($was_summary['worked'] as $was) { // Fills the table with the data
echo '<td style="text-align: center">' . $was . '</td>';
}
echo '</tr><tr>
<td>Total confirmed</td>';
foreach ($was_summary['confirmed'] as $was) { // Fills the table with the data
echo '<td style="text-align: center">' . $was . '</td>';
}
echo '</tr>
</table>
</div>';
}
else {
echo '<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>Nothing found!</div>';