1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 25/12/2015
* Time: 2:22 CH
*/
if (!defined('BASEPATH')) exit('No direct script access allowed');
class CmsVheartbeatlive extends CI_Controller
{
public function __construct()
{
parent::__construct();
date_default_timezone_set("Asia/Ho_Chi_Minh");
//
$this->load->model('vheartbeat_live_model');
$this->load->model('actionlog_model');
}
public function listVheartbeatlive()
{
$this->_data['functionName'] = 'Mã nhúng V Heartbeat Live';
$this->_data['action'] = __FUNCTION__;
$this->_data['titlePage'] = 'Nghệ sĩ';
$this->_data['loadPage'] = 'backend/cms_vheartbeatlive/list_vheartbeatlive_view';
$this->load->view('backend/admin_template_view', $this->_data);
}
public function listVheartbeatliveAjax()
{
$data = array();
$fByName = $this->input->post('fByName');
$pageId = $this->input->post('pageId');
//
$pageId = ($pageId == 0) ? 1 : $pageId;
//
$limit = 25;
$offset = ($pageId - 1) * $limit;
$data['offset'] = ($pageId - 1) * $limit;
$totalRecord = $this->vheartbeat_live_model->countAll($fByName);
$data['pagination'] = MyHelper::genPaginationLink($totalRecord, $limit, $pageId);
$data['listData'] = $this->vheartbeat_live_model->getPagination($limit, $offset, $fByName);
//
$this->load->view('backend/ajax/cms_vheartbeatlive/list_vheartbeatlive_view', $data);
}
public function editArtist($user_id)
{
$this->_data['contest'] = $contest = $this->user_model->getById($user_id);
// Kiểm tra trùng giá trị nếu thay đổi ở form
// Thiết lập validate
$this->form_validation->set_rules(
'id',
'ID',
'trim'
);
$this->form_validation->set_rules(
'full_name',
'text',
'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('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['full_name'] = $this->input->post('full_name');
$this->_data['link_zing'] = $this->input->post('link_zing');
$this->_data['link_nct'] = $this->input->post('link_nct');
$this->_data['link_keeng'] = $this->input->post('link_keeng');
//
$this->_data['functionName'] = 'Cập nhật thông tin Ca sĩ/Nghệ sĩ';
$this->_data['action'] = 'editArtist';
$this->_data['titlePage'] = 'Cập nhật thông tin Ca sĩ/Nghệ sĩ';
$this->_data['loadPage'] = 'backend/cms_artist/edit_artist_view';
$this->load->view('backend/admin_template_view', $this->_data);
}else{
$full_name = $this->input->post('full_name');
$link_zing = $this->input->post('link_zing');
$link_nct = $this->input->post('link_nct');
$link_keeng = $this->input->post('link_keeng');
if( $full_name){
$dataUpdate = array(
'user_type' => 2,
'full_name' => $full_name,
'link' => $link_zing,
'link_nct' => $link_nct,
'link_keeng' => $link_keeng
);
$this->user_model->update($user_id, $dataUpdate);
// 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', 'Cập nhật Nghệ sĩ thành công');
}else{
$this->session->set_flashdata('error', 'Cập nhật Nghệ sĩ không thành công');
}
redirect(base_url().'backend/cmsArtist/listVheartbeatlive');
}
}
public function addVheartbeatlive()
{
// Thiết lập validate
$this->form_validation->set_rules('id', 'ID', 'trim');
$this->form_validation->set_rules('title', 'Tiêu đề', 'trim|required|xss_clean');
$this->form_validation->set_rules('embed_code', 'Mã nhúng', 'trim|required');
$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['embed_code'] = $this->input->post('embed_code', false);
//
$this->_data['functionName'] = 'Thêm mới mã nhúng V Heartbeat Live';
$this->_data['action'] = 'addArtist';
$this->_data['titlePage'] = 'Thêm mới mã nhúng V Heartbeat Live';
$this->_data['loadPage'] = 'backend/cms_vheartbeatlive/add_vheartbeatlive_view';
$this->load->view('backend/admin_template_view', $this->_data);
}else{
$title = $this->input->post('title');
$embed_code = $this->input->post('embed_code');
if($title && $embed_code){
$data_insert = array(
'title' => $title,
'embed_code' => $embed_code,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
);
$insert_id = $this->vheartbeat_live_model->add($data_insert);
// Ghi log
$this->actionlog_model->add('ADDED', 'Thêm mới mã nhúng thành công!', 'Actionlog_model', 'action_log', $insert_id);
//
$this->session->set_flashdata('success', 'Thêm mới mã nhúng thành công');
}else{
$this->session->set_flashdata('error', 'Thêm mới mã nhúng không thành công');
}
redirect(base_url().'backend/cmsVheartbeatlive/listVheartbeatlive');
}
}
public function editVheartbeatlive($id)
{
$this->_data['vlive'] = $vlive = $this->vheartbeat_live_model->getById($id);
if (is_numeric($id) && isset($vlive[0])) {
// Thiết lập validate
$this->form_validation->set_rules('id', 'ID', 'trim');
$this->form_validation->set_rules('title', 'Tiêu đề', 'trim|required|xss_clean');
$this->form_validation->set_rules('embed_code', 'Mã nhúng', 'trim|required');
$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['embed_code'] = $this->input->post('embed_code', false);
//
$this->_data['functionName'] = 'Cập nhật mã nhúng V Heartbeat Live';
$this->_data['action'] = 'addArtist';
$this->_data['titlePage'] = 'Cập nhật mã nhúng V Heartbeat Live';
$this->_data['loadPage'] = 'backend/cms_vheartbeatlive/edit_vheartbeatlive_view';
$this->load->view('backend/admin_template_view', $this->_data);
}else{
$title = $this->input->post('title');
$embed_code = $this->input->post('embed_code');
if($title && $embed_code){
$data_update = array(
'title' => $title,
'embed_code' => $embed_code,
'updated_at' => date('Y-m-d H:i:s')
);
$this->vheartbeat_live_model->update($id, $data_update);
// Ghi log
$this->actionlog_model->add('UPDATED', 'Cập nhật mã nhúng thành công!', 'Actionlog_model', 'action_log', $id);
//
$this->session->set_flashdata('success', 'Cập nhật mã nhúng thành công.');
}else{
$this->session->set_flashdata('error', 'Cập nhật mã nhúng không thành công.');
}
redirect(base_url().'backend/cmsVheartbeatlive/listVheartbeatlive');
}
} else {
$this->session->set_flashdata('error', 'Không tìm thấy mã nhúng.');
redirect(base_url().'backend/cmsVheartbeatlive/listVheartbeatlive');
}
}
}