[Upcoming Dxped] Split output into months
这个提交包含在:
父节点
df1e227625
当前提交
660cdc6b24
共有 2 个文件被更改,包括 140 次插入 和 115 次删除
|
|
@ -1,19 +1,25 @@
|
|||
<?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();
|
||||
|
||||
$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";
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
|
|
@ -21,7 +27,8 @@ class Workabledxcc extends CI_Controller {
|
|||
$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');
|
||||
|
||||
|
|
@ -66,6 +73,7 @@ class Workabledxcc extends CI_Controller {
|
|||
}
|
||||
|
||||
$requiredData[] = array(
|
||||
'clean_date' => $item['0'],
|
||||
'start_date' => $StartDate,
|
||||
'end_date' => $EndDate,
|
||||
'country' => $item['2'],
|
||||
|
|
@ -83,7 +91,8 @@ class Workabledxcc extends CI_Controller {
|
|||
$this->load->view('/workabledxcc/components/dxcclist', $data);
|
||||
}
|
||||
|
||||
function dxccWorked($country) {
|
||||
function dxccWorked($country)
|
||||
{
|
||||
|
||||
$return = [
|
||||
"workedBefore" => false,
|
||||
|
|
@ -102,8 +111,7 @@ class Workabledxcc extends CI_Controller {
|
|||
$this->db->where('COL_COUNTRY', urldecode($country));
|
||||
|
||||
$query = $this->db->get($this->config->item('table_name'), 1, 0);
|
||||
foreach ($query->result() as $workedBeforeRow)
|
||||
{
|
||||
foreach ($query->result() as $workedBeforeRow) {
|
||||
$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>End Date</td>
|
||||
<td>Country</td>
|
||||
<td>Callsign</td>
|
||||
<td></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): ?>
|
||||
<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']; ?>
|
||||
if ($dxcc['confirmed']) {
|
||||
echo '<span class="badge bg-primary">Confirmed</span>';
|
||||
}
|
||||
|
||||
</td>
|
||||
<td>
|
||||
echo '</td>
|
||||
<td>' . $dxcc['notes'] . '</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
<?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>
|
||||
echo '</table>';
|
||||
}
|
||||
|
|
|
|||
正在加载…
在新工单中引用