diff --git a/application/config/migration.php b/application/config/migration.php index 09355286..49ca7587 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -4,7 +4,7 @@ | Enable/Disable Migrations |-------------------------------------------------------------------------- | -| Migrations are disabled by default but should be enabled +| Migrations are disabled by default but should be enabled | whenever you intend to do a schema migration. | */ @@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 62; +$config['migration_version'] = 63; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Contesting.php b/application/controllers/Contesting.php index c466a08d..b9996ccb 100644 --- a/application/controllers/Contesting.php +++ b/application/controllers/Contesting.php @@ -13,7 +13,7 @@ class Contesting extends CI_Controller { { parent::__construct(); $this->lang->load('contesting'); - + $this->load->model('user_model'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } } @@ -26,13 +26,14 @@ class Contesting extends CI_Controller { $this->load->model('logbook_model'); $this->load->model('user_model'); $this->load->model('modes'); + $this->load->model('contesting_model'); $data['active_station_profile'] = $this->stations->find_active(); $data['notice'] = false; $data['stations'] = $this->stations->all(); $data['radios'] = $this->cat->radios(); - $data['dxcc'] = $this->logbook_model->fetchDxcc(); $data['modes'] = $this->modes->active(); + $data['contestnames'] = $this->contesting_model->getActivecontests(); $this->load->library('form_validation'); @@ -71,4 +72,90 @@ class Contesting extends CI_Controller { return json_encode($data); } -} \ No newline at end of file + + public function create() + { + $this->load->model('Contesting_model'); + $this->load->library('form_validation'); + + $this->form_validation->set_rules('name', 'Contest Name', 'required'); + $this->form_validation->set_rules('adifname', 'Contest Adif Name', 'required'); + + if ($this->form_validation->run() == FALSE) + { + $data['page_title'] = "Create Mode"; + $this->load->view('contesting/create', $data); + } + else + { + $this->Contesting_model->add(); + } + } + + public function add() { + $this->load->model('Contesting_model'); + + $data['contests'] = $this->Contesting_model->getAllContests(); + + // Render Page + $data['page_title'] = "Contests"; + $this->load->view('interface_assets/header', $data); + $this->load->view('contesting/add'); + $this->load->view('interface_assets/footer'); + } + + public function edit($id) + { + $this->load->library('form_validation'); + + $this->load->model('Contesting_model'); + + $item_id_clean = $this->security->xss_clean($id); + + $data['contest'] = $this->Contesting_model->contest($item_id_clean); + + $data['page_title'] = "Edit Contest"; + + $this->form_validation->set_rules('name', 'Contest Name', 'required'); + $this->form_validation->set_rules('adifname', 'Adif Contest Name', 'required'); + + if ($this->form_validation->run() == FALSE) + { + $this->load->view('interface_assets/header', $data); + $this->load->view('contesting/edit'); + $this->load->view('interface_assets/footer'); + } + else + { + $this->Contesting_model->edit($item_id_clean); + + $data['notice'] = "Contest ".$this->security->xss_clean($this->input->post('name', true))." Updated"; + + redirect('contesting/add'); + } + } + + public function delete() { + $id = $this->input->post('id'); + $this->load->model('Contesting_model'); + $this->Contesting_model->delete($id); + } + + public function activate() { + $id = $this->input->post('id'); + $this->load->model('Contesting_model'); + $this->Contesting_model->activate($id); + header('Content-Type: application/json'); + echo json_encode(array('message' => 'OK')); + return; + } + + public function deactivate() { + $id = $this->input->post('id'); + $this->load->model('Contesting_model'); + $this->Contesting_model->deactivate($id); + header('Content-Type: application/json'); + echo json_encode(array('message' => 'OK')); + return; + } +} diff --git a/application/models/Contesting_model.php b/application/models/Contesting_model.php index 5a0b022a..1b6d60d8 100644 --- a/application/models/Contesting_model.php +++ b/application/models/Contesting_model.php @@ -32,4 +32,91 @@ class Contesting_model extends CI_Model { header('Content-Type: application/json'); echo json_encode($data->result()); } -} \ No newline at end of file + + function getActivecontests() { + + $sql = "SELECT name, adifname FROM contest WHERE active = 1 ORDER BY name ASC"; + + $data = $this->db->query($sql); + + return($data->result_array()); + } + + function getAllContests() { + + $sql = "SELECT id, name, adifname, active FROM contest ORDER BY name ASC"; + + $data = $this->db->query($sql); + + return($data->result_array()); + } + + function delete($id) { + // Clean ID + $clean_id = $this->security->xss_clean($id); + + // Delete Contest + $this->db->delete('contest', array('id' => $clean_id)); + } + + function activate($id) { + // Clean ID + $clean_id = $this->security->xss_clean($id); + + $data = array( + 'active' => '1', + ); + + $this->db->where('id', $clean_id); + + $this->db->update('contest', $data); + + return true; + } + + function deactivate($id) { + // Clean ID + $clean_id = $this->security->xss_clean($id); + + $data = array( + 'active' => '0', + ); + + $this->db->where('id', $clean_id); + + $this->db->update('contest', $data); + + return true; + } + + function add() { + $data = array( + 'name' => xss_clean($this->input->post('name', true)), + 'adifname' => xss_clean($this->input->post('adifname', true)), + ); + + $this->db->insert('contest', $data); + } + + function contest($id) { + // Clean ID + $clean_id = $this->security->xss_clean($id); + + $sql = "SELECT id, name, adifname, active FROM contest where id =" . $clean_id; + + $data = $this->db->query($sql); + + return ($data->row()); + } + + function edit($id) { + $data = array( + 'name' => xss_clean($this->input->post('name', true)), + 'adifname' => xss_clean($this->input->post('adifname', true)), + 'active' => xss_clean($this->input->post('active', true)), + ); + + $this->db->where('id', $id); + $this->db->update('contest', $data); + } +} diff --git a/application/views/contesting/add.php b/application/views/contesting/add.php new file mode 100644 index 00000000..661b6830 --- /dev/null +++ b/application/views/contesting/add.php @@ -0,0 +1,64 @@ +
+ +
+ session->flashdata('message')) { ?> + +
+

session->flashdata('message'); ?>

+
+ + +

+ +
+
+ Contests +
+
+

+ Using the contest list, you can control which Contests are shown when logging QSOs in a contest. +

+

+ Active contests will be shown in the Contest Name drop-down, while inactive contests will be hidden and cannot be selected. +

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
NameAdif modeActive
'> + Deactivate"; + } else { + echo ""; + };?> + + " class="btn btn-outline-primary btn-sm"> Edit + + Delete +
+ +
+

+ + diff --git a/application/views/contesting/create.php b/application/views/contesting/create.php new file mode 100644 index 00000000..5437fa4d --- /dev/null +++ b/application/views/contesting/create.php @@ -0,0 +1,38 @@ + +
+ +
+ session->flashdata('message')) { ?> + +
+

session->flashdata('message'); ?>

+
+ + + session->flashdata('notice')) { ?> +
+ session->flashdata('notice'); ?> +
+ + + load->helper('form'); ?> + + + +
+
+ + + Name of Contest +
+ +
+ + + Name of Contest in ADIF-specification +
+ + + + +
diff --git a/application/views/contesting/edit.php b/application/views/contesting/edit.php new file mode 100644 index 00000000..dfe967b1 --- /dev/null +++ b/application/views/contesting/edit.php @@ -0,0 +1,61 @@ + +
+ +
+ session->flashdata('message')) { ?> + +
+

session->flashdata('message'); ?>

+
+ + +
+
+ +
+
+
+

+ session->flashdata('notice')) { ?> +
+ session->flashdata('notice'); ?> +
+ + + load->helper('form'); ?> + + + +
+
+ + name; } ?>" required> + Name of Contest +
+ +
+ + adifname; } ?>"> + Name of Contest in ADIF-specification +
+ +
+ + + Set to active if to be listed in Contest-list +
+ + + + +
+
+ +
+ +
diff --git a/application/views/contesting/index.php b/application/views/contesting/index.php index ff0a2451..2b482085 100644 --- a/application/views/contesting/index.php +++ b/application/views/contesting/index.php @@ -9,13 +9,13 @@
- +
- +
@@ -23,236 +23,12 @@
- +
@@ -361,7 +137,7 @@
- +
@@ -373,7 +149,7 @@
- + @@ -406,7 +182,7 @@ - +
lang->line('gen_hamradio_exchange_recv_short'); ?>
diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 67f233d2..b075c5dc 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -139,7 +139,7 @@ $('[data-fancybox]').fancybox({ iframe : { preload : false } -}); +}); @@ -156,7 +156,7 @@ $('[data-fancybox]').fancybox({ var q_lat = ; - var q_lng = ; + var q_lng = ; var q_lat = 40.313043; var q_lng = -32.695312; @@ -187,7 +187,7 @@ $('[data-fancybox]').fancybox({ var q_lat = ; - var q_lng = ; + var q_lng = ; var q_lat = 40.313043; var q_lng = -32.695312; @@ -218,7 +218,7 @@ $('[data-fancybox]').fancybox({ var q_lat = ; - var q_lng = ; + var q_lng = ; var q_lat = 40.313043; var q_lng = -32.695312; @@ -274,8 +274,8 @@ $(document).ready(function(){ $('#partial_view').load("logbook/search_result/input->post('callsign'); ?>", function() { }); - -$(document).on('keypress',function(e) { + +$(document).on('keypress',function(e) { if(e.which == 13) { if ($('#callsign').val()) { @@ -299,7 +299,7 @@ $(document).on('keypress',function(e) { + + +uri->segment(1) == "contesting" && $this->uri->segment(2) == "add") { ?> + + diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index abfe91fc..96a7cbac 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -54,7 +54,7 @@