<%
'<!--
'################################################
'	名称	:経費管理・労務費管理
'	作成日	:2016/1/28
'	作成者	:小野
'	目的	:
'	概要	:
'################################################
'-->
'

Function KeihiRoumuhiKanrihyo(EnshuCD, KaisyaCD, SyohinCD, SyohinKubun, Kubun, AutoFlg, PrintFlg)


	Dim RowBreakNum, RowCount
	Dim Page
	RowCount = 0
	
	If PrintFlg = 1 Then
		RowBreakNum = 30
	Else
		RowBreakNum = MaxRowBreakNum
		MaxPage = 1
	End If


	Dim Shohinmei , ShohinRyakumei		'商品名称、商品略名称
	Dim HanbaiTanka , ShireTnanka , UnsoTanka		'標準販売単価、標準仕入単価、運送費単価
	Dim SokoryoTanka , Jyuryo , Yoseki			'倉庫料単価、重量、容積
	Dim Bikou						'備考
	Dim GazoFile
	Dim Tani
	Dim Lot
	Dim ShijyoCD, SyoyuKaisyaCD

	Dim ii

	Dim Query
	Dim Content


	Dim Title
	If SyohinKubun = "Z" Then
		Title = "材料"
	Else
		Title = "商品"
	End If


	Dim Label
	Label = "経費"
	Dim LabelSep
	LabelSep = "経 費"
	If Kubun <> "K" Then
		Label = "労務費"
		LabelSep = "労 務 費"
	End If


	Dim GakuseiBango
	If Session(HomeAlias & "EnshuKubun") = "P" AND GB_JisyaFlag = "0" Then
	Else
		GakuseiBango =  GB_GakuseiNo
	End If

'演習名称GET
'	Dim EnshuName
'	EnshuName = ConvEnshuMeisyo(EnshuCD)


	If SyohinCD <> "" Then

		Query = "exec SPM" & Title & "取得 '" & GB_SystemCD & "', '" & EnshuCD & "', '" & SyohinCD & "'"

		Set Content = OpenQuery(Query)

		If Not(Content.BOF Or Content.EOF) Then
			ShijyoCD = Content.Fields("市場CD")
			Shohinmei = Content.Fields("" & Title & "名称")
			ShohinRyakumei = Content.Fields("" & Title & "略名称")
			HanbaiTanka = Content.Fields("標準販売単価")
			ShireTnanka = Content.Fields("標準仕入単価")
			UnsoTanka = Content.Fields("運送料単価")
			SokoryoTanka = Content.Fields("倉庫料単価")
			Jyuryo = Content.Fields("" & Title & "重量")
			Yoseki = Content.Fields("" & Title & "容積")
			Bikou = Content.Fields("備考")
			GazoFile = Content.Fields("画像ファイル")
			Tani = Content.Fields("単位")
			Lot = Content.Fields("ロット")
			SyoyuKaisyaCD = Content.Fields("所有会社CD")
		End If

	End If

	Dim jj,tmps


	'改ページでリセットされないよう此処で取得する
	Dim GokeiKingaku
	Query = "exec SPM経費労務費取得 '" & GB_SystemCD & "', '" & EnshuCD & "', '" & KaisyaCD & "', '" & SyohinKubun & "', '" & SyohinCD & "', '" & Kubun & "'"
	Set Content = OpenQuery(Query)
	GokeiKingaku = 0

	'存在しなければ入力フォームに飛ぶ
	If (Content.BOF Or Content.EOF) Then
		Response.Redirect("fd_keihiroumuhi.asp?PageType=SeizoBu&SyohinCD=" & SyohinCD & "&SyohinKubun=" & SyohinKubun & "&Mode=KeihiRoumuhi" & "&Kubun=" & Kubun)
	End If

	For Page = 1 To MaxPage
		If Page <> 1 Then
			Response.Write(PageBreakBefore)
		End If
%>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="5">
	<tr>
		<td align="center" style="background-image: url('images/bkimg_bsq.gif'); background-repeat: repeat-y; background-attachment: scroll; background-position: 0% 50%">
		<%
			If PrintFlg = 1 Then
				Response.Write(PrintHeader1(AutoFlg))
			End if
		%>
			<table width="601" height="388" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border:solid 1px #111111">
				<tr height="40">
					<td width="600" height="40">
						<table width="586" height="40" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td width="100%" align="right" valign="bottom">
									<table  width="100%" border="0" cellpadding="0" cellspacing="0" width="100%">
										<tr>
											<td height="3" colspan="3"><img src="/<% = HomeAlias %>/images/spacer.gif" height="1"></td>
										</tr>
										<tr>
											<td width="30" valign="bottom"></td>
											<td width="145">
												<table width="160" height="30" border="0" cellpadding="0" cellspacing="0">
													<tr>
														<td height="30" class="tx2022"><% = LabelSep %> 管 理 表</td>
													</tr>
												</table>
											</td>
											<td>
												<table width="100%" height="20" border="0" cellpadding="0" cellspacing="0">
													<tr class="tx1618">
														<td height="20" align="right"><% = Title %>名:</td>
														<td height="20" align="left"><% = Shohinmei %></td>
														<td height="20" align="right">ロット:</td>
														<td height="20" align="left"><% = Lot %><% = Tani %></td>
													</tr>
												</table>
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr height="26"> 
					<td align="center" valign="top"> 
						<table width="560" height="26" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td>
									<table width="540" height="26" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#000000">
										<tr class="tx1416">
											<td align="center">科目名</td>
											<td align="center" width="110">金額</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td height="250" align="center" valign="top">
						<table width="560" height="260" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td>
									<% If PrintFlg = 0 Then %>
									<DIV ID="Layer1" STYLE="position:relative; left:0px; top:0px; width:560px; height:277px; z-index:1; border: 1px none #000000; overflow: auto;">
									<% End If %>
									<table width="540" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#000000">
<%
										Do While Not(Content.BOF Or Content.EOF)
%>
										<tr height="25" class="tx1416"> 
											<td align="left">&nbsp;<% = Content.Fields("摘要") %>
											<td width="110" align="right"><% = SetMoney(Content.Fields("金額"), false, true) %>&nbsp;</td>
										</tr>
<%
											GokeiKingaku = GokeiKingaku + Content.Fields("金額")
											RowCount = RowCount + 1
											Content.MoveNext

											'ページ上限を超えたらDoループを抜ける
											If (RowCount Mod RowBreakNum = 0) Then
												Exit Do
											End If

										Loop

										For jj = RowCount + 1 To Max(11, Max(RowBreakNum, (Int((RowCount - 1) / RowBreakNum) + 1) * RowBreakNum) * PrintFlg)
'										For ii = RowCnt To 11 - 1
%>
										<tr height="25" class="tx1416"> 
											<td align="left">&nbsp;</td>
											<td align="right">&nbsp;</td>
										</tr>
<%
										Next

%>

									</table>
									<% If PrintFlg = 0 Then %>
									</DIV>
									<% End If %>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr> 
					<td align="center" valign="top"> 
						<table width="560" height="26" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td>
									<table width="540" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#000000">
										<tr height="26" class="tx1416"> 
											<td align="right"><% = Label %>合計&nbsp;&nbsp;</td>
											<td align="right" width="110"><% = SetMoney(GokeiKingaku, false, true) %>&nbsp;</td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td height="14"><img src="/<% = HomeAlias %>/images/spacer.gif" height="1"></td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		<%
			If PrintFlg > 0 Then
				Response.Write(PrintFooter())
			End if
		%>
		</td>
	</tr>
</table>
<%
		If (Content.BOF Or Content.EOF) Then
			Exit For
		End If
	Next
%>


<%
End Function
%>