Commit bb3a980e by Phạm Văn Đoan

code chức năng quản lý mã nhúng BXH tháng

parent 28d98bfc
...@@ -409,6 +409,8 @@ $config['csrf_exclude_uris'] = array( ...@@ -409,6 +409,8 @@ $config['csrf_exclude_uris'] = array(
'backend/cmsArtist/listArtistAjax', 'backend/cmsArtist/listArtistAjax',
'backend/cmsArtist/addArtistAjax', 'backend/cmsArtist/addArtistAjax',
'backend/cmsVheartbeatlive/listVheartbeatliveAjax',
'backend/cmsSetting/listGroupAjax', 'backend/cmsSetting/listGroupAjax',
'backend/cmsSetting/listUserAdminAjax', 'backend/cmsSetting/listUserAdminAjax',
'backend/cmsSetting/logUserAjax', 'backend/cmsSetting/logUserAjax',
......
<?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'] = 'Nghệ sĩ';
$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,
);
$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,
);
$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');
}
}
}
\ No newline at end of file
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Vheartbeat_live_model extends CI_Model
{
protected $_table = 'vheartbeat_lives';
public function __construct()
{
parent::__construct();
date_default_timezone_set("Asia/Ho_Chi_Minh");
}
public function add($data_insert)
{
$this->db->insert($this->_table, $data_insert);
$insert_id = $this->db->insert_id();
return $insert_id;
}
public function update($id, $data_update)
{
$this->db->where('id', $id);
$this->db->update($this->_table, $data_update);
}
public function getById($id)
{
$this->db->select('*');
$this->db->from($this->_table);
$this->db->where('id', $id);
$query = $this->db->get();
return $query->result_array();
}
public function countAll($name = null)
{
$this->db->select('COUNT(*) AS totalResults');
$this->db->from($this->_table);
if ($name != null) {
$this->db->like($this->_table . '.title', $name, 'both');
}
$query = $this->db->get();
$result = $query->result_array();
if ($result) {
return $result[0]['totalResults'];
} else {
return 0;
}
}
public function getPagination($record, $start, $name = null)
{
$this->db->select('*');
$this->db->from($this->_table);
if ($name != null) {
$this->db->like($this->_table . '.title', $name, 'both');
}
$this->db->order_by($this->_table . '.id', 'desc');
$this->db->limit($record, $start);
$query = $this->db->get();
return $query->result_array();
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
\ No newline at end of file
...@@ -211,6 +211,24 @@ $action = $CI->router->fetch_method(); ...@@ -211,6 +211,24 @@ $action = $CI->router->fetch_method();
</ul> </ul>
</li> </li>
<!-- Quan ly V Heartbeat Live -->
<li class="<?php if($controller && $controller == 'cmsVheartbeatlive') echo 'active open'?>">
<a href="#" class="dropdown-toggle">
<i class="menu-icon fa fa-video-camera"></i>
<span class="menu-text">V Heartbeat Live</span>
<b class="arrow fa fa-angle-down"></b>
</a>
<b class="arrow"></b>
<ul class="submenu">
<li class="<?php if($action && (in_array($action, array('listVheartbeatlive','addVheartbeatlive','editVheartbeatlive')))) echo 'active'?>">
<a href="<?php echo base_url('backend/cmsVheartbeatlive/listVheartbeatlive'); ?>">
<i class="menu-icon fa fa-caret-right"></i>Danh sách mã nhúng
</a>
<b class="arrow"></b>
</li>
</ul>
</li>
<!-- Quan ly tai nguyen --> <!-- Quan ly tai nguyen -->
<!--<li class="<?php /*if($controller && $controller == 'cmsResource') echo 'active open'*/?>"> <!--<li class="<?php /*if($controller && $controller == 'cmsResource') echo 'active open'*/?>">
<a href="#" class="dropdown-toggle"> <a href="#" class="dropdown-toggle">
......
<div style="/*max-height: 465px; overflow: scroll*/">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th style="text-align: center">TT</th>
<th style="text-align: center">Tiêu đề V Heartbeat Live</th>
<th style="text-align: center">Mã nhúng</th>
<th style="text-align: center">Trạng thái</th>
<th style="text-align: center">Xử lý</th>
</tr>
</thead>
<tbody>
<?php if(count($listData) > 0): foreach($listData as $key => $data): ?>
<tr>
<td style="text-align: center"><?php echo ($key+1+$offset); ?></td>
<td style="text-align: center"><?php echo $data['title']; ?></td>
<td style="text-align: left"><?php echo htmlentities($data['embed_code']); ?></td>
<td style="text-align: left">
<?php echo ($key == 0) ? 'Đang hiển thị ở trang chủ. <br>Xem <a href="https://vmusicchart.vn/" target="_blank" class="color-red">tại đây</a>.' : '' ?>
</td>
<td style="text-align: center">
<a href="<?php echo base_url().'backend/cmsVheartbeatlive/editVheartbeatlive/'.$data['id']; ?>" title="Sửa thông tin">
<i class="ace-icon fa fa-pencil bigger-130"></i>
</a>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="10" style="color: red; font-style: italic">Không có dữ liệu nào!</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
<!-- /.row -->
<div style="text-align: center;"><?php echo $pagination; ?></div>
\ No newline at end of file
<?php
$input_title = array(
'name' => 'title',
'type' => 'text',
'value' => isset($title) ? $title : 'V Heartbeat Live | Tháng ' . date('m - Y'),
'placeholder' => '',
'class' => '',
'style' => 'width: 100%'
);
$input_embed_code = array(
'name' => 'embed_code',
'type' => 'text',
'value' => isset($embed_code) ? $embed_code : '',
'placeholder' => '',
'class' => '',
'style' => 'width: 100%',
'rows' => 3
);
?>
<div class="row">
<div class="widget-box">
<div class="widget-header">
<p class="widget-title"><?php echo (isset($functionName)) ? $functionName : 'Thêm mới' ?></p>
</div>
<div class="widget-body">
<div class="widget-main">
<?php $attributes = array('class' => 'form-horizontal', 'id' => 'myform'); ?>
<?php echo form_open(base_url('backend/cmsVheartbeatlive/addVheartbeatlive'), $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">Tiêu đề (*)</label>
<div class="col-lg-6">
<?php echo form_input($input_title); ?>
<?php if(validation_errors()){echo form_error('title', '<div class="error">', '</div>');} ?>
</div>
</div>
<div class="form-group">
<label class="col-lg-3">Mã nhúng (*)</label>
<div class="col-lg-6">
<?php echo form_textarea($input_embed_code); ?>
<?php if(validation_errors()){echo form_error('embed_code', '<div class="error">', '</div>');} ?>
</div>
</div>
<div class="form-group">
<div class="col-lg-3"></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(); ?>
</div>
</div>
</div>
</div><!-- /.row -->
<?php
$input_title = array(
'name' => 'title',
'type' => 'text',
'value' => isset($title) ? $title : $vlive[0]['title'],
'placeholder' => '',
'class' => '',
'style' => 'width: 100%'
);
$input_embed_code = array(
'name' => 'embed_code',
'type' => 'text',
'value' => isset($embed_code) ? $embed_code : $vlive[0]['embed_code'],
'placeholder' => '',
'class' => '',
'style' => 'width: 100%',
'rows' => 3
);
?>
<div class="row">
<div class="widget-box">
<div class="widget-header">
<p class="widget-title"><?php echo (isset($functionName)) ? $functionName : 'Thêm mới' ?></p>
</div>
<div class="widget-body">
<div class="widget-main">
<?php $attributes = array('class' => 'form-horizontal', 'id' => 'myform'); ?>
<?php echo form_open(base_url('backend/cmsVheartbeatlive/editVheartbeatlive/' . $vlive[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 $vlive[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">Tiêu đề (*)</label>
<div class="col-lg-6">
<?php echo form_input($input_title); ?>
<?php if(validation_errors()){echo form_error('title', '<div class="error">', '</div>');} ?>
</div>
</div>
<div class="form-group">
<label class="col-lg-3">Mã nhúng (*)</label>
<div class="col-lg-6">
<?php echo form_textarea($input_embed_code); ?>
<?php if(validation_errors()){echo form_error('embed_code', '<div class="error">', '</div>');} ?>
</div>
</div>
<div class="form-group">
<div class="col-lg-3"></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(); ?>
</div>
</div>
</div>
</div><!-- /.row -->
<?php if($this->session->flashdata('success')): ?>
<div class="row">
<div class="alert alert-block alert-success" style="margin-bottom: 5px">
<button type="button" class="close" data-dismiss="alert">
<i class="ace-icon fa fa-times"></i>
</button>
<i class="ace-icon fa fa-check green"></i>
<?php echo $this->session->flashdata('success'); ?>
</div>
</div>
<?php endif; ?>
<?php if($this->session->flashdata('error')): ?>
<div class="row">
<div class="alert alert-block alert-danger" style="margin-bottom: 5px">
<button type="button" class="close" data-dismiss="alert">
<i class="ace-icon fa fa-times"></i>
</button>
<i class="ace-icon fa fa-times"></i>
<?php echo $this->session->flashdata('error'); ?>
</div>
</div>
<?php endif; ?>
<div class="row">
<div class="col-lg-3">
<input class="form-control" type="text" name="input-name" id="input-name"
placeholder="Nhập id, tên nghệ sĩ, email..." />
</div>
<div class="col-lg-1">
<button class="btn btn-sm btn-default" id="delete-filter">Xóa bộ lọc</button>
</div>
<div class="col-lg-1" style="float:right;">
<a class="btn btn-sm btn-success" href="<?php echo base_url('backend/cmsVheartbeatlive/addVheartbeatlive');?>">
<i class="glyphicon-plus"></i> Thêm</a>
</div>
</div>
<!-- /.row -->
<div class="space-6"></div>
<div class="row">
<div style="text-align: center" id="data-loading">
<i class="fa fa-refresh fa-spin bigger-200"></i> Đang tải dữ liệu...
</div>
<div class="col-lg-12">
<div id="div-response"></div>
</div>
</div>
<script type="text/javascript">
//Thuc hien viec ve bieu do$data
$(document).ready(function() {
var url = '<?php echo base_url("backend/cmsVheartbeatlive/listVheartbeatliveAjax"); ?>';
// Tìm kiếm theo cú pháp
var oldTimeout2 = '';
$('#input-name').keyup(function() {
clearTimeout(oldTimeout2);
oldTimeout2 = setTimeout(function() {
loadDataByAjaxFromInput(url);
}, 250);
});
// Xóa bộ lọc
$('#delete-filter').click(function() {
$("#input-name").val('');
changePagination('0');
return false;
});
changePagination('0');
});
//Ham chung cho cac input
function loadDataByAjaxFromInput(url) {
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data) {
$('#div-response').html(data);
$('#data-loading').hide();
}
});
}
//Ham chung cho cac SelectBox
function loadDataByAjaxFromSelectBox(id, url) {
$('#' + id).change(function() {
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data) {
$('#div-response').html(data);
$('#data-loading').hide();
}
});
});
}
function loadDataByAjaxDateRange(dtFrom, dtTo, url) {
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
// ajax
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data) {
$('#div-response').html(data);
$('#data-loading').hide();
}
});
}
function changePagination(pageId) {
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var url = '<?php echo base_url()."backend/cmsVheartbeatlive/listVheartbeatliveAjax"; ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do\
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName,
pageId: pageId
},
dataType: "text",
cache: false,
success: function(data) {
$('#div-response').html(data);
$('#data-loading').hide();
}
});
}
</script>
\ No newline at end of file
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