[Dashboard] DXCC Upcoming now a component loaded after the main page load

pull/2978/head
Peter Goodhall 2024-02-18 13:47:01 +00:00
rodzic 039341039a
commit 945c1f9ef7
3 zmienionych plików z 45 dodań i 44 usunięć

Wyświetl plik

@ -127,30 +127,6 @@ class Dashboard extends CI_Controller
$data['total_countries_needed'] = count($dxcc->result()) - $current;
$this->load->model('Workabledxcc_model');
$this->load->driver('cache', array('adapter' => 'file', 'backup' => 'file'));
// Get the user ID from the session data
$userID = $this->session->userdata('user_id');
// Use the user ID to create a unique cache name
$cacheName = 'thisWeekRecords_' . $userID;
if (!$thisWeekRecords = $this->cache->get($cacheName)) {
// If the cache does not exist, get the data and save it to the cache.
$thisWeekRecords = $this->Workabledxcc_model->GetThisWeek();
$this->cache->save($cacheName, $thisWeekRecords, 3600); // Cache for 1 hour (3600 seconds)
}
$data['thisWeekRecords'] = $thisWeekRecords;
usort($data['thisWeekRecords'], function ($a, $b) {
$dateA = new DateTime($a['1']);
$dateB = new DateTime($b['1']);
return $dateA <=> $dateB;
});
$this->load->view('interface_assets/header', $data);
$this->load->view('dashboard/index');
$this->load->view('interface_assets/footer');
@ -164,4 +140,29 @@ class Dashboard extends CI_Controller
$data['radio_status'] = $this->cat->recent_status();
$this->load->view('components/radio_display_table', $data);
}
function upcoming_dxcc_component()
{
$this->load->model('Workabledxcc_model');
$this->load->driver('cache', array('adapter' => 'file', 'backup' => 'file'));
// Get the user ID from the session data
$userID = $this->session->userdata('user_id');
$thisWeekRecords = $this->Workabledxcc_model->GetThisWeek();
$data['thisWeekRecords'] = $thisWeekRecords;
usort($data['thisWeekRecords'], function ($a, $b) {
$dateA = new DateTime($a['1']);
$dateB = new DateTime($b['1']);
return $dateA <=> $dateB;
});
$this->load->view('components/upcoming_dxccs', $data);
}
}

Wyświetl plik

@ -0,0 +1,16 @@
<table class="table table-striped border-top">
<tr class="titles">
<td colspan="3"><i class="fas fa-chart-bar"></i> DXPeditions (This Week)</td>
</tr>
<?php
foreach ($thisWeekRecords as $record) {
$color = $record['workedBefore'] == 1 ? '#ddffdd' : '#ffdddd';
echo '<tr>';
echo '<td style="background-color: ' . $color . ';" width="33%">' . $record['daysLeft'] . '</td>'; // Date
echo '<td style="background-color: ' . $color . ';" width="33%">' . $record['callsign'] . '</td>'; // Callsign
echo '<td style="background-color: ' . $color . ';" width="33%">' . $record['2'] . '</td>'; // Country
echo '</tr>';
}
?>
</table>

Wyświetl plik

@ -295,26 +295,10 @@ function echoQrbCalcLink($mygrid, $grid, $vucc)
<div id="radio_display" hx-get="<?php echo site_url('visitor/radio_display_component'); ?>" hx-trigger="load, every 5s"></div>
<table class="table table-striped border-top">
<tr class="titles">
<td colspan="3"><i class="fas fa-chart-bar"></i> DXPeditions (This Week)</td>
</tr>
<?php
foreach ($thisWeekRecords as $record) {
$color = $record['workedBefore'] == 1 ? '#ddffdd' : '#ffdddd';
echo '<tr>';
echo '<td style="background-color: ' . $color . ';" width="33%">' . $record['daysLeft'] . '</td>'; // Date
echo '<td style="background-color: ' . $color . ';" width="33%">' . $record['callsign'] . '</td>'; // Callsign
echo '<td style="background-color: ' . $color . ';" width="33%">' . $record['2'] . '</td>'; // Country
echo '</tr>';
}
?>
</table>
<div>
<div id="upcoming_dxccs_component" hx-get="<?php echo site_url('dashboard/upcoming_dxcc_component'); ?>" hx-trigger="load" hx-indicator="#loading_upcoming_dxcc"></div>
<div id="loading_upcoming_dxcc" style="display: none;">Loading Upcoming DXPeditions.</div>
</div>
<table class="table table-striped border-top">
<tr class="titles">
<td colspan="2"><i class="fas fa-chart-bar"></i> <?php echo lang('dashboard_qso_breakdown'); ?></td>