<?php
	session_start();
	header("Content-type:text/html;charset=gb2312");
	require_once("db/db.php");	
	require_once("common/common.php");
	
	//设置统一语言格式
	header("Content-type: text/html; charset=gb2312"); 
	
	$strorderno=trim($_REQUEST['tbno']);	//订单号
	$strdoid=trim($_REQUEST['doid']);		//1是历史订单,否则我的订单
	
	$retval=0;

	//开始创建
	$sql = sprintf("EXECUTE TRS_CancelOrderNoBook '%s','APP预订取消订单'",$strorderno);
	
	$strRet=0;		//得到处理返回值
	
	$result = querySql($sql);
	if($row = fetch_array($result))
	{
		$strRet=$row['RET'];
		if($strRet==0)
		{	//注册成功
			$retval=0;
		}
		elseif($strRet==1)
		{
			$retval=1;	
			//状态不正确,不能取消
		}
		elseif($strRet==2)
		{
			$retval=2;
			//已有账目生成,不能取消
		}
		else
		{
			$retval=3;
			//未知结果
		}
	}
	freeResult($result);
	closeDb();
	if($retval==0)
	{	
		if($strdoid=='1'){
			echo "<script>window.location.href='hisorder1.php';</script>";
		} 
		elseif($strdoid=='2'){
			echo "<script>window.location.href='hisorder2.php';</script>";
		} 
		else {
			echo "<script>window.location.href='orderlist.php';</script>";
		}
	}
	else
	{
		//重新编辑
		echo "<script>window.location.href='orderqxqr.php?stext=".$retval."';</script>";
	}
?>



