");
		}
$station = getgetnumform(station);
		if ($station == "") {
		$station = 0;
		}
$bitrate = getgetnumform(bitrate);
		if ($bitrate == "") {
		$bitrate = 5;
		}
$con = m_connect();
$now = date("YmdHi");   
//タイトル取得
	$query = "select title from foltia_program where tid='$tid'";
	$rs = m_query($con, $query, "DBクエリに失敗しました");
	$maxrows = pg_num_rows($rs);
			
		if ($maxrows == 0) {
		$title = "(未登録)";
		}else{
		$rowdata = pg_fetch_row($rs, 0);
		$title = htmlspecialchars($rowdata[0]);
		}
?>
  予約完了
  
「=$title?>」を番組予約モードで予約しました。 
 
予約スケジュール 
=  '$now'  AND foltia_program.tid ='$tid' 
ORDER BY foltia_subtitle.startdatetime  ASC
";
}else{
//全局
	$query = "
SELECT 
foltia_subtitle.pid ,  
stationname,
foltia_subtitle.countno,
foltia_subtitle.subtitle,
foltia_subtitle.startdatetime ,
foltia_subtitle.lengthmin ,
foltia_subtitle.startoffset 
FROM foltia_subtitle , foltia_program ,foltia_station  
WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid 
 AND foltia_subtitle.startdatetime >=  '$now'  AND foltia_program.tid ='$tid' 
ORDER BY foltia_subtitle.startdatetime  ASC
";
}
	$rs = m_query($con, $query, "DBクエリに失敗しました");
	$maxrows = pg_num_rows($rs);
			
		if ($maxrows == 0) {
		echo("放映予定はいまのところありません
");
		}
		else{
		$maxcols = pg_num_fields($rs);		
?>
  
	
		
			| PID | 
			放映局 | 
			話数 | 
			サブタイトル | 
			開始時刻 | 
			総尺 | 
			時刻ずれ | 
		
	
	
		\n");
				/* pg_fetch_row で一行取り出す */
				$rowdata = pg_fetch_row($rs, $row);
				for ($col = 0; $col < $maxcols; $col++) { /* 列に対応 */
					echo("".htmlspecialchars($rowdata[$col])."
  | \n");
				}
				echo("\n");
			}
		}//end if
		?>
	
 0){
	//既存局を消す
		$query = "DELETE 
FROM foltia_tvrecord  
WHERE tid = '$tid' 
";
	$rs = m_query($con, $query, "DBクエリに失敗しました");
		}
}//endif
	$query = "
SELECT 
 * 
FROM foltia_tvrecord  
WHERE tid = '$tid'  AND stationid = '$station' 
";
	$rs = m_query($con, $query, "DBクエリに失敗しました");
	$maxrows = pg_num_rows($rs);
		if ($maxrows == 0) { //新規追加
				$query = "INSERT INTO  foltia_tvrecord  values ('$tid','$station','$bitrate')";
				$rs = m_query($con, $query, "DB書き込みに失敗しました");
		}else{//修正 (ビットレート)
			$query = "UPDATE  foltia_tvrecord  SET 
  bitrate = '$bitrate' WHERE tid = '$tid'  AND stationid = '$station'
			";
			$rs = m_query($con, $query, "DB書き込みに失敗しました");
		}
	
//キュー入れプログラムをキック
//引数 TID チャンネルID
//echo("$toolpath/perl/addatq.pl $tid $station");
$oserr = system("$toolpath/perl/addatq.pl $tid $station");
}//end if demomode
?>