Commit cbb93d1a by Phạm Văn Đoan

cập nhật lọc ca sĩ và nhạc sĩ

parent d4b1a742
......@@ -41,9 +41,9 @@ class CmsTrack extends CI_Controller
$limit = 100;
$offset = ($pageId - 1) * $limit;
$data['offset'] = ($pageId - 1) * $limit;
$totalRecord = $this->track_model->cmsCountAll($fByName);
$totalRecord = $this->track_model->cmsCountAll($fByName, $fBySinger, $fByComposer);
$data['pagination'] = MyHelper::genPaginationLink($totalRecord, $limit, $pageId);
$data['listData'] = $this->track_model->cmsGetPagination($limit, $offset, $fByName);
$data['listData'] = $this->track_model->cmsGetPagination($limit, $offset, $fByName, $fBySinger, $fByComposer);
//
$this->load->view('backend/ajax/cms_track/list_track_view', $data);
}
......
......@@ -128,7 +128,7 @@ class Track_model extends CI_Model
return $query->result_array();
}
public function cmsCountAll($name = null)
public function cmsCountAll($name = null, $fBySinger = null, $fByComposer = null)
{
$this->db->select('COUNT(*) AS totalResults');
$this->db->from($this->_table);
......@@ -138,6 +138,16 @@ class Track_model extends CI_Model
$this->db->or_like('slug', $name, 'both');
$this->db->or_like('tag', $name, 'both');
}
if ($fBySinger == 1) {
$this->db->where('singer_list is NOT NULL', null, false);
} else if ($fBySinger == 2) {
$this->db->where('singer_list', null);
}
if ($fByComposer == 1) {
$this->db->where('composer_list is NOT NULL', null, false);
} else if ($fByComposer == 2) {
$this->db->where('composer_list', null);
}
$query = $this->db->get();
$result = $query->result_array();
if ($result) {
......@@ -172,7 +182,7 @@ class Track_model extends CI_Model
return $query->result_array();
}
public function cmsGetPagination($record, $start, $name = null)
public function cmsGetPagination($record, $start, $name = null, $fBySinger = null, $fByComposer = null)
{
$this->db->select($this->_table . '.*');
$this->db->from($this->_table);
......@@ -182,6 +192,16 @@ class Track_model extends CI_Model
$this->db->or_like('tracks.slug', $name, 'both');
$this->db->or_like('tracks.tag', $name, 'both');
}
if ($fBySinger == 1) {
$this->db->where('singer_list is NOT NULL', null, false);
} else if ($fBySinger == 2) {
$this->db->where('singer_list', null);
}
if ($fByComposer == 1) {
$this->db->where('composer_list is NOT NULL', null, false);
} else if ($fByComposer == 2) {
$this->db->where('composer_list', null);
}
$this->db->order_by($this->_table . '.title', 'asc');
$this->db->limit($record, $start);
$query = $this->db->get();
......
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