番組予約
  
foltia:EPG予約:Error\n";
		die_exit("登録番組がありません
");
		}
print "	foltia:EPG予約:完了
\n";
$now = date("YmdHi");   
// - DB登録作業
//時刻検査
if (($startdatetime > $now ) && ($enddatetime > $now ) && ($enddatetime  > $startdatetime ) ){
//min pidを探す
$query = "SELECT min(pid) FROM  foltia_subtitle ";
//	$rs = m_query($con, $query, "DBクエリに失敗しました");
	$rs = sql_query($con, $query, "DBクエリに失敗しました");
	$rowdata = $rs->fetch();
	if (! $rowdata) {
	$insertpid = -1 ;
	}else{
	$insertpid = $rowdata[0];
		if ($insertpid > 0){
		$insertpid = -1;
		}else{
		$insertpid-- ;
		}
	}
// next 話数を探す
$query = "SELECT max(countno) FROM  foltia_subtitle WHERE tid = 0";
//	$rs = m_query($con, $query, "DBクエリに失敗しました");
	$rs = sql_query($con, $query, "DBクエリに失敗しました");
	$rowdata = $rs->fetch();
	if (! $rowdata) {
	$nextcno = 1 ;
	}else{
	$nextcno = $rowdata[0];
	$nextcno++ ;
	}
//INSERT
if ($demomode){
	print "下記予約を完了いたしました。
";
}else{
$userclass = getuserclass($con);
if ( $userclass <= 2){
/*
pid 
tid 
stationid  
countno 
subtitle
startdatetime  
enddatetime  
startoffset  
lengthmin  
m2pfilename 
pspfilename 
epgaddedby  
*/
$memberid = getmymemberid($con);
	$query = "
insert into foltia_subtitle  (pid ,tid ,stationid , countno ,subtitle ,
startdatetime ,enddatetime ,startoffset , lengthmin , epgaddedby ) 
values ( ?,'0',?,?,?,?,?,'0',?,?)";
//	$rs = m_query($con, $query, "DBクエリに失敗しました");
	$rs = sql_query($con, $query, "DBクエリに失敗しました",array($insertpid,$stationid,$nextcno,$subtitle,$startdatetime,$enddatetime,$lengthmin,$memberid));
	//addatq.pl
	//キュー入れプログラムをキック
	//引数 TID チャンネルID
	//echo("$toolpath/perl/addatq.pl $tid $station");
	$oserr = system("$toolpath/perl/addatq.pl 0 0");
	print "下記予約を完了いたしました。
";
}else{
	print "EPG予約を行う権限がありません。";
}// end if $userclass <= 2
}//end if demomode
}else{
print "時刻が不正なために予約できませんでした。 
";
}
print "
    | 放送開始 | $startdatetime | 
    | 放送終了 | $enddatetime | 
    | 局コード | $stationid | 
    | 尺(分) | $lengthmin | 
    | 番組名 | $subtitle | 
	
";
?>