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
033d243d
Commit
033d243d
authored
Apr 13, 2020
by
Phạm Văn Đoan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
review code liên quan đến bài hát
parent
0403ee6f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
230 additions
and
40 deletions
+230
-40
CmsTrack.php
application/controllers/backend/CmsTrack.php
+80
-7
Track_model.php
application/models/Track_model.php
+60
-16
add_composer_view.php
application/views/backend/cms_track/add_composer_view.php
+71
-0
add_singer_view.php
application/views/backend/cms_track/add_singer_view.php
+8
-6
show_track_view.php
application/views/backend/cms_track/show_track_view.php
+11
-11
No files found.
application/controllers/backend/CmsTrack.php
View file @
033d243d
...
...
@@ -97,7 +97,6 @@ class CmsTrack extends CI_Controller
$this
->
_data
[
'loadPage'
]
=
'backend/cms_track/edit_track_view'
;
$this
->
load
->
view
(
'backend/admin_template_view'
,
$this
->
_data
);
}
else
{
$title
=
$this
->
input
->
post
(
'title'
);
$update_singer
=
$this
->
input
->
post
(
'update_singer'
);
$singer
=
(
$track_user
!=
''
)
?
$track_user
[
0
][
'user_id'
]
:
''
;
...
...
@@ -132,13 +131,15 @@ class CmsTrack extends CI_Controller
$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
);
// Ghi log
$this
->
actionlog_model
->
add
(
'UPDATED'
,
'Cập nhật bài hát.'
,
'Actionlog_model'
,
'action_log'
,
$track_id
);
$this
->
session
->
set_flashdata
(
'success'
,
'Cập nhật bài hát thành công'
);
redirect
(
base_url
(
)
.
'backend/cmsTrack/showTrack/'
.
$track_id
);
redirect
(
base_url
(
'backend/cmsTrack/showTrack/'
.
$track_id
)
);
}
}
...
...
@@ -248,7 +249,11 @@ class CmsTrack extends CI_Controller
}
else
{
$this
->
session
->
set_flashdata
(
'error'
,
'Tạo Bài hát không thành công'
);
}
redirect
(
base_url
()
.
'backend/cmsTrack/listTrack'
);
// Ghi log
$this
->
actionlog_model
->
add
(
'ADDED'
,
'Thêm mới bài hát.'
,
'Actionlog_model'
,
'action_log'
,
null
);
redirect
(
base_url
(
'backend/cmsTrack/listTrack'
));
}
}
...
...
@@ -259,6 +264,9 @@ class CmsTrack extends CI_Controller
*/
public
function
addSinger
(
$track_id
)
{
// Thêm đoạn check sự tồn tại của bài hát
//
$this
->
_data
[
'track'
]
=
$contest
=
$this
->
track_model
->
getById
(
$track_id
);
$this
->
_data
[
'list_user'
]
=
$list_user
=
$this
->
track_model
->
getListUsers
();
...
...
@@ -281,14 +289,75 @@ class CmsTrack extends CI_Controller
$this
->
load
->
view
(
'backend/admin_template_view'
,
$this
->
_data
);
}
else
{
$singer
=
$this
->
input
->
post
(
'singer'
);
$this
->
track_model
->
add_singer
(
$singer
,
$track_id
);
$this
->
session
->
set_flashdata
(
'success'
,
'Thêm ca sĩ vào bài hát thành công'
);
redirect
(
base_url
()
.
'backend/cmsTrack/showTrack/'
.
$track_id
);
// Ghi log
$this
->
actionlog_model
->
add
(
'ADDED'
,
'Thêm mới Ca sĩ cho bài hát.'
,
'Actionlog_model'
,
'action_log'
,
$track_id
);
redirect
(
base_url
(
'backend/cmsTrack/showTrack/'
.
$track_id
));
}
}
/**
* Xử lý xóa ca sĩ khỏi bài hát
*
* @param $track_id
* @param $singer_id
*/
public
function
removeSinger
(
$track_id
,
$singer_id
)
{
// Thêm đoạn check tồn tại bài hát và ca sĩ, ok thì mới gọi xóa
// Xử lý
$this
->
track_model
->
removeSinger
(
$track_id
,
$singer_id
);
// Ghi log
$this
->
actionlog_model
->
add
(
'DELETED'
,
'Xóa Ca sĩ khỏi bài hát.'
,
'Actionlog_model'
,
'action_log'
,
$track_id
);
redirect
(
base_url
(
'backend/cmsTrack/showTrack/'
.
$track_id
));
}
/**
* Hàm xử lý thêm Nhạc sĩ cho bài hát
*
* @param $track_id
*/
public
function
addComposer
(
$track_id
)
{
// Thêm đoạn check sự tồn tại của bài hát
// Xử lý
$this
->
_data
[
'track'
]
=
$contest
=
$this
->
track_model
->
getById
(
$track_id
);
$this
->
_data
[
'list_user'
]
=
$list_user
=
$this
->
track_model
->
getListUsers
();
$this
->
form_validation
->
set_rules
(
'composer'
,
'Nhạc sĩ'
,
'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
if
(
$this
->
form_validation
->
run
(
$this
)
==
false
)
{
$this
->
_data
[
'composer'
]
=
$this
->
input
->
post
(
'composer'
);
$this
->
_data
[
'functionName'
]
=
'Thêm Người thể hiện vào bài hát'
;
$this
->
_data
[
'action'
]
=
'addComposer'
;
$this
->
_data
[
'titlePage'
]
=
'Thêm Người thể hiện vào bài hát'
;
$this
->
_data
[
'loadPage'
]
=
'backend/cms_track/add_composer_view'
;
$this
->
load
->
view
(
'backend/admin_template_view'
,
$this
->
_data
);
}
else
{
$composer
=
$this
->
input
->
post
(
'composer'
);
$this
->
track_model
->
add_artist
(
$composer
,
$track_id
);
$this
->
session
->
set_flashdata
(
'success'
,
'Thêm Nhạc sĩ vào bài hát thành công'
);
// Ghi log
$this
->
actionlog_model
->
add
(
'ADDED'
,
'Thêm Nhạc sĩ cho bài hát.'
,
'Actionlog_model'
,
'action_log'
,
$track_id
);
redirect
(
base_url
(
'backend/cmsTrack/showTrack/'
.
$track_id
));
}
}
/**
...
...
@@ -298,7 +367,11 @@ class CmsTrack extends CI_Controller
*/
public
function
showTrack
(
$track_id
)
{
// Thêm đoạn check sự tồn tại của bài hát
//
$this
->
_data
[
'track'
]
=
$this
->
track_model
->
getById
(
$track_id
);
$this
->
_data
[
'singers'
]
=
$this
->
track_model
->
getSingerLítByTrackId
(
$track_id
);
//
$this
->
_data
[
'functionName'
]
=
'Thông tin Bài Hát'
;
$this
->
_data
[
'action'
]
=
'showTrack'
;
...
...
application/models/Track_model.php
View file @
033d243d
...
...
@@ -3,8 +3,8 @@
class
Track_model
extends
CI_Model
{
protected
$_table
=
'tracks'
;
protected
$track_user
=
'track_user'
;
protected
$track_artists
=
'track_artists'
;
protected
$
_table_
track_user
=
'track_user'
;
protected
$
_table_
track_artists
=
'track_artists'
;
public
function
__construct
()
{
...
...
@@ -19,30 +19,42 @@ class Track_model extends CI_Model
return
$insert_id
;
}
/**
* Xử lý thông tin ca sĩ
*
* @param $user_id
* @param $track_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
(
'user_id'
,
$user_id
);
$this
->
db
->
set
(
'track_id'
,
$track_id
);
$this
->
db
->
insert
(
$this
->
track_user
);
$this
->
db
->
insert
(
$this
->
_table_
track_user
);
}
/**
* Xử lý thông tin nhạc sĩ
*
* @param $user_id
* @param $track_id
*/
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
(
'user_id'
,
$user_id
);
$this
->
db
->
set
(
'track_id'
,
$track_id
);
$this
->
db
->
insert
(
$this
->
track_artists
);
$this
->
db
->
insert
(
$this
->
_table_
track_artists
);
}
public
function
update
(
$id
,
$dataUpdate
,
$art_path
)
...
...
@@ -65,11 +77,11 @@ class Track_model extends CI_Model
}
if
(
$active
==
'insert'
)
{
$this
->
db
->
set
(
'track_id'
,
$id_track
);
$this
->
db
->
insert
(
$this
->
track_artists
);
$this
->
db
->
insert
(
$this
->
_table_
track_artists
);
}
else
{
$this
->
db
->
where
(
'track_id'
,
$id_track
);
$this
->
db
->
where
(
'id'
,
$id
);
$this
->
db
->
update
(
$this
->
track_artists
);
$this
->
db
->
update
(
$this
->
_table_
track_artists
);
}
}
...
...
@@ -84,11 +96,11 @@ class Track_model extends CI_Model
}
if
(
$active
==
'insert'
)
{
$this
->
db
->
set
(
'track_id'
,
$id_track
);
$this
->
db
->
insert
(
$this
->
track_user
);
$this
->
db
->
insert
(
$this
->
_table_
track_user
);
}
else
{
$this
->
db
->
where
(
'track_id'
,
$id_track
);
$this
->
db
->
where
(
'id'
,
$id
);
$this
->
db
->
update
(
$this
->
track_user
);
$this
->
db
->
update
(
$this
->
_table_
track_user
);
}
}
...
...
@@ -99,13 +111,45 @@ class Track_model extends CI_Model
track_artists.name AS artist,
track_artists.id AS id_track_artist'
);
$this
->
db
->
from
(
$this
->
_table
);
$this
->
db
->
join
(
$this
->
track_user
,
'track_user.track_id = tracks.id'
,
'left'
);
$this
->
db
->
join
(
$this
->
track_artists
,
'track_artists.track_id = tracks.id'
,
'left'
);
$this
->
db
->
join
(
$this
->
_table_
track_user
,
'track_user.track_id = tracks.id'
,
'left'
);
$this
->
db
->
join
(
$this
->
_table_
track_artists
,
'track_artists.track_id = tracks.id'
,
'left'
);
$this
->
db
->
where
(
$this
->
_table
.
'.id'
,
$id
);
$query
=
$this
->
db
->
get
();
return
$query
->
result_array
();
}
/**
* Lấy ds ca sĩ theo ID của bài hát từ bảng track_user
*
* @param $id
* @return mixed
*/
public
function
getSingerLítByTrackId
(
$id
)
{
$this
->
db
->
select
(
'track_user.name AS name_singer, track_user.user_id AS id_singer'
);
$this
->
db
->
from
(
$this
->
_table_track_user
);
$this
->
db
->
join
(
'tracks'
,
'tracks.id = track_user.track_id'
,
'left'
);
$this
->
db
->
where
(
$this
->
_table_track_user
.
'.track_id'
,
$id
);
$query
=
$this
->
db
->
get
();
return
$query
->
result_array
();
}
/**
* Hàm xóa ca sĩ khỏi bài hát
*
* @param $track_id
* @param $singer_id
* @return boolean
*/
public
function
removeSinger
(
$track_id
,
$singer_id
)
{
$this
->
db
->
where
(
'track_id'
,
$track_id
);
$this
->
db
->
where
(
'user_id'
,
$singer_id
);
$this
->
db
->
delete
(
$this
->
_table_track_user
);
return
true
;
}
public
function
getByIdUser
(
$table
,
$id
)
{
if
(
$id
!=
0
)
{
$this
->
db
->
select
(
"*"
);
...
...
@@ -183,8 +227,8 @@ class Track_model extends CI_Model
track_user.name AS singer_name2, track_user.id AS id_user,
track_artists.name AS composer_name2, track_artists.id AS id_artist'
);
$this
->
db
->
from
(
$this
->
_table
);
$this
->
db
->
join
(
$this
->
track_user
,
'track_user.track_id = tracks.id'
,
'left'
);
$this
->
db
->
join
(
$this
->
track_artists
,
'track_artists.track_id = tracks.id'
,
'left'
);
$this
->
db
->
join
(
$this
->
_table_
track_user
,
'track_user.track_id = tracks.id'
,
'left'
);
$this
->
db
->
join
(
$this
->
_table_
track_artists
,
'track_artists.track_id = tracks.id'
,
'left'
);
$this
->
db
->
join
(
'users u1'
,
'u1.id = track_user.user_id'
,
'left'
);
$this
->
db
->
join
(
'users u2'
,
'u2.id = track_artists.user_id'
,
'left'
);
if
(
$name
!=
null
)
{
...
...
@@ -347,7 +391,7 @@ class Track_model extends CI_Model
//if ($query) $users = $query->result_array();
//return $users;
$this
->
db
->
from
(
$this
->
track_user
);
$this
->
db
->
from
(
$this
->
_table_
track_user
);
$this
->
db
->
where
(
'track_id ='
,
$track_id
);
$query
=
$this
->
db
->
get
();
...
...
@@ -359,7 +403,7 @@ class Track_model extends CI_Model
//if ($query) $users = $query->result_array();
//return $users;
$this
->
db
->
from
(
$this
->
track_artists
);
$this
->
db
->
from
(
$this
->
_table_
track_artists
);
$this
->
db
->
where
(
'track_id ='
,
$track_id
);
$query
=
$this
->
db
->
get
();
...
...
application/views/backend/cms_track/add_composer_view.php
0 → 100644
View file @
033d243d
<div
class=
"row"
>
<div
class=
"widget-box"
>
<div
class=
"widget-header"
>
<p
class=
"widget-title"
>
Cập nhật thông tin Nhạc sĩ
</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/addComposer/'
.
$track
[
0
][
'id'
]),
$attributes
);
?>
<div
class=
"form-group"
>
<label
class=
"col-lg-3"
></label>
<div
class=
"col-lg-3"
>
<input
type=
"hidden"
name=
"id"
value=
"
<?php
echo
$track
[
0
][
'id'
];
?>
"
/>
<?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"
>
<p>
<?php
echo
$track
[
0
][
'title'
];
?>
</p>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-lg-3"
>
Chọn Nhạc sĩ
</label>
<div
class=
"col-lg-3"
>
<select
id=
'form-field-select-3'
name=
"composer"
style=
'width: 200px;'
class=
"chosen-select form-control"
data-placeholder=
"Choose a State..."
>
<option
value=
"0"
>
- Chọn -
</option>
<?php
foreach
(
$list_user
as
$composers
)
:
?>
<option
value=
"
<?php
echo
$composers
[
'id'
];
?>
"
<?php
if
(
$composer
&&
$composer
==
$composers
[
'id'
]){
echo
'selected="selected"'
;
}
else
echo
''
;
?>
>
<?php
echo
$composers
[
'full_name'
];
?>
</option>
<?php
endforeach
;
?>
</select>
<?php
if
(
validation_errors
()){
echo
form_error
(
'composer'
,
'<div class="error">'
,
'</div>'
);}
?>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"col-lg-3"
>
<a
href=
"
<?php
echo
base_url
(
'backend/cmsTrack/showTrack/'
.
$track
[
0
][
'id'
]);
?>
"
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>
</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>
</div>
</div>
<?php
echo
form_close
();
?>
</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"
});
});
</script>
application/views/backend/cms_track/add_singer_view.php
View file @
033d243d
...
...
@@ -39,9 +39,6 @@
</select>
<?php
if
(
validation_errors
()){
echo
form_error
(
'singer'
,
'<div class="error">'
,
'</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
class=
"form-group"
>
...
...
@@ -57,9 +54,6 @@
<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
();
?>
...
...
@@ -67,3 +61,11 @@
</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"
});
});
</script>
application/views/backend/cms_track/show_track_view.php
View file @
033d243d
...
...
@@ -24,10 +24,10 @@
<div
class=
"row"
>
<div
class=
"col-lg-12"
>
<a
class=
"btn btn-sm btn-success"
href=
"
<?php
echo
base_url
(
'backend/cmsTrack/addSinger/'
.
$track
[
0
][
'id'
]);
?>
"
>
<i
class=
"glyphicon-plus"
></i>
Thêm
Ca sĩ
<i
class=
"glyphicon-plus"
></i>
Cập nhật
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
<i
class=
"glyphicon-plus"
></i>
Cập nhật Nhạc sĩ
</a>
</div>
</div>
...
...
@@ -68,24 +68,24 @@
<div
class=
"profile-info-row"
>
<div
class=
"profile-info-name"
>
Số người biểu diễn
</div>
<div
class=
"profile-info-value"
>
<span>
<?php
echo
count
(
$
track
);
?>
</span>
<span>
<?php
echo
count
(
$
singers
);
?>
</span>
</div>
</div>
<div
class=
"profile-info-row"
>
<div
class=
"profile-info-name"
>
Biểu diễn
</div>
<div
class=
"profile-info-value"
>
<?php
if
(
count
(
$
track
)
>
0
)
:
foreach
(
$track
as
$key
=>
$tracks
)
:
?>
<
div
style=
"
<?php
if
(
count
(
$track
)
>
1
)
:
echo
'width: 50%; float:left; text-align: left;'
;
endif
;
if
(
count
(
$track
)
-
1
>
$key
)
:
echo
'border-right: solid #dddddd 2px;'
;
endif
;
?>
"
>
<?php
echo
$
tracks
[
'name_singer'
];
?>
<a
href=
"
<?php
echo
base_url
(
'backend/cmsTrack/
editTrack/'
.
$track
[
0
][
'id'
]
.
'/'
.
$tracks
[
'id_singer'
]
.
'/'
.
$tracks
[
'id_track_artist
'
]);
?>
"
title=
"Click để
thay đổi c
a sĩ"
>
<i
class=
"ace-icon fa fa-
pencil-square-o
bigger-150"
style=
"color: red;"
></i>
<?php
if
(
count
(
$
singers
)
>
0
)
:
?>
<
?php
foreach
(
$singers
as
$key
=>
$singer
)
:
?>
<div
style=
"
<?php
if
(
count
(
$track
)
>
1
)
:
echo
'width: 50%; float:left; text-align: left;'
;
endif
;
if
(
count
(
$track
)
-
1
>
$key
)
:
echo
'border-right: solid #dddddd 2px;'
;
endif
;
?>
"
>
<?php
echo
$
singer
[
'name_singer'
];
?>
<a
href=
"
<?php
echo
base_url
(
'backend/cmsTrack/
removeSinger/'
.
$track
[
0
][
'id'
]
.
'/'
.
$singer
[
'id_singer
'
]);
?>
"
title=
"Click để
xóa C
a sĩ"
>
<i
class=
"ace-icon fa fa-
trash
bigger-150"
style=
"color: red;"
></i>
</a>
</div>
<?php
endforeach
;
?>
<?php
else
:
echo
'<span class="text-danger">Chưa có
</span
>'
;
?>
<?php
else
:
echo
'<span class="text-danger">Chưa có
, cập nhật </span> <a href="'
.
base_url
(
'backend/cmsTrack/addSinger/'
.
$track
[
0
][
'id'
])
.
'">tại đây.</a
>'
;
?>
<?php
endif
?>
</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