2019-09-11 17:38:09 +01:00
|
|
|
<?php
|
|
|
|
|
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
|
|
|
|
|
|
/*
|
2021-10-07 21:42:19 +02:00
|
|
|
This controller contains features for contesting
|
2019-09-11 17:38:09 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class Contesting extends CI_Controller {
|
|
|
|
|
|
2021-10-07 21:42:19 +02:00
|
|
|
function __construct() {
|
2021-01-05 16:14:50 +00:00
|
|
|
parent::__construct();
|
|
|
|
|
$this->lang->load('contesting');
|
2021-02-12 23:27:08 +01:00
|
|
|
|
2021-01-05 16:14:50 +00: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'); }
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-07 21:42:19 +02:00
|
|
|
public function index() {
|
2020-11-08 10:46:08 +01:00
|
|
|
$this->load->model('cat');
|
|
|
|
|
$this->load->model('stations');
|
|
|
|
|
$this->load->model('modes');
|
2021-02-12 23:27:08 +01:00
|
|
|
$this->load->model('contesting_model');
|
2022-09-08 20:19:41 +02:00
|
|
|
$this->load->model('bands');
|
2020-11-08 10:46:08 +01:00
|
|
|
|
2021-10-07 21:42:19 +02:00
|
|
|
$data['my_gridsquare'] = $this->stations->find_gridsquare();
|
2020-11-08 10:46:08 +01:00
|
|
|
$data['radios'] = $this->cat->radios();
|
|
|
|
|
$data['modes'] = $this->modes->active();
|
2021-02-12 23:27:08 +01:00
|
|
|
$data['contestnames'] = $this->contesting_model->getActivecontests();
|
2022-09-08 20:19:41 +02:00
|
|
|
$data['bands'] = $this->bands->get_user_bands_for_qso_entry();
|
Add Cabrillo export modal & format improvements
Add a full Cabrillo export workflow and harden Cabrillo/QSO formatting. Introduces a modal UI to export contest logs (new button + modal form with fields for location, category time, operators, club, soapbox, date range and other Cabrillo categories). Controller updates pass the new fields to the export action. Cabrilloformat library extended to accept and emit LOCATION and CATEGORY-TIME, improve header field ordering and presence checks, map ADIF modes to the five Cabrillo modes (CW/PH/FM/RY/DG), fix a band label (2.4G -> 2.3G), and emit placeholders for missing received exchanges to preserve column alignment. Contesting_model: more robust date parsing with UTC fallback, ensure session QSO marker only persists when timestamp valid, and build start timestamp when LIVE mode omits start_date/start_time. Frontend JS: setSession() now returns the ajax promise so callers can await it; several callers updated to await setSession and re-fetch session data before refreshing the QSO table; restore full table search on callsign blur and when suggestions are cleared. Misc: small form/input fixes (club field type, default overlay option) and additional server-supplied data loaded into the contesting view (active station id, contest session, station profile). These changes add required Cabrillo fields for certain contests and make exports and session handling more reliable.
2026-03-27 00:04:21 +00:00
|
|
|
$data['active_station_id'] = $this->stations->find_active();
|
|
|
|
|
$data['contest_session'] = $this->contesting_model->getSession();
|
|
|
|
|
$data['station_profile'] = $this->stations->all_of_user();
|
2020-11-08 10:46:08 +01:00
|
|
|
|
2021-10-07 21:42:19 +02:00
|
|
|
$this->load->library('form_validation');
|
2020-11-08 10:46:08 +01:00
|
|
|
|
|
|
|
|
$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');
|
|
|
|
|
|
2021-10-07 21:42:19 +02:00
|
|
|
$data['page_title'] = "Contest Logging";
|
2020-11-08 10:46:08 +01:00
|
|
|
|
2021-10-07 21:42:19 +02:00
|
|
|
$this->load->view('interface_assets/header', $data);
|
|
|
|
|
$this->load->view('contesting/index');
|
|
|
|
|
$this->load->view('interface_assets/footer');
|
2020-11-08 10:46:08 +01:00
|
|
|
}
|
2020-12-28 19:55:51 +01:00
|
|
|
|
|
|
|
|
public function getSessionQsos() {
|
|
|
|
|
$this->load->model('Contesting_model');
|
|
|
|
|
|
|
|
|
|
$qso = $this->input->post('qso');
|
|
|
|
|
|
2023-04-10 18:54:24 +02:00
|
|
|
header('Content-Type: application/json');
|
|
|
|
|
echo json_encode($this->Contesting_model->getSessionQsos($qso));
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-14 18:04:35 +00:00
|
|
|
public function getSessionFreshQsos() {
|
|
|
|
|
$this->load->model('Contesting_model');
|
|
|
|
|
|
|
|
|
|
$contest_id = $this->input->post('contest_id');
|
|
|
|
|
|
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
|
echo json_encode($this->Contesting_model->getSessionFreshQsos($contest_id));
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-10 18:54:24 +02:00
|
|
|
public function getSession() {
|
|
|
|
|
$this->load->model('Contesting_model');
|
|
|
|
|
|
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
|
echo json_encode($this->Contesting_model->getSession());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function deleteSession() {
|
|
|
|
|
$this->load->model('Contesting_model');
|
|
|
|
|
|
|
|
|
|
$qso = $this->input->post('qso');
|
|
|
|
|
|
|
|
|
|
$data = $this->Contesting_model->deleteSession($qso);
|
2020-12-28 19:55:51 +01:00
|
|
|
|
|
|
|
|
return json_encode($data);
|
|
|
|
|
}
|
2021-02-12 23:27:08 +01:00
|
|
|
|
2023-04-10 18:54:24 +02:00
|
|
|
public function setSession() {
|
|
|
|
|
$this->load->model('Contesting_model');
|
|
|
|
|
|
|
|
|
|
$this->Contesting_model->setSession();
|
|
|
|
|
|
|
|
|
|
return json_encode("ok");
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-07 21:42:19 +02:00
|
|
|
public function create() {
|
2021-02-12 23:27:08 +01:00
|
|
|
$this->load->model('Contesting_model');
|
|
|
|
|
$this->load->library('form_validation');
|
|
|
|
|
|
|
|
|
|
$this->form_validation->set_rules('name', 'Contest Name', 'required');
|
2023-10-06 13:14:54 +02:00
|
|
|
$this->form_validation->set_rules('adifname', 'Adif Contest Name', 'required');
|
2021-02-12 23:27:08 +01:00
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-07 21:42:19 +02:00
|
|
|
public function edit($id) {
|
2021-02-12 23:27:08 +01:00
|
|
|
$this->load->model('Contesting_model');
|
2023-10-06 13:14:54 +02:00
|
|
|
$this->load->library('form_validation');
|
2021-02-12 23:27:08 +01:00
|
|
|
|
2026-06-24 22:08:30 +01:00
|
|
|
$item_id_clean = (int) $id;
|
2021-02-12 23:27:08 +01:00
|
|
|
|
|
|
|
|
$data['contest'] = $this->Contesting_model->contest($item_id_clean);
|
|
|
|
|
|
2023-10-06 10:48:01 +02:00
|
|
|
$data['page_title'] = lang('admin_contest_edit_update_contest');
|
2021-02-12 23:27:08 +01:00
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
}
|
2021-10-23 19:44:41 +02:00
|
|
|
|
|
|
|
|
public function deactivateall() {
|
|
|
|
|
$this->load->model('Contesting_model');
|
|
|
|
|
$this->Contesting_model->deactivateall();
|
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
|
echo json_encode(array('message' => 'OK'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function activateall() {
|
|
|
|
|
$this->load->model('Contesting_model');
|
|
|
|
|
$this->Contesting_model->activateall();
|
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
|
echo json_encode(array('message' => 'OK'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-10-24 16:48:23 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Function is used for dupe-checking in contestinglogging
|
|
|
|
|
*/
|
|
|
|
|
public function checkIfWorkedBefore() {
|
|
|
|
|
$call = $this->input->post('call');
|
|
|
|
|
$band = $this->input->post('band');
|
|
|
|
|
$mode = $this->input->post('mode');
|
|
|
|
|
$contest = $this->input->post('contest');
|
|
|
|
|
|
|
|
|
|
$this->load->model('Contesting_model');
|
2023-04-10 18:54:24 +02:00
|
|
|
|
|
|
|
|
$result = $this->Contesting_model->checkIfWorkedBefore($call, $band, $mode, $contest);
|
2021-10-24 16:48:23 +02:00
|
|
|
|
|
|
|
|
header('Content-Type: application/json');
|
2023-11-09 15:11:36 +01:00
|
|
|
if ($result && $result->num_rows()) {
|
2023-12-31 07:01:43 +00:00
|
|
|
$timeb4=substr($result->row()->b4,0,5);
|
2023-12-31 06:55:25 +00:00
|
|
|
$custom_date_format = $this->session->userdata('user_date_format');
|
|
|
|
|
$abstimeb4=date($custom_date_format, strtotime($result->row()->COL_TIME_OFF)).' '.date('H:i',strtotime($result->row()->COL_TIME_OFF));
|
2023-12-31 07:01:43 +00:00
|
|
|
echo json_encode(array('message' => 'Worked at '.$abstimeb4.' ('.$timeb4.' ago) before'));
|
2024-03-08 12:41:12 +00:00
|
|
|
} else {
|
|
|
|
|
echo json_encode(array('message' => 'OKAY'));
|
2021-10-24 16:48:23 +02:00
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-02-12 23:27:08 +01:00
|
|
|
}
|