diff --git a/application/controllers/contest.php b/application/controllers/contest.php deleted file mode 100644 index 9888825f..00000000 --- a/application/controllers/contest.php +++ /dev/null @@ -1,133 +0,0 @@ -load->model('logbook_model'); - $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'); } - - // Load database items - $this->load->model('contests'); - $data['contests'] = $this->contests->list_contests(); - - // Load views - $this->load->view('layout/header'); - $this->load->view('contest/main', $data); - $this->load->view('layout/footer'); - } - - /* - Displays contest logging view based on the ID provided, allowing users to log in contest mode giving them serial numbers and scoring information. - */ - public function view($id) { - $this->load->model('logbook_model'); - $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'); } - - // Load database information - $this->load->model('contests'); - - $data['info'] = $this->contests->information($id); - $data['log'] = $this->contests->contest_log_view($data['info']->start, $data['info']->end, $data['info']); - $data['summary'] = $this->contests->contest_summary_bands($data['info']->start, $data['info']->end, $data['info']); - - // Run validation checks on QSO submission - $this->load->library('form_validation'); - - $this->form_validation->set_rules('start_time', 'Time', 'required'); - $this->form_validation->set_rules('callsign', 'Callsign', 'required'); - $this->form_validation->set_rules('sent_serial', 'Sent Serial Number', 'required'); - $this->form_validation->set_rules('rst_recv', 'Recevied RST', 'required'); - $this->form_validation->set_rules('recv_serial', 'Received Serial Number', 'required'); - - if($data['info']->qra == "Y") { - $this->form_validation->set_rules('locator', 'Received QRA', 'required'); - } - - // Load Views - if ($this->form_validation->run() == FALSE) - { - $this->load->view('layout/header'); - $this->load->view('contest/log', $data); - $this->load->view('layout/footer'); - } else { - $contest_id = $id; - // Add QSO - $this->contests->add($contest_id); - - // Store Basic QSO Info for reuse - $this->session->set_userdata('band', $this->input->post('band')); - $this->session->set_userdata('freq', $this->input->post('freq')); - $this->session->set_userdata('mode', $this->input->post('mode')); - - $data['info'] = $this->contests->information($id); - $data['log'] = $this->contests->contest_log_view($data['info']->start, $data['info']->end, $data['info']); - - // Set Any Notice Messages - $data['notice'] = "QSO Added"; - - $this->load->view('layout/header'); - $this->load->view('contest/log', $data); - $this->load->view('layout/footer'); - } - } - - /* - Create a contest, these are linked to templates for scoring information. contests are per entry like a weekly RSGB Club contest etc. - */ - public function create() { - $this->load->model('logbook_model'); - $this->load->model('user_model'); - $this->load->model('contests'); - if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } - - $data['templates'] = $this->contests->list_templates(); - - $this->load->helper(array('form', 'url')); - - // Run Validation - $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'); - } - } - - /* - Create a template, Contest Templates are sets of parameters for a series or single contest selecting items like scoring, bands and modes available. - */ - public function add_template() { - - $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'); } - - $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'); - } - } -} diff --git a/application/models/contests.php b/application/models/contests.php deleted file mode 100644 index 4bcf77cd..00000000 --- a/application/models/contests.php +++ /dev/null @@ -1,165 +0,0 @@ -db->select('*'); - $this->db->from('contests'); - $this->db->where('contests.template', $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'); - } - - function contest_summary_bands($start_date, $end_date, $info) { - $query = $this->db->query('SELECT DISTINCT (COL_BAND) AS band, count( * ) AS count, COL_TIME_ON FROM '.$this->config->item('table_name').' WHERE COL_TIME_ON >= \''.$start_date.'\' AND COL_TIME_ON <= \''.$end_date.'\' GROUP BY band ORDER BY count DESC'); - - return $query; - } - - function contest_log_view($start_date, $end_date, $info) { - $this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_NAME,COL_STX_STRING,COL_SRX_STRING, COL_COUNTRY, COL_PRIMARY_KEY'); - $this->db->where('COL_TIME_ON >=', $start_date); - $this->db->where('COL_TIME_ON <=', $end_date); - if($info->band_160 == "Y") { - $this->db->where('COL_BAND', '160m'); - } - if($info->band_80 == "Y") { - $this->db->where('COL_BAND', '80m'); - } - if($info->band_40 == "Y") { - $this->db->where('COL_BAND', '40m'); - } - if($info->band_20 == "Y") { - $this->db->where('COL_BAND', '20m'); - } - if($info->band_15 == "Y") { - $this->db->where('COL_BAND', '15m'); - } - if($info->band_10 == "Y") { - $this->db->where('COL_BAND', '10m'); - } - if($info->band_6m == "Y") { - $this->db->where('COL_BAND', '6m'); - } - if($info->band_4m == "Y") { - $this->db->where('COL_BAND', '4m'); - } - if($info->band_2m == "Y") { - $this->db->where('COL_BAND', '2m'); - } - if($info->band_70cm == "Y") { - $this->db->where('COL_BAND', '70cm'); - } - if($info->band_23cm == "Y") { - $this->db->where('COL_BAND', '23cm'); - } - if($info->mode_ssb == "Y") { - $this->db->where('COL_MODE', 'SSB'); - } - if($info->mode_cw == "Y") { - $this->db->where('COL_MODE', 'CW'); - } - //$this->db->order_by("COL_PRIMARY_KEY", "asc"); - $this->db->order_by("COL_TIME_ON", "desc"); - //$this->db->order_by("COL_STX_STRING", "ASC"); - $this->db->limit(10); - - return $this->db->get($this->config->item('table_name')); - - } - - function add($contest_id) { - // Join date+time - $datetime = date('Y-m-d') ." ". $this->input->post('start_time'); - - // Create array with QSO Data - $data = array( - 'COL_TIME_ON' => $datetime, - 'COL_TIME_OFF' => $datetime, - 'COL_CALL' => strtoupper($this->input->post('callsign')), - 'COL_BAND' => $this->input->post('band'), - 'COL_FREQ' => $this->input->post('freq'), - 'COL_MODE' => $this->input->post('mode'), - 'COL_RST_RCVD' => $this->input->post('rst_recv'), - 'COL_SRX_STRING' => $this->input->post('recv_serial'), - 'COL_RST_SENT' => $this->input->post('rst_sent'), - 'COL_STX_STRING' => $this->input->post('sent_serial'), - 'COL_GRIDSQUARE' => $this->input->post('locator'), - 'COL_COUNTRY' => $this->input->post('country'), - 'COL_QSLSDATE' => date('Y-m-d'), - 'COL_QSLRDATE' => date('Y-m-d'), - 'COL_QSL_SENT' => 'N', - 'COL_QSL_RCVD' => 'N', - 'COL_OPERATOR' => $this->session->userdata('user_callsign'), - ); - - // Add QSO to database - $this->db->insert($this->config->item('table_name'), $data); - - // Update contest file stored serial number. - $data = array( - 'serial_num' => $this->input->post('sent_serial'), - ); - - $this->db->where('id', $contest_id); - $this->db->update('contests', $data); - } - -} - -?> \ No newline at end of file diff --git a/application/views/contest/add_template.php b/application/views/contest/add_template.php deleted file mode 100644 index 3327287d..00000000 --- a/application/views/contest/add_template.php +++ /dev/null @@ -1,91 +0,0 @@ -
| 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) { ?> - - - | -
| - | - |
| Date | -Time | -Band | -Call | -Mode | -RST(S) | -Serial | -Recv | -Serial | -COL_TIME_ON); echo date('d/m/y', $timestamp); ?> | -COL_TIME_ON); echo date('H:i', $timestamp); ?> | -COL_BAND; ?> | -COL_PRIMARY_KEY; ?>">COL_CALL); ?> | -COL_MODE; ?> | -COL_RST_SENT; ?> | -COL_STX_STRING; ?> | -COL_RST_RCVD; ?> | -COL_SRX_STRING; ?> | - - - - -
You have no contests, why not create one!
"; - } - -?> -