<?php
require(dirname(__FILE__) .'/check.php');
$skin->CheckIframe();


/* **** 版权所有 ****

 程序开发：网钛科技
 网钛CMS官网：http://otcms.com
 网钛IDC官网：http://idccms.com
 ＱＱ：877873666
 微信：QQ877873666
 邮箱：877873666@qq.com

 **** 版权所有 **** */



//打开用户表，并检测用户是否登录
$MB->Open(',MB_foreUsername','login');

$skin->WebTop();


echo('
<script language="javascript" type="text/javascript" src="js/inc/calc.js?v='. OT_VERSION .'"></script>
<script language="javascript" type="text/javascript" src="js/inc/list.js?v='. OT_VERSION .'"></script>
<script language="javascript" type="text/javascript" src="js/share.js?v='. OT_VERSION .'"></script>
');


switch ($mudi){
	case 'manage':
		$MB->IsSecMenuRight('alertBack',637,$dataType);
		manage();
		break;

	default:
		die('err');
}

$skin->WebBottom();

$MB->Close();
$DB->Close();





function manage(){
	global $DB,$MB,$skin,$mudi,$dataType,$dataTypeCN,$pageCount,$recordCount;

	$dataMode		= OT::GetStr('dataMode');
	$dataModeStr	= OT::GetStr('dataModeStr');

	$refProName		= OT::GetRegExpStr('refProName','sql');
	$refUsername	= OT::GetRegExpStr('refUsername','sql');
	$refAdminName	= OT::GetRegExpStr('refAdminName','sql');
	$refType		= OT::GetRegExpStr('refType','sql');
	$refType2		= OT::GetRegExpStr('refType2','sql');
	$refVpsName		= OT::GetRegExpStr('refVpsName','sql');
	$refState		= OT::GetInt('refState',-1);
	$refDate1		= OT::GetStr('refDate1');
		if (! strtotime($refDate1)){ $refDate1=''; }
	$refDate2		= OT::GetStr('refDate2');
		if (! strtotime($refDate2)){ $refDate2=''; }
	$refEndDate1		= OT::GetStr('refEndDate1');
		if (strtotime($refEndDate1)==false){$refEndDate1='';}
	$refEndDate2		= OT::GetStr('refEndDate2');
		if (strtotime($refEndDate2)==false){$refEndDate2='';}

	$SQLstr='select * from '. OT_dbPref .'tixing where 1=1';

	if ($refProName != ''){ $SQLstr .= " and TX_proDataName like '%". $DB->ForStr($refProName,false) ."%'"; }
	if ($refUsername != ''){ $SQLstr .= " and TX_username like '%". $DB->ForStr($refUsername,false) ."%'"; }
	if ($refAdminName != ''){ $SQLstr .= " and TX_adminName like '%". $DB->ForStr($refAdminName,false) ."%'"; }
	if ($refType != ''){ $SQLstr .= " and TX_type=". $DB->ForStr($refType); }
	if ($refType2 != ''){ $SQLstr .= " and TX_type2=". $DB->ForStr($refType); }
	if ($refVpsName != ''){ $SQLstr .= " and TX_vpsName like '%". $DB->ForStr($refVpsName,false) ."%'"; }
	if ($refState > -1){ $SQLstr .= ' and TX_state='. $refState .''; }
	if ($refDate1 != ''){ $SQLstr .= ' and TX_startTime>='. $DB->ForTime($refDate1); }
	if ($refDate2 != ''){ $SQLstr .= ' and TX_startTime<'. $DB->ForTime(TimeDate::Add('d',1,$refDate2)); }
	if ($refEndDate1 != ''){ $SQLstr .= ' and TX_endTime>='. $DB->ForTime($refEndDate1); }
	if ($refEndDate2 != ''){ $SQLstr .= ' and TX_endTime<'. $DB->ForTime(TimeDate::Add('d',1,$refEndDate2)); }

	$orderName = OT::ListDefVal(OT::GetStr('orderName'), 'username|price|startTime|endTime|type|state|adminName|adminTime', 'ID');
	$orderSort = OT::ListDefVal(OT::GetStr('orderSort'), 'ASC', 'DESC');

	$proDataArr = array();
//	$proDataStr = '';
	$proexe = $DB->query('select VAD_ID,VAD_theme from '. OT_dbPref .'vpsApiData order by VAD_rank ASC');
	while ($row = $proexe->fetch()){
		$proDataArr[$row['VAD_ID']]	= $row['VAD_theme'];
//		$proDataStr .= '<option value="'. $row['VAD_ID'] .'">'. $row['VAD_theme'] .'</option>';
	}
	unset($proexe);

	$skin->TableTop('share_refer.gif','',$dataTypeCN .'查询');
		echo('
		<form id="refForm" name="refForm" method="get" action="">
		<input type="hidden" name="mudi" value="'. $mudi .'" />
		<input type="hidden" name="dataType" value="'. $dataType .'" />
		<input type="hidden" name="dataTypeCN" value="'. $dataTypeCN .'" />

		<table width="99%" align="center" border="0" cellSpacing="0" cellPadding="0" summary="" class="padd5td">
		<tr>
			<td style="width:22%;">
				&ensp;&ensp;产品类型：<select name="refType">
					<option value="">&ensp;</option>
					<option value="domain" '. Is::Selected($refType,'domain') .'>域名</option>
					<option value="host" '. Is::Selected($refType,'host') .'>虚拟主机</option>
					<option value="vpsApi" '. Is::Selected($refType,'vpsApi') .'>云服务器</option>
					<option value="dialing" '. Is::Selected($refType,'dialing') .'>拨号VPS</option>
					<option value="serv" '. Is::Selected($refType,'serv') .'>服务器租用</option>
					<option value="ssl" '. Is::Selected($refType,'ssl') .'>SSL证书</option>
					</select>
			</td>
			<td style="width:22%;">
				&ensp;&ensp;产品名称：<input type="text" name="refProName" size="20" value="'. $refProName .'" style="width:120px;" />
			</td>
			<td style="width:28%;">
				&ensp;&ensp;&ensp;&ensp;操作者：<input type="text" name="refAdminName" size="20" value="'. $refAdminName .'" style="width:60px;" />
				&ensp;&ensp;&ensp;&ensp;类型：<select name="refType2">
					<option value="">&ensp;</option>
					<option value="开通" '. Is::Selected($refType2,'开通') .'>开通</option>
					<option value="续费" '. Is::Selected($refType2,'续费') .'>续费</option>
					</select>
			</td>
			<td style="width:28%;">
				&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;状态：<select name="refState">
					<option value="">&ensp;</option>
					<option value="0" '. Is::Selected($refState,0) .'>未处理</option>
					<option value="1" '. Is::Selected($refState,1) .'>已同意</option>
					<option value="2" '. Is::Selected($refState,2) .'>已拒绝</option>
					</select>
			</td>
		</tr>
		<tr>
			<td>
				&ensp;&ensp;机器编码：<input type="text" name="refVpsName" size="20" value="'. $refVpsName .'" style="width:120px;" />
			</td>
			<td>
				&ensp;&ensp;&ensp;&ensp;用户名：<input type="text" name="refUsername" size="20" value="'. $refUsername .'" style="width:120px;" />
			</td>
			<td>
				&ensp;&ensp;开通日期：<input type="text" name="refDate1" size="10" value="'. $refDate1 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />&ensp;至&ensp;<input type="text" name="refDate2" size="10" value="'. $refDate2 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />
			</td>
			<td>
				&ensp;&ensp;到期日期：<input type="text" name="refEndDate1" size="10" value="'. $refEndDate1 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />&ensp;至&ensp;<input type="text" name="refEndDate2" size="10" value="'. $refEndDate2 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />
			</td>
		</tr>
		<tr>
			<td align="center" style="padding:5px;padding-top:20px" colspan="4">
				<input type="image" src="'. AdmTpl::ImgSrc('button_refer') .'" />
				&ensp;&ensp;&ensp;&ensp;
				<img src="'. AdmTpl::ImgSrc('button_reset') .'" onclick=\'document.location.href="?mudi='. $mudi .'&dataMode='. $dataMode .'&dataModeStr='. $dataModeStr .'&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'"\' style="cursor:pointer" alt="" />
			</td>
		</tr>
		</table>
		</form>
		');

	$skin->TableBottom();

	echo('
	<br />

	<div style="padding:5px;"><label style="font-weight:normal;"><input type="checkbox" id="skipEndTime" name="skipEndTime" value="1" />忽略到期时间不匹配</label>&ensp;&ensp;<label style="font-weight:normal;"><input type="checkbox" id="skipState" name="skipState" value="1" />忽略状态不匹配</label></div>
	<form id="listForm" name="listForm" method="post" action="" onsubmit="return CheckListForm()">
	<script language="javascript" type="text/javascript">document.write (\'<input type="hidden" name="backURL" value="\'+ document.location.href +\'" />\')</script>
	<input type="hidden" name="dataMode" value="'. $dataMode .'" />
	<input type="hidden" name="dataModeStr" value="'. $dataModeStr .'" />
	<input type="hidden" name="dataType" value="'. $dataType .'" />
	<input type="hidden" name="dataTypeCN" value="'. $dataTypeCN .'" />
	');

	$skin->TableTop2('share_list.gif','',''. $dataTypeCN .'管理');
	$skin->TableItemTitle('4%,8%,16%,9%,9%,8%,8%,5%,5%,7%,8%,13%','序号,'. $skin->ShowArrow('产品类型','type',$orderName,$orderSort) .','. $skin->ShowArrow('产品名称','dataName',$orderName,$orderSort) .'/IP/域名/标识,'. $skin->ShowArrow('用户名','username',$orderName,$orderSort) .','. $skin->ShowArrow('价格/费用','price',$orderName,$orderSort) .','. $skin->ShowArrow('原到期/开通','startTime',$orderName,$orderSort) .','. $skin->ShowArrow('延期至/到期','endTime',$orderName,$orderSort) .','. $skin->ShowArrow('类型','type2',$orderName,$orderSort) .','. $skin->ShowArrow('状态','state',$orderName,$orderSort) .','. $skin->ShowArrow('操作者','adminName',$orderName,$orderSort) .','. $skin->ShowArrow('操作时间','adminTime',$orderName,$orderSort) .',财务&ensp;详细&ensp;同意&ensp;拒绝');

	$pageSize	= $MB->mMbRow['MB_itemNum'];		//每页条数
	$page		= OT::GetInt('page');
	$showRow=$DB->GetLimit($SQLstr .' order by TX_'. $orderName .' '. $orderSort,$pageSize,$page);
	if (! $showRow){
		$skin->TableNoData();
	}else{
		$recordCount=$DB->GetRowCount();
		$pageCount=ceil($recordCount/$pageSize);
		if ($page < 1 || $page > $pageCount){$page=1;}

		echo('
		<tbody class="tabBody padd3td">
		');
		$number=1+($page-1)*$pageSize;
		$rowCount = count($showRow);
		for ($i=0; $i<$rowCount; $i++){
			if ($i % 2 == 1){ $bgcolor='class="tabColorTr"'; }else{ $bgcolor=''; }
			if ($showRow[$i]['TX_state'] != 0){
				$dealBtnStr = '
					<img src="images/img_yes.gif" class="gray" alt="同意" title="同意" />&ensp;
					<img src="images/img_err.gif" class="gray" alt="拒绝" title="拒绝" />
					';
			}else{
				$dealBtnStr = '
					<img src="images/img_yes.gif" class="pointer" onclick=\'TixingDeal("同意","'. $showRow[$i]['TX_type'] .'","tixing_deal.php?mudi=deal&mode=yes&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&theme='. urlencode($showRow[$i]['TX_dataName']) .'&dataID='. $showRow[$i]['TX_ID'] .'")\' alt="同意" title="同意" />&ensp;
					<img src="images/img_err.gif" class="pointer" onclick=\'TixingDeal("拒绝","'. $showRow[$i]['TX_type'] .'","tixing_deal.php?mudi=deal&mode=no&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&theme='. urlencode($showRow[$i]['TX_dataName']) .'&dataID='. $showRow[$i]['TX_ID'] .'")\' alt="拒绝" title="拒绝" />
					';
			}

			echo('
			<tr id="tixingData'. $showRow[$i]['TX_ID'] .'" '. $bgcolor .'>
				<td align="center">'. $number .'</td>
				<td align="center">'. IdcInfo::TypeCN($showRow[$i]['TX_type']) .'</td>
				<td align="center">'. $showRow[$i]['TX_dataName'] .'<div>'. IdcArea::IpStr($showRow[$i]['TX_ipStr']) .'</div></td>
				<td align="center">'. $showRow[$i]['TX_username'] . AdmArea::UserInfoImg($showRow[$i]['TX_userID']) .'</td>
				<td align="center" title="成本：'. $showRow[$i]['TX_cost'] .'">'. IdcInfo::PayMode($showRow[$i]['TX_payMode']) .'：'. $showRow[$i]['TX_price'] .'</td>
				<td align="center">'. $showRow[$i]['TX_startTime'] .'</td>
				<td align="center">'. $showRow[$i]['TX_endTime'] .'</td>
				<td align="center">'. $showRow[$i]['TX_type2'] .'</td>
				<td align="center">'. IdcInfo::TixingStateCN($showRow[$i]['TX_state']) .'</td>
				<td align="center" title="管理员ID：'. $showRow[$i]['TX_adminID'] .'">'. $showRow[$i]['TX_adminName'] .'</td>
				<td align="center">'. $showRow[$i]['TX_adminTime'] .'</td>
				<td align="center">
					<img src="images/img_money.gif" class="pointer" onclick=\'OT_OpenMoneyRecord("&refVpsName='. $showRow[$i]['TX_vpsName'] .'")\' alt="财务信息" title="财务信息" />&ensp;&ensp;
					<img src="images/img_det.gif" style="cursor:pointer" onclick=\'var a=window.open("'. IdcInfo::DetFile($showRow[$i]['TX_type']) .'?mudi=show&nohrefStr=close&dataMode='. $dataMode .'&dataModeStr='. $dataModeStr .'&dataType='. $dataType .'&dataTypeCN='. urlencode(IdcInfo::TypeCN($showRow[$i]['TX_type'])) .'&dataID='. $showRow[$i]['TX_dataID'] .'")\' alt="详细" title="详细" />&ensp;&ensp;
					'. $dealBtnStr .'
				</td>
			</tr>
			');
			$number ++;
		}
		echo('
		</tbody>
		');
	}
	unset($showRow);

	$skin->TableBottom2($pageCount, $pageSize, $recordCount);
}

?>