Commit 6c613dcf by Trần Văn Minh

Update chỉnh sửa ca sĩ/ nhạc sĩ bài hát

parent fac721d2
...@@ -49,9 +49,18 @@ class CmsTrack extends CI_Controller ...@@ -49,9 +49,18 @@ class CmsTrack extends CI_Controller
public function editTrack($contest_id, $id_user = '', $id_artist = '') public function editTrack($contest_id, $id_user = '', $id_artist = '')
{ {
$this->_data['contest'] = $contest = $this->track_model->getById($contest_id, $id_user, $id_artist); $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); $track_user = '';
$this->_data['track_user'] = $track_user = $this->track_model->getByIdUser('track_user', $id_user); $this->_data['track_artists'] = $track_artists = '';
if ($id_user != 0) {
$track_user = $this->track_model->getByIdUser('track_user', $id_user);
$this->_data['track_user'] = $track_user;
}
if ($id_artist != 0) {
$track_artists = $this->track_model->getByIdUser('track_artists', $id_artist);
$this->_data['track_artists'] = $track_artists;
}
$this->_data['list_user'] = $list_user = $this->track_model->getListUsers(); $this->_data['list_user'] = $list_user = $this->track_model->getListUsers();
// print_r($id_user.'Nhạc sĩ'.$id_artist);
// Kiểm tra trùng giá trị nếu thay đổi ở form // Kiểm tra trùng giá trị nếu thay đổi ở form
//Thiết lập validate //Thiết lập validate
...@@ -89,14 +98,14 @@ class CmsTrack extends CI_Controller ...@@ -89,14 +98,14 @@ class CmsTrack extends CI_Controller
$title = $this->input->post('title'); $title = $this->input->post('title');
$update_singer = $this->input->post('update_singer'); $update_singer = $this->input->post('update_singer');
$singer = $track_user[0]['user_id']; $singer = ($track_user != '') ? $track_user[0]['user_id']: '';
$artist = $track_artists[0]['user_id']; $artist = ($track_artists != '') ? $track_artists[0]['user_id']: '';
$update_artist = $this->input->post('update_artist'); $update_artist = $this->input->post('update_artist');
$id_singer = ($update_singer > 0) ? $update_singer: $singer; $id_singer = ($update_singer > 0) ? $update_singer: $singer;
$id_artists = ($update_artist > 0) ? $update_artist: $artist; $id_artists = ($update_artist > 0) ? $update_artist: $artist;
($singer || $id_user) ? $active_singer = 'update': $active_singer = 'insert'; ($singer || $id_user) ? $active_singer = 'update': $active_singer = 'insert';
($artist || $id_artist) ? $active_artist = 'update': $active_artist = 'insert'; ($artist || $id_artist) ? $active_artist = 'update': $active_artist = 'insert';
// die($id_singer.$id_artists); // die($active_artist.$active_singer.'ca sĩ'.$id_singer.'/'.$singer.'nhạc sĩ'.$id_artists.'/'.$artist);
$this->track_model->update_track_artists($contest_id, $id_artists, $id_artist, $active_artist); $this->track_model->update_track_artists($contest_id, $id_artists, $id_artist, $active_artist);
$this->track_model->update_track_user($contest_id, $id_singer, $id_user, $active_singer); $this->track_model->update_track_user($contest_id, $id_singer, $id_user, $active_singer);
$this->track_model->update($contest_id, $title); $this->track_model->update($contest_id, $title);
......
...@@ -31,7 +31,9 @@ class Track_model extends CI_Model ...@@ -31,7 +31,9 @@ class Track_model extends CI_Model
$this->db->where('id', $user_id); $this->db->where('id', $user_id);
$query = $this->db->get('users')->result_array(); $query = $this->db->get('users')->result_array();
$this->db->set('user_id', $user_id); $this->db->set('user_id', $user_id);
if ($query) {
$this->db->set('name', $query[0]['full_name']); $this->db->set('name', $query[0]['full_name']);
}
if ($active == 'insert') { if ($active == 'insert') {
$this->db->set('track_id', $id_track); $this->db->set('track_id', $id_track);
$this->db->insert('track_artists'); $this->db->insert('track_artists');
...@@ -48,7 +50,9 @@ class Track_model extends CI_Model ...@@ -48,7 +50,9 @@ class Track_model extends CI_Model
$this->db->where('id', $user_id); $this->db->where('id', $user_id);
$query = $this->db->get('users')->result_array(); $query = $this->db->get('users')->result_array();
$this->db->set('user_id', $user_id); $this->db->set('user_id', $user_id);
if ($query) {
$this->db->set('name', $query[0]['full_name']); $this->db->set('name', $query[0]['full_name']);
}
if ($active == 'insert') { if ($active == 'insert') {
$this->db->set('track_id', $id_track); $this->db->set('track_id', $id_track);
$this->db->insert('track_user'); $this->db->insert('track_user');
...@@ -76,9 +80,13 @@ class Track_model extends CI_Model ...@@ -76,9 +80,13 @@ class Track_model extends CI_Model
} }
public function getByIdUser($table, $id) { public function getByIdUser($table, $id) {
if ($id != 0) {
$this->db->select("*"); $this->db->select("*");
$this->db->where('id', $id); $this->db->where('id', $id);
return $this->db->get($table)->result_array(); return $this->db->get($table)->result_array();
} else
return false;
} }
/** /**
* Lay cuoc thi hien hanh * Lay cuoc thi hien hanh
......
...@@ -19,6 +19,14 @@ ...@@ -19,6 +19,14 @@
<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['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: left"><?php echo ($data['composer_name']) ? $data['composer_name'] : $data['composer_name2']; ?></td>
<td style="text-align: center"> <td style="text-align: center">
<?php
if (!$data['id_user']) {
$data['id_user'] = 0;
}
if (!$data['id_artist']) {
$data['id_artist'] = 0;
}
?>
<a href="<?php echo base_url().'backend/cmsTrack/editTrack/'.$data['id'].'/'.$data['id_user'].'/'.$data['id_artist']; ?>" 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> <i class="ace-icon fa fa-pencil bigger-130"></i>
</a> </a>
......
...@@ -12,7 +12,7 @@ $input_title = array( ...@@ -12,7 +12,7 @@ $input_title = array(
$input_singer = array( $input_singer = array(
'name' => 'singer', 'name' => 'singer',
'type' => 'text', 'type' => 'text',
'value' => isset($singer) ? $singer : $track_user[0]['name'], 'value' => isset($singer) ? $singer : isset($track_user[0]['id'])? $track_user[0]['name']: '',
'placeholder' => '', 'placeholder' => '',
'class' => '', 'class' => '',
'disabled' => 'true', 'disabled' => 'true',
...@@ -24,7 +24,7 @@ $input_artist = array( ...@@ -24,7 +24,7 @@ $input_artist = array(
'name' => 'artist', 'name' => 'artist',
'type' => 'text', 'type' => 'text',
'disabled' => 'true', 'disabled' => 'true',
'value' => isset($artist) ? $artist : $track_artists[0]['name'], 'value' => isset($artist) ? $artist : isset($track_artists[0]['id']) ? $track_artists[0]['name']: '',
'placeholder' => '', 'placeholder' => '',
'class' => '', 'class' => '',
'style' => 'width: 100%', 'style' => 'width: 100%',
...@@ -40,7 +40,17 @@ $input_artist = array( ...@@ -40,7 +40,17 @@ $input_artist = array(
<div class="widget-main"> <div class="widget-main">
<?php <?php
$attributes = array('class' => 'form-horizontal', 'id' => 'myform'); $attributes = array('class' => 'form-horizontal', 'id' => 'myform');
echo form_open(base_url('backend/cmsTrack/editTrack/'.$contest[0]['id'].'/'.$track_user[0]['id'].'/'.$track_artists[0]['id']), $attributes); if (!$track_user[0]['id']) {
$user_singer = 0;
} else {
$user_singer = $track_user[0]['id'];
}
if (!$track_artists) {
$user_artist = 0;
} else {
$user_artist = $track_artists[0]['id'];
}
echo form_open(base_url('backend/cmsTrack/editTrack/'.$contest[0]['id'].'/'.$user_singer.'/'.$user_artist), $attributes);
?> ?>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3"></label> <label class="col-lg-3"></label>
......
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