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


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

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

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


//用户检测
$MB->Open('','login',2);


@ini_set('max_execution_time', 0);
@set_time_limit(0); 


switch ($mudi){
	case 'del':
		$menuFileID = 11;
		$MB->IsSecMenuRight('alert',$menuFileID,$dataType);
		del();
		break;

	case 'moreDel':
		$menuFileID = 11;
		$MB->IsSecMenuRight('alertBack',$menuFileID,$dataType);
		MoreDel();
		break;

	default:
		die('err');
}

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



// 删除
function del(){
	global $DB,$mudi,$menuFileID,$menuTreeID,$dataType,$dataTypeCN;

	$dataID	= OT::GetInt2( OT::ParaArr('id') );
	$theme	= OT::GetStr('theme');

	$DB->query('delete from '. OT_dbPref .'infoPayData where IPD_ID='. $dataID);

	Adm::AddLog(array(
		'theme'	=> $theme,
		'note'	=> '【'. $dataTypeCN .'】删除完成！',
		));
	
	JS::ParentHiddenEnd('data'. $dataID);
}



// 批量删除
function MoreDel(){
	global $DB,$mudi,$menuFileID,$menuTreeID,$systemArr;

	$backURL	= OT::PostStr('backURL');
	$dataType	= OT::PostStr('dataType');
	$dataTypeCN	= OT::PostStr('dataTypeCN');
	$selDataID	= OT::Post('selDataID');
	
	$selCount = OT::NewCount($selDataID);
	if ($selCount <= 0){
		JS::AlertBackEnd('请先选择要删除的记录.');
	}

	$whereStr = '';
	for ($i=0; $i<$selCount; $i++){
		$whereStr .= ','. intval($selDataID[$i]);
	}
	if ($whereStr == ''){
		JS::AlertBackEnd('请先选择要删除的记录.');
	}

	$succNum = 0;
	$chkexe = $DB->query('select IPD_ID from '. OT_dbPref .'infoPayData where IPD_ID in (0'. $whereStr .')');
	while ($row = $chkexe->fetch()){
		$DB->query('delete from '. OT_dbPref .'infoPayData where IPD_ID='. $row['IPD_ID']);
		$succNum ++;
	}
	unset($chkexe);

	Adm::AddLog(array(
		'note'		=> '【'. $dataTypeCN .'】批量删除完成（删除'. $succNum .'个）！',
		));

	JS::AlertHrefEnd('批量删除完成（删除'. $succNum .'个）.',$backURL);
}
?>
