kopia lustrzana https://github.com/magicbug/Cloudlog
[Upcoming Dxped] Split output into months
rodzic
df1e227625
commit
660cdc6b24
|
@ -1,89 +1,98 @@
|
||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Controller to interact with the Clublog API
|
Controller to interact with the Cloudlog DXPed Aggregator
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Workabledxcc extends CI_Controller {
|
class Workabledxcc extends CI_Controller
|
||||||
|
{
|
||||||
|
|
||||||
function __construct() {
|
function __construct()
|
||||||
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index()
|
||||||
// Load public view
|
{
|
||||||
$data['page_title'] = "Upcoming DXPeditions";
|
// Load public view
|
||||||
$this->load->view('interface_assets/header', $data);
|
$data['page_title'] = "Upcoming DXPeditions";
|
||||||
$this->load->view('/workabledxcc/index');
|
$this->load->view('interface_assets/header', $data);
|
||||||
$this->load->view('interface_assets/footer');
|
$this->load->view('/workabledxcc/index');
|
||||||
}
|
$this->load->view('interface_assets/footer');
|
||||||
|
}
|
||||||
|
|
||||||
public function dxcclist() {
|
public function dxcclist()
|
||||||
|
{
|
||||||
|
|
||||||
$json = file_get_contents('https://cdn.cloudlog.org/read_ng3k_dxped_list.php');
|
$json = file_get_contents('https://cdn.cloudlog.org/read_ng3k_dxped_list.php');
|
||||||
|
|
||||||
// Decode the JSON data into a PHP array
|
// Decode the JSON data into a PHP array
|
||||||
$dataResult = json_decode($json, true);
|
$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
|
// Initialize an empty array to store the required data
|
||||||
foreach ($dataResult as $item) {
|
$requiredData = array();
|
||||||
// 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']);
|
// Get Date format
|
||||||
|
if ($this->session->userdata('user_date_format')) {
|
||||||
$EndDate = $oldEndDate->format($custom_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');
|
||||||
|
}
|
||||||
|
|
||||||
$this->load->model('logbook_model');
|
// Iterate through the decoded JSON data
|
||||||
$dxccInfo = $this->logbook_model->dxcc_lookup($item['callsign'], $StartDate);
|
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']);
|
||||||
|
|
||||||
// Call DXCC Worked function to check if the DXCC has been worked before
|
$StartDate = $oldStartDate->format($custom_date_format);
|
||||||
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(
|
$oldEndDate = DateTime::createFromFormat('Y-m-d', $item['1']);
|
||||||
'start_date' => $StartDate,
|
|
||||||
'end_date' => $EndDate,
|
|
||||||
'country' => $item['2'],
|
|
||||||
'notes' => $item['6'],
|
|
||||||
'callsign' => $item['callsign'],
|
|
||||||
'workedBefore' => $dxccWorked['workedBefore'],
|
|
||||||
'confirmed' => $dxccWorked['confirmed'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$data['dxcclist'] = $requiredData;
|
$EndDate = $oldEndDate->format($custom_date_format);
|
||||||
|
|
||||||
// Return the array with the required data
|
|
||||||
|
|
||||||
$this->load->view('/workabledxcc/components/dxcclist', $data);
|
$this->load->model('logbook_model');
|
||||||
}
|
$dxccInfo = $this->logbook_model->dxcc_lookup($item['callsign'], $StartDate);
|
||||||
|
|
||||||
function dxccWorked($country) {
|
// 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(
|
||||||
|
'clean_date' => $item['0'],
|
||||||
|
'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 = [
|
$return = [
|
||||||
"workedBefore" => false,
|
"workedBefore" => false,
|
||||||
|
@ -95,50 +104,49 @@ class Workabledxcc extends CI_Controller {
|
||||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||||
$this->load->model('logbook_model');
|
$this->load->model('logbook_model');
|
||||||
|
|
||||||
if(!empty($logbooks_locations_array)) {
|
if (!empty($logbooks_locations_array)) {
|
||||||
$this->db->where('COL_PROP_MODE !=','SAT');
|
$this->db->where('COL_PROP_MODE !=', 'SAT');
|
||||||
|
|
||||||
$this->db->where_in('station_id', $logbooks_locations_array);
|
$this->db->where_in('station_id', $logbooks_locations_array);
|
||||||
$this->db->where('COL_COUNTRY', urldecode($country));
|
$this->db->where('COL_COUNTRY', urldecode($country));
|
||||||
|
|
||||||
$query = $this->db->get($this->config->item('table_name'), 1, 0);
|
$query = $this->db->get($this->config->item('table_name'), 1, 0);
|
||||||
foreach ($query->result() as $workedBeforeRow)
|
foreach ($query->result() as $workedBeforeRow) {
|
||||||
{
|
|
||||||
$return['workedBefore'] = true;
|
$return['workedBefore'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$extrawhere='';
|
$extrawhere = '';
|
||||||
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) {
|
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) {
|
||||||
$extrawhere="COL_QSL_RCVD='Y'";
|
$extrawhere = "COL_QSL_RCVD='Y'";
|
||||||
}
|
}
|
||||||
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'L') !== false) {
|
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'L') !== false) {
|
||||||
if ($extrawhere!='') {
|
if ($extrawhere != '') {
|
||||||
$extrawhere.=" OR";
|
$extrawhere .= " OR";
|
||||||
}
|
}
|
||||||
$extrawhere.=" COL_LOTW_QSL_RCVD='Y'";
|
$extrawhere .= " COL_LOTW_QSL_RCVD='Y'";
|
||||||
}
|
}
|
||||||
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'E') !== false) {
|
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'E') !== false) {
|
||||||
if ($extrawhere!='') {
|
if ($extrawhere != '') {
|
||||||
$extrawhere.=" OR";
|
$extrawhere .= " OR";
|
||||||
}
|
}
|
||||||
$extrawhere.=" COL_EQSL_QSL_RCVD='Y'";
|
$extrawhere .= " COL_EQSL_QSL_RCVD='Y'";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Z') !== false) {
|
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Z') !== false) {
|
||||||
if ($extrawhere!='') {
|
if ($extrawhere != '') {
|
||||||
$extrawhere.=" OR";
|
$extrawhere .= " OR";
|
||||||
}
|
}
|
||||||
$extrawhere.=" COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'";
|
$extrawhere .= " COL_QRZCOM_QSO_DOWNLOAD_STATUS='Y'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->load->model('logbook_model');
|
$this->load->model('logbook_model');
|
||||||
$this->db->where('COL_PROP_MODE !=','SAT');
|
$this->db->where('COL_PROP_MODE !=', 'SAT');
|
||||||
if ($extrawhere != '') {
|
if ($extrawhere != '') {
|
||||||
$this->db->where('('.$extrawhere.')');
|
$this->db->where('(' . $extrawhere . ')');
|
||||||
} else {
|
} else {
|
||||||
$this->db->where("1=0");
|
$this->db->where("1=0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->db->where_in('station_id', $logbooks_locations_array);
|
$this->db->where_in('station_id', $logbooks_locations_array);
|
||||||
|
@ -146,7 +154,7 @@ class Workabledxcc extends CI_Controller {
|
||||||
|
|
||||||
$query = $this->db->get($this->config->item('table_name'), 1, 0);
|
$query = $this->db->get($this->config->item('table_name'), 1, 0);
|
||||||
foreach ($query->result() as $workedBeforeRow) {
|
foreach ($query->result() as $workedBeforeRow) {
|
||||||
$return['confirmed']=true;
|
$return['confirmed'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
|
@ -1,39 +1,56 @@
|
||||||
<table class="table table-striped table-hover">
|
<?php
|
||||||
|
$grouped = [];
|
||||||
|
|
||||||
<tr>
|
// Step 2: Iterate over $dxcclist.
|
||||||
|
foreach ($dxcclist as $dxcc) {
|
||||||
|
// Get the month from the start date.
|
||||||
|
$month = date('F Y', strtotime($dxcc['clean_date']));
|
||||||
|
|
||||||
|
// Check if this month already exists in $grouped.
|
||||||
|
if (!isset($grouped[$month])) {
|
||||||
|
// If it doesn't, create a new array for it.
|
||||||
|
$grouped[$month] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the current item to the array for its month.
|
||||||
|
$grouped[$month][] = $dxcc;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 5: Iterate over $grouped to create a table for each month.
|
||||||
|
foreach ($grouped as $month => $dxccs) {
|
||||||
|
echo "<h3>$month</h3>";
|
||||||
|
echo '<table class="table table-striped table-hover">';
|
||||||
|
echo '<tr>
|
||||||
<td>Start Date</td>
|
<td>Start Date</td>
|
||||||
<td>End Date</td>
|
<td>End Date</td>
|
||||||
<td>Country</td>
|
<td>Country</td>
|
||||||
<td>Callsign</td>
|
<td>Callsign</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>Notes</td>
|
<td>Notes</td>
|
||||||
</tr>
|
</tr>';
|
||||||
|
|
||||||
|
foreach ($dxccs as $dxcc) {
|
||||||
|
echo '<tr>
|
||||||
|
<td>' . $dxcc['start_date'] . '</td>
|
||||||
|
<td>' . $dxcc['end_date'] . '</td>
|
||||||
|
<td>' . $dxcc['country'] . '</td>
|
||||||
|
<td>' . $dxcc['callsign'] . '</td>
|
||||||
|
<td>';
|
||||||
|
|
||||||
|
if (!$dxcc['workedBefore']) {
|
||||||
|
echo '<span class="badge bg-danger">Not Worked Before</span>';
|
||||||
|
} else {
|
||||||
|
echo '<span class="badge bg-success">Worked Before</span>';
|
||||||
|
}
|
||||||
|
|
||||||
<?php foreach($dxcclist as $dxcc): ?>
|
if ($dxcc['confirmed']) {
|
||||||
<tr>
|
echo '<span class="badge bg-primary">Confirmed</span>';
|
||||||
<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>
|
echo '</td>
|
||||||
<td>
|
<td>' . $dxcc['notes'] . '</td>
|
||||||
|
</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
<?php if (!$dxcc['workedBefore']) { ?>
|
echo '</table>';
|
||||||
<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>
|
|
||||||
|
|
Ładowanie…
Reference in New Issue