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

<%
'<!-- 
'################################################
'	名称	:商品一覧の印刷画面
'	作成日	:2002/9/6
'	作成者	:徳田
'	目的	:商品Mの一覧印刷画面を表示する。
'	概要	:
'			:[080314小野]材料マスタモードを追加
'################################################
'-->
'
'
%>

<%

 
main()

Sub main()
	Dim i
	Dim PageType
	PageType = Request("PageType")
	MaxPage = 100

	Dim Mode
	Mode = Request("Mode")

	Dim ShijoCD
	ShijoCD = Request("ShijoCD")

	Dim SyohinCD2
	Dim SyohinKubun
	SyohinCD2 = Request("SyohinCD")
	SyohinKubun = Request("SyohinKubun")

	Dim GenkaKaikeiRiyo
	Dim ShohizeiMode
	ShohizeiMode = TaxRateSelection 'include_stasicのグローバル変数
	Query = "exec SPM演習取得 '" & GB_SystemCD & "','" & EnshuCD & "'"
	Set Content = OpenQuery(Query)
	If Not(Content.BOF Or Content.EOF) Then
		GenkaKaikeiRiyo = "" & Content.Fields("原価会計利用")
		If Content.Fields("消費税") <= 0 And "" & Content.Fields("インボイス対応") <> "1" And "" & Content.Fields("インボイス対応") <> "2" Then
			ShohizeiMode = 0 '内税の場合は消費税率マスタ非利用に上書き ※インボイス対応を除く
		End If
	End If

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

	//印刷余白指定(ミリ指定)
	PrintTopMargin = 20;
	PrintLeftMargin = 13;
//	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 %>

<%

	Dim Title
	If Mode = "Zairyo" Then
		Title = "材料"
	Else
		Title = "商品"
	End If

	Dim RowBreakNum, RowCount
	Dim Page
	If PackageMode = "1" Then
		RowBreakNum = 30
	Else
		RowBreakNum = 5
	End If
	RowCount = 0
	

	Dim Query
	Dim Content
	Dim ii, jj
	ii = 0
	Query = "exec SPM" & Title & "一覧 '" & GB_SystemCD & "','" & EnshuCD & "', '" & GB_GakuseiNo & "'"
	Set Content = OpenQuery(Query)


	For Page = 1 To MaxPage

		If Page <> 1 Then
			Response.Write(PageBreakBefore)
		End If
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
	<tr>
		<td valign="top" align="center">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td height="100%" width="100%" valign="top">
						<%
							Response.Write(PrintHeader(0, Title & "マスター"))
						%>	
<% 'PackageMode = "1" %>
<% 'TaxRateSelection = 0 %>
						<TABLE WIDTH="700" BORDER="1" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#FFFFFF" STYLE="border-collapse: collapse" BORDERCOLOR="#000000" CLASS="tx1416">
									<% If PackageMode = "1" Then %>
													<TR ALIGN="CENTER">
														<td align="center" width="60"><% = Title %>CD</td>
														<td align="center"><% = Title %>名称</td>
														<td align="center" width="170"><% = Title %>略名称</td>
														<td align="center" width="110"><% If MHMSTDSELLPRICE <> "" Then Response.Write(MHMSTDSELLPRICE) Else Response.Write("標準販売単価") End If %></td>
													<% If ShohizeiMode = 1 Then %>
														<td align="center" width="70">標準税率</td>
													<% End If %>
													</TR>
									<% End If %>
<%
													Dim ImageFile, Tani
													Dim Lot
													Dim SyohinCD, Shohinmei , ShohinRyakumei				'商品コード、商品名称、商品略名称
													Dim HanbaiTanka , ShireTnanka , UnsoTanka		'標準販売単価、標準仕入単価、運送費単価
													Dim SokoryoTanka , Jyuryo , Yoseki			'倉庫料単価、重量、容積
													Dim Bikou						'備考
													Dim ShijyoCD, SyoyuKaisyaRyakuMeisyo, SyoyuKaisyaCD	'市場コード、所有会社略名、所有会社コード
													Dim TaxRate
													Dim ShijyoA, ShijyoB
													Dim iiDef
												
													ii = 0
													iiDef = -1

													Dim LoopFlg
													If Mode = "BuhinTenkai" Then
														'LoopFlg = 2
														LoopFlg = 1 '多段製造機能は廃止。部品展開・経費労務費の対象は製品のみ。
													Else
														LoopFlg = 1
													End If

													For jj = 1 To LoopFlg

														If jj = 2 Then
															Title = "材料"
														End If

'														Query = "exec SPM" & Title & "一覧 '" & GB_SystemCD & "','" & EnshuCD & "', '" & GB_GakuseiNo & "'"
'														Set Content = OpenQuery(Query)
'Response.Write(Query)
'Exit Sub

														Do While Not(Content.BOF Or Content.EOF)
															If ShijoCD = "" Or "" & Content.Fields("市場CD") = ShijoCD Or (ShijoCD = "higenteietnegih" And "" & Content.Fields("市場CD") = "") Then

															If Mode <> "BuhinTenkai" Or (SyohinKubun = "S" And Title = "商品") Or (SyohinKubun = "Z" And Title = "材料") Then
																If SyohinCD2 = Content.Fields("" & Title & "CD") Then
																	iiDef = ii
																End If
															End If

															SyohinCD =  Content.Fields("" & Title & "CD")
															If GB_GakuseiNo <> "" Then
																SyohinCD = Replace(SyohinCD, "-" & GB_GakuseiNo, "")
															End If
															Shohinmei = Content.Fields("" & Title & "名称")
															ShohinRyakumei = Content.Fields("" & Title & "略名称")
															HanbaiTanka = ConvIntToMoney(Content.Fields("標準販売単価"),false,false)
															ShireTnanka = ConvIntToMoney(Content.Fields("標準仕入単価"),false,false)
															UnsoTanka = ConvIntToMoney(Content.Fields("運送料単価"),false,false)
															SokoryoTanka = ConvIntToMoney(Content.Fields("倉庫料単価"),false,false)
															Jyuryo = ConvIntToMoney(Content.Fields("" & Title & "重量"),false,false)
															Yoseki = ConvIntToMoney(Content.Fields("" & Title & "容積"),false,false)
															Bikou = Content.Fields("備考")
															ImageFile = ""
															If Content.Fields("画像ファイル") <> "" Then
																ImageFile = Fgoods & "/" & EnshuCD & "/" & Content.Fields("画像ファイル")
															End If
															Tani = Content.Fields("単位")
															Lot = Content.Fields("ロット")
															ShijyoCD = Content.Fields("市場CD")
															SyoyuKaisyaRyakuMeisyo = Content.Fields("所有会社略名称")
															SyoyuKaisyaCD = Content.Fields("所有会社CD")
															TaxRate = Content.Fields("標準消費税率")

															If ShijyoCD <> "" Then
																ShijyoA = "市場"
																ShijyoB = "" & Content.Fields("市場名称")
																If ShijyoB = "" Then
																	'ShijyoB = "<span class=""tx1012""><font color=""#ff0000"">設定された<BR>市場が存在<BR>しません</font></span>"
																	ShijyoB = "<span class=""tx1012""><font color=""#ff0000"">市場コード<BR>[ <B>" & ShijyoCD & "</B> ]<BR>の市場が<BR>存在しません</font></span>"
																End If
															Else
																ShijyoA = "製造会社"
																ShijyoB = SyoyuKaisyaRyakuMeisyo
															End If
	
																												'製造部では自社企画及びマスターを表示											'商品企画室では自社商品のみ表示
'															If (PageType <> "Original" And PageType <> "SeizoBu") Or (PageType = "SeizoBu" And (SyoyuKaisyaCD = KaisyaCD Or SyoyuKaisyaCD = "")) Or (PageType = "Original" And SyoyuKaisyaCD = KaisyaCD) Then
																												'製造部・商品企画室では自社商品・材料のみ表示
															If (PageType <> "Original" And PageType <> "SeizoBu") Or ((PageType = "SeizoBu" Or PageType = "Original") And SyoyuKaisyaCD = KaisyaCD) Then
																RowCount = RowCount + 1
																Response.Write("<TR ALIGN=""CENTER"" onClick=""celsel(" & ii & ",'fm_")
																If Mode = "BuhinTenkai" Then Response.Write("buhintenkai") Else Response.Write("shohin") End If
																Response.Write("_view.asp?SyohinCD=" & Content.Fields("" & Title & "CD") & "&SyohinKubun=")
																If Title = "材料" Then Response.Write("Z") Else Response.Write("S") End If
																Response.Write("')"" onDblClick=""syokaibtn()"">" & vbCrLf)

																If PackageMode = "1" Then
%>
																			<td align="center" width="60"><% = SyohinCD %></td>
																			<td align="center" height="23">&nbsp;<% = Shohinmei %>&nbsp;</td>
																			<td align="center" width="170">&nbsp;<%= ShohinRyakumei %>&nbsp;</td>
																			<td align="right" width="110">&nbsp;<% = HanbaiTanka %>&nbsp;</td>
<%
																	If ShohizeiMode = 1 Then
%>
																			<td align="right" width="70">&nbsp;<% = TaxRate %>&nbsp;%&nbsp;</td>
<%
																	End If
																Else
%>
													<td>
														<table border="0" width="700" cellspacing="0" cellpadding="0">
<!--
															<tr>
																<td height="10" colspan="2" bgcolor="#CCCCCC">
																	<TABLE WIDTH="100%" BORDER="1" CELLPADDING="2" CELLSPACING="0" BORDERCOLOR="#000000" CLASS="tx1214" STYLE="border-collapse: collapse">
																		<tr>
																			<td align="center" width="110"><% = Title %>コード</td>
																			<td align="center"><% = SyohinCD %></td>
																		</tr>
																	</table>
																</td>
															</tr>
-->
															<tr>
																<td>
																	<TABLE WIDTH="100%" BORDER="1" CELLPADDING="2" CELLSPACING="0" BORDERCOLOR="#000000" CLASS="tx1416" STYLE="border-collapse: collapse">
																		<tr bgcolor="#dddddd">
																			<td align="center" height="27" CLASS="tx1214"><nobr><% = Title %>CD</nobr></td>
																			<td align="center" width="280"><% = Title %>名称</td>
																			<td align="center" width="140"><% = Title %>略名称</td>
																			<td align="center" width="100"><% = ShijyoA %></td>
																		</tr>
																		<tr>
																			<td align="center" height="31" CLASS="tx1214"><nobr><% = SyohinCD %></nobr></td>
																			<td align="center"><% = HardWrap(Shohinmei) %></nobr></td>
																			<td align="center"><nobr><%= ShohinRyakumei %></nobr></td>
																			<td align="center"><nobr><% = ShijyoB %></nobr></td>
																		</tr>
																	</table>
																</td>
																<td width="120" rowspan="2">
																	<TABLE width="122" BORDER="1" CELLPADDING="0" CELLSPACING="0" BORDERCOLOR="#000000" CLASS="tx1416" STYLE="border-collapse: collapse">
																		<tr>
																			<td align="center" height="27" bgcolor="#dddddd"><% = Title %>画像</td>
																		</tr>
																		<tr>
																			<td width="120" height="91"><% If ImageFile <> "" Then %><img src="<% = ImageFile %>" width="120" height="90" border="0"><% Else %>&nbsp;<% End If %></td>
																		</tr>
																	</table>
																</td>
															</tr>
															<tr>
																<td>
																	<TABLE WIDTH="100%" BORDER="1" CELLPADDING="2" CELLSPACING="0" BORDERCOLOR="#000000" CLASS="tx1315" STYLE="border-collapse: collapse">
																		<tr bgcolor="#dddddd">
																			<td align="center" height="27" width="16%"><% If MHMSTDSELLPRICE <> "" Then Response.Write(MHMSTDSELLPRICE) Else Response.Write("標準販売単価") End If %></td>
																		<% If ShohizeiMode = 1 Then %>
																			<td align="center" width="8%">税率</td>
																		<% End If %>
																			<td align="center" width="16%">標準仕入単価</td>
																			<td align="center" width="13%">運送料単価</td>
																			<td align="center" width="13%">倉庫料単価</td>
																			<td align="center" width="11%"><% = Title %>重量</td>
																			<td align="center" width="11%"><% = Title %>容積</td>
																			<td align="center">単位</td>
																		<% If PageType = "SeizoBu" Then %>
																			<td align="center" width="8%">ロット</td>
																		<% End If %>
																		</tr>
																		<tr>
																			<td align="right" height="31"><% = HanbaiTanka %></td>
																		<% If ShohizeiMode = 1 Then %>
																			<td align="right"><% = TaxRate %></td>
																		<% End If %>
																			<td align="right"><% = ShireTnanka %></td>
																			<td align="right"><% = UnsoTanka %></td>
																			<td align="right"><% = SokoryoTanka %></td>
																			<td align="right"><% = Jyuryo %></td>
																			<td align="right"><% = Yoseki %></td>
																			<td align="center"><% = Tani %></td>
																		<% If PageType = "SeizoBu" Then %>
																			<td align="right"><% = Lot %></td>
																		<% End If %>
																		</tr>
																	</table>
																</td>
															</tr>
															<tr>
																<td colspan="2">
																	<TABLE WIDTH="100%" BORDER="1" CELLPADDING="2" CELLSPACING="0" BORDERCOLOR="#000000" CLASS="tx1416" STYLE="border-collapse: collapse">
																		<tr>
																			<td align="center" width="60" height="27" bgcolor="#dddddd">備考</td>
																			<td align="center"><% = Bikou %></td>
																		</tr>
																	</table>
																</td>
															</tr>
														</table>
													</td>
<%
																End If

																Response.Write("</tr>")
																ii = ii + 1
															End If
															End If
															Content.MoveNext
															If RowCount <> 0 And (RowCount Mod RowBreakNum = 0) Then
																'終端判定のため次の同一市場商品が発生するまで行送りする(市場限定の場合)
																Do While Not(Content.BOF Or Content.EOF)
																	If ShijoCD = "" Or "" & Content.Fields("市場CD") = ShijoCD Or (ShijoCD = "higenteietnegih" And "" & Content.Fields("市場CD") = "") Then
																		Exit Do
																	End If
																	Content.MoveNext
																Loop
																Exit Do
															End If
														Loop

													Next

%>
						</TABLE>
						<%
							Response.Write(PrintFooter())
						%>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<%
		If (Content.BOF Or Content.EOF) Then
			Exit For
		End If
 Next
%>
</body>
</html>
<% 
End Sub
%>