Commit a418033c by Phạm Văn Đoan

thêm lọc theo nguồn ở quản lý bài hát

parent 641878e6
...@@ -32,6 +32,7 @@ class CmsTrack extends CI_Controller ...@@ -32,6 +32,7 @@ class CmsTrack extends CI_Controller
{ {
$data = array(); $data = array();
$fByName = $this->input->post('fByName'); $fByName = $this->input->post('fByName');
$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');
$pageId = $this->input->post('pageId'); $pageId = $this->input->post('pageId');
...@@ -41,9 +42,9 @@ class CmsTrack extends CI_Controller ...@@ -41,9 +42,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); $totalRecord = $this->track_model->cmsCountAll($fByName, $fBySinger, $fByComposer, $fBySource);
$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); $data['listData'] = $this->track_model->cmsGetPagination($limit, $offset, $fByName, $fBySinger, $fByComposer, $fBySource);
// //
$this->load->view('backend/ajax/cms_track/list_track_view', $data); $this->load->view('backend/ajax/cms_track/list_track_view', $data);
} }
......
...@@ -130,7 +130,7 @@ class Track_model extends CI_Model ...@@ -130,7 +130,7 @@ class Track_model extends CI_Model
return $query->result_array(); return $query->result_array();
} }
public function cmsCountAll($name = null, $fBySinger = null, $fByComposer = null) public function cmsCountAll($name = null, $fBySinger = null, $fByComposer = null, $fBySource = null)
{ {
$this->db->select('COUNT(*) AS totalResults'); $this->db->select('COUNT(*) AS totalResults');
$this->db->from($this->_table); $this->db->from($this->_table);
...@@ -142,6 +142,22 @@ class Track_model extends CI_Model ...@@ -142,6 +142,22 @@ class Track_model extends CI_Model
$this->db->or_like('tag', $name, 'both'); $this->db->or_like('tag', $name, 'both');
$this->db->or_where('id', intval($name)); $this->db->or_where('id', intval($name));
} }
if (!empty($fBySource)) {
switch ($fBySource) {
case 'ZING':
$this->db->where('id_zing is NOT NULL', null, false);
$this->db->where('id_zing !=', '');
break;
case 'NCT':
$this->db->where('id_nct is NOT NULL', null, false);
$this->db->where('id_nct !=', '');
break;
case 'KEENG':
$this->db->where('id_keeng is NOT NULL', null, false);
$this->db->where('id_keeng !=', '');
break;
}
}
if ($fBySinger == 1) { if ($fBySinger == 1) {
$this->db->where('singer_list is NOT NULL', null, false); $this->db->where('singer_list is NOT NULL', null, false);
} else if ($fBySinger == 2) { } else if ($fBySinger == 2) {
...@@ -186,7 +202,7 @@ class Track_model extends CI_Model ...@@ -186,7 +202,7 @@ class Track_model extends CI_Model
return $query->result_array(); return $query->result_array();
} }
public function cmsGetPagination($record, $start, $name = null, $fBySinger = null, $fByComposer = null) 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);
...@@ -198,6 +214,22 @@ class Track_model extends CI_Model ...@@ -198,6 +214,22 @@ class Track_model extends CI_Model
$this->db->or_like('tracks.tag', $name, 'both'); $this->db->or_like('tracks.tag', $name, 'both');
$this->db->or_where('id', intval($name)); $this->db->or_where('id', intval($name));
} }
if (!empty($fBySource)) {
switch ($fBySource) {
case 'ZING':
$this->db->where('id_zing is NOT NULL', null, false);
$this->db->where('id_zing !=', '');
break;
case 'NCT':
$this->db->where('id_nct is NOT NULL', null, false);
$this->db->where('id_nct !=', '');
break;
case 'KEENG':
$this->db->where('id_keeng is NOT NULL', null, false);
$this->db->where('id_keeng !=', '');
break;
}
}
if ($fBySinger == 1) { if ($fBySinger == 1) {
$this->db->where('singer_list is NOT NULL', null, false); $this->db->where('singer_list is NOT NULL', null, false);
} else if ($fBySinger == 2) { } else if ($fBySinger == 2) {
......
...@@ -22,13 +22,21 @@ ...@@ -22,13 +22,21 @@
<?php endif; ?> <?php endif; ?>
<div class="row"> <div class="row">
<?php //echo form_open(base_url().'backend/cmsTrack/listTrackAjax'); ?>
<!-- Tìm kiếm theo tên bài hát --> <!-- Tìm kiếm theo tên bài hát -->
<div class="col-lg-3"> <div class="col-lg-3">
<input class="form-control" type="text" name="input-name" id="input-name" placeholder="Nhập #ID, tên bài hát..." /> <input class="form-control" type="text" name="input-name" id="input-name" placeholder="Nhập #ID, tên bài hát..." />
</div> </div>
<!-- Lọc theo nguồn cung cấp nhạc -->
<div class="col-lg-2">
<select class="form-control" name="fBySource" id="fBySource">
<option value="">Tất cả nguồn</option>
<option value="ZING">Nguồn Zing</option>
<option value="NCT">Nguồn NCT</option>
<option value="KEENG">Nguồn Keeng</option>
</select>
</div>
<!-- Lọc theo thông tin ca sĩ --> <!-- Lọc theo thông tin ca sĩ -->
<div class="col-lg-3"> <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>
...@@ -36,18 +44,18 @@ ...@@ -36,18 +44,18 @@
</select> </select>
</div> </div>
<!-- Lọc theo thông tin nhạc sĩ --> <!-- Lọc theo thông tin nhạc sĩ -->
<div class="col-lg-3"> <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-3"></div> <!-- 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>
</div> </div>
<?php //echo form_close(); ?> <!-- Thêm mới bài hát -->
<div class="col-lg-1" style="float:right;"> <div class="col-lg-1" style="float:right;">
<a class="btn btn-sm btn-success" href="<?php echo base_url('backend/cmsTrack/addTrack');?>"> <a class="btn btn-sm btn-success" href="<?php echo base_url('backend/cmsTrack/addTrack');?>">
<i class="glyphicon-plus"></i> Thêm</a> <i class="glyphicon-plus"></i> Thêm</a>
...@@ -65,7 +73,6 @@ ...@@ -65,7 +73,6 @@
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
//Thuc hien viec ve bieu do$data
$(document).ready(function() { $(document).ready(function() {
var url = '<?php echo base_url("backend/cmsTrack/listTrackAjax"); ?>'; var url = '<?php echo base_url("backend/cmsTrack/listTrackAjax"); ?>';
...@@ -78,6 +85,7 @@ $(document).ready(function() { ...@@ -78,6 +85,7 @@ $(document).ready(function() {
}, 250); }, 250);
}); });
loadDataByAjaxFromSelectBox('fBySource', url);
loadDataByAjaxFromSelectBox('fBySinger', url); loadDataByAjaxFromSelectBox('fBySinger', url);
loadDataByAjaxFromSelectBox('fByComposer', url); loadDataByAjaxFromSelectBox('fByComposer', url);
...@@ -123,11 +131,13 @@ function changePagination(pageId) { ...@@ -123,11 +131,13 @@ function changePagination(pageId) {
function callAjax(pageId, url) { function callAjax(pageId, url) {
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>'; var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val(); var fByName = $("#input-name").val();
var fBySource = $("#fBySource").val();
var fBySinger = $("#fBySinger").val(); var fBySinger = $("#fBySinger").val();
var fByComposer = $("#fByComposer").val(); var fByComposer = $("#fByComposer").val();
var dataReq = { var dataReq = {
csrf_name: csrf_value, csrf_name: csrf_value,
fByName: fByName, fByName: fByName,
fBySource: fBySource,
fBySinger: fBySinger, fBySinger: fBySinger,
fByComposer: fByComposer, fByComposer: fByComposer,
pageId: pageId pageId: pageId
......
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