<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Manage extends Admin_Controller{

    public function __construct()
    {
        parent::__construct();
        $this->load->library('pagination');
        $this->load->model('site_user_model');
        $this->config->load('otherconf',TRUE);
        $this->load->library('Export_service');
        $this->data['now'] = 'card';
    }

    public function index($offset = '')
    {
        #配置分页信息
        $config['base_url'] = site_url('admin/manage/index');
        $config['total_rows'] = $this->site_user_model->countuser();
        $config['per_page'] = 30;
        $config['uri_segment'] = 4;

        $config['first_link'] = '首页';
        $config['first_tag_open'] = '<li id="first">';
        $config['first_tag_close'] = '</li>';

        $config['last_link'] = '末页';
        $config['last_tag_open'] = '<li id="last">';
        $config['last_tag_close'] = '</li>';

        $config['next_link'] = '下一页';
        $config['next_tag_open'] = '<li id="down">';
        $config['next_tag_close'] = '</li>';

        $config['prev_link'] = '上一页';
        $config['prev_tag_open'] = '<li id="top">';
        $config['prev_tag_close'] = '</li>';
        $config['num_links'] = 5;

        $config['full_tag_open'] = '<div class="wrap"><div class="fenye"><ul>';
        $config['full_tag_close'] = '</ul></div></div>';
        
        #初始化分页类
        $this->pagination->initialize($config);

         #生成分页信息
        $data['pageinfo'] = $this->pagination->create_links();

        $limit = $config["per_page"];
        $fields = "username,realname,sex,age,tel,buys,status,startime,endtime,type,opencard_time";
        $data['userinfo'] = $this->site_user_model->listuser($fields,$limit,$offset);

        $status = $this->config->item('status','otherconf');
        $type = $this->config->item('type','otherconf');
        $sex = $this->config->item('sex','otherconf');
        foreach ($data['userinfo'] as $k=>$v) {
            $data['userinfo'][$k]['status'] = $status[$v['status']];
            $data['userinfo'][$k]['type'] = $type[$v['type']];
            $data['userinfo'][$k]['sex'] = $sex[$v['sex']];
        }

        $data['title'] = '高级权益用户';
        $this->_view('senior_rights',$data);
    }

    public function export()
    {
        echo $this->export_service->export();
    }

}