Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vmusicchart-cms
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Phạm Văn Đoan
vmusicchart-cms
Commits
0403ee6f
Commit
0403ee6f
authored
Apr 12, 2020
by
Phạm Văn Đoan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cập nhật form thêm ca sĩ
parent
9828719e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
281 deletions
+51
-281
CmsTrack.php
application/controllers/backend/CmsTrack.php
+42
-17
add_singer_view.php
application/views/backend/cms_track/add_singer_view.php
+4
-260
show_track_view.php
application/views/backend/cms_track/show_track_view.php
+5
-4
No files found.
application/controllers/backend/CmsTrack.php
View file @
0403ee6f
...
...
@@ -63,7 +63,7 @@ class CmsTrack extends CI_Controller
$this
->
_data
[
'track_artists'
]
=
$track_artists
;
}
$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
//Thiết lập validate
...
...
@@ -82,7 +82,7 @@ class CmsTrack extends CI_Controller
$this
->
form_validation
->
set_message
(
'required'
,
'<li>Bắt buộc nhập, chọn.</li>'
);
$this
->
form_validation
->
set_message
(
'is_unique'
,
'<li>Đã tồn tại.</li>'
);
// Xử lý form
đăng nhập
// Xử lý form
if
(
$this
->
form_validation
->
run
(
$this
)
==
false
)
{
// $this->_data['date_limit'] = $this->input->post('name');
$this
->
_data
[
'title'
]
=
$this
->
input
->
post
(
'title'
);
...
...
@@ -108,10 +108,8 @@ class CmsTrack extends CI_Controller
$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
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
;
...
...
@@ -144,7 +142,9 @@ class CmsTrack extends CI_Controller
}
}
//Thêm bài hát mới
/**
* Thêm bài hát mới
*/
public
function
addTrack
()
{
$this
->
_data
[
'list_user'
]
=
$list_user
=
$this
->
track_model
->
getListUsers
();
...
...
@@ -179,7 +179,7 @@ class CmsTrack extends CI_Controller
$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>'
);
// Xử lý form
đăng nhập
// Xử lý form
if
(
$this
->
form_validation
->
run
(
$this
)
==
false
)
{
$this
->
_data
[
'title'
]
=
$this
->
input
->
post
(
'title'
);
$this
->
_data
[
'singer'
]
=
$this
->
input
->
post
(
'singer'
);
...
...
@@ -196,8 +196,7 @@ class CmsTrack extends CI_Controller
$this
->
_data
[
'titlePage'
]
=
'Tạo mới Bài hát'
;
$this
->
_data
[
'loadPage'
]
=
'backend/cms_track/add_track_view'
;
$this
->
load
->
view
(
'backend/admin_template_view'
,
$this
->
_data
);
}
else
{
// $username = $this->input->post('username');
}
else
{
$title
=
$this
->
input
->
post
(
'title'
);
$singer
=
$this
->
input
->
post
(
'singer'
);
$artist
=
$this
->
input
->
post
(
'artist'
);
...
...
@@ -221,7 +220,7 @@ class CmsTrack extends CI_Controller
);
$insert_id
=
$this
->
track_model
->
add
(
$dataUpdate
);
if
(
$insert_id
)
{
// Xử lý upload: avatar
// Xử lý upload: avatar
$db_art_path
=
''
;
$upload_path
=
'uploads/tracks/arts'
;
$upload_full_path
=
'/home/aseanvn/public_html/vmusicchart.dcv.vn/'
.
$upload_path
;
...
...
@@ -253,6 +252,11 @@ class CmsTrack extends CI_Controller
}
}
/**
* Hàm xử lý thêm ca sĩ cho bài hát
*
* @param $track_id
*/
public
function
addSinger
(
$track_id
)
{
$this
->
_data
[
'track'
]
=
$contest
=
$this
->
track_model
->
getById
(
$track_id
);
...
...
@@ -266,7 +270,7 @@ class CmsTrack extends CI_Controller
$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>'
);
// Xử lý form
đăng nhập
// Xử lý form
if
(
$this
->
form_validation
->
run
(
$this
)
==
false
)
{
$this
->
_data
[
'singer'
]
=
$this
->
input
->
post
(
'singer'
);
...
...
@@ -286,7 +290,12 @@ class CmsTrack extends CI_Controller
}
}
/**
* Xem chi tiết bài hát
*
* @param $track_id
*/
public
function
showTrack
(
$track_id
)
{
$this
->
_data
[
'track'
]
=
$this
->
track_model
->
getById
(
$track_id
);
...
...
@@ -298,7 +307,12 @@ class CmsTrack extends CI_Controller
$this
->
load
->
view
(
'backend/admin_template_view'
,
$this
->
_data
);
}
// Tên bài hát tồn tại hay chưa
/**
* Tên bài hát tồn tại hay chưa
*
* @param $title
* @return bool
*/
public
function
check_title
(
$title
)
{
if
(
$this
->
input
->
post
(
'id'
))
{
...
...
@@ -312,21 +326,31 @@ class CmsTrack extends CI_Controller
$this
->
form_validation
->
set_message
(
'check_title'
,
'<li class="list-unstyled">Bài hát đã tồn tại.</li>'
);
return
false
;
}
else
{
return
TRUE
;
return
true
;
}
}
// kiểm tra đã chọn ca sĩ/nhạc sĩ
/**
* Kiểm tra đã chọn ca sĩ/nhạc sĩ
*
* @param $value
* @return bool
*/
public
function
check_default
(
$value
)
{
if
(
$value
==
'0'
)
{
$this
->
form_validation
->
set_message
(
'check_default'
,
'<li class="list-unstyled">Vui lòng chọn ca sĩ hoặc sáng tác.</li>'
);
return
false
;
}
else
return
TRUE
;
return
true
;
}
// kiểm tra id_nct khác null
/**
* Kiểm tra id_nct khác null
*
* @param $nct_id
* @return bool
*/
public
function
check_nct_id
(
$nct_id
)
{
$source
=
$this
->
input
->
post
(
'source'
);
...
...
@@ -334,7 +358,7 @@ class CmsTrack extends CI_Controller
$this
->
form_validation
->
set_message
(
'check_nct_id'
,
'<li class="list-unstyled">Vui lòng nhập ID bài hát trên NCT.</li>'
);
return
false
;
}
else
return
TRUE
;
return
true
;
}
}
\ No newline at end of file
application/views/backend/cms_track/add_singer_view.php
View file @
0403ee6f
<?php
?>
<div
class=
"row"
>
<div
class=
"widget-box"
>
<div
class=
"widget-header"
>
<p
class=
"widget-title"
>
Cập nhật thông tin
bài hát
</p>
<p
class=
"widget-title"
>
Cập nhật thông tin
Ca sĩ
</p>
</div>
<div
class=
"widget-body"
>
<div
class=
"widget-main"
>
...
...
@@ -28,14 +25,14 @@
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-lg-3"
>
Thêm Tê
n Ca sĩ
</label>
<label
class=
"col-lg-3"
>
Chọ
n Ca sĩ
</label>
<div
class=
"col-lg-3"
>
<select
id=
'form-field-select-3'
name=
"singer"
style=
'width: 200px;'
class=
"chosen-select form-control"
data-placeholder=
"Choose a State..."
>
<option
value=
"0"
>
Chọn ca sĩ
</option>
<option
value=
"0"
>
- Chọn -
</option>
<?php
foreach
(
$list_user
as
$singers
)
:
?>
<option
value=
"
<?php
echo
$singers
[
'id'
];
?>
"
<?php
if
(
$singer
&&
$singer
==
$singers
[
'id'
]){
echo
'selected="selected"'
;
}
else
echo
''
;
?>
>
<?php
if
(
$singer
&&
$singer
==
$singers
[
'id'
]){
echo
'selected="selected"'
;
}
else
echo
''
;
?>
>
<?php
echo
$singers
[
'full_name'
];
?>
</option>
<?php
endforeach
;
?>
...
...
@@ -67,258 +64,6 @@
</div>
<?php
echo
form_close
();
?>
</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 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"
>
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
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
class=
"form-group"
>
<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
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
class=
"form-group"
>
<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
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
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 -->
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.chosen-select'
).
chosen
({
allow_single_deselect
:
true
,
no_results_text
:
"Không có kết quả cần tìm"
});
$
(
window
)
.
off
(
'resize.chosen'
)
.
on
(
'resize.chosen'
,
function
()
{
$
(
'.chosen-select'
).
each
(
function
()
{
var
$this
=
$
(
this
);
$this
.
next
().
css
({
'width'
:
$this
.
parent
().
width
()
});
})
}).
trigger
(
'resize.chosen'
);
//resize chosen on sidebar collapse/expand
$
(
document
).
on
(
'settings.ace.chosen'
,
function
(
e
,
event_name
,
event_val
)
{
if
(
event_name
!=
'sidebar_collapsed'
)
return
;
$
(
'.chosen-select'
).
each
(
function
()
{
var
$this
=
$
(
this
);
$this
.
next
().
css
({
'width'
:
$this
.
parent
().
width
()
});
})
});
//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
();
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_full_name'
])
{
$
(
'#err'
).
append
(
data
[
'check_full_name'
]);
$
(
'#err-full-name'
).
addClass
(
'has-error'
);
}
else
$
(
'#err-full-name'
).
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>
\ No newline at end of file
application/views/backend/cms_track/show_track_view.php
View file @
0403ee6f
...
...
@@ -22,11 +22,12 @@
<?php
endif
;
?>
<?php
if
(
isset
(
$track
[
0
]))
:
?>
<div
class=
"row"
>
<div
class=
"col-lg-2"
>
<div
class=
"col-lg-
1
2"
>
<a
class=
"btn btn-sm btn-success"
href=
"
<?php
echo
base_url
(
'backend/cmsTrack/addSinger/'
.
$track
[
0
][
'id'
]);
?>
"
>
<i
class=
"glyphicon-plus"
>
Thêm ca sĩ
</i>
<i
class=
"glyphicon-plus"
></i>
Thêm Ca sĩ
</a>
<a
class=
"btn btn-sm btn-primary"
href=
"
<?php
echo
base_url
(
'backend/cmsTrack/addComposer/'
.
$track
[
0
][
'id'
]);
?>
"
>
<i
class=
"glyphicon-plus"
></i>
Thêm Nhạc sĩ / Sáng tác
</a>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment