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

<%
'<!--
'################################################
'	名称	:寄託出庫依頼処理
'	作成日:2006/12/11
'	作成者:鈴木
'	目的  :寄託出庫依頼を表示する。
'	概要	:
'################################################
'-->
'
%>

<%
main()

Sub main()

	Dim SakuseiKaisyaCD                            '作成会社CD
	Dim TorihikisakiCD                             '取引先CD
	Dim KitakuGaisyaCD                             '寄託会社CD
	Dim SenpoKitakuGaisyaCD                        '先方寄託会社CD
	Dim UnsoGaisyaCD                               '運送会社CD
	Dim UnsoGaisyaMei                              '運送会社名
	Dim BunsyoSyuruiCD                             '文書種類CD
	Dim BunsyoNaiyoCD                              '文書内容CD
	Dim SenpoBunsyoSyuruiCD                        '先方文書種類CD
	Dim SenpoBunsyoNaiyoCD                         '先方文書内容CD
	Dim Syoribi                                    '処理日
	Dim SenpoSyoribi                               '先方処理日
	Dim NonyuKijitsu                               '納入期日
	Dim UntinSyogakariKubun                        '運賃諸掛区分
	Dim Unsohi                                     '運送費
	Dim UnsohiSeikyuFlg                            '運送請求フラグ
	Dim Tekiyo                                     '摘要
	Dim ShiharaiHoho                               '支払方法
	Dim HasshinFlg                                 '発信フラグ
	Dim Kakaku(6)		                               '標準単価
	Dim SyohinCD(6)	                               '商品コード
	Dim SyohinName(6)							                 '商品名称
	Dim Suryo(6)		                               '数量
	Dim Tanka(6)		                               '単価
	Dim UnsoTanka(6)	                             '運送単価
	Dim Zaiko(6)		                               '在庫数量
	Dim GakuseiShimei							                 '学生氏名(係印)
	Dim SyoruiMei                                  '書類名
	Dim Query
	Dim Content
	Dim Shimei                                     '氏名
	Dim PageType
	Dim ZaikoTemp
	Dim ShijyoCD(5)                                '市場CD
	Dim SyohinNyusyukkoSeikousei

	BunsyoNaiyoCD = Request("BunsyoNaiyoCD")
	BunsyoSyuruiCD = Request("BunsyoSyuruiCD")
	SenpoBunsyoNaiyoCD = Request("SenpoBunsyoNaiyoCD")
	SenpoBunsyoSyuruiCD = Request("SenpoBunsyoSyuruiCD")
	
	Dim Bintype
	Bintype = Request("Bintype")
	If Bintype = "" Then
		Bintype = "KitakuSyukoIrai"
	End If

	'フラグ取得
	Dim Kitakuriyou
	Dim Jissenbi
	Query = "exec SPM演習取得 '" & GB_SystemCD & "','" & EnshuCD & "'"
	Set Content = OpenQuery(Query)
	If Not(Content.BOF Or Content.EOF) Then
		SyohinNyusyukkoSeikousei = Content.Fields("商品入出庫整合性利用")
		Kitakuriyou = Content.Fields("寄託倉庫利用") 
		Jissenbi = "" & Content.Fields("実践日")
	End If

	Query = "exec SPM会社取得 '" & GB_SystemCD & "','" & EnshuCD & "','" & KaisyaCD & "'"
	Set Content = OpenQuery(Query)
	If Not(Content.BOF Or Content.EOF) Then
		If KitakuGaisyaCD = "" Then
			KitakuGaisyaCD = Content.Fields("寄託会社CD")
		End If
	End If

	PageType = Request("PageType")

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

	'SyoruiMei = ConvKubunMeisyo("入出庫区分", BunsyoSyuruiCD)
	If BunsyoSyuruiCD = "SX" Then
		SyoruiMei = "寄託確認"
	Else
		SyoruiMei = "寄託出庫依頼書"
	End If

	If BunsyoNaiyoCD <> "" Or SenpoBunsyoNaiyoCD <> "" Then
	
		If SenpoFlg = 1 Then
		
			Query = "exec SPD仕入売上書類取得4 '" & GB_SystemCD & "','" & EnshuCD & "','" & KaisyaCD & "', '" & SakuseiKaisyaCD & "', '" & SenpoBunsyoSyuruiCD & "', '" & SenpoBunsyoNaiyoCD & "'"
			
		Else
		
			Query = "exec SPD仕入売上書類取得4 '" & GB_SystemCD & "','" & EnshuCD & "','" & KaisyaCD & "', '" & KaisyaCD & "', '" & BunsyoSyuruiCD & "', '" & BunsyoNaiyoCD & "'"
			
		End If

'Response.Write(Query)

		Set Content = OpenQuery(Query)

		If Not(Content.BOF Or Content.EOF) Then
		
			If SenpoFlg = 1 Then
				SakuseiKaisyaCD = Content.Fields("作成会社CD")
				TorihikisakiCD = Content.Fields("取引先CD")
				Syoribi = Content.Fields("処理日")
				SenpoSyoribi = Content.Fields("先方処理日")
			Else
				SakuseiKaisyaCD = Content.Fields("作成会社CD")
				TorihikisakiCD = Content.Fields("取引先CD")
				Syoribi = Content.Fields("先方処理日")
				SenpoSyoribi = Content.Fields("処理日")
			End If
			
			UnsoGaisyaCD = Content.Fields("運送会社CD")
			KitakuGaisyaCD = Content.Fields("寄託会社CD")
			SenpoKitakuGaisyaCD = Content.Fields("先方寄託会社CD")
			

			Do While Not(Content.BOF Or Content.EOF)
				Dim DenpyoSEQ,PreDenpyoSEQ
				DenpyoSEQ = Content.Fields("文書内容SEQ")
				SyohinCD(DenpyoSEQ) = Content.Fields("商品CD")
				
				Zaiko(DenpyoSEQ) = ConvSyohinZaiko(Content.Fields("商品CD"))

				ShijyoCD(DenpyoSEQ) = Content.Fields("市場CD")
				
				SyohinName(DenpyoSEQ) = ConvSyohinMeisyo(Content.Fields("商品CD"))
				Kakaku(DenpyoSEQ) = ConvSyohinHanbaiTanka(Content.Fields("商品CD"))
				Suryo(DenpyoSEQ) = Content.Fields("数量")
				Tanka(DenpyoSEQ) = Content.Fields("単価")
				UnsoTanka(DenpyoSEQ) = Content.Fields("運送単価")
				
				Content.MoveNext
			Loop
		End If
	End If

	Query = "exec SPD仕入売上書類取得4 '" & GB_SystemCD & "','" & EnshuCD & "','" & KaisyaCD & "', '" & KaisyaCD & "', 'KS', '" & BunsyoNaiyoCD & "'"
	Set Content = OpenQuery(Query)
	If Not(Content.BOF Or Content.EOF) Then
'		Response.Redirect("fd_kitaku_syukko_view.asp?SakuseiKaisyaCD=" & KaisyaCD & "&BunsyoSyuruiCD=KS&BunsyoNaiyoCD=" & BunsyoNaiyoCD & "&BinType=Hasshin")
		HasshinFlg = Content.Fields("発行フラグ")
	End If

	Dim jj,tmps
	Dim SyohinMeisyo, SyohinMeisyoListWidth, ShijyoListWidth
	
	SyohinMeisyo = "商品略名称"
	SyohinMeisyoListWidth = "width: 120;"
	ShijyoListWidth = "width:80"
	If BunsyoSyuruiCD <> "KI" AND BunsyoSyuruiCD <> "KX" AND BunsyoSyuruiCD <> "KY" Then
		SyohinMeisyo = "商品略名称"
		SyohinMeisyoListWidth = "width: 120;"
		ShijyoListWidth = "width:80"
	Else
		SyohinMeisyo = "商品名称"
	End If

'Response.Write("[" & KitakuGaisyaCD & "]<br>")
'Response.Write("[" & SenpoKitakuGaisyaCD & "]<br>")
'Exit Sub


	'何らかの理由で仕入売上書類Fの寄託会社・先方寄託会社にNULLがセットされてしまうことがあるので保険(091225)
	If "" & KitakuGaisyaCD = "" Then
		Query = "exec SPM会社取得 '" & GB_SystemCD & "','" & EnshuCD & "','" & KaisyaCD & "'"
		Set Content = OpenQuery(Query)
		If Not(Content.BOF Or Content.EOF) Then
			KitakuGaisyaCD = Content.Fields("寄託会社CD")
			Query = ""
			Query = Query & "  "
			Query = Query & " UPDATE TSA仕入売上書類F "
			Query = Query & " SET 寄託会社CD = '" & KitakuGaisyaCD & "' "
			Query = Query & " WHERE システムCD = '" & GB_SystemCD & "' "
			Query = Query & " 	AND 演習CD = '" & EnshuCD & "' "
			Query = Query & " 	AND 作成会社CD = '" & KaisyaCD & "' "
			Query = Query & " 	AND (寄託会社CD = '' OR 寄託会社CD IS NULL) "
'			Set Content = OpenQuery(Query)
'			Query = ""
'			Query = Query & "  "
			Query = Query & " UPDATE TSA仕入売上書類F "
			Query = Query & " SET 先方寄託会社CD = '" & KitakuGaisyaCD & "' "
			Query = Query & " WHERE システムCD = '" & GB_SystemCD & "' "
			Query = Query & " 	AND 演習CD = '" & EnshuCD & "' "
			Query = Query & " 	AND 取引先CD = '" & KaisyaCD & "' "
			Query = Query & " 	AND (先方寄託会社CD = '' OR 先方寄託会社CD IS NULL) "
			Set Content = OpenQuery(Query)
		End If
	End If
	If "" & SenpoKitakuGaisyaCD = "" Then
		Query = "exec SPM会社取得 '" & GB_SystemCD & "','" & EnshuCD & "','" & TorihikisakiCD & "'"
		Set Content = OpenQuery(Query)
		If Not(Content.BOF Or Content.EOF) Then
			SenpoKitakuGaisyaCD = Content.Fields("寄託会社CD")
			Query = ""
			Query = Query & "  "
			Query = Query & " UPDATE TSA仕入売上書類F "
			Query = Query & " SET 先方寄託会社CD = '" & SenpoKitakuGaisyaCD & "' "
			Query = Query & " WHERE システムCD = '" & GB_SystemCD & "' "
			Query = Query & " 	AND 演習CD = '" & EnshuCD & "' "
			Query = Query & " 	AND 取引先CD = '" & TorihikisakiCD & "' "
			Query = Query & " 	AND (先方寄託会社CD = '' OR 先方寄託会社CD IS NULL) "
'			Set Content = OpenQuery(Query)
'			Query = ""
'			Query = Query & "  "
			Query = Query & " UPDATE TSA仕入売上書類F "
			Query = Query & " SET 寄託会社CD = '" & SenpoKitakuGaisyaCD & "' "
			Query = Query & " WHERE システムCD = '" & GB_SystemCD & "' "
			Query = Query & " 	AND 演習CD = '" & EnshuCD & "' "
			Query = Query & " 	AND 作成会社CD = '" & TorihikisakiCD & "' "
			Query = Query & " 	AND (寄託会社CD = '' OR 寄託会社CD IS NULL) "
			Set Content = OpenQuery(Query)
		End If
	End If

'Response.Write("[" & KitakuGaisyaCD & "]<br>")
'Response.Write("[" & SenpoKitakuGaisyaCD & "]<br>")
'Exit Sub


%>
<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 = 2;
	
/////////////////////////////////////////
//function CngShohin
//市場を選択し商品を変更する
//060803suzuki
//配列をASPでJavaScript内で作成しResponse.Write。
/////////////////////////////////////////
function CngShohin(selindex,selname){
//商品CD及び商品名の配列を作成
Val = new Array();
Tex = new Array();

//debug
//alert(selindex);
//alert(selname);

<%
	Dim Query2,Content2,i,j
	i=0
	j=0
	
	'TDA市場Mから市場(市場CD)を取得
	Query = "exec SPM市場一覧 '" & GB_SystemCD & "','" & EnshuCD & "'"
	Set Content = OpenQuery(Query)

	If Not(Content.BOF Or Content.EOF) Then
	
		Do While Not(Content.BOF Or Content.EOF)
			
			Response.Write("Val[" & i & "] = new Array()" & vbCrLf)
			Response.Write("Tex[" & i & "] = new Array()" & vbCrLf)
			
			'TDA商品Mから商品CDと商品名を取得し、JavaScript用の配列として書き出す
			if i = 0 then
				Query2 = "exec SPM商品市場一覧 '" & GB_SystemCD & "','" & EnshuCD & "','', '" & GB_GakuseiNo & "'"
			else
				Query2 = "exec SPM商品市場一覧2 '" & GB_SystemCD & "','" & EnshuCD & "','" & Content.Fields("市場CD") & "', '" & GB_GakuseiNo & "'"
			end if
			
			Set Content2 = OpenQuery(Query2)
			
			If Not(Content2.BOF Or Content2.EOF) Then
			
				j = 0
					Response.Write("Val[" & i & "][" & j & "] = ''" & vbCrLf )
					Response.Write("Tex[" & i & "][" & j & "] = '    '" & vbCrLf )
				j = j + 1
				Do While Not(Content2.BOF Or Content2.EOF)
				
					Response.Write("Val[" & i & "][" & j & "] = '" & Content2.Fields("商品CD") & "'" & vbCrLf )
					Response.Write("Tex[" & i & "][" & j & "] = '" & Content2.Fields(SyohinMeisyo) & "'" & vbCrLf )

					Content2.MoveNext
					
					j = j + 1
				Loop
				
			End If
			
			if i <> 0 then
				Content.MoveNext
			end if
			
			i = i + 1
		Loop

	End If
%>

	switch (selname) {
	  case 'S1':
			document.form1.SyohinCD1.options.length = Val[selindex].length //配列長を変更
			for(i=0;i<Val[selindex].length;i++){
				document.form1.SyohinCD1.options[i].value = Val[selindex][i]
				document.form1.SyohinCD1.options[i].text = Tex[selindex][i]
			}
			document.form1.SyohinCD1.selectedIndex = 0
			break;
			
	  case 'S2':

			document.form1.SyohinCD2.options.length = Val[selindex].length //配列長を変更
			for(i=0;i<Val[selindex].length;i++){
				document.form1.SyohinCD2.options[i].value = Val[selindex][i]
				document.form1.SyohinCD2.options[i].text = Tex[selindex][i]
			}
			document.form1.SyohinCD2.selectedIndex = 0
			break;
			
	  case 'S3':
	  
			document.form1.SyohinCD3.options.length = Val[selindex].length //配列長を変更
			for(i=0;i<Val[selindex].length;i++){
				document.form1.SyohinCD3.options[i].value = Val[selindex][i]
				document.form1.SyohinCD3.options[i].text = Tex[selindex][i]
			}
			document.form1.SyohinCD3.selectedIndex = 0
			break;
			
	  case 'S4':
	  
			document.form1.SyohinCD4.options.length = Val[selindex].length //配列長を変更
			for(i=0;i<Val[selindex].length;i++){
				document.form1.SyohinCD4.options[i].value = Val[selindex][i]
				document.form1.SyohinCD4.options[i].text = Tex[selindex][i]
			}
			document.form1.SyohinCD4.selectedIndex = 0
			break;
			
	  case 'S5':
	  
			document.form1.SyohinCD5.options.length = Val[selindex].length //配列長を変更
			for(i=0;i<Val[selindex].length;i++){
				document.form1.SyohinCD5.options[i].value = Val[selindex][i]
				document.form1.SyohinCD5.options[i].text = Tex[selindex][i]
			}
			document.form1.SyohinCD5.selectedIndex = 0
			break;
		
    default:
			break;
   }

}
	
-->
</SCRIPT>

<body onkeydown="if(ExitFlg==2)ExitFlg=3;" onBeforeUnload="window.event.returnValue = ExitMsg(ExitFlg)" bgcolor="#5C70B6" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<form OnKeyDown="FormKeyDown(this)"	 method="POST" action="fd_kitaku_syukko_bin.asp" name="form1">
<input type="hidden" name="OldBunsyoNaiyoCD" value="<% = BunsyoNaiyoCD %>">
<input type="hidden" name="BinType" value="<% = BinType %>">
<input type="hidden" name="Action" value="">

<%
	Response.Write(HtmlDesign(1))

	Response.Write(HttpL1(3))

	If BunsyoSyuruiCD = "SC" Then
		Response.Write(HttpL2("会社選択" ,"tblbtn( '/" & HomeAlias & "/user/bk/')", GB_GyosyuMeisyo, "tblbtn( '/" & HomeAlias & "/user/bk/menu_" & GB_Gyosyu & ".asp')", "商品企画室", "tblbtn( '/" & HomeAlias & "/user/bk/menu_s5.asp')", SyoruiMei, "", "", "", "", ""))
	ElseIf BunsyoSyuruiCD = "SX" Then
		Response.Write(HttpL2("会社選択" ,"tblbtn( '/" & HomeAlias & "/user/bk/')", GB_GyosyuMeisyo, "tblbtn( '/" & HomeAlias & "/user/bk/menu_" & GB_Gyosyu & ".asp')", "仕入部", "tblbtn( '/" & HomeAlias & "/user/bk/menu_s3.asp')", SyoruiMei, "", "", "", "", ""))
	Else
		Response.Write(HttpL2("会社選択" ,"tblbtn( '/" & HomeAlias & "/user/bk/')", GB_GyosyuMeisyo, "tblbtn( '/" & HomeAlias & "/user/bk/menu_" & GB_Gyosyu & ".asp')", "販売部", "tblbtn( '/" & HomeAlias & "/user/bk/menu_s2.asp')", SyoruiMei, "", "", "", "", ""))
	End If

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

	If SyohinNyusyukkoSeikousei = "1" And SenpoBunsyoNaiyoCD <> "" Then
		Response.Write(HttpL3_1("受け付ける", "SubmitCheck()", "受け付けない", "form1.Action.value='Deny';SubmitReal(form1);", "", "", "", "", "", ""))
	Else 
		If HasshinFlg <> 1 Then
			Response.Write(HttpL3_1("保存", "SubmitCheck()", "", "", "", "", "", "", "", ""))
		Else
			Response.Write(HttpL3_1("", "", "", "", "", "", "", "", "", ""))
		End If
	End If

	'Response.Write(HttpL3_2("先方書類一覧", "tblbtn( 'fd_kitaku_syukko_ichiran.asp?BunsyoSyuruiCD=" & BunsyoSyuruiCD & "')", "一覧表示", "tblbtn( 'fd_kitaku_syukko_ichiran.asp?BunsyoSyuruiCD=" & BunsyoSyuruiCD & "')", "", "", "", "", "", ""))
	'Response.Write(HttpL3_2("先方書類一覧", "tblbtn( 'fd_kitaku_syukko_ichiran.asp?BunsyoSyuruiCD=" & BunsyoSyuruiCD & "')", "", "", "", "", "", "", "", ""))
	Response.Write(HttpL3_2("一覧表示", "tblbtn('fd_kitaku_syukko_ichiran.asp?BunsyoSyuruiCD=KS')", "先方書類一覧", "tblbtn( 'fd_kitaku_syukko_ichiran.asp?BunsyoSyuruiCD=KU')", "", "", "", "", "", ""))

	Response.Write(HttpL4("寄託出庫依頼書",""))


%>

<div id="L0" style="position: absolute; visibility: hidden; left: 0px; top: -2000px;">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="5">
	<tr>
		<td align="CENTER" valign="middle">
			<table width="600" height="355" border="0" cellpadding="10" cellspacing="0" style="border:solid 1px #000000" bgcolor="#FFFFFF">
				<tr>
					<td height="355" align="CENTER" valign="middle">
						<table width="600" border="0" cellspacing="0" cellpadding="0" height="355">
							<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 border="0" cellpadding="0" cellspacing="0">
													<tr class="tx1214">
														<td align="left">
															<table 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="middle">
									<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse"  height="168" width="580" class="tx1618">
										<tr>
											<td width="13%" height="20">出庫番号</td>
											<td width="51%" height="20">
												<input type="hidden" name="BunsyoNaiyoCD" size="13" readonly class="tbox4_ro" value="<% = BunsyoNaiyoCD %>"><% = BunsyoNaiyoCD %>
											</td>
											<td width="13%" height="20">処 理 日</td>
											<td width="23%" height="20">
												<% If HasshinFlg = 1 Then %>
													<input type="text" name="Syoribi" size="12" readonly class="tbox4_ro" value="<% = Syoribi %>">
												<% ElseIf Jissenbi <> "" Then %>
													<input type="text" name="Syoribi" size="12" readonly class="tbox4_ro" value="<% = Jissenbi %>">
												<% Else %>
													<input type="text" name="Syoribi" size="12" value="" onBlur="SetDate(this, 1, true)" class="tbox4">
												<% End If %>
											</td>
										</tr>
										
										<tr>
											<td height="20">取 引 先</td>
											<td height="20">
												<% If BunsyoNaiyoCD <> "" Then %>
													<input type="hidden" name="TorihikisakiMei" size="15" readonly class="tbox4_ro" value="<% =ConvKaisyaMeisyoDX(EnshuCD, TorihikisakiCD) %>"><% =ConvKaisyaMeisyoDX(EnshuCD, TorihikisakiCD) %>
													<input type="hidden" name="TorihikisakiCD" size="15" value="<% = TorihikisakiCD %>">
												<% Else %>
												
												
															<select size="1" name="TorihikisakiCD" class="tbox4" style="width:105" OnChange="SetSenpoKitakuGaisya();">

																<option value="">    </option>
																<%
																		Query = "exec SPM会社全部一覧 '" & GB_SystemCD & "','" & EnshuCD & "', '" & GakuseiNo & "'"
																	Set Content = OpenQuery(Query)

																		Do While Not(Content.BOF Or Content.EOF)

																			'If ((BunsyoKubun = "X" OR BunsyoKubun = "1") AND Content.Fields("業種CD") = "K") OR ((BunsyoKubun <> "X" AND BunsyoKubun <> "1") AND Content.Fields("業種CD") = "S") Then
																			If (Content.Fields("業種CD") = "S") Then
																				Dim TmpKaisyaCD
																				TmpKaisyaCD = Content.Fields("会社CD")
																				If TmpkaisyaCD <> KaisyaCD Then
																					Response.Write("<option value=""" & Content.Fields("会社CD") & """")
																					If Content.Fields("会社CD") = TorihikisakiCD Then
																						Response.Write(" selected")
																					End If
																					Response.Write(">" & Content.Fields("会社名称") & "</option>" & vbCrLf)
																				End If
																			End If
																			Content.MoveNext
																		Loop
																%>

															</select>
												
												
												<% End If %>
											</td>
											<td height="20">注文請日</td>
											<td height="20">
												<% If BunsyoNaiyoCD <> "" Then %>
													<input type="hidden" name="SenpoSyoribi" size="15" readonly class="tbox4_ro" value="<% = SenpoSyoribi %>"><% = SenpoSyoribi %>
												<% Else %>
													<input type="text" name="SenpoSyoribi" size="16" value="" onBlur="SetDate(this, 1, true)" class="tbox4">
												<% End If %>
											</td>
										</tr>

										<tr>
											<td height="20">依頼会社</td>
											<td height="20">

													<input type="hidden" name="IraiGaisyaMei" size="15" readonly class="tbox4_ro" value="<% =ConvKaisyaMeisyoDX(EnshuCD, SakuseiKaisyaCD) %>"><% =ConvKaisyaMeisyoDX(EnshuCD, SakuseiKaisyaCD) %>
													<input type="hidden" name="IraiGaisyaCD" value="<% = SakuseiKaisyaCD %>">

											</td>
											<td height="20" align="center"></td>
											<td height="20"></td>
										</tr>

										<tr>
											<td height="20">寄託倉庫</td>
											<td height="20">

													<input type="hidden" name="KitakuGaisyaMei" size="15" readonly class="tbox4_ro" value="<% =ConvKaisyaMeisyoDX(EnshuCD, KitakuGaisyaCD) %>"><% =ConvKaisyaMeisyoDX(EnshuCD, KitakuGaisyaCD) %>
													<input type="hidden" name="KitakuGaisyaCD" value="<% =KitakuGaisyaCD %>">

											</td>
											<td height="20" align="center"></td>
											<td height="20"></td>
										</tr>

										<tr>
											<td height="20">納入場所</td>
											<td height="20">
												<% If BunsyoNaiyoCD <> "" Then %>
<!--
													<input type="hidden" name="SenpoKitakuGaisyaCD" size="15" readonly class="tbox4_ro" value="<% =ConvKaisyaMeisyoDX(EnshuCD, SenpoKitakuGaisyaCD) %>"><% =ConvKaisyaMeisyoDX(EnshuCD, SenpoKitakuGaisyaCD) %>
-->
													<input type="hidden" name="SenpoKitakuGaisyaCD" size="15" readonly class="tbox4_ro" value="<% = SenpoKitakuGaisyaCD %>"><% =ConvKaisyaMeisyoDX(EnshuCD, SenpoKitakuGaisyaCD) %>
												<% Else %>
																
																<input type="hidden" name="SenpoKitakuGaisyaMei" size="15" value="<% =ConvKaisyaMeisyo(SenpoKitakuGaisyaCD) %>" readonly class="tbox4_ro"><% =ConvKaisyaMeisyo(SenpoKitakuGaisyaCD) %>
																<input type="hidden" name="SenpoKitakuGaisyaCD" value="<% =SenpoKitakuGaisyaCD %>">
																
												<% End If %>
											</td>
											<td height="20" align="center"></td>
											<td height="20"></td>
										</tr>

										<tr>
											<td height="20">運送会社</td>
											<td height="20">
												<% If BunsyoNaiyoCD <> "" Then %>
													<input type="hidden" name="UnsoGaisyaCD" size="15" readonly class="tbox4_ro" value="<% =ConvKaisyaMeisyoDX(EnshuCD, UnsoGaisyaCD) %>"><% =ConvKaisyaMeisyoDX(EnshuCD, UnsoGaisyaCD) %>
												<% Else %>
												
															<select size="1" name="UnsoGaisyaCD" class="tbox4" style="width:105">
																<option value="">    </option>
																<%
																	Query = "exec SPM会社全部一覧 '" & GB_SystemCD & "','" & EnshuCD & "', '" & GakuseiNo & "'"
																	Set Content = OpenQuery(Query)
																		Do While Not(Content.BOF Or Content.EOF)
																			If Content.Fields("業種CD") = "U" Then
																				Response.Write("<option value=""" & Content.Fields("会社CD") & """")
																				If Content.Fields("会社CD") = UnsoGaisyaCD Then
																					Response.Write(" selected")
																				End If
																				Response.Write(">" & Content.Fields("会社名称") & "</option>" & vbCrLf)
																			End If
																			Content.MoveNext
																		Loop
																%>
															</select>
												
												<% End If %>
											</td>
											<td height="20" align="center"></td>
											<td height="20"></td>
										</tr>
										
									</table>
								</td>
							</tr>
							<tr>
								<td align="CENTER">

									<table width="520" height="180" border="0" cellpadding="4" cellspacing="0" style="border-collapse: collapse; border:solid 2px #FFFFFF">
										<tr>
											<td width="100%" align="RIGHT">
												<table border="0" 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" style="border-collapse: collapse" bordercolor="#000000"  class="tx1618" bgcolor="#CCCCCC">
																	<tr>
																		<td align="center">商品名称</td>
																		<td align="center" width="19%"><% If MHMSTDSELLPRICE <> "" Then Response.Write(MHMSTDSELLPRICE) Else Response.Write("標準単価") End If %></td>
																		<% If HasshinFlg <> 1  Then %>
																		<td align="center" width="18%">在庫数</td>
																		<% End If %>
																		<td align="center" width="18%">数 量</td>

																		</tr>
																</table>
															</td>
													</tr>
													<tr>
															<td>
															
															<!-- ■市場選択機能追加060803suzuki //-->
															
																<table width="100%" height="180" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#000000"  class="tx1618">
																<%
																	dim ii
																	For ii = 1 to 5
																		Response.Write("<tr>")

																		If SenpoBunsyoSyuruiCD <> "" Or HasshinFlg = 1  Then 

																			Response.Write("<td align='left'>" & ConvSyohinRyakuMeisyo(SyohinCD(ii)) & "<br></td>" & vbCrLf)
																			Response.Write("<td align='right' width='16%'>" & SetMoney(Kakaku(ii), false, true) & "<br></td>" & vbCrLf)
																			If GB_Gyosyu <> "K" AND BunsyoNaiyoCD = "" Then
																				Response.Write("<td align='right' width='16%'>" & SetMoney(Zaiko(ii), false, true) & "<br></td>" & vbCrLf)
																			End If
																			Response.Write("<td align='right' width='16%'>" & SetMoney(Suryo(ii), false, true) & "<br></td>" & vbCrLf)

																		Else

																			Response.Write("<td align='center'>")

																			If 0=1 Then
																	%>

																			<select name="S<% =ii %>" size="1" style="<% = ShijyoListWidth %>" onChange="CngShohin(this.selectedIndex,this.name)" class="tbox4">
																			<option value="">    </option>
																			<% 

																					Query = "exec SPM市場一覧 '" & GB_SystemCD & "','" & EnshuCD & "'"
																					Set Content = OpenQuery(Query)
																					Do While Not(Content.BOF Or Content.EOF)
																					
																						Response.Write("<option value=""" & Content.Fields("市場CD") & """")
																						If Content.Fields("市場CD") = ShijyoCD(ii) Then 
																							Response.Write(" selected")
																						End If
																						Response.Write(">" & Content.Fields("市場名称") & "</option>" & vbCrLf)
																						
																						Content.MoveNext
																					Loop

																			%>
																			</select>
																<%

																				
																				Response.Write("<select name='SyohinCD" & ii & "' size='1' class='tbox4' style='" & SyohinMeisyoListWidth & "' onChange='SetSyohinHanbaiTanka(" & ii & ");SetSyohinZaiko(" & ii & ");'>")
																				Response.Write("<option value=''>    </option>")

																				Query = "exec SPM商品市場一覧 '" & GB_SystemCD & "','" & EnshuCD & "','" & ShijyoCD(ii) & "', '" & GB_GakuseiNo & "'"
																				Set Content = OpenQuery(Query)
																				Do While Not(Content.BOF Or Content.EOF)
																					If BunsyoSyuruiCD <> "SC" Or (BunsyoSyuruiCD = "SC" And Content.Fields("所有会社CD") = KaisyaCD ) Then 
																						Response.Write("<option value='" & Content.Fields("商品CD") & "'")
																						If Content.Fields("商品CD") = SyohinCD(ii) Then
																							Response.Write(" selected")
																						End If
																						Response.Write(">" & Content.Fields("商品略名称") & "</option>" & vbCrLf)
																					End If
																					Content.MoveNext
																				Loop
																				Response.Write("</select>")

																			Else

																				Response.Write("<input type='text' name='SyohinMeisyo" & ii & "' size='40' value='" & ConvSyohinMeisyo(SyohinCD(ii)) & "' class='tbox4_ro' readonly>" & vbCrLf)
																				Response.Write("<input type='hidden' name='SyohinCD" & ii & "' value='" & SyohinCD(ii) & "'>" & vbCrLf)

																			End If

																				Response.Write("</td>")
																				
																				Response.Write("<td align='center' width='19%'><input type='text' name='Kakaku" & ii & "' size='15' value='" & SetMoney(Kakaku(ii), false, true) & "' class='tbox5_ro' readonly></td>" & vbCrLf)
																				
																				If Kitakuriyou <> 1 Then
																				Response.Write("<td align='center' width='18%'><input type='text' name='Zaiko" & ii & "' size='14' value='" & SetMoney(Zaiko(ii) + Suryo(ii), false, true) & "' class='tbox5_ro' readonly></td>" & vbCrLf)
																				Else
																				Response.Write("<td align='center' width='18%'><input type='text' name='Zaiko" & ii & "' size='14' value='" & SetMoney(Zaiko(ii), false, true) & "' class='tbox5_ro' readonly></td>" & vbCrLf)
																				End If
																				
																				'If HasshinFlg <> 1 Then
																				'	Response.Write("<td align='center' width='18%'><input type='text' name='Suryo" & ii & "' size='14' value='" & SetMoney(Suryo(ii), false, true) & "' onBlur='SetNumber(this, false, 9);SetUntin();' onkeyup='ChangeMoney(this);' class='tbox5' ></td>" & vbCrLf)
																				'Else
																					Response.Write("<td align='center' width='18%'><input type='text' name='Suryo" & ii & "' size='14' value='" & SetMoney(Suryo(ii), false, true) & "' class='tbox5_ro' readonly></td>" & vbCrLf)
																				'End If
																				
																			End If

																		Response.Write("</tr>" & vbCrLf)
																	Next
																%>


																</table>
															</td>
													</tr>
												</table>
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</div>
<input type="hidden" name="BunsyoSyuruiCD" value="<% = BunsyoSyuruiCD %>">

<input type="hidden" name="SenpoBunsyoNaiyoCD" value="<% = SenpoBunsyoNaiyoCD %>">
<input type="hidden" name="SenpoBunsyoSyuruiCD" value="<% = SenpoBunsyoSyuruiCD %>">
<% If SenpoBunsyoSyuruiCD <> "" Then %>
<input type="hidden" name="TorihikisakiCD" value="<% = TorihikisakiCD %>">
<input type="hidden" name="SyohinCD1" value="<% = SyohinCD(1) %>">
<input type="hidden" name="Suryo1" value="<% = Suryo(1) %>">
<input type="hidden" name="SyohinCD2" value="<% = SyohinCD(2) %>">
<input type="hidden" name="Suryo2" value="<% = Suryo(2) %>">
<input type="hidden" name="SyohinCD3" value="<% = SyohinCD(3) %>">
<input type="hidden" name="Suryo3" value="<% = Suryo(3) %>">
<input type="hidden" name="SyohinCD4" value="<% = SyohinCD(4) %>">
<input type="hidden" name="Suryo4" value="<% = Suryo(4) %>">
<input type="hidden" name="SyohinCD5" value="<% = SyohinCD(5) %>">
<input type="hidden" name="Suryo5" value="<% = Suryo(5) %>">
<% End If %>
<input type="hidden" name="TmpTanka1" value="<% = Tanka(1) %>">
<input type="hidden" name="TmpTanka2" value="<% = Tanka(2) %>">
<input type="hidden" name="TmpTanka3" value="<% = Tanka(3) %>">
<input type="hidden" name="TmpTanka4" value="<% = Tanka(4) %>">
<input type="hidden" name="TmpTanka5" value="<% = Tanka(5) %>">
<input type="hidden" name="UnsoTanka1" value="<% = UnsoTanka(1) %>">
<input type="hidden" name="UnsoTanka2" value="<% = UnsoTanka(2) %>">
<input type="hidden" name="UnsoTanka3" value="<% = UnsoTanka(3) %>">
<input type="hidden" name="UnsoTanka4" value="<% = UnsoTanka(4) %>">
<input type="hidden" name="UnsoTanka5" value="<% = UnsoTanka(5) %>">


</form>

</body>

<SCRIPT FOR="window" EVENT="onload" LANGUAGE="JavaScript">
	SetUntin();
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript">

//################################################
//	名称:SetSyohinHanbaiTanka
//	目的:商品標準販売価格をセットする。
// 作成:2002/11/1 山崎
//################################################
	function SetSyohinHanbaiTanka(iiflag)
	{
		form1["Kakaku" + iiflag].value = ConvIntToMoney(ConvSyohinHanbaiTanka(document.form1["SyohinCD" + iiflag].value));
	}

//################################################
//	名称:SetSyohinZaiko
//	目的:商品在庫数をセットする。
// 作成:2002/11/1 山崎
//################################################
	function SetSyohinZaiko(iiflag)
	{
		if(typeof(form1["Zaiko" + iiflag]) == "object")
		{
			form1["Zaiko" + iiflag].value = ConvIntToMoney(ConvSyohinZaiko(document.form1["SyohinCD" + iiflag].value));
		}
	}

//################################################
//	名称:SetUntin
//	目的:運賃請求額を更新する
// 概要:運賃諸掛をチェックし、UnsohiSeikyuFlgを更新し、運賃とUnsohiSeikyuFlgを掛け運賃請求額を求める
//################################################
	function SetUntin()
	{
				<% If 1 = 0 Then %>
		var GokeiSuryo, UnsoTanka;
		GokeiSuryo = 0;
		for(ii = 1; ii<= 5; ii++)
		{
			if(form1["SyohinCD" + ii].value != "")
			{
				GokeiSuryo = GokeiSuryo + ConvMoneyToInt(form1["Suryo" + ii].value);
				form1["UnsoTanka" + ii].value = 0;
			}
			else
			{
				form1["UnsoTanka" + ii].value = "";
			}
		}

		if(form1.UntinSyogakariKubun.value == "K")
		{
			if(GokeiSuryo != 0)
			{
				UnsoTanka = Math.floor(ConvMoneyToInt(form1.Unsohi.value) / GokeiSuryo);
				for(ii = 1; ii<= 5; ii++)
				{
					if(form1["SyohinCD" + ii].value != "")
					{
						form1["UnsoTanka" + ii].value = UnsoTanka ;
					}
				}
			}
		}
		<% End If %>
	}

//################################################
//	名称:SubmitCheck
//	目的:更新前に入力値をチェックする。
//################################################
	function SubmitCheck()
	{

		if(form1.Syoribi.value == "")
		{
			alert("処理日を入力して下さい");
			form1.Syoribi.focus();
			return false;
		}
		
		if(typeof(form1.TorihikisakiCD) == "object")
		{
			if(form1.TorihikisakiCD.value == "")
			{
				alert("取引先を入力して下さい");
				form1.TorihikisakiCD.focus();
				return false;
			}
		}
		
		if(form1.SenpoSyoribi.value == "")
		{
			alert("注文請日を入力して下さい");
			form1.SenpoSyoribi.focus();
			return false;
		}
		
		//寄託会社CDのチェック
		<% If Kitakuriyou = 1 Then %>
		if(typeof(form1.KitakuGaisyaCD) == "object")
		{
			if(form1.KitakuGaisyaCD.value == "")
			{
				alert("寄託倉庫が設定されていません。");
				//readonlyなのでフォーカスは特にあてない
				//form1.SenpoKitakuGaisyaCD.focus(); 
				return false;
			}
		}
		
		<% If  BunsyoSyuruiCD <> "KP" Then %>
		if(typeof(form1.SenpoKitakuGaisyaCD) == "object")
		{
			if(form1.SenpoKitakuGaisyaCD.value == "")
			{
				alert("取引先の寄託倉庫が設定されていません。");
				//readonlyなのでフォーカスは特にあてない
				//form1.SenpoKitakuGaisyaCD.focus(); 
				return false;
			}
		}
		
		<% End If %>

		<% End If %>


		//** 2.運送会社のチェック
		if(typeof(form1.UnsoGaisyaCD) == "object")
		{
			if(form1.UnsoGaisyaCD.value == "")
			{
				alert("運送会社を入力して下さい");
				form1.UnsoGaisyaCD.focus();
				return false;
			}
		}


		//** 3.明細部のチェック
		var ii;
		var cnt;
		cnt=0;
		for(ii = 1;ii <= 5; ii++)
		{
			var SyohinCD;
			var Suryo;
			var Tanka;
			var Zaiko;
			var Kubun;
			SyohinCD = document.form1["SyohinCD" + ii].value;
			if(SyohinCD != "")
			{

				if(SyohinCD == "")
				{
					alert("商品を正しく選択して下さい");
					form1["SyohinCD" + ii].focus();
					return false;
				}

				Suryo = Math.floor(ConvMoneyToInt(document.form1["Suryo" + ii].value));
				if ((isNaN(Suryo)) || (Suryo == 0))
				{
					alert("数量を入力して下さい");
					form1["Suryo" + ii].focus();
					return false;
				}

				<% 'If GB_Gyosyu <> "K" AND BunsyoNaiyoCD = "" AND SyohinNyusyukkoSeikousei = "1" AND (BunsyoSyuruiCD = "SU" Or BunsyoSyuruiCD = "SX") Then %>
				<% If SyohinNyusyukkoSeikousei = "1" Then %>
				Zaiko = Math.floor(ConvMoneyToInt(document.form1["Zaiko" + ii].value, false, false));
				if (isNaN(Zaiko))
				{
					Zaiko = 0;
				}
				if (Suryo > Zaiko)
				{
					alert("在庫数量が不足しています。数量を正しく入力して下さい");
					return false;
				}
				<% End If %>

				<% If 1 = 0 Then %>
				Zaiko = Math.floor(ConvMoneyToInt(document.form1["Zaiko" + ii].value, false, false));
				if (isNaN(Zaiko))
				{
					Zaiko = 0;
				}
				if (Suryo > Zaiko)
				{
					if(!confirm("在庫数量が不足している可能性がありますが、出庫してもよろしいですか?"))
					{
						return false;
					}
				}
				<% End If %>


				<% If BunsyoSyuruiCD = "SC" Or BunsyoSyuruiCD = "SS" Or BunsyoSyuruiCD = "SX" Then %>
				Tanka = document.form1["Tanka" + ii].value;
				if(Tanka == "")
				{
					alert("仕入単価を入力して下さい");
					form1["Tanka" + ii].focus();
					return false;
				}
				<% End If %>
				cnt = 1

			}
		}

		//** 3.明細部に入力が有るかどうかのチェック
		if (cnt == 0)
		{
			alert("商品明細を入力して下さい");
			form1["SyohinCD1"].focus();
			return false;
		}
		SubmitReal(form1);
		return true;
	}



//################################################
//	名称:ConvSyohinHanbaiTanka
//	目的:商品リストの表示
// 作成:2002/8/26 川崎
// 概要:TS商品Mの標準販売単価を返す。
//################################################
	function ConvSyohinHanbaiTanka(SyohinCD)
	{
<%
	Query = "exec SPM商品一覧 '" & GB_SystemCD & "','" & EnshuCD & "', '" & GB_GakuseiNo & "'"
	Set Content = OpenQuery(Query)

		Do While Not(Content.BOF Or Content.EOF)
			Response.Write("if(SyohinCD == """ & Content.Fields("商品CD") & """)return """ & Content.Fields("標準販売単価") & """;" & vbCrLf)
			Content.MoveNext
		Loop
%>
		return "";
	}

//################################################
//	名称:ConvSyohinZaiko
//	目的:商品在庫数リストの表示
// 作成:2002/8/26 川崎
// 概要:指定日時の商品在庫数を返す。
//################################################
	function ConvSyohinZaiko(SyohinCD)
	{
<%
	Query = "exec SPR入出庫在庫 '" & GB_SystemCD & "','" & EnshuCD & "','" &	KaisyaCD & "','" & GB_KaikeiSyuryobi & "'"
	Set Content = OpenQuery(Query)

		Do While Not(Content.BOF Or Content.EOF)
			Response.Write("if(SyohinCD == """ & Content.Fields("商品CD") & """)return """ & Content.Fields("在庫数") & """;" & vbCrLf)
			Content.MoveNext
		Loop
%>
		if(SyohinCD != "")return "0";
		return "";
	}
	
	
//寄託倉庫を利用する設定で使用するスクリプトを作成
<% If Kitakuriyou = 1 Then %>
	
//################################################
//	名称:SetSenpoKitakuGaisya
//	目的:先方寄託倉庫会社をセットする。
//  作成:2006/12/10 鈴木
//################################################
	function SetSenpoKitakuGaisya()
	{
		form1.SenpoKitakuGaisyaCD.value = ConvKitakuGaisya(document.form1.TorihikisakiCD.value);
		form1.SenpoKitakuGaisyaMei.value = ConvKaisyaMei(ConvKitakuGaisya(document.form1.TorihikisakiCD.value));

	}
	
//################################################
//	名称:ConvKitakuGaisya
//	目的:寄託倉庫会社表示
//  作成:2006/12/10 鈴木
//  概要:TDA会社Mの寄託会社CDを返す
//################################################
	function ConvKitakuGaisya(KaisyaCD)
	{
	<%

	Query = "exec SPM会社一覧 '" & GB_SystemCD & "','" & EnshuCD & "', '1'"
	Set Content = OpenQuery(Query)

		Do While Not(Content.BOF Or Content.EOF)
			Response.Write("if(KaisyaCD == """ & Content.Fields("会社CD") & """)return """ & Content.Fields("寄託会社CD") & """;" & vbCrLf)
			Content.MoveNext
		Loop
	%>
		return "";
	}

//################################################
//	名称:ConvKaisyaMei
//	目的:会社名表示
//  作成:2006/12/10 鈴木
//  概要:TDA会社Mの会社名称を返す
//################################################
	function ConvKaisyaMei(KaisyaCD)
	{
	<%

	Query = "exec SPM会社一覧 '" & GB_SystemCD & "','" & EnshuCD & "', '1'"
	Set Content = OpenQuery(Query)

		Do While Not(Content.BOF Or Content.EOF)
			Response.Write("if(KaisyaCD == """ & Content.Fields("会社CD") & """)return """ & Content.Fields("会社名称") & """;" & vbCrLf)
			Content.MoveNext
		Loop
	%>
		return "";
	}

<% End If %>
//寄託利用スクリプトここまで

	
</SCRIPT>

<% = HtmlFooter %>
<SCRIPT FOR="window" EVENT="onload" LANGUAGE="JavaScript">

	<% If HasshinFlg <> 1 Then %>
	form1.Syoribi.select;

	form1.Syoribi.focus();
	form1.Syoribi.select();
	event.returnValue = false;
	return;
	<% End If %>
</SCRIPT>

</html>
<%
End Sub
%>