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

class Shoporder extends Admin_Controller{

    public function __construct()
    {
        parent::__construct();
        $this->load->model('mocuz/setting_model', 'setting');

    }

    public function index($search_sid, $search_level, $offset)
    {

        $this->load->model('shoporder_model', 'shoporder');
        $this->load->library('pagination');

        $search_sid = empty($search_sid) ? intval($this->input->post('sid')) : $search_sid;
        $search_level = empty($search_level) ? intval($this->input->post('level')) : $search_level;

        $this->shoporder->setList('sid', $search_sid);
        $this->shoporder->setList('level', $search_level);



        $pagesize = 50;
        
        $offset = intval($offset);
        $data['list'] = $this->shoporder->getList($offset,$pagesize);
        $data['all_level'] = array(0 => '全部',1 => '普通', 2=> '高级');

        $config['base_url'] = site_url("admin/shoporder/index/{$search_sid}/{$search_level}");

        #配置分页信息
        $config['total_rows'] = $this->shoporder->countList();

        $config['per_page'] = $pagesize;

        $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();
        $data['search_sid'] = $search_sid;
        $data['search_level'] = $search_level;
	    $this->load->view('common/innerheader',$data);
		$this->load->view('admin/shoporder',$data);

    }

    public function save(){
        $card_share_text = $this->input->post('card_share_text');
        $card_share_link = $this->input->post('card_share_link');
        $this->setting->set('card_share_link', $card_share_link);
        $this->setting->set('card_share_text', $card_share_text);
        redirect('admin/share/index');
    }


}