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
9f239279
Commit
9f239279
authored
Mar 12, 2020
by
Trần Văn Minh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tạo mới bài hát
parent
2a14e835
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
305 additions
and
2 deletions
+305
-2
CmsTrack.php
application/controllers/backend/CmsTrack.php
+118
-1
Track_model.php
application/models/Track_model.php
+38
-0
add_track_view.php
application/views/backend/cms_track/add_track_view.php
+137
-0
edit_track_view.php
application/views/backend/cms_track/edit_track_view.php
+1
-1
list_track_view.php
application/views/backend/cms_track/list_track_view.php
+3
-0
show_track_view.php
application/views/backend/cms_track/show_track_view.php
+8
-0
No files found.
application/controllers/backend/CmsTrack.php
View file @
9f239279
...
...
@@ -129,11 +129,102 @@ class CmsTrack extends CI_Controller
$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'
,
'
Cập nhật
bài hát thành công'
);
$this
->
session
->
set_flashdata
(
'success'
,
'
Tạo
bài hát thành công'
);
redirect
(
base_url
()
.
'backend/cmsTrack/showTrack/'
.
$track_id
);
}
}
public
function
addTrack
()
{
$this
->
_data
[
'list_user'
]
=
$list_user
=
$this
->
track_model
->
getListUsers
();
// Thiết lập validate
$this
->
form_validation
->
set_rules
(
'id'
,
'ID'
,
'trim'
);
$this
->
form_validation
->
set_rules
(
'title'
,
'Tên bài hát'
,
'trim|required|callback_check_title|xss_clean'
);
$this
->
form_validation
->
set_rules
(
'singer'
,
'Ca sĩ'
,
'trim|required|callback_check_default|xss_clean'
);
$this
->
form_validation
->
set_rules
(
'artist'
,
'Sáng tác'
,
'trim|required|callback_check_default|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
(
'is_unique'
,
'<li class="list-unstyled">Đã tồn tại.</li>'
);
// Xử lý form đăng nhập
if
(
$this
->
form_validation
->
run
(
$this
)
==
false
)
{
$this
->
_data
[
'title'
]
=
$this
->
input
->
post
(
'title'
);
$this
->
_data
[
'singer'
]
=
$this
->
input
->
post
(
'singer'
);
$this
->
_data
[
'artist'
]
=
$this
->
input
->
post
(
'artist'
);
$this
->
_data
[
'img'
]
=
$this
->
input
->
post
(
'image_path'
);
//
$this
->
_data
[
'functionName'
]
=
'Tạo mới Bài hát'
;
$this
->
_data
[
'action'
]
=
'addTrack'
;
$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');
$title
=
$this
->
input
->
post
(
'title'
);
$singer
=
$this
->
input
->
post
(
'singer'
);
$artist
=
$this
->
input
->
post
(
'artist'
);
if
(
$title
){
$dataUpdate
=
array
(
'title'
=>
$title
,
'userid'
=>
$artist
,
// 'art' => $db_art_path,
'tag'
=>
'vmusic'
,
'genre'
=>
1
,
'time'
=>
time
()
);
// print_r($dataUpdate);
$insert_id
=
$this
->
track_model
->
add
(
$dataUpdate
);
if
(
$insert_id
)
{
// 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
(
$insert_id
.
time
());
$config
[
'allowed_types'
]
=
'gif|jpg|png'
;
$config
[
'max_size'
]
=
20480
;
$config
[
'max_width'
]
=
1024
;
$config
[
'max_height'
]
=
768
;
$this
->
load
->
library
(
'upload'
,
$config
);
if
(
$this
->
upload
->
do_upload
(
'avatar'
))
{
$upload_data
=
$this
->
upload
->
data
();
$db_art_path
=
$upload_path
.
'/'
.
$upload_data
[
'file_name'
];
}
$this
->
track_model
->
update
(
$insert_id
,
$title
,
$db_art_path
);
$this
->
track_model
->
add_singer
(
$singer
,
$insert_id
);
$this
->
track_model
->
add_artist
(
$artist
,
$insert_id
);
}
// Ghi log
// $this->mactionlog->add('UPDATED', 'Cập nhật Cuộc đua thành công!', 'Mactionlog', 'action_log', $contest_id);
//
$this
->
session
->
set_flashdata
(
'success'
,
'Tạo Bài hát thành công'
);
}
else
{
$this
->
session
->
set_flashdata
(
'error'
,
'Tạo Bài hát không thành công'
);
}
redirect
(
base_url
()
.
'backend/cmsTrack/listTrack'
);
}
}
public
function
showTrack
(
$track_id
)
{
$this
->
_data
[
'track'
]
=
$this
->
track_model
->
getById
(
$track_id
);
...
...
@@ -145,4 +236,29 @@ class CmsTrack extends CI_Controller
$this
->
load
->
view
(
'backend/admin_template_view'
,
$this
->
_data
);
}
public
function
check_title
(
$title
)
{
if
(
$this
->
input
->
post
(
'id'
))
{
$id
=
$this
->
input
->
post
(
'id'
);
}
else
{
$id
=
''
;
}
$result
=
$this
->
track_model
->
getByTitle
(
$title
,
$id
);
if
(
$result
)
{
$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
;
}
}
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
;
}
}
\ No newline at end of file
application/models/Track_model.php
View file @
9f239279
...
...
@@ -17,6 +17,32 @@ class Track_model extends CI_Model
return
$insert_id
;
}
public
function
add_singer
(
$user_id
,
$track_id
)
{
$this
->
db
->
select
(
'full_name'
);
$this
->
db
->
where
(
'id'
,
$user_id
);
$query
=
$this
->
db
->
get
(
'users'
)
->
result_array
();
$this
->
db
->
set
(
'user_id'
,
$user_id
);
if
(
$query
)
{
$this
->
db
->
set
(
'name'
,
$query
[
0
][
'full_name'
]);
}
$this
->
db
->
set
(
'track_id'
,
$track_id
);
$this
->
db
->
insert
(
'track_user'
);
}
public
function
add_artist
(
$user_id
,
$track_id
)
{
$this
->
db
->
select
(
'full_name'
);
$this
->
db
->
where
(
'id'
,
$user_id
);
$query
=
$this
->
db
->
get
(
'users'
)
->
result_array
();
$this
->
db
->
set
(
'user_id'
,
$user_id
);
if
(
$query
)
{
$this
->
db
->
set
(
'name'
,
$query
[
0
][
'full_name'
]);
}
$this
->
db
->
set
(
'track_id'
,
$track_id
);
$this
->
db
->
insert
(
'track_artists'
);
}
public
function
update
(
$id
,
$dataUpdate
,
$art_path
)
{
$this
->
db
->
set
(
'title'
,
$dataUpdate
);
...
...
@@ -241,6 +267,18 @@ class Track_model extends CI_Model
return
$query
->
result_array
();
}
public
function
getByTitle
(
$title
,
$id
)
{
$this
->
db
->
select
(
$this
->
_table
.
'.*'
);
$this
->
db
->
from
(
$this
->
_table
);
$this
->
db
->
where
(
$this
->
_table
.
'.title'
,
$title
);
if
(
$id
)
{
$this
->
db
->
where_not_in
(
'id'
,
$id
);
}
$this
->
db
->
limit
(
1
);
$query
=
$this
->
db
->
get
();
return
$query
->
result_array
();
}
}
/* End of file welcome.php */
...
...
application/views/backend/cms_track/add_track_view.php
0 → 100644
View file @
9f239279
<?php
$input_title
=
array
(
'name'
=>
'title'
,
'type'
=>
'text'
,
'value'
=>
isset
(
$title
)
?
$title
:
''
,
'placeholder'
=>
''
,
'class'
=>
''
,
'style'
=>
'width: 100%'
,
'min'
=>
1
,
'max'
=>
50
);
?>
<div
class=
"row"
>
<div
class=
"widget-box"
>
<div
class=
"widget-header"
>
<p
class=
"widget-title"
>
Thêm mới bài hát
</p>
</div>
<div
class=
"widget-body"
>
<div
class=
"widget-main"
>
<?php
$attributes
=
array
(
'class'
=>
'form-horizontal'
,
'id'
=>
'myform'
);
echo
form_open_multipart
(
base_url
(
'backend/cmsTrack/addTrack'
),
$attributes
);
?>
<div
class=
"form-group"
>
<label
class=
"col-lg-3"
></label>
<div
class=
"col-lg-3"
>
<input
type=
"hidden"
name=
"id"
value=
""
/>
<?php
if
(
validation_errors
()){
echo
form_error
(
'id'
,
'<div class="error">'
,
'</div>'
);}
?>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-lg-3"
>
Tên bài hát (*)
</label>
<div
class=
"col-lg-3"
>
<?php
echo
form_input
(
$input_title
);
if
(
validation_errors
()){
echo
form_error
(
'title'
,
'<div class="error">'
,
'</div>'
);}
?>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-lg-3"
>
Tê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..."
>
<?php
if
(
!
$singer
)
:?>
<
option
value
=
"0"
>
Chọn
ca
sĩ
</
option
>
<?
php
endif
;
?>
<?php
foreach
(
$list_user
as
$singers
)
:
?>
<option
value=
"
<?php
echo
$singers
[
'id'
];
?>
"
<?php
if
(
$singer
&&
$singer
==
$singers
[
'id'
]){
echo
'selected="selected"'
;}
else
echo
''
;
?>
>
<?php
echo
$singers
[
'full_name'
];
?>
</option>
<?php
endforeach
;
?>
</select>
<?php
if
(
validation_errors
()){
echo
form_error
(
'singer'
,
'<div class="error">'
,
'</div>'
);}
?>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-lg-3"
>
Tên Người sáng tác (*)
</label>
<div
class=
"col-lg-3"
>
<select
id=
'form-field-select-3'
name=
"artist"
style=
'width: 200px;'
class=
"chosen-select form-control"
data-placeholder=
"Choose a State..."
>
<option
value=
"0"
>
Chọn người sáng tác
</option>
<?php
foreach
(
$list_user
as
$artists
)
:
?>
<option
value=
"
<?php
echo
$artists
[
'id'
];
?>
"
<?php
if
(
$artist
&&
$artist
==
$artists
[
'id'
]){
echo
'selected="selected"'
;}
else
echo
''
;
?>
>
<?php
echo
$artists
[
'full_name'
];
?>
</option>
<?php
endforeach
;
?>
</select>
<?php
if
(
validation_errors
()){
echo
form_error
(
'artist'
,
'<div class="error">'
,
'</div>'
);}
?>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-lg-3"
>
Ảnh nhạc sĩ
</label>
<div
class=
"col-lg-3"
>
<input
type=
"file"
name=
"avatar"
size=
"20"
/>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"col-lg-3"
>
<a
href=
"
<?php
echo
base_url
(
'backend/cmsTrack/listTrack'
);
?>
"
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"
type=
"submit"
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>
<?php
echo
form_close
();
?>
<p
class=
"text-danger"
>
Chú ý: Có thể cập nhật lại ca sĩ hoặc nhạc sĩ.
</p>
</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
()
});
})
});
});
</script>
\ No newline at end of file
application/views/backend/cms_track/edit_track_view.php
View file @
9f239279
...
...
@@ -117,7 +117,7 @@ $input_artist = array(
<div
class=
"form-group"
>
<div
class=
"col-lg-3"
>
<a
href=
"
<?php
echo
base_url
(
'backend/cmsTrack/showTrack/'
.
$contest
[
0
][
'id'
]);
?>
"
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
trang chi tiết
không?')"
>
<button
type=
"button"
class=
"btn btn-sm btn-default"
>
<i
class=
"ace-icon fa fa-arrow-left"
></i>
Quay lại
</button>
...
...
application/views/backend/cms_track/list_track_view.php
View file @
9f239279
...
...
@@ -34,6 +34,9 @@
<button
class=
"btn btn-sm btn-default"
id=
"delete-filter"
>
Xóa bộ lọc
</button>
</div>
<?php
echo
form_close
();
?>
<div
class=
"col-lg-1"
style=
"float:right;"
>
<a
class=
"btn btn-sm btn-success"
href=
"
<?php
echo
base_url
(
'backend/cmsTrack/addTrack'
);
?>
"
><i
class=
"glyphicon-plus"
>
Thêm
</i></a>
</div>
</div>
<!-- /.row -->
<div
class=
"space-6"
></div>
...
...
application/views/backend/cms_track/show_track_view.php
View file @
9f239279
...
...
@@ -80,6 +80,14 @@
</div>
</div>
</div>
<div
class=
"col-lg-3"
>
<a
href=
"
<?php
echo
base_url
(
'backend/cmsTrack/listTrack'
);
?>
"
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>
<?php
else
:
?>
<p>
Không tìm thấy thông tin Người chơi!
</p>
...
...
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