<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 25/12/2015
 * Time: 2:22 CH
 */
if (!defined('BASEPATH')) exit('No direct script access allowed');

class CmsUser extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        date_default_timezone_set("Asia/Ho_Chi_Minh");
        //
        $this->load->model('muser_model');
    }

    public function listUser()
    {
        $this->_data['functionName'] = 'QL Người chơi';
        $this->_data['action'] = 'listUser';
        $this->_data['titlePage'] = 'QL Người chơi';
        $this->_data['loadPage'] = 'backend/cms_user/list_user_view';
        $this->load->view('backend/admin_template_view', $this->_data);
    }

    public function listUserAjax()
    {
        $data = array();
        $fByName = $this->input->post('fByName');
        $pageId = $this->input->post('pageId');
        //
        $pageId = ($pageId == 0) ? 1 : $pageId;
        //
        $limit = 10;
        $offset = ($pageId - 1) * $limit;
        $data['offset'] = ($pageId - 1) * $limit;
        $totalRecord = $this->muser->cmsCountAll($fByName);
        $data['pagination'] = MyHelper::genPaginationLink($totalRecord, $limit, $pageId);
        $data['listData'] = $this->muser->cmsGetPagination($limit, $offset, $fByName);
        //
        $this->load->view('backend/ajax/cms_user/list_user_view', $data);
    }

    public function showUser($user_id)
    {
        $this->_data['user']= $this->muser->getById($user_id);
        //
        $this->_data['functionName'] = 'Thông tin Người chơi';
        $this->_data['action'] = 'showUser';
        $this->_data['titlePage'] = 'Thông tin Người chơi';
        $this->_data['loadPage'] = 'backend/cms_user/show_user_view';
        $this->load->view('backend/admin_template_view', $this->_data);
    }

}