Fixed summary to include SAT. Also split the query for the was summary in two. Some configurations of mysql didn't like this type of query.

这个提交包含在:
Andreas 2020-08-19 17:23:24 +02:00
父节点 c8b999659c
当前提交 49a6ca53e1
共有 3 个文件被更改,包括 50 次插入21 次删除

查看文件

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

查看文件

@ -135,30 +135,58 @@ class was extends CI_Model {
/*
* Function gets worked and confirmed summary on each band on the active stationprofile
*/
function get_was_summary() {
function get_was_summary($bands)
{
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
$stateArray = explode(',', $this->stateString);
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;
}
$states = array(); // Used for keeping track of which states that are not worked
return $wasSummary;
}
$sql = "SELECT thcv.col_band, count(distinct thcv.col_state) as count, coalesce (cfmwas.count, 0) as cfmwas FROM " . $this->config->item('table_name') . " thcv";
$sql .= " left outer join (
select col_band, count(distinct col_state) as count from " . $this->config->item('table_name') . " thcv";
$sql .= " where station_id = " . $station_id;
$sql .= $this->addStateToQuery();
$sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')
group by col_band";
$sql .= ") cfmwas on thcv.col_band = cfmwas.col_band ";
function getSummaryByBand($band, $station_id)
{
$sql = "SELECT thcv.col_band, 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 .= " group by thcv.col_band order by thcv.col_band+0 desc";
$query = $this->db->query($sql);
return $query->result();
}
function getSummaryByBandConfirmed($band, $station_id)
{
$sql = "SELECT thcv.col_band, 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);

查看文件

@ -100,9 +100,10 @@
<thead>
<tr><td></td>';
foreach ($was_summary as $was) { // Fills the table with the data
echo '<td style="text-align: center">' . $was->col_band . '</td>';
foreach($bands as $band) {
echo '<td>' . $band . '</td>';
}
echo '</tr>';
echo '</tr>
</thead>
@ -110,14 +111,14 @@
<tr><td>Total worked</td>';
foreach ($was_summary as $was) { // Fills the table with the data
echo '<td style="text-align: center">' . $was->count . '</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 as $was) { // Fills the table with the data
echo '<td style="text-align: center">' . $was->cfmwas . '</td>';
foreach ($was_summary['confirmed'] as $was) { // Fills the table with the data
echo '<td style="text-align: center">' . $was . '</td>';
}
echo '</tr>