diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 755c8246..0d924477 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -257,6 +257,23 @@ class Awards extends CI_Controller { $this->load->view('interface_assets/footer'); } + /* + Handles showing worked POTAs + Comment field - POTA:# + */ + public function pota() { + + // Grab all worked pota stations + $this->load->model('pota'); + $data['pota_all'] = $this->pota->get_all(); + + // Render page + $data['page_title'] = "Awards - POTA"; + $this->load->view('interface_assets/header', $data); + $this->load->view('awards/pota/index'); + $this->load->view('interface_assets/footer'); + } + public function cq() { $CI =& get_instance(); $CI->load->model('logbooks_model'); diff --git a/application/migrations/102_add_pota_columns.php b/application/migrations/102_add_pota_columns.php index 204857da..1bb206a4 100644 --- a/application/migrations/102_add_pota_columns.php +++ b/application/migrations/102_add_pota_columns.php @@ -37,6 +37,17 @@ class Migration_add_pota_columns extends CI_Migration { ); $this->dbforge->add_column('station_profile', $fields); } + if (!$this->db->field_exists('pota', 'bandxuser')) { + $fields = array( + 'pota' => array( + 'type' => 'INT', + 'constraint' => 20, + 'unsigned' => TRUE, + ), + ); + $this->dbforge->add_column('bandxuser', $fields); + $this->db->query("update bandxuser set pota = 1"); + } } public function down() @@ -50,5 +61,8 @@ class Migration_add_pota_columns extends CI_Migration { if ($this->db->field_exists('station_pota', 'station_profile')) { $this->dbforge->drop_column('station_profile', 'station_pota'); } + if ($this->db->field_exists('pota', 'bandxuser')) { + $this->dbforge->drop_column('bandxuser', 'pota'); + } } } diff --git a/application/models/Bands.php b/application/models/Bands.php index a31582e5..73696862 100644 --- a/application/models/Bands.php +++ b/application/models/Bands.php @@ -247,6 +247,7 @@ class Bands extends CI_Model { 'dok' => $band['dok'] == "true" ? '1' : '0', 'dxcc' => $band['dxcc'] == "true" ? '1' : '0', 'iota' => $band['iota'] == "true" ? '1' : '0', + 'pota' => $band['pota'] == "true" ? '1' : '0', 'sig' => $band['sig'] == "true" ? '1' : '0', 'sota' => $band['sota'] == "true" ? '1' : '0', 'uscounties' => $band['uscounties'] == "true" ? '1' : '0', @@ -279,8 +280,8 @@ class Bands extends CI_Model { $this->db->insert('bands', $data); } - $this->db->query("insert into bandxuser (bandid, userid, active, cq, dok, dxcc, iota, sig, sota, uscounties, was, wwff, vucc) - select bands.id, " . $this->session->userdata('user_id') . ", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 from bands where band ='".$data['band']."' and not exists (select 1 from bandxuser where userid = " . $this->session->userdata('user_id') . " and bandid = bands.id);"); + $this->db->query("insert into bandxuser (bandid, userid, active, cq, dok, dxcc, iota, pota, sig, sota, uscounties, was, wwff, vucc) + select bands.id, " . $this->session->userdata('user_id') . ", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 from bands where band ='".$data['band']."' and not exists (select 1 from bandxuser where userid = " . $this->session->userdata('user_id') . " and bandid = bands.id);"); } function getband($id) { @@ -305,4 +306,4 @@ class Bands extends CI_Model { } } -?> \ No newline at end of file +?> diff --git a/application/models/Pota.php b/application/models/Pota.php new file mode 100644 index 00000000..117a8c42 --- /dev/null +++ b/application/models/Pota.php @@ -0,0 +1,27 @@ +load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + if (!$logbooks_locations_array) { + return null; + } + + $this->load->model('bands'); + + $bandslots = $this->bands->get_worked_bands('pota'); + + $this->db->where_in("station_id", $logbooks_locations_array); + $this->db->where_in("col_band", $bandslots); + $this->db->order_by("COL_POTA_REF", "ASC"); + $this->db->where('COL_POTA_REF !=', ''); + + return $this->db->get($this->config->item('table_name')); + } +} + +?> diff --git a/application/models/User_model.php b/application/models/User_model.php index 2292ed0b..2d2cb88f 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -152,7 +152,7 @@ class User_Model extends CI_Model { // Add user and insert bandsettings for user $this->db->insert($this->config->item('auth_table'), $data); $insert_id = $this->db->insert_id(); - $this->db->query("insert into bandxuser (bandid, userid, active, cq, dok, dxcc, iota, sig, sota, uscounties, was, wwff, vucc) select bands.id, " . $insert_id . ", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 from bands;"); + $this->db->query("insert into bandxuser (bandid, userid, active, cq, dok, dxcc, iota, pota, sig, sota, uscounties, was, wwff, vucc) select bands.id, " . $insert_id . ", 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 from bands;"); return OK; } else { return EUSERNAMEEXISTS; diff --git a/application/views/awards/pota/index.php b/application/views/awards/pota/index.php new file mode 100644 index 00000000..65d4abe8 --- /dev/null +++ b/application/views/awards/pota/index.php @@ -0,0 +1,44 @@ +
| Reference | +Date/Time | +Callsign | +Band | +RST Sent | +RST Received | +
| + COL_POTA_REF; ?> + | +COL_TIME_ON); echo date('d/m/y', $timestamp); ?> - COL_TIME_ON); echo date('H:i', $timestamp); ?> | +COL_CALL; ?> | +COL_BAND; ?> | +COL_RST_SENT; ?> | +COL_RST_RCVD; ?> | +