Commit 68223263 by Phạm Văn Đoan

cập nhật lưu tên bài hát khi chọn blacklist

parent 4efddab5
...@@ -554,10 +554,11 @@ class CmsTrack extends CI_Controller ...@@ -554,10 +554,11 @@ class CmsTrack extends CI_Controller
public function updateBlacklistByAjax() public function updateBlacklistByAjax()
{ {
$track_id = $this->input->post('track_id'); $track_id = $this->input->post('track_id');
$title = $this->input->post('title');
$src = $this->input->post('src'); $src = $this->input->post('src');
$selected = $this->input->post('selected'); $selected = $this->input->post('selected');
// //
$result = $this->crawler_listen_blacklist_model->checkAndUpdate($track_id, $src, $selected); $result = $this->crawler_listen_blacklist_model->checkAndUpdate($track_id, $title, $src, $selected);
// //
if ($result) { if ($result) {
echo json_encode([ echo json_encode([
......
...@@ -47,7 +47,7 @@ class Crawler_listen_blacklist_model extends CI_Model ...@@ -47,7 +47,7 @@ class Crawler_listen_blacklist_model extends CI_Model
return $data; return $data;
} }
public function checkAndUpdate($track_id, $src, $selected) public function checkAndUpdate($track_id, $title, $src, $selected)
{ {
$this->db->select($this->_table . '.*'); $this->db->select($this->_table . '.*');
$this->db->from($this->_table); $this->db->from($this->_table);
...@@ -66,7 +66,7 @@ class Crawler_listen_blacklist_model extends CI_Model ...@@ -66,7 +66,7 @@ class Crawler_listen_blacklist_model extends CI_Model
$this->db->insert($this->_table, [ $this->db->insert($this->_table, [
'track_id' => $track_id, 'track_id' => $track_id,
'src' => strtolower($src), 'src' => strtolower($src),
'title' => null, 'title' => $title,
'created_at' => date('Y-m-d H:i:s'), 'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s') 'updated_at' => date('Y-m-d H:i:s')
]); ]);
......
...@@ -97,17 +97,17 @@ ...@@ -97,17 +97,17 @@
<div class="profile-info-value"> <div class="profile-info-value">
<label> <label>
<input type="checkbox" value="zing" id="chk_zing" <input type="checkbox" value="zing" id="chk_zing"
onclick="updateBlacklistByAjax(<?php echo $track[0]['id'] ?>, 'zing')" onclick="updateBlacklistByAjax(<?php echo $track[0]['id'] ?>, '<?php echo str_replace(["'", '"'], [","], $track[0]['title']); ?>', 'zing')"
<?php echo (in_array('zing', $blacklist) ? 'checked' : '') ?>>&nbsp;Zing <?php echo (in_array('zing', $blacklist) ? 'checked' : '') ?>>&nbsp;Zing
</label><br> </label><br>
<label> <label>
<input type="checkbox" value="nct" id="chk_nct" <input type="checkbox" value="nct" id="chk_nct"
onclick="updateBlacklistByAjax(<?php echo $track[0]['id'] ?>, 'nct')" onclick="updateBlacklistByAjax(<?php echo $track[0]['id'] ?>, '<?php echo str_replace(["'", '"'], [","], $track[0]['title']); ?>', 'nct')"
<?php echo (in_array('nct', $blacklist) ? 'checked' : '') ?>>&nbsp;NCT <?php echo (in_array('nct', $blacklist) ? 'checked' : '') ?>>&nbsp;NCT
</label><br> </label><br>
<label> <label>
<input type="checkbox" value="keeng" id="chk_keeng" <input type="checkbox" value="keeng" id="chk_keeng"
onclick="updateBlacklistByAjax(<?php echo $track[0]['id'] ?>, 'keeng')" onclick="updateBlacklistByAjax(<?php echo $track[0]['id'] ?>, '<?php echo str_replace(["'", '"'], [","], $track[0]['title']); ?>', 'keeng')"
<?php echo (in_array('keeng', $blacklist) ? 'checked' : '') ?>>&nbsp;Keeng <?php echo (in_array('keeng', $blacklist) ? 'checked' : '') ?>>&nbsp;Keeng
</label> </label>
</div> </div>
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
<p>Không tìm thấy thông tin Bài hát!</p> <p>Không tìm thấy thông tin Bài hát!</p>
<?php endif; ?> <?php endif; ?>
<script> <script>
function updateBlacklistByAjax(track_id, src) { function updateBlacklistByAjax(track_id, title, src) {
var selected = 0; var selected = 0;
if ($('#chk_' + src).is(":checked")) { if ($('#chk_' + src).is(":checked")) {
...@@ -138,15 +138,16 @@ ...@@ -138,15 +138,16 @@
selected = 0; selected = 0;
} }
callAjax(track_id, src, selected); callAjax(track_id, title, src, selected);
} }
function callAjax(track_id, src, selected) { function callAjax(track_id, title, src, selected) {
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>'; var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var url = '<?php echo base_url("backend/cmsTrack/updateBlacklistByAjax"); ?>'; var url = '<?php echo base_url("backend/cmsTrack/updateBlacklistByAjax"); ?>';
var dataReq = { var dataReq = {
csrf_name: csrf_value, csrf_name: csrf_value,
track_id: track_id, track_id: track_id,
title: title,
src: src, src: src,
selected: selected selected: selected
}; };
......
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