First Rev of showing upcoming dxpeditions
这个提交包含在:
父节点
5c29e1ad59
当前提交
4e9e7aeea6
共有 4 个文件被更改,包括 207 次插入 和 0 次删除
|
|
@ -0,0 +1,161 @@
|
||||||
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
|
||||||
|
/*
|
||||||
|
Controller to interact with the Clublog API
|
||||||
|
*/
|
||||||
|
|
||||||
|
class WorkableDXCC extends CI_Controller {
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$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 index() {
|
||||||
|
// Load public view
|
||||||
|
$data['page_title'] = "Upcoming DXPeditions";
|
||||||
|
$this->load->view('interface_assets/header', $data);
|
||||||
|
$this->load->view('/workabledxcc/index');
|
||||||
|
$this->load->view('interface_assets/footer');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dxcclist() {
|
||||||
|
|
||||||
|
$json = file_get_contents('https://oscarwatch.org/scripts/read_ng3k_dxped_list.php');
|
||||||
|
|
||||||
|
// Decode the JSON data into a PHP array
|
||||||
|
$dataResult = json_decode($json, true);
|
||||||
|
|
||||||
|
// Initialize an empty array to store the required data
|
||||||
|
$requiredData = array();
|
||||||
|
|
||||||
|
// Get Date format
|
||||||
|
if($this->session->userdata('user_date_format')) {
|
||||||
|
// If Logged in and session exists
|
||||||
|
$custom_date_format = $this->session->userdata('user_date_format');
|
||||||
|
} else {
|
||||||
|
// Get Default date format from /config/cloudlog.php
|
||||||
|
$custom_date_format = $this->config->item('qso_date_format');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iterate through the decoded JSON data
|
||||||
|
foreach ($dataResult as $item) {
|
||||||
|
// Create a new array with the required fields and add it to the main array
|
||||||
|
$oldStartDate = DateTime::createFromFormat('Y-m-d', $item['0']);
|
||||||
|
|
||||||
|
$StartDate = $oldStartDate->format($custom_date_format);
|
||||||
|
|
||||||
|
$oldEndDate = DateTime::createFromFormat('Y-m-d', $item['1']);
|
||||||
|
|
||||||
|
$EndDate = $oldEndDate->format($custom_date_format);
|
||||||
|
|
||||||
|
$this->load->model('logbook_model');
|
||||||
|
$dxccInfo = $this->logbook_model->dxcc_lookup($item['callsign'], $StartDate);
|
||||||
|
|
||||||
|
// Call DXCC Worked function to check if the DXCC has been worked before
|
||||||
|
if (isset($dxccInfo['entity'])) {
|
||||||
|
$dxccWorked = $this->dxccWorked($dxccInfo['entity']);
|
||||||
|
} else {
|
||||||
|
// Handle the case where 'entity' is not set in $dxccInfo
|
||||||
|
$dxccWorked = array(
|
||||||
|
'workedBefore' => false,
|
||||||
|
'confirmed' => false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$requiredData[] = array(
|
||||||
|
'start_date' => $StartDate,
|
||||||
|
'end_date' => $EndDate,
|
||||||
|
'country' => $item['2'],
|
||||||
|
'notes' => $item['6'],
|
||||||
|
'callsign' => $item['callsign'],
|
||||||
|
'workedBefore' => $dxccWorked['workedBefore'],
|
||||||
|
'confirmed' => $dxccWorked['confirmed'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['dxcclist'] = $requiredData;
|
||||||
|
|
||||||
|
// Return the array with the required data
|
||||||
|
|
||||||
|
$this->load->view('/workabledxcc/components/dxcclist', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
function dxccWorked($country) {
|
||||||
|
|
||||||
|
$return = [
|
||||||
|
"workedBefore" => false,
|
||||||
|
"confirmed" => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
$user_default_confirmation = $this->session->userdata('user_default_confirmation');
|
||||||
|
$this->load->model('logbooks_model');
|
||||||
|
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||||
|
$this->load->model('logbook_model');
|
||||||
|
|
||||||
|
if(!empty($logbooks_locations_array)) {
|
||||||
|
$this->db->where('COL_PROP_MODE !=','SAT');
|
||||||
|
|
||||||
|
$this->db->where_in('station_id', $logbooks_locations_array);
|
||||||
|
$this->db->where('COL_COUNTRY', urldecode($country));
|
||||||
|
|
||||||
|
$query = $this->db->get($this->config->item('table_name'), 1, 0);
|
||||||
|
foreach ($query->result() as $workedBeforeRow)
|
||||||
|
{
|
||||||
|
$return['workedBefore'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$extrawhere='';
|
||||||
|
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) {
|
||||||
|
$extrawhere="COL_QSL_RCVD='Y'";
|
||||||
|
}
|
||||||
|
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'L') !== false) {
|
||||||
|
if ($extrawhere!='') {
|
||||||
|
$extrawhere.=" OR";
|
||||||
|
}
|
||||||
|
$extrawhere.=" COL_LOTW_QSL_RCVD='Y'";
|
||||||
|
}
|
||||||
|
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'E') !== false) {
|
||||||
|
if ($extrawhere!='') {
|
||||||
|
$extrawhere.=" OR";
|
||||||
|
}
|
||||||
|
$extrawhere.=" COL_EQSL_QSL_RCVD='Y'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Z') !== false) {
|
||||||
|
if ($extrawhere!='') {
|
||||||
|
$extrawhere.=" OR";
|
||||||
|
}
|
||||||
|
$extrawhere.=" COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->load->model('logbook_model');
|
||||||
|
$this->db->where('COL_PROP_MODE !=','SAT');
|
||||||
|
if ($extrawhere != '') {
|
||||||
|
$this->db->where('('.$extrawhere.')');
|
||||||
|
} else {
|
||||||
|
$this->db->where("1=0");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->db->where_in('station_id', $logbooks_locations_array);
|
||||||
|
$this->db->where('COL_COUNTRY', urldecode($country));
|
||||||
|
|
||||||
|
$query = $this->db->get($this->config->item('table_name'), 1, 0);
|
||||||
|
foreach ($query->result() as $workedBeforeRow) {
|
||||||
|
$return['confirmed']=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
} else {
|
||||||
|
$return['workedBefore'] = false;
|
||||||
|
$return['confirmed'] = false;
|
||||||
|
|
||||||
|
|
||||||
|
return $return;;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -182,6 +182,8 @@
|
||||||
<div class="d-inline d-lg-none" style="padding-left: 10px">Tools</div>
|
<div class="d-inline d-lg-none" style="padding-left: 10px">Tools</div>
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
|
<a class="dropdown-item" href="<?php echo site_url('workabledxcc'); ?>" title="Upcoming DXPeditions"><i class="fas fa-globe"></i> Upcoming DXPeditions</a>
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item" href="<?php echo site_url('hamsat'); ?>" title="Hams.at"><i class="fas fa-list"></i> Hams.at</a>
|
<a class="dropdown-item" href="<?php echo site_url('hamsat'); ?>" title="Hams.at"><i class="fas fa-list"></i> Hams.at</a>
|
||||||
<?php if ($this->optionslib->get_option('dxcache_url') != '') { ?>
|
<?php if ($this->optionslib->get_option('dxcache_url') != '') { ?>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
<table class="table table-striped table-hover">
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Start Date</td>
|
||||||
|
<td>End Date</td>
|
||||||
|
<td>Country</td>
|
||||||
|
<td>Callsign</td>
|
||||||
|
<td></td>
|
||||||
|
<td>Notes</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php foreach($dxcclist as $dxcc): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $dxcc['start_date']; ?></td>
|
||||||
|
<td><?php echo $dxcc['end_date']; ?></td>
|
||||||
|
<td><?php echo $dxcc['country']; ?></td>
|
||||||
|
<td>
|
||||||
|
<?php echo $dxcc['callsign']; ?>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<?php if (!$dxcc['workedBefore']) { ?>
|
||||||
|
<span class="badge bg-danger">Not Worked Before</span>
|
||||||
|
<?php } else { ?>
|
||||||
|
<span class="badge bg-success">Worked Before</span>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php if ($dxcc['confirmed']): ?>
|
||||||
|
<span class="badge bg-primary">Confirmed</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
<td><?php echo $dxcc['notes']; ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<h2><?php echo $page_title; ?></h2>
|
||||||
|
<div id="dxcclist_display" hx-get="<?php echo site_url('workabledxcc/dxcclist'); ?>" hx-trigger="load, every 60s"></div>
|
||||||
|
</div>
|
||||||
正在加载…
在新工单中引用