kopia lustrzana https://github.com/magicbug/Cloudlog
Split the query for the dxcc summary in two. Some configurations of mysql didn't like this type of query.
rodzic
640d0c151b
commit
48980c0566
|
@ -128,6 +128,7 @@ class Awards extends CI_Controller {
|
|||
|
||||
$dxcclist = $this->dxcc->fetchdxcc($postdata);
|
||||
$data['dxcc_array'] = $this->dxcc->get_dxcc_array($dxcclist, $bands, $postdata);
|
||||
$data['dxcc_summary'] = $this->dxcc->get_dxcc_summary($bands);
|
||||
|
||||
// Render Page
|
||||
$data['page_title'] = "Awards - DXCC";
|
||||
|
|
|
@ -463,5 +463,62 @@ class DXCC extends CI_Model {
|
|||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function gets worked and confirmed summary on each band on the active stationprofile
|
||||
*/
|
||||
function get_dxcc_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);
|
||||
$dxccSummary['worked'][$band] = $worked[0]->count;
|
||||
$dxccSummary['confirmed'][$band] = $confirmed[0]->count;
|
||||
}
|
||||
|
||||
return $dxccSummary;
|
||||
}
|
||||
|
||||
function getSummaryByBand($band, $station_id)
|
||||
{
|
||||
$sql = "SELECT thcv.col_band, count(distinct thcv.col_dxcc) 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 . "'";
|
||||
|
||||
}
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function getSummaryByBandConfirmed($band, $station_id)
|
||||
{
|
||||
$sql = "SELECT thcv.col_band, count(distinct thcv.col_dxcc) 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 .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
<div class="container">
|
||||
<h1><?php echo $page_title; ?></h1>
|
||||
<h1><?php echo $page_title; ?></h1>
|
||||
|
||||
<!-- Sub Nav for Awards -->
|
||||
|
||||
<!-- Sub Nav for Awards -->
|
||||
|
||||
<?php $this->load->view("awards/nav_bar")?>
|
||||
<form class="form" action="<?php echo site_url('awards/dxcc'); ?>" method="post" enctype="multipart/form-data">
|
||||
<fieldset>
|
||||
|
@ -93,9 +93,9 @@
|
|||
<select id="band2" name="band" class="form-control">
|
||||
<option value="All" <?php if ($this->input->post('band') == "All" || $this->input->method() !== 'post') echo ' selected'; ?> >Every band</option>
|
||||
<?php foreach($worked_bands as $band) {
|
||||
echo '<option value="' . $band . '"';
|
||||
if ($this->input->post('band') == $band) echo ' selected';
|
||||
echo '>' . $band . '</option>'."\n";
|
||||
echo '<option value="' . $band . '"';
|
||||
if ($this->input->post('band') == $band) echo ' selected';
|
||||
echo '>' . $band . '</option>'."\n";
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
|
@ -112,7 +112,7 @@
|
|||
|
||||
</fieldset>
|
||||
</form>
|
||||
<?php
|
||||
<?php
|
||||
$i = 1;
|
||||
if ($dxcc_array) {
|
||||
echo '
|
||||
|
@ -126,25 +126,55 @@
|
|||
if ($this->input->post('includedeleted') || $this->input->method() !== 'post')
|
||||
echo '
|
||||
<td>Deleted</td>';
|
||||
foreach($bands as $band) {
|
||||
echo '<td>' . $band . '</td>';
|
||||
}
|
||||
echo '</tr>
|
||||
foreach($bands as $band) {
|
||||
echo '<td>' . $band . '</td>';
|
||||
}
|
||||
echo '</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($dxcc_array as $dxcc => $value) { // Fills the table with the data
|
||||
echo '<tr>
|
||||
foreach ($dxcc_array as $dxcc => $value) { // Fills the table with the data
|
||||
echo '<tr>
|
||||
<td>'. $i++ .'</td>';
|
||||
foreach ($value as $key) {
|
||||
echo '<td style="text-align: center">' . $key . '</td>';
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tfoot></table></div>';
|
||||
foreach ($value as $key) {
|
||||
echo '<td style="text-align: center">' . $key . '</td>';
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
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 ($dxcc_summary['worked'] as $dxcc) { // Fills the table with the data
|
||||
echo '<td style="text-align: center">' . $dxcc . '</td>';
|
||||
}
|
||||
|
||||
echo '</tr><tr>
|
||||
<td>Total confirmed</td>';
|
||||
foreach ($dxcc_summary['confirmed'] as $dxcc) { // Fills the table with the data
|
||||
echo '<td style="text-align: center">' . $dxcc . '</td>';
|
||||
}
|
||||
|
||||
echo '</tr>
|
||||
</table>
|
||||
</div>';
|
||||
|
||||
}
|
||||
else {
|
||||
echo '<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Nothing found!</div>';
|
||||
}
|
||||
?>
|
||||
?>
|
||||
</div>
|
||||
|
|
Ładowanie…
Reference in New Issue