<?php
class OrdersAction extends HomeAction{
    
    public function _initialize() {
        parent::_initialize();
    }
    
	public function post(){
				$ary_post = $this->_post();
				$ip = get_client_ip();
				$orderid=time().mt_rand(100,1000);
                $ary_data = array(
					'orderid'        =>  $orderid,
                    'name'        =>  $ary_post['name'],
                    'tel'       =>  trim($ary_post['tel']),
                    'address'    =>  trim($ary_post['address']),
                    'proid'      =>  trim($ary_post['productid']),
					'proname'      =>  trim($ary_post['proname']),
                    'create_time'    =>  time(),
					'price'    =>  trim($ary_post['price']),
                    'ip'      =>  $ip,
					'remark'      => trim($ary_post['remark']),
                );
                $ary_result = D('Orders')->add($ary_data);
                if(FALSE !== $ary_result){
					header('Location: /Orders/success?orderid='.$orderid);
                   	exit();
				   //$this->success("订单提交成功",'/',1);
				   //$this->display('success');
                }else{
                    $this->error("订单提交失败");
                }		
	}
    public function index(){
        $this->display();
    }
    public function success(){
        $this->display();
    }	
}