Commit 123bc1cd by Trần Văn Minh

cập nhật thêm mới nghệ sĩ ở view thêm mới bài hát và sửa bài hát

parent ad6be874
......@@ -403,6 +403,8 @@ $config['csrf_exclude_uris'] = array(
'backend/cmsTrack/listTrackAjax',
'backend/cmsArtist/listArtistAjax',
'backend/cmsTrack/addTrack',
'backend/cmsArtist/addArtistAjax',
'backend/cmsSetting/listGroupAjax',
'backend/cmsSetting/listUserAdminAjax',
......
......@@ -101,6 +101,7 @@ class CmsArtist extends CI_Controller
$dataUpdate = array(
'username' => $username,
'email' => $email,
'user_type' => 2,
'full_name' => $full_name,
'link' => $link_zing,
'link_nct' => $link_nct,
......@@ -118,6 +119,48 @@ class CmsArtist extends CI_Controller
}
}
public function addArtistAjax()
{
$email = $this->input->post('email');
$username = $this->input->post('username');
$full_name = $this->input->post('full_name');
$link_zing = $this->input->post('link_zing');
$link_nct = $this->input->post('link_nct');
$link_keeng = $this->input->post('link_keeng');
$password = MyHelper::genKeyCode(trim('123456'));
$result = $this->user_model->getByEmail($email, 2, '');
// MyHelper::echoPreDie($result);
$check_username = $this->user_model->getByUsername($username, 2, '');
if($email == '' || $username == '' || $full_name == '') {
$data['required'] = 'Vui lòng điền Vào chỗ trống!';
} else if($result) {
$data['check_email'] = 'Email đã được sử dụng!';
} else if($check_username) {
$data['check_username'] = 'Username đã tồn tại!';
} else {
$dataUpdate = array(
'username' => $username,
'password' => $password,
'email' => $email,
'user_type' => 2,
'full_name' => $full_name,
'link' => ($link_zing == '') ? null: $link_zing,
'link_nct' => ($link_nct == '') ? null: $link_nct,
'link_keeng' => ($link_keeng == '') ? null: $link_keeng,
'date_created' => time()
);
$insert_id = $this->user_model->add($dataUpdate);
if($insert_id) {
$this->session->set_flashdata('success', 'Tạo nghệ sĩ thành công!');
$data['success'] = 'Thành công!';
} else{
$this->session->set_flashdata('error', 'Tạo nghệ sĩ không thành công!');
$data['error'] = 'Xảy ra lỗi! Vui lòng thử lại.';
}
}
echo json_encode($data);
}
public function addArtist()
{
// Thiết lập validate
......@@ -174,10 +217,11 @@ class CmsArtist extends CI_Controller
'username' => $username,
'password' => $password,
'email' => $email,
'user_type' => 2,
'full_name' => $full_name,
'link' => $link_zing,
'link_nct' => $link_nct,
'link_keeng' => $link_keeng,
'link' => ($link_zing == '') ? null: $link_zing,
'link_nct' => ($link_nct == '') ? null: $link_nct,
'link_keeng' => ($link_keeng == '') ? null: $link_keeng,
'date_created' => time()
);
$this->user_model->add($dataUpdate);
......
......@@ -50,7 +50,7 @@ class CmsTrack extends CI_Controller
public function editTrack($track_id, $id_user = '', $id_artist = '')
{
$this->_data['contest'] = $contest = $this->track_model->getById($track_id);
$this->_data['contest'] = $track = $this->track_model->getById($track_id);
$track_user = '';
$this->_data['track_artists'] = $track_artists = '';
if ($id_user != 0) {
......@@ -102,33 +102,41 @@ class CmsTrack extends CI_Controller
$singer = ($track_user != '') ? $track_user[0]['user_id']: '';
$artist = ($track_artists != '') ? $track_artists[0]['user_id']: '';
$update_artist = $this->input->post('update_artist');
$file = $_FILES['avatar']['name'];
$id_singer = ($update_singer > 0) ? $update_singer: $singer;
$id_artists = ($update_artist > 0) ? $update_artist: $artist;
($singer || $id_user) ? $active_singer = 'update': $active_singer = 'insert';
($artist || $id_artist) ? $active_artist = 'update': $active_artist = 'insert';
// die($active_artist.$active_singer.'ca sĩ'.$id_singer.'/'.$singer.'nhạc sĩ'.$id_artists.'/'.$artist);
// Xử lý upload: avatar
$db_art_path = '';
$upload_path = 'uploads/tracks/arts';
$upload_full_path = '/home/aseanvn/public_html/vmusicchart.dcv.vn/' . $upload_path;
$config['upload_path'] = $upload_full_path;
$config['file_name'] = md5($track_id.time());
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = 20480;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
if($file != ''){
MyHelper::echoPreDie('1230');
$db_art_path = '';
$upload_path = 'uploads/tracks/arts';
$upload_full_path = '/home/aseanvn/public_html/vmusicchart.dcv.vn/' . $upload_path;
$config['upload_path'] = $upload_full_path;
$config['file_name'] = md5($track_id.time());
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = 20480;
$config['max_width'] = 1024;
$config['max_height'] = 768;
if ($this->upload->do_upload('avatar')) {
$upload_data = $this->upload->data();
$db_art_path = $upload_path . '/' . $upload_data['file_name'];
$this->load->library('upload', $config);
// if()
if ($this->upload->do_upload('avatar')) {
$upload_data = $this->upload->data();
MyHelper::echoPreDie('ac: '.$$upload_data);
$db_art_path = $upload_path . '/' . $upload_data['file_name'];
}
$this->track_model->update($track_id, $title, $db_art_path);
} else {
$art = $track[0]['art'];
$this->track_model->update($track_id, $title, $art);
}
// MyHelper::echoPreDie($config);
$this->track_model->update_track_artists($track_id, $id_artists, $id_artist, $active_artist);
$this->track_model->update_track_user($track_id, $id_singer, $id_user, $active_singer);
$this->track_model->update($track_id, $title, $db_art_path);
$this->session->set_flashdata('success', 'Tạo bài hát thành công');
redirect(base_url().'backend/cmsTrack/showTrack/'.$track_id);
......
......@@ -32,13 +32,13 @@ class User_model extends CI_Model
return $query->result_array();
}
public function getByUsername($username, $id, $account_type)
public function getByUsername($username, $account_type, $id = '')
{
$this->db->select($this->_table . '.*');
$this->db->from($this->_table);
$this->db->where($this->_table . '.username', $username);
$this->db->where($this->_table . '.user_type', $account_type);
if ($id) {
if ($id || $id != '') {
$this->db->where_not_in('id', $id);
}
$this->db->limit(1);
......@@ -46,13 +46,14 @@ class User_model extends CI_Model
return $query->result_array();
}
public function getByEmail($email, $id, $account_type)
{
public function getByEmail($email, $account_type, $id = '')
{
// MyHelper::echoPreDie($email);
$this->db->select($this->_table . '.*');
$this->db->from($this->_table);
$this->db->where($this->_table . '.email', $email);
$this->db->where($this->_table . '.user_type', $account_type);
if ($id) {
if ($id || $id != '') {
$this->db->where_not_in('id', $id);
}
$this->db->limit(1);
......
......@@ -19,6 +19,8 @@ $action = $CI->router->fetch_method();
<link rel="stylesheet" href="<?php echo base_url('public/assets/css/datepicker.min.css') ?>" />
<link rel="stylesheet" href="<?php echo base_url().'public/assets/css/daterangepicker.min.css' ?>" />
<link rel="stylesheet" href="<?php echo base_url().'public/assets/css/chosen.min.css' ?>"/>
<link rel="stylesheet" href="<?php echo base_url().'public/assets/css/jquery-ui.min.css' ?>"/>
<!-- <link rel="stylesheet" href="assets/css/jquery-ui.min.css" /> -->
<!-- text fonts -->
<link rel="stylesheet" href="<?php echo base_url().'public/assets/fonts/fonts.googleapis.com.css' ?>"/>
<!-- ace styles -->
......@@ -39,6 +41,8 @@ $action = $CI->router->fetch_method();
<!-- <script src="<?php echo base_url().'public/assets/js/jquery.1.11.1.min.js' ?>"></script> -->
<script src="<?php echo base_url().'public/assets/js/jquery.2.1.1.min.js' ?>"></script>
<script src="<?php echo base_url().'public/assets/js/bootstrap.min.js' ?>"></script>
<script src="<?php echo base_url().'public/assets/js/jquery-ui.min.js' ?>"></script>
<script src="<?php echo base_url().'public/assets/js/jquery.ui.touch-punch.min.js' ?>"></script>
<script src="<?php echo base_url().'public/assets/js/chosen.jquery.min.js' ?>"></script>
<script src="<?php echo base_url().'public/fckeditor/ckfinder/ckfinder.js' ?>"></script>
......
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