<?php

/**
 * 前台 订单查询 模块 Controller
 * ============================================================================
 * ZhunaCMS 住哪网酒店分销联盟程序php版　BY Tmac PHP MVC framework
 * $Author: zhangwentao $  <zwttmac@qq.com>
 * $Id: orderlist.php 19 2011-11-22 11:00:06Z zhangwentao $
 * http://un.zhuna.cn；
 */
class orderlistAction extends Action
{

    private $tmp_model;
    private $common_model;

    /**
     * _init 方法 在执行任何Action前执行
     */
    public function _init()
    {
        $this->assign('action', $_GET['TMAC_ACTION']);
        $this->tmp_model = Tmac::model('orderlist');
        $this->common_model = Tmac::model('common');

        //footer里的相关设置
        $config_footer = $this->common_model->footer();
        $this->assign($config_footer);
    }

    /**
     * 资讯类别管理 首页
     */
    public function index()
    {
        $oname = empty($_POST['oname']) ? '' : $_POST['oname'];  //oname
        $mobile = empty($_POST['mobile']) ? '' : $_POST['mobile'];  //mobile

        if ($oname == '') {
            $this->redirect('请填写入住人姓名!');
            exit();
        }
        if ($mobile == '') {
            $this->redirect('请填写入住人手机号码!');
            exit();
        } else {
            $mobilephone = trim($mobile);
            //手机号码的正则验证
            if (!preg_match("/^13[0-9]{1}[0-9]{8}$|15[0189]{1}[0-9]{8}$|18[0-9]{9}$/", $mobilephone)) {
                //手机号码格式不对
                $this->redirect('手机号码格式不对!');
                exit();
            }
        }
        //获取客人订单信息
        $result = $this->tmp_model->orderinfo($oname, $mobile);

        $this->assign($result);
        $this->assign('oname', $oname);
        $this->assign('mobile', $mobile);
        $this->V('orderlist');
    }

}