Commit 3f52cb10 by Phạm Văn Đoan

cập nhật lọc theo những ài đã chặn lấy lượt nghe

parent c59c76ea
...@@ -42,6 +42,7 @@ class CmsTrack extends CI_Controller ...@@ -42,6 +42,7 @@ class CmsTrack extends CI_Controller
$fBySource = $this->input->post('fBySource'); $fBySource = $this->input->post('fBySource');
$fBySinger = $this->input->post('fBySinger'); $fBySinger = $this->input->post('fBySinger');
$fByComposer = $this->input->post('fByComposer'); $fByComposer = $this->input->post('fByComposer');
$fByBlacklist = $this->input->post('fByBlacklist');
$pageId = $this->input->post('pageId'); $pageId = $this->input->post('pageId');
// //
$pageId = ($pageId == 0) ? 1 : $pageId; $pageId = ($pageId == 0) ? 1 : $pageId;
...@@ -49,9 +50,9 @@ class CmsTrack extends CI_Controller ...@@ -49,9 +50,9 @@ class CmsTrack extends CI_Controller
$limit = 100; $limit = 100;
$offset = ($pageId - 1) * $limit; $offset = ($pageId - 1) * $limit;
$data['offset'] = ($pageId - 1) * $limit; $data['offset'] = ($pageId - 1) * $limit;
$totalRecord = $this->track_model->cmsCountAll($fByName, $fBySinger, $fByComposer, $fBySource); $totalRecord = $this->track_model->cmsCountAll($fByName, $fBySinger, $fByComposer, $fBySource, $fByBlacklist);
$data['pagination'] = MyHelper::genPaginationLink($totalRecord, $limit, $pageId); $data['pagination'] = MyHelper::genPaginationLink($totalRecord, $limit, $pageId);
$data['listData'] = $this->track_model->cmsGetPagination($limit, $offset, $fByName, $fBySinger, $fByComposer, $fBySource); $data['listData'] = $this->track_model->cmsGetPagination($limit, $offset, $fByName, $fBySinger, $fByComposer, $fBySource, $fByBlacklist);
// //
$this->load->view('backend/ajax/cms_track/list_track_view', $data); $this->load->view('backend/ajax/cms_track/list_track_view', $data);
} }
......
...@@ -227,7 +227,7 @@ class Track_model extends CI_Model ...@@ -227,7 +227,7 @@ class Track_model extends CI_Model
return $query->result_array(); return $query->result_array();
} }
public function cmsCountAll($name = null, $fBySinger = null, $fByComposer = null, $fBySource = null) public function cmsCountAll($name = null, $fBySinger = null, $fByComposer = null, $fBySource = null, $fByBlacklist = null)
{ {
$this->db->select('COUNT(*) AS totalResults'); $this->db->select('COUNT(*) AS totalResults');
$this->db->from($this->_table); $this->db->from($this->_table);
...@@ -265,6 +265,9 @@ class Track_model extends CI_Model ...@@ -265,6 +265,9 @@ class Track_model extends CI_Model
} else if ($fByComposer == 2) { } else if ($fByComposer == 2) {
$this->db->where('composer_list', null); $this->db->where('composer_list', null);
} }
if ($fByBlacklist == 1) {
$this->db->where('blacklist_listen is NOT NULL', null, false);
}
$query = $this->db->get(); $query = $this->db->get();
$result = $query->result_array(); $result = $query->result_array();
if ($result) { if ($result) {
...@@ -274,32 +277,7 @@ class Track_model extends CI_Model ...@@ -274,32 +277,7 @@ class Track_model extends CI_Model
} }
} }
public function cmsGetPaginationBk($record, $start, $name = null) public function cmsGetPagination($record, $start, $name = null, $fBySinger = null, $fByComposer = null, $fBySource = null, $fByBlacklist = 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_user.id AS id_user,
track_artists.name AS composer_name2, track_artists.id AS id_artist');
$this->db->from($this->_table);
$this->db->join($this->_table_track_user, 'track_user.track_id = tracks.id', 'left');
$this->db->join($this->_table_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');
}
// $where = 'track_user.user_id !=0 AND track_artists.user_id != 0';
// $this->db->where($where);
$this->db->order_by($this->_table . '.title', 'asc');
$this->db->limit($record, $start);
$query = $this->db->get();
return $query->result_array();
}
public function cmsGetPagination($record, $start, $name = null, $fBySinger = null, $fByComposer = null, $fBySource = null)
{ {
$this->db->select($this->_table . '.*'); $this->db->select($this->_table . '.*');
$this->db->from($this->_table); $this->db->from($this->_table);
...@@ -337,10 +315,13 @@ class Track_model extends CI_Model ...@@ -337,10 +315,13 @@ class Track_model extends CI_Model
} else if ($fByComposer == 2) { } else if ($fByComposer == 2) {
$this->db->where('composer_list', null); $this->db->where('composer_list', null);
} }
if ($fByBlacklist == 1) {
$this->db->where('blacklist_listen is NOT NULL', null, false);
}
$this->db->order_by($this->_table . '.id', 'desc'); $this->db->order_by($this->_table . '.id', 'desc');
$this->db->limit($record, $start); $this->db->limit($record, $start);
$query = $this->db->get(); $query = $this->db->get();
error_log($this->db->last_query());
return $query->result_array(); return $query->result_array();
} }
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<!-- Lọc theo nguồn cung cấp nhạc --> <!-- Lọc theo nguồn cung cấp nhạc -->
<div class="col-lg-2"> <div class="col-lg-2">
<select class="form-control" name="fBySource" id="fBySource"> <select class="form-control" name="fBySource" id="fBySource">
<option value="">Tất cả nguồn</option> <option value="">- Tất cả nguồn -</option>
<option value="ZING">Nguồn Zing</option> <option value="ZING">Nguồn Zing</option>
<option value="NCT">Nguồn NCT</option> <option value="NCT">Nguồn NCT</option>
<option value="KEENG">Nguồn Keeng</option> <option value="KEENG">Nguồn Keeng</option>
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<!-- Lọc theo thông tin ca sĩ --> <!-- Lọc theo thông tin ca sĩ -->
<div class="col-lg-2"> <div class="col-lg-2">
<select class="form-control" name="fBySinger" id="fBySinger"> <select class="form-control" name="fBySinger" id="fBySinger">
<option value="-1">Thông tin ca sĩ</option> <option value="-1">- Thông tin ca sĩ -</option>
<option value="1">Đã cập nhật</option> <option value="1">Đã cập nhật</option>
<option value="2">Chưa cập nhật</option> <option value="2">Chưa cập nhật</option>
</select> </select>
...@@ -50,11 +50,17 @@ ...@@ -50,11 +50,17 @@
<!-- Lọc theo thông tin nhạc sĩ --> <!-- Lọc theo thông tin nhạc sĩ -->
<div class="col-lg-2"> <div class="col-lg-2">
<select class="form-control" name="fByComposer" id="fByComposer"> <select class="form-control" name="fByComposer" id="fByComposer">
<option value="-1">Thông tin nhạc sĩ</option> <option value="-1">- Thông tin nhạc sĩ -</option>
<option value="1">Đã cập nhật</option> <option value="1">Đã cập nhật</option>
<option value="2">Chưa cập nhật</option> <option value="2">Chưa cập nhật</option>
</select> </select>
</div> </div>
<div class="col-lg-2">
<select class="form-control" name="fByBlacklist" id="fByBlacklist">
<option value="-1">- Chặn lượt nghe -</option>
<option value="1">Đã chặn</option>
</select>
</div>
<!-- Xóa bộ lọc --> <!-- Xóa bộ lọc -->
<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>
...@@ -92,12 +98,14 @@ $(document).ready(function() { ...@@ -92,12 +98,14 @@ $(document).ready(function() {
loadDataByAjaxFromSelectBox('fBySource', url); loadDataByAjaxFromSelectBox('fBySource', url);
loadDataByAjaxFromSelectBox('fBySinger', url); loadDataByAjaxFromSelectBox('fBySinger', url);
loadDataByAjaxFromSelectBox('fByComposer', url); loadDataByAjaxFromSelectBox('fByComposer', url);
loadDataByAjaxFromSelectBox('fByBlacklist', url);
// Xóa bộ lọc // Xóa bộ lọc
$('#delete-filter').click(function() { $('#delete-filter').click(function() {
$("#input-name").val(''); $("#input-name").val('');
$("#fBySinger").val('-1'); $("#fBySinger").val('-1');
$("#fByComposer").val('-1'); $("#fByComposer").val('-1');
$("#fByBlacklist").val('-1');
changePagination('0'); changePagination('0');
return false; return false;
...@@ -138,12 +146,14 @@ function callAjax(pageId, url) { ...@@ -138,12 +146,14 @@ function callAjax(pageId, url) {
var fBySource = $("#fBySource").val(); var fBySource = $("#fBySource").val();
var fBySinger = $("#fBySinger").val(); var fBySinger = $("#fBySinger").val();
var fByComposer = $("#fByComposer").val(); var fByComposer = $("#fByComposer").val();
var fByBlacklist = $("#fByBlacklist").val();
var dataReq = { var dataReq = {
csrf_name: csrf_value, csrf_name: csrf_value,
fByName: fByName, fByName: fByName,
fBySource: fBySource, fBySource: fBySource,
fBySinger: fBySinger, fBySinger: fBySinger,
fByComposer: fByComposer, fByComposer: fByComposer,
fByBlacklist: fByBlacklist,
pageId: pageId pageId: pageId
}; };
//Ajax //Ajax
......
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