kopia lustrzana https://github.com/magicbug/Cloudlog
[Upcoming Dxped] Split output into months
rodzic
df1e227625
commit
660cdc6b24
|
@ -1,19 +1,25 @@
|
||||||
<?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
|
// Load public view
|
||||||
$data['page_title'] = "Upcoming DXPeditions";
|
$data['page_title'] = "Upcoming DXPeditions";
|
||||||
$this->load->view('interface_assets/header', $data);
|
$this->load->view('interface_assets/header', $data);
|
||||||
|
@ -21,7 +27,8 @@ class Workabledxcc extends CI_Controller {
|
||||||
$this->load->view('interface_assets/footer');
|
$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');
|
||||||
|
|
||||||
|
@ -66,6 +73,7 @@ class Workabledxcc extends CI_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$requiredData[] = array(
|
$requiredData[] = array(
|
||||||
|
'clean_date' => $item['0'],
|
||||||
'start_date' => $StartDate,
|
'start_date' => $StartDate,
|
||||||
'end_date' => $EndDate,
|
'end_date' => $EndDate,
|
||||||
'country' => $item['2'],
|
'country' => $item['2'],
|
||||||
|
@ -83,7 +91,8 @@ class Workabledxcc extends CI_Controller {
|
||||||
$this->load->view('/workabledxcc/components/dxcclist', $data);
|
$this->load->view('/workabledxcc/components/dxcclist', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dxccWorked($country) {
|
function dxccWorked($country)
|
||||||
|
{
|
||||||
|
|
||||||
$return = [
|
$return = [
|
||||||
"workedBefore" => false,
|
"workedBefore" => false,
|
||||||
|
@ -102,8 +111,7 @@ class Workabledxcc extends CI_Controller {
|
||||||
$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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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