#!/usr/bin/perl
#-----------------------------------------------------------------------------------------------------#
#	
#-----------------------------------------------------------------------------------------------------#
require	"./jcode.pl" ;
require	"./formdeco.cgi";
require	"./fileutil.cgi";
require	"./util.cgi";

#-----------------------------------------------------------------------------------------------------#
$ConfigFile			=	"./config.cfg";		# 各種設定定義ファイル
$DispEncode			=	"sjis";
$Meth				=	"POST";
@WeekDay = ( "日", "月", "火", "水", "木", "金", "土" );
@MaxDay	 = ( 31, 28, 31, 30, 31, 30, 31,31, 30, 31, 30, 31 );
@SWday	 = ( 4, 0, 1, 4, 6, 2, 4, 0, 3, 5, 1, 3 );	# 
@SWday2	 = ( 6, 2, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 );	# 
@SWTbl	 = ( \@SWDay, \@SWDay2 );
$sendmail= "/usr/lib/sendmail";
$Mailto	 = 'reserve@business-hotel-isuzu.jp';
$ChkAki	 = 5;

#-----------------------------------------------------------------------------------------------------#

	%Form = &formdecode::FormDecode2($DispEncode) ;
	
	$NowTask	= $Form{ 'Tk' };
	
	&GetConfig( $ConfigFile ) ;
	
	@DataFileTbl = ( $DataFileName01, $DataFileName02, $DataFileName03, $DataFileName04, $DataFileName05, $DataFileName06,
					 $DataFileName07, $DataFileName08, $DataFileName09, $DataFileName10, $DataFileName11, $DataFileName12 );
	
	$Year	= &util::GetDayStr( 'YEAR' );
	$Year  -= 2000;
	$Month	= &util::GetDayStr( 'MONTH' );
	$Wday	= &util::GetDayStr( 'WDAY' );
	$Mday	= &util::GetDayStr( 'MDAY' );
	
	
	($second,$minute,$hour,$day,$month,$year)=localtime();
	$year += 1900;
	$month += 1;
	
	if( $NowTask eq "1" )				# 予約トップ画面
	{
		DispHtml( $ActionMenuHtmlA1 );
	}
	elsif( $NowTask eq "2" )			# 予約画面
	{
		if( $Year < $Form{'SYear'} ){ DispHtml( $ActionMenuHtmlA2 ); }
		elsif( $Year > $Form{'SYear'} ){ DispHtml( $ActionMenuHtml ); }
		else
		{
			if( $Month < $Form{'SMonth'} ){ DispHtml( $ActionMenuHtmlA2 ); }
			elsif( $Month > $Form{'SMonth'} ){ DispHtml( $ActionMenuHtml ); }
			else
			{
				if( $Mday <= $Form{'SDay'} ){ DispHtml( $ActionMenuHtmlA2 ); }
				elsif( $Mday > $Form{'SDay'} ){ DispHtml( $ActionMenuHtml ); }
				else { DispHtml( $ActionMenuHtml ); };
			}
		}
	}
	elsif( $NowTask eq "3" )				# 予約メール画面
	{
		&CheckFormData();
		DispHtml( $ActionMenuHtmlA3 );
	}
	elsif( $NowTask eq "4" )				# 予約メール確認画面
	{
		&CheckMailForm();
		DispHtml( $ActionMenuHtmlA4 );
	}
	elsif( $NowTask eq "5" )				# 予約メール送信OK
	{
		ReserveMail();
		DispHtml( $ActionMenuHtml2 );
	}
	else
	{
		&util::Error( 'IllegalAccess' );
	}
	
	exit ;

#---------------------------------------------------------------------------------------------------#
#	プラン名取得
#---------------------------------------------------------------------------------------------------#
sub SetPlanName()
{
	my ( @Temp, $temp, $ii );
	
	@Temp = &fileutil::DataFileRead( $RoomPlanFileName01 );
	for( $ii=0; $ii<(@Temp/2); $ii++ )
	{
		$temp = $Temp[$ii*2];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $PName, $Kikan, $dammy ) = split( /\t/, $temp );
		$PName =~ s/<Br>//g;
		$PName =~ s/<bR>//g;
		$PName =~ s/<BR>//g;
		$PName =~ s/<br>//g;
		
		$PlanName[$ii] = $PName;
		$KikanTbl[$ii] = $Kikan;
	}
	
}

#---------------------------------------------------------------------------------------------------#
#	メールフォームチェック
#---------------------------------------------------------------------------------------------------#
sub CheckMailForm
{
	my ( $temp, $EStr );
	
	$EStr = "";
	if( $Form{"Name"} eq "" )	 { $EStr .= "お名前が入力されていません。<Br>"; }
	if( $Form{"Furigana"} eq "" ){ $EStr .= "フリガナが入力されていません。<Br>"; }
	if( $Form{"Tel"} eq "" )	 { $EStr .= "電話番号が入力されていません。<Br>"; }
	if( $Form{"Tel2"} eq "" )	 { $EStr .= "携帯番号が入力されていません。<Br>"; }
	if( $Form{"Flg2"} ne "" && $Form{"Mail"} eq "" ){ $EStr .= "E-Mailが入力されていません。<Br>"; }
#	if( $Form{"Flg1"} eq "" && $Form{"Flg2"} eq "" ){ $EStr .= "\予\約\確\認方法が入力されていません。<Br>"; }
	if( $Form{'Mail'} ne "" )
	{
		if( ( $Form{'Mail'} !~ /([#-9A-~\-\_]+\@[#-9A-~\-\_\.]+)/ ) )
		{
			$EStr = 'メールアドレスを正しく入力してください。<Br>' ;
		}
	}
	if( $EStr ne "" ){ &InputError( "$EStr" ); }
	
}

#---------------------------------------------------------------------------------------------------#
#	メールフォームチェック２
#---------------------------------------------------------------------------------------------------#
sub CheckMailForm2
{
	my ( $temp, $EStr );
	
	$EStr = "";
	if( $Form{"Name"} eq "" )	 { $EStr .= "お名前が入力されていません。<Br>"; }
	if( $Form{"Furigana"} eq "" ){ $EStr .= "フリガナが入力されていません。<Br>"; }
	if( $Form{"Tel"} eq "" )	 { $EStr .= "電話番号が入力されていません。<Br>"; }
	if( $Form{"Tel2"} eq "" )	 { $EStr .= "携帯番号が入力されていません。<Br>"; }
	if( $Form{"Flg2"} ne "" && $Form{"Mail"} eq "" ){ $EStr .= "E-Mailが入力されていません。<Br>"; }
#	if( $Form{"Flg1"} eq "" && $Form{"Flg2"} eq "" ){ $EStr .= "予約確認方法が入力されていません。<Br>"; }
	
	if( $NowTask!=100 && $NowTask!=101 )
	{
		if( $Year < $Form{'SYear'} ){  }
		elsif( $Year > $Form{'SYear'} ){ $EStr .= "本日より以前の予約は出来ません。<Br>"; }
		else
		{
			if( $Month < $Form{'SMonth'} ){  }
			elsif( $Month > $Form{'SMonth'} ){ $EStr .= "本日より以前の予約は出来ません。<Br>"; }
			else
			{
				if( $Mday <= $Form{'SDay'} ){  }
				elsif( $Mday > $Form{'SDay'} ){ $EStr .= "本日より以前の予約は出来ません。<Br>"; }
				else { DispHtml( $EStr .= "本日より以前の予約は出来ません。<Br>" ); };
			}
		}
	}
	if( $Form{'Mail'} ne "" )
	{
		if( ( $Form{'Mail'} !~ /([#-9A-~\-\_]+\@[#-9A-~\-\_\.]+)/ ) )
		{
			$EStr = 'メールアドレスを正しく入力してください。<Br>' ;
		}
	}
	if( $EStr ne "" ){ &InputError( "$EStr" ); }
	
}

#---------------------------------------------------------------------------------------------------#
#	予約送信
#---------------------------------------------------------------------------------------------------#
sub ReserveMail()
{
	my ( $temp, $MStr );
	my ( @Temp, @Data, @Data2, $temp, $CategoryNum, @M, @R, $num, $ii, $nn, $Log );
	
	$DataFileName = "./data/log.dat";
	@LG = fileutil::DataFileRead( $DataFileName );
	
	@Room = &fileutil::DataFileRead( $RoomTypeFileName01 );
	
	$RNum = $Form{"RNum"};
	$ii=0;
	$SYear = $Form{"SYear"};
	$SMonth = $Form{"SMonth"};
	$SDay = $Form{"SDay"};
	$RNum = $Form{"RNum"};
	
	$MStr = "宿泊\予\約\申\込み\n\n";
	
	$Name = $Form{"Name"};
	$Furigana = $Form{"Furigana"};
	$Address = "〒$Form{\"Zip1\"}-$Form{\"Zip2\"} ";
	$Address.= &util::ExtendSelectBox( $IncFile06, $Form{"Address"} );
	$Address.= "$Form{\"Address2\"}";
	$Mail = $Form{"Mail"};
	$Tel = $Form{"Tel"};
	$Tel2= $Form{"Tel2"};
	$Company = $Form{"Company"};
	$Comment = $Form{"Comment"};
	$Comment=~s/\r//g;
	$Flg1 = $Form{"Flg1"};
	$Flg2 = $Form{"Flg2"};
	
	$MStr .= "名前：$Name\n";
	$MStr .= "フリガナ：$Furigana\n";
	$MStr .= "住所：$Address\n";
	$MStr .= "E-Mail：$Mail\n";
	$MStr .= "電話番号：$Tel\n";
	$MStr .= "携帯番号：$Tel2\n";
	$MStr .= "\予\定到着時間：$Form{\"YTime\"}\n";
	$MStr .= "大人(男)：$Form{\"MO\"}人\n";
	$MStr .= "大人(女)：$Form{\"FO\"}人\n";
	$MStr .= "通信欄：\n$Comment\n";
	$temp = "";
	if( $Form{"Flg1"}==1 )
	{
		if( $Form{"Flg2"}==1 ){ $temp = "TEL・E-Mail"; }
		else				  { $temp = "TEL"; }
	}
	elsif( $Form{"Flg2"}==1 ){ $temp = "E-Mail"; }
	
	$MStr .= "\予\約確認方法：$temp\n" . "-----------------------------------\n";
	
	($sec,$min,$hour,$mday,$mon,$year,$wday)=localtime( time );
	$mon = $mon + 1;
	$year += 1900 ;
	$mon = sprintf("%02d" , $mon );
	$mday = sprintf("%02d" , $mday );
	$hour = sprintf("%02d" , $hour );
	$min = sprintf("%02d" , $min );
	$sec = sprintf("%02d" , $sec );
	
	for( $ii=0; $ii<$RNum; $ii++ )
	{
		$temp = $Form{"RData$ii"};
		( $Y, $M, $D, $T) = split( /_/, $temp );
		
#		&fileutil::GetLockFileStatus( $RLockFileName01 );
#		$ret = &fileutil::SetLockFileStatus( $RLockFileName01, "LOCK" ) ;
#		if( $ret == 1 ){ &InputError( "大変混雑しています。<Br>しばらく時間を置いてからもう一度アクセスして下さい。" ); }
		
		$FileName = $DataFilePath01 . "$Y/" . $DataFileTbl[$M-1];
		@Data = &fileutil::DataFileRead( $FileName );
		
		$temp = $Data[$T*4];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $Money[1], $Money[2], $Money[3], $Money[4], $Money[5], $Money[6], $Money[7], $Money[8], $Money[9], $Money[10], $Money[11], $Money[12], $Money[13], $Money[14], $Money[15] ) = split( /\t/, $temp );
		$temp = $Data[$T*4+1];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $R[1], $R[2], $R[3], $R[4], $R[5], $R[6], $R[7], $R[8], $R[9], $R[10], $R[11], $R[12], $R[13], $R[14], $R[15] ) = split( /\t/, $temp );
		$temp = $Data[$T*4+2];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $Money[16], $Money[17], $Money[18], $Money[19], $Money[20], $Money[21], $Money[22], $Money[23], $Money[24], $Money[25], $Money[26], $Money[27], $Money[28], $Money[29], $Money[30], $Money[31] ) = split( /\t/, $temp );
		$temp = $Data[$T*4+3];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $R[16], $R[17], $R[18], $R[19], $R[20], $R[21], $R[22], $R[23], $R[24], $R[25], $R[26], $R[27], $R[28], $R[29], $R[30], $R[31] ) = split( /\t/, $temp );
		
		#print "<Tr><Td Nowrap Align=Center>$Y\/$M\/$D</Td><Td Nowrap>$Room[$T]　</Td><Td Nowrap>$Money[$D]　</Td><Td Nowrap>$R[$D]　</Td></Tr>";
		$MStr .= "ご\予\約日：$Y\/$M\/$D\n";
		$RoomType = $Room[$T];
#		chomp( $RoomType );
		$RoomType =~ s/\r//g;
		$RoomType =~ s/\n//g;
		$RoomType =~ s/<Br>//g;
		$MStr .= "部屋タイプ名：$RoomType\n";
		$MStr .= "料金：\\$Money[$D]\n";
		$Aki = $Form{"Aki$ii"};
		$ONin = $Form{"ONinsuu$ii"};
		$NNin = $Form{"NNinsuu$ii"};
		$YNin = $Form{"YNinsuu$ii"};
		$SNin = $Form{"SNinsuu$ii"};
		$MStr .= "部屋数：$Aki室\n";
		
		# ログ生成
		$id = "$year$mon$mday$hour$min$sec$ii";
		$Form{"Comment"}=~s/\r//g;
		$Form{"Comment"}=~s/\n/<Br>/g;
		$Log.="$id\t$year$mon$mday$hour$min$sec\t$Form{\"Name\"}\t$Form{\"Furigana\"}\t$Address\t$Form{\"Tel\"}\t$Form{\"Mail\"}\t$Form{\"Company\"}\t$Form{\"Comment\"}\t$Form{\"Flg1\"}\t$Form{\"Flg2\"}\t$Y/$M/$D\t$RoomType\t$Aki\t$ONin\t$NNin\t$YNin\t$SNin\t\n";
		
		$R[$D] -= $Aki;
		
		$Data[$T*4+1] = "$R[1]\t$R[2]\t$R[3]\t$R[4]\t$R[5]\t$R[6]\t$R[7]\t$R[8]\t$R[9]\t$R[10]\t$R[11]\t$R[12]\t$R[13]\t$R[14]\t$R[15]\n";
		$Data[$T*4+3] = "$R[16]\t$R[17]\t$R[18]\t$R[19]\t$R[20]\t$R[21]\t$R[22]\t$R[23]\t$R[24]\t$R[25]\t$R[26]\t$R[27]\t$R[28]\t$R[29]\t$R[30]\t$R[31]\n";
#		&util::Error( "$Data[$T*4+1]<Br>$Data[$T*4+3]" );
		
		if(!open(FDATA,"+<$FileName")){ &util::Error( "ファイルのオープンに失敗しました。 [$FileName]" ); }
		eval flock( FDATA, 2 );
		truncate(OUT, 0);
		seek(OUT, 0, 0);
		print FDATA @Data;
		close(FDATA);
#		fileutil::SetLockFileStatus( $RLockFileName01, "NOLOCK" ) ;
	}
	$MStr.="-----------------------------------\n";
	$MStr.="■オプション\n";
	
	$Total = 0;
	@OP = fileutil::DataFileRead( "./data/option.cgi" );
	for( $ii=0; $ii<@OP; $ii++ )
	{
		@Temp = split( /\t/, $OP[$ii] );
		$Temp[2]=~s/\r//g;
		$Temp[2]=~s/\n//g;
		if( $Form{"$Temp[0]"}==1 )
		{
			$MStr.="・$Temp[1] \\$Temp[2]\n";
			$Total += $Temp[2];
		}
	}
	
	
#	$Tax = int(($Form{"RTotal"}+$Form{"KTax"})*0.05);
	$MStr.="基本料金 \\$Form{\"RTotal\"}\n";
#	$MStr.="サービス料金(10%) \\$Form{\"KTax\"}\n";
#	$MStr.="消費税(5%) \\$Tax\n";
#	$MStr.="入湯税 \\$Form{\"NTax\"}\n";
	
#	$Total = $Form{"NTax"}+$Form{"KTax"}+$Form{"RTotal"}+$Tax;
	$Total += $Form{"RTotal"};
	$MStr.="合計 \\$Total\n";
	
#	$MStr=~s/\r//g;
#	$MStr=~s/\n/<Br>/g;
#	util::Error($MStr);
	
#	$Log=~s/\r//g;
#	$Log=~s/\n/<Br>/g;
#	util::Error($Log);
	push( @LG, $Log );
	if(!open(FDATA,"+<$DataFileName")){ &util::Error( "ファイルのオープンに失敗しました。 [$DataFileName]" ); }
	eval flock( FDATA, 2 );
	truncate(OUT, 0);
	seek(OUT, 0, 0);
	print FDATA @LG;
	close(FDATA);
	
#	$MStr=~s/\r//g;
#	$MStr=~s/\n/<Br>/g;
#	util::Error( $MStr );
	
#	return;
	
	
#	$MStr =~ s/\n/<Br>/g;
#	&util::Error( "$MStr" );
	
# $ma_m		送信者
# $ma_t		あて先
# $msubj	件名
# $mailmsg	本文
	if( $Mail eq "" ){ $Mail = "none"; }
	&mailsend( "$Mail", $Mailto, "宿泊\予\約\申\込み", $MStr );
	if( $Mail ne "none" ){ &mailsend( $Mailto, "$Mail", "宿泊\予\約\申\込み確認", $MStr ); }
	
}

#---------------------------------------------------------------------------------------------------#
#	プラン予約送信
#---------------------------------------------------------------------------------------------------#
sub ReserveMail2()
{
	my ( $temp, $MStr );
	my ( @Temp, @Data, @Data2, $temp, $CategoryNum, $num, $ii, $nn );
	
	@Room = &fileutil::DataFileRead( $RoomTypeFileName01 );
	
	$RNum = $Form{"RNum"};
	$ii=0;
	$SYear = $Form{"SYear"};
	$SMonth = $Form{"SMonth"};
	$SDay = $Form{"SDay"};
	$RNum = $Form{"RNum"};
	
	$MStr = "宿泊プラン予約申込み\n\n";
	
	$Name = $Form{"Name"};
	$Furigana = $Form{"Furigana"};
	$Address = &util::ExtendSelectBox( $IncFile06, $Form{"Address"} );
	$Mail = $Form{"Mail"};
	$Tel = $Form{"Tel"};
	$Company = $Form{"Company"};
	$Comment = $Form{"Comment"};
	$Flg1 = $Form{"Flg1"};
	$Flg2 = $Form{"Flg2"};
	
	$MStr .= "名前：$Name\n";
	$MStr .= "フリガナ：$Furigana\n";
	$MStr .= "住所：$Address\n";
	$MStr .= "E-Mail：$Mail\n";
	$MStr .= "TEL：$Tel\n";
	$MStr .= "会社名：$Company\n";
	$MStr .= "要望：\n$Comment\n";
	$temp = "";
	if( $Form{"Flg1"}==1 )
	{
		if( $Form{"Flg2"}==1 ){ $temp = "TEL・E-Mail"; }
		else				  { $temp = "TEL"; }
	}
	elsif( $Form{"Flg2"}==1 ){ $temp = "E-Mail"; }
	$MStr .= "予約確認方法：$temp\n―――――――――――――――――――\n";
	
	$MStr .= "プラン名：$PlanName[$Form{'Num'}]\n";
	$temp = $Form{'SYear'}+2000;
	$MStr .= "ご予約日：$temp年$Form{'SMonth'}月$Form{'SDay'}日\n";
	$MStr .= "人数：$Form{'Ninzuu'}\n";
	
#	$MStr =~ s/\n/<Br>/g;
#	&util::Error( "$MStr" );
	
# $ma_m		送信者
# $ma_t		あて先
# $msubj	件名
# $mailmsg	本文
	if( $Mail eq "" ){ $Mail = "none"; }
	&mailsend( $Mail, $Mailto, "宿泊プラン予約申込み", $MStr );
#	&mailsend( $Mailto, "$Mail", "宿泊プラン予約申込み確認", $MStr );
	if( $Mail ne "none" ){ &mailsend( $Mailto, "$Mail", "宿泊プラン予約申込み確認", $MStr ); }
	
}

#---------------------------------------------------------------------------------------------------#
#	HTMLファイルのの表示
#	引数：
#		表示するHTMLファイル
#	戻り値：
#		なし
#---------------------------------------------------------------------------------------------------#
sub	DispHtml( @ )
{
	my	( $DatFile ) ;
	my	( @Data , @FData, @Temp, $temp, $temp2, $temp3 ) ;
	my	@MStr = ( '１', '２', '３', '４', '５', '６', '７', '８', '９', '１０', '１１', '１２' );
	my	@YStr = ( '２００１', '２００２', '２００３', '２００４', '２００５', '２００６', '２００７', '２００８', '２００９', '２０１０', '２０１１', '２０１２', '２０１３', '２０１４', '２０１５', '２０１６', '２０１７', '２０１８', '２０１９', '２０２０', '２０２１', '２０２２', '２０２３', '２０２４', '２０２５' );
	
	( $DatFile ) = @_ ;
	
	@Data	= &fileutil::DataFileRead( $DatFile );
	
	print	"Content-type:text/html\n\n" ;
	
	foreach $temp (@Data)
	{
		BK_SWITCH:
		{
			if( $temp =~ /##ExtendAddress##/ )
			{
				$temp	= &util::ExtendSelectBox( $IncFile06, $Form{"Address"} );
				$temp	= &util::str_convert( $temp, "##SelectAddress##", $temp );
				last BK_SWITCH;
			}
			if( $temp =~ /##SelectAddress##/ )
			{
				$temp	= &util::MakeSelectBox( $IncFile06, "Address", 0 );
				$temp	= &util::str_convert( $temp, "##SelectAddress##", $temp );
				last BK_SWITCH;
			}
			if( $temp =~ /##SelectYear##/ )
			{
				$temp	= &util::MakeSelectBox( $IncFile01, "SYear", $Year );
				$temp	= &util::str_convert( $temp, "##SelectYear##", $temp );
				last BK_SWITCH;
			}
			if( $temp =~ /##SelectMonth##/ )
			{
				$temp	= &util::MakeSelectBox( $IncFile02, "SMonth", $Month );
				$temp	= &util::str_convert( $temp, "##SelectMonth##", $temp );
				last BK_SWITCH;
			}
			if( $temp =~ /##SelectDay##/ )
			{
				$Mday	= util::GetDayStr( 'MDAY' );
				$temp	= &MakeDateSelectBox( $IncFile03, "SDay", $Mday );
				$temp	= &util::str_convert( $temp, "##SelectDay##", $temp );
				last BK_SWITCH;
			}
			if( $temp =~ /##SelectYear2##/ )
			{
				$temp	= &util::MakeSelectBox( $IncFile01, "SYear", $Form{'SYear'} );
				$temp	= &util::str_convert( $temp, "##SelectYear##", $temp );
				last BK_SWITCH;
			}
			if( $temp =~ /##SelectMonth2##/ )
			{
				$temp	= &util::MakeSelectBox( $IncFile02, "SMonth", $Form{'SMonth'} );
				$temp	= &util::str_convert( $temp, "##SelectMonth##", $temp );
				last BK_SWITCH;
			}
			if( $temp =~ /##SelectDay2##/ )
			{
				$temp	= &MakeDateSelectBox( $IncFile03, "SDay", $Form{'SDay'}, $Form{'SMonth'} );
				$temp	= &util::str_convert( $temp, "##SelectDay##", $temp );
				last BK_SWITCH;
			}
			if( $temp =~ /##SelectNinzuu##/ )
			{
				print	"<Select Name=\"Ninzuu\">\n";
				for( $ii=1; $ii<10; $ii++ )
				{
					print	"<Option Value=\"$ii\">$ii</Option>\n";
				}
				print	"</Select>\n";
				$temp	= &util::str_convert( $temp, "##SelectNinzuu##", "" );
				last BK_SWITCH;
			}
			if( $temp =~ /##DispYNin##/ )
			{
				$str= "<Select Name=\"YNin\">\n";
				for( $ii=0; $ii<99; $ii++ )
				{
					$str.= "<Option Value=\"$ii\">$ii</Option>\n";
				}
				$str.= "</Select>\n";
				$temp	= &util::str_convert( $temp, "##DispYNin##", $str );
				last BK_SWITCH;
			}
			if( $temp =~ /##DispMO##/ )
			{
				$str= "<Select Name=\"MO\">\n";
				for( $ii=0; $ii<10; $ii++ )
				{
					$str.= "<Option Value=\"$ii\">$ii</Option>\n";
				}
				$str.= "</Select>\n";
				$temp	= &util::str_convert( $temp, "##DispMO##", $str );
				last BK_SWITCH;
			}
			if( $temp =~ /##DispFO##/ )
			{
				$str= "<Select Name=\"FO\">\n";
				for( $ii=0; $ii<10; $ii++ )
				{
					$str.=	"<Option Value=\"$ii\">$ii</Option>\n";
				}
				$str.= "</Select>\n";
				$temp	= &util::str_convert( $temp, "##DispFO##", $str );
				last BK_SWITCH;
			}
			if( $temp =~ /##DispMC##/ )
			{
				$str= "<Select Name=\"MC\">\n";
				for( $ii=0; $ii<10; $ii++ )
				{
					$str.= "<Option Value=\"$ii\">$ii</Option>\n";
				}
				$str.= "</Select>\n";
				$temp	= &util::str_convert( $temp, "##DispMC##", $str );
				last BK_SWITCH;
			}
			if( $temp =~ /##DispFC##/ )
			{
				$str="<Select Name=\"FC\">\n";
				for( $ii=0; $ii<10; $ii++ )
				{
					$str.="<Option Value=\"$ii\">$ii</Option>\n";
				}
				$str.="</Select>\n";
				$temp	= &util::str_convert( $temp, "##DispFC##", $str );
				last BK_SWITCH;
			}
			if( $temp =~ /##DispYC##/ )
			{
				$str="<Select Name=\"YC\">\n";
				for( $ii=0; $ii<10; $ii++ )
				{
					$str.="<Option Value=\"$ii\">$ii</Option>\n";
				}
				$str.="</Select>\n";
				$temp	= &util::str_convert( $temp, "##DispYC##", $str );
				last BK_SWITCH;
			}
			if( $temp =~ /##DispRoomData##/ )
			{
				&DispRoomData();
				$temp	= &util::str_convert( $temp, "##DispRoomData##", "" );
				last BK_SWITCH;
			}
			if( $temp =~ /##DispReserveList##/ )
			{
				&DispReserveList();
				$temp	= &util::str_convert( $temp, "##DispReserveList##", "" );
				last BK_SWITCH;
			}
			if( $temp =~ /##DispReserveList2##/ )
			{
				&DispReserveList2();
				$temp	= &util::str_convert( $temp, "##DispReserveList2##", "" );
				last BK_SWITCH;
			}
			if( $temp =~ /##Comment##/ )
			{
				$temp2 = $Form{"Comment"};
				$temp2 =~ s/\n/<Br>/g;
				$temp	= &util::str_convert( $temp, "##Comment##", $temp2 );
				last BK_SWITCH;
			}
			if( $temp =~ /##CheckFlg##/ )
			{
				print	"<Input Type=HIDDEN Name=\"Name\" Value=\"$Form{'Name'}\">\n";
				print	"<Input Type=HIDDEN Name=\"Furigana\" Value=\"$Form{'Furigana'}\">\n";
				print	"<Input Type=HIDDEN Name=\"Address\" Value=\"$Form{'Address'}\">\n";
				print	"<Input Type=HIDDEN Name=\"Address2\" Value=\"$Form{'Address2'}\">\n";
				print	"<Input Type=HIDDEN Name=\"Tel\" Value=\"$Form{'Tel'}\">\n";
				print	"<Input Type=HIDDEN Name=\"Tel2\" Value=\"$Form{'Tel2'}\">\n";
				print	"<Input Type=HIDDEN Name=\"Zip1\" Value=\"$Form{'Zip1'}\">\n";
				print	"<Input Type=HIDDEN Name=\"Zip2\" Value=\"$Form{'Zip2'}\">\n";
				print	"<Input Type=HIDDEN Name=\"KTime\" Value=\"$Form{'KTime'}\">\n";
				print	"<Input Type=HIDDEN Name=\"YTime\" Value=\"$Form{'YTime'}\">\n";
				print	"<Input Type=HIDDEN Name=\"YNin\" Value=\"$Form{'YNin'}\">\n";
				print	"<Input Type=HIDDEN Name=\"MO\" Value=\"$Form{'MO'}\">\n";
				print	"<Input Type=HIDDEN Name=\"FO\" Value=\"$Form{'FO'}\">\n";
				print	"<Input Type=HIDDEN Name=\"MC\" Value=\"$Form{'MC'}\">\n";
				print	"<Input Type=HIDDEN Name=\"FC\" Value=\"$Form{'FC'}\">\n";
				print	"<Input Type=HIDDEN Name=\"YC\" Value=\"$Form{'YC'}\">\n";
				print	"<Input Type=HIDDEN Name=\"Mail\" Value=\"$Form{'Mail'}\">\n";
				print	"<Input Type=HIDDEN Name=\"Company\" Value=\"$Form{'Company'}\">\n";
				print	"<Input Type=HIDDEN Name=\"Comment\" Value=\"$Form{'Comment'}\">\n";
				print	"<Input Type=HIDDEN Name=\"Flg1\" Value=\"$Form{'Flg1'}\">\n";
				print	"<Input Type=HIDDEN Name=\"Flg2\" Value=\"$Form{'Flg2'}\">\n";
				
				print	"<Input Type=HIDDEN Name=\"SYear\" Value=\"$Form{'SYear'}\">\n";
				print	"<Input Type=HIDDEN Name=\"SMonth\" Value=\"$Form{'SMonth'}\">\n";
				print	"<Input Type=HIDDEN Name=\"SDay\" Value=\"$Form{'SDay'}\">\n";
				print	"<Input Type=HIDDEN Name=\"Ninzuu\" Value=\"$Form{'Ninzuu'}\">\n";
				print	"<Input Type=HIDDEN Name=\"Num\" Value=\"$Form{'Num'}\">\n";
				
				$temp2 = "";
				if( $Form{"Flg1"}==1 )
				{
					if( $Form{"Flg2"}==1 ){ $temp2 = "TEL・E-Mail"; }
					else				  { $temp2 = "TEL"; }
				}
				elsif( $Form{"Flg2"}==1 ){ $temp2 = "E-Mail"; }
				$temp	= &util::str_convert( $temp, "##CheckFlg##", $temp2 );
				last BK_SWITCH;
			}
			if( $temp =~ /##SPreviewComment##/ )
			{
				&DispSPreview();
				$temp	= &util::str_convert( $temp, "##SPreviewComment##", "" );
				last BK_SWITCH;
			}
			if( $temp =~ /##PPreviewComment##/ )
			{
				&DispPPreview();
				$temp	= &util::str_convert( $temp, "##PPreviewComment##", "" );
				last BK_SWITCH;
			}
			if( $temp =~ /##DispPlanList##/ )
			{
				&DispPlanList();
				$temp	= &util::str_convert( $temp, "##DispPlanList##", "" );
				last BK_SWITCH;
			}
			if( $temp =~ /##DispCalender##/ )
			{
				DispCalender();
				$temp	= &util::str_convert( $temp, "##DispCalender##", "" );
			}
			if( $temp =~ /##DispOptionList##/ )
			{
				DispOptionList();
				$temp	= &util::str_convert( $temp, "##DispOptionList##", "" );
			}
			if( $temp =~ /##DispOptionList2##/ )
			{
				DispOptionList2();
				$temp	= &util::str_convert( $temp, "##DispOptionList2##", "" );
			}
			$temp = &util::str_convert( $temp, "##NTax##", $Form{"NTax"} );
			$temp = &util::str_convert( $temp, "##KTax##", $Form{"KTax"} );
			$temp = &util::str_convert( $temp, "##RTotal##", $Form{"RTotal"} );
			$temp = &util::str_convert( $temp, "##DispMonth##", $month );
			
			$temp = &util::str_convert( $temp, "##SendNum##", $Form{"Num"} );
			$temp = &util::str_convert( $temp, "##DispPlanName##", $PlanName[$Form{"Num"}] );
			$temp = &util::str_convert( $temp, "##DispKikan##", $KikanTbl[$Form{"Num"}] );
			$temp = &util::str_convert( $temp, "##DispNinzuu##", $Form{"Ninzuu"} );
			
			$temp = &util::str_convert( $temp, "##DispYear##", $Form{"SYear"}+2000 );
			$temp = &util::str_convert( $temp, "##DispMonth##", $Form{"SMonth"} );
			$temp = &util::str_convert( $temp, "##DispDay##", $Form{"SDay"} );
			$temp = &util::str_convert( $temp, "##Name##", $Form{"Name"} );
			$temp = &util::str_convert( $temp, "##Furigana##", $Form{"Furigana"} );
			$temp = &util::str_convert( $temp, "##Tel##", $Form{"Tel"} );
			$temp = &util::str_convert( $temp, "##Mail##", $Form{"Mail"} );
			$temp = &util::str_convert( $temp, "##Company##", $Form{"Company"} );
			$temp = &util::str_convert( $temp, "##Zip1##", $Form{"Zip1"} );
			$temp = &util::str_convert( $temp, "##Zip2##", $Form{"Zip2"} );
			$temp = &util::str_convert( $temp, "##Address2##", $Form{"Address2"} );
			$temp = &util::str_convert( $temp, "##MO##", $Form{"MO"} );
			$temp = &util::str_convert( $temp, "##FO##", $Form{"FO"} );
			$temp = &util::str_convert( $temp, "##MC##", $Form{"MC"} );
			$temp = &util::str_convert( $temp, "##FC##", $Form{"FC"} );
			$temp = &util::str_convert( $temp, "##YC##", $Form{"YC"} );
			$temp = &util::str_convert( $temp, "##Tel2##", $Form{"Tel2"} );
			$temp = &util::str_convert( $temp, "##KTime##", $Form{"KTime"} );
			$temp = &util::str_convert( $temp, "##YTime##", $Form{"YTime"} );
			$temp = &util::str_convert( $temp, "##YNin##", $Form{"YNin"} );

			$temp = &util::str_convert( $temp, "##CGIFullUrl##", $CGIFullUrl );
			$temp = &util::str_convert( $temp, "##CGIFileName##", $CGIFileName );
			$temp = &util::str_convert( $temp, "##ImgUrlHeader##", $ImgUrlHeader );
		}
		print	$temp;
	}
}

#---------------------------------------------------------------------------------------------------#
#		オプション一覧表示
#---------------------------------------------------------------------------------------------------#
sub DispOptionList()
{
	my ( @Data, @Temp, $temp, $CategoryNum, @M, @R, $num, $ii, $nn, $wstr );
	
	@Data = fileutil::DataFileRead( "./data/option.cgi" );
	for( $ii=0; $ii<@Data; $ii++ )
	{
		@Temp = split( /\t/, $Data[$ii] );
		$Temp[2] =~ s/\r//g;
		$Temp[2] =~ s/\n//g;
		
		$wstr.="<Input Type=checkbox Name=\"$Temp[0]\" Value=\"1\">$Temp[1](\\$Temp[2])";
		
	}
	print $wstr;
	
}

#---------------------------------------------------------------------------------------------------#
#		オプション選択一覧表示
#---------------------------------------------------------------------------------------------------#
sub DispOptionList2()
{
	my ( @Data, @Temp, $temp, $CategoryNum, @M, @R, $num, $ii, $nn, $wstr );
	
	@Data = fileutil::DataFileRead( "./data/option.cgi" );
	$tm = 0;
	for( $ii=0; $ii<@Data; $ii++ )
	{
		@Temp = split( /\t/, $Data[$ii] );
		$Temp[2] =~ s/\r//g;
		$Temp[2] =~ s/\n//g;
		
		if( $Form{"$Temp[0]"} == 1 )
		{
			$wstr.="<Tr><Td>$Temp[1]</Td><Td Align=right>\\$Temp[2]</Td></Tr>\n";
			$wstr.="<Input Type=HIDDEN Name=\"$Temp[0]\" Value=1>";
			$tm+=$Temp[2];
		}
	}
#	$Form{"KTax"} = int($Form{"KTax"}/10);
	
	
#	$tm += $Form{"NTax"} + $Form{"KTax"} + $Form{"RTotal"} + $Form{"Tax"};
#	$tm += $Form{"RTotal"};
#	if( $Form{"Tk"}!=3 ){ $wstr.="<Tr><Td>基本料金</Td><Td Align=right>\\$Form{\"RTotal\"}</Td></Tr>\n"; }
#	if( $Form{"Tk"}!=3 ){ $wstr.="<Tr><Td>サービス料金(10%)</Td><Td Align=right>\\$Form{\"KTax\"}</Td></Tr>\n"; }
#	if( $Form{"Tk"}!=3 ){ $wstr.="<Tr><Td>消費税(5%)</Td><Td Align=right>\\$Form{\"Tax\"}</Td></Tr>\n"; }
#	if( $Form{"Tk"}!=3 ){ $wstr.="<Tr><Td>入湯税</Td><Td Align=right>\\$Form{\"NTax\"}</Td></Tr>\n"; }
	$wstr.="<Tr><Td>合計</Td><Td Align=right>\\$tm</Td></Tr>\n";
	print $wstr;
	
}

#---------------------------------------------------------------------------------------------------#
#		フォームデータチェック
#---------------------------------------------------------------------------------------------------#
sub CheckFormData()
{
	my ( @Temp, $temp, $CategoryNum, @M, @R, $num, $ii, $nn );
	
	$SYear	= $Form{'SYear'};
	$SMonth	= $Form{'SMonth'};
	$SDay	= $Form{'SDay'};
	$SYear2 = $SYear;
	$SMonth2= $SMonth;
	$SDay2	= $SDay;
	
	@Room = &fileutil::DataFileRead( $RoomTypeFileName01 );
#	@Temp = &fileutil::DataFileRead( $DataFilePath01 . "$SYear/" . $DataFileTbl[$Form{'SMonth'}-1] );
#	@Temp2= &fileutil::DataFileRead( $DataFilePath01 . "$SYear/" . $DataFileTbl[$Form{'SMonth'}-1] );
	$ii=0;
	$nn=0;
	$flg=0;
#	&util::Error( "R2001_8_7_0_99" );
#	&util::Error( $Form{"R2001_8_7_0_99"} );
	$str="_";
	foreach $RType( @Room )
	{
#		chomp( $RType );
		$RType =~ s/\r//g;
		$RType =~ s/\n//g;
		if( $RType eq"" ){ $ii++; next; }
		
		$SYear	= $SYear2;
		$SMonth	= $SMonth2;
		$SDay	= $SDay2;
		for( $jj=0; $jj<7; $jj++ )
		{
			if( $Form{"$SYear$str$SMonth$str$SDay$str$ii"} == 1 )
			{
				$Reserve[$nn] = "$SYear$str$SMonth$str$SDay$str$ii";
				$flg=1;
				$nn++;
			}
			$SDay++;
			if( $SDay > $MaxDay[$SMonth-1] )
			{
				$SDay=1;
				if( $SMonth == 12 ){ $SMonth=1; $SYear++; }
				else			   { $SMonth++; }
			}
		}
		$ii++;
	}
	if( $flg==0 ){ &InputError( "部屋が選択されていません。" ); }
	
#	&util::Error( $Reserve[0] );
}

#---------------------------------------------------------------------------------------------------#
#		予約リストの表示
#---------------------------------------------------------------------------------------------------#
sub DispReserveList()
{
	my ( @Temp, @Data, @Data2, $temp, $CategoryNum, @M, @R, $num, $ii, $nn );
	
	@Room = &fileutil::DataFileRead( $RoomTypeFileName01 );

	@Temp = @Reserve;
	$ii=0;
	print	"<Input Type=HIDDEN Name=\"SYear\" Value=\"$SYear\">\n";
	print	"<Input Type=HIDDEN Name=\"SMonth\" Value=\"$SMonth\">\n";
	print	"<Input Type=HIDDEN Name=\"SDay\" Value=\"$SDay\">\n";
	$temp = @Temp;
	print	"<Input Type=HIDDEN Name=\"RNum\" Value=\"$temp\">";
	foreach $temp( @Temp )
	{
		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		print	"<Input Type=HIDDEN Name=\"RData$ii\" Value=\"$temp\">";
		( $Y, $M, $D, $T) = split( /_/, $temp );
		@Data = &fileutil::DataFileRead( $DataFilePath01 . "$Y/" . $DataFileTbl[$M-1] );
		
		$temp = $Data[$T*4];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $Money[1], $Money[2], $Money[3], $Money[4], $Money[5], $Money[6], $Money[7], $Money[8], $Money[9], $Money[10], $Money[11], $Money[12], $Money[13], $Money[14], $Money[15] ) = split( /\t/, $temp );
		$temp = $Data[$T*4+1];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $R[1], $R[2], $R[3], $R[4], $R[5], $R[6], $R[7], $R[8], $R[9], $R[10], $R[11], $R[12], $R[13], $R[14], $R[15] ) = split( /\t/, $temp );
		$temp = $Data[$T*4+2];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $Money[16], $Money[17], $Money[18], $Money[19], $Money[20], $Money[21], $Money[22], $Money[23], $Money[24], $Money[25], $Money[26], $Money[27], $Money[28], $Money[29], $Money[30], $Money[31] ) = split( /\t/, $temp );
		$temp = $Data[$T*4+3];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $R[16], $R[17], $R[18], $R[19], $R[20], $R[21], $R[22], $R[23], $R[24], $R[25], $R[26], $R[27], $R[28], $R[29], $R[30], $R[31] ) = split( /\t/, $temp );
		
		print	"<Tr><Td Nowrap Align=Center>$Y\/$M\/$D</Td><Td Nowrap>$Room[$T]" . "　</Td><Td Nowrap>\\$Money[$D]" . "　</Td><Td Nowrap>\n";
		
		print	"<Select Name=\"Aki$ii\">\n";
		for( $jj=1; $jj<=$R[$D]; $jj++ )
		{
			if( $jj<10 ){ print	"<Option Value=\"$jj\">0$jj</Option>\n"; }
			else		{ print	"<Option Value=\"$jj\">$jj</Option>\n"; }
		}
		print	"</Selcet>";
		print	"</Td><Td Nowrap>\n";
		print	"<Select Name=\"ONinsuu$ii\">\n";
		for( $jj=1; $jj<=10; $jj++ )
		{
			if( $jj<10 ){ print	"<Option Value=\"$jj\">0$jj</Option>\n"; }
			else		{ print	"<Option Value=\"$jj\">$jj</Option>\n"; }
		}
		print	"</Selcet>人";
		print	"</Td><Td Nowrap>\n";
		print	"<Select Name=\"SNinsuu$ii\">\n";
		for( $jj=0; $jj<=10; $jj++ )
		{
			if( $jj<10 ){ print	"<Option Value=\"$jj\">0$jj</Option>\n"; }
			else		{ print	"<Option Value=\"$jj\">$jj</Option>\n"; }
		}
		print	"</Selcet>人";
		print	"</Td><Td Nowrap>\n";
		print	"<Select Name=\"YNinsuu$ii\">\n";
		for( $jj=0; $jj<=10; $jj++ )
		{
			if( $jj<10 ){ print	"<Option Value=\"$jj\">0$jj</Option>\n"; }
			else		{ print	"<Option Value=\"$jj\">$jj</Option>\n"; }
		}
		print	"</Selcet>人";
		print	"</Td><Td Nowrap>\n";
		print	"<Select Name=\"NNinsuu$ii\">\n";
		for( $jj=0; $jj<=10; $jj++ )
		{
			if( $jj<10 ){ print	"<Option Value=\"$jj\">0$jj</Option>\n"; }
			else		{ print	"<Option Value=\"$jj\">$jj</Option>\n"; }
		}
		print	"</Selcet>人";
		print	"</Td>\n";
		
		print	"</Tr>\n";
		
		$ii++;
	}
}

#---------------------------------------------------------------------------------------------------#
#		予約リストの表示２
#---------------------------------------------------------------------------------------------------#
sub DispReserveList2()
{
	my ( @Temp, @Data, @Data2, $temp, $CategoryNum, @M, @R, $num, $ii, $nn );
	
	@Room = &fileutil::DataFileRead( $RoomTypeFileName01 );

	$RNum = $Form{"RNum"};
	$ii=0;
	print	"<Input Type=HIDDEN Name=\"SYear\" Value=\"$Form{'SYear'}\">\n";
	print	"<Input Type=HIDDEN Name=\"SMonth\" Value=\"$Form{'SMonth'}\">\n";
	print	"<Input Type=HIDDEN Name=\"SDay\" Value=\"$Form{'SDay'}\">\n";
	print	"<Input Type=HIDDEN Name=\"RNum\" Value=\"$RNum\">";
	
#	$SYear	= &util::ExtendSelectBox( $IncFile01, $Form{'SYear'} );
	
#	&util::Error( $Form{"RNum"} );
	
	for( $ii=0; $ii<$RNum; $ii++ )
	{
		$temp = $Form{"RData$ii"};
		print	"<Input Type=HIDDEN Name=\"RData$ii\" Value=\"$temp\">";
		( $Y, $M, $D, $T) = split( /_/, $temp );
		@Data = &fileutil::DataFileRead( $DataFilePath01 . "$Y/" . $DataFileTbl[$M-1] );
		
		$temp = $Data[$T*4];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $Money[1], $Money[2], $Money[3], $Money[4], $Money[5], $Money[6], $Money[7], $Money[8], $Money[9], $Money[10], $Money[11], $Money[12], $Money[13], $Money[14], $Money[15] ) = split( /\t/, $temp );
		$temp = $Data[$T*4+1];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $R[1], $R[2], $R[3], $R[4], $R[5], $R[6], $R[7], $R[8], $R[9], $R[10], $R[11], $R[12], $R[13], $R[14], $R[15] ) = split( /\t/, $temp );
		$temp = $Data[$T*4+2];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $Money[16], $Money[17], $Money[18], $Money[19], $Money[20], $Money[21], $Money[22], $Money[23], $Money[24], $Money[25], $Money[26], $Money[27], $Money[28], $Money[29], $Money[30], $Money[31] ) = split( /\t/, $temp );
		$temp = $Data[$T*4+3];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $R[16], $R[17], $R[18], $R[19], $R[20], $R[21], $R[22], $R[23], $R[24], $R[25], $R[26], $R[27], $R[28], $R[29], $R[30], $R[31] ) = split( /\t/, $temp );
		
		$Aki = $Form{"Aki$ii"};
		$ONin = $Form{"ONinsuu$ii"};
		$NNin = $Form{"NNinsuu$ii"};
		$YNin = $Form{"YNinsuu$ii"};
		$SNin = $Form{"SNinsuu$ii"};
		
		
		$OTax = int($Money[$D]*0.1)*$ONin;
		$NTax = 210*$NNin;
		$YTax = int((int($Money[$D]*0.5)*0.1))*$YNin;
		$STax = int((int($Money[$D]*0.7)*0.1))*$SNin;
		$Form{"KTax"} += $OTax + $NTax + $YTax + $STax;
#		util::Error( "$OTax/$NTax/$YTax/$STax" );
#		util::Error( $Form{"KTax"} );
		$Form{"NTax"} += $ONin * 150;
		$Form{"RTotal"}+= $Money[$D]*$ONin;
		$Form{"RTotal"}+= ($Money[$D]*0.5)*$YNin;
		$Form{"RTotal"}+= ($Money[$D]*0.7)*$SNin;
		$Form{"RTotal"}+= 2100*$NNin;
		
		print	"<Tr><Td Nowrap Align=Center>$Y\/$M\/$D</Td><Td Nowrap>$Room[$T]　</Td><Td Nowrap>\\$Money[$D]　</Td>";
		print	"<Td Nowrap Align=Center>$Aki　</Td>\n";
		print	"<Td Nowrap Align=Center>$ONin　</Td>\n";
		print	"<Td Nowrap Align=Center>$SNin　</Td>\n";
		print	"<Td Nowrap Align=Center>$YNin　</Td>\n";
		print	"<Td Nowrap Align=Center>$NNin　</Td>\n";
		print	"</Tr>\n";
		print	"<Input Type=HIDDEN Name=\"Aki$ii\" Value=\"$Aki\">";
		print	"<Input Type=HIDDEN Name=\"ONinsuu$ii\" Value=\"$ONin\">";
		print	"<Input Type=HIDDEN Name=\"NNinsuu$ii\" Value=\"$NNin\">";
		print	"<Input Type=HIDDEN Name=\"YNinsuu$ii\" Value=\"$YNin\">";
		print	"<Input Type=HIDDEN Name=\"SNinsuu$ii\" Value=\"$SNin\">";
	}
	$Form{"Tax"} = int(($Form{"RTotal"}+$Form{"KTax"})*0.05);
#	util::Error( $Form{"Tax"} );
}

#---------------------------------------------------------------------------------------------------#
#		空き室情報表示
#---------------------------------------------------------------------------------------------------#
sub DispRoomData()
{
	my ( @Temp, $temp, $CategoryNum, @M, @R, $num, $ii, $nn );
	
	$SYear	= &util::ExtendSelectBox( $IncFile01, $Form{'SYear'} );
	$SMonth	= &util::ExtendSelectBox( $IncFile02, $Form{'SMonth'} );
	$SDay	= &util::ExtendSelectBox( $IncFile03, $Form{'SDay'} );
	$SYear2 = $SYear;
	$SMonth2= $SMonth;
	$SDay2	= $SDay;
	
	if( $SDay>$MaxDay[$SMonth-1] )
	{
		print	"</Table>\n";
		print	"<Table Border=0 Cellspacing=0 Cellpadding=0>\n\n";
		print		"<Tr><Td Nowrap><B>日にちの入力が不正です。";
		print		"$SMonth月は$MaxDay[$SMonth-1]日までです。<Br>\n";
		print		"お手数ですが前のページに戻り、$MaxDay[$SMonth-1]日までの日にちを入力して下さい。</B></Td></Tr>\n";
		print	"</Table><Br><Br>\n";
		print	"<Input Type=button Value=\" 戻る \" onclick=\"history.back()\">";
		print	"</Center>";
		print	"</Body></Html>\n";
		exit;
		#&InputError( "入力エラー" );
	}
#	print	"<Tr><Td Nowrap>\n";
#	print		"<Table><Tr><Td Nowrap><B><Font Size=3>○：空室あり</Font></B></Td><Td>　</Td><Td Nowrap><B><Font Size=3 Color=#FF0000>満</Font><Font Size=3>：満室</Font></B></Td></Tr></Table>\n";
#	print	"</Td></Tr>\n";
	
	
	@Room = &fileutil::DataFileRead( $RoomTypeFileName01 );

	@Temp = &fileutil::DataFileRead( $DataFilePath01 . "$SYear/" . $DataFileTbl[$Form{'SMonth'}-1] );
	if( $Temp[0]==-1 ){ @Temp = (); }

#	util::Error( $DataFilePath01 . "$SYear/" . $DataFileTbl[$Form{'SMonth'}-1] );
	
	
#	@Temp = &fileutil::DataFileRead( $DataFilePath01 . "2001/" . $DataFileTbl[8-1] );

#	@Temp2= &fileutil::DataFileRead( $DataFilePath01 . "$SYear/" . $DataFileTbl[$Form{'SMonth'}-1] );
#	&util::Error( "$SYear/$SMonth" );
	
	print	"<Input Type=HIDDEN Name=\"SYear\" Value=\"$SYear\">\n";
	print	"<Input Type=HIDDEN Name=\"SMonth\" Value=\"$SMonth\">\n";
	print	"<Input Type=HIDDEN Name=\"SDay\" Value=\"$SDay\">\n";
	
	print	"<Tr><Td Nowrap>\n";
	print	"<Table Border=1 Cellspacing=0 Cellpadding=2>\n";
	print		"<Tr>\n";
	print		"<Td Align=Center Height=32 Width=95>　</Font></Td>\n";
	
#	$Wday = ($SWday[$SMonth2-1] + $SDay2-1) % 7;
	$temp	= $SYear;
#	&util::Error( $temp );
#	$WTemp	= $SWTbl->[$temp-2001];
#	$Wday	= (@$WTemp[$SMonth2-1] + $SDay2-1) % 7;
	
#	if( $SYear==2004 )	 { $Wday = ($SWday[$SMonth2-1] + $SDay2-1) % 7; }
#	elsif( $SYear==2005 ){ $Wday = ($SWday2[$SMonth2-1] + $SDay2-1) % 7; }
	
	$Wday = GetWeek( $SYear, $SMonth2, $SDay2 );
	
#	&util::Error( $Wday );
	
	for( $ii=0; $ii<7; $ii++ )
	{
		if( $Wday==0 )	 { print "<Td Width=95 Bgcolor=#FFF4F4 Colspan=3 Align=Center>$SYear/$SMonth/$SDay<Br><Font Color=#FF0000>($WeekDay[$Wday])</Font></Td>\n"; }
#		elsif( $Wday==5 ){ print "<Td Width=95 Bgcolor=#FFF4F4 Colspan=3 Align=Center>$SYear/$SMonth/$SDay<Br><Font Color=#0080FF>($WeekDay[$Wday])</Font></Td>\n"; }
		elsif( $Wday==6 ){ print "<Td Width=95 Bgcolor=#FFF4F4 Colspan=3 Align=Center>$SYear/$SMonth/$SDay<Br><Font Color=#0080FF>($WeekDay[$Wday])</Font></Td>\n"; }
		else			 { print "<Td Width=95 Bgcolor=#FFF4F4 Colspan=3 Align=Center>$SYear/$SMonth/$SDay<Br>($WeekDay[$Wday])</Td>\n"; }
		
		if( $Wday==6 ){ $Wday=0; }
		else		  { $Wday++; }
		$SDay++;
		if( $SDay > $MaxDay[$SMonth-1] )
		{
			$SDay=1;
			if( $SMonth == 12 ){ $SMonth=1; $SYear++; }
			else			   { $SMonth++; }
		}
	}
	print	"</Tr><Tr><Td Height=32>　</Td>\n";
	for( $ii=0; $ii<7; $ii++ ){ print	"<Td Nowrap Colspan=2 Bgcolor=#F4F4FF Align=Center><Font Size=1>空室<Br>状況</Font></Td><Td Nowrap Bgcolor=#F4FFF4 Align=Center><Font Size=2>料金</Font></Td>\n"; }
	print	"</Tr>\n";
	$ii=0;
	$nn=0;
	$str="_";
	foreach $RType( @Room )
	{
#		chomp( $RType );
		$RType =~ s/\r//g;
		$RType =~ s/\n//g;
		if( $RType eq"" ){ $nn++; $ii++; next; }
		
		$temp = $Temp[$ii*4];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $M[1], $M[2], $M[3], $M[4], $M[5], $M[6], $M[7], $M[8], $M[9], $M[10], $M[11], $M[12], $M[13], $M[14], $M[15] ) = split( /\t/, $temp );
		$temp = $Temp[$ii*4+1];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $R[1], $R[2], $R[3], $R[4], $R[5], $R[6], $R[7], $R[8], $R[9], $R[10], $R[11], $R[12], $R[13], $R[14], $R[15] ) = split( /\t/, $temp );
		$temp = $Temp[$ii*4+2];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $M[16], $M[17], $M[18], $M[19], $M[20], $M[21], $M[22], $M[23], $M[24], $M[25], $M[26], $M[27], $M[28], $M[29], $M[30], $M[31] ) = split( /\t/, $temp );
		$temp = $Temp[$ii*4+3];
#		chomp( $temp );
		$temp =~ s/\r//g;
		$temp =~ s/\n//g;
		( $R[16], $R[17], $R[18], $R[19], $R[20], $R[21], $R[22], $R[23], $R[24], $R[25], $R[26], $R[27], $R[28], $R[29], $R[30], $R[31] ) = split( /\t/, $temp );
		
		$SYear	= $SYear2;
		$SMonth	= $SMonth2;
		$SDay	= $SDay2;
		print	"<Tr>\n";
		print	"<Td Bgcolor=#FFFFEE Width=200 Height=32><Font Size=2>$RType</Font></Td>\n";
		$flg=0;
		for( $jj=0; $jj<7; $jj++ )
		{
			if( $R[$SDay] > 0 )
			{
				if( $R[$SDay] <= $ChkAki ){ print "<Td Bgcolor=#F4F4FF Width=30 Align=Center><Font Size=1>△[$R[$SDay]]</Font></Td><Td Nowrap Bgcolor=#F4F4FF><Input Type=checkbox Name=\"$SYear$str$SMonth$str$SDay$str$ii\" Value=\"1\"></Td>\n"; }
				else				{ print "<Td Bgcolor=#F4F4FF Width=30 Align=Center><Font Size=1>○[$R[$SDay]]</Font></Td><Td Nowrap Bgcolor=#F4F4FF><Input Type=checkbox Name=\"$SYear$str$SMonth$str$SDay$str$ii\" Value=\"1\"></Td>\n"; }
			} else { print "<Td Bgcolor=#F4F4FF Align=Center><Font Size=1 Color=#FF0000>満</Font></Td><Td Nowrap Bgcolor=#F4F4FF Width=20>　</Td>\n"; }
			print	"<Td Bgcolor=#F4FFF4 Width=36 Align=Center><Font Size=2>\\$M[$SDay]</Font></Td>\n";
			$SDay++;
			if( $SDay > $MaxDay[$SMonth-1] )
			{
				$SDay=1;
				if( $SMonth == 12 )
				{
					$SMonth=1;
					$SYear++;
					@Temp = &fileutil::DataFileRead( $DataFilePath01 . "$SYear/" . $DataFileTbl[$SMonth-1] );
					if( $Temp[0]==-1 ){ @Temp = (); }
					$temp = $Temp[$ii*4];
#					chomp( $temp );
					$temp =~ s/\r//g;
					$temp =~ s/\n//g;
					( $M[1], $M[2], $M[3], $M[4], $M[5], $M[6], $M[7], $M[8], $M[9], $M[10], $M[11], $M[12], $M[13], $M[14], $M[15] ) = split( /\t/, $temp );
					$temp = $Temp[$ii*4+1];
#					chomp( $temp );
					$temp =~ s/\r//g;
					$temp =~ s/\n//g;
					( $R[1], $R[2], $R[3], $R[4], $R[5], $R[6], $R[7], $R[8], $R[9], $R[10], $R[11], $R[12], $R[13], $R[14], $R[15] ) = split( /\t/, $temp );
					$temp = $Temp[$ii*4+2];
#					chomp( $temp );
					$temp =~ s/\r//g;
					$temp =~ s/\n//g;
					( $M[16], $M[17], $M[18], $M[19], $M[20], $M[21], $M[22], $M[23], $M[24], $M[25], $M[26], $M[27], $M[28], $M[29], $M[30], $M[31] ) = split( /\t/, $temp );
					$temp = $Temp[$ii*4+3];
#					chomp( $temp );
					$temp =~ s/\r//g;
					$temp =~ s/\n//g;
					( $R[16], $R[17], $R[18], $R[19], $R[20], $R[21], $R[22], $R[23], $R[24], $R[25], $R[26], $R[27], $R[28], $R[29], $R[30], $R[31] ) = split( /\t/, $temp );
					$flg=2;
				}
				else
				{
					$SMonth++;
					@Temp = &fileutil::DataFileRead( $DataFilePath01 . "$SYear/" . $DataFileTbl[$SMonth-1] );
					if( $Temp[0]==-1 ){ @Temp = (); }
					$temp = $Temp[$ii*4];
#					chomp( $temp );
					$temp =~ s/\r//g;
					$temp =~ s/\n//g;
					( $M[1], $M[2], $M[3], $M[4], $M[5], $M[6], $M[7], $M[8], $M[9], $M[10], $M[11], $M[12], $M[13], $M[14], $M[15] ) = split( /\t/, $temp );
					$temp = $Temp[$ii*4+1];
#					chomp( $temp );
					$temp =~ s/\r//g;
					$temp =~ s/\n//g;
					( $R[1], $R[2], $R[3], $R[4], $R[5], $R[6], $R[7], $R[8], $R[9], $R[10], $R[11], $R[12], $R[13], $R[14], $R[15] ) = split( /\t/, $temp );
					$temp = $Temp[$ii*4+2];
#					chomp( $temp );
					$temp =~ s/\r//g;
					$temp =~ s/\n//g;
					( $M[16], $M[17], $M[18], $M[19], $M[20], $M[21], $M[22], $M[23], $M[24], $M[25], $M[26], $M[27], $M[28], $M[29], $M[30], $M[31] ) = split( /\t/, $temp );
					$temp = $Temp[$ii*4+3];
#					chomp( $temp );
					$temp =~ s/\r//g;
					$temp =~ s/\n//g;
					( $R[16], $R[17], $R[18], $R[19], $R[20], $R[21], $R[22], $R[23], $R[24], $R[25], $R[26], $R[27], $R[28], $R[29], $R[30], $R[31] ) = split( /\t/, $temp );
					$flg=1;
				}
			}
		}
			if( $flg==1 )
			{
				$SMonth--;
				@Temp = &fileutil::DataFileRead( $DataFilePath01 . "$SYear/" . $DataFileTbl[$SMonth-1] );
				$flg=0;
			}
			elsif( $flg==2 )
			{
				$SMonth=12;
				$SYear--;
				@Temp = &fileutil::DataFileRead( $DataFilePath01 . "$SYear/" . $DataFileTbl[$SMonth-1] );
				$flg=0;
			}
		
		print	"</Tr>\n";
		$nn++;
		$ii++;
	}
	
	print	"</Table></Td></Tr>\n";
}


#---------------------------------------------------------------------------------------------------#
#		曜日取得
#---------------------------------------------------------------------------------------------------#
sub GetWeek()
{
	my ( $year, $month, $day );
	( $year, $month, $day ) = @_;
	
	if ($month == 1 || $month == 2)
	{
		$yr = $year;
		$yr--;
		$mt = $month;
		$mt += 12;
	}
	else
	{
		$yr = $year;
		$mt = $month;
	}
	$i = ($yr + int($yr/4) - int($yr/100) + int($yr/400) + int((13*$mt + 8)/5) + $day) %7;
	return $i;
}

#-----------------------------------------------------------------------------------------------------#
#	セレクトボックスの作成
#	引数
#		セレクトボックス用データファイル名
#		<Select Name=xxxx>のName部分
#		selectedにする Index
#	戻り値
#		<Select>〜</Select>文字列
#-----------------------------------------------------------------------------------------------------#
sub	MakeDateSelectBox( @ )
{
	my	$DataFile , @TempData , $Temp , $Temp2 ;
	my	$name , $value, $dispstr , $i, $SM ;
	
	my	@Strings , $Strings2 ;
	
	
	( $DataFile , $name , $SelectedNum, $SM ) = @_ ;
	
	@Strings = () ;
	
	
	$Temp2 = "<Select Name=\"$name\">\n" ;
	push(@Strings ,$Temp2 ) ;
	
	
	if ( ! open(DATA , "$DataFile") )
	{
		print	"Content-type:text/html\n\n" ;
print	<<HearStr ;
		<Html>
			<Head>
				<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset="euc-jp">
				<Title>エラー</Title>
			</Head>
			<Body BGCOLOR=#FFFFFF TEXT=#000000>
				<BR>
				<Center>
					<P><Font Size=4 Color=#800000>System Error</Font></P><Br>
					<P><Font SIZE=3>Don\'t Open File $DataFile</Font></P><Br>
				</Center>
			</Body>
		</Html>
HearStr
		exit;
	}
	
	@TempData = <DATA> ;
	close(DATA) ;
	
	$i = 0 ;
	$flg=0;
	foreach $Temp (@TempData)
	{
		($value,$dispstr, $dummy) = split(/\t/,$Temp, 3) ;
		if( $value != 0 && $dispstr eq "" ){ next; }
		if ( $value == $SelectedNum && $flg==0 )
		{
			if( $value <= $MaxDay[$SM-1] )
			{
				$Temp2 = "<Option value=\"$value\" Selected>$dispstr" ;
				push(@Strings ,$Temp2 ) ;
			}
			$flg=1;
		}
		else
		{
			if( $value <= $MaxDay[$SM-1] )
			{
				$Temp2 = "<Option value=\"$value\">$dispstr" ;
				push(@Strings ,$Temp2 ) ;
			}
#			$Temp2 = "<Option value=\"$value\">$dispstr" ;
		}
		
		$i ++ ;
		
	}
	$Temp2 = "</Select>\n" ;
	push(@Strings ,$Temp2 ) ;
	
	$Strings2 = join("" , @Strings) ;
	
	return($Strings2) ;
}

#---------------------------------------------------------------------------------------------------#
#----[ メール送信 ]
# $ma_m		送信者
# $ma_t		あて先
# $msubj	件名
# $mailmsg	本文
#
# $sendmail	sendmailのパス
# $tmp_file	一時ファイル名
#
#メール送信プログラム
sub mailsend
{
	local($ma_m,$ma_t,$msubj,$mailmsg) = @_;
	$dmy1 = $msubj;
	&jcode'convert(*mailmsg,'jis');
	&jcode'convert(*dmy1,'jis');
##	($dmy1) = &mail64encode($dmy1);
#	if(!open(OUT, ">$tmp_file")) {
#		print "Content-type:text/html\n\n";
#		print "File write error.";
#		exit;
#	}
	
	if ( open( OUT,"| $sendmail $ma_t") )
	{
		print OUT "To: $ma_t\n";
		print OUT "From: $ma_m\n";
		print OUT "Subject: $dmy1\n";
		print OUT "Content-Transfer-Encoding: 7bit\n";
		print OUT "Content-Type: text/plain\; charset=iso-2022-jp\n";
		print OUT "\n\n";
		print OUT "$mailmsg\n";
		close(OUT);
	}
	sleep(1) ;
	
	
	
#	print OUT "To: $ma_t\n";
#	print OUT "From: $ma_m\n";
#	print OUT "Subject: $dmy1\n";
#	print OUT "Content-Transfer-Encoding: 7bit\n";
#	print OUT "Content-Type: text/plain\n";
#	print OUT "\n\n";
#	print OUT "$mailmsg\n";
#	close(OUT);
#	`$Sendmail $ma_t < $tmp_file`;
#	unlink("$tmp_file");
}


#---------------------------------------------------------------------------------------------------#
sub mail64encode
{
	local($xx) = $_[0];
	&jcode'convert(*xx, "jis");
	$xx =~ s/\x1b\x28\x42/\x1b\x28\x4a/g; # 不要かも
	$xx = &base64encode($xx);
	return("=?iso-2022-jp?B?$xx?=");
}
#---------------------------------------------------------------------------------------------------#
sub base64encode
{
	local($xx) = unpack("B*", $_[0]);
	local($base) = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"."abcdefghijklmnopqrstuvwxyz"."0123456789+/";
	local($yy) ='';
	local($zz) = '';
	local($i) = 0;
	for ($i = 0; $yy = substr($xx, $i, 6); $i += 6) {
		$zz .= substr($base, ord(pack("B*", "00" . $yy)), 1);
		if(length($yy) == 2) {
			$zz .= "==";
		}
		elsif(length($yy) == 4) {
			$zz .= "=";
		}
	}
	return($zz);
}

#---------------------------------------------------------------------------------------------------#
#		パスワードのチェック
#---------------------------------------------------------------------------------------------------#
sub PasswordCheck( @ )
{
	my ( $pwd1, $pwd2, $temp );
	( $pwd1, $pwd2 ) = @_;
	if( $ID01 ne $pwd1 )	  { return 0; }
	if( $Password01 ne $pwd2 ){ return 0;  }
	return	1;
}

#---------------------------------------------------------------------------------------------------#
#		各種設定の読み込み
#---------------------------------------------------------------------------------------------------#
sub	GetConfig( $ )
{
	my	@line ;
	my	( $ConfigName , $Value ) ;
	
	
	if ( !open( CFG , $_[0] ) )
	{
		&util::Error ( "ConfigFileOpenError" ) ;
	}
	@line = <CFG> ;
	close( CFG ) ;

	foreach $temp (@line){
		
		( $ConfigName , $Value , $Comment ) = split(/\t/,$temp, 3) ;
		chomp( $Value );
		$Value =~ s/\r//g;
		$Value =~ s/\n//g;
		$Value =~ s/\r\n//g;
		$Value =~ s/\n\r//g;
		
		if( $ConfigName eq "ImgUrlHeader" )		{	$ImgUrlHeader	= $Value ;	}
		
		if( $ConfigName eq "CGIFullUrl" )		{	$CGIFullUrl		= $Value ;	}
		if( $ConfigName eq "CGIFileName" )		{	$CGIFileName	= $Value ;	}
		
		if( $ConfigName eq "ActionMenuHtml" )	{	$ActionMenuHtml = $Value ;	}
		if( $ConfigName eq "ActionMenuHtml2" )	{	$ActionMenuHtml2= $Value ;	}
		if( $ConfigName eq "ActionMenuHtml3" )	{	$ActionMenuHtml3= $Value ;	}
		if( $ConfigName eq "ActionMenuHtmlA1" )	{	$ActionMenuHtmlA1 = $Value ;	}
		if( $ConfigName eq "ActionMenuHtmlA1_2" ){	$ActionMenuHtmlA1_2 = $Value ;	}
		if( $ConfigName eq "ActionMenuHtmlA2" )	{	$ActionMenuHtmlA2 = $Value ;	}
		if( $ConfigName eq "ActionMenuHtmlA3" )	{	$ActionMenuHtmlA3 = $Value ;	}
		if( $ConfigName eq "ActionMenuHtmlA4" )	{	$ActionMenuHtmlA4 = $Value ;	}
		if( $ConfigName eq "ActionMenuHtmlB1" )	{	$ActionMenuHtmlB1 = $Value ;	}
		if( $ConfigName eq "ActionMenuHtmlB2" )	{	$ActionMenuHtmlB2 = $Value ;	}
		if( $ConfigName eq "ActionMenuHtmlC1" )	{	$ActionMenuHtmlC1 = $Value ;	}
		if( $ConfigName eq "ActionMenuHtmlC2" )	{	$ActionMenuHtmlC2 = $Value ;	}
		
		if( $ConfigName eq "DataFilePath01" )	{	$DataFilePath01	= $Value ;	}
		if( $ConfigName eq "DataFileName01" )	{	$DataFileName01	= $Value ;	}
		if( $ConfigName eq "DataFileName02" )	{	$DataFileName02	= $Value ;	}
		if( $ConfigName eq "DataFileName03" )	{	$DataFileName03	= $Value ;	}
		if( $ConfigName eq "DataFileName04" )	{	$DataFileName04	= $Value ;	}
		if( $ConfigName eq "DataFileName05" )	{	$DataFileName05	= $Value ;	}
		if( $ConfigName eq "DataFileName06" )	{	$DataFileName06	= $Value ;	}
		if( $ConfigName eq "DataFileName07" )	{	$DataFileName07	= $Value ;	}
		if( $ConfigName eq "DataFileName08" )	{	$DataFileName08	= $Value ;	}
		if( $ConfigName eq "DataFileName09" )	{	$DataFileName09	= $Value ;	}
		if( $ConfigName eq "DataFileName10" )	{	$DataFileName10	= $Value ;	}
		if( $ConfigName eq "DataFileName11" )	{	$DataFileName11	= $Value ;	}
		if( $ConfigName eq "DataFileName12" )	{	$DataFileName12	= $Value ;	}
		if( $ConfigName eq "RoomTypeFileName01" ){	$RoomTypeFileName01	= $Value ;	}
		if( $ConfigName eq "RoomDataFileName01" ){	$RoomDataFileName01	= $Value ;	}
		if( $ConfigName eq "RoomPlanFileName01" ){	$RoomPlanFileName01	= $Value ;	}

		if( $ConfigName eq "RLockFileName01" )	{	$RLockFileName01= $Value ;	}
		
		if( $ConfigName eq "IncFile01" )		{	$IncFile01		= $Value ;	}
		if( $ConfigName eq "IncFile02" )		{	$IncFile02		= $Value ;	}
		if( $ConfigName eq "IncFile03" )		{	$IncFile03		= $Value ;	}
		if( $ConfigName eq "IncFile04" )		{	$IncFile04		= $Value ;	}
		if( $ConfigName eq "IncFile05" )		{	$IncFile05		= $Value ;	}
		if( $ConfigName eq "IncFile06" )		{	$IncFile06		= $Value ;	}
		
		if( $ConfigName eq "ID01" )				{	$ID01			= $Value ;	}
		if( $ConfigName eq "Password01" )		{	$Password01		= $Value ;	}
	}
	
	$TempFileName01	= $TempFilePath01 . $TempFileName01;
	$TempFileName02	= $TempFilePath01 . $TempFileName02;
	$RoomTypeFileName01	= $DataFilePath01 . $RoomTypeFileName01;
	$RoomDataFileName01	= $DataFilePath01 . $RoomDataFileName01;
	$RoomPlanFileName01	= $DataFilePath01 . $RoomPlanFileName01;
}

#---------------------------------------------------------------------------------------------------#
#		カレンダー表示
#---------------------------------------------------------------------------------------------------#
sub DispCalender(@)
{
	# 月の末日の指定
	@days = (31,28,31,30,31,30,31,31,30,31,30,31);
	
	# 現在の日時を取得
	($second,$minute,$hour,$day,$month,$year)=localtime();
	$year += 1900;
	$month += 1;
	
	$Form{"DYYear"}  = $Form{"SYear"};
	$Form{"DYMonth"} = $Form{"SMonth"};
	
	# 指定されていた日時を変数に代入
	if ($Form{'DYYear'} && $Form{'DYMonth'})
	{
		$year = $Form{'DYYear'};
		$month = $Form{'DYMonth'};
	}
#	$month=12;
	
	# うるう年の判定（4の倍数ならうるう年、しかし100の倍数ならうるう年でない、また400の倍数ならうるう年）
	if( (($year%4 ==0)&&($year%100 != 0))||($year%400 == 0) ){
	    $days[1]=29;
	}
	
	# 月の初日の曜日（ツェラーの公式）、月の末日を取得
	$start = wday($year,$month,1);
	$lastday=$days[$month-1];
	
	# カレンダー表示
	print "<TABLE BORDER=1>\n";
	print "<TR class=\"a01\"><TD bgColor=#dddddd><FONT color=#dd0022>日</Font></TD><TD bgColor=#dddddd>月</TD><TD bgColor=#dddddd>火</TD><TD bgColor=#dddddd>水</TD><TD bgColor=#dddddd>木</TD><TD bgColor=#dddddd>金</TD><TD bgColor=#dddddd>土</TD></TR>\n";
	
	# 月の初日の前まで、表のセルにスペース（改行）を入れる
	if($start!=0){
		print "<TR class=\"a01\">";
		for($i=0;$i<$start;$i++){ print "<TD Alig=right><BR></TD>"; $col++; }
	}
	
	# カレンダーのセルを作成
#	@Data = fileutil::DataFileRead2( $DataFilePath01 . "sdata/$Form{\"Id\"}/dialy.dat" );
#	if( $Data[0]==-1 ){ $Data = (); }
	$month = sprintf("%02d" , $month );
	for($i=1;$i<=$lastday;$i++)
	{
		$tmp  = $i;
		$tmp  = sprintf("%02d" , $i );
		$day  = $tmp;
		$date = "$year$month$tmp";
		for( $ii=0; $ii<@Data; $ii++ )
		{
			@Temp = split( /\t/, $Data[$ii] );
			if( $Temp[0] eq $date ){ $tmp = "<A Href=\"./smem.cgi?Tk=dy&DYYear=$Form{\"DYYear\"}&DYMonth=$Form{\"DYMonth\"}&DYDay=$day&Id=$Form{\"Id\"}\">$i</A>"; last; }
			else				   { $tmp = $i; }
		}
		
		if($col==0)
		{
			print "<TR class=\"a01\">";
			print "<TD Align=right><Font Color=#FF0000>$tmp</Font></TD>";
		}
		else
		{
			if( $col>=6 ){ print "<TD Align=right><Font Color=#0000FF>$tmp</Font></TD>"; }
			else		 { print "<TD Align=right>$tmp</TD>"; }
		}
		$col++;
		if($col>=7)
		{
			print "</TR>\n";
			if ($i<$lastday) { $col=0; }
		}
	}
	for($i=$col;$i<7;$i++){ print "<TD><BR></TD>"; }
	print "</TABLE>";

	# 先月、来月のリンクを作成
	$lastmonth = $month - 1;
	$nextmonth = $month + 1;
	$lastyear = $year;
	$nextyear = $year;
	if ($lastmonth == 0)
	{
		$lastmonth = 12;
		$lastyear--;
	}
	if ($nextmonth == 13)
	{
		$nextmonth = 1;
		$nextyear++;
	}
	
#	print "<A HREF=\"calendar.cgi?y=$lastyear&amp;m=$lastmonth\">先月</A> <A HREF=\"calendar.cgi?y=$nextyear&amp;m=$nextmonth\">来月</A>\n";
}
sub wday {
	my ($year,$month,$day)=@_;
	if($month<3){ $month += 12; $year--; }
	return ($year+int($year/4)-int($year/100)+int($year/400)+int((13*$month+8)/5)+$day)% 7;
}

#---------------------------------------------------------------------------------------------------#
#		入力Error表示
#---------------------------------------------------------------------------------------------------#
sub	InputError( $ )
{
	my ( $mes, $Tk );
	( $mes, $Tk, $Menu ) = @_;
	
	print	"Content-type:text/html\n\n";
	print	"<Html>\n";
	print		"<Body BGCOLOR=#FFFFFF TEXT=#000000>\n";
	print			"<Head>\n";
	print			"<meta http-equiv='Content-Type' content='text/html; charset=Shift_JIS'>\n";
	print			"<Title>Error</Title></Head>\n";
	print			"<BR><BR>\n";
	print			"<Center>\n";
	print				"<P><Font Size=3 Color=#FF0040><B>$mes</B>　</Font><Br>\n";
	print				"<Form Method=\"POST\" Action=\"$CGIFullUrl$CGIFileName\">";
	print					"<Input Type=HIDDEN Name=\"Tk\" Value=\"$Tk\">\n";
	print					"<Input Type=HIDDEN Name=\"Menu\" Value=\"$Menu\">\n";
	print					"<Br><Br><Input Type=button Value=\"　戻る　\" onclick=\"history.back()\">\n";
	print				"</Form>\n";
	print			"</Center>\n";
	print		"</Body>\n";
	print	"</Html>\n";
	
	exit;
}

