Skip to content

Commit

Permalink
Merge pull request #1019 from AndreasK79/selectable_columns
Browse files Browse the repository at this point in the history
[User selectable columns] Added the possibility to configure some of …
  • Loading branch information
magicbug authored May 6, 2021
2 parents 4fb2d03 + da279ff commit d6782e5
Show file tree
Hide file tree
Showing 12 changed files with 511 additions and 81 deletions.
2 changes: 1 addition & 1 deletion application/config/migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 68;
$config['migration_version'] = 69;

/*
|--------------------------------------------------------------------------
Expand Down
64 changes: 32 additions & 32 deletions application/controllers/Logbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,22 @@ function json($callsign, $type, $band, $mode)
function worked_grid_before($gridsquare, $type, $band, $mode)
{
if (strlen($gridsquare) < 4)
return false;
return false;

$CI =& get_instance();
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();


if($type == "SAT") {
$this->db->where('COL_PROP_MODE', 'SAT');
$this->db->where('COL_PROP_MODE', 'SAT');
} else {
$this->db->where('COL_MODE', $mode);
$this->db->where('COL_BAND', $band);
$this->db->where('COL_MODE', $mode);
$this->db->where('COL_BAND', $band);
$this->db->where('COL_PROP_MODE !=','SAT');

}
$this->db->where('station_id', $station_id);
$this->db->where('station_id', $station_id);
$this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4));
$this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "desc");
$this->db->limit(1);
Expand All @@ -257,7 +257,7 @@ function worked_grid_before($gridsquare, $type, $band, $mode)
/*
* Function: jsonlookupgrid
*
* Usage: Used to look up gridsquares when creating a QSO to check whether its needed or not
* Usage: Used to look up gridsquares when creating a QSO to check whether its needed or not
* the $type variable is only used for satellites, set this to SAT.
*
*/
Expand All @@ -271,16 +271,16 @@ function jsonlookupgrid($gridsquare, $type, $band, $mode) {
$station_id = $CI->Stations->find_active();

if($type == "SAT") {
$this->db->where('COL_PROP_MODE', 'SAT');
$this->db->where('COL_PROP_MODE', 'SAT');
} else {
$this->db->where('COL_MODE', $mode);
$this->db->where('COL_BAND', $band);
$this->db->where('COL_MODE', $mode);
$this->db->where('COL_BAND', $band);
$this->db->where('COL_PROP_MODE !=','SAT');

}

$this->db->where('station_id', $station_id);
$this->db->where('station_id', $station_id);

$this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4));
$query = $this->db->get($this->config->item('table_name'), 1, 0);
foreach ($query->result() as $workedBeforeRow)
Expand All @@ -295,7 +295,7 @@ function jsonlookupgrid($gridsquare, $type, $band, $mode) {
}

function jsonlookupdxcc($country, $type, $band, $mode) {

$return = [
"workedBefore" => false,
];
Expand All @@ -305,17 +305,17 @@ function jsonlookupdxcc($country, $type, $band, $mode) {
$station_id = $CI->Stations->find_active();

if($type == "SAT") {
$this->db->where('COL_PROP_MODE', 'SAT');
$this->db->where('COL_PROP_MODE', 'SAT');
} else {
$this->db->where('COL_MODE', $mode);
$this->db->where('COL_BAND', $band);
$this->db->where('COL_MODE', $mode);
$this->db->where('COL_BAND', $band);
$this->db->where('COL_PROP_MODE !=','SAT');

}

$this->db->where('station_id', $station_id);
$this->db->where('COL_COUNTRY', urldecode($country));
$this->db->where('station_id', $station_id);
$this->db->where('COL_COUNTRY', urldecode($country));

$query = $this->db->get($this->config->item('table_name'), 1, 0);
foreach ($query->result() as $workedBeforeRow)
{
Expand All @@ -329,7 +329,7 @@ function jsonlookupdxcc($country, $type, $band, $mode) {
}

function jsonlookupcallsign($callsign, $type, $band, $mode) {

// Convert - in Callsign to / Used for URL processing
$callsign = str_replace("-","/",$callsign);

Expand All @@ -342,17 +342,17 @@ function jsonlookupcallsign($callsign, $type, $band, $mode) {
$station_id = $CI->Stations->find_active();

if($type == "SAT") {
$this->db->where('COL_PROP_MODE', 'SAT');
$this->db->where('COL_PROP_MODE', 'SAT');
} else {
$this->db->where('COL_MODE', $mode);
$this->db->where('COL_BAND', $band);
$this->db->where('COL_MODE', $mode);
$this->db->where('COL_BAND', $band);
$this->db->where('COL_PROP_MODE !=','SAT');

}

$this->db->where('station_id', $station_id);
$this->db->where('COL_CALL', strtoupper($callsign));
$this->db->where('station_id', $station_id);
$this->db->where('COL_CALL', strtoupper($callsign));

$query = $this->db->get($this->config->item('table_name'), 1, 0);
foreach ($query->result() as $workedBeforeRow)
{
Expand Down Expand Up @@ -413,7 +413,7 @@ function qso_map() {
echo "]";
echo "}";
}

function view($id) {
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
Expand All @@ -437,11 +437,11 @@ function view($id) {
$this->load->view('view_log/qso');
$this->load->view('interface_assets/footer');
}

function partial($id) {
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }

$html = "";


Expand Down Expand Up @@ -563,12 +563,12 @@ function search_result($id="") {

if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }

$this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_NAME, '.$this->config->item('table_name').'.COL_COUNTRY, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*');
//$this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_NAME, '.$this->config->item('table_name').'.COL_COUNTRY, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*');

$this->db->from($this->config->item('table_name'));

$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');

$this->db->like(''.$this->config->item('table_name').'.COL_CALL', $id);
$this->db->or_like(''.$this->config->item('table_name').'.COL_GRIDSQUARE', $id);
$this->db->or_like(''.$this->config->item('table_name').'.COL_VUCC_GRIDS', $id);
Expand Down Expand Up @@ -716,4 +716,4 @@ function get_qsos($num, $offset) {
}


}
}
64 changes: 63 additions & 1 deletion application/controllers/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

class User extends CI_Controller {

function __construct()
{
parent::__construct();

// Load language files
$this->lang->load(array(
'account',
));
}

public function index()
{
Expand Down Expand Up @@ -57,6 +66,10 @@ function add() {
$data['user_stylesheet'] = $this->input->post('user_stylesheet');
$data['user_sota_lookup'] = $this->input->post('user_sota_lookup');
$data['user_show_notes'] = $this->input->post('user_show_notes');
$data['user_column1'] = $this->input->post('user_column1');
$data['user_column2'] = $this->input->post('user_column2');
$data['user_column3'] = $this->input->post('user_column3');
$data['user_column4'] = $this->input->post('user_column4');
$this->load->view('user/add', $data);
} else {
$this->load->view('user/add', $data);
Expand All @@ -65,7 +78,24 @@ function add() {
}
else
{
switch($this->user_model->add($this->input->post('user_name'), $this->input->post('user_password'), $this->input->post('user_email'), $this->input->post('user_type'), $this->input->post('user_firstname'), $this->input->post('user_lastname'), $this->input->post('user_callsign'), $this->input->post('user_locator'), $this->input->post('user_timezone'), $this->input->post('user_measurement_base'), $this->input->post('user_date_format'), $this->input->post('user_stylesheet'), $this->input->post('user_sota_lookup'), $this->input->post('user_show_notes'))) {
switch($this->user_model->add($this->input->post('user_name'),
$this->input->post('user_password'),
$this->input->post('user_email'),
$this->input->post('user_type'),
$this->input->post('user_firstname'),
$this->input->post('user_lastname'),
$this->input->post('user_callsign'),
$this->input->post('user_locator'),
$this->input->post('user_timezone'),
$this->input->post('user_measurement_base'),
$this->input->post('user_date_format'),
$this->input->post('user_stylesheet'),
$this->input->post('user_sota_lookup'),
$this->input->post('user_show_notes'),
$this->input->post('user_column1'),
$this->input->post('user_column2'),
$this->input->post('user_column3'),
$this->input->post('user_column4'))) {
// Check for errors
case EUSERNAMEEXISTS:
$data['username_error'] = 'Username <b>'.$this->input->post('user_name').'</b> already in use!';
Expand Down Expand Up @@ -97,6 +127,10 @@ function add() {
$data['user_stylesheet'] = $this->input->post('user_stylesheet');
$data['user_sota_lookup'] = $this->input->post('user_sota_lookup');
$data['user_show_notes'] = $this->input->post('user_show_notes');
$data['user_column1'] = $this->input->post('user_column1');
$data['user_column2'] = $this->input->post('user_column2');
$data['user_column3'] = $this->input->post('user_column3');
$data['user_column4'] = $this->input->post('user_column4');
$this->load->view('user/add', $data);
$this->load->view('interface_assets/footer');
}
Expand Down Expand Up @@ -265,6 +299,30 @@ function edit() {
$data['user_show_notes'] = $q->user_show_notes;
}

if($this->input->post('user_column1')) {
$data['user_column1'] = $this->input->post('user_column1', true);
} else {
$data['user_column1'] = $q->user_column1;
}

if($this->input->post('user_column2')) {
$data['user_column2'] = $this->input->post('user_column2', true);
} else {
$data['user_column2'] = $q->user_column2;
}

if($this->input->post('user_column3')) {
$data['user_column3'] = $this->input->post('user_column3', true);
} else {
$data['user_column3'] = $q->user_column3;
}

if($this->input->post('user_column4')) {
$data['user_column4'] = $this->input->post('user_column4', true);
} else {
$data['user_column4'] = $q->user_column4;
}

$this->load->view('user/edit', $data);
$this->load->view('interface_assets/footer');
}
Expand Down Expand Up @@ -308,6 +366,10 @@ function edit() {
$data['user_stylesheet'] = $this->input->post('user_stylesheet');
$data['user_sota_lookup'] = $this->input->post('user_sota_lookup');
$data['user_show_notes'] = $this->input->post('user_show_notes');
$data['user_column1'] = $this->input->post('user_column1');
$data['user_column2'] = $this->input->post('user_column2');
$data['user_column3'] = $this->input->post('user_column3');
$data['user_column4'] = $this->input->post('user_column4');
$this->load->view('user/edit');
$this->load->view('interface_assets/footer');
}
Expand Down
9 changes: 9 additions & 0 deletions application/language/english/account_lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

defined('BASEPATH') OR exit('No direct script access allowed');

$lang['account_logbook_fields'] = 'Logbook fields';
$lang['account_column1_text'] = 'Choose column 1';
$lang['account_column2_text'] = 'Choose column 2';
$lang['account_column3_text'] = 'Choose column 3';
$lang['account_column4_text'] = 'Choose column 4';
3 changes: 3 additions & 0 deletions application/language/english/general_words_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
$lang['gen_hamradio_sota_reference'] = 'SOTA Reference';
$lang['gen_hamradio_wwff_reference'] = 'WWFF Reference';
$lang['gen_hamradio_dok'] = 'DOK';
$lang['gen_hamradio_state'] = 'State';
$lang['gen_hamradio_iota'] = 'IOTA';
$lang['gen_hamradio_gridsquare'] = 'Gridsquare';

$lang['gen_hamradio_sig'] = 'Sig';
$lang['gen_hamradio_sig_info'] = 'Sig Info';
Expand Down
46 changes: 46 additions & 0 deletions application/migrations/069_add_user_definable_columns.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

defined('BASEPATH') OR exit('No direct script access allowed');

/*
* This migration creates a table called options which will hold global options needed within cloudlog
* removing the need for lots of configuration files.
*/

class Migration_add_user_definable_columns extends CI_Migration {

public function up()
{
$fields = array(
'user_column1 varchar(32) default "Mode"',
);

$this->dbforge->add_column('users', $fields);

$fields = array(
'user_column2 varchar(32) default "RSTS"',
);

$this->dbforge->add_column('users', $fields);

$fields = array(
'user_column3 varchar(32) default "RSTR"',
);

$this->dbforge->add_column('users', $fields);

$fields = array(
'user_column4 varchar(32) default "Band"',
);

$this->dbforge->add_column('users', $fields);
}

public function down()
{
$this->dbforge->drop_column('users', 'user_column1');
$this->dbforge->drop_column('users', 'user_column2');
$this->dbforge->drop_column('users', 'user_column3');
$this->dbforge->drop_column('users', 'user_column4');
}
}
4 changes: 2 additions & 2 deletions application/models/Logbook_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ function get_qsos_for_printing() {
}

function get_qsos($num, $offset) {
$this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_NAME, '.$this->config->item('table_name').'.COL_COUNTRY, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*');
//$this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_NAME, '.$this->config->item('table_name').'.COL_COUNTRY, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*');
$this->db->from($this->config->item('table_name'));

$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
Expand Down Expand Up @@ -865,7 +865,7 @@ function get_last_qsos($num) {
$CI->load->model('Stations');
$station_id = $CI->Stations->find_active();

$this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_SUBMODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME, COL_STX_STRING, COL_SRX_STRING');
//$this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_SUBMODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME, COL_STX_STRING, COL_SRX_STRING, COL_IOTA, COL_STATE, COL_GRIDSQUARE');
$this->db->where("station_id", $station_id);
$this->db->order_by("COL_TIME_ON", "desc");
$this->db->limit($num);
Expand Down
Loading

0 comments on commit d6782e5

Please sign in to comment.