diff --git a/application/controllers/contest.php b/application/controllers/contest.php new file mode 100644 index 00000000..618a6b9f --- /dev/null +++ b/application/controllers/contest.php @@ -0,0 +1,66 @@ +load->model('contests'); + $data['contests'] = $this->contests->list_contests(); + + $this->load->view('layout/header'); + $this->load->view('contest/main', $data); + $this->load->view('layout/footer'); + } + + public function view($id) { + $this->load->model('contests'); + $data['info'] = $this->contests->information($id); + + $this->load->view('layout/header'); + $this->load->view('contest/log', $data); + $this->load->view('layout/footer'); + } + + // Create a contest + public function create() { + $this->load->model('contests'); + $data['templates'] = $this->contests->list_templates(); + + $this->load->helper(array('form', 'url')); + $this->load->library('form_validation'); + + $this->form_validation->set_rules('contest_name', 'Contest Name', 'required'); + + if ($this->form_validation->run() == FALSE) + { + $this->load->view('layout/header'); + $this->load->view('contest/create', $data); + $this->load->view('layout/footer'); + } else { + $this->load->model('contests'); + $this->contests->create_contest(); + redirect('contest'); + } + } + + public function add_template() { + + $this->load->helper(array('form', 'url')); + $this->load->library('form_validation'); + + $this->form_validation->set_rules('contest_name', 'Contest Name', 'required'); + + if ($this->form_validation->run() == FALSE) + { + $this->load->view('layout/header'); + $this->load->view('contest/add_template'); + $this->load->view('layout/footer'); + } else { + $this->load->model('contests'); + $this->contests->create_template(); + redirect('contest'); + } + } +} \ No newline at end of file diff --git a/application/models/contests.php b/application/models/contests.php new file mode 100644 index 00000000..cdf36424 --- /dev/null +++ b/application/models/contests.php @@ -0,0 +1,70 @@ +db->select('*'); + $this->db->from('contests'); + //$this->db->where('id', $id); + $this->db->join('contest_template', 'contest_template.id = contests.template'); + $query = $this->db->get(); + return $query->row(); + } + + function create_template() { + $data = array( + 'name' => $this->input->post('contest_name'), + 'band_160' => $this->input->post('160m'), + 'band_80' => $this->input->post('80m'), + 'band_40' => $this->input->post('40m'), + 'band_20' => $this->input->post('20m'), + 'band_15' => $this->input->post('15m'), + 'band_10' => $this->input->post('10m'), + 'band_6m' => $this->input->post('6m'), + 'band_4m' => $this->input->post('4m'), + 'band_2m' => $this->input->post('2m'), + 'band_70cm' => $this->input->post('70cm'), + 'band_23cm' => $this->input->post('23cm'), + 'mode_ssb' => $this->input->post('SSB'), + 'mode_cw' => $this->input->post('CW'), + 'serial' => $this->input->post('serial_num'), + 'point_per_km' => $this->input->post('points_per_km'), + 'qra' => $this->input->post('qra'), + 'other_exch' => $this->input->post('other_exch'), + 'scoring' => $this->input->post('scoring'), + ); + + $this->db->insert('contest_template', $data); + } + + + function create_contest() { + $start = $this->input->post('start_date')." ".$this->input->post('start_time'); + $end = $this->input->post('end_date')." ".$this->input->post('end_time'); + $data = array( + 'name' => $this->input->post('contest_name'), + 'start' => $start, + 'end' => $end, + 'template' => $this->input->post('template'), + ); + + $this->db->insert('contests', $data); + } + + function list_templates() { + return $this->db->get('contest_template'); + } + + function list_contests() { + return $this->db->get('contests'); + } + +} + +?> \ No newline at end of file diff --git a/application/models/logbook_model.php b/application/models/logbook_model.php index e4d3d625..fd030744 100644 --- a/application/models/logbook_model.php +++ b/application/models/logbook_model.php @@ -74,7 +74,7 @@ class Logbook_model extends CI_Model { /* Return last 10 QSOs */ function last_ten() { $this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY'); - $this->db->order_by("COL_TIME_ON", "desc"); + $this->db->order_by("COL_TIME_ON", "desc"); $this->db->limit(10); return $this->db->get($this->config->item('table_name')); diff --git a/application/views/contest/add_template.php b/application/views/contest/add_template.php new file mode 100644 index 00000000..3327287d --- /dev/null +++ b/application/views/contest/add_template.php @@ -0,0 +1,91 @@ +
| Name | ++ |
| Bands | +
+ 160m + 80m + 40m + 20m + 15m + 10m + 6m + 4m + 2m + 70cm + 23cm + |
+
| Modes | +
+ SSB + CW + |
+
| Requires Serial: | ++ + | +
| Points Per KM | +(If needed entered amount of points) |
+
| Gridsquare | ++ + | +
| Other Exchange | ++ |
| Scoring | ++ + | +
| + | + |
| Name | ++ |
| Start Date | ++ |
| Start Time | ++ |
| End Date | ++ |
| End Time | ++ |
| Template | ++ num_rows() > 0) { ?> + + + | +
| + | + |
You have no contests, why not create one!
"; + } + +?> + + + +