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 ...@@ -26,9 +26,9 @@ class CmsRanking extends CI_Controller
public function listByDaily() public function listByDaily()
{ {
$this->_data['functionName'] = 'BXH theo ngày'; $this->_data['functionName'] = 'BXH Theo ngày';
$this->_data['action'] = 'listByDaily'; $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->_data['loadPage'] = 'backend/cms_ranking/list_by_daily_view';
$this->load->view('backend/admin_template_view', $this->_data); $this->load->view('backend/admin_template_view', $this->_data);
} }
...@@ -37,6 +37,7 @@ class CmsRanking extends CI_Controller ...@@ -37,6 +37,7 @@ class CmsRanking extends CI_Controller
{ {
$data = array(); $data = array();
$fByName = $this->input->post('fByName'); $fByName = $this->input->post('fByName');
$fByName = str_replace('/', '-', $fByName);
$pageId = $this->input->post('pageId'); $pageId = $this->input->post('pageId');
// //
$pageId = ($pageId == 0) ? 1 : $pageId; $pageId = ($pageId == 0) ? 1 : $pageId;
......
...@@ -13,6 +13,9 @@ class Report_views_daily_model extends CI_Model ...@@ -13,6 +13,9 @@ class Report_views_daily_model extends CI_Model
{ {
$this->db->select('COUNT(*) AS totalResults'); $this->db->select('COUNT(*) AS totalResults');
$this->db->from($this->_table); $this->db->from($this->_table);
if ($name != null) {
$this->db->where('date', date('Y-m-d', strtotime($name)));
}
$query = $this->db->get(); $query = $this->db->get();
$result = $query->result_array(); $result = $query->result_array();
if ($result) { if ($result) {
...@@ -22,21 +25,22 @@ class Report_views_daily_model extends CI_Model ...@@ -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) public function cmsGetPagination($record, $start, $name = null)
{ {
print_r($name); $this->db->select($this->_table . '.*, tracks.title AS name_song, tracks.art AS art');
$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->from($this->_table); $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('tracks', 'tracks.id = report_views_daily.track_id', 'left');
$this->db->join('users u1', 'u1.id = track_user.user_id', 'left');
if ($name != null) { if ($name != null) {
$data = explode('-', $name); $this->db->where('date', date('Y-m-d', strtotime($name)));
$this->db->where('day', $data[0]);
$this->db->where('month', $data[1]);
$this->db->where('year', $data[2]);
} }
$this->db->group_by('report_views_daily.id'); $this->db->group_by('report_views_daily.id');
$this->db->order_by($this->_table . '.total_point', 'desc'); $this->db->order_by($this->_table . '.total_point', 'desc');
...@@ -46,17 +50,4 @@ class Report_views_daily_model extends CI_Model ...@@ -46,17 +50,4 @@ class Report_views_daily_model extends CI_Model
return $query->result_array(); 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(); ...@@ -352,15 +352,11 @@ $action = $CI->router->fetch_method();
<script src="<?php echo base_url().'public/assets/js/ace.min.js' ?>"></script> <script src="<?php echo base_url().'public/assets/js/ace.min.js' ?>"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
$('input[name=input-date-range-revenue-daily]').daterangepicker({ $('.date-picker').datepicker({
'applyClass' : 'btn-sm btn-success', autoclose: true,
'cancelClass' : 'btn-sm btn-default', todayHighlight: true,
locale: { format: 'dd/mm/yyyy',
applyLabel: 'Chọn', endDate: '<?php echo date('d/m/Y', time()-86400)?>'
cancelLabel: 'Hủy'
},
format: 'DD/MM/YYYY',
maxDate: '<?php echo date('d/m/Y')?>'
}); });
$('input[name=date-range-picker]').daterangepicker({ $('input[name=date-range-picker]').daterangepicker({
...@@ -373,9 +369,7 @@ $action = $CI->router->fetch_method(); ...@@ -373,9 +369,7 @@ $action = $CI->router->fetch_method();
format: 'DD/MM/YYYY', format: 'DD/MM/YYYY',
maxDate: '<?php echo date('d/m/Y')?>' maxDate: '<?php echo date('d/m/Y')?>'
}); });
}); });
</script> </script>
</body> </body>
......
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
<th style="text-align: center">Ảnh</th> <th style="text-align: center">Ảnh</th>
<th style="text-align: center">Tên bài hát</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">Ca sĩ</th>
<th style="text-align: center">Nhạc sĩ</th> <th style="text-align: center">Tổng điểm</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php if(count($listData) > 0): foreach($listData as $key => $data): ?> <?php if(count($listData) > 0): foreach($listData as $key => $data): ?>
<tr> <tr>
<td style="text-align: center"><?php echo ($key+1+$offset); ?></td> <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: 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['name_song']; ?></td>
<td style="text-align: left"><?php echo $data['all_name']; ?></td> <td style="text-align: left"><?php echo $data['all_name']; ?></td>
......
...@@ -24,21 +24,13 @@ ...@@ -24,21 +24,13 @@
<div class="row"> <div class="row">
<?php echo form_open(base_url().'backend/cmsRanking/listByDailyAjax'); ?> <?php echo form_open(base_url().'backend/cmsRanking/listByDailyAjax'); ?>
<div class="col-lg-3"> <div class="col-lg-3">
<select class="form-control" name="input-name" id="input-name"> <div class="input-group text-center">
<?php <input class="form-control date-picker" id="input-date-picker" type="text" data-date-format="dd/mm/yyyy"
$listSearch= $this->report_views_daily_model->selectSearch(); value="<?php echo date('d/m/Y', time()-86400)?>" readonly>
if ($listSearch == array()) { <span class="input-group-addon">
?> <i class="fa fa-calendar bigger-110"></i>
<option value = "">None</option> </span>
<?php </div>
} 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> </div>
<div class="col-lg-1"> <div class="col-lg-1">
<button class="btn btn-sm btn-default" id="delete-filter">Xóa bộ lọc</button> <button class="btn btn-sm btn-default" id="delete-filter">Xóa bộ lọc</button>
...@@ -63,7 +55,7 @@ ...@@ -63,7 +55,7 @@
// Tìm kiếm theo cú pháp // Tìm kiếm theo cú pháp
var oldTimeout2 = ''; var oldTimeout2 = '';
$('#input-name').change(function(){ $('#input-date-picker').change(function(){
clearTimeout(oldTimeout2); clearTimeout(oldTimeout2);
oldTimeout2 = setTimeout(function(){ oldTimeout2 = setTimeout(function(){
loadDataByAjaxFromInput(url); loadDataByAjaxFromInput(url);
...@@ -71,7 +63,7 @@ ...@@ -71,7 +63,7 @@
}); });
// Xóa bộ lọc // Xóa bộ lọc
$('#delete-filter').click(function(){ $('#delete-filter').click(function(){
$("#input-name").val(''); $("#input-date-picker").val('<?php echo date('d/m/Y', time()-86400)?>');
changePagination('0'); changePagination('0');
return false; return false;
...@@ -82,86 +74,43 @@ ...@@ -82,86 +74,43 @@
//Ham chung cho cac input //Ham chung cho cac input
function loadDataByAjaxFromInput(url){ function loadDataByAjaxFromInput(url){
$('#data-loading').show(); $('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>'; callAjax(0, url);
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 //Ham chung cho cac SelectBox
function loadDataByAjaxFromSelectBox(id, url){ function loadDataByAjaxFromSelectBox(id, url){
$('#'+id).change(function(){ $('#'+id).change(function(){
$('#data-loading').show(); $('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>'; callAjax(0, url);
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){ function loadDataByAjaxDateRange(dtFrom, dtTo, url){
$('#data-loading').show(); $('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>'; callAjax(0, url);
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) { function changePagination(pageId) {
$('#data-loading').show(); $('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var url = '<?php echo base_url()."backend/cmsRanking/listByDailyAjax"; ?>'; var url = '<?php echo base_url()."backend/cmsRanking/listByDailyAjax"; ?>';
var fByName = $("#input-name").val(); callAjax(pageId, url);
//Ajax ve bieu do\ }
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({ $.ajax({
type: "POST", type: "POST",
url: url, url: url,
data: { data: dataReq,
csrf_name: csrf_value,
fByName: fByName,
pageId: pageId
},
dataType: "text", dataType: "text",
cache: false, cache: false,
success: function(data){ success: function(data) {
$('#div-response').html(data); $('#div-response').html(data);
$('#data-loading').hide(); $('#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