Commit 990e1aa8 by Phạm Văn Đoan

thêm chức năng xem log crontjob

parent 01058cae
...@@ -416,8 +416,8 @@ $config['csrf_exclude_uris'] = array( ...@@ -416,8 +416,8 @@ $config['csrf_exclude_uris'] = array(
'backend/cmsSetting/listGroupAjax', 'backend/cmsSetting/listGroupAjax',
'backend/cmsSetting/listUserAdminAjax', 'backend/cmsSetting/listUserAdminAjax',
'backend/cmsSetting/logUserAjax', 'backend/cmsSetting/logUserAjax',
'backend/cmsSetting/logUserAjax',
'backend/cmsSetting/logActionAjax', 'backend/cmsSetting/logActionAjax',
'backend/cmsSetting/logCrontjobAjax',
'backend/cmsSetting/overlapRankingAjax', 'backend/cmsSetting/overlapRankingAjax',
......
...@@ -1829,6 +1829,39 @@ class CmsSetting extends CI_Controller ...@@ -1829,6 +1829,39 @@ class CmsSetting extends CI_Controller
$this->load->view('backend/ajax/cms_setting/overlap_ranking_view', $data); $this->load->view('backend/ajax/cms_setting/overlap_ranking_view', $data);
} }
/**
* ----------------------------------------------------------------------------------------------------------------
* Log
*/
public function logCrontjob()
{
$this->_data['functionName'] = 'Log crontjob';
$this->_data['action'] = __FUNCTION__;
$this->_data['titlePage'] = 'Log crontjob';
$this->_data['loadPage'] = 'backend/cms_setting/crontjob/log_crontjob_view';
$this->load->view('backend/admin_template_view', $this->_data);
}
public function logCrontjobAjax()
{
$this->load->model('crontjob_model');
//
$data = array();
$fByName = $this->input->post('fByName');
$pageId = $this->input->post('pageId');
//
$pageId = ($pageId == 0) ? 1 : $pageId;
//
$limit = 30;
$offset = ($pageId - 1)*$limit;
$data['offset'] = ($pageId - 1)*$limit;
$totalRecord = $this->crontjob_model->cmsCountAll($fByName);
$data['pagination'] = MyHelper::genPaginationLink($totalRecord, $limit, $pageId);
$data['listData'] = $this->crontjob_model->cmsGetPagination($limit, $offset, $fByName);
//
$this->load->view('backend/ajax/cms_setting/log_crontjob_view', $data);
}
......
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Crontjob_model extends CI_Model
{
protected $_table = TABLE_CRONTJOBS;
public function __construct()
{
parent::__construct();
date_default_timezone_set("Asia/Ho_Chi_Minh");
}
public function cmsCountAll($name = null)
{
$this->db->select('COUNT(*) AS totalResults');
$this->db->from($this->_table);
if ($name != null) {
$this->db->like($this->_table . '.message', $name, 'both');
}
$query = $this->db->get();
$result = $query->result_array();
if ($result) {
return $result[0]['totalResults'];
} else {
return 0;
}
}
public function cmsGetPagination($record, $start, $name = null)
{
$this->db->select('*');
$this->db->from($this->_table);
if ($name != null) {
$this->db->like($this->_table . '.message', $name, 'both');
}
$this->db->order_by($this->_table . '.id', 'desc');
$this->db->limit($record, $start);
$query = $this->db->get();
return $query->result_array();
}
}
/* End of file welcome.php */
\ No newline at end of file
...@@ -278,6 +278,13 @@ $action = $CI->router->fetch_method(); ...@@ -278,6 +278,13 @@ $action = $CI->router->fetch_method();
<b class="arrow"></b> <b class="arrow"></b>
</li> </li>
<li class="<?php if($action && $action == 'logCrontjob') echo 'active'?>">
<a href="<?php echo base_url().'backend/cmsSetting/logCrontjob'; ?>">
<i class="menu-icon fa fa-caret-right"></i>Log crontjob
</a>
<b class="arrow"></b>
</li>
<li class="<?php if($action && $action == 'logUser') echo 'active'?>"> <li class="<?php if($action && $action == 'logUser') echo 'active'?>">
<a href="<?php echo base_url().'backend/cmsSetting/logUser'; ?>"> <a href="<?php echo base_url().'backend/cmsSetting/logUser'; ?>">
<i class="menu-icon fa fa-caret-right"></i>Log nhập, xuất <i class="menu-icon fa fa-caret-right"></i>Log nhập, xuất
......
<div>
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th style="text-align: center">STT</th>
<th style="text-align: center">Nội dung log</th>
<th style="text-align: center">Thời gian chạy</th>
</tr>
</thead>
<tbody>
<?php if(count($listData) > 0): foreach($listData as $key => $data): ?>
<tr>
<td style="text-align: center"><?php echo ($key+1+$offset); ?></td>
<td style="text-align: left"><?php echo $data['message']; ?></td>
<td style="text-align: center"><?php echo MyHelper::reFormatDate($data['created_at']); ?></td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="5" style="color: red; font-style: italic">Không có dữ liệu nào!</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
<!-- /.row -->
<div style="text-align: center;"><?php echo $pagination; ?></div>
\ No newline at end of file
<!-- Thông báo lỗi -->
<?php MyHelper::loadView('backend/cms_partials/error_message_view') ?>
<div class="row" >
<div style="text-align: center" id="data-loading">
<i class="fa fa-refresh fa-spin bigger-200"></i> Đang tải dữ liệu...
</div>
<div class="col-lg-12">
<div id="div-response"></div>
</div>
</div>
<script type="text/javascript">
//Thuc hien viec ve bieu do$data
$(document).ready(function() {
var url = '<?php echo base_url("backend/cmsSetting/logCrontjobAjax"); ?>';
// Tìm kiếm theo cú pháp
var oldTimeout2 = '';
$('#input-date-picker').change(function(){
clearTimeout(oldTimeout2);
oldTimeout2 = setTimeout(function(){
//loadDataByAjaxFromInput(url);
}, 250);
});
// Xóa bộ lọc
$('#delete-filter').click(function(){
$("#input-date-picker").val('<?php echo date('d/m/Y', time()-86400)?>');
changePagination('0');
return false;
});
changePagination('0');
});
function changePagination(pageId) {
$('#data-loading').show();
var url = '<?php echo base_url("backend/cmsSetting/logCrontjobAjax"); ?>';
callAjax(pageId, url);
}
function callAjax(pageId, url) {
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-date-picker").val();
var dataReq = {
csrf_name: csrf_value,
fByName: fByName,
pageId: pageId
};
//Ajax
$.ajax({
type: "POST",
url: url,
data: dataReq,
dataType: "text",
cache: false,
success: function(data) {
$('#div-response').html(data);
$('#data-loading').hide();
}
});
}
</script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment