Commit 6e733a19 by Phạm Văn Đoan

tạo chức năng xem BXH ngày

parent 195f9c73
......@@ -26,9 +26,9 @@ class CmsRanking extends CI_Controller
public function listByDaily()
{
$this->_data['functionName'] = 'BXH theo ngày';
$this->_data['functionName'] = 'BXH Theo ngày';
$this->_data['action'] = 'listByDaily';
$this->_data['titlePage'] = 'BXH theo ngày';
$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);
}
......@@ -37,6 +37,7 @@ class CmsRanking extends CI_Controller
{
$data = array();
$fByName = $this->input->post('fByName');
$fByName = str_replace('/', '-', $fByName);
$pageId = $this->input->post('pageId');
//
$pageId = ($pageId == 0) ? 1 : $pageId;
......
......@@ -13,6 +13,9 @@ class Report_views_daily_model extends CI_Model
{
$this->db->select('COUNT(*) AS totalResults');
$this->db->from($this->_table);
if ($name != null) {
$this->db->where('date', date('Y-m-d', strtotime($name)));
}
$query = $this->db->get();
$result = $query->result_array();
if ($result) {
......@@ -22,21 +25,22 @@ class Report_views_daily_model extends CI_Model
}
}
/**
* Hàm lấy dữ liệu phân trang
*
* @param $record
* @param $start
* @param null $name
*
* @return mixed
*/
public function cmsGetPagination($record, $start, $name = null)
{
print_r($name);
$this->db->select($this->_table . '.*, u1.full_name AS singer_name, track_user.name AS singer_name2,
tracks.title AS name_song, GROUP_CONCAT(track_user.`name` SEPARATOR ",") AS all_name, tracks.art AS art');
$this->db->select($this->_table . '.*, tracks.title AS name_song, tracks.art AS art');
$this->db->from($this->_table);
$this->db->join('track_user', 'track_user.track_id = report_views_daily.track_id', 'left');
$this->db->join('tracks', 'tracks.id = report_views_daily.track_id', 'left');
$this->db->join('users u1', 'u1.id = track_user.user_id', 'left');
if ($name != null) {
$data = explode('-', $name);
$this->db->where('day', $data[0]);
$this->db->where('month', $data[1]);
$this->db->where('year', $data[2]);
$this->db->where('date', date('Y-m-d', strtotime($name)));
}
$this->db->group_by('report_views_daily.id');
$this->db->order_by($this->_table . '.total_point', 'desc');
......@@ -46,17 +50,4 @@ class Report_views_daily_model extends CI_Model
return $query->result_array();
}
public function selectSearch() {
$this->db->select('day,month, year');
$this->db->from($this->_table);
$this->db->distinct($this->_table . '.day');
$this->db->order_by( $this->_table . '.year desc');
$this->db->order_by( $this->_table . '.month desc');
$this->db->order_by( $this->_table . '.day desc');
$this->db->limit(15);
$query = $this->db->get();
return $query->result_array();
}
}
\ No newline at end of file
......@@ -352,15 +352,11 @@ $action = $CI->router->fetch_method();
<script src="<?php echo base_url().'public/assets/js/ace.min.js' ?>"></script>
<script type="text/javascript">
$(document).ready(function(){
$('input[name=input-date-range-revenue-daily]').daterangepicker({
'applyClass' : 'btn-sm btn-success',
'cancelClass' : 'btn-sm btn-default',
locale: {
applyLabel: 'Chọn',
cancelLabel: 'Hủy'
},
format: 'DD/MM/YYYY',
maxDate: '<?php echo date('d/m/Y')?>'
$('.date-picker').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
endDate: '<?php echo date('d/m/Y', time()-86400)?>'
});
$('input[name=date-range-picker]').daterangepicker({
......@@ -373,9 +369,7 @@ $action = $CI->router->fetch_method();
format: 'DD/MM/YYYY',
maxDate: '<?php echo date('d/m/Y')?>'
});
});
</script>
</body>
......
......@@ -7,14 +7,14 @@
<th style="text-align: center">Ảnh</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">Tổng điểm</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: center">#<?php echo $data['track_id']; ?></td>
<td style="text-align: center"><img src="<?php echo base_url($data['art']); ?>"></td>
<td style="text-align: left"><?php echo $data['name_song']; ?></td>
<td style="text-align: left"><?php echo $data['all_name']; ?></td>
......
......@@ -24,21 +24,13 @@
<div class="row">
<?php echo form_open(base_url().'backend/cmsRanking/listByDailyAjax'); ?>
<div class="col-lg-3">
<select class="form-control" name="input-name" id="input-name">
<?php
$listSearch= $this->report_views_daily_model->selectSearch();
if ($listSearch == array()) {
?>
<option value = "">None</option>
<?php
} else
foreach ($listSearch as $data):
?>
<option value = "<?php echo $data['day'].'-'.$data['month'].'-'.$data['year']; ?>">Ngày<?php echo $data['day']; ?>/ <?php echo $data['month']; ?>/ <?php echo $data['year']; ?></option>
<?php
endforeach;
?>
</select>
<div class="input-group text-center">
<input class="form-control date-picker" id="input-date-picker" type="text" data-date-format="dd/mm/yyyy"
value="<?php echo date('d/m/Y', time()-86400)?>" readonly>
<span class="input-group-addon">
<i class="fa fa-calendar bigger-110"></i>
</span>
</div>
</div>
<div class="col-lg-1">
<button class="btn btn-sm btn-default" id="delete-filter">Xóa bộ lọc</button>
......@@ -63,7 +55,7 @@
// Tìm kiếm theo cú pháp
var oldTimeout2 = '';
$('#input-name').change(function(){
$('#input-date-picker').change(function(){
clearTimeout(oldTimeout2);
oldTimeout2 = setTimeout(function(){
loadDataByAjaxFromInput(url);
......@@ -71,7 +63,7 @@
});
// Xóa bộ lọc
$('#delete-filter').click(function(){
$("#input-name").val('');
$("#input-date-picker").val('<?php echo date('d/m/Y', time()-86400)?>');
changePagination('0');
return false;
......@@ -82,86 +74,43 @@
//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();
}
});
callAjax(0, url);
}
//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();
}
});
callAjax(0, url);
});
}
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();
}
});
callAjax(0, url);
}
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: {
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){
success: function(data) {
$('#div-response').html(data);
$('#data-loading').hide();
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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