kopia lustrzana https://github.com/magicbug/Cloudlog
Enhanced the CQ award with a table and form.
rodzic
cde55ab338
commit
2cfd8efdf2
|
@ -253,6 +253,41 @@ class Awards extends CI_Controller {
|
|||
}
|
||||
$data['cqz'] = $zones;
|
||||
|
||||
$data['worked_bands'] = $this->cq->get_worked_bands();
|
||||
|
||||
if ($this->input->post('band') != NULL) { // Band is not set when page first loads.
|
||||
if ($this->input->post('band') == 'All') { // Did the user specify a band? If not, use all bands
|
||||
$bands = $data['worked_bands'];
|
||||
}
|
||||
else {
|
||||
$bands[] = $this->input->post('band');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$bands = $data['worked_bands'];
|
||||
}
|
||||
|
||||
$data['bands'] = $bands; // Used for displaying selected band(s) in the table in the view
|
||||
|
||||
if($this->input->method() === 'post') {
|
||||
$postdata['lotw'] = $this->input->post('lotw');
|
||||
$postdata['qsl'] = $this->input->post('qsl');
|
||||
$postdata['worked'] = $this->input->post('worked');
|
||||
$postdata['confirmed'] = $this->input->post('confirmed');
|
||||
$postdata['notworked'] = $this->input->post('notworked');
|
||||
$postdata['band'] = $this->input->post('band');
|
||||
}
|
||||
else { // Setting default values at first load of page
|
||||
$postdata['lotw'] = 1;
|
||||
$postdata['qsl'] = 1;
|
||||
$postdata['worked'] = 1;
|
||||
$postdata['confirmed'] = 1;
|
||||
$postdata['notworked'] = 1;
|
||||
$postdata['band'] = 'All';
|
||||
}
|
||||
|
||||
$data['cq_array'] = $this->cq->get_cq_array($bands, $postdata);
|
||||
|
||||
// Render page
|
||||
$data['page_title'] = "Awards - CQ Magazine";
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
|
@ -264,7 +299,8 @@ class Awards extends CI_Controller {
|
|||
$this->load->model('logbook_model');
|
||||
|
||||
$cqzone = str_replace('"', "", $this->input->get("CQZone"));
|
||||
$data['results'] = $this->logbook_model->cq_qso_details($cqzone);
|
||||
$band = str_replace('"', "", $this->input->get("Band"));
|
||||
$data['results'] = $this->logbook_model->cq_qso_details($cqzone, $band);
|
||||
|
||||
// Render Page
|
||||
$data['page_title'] = "Log View - DXCC";
|
||||
|
|
|
@ -7,7 +7,6 @@ class CQ extends CI_Model{
|
|||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
function get_zones(){
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
|
@ -22,4 +21,195 @@ class CQ extends CI_Model{
|
|||
|
||||
return $data->result();
|
||||
}
|
||||
|
||||
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,
|
||||
"SAT" => 0,
|
||||
);
|
||||
|
||||
function get_worked_bands()
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
|
||||
// get all worked slots from database
|
||||
$data = $this->db->query(
|
||||
"SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `" . $this->config->item('table_name') . "` WHERE station_id = " . $station_id . " AND COL_PROP_MODE != \"SAT\""
|
||||
);
|
||||
$worked_slots = array();
|
||||
foreach ($data->result() as $row) {
|
||||
array_push($worked_slots, $row->COL_BAND);
|
||||
}
|
||||
|
||||
$SAT_data = $this->db->query(
|
||||
"SELECT distinct LOWER(`COL_PROP_MODE`) as `COL_PROP_MODE` FROM `" . $this->config->item('table_name') . "` WHERE station_id = " . $station_id . " AND COL_PROP_MODE = \"SAT\""
|
||||
);
|
||||
|
||||
foreach ($SAT_data->result() as $row) {
|
||||
array_push($worked_slots, strtoupper($row->COL_PROP_MODE));
|
||||
}
|
||||
|
||||
// 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 get_cq_array($bands, $postdata) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
|
||||
$cqZ = array(); // Used for keeping track of which states that are not worked
|
||||
|
||||
for ($i = 1; $i <= 40; $i++) {
|
||||
$cqZ[$i]['count'] = 0; // Inits each cq zone's count
|
||||
}
|
||||
|
||||
foreach ($bands as $band) {
|
||||
for ($i = 1; $i <= 40; $i++) {
|
||||
$bandCq[$i][$band] = '-'; // Sets all to dash to indicate no result
|
||||
}
|
||||
|
||||
if ($postdata['worked'] != NULL) {
|
||||
$cqBand = $this->getCQWorked($station_id, $band, $postdata);
|
||||
foreach ($cqBand as $line) {
|
||||
$bandCq[$line->col_cqz][$band] = '<div class="alert-danger"><a href=\'cq_details?CQZone="' . str_replace("&", "%26", $line->col_cqz) . '"&Band="' . $band . '"\'>W</a></div>';
|
||||
$cqZ[$line->col_cqz]['count']++;
|
||||
}
|
||||
}
|
||||
if ($postdata['confirmed'] != NULL) {
|
||||
$cqBand = $this->getCQConfirmed($station_id, $band, $postdata);
|
||||
foreach ($cqBand as $line) {
|
||||
$bandCq[$line->col_cqz][$band] = '<div class="alert-success"><a href=\'cq_details?CQZone="' . str_replace("&", "%26", $line->col_cqz) . '"&Band="' . $band . '"\'>C</a></div>';
|
||||
$cqZ[$line->col_cqz]['count']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We want to remove the worked zones in the list, since we do not want to display them
|
||||
if ($postdata['worked'] == NULL) {
|
||||
$cqBand = $this->getCQWorked($station_id, $postdata['band'], $postdata);
|
||||
foreach ($cqBand as $line) {
|
||||
unset($bandCq[$line->col_cqz]);
|
||||
}
|
||||
}
|
||||
|
||||
// We want to remove the confirmed zones in the list, since we do not want to display them
|
||||
if ($postdata['confirmed'] == NULL) {
|
||||
$cqBand = $this->getCQConfirmed($station_id, $postdata['band'], $postdata);
|
||||
foreach ($cqBand as $line) {
|
||||
unset($bandCq[$line->col_cqz]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($postdata['notworked'] == NULL) {
|
||||
for ($i = 1; $i <= 40; $i++) {
|
||||
if ($cqZ[$i]['count'] == 0) {
|
||||
unset($bandCq[$i]);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($bandCq)) {
|
||||
return $bandCq;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function returns all worked, but not confirmed states
|
||||
* $postdata contains data from the form, in this case Lotw or QSL are used
|
||||
*/
|
||||
function getCQWorked($station_id, $band, $postdata) {
|
||||
$sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv
|
||||
where station_id = " . $station_id . " and col_cqz <> ''";
|
||||
|
||||
$sql .= $this->addBandToQuery($band);
|
||||
|
||||
$sql .= " and not exists (select 1 from " . $this->config->item('table_name') .
|
||||
" where station_id = " . $station_id .
|
||||
" and col_cqz = thcv.col_cqz and col_cqz <> '' ";
|
||||
|
||||
$sql .= $this->addBandToQuery($band);
|
||||
|
||||
$sql .= $this->addQslToQuery($postdata);
|
||||
|
||||
$sql .= ")";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
/*
|
||||
* Function returns all confirmed states on given band and on LoTW or QSL
|
||||
* $postdata contains data from the form, in this case Lotw or QSL are used
|
||||
*/
|
||||
function getCQConfirmed($station_id, $band, $postdata) {
|
||||
$sql = "SELECT distinct col_cqz FROM " . $this->config->item('table_name') . " thcv
|
||||
where station_id = " . $station_id . " and col_cqz <> ''";
|
||||
|
||||
$sql .= $this->addBandToQuery($band);
|
||||
|
||||
$sql .= $this->addQslToQuery($postdata);
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
function addQslToQuery($postdata) {
|
||||
$sql = '';
|
||||
if ($postdata['lotw'] != NULL and $postdata['qsl'] == NULL) {
|
||||
$sql .= " and col_lotw_qsl_rcvd = 'Y'";
|
||||
}
|
||||
|
||||
if ($postdata['qsl'] != NULL and $postdata['lotw'] == NULL) {
|
||||
$sql .= " and col_qsl_rcvd = 'Y'";
|
||||
}
|
||||
|
||||
if ($postdata['qsl'] != NULL && $postdata['lotw'] != NULL) {
|
||||
$sql .= " and (col_qsl_rcvd = 'Y' or col_lotw_qsl_rcvd = 'Y')";
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function addBandToQuery($band) {
|
||||
$sql = '';
|
||||
if ($band != 'All') {
|
||||
if ($band == 'SAT') {
|
||||
$sql .= " and col_prop_mode ='" . $band . "'";
|
||||
} else {
|
||||
$sql .= " and col_prop_mode !='SAT'";
|
||||
$sql .= " and col_band ='" . $band . "'";
|
||||
}
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -238,11 +238,18 @@ class Logbook_model extends CI_Model {
|
|||
return $this->db->query($sql);
|
||||
}
|
||||
|
||||
public function cq_qso_details($cqzone){
|
||||
public function cq_qso_details($cqzone, $band){
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('Stations');
|
||||
$station_id = $CI->Stations->find_active();
|
||||
|
||||
if ($band == 'SAT') {
|
||||
$this->db->where('col_prop_mode', $band);
|
||||
} else if ($band != '') {
|
||||
$this->db->where('col_prop_mode !=', 'SAT');
|
||||
$this->db->where('col_band', $band);
|
||||
}
|
||||
|
||||
$this->db->where('station_id', $station_id);
|
||||
$this->db->where('COL_CQZ', $cqzone);
|
||||
|
||||
|
|
|
@ -5,6 +5,19 @@
|
|||
<?php $this->load->view("awards/nav_bar")?>
|
||||
|
||||
<h3>CQ Zones worked:</h3>
|
||||
|
||||
<ul class="nav nav-tabs" id="myTab" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" id="table-tab" data-toggle="tab" href="#table" role="tab" aria-controls="table" aria-selected="true">Table</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="map-tab" data-toggle="tab" href="#map" role="tab" aria-controls="home" aria-selected="false">Map</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade" id="map" role="tabpanel" aria-labelledby="home-tab">
|
||||
<br />
|
||||
<map name="CQ">
|
||||
<area href="cq_details?CQZone=1" title="zone_1" class="zone_1" shape="poly" coords="306,0,306,25,322,37,322,41,291,62,291,76,291,84,364,84,364,67,368,64,373,60,378,60,378,57,377,57,372,52,366,52,366,51,393,51,419,51,419,37,422,35,422,33,420,33,417,30,417,26,408,17,408,0">
|
||||
<area href="cq_details?CQZone=2" title="zone_2" class="zone_2" shape="poly" coords="408,0,408,17,417,26,417,30,420,33,422,33,422,35,419,37,419,51,444,51,452,64,452,67,483,67,487,64,495,61,494,53,491,48,490,46,486,40,485,39,461,21,461,19,471,16,477,15,480,14,480,0">
|
||||
|
@ -54,6 +67,7 @@
|
|||
<area href="cq_details?CQZone=40" title="zone_40" class="zone_40" shape="poly" coords="0,0,0,51,88,28,89,28,145,15,145,0">
|
||||
<area href="cq_details?CQZone=40" title="zone_40" class="zone_40" shape="poly" coords="480,0,480,14,477,15,471,16,461,19,461,21,485,39,486,40,490,46,491,48,494,53,495,61,517,53,524,51,524,0">
|
||||
</map>
|
||||
|
||||
<img class="map" src="<?php echo site_url("../images/CQzone.gif"); ?>" usemap="#CQ" border="0">
|
||||
|
||||
Maps from <a href="http://www4.plala.or.jp/nomrax/hammaps.htm">JF9EXF</a> site.
|
||||
|
@ -61,4 +75,102 @@
|
|||
<ul>
|
||||
<li>All US callsigns are allocated zone 5 by the FCC. This may not be correct</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade show active" id="table" role="tabpanel" aria-labelledby="table-tab">
|
||||
<br />
|
||||
<form class="form" action="<?php echo site_url('awards/cq'); ?>" method="post" enctype="multipart/form-data">
|
||||
<fieldset>
|
||||
|
||||
<!-- Multiple Checkboxes (inline) -->
|
||||
<div class="form-group row">
|
||||
<div class="col-md-2" for="checkboxes">Worked / confirmed</div>
|
||||
<div class="col-md-10">
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" name="worked" id="worked" value="1" <?php if ($this->input->post('worked') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
|
||||
<label class="form-check-label" for="worked">Show worked</label>
|
||||
</div>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" name="confirmed" id="confirmed" value="1" <?php if ($this->input->post('confirmed') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
|
||||
<label class="form-check-label" for="confirmed">Show confirmed</label>
|
||||
</div>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" name="notworked" id="notworked" value="1" <?php if ($this->input->post('notworked') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
|
||||
<label class="form-check-label" for="notworked">Show not worked</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-md-2">QSL / LoTW</div>
|
||||
<div class="col-md-10">
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" name="qsl" value="1" id="qsl" <?php if ($this->input->post('qsl') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
|
||||
<label class="form-check-label" for="qsl">QSL</label>
|
||||
</div>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" name="lotw" value="1" id="lotw" <?php if ($this->input->post('lotw') || $this->input->method() !== 'post') echo ' checked="checked"'; ?> >
|
||||
<label class="form-check-label" for="lotw">LoTW</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Select Basic -->
|
||||
<div class="form-group row">
|
||||
<label class="col-md-2 control-label" for="band">Band</label>
|
||||
<div class="col-md-2">
|
||||
<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";
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Button (Double) -->
|
||||
<div class="form-group row">
|
||||
<label class="col-md-2 control-label" for="button1id"></label>
|
||||
<div class="col-md-10">
|
||||
<button id="button2id" type="reset" name="button2id" class="btn btn-danger">Reset</button>
|
||||
<button id="button1id" type="submit" name="button1id" class="btn btn-success btn-primary">Show</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
<?php
|
||||
if ($cq_array) {
|
||||
echo '
|
||||
<table class="table table-bordered table-hover table-striped table-condensed text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>CQ Zone</td>';
|
||||
foreach($bands as $band) {
|
||||
echo '<td>' . $band . '</td>';
|
||||
}
|
||||
echo '</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($cq_array as $cq => $value) { // Fills the table with the data
|
||||
echo '<tr>
|
||||
<td>'. $cq .'</td>';
|
||||
foreach ($value as $key) {
|
||||
echo '<td style="text-align: center">' . $key . '</td>';
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tfoot></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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Ładowanie…
Reference in New Issue