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

class pages extends CI_Controller{
	public function __construct(){
        parent::__construct();
		$this->load->helper('tuniu');
	}
	
	public function index(){
		exit('前方高能！！！');
	}
	
	public function homepage(){
		$this->load->view('common/header');
		$this->load->view('homepage');
		$this->load->view('common/footer');
	}
	
	public function order_list(){
		$page = $this->input->get("page");
		$page_size = 10;
		$page = 1;
		$page_parameter = "";
		
		$timestamp = time();
		$data = '{"pageIndex":'.$page.'}';
		$sign = md5(TUNIU_FLIGHT_KEY.$data.$timestamp);
		$orderlistjson = '{
			"purchaseId": '.TUNIU_FLIGHT_ID.',
			"sign": "'.$sign .'",
			"timestamp": '.$timestamp.',
			"function": "orderList",
			"data":'.$data.'
		}';
		$returnJson = post_tuniu(TUNIU_FLIGHT_API,$orderlistjson,'POST');
		
		$page_parameter = "";
		$returndata = json_decode($returnJson);
		
		$list["data"] = $returndata;
		
		$this->load->library('pagination');
        $config['base_url'] = site_url("/apps/flightsystem/pages/order_list");
        $config['total_rows'] = $returndata->data->count;
        $config['per_page'] = $page_size;
        $config['page_query_string']=TRUE;
        $config['query_string_segment']="page";
        $config['cur_tag_open'] = '<li class="active"><a href="#">';        
        $config['cur_tag_close'] = '</a></li>';
        $config['first_tag_open']=$config['last_tag_open']=$config['next_tag_open']=$config['prev_tag_open']=$config['num_tag_open']="<li>";
        $config['first_tag_close']=$config['last_tag_close']=$config['next_tag_close']=$config['prev_tag_close']=$config['num_tag_close']="</li>";
        $this->pagination->initialize($config);

        $list["page_link"] = $this->pagination->create_links();
		
		$this->load->view('common/header');
		$this->load->view('order_list',$list);
		$this->load->view('common/footer');
	}
	
	public function order_detail($orderid=null){
		if(empty($orderid)){
			exit('请输入订单号');
		}else{
			$data = array();
			$data['orderid'] = $orderid;
			$this->load->view('common/header');
			$this->load->view('order_detail',$data);
			$this->load->view('common/footer');
		}
	}
	
	public function order_refund($orderid=null){
		if(empty($orderid)){
			exit('请输入订单号');
		}else{
			$data = array();
			$data['orderid'] = $orderid;
			$this->load->view('common/header');
			$this->load->view('order_refund',$data);
			$this->load->view('common/footer');
		}
	}
}