<!-- #include file="../../include.asp" -->

<%
'<!--
'################################################
'	名称	:手形取立・割引満期処理
'	作成日	:2009/9/29
'	作成者	:小野
'	目的	:手形取立・割引申込の満期処理を実行する。
'	概要	:(091014小野)銀行-窓口業務からも利用出来るよう変更
'################################################
'-->
%>
<%
main()
Sub main()

	If Not(SessionCheck()) Then
		Exit Sub
	End If


	Dim Query
	Dim Content
	Dim ContentTG

	Dim EnshuCD
	Dim EnshuName
	EnshuCD = Request("EnshuCD")
	If GB_EnshuCD <> "" Then
		EnshuCD = GB_EnshuCD
	End If

	If EnshuCD <> "" Then
		Query = "exec SPM演習取得 '" & GB_SystemCD & "', '" & EnshuCD & "'"
		Set Content = OpenQuery(Query)
		If Not(Content.BOF Or Content.EOF) Then
			EnshuName = Content.Fields("演習名称")
		End If
	End If

	'同時同業で銀行-窓口業務から利用する際は学生番号が特定出来なければならない
	Dim SeitoCD
	SeitoCD = Request("SeitoCD")

	Dim LimitDate
	LimitDate = Request("LimitDate")

%>

<html>
<% = HtmlHeader("") %>
<SCRIPT LANGUAGE="JavaScript">
<!--
	HomeAlias = "<% = HomeAlias %>";
	HomeAliasSL = "<% = HomeAliasSL %>";
	ExitFlg = 0;
-->
</SCRIPT>

<body onkeydown="if(ExitFlg==2)ExitFlg=3;" onBeforeUnload="if(ExitFlg!=0)window.event.returnValue = ExitMsg(ExitFlg)" bgcolor="#5C70B6" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form OnKeyDown="FormKeyDown(this)"	name="form1" method="POST" action="fm_enshucontrol04_bin.asp" onSubmit="return SubmitCheck();" autocomplete="off">
<input type="hidden" name="EnshuCD" value="<% = EnshuCD %>">

<%
	Response.Write(HtmlDesign(1))

	Response.Write(HttpL1(4))

	If GB_Admin = 1 Then
		Response.Write(HttpL2("運用管理メニュー" ,"tblbtn( '/" & HomeAlias & "/admin/admenu_w.asp')", "演習管理", "tblbtn( '/" & HomeAlias & "/admin/enshu/fm_enshu_ichiran.asp?EnshuCD=" & EnshuCD & "')", "演習コントロール", "tblbtn( '/" & HomeAlias & "/admin/enshu/fm_enshucontrol.asp?EnshuCD=" & EnshuCD & "')", "手形満期処理", "", "", "", "", ""))	
	ElseIf GB_Admin > 1 Then
		Response.Write(HttpL2("運用管理メニュー" ,"tblbtn( '/" & HomeAlias & "/admin/admenu_w.asp')", "演習管理", "tblbtn( '/" & HomeAlias & "/admin/enshu/fm_enshu1_view.asp?EnshuCD=" & EnshuCD & "')", "演習コントロール", "tblbtn( '/" & HomeAlias & "/admin/enshu/fm_enshucontrol.asp?En6shuCD=" & EnshuCD & "')", "手形満期処理", "", "", "", "", ""))	
	Else
		Response.Write(HttpL2("会社選択" ,"tblbtn( '/" & HomeAlias & "/user/bk/')", "銀行", "tblbtn( '/" & HomeAlias & "/user/bk/menu_b.asp')", "窓口業務" , "tblbtn( '/" & HomeAlias & "/user/bk/menu_b2.asp')", "手形満期処理", "", "", "", "", ""))
	End If

	Response.Write(HttpL3("","" ,"", "", "", "", "", "", "", "", "", "", "", "", "", ""))

	Response.Write(HttpL3_1("手形満期処理を実行する", "SubmitCheck()", "", "", "", "", "", "", "", ""))
	Response.Write(HttpL3_1("", "", "", "", "", "", "", "", "", ""))

	If GB_Admin => 1 Then
		Response.Write(HttpL3_2("戻る", "tblbtn( '/" & HomeAlias & "/admin/enshu/fm_enshucontrol.asp?EnshuCD=" & EnshuCD & "')", "", "", "", "", "", "", "", ""))
	Else
		Response.Write(HttpL3_2("", "", "", "", "", "", "", "", "", ""))
	End If

	If GB_Admin => 1 Then
		Response.Write(HttpL4("演習コントロール", "手形満期処理"))
	Else
		Response.Write(HttpL4("手形満期処理", ""))
	End If

	If GB_Admin => 1 Then
		Response.Write(HttpL5("申込受付済みで満期処理(当座入出金)されていない手形取立・割引申込を表示しています"))
	Else
		Response.Write(HttpL5("満期処理されていない手形取立・割引申込を表示しています"))
	End If

%>

<div id="L0" style="position: absolute; visibility: hidden; left: 0px; top: -2000px;">
<table width="1" height="100%" border="0" cellspacing="5" cellpadding="5" bgcolor="#ffffff" style="border:1px solid #000000">
	<tr>
		<td align="center" background="/<% = HomeAlias %>/images/window_bk.gif?<% = GB_STU %>">
			<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
				<tr height="10">
					<td valign="top">
						<table height="30" border="0" cellpadding="0" cellspacing="0" class="tx1416">
							<tr>
								<td>
									<table height="30" border="0" cellpadding="0" cellspacing="0" class="tx1416">
										<tr>
											<td>
<%
	'同時同業の場合は生徒選択可能
	Dim SeitoCnt
	Dim Sonzai
	Dim SeitoCDAry
	ReDim SeitoCDAry(0)
	If ConvEnshuKubun(EnshuCD) = "P" Then
		If GB_Admin => 1 Then
			'生徒配列作成
			Query = "exec SPB銀行取引書類一覧 '" & GB_SystemCD & "', '" & EnshuCD & "', '', '', ''"
			Set Content = OpenQuery(Query)
			Do While Not(Content.BOF Or Content.EOF)
				If (Content.Fields("文書種類CD") = "BS" Or Content.Fields("文書種類CD") = "BT") And "" & Content.Fields("受付区分") = "Y" And "" & Content.Fields("入出金フラグ") <> "1" And "" & Content.Fields("削除フラグ") <> "1" Then
					Sonzai = 0
					'現在配列に存在するか調べる
					For SeitoCnt = 1 To UBound(SeitoCDAry)
						If SeitoCDAry(SeitoCnt) = "" & ConvKaisyaGakuseiNo(EnshuCD, Content.Fields("作成会社CD")) Then	'学生番号ベース
							Sonzai = 1
							Exit For
						End If
					Next
					'現在配列に存在しなければ配列に追加
					If Sonzai = 0 Then
						ReDim PreServe SeitoCDAry(UBound(SeitoCDAry) + 1)	'配列+1
						SeitoCDAry(UBound(SeitoCDAry)) = "" & ConvKaisyaGakuseiNo(EnshuCD, Content.Fields("作成会社CD"))	'学生番号ベース
					End If
				End If
				Content.MoveNext
			Loop
			Response.Write("<select size=""1"" class=""tbox4"" style=""width:190px;"" name=""SeitoCD"" onChange=""tblbtn('fm_enshucontrol04.asp?EnshuCD=" & EnshuCD & "&SeitoCD=' + this.value);"">" & vbCrLf)
			Response.Write("	<option value=""""><全ての生徒></option>" & vbCrLf)
			For SeitoCnt = 1 To UBound(SeitoCDAry)
				Response.Write("	<option value=""" & SeitoCDAry(SeitoCnt) & """")
				If SeitoCDAry(SeitoCnt) = SeitoCD Then
					Response.Write(" selected")
				End If
				Response.Write(">" & ConvGakuseiShimei(SeitoCDAry(SeitoCnt)) & "</option>" & vbCrLf)
			Next
			Response.Write("</select>&nbsp;&nbsp;" & vbCrLf)
		Else
			Response.Write("<input type=""hidden"" name=""SeitoCD"" value=""" & SeitoCD & """>" & vbCrLf)
		End If
	End If
%>
												日付:<input type="text" name="LimitDate" size="12" value="<% = LimitDate %>" onkeyup="FormStrDate(this);" onKeypress="FormStrDate(this);" onBlur="SetDate(this, 1, false);" class="tbox4">
												までの手形取立・割引申込の満期処理(当座入出金)を実行する
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
						<% If GB_Admin => 1 Then %>
						<TABLE WIDTH="<% If GB_Admin => 1 Then %>820<% Else %>520<% End If %>" HEIGHT="30" BORDER="1" CELLPADDING="0" CELLSPACING="0" BORDERCOLOR="#000000" BGCOLOR="#FFFFCC" CLASS="tx1416" STYLE="border-collapse: collapse">
							<TR ALIGN="CENTER">
								<TD HEIGHT="30" width="90" align="center">対象演習名</TD>
								<TD height="30" align="center">
									<% = EnshuMeisyo %>
								</TD>
							</TR>
						</table>
						<% End If %>
						<table BORDER="0" CELLPADDING="0" CELLSPACING="0">
							<TR>
								<TD VALIGN="BOTTOM" WIDTH="1">
									<TABLE HEIGHT="20" BORDER="1" WIDTH="<% If GB_Admin => 1 Then %>820<% Else %>520<% End If %>" CELLPADDING="3" CELLSPACING="0" BORDERCOLOR="#000000" BGCOLOR="#FFFFCC" CLASS="tx1416" STYLE="border-collapse: collapse">
										<TR ALIGN="CENTER">
										<% If GB_Admin => 1 Then %>
											<% If ConvEnshuKubun(EnshuCD) = "P" Then %>
											<TD HEIGHT="20" WIDTH="140">学生氏名</TD>
											<% Else %>
											<TD HEIGHT="20" WIDTH="140">会社コード</TD>
											<% End If %>
											<TD HEIGHT="20" WIDTH="210">申込会社</TD>
										<% End If %>
											<TD HEIGHT="20" WIDTH="30">種別</TD>
											<TD HEIGHT="20" WIDTH="82">支払期日</TD>
											<TD HEIGHT="20">支払会社</TD>
											<TD HEIGHT="20" WIDTH="100">額面</TD>
										</TR>
									</TABLE>
								</TD>
							</TR>
						</table>
					</TD>
				</TR>
				<TR>
					<TD VALIGN="TOP">
						<DIV ID="Layer1" STYLE="position:relative; left:0px; top:0px; width:<% If GB_Admin => 1 Then %>840<% Else %>540<% End If %>px; height:100%; z-index:1; border: 1px none #000000; overflow: auto;">
							<TABLE ID="SyoukaiList" BORDER="1" WIDTH="<% If GB_Admin => 1 Then %>820<% Else %>520<% End If %>" CELLSPACING="0" CELLPADDING="3" BGCOLOR="#FFFFFF" CLASS="tx1416" STYLE="border-collapse: collapse" BORDERCOLOR="#000000">
<%
	Dim Cell1
	Dim Cell2
	Dim Cell3
	Dim Cell4
	Dim Cell5
	Dim Cell6
	ReDim Cell1(0)
	ReDim Cell2(0)
	ReDim Cell3(0)
	ReDim Cell4(0)
	ReDim Cell5(0)
	ReDim Cell6(0)
	Dim ii
	ii = 0
	Query = "exec SPB銀行取引書類一覧 '" & GB_SystemCD & "', '" & EnshuCD & "', '', '', ''"
	Set Content = OpenQuery(Query)
	Do While Not(Content.BOF Or Content.EOF)
		If (Content.Fields("文書種類CD") = "BS" Or Content.Fields("文書種類CD") = "BT") And "" & Content.Fields("受付区分") = "Y" And "" & Content.Fields("入出金フラグ") <> "1" And "" & Content.Fields("削除フラグ") <> "1" Then
												'同時同業の場合は選択生徒のみ表示
			If ConvEnshuKubun(EnshuCD) = "G" Or SeitoCD = "" Or "" & ConvKaisyaGakuseiNo(EnshuCD, Content.Fields("作成会社CD")) = SeitoCD Then
				ReDim PreServe Cell1(UBound(Cell1) + 1)	'配列+1
				ReDim PreServe Cell2(UBound(Cell2) + 1)	'配列+1
				ReDim PreServe Cell3(UBound(Cell3) + 1)	'配列+1
				ReDim PreServe Cell4(UBound(Cell4) + 1)	'配列+1
				ReDim PreServe Cell5(UBound(Cell5) + 1)	'配列+1
				ReDim PreServe Cell6(UBound(Cell6) + 1)	'配列+1
				Dim TorihikisakiCD
				TorihikisakiCD = Content.Fields("作成会社CD")
				Dim ShiharaininCD
				ShiharaininCD = Content.Fields("手形作成会社CD")
				'手形から支払情報を取得
				Dim Kingaku
				Dim Kijutsu
				Dim Tenmatsubi
				Query = "exec SPK手形取得"
				Query = Query & " '" & GB_SystemCD & "', '" & EnshuCD & "'"
				Query = Query & ",'" & Content.Fields("取引先CD") & "'"
				Query = Query & ",'" & Content.Fields("手形作成会社CD") & "'"
				Query = Query & ",'" & Content.Fields("手形文書種類CD") & "'"
				Query = Query & ",'" & Content.Fields("手形文書内容CD") & "'"
				Set ContentTG = OpenQuery(Query)
				If Not(ContentTG.BOF Or ContentTG.EOF) Then
					Kingaku = ContentTG.Fields("金額")
					Kijutsu = SetTimeYYYYMMDD(ContentTG.Fields("支払期日"))
					Tenmatsubi = SetTimeYYYYMMDD(ContentTG.Fields("顛末日"))
				Else	'手形が存在しない場合
					Kingaku = Content.Fields("手形小切手出金金額")
					Kijutsu = SetTimeYYYYMMDD(Content.Fields("手形支払期日"))
					Tenmatsubi = "--"
					TorihikisakiCD = Content.Fields("取引先CD")
					ShiharaininCD = GetKozaShoyuKaishaCD(EnshuCD, Content.Fields("手形小切手出金銀行CD"), Content.Fields("手形小切手出金口座区分"), Content.Fields("手形小切手出金口座番号"))
				End If
				If GB_Admin => 1 Then
					If ConvEnshuKubun(EnshuCD) = "P" Then
						Cell1(UBound(Cell1)) = ConvGakuseiShimei(ConvKaisyaGakuseiNo(EnshuCD, TorihikisakiCD))
					Else
						Cell1(UBound(Cell1)) = TorihikisakiCD
					End If
					Cell2(UBound(Cell2)) = ConvKaisyaMeisyoDx(EnshuCD, TorihikisakiCD)
				End If
				If Content.Fields("文書種類CD") = "BS" Then
					Cell3(UBound(Cell3)) = "取立"
				Else
					Cell3(UBound(Cell3)) = "割引"
				End If
				Cell4(UBound(Cell4)) = Kijutsu
				Cell5(UBound(Cell5)) = ConvKaisyaMeisyoDx(EnshuCD, ShiharaininCD)
				Cell6(UBound(Cell6)) = SetMoney(Kingaku, false, true)
				ii = ii + 1
			End If
		End If
		Content.MoveNext
	Loop

	'インスタントソート出力
	If UBound(Cell1) > 0 Then
		'最大の支払期日を取得(デクリメントするため)
		Dim TmpMaxDate
		TmpMaxDate = Cell4(1)	'先頭行を仮代入する
		For ii = 2 To UBound(Cell1)
			If DateDiff("d", TmpMaxDate, Cell4(ii)) > 0 Then
				TmpMaxDate = Cell4(ii)
			End If
		Next
		Dim jj
		For jj = 1 To UBound(Cell1)
			'最小の支払期日を取得し、該当する行を全出力
			Dim TmpMinDate
			TmpMinDate = TmpMaxDate
			For ii = 1 To UBound(Cell1)
				If Cell4(ii) <> "" Then
					If DateDiff("d", TmpMinDate, Cell4(ii)) < 0 Then
						TmpMinDate = Cell4(ii)
					End If
				End If
			Next
			For ii = 1 To UBound(Cell1)
				If Cell4(ii) <> "" And Cell4(ii) = TmpMinDate Then
					Response.Write("<TR ALIGN=""CENTER"">" & vbCrLf)
					If GB_Admin => 1 Then
						Response.Write("<TD HEIGHT=""20"" ALIGN=""LEFT"" WIDTH=""140"">" & Cell1(ii) & "</TD>" & vbCrLf)
						Response.Write("<TD HEIGHT=""20"" WIDTH=""210"" ALIGN=""LEFT"">" & Cell2(ii) & "</TD>" & vbCrLf)
					End If
					Response.Write("<TD HEIGHT=""23"" WIDTH=""30"" ALIGN=""CENTER"">" & Cell3(ii) & "</TD>" & vbCrLf)
					Response.Write("<TD HEIGHT=""20"" WIDTH=""82"" ALIGN=""CENTER"">" & Cell4(ii) & "</TD>" & vbCrLf)
					Response.Write("<TD HEIGHT=""20"" ALIGN=""LEFT"">" & Cell5(ii) & "</TD>" & vbCrLf)
					Response.Write("<TD HEIGHT=""20"" WIDTH=""100"" ALIGN=""RIGHT"">" & Cell6(ii) & "</TD>" & vbCrLf)
					Response.Write("</TR>" & vbCrLf)
					Cell4(ii) = ""	'以降の処理から除外するためNULL代入
				End If
			Next
		Next
		'最大の支払期日に該当する行を全出力
		For ii = 1 To UBound(Cell1)
			If Cell4(ii) = TmpMaxDate Then
				Response.Write("<TR ALIGN=""CENTER"">" & vbCrLf)
				If GB_Admin => 1 Then
					Response.Write("<TD HEIGHT=""20"" ALIGN=""LEFT"" WIDTH=""140"">" & Cell1(ii) & "</TD>" & vbCrLf)
					Response.Write("<TD HEIGHT=""20"" WIDTH=""210"" ALIGN=""LEFT"">" & Cell2(ii) & "</TD>" & vbCrLf)
				End If
				Response.Write("<TD HEIGHT=""23"" WIDTH=""30"" ALIGN=""CENTER"">" & Cell3(ii) & "</TD>" & vbCrLf)
				Response.Write("<TD HEIGHT=""20"" WIDTH=""82"" ALIGN=""CENTER"">" & Cell4(ii) & "</TD>" & vbCrLf)
				Response.Write("<TD HEIGHT=""20"" ALIGN=""LEFT"">" & Cell5(ii) & "</TD>" & vbCrLf)
				Response.Write("<TD HEIGHT=""20"" WIDTH=""100"" ALIGN=""RIGHT"">" & Cell6(ii) & "</TD>" & vbCrLf)
				Response.Write("</TR>" & vbCrLf)
			End If
		Next
	End If
%>
							</TABLE>
						</DIV>
					</TD>
				</TR>
			</TABLE>
		</td>
	</tr>
</table>
</DIV>
</form>

</body>

<% = HtmlFooter %>
</html>
<SCRIPT LANGUAGE="JavaScript">

	function SubmitCheck() {
		if (form1.LimitDate.value == "") {
			alert("日付を入力してください ");
			form1.LimitDate.focus();
			return false;
		}
		if (!confirm("\n指定された日付までの手形取立・割引受付の満期処理(当座入出金)を行います。よろしいですか? \n\n(日付は会計期間外も指定出来ますので、西暦年の誤りにご注意ください) \n\n")) {
			return false;
		}
		SubmitReal(form1);
		return true;
	}

</script>

<%
End Sub
%>