Extended the Station Profile options these will act as logbooks within Cloudlog

pull/355/head
Peter Goodhall 2019-09-23 17:29:22 +01:00
rodzic 1c3dc32c23
commit 8c9e50ff85
4 zmienionych plików z 139 dodań i 8 usunięć

Wyświetl plik

@ -18,7 +18,11 @@ class Station extends CI_Controller {
public function index()
{
$this->load->model('stations');
$this->load->model('Logbook_model');
$data['stations'] = $this->stations->all();
$data['current_active'] = $this->stations->find_active();
$data['is_there_qsos_with_no_station_id'] = $this->Logbook_model->check_for_station_id();
// Render Page
$data['page_title'] = "Station Profiles";
@ -33,7 +37,6 @@ class Station extends CI_Controller {
$this->load->model('dxcc');
$data['dxcc_list'] = $this->dxcc->list();
$this->load->library('form_validation');
$this->form_validation->set_rules('station_profile_name', 'Station Profile Name', 'required');
@ -58,6 +61,23 @@ class Station extends CI_Controller {
}
function reassign_profile($id) {
// $id is the profile that needs reassigned to QSOs
$this->load->model('stations');
$this->stations->reassign($id);
//$this->stations->logbook_session_data();
redirect('station');
}
function set_active($current, $new) {
$this->load->model('stations');
$this->stations->set_active($current, $new);
//$this->stations->logbook_session_data();
redirect('station');
}
public function delete($id) {
$this->load->model('stations');
$this->stations->delete($id);

Wyświetl plik

@ -1371,6 +1371,17 @@ class Logbook_model extends CI_Model {
print("$count updated\n");
}
public function check_for_station_id() {
$this->db->where('station_id !=', "");
$query = $this->db->get($this->config->item('table_name'));
if($query->num_rows() >= 1) {
return 1;
} else {
return 0;
}
}
public function parse_frequency($frequency)
{
if (is_int($frequency))

Wyświetl plik

@ -59,6 +59,81 @@ class Stations extends CI_Model {
$this->db->delete('station_profile', array('station_id' => $id));
}
function set_active($current, $new) {
// Deselect current default
$current_default = array(
'station_active' => null,
);
$this->db->where('station_id', $current);
$this->db->update('station_profile', $current_default);
// Deselect current default
$newdefault = array(
'station_active' => 1,
);
$this->db->where('station_id', $new);
$this->db->update('station_profile', $newdefault);
}
public function find_active() {
$this->db->where('station_active', 1);
$query = $this->db->get('station_profile');
if($query->num_rows() >= 1) {
foreach ($query->result() as $row)
{
return $row->station_id;
}
} else {
return "0";
}
}
public function reassign($id) {
$this->db->where('station_id', $id);
$query = $this->db->get('station_profile');
$row = $query->row();
//print_r($row);
$data = array(
'station_id' => $id,
);
$this->db->where('COL_STATION_CALLSIGN', $row->station_callsign);
if($row->station_iota != "") {
$this->db->where('COL_MY_IOTA', $row->station_country);
}
if($row->station_sota != "") {
$this->db->where('COL_MY_SOTA_REF', $row->station_sota);
}
$this->db->where('COL_MY_COUNTRY', $row->station_country);
if( strpos($row->station_gridsquare, ',') !== false ) {
$this->db->where('COL_MY_VUCC_GRIDS', $row->station_gridsquare);
} else {
$this->db->where('COL_MY_GRIDSQUARE', $row->station_gridsquare);
}
$this->db->update($this->config->item('table_name'), $data);
$str = $this->db->last_query();
}
function profile_exists() {
$query = $this->db->get('station_profile');
if($query->num_rows() >= 1) {
return 1;
} else {
return 0;
}
}
}
?>

Wyświetl plik

@ -13,46 +13,71 @@
<?php echo $page_title; ?>
</div>
<div class="card-body">
<h5 class="card-title">Lets Explore Operating Locations</h5>
<p class="card-text">Station Profiles define locations of operating positions, useful for portable operating or using a friends QTH.</p>
<p class="card-text">Station Profiles define locations of operating, useful for portable operating or using a friends QTH.</p>
<p class="card-text">Within Cloudlog these act in a similar way to logbooks, a Station Profile keeps a set of QSOs together.</p>
<?php if ($stations->num_rows() > 0) { ?>
<?php if($current_active == 0) { ?>
<div class="alert alert-danger" role="alert">
Attention you need to set an active station profile.
</div>
<?php } ?>
<?php if($is_there_qsos_with_no_station_id == 0) { ?>
<div class="alert alert-danger" role="alert">
<span class="badge badge-pill badge-warning">Warning</span> Due to recent changes within Cloudlog you need to reassign QSOs to your station profiles.
</div>
<?php } ?>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Profile Name</th>
<th scope="col">Station Callsign</th>
<th scope="col">Country</th>
<th scope="col">Gridsquare</th>
<th scope="col">City</th>
<th scope="col">IOTA</th>
<th scope="col">SOTA</th>
<th scope="col">Cnty</th>
<th scope="col">CQ</th>
<th scope="col">ITU</th>
<th></th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<?php foreach ($stations->result() as $row) { ?>
<tr>
<td><?php echo $row->station_profile_name;?></td>
<td><?php echo $row->station_profile_name;?> (#<?php echo $row->station_id;?>)</td>
<td><?php echo $row->station_callsign;?></td>
<td><?php echo $row->station_country;?></td>
<td><?php echo $row->station_gridsquare;?></td>
<td><?php echo $row->station_city;?></td>
<td><?php echo $row->station_iota;?></td>
<td><?php echo $row->station_sota;?></td>
<td><?php echo $row->station_cnty;?></td>
<td><?php echo $row->station_cq;?></td>
<td><?php echo $row->station_itu;?></td>
<td>
<?php if($row->station_active != 1) { ?>
<a href="<?php echo site_url('station/set_active/').$current_active."/".$row->station_id; ?>" class="btn btn-outline-secondary btn-sm btn-sm" onclick="return confirm('Are you sure you want to make logbook <?php echo $row->station_profile_name; ?> the active logbook?');">Set Active</a>
<?php } else { ?>
<span class="badge badge-success">Active Logbook</span>
<?php } ?>
<?php if($is_there_qsos_with_no_station_id == 0) { ?>
<a href="<?php echo site_url('station/reassign_profile/').$row->station_id; ?>" class="btn btn-outline-secondary btn-sm btn-sm" onclick="return confirm('Are you sure you want to reassign QSOs to the <?php echo $row->station_profile_name; ?> profile?');">Reassign</a>
<?php } ?>
</td>
<td><a href="<?php echo site_url('station/delete')."/".$row->station_id; ?>" class="btn btn-danger" onclick="return confirm('Are you sure you want delete QSO <?php echo $row->station_profile_name; ?>?');"><i class="fas fa-trash-alt"></i> Delete</a></td>
</tr>
</tr>
<?php } ?>
</tbody>
<table>
<?php } ?>
<p><a href="<?php echo site_url('station/create'); ?>" class="btn btn-primary"><i class="fas fa-plus"></i> Create a Station Location</a></p>
<p><a href="<?php echo site_url('station/create'); ?>" class="btn btn-primary"><i class="fas fa-plus"></i> Create a Station Profile</a></p>
</div>
</div>