<?php

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

class Look_order extends CI_Controller {

    function __construct() {
        parent::__construct();
        //$this->permission->is_admin();
        // $this->output->enable_profiler(TRUE);
        $this->load->model('Orders_model');
        $this->load->model('Logs_model');
    }

    //订单情况
    public function index() {
        //$data['order_list'] = $this->Orders_model->all();
        $data = array();
        $data['start_date'] = $this->input->post('order_startdate');
        $data['end_date'] = $this->input->post('order_enddate');
        if (empty($data['start_date']) || empty($data['end_date'])) {
            $data['start_date'] = date('Y-m-d', time());
            $data['end_date'] = date('Y-m-d', strtotime('+1 day'));
        } else {
            $data['order_list'] = $this->Orders_model->get_test_order($data['start_date'], $data['end_date']);
        }

        $this->load->view('bootstrap/header', $data);
        $this->load->view('bootstrap/order_list');
        $this->load->view('bootstrap/footer');
    }

    //显示订单数量，如果大于阈值就显示错误
    public function status() {
        $data = array();
        $tour_count = $this->Orders_model->tour_count();
        $biz_count = $this->Orders_model->biz_count();
        $data['tour_count'] = $tour_count + $biz_count;
        if ($data['tour_count'] >= 550) {
            $this->output->set_status_header(500);
        }
        $data['insert_id']=$this->Logs_model->write_test();
        if (empty($data['insert_id'])) {
            $this->output->set_status_header(500);
        }
        $this->load->view('welcome_message', $data);
    }

}
