Expanded timeline with more options.

This commit is contained in:
Andreas 2020-10-23 12:25:16 +02:00
parent e8b660b775
commit b33898abdb
7 changed files with 334 additions and 53 deletions

View File

@ -14,7 +14,7 @@ class Timeline extends CI_Controller {
public function index()
{
// Render Page
$data['page_title'] = "DXCC Timeline";
$data['page_title'] = "Timeline";
$this->load->model('Timeline_model');
@ -25,9 +25,28 @@ class Timeline extends CI_Controller {
$band = 'All';
}
$data['dxcc_timeline_array'] = $this->Timeline_model->get_dxcc_timeline($band);
if ($this->input->post('mode') != NULL) { // Band is not set when page first loads.
$mode = $this->input->post('mode');
}
else {
$mode = 'All';
}
if ($this->input->post('awardradio') != NULL) { // Band is not set when page first loads.
$award = $this->input->post('awardradio');
}
else {
$award = 'dxcc';
}
$this->load->model('modes');
$data['modes'] = $this->modes->active();
$data['timeline_array'] = $this->Timeline_model->get_timeline($band, $mode, $award);
$data['worked_bands'] = $this->Timeline_model->get_worked_bands();
$data['bandselect'] = $band;
$data['modeselect'] = $mode;
$this->load->view('interface_assets/header', $data);
$this->load->view('timeline/index');
@ -37,14 +56,29 @@ class Timeline extends CI_Controller {
public function details() {
$this->load->model('logbook_model');
$adif = str_replace('"', "", $this->input->post("Adif"));
$country = $this->logbook_model->get_entity($adif);
$band = str_replace('"', "", $this->input->post("Band"));
$data['results'] = $this->logbook_model->timeline_qso_details($adif, $band);
$querystring = str_replace('"', "", $this->input->post("Querystring"));
// Render Page
$data['page_title'] = "Log View - DXCC";
$data['filter'] = "country ". $country['name'];
$band = str_replace('"', "", $this->input->post("Band"));
$mode = str_replace('"', "", $this->input->post("Mode"));
$type = str_replace('"', "", $this->input->post("Type"));
$data['results'] = $this->logbook_model->timeline_qso_details($querystring, $band, $mode, $type);
switch($type) {
case 'dxcc': $country = $this->logbook_model->get_entity($querystring);
$data['page_title'] = "Log View - DXCC";
$data['filter'] = "country ". $country['name'];
break;
case 'was' : $data['page_title'] = "Log View - WAS";
$data['filter'] = "state ". $querystring;
break;
case 'iota': $data['page_title'] = "Log View - IOTA";
$data['filter'] = "iota ". $querystring;
break;
case 'waz' : $data['page_title'] = "Log View - WAZ";
$data['filter'] = "CQ zone ". $querystring;
break;
}
if ($band != "All") {
$data['filter'] .= " and " . $band;

View File

@ -278,7 +278,7 @@ class Logbook_model extends CI_Model {
return $this->db->get($this->config->item('table_name'));
}
public function timeline_qso_details($adif, $band){
public function timeline_qso_details($querystring, $band, $mode, $type){
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
@ -292,8 +292,18 @@ class Logbook_model extends CI_Model {
}
}
if ($mode != 'All') {
$this->db->where('col_mode', $mode);
}
$this->db->where('station_id', $station_id);
$this->db->where('COL_DXCC', $adif);
switch($type) {
case 'dxcc': $this->db->where('COL_DXCC', $querystring); break;
case 'was': $this->db->where('COL_STATE', $querystring); break;
case 'iota': $this->db->where('COL_IOTA', $querystring); break;
case 'waz': $this->db->where('COL_CQZ', $querystring); break;
}
return $this->db->get($this->config->item('table_name'));
}

View File

@ -9,12 +9,22 @@ class Timeline_model extends CI_Model
parent::__construct();
}
function get_dxcc_timeline($band)
{
function get_timeline($band, $mode, $award) {
$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();
switch ($award) {
case 'dxcc': $result = $this->get_timeline_dxcc($band, $mode, $station_id); break;
case 'was': $result = $this->get_timeline_was($band, $mode, $station_id); break;
case 'iota': $result = $this->get_timeline_iota($band, $mode, $station_id); break;
case 'waz': $result = $this->get_timeline_waz($band, $mode, $station_id); break;
}
return $result;
}
public function get_timeline_dxcc($band, $mode, $station_id) {
$sql = "select min(date(COL_TIME_ON)) date, prefix, col_country, end, adif from "
.$this->config->item('table_name'). " thcv
join dxcc_entities on thcv.col_dxcc = dxcc_entities.adif
@ -30,6 +40,10 @@ class Timeline_model extends CI_Model
}
}
if ($mode != 'All') {
$sql .= " and col_mode ='" . $mode . "'";
}
$sql .= " group by col_dxcc, col_country
order by date desc";
@ -38,6 +52,91 @@ class Timeline_model extends CI_Model
return $query->result();
}
public function get_timeline_was($band, $mode, $station_id) {
$sql = "select min(date(COL_TIME_ON)) date, col_state from "
.$this->config->item('table_name'). " thcv
where station_id = " . $station_id;
if ($band != 'All') {
if ($band == 'SAT') {
$sql .= " and col_prop_mode ='" . $band . "'";
}
else {
$sql .= " and col_prop_mode !='SAT'";
$sql .= " and col_band ='" . $band . "'";
}
}
if ($mode != 'All') {
$sql .= " and col_mode ='" . $mode . "'";
}
$sql .= " and COL_DXCC in ('291', '6', '110')";
$sql .= " and COL_STATE in ('AK','AL','AR','AZ','CA','CO','CT','DE','FL','GA','HI','IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VA','VT','WA','WI','WV','WY')";
$sql .= " group by col_state
order by date desc";
$query = $this->db->query($sql);
return $query->result();
}
public function get_timeline_iota($band, $mode, $station_id) {
$sql = "select min(date(COL_TIME_ON)) date, col_iota, name, prefix from "
.$this->config->item('table_name'). " thcv
join iota on thcv.col_iota = iota.tag
where station_id = " . $station_id;
if ($band != 'All') {
if ($band == 'SAT') {
$sql .= " and col_prop_mode ='" . $band . "'";
}
else {
$sql .= " and col_prop_mode !='SAT'";
$sql .= " and col_band ='" . $band . "'";
}
}
if ($mode != 'All') {
$sql .= " and col_mode ='" . $mode . "'";
}
$sql .= " and col_iota <> '' group by col_iota
order by date desc";
$query = $this->db->query($sql);
return $query->result();
}
public function get_timeline_waz($band, $mode, $station_id) {
$sql = "select min(date(COL_TIME_ON)) date, col_cqz from "
.$this->config->item('table_name'). " thcv
where station_id = " . $station_id;
if ($band != 'All') {
if ($band == 'SAT') {
$sql .= " and col_prop_mode ='" . $band . "'";
}
else {
$sql .= " and col_prop_mode !='SAT'";
$sql .= " and col_band ='" . $band . "'";
}
}
if ($mode != 'All') {
$sql .= " and col_mode ='" . $mode . "'";
}
$sql .= " and col_cqz <> '' group by col_cqz
order by date desc";
$query = $this->db->query($sql);
return $query->result();
}
public $bandslots = array("160m" => 0,
"80m" => 0,
"60m" => 0,

View File

@ -1903,13 +1903,15 @@ $(document).ready(function(){
$(".buttons-csv").css("color", "white");
}
function displayTimelineContacts(adif, band) {
function displayTimelineContacts(querystring, band, mode, type) {
var baseURL= "<?php echo base_url();?>";
$.ajax({
url: baseURL + 'index.php/timeline/details',
type: 'post',
data: {'Adif': adif,
'Band': band
data: {'Querystring': querystring,
'Band': band,
'Mode': mode,
'Type': type
},
success: function(html) {
BootstrapDialog.show({

View File

@ -84,9 +84,9 @@
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('dayswithqso');?>" title="Dayswithqso">Days with QSOs</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('timeline');?>" title="Dxcctimeline">DXCC Timeline</a>
<a class="dropdown-item" href="<?php echo site_url('timeline');?>" title="Timeline">Timeline</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('accumulated');?>" title="Dxcctimeline">Accumulated statistics</a>
<a class="dropdown-item" href="<?php echo site_url('accumulated');?>" title="Accumulated statistics">Accumulated statistics</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('timeplotter');?>" title="View time when worked">Timeplotter</a>
</div>

View File

@ -1,7 +1,4 @@
<div class="container">
<h2>Logbook</h2>
<h3>Filtering on <?php echo $filter ?></h3>
<h5>Filtering on <?php echo $filter ?></h5>
<?php $this->load->view('view_log/partial/log_ajax') ?>

View File

@ -2,23 +2,72 @@
<h1><?php echo $page_title; ?></h1>
<form class="form" action="<?php echo site_url('timeline'); ?>" method="post" enctype="multipart/form-data">
<fieldset>
<!-- Select Basic -->
<div class="form-group row">
<label class="col-md-1 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'; ?> >All</option>
<?php foreach($worked_bands as $band) {
echo '<option value="' . $band . '"';
if ($this->input->post('band') == $band) echo ' selected';
echo '>' . $band . '</option>'."\n";
} ?>
</select>
<!-- Select Basic -->
<div class="form-group row">
<label class="col-md-1 control-label" for="band">Band</label>
<div class="col-md-3">
<select id="band" name="band" class="form-control custom-select">
<option value="All" <?php if ($this->input->post('band') == "All" || $this->input->method() !== 'post') echo ' selected'; ?> >All</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>
<label class="col-md-1 control-label" for="mode">Mode</label>
<div class="col-md-3">
<select id="mode" name="mode" class="form-control custom-select">
<option value="All" <?php if ($this->input->post('band') == "All" || $this->input->method() !== 'post') echo ' selected'; ?> >All</option>
<?php
foreach($modes->result() as $mode){
if ($mode->submode == null) {
echo '<option value="' . $mode->mode . '"';
if ($this->input->post('mode') == $mode->mode) echo ' selected';
echo '>' . $mode->mode . '</option>'."\n";
} else {
echo '<option value="' . $mode->submode . '"';
if ($this->input->post('mode') == $mode->submode) echo ' selected';
echo '>' . $mode->submode . '</option>'."\n";
}
}
?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-md-1 control-label" for="radio">Award</label>
<div class="col-md-3">
<div class="form-check">
<input class="form-check-input" type="radio" name="awardradio" id="dxcc" value="dxcc" <?php if ($this->input->post('awardradio') == 'dxcc' || $this->input->method() !== 'post') echo ' checked'?>>
<label class="form-check-label" for="dxcc">
DX Century Club (DXCC)
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="awardradio" id="was" value="was" <?php if ($this->input->post('awardradio') == 'was') echo ' checked'?>>
<label class="form-check-label" for="was">
Worked all states (WAS)
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="awardradio" id="iota" value="iota" <?php if ($this->input->post('awardradio') == 'iota') echo ' checked'?>>
<label class="form-check-label" for="iota">
Islands on the air (IOTA)
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="awardradio" id="waz" value="waz" <?php if ($this->input->post('awardradio') == 'waz') echo ' checked'?>>
<label class="form-check-label" for="waz">
Worked all zones (WAZ)
</label>
</div>
</div>
</div>
<!-- Button (Double) -->
<div class="form-group row">
<label class="col-md-1 control-label" for="button1id"></label>
<div class="col-md-10">
@ -26,7 +75,6 @@
</div>
</div>
</fieldset>
</form>
<?php
@ -41,9 +89,27 @@
?>
<?php
$i = count($dxcc_timeline_array);
if ($dxcc_timeline_array) {
echo '<table style="width:100%" class="table timelinetable table-bordered table-hover table-striped table-condensed text-center">
if ($timeline_array) {
switch ($this->input->post('awardradio')) {
case 'dxcc': $result = write_dxcc_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $this->input->post('awardradio')); break;
case 'was': $result = write_was_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $this->input->post('awardradio')); break;
case 'iota': $result = write_iota_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $this->input->post('awardradio')); break;
case 'waz': $result = write_waz_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $this->input->post('awardradio')); break;
}
}
else {
echo '<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>Nothing found!</div>';
}
?>
</div>
<?php
function write_dxcc_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $award) {
$i = count($timeline_array);
echo '<table style="width:100%" class="table table-sm timelinetable table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<td>#</td>
@ -57,25 +123,98 @@
</thead>
<tbody>';
foreach ($dxcc_timeline_array as $line) {
$date_as_timestamp = strtotime($line->date);
echo '<tr>
foreach ($timeline_array as $line) {
$date_as_timestamp = strtotime($line->date);
echo '<tr>
<td>' . $i-- . '</td>
<td>' . date($custom_date_format, $date_as_timestamp) . '</td>
<td>' . $line->prefix . '</td>
<td>' . $line->col_country . '</td>
<td>';
if (!empty($line->end)) echo 'Yes';
echo '</td>
if (!empty($line->end)) echo 'Yes';
echo '</td>
<td>' . $line->end . '</td>
<td><a href=javascript:displayTimelineContacts("' . $line->adif . '","'. $bandselect . '")>Show</a></td>
<td><a href=javascript:displayTimelineContacts("' . $line->adif . '","'. $bandselect . '","'. $modeselect . '","' . $award .'")>Show</a></td>
</tr>';
}
echo '</tfoot></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>';
}
?>
echo '</tfoot></table></div>';
}
</div>
function write_was_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $award) {
$i = count($timeline_array);
echo '<table style="width:100%" class="table table-sm timelinetable table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<td>#</td>
<td>Date</td>
<td>State</td>
<td>Show QSOs</td>
</tr>
</thead>
<tbody>';
foreach ($timeline_array as $line) {
$date_as_timestamp = strtotime($line->date);
echo '<tr>
<td>' . $i-- . '</td>
<td>' . date($custom_date_format, $date_as_timestamp) . '</td>
<td>' . $line->col_state . '</td>
<td><a href=javascript:displayTimelineContacts("' . $line->col_state . '","'. $bandselect . '","'. $modeselect . '","' . $award .'")>Show</a></td>
</tr>';
}
echo '</tfoot></table></div>';
}
function write_iota_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $award) {
$i = count($timeline_array);
echo '<table style="width:100%" class="table table-sm timelinetable table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<td>#</td>
<td>Date</td>
<td>Iota</td>
<td>Name</td>
<td>Prefix</td>
<td>Show QSOs</td>
</tr>
</thead>
<tbody>';
foreach ($timeline_array as $line) {
$date_as_timestamp = strtotime($line->date);
echo '<tr>
<td>' . $i-- . '</td>
<td>' . date($custom_date_format, $date_as_timestamp) . '</td>
<td>' . $line->col_iota . '</td>
<td>' . $line->name . '</td>
<td>' . $line->prefix . '</td>
<td><a href=javascript:displayTimelineContacts("' . $line->col_iota . '","'. $bandselect . '","'. $modeselect . '","' . $award .'")>Show</a></td>
</tr>';
}
echo '</tfoot></table></div>';
}
function write_waz_timeline($timeline_array, $custom_date_format, $bandselect, $modeselect, $award) {
$i = count($timeline_array);
echo '<table style="width:100%" class="table table-sm timelinetable table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<td>#</td>
<td>Date</td>
<td>CQ Zone</td>
<td>Show QSOs</td>
</tr>
</thead>
<tbody>';
foreach ($timeline_array as $line) {
$date_as_timestamp = strtotime($line->date);
echo '<tr>
<td>' . $i-- . '</td>
<td>' . date($custom_date_format, $date_as_timestamp) . '</td>
<td>' . $line->col_cqz . '</td>
<td><a href=javascript:displayTimelineContacts("' . $line->col_cqz . '","'. $bandselect . '","'. $modeselect . '","' . $award .'")>Show</a></td>
</tr>';
}
echo '</tfoot></table></div>';
}