Commit ce500d2d by Trần Văn Minh

update form add, edit nghệ sĩ

parent 7662ec53
...@@ -58,28 +58,15 @@ class CmsArtist extends CI_Controller ...@@ -58,28 +58,15 @@ class CmsArtist extends CI_Controller
); );
$this->form_validation->set_rules( $this->form_validation->set_rules(
'username',
'Tên tài khoản',
'trim|required|callback_check_username|xss_clean'
);
$this->form_validation->set_rules(
'email',
'Email',
'trim|required|callback_check_email|xss_clean'
);
$this->form_validation->set_rules(
'full_name', 'full_name',
'text', 'text',
'trim|required|xss_clean' 'trim|callback_check_full_name|required|xss_clean'
); );
$this->form_validation->set_message('required', '<li class="list-unstyled">Bắt buộc nhập, chọn.</li>'); $this->form_validation->set_message('required', '<li class="list-unstyled">Bắt buộc nhập, chọn.</li>');
$this->form_validation->set_message('is_unique', '<li class="list-unstyled">Đã tồn tại.</li>'); $this->form_validation->set_message('is_unique', '<li class="list-unstyled">Đã tồn tại.</li>');
// Xử lý form đăng nhập // Xử lý form đăng nhập
if($this->form_validation->run($this) == false) { if($this->form_validation->run($this) == false) {
$this->_data['email'] = $this->input->post('email');
$this->_data['username'] = $this->input->post('username');
$this->_data['full_name'] = $this->input->post('full_name'); $this->_data['full_name'] = $this->input->post('full_name');
$this->_data['link_zing'] = $this->input->post('link_zing'); $this->_data['link_zing'] = $this->input->post('link_zing');
$this->_data['link_nct'] = $this->input->post('link_nct'); $this->_data['link_nct'] = $this->input->post('link_nct');
...@@ -91,16 +78,12 @@ class CmsArtist extends CI_Controller ...@@ -91,16 +78,12 @@ class CmsArtist extends CI_Controller
$this->_data['loadPage'] = 'backend/cms_artist/edit_artist_view'; $this->_data['loadPage'] = 'backend/cms_artist/edit_artist_view';
$this->load->view('backend/admin_template_view', $this->_data); $this->load->view('backend/admin_template_view', $this->_data);
}else{ }else{
$email = $this->input->post('email');
$username = trim($this->input->post('username'));
$full_name = $this->input->post('full_name'); $full_name = $this->input->post('full_name');
$link_zing = $this->input->post('link_zing'); $link_zing = $this->input->post('link_zing');
$link_nct = $this->input->post('link_nct'); $link_nct = $this->input->post('link_nct');
$link_keeng = $this->input->post('link_keeng'); $link_keeng = $this->input->post('link_keeng');
if($username && $email && $full_name){ if( $full_name){
$dataUpdate = array( $dataUpdate = array(
'username' => $username,
'email' => $email,
'user_type' => 2, 'user_type' => 2,
'full_name' => $full_name, 'full_name' => $full_name,
'link' => $link_zing, 'link' => $link_zing,
...@@ -121,27 +104,19 @@ class CmsArtist extends CI_Controller ...@@ -121,27 +104,19 @@ class CmsArtist extends CI_Controller
public function addArtistAjax() public function addArtistAjax()
{ {
$email = $this->input->post('email'); // Kiểm tra trùng giá trị nếu thay đổi ở form
$username = $this->input->post('username');
$full_name = $this->input->post('full_name'); $full_name = $this->input->post('full_name');
$link_zing = $this->input->post('link_zing'); $link_zing = $this->input->post('link_zing');
$link_nct = $this->input->post('link_nct'); $link_nct = $this->input->post('link_nct');
$link_keeng = $this->input->post('link_keeng'); $link_keeng = $this->input->post('link_keeng');
$password = MyHelper::genKeyCode(trim('123456'));
$result = $this->user_model->getByEmail($email, 2, '');
// MyHelper::echoPreDie($result); // MyHelper::echoPreDie($result);
$check_username = $this->user_model->getByUsername($username, 2, ''); $check_full_name = $this->user_model->getByFullName($full_name, 2, '');
if($email == '' || $username == '' || $full_name == '') { if($full_name == '') {
$data['required'] = 'Vui lòng điền Vào chỗ trống!'; $data['required'] = 'Vui lòng điền Vào chỗ trống!';
} else if($result) { } else if($check_full_name) {
$data['check_email'] = 'Email đã được sử dụng!'; $data['check_full_name'] = 'Tên nghệ sĩ đã tồn tại!';
} else if($check_username) {
$data['check_username'] = 'Username đã tồn tại!';
} else { } else {
$dataUpdate = array( $dataUpdate = array(
'username' => $username,
'password' => $password,
'email' => $email,
'user_type' => 2, 'user_type' => 2,
'full_name' => $full_name, 'full_name' => $full_name,
'link' => ($link_zing == '') ? null: $link_zing, 'link' => ($link_zing == '') ? null: $link_zing,
...@@ -171,28 +146,15 @@ class CmsArtist extends CI_Controller ...@@ -171,28 +146,15 @@ class CmsArtist extends CI_Controller
); );
$this->form_validation->set_rules( $this->form_validation->set_rules(
'username',
'Tên tài khoản',
'trim|required|callback_check_username|xss_clean'
);
$this->form_validation->set_rules(
'email',
'Email',
'trim|required|callback_check_email|xss_clean'
);
$this->form_validation->set_rules(
'full_name', 'full_name',
'text', 'text',
'trim|required|xss_clean' 'trim|callback_check_full_name|required|xss_clean'
); );
$this->form_validation->set_message('required', '<li class="list-unstyled">Bắt buộc nhập, chọn.</li>'); $this->form_validation->set_message('required', '<li class="list-unstyled">Bắt buộc nhập, chọn.</li>');
$this->form_validation->set_message('is_unique', '<li class="list-unstyled">Đã tồn tại.</li>'); $this->form_validation->set_message('is_unique', '<li class="list-unstyled">Đã tồn tại.</li>');
// Xử lý form đăng nhập // Xử lý form đăng nhập
if($this->form_validation->run($this) == false) { if($this->form_validation->run($this) == false) {
$this->_data['email'] = $this->input->post('email');
$this->_data['username'] = $this->input->post('username');
$this->_data['full_name'] = $this->input->post('full_name'); $this->_data['full_name'] = $this->input->post('full_name');
$this->_data['link_zing'] = $this->input->post('link_zing'); $this->_data['link_zing'] = $this->input->post('link_zing');
$this->_data['link_nct'] = $this->input->post('link_nct'); $this->_data['link_nct'] = $this->input->post('link_nct');
...@@ -204,19 +166,13 @@ class CmsArtist extends CI_Controller ...@@ -204,19 +166,13 @@ class CmsArtist extends CI_Controller
$this->_data['loadPage'] = 'backend/cms_artist/add_artist_view'; $this->_data['loadPage'] = 'backend/cms_artist/add_artist_view';
$this->load->view('backend/admin_template_view', $this->_data); $this->load->view('backend/admin_template_view', $this->_data);
}else{ }else{
$username = trim($this->input->post('username'));
$password = MyHelper::genKeyCode(trim('123456'));
$email = $this->input->post('email');
// $username = $this->input->post('username'); // $username = $this->input->post('username');
$full_name = $this->input->post('full_name'); $full_name = $this->input->post('full_name');
$link_zing = $this->input->post('link_zing'); $link_zing = $this->input->post('link_zing');
$link_nct = $this->input->post('link_nct'); $link_nct = $this->input->post('link_nct');
$link_keeng = $this->input->post('link_keeng'); $link_keeng = $this->input->post('link_keeng');
if($username && $email && $full_name){ if($full_name){
$dataUpdate = array( $dataUpdate = array(
'username' => $username,
'password' => $password,
'email' => $email,
'user_type' => 2, 'user_type' => 2,
'full_name' => $full_name, 'full_name' => $full_name,
'link' => ($link_zing == '') ? null: $link_zing, 'link' => ($link_zing == '') ? null: $link_zing,
...@@ -247,7 +203,7 @@ class CmsArtist extends CI_Controller ...@@ -247,7 +203,7 @@ class CmsArtist extends CI_Controller
$this->load->view('backend/admin_template_view', $this->_data); $this->load->view('backend/admin_template_view', $this->_data);
} }
public function check_username($username) public function check_full_name($full_name)
{ {
if ($this->input->post('id')) { if ($this->input->post('id')) {
$id = $this->input->post('id'); $id = $this->input->post('id');
...@@ -255,28 +211,10 @@ class CmsArtist extends CI_Controller ...@@ -255,28 +211,10 @@ class CmsArtist extends CI_Controller
else { else {
$id = ''; $id = '';
} }
$result = $this->user_model->getByUsername($username, 2, $id); $result = $this->user_model->getByFullName($full_name, 2, $id);
if($result) { if($result) {
//die('2335'); //die('2335');
$this->form_validation->set_message('check_username', '<li class="list-unstyled">Đã tồn tại.</li>'); $this->form_validation->set_message('check_full_name', '<li class="list-unstyled">Tên ca sĩ đã tồn tại.</li>');
return false;
}else{
return TRUE;
}
}
public function check_email($email)
{
// die($email);
if ($this->input->post('id')) {
$id = $this->input->post('id');
}
else {
$id = '';
}
$result = $this->user_model->getByEmail($email, 2, $id);
if($result) {
// die('2335');
$this->form_validation->set_message('check_email', '<li class="list-unstyled">Email đã tồn tại.</li>');
return false; return false;
}else{ }else{
return TRUE; return TRUE;
......
...@@ -46,6 +46,20 @@ class User_model extends CI_Model ...@@ -46,6 +46,20 @@ class User_model extends CI_Model
return $query->result_array(); return $query->result_array();
} }
public function getByFullName($full_name, $account_type, $id = '')
{
$this->db->select($this->_table . '.*');
$this->db->from($this->_table);
$this->db->where($this->_table . '.full_name', $full_name);
$this->db->where($this->_table . '.user_type', $account_type);
if ($id || $id != '') {
$this->db->where_not_in('id', $id);
}
$this->db->limit(1);
$query = $this->db->get();
return $query->result_array();
}
public function getByEmail($email, $account_type, $id = '') public function getByEmail($email, $account_type, $id = '')
{ {
// MyHelper::echoPreDie($email); // MyHelper::echoPreDie($email);
...@@ -99,6 +113,7 @@ class User_model extends CI_Model ...@@ -99,6 +113,7 @@ class User_model extends CI_Model
$this->db->like('username', $name, 'both'); $this->db->like('username', $name, 'both');
$this->db->or_like('email', $name, 'both'); $this->db->or_like('email', $name, 'both');
$this->db->or_like('full_name', $name, 'both'); $this->db->or_like('full_name', $name, 'both');
$this->db->or_where('id', intval($name));
} }
$query = $this->db->get(); $query = $this->db->get();
$result = $query->result_array(); $result = $query->result_array();
...@@ -111,12 +126,14 @@ class User_model extends CI_Model ...@@ -111,12 +126,14 @@ class User_model extends CI_Model
public function cmsGetPagination($record, $start, $name = null) public function cmsGetPagination($record, $start, $name = null)
{ {
$this->db->select($this->_table . '.*'); $this->db->select($this->_table . '.*');
$this->db->from($this->_table); $this->db->from($this->_table);
if ($name != null) { if ($name != null) {
$this->db->like('username', $name, 'both'); $this->db->like('username', $name, 'both');
$this->db->or_like('email', $name, 'both'); $this->db->or_like('email', $name, 'both');
$this->db->or_like('full_name', $name, 'both'); $this->db->or_like('full_name', $name, 'both');
$this->db->or_where('id', intval($name));
} }
$this->db->order_by($this->_table . '.username', 'asc'); $this->db->order_by($this->_table . '.username', 'asc');
$this->db->limit($record, $start); $this->db->limit($record, $start);
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
<th style="text-align: center">TT</th> <th style="text-align: center">TT</th>
<th style="text-align: center">#ID</th> <th style="text-align: center">#ID</th>
<th style="text-align: center">Tên Ca sĩ/Nhạc sĩ</th> <th style="text-align: center">Tên Ca sĩ/Nhạc sĩ</th>
<th style="text-align: center">Tài khoản</th>
<th style="text-align: center">Email</th>
<th style="text-align: center">Xử lý</th> <th style="text-align: center">Xử lý</th>
</tr> </tr>
</thead> </thead>
...@@ -16,8 +14,6 @@ ...@@ -16,8 +14,6 @@
<td style="text-align: center"><?php echo ($key+1+$offset); ?></td> <td style="text-align: center"><?php echo ($key+1+$offset); ?></td>
<td style="text-align: center">#<?php echo $data['id']; ?></td> <td style="text-align: center">#<?php echo $data['id']; ?></td>
<td style="text-align: left"><?php echo $data['full_name']; ?></td> <td style="text-align: left"><?php echo $data['full_name']; ?></td>
<td style="text-align: left"><?php echo $data['username']; ?></td>
<td style="text-align: left"><?php echo $data['email']; ?></td>
<td style="text-align: center"> <td style="text-align: center">
<a href="<?php echo base_url().'backend/cmsArtist/editArtist/'.$data['id']; ?>" title="Sửa thông tin"> <a href="<?php echo base_url().'backend/cmsArtist/editArtist/'.$data['id']; ?>" title="Sửa thông tin">
<i class="ace-icon fa fa-pencil bigger-130"></i> <i class="ace-icon fa fa-pencil bigger-130"></i>
......
...@@ -92,36 +92,6 @@ $input_link_keeng = array( ...@@ -92,36 +92,6 @@ $input_link_keeng = array(
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3">Username (*)</label>
<div class="col-lg-3">
<?php
echo form_input($input_username);
if(validation_errors()){echo form_error('username', '<div class="error">', '</div>');}
?>
</div>
<div><span name></span></div>
</div>
<!-- <?php if (!$contest[0]) { ?>
<div class="form-group">
<label class="col-lg-3">Password (*)</label>
<div class="col-lg-3">
<?php
echo form_input($input_password);
if(validation_errors()){echo form_error('username', '<div class="error">', '</div>');}
?>
</div>
</div>
<?php } ?> -->
<div class="form-group">
<label class="col-lg-3">Email (*)</label>
<div class="col-lg-3">
<?php
echo form_input($input_email);
if(validation_errors()){echo form_error('email', '<div class="error">', '</div>');}
?>
</div>
</div>
<div class="form-group">
<label class="col-lg-3">Tên đầu đủ (*)</label> <label class="col-lg-3">Tên đầu đủ (*)</label>
<div class="col-lg-3"> <div class="col-lg-3">
<?php <?php
...@@ -130,54 +100,38 @@ $input_link_keeng = array( ...@@ -130,54 +100,38 @@ $input_link_keeng = array(
?> ?>
</div> </div>
</div> </div>
<!-- <div class="form-group">
<label class="col-lg-3">Bio </label>
<div class="col-lg-3">
<?php
echo form_textarea($input_bio);
if(validation_errors()){echo form_error('date_from', '<div class="error">', '</div>');}
?>
</div>
</div>
<div class="form-group">
<label class="col-lg-3">Avartar</label>
<div class="col-lg-3">
<?php
echo form_upload($input_avatar);
?>
</div>
</div>
<div class="form-group">
<label class="col-lg-3">Cover</label>
<div class="col-lg-3">
<?php
echo form_upload($input_cover);
?>
</div>
</div> -->
<div class="form-group"> <div class="form-group">
<label class="col-lg-3">Link Zingmp3</label> <label class="col-lg-3">Link Zingmp3</label>
<div class="col-lg-3"> <div class="col-lg-6">
<?php <?php
echo form_input($input_link_zing); echo form_input($input_link_zing);
?> ?>
</div> </div>
<div class="col-lg-3">
<span><a href="https://zingmp3.vn/the-loai-nghe-si/Viet-Nam/IWZ9Z08I.html" target="_blank" >Lấy link ở ZingMp3</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3">Link Nhạc của tui</label> <label class="col-lg-3">Link Nhạc của tui</label>
<div class="col-lg-3"> <div class="col-lg-6">
<?php <?php
echo form_input($input_link_nct); echo form_input($input_link_nct);
?> ?>
</div> </div>
<div class="col-lg-3">
<span><a href="https://www.nhaccuatui.com/nghe-si.html" target="_blank">Lấy link ở NCT</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3">Link Keeng</label> <label class="col-lg-3">Link Keeng</label>
<div class="col-lg-3"> <div class="col-lg-6">
<?php <?php
echo form_input($input_link_keeng); echo form_input($input_link_keeng);
?> ?>
</div> </div>
<div class="col-lg-3">
<span><a href="http://keeng.vn/danh-sach-ca-si" target="_blank">Lấy link ở Keeng</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-lg-3"> <div class="col-lg-3">
......
...@@ -100,36 +100,6 @@ $input_link_keeng = array( ...@@ -100,36 +100,6 @@ $input_link_keeng = array(
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3">Username (*)</label>
<div class="col-lg-3">
<?php
echo form_input($input_username);
if(validation_errors()){echo form_error('username', '<div class="error">', '</div>');}
?>
</div>
<div><span name></span></div>
</div>
<!-- <?php if (!$contest[0]) { ?>
<div class="form-group">
<label class="col-lg-3">Password (*)</label>
<div class="col-lg-3">
<?php
echo form_input($input_password);
if(validation_errors()){echo form_error('username', '<div class="error">', '</div>');}
?>
</div>
</div>
<?php } ?> -->
<div class="form-group">
<label class="col-lg-3">Email (*)</label>
<div class="col-lg-3">
<?php
echo form_input($input_email);
if(validation_errors()){echo form_error('email', '<div class="error">', '</div>');}
?>
</div>
</div>
<div class="form-group">
<label class="col-lg-3">Tên đầu đủ (*)</label> <label class="col-lg-3">Tên đầu đủ (*)</label>
<div class="col-lg-3"> <div class="col-lg-3">
<?php <?php
...@@ -138,54 +108,38 @@ $input_link_keeng = array( ...@@ -138,54 +108,38 @@ $input_link_keeng = array(
?> ?>
</div> </div>
</div> </div>
<!-- <div class="form-group">
<label class="col-lg-3">Bio </label>
<div class="col-lg-3">
<?php
echo form_textarea($input_bio);
if(validation_errors()){echo form_error('date_from', '<div class="error">', '</div>');}
?>
</div>
</div>
<div class="form-group">
<label class="col-lg-3">Avartar</label>
<div class="col-lg-3">
<?php
echo form_upload($input_avatar);
?>
</div>
</div>
<div class="form-group">
<label class="col-lg-3">Cover</label>
<div class="col-lg-3">
<?php
echo form_upload($input_cover);
?>
</div>
</div> -->
<div class="form-group"> <div class="form-group">
<label class="col-lg-3">Link Zingmp3</label> <label class="col-lg-3">Link Zingmp3</label>
<div class="col-lg-3"> <div class="col-lg-6">
<?php <?php
echo form_input($input_link_zing); echo form_input($input_link_zing);
?> ?>
</div> </div>
<div class="col-lg-3">
<span><a href="https://zingmp3.vn/the-loai-nghe-si/Viet-Nam/IWZ9Z08I.html" target="_blank" >Lấy link ở ZingMp3</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3">Link Nhạc của tui</label> <label class="col-lg-3">Link Nhạc của tui</label>
<div class="col-lg-3"> <div class="col-lg-6">
<?php <?php
echo form_input($input_link_nct); echo form_input($input_link_nct);
?> ?>
</div> </div>
<div class="col-lg-3">
<span><a href="https://www.nhaccuatui.com/nghe-si.html" target="_blank">Lấy link ở NCT</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3">Link Keeng</label> <label class="col-lg-3">Link Keeng</label>
<div class="col-lg-3"> <div class="col-lg-6">
<?php <?php
echo form_input($input_link_keeng); echo form_input($input_link_keeng);
?> ?>
</div> </div>
<div class="col-lg-3">
<span><a href="http://keeng.vn/danh-sach-ca-si" target="_blank">Lấy link ở Keeng</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="col-lg-3"> <div class="col-lg-3">
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<?php echo form_open(base_url().'backend/cmsArtist/listArtistAjax'); ?> <?php echo form_open(base_url().'backend/cmsArtist/listArtistAjax'); ?>
<div class="col-lg-3"> <div class="col-lg-3">
<input class="form-control" type="text" name="input-name" id="input-name" <input class="form-control" type="text" name="input-name" id="input-name"
placeholder="Nhập tên nghệ sĩ, email..." /> placeholder="Nhập id, tên nghệ sĩ, email..." />
</div> </div>
<div class="col-lg-1"> <div class="col-lg-1">
<button class="btn btn-sm btn-default" id="delete-filter">Xóa bộ lọc</button> <button class="btn btn-sm btn-default" id="delete-filter">Xóa bộ lọc</button>
......
...@@ -91,24 +91,6 @@ ...@@ -91,24 +91,6 @@
<input type="hidden" name="id" value="" /> <input type="hidden" name="id" value="" />
</div> </div>
</div> </div>
<div class="form-group" id="err-username">
<label class="col-lg-3"></label>
<label class="col-lg-3">Username (*)</label>
<div class="col-lg-3">
<input type="text" name="username" value="" class="form-control"
style="width:100%;" placeholder="Nhập username" />
</div>
<label class="col-lg-3"></label>
<div><span name></span></div>
</div>
<div class="form-group" id="err-email">
<label class="col-lg-3"></label>
<label class="col-lg-3">Email (*)</label>
<div class="col-lg-3">
<input type="email" name="email" value="" class="form-control"
style="width:100%;" placeholder="Nhập email" />
</div>
</div>
<div class="form-group err-full-name"> <div class="form-group err-full-name">
<label class="col-lg-3"></label> <label class="col-lg-3"></label>
<label class="col-lg-3">Tên đầu đủ (*)</label> <label class="col-lg-3">Tên đầu đủ (*)</label>
...@@ -118,28 +100,34 @@ ...@@ -118,28 +100,34 @@
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3"></label>
<label class="col-lg-3">Link Zingmp3</label> <label class="col-lg-3">Link Zingmp3</label>
<div class="col-lg-3"> <div class="col-lg-3">
<input type="text" name="link_zing" value="" class="form-control" <input type="text" name="link_zing" value="" class="form-control"
style="width:100%;" placeholder="Nhập link ZingMp3" /> style="width:100%;" placeholder="Nhập link ZingMp3" />
</div> </div>
<div class="col-lg-3">
<span><a href="https://zingmp3.vn/the-loai-nghe-si/Viet-Nam/IWZ9Z08I.html" target="_blank" >Lấy link ở ZingMp3</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3"></label>
<label class="col-lg-3">Link Nhạc của tui</label> <label class="col-lg-3">Link Nhạc của tui</label>
<div class="col-lg-3"> <div class="col-lg-3">
<input type="text" name="link_nct" value="" class="form-control" <input type="text" name="link_nct" value="" class="form-control"
style="width:100%;" placeholder="Nhập link NCT" /> style="width:100%;" placeholder="Nhập link NCT" />
</div> </div>
<div class="col-lg-3">
<span><a href="https://www.nhaccuatui.com/nghe-si.html" target="_blank">Lấy link ở NCT</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3"></label>
<label class="col-lg-3">Link Keeng</label> <label class="col-lg-3">Link Keeng</label>
<div class="col-lg-3"> <div class="col-lg-3">
<input type="text" name="link_keeng" value="" class="form-control" <input type="text" name="link_keeng" value="" class="form-control"
style="width:100%;" placeholder="Nhập Link Keeng" /> style="width:100%;" placeholder="Nhập Link Keeng" />
</div> </div>
<div class="col-lg-3">
<span><a href="http://keeng.vn/danh-sach-ca-si" target="_blank">Lấy link ở Keeng</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3"></label> <label class="col-lg-3"></label>
...@@ -232,9 +220,6 @@ $('#add_artists').click(function(e) { ...@@ -232,9 +220,6 @@ $('#add_artists').click(function(e) {
$('#err').empty(); $('#err').empty();
e.preventDefault(); e.preventDefault();
var formData = new FormData(); var formData = new FormData();
//append some non-form data also
formData.append('username', $("input[name='username']").val());
formData.append('email', $("input[name='email']").val());
formData.append('full_name', $("input[name='full_name']").val()); formData.append('full_name', $("input[name='full_name']").val());
formData.append('link_zing', $("input[name='link_zing']").val()); formData.append('link_zing', $("input[name='link_zing']").val());
formData.append('link_nct', $("input[name='link_nct']").val()); formData.append('link_nct', $("input[name='link_nct']").val());
...@@ -248,16 +233,12 @@ $('#add_artists').click(function(e) { ...@@ -248,16 +233,12 @@ $('#add_artists').click(function(e) {
processData: false, processData: false,
contentType: false, contentType: false,
success: function(data) { success: function(data) {
if (data['check_username']) {
$('#err').append(data['check_username']); if (data['check_full_name']) {
$('#err-username').addClass('has-error'); $('#err').append(data['check_full_name']);
$('#err-full-name').addClass('has-error');
} else } else
$('#err-username').removeClass('has-error'); $('#err-full-name').removeClass('has-error');
if (data['check_email']) {
$('#err').append(data['check_email']);
$('#err-email').addClass('has-error');
} else
$('#err-email').removeClass('has-error');
if(data['success']){ if(data['success']){
$("#form_add_artist").trigger("reset"); $("#form_add_artist").trigger("reset");
alert('Tạo nghệ sĩ thành công!'); alert('Tạo nghệ sĩ thành công!');
......
...@@ -281,25 +281,7 @@ $check = "checked => 1"; ...@@ -281,25 +281,7 @@ $check = "checked => 1";
<input type="hidden" name="id" value="" /> <input type="hidden" name="id" value="" />
</div> </div>
</div> </div>
<div class="form-group" id="err-username"> <div class="form-group err-full-name" id="err-full-name">
<label class="col-lg-3"></label>
<label class="col-lg-3">Username (*)</label>
<div class="col-lg-3">
<input type="text" name="username" value="" class="form-control"
style="width:100%;" placeholder="Nhập username" />
</div>
<div><span name></span></div>
</div>
<div class="form-group" id="err-email">
<label class="col-lg-3"></label>
<label class="col-lg-3">Email (*)</label>
<div class="col-lg-3">
<input type="email" name="email" value="" class="form-control"
style="width:100%;" placeholder="Nhập email" />
</div>
</div>
<div class="form-group err-full-name">
<label class="col-lg-3"></label>
<label class="col-lg-3">Tên đầu đủ (*)</label> <label class="col-lg-3">Tên đầu đủ (*)</label>
<div class="col-lg-3"> <div class="col-lg-3">
<input type="text" name="full_name" value="" class="form-control" <input type="text" name="full_name" value="" class="form-control"
...@@ -307,31 +289,38 @@ $check = "checked => 1"; ...@@ -307,31 +289,38 @@ $check = "checked => 1";
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3"></label>
<label class="col-lg-3">Link Zingmp3</label> <label class="col-lg-3">Link Zingmp3</label>
<div class="col-lg-3"> <div class="col-lg-6">
<input type="text" name="link_zing" value="" class="form-control" <input type="text" name="link_zing" value="" class="form-control"
style="width:100%;" placeholder="Nhập link ZingMp3" /> style="width:100%;" placeholder="Nhập link ZingMp3" />
</div> </div>
<div class="col-lg-3 text-right">
<span><a href="https://zingmp3.vn/the-loai-nghe-si/Viet-Nam/IWZ9Z08I.html" target="_blank" >Lấy link ở ZingMp3</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3"></label> <label class="col-lg-3"></label>
<label class="col-lg-3">Link Nhạc của tui</label> <label class="col-lg-3">Link Nhạc của tui</label>
<div class="col-lg-3"> <div class="col-lg-6">
<input type="text" name="link_nct" value="" class="form-control" <input type="text" name="link_nct" value="" class="form-control"
style="width:100%;" placeholder="Nhập link NCT" /> style="width:100%;" placeholder="Nhập link NCT" />
</div> </div>
<div class="col-lg-3 text-right">
<span><a href="https://www.nhaccuatui.com/nghe-si.html" target="_blank">Lấy link ở NCT</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3"></label> <label class="col-lg-3"></label>
<label class="col-lg-3">Link Keeng</label> <label class="col-lg-3">Link Keeng</label>
<div class="col-lg-3"> <div class="col-lg-6">
<input type="text" name="link_keeng" value="" class="form-control" <input type="text" name="link_keeng" value="" class="form-control"
style="width:100%;" placeholder="Nhập Link Keeng" /> style="width:100%;" placeholder="Nhập Link Keeng" />
</div> </div>
<div class="col-lg-3 text-right">
<span><a href="http://keeng.vn/danh-sach-ca-si" target="_blank">Lấy link ở Keeng</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3"></label>
<div class="col-lg-3"> <div class="col-lg-3">
<a href="<?php echo base_url().'backend/cmsArtist/listArtist'?>" <a href="<?php echo base_url().'backend/cmsArtist/listArtist'?>"
onclick="return confirm('Bạn có chắc chắn muốn quay lại Danh sách không?')"> onclick="return confirm('Bạn có chắc chắn muốn quay lại Danh sách không?')">
...@@ -431,8 +420,6 @@ $('#add_artists').click(function(e) { ...@@ -431,8 +420,6 @@ $('#add_artists').click(function(e) {
e.preventDefault(); e.preventDefault();
var formData = new FormData(); var formData = new FormData();
//append some non-form data also //append some non-form data also
formData.append('username', $("input[name='username']").val());
formData.append('email', $("input[name='email']").val());
formData.append('full_name', $("input[name='full_name']").val()); formData.append('full_name', $("input[name='full_name']").val());
formData.append('link_zing', $("input[name='link_zing']").val()); formData.append('link_zing', $("input[name='link_zing']").val());
formData.append('link_nct', $("input[name='link_nct']").val()); formData.append('link_nct', $("input[name='link_nct']").val());
...@@ -446,16 +433,12 @@ $('#add_artists').click(function(e) { ...@@ -446,16 +433,12 @@ $('#add_artists').click(function(e) {
processData: false, processData: false,
contentType: false, contentType: false,
success: function(data) { success: function(data) {
if (data['check_username']) {
$('#err').append(data['check_username']); if (data['check_full_name']) {
$('#err-username').addClass('has-error'); $('#err').append(data['check_full_name']);
} else $('#err-full-name').addClass('has-error');
$('#err-username').removeClass('has-error');
if (data['check_email']) {
$('#err').append(data['check_email']);
$('#err-email').addClass('has-error');
} else } else
$('#err-email').removeClass('has-error'); $('#err-full-name').removeClass('has-error');
if(data['success']){ if(data['success']){
$("#form_add_artist").trigger("reset"); $("#form_add_artist").trigger("reset");
alert('Tạo nghệ sĩ thành công!'); alert('Tạo nghệ sĩ thành công!');
...@@ -468,42 +451,6 @@ $('#add_artists').click(function(e) { ...@@ -468,42 +451,6 @@ $('#add_artists').click(function(e) {
// validation // validation
$('#add_composer').click(function() { $('#add_composer').click(function() {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
$("#add_artists").attr("disabled", true);
$("input[name='username']").keyup(function(){
$('#err').empty();
if ($("input[name='username']").val() == '') {
$('#err').append('Vui lòng nhập username');
$('#err-username').addClass('has-error');
} else {
$('#err-username').removeClass('has-error');
$('#err-username').addClass('has-success');
}
var full_name = $("input[name='full_name']").val();
var email = $("input[name='email']").val();
var username = $("input[name='username']").val();
validation(username, email, full_name);
});
$("input[name='email']").keyup(function(){
$('#err').empty();
if ($("input[name='email']").val() == '') {
$('#err').append('Vui lòng nhập email');
$('#err-email').addClass('has-error');
} else {
var email_vali = regex.test($("input[name='email']").val());
if(email_vali == false) {
$('#err').append('Vui lòng nhập đúng email');
$('#err-email').addClass('has-error');
} else {
$('#err-email').removeClass('has-error');
$('#err-email').addClass('has-success');
}
}
var full_name = $("input[name='full_name']").val();
var email = $("input[name='email']").val();
var username = $("input[name='username']").val();
validation(username, email, full_name);
});
$("input[name='full_name']").keyup(function(){ $("input[name='full_name']").keyup(function(){
if ($("input[name='full_name']").val() == '') { if ($("input[name='full_name']").val() == '') {
...@@ -515,17 +462,17 @@ $('#add_composer').click(function() { ...@@ -515,17 +462,17 @@ $('#add_composer').click(function() {
$('.err-full-name').addClass('has-success'); $('.err-full-name').addClass('has-success');
} }
var full_name = $("input[name='full_name']").val(); var full_name = $("input[name='full_name']").val();
var email = $("input[name='email']").val(); // var email = $("input[name='email']").val();
var username = $("input[name='username']").val(); // var username = $("input[name='username']").val();
validation(username, email, full_name); validation(full_name);
}); });
}); });
// validation // validation
function validation(username, email, full_name) { function validation(username = null, email = null, full_name) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; // var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var email_vali = regex.test(email); // var email_vali = regex.test(email);
if (full_name != '' && email_vali == true && username != '') { if (full_name != '') {
$("#add_artists").attr("disabled", false); $("#add_artists").attr("disabled", false);
} else { } else {
$("#add_artists").attr("disabled", true); $("#add_artists").attr("disabled", true);
......
...@@ -209,64 +209,52 @@ $input_link_keeng = array( ...@@ -209,64 +209,52 @@ $input_link_keeng = array(
<div class="widget-body"> <div class="widget-body">
<div class="widget-main"> <div class="widget-main">
<form id="form_add_artist" method="POST" class="form-horizontal"> <form id="form_add_artist" method="POST" class="form-horizontal">
<span id="err" class="text-danger"></span>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3"></label> <label class="col-lg-3"></label>
<div class="col-lg-3"> <div class="col-lg-3">
<input type="hidden" name="id" value="" /> <input type="hidden" name="id" value="" />
</div> </div>
</div> </div>
<div class="form-group" id="err-username"> <div class="form-group err-full-name" id="err-full-name">
<label class="col-lg-3"></label>
<label class="col-lg-3">Username (*)</label>
<div class="col-lg-3">
<input type="text" name="username" value="" class="form-control"
style="width:100%;" placeholder="Nhập username" />
</div>
<div><span name></span></div>
</div>
<div class="form-group" id="err-email">
<label class="col-lg-3"></label>
<label class="col-lg-3">Email (*)</label>
<div class="col-lg-3">
<input type="email" name="email" value="" class="form-control"
style="width:100%;" placeholder="Nhập email" />
</div>
</div>
<div class="form-group err-full-name">
<label class="col-lg-3"></label>
<label class="col-lg-3">Tên đầu đủ (*)</label> <label class="col-lg-3">Tên đầu đủ (*)</label>
<div class="col-lg-3"> <div class="col-lg-3">
<input type="text" name="full_name" value="" class="form-control" <input type="text" name="full_name" value="" class="form-control"
style="width:100%;" placeholder="Nhập họ tên đầy đủ" /> style="width:100%;" placeholder="Nhập họ tên đầy đủ" />
<span id="err" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3"></label>
<label class="col-lg-3">Link Zingmp3</label> <label class="col-lg-3">Link Zingmp3</label>
<div class="col-lg-3"> <div class="col-lg-6">
<input type="text" name="link_zing" value="" class="form-control" <input type="text" name="link_zing" value="" class="form-control"
style="width:100%;" placeholder="Nhập link ZingMp3" /> style="width:100%;" placeholder="Nhập link ZingMp3" />
</div> </div>
<div class="col-lg-3 text-right">
<span><a href="https://zingmp3.vn/the-loai-nghe-si/Viet-Nam/IWZ9Z08I.html" target="_blank" >Lấy link ở ZingMp3</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3"></label>
<label class="col-lg-3">Link Nhạc của tui</label> <label class="col-lg-3">Link Nhạc của tui</label>
<div class="col-lg-3"> <div class="col-lg-6">
<input type="text" name="link_nct" value="" class="form-control" <input type="text" name="link_nct" value="" class="form-control"
style="width:100%;" placeholder="Nhập link NCT" /> style="width:100%;" placeholder="Nhập link NCT" />
</div> </div>
<div class="col-lg-3 text-right">
<span><a href="https://www.nhaccuatui.com/nghe-si.html" target="_blank">Lấy link ở NCT</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3"></label>
<label class="col-lg-3">Link Keeng</label> <label class="col-lg-3">Link Keeng</label>
<div class="col-lg-3"> <div class="col-lg-6">
<input type="text" name="link_keeng" value="" class="form-control" <input type="text" name="link_keeng" value="" class="form-control"
style="width:100%;" placeholder="Nhập Link Keeng" /> style="width:100%;" placeholder="Nhập Link Keeng" />
</div> </div>
<div class="col-lg-3 text-right">
<span><a href="http://keeng.vn/danh-sach-ca-si" target="_blank">Lấy link ở Keeng</a></span>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-3"></label>
<div class="col-lg-3"> <div class="col-lg-3">
<a href="<?php echo base_url().'backend/cmsArtist/listArtist'?>" <a href="<?php echo base_url().'backend/cmsArtist/listArtist'?>"
onclick="return confirm('Bạn có chắc chắn muốn quay lại Danh sách không?')"> onclick="return confirm('Bạn có chắc chắn muốn quay lại Danh sách không?')">
...@@ -357,8 +345,6 @@ $('#add_artists').click(function(e) { ...@@ -357,8 +345,6 @@ $('#add_artists').click(function(e) {
e.preventDefault(); e.preventDefault();
var formData = new FormData(); var formData = new FormData();
//append some non-form data also //append some non-form data also
formData.append('username', $("input[name='username']").val());
formData.append('email', $("input[name='email']").val());
formData.append('full_name', $("input[name='full_name']").val()); formData.append('full_name', $("input[name='full_name']").val());
formData.append('link_zing', $("input[name='link_zing']").val()); formData.append('link_zing', $("input[name='link_zing']").val());
formData.append('link_nct', $("input[name='link_nct']").val()); formData.append('link_nct', $("input[name='link_nct']").val());
...@@ -372,16 +358,12 @@ $('#add_artists').click(function(e) { ...@@ -372,16 +358,12 @@ $('#add_artists').click(function(e) {
processData: false, processData: false,
contentType: false, contentType: false,
success: function(data) { success: function(data) {
if (data['check_username']) {
$('#err').append(data['check_username']); if (data['check_full_name']) {
$('#err-username').addClass('has-error'); $('#err').append(data['check_full_name']);
$('#err-full-name').addClass('has-error');
} else } else
$('#err-username').removeClass('has-error'); $('#err-full-name').removeClass('has-error');
if (data['check_email']) {
$('#err').append(data['check_email']);
$('#err-email').addClass('has-error');
} else
$('#err-email').removeClass('has-error');
if(data['success']){ if(data['success']){
$("#form_add_artist").trigger("reset"); $("#form_add_artist").trigger("reset");
alert('Tạo nghệ sĩ thành công!'); alert('Tạo nghệ sĩ thành công!');
...@@ -394,42 +376,42 @@ $('#add_artists').click(function(e) { ...@@ -394,42 +376,42 @@ $('#add_artists').click(function(e) {
// validation // validation
$('#add_composer').click(function() { $('#add_composer').click(function() {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; // var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
$("#add_artists").attr("disabled", true); // $("#add_artists").attr("disabled", true);
$("input[name='username']").keyup(function(){ // $("input[name='username']").keyup(function(){
$('#err').empty(); // $('#err').empty();
if ($("input[name='username']").val() == '') { // if ($("input[name='username']").val() == '') {
$('#err').append('Vui lòng nhập username'); // $('#err').append('Vui lòng nhập username');
$('#err-username').addClass('has-error'); // $('#err-username').addClass('has-error');
} else { // } else {
$('#err-username').removeClass('has-error'); // $('#err-username').removeClass('has-error');
$('#err-username').addClass('has-success'); // $('#err-username').addClass('has-success');
} // }
var full_name = $("input[name='full_name']").val(); // var full_name = $("input[name='full_name']").val();
var email = $("input[name='email']").val(); // var email = $("input[name='email']").val();
var username = $("input[name='username']").val(); // var username = $("input[name='username']").val();
validation(username, email, full_name); // validation(username, email, full_name);
}); // });
$("input[name='email']").keyup(function(){ // $("input[name='email']").keyup(function(){
$('#err').empty(); // $('#err').empty();
if ($("input[name='email']").val() == '') { // if ($("input[name='email']").val() == '') {
$('#err').append('Vui lòng nhập email'); // $('#err').append('Vui lòng nhập email');
$('#err-email').addClass('has-error'); // $('#err-email').addClass('has-error');
} else { // } else {
var email_vali = regex.test($("input[name='email']").val()); // var email_vali = regex.test($("input[name='email']").val());
if(email_vali == false) { // if(email_vali == false) {
$('#err').append('Vui lòng nhập đúng email'); // $('#err').append('Vui lòng nhập đúng email');
$('#err-email').addClass('has-error'); // $('#err-email').addClass('has-error');
} else { // } else {
$('#err-email').removeClass('has-error'); // $('#err-email').removeClass('has-error');
$('#err-email').addClass('has-success'); // $('#err-email').addClass('has-success');
} // }
} // }
var full_name = $("input[name='full_name']").val(); // var full_name = $("input[name='full_name']").val();
var email = $("input[name='email']").val(); // var email = $("input[name='email']").val();
var username = $("input[name='username']").val(); // var username = $("input[name='username']").val();
validation(username, email, full_name); // validation(username, email, full_name);
}); // });
$("input[name='full_name']").keyup(function(){ $("input[name='full_name']").keyup(function(){
if ($("input[name='full_name']").val() == '') { if ($("input[name='full_name']").val() == '') {
...@@ -441,18 +423,23 @@ $('#add_composer').click(function() { ...@@ -441,18 +423,23 @@ $('#add_composer').click(function() {
$('.err-full-name').addClass('has-success'); $('.err-full-name').addClass('has-success');
} }
var full_name = $("input[name='full_name']").val(); var full_name = $("input[name='full_name']").val();
var email = $("input[name='email']").val(); // var email = $("input[name='email']").val();
var username = $("input[name='username']").val(); // var username = $("input[name='username']").val();
validation(username, email, full_name); validation(full_name);
}); });
}); });
// validation // validation
function validation(username, email, full_name) { function validation(username =null, email = null, full_name) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; // var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var email_vali = regex.test(email); // var email_vali = regex.test(email);
if (full_name != '' && email_vali == true && username != '') { // if (full_name != '' && email_vali == true && username != '') {
// $("#add_artists").attr("disabled", false);
// } else {
// $("#add_artists").attr("disabled", true);
// }
if (full_name != '') {
$("#add_artists").attr("disabled", false); $("#add_artists").attr("disabled", false);
} else { } else {
$("#add_artists").attr("disabled", true); $("#add_artists").attr("disabled", true);
......
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