Commit 57bd233d by Trần Văn Minh

update cập nhập thông tin bài hát

parent 59591cd1
......@@ -46,9 +46,11 @@ class CmsTrack extends CI_Controller
$this->load->view('backend/ajax/cms_track/list_track_view', $data);
}
public function editTrack($contest_id)
public function editTrack($contest_id, $id_user, $id_artist)
{
$this->_data['contest'] = $contest = $this->track_model->getById($contest_id);
$this->_data['contest'] = $contest = $this->track_model->getById($contest_id, $id_user, $id_artist);
$this->_data['track_artists'] = $track_artists = $this->track_model->getByIdUser('track_artists', $id_artist);
$this->_data['track_user'] = $track_user = $this->track_model->getByIdUser('track_user', $id_user);
$this->_data['list_user'] = $list_user = $this->track_model->getListUsers();
// Kiểm tra trùng giá trị nếu thay đổi ở form
......@@ -92,10 +94,11 @@ class CmsTrack extends CI_Controller
$update_artist = $this->input->post('update_artist');
$id_singer = ($update_singer > 0) ? $update_singer: $singer;
$id_artist = ($update_artist > 0) ? $update_artist: $artist;
($singer) ? $active_singer = 'update': $active_singer = 'insert';
($artist) ? $active_artist = 'update': $active_artist = 'insert';
$this->track_model->update_track_artists($contest_id, $id_artist, $active_artist);
$this->track_model->update_track_user($contest_id, $id_singer, $active_singer);
($singer || $id_user) ? $active_singer = 'update': $active_singer = 'insert';
($artist || $id_artist) ? $active_artist = 'update': $active_artist = 'insert';
// die($active_artist.$active_singer);
$this->track_model->update_track_artists($contest_id, $id_artist, $id_artist, $active_artist);
$this->track_model->update_track_user($contest_id, $id_singer, $id_user, $active_singer);
$this->track_model->update($contest_id, $title);
// Ghi log
// $this->mactionlog->add('UPDATED', 'Cập nhật Cuộc đua thành công!', 'Mactionlog', 'action_log', $contest_id);
......
......@@ -24,51 +24,62 @@ class Track_model extends CI_Model
$this->db->update($this->_table);
}
public function update_track_artists($id, $dataUpdate, $active)
public function update_track_artists($id_track, $user_id, $id, $active)
{
// die($dataUpdate);
$this->db->select('full_name');
$this->db->where('id', $dataUpdate);
$this->db->where('id', $user_id);
$query = $this->db->get('users')->result_array();
$this->db->set('user_id', $dataUpdate);
$this->db->set('user_id', $user_id);
$this->db->set('name', $query[0]['full_name']);
if ($active == 'insert') {
$this->db->set('track_id', $id);
$this->db->set('track_id', $id_track);
$this->db->insert('track_artists');
} else {
$this->db->where('track_id', $id);
$this->db->where('track_id', $id_track);
$this->db->where('id', $id);
$this->db->update('track_artists');
}
}
public function update_track_user($id_track, $dataUpdate, $active)
public function update_track_user($id_track, $user_id, $id, $active)
{
$this->db->select('full_name');
$this->db->where('id', $dataUpdate);
$this->db->where('id', $user_id);
$query = $this->db->get('users')->result_array();
$this->db->set('user_id', $dataUpdate);
$this->db->set('user_id', $user_id);
$this->db->set('name', $query[0]['full_name']);
if ($active == 'insert') {
$this->db->set('track_id', $id_track);
$this->db->insert('track_user');
} else {
$this->db->where('track_id', $id_track);
$this->db->where('id', $id);
$this->db->update('track_user');
}
}
public function getById($id)
public function getById($id, $track_user, $track_artist)
{
$this->db->select($this->_table . '.*, track_user.name AS name_singer, track_user.user_id AS id_singer,
track_artists.name AS artist, track_artists.user_id AS id_artist, track_artists.clear_name AS clear_artists');
$this->db->select($this->_table . '.*, track_user.name AS name_singer,
track_user.user_id AS id_singer,
track_artists.name AS artist,
track_artists.clear_name AS clear_artists, track_artists.id AS id_track_artist');
$this->db->from($this->_table);
$this->db->join('track_user', 'track_user.track_id = tracks.id', 'left');
$this->db->join('track_artists', 'track_artists.track_id = tracks.id', 'left');
$this->db->where($this->_table . '.id', $id);
// $this->db->where('track_artists.id', $track_artist);
// $this->db->where('track_user.id', $track_user);/
$query = $this->db->get();
return $query->result_array();
}
public function getByIdUser($table, $id) {
$this->db->select("*");
$this->db->where('id', $id);
return $this->db->get($table)->result_array();
}
/**
* Lay cuoc thi hien hanh
* @return mixed
......@@ -105,7 +116,9 @@ class Track_model extends CI_Model
public function cmsGetPagination($record, $start, $name = 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_artists.name AS composer_name2');
$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('track_user', 'track_user.track_id = tracks.id', 'left');
$this->db->join('track_artists', 'track_artists.track_id = tracks.id', 'left');
......@@ -117,6 +130,8 @@ class Track_model extends CI_Model
$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();
......
......@@ -19,7 +19,7 @@
<td style="text-align: left"><?php echo ($data['singer_name']) ? $data['singer_name'] : $data['singer_name2']; ?></td>
<td style="text-align: left"><?php echo ($data['composer_name']) ? $data['composer_name'] : $data['composer_name2']; ?></td>
<td style="text-align: center">
<a href="<?php echo base_url().'backend/cmsTrack/editTrack/'.$data['id']; ?>" title="Xem chi tiết">
<a href="<?php echo base_url().'backend/cmsTrack/editTrack/'.$data['id'].'/'.$data['id_user'].'/'.$data['id_artist']; ?>" title="Xem chi tiết">
<i class="ace-icon fa fa-pencil bigger-130"></i>
</a>
</td>
......
......@@ -12,7 +12,7 @@ $input_title = array(
$input_singer = array(
'name' => 'singer',
'type' => 'text',
'value' => isset($singer) ? $singer : $contest[0]['name_singer'],
'value' => isset($singer) ? $singer : $track_user[0]['name'],
'placeholder' => '',
'class' => '',
'disabled' => 'true',
......@@ -24,7 +24,7 @@ $input_artist = array(
'name' => 'artist',
'type' => 'text',
'disabled' => 'true',
'value' => isset($artist) ? $artist : $contest[0]['artist'],
'value' => isset($artist) ? $artist : $track_artists[0]['name'],
'placeholder' => '',
'class' => '',
'style' => 'width: 100%',
......@@ -40,7 +40,7 @@ $input_artist = array(
<div class="widget-main">
<?php
$attributes = array('class' => 'form-horizontal', 'id' => 'myform');
echo form_open(base_url('backend/cmsTrack/editTrack/'.$contest[0]['id']), $attributes);
echo form_open(base_url('backend/cmsTrack/editTrack/'.$contest[0]['id'].'/'.$track_user[0]['id'].'/'.$track_artists[0]['id']), $attributes);
?>
<div class="form-group">
<label class="col-lg-3"></label>
......@@ -61,7 +61,7 @@ $input_artist = array(
</div>
</div>
<div class="form-group">
<label class="col-lg-3">Tên ca sĩ hiện tại (*)</label>
<label class="col-lg-3">Tên ca sĩ hiện tại (*)<?php echo $track_user[0]['id']; ?></label>
<div class="col-lg-3">
<?php
echo form_input($input_singer);
......@@ -69,7 +69,7 @@ $input_artist = array(
</div>
</div>
<div class="form-group">
<label class="col-lg-3">Tên nhạc sĩ hiện tại(*)</label>
<label class="col-lg-3">Tên nhạc sĩ hiện tại(*)<?php echo $track_artists[0]['id']; ?></label>
<div class="col-lg-3">
<?php
echo form_input($input_artist);
......
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