Commit a5cfe777 by Trần Văn Minh

Chỉnh lại form thêm mới nghệ sĩ. Thêm add nghệ sĩ khi select nghệ sĩ chưa có

parent bf301bc9
...@@ -42,6 +42,9 @@ ...@@ -42,6 +42,9 @@
</select> </select>
<?php if(validation_errors()){echo form_error('singer', '<div class="error">', '</div>');} ?> <?php if(validation_errors()){echo form_error('singer', '<div class="error">', '</div>');} ?>
</div> </div>
<div id="add_composer" style="display: none;">
<a href="#myModal" role="button" class="btn btn-success" data-toggle="modal">Thêm nghệ sĩ</a>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
...@@ -67,6 +70,106 @@ ...@@ -67,6 +70,106 @@
</div> </div>
</div> </div>
<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Thêm mới Ca sĩ/Nhạc sĩ</h3>
</div>
<div class="modal-body">
<div class="row">
<div class="widget-box">
<div class="widget-body">
<div class="widget-main">
<form id="form_add_artist" method="POST" class="form-horizontal">
<span id="err" class="text-danger"></span>
<div class="form-group">
<label class="col-lg-3"></label>
<div class="col-lg-3">
<input type="hidden" name="id" value="" />
</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">
<label class="col-lg-3"></label>
<label class="col-lg-3">Tên đầu đủ (*)</label>
<div class="col-lg-3">
<input type="text" name="full_name" value="" class="form-control"
style="width:100%;" placeholder="Nhập họ tên đầy đủ" />
</div>
</div>
<div class="form-group">
<label class="col-lg-3"></label>
<label class="col-lg-3">Link Zingmp3</label>
<div class="col-lg-3">
<input type="text" name="link_zing" value="" class="form-control"
style="width:100%;" placeholder="Nhập link ZingMp3" />
</div>
</div>
<div class="form-group">
<label class="col-lg-3"></label>
<label class="col-lg-3">Link Nhạc của tui</label>
<div class="col-lg-3">
<input type="text" name="link_nct" value="" class="form-control"
style="width:100%;" placeholder="Nhập link NCT" />
</div>
</div>
<div class="form-group">
<label class="col-lg-3"></label>
<label class="col-lg-3">Link Keeng</label>
<div class="col-lg-3">
<input type="text" name="link_keeng" value="" class="form-control"
style="width:100%;" placeholder="Nhập Link Keeng" />
</div>
</div>
<div class="form-group">
<label class="col-lg-3"></label>
<div class="col-lg-3">
<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?')">
<button type="button" class="btn btn-sm btn-default">
<i class="ace-icon fa fa-arrow-left"></i>Quay lại
</button>
</a>
</div>
<div class="col-lg-4">
<button class="btn btn-sm btn-primary" id="add_artists" name="btnSave">
<i class="ace-icon fa fa-check bigger-110"></i>Lưu lại
</button>
<button class="btn btn-sm" type="reset">
<i class="ace-icon fa fa-undo bigger-110"></i>Xóa form
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div><!-- /.row --> </div><!-- /.row -->
<script> <script>
$(document).ready(function() { $(document).ready(function() {
...@@ -94,5 +197,147 @@ $(document).ready(function() { ...@@ -94,5 +197,147 @@ $(document).ready(function() {
}); });
}) })
}); });
//Hiển thị nút thêm mới nghệ sĩ
$('#add_composer').hide();
$('.chosen-single').click(function() {
$('#add_composer').hide();
var count = 0;
var count1 = 0;
$('.chosen-with-drop .chosen-drop .chosen-search input').keyup(function() {
count = $(".chosen-with-drop .chosen-drop .no-results").size();
count1 = $(".chosen-with-drop .chosen-drop .active-result").size();
var keywork1 = $('.chosen-with-drop .chosen-drop .chosen-search input').val();
if (count1 > 0 && keywork1 != '') {
if (count == 1) {
$('#add_composer').hide();
} else if (count == 0) {
$('#add_composer').hide();
}
} else {
if(count == 1) {
$('#add_composer').show();
} else if(count == 0) {
$('#add_composer').hide();
}
}
});
});
}); });
var url = '<?php echo base_url().'backend/cmsArtist/addArtistAjax'; ?>';
//Thêm mới nghệ sĩ
$('#add_artists').click(function(e) {
$('#err').empty();
e.preventDefault();
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('link_zing', $("input[name='link_zing']").val());
formData.append('link_nct', $("input[name='link_nct']").val());
formData.append('link_keeng', $("input[name='link_keeng']").val());
$.ajax({
url: url,
type: 'POST',
data: formData,
dataType: 'json',
processData: false,
contentType: false,
success: function(data) {
if (data['check_username']) {
$('#err').append(data['check_username']);
$('#err-username').addClass('has-error');
} else
$('#err-username').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']){
$("#form_add_artist").trigger("reset");
alert('Tạo nghệ sĩ thành công!');
location.reload(true);
$('#myModal').modal('hide');
}
}
});
});
// validation
$('#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(){
if ($("input[name='full_name']").val() == '') {
$('#err').append('Vui lòng nhập họ tên');
$('.err-full-name').addClass('has-error');
} else {
$('#err').empty();
$('.err-full-name').removeClass('has-error');
$('.err-full-name').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);
});
});
// validation
function validation(username, email, full_name) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var email_vali = regex.test(email);
if (full_name != '' && email_vali == true && username != '') {
$("#add_artists").attr("disabled", false);
} else {
$("#add_artists").attr("disabled", true);
}
}
function show_src_option(status) {
if (status == 'nct') {
$('#nct_id').show();
} else
$('#nct_id').hide();
}
</script> </script>
\ No newline at end of file
...@@ -174,7 +174,7 @@ $check = "checked => 1"; ...@@ -174,7 +174,7 @@ $check = "checked => 1";
</select> </select>
<?php if(validation_errors()){echo form_error('artist', '<div class="error">', '</div>');} ?> <?php if(validation_errors()){echo form_error('artist', '<div class="error">', '</div>');} ?>
</div> </div>
<div id="add_composer"> <div id="add_composer" style="display: none;">
<a href="#myModal" role="button" class="btn btn-success" data-toggle="modal">Thêm nghệ sĩ</a> <a href="#myModal" role="button" class="btn btn-success" data-toggle="modal">Thêm nghệ sĩ</a>
</div> </div>
</div> </div>
...@@ -265,8 +265,8 @@ $check = "checked => 1"; ...@@ -265,8 +265,8 @@ $check = "checked => 1";
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h3 id="myModalLabel">Thêm mới Ca sĩ/Nhạc sĩ</h3>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Thêm mới Ca sĩ/Nhạc sĩ</h3>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="row"> <div class="row">
...@@ -282,6 +282,7 @@ $check = "checked => 1"; ...@@ -282,6 +282,7 @@ $check = "checked => 1";
</div> </div>
</div> </div>
<div class="form-group" id="err-username"> <div class="form-group" id="err-username">
<label class="col-lg-3"></label>
<label class="col-lg-3">Username (*)</label> <label class="col-lg-3">Username (*)</label>
<div class="col-lg-3"> <div class="col-lg-3">
<input type="text" name="username" value="" class="form-control" <input type="text" name="username" value="" class="form-control"
...@@ -290,6 +291,7 @@ $check = "checked => 1"; ...@@ -290,6 +291,7 @@ $check = "checked => 1";
<div><span name></span></div> <div><span name></span></div>
</div> </div>
<div class="form-group" id="err-email"> <div class="form-group" id="err-email">
<label class="col-lg-3"></label>
<label class="col-lg-3">Email (*)</label> <label class="col-lg-3">Email (*)</label>
<div class="col-lg-3"> <div class="col-lg-3">
<input type="email" name="email" value="" class="form-control" <input type="email" name="email" value="" class="form-control"
...@@ -297,6 +299,7 @@ $check = "checked => 1"; ...@@ -297,6 +299,7 @@ $check = "checked => 1";
</div> </div>
</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">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"
...@@ -304,6 +307,7 @@ $check = "checked => 1"; ...@@ -304,6 +307,7 @@ $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-3">
<input type="text" name="link_zing" value="" class="form-control" <input type="text" name="link_zing" value="" class="form-control"
...@@ -311,6 +315,7 @@ $check = "checked => 1"; ...@@ -311,6 +315,7 @@ $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 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"
...@@ -318,6 +323,7 @@ $check = "checked => 1"; ...@@ -318,6 +323,7 @@ $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 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"
...@@ -325,6 +331,7 @@ $check = "checked => 1"; ...@@ -325,6 +331,7 @@ $check = "checked => 1";
</div> </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?')">
......
...@@ -155,7 +155,7 @@ $input_link_keeng = array( ...@@ -155,7 +155,7 @@ $input_link_keeng = array(
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>
<div id="add_composer"> <div id="add_composer" style="display: none;">
<a href="#myModal" role="button" class="btn btn-success" data-toggle="modal">Thêm nghệ sĩ</a> <a href="#myModal" role="button" class="btn btn-success" data-toggle="modal">Thêm nghệ sĩ</a>
</div> </div>
</div> </div>
...@@ -200,8 +200,8 @@ $input_link_keeng = array( ...@@ -200,8 +200,8 @@ $input_link_keeng = array(
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h3 id="myModalLabel">Thêm mới Ca sĩ/Nhạc sĩ</h3>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<div id="myModalLabel">Thêm mới Ca sĩ/Nhạc sĩ</div>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="row"> <div class="row">
...@@ -217,6 +217,7 @@ $input_link_keeng = array( ...@@ -217,6 +217,7 @@ $input_link_keeng = array(
</div> </div>
</div> </div>
<div class="form-group" id="err-username"> <div class="form-group" id="err-username">
<label class="col-lg-3"></label>
<label class="col-lg-3">Username (*)</label> <label class="col-lg-3">Username (*)</label>
<div class="col-lg-3"> <div class="col-lg-3">
<input type="text" name="username" value="" class="form-control" <input type="text" name="username" value="" class="form-control"
...@@ -225,6 +226,7 @@ $input_link_keeng = array( ...@@ -225,6 +226,7 @@ $input_link_keeng = array(
<div><span name></span></div> <div><span name></span></div>
</div> </div>
<div class="form-group" id="err-email"> <div class="form-group" id="err-email">
<label class="col-lg-3"></label>
<label class="col-lg-3">Email (*)</label> <label class="col-lg-3">Email (*)</label>
<div class="col-lg-3"> <div class="col-lg-3">
<input type="email" name="email" value="" class="form-control" <input type="email" name="email" value="" class="form-control"
...@@ -232,6 +234,7 @@ $input_link_keeng = array( ...@@ -232,6 +234,7 @@ $input_link_keeng = array(
</div> </div>
</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">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"
...@@ -239,6 +242,7 @@ $input_link_keeng = array( ...@@ -239,6 +242,7 @@ $input_link_keeng = array(
</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"
...@@ -246,6 +250,7 @@ $input_link_keeng = array( ...@@ -246,6 +250,7 @@ $input_link_keeng = array(
</div> </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"
...@@ -253,6 +258,7 @@ $input_link_keeng = array( ...@@ -253,6 +258,7 @@ $input_link_keeng = array(
</div> </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"
...@@ -260,6 +266,7 @@ $input_link_keeng = array( ...@@ -260,6 +266,7 @@ $input_link_keeng = array(
</div> </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?')">
......
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