Commit ff73b82f by Phạm Văn Đoan

code module BXH ngày, tuần, tháng

parent ce29cc61
......@@ -397,6 +397,10 @@ $config['csrf_exclude_uris'] = array(
'backend/cmsStatistic/listUserClickAjax',
'backend/cmsContest/listContestAjax',
'backend/cmsRanking/listByDailyAjax',
'backend/cmsRanking/listByWeeklyAjax',
'backend/cmsRanking/listByMonthlyAjax',
'backend/cmsTrack/listTrackAjax',
'backend/cmsArtist/listArtistAjax',
......
......@@ -15,20 +15,21 @@ class CmsRanking extends CI_Controller
date_default_timezone_set("Asia/Ho_Chi_Minh");
//
$this->load->model('track_model');
$this->load->model('user_model');
$this->load->model('actionlog_model');
$this->load->model('report_views_daily_model');
$this->load->model('report_views_weekly_model');
$this->load->model('report_views_monthly_model');
}
public function listTrack()
public function listByDaily()
{
$this->_data['functionName'] = 'Track';
$this->_data['action'] = 'listTrack';
$this->_data['titlePage'] = 'Track';
$this->_data['loadPage'] = 'backend/cms_track/list_track_view';
$this->_data['functionName'] = 'BXH theo ngày';
$this->_data['action'] = 'listByDaily';
$this->_data['titlePage'] = 'BXH theo ngày';
$this->_data['loadPage'] = 'backend/cms_ranking/list_by_daily_view';
$this->load->view('backend/admin_template_view', $this->_data);
}
public function listTrackAjax()
public function listByDailyAjax()
{
$data = array();
$fByName = $this->input->post('fByName');
......@@ -39,86 +40,71 @@ class CmsRanking extends CI_Controller
$limit = 25;
$offset = ($pageId - 1) * $limit;
$data['offset'] = ($pageId - 1) * $limit;
$totalRecord = $this->mtrack->cmsCountAll($fByName);
$totalRecord = $this->track_model->cmsCountAll($fByName);
$data['pagination'] = MyHelper::genPaginationLink($totalRecord, $limit, $pageId);
$data['listData'] = $this->mtrack->cmsGetPagination($limit, $offset, $fByName);
$data['listData'] = $this->track_model->cmsGetPagination($limit, $offset, $fByName);
//
$this->load->view('backend/ajax/cms_track/list_track_view', $data);
$this->load->view('backend/ajax/cms_ranking/list_by_daily_view', $data);
}
public function editContest($contest_id)
/**
* BXH theo tuần ---------------------------------------------------------------------------------------------------
*/
public function listByWeekly()
{
$this->_data['contest'] = $contest = $this->mtrack->getById($contest_id);
// Kiểm tra trùng giá trị nếu thay đổi ở form
// Thiết lập validate
$this->form_validation->set_rules(
'id',
'ID',
'trim'
);
$this->form_validation->set_rules(
'date_limit',
'Số ngày diễn ra cuộc thi',
'trim|required|xss_clean'
);
$this->_data['functionName'] = 'BXH theo tuần';
$this->_data['action'] = 'listByDaily';
$this->_data['titlePage'] = 'BXH theo tuần';
$this->_data['loadPage'] = 'backend/cms_ranking/list_by_weekly_view';
$this->load->view('backend/admin_template_view', $this->_data);
}
$this->form_validation->set_rules(
'date_from',
'Ngày bắt đầu diễn ra cuộc thi',
'trim|required|xss_clean'
);
public function listByWeeklyAjax()
{
$data = array();
$fByName = $this->input->post('fByName');
$pageId = $this->input->post('pageId');
//
$pageId = ($pageId == 0) ? 1 : $pageId;
//
$limit = 25;
$offset = ($pageId - 1) * $limit;
$data['offset'] = ($pageId - 1) * $limit;
$totalRecord = $this->track_model->cmsCountAll($fByName);
$data['pagination'] = MyHelper::genPaginationLink($totalRecord, $limit, $pageId);
$data['listData'] = $this->track_model->cmsGetPagination($limit, $offset, $fByName);
//
$this->load->view('backend/ajax/cms_ranking/list_by_weekly_view', $data);
}
$this->form_validation->set_message('required', '<li>Bắt buộc nhập, chọn.</li>');
$this->form_validation->set_message('is_unique', '<li>Đã tồn tại.</li>');
// Xử lý form đăng nhập
if($this->form_validation->run($this) == false) {
$this->_data['date_limit'] = $this->input->post('name');
$this->_data['date_from'] = $this->input->post('description');
//
$this->_data['functionName'] = 'QL Cuộc đua';
$this->_data['action'] = 'editContest';
$this->_data['titlePage'] = 'QL Cuộc đua';
$this->_data['loadPage'] = 'backend/cms_track/edit_track_view';
$this->load->view('backend/admin_template_view', $this->_data);
}else{
$date_limit = intval(trim($this->input->post('date_limit')));
$date_from = trim($this->input->post('date_from'));
if(($date_limit >= 7) && ($date_limit <= 50) && (strtotime($date_from) >= strtotime(date('Y-m-d', time())))){
$dataUpdate = array(
'date_limit' => $date_limit,
'date_from' => $date_from,
'updated_at'=> date("Y-m-d H:i:s")
);
$this->mtrack->update($contest_id, $dataUpdate);
// Cap nhat mang thoi gian ngay tham gia tu so ngay
for($i=1; $i <= $date_limit; $i++){
$data_update_contest_details = array(
'date_play' => date('Y-m-d', strtotime($date_from) + ($i-1)*86400)
);
$this->mcontest_details->update($i, $data_update_contest_details);
}
// Ghi log
$this->mactionlog->add('UPDATED', 'Cập nhật Cuộc đua thành công!', 'Mactionlog', 'action_log', $contest_id);
//
$this->session->set_flashdata('success', 'Cập nhật Cuộc đua thành công');
}else{
$this->session->set_flashdata('error', 'Cập nhật Cuộc đua không thành công');
}
redirect(base_url().'backend/cmsContest/listContest');
}
/**
* BXH theo tháng --------------------------------------------------------------------------------------------------
*/
public function listByMonthly()
{
$this->_data['functionName'] = 'BXH theo tháng';
$this->_data['action'] = 'listByDaily';
$this->_data['titlePage'] = 'BXH theo tháng';
$this->_data['loadPage'] = 'backend/cms_ranking/list_by_monthly_view';
$this->load->view('backend/admin_template_view', $this->_data);
}
public function showUser($user_id)
public function listByMonthlyAjax()
{
$this->_data['user'] = $this->muser->getById($user_id);
$data = array();
$fByName = $this->input->post('fByName');
$pageId = $this->input->post('pageId');
//
$this->_data['functionName'] = 'Thông tin Người chơi';
$this->_data['action'] = 'showUser';
$this->_data['titlePage'] = 'Thông tin Người chơi';
$this->_data['loadPage'] = 'backend/cms_user/show_user_view';
$this->load->view('backend/admin_template_view', $this->_data);
$pageId = ($pageId == 0) ? 1 : $pageId;
//
$limit = 25;
$offset = ($pageId - 1) * $limit;
$data['offset'] = ($pageId - 1) * $limit;
$totalRecord = $this->track_model->cmsCountAll($fByName);
$data['pagination'] = MyHelper::genPaginationLink($totalRecord, $limit, $pageId);
$data['listData'] = $this->track_model->cmsGetPagination($limit, $offset, $fByName);
//
$this->load->view('backend/ajax/cms_ranking/list_by_monthly_view', $data);
}
}
\ No newline at end of file
......@@ -9,4 +9,44 @@ class Report_views_daily_model extends CI_Model
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('title', $name, 'both');
$this->db->or_like('description', $name, 'both');
$this->db->or_like('slug', $name, 'both');
$this->db->or_like('tag', $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->_table . '.*, u1.full_name AS singer_name, u2.full_name AS composer_name, track_user.name AS singer_name2, track_artists.name AS composer_name2');
$this->db->from($this->_table);
$this->db->join('track_user', 'track_user.track_id = tracks.id', 'left');
$this->db->join('track_artists', 'track_artists.track_id = tracks.id', 'left');
$this->db->join('users u1', 'u1.id = track_user.user_id', 'left');
$this->db->join('users u2', 'u2.id = track_artists.user_id', 'left');
if ($name != null) {
$this->db->like('tracks.title', $name, 'both');
$this->db->or_like('tracks.description', $name, 'both');
$this->db->or_like('tracks.slug', $name, 'both');
$this->db->or_like('tracks.tag', $name, 'both');
}
$this->db->order_by($this->_table . '.title', 'asc');
$this->db->limit($record, $start);
$query = $this->db->get();
return $query->result_array();
}
}
\ No newline at end of file
......@@ -9,4 +9,44 @@ class Report_views_monthly_model extends CI_Model
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('title', $name, 'both');
$this->db->or_like('description', $name, 'both');
$this->db->or_like('slug', $name, 'both');
$this->db->or_like('tag', $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->_table . '.*, u1.full_name AS singer_name, u2.full_name AS composer_name, track_user.name AS singer_name2, track_artists.name AS composer_name2');
$this->db->from($this->_table);
$this->db->join('track_user', 'track_user.track_id = tracks.id', 'left');
$this->db->join('track_artists', 'track_artists.track_id = tracks.id', 'left');
$this->db->join('users u1', 'u1.id = track_user.user_id', 'left');
$this->db->join('users u2', 'u2.id = track_artists.user_id', 'left');
if ($name != null) {
$this->db->like('tracks.title', $name, 'both');
$this->db->or_like('tracks.description', $name, 'both');
$this->db->or_like('tracks.slug', $name, 'both');
$this->db->or_like('tracks.tag', $name, 'both');
}
$this->db->order_by($this->_table . '.title', 'asc');
$this->db->limit($record, $start);
$query = $this->db->get();
return $query->result_array();
}
}
\ No newline at end of file
......@@ -9,4 +9,44 @@ class Report_views_weekly_model extends CI_Model
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('title', $name, 'both');
$this->db->or_like('description', $name, 'both');
$this->db->or_like('slug', $name, 'both');
$this->db->or_like('tag', $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->_table . '.*, u1.full_name AS singer_name, u2.full_name AS composer_name, track_user.name AS singer_name2, track_artists.name AS composer_name2');
$this->db->from($this->_table);
$this->db->join('track_user', 'track_user.track_id = tracks.id', 'left');
$this->db->join('track_artists', 'track_artists.track_id = tracks.id', 'left');
$this->db->join('users u1', 'u1.id = track_user.user_id', 'left');
$this->db->join('users u2', 'u2.id = track_artists.user_id', 'left');
if ($name != null) {
$this->db->like('tracks.title', $name, 'both');
$this->db->or_like('tracks.description', $name, 'both');
$this->db->or_like('tracks.slug', $name, 'both');
$this->db->or_like('tracks.tag', $name, 'both');
}
$this->db->order_by($this->_table . '.title', 'asc');
$this->db->limit($record, $start);
$query = $this->db->get();
return $query->result_array();
}
}
\ No newline at end of file
......@@ -134,7 +134,7 @@ $action = $CI->router->fetch_method();
</li>
<!-- Quan ly Thong ke -->
<li class="<?php if($controller && $controller == 'cmsStatistic') echo 'active open'?>">
<li class="<?php if($controller && $controller == 'cmsRanking') echo 'active open'?>">
<a href="#" class="dropdown-toggle">
<i class="menu-icon fa fa-bar-chart-o"></i>
<span class="menu-text">BXH</span>
......@@ -142,20 +142,20 @@ $action = $CI->router->fetch_method();
</a>
<b class="arrow"></b>
<ul class="submenu">
<li class="<?php if($action && (in_array($action, array('listGame','addGame','editGame')))) echo 'active'?>">
<a href="<?php echo base_url('backend/cmsStatistic/listGame'); ?>">
<li class="<?php if($action && (in_array($action, array('listByDaily')))) echo 'active'?>">
<a href="<?php echo base_url('backend/cmsRanking/listByDaily'); ?>">
<i class="menu-icon fa fa-caret-right"></i>BXH Ngày
</a>
<b class="arrow"></b>
</li>
<li class="<?php if($action && (in_array($action, array('listGame','addGame','editGame')))) echo 'active'?>">
<a href="<?php echo base_url('backend/cmsStatistic/listGame'); ?>">
<li class="<?php if($action && (in_array($action, array('listByWeekly')))) echo 'active'?>">
<a href="<?php echo base_url('backend/cmsRanking/listByWeekly'); ?>">
<i class="menu-icon fa fa-caret-right"></i>BXH Tuần
</a>
<b class="arrow"></b>
</li>
<li class="<?php if($action && (in_array($action, array('listTop','addTop','editTop')))) echo 'active'?>">
<a href="<?php echo base_url('backend/cmsStatistic/listTop'); ?>">
<li class="<?php if($action && (in_array($action, array('listByMonthly')))) echo 'active'?>">
<a href="<?php echo base_url('backend/cmsRanking/listByMonthly'); ?>">
<i class="menu-icon fa fa-caret-right"></i>BXH Tháng
</a>
<b class="arrow"></b>
......
<div style="max-height: 465px; overflow: scroll">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th style="text-align: center">TT</th>
<th style="text-align: center">#ID</th>
<th style="text-align: center">Tên bài hát</th>
<th style="text-align: center">Ca sĩ</th>
<th style="text-align: center">Nhạc sĩ</th>
<th style="text-align: center">Xử lý</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: center">#<?php echo $data['id']; ?></td>
<td style="text-align: left"><?php echo $data['title']; ?></td>
<td style="text-align: left"><?php echo ($data['singer_name']) ? $data['singer_name'] : $data['singer_name2']; ?></td>
<td style="text-align: left"><?php echo ($data['composer_name']) ? $data['composer_name'] : $data['composer_name2']; ?></td>
<td style="text-align: center">
<a href="<?php echo base_url().'backend/cmsTrack/editTrack/'.$data['id']; ?>" title="Xem chi tiết">
<i class="ace-icon fa fa-pencil bigger-130"></i>
</a>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="10" 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
<div style="max-height: 465px; overflow: scroll">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th style="text-align: center">TT</th>
<th style="text-align: center">#ID</th>
<th style="text-align: center">Tên bài hát</th>
<th style="text-align: center">Ca sĩ</th>
<th style="text-align: center">Nhạc sĩ</th>
<th style="text-align: center">Xử lý</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: center">#<?php echo $data['id']; ?></td>
<td style="text-align: left"><?php echo $data['title']; ?></td>
<td style="text-align: left"><?php echo ($data['singer_name']) ? $data['singer_name'] : $data['singer_name2']; ?></td>
<td style="text-align: left"><?php echo ($data['composer_name']) ? $data['composer_name'] : $data['composer_name2']; ?></td>
<td style="text-align: center">
<a href="<?php echo base_url().'backend/cmsTrack/editTrack/'.$data['id']; ?>" title="Xem chi tiết">
<i class="ace-icon fa fa-pencil bigger-130"></i>
</a>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="10" 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
<div style="max-height: 465px; overflow: scroll">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th style="text-align: center">TT</th>
<th style="text-align: center">#ID</th>
<th style="text-align: center">Tên bài hát</th>
<th style="text-align: center">Ca sĩ</th>
<th style="text-align: center">Nhạc sĩ</th>
<th style="text-align: center">Xử lý</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: center">#<?php echo $data['id']; ?></td>
<td style="text-align: left"><?php echo $data['title']; ?></td>
<td style="text-align: left"><?php echo ($data['singer_name']) ? $data['singer_name'] : $data['singer_name2']; ?></td>
<td style="text-align: left"><?php echo ($data['composer_name']) ? $data['composer_name'] : $data['composer_name2']; ?></td>
<td style="text-align: center">
<a href="<?php echo base_url().'backend/cmsTrack/editTrack/'.$data['id']; ?>" title="Xem chi tiết">
<i class="ace-icon fa fa-pencil bigger-130"></i>
</a>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="10" 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
<?php if($this->session->flashdata('success')): ?>
<div class="row">
<div class="alert alert-block alert-success" style="margin-bottom: 5px">
<button type="button" class="close" data-dismiss="alert">
<i class="ace-icon fa fa-times"></i>
</button>
<i class="ace-icon fa fa-check green"></i>
<?php echo $this->session->flashdata('success'); ?>
</div>
</div>
<?php endif; ?>
<?php if($this->session->flashdata('error')): ?>
<div class="row">
<div class="alert alert-block alert-danger" style="margin-bottom: 5px">
<button type="button" class="close" data-dismiss="alert">
<i class="ace-icon fa fa-times"></i>
</button>
<i class="ace-icon fa fa-times"></i>
<?php echo $this->session->flashdata('error'); ?>
</div>
</div>
<?php endif; ?>
<div class="row">
<?php echo form_open(base_url().'backend/cmsRanking/listByDailyAjax'); ?>
<div class="col-lg-3">
<input
class="form-control" type="text"
name="input-name"
id="input-name"
placeholder="Nhập tên bài hát..."/>
</div>
<div class="col-lg-1">
<button class="btn btn-sm btn-default" id="delete-filter">Xóa bộ lọc</button>
</div>
<?php echo form_close(); ?>
</div>
<!-- /.row -->
<div class="space-6"></div>
<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/cmsRanking/listByDailyAjax"); ?>';
// Tìm kiếm theo cú pháp
var oldTimeout2 = '';
$('#input-name').keyup(function(){
clearTimeout(oldTimeout2);
oldTimeout2 = setTimeout(function(){
loadDataByAjaxFromInput(url);
}, 250);
});
// Xóa bộ lọc
$('#delete-filter').click(function(){
$("#input-name").val('');
changePagination('0');
return false;
});
changePagination('0');
});
//Ham chung cho cac input
function loadDataByAjaxFromInput(url){
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
}
//Ham chung cho cac SelectBox
function loadDataByAjaxFromSelectBox(id, url){
$('#'+id).change(function(){
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
});
}
function loadDataByAjaxDateRange(dtFrom, dtTo, url){
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
// ajax
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
}
function changePagination(pageId) {
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var url = '<?php echo base_url()."backend/cmsRanking/listByDailyAjax"; ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do\
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName,
pageId: pageId
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
}
</script>
\ No newline at end of file
<?php if($this->session->flashdata('success')): ?>
<div class="row">
<div class="alert alert-block alert-success" style="margin-bottom: 5px">
<button type="button" class="close" data-dismiss="alert">
<i class="ace-icon fa fa-times"></i>
</button>
<i class="ace-icon fa fa-check green"></i>
<?php echo $this->session->flashdata('success'); ?>
</div>
</div>
<?php endif; ?>
<?php if($this->session->flashdata('error')): ?>
<div class="row">
<div class="alert alert-block alert-danger" style="margin-bottom: 5px">
<button type="button" class="close" data-dismiss="alert">
<i class="ace-icon fa fa-times"></i>
</button>
<i class="ace-icon fa fa-times"></i>
<?php echo $this->session->flashdata('error'); ?>
</div>
</div>
<?php endif; ?>
<div class="row">
<?php echo form_open(base_url().'backend/cmsRanking/listByMonthlyAjax'); ?>
<div class="col-lg-3">
<input
class="form-control" type="text"
name="input-name"
id="input-name"
placeholder="Nhập tên bài hát..."/>
</div>
<div class="col-lg-1">
<button class="btn btn-sm btn-default" id="delete-filter">Xóa bộ lọc</button>
</div>
<?php echo form_close(); ?>
</div>
<!-- /.row -->
<div class="space-6"></div>
<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/cmsRanking/listByMonthlyAjax"); ?>';
// Tìm kiếm theo cú pháp
var oldTimeout2 = '';
$('#input-name').keyup(function(){
clearTimeout(oldTimeout2);
oldTimeout2 = setTimeout(function(){
loadDataByAjaxFromInput(url);
}, 250);
});
// Xóa bộ lọc
$('#delete-filter').click(function(){
$("#input-name").val('');
changePagination('0');
return false;
});
changePagination('0');
});
//Ham chung cho cac input
function loadDataByAjaxFromInput(url){
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
}
//Ham chung cho cac SelectBox
function loadDataByAjaxFromSelectBox(id, url){
$('#'+id).change(function(){
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
});
}
function loadDataByAjaxDateRange(dtFrom, dtTo, url){
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
// ajax
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
}
function changePagination(pageId) {
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var url = '<?php echo base_url()."backend/cmsRanking/listByMonthlyAjax"; ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do\
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName,
pageId: pageId
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
}
</script>
\ No newline at end of file
<?php if($this->session->flashdata('success')): ?>
<div class="row">
<div class="alert alert-block alert-success" style="margin-bottom: 5px">
<button type="button" class="close" data-dismiss="alert">
<i class="ace-icon fa fa-times"></i>
</button>
<i class="ace-icon fa fa-check green"></i>
<?php echo $this->session->flashdata('success'); ?>
</div>
</div>
<?php endif; ?>
<?php if($this->session->flashdata('error')): ?>
<div class="row">
<div class="alert alert-block alert-danger" style="margin-bottom: 5px">
<button type="button" class="close" data-dismiss="alert">
<i class="ace-icon fa fa-times"></i>
</button>
<i class="ace-icon fa fa-times"></i>
<?php echo $this->session->flashdata('error'); ?>
</div>
</div>
<?php endif; ?>
<div class="row">
<?php echo form_open(base_url().'backend/cmsRanking/listByWeeklyAjax'); ?>
<div class="col-lg-3">
<input
class="form-control" type="text"
name="input-name"
id="input-name"
placeholder="Nhập tên bài hát..."/>
</div>
<div class="col-lg-1">
<button class="btn btn-sm btn-default" id="delete-filter">Xóa bộ lọc</button>
</div>
<?php echo form_close(); ?>
</div>
<!-- /.row -->
<div class="space-6"></div>
<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/cmsRanking/listByWeeklyAjax"); ?>';
// Tìm kiếm theo cú pháp
var oldTimeout2 = '';
$('#input-name').keyup(function(){
clearTimeout(oldTimeout2);
oldTimeout2 = setTimeout(function(){
loadDataByAjaxFromInput(url);
}, 250);
});
// Xóa bộ lọc
$('#delete-filter').click(function(){
$("#input-name").val('');
changePagination('0');
return false;
});
changePagination('0');
});
//Ham chung cho cac input
function loadDataByAjaxFromInput(url){
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
}
//Ham chung cho cac SelectBox
function loadDataByAjaxFromSelectBox(id, url){
$('#'+id).change(function(){
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
});
}
function loadDataByAjaxDateRange(dtFrom, dtTo, url){
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
// ajax
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
}
function changePagination(pageId) {
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var url = '<?php echo base_url()."backend/cmsRanking/listByWeeklyAjax"; ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do\
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName,
pageId: pageId
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
}
</script>
\ No newline at end of file
......@@ -22,7 +22,7 @@
<?php endif; ?>
<div class="row">
<?php echo form_open(base_url().'backend/cmsTrack/listContestAjax'); ?>
<?php echo form_open(base_url().'backend/cmsTrack/listTrackAjax'); ?>
<div class="col-lg-3">
<input
class="form-control" type="text"
......
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