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

<%
'<!--
'################################################
'	名称	:仕入売上書類表示
'	作成日:2002/9/10
'	作成者:山崎 貴史
'	目的 :仕入売上書類画面を表示する。
'	概要	:
'	 <<表示>>
'	修正変更:(080327)材料入庫モードを追加
'################################################
'-->
'
%>

<%
main()

Sub main()

	Dim BunsyoNaiyoCD, Syoribi, TorihikisakiCD, NonyuKijitsu
	Dim UnsoGaisyaCD, UntinSyogakariKubun, Unsohi, UnsohiSeikyuFlg, Tekiyo, ShiharaiHoho, HasshinFlg
	Dim SenpoBunsyoNaiyoCD, SenpoBunsyoSyuruiCD, SenpoSyoribi
	Dim BunsyoSyuruiCD
	Dim Kakaku(5)		'標準単価
	Dim SyohinCD(5)														'商品コード
	Dim SyohinName(5)							'商品名称
	Dim Suryo(5)															'数量
	Dim Tanka(5)															'単価
	Dim UnsoTanka(5)														'運送単価

	Dim GakuseiShimei							'学生氏名(係印)
	Dim SyoruiMei
	Dim Query
	Dim Content
	Dim Shimei
	Dim PageType
	Dim RouteType
	RouteType = Request("RouteType")
	PageType = Request("PageType")
	BunsyoNaiyoCD = Request("BunsyoNaiyoCD")
	BunsyoSyuruiCD = Request("BunsyoSyuruiCD")
	SenpoBunsyoNaiyoCD = Request("SenpoBunsyoNaiyoCD")
	SenpoBunsyoSyuruiCD = Request("SenpoBunsyoSyuruiCD")
	TorihikisakiCD = Request("TorihikisakiCD")
	Dim SakuseiKaisyaCD
	SakuseiKaisyaCD = Request("SakuseiKaisyaCD")

	Dim SenpoFlg
	SenpoFlg = 0
	If SenpoBunsyoNaiyoCD <> "" Then
		SenpoFlg = 1
	End If


	If SenpoFlg = 0 Then
		SakuseiKaisyaCD = KaisyaCD
	End If


	Dim SenpoTmpBunsyoSyuruiCD

	Dim SyoruiKubun


	Select Case BunsyoSyuruiCD
	Case "SC"
		SyoruiMei = "オリジナル商品入庫"
		SyoruiKubun = "S"
		SenpoTmpBunsyoSyuruiCD = "U"
	Case "SS"
		SyoruiMei = "仕入入庫"
		SyoruiKubun = "S"
		SenpoTmpBunsyoSyuruiCD = "U"
	Case "SX"
		SyoruiMei = "仕入返品"
		SyoruiKubun = "X"
	Case "SU"
		SyoruiMei = "売上出庫"
		SyoruiKubun = "U"
	Case "SY"
		SyoruiMei = "売上返品"
		SyoruiKubun = "1"
	Case "ZS"
		SyoruiMei = "材料入庫"
		SyoruiKubun = "S"
	Case "ZU"
		SyoruiMei = "材料出庫"
		SyoruiKubun = "S"
	Case "MU"
		SyoruiMei = "製品出庫"
		SyoruiKubun = "U"
	Case Else
	End Select

	Dim Label
	If BunsyoSyuruiCD = "ZS" Then
		Label = "材料"
	Else
		Label = "商品"
	End If

	Dim ButtonLabel
	If BunsyoSyuruiCD = "SU" Or BunsyoSyuruiCD = "SX" Or BunsyoSyuruiCD = "MU" Then
		ButtonLabel = "出庫"
	Else
		ButtonLabel = "入庫"
	End If

	If BunsyoNaiyoCD <> "" Or SenpoBunsyoNaiyoCD <> "" Then
		If SenpoFlg = 1 Then
			If GB_JisyaFlag <> "" Then	'運用管理・演習管理(自社フラグ無し)では開封フラグを立てない(061213小野)
				Query = "exec SPD仕入売上書類開封 '" & GB_SystemCD & "','" & EnshuCD & "','" & TorihikisakiCD	&"', '" & SenpoBunsyoSyuruiCD & "', '" & SenpoBunsyoNaiyoCD & "'"
				Set Content = OpenQuery(Query)
			End If
			Query = "exec SPD仕入売上書類取得 '" & GB_SystemCD & "','" & EnshuCD & "','" & TorihikisakiCD	&"', '" & KaisyaCD & "', '" & SenpoBunsyoSyuruiCD & "', '" & SenpoBunsyoNaiyoCD & "'"
		Else
			Query = "exec SPD入出庫取得 '" & GB_SystemCD & "','" & EnshuCD & "','" & KaisyaCD & "', '" & SakuseiKaisyaCD & "', '" & BunsyoSyuruiCD & "', '" & BunsyoNaiyoCD & "'"
		End If
'Response.Write(Query)
'Exit Sub
		Set Content = OpenQuery(Query)

		If Not(Content.BOF Or Content.EOF) Then

			If SenpoFlg = 1 Then
				TorihikisakiCD = Content.Fields("会社CD")
				SenpoSyoribi = Content.Fields("処理日")
			Else
				TorihikisakiCD = Content.Fields("取引先CD")
				SenpoSyoribi = Content.Fields("先方処理日")
				Syoribi = Content.Fields("処理日")
			End If

			If 1 = 0 Then
				UntinSyogakariKubun = Content.Fields("運賃諸掛区分")
				Unsohi = Content.Fields("運送費")
			End If

'			GakuseiShimei = Content.Fields("氏名")

'			SenpoBunsyoNaiyoCD = Content.Fields("先方文書内容CD")
'			SenpoBunsyoSyuruiCD = Content.Fields("先方文書種類CD")


			Do While Not(Content.BOF Or Content.EOF)
				Dim NyusyukoSEQ
				If SenpoFlg = 1 Then
					NyusyukoSEQ = Content.Fields("文書内容SEQ")
				Else
					NyusyukoSEQ = Content.Fields("入出庫SEQ")
				End If
				If BunsyoSyuruiCD = "ZS" Then
'					SyohinGazo(NyusyukoSEQ) = ConvZairyoGazo(EnshuCD, Content.Fields("商品CD"))
					Kakaku(NyusyukoSEQ) = ConvZairyoHanbaiTanka(Content.Fields("商品CD"))
				Else
'					SyohinGazo(NyusyukoSEQ) = ConvSyohinGazo(EnshuCD, Content.Fields("商品CD"))
					Kakaku(NyusyukoSEQ) = ConvSyohinHanbaiTanka(Content.Fields("商品CD"))
				End If
				SyohinCD(NyusyukoSEQ) = Content.Fields("商品CD")
				Suryo(NyusyukoSEQ) = Content.Fields("数量")
				Tanka(NyusyukoSEQ) = Content.Fields("単価")

'				If SyoruiKubun = "X" Or SyoruiKubun = "1" Then
'					If Suryo(NyusyukoSEQ) <> "" Then
'						Suryo(NyusyukoSEQ) = -1 * Suryo(NyusyukoSEQ)
'					End If
'				End If

				If 1 = 0 Then
					If SenpoFlg = 1 Then
						UnsoTanka(NyusyukoSEQ) = ""
					Else
						UnsoTanka(NyusyukoSEQ) = Content.Fields("運送単価")
					End If
				End If
				Content.MoveNext
			Loop
		End If
	End If


	Dim HyojunTankaHyoji
	Dim HaraidashiTankaRiyo
	Query = "exec SPM演習取得 '" & GB_SystemCD & "','" & EnshuCD & "'"
	Set Content = OpenQuery(Query)
	If Not(Content.BOF Or Content.EOF) Then
		HyojunTankaHyoji = "" & Content.Fields("標準販売単価表示") 
		HaraidashiTankaRiyo = "" & Content.Fields("出庫時払出単価入力")
	End If

	'HaraidashiTankaRiyo = "1"


	Dim jj,tmps
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="-1">
<link href="../../../binx/sj3web.css?<% = TimeUniq() %>" rel="stylesheet" type="text/css">
<title><% = AppTitle %></title>
<script language="JScript" src="../../../include.js?<% = TimeUniq() %>"></script>
<script language="JScript" src="../../../includesj.js?<% = TimeUniq() %>"></script>
<script language="JScript.Encode" src="../../../include_enc.js?<% = TimeUniq() %>"></script>
<script language="JScript.Encode" src="../../../includesj_enc.js?<% = TimeUniq() %>"></script>
<script type=""text/javascript"" src="../../../javascript.js?<% = TimeUniq() %>"></script>
</head>
<SCRIPT LANGUAGE="JavaScript">
<!--
	HomeAlias = "<% = HomeAlias %>";
	HomeAliasSL = "<% = HomeAliasSL %>";
	ExitFlg = 0;

	//印刷余白指定(ミリ指定)
	PrintTopMargin = 20;
	PrintLeftMargin = 20;
//	PrintTopMargin = 0;
//	PrintLeftMargin = 0;

-->
</SCRIPT>

<body onload="<% = PrintOnLoad %>" onkeydown="if(ExitFlg==2)ExitFlg=3;" bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<% = PrintScriptX %>

<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" style="border:solid 0px #000000">
<tr>
	<td height="30" align="left" valign="top">
		
	<%
		Response.Write(PrintHeader(0, ""))
	%>
		
			<table width="600" border="0" cellspacing="0" cellpadding="10" height="305" bgcolor="#FFFFFF" style="border:solid 1px #000000">
				<tr>
					<td  width="600" height="305" align="CENTER" valign="top">
						<table width="600" border="0" cellspacing="0" cellpadding="0" height="305">
							<tr>
								<td height="40" align="CENTER" valign="middle">
									<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse"  height="30" width="580" class="tx1416">
										<tr>
											<td width="25%">
												<table width="190" border="0" cellpadding="0" cellspacing="0">
													<tr class="tx1214">
														<td width="190" align="left">
															<table width="130" class="tx2224b" border="0" cellpadding="0" cellspacing="0" >
																<tr>
																	<td align="center" nowrap><%
																		If Len(SyoruiMei) < 8 Then
																			Response.Write(SetStringInsertSpace(SyoruiMei))
																		Else
																			Response.Write(SyoruiMei)
																		End If
																	%></td>
																</tr>
															</table>
														</td>
													</tr>
												</table>
											</td>
											<td> </td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td height="45" align="CENTER" valign="BOTTOM">
									<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse"  height="54" width="580" class="tx1618">
										<tr>
											<td width="12%" height="20"><% = ButtonLabel %>番号</td>
											<td width="38%" height="20"><% = BunsyoNaiyoCD %></td>
											<td width="20%" height="20">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;処理日</td>
											<td width="30%" height="20"><% = Syoribi %></td>
										</tr>
<% 'If BunsyoSyuruiCD <> "SC" And BunsyoSyuruiCD <> "MU" Then %>
<% If BunsyoSyuruiCD <> "MU" And  TorihikisakiCD <> KaisyaCD Then %>
										<tr>
											<td height="20">取引先</td>
											<td height="20">
											<%
											If TorihikisakiCD = "SJ4KOURIHANBAI" Then
												Response.Write("小売販売")
											Else
												Response.Write(ConvKaisyaMeisyoDx(EnshuCD, TorihikisakiCD))
											End If
											%>
											<td width="80" height="20"></td>
											<td width="120" height="20"></td>
										</tr>
<% End If %>
										</table>
								</td>
							</tr>
							<tr>
								<td align="CENTER">
									<table width="580" height="230" border="0" cellpadding="4" cellspacing="0" style="border-collapse: collapse; border:solid 2px #FFFFFF">
										<tr>
											<td width="100%" align="RIGHT">
												<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="580" bordercolor="#000000">
													<tr>
														<td height="30" valign="TOP">
															<table width="100%" height="30" border="1" cellpadding="0" cellspacing="0" frame="below" style="border-collapse: collapse" bordercolor="#000000" class="tx1618" bgcolor="#CCCCCC">
																<tr>
																	<td align="center"><% = Label %>名称</td>
																	<% If HyojunTankaHyoji <> "0" Then '標準販売単価表示 %>
																	<td align="center" width="17%"><% If MHMSTDSELLPRICE <> "" Then Response.Write(MHMSTDSELLPRICE) Else Response.Write("標準単価") End If %></td>
																	<% End If %>
																	<td align="center" width="16%">数 量</td>
																	<% If BunsyoSyuruiCD = "SC" Or BunsyoSyuruiCD = "SS" Or BunsyoSyuruiCD = "SX" Or BunsyoSyuruiCD = "ZS" Then %>
																	<td align="center" width="17%">単 価</td>
																	<% ElseIf HaraidashiTankaRiyo <> "1" Then %>
																	<td align="center" width="17%">払出単価</td>
																	<% End If %>
																	<% If 1 = 0 Then %>
																	<td align="center" width="17%">運送単価</td>
																	<% End If %>
																	</tr>
															</table>
														</td>
													</tr>


													<tr>
														<td>
															<table width="100%" height="180" border="1" cellpadding="3" cellspacing="0" frame="below" style="border-collapse: collapse" bordercolor="#000000" class="tx1618">
																<tr>
																	<% If BunsyoSyuruiCD = "ZS" Then %>
																	<td align="left"><% = AscLeft(ConvZairyoMeisyo(SyohinCD(1)),38) %><br></td> <!-- 商品名称を38Byteで切り捨て(061031小野)-->
																	<% Else %>
																	<td align="left"><% = AscLeft(ConvSyohinMeisyo(SyohinCD(1)),38) %><br></td> <!-- 商品名称を38Byteで切り捨て(061031小野)-->
																	<% End If %>
																	<% If HyojunTankaHyoji <> "0" Then '標準販売単価表示 %>
																	<td align="right" width="17%"><% = SetMoney(Kakaku(1), false, true) %><br></td>
																	<% End If %>
																	<td align="right" width="16%"><% = SetMoney(Suryo(1), false, true) %><br></td>
																	<% 'If 1 = 1 Or BunsyoSyuruiCD = "SC" Or BunsyoSyuruiCD = "SS" Or BunsyoSyuruiCD = "SX" Then %>
																	<% If BunsyoSyuruiCD = "SC" Or BunsyoSyuruiCD = "SS" Or BunsyoSyuruiCD = "SX" Or HaraidashiTankaRiyo <> "1" Then %>
																	<td align="right" width="17%"><% = SetMoney(Tanka(1), false, true) %><br></td>
																	<% End If %>
																</tr>
																<tr>
																	<% If BunsyoSyuruiCD = "ZS" Then %>
																	<td align="left"><% = AscLeft(ConvZairyoMeisyo(SyohinCD(2)),38) %><br></td> <!-- 商品名称を38Byteで切り捨て(061031小野)-->
																	<% Else %>
																	<td align="left"><% = AscLeft(ConvSyohinMeisyo(SyohinCD(2)),38) %><br></td> <!-- 商品名称を38Byteで切り捨て(061031小野)-->
																	<% End If %>
																	<% If HyojunTankaHyoji <> "0" Then '標準販売単価表示 %>
																	<td align="right" width="17%"><% = SetMoney(Kakaku(2), false, true) %><br></td>
																	<% End If %>
																	<td align="right" width="16%"><% = SetMoney(Suryo(2), false, true) %><br></td>
																	<% 'If 1 = 1 Or BunsyoSyuruiCD = "SC" Or BunsyoSyuruiCD = "SS" Or BunsyoSyuruiCD = "SX" Then %>
																	<% If BunsyoSyuruiCD = "SC" Or BunsyoSyuruiCD = "SS" Or BunsyoSyuruiCD = "SX" Or HaraidashiTankaRiyo <> "1" Then %>
																	<td align="right" width="17%"><% = SetMoney(Tanka(2), false, true) %><br></td>
																	<% End If %>
																</tr>
																<tr>
																	<% If BunsyoSyuruiCD = "ZS" Then %>
																	<td align="left"><% = AscLeft(ConvZairyoMeisyo(SyohinCD(3)),38) %><br></td> <!-- 商品名称を38Byteで切り捨て(061031小野)-->
																	<% Else %>
																	<td align="left"><% = AscLeft(ConvSyohinMeisyo(SyohinCD(3)),38) %><br></td> <!-- 商品名称を38Byteで切り捨て(061031小野)-->
																	<% End If %>
																	<% If HyojunTankaHyoji <> "0" Then '標準販売単価表示 %>
																	<td align="right" width="17%"><% = SetMoney(Kakaku(3), false, true) %><br></td>
																	<% End If %>
																	<td align="right" width="16%"><% = SetMoney(Suryo(3), false, true) %><br></td>
																	<% 'If 1 = 1 Or BunsyoSyuruiCD = "SC" Or BunsyoSyuruiCD = "SS" Or BunsyoSyuruiCD = "SX" Then %>
																	<% If BunsyoSyuruiCD = "SC" Or BunsyoSyuruiCD = "SS" Or BunsyoSyuruiCD = "SX" Or HaraidashiTankaRiyo <> "1" Then %>
																	<td align="right" width="17%"><% = SetMoney(Tanka(3), false, true) %><br></td>
																	<% End If %>
																</tr>
																<tr>
																	<% If BunsyoSyuruiCD = "ZS" Then %>
																	<td align="left"><% = AscLeft(ConvZairyoMeisyo(SyohinCD(4)),38) %><br></td> <!-- 商品名称を38Byteで切り捨て(061031小野)-->
																	<% Else %>
																	<td align="left"><% = AscLeft(ConvSyohinMeisyo(SyohinCD(4)),38) %><br></td> <!-- 商品名称を38Byteで切り捨て(061031小野)-->
																	<% End If %>
																	<% If HyojunTankaHyoji <> "0" Then '標準販売単価表示 %>
																	<td align="right" width="17%"><% = SetMoney(Kakaku(4), false, true) %><br></td>
																	<% End If %>
																	<td align="right" width="16%"><% = SetMoney(Suryo(4), false, true) %><br></td>
																	<% 'If 1 = 1 Or BunsyoSyuruiCD = "SC" Or BunsyoSyuruiCD = "SS" Or BunsyoSyuruiCD = "SX" Then %>
																	<% If BunsyoSyuruiCD = "SC" Or BunsyoSyuruiCD = "SS" Or BunsyoSyuruiCD = "SX" Or HaraidashiTankaRiyo <> "1" Then %>
																	<td align="right" width="17%"><% = SetMoney(Tanka(4), false, true) %><br></td>
																	<% End If %>
																</tr>
																<tr>
																	<% If BunsyoSyuruiCD = "ZS" Then %>
																	<td align="left"><% = AscLeft(ConvZairyoMeisyo(SyohinCD(5)),38) %><br></td> <!-- 商品名称を38Byteで切り捨て(061031小野)-->
																	<% Else %>
																	<td align="left"><% = AscLeft(ConvSyohinMeisyo(SyohinCD(5)),38) %><br></td> <!-- 商品名称を38Byteで切り捨て(061031小野)-->
																	<% End If %>
																	<% If HyojunTankaHyoji <> "0" Then '標準販売単価表示 %>
																	<td align="right" width="17%"><% = SetMoney(Kakaku(5), false, true) %><br></td>
																	<% End If %>
																	<td align="right" width="16%"><% = SetMoney(Suryo(5), false, true) %><br></td>
																	<% 'If 1 = 1 Or BunsyoSyuruiCD = "SC" Or BunsyoSyuruiCD = "SS" Or BunsyoSyuruiCD = "SX" Then %>
																	<% If BunsyoSyuruiCD = "SC" Or BunsyoSyuruiCD = "SS" Or BunsyoSyuruiCD = "SX" Or HaraidashiTankaRiyo <> "1" Then %>
																	<td align="right" width="17%"><% = SetMoney(Tanka(5), false, true) %><br></td>
																	<% End If %>
																</tr>


															</table>
														</td>
													</tr>
												</table>
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>


<%
		Response.Write(PrintFooter())
%>
</body>
<% = HtmlFooter %>
<%
End Sub
%>