Started adding contesting features

pull/106/merge
Peter Goodhall 2011-08-17 16:12:41 +01:00
rodzic 052b820b42
commit fa545833d1
9 zmienionych plików z 324 dodań i 4 usunięć

Wyświetl plik

@ -0,0 +1,66 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Contest extends CI_Controller {
// Displays available contests
public function index()
{
$this->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');
}
}
}

Wyświetl plik

@ -0,0 +1,70 @@
<?php
class Contests extends CI_Model {
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function information($id) {
$this->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');
}
}
?>

Wyświetl plik

@ -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'));

Wyświetl plik

@ -0,0 +1,91 @@
<h2>Create Contest Template</h2>
<script>
$(function() {
$( ".datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' });
});
</script>
<div class="wrap_content note">
<?php echo validation_errors(); ?>
<?php echo form_open('contest/add_template'); ?>
<table>
<tr>
<td>Name</td>
<td><input type="text" name="contest_name" value="" /></td>
</tr>
<tr>
<td>Bands</td>
<td>
<input type="checkbox" name="160m" value="Y" /> 160m<br />
<input type="checkbox" name="80m" value="Y" /> 80m<br />
<input type="checkbox" name="40m" value="Y" /> 40m<br />
<input type="checkbox" name="20m" value="Y" /> 20m<br />
<input type="checkbox" name="15m" value="Y" /> 15m<br />
<input type="checkbox" name="10m" value="Y" /> 10m<br />
<input type="checkbox" name="6m" value="Y" /> 6m<br />
<input type="checkbox" name="4m" value="Y" /> 4m<br />
<input type="checkbox" name="2m" value="Y" /> 2m<br />
<input type="checkbox" name="70cm" value="Y" /> 70cm<br />
<input type="checkbox" name="23cm" value="Y" /> 23cm<br />
</td>
</tr>
<tr>
<td>Modes</td>
<td>
<input type="checkbox" name="SSB" value="SSB" /> SSB<br />
<input type="checkbox" name="CW" value="CW" /> CW<br />
</td>
</tr>
<tr>
<td>Requires Serial:</td>
<td>
<select name="serial_num">
<option value="Y" selected="selected">Yes</option>
<option value="N">N</option>
</select>
</td>
</tr>
<tr>
<td>Points Per KM</td>
<td><input type="text" name="points_per_km" value="" size="3"/><br />(If needed entered amount of points)</td>
</tr>
<tr>
<td>Gridsquare</td>
<td>
<select name="qra">
<option value="N" selected="selected">No</option>
<option value="Y">Yes</option>
</select>
</td>
</tr>
<tr>
<td>Other Exchange</td>
<td><input type="text" name="other_exch" value="" /></td>
</tr>
<tr>
<td>Scoring</td>
<td>
<select name="scoring">
<option value=""></option>
<option value="km*qra">Per KM x QRA</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td><div class="controls"><input type="submit" value="Create" /></div></td>
</tr>
</table>
</form>
</div>

Wyświetl plik

@ -0,0 +1,57 @@
<h2>Create Contest</h2>
<script>
$(function() {
$( ".datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' });
});
</script>
<div class="wrap_content note">
<?php echo validation_errors(); ?>
<?php echo form_open('contest/create'); ?>
<table>
<tr>
<td>Name</td>
<td><input type="text" name="contest_name" value="" /></td>
</tr>
<tr>
<td>Start Date</td>
<td><input type="text" name="start_date" value="" class="datepicker" /></td>
</tr>
<tr>
<td>Start Time</td>
<td><input type="text" name="start_time" value="hh:mm:ss" /></td>
</tr>
<tr>
<td>End Date</td>
<td><input type="text" name="end_date" value="" class="datepicker" /></td>
</tr>
<tr>
<td>End Time</td>
<td><input type="text" name="end_time" value="hh:mm:ss" /></td>
</tr>
<tr>
<td>Template</td>
<td>
<?php if ($templates->num_rows() > 0) { ?>
<select name="template">
<?php foreach ($templates->result() as $row) { ?>
<option value="<?php echo $row->id; ?>"><?php echo $row->name; ?></option>
<?php } ?>
</select>
<?php } ?>
</td>
</tr>
<tr>
<td></td>
<td><div class="controls"><input type="submit" value="Create" /></div></td>
</tr>
</table>
</form>
</div>

Wyświetl plik

@ -0,0 +1,6 @@
<div class="contest_wrap">
<h2>Contest - <?php echo $info->name; ?></h2>
<div class="contest_view">
</div>
</div>

Wyświetl plik

@ -0,0 +1,27 @@
<h2>Contests</h2>
<div class="wrap_content note">
<?php
if ($contests->num_rows() > 0)
{
echo "<ul class=\"notes_list\">";
foreach ($contests->result() as $row)
{
echo "<li>";
echo "<a href=\"".site_url()."/contest/view/".$row->id."\">".$row->name."</a>";
echo "</li>";
}
echo "</ul>";
} else {
echo "<p>You have no contests, why not create one!</p>";
}
?>
<p>
<a href="<?php echo site_url('contest/create'); ?>" title="Create Contest">Create a contest</a><br /><a href="<?php echo site_url('contest/add_template'); ?>" title="Create Template">Create a template</a>
</p>
</div>

Wyświetl plik

@ -75,6 +75,9 @@ line-height: 1.7;
margin: 10px 0;
}
.contest_wrap { margin: 0 auto; width: 95%; }
.contest_wrap h2 { margin: 0; width: 100%; font-weight: bold; font-size: 23px; margin-top: 5px; margin-bottom: 10px; }
.contest_view { margin: 0 auto; width: 100%; border: 1px solid #d7d7d7; background-color: #ffffff; padding: 5px; }
</style>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo $this->config->item('google_maps_api'); ?>&sensor=true"
@ -90,6 +93,7 @@ margin: 10px 0;
<li><a href="<?php echo site_url('logbook');?>" title="View Log">View Log</a></li>
<li><a href="<?php echo site_url('search');?>" title="Search">Search</a></li>
<li><a href="<?php echo site_url('qso');?>" title="Add QSO">Add QSO</a></li>
<li><a href="<?php echo site_url('contest');?>" title="Contests">Contests</a></li>
<li><a href="<?php echo site_url('notes');?>" title="Notes">Notes</a></li>
<li><a href="<?php echo site_url('statistics');?>" title="statistics">Statistics</a></li>
</ul>

Wyświetl plik

@ -69,18 +69,17 @@
</table>
<h3>QSLing</h3>
<table>
<tr>
<td>Sent</td>
<td><select name="qsl_sent">
<option value="N" <?php if($COL_QSL_SENT == "N" || $COL_QSL_SENT == null) { echo "selected=\"selected\""; } ?>>No</option>
<option value="N" <?php if($COL_QSL_SENT == "N") { echo "selected=\"selected\""; } ?>>No</option>
<option value="Y" <?php if($COL_QSL_SENT == "Y") { echo "selected=\"selected\""; } ?>>Yes</option>
<option value="R" <?php if($COL_QSL_SENT == "R") { echo "selected=\"selected\""; } ?>>Requested</option>
</select></td>
<td>Recv</td>
<td><select name="qsl_recv">
<option value="N" <?php if($COL_QSL_RCVD == "N" || $COL_QSL_RCVD == null) { echo "selected=\"selected\""; } ?>>No</option>
<option value="N" <?php if($COL_QSL_RCVD == "N") { echo "selected=\"selected\""; } ?>>No</option>
<option value="Y" <?php if($COL_QSL_RCVD == "Y") { echo "selected=\"selected\""; } ?>>Yes</option>
<option value="R" <?php if($COL_QSL_RCVD == "R") { echo "selected=\"selected\""; } ?>>Requested</option>
</select></td>