cloudlog/application/controllers/Accumulated.php
Peter Goodhall d1446a6c22 Add HTMX component and refactor accumulated UI/JS
Introduce a new partial view and controller endpoint for rendering accumulated-results as an HTMX component, and refactor the accumulated statistics page and JS. Changes include: adding component_accumulated_results() in the Accumulated controller and a new view (accumulate/component_results.php) exposing filter params via data-attributes; updating accumulate/index.php to use a card-based layout, improved form markup, and HTMX attributes to load the results component; and a major rewrite of assets/js/sections/accumulatedstatistics.js to modularize logic (getAwardText, setAccumulateLoading, accumulateRender), improve loading/error handling, rebuild chart/table markup, update DataTables usage, and hook into htmx:afterSwap to render the chart when the component is swapped in. Overall this enables partial updates, better UX, and cleaner client-side code.
2026-04-26 22:05:52 +01:00

58 lines
No EOL
1.8 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Accumulated 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()
{
// Render Page
$data['page_title'] = "Accumulated Statistics";
$this->load->model('bands');
$data['worked_bands'] = $this->bands->get_worked_bands(); // Used in the view for band select
$this->load->model('modes');
$data['modes'] = $this->modes->active();
$this->load->view('interface_assets/header', $data);
$this->load->view('accumulate/index');
$this->load->view('interface_assets/footer');
}
public function component_accumulated_results() {
$data['band'] = $this->input->post('band') ?: 'All';
$data['mode'] = $this->input->post('mode') ?: 'All';
$data['award'] = $this->input->post('awardradio') ?: 'dxcc';
$data['period'] = $this->input->post('periodradio') ?: 'year';
$this->load->view('accumulate/component_results', $data);
}
/*
* Used for ajax-call in javascript to fetch the data and insert into table and chart
*/
public function get_accumulated_data(){
//load model
$this->load->model('accumulate_model');
$band = $this->input->post('Band');
$award = $this->input->post('Award');
$mode = $this->input->post('Mode');
$period = $this->input->post('Period');
// get data
$data = $this->accumulate_model->get_accumulated_data($band, $award, $mode, $period);
header('Content-Type: application/json');
echo json_encode($data);
}
}