-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudit.php
More file actions
55 lines (47 loc) · 1.54 KB
/
Copy pathAudit.php
File metadata and controls
55 lines (47 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Class Audit.
*
* This controller serves the registration and login history page.
*/
class Audit extends CI_Controller
{
/**
* Audit constructor.
*
* Initialize the database, loads the pagination library and audit model.
*/
public function __construct()
{
parent::__construct();
$this->load->database();
$this->load->library('pagination');
$this->load->model('audit_model');
}
/**
* Default function.
*
* Retrieve the registration and login history of the logged-in user from the database
* based on the session. Present the history in a tabular form with pagination.
*/
function index()
{
$userId = $this->session->userdata('id_user');
if (!$userId) {
redirect('/');
}
$data = [];
$resultsPerPage = 5;
$currentPageNo = $this->input->get('per_page');
$resultsCount = $this->audit_model->get_audit_count_by_id_user($userId);
$config['base_url'] = '/audit';
$config['per_page'] = $resultsPerPage;
$config['total_rows'] = $resultsCount;
$this->pagination->initialize($config);
$data['paginationLinks'] = $this->pagination->create_links();
$audits = $this->audit_model->get_audit_by_id_user($userId, $currentPageNo, $resultsPerPage);
$data['audits'] = $audits;
$this->load->view('audit', $data);
}
}