Cloudlog/application/controllers/qso.php

107 行
2.9 KiB
PHP

2011-04-25 23:24:01 +08:00
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
TODO
- Update Edit
- Store Radio Information
- Upload to clublog (request api key)
*/
2011-04-25 23:24:01 +08:00
class QSO extends CI_Controller {
public function index()
{
2011-07-22 08:08:47 +08:00
$this->load->model('logbook_model');
2011-08-20 00:12:13 +08:00
$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'); }
2011-07-22 08:08:47 +08:00
$data['notice'] = false;
2011-07-22 08:08:47 +08:00
$data['query'] = $this->logbook_model->last_ten();
$this->load->library('form_validation');
$this->form_validation->set_rules('start_date', 'Date', 'required');
$this->form_validation->set_rules('start_time', 'Time', 'required');
$this->form_validation->set_rules('callsign', 'Callsign', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('layout/header');
$this->load->view('qso/index', $data);
$this->load->view('layout/footer');
}
else
{
2011-07-22 08:08:47 +08:00
// Add QSO
$this->logbook_model->add();
2011-07-22 08:08:47 +08:00
// 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'));
2011-07-22 07:10:09 +08:00
$this->session->set_userdata('sat_name', $this->input->post('sat_name'));
$this->session->set_userdata('sat_mode', $this->input->post('sat_mode'));
2011-07-22 08:08:47 +08:00
// Get last Ten QSOs
$data['query'] = $this->logbook_model->last_ten();
2011-07-22 08:08:47 +08:00
// Set Any Notice Messages
$data['notice'] = "QSO Added";
2011-07-22 08:08:47 +08:00
// Load view to create another contact
$this->load->view('layout/header');
$this->load->view('qso/index', $data);
$this->load->view('layout/footer');
}
}
function edit() {
2011-07-22 08:08:47 +08:00
$this->load->model('logbook_model');
2011-08-20 00:12:13 +08:00
$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'); }
2011-07-22 08:08:47 +08:00
$query = $this->logbook_model->qso_info($this->uri->segment(3));
$this->load->library('form_validation');
$this->form_validation->set_rules('time_on', 'Start Date', 'required');
$this->form_validation->set_rules('time_off', 'End Date', 'required');
$this->form_validation->set_rules('callsign', 'Callsign', 'required');
$data = $query->row();
2011-07-22 08:08:47 +08:00
if ($this->form_validation->run() == FALSE)
{
$this->load->view('layout/header');
$this->load->view('qso/edit', $data);
$this->load->view('layout/footer');
}
else
{
2011-07-22 08:08:47 +08:00
$this->logbook_model->edit();
$this->session->set_flashdata('notice', 'Record Updated');
redirect('logbook');
}
}
/* Delete QSO */
function delete($id) {
$this->load->model('logbook_model');
$this->logbook_model->delete($id);
$this->session->set_flashdata('notice', 'QSO Deleted Successfully');
redirect('logbook');
2011-04-25 23:24:01 +08:00
}
function freq() {
$this->load->library('frequency');
echo $this->frequency->convent_band('40m', 'SSB');
}
2011-08-20 00:12:13 +08:00
}