Merge branch 'dev' of https://github.com/magicbug/Cloudlog into dev
这个提交包含在:
当前提交
435e467d1e
共有 6 个文件被更改,包括 474 次插入 和 392 次删除
|
|
@ -3,16 +3,15 @@
|
||||||
class eqsl extends CI_Controller {
|
class eqsl extends CI_Controller {
|
||||||
|
|
||||||
/* Controls who can access the controller and its functions */
|
/* Controls who can access the controller and its functions */
|
||||||
function __construct()
|
function __construct() {
|
||||||
{
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->load->helper(array('form', 'url'));
|
$this->load->helper(array('form', 'url'));
|
||||||
|
|
||||||
$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'); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function import() {
|
public function import() {
|
||||||
|
$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'); }
|
||||||
|
|
||||||
// Check if eQSL Nicknames have been defined
|
// Check if eQSL Nicknames have been defined
|
||||||
$this->load->model('stations');
|
$this->load->model('stations');
|
||||||
$eqsl_locations = $this->stations->all_of_user_with_eqsl_nick_defined();
|
$eqsl_locations = $this->stations->all_of_user_with_eqsl_nick_defined();
|
||||||
|
|
@ -29,7 +28,7 @@ class eqsl extends CI_Controller {
|
||||||
|
|
||||||
$this->load->library('upload', $config);
|
$this->load->library('upload', $config);
|
||||||
|
|
||||||
$this->load->model('logbook_model');
|
$this->load->model('eqslmethods_model');
|
||||||
|
|
||||||
$eqsl_results = array();
|
$eqsl_results = array();
|
||||||
if ($this->input->post('eqslimport') == 'fetch')
|
if ($this->input->post('eqslimport') == 'fetch')
|
||||||
|
|
@ -91,6 +90,9 @@ class eqsl extends CI_Controller {
|
||||||
} // end function
|
} // end function
|
||||||
|
|
||||||
public function export() {
|
public function export() {
|
||||||
|
$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'); }
|
||||||
|
|
||||||
// Check if eQSL Nicknames have been defined
|
// Check if eQSL Nicknames have been defined
|
||||||
$this->load->model('stations');
|
$this->load->model('stations');
|
||||||
if($this->stations->are_eqsl_nicks_defined() == 0) {
|
if($this->stations->are_eqsl_nicks_defined() == 0) {
|
||||||
|
|
@ -100,13 +102,12 @@ class eqsl extends CI_Controller {
|
||||||
|
|
||||||
ini_set('memory_limit', '-1');
|
ini_set('memory_limit', '-1');
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
$this->load->model('logbook_model');
|
$this->load->model('eqslmethods_model');
|
||||||
|
|
||||||
$data['page_title'] = "eQSL QSO Upload";
|
$data['page_title'] = "eQSL QSO Upload";
|
||||||
$custom_date_format = $this->session->userdata('user_date_format');
|
$custom_date_format = $this->session->userdata('user_date_format');
|
||||||
|
|
||||||
if ($this->input->post('eqslexport') == "export")
|
if ($this->input->post('eqslexport') == "export") {
|
||||||
{
|
|
||||||
// Get credentials for eQSL
|
// Get credentials for eQSL
|
||||||
$query = $this->user_model->get_by_id($this->session->userdata('user_id'));
|
$query = $this->user_model->get_by_id($this->session->userdata('user_id'));
|
||||||
$q = $query->row();
|
$q = $query->row();
|
||||||
|
|
@ -121,26 +122,132 @@ class eqsl extends CI_Controller {
|
||||||
|
|
||||||
// Grab the list of QSOs to send information about
|
// Grab the list of QSOs to send information about
|
||||||
// perform an HTTP get on each one, and grab the status back
|
// perform an HTTP get on each one, and grab the status back
|
||||||
$qslsnotsent = $this->logbook_model->eqsl_not_yet_sent();
|
$qslsnotsent = $this->eqslmethods_model->eqsl_not_yet_sent();
|
||||||
|
|
||||||
|
$rows = "<tr>";
|
||||||
|
foreach ($qslsnotsent->result_array() as $qsl) {
|
||||||
|
|
||||||
$table = "<table width=\"100%\">";
|
|
||||||
$table .= "<tr class=\"titles\">";
|
|
||||||
$table .= "<td>Date</td>";
|
|
||||||
$table .= "<td>Time</td>";
|
|
||||||
$table .= "<td>Call</td>";
|
|
||||||
$table .= "<td>Mode</td>";
|
|
||||||
$table .= "<td>Submode</td>";
|
|
||||||
$table .= "<td>Band</td>";
|
|
||||||
$table .= "<td>Result</td>";
|
|
||||||
$table .= "<tr>";
|
|
||||||
// Build out the ADIF info string according to specs http://eqsl.cc/qslcard/ADIFContentSpecs.cfm
|
|
||||||
foreach ($qslsnotsent->result_array() as $qsl)
|
|
||||||
{
|
|
||||||
// eQSL username changes for linked account.
|
// eQSL username changes for linked account.
|
||||||
// i.e. when operating /P it must be callsign/p
|
// i.e. when operating /P it must be callsign/p
|
||||||
// the password, however, is always the same as the main account
|
// the password, however, is always the same as the main account
|
||||||
$data['user_eqsl_name'] = $qsl['station_callsign'];
|
$data['user_eqsl_name'] = $qsl['station_callsign'];
|
||||||
|
$adif = $this->generateAdif($qsl, $data);
|
||||||
|
|
||||||
|
$status = $this->uploadQso($adif, $qsl);
|
||||||
|
|
||||||
|
|
||||||
|
$timestamp = strtotime($qsl['COL_TIME_ON']);
|
||||||
|
$rows .= "<td>".date($custom_date_format, $timestamp)."</td>";
|
||||||
|
$rows .= "<td>".date('H:i', $timestamp)."</td>";
|
||||||
|
$rows .= "<td>".str_replace("0","Ø",$qsl['COL_CALL'])."</td>";
|
||||||
|
$rows .= "<td>".$qsl['COL_MODE']."</td>";
|
||||||
|
if(isset($qsl['COL_SUBMODE'])) {
|
||||||
|
$rows .= "<td>".$qsl['COL_SUBMODE']."</td>";
|
||||||
|
} else {
|
||||||
|
$rows .= "<td></td>";
|
||||||
|
}
|
||||||
|
$rows .= "<td>".$qsl['COL_BAND']."</td>";
|
||||||
|
$rows .= "<td>".$status."</td>";
|
||||||
|
}
|
||||||
|
$rows .= "</tr>";
|
||||||
|
$data['eqsl_table'] = $this->generateResultTable($custom_date_format, $rows);
|
||||||
|
} else {
|
||||||
|
$qslsnotsent = $this->eqslmethods_model->eqsl_not_yet_sent();
|
||||||
|
if ($qslsnotsent->num_rows() > 0) {
|
||||||
|
$data['eqsl_table'] = $this->writeEqslNotSent($qslsnotsent->result_array(), $custom_date_format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->load->view('interface_assets/header', $data);
|
||||||
|
$this->load->view('eqsl/export');
|
||||||
|
$this->load->view('interface_assets/footer');
|
||||||
|
}
|
||||||
|
|
||||||
|
function uploadQso($adif, $qsl) {
|
||||||
|
$this->load->model('eqslmethods_model');
|
||||||
|
$status = "";
|
||||||
|
|
||||||
|
// begin script
|
||||||
|
$ch = curl_init();
|
||||||
|
|
||||||
|
// basic curl options for all requests
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_HEADER, 1);
|
||||||
|
|
||||||
|
// use the URL we built
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $adif);
|
||||||
|
|
||||||
|
$result = curl_exec($ch);
|
||||||
|
$chi = curl_getinfo($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
/* Time for some error handling
|
||||||
|
Things we might get back
|
||||||
|
Result: 0 out of 0 records added -> eQSL didn't understand the format
|
||||||
|
Result: 1 out of 1 records added -> Fantastic
|
||||||
|
Error: No match on eQSL_User/eQSL_Pswd -> eQSL credentials probably wrong
|
||||||
|
Warning: Y=2013 M=08 D=11 F6ARS 15M JT65 Bad record: Duplicate
|
||||||
|
Result: 0 out of 1 records added -> Dupe, OM!
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($chi['http_code'] == "200") {
|
||||||
|
if (stristr($result, "Result: 1 out of 1 records added")) {
|
||||||
|
$status = "Sent";
|
||||||
|
$this->eqslmethods_model->eqsl_mark_sent($qsl['COL_PRIMARY_KEY']);
|
||||||
|
} else {
|
||||||
|
if (stristr($result, "Error: No match on eQSL_User/eQSL_Pswd")) {
|
||||||
|
$this->session->set_flashdata('warning', 'Your eQSL username and/or password is incorrect.'); redirect('eqsl/export');
|
||||||
|
} else {
|
||||||
|
if (stristr($result, "Result: 0 out of 0 records added")) {
|
||||||
|
$this->session->set_flashdata('warning', 'Something went wrong with eQSL.cc!'); redirect('eqsl/export');
|
||||||
|
} else {
|
||||||
|
if (stristr($result, "Bad record: Duplicate")) {
|
||||||
|
$status = "Duplicate";
|
||||||
|
|
||||||
|
# Mark the QSL as sent if this is a dupe.
|
||||||
|
$this->eqslmethods_model->eqsl_mark_sent($qsl['COL_PRIMARY_KEY']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($chi['http_code'] == "500") {
|
||||||
|
$this->session->set_flashdata('warning', 'eQSL.cc is experiencing issues. Please try exporting QSOs later.'); redirect('eqsl/export');
|
||||||
|
} else {
|
||||||
|
if ($chi['http_code'] == "400") {
|
||||||
|
$this->session->set_flashdata('warning', 'There was an error in one of the QSOs. You might want to manually upload them.'); redirect('eqsl/export');
|
||||||
|
$status = "Error";
|
||||||
|
} else {
|
||||||
|
if ($chi['http_code'] == "404") {
|
||||||
|
$this->session->set_flashdata('warning', 'It seems that the eQSL site has changed. Please open up an issue on GitHub.'); redirect('eqsl/export');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log_message('debug', $result);
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateResultTable($custom_date_format, $rows) {
|
||||||
|
$table = '<table = style="width:100%" class="table-sm table table-bordered table-hover table-striped table-condensed text-center">';
|
||||||
|
$table .= "<thead><tr class=\"titles\">";
|
||||||
|
$table .= "<th>Date</th>";
|
||||||
|
$table .= "<th>Time</th>";
|
||||||
|
$table .= "<th>Call</th>";
|
||||||
|
$table .= "<th>Mode</th>";
|
||||||
|
$table .= "<th>Submode</th>";
|
||||||
|
$table .= "<th>Band</th>";
|
||||||
|
$table .= "<th>Status</th>";
|
||||||
|
$table .= "</tr></thead><tbody>";
|
||||||
|
|
||||||
|
$table .= $rows;
|
||||||
|
$table .= "</tbody></table>";
|
||||||
|
|
||||||
|
return $table;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build out the ADIF info string according to specs http://eqsl.cc/qslcard/ADIFContentSpecs.cfm
|
||||||
|
function generateAdif($qsl, $data) {
|
||||||
$COL_QSO_DATE = date('Ymd',strtotime($qsl['COL_TIME_ON']));
|
$COL_QSO_DATE = date('Ymd',strtotime($qsl['COL_TIME_ON']));
|
||||||
$COL_TIME_ON = date('Hi',strtotime($qsl['COL_TIME_ON']));
|
$COL_TIME_ON = date('Hi',strtotime($qsl['COL_TIME_ON']));
|
||||||
|
|
||||||
|
|
@ -239,7 +346,6 @@ class eqsl extends CI_Controller {
|
||||||
|
|
||||||
# End all the required fields
|
# End all the required fields
|
||||||
|
|
||||||
|
|
||||||
// adding RST_Sent
|
// adding RST_Sent
|
||||||
$adif .= "%3C";
|
$adif .= "%3C";
|
||||||
$adif .= "RST%5FSENT";
|
$adif .= "RST%5FSENT";
|
||||||
|
|
@ -314,7 +420,6 @@ class eqsl extends CI_Controller {
|
||||||
$adif .= "%20";
|
$adif .= "%20";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Tie a bow on it!
|
# Tie a bow on it!
|
||||||
$adif .= "%3C";
|
$adif .= "%3C";
|
||||||
$adif .= "EOR";
|
$adif .= "EOR";
|
||||||
|
|
@ -323,125 +428,22 @@ class eqsl extends CI_Controller {
|
||||||
# Make sure we don't have any spaces
|
# Make sure we don't have any spaces
|
||||||
$adif = str_replace(" ", '%20', $adif);
|
$adif = str_replace(" ", '%20', $adif);
|
||||||
|
|
||||||
$status = "";
|
return $adif;
|
||||||
|
}
|
||||||
|
|
||||||
// begin script
|
function writeEqslNotSent($qslsnotsent, $custom_date_format) {
|
||||||
$ch = curl_init();
|
$table = '<table = style="width:100%" class="table-sm table table-bordered table-hover table-striped table-condensed text-center">';
|
||||||
|
$table .= "<thead><tr class=\"titles\">";
|
||||||
|
$table .= "<th>Date</th>";
|
||||||
|
$table .= "<th>Time</th>";
|
||||||
|
$table .= "<th>Call</th>";
|
||||||
|
$table .= "<th>Mode</th>";
|
||||||
|
$table .= "<th>Submode</th>";
|
||||||
|
$table .= "<th>Band</th>";
|
||||||
|
$table .= "<th>eQSL QTH Nickname</th>";
|
||||||
|
$table .= "</tr></thead><tbody>";
|
||||||
|
|
||||||
// basic curl options for all requests
|
foreach ($qslsnotsent as $qsl)
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_HEADER, 1);
|
|
||||||
|
|
||||||
// use the URL we built
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $adif);
|
|
||||||
|
|
||||||
$result = curl_exec($ch);
|
|
||||||
$chi = curl_getinfo($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
|
|
||||||
/* Time for some error handling
|
|
||||||
Things we might get back
|
|
||||||
Result: 0 out of 0 records added -> eQSL didn't understand the format
|
|
||||||
Result: 1 out of 1 records added -> Fantastic
|
|
||||||
Error: No match on eQSL_User/eQSL_Pswd -> eQSL credentials probably wrong
|
|
||||||
Warning: Y=2013 M=08 D=11 F6ARS 15M JT65 Bad record: Duplicate
|
|
||||||
Result: 0 out of 1 records added -> Dupe, OM!
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ($chi['http_code'] == "200")
|
|
||||||
{
|
|
||||||
if (stristr($result, "Result: 1 out of 1 records added"))
|
|
||||||
{
|
|
||||||
$status = "Sent";
|
|
||||||
$this->logbook_model->eqsl_mark_sent($qsl['COL_PRIMARY_KEY']);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (stristr($result, "Error: No match on eQSL_User/eQSL_Pswd"))
|
|
||||||
{
|
|
||||||
$this->session->set_flashdata('warning', 'Your eQSL username and/or password is incorrect.'); redirect('eqsl/export');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (stristr($result, "Result: 0 out of 0 records added"))
|
|
||||||
{
|
|
||||||
$this->session->set_flashdata('warning', 'Something went wrong with eQSL.cc!'); redirect('eqsl/export');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (stristr($result, "Bad record: Duplicate"))
|
|
||||||
{
|
|
||||||
$status = "Duplicate";
|
|
||||||
|
|
||||||
# Mark the QSL as sent if this is a dupe.
|
|
||||||
$this->logbook_model->eqsl_mark_sent($qsl['COL_PRIMARY_KEY']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($chi['http_code'] == "500")
|
|
||||||
{
|
|
||||||
$this->session->set_flashdata('warning', 'eQSL.cc is experiencing issues. Please try exporting QSOs later.'); redirect('eqsl/export');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($chi['http_code'] == "400")
|
|
||||||
{
|
|
||||||
$this->session->set_flashdata('warning', 'There was an error in one of the QSOs. You might want to manually upload them.'); redirect('eqsl/export');
|
|
||||||
$status = "Error";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($chi['http_code'] == "404")
|
|
||||||
{
|
|
||||||
$this->session->set_flashdata('warning', 'It seems that the eQSL site has changed. Please open up an issue on GitHub.'); redirect('eqsl/export');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$table .= "<tr>";
|
|
||||||
$timestamp = strtotime($qsl['COL_TIME_ON']);
|
|
||||||
$table .= "<td>".date($custom_date_format, $timestamp)."</td>";
|
|
||||||
$table .= "<td>".date('H:i', $timestamp)."</td>";
|
|
||||||
$table .= "<td>".str_replace("0","Ø",$qsl['COL_CALL'])."</td>";
|
|
||||||
$table .= "<td>".$qsl['COL_MODE']."</td>";
|
|
||||||
if(isset($qsl['COL_SUBMODE'])) {
|
|
||||||
$table .= "<td>".$qsl['COL_SUBMODE']."</td>";
|
|
||||||
} else {
|
|
||||||
$table .= "<td></td>";
|
|
||||||
}
|
|
||||||
$table .= "<td>".$qsl['COL_BAND']."</td>";
|
|
||||||
$table .= "<td>".$status."</td>";
|
|
||||||
$table .= "<tr>";
|
|
||||||
}
|
|
||||||
$table .= "</table>";
|
|
||||||
|
|
||||||
// Dump out a table with the results
|
|
||||||
$data['eqsl_results_table'] = $table;
|
|
||||||
log_message('debug', $result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$qslsnotsent = $this->logbook_model->eqsl_not_yet_sent();
|
|
||||||
|
|
||||||
if ($qslsnotsent->num_rows() > 0)
|
|
||||||
{
|
|
||||||
$table = "<table width=\"100%\">";
|
|
||||||
$table .= "<tr class=\"titles\">";
|
|
||||||
$table .= "<td>Date</td>";
|
|
||||||
$table .= "<td>Time</td>";
|
|
||||||
$table .= "<td>Call</td>";
|
|
||||||
$table .= "<td>Mode</td>";
|
|
||||||
$table .= "<td>Submode</td>";
|
|
||||||
$table .= "<td>Band</td>";
|
|
||||||
$table .= "<td>eQSL QTH Nickname</td>";
|
|
||||||
$table .= "<tr>";
|
|
||||||
|
|
||||||
foreach ($qslsnotsent->result_array() as $qsl)
|
|
||||||
{
|
{
|
||||||
$table .= "<tr>";
|
$table .= "<tr>";
|
||||||
$timestamp = strtotime($qsl['COL_TIME_ON']);
|
$timestamp = strtotime($qsl['COL_TIME_ON']);
|
||||||
|
|
@ -457,17 +459,11 @@ class eqsl extends CI_Controller {
|
||||||
}
|
}
|
||||||
$table .= "<td>".$qsl['COL_BAND']."</td>";
|
$table .= "<td>".$qsl['COL_BAND']."</td>";
|
||||||
$table .= "<td>".$qsl['eqslqthnickname']."</td>";
|
$table .= "<td>".$qsl['eqslqthnickname']."</td>";
|
||||||
$table .= "<tr>";
|
$table .= "</tr>";
|
||||||
}
|
}
|
||||||
$table .= "</table>";
|
$table .= "</tbody></table>";
|
||||||
|
|
||||||
$data['eqsl_table'] = $table;
|
return $table;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->load->view('interface_assets/header', $data);
|
|
||||||
$this->load->view('eqsl/export');
|
|
||||||
$this->load->view('interface_assets/footer');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function image($id) {
|
function image($id) {
|
||||||
|
|
@ -529,7 +525,6 @@ class eqsl extends CI_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tools() {
|
public function tools() {
|
||||||
|
|
||||||
// Check logged in
|
// Check logged in
|
||||||
$this->load->model('user_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'); }
|
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||||
|
|
@ -543,7 +538,6 @@ class eqsl extends CI_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mark_all_sent() {
|
public function mark_all_sent() {
|
||||||
|
|
||||||
// Check logged in
|
// Check logged in
|
||||||
$this->load->model('user_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'); }
|
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||||
|
|
@ -557,4 +551,34 @@ class eqsl extends CI_Controller {
|
||||||
redirect('eqsl/tools');
|
redirect('eqsl/tools');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Used for CRON job
|
||||||
|
*/
|
||||||
|
public function upload() {
|
||||||
|
$this->load->model('eqslmethods_model');
|
||||||
|
|
||||||
|
$users = $this->eqslmethods_model->get_eqsl_users();
|
||||||
|
|
||||||
|
foreach ($users as $user) {
|
||||||
|
$this->uploadUser($user->user_id, $user->user_eqsl_name, $user->user_eqsl_password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function uploadUser($userid, $username, $password) {
|
||||||
|
ini_set('memory_limit', '-1');
|
||||||
|
set_time_limit(0);
|
||||||
|
$data['user_eqsl_name'] = $this->security->xss_clean($username);
|
||||||
|
$data['user_eqsl_password'] = $this->security->xss_clean($password);
|
||||||
|
$clean_userid = $this->security->xss_clean($userid);
|
||||||
|
|
||||||
|
$qslsnotsent = $this->eqslmethods_model->eqsl_not_yet_sent($clean_userid);
|
||||||
|
|
||||||
|
foreach ($qslsnotsent->result_array() as $qsl) {
|
||||||
|
$data['user_eqsl_name'] = $qsl['station_callsign'];
|
||||||
|
$adif = $this->generateAdif($qsl, $data);
|
||||||
|
|
||||||
|
$status = $this->uploadQso($adif, $qsl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // end class
|
} // end class
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,69 @@ class Eqslmethods_model extends CI_Model {
|
||||||
$this->db->update($this->config->item('table_name'), $data);
|
$this->db->update($this->config->item('table_name'), $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_eqsl_users() {
|
||||||
|
$this->db->select('user_eqsl_name, user_eqsl_password, user_id');
|
||||||
|
$this->db->where('coalesce(user_eqsl_name, "") != ""');
|
||||||
|
$this->db->where('coalesce(user_eqsl_password, "") != ""');
|
||||||
|
$query = $this->db->get($this->config->item('auth_table'));
|
||||||
|
return $query->result();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets all station location for user, for use in cron where we don't have any login
|
||||||
|
*/
|
||||||
|
function get_all_user_locations($userid) {
|
||||||
|
$this->db->select('station_profile.*, dxcc_entities.name as station_country, dxcc_entities.end as dxcc_end');
|
||||||
|
$this->db->where('user_id', $userid);
|
||||||
|
$this->db->join('dxcc_entities','station_profile.station_dxcc = dxcc_entities.adif','left outer');
|
||||||
|
return $this->db->get('station_profile');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show all QSOs we need to send to eQSL
|
||||||
|
function eqsl_not_yet_sent($userid = null) {
|
||||||
|
$CI =& get_instance();
|
||||||
|
if ($userid == null) {
|
||||||
|
$CI->load->model('logbooks_model');
|
||||||
|
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||||
|
} else {
|
||||||
|
$stations = $this->get_all_user_locations($userid);
|
||||||
|
$logbooks_locations_array = array();
|
||||||
|
foreach ($stations->result() as $row) {
|
||||||
|
array_push($logbooks_locations_array, $row->station_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->select('station_profile.*, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_COMMENT, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_PROP_MODE, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_SAT_MODE, '.$this->config->item('table_name').'.COL_QSLMSG');
|
||||||
|
$this->db->from('station_profile');
|
||||||
|
$this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
||||||
|
$this->db->where("coalesce(station_profile.eqslqthnickname, '') <> ''");
|
||||||
|
$this->db->where($this->config->item('table_name').'.COL_CALL !=', '');
|
||||||
|
$this->db->group_start();
|
||||||
|
$this->db->where($this->config->item('table_name').'.COL_EQSL_QSL_SENT is null');
|
||||||
|
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', '');
|
||||||
|
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'R');
|
||||||
|
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'Q');
|
||||||
|
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'N');
|
||||||
|
$this->db->group_end();
|
||||||
|
$this->db->where_in('station_profile.station_id', $logbooks_locations_array);
|
||||||
|
|
||||||
|
return $this->db->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark the QSO as sent to eQSL
|
||||||
|
function eqsl_mark_sent($primarykey) {
|
||||||
|
$data = array(
|
||||||
|
'COL_EQSL_QSLSDATE' => date('Y-m-d H:i:s'), // eQSL doesn't give us a date, so let's use current
|
||||||
|
'COL_EQSL_QSL_SENT' => 'Y',
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->db->where('COL_PRIMARY_KEY', $primarykey);
|
||||||
|
|
||||||
|
$this->db->update($this->config->item('table_name'), $data);
|
||||||
|
|
||||||
|
return "eQSL Sent";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
@ -2573,20 +2573,6 @@ class Logbook_model extends CI_Model {
|
||||||
return "Updated";
|
return "Updated";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark the QSO as sent to eQSL
|
|
||||||
function eqsl_mark_sent($primarykey) {
|
|
||||||
$data = array(
|
|
||||||
'COL_EQSL_QSLSDATE' => date('Y-m-d H:i:s'), // eQSL doesn't give us a date, so let's use current
|
|
||||||
'COL_EQSL_QSL_SENT' => 'Y',
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->db->where('COL_PRIMARY_KEY', $primarykey);
|
|
||||||
|
|
||||||
$this->db->update($this->config->item('table_name'), $data);
|
|
||||||
|
|
||||||
return "eQSL Sent";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the last date we received an eQSL
|
// Get the last date we received an eQSL
|
||||||
function eqsl_last_qsl_rcvd_date($callsign, $nickname) {
|
function eqsl_last_qsl_rcvd_date($callsign, $nickname) {
|
||||||
$qso_table_name = $this->config->item('table_name');
|
$qso_table_name = $this->config->item('table_name');
|
||||||
|
|
@ -2637,29 +2623,6 @@ class Logbook_model extends CI_Model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show all QSOs we need to send to eQSL
|
|
||||||
function eqsl_not_yet_sent() {
|
|
||||||
$CI =& get_instance();
|
|
||||||
$CI->load->model('logbooks_model');
|
|
||||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
|
||||||
|
|
||||||
$this->db->select('station_profile.*, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_COMMENT, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_PROP_MODE, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_SAT_MODE, '.$this->config->item('table_name').'.COL_QSLMSG');
|
|
||||||
$this->db->from('station_profile');
|
|
||||||
$this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
|
|
||||||
$this->db->where("coalesce(station_profile.eqslqthnickname, '') <> ''");
|
|
||||||
$this->db->where($this->config->item('table_name').'.COL_CALL !=', '');
|
|
||||||
$this->db->group_start();
|
|
||||||
$this->db->where($this->config->item('table_name').'.COL_EQSL_QSL_SENT is null');
|
|
||||||
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', '');
|
|
||||||
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'R');
|
|
||||||
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'Q');
|
|
||||||
$this->db->or_where($this->config->item('table_name').'.COL_EQSL_QSL_SENT', 'N');
|
|
||||||
$this->db->group_end();
|
|
||||||
$this->db->where_in('station_profile.station_id', $logbooks_locations_array);
|
|
||||||
|
|
||||||
return $this->db->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $skipDuplicate - used in ADIF import to skip duplicate checking when importing QSOs
|
* $skipDuplicate - used in ADIF import to skip duplicate checking when importing QSOs
|
||||||
* $markLoTW - used in ADIF import to mark QSOs as exported to LoTW when importing QSOs
|
* $markLoTW - used in ADIF import to mark QSOs as exported to LoTW when importing QSOs
|
||||||
|
|
@ -3901,6 +3864,4 @@ function validateADIFDate($date, $format = 'Ymd')
|
||||||
$d = DateTime::createFromFormat($format, $date);
|
$d = DateTime::createFromFormat($format, $date);
|
||||||
return $d && $d->format($format) == $date;
|
return $d && $d->format($format) == $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
@ -1247,13 +1247,32 @@ $(document).on('keypress',function(e) {
|
||||||
var minutes = Math.floor(<?php echo $this->optionslib->get_option('cat_timeout_interval'); ?> / 60);
|
var minutes = Math.floor(<?php echo $this->optionslib->get_option('cat_timeout_interval'); ?> / 60);
|
||||||
|
|
||||||
if(data.updated_minutes_ago > minutes) {
|
if(data.updated_minutes_ago > minutes) {
|
||||||
|
$(".radio_cat_state" ).remove();
|
||||||
if($('.radio_timeout_error').length == 0) {
|
if($('.radio_timeout_error').length == 0) {
|
||||||
$('.qso_panel').prepend('<div class="alert alert-danger radio_timeout_error" role="alert">Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.</div>');
|
$('.qso_panel').prepend('<div class="alert alert-danger radio_timeout_error" role="alert"><i class="fas fa-broadcast-tower"></i> Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.</div>');
|
||||||
} else {
|
} else {
|
||||||
$('.radio_timeout_error').text('Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.');
|
$('.radio_timeout_error').html('Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$(".radio_timeout_error" ).remove();
|
$(".radio_timeout_error" ).remove();
|
||||||
|
text = '<i class="fas fa-broadcast-tower"></i><span style="margin-left:10px;"></span><b>TX:</b> '+parseInt(data.frequency)/1000/1000+' MHz';
|
||||||
|
if(data.power != null && data.power != 0) {
|
||||||
|
text = text+'<span style="margin-left:10px"></span>'+data.power+'W';
|
||||||
|
}
|
||||||
|
if(data.prop_mode != null && data.prop_mode != '') {
|
||||||
|
text = text+'<span style="margin-left:10px"></span>('+data.prop_mode;
|
||||||
|
if (data.prop_mode == 'SAT') {
|
||||||
|
text = text+' '+data.satname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(data.frequency_rx != null && data.frequency_rx != 0) {
|
||||||
|
text = text+'<span style="margin-left:10px"></span><b>RX:</b> '+parseInt(data.frequency_rx)/1000/1000+' MHz)';
|
||||||
|
}
|
||||||
|
if (! $('#radio_cat_state').length) {
|
||||||
|
$('.qso_panel').prepend('<div id="radio_cat_state" class="alert alert-success radio_cat_state" role="alert">'+text+'</div>');
|
||||||
|
} else {
|
||||||
|
$('#radio_cat_state').html(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -2672,6 +2691,21 @@ function deleteQsl(id) {
|
||||||
</script>
|
</script>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
|
||||||
|
<?php if ($this->uri->segment(1) == "eqsl") { ?>
|
||||||
|
<script>
|
||||||
|
$('.table').DataTable({
|
||||||
|
"stateSave": true,
|
||||||
|
"pageLength": 25,
|
||||||
|
responsive: false,
|
||||||
|
"scrollY": "400px",
|
||||||
|
"scrollCollapse": true,
|
||||||
|
"paging": false,
|
||||||
|
"scrollX": true,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
<?php if ($this->uri->segment(1) == "qslprint") { ?>
|
<?php if ($this->uri->segment(1) == "qslprint") { ?>
|
||||||
<script>
|
<script>
|
||||||
function deleteFromQslQueue(id) {
|
function deleteFromQslQueue(id) {
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@
|
||||||
<button type="button" class="btn btn-sm btn-success" id="sentBureau">Sent Bureau</button>
|
<button type="button" class="btn btn-sm btn-success" id="sentBureau">Sent Bureau</button>
|
||||||
<button type="button" class="btn btn-sm btn-success" id="sentDirect">Sent Direct</button>
|
<button type="button" class="btn btn-sm btn-success" id="sentDirect">Sent Direct</button>
|
||||||
<button type="button" class="btn btn-sm btn-success" id="sentElectronic">Sent Electronic</button>
|
<button type="button" class="btn btn-sm btn-success" id="sentElectronic">Sent Electronic</button>
|
||||||
<button type="button" class="btn btn-sm btn-warning" id="dontSend">Don't Send</button>
|
<button type="button" class="btn btn-sm btn-warning" id="dontSend">Not Sent</button>
|
||||||
<button type="button" class="btn btn-sm btn-warning" id="notRequired">QSL Not Required</button>
|
<button type="button" class="btn btn-sm btn-warning" id="notRequired">QSL Not Required</button>
|
||||||
<button type="button" class="btn btn-sm btn-info" id="exportAdif">Create ADIF</button>
|
<button type="button" class="btn btn-sm btn-info" id="exportAdif">Create ADIF</button>
|
||||||
<button type="button" class="btn btn-sm btn-danger" id="deleteQsos">Delete</button>
|
<button type="button" class="btn btn-sm btn-danger" id="deleteQsos">Delete</button>
|
||||||
|
|
|
||||||
|
|
@ -372,16 +372,16 @@
|
||||||
$hashtags = "#hamr #cloudlog";
|
$hashtags = "#hamr #cloudlog";
|
||||||
}
|
}
|
||||||
if($row->COL_IOTA != null) {
|
if($row->COL_IOTA != null) {
|
||||||
$hashtags .= " #iota";
|
$hashtags .= " #IOTA ".$row->COL_IOTA;
|
||||||
}
|
}
|
||||||
if($row->COL_SOTA_REF != null) {
|
if($row->COL_SOTA_REF != null) {
|
||||||
$hashtags .= " #sota";
|
$hashtags .= " #SOTA ".$row->COL_SOTA_EF;
|
||||||
}
|
}
|
||||||
if($row->COL_POTA_REF != null) {
|
if($row->COL_POTA_REF != null) {
|
||||||
$hashtags .= " #pota";
|
$hashtags .= " #POTA ".$row->COL_POTA_REF;
|
||||||
}
|
}
|
||||||
if($row->COL_WWFF_REF != null) {
|
if($row->COL_WWFF_REF != null) {
|
||||||
$hashtags .= " #wwff";
|
$hashtags .= " #WWFF ".$row->COL_WWFF_REF;
|
||||||
}
|
}
|
||||||
if (!isset($distance)) {
|
if (!isset($distance)) {
|
||||||
$twitter_string = urlencode("Just worked ".$row->COL_CALL." in ".ucwords(strtolower(($row->COL_COUNTRY)))." on ".$twitter_band_sat." using ".($row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE)." ".$hashtags);
|
$twitter_string = urlencode("Just worked ".$row->COL_CALL." in ".ucwords(strtolower(($row->COL_COUNTRY)))." on ".$twitter_band_sat." using ".($row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE)." ".$hashtags);
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用