| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/wamp/www/sipkd_2016/application/modules/auditlog/controllers/ |
Upload File : |
<?php
class Auditlog extends Admin_Controller {
public function __construct()
{
parent::__construct();
$this->modul_name = 'auditlog';
$this->modul_display = 'Auditlog';
$this->view_daftar = 'auditlog_view';
$this->report_daftar = 'Daftar AuditLog';
$this->load->model('auditlog_model', 'data_model');
}
public function index()
{
$this->daftar();
}
public function daftar()
{
$this->load->model('auth/login_model', 'auth');
$data['breadcrumbs'] = 'Daftar '.$this->modul_display;
$data['modul'] = $this->modul_name;
$data['report_daftar'] = $this->report_daftar;
$data['akses'] = $this->auth->get_level_akses($this->uri->slash_segment(1));
$data['grid']['fields'] = $this->data_model->get_data_fields();
$data['main_content'] = $this->view_daftar;
$this->load->view('layout/template_admin', $data);
}
public function get_daftar()
{
parent::get_daftar();
// sortir berdasarkan id secara descending
$this->search_param["sort_by"] = 'id';
$this->search_param["sort_direction"] = 'desc';
$count = $this->data_model->get_data($this->search_param, TRUE);
$response = (object) NULL;
$response->sql = $this->db->queries;
if($count == 0) // tidak ada data
{
echo json_encode($response);
return '';
}
$page = $this->page;
$limit = $this->limit;
$total_pages = ceil($count/$limit);
if ($page > $total_pages) $page = $total_pages;
$start = $limit * $page - $limit;
if($start < 0) $start = 0;
$this->search_param['limit'] = array(
'start' => $start,
'end' => $limit
);
$result = $this->data_model->get_data($this->search_param);
$response->page = $page;
$response->total = $total_pages;
$response->records = $count;
$response->sql = $this->db->queries;
$fields = $this->data_model->fieldmap_daftar;
for($i=0; $i<count($result); $i++)
{
$response->rows[$i]['id'] = $result[$i][$fields[0]];
$data = array();
for ($n=1; $n < count($fields); $n++)
{
if ($fields[$n] == 'WAKTU') {
$data[] = date('d-m-Y H:i', strtotime($result[$i][$fields[$n]] ));
}
else $data[] = $result[$i][$fields[$n]];
}
$response->rows[$i]['cell'] = $data;
}
echo json_encode($response);
}
public function hapus()
{
$response = (object) NULL;
$this->load->model('auth/login_model', 'auth');
$akses = $this->auth->get_level_akses($this->uri->slash_segment(1));
if($akses !== 3)
{
$response->isSuccess = FALSE;
$response->message = 'Anda tidak memiliki Hak akses.';
echo json_encode($response);
return;
}
$id = $this->input->post('id');
if ($id > 0)
{
// hapus log sampai dengan baris yang dipilih
$result = $this->data_model->delete_log($id);
}
else {
// hapus semua log
$result = $this->data_model->clear_log();
}
if($result)
{
$response->isSuccess = TRUE;
$response->message = $id > 0 ? 'AuditLog telah dihapus.' : 'AuditLog telah dikosongkan.';
}
else
{
$response->isSuccess = FALSE;
$response->message = $id > 0 ? 'AuditLog gagal di hapus.' : 'AuditLog gagal dikosongkan.';
$response->error = $this->data_model->last_error_message;
}
$response->sql = $this->db->queries;
echo json_encode($response);
}
}