1939 lines
137 KiB
Plaintext
1939 lines
137 KiB
Plaintext
<!-- #include virtual = "lib/config.asp" -->
|
|
<!-- #include file = "../include/top_menu.asp" -->
|
|
<%''#####################################################
|
|
'''클라이언트별매출통계 - 클라이언트별 매출액 관리
|
|
|
|
''#####################################################
|
|
%>
|
|
<%
|
|
command = request("command")
|
|
tmp_year = request("tmp_year")
|
|
|
|
if command = "" then
|
|
command = "view"
|
|
end if
|
|
if tmp_year = "" then
|
|
tmp_year = year(date)
|
|
end if
|
|
if tmp_month = "" then
|
|
tmp_month = 0
|
|
end if
|
|
|
|
Dim arr_hd_sum()
|
|
%>
|
|
<!-- #include file = "../statistics/inc_team_project.asp" -->
|
|
<%
|
|
web_position = "통계 : 프로젝트 조사방법별 내역"
|
|
|
|
call Time_Check(Session("Login_Check"))
|
|
%>
|
|
<form name='team_project_count' method='post' >
|
|
|
|
|
|
<td width="100%" valign="top">
|
|
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
|
<%if command <> "excel" then%>
|
|
<tr>
|
|
<!-- 확인 -->
|
|
</tr>
|
|
<%end if%>
|
|
<tr>
|
|
<td colspan="2" style="padding:20;">
|
|
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
|
<tr>
|
|
<td>
|
|
|
|
<font class="brown">팀별 프로젝트 실적 집계 화면입니다. </font>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="padding:5 0 0 0;">
|
|
<table width="100%" height="37" cellpadding="0" cellspacing="1" border="0" bgcolor="#c0c0c0">
|
|
<tr>
|
|
<td bgcolor="#DFDFDF" style="padding:0 10 0 10">
|
|
등록년도
|
|
<%
|
|
Dim temp_minus_yyyy
|
|
temp_minus_yyyy = 0
|
|
%>
|
|
<select name=tmp_year>
|
|
<%for i=cint(year(date)+temp_minus_yyyy) to 2014 step -1 %>
|
|
<OPTION value='<%=i%>' <%if cint(i) = cint(tmp_year) then%> selected <%end if%>><%=i%></OPTION>
|
|
<%next%>
|
|
</SELECT>
|
|
<img src="/images/common/btn_smallsrch.gif" align="absmiddle" onclick="goView('view');" style="cursor:pointer">
|
|
<img src="/images/common/btn_smallexcel.gif" align="absmiddle" onclick="goView('excel');" style='display:none;CURSOR:pointer;'>
|
|
|
|
<input type="button" name="" value="팀별 실적 페이지 이동" onclick="javascript:pageMove('view');"/>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
<!-------------------1. 계약 실적 시작------------------------------------------------------------------------------------------------------------------------------------------------------>
|
|
<tr><td style="padding:15 0 0 0"><font class="brown" size="3">1. 계약실적</font></td></tr>
|
|
<tr>
|
|
<td style="padding:5 0 0 0">
|
|
|
|
<table width="100%" cellpadding="3" cellspacing="0" border="0" style="border-collapse:collapse;">
|
|
<tr>
|
|
<td width="13%" align="center" >부서</td>
|
|
<td width="13%" align="right" >수주실적</td>
|
|
<td width="13%" align="right" >수행실적</td>
|
|
<td width="13%" align="right" >예상직접비</td>
|
|
<td width="13%" align="right" >예상공헌이익</td>
|
|
<td width="13%" align="center" >비고</td>
|
|
</tr>
|
|
</table>
|
|
<% '1. 계약실적 쿼리문
|
|
query = ""
|
|
query = query & " SELECT team_name, team_cd, "&VbCrlf
|
|
query = query & " SUM(p_total_cost) as p_total_cost, "&VbCrlf
|
|
query = query & " SUM(p_cont_cost) as p_cont_cost, SUM(est_money) as est_money, "&VbCrlf
|
|
query = query & " SUM(act_money) as act_money, SUM(cost_money) as cost_money, "&VbCrlf
|
|
query = query & " SUM(entertain_money) as entertain_money, SUM(tf_money) as tf_money, "&VbCrlf
|
|
query = query & " SUM(benefit) as benefit "&VbCrlf
|
|
query = query & " FROM "&VbCrlf
|
|
query = query & " ( "&VbCrlf
|
|
query = query & " SELECT team_name, team_cd, p_sn, "&VbCrlf'p_total_cost, "
|
|
query = query & " case when LEFT(p_sn, 2) = '" &RIGHT(tmp_year, 2)-1& "' Then "&VbCrlf
|
|
query = query & " case when p_total_cost='0' Then SUM(p_cont_cost) else p_total_cost end "&VbCrlf
|
|
query = query & " else p_total_cost end as p_total_cost, "&VbCrlf '##### 이월 프로젝트의 수주실적 총 합계 -> 0원이면 수주실적 = 수행실적(2018-10-24)
|
|
query = query & " SUM(p_cont_cost) as p_cont_cost, SUM(est_money) as est_money, "&VbCrlf
|
|
query = query & " SUM(act_money) as act_money, SUM(cost_money) as cost_money, "&VbCrlf
|
|
query = query & " SUM(entertain_money) as entertain_money, SUM(tf_money) as tf_money, "&VbCrlf
|
|
query = query & " SUM(benefit) as benefit "&VbCrlf
|
|
query = query & " FROM #statistics "&VbCrlf
|
|
query = query & " WHERE (LEFT(p_sn, 2) = '" & RIGHT(tmp_year, 2) & "' OR (LEFT(p_sn, 2) = '" & RIGHT(tmp_year, 2) - 1 & "' AND p_statistics = '" & tmp_year & "')) "&VbCrlf
|
|
query = query & " GROUP BY team_name, team_cd, p_sn, p_total_cost "&VbCrlf
|
|
query = query & " ) T "&VbCrlf
|
|
query = query & " where 1=1 "&VbCrlf
|
|
query = query & " GROUP BY team_name, team_cd "&VbCrlf
|
|
query = query & " ORDER BY team_name "&VbCrlf
|
|
|
|
'Response.Write query & "<br>"
|
|
|
|
adors.Open query, adoconn, adOpenStatic, adLockReadOnly
|
|
|
|
if adors.RecordCount > 0 then
|
|
%>
|
|
<table width="100%" cellpadding="3" cellspacing="0" border="0" style="border-collapse:collapse;">
|
|
<%
|
|
sum_total_cost = 0
|
|
sum_cont_cost = 0
|
|
sum_est_money = 0
|
|
sum_benefit = 0
|
|
For i = 1 To adors.RecordCount
|
|
If i mod 2 Then
|
|
list_bgcolor="#dbe9f2"
|
|
Else
|
|
list_bgcolor="#FFFFFF"
|
|
End If
|
|
%>
|
|
<tr bgcolor="<%=list_bgcolor%>">
|
|
<td width="13%" class="tahoma" align="center"><a href="javascript:detailView('<%=adors("team_cd")%>')"><%=adors("team_name")%></a></td>
|
|
<td width="13%" class="tahoma" align="right"><%=formatnumber(adors("p_total_cost"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right"><%=formatnumber(adors("p_cont_cost"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right"><%=formatnumber(adors("est_money"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right"><%=formatnumber(adors("benefit"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right"></td>
|
|
</tr>
|
|
<%
|
|
sum_total_cost = sum_total_cost + cdbl(adors("p_total_cost"))
|
|
sum_cont_cost = sum_cont_cost + cdbl(adors("p_cont_cost"))
|
|
sum_est_money = sum_est_money + cdbl(adors("est_money"))
|
|
sum_benefit = sum_benefit + cdbl(adors("benefit"))
|
|
|
|
adors.MoveNext
|
|
Next
|
|
query = ""
|
|
query = query & " SELECT hd_name, hd_cd, "
|
|
query = query & " SUM(p_total_cost) as p_total_cost, "
|
|
query = query & " SUM(p_cont_cost) as p_cont_cost, SUM(est_money) as est_money, "
|
|
query = query & " SUM(act_money) as act_money, SUM(cost_money) as cost_money, "
|
|
query = query & " SUM(entertain_money) as entertain_money, SUM(tf_money) as tf_money, "
|
|
query = query & " SUM(benefit) as benefit "
|
|
query = query & " FROM "
|
|
query = query & " ( "
|
|
query = query & " SELECT hd_name, hd_cd, p_sn, "&VbCrlf'p_total_cost, "
|
|
query = query & " case when LEFT(p_sn, 2) = '" &RIGHT(tmp_year, 2)-1& "' Then "&VbCrlf
|
|
query = query & " case when p_total_cost='0' Then SUM(p_cont_cost) else p_total_cost end "&VbCrlf
|
|
query = query & " else p_total_cost end as p_total_cost, "&VbCrlf '##### 이월 프로젝트의 수주실적 총 합계 -> 0원이면 수주실적 = 수행실적(2018-10-24)
|
|
query = query & " SUM(p_cont_cost) as p_cont_cost, SUM(est_money) as est_money, "
|
|
query = query & " SUM(act_money) as act_money, SUM(cost_money) as cost_money, "
|
|
query = query & " SUM(entertain_money) as entertain_money, SUM(tf_money) as tf_money, "
|
|
query = query & " SUM(benefit) as benefit "
|
|
query = query & " FROM #statistics "
|
|
query = query & " WHERE (LEFT(p_sn, 2) = '" & RIGHT(tmp_year, 2) & "' OR (LEFT(p_sn, 2) = '" & RIGHT(tmp_year, 2) - 1 & "' AND p_statistics = '" & tmp_year & "')) "&VbCrlf
|
|
query = query & " GROUP BY hd_name, hd_cd, p_sn, p_total_cost "
|
|
query = query & " ) T "
|
|
query = query & " GROUP BY hd_name, hd_cd "
|
|
query = query & " ORDER BY hd_cd "
|
|
rsc.Open query, adoconn, adOpenStatic, adLockReadOnly
|
|
%>
|
|
<!--
|
|
<tr style="border-top:1px solid gray;height:1px;font-size:1px;">
|
|
<td colspan="6"></td>
|
|
</tr>
|
|
<%
|
|
Do While Not rsc.Eof
|
|
%>
|
|
<tr bgcolor="#FBEFFB">
|
|
<td width="13%" class="tahoma" align="center" style="font-weight:bold;"><%=rsc("hd_name")%></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(rsc("p_total_cost"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(rsc("p_cont_cost"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(rsc("est_money"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(rsc("benefit"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"></td>
|
|
</tr>
|
|
<%
|
|
rsc.MoveNext
|
|
Loop
|
|
rsc.Close
|
|
%>
|
|
-->
|
|
<tr bgcolor="#F7F2E0" style="border-top:1px solid gray;">
|
|
<td width="13%" class="tahoma" align="center" style="font-weight:bold;">합 계</td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(sum_total_cost,0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(sum_cont_cost,0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(sum_est_money,0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(sum_benefit,0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"></td>
|
|
</tr>
|
|
</table>
|
|
<%
|
|
end if' if adors.RecordCount > 0 then
|
|
adors.Close
|
|
%>
|
|
</td>
|
|
</tr>
|
|
<!-------------------1. 계약 실적 종료------------------------------------------------------------------------------------------------------------------------------------------------------>
|
|
<!-------------------2. 진행 실적 시작------------------------------------------------------------------------------------------------------------------------------------------------------>
|
|
<tr><td style="padding:15 0 0 0"><font class="brown" size="3">2. 진행 프로젝트</font></td></tr>
|
|
<tr>
|
|
<td style="padding:5 0 0 0">
|
|
<table width="100%" cellpadding="3" cellspacing="0" border="0" style="border-collapse:collapse;">
|
|
<tr>
|
|
<td width="13%" align="center" >부서</td>
|
|
<td width="13%" align="right" >수행실적</td>
|
|
<td width="13%" align="right" >예상직접비</td>
|
|
<td width="13%" align="right" >실제직접비+진행비</td>
|
|
<td width="13%" align="right" >예상공헌이익</td>
|
|
<td width="13%" align="center" >비고</td>
|
|
</tr>
|
|
</table>
|
|
<% '2. 진행실적 쿼리문
|
|
query = ""
|
|
query = query & " SELECT team_name, team_cd, "
|
|
query = query & " SUM(p_total_cost) as p_total_cost, "
|
|
query = query & " SUM(p_cont_cost) as p_cont_cost, SUM(est_money) as est_money, "
|
|
query = query & " SUM(act_money) as act_money, SUM(cost_money) as cost_money, "
|
|
query = query & " SUM(entertain_money) as entertain_money, SUM(tf_money) as tf_money, "
|
|
query = query & " SUM(benefit) as benefit "
|
|
query = query & " FROM "
|
|
query = query & " ( "
|
|
query = query & " SELECT team_name, team_cd, p_sn, p_total_cost, "
|
|
query = query & " SUM(p_cont_cost) as p_cont_cost, SUM(est_money) as est_money, "
|
|
query = query & " SUM(act_money) as act_money, SUM(cost_money) as cost_money, "
|
|
query = query & " SUM(entertain_money) as entertain_money, SUM(tf_money) as tf_money, "
|
|
query = query & " SUM(benefit) as benefit "
|
|
query = query & " FROM #statistics "
|
|
query = query & " WHERE (LEFT(p_sn, 2) = '" & RIGHT(tmp_year, 2) & "' OR (LEFT(p_sn, 2) = '" & RIGHT(tmp_year, 2) - 1 & "' AND p_statistics = '" & tmp_year & "')) "&VbCrlf
|
|
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 진행 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
query = query & " AND p_progress_status = '008' AND complete_yn = '0' "
|
|
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ↑↑ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
query = query & " GROUP BY team_name, team_cd, p_sn, p_total_cost "
|
|
query = query & " ) T "
|
|
query = query & " where 1=1 "&VbCrlf
|
|
query = query & " GROUP BY team_name, team_cd "
|
|
query = query & " ORDER BY team_name "
|
|
|
|
'Response.Write query & "<br>"
|
|
If tmp_year <> "0000" then
|
|
adors.Open query, adoconn,adOpenStatic,adLockReadOnly
|
|
|
|
if adors.RecordCount > 0 then
|
|
%>
|
|
<table width="100%" cellpadding="3" cellspacing="0" border="0" style="border-collapse:collapse;">
|
|
<!-- loop start -->
|
|
<%
|
|
sum_cont_cost = 0
|
|
sum_est_money = 0
|
|
sum_act_money = 0
|
|
sum_benefit = 0
|
|
For i = 1 To adors.RecordCount
|
|
If i mod 2 Then
|
|
list_bgcolor="#dbe9f2"
|
|
Else
|
|
list_bgcolor="#FFFFFF"
|
|
End If
|
|
%>
|
|
<tr bgcolor="<%=list_bgcolor%>">
|
|
<td width="13%" class="tahoma" align="center"><a href="javascript:detailView('<%=adors("team_cd")%>')"><%=adors("team_name")%></a></td>
|
|
<td width="13%" class="tahoma" align="right"><%=formatnumber(adors("p_cont_cost"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right"><%=formatnumber(adors("est_money"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right"><%=formatnumber(cdbl(adors("act_money")) + cdbl(adors("cost_money")) + cdbl(adors("entertain_money")) + cdbl(adors("tf_money")),0) %></td>
|
|
<td width="13%" class="tahoma" align="right"><%=formatnumber(adors("benefit"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right"></td>
|
|
</tr>
|
|
<%
|
|
sum_cont_cost = sum_cont_cost + cdbl(adors("p_cont_cost"))
|
|
sum_est_money = sum_est_money + cdbl(adors("est_money"))
|
|
sum_act_money = sum_act_money + cdbl(adors("act_money")) + cdbl(adors("cost_money")) + cdbl(adors("entertain_money")) + cdbl(adors("tf_money"))
|
|
sum_benefit = sum_benefit + cdbl(adors("benefit"))
|
|
|
|
adors.movenext
|
|
next
|
|
|
|
query = ""
|
|
query = query & " SELECT hd_name, hd_cd, "
|
|
query = query & " SUM(p_total_cost) as p_total_cost, "
|
|
query = query & " SUM(p_cont_cost) as p_cont_cost, SUM(est_money) as est_money, "
|
|
query = query & " SUM(act_money) as act_money, SUM(cost_money) as cost_money, "
|
|
query = query & " SUM(entertain_money) as entertain_money, SUM(tf_money) as tf_money, "
|
|
query = query & " SUM(benefit) as benefit "
|
|
query = query & " FROM "
|
|
query = query & " ( "
|
|
query = query & " SELECT hd_name, hd_cd, p_sn, p_total_cost, "
|
|
query = query & " SUM(p_cont_cost) as p_cont_cost, SUM(est_money) as est_money, "
|
|
query = query & " SUM(act_money) as act_money, SUM(cost_money) as cost_money, "
|
|
query = query & " SUM(entertain_money) as entertain_money, SUM(tf_money) as tf_money, "
|
|
query = query & " SUM(benefit) as benefit "
|
|
query = query & " FROM #statistics "
|
|
query = query & " WHERE (LEFT(p_sn, 2) = '" & RIGHT(tmp_year, 2) & "' OR p_statistics = '" & tmp_year & "') "
|
|
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 진행 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
query = query & " AND p_progress_status = '008' AND complete_yn = '0' "
|
|
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ↑↑ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
query = query & " GROUP BY hd_name, hd_cd, p_sn, p_total_cost "
|
|
query = query & " ) T "
|
|
query = query & " GROUP BY hd_name, hd_cd "
|
|
query = query & " ORDER BY hd_cd "
|
|
rsc.Open query, adoconn, adOpenStatic, adLockReadOnly
|
|
%>
|
|
<!--
|
|
<tr style="border-top:1px solid gray;height:1px;font-size:1px;">
|
|
<td colspan="6"></td>
|
|
</tr>
|
|
<%
|
|
Do While Not rsc.Eof
|
|
%>
|
|
<tr bgcolor="#FBEFFB">
|
|
<td width="13%" class="tahoma" align="center" style="font-weight:bold;"><%=rsc("hd_name")%></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(rsc("p_cont_cost"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(rsc("est_money"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(cdbl(rsc("act_money")) + cdbl(rsc("cost_money")) + cdbl(rsc("entertain_money")) + cdbl(rsc("tf_money")),0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(rsc("benefit"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"></td>
|
|
</tr>
|
|
<%
|
|
rsc.MoveNext
|
|
Loop
|
|
rsc.Close
|
|
%>
|
|
-->
|
|
<tr bgcolor="#F7F2E0" style="border-top:1px solid gray;">
|
|
<td width="13%" class="tahoma" align="center" style="font-weight:bold;">합 계</td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(sum_cont_cost,0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(sum_est_money,0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(sum_act_money,0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(sum_benefit,0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"></td>
|
|
</tr>
|
|
</table>
|
|
<%
|
|
end if' if adors.RecordCount > 0 then
|
|
adors.Close
|
|
End if
|
|
%>
|
|
</td>
|
|
</tr>
|
|
<!-------------------2. 진행 실적 종료------------------------------------------------------------------------------------------------------------------------------------------------------>
|
|
<!-------------------3. 종료 실적 시작------------------------------------------------------------------------------------------------------------------------------------------------------>
|
|
<tr><td style="padding:15 0 0 0"><font class="brown" size="3">3. 수행 종료 실적</font></td></tr>
|
|
<tr>
|
|
<td style="padding:5 0 0 0">
|
|
<table width="100%" cellpadding="3" cellspacing="0" border="0" style="border-collapse:collapse;">
|
|
<tr>
|
|
<td width="13%" align="center" >부서</td>
|
|
<td width="13%" align="right" >수행실적</td>
|
|
<td width="13%" align="right" >예상직접비</td>
|
|
<td width="13%" align="right" >실제직접비+진행비</td>
|
|
<td width="13%" align="right" >공헌이익</td>
|
|
<td width="13%" align="center" >비고</td>
|
|
</tr>
|
|
</table>
|
|
<% '3. 종료 실적 쿼리문
|
|
query = ""
|
|
query = query & " SELECT team_name, team_cd, "
|
|
query = query & " SUM(p_total_cost) as p_total_cost, "
|
|
query = query & " SUM(p_cont_cost) as p_cont_cost, SUM(est_money) as est_money, "
|
|
query = query & " SUM(act_money) as act_money, SUM(cost_money) as cost_money, "
|
|
query = query & " SUM(entertain_money) as entertain_money, SUM(tf_money) as tf_money, "
|
|
query = query & " SUM(benefit) as benefit "
|
|
query = query & " FROM "
|
|
query = query & " ( "
|
|
query = query & " SELECT LEFT(p_con_date_end, 7) as p_con_date_end, team_name, team_cd, p_sn, p_total_cost, "
|
|
query = query & " SUM(p_cont_cost) as p_cont_cost, SUM(est_money) as est_money, "
|
|
query = query & " SUM(act_money) as act_money, SUM(cost_money) as cost_money, "
|
|
query = query & " SUM(entertain_money) as entertain_money, SUM(tf_money) as tf_money, "
|
|
query = query & " SUM(benefit) as benefit "
|
|
query = query & " FROM #statistics "
|
|
query = query & " WHERE p_statistics = '" & tmp_year & "' "
|
|
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 종료 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
query = query & " AND complete_yn = '1' "
|
|
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ↑↑ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
|
|
query = query & " GROUP BY LEFT(p_con_date_end, 7), team_name, team_cd, p_sn, p_total_cost "
|
|
query = query & " ) T "
|
|
query = query & " where 1=1 "&VbCrlf
|
|
query = query & " GROUP BY team_name, team_cd "
|
|
query = query & " ORDER BY team_name "
|
|
'Response.Write query & "<br>"
|
|
If tmp_year <> "0000" then
|
|
adors.Open query, adoconn,adOpenStatic,adLockReadOnly
|
|
|
|
if adors.RecordCount > 0 then
|
|
%>
|
|
<table width="100%" cellpadding="3" cellspacing="0" border="0" style="border-collapse:collapse;">
|
|
<!-- loop start -->
|
|
<%
|
|
sum_cont_cost = 0
|
|
sum_est_money = 0
|
|
sum_act_money = 0
|
|
sum_benefit = 0
|
|
For i = 1 To adors.RecordCount
|
|
If i mod 2 Then
|
|
list_bgcolor="#dbe9f2"
|
|
Else
|
|
list_bgcolor="#FFFFFF"
|
|
End If
|
|
%>
|
|
<tr bgcolor="<%=list_bgcolor%>">
|
|
<td width="13%" class="tahoma" align="center"><a href="javascript:detailView('<%=adors("team_cd")%>')"><%=adors("team_name")%></a></td>
|
|
<td width="13%" class="tahoma" align="right"><%=formatnumber(adors("p_cont_cost"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right"><%=formatnumber(adors("est_money"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right"><%=formatnumber(cdbl(adors("act_money")) + cdbl(adors("cost_money")) + cdbl(adors("entertain_money")) + cdbl(adors("tf_money")),0) %></td>
|
|
<td width="13%" class="tahoma" align="right"><%=formatnumber(adors("benefit"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right"></td>
|
|
</tr>
|
|
<%
|
|
sum_cont_cost = sum_cont_cost + cdbl(adors("p_cont_cost"))
|
|
sum_est_money = sum_est_money + cdbl(adors("est_money"))
|
|
sum_act_money = sum_act_money + cdbl(adors("act_money")) + cdbl(adors("cost_money")) + cdbl(adors("entertain_money")) + cdbl(adors("tf_money"))
|
|
sum_benefit = sum_benefit + cdbl(adors("benefit"))
|
|
|
|
adors.movenext
|
|
next
|
|
query = ""
|
|
query = query & " SELECT hd_name, hd_cd, "
|
|
query = query & " SUM(p_total_cost) as p_total_cost, "
|
|
query = query & " SUM(p_cont_cost) as p_cont_cost, SUM(est_money) as est_money, "
|
|
query = query & " SUM(act_money) as act_money, SUM(cost_money) as cost_money, "
|
|
query = query & " SUM(entertain_money) as entertain_money, SUM(tf_money) as tf_money, "
|
|
query = query & " SUM(benefit) as benefit "
|
|
query = query & " FROM "
|
|
query = query & " ( "
|
|
query = query & " SELECT LEFT(p_con_date_end, 7) as p_con_date_end, hd_name, hd_cd, p_sn, p_total_cost, "
|
|
query = query & " SUM(p_cont_cost) as p_cont_cost, SUM(est_money) as est_money, "
|
|
query = query & " SUM(act_money) as act_money, SUM(cost_money) as cost_money, "
|
|
query = query & " SUM(entertain_money) as entertain_money, SUM(tf_money) as tf_money, "
|
|
query = query & " SUM(benefit) as benefit "
|
|
query = query & " FROM #statistics "
|
|
query = query & " WHERE p_statistics = '" & tmp_year & "' "
|
|
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 종료 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
query = query & " AND complete_yn = '1' "
|
|
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ↑↑ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
|
|
query = query & " GROUP BY LEFT(p_con_date_end, 7), hd_name, hd_cd, p_sn, p_total_cost "
|
|
query = query & " ) T "
|
|
query = query & " GROUP BY hd_name, hd_cd "
|
|
query = query & " ORDER BY hd_cd "
|
|
rsc.Open query, adoconn, adOpenStatic, adLockReadOnly
|
|
%>
|
|
<!--
|
|
<tr style="border-top:1px solid gray;height:1px;font-size:1px;">
|
|
<td colspan="6"></td>
|
|
</tr>
|
|
<%
|
|
Do While Not rsc.Eof
|
|
%>
|
|
<tr bgcolor="#FBEFFB">
|
|
<td width="13%" class="tahoma" align="center" style="font-weight:bold;"><%=rsc("hd_name")%></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(rsc("p_cont_cost"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(rsc("est_money"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(cdbl(rsc("act_money")) + cdbl(rsc("cost_money")) + cdbl(rsc("entertain_money")) + cdbl(rsc("tf_money")),0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(rsc("benefit"),0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"></td>
|
|
</tr>
|
|
<%
|
|
rsc.MoveNext
|
|
Loop
|
|
rsc.Close
|
|
%>
|
|
-->
|
|
<tr bgcolor="#F7F2E0" style="border-top:1px solid gray;">
|
|
<td width="13%" class="tahoma" align="center" style="font-weight:bold;">합 계</td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(sum_cont_cost,0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(sum_est_money,0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(sum_act_money,0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"><%=formatnumber(sum_benefit,0) %></td>
|
|
<td width="13%" class="tahoma" align="right" style="font-weight:bold;"></td>
|
|
</tr>
|
|
</table>
|
|
<%end if' if adors.RecordCount > 0 then
|
|
adors.Close
|
|
End if
|
|
%>
|
|
|
|
</td>
|
|
</tr>
|
|
<!-------------------3. 종료 실적 종료------------------------------------------------------------------------------------------------------------------------------------------------------>
|
|
<!-------------------4. 부서 공통경비내역 시작------------------------------------------------------------------------------------------------------------------------------------------------------>
|
|
<tr><td style="padding:15 0 0 0"><font class="brown" size="3">4. 부서별 프로젝트 진행비 세부 내역</font></td></tr>
|
|
<tr>
|
|
<td style="padding:5 0 0 0">
|
|
|
|
<table width="100%" cellpadding="3" cellspacing="0" border="0" style="border-collapse:collapse;">
|
|
|
|
<tr>
|
|
<td width="10%" align="center" >부서</td>
|
|
<td width="10%" align="right" >식대</td>
|
|
<td width="10%" align="right" >일반교통비</td>
|
|
<td width="10%" align="right" >시외출장교통비</td>
|
|
<td width="10%" align="right" >택배비</td>
|
|
<td width="10%" align="right" >인쇄비</td>
|
|
<td width="10%" align="right" >우편발송비</td>
|
|
<td width="10%" align="right" >접대비보고서</td>
|
|
<td width="10%" align="right" >총선기타비</td>
|
|
<td width="10%" align="right" >합계</td>
|
|
</tr>
|
|
</table>
|
|
<% '4. 부서 공통경비내역 쿼리문
|
|
query = " select TT.depart, (select T_name from V_Department as d where TT.depart = d.before_t_cd1) as 부서, SUM(식대) as 식대, SUM(일반교통비) as 일반교통비, SUM(시외출장교통비) as 시외출장교통비 "
|
|
query = query & " , SUM(택배비) as 택배비, SUM(인쇄비) as 인쇄비, SUM(우편발송비) as 우편발송비, SUM(총선기타비) as 총선기타비, SUM(접대비보고서) as 접대비보고서, SUM(행합계) as 행합계 "
|
|
query = query & " from ( "
|
|
query = query & " select isnull(vp.p_depart_dep, d_code) as depart, '20'+left(T.p_sn,2)+'-'+SUBSTRING(T.p_sn,3,2) as 날짜, "
|
|
query = query & " SUM(일반교통비) as 일반교통비, SUM(식대) as 식대, SUM(시외출장교통비) as 시외출장교통비, "
|
|
query = query & " SUM(택배비) as 택배비, SUM(인쇄비) as 인쇄비, SUM(우편발송비) as 우편발송비, "
|
|
query = query & " SUM(총선기타비) as 총선기타비, SUM(접대비보고서) as 접대비보고서, "
|
|
query = query & " SUM(일반교통비)+SUM(식대)+SUM(시외출장교통비)+SUM(택배비)+SUM(인쇄비)+SUM(우편발송비)+SUM(총선기타비)+SUM(접대비보고서) as 행합계 "
|
|
query = query & " from "
|
|
query = query & " ( "
|
|
query = query & " select a.d_code, job_date, p_sn, "
|
|
query = query & " sum(case when cost_code IN ('9','10','19','21','28','99') then cost_money else 0 end ) as '식대', "
|
|
query = query & " sum(case when cost_code IN ('7','11','17','18','20','23','24') then cost_money else 0 end ) as '일반교통비', "
|
|
query = query & " sum(case when cost_code IN ('12','13','14','15','16','29') then cost_money else 0 end ) as '시외출장교통비', "
|
|
query = query & " sum(case when cost_code IN ('8','90') then cost_money else 0 end ) as '택배비', "
|
|
query = query & " sum(case when cost_code = '6' then cost_money else 0 end ) as '인쇄비', "
|
|
query = query & " sum(case when cost_code = '5' then cost_money else 0 end ) as '우편발송비', "
|
|
query = query & " 0 as 총선기타비, '0' as 접대비보고서 "
|
|
query = query & " from ( "
|
|
query = query & " select vpm.p_rsch_dept as d_code, BC.p_sn, left(job_date,7) as job_date, cost_code, sum(cost_money) as cost_money "
|
|
query = query & " from V_BUSI_COST BC left outer join V_Person P on BC.p_no = P.p_no "
|
|
query = query & " left outer join V_PROJECT_METHOD VPM on BC.p_sn = VPM.p_child_sn "
|
|
query = query & " WHERE VPM.p_statistics = '" & tmp_year & "' "
|
|
query = query & " and LEN(BC.p_sn) > 6 "
|
|
query = query & " and cost_money > 0 "
|
|
query = query & " and BC.p_sn not like '%9999%' "
|
|
query = query & " group by vpm.p_rsch_dept, BC.p_sn, cost_code, left(job_date,7) "
|
|
query = query & " ) as a "
|
|
query = query & " group by job_date, a.d_code, p_sn "
|
|
query = query & " "
|
|
query = query & " union all "
|
|
query = query & " "
|
|
query = query & " select vp.p_depart_dep as p_depart, left(convert(varchar(20),target3),7) as date, a.p_sn, "
|
|
query = query & " '0' as 일반교통비, '0' as 식대, '0' as 시외출장교통비, '0' as 택배비, '0' as 인쇄비, '0' as 우편발송비, "
|
|
query = query & " 0 as 총선기타비, sum(convert(numeric(18,2), replace(convert(varchar(15), target6), ',', ''))) as 접대비보고서 "
|
|
query = query & " from 문서내용 as a left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " left outer join V_PROJECT_METHOD as vpm on a.p_sn = vpm.p_child_sn "
|
|
query = query & " left outer join V_PROJECT as vp on left(a.p_sn,7) = vp.p_sn "
|
|
query = query & " left outer join document d on a.문서번호 = d.d_no "
|
|
query = query & " where 문서제목 in ('접대비보고서') "
|
|
query = query & " and vpm.p_statistics = '" & tmp_year & "' "
|
|
query = query & " and LEN(a.p_sn) > 6 "
|
|
query = query & " and not (a.p_sn = '99999' OR a.p_sn like '9999___') "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " and d_order_cnt = '77' "
|
|
query = query & " group by 문서제목, vp.p_depart_dep, a.p_sn, left(convert(varchar(20),target3),7) "
|
|
query = query & " ) T left outer join V_PROJECT VP on replace(T.p_sn,',','') = vp.p_sn "
|
|
query = query & " where replace(T.p_sn,',','') not in ('','0','9999','99999','9999003','9999004','9999005','9999012','9999017','9999018') "
|
|
query = query & " and (isnull(vp.p_depart_dep, d_code) between 20 and 90 or isnull(vp.p_depart_dep, d_code) = 90) "
|
|
query = query & " and (LEFT(T.p_sn,2) = '"& right(tmp_year,2) &"' or LEFT(T.p_sn,2) = '"& right(tmp_year,2)-1 &"') "
|
|
query = query & " group by isnull(vp.p_depart_dep, d_code), '20'+left(T.p_sn,2)+'-'+SUBSTRING(T.p_sn,3,2) "
|
|
query = query & " ) TT "
|
|
query = query & " where 1=1 "
|
|
query = query & " group by TT.depart "
|
|
query = query & " order by 부서 "
|
|
|
|
|
|
|
|
'Response.Write query & "<br>"
|
|
|
|
adors.Open query, adoconn,adOpenStatic,adLockReadOnly
|
|
|
|
dim sum_meal
|
|
dim sum_nomal_traffic
|
|
dim sum_outside_traffic
|
|
dim sum_delivery
|
|
dim sum_print
|
|
dim sum_post
|
|
dim sum_expence
|
|
dim sum_entertain
|
|
dim sum_all
|
|
dim sum_etc
|
|
|
|
sum_meal = 0
|
|
sum_nomal_traffic = 0
|
|
sum_outside_traffic = 0
|
|
sum_delivery = 0
|
|
sum_print = 0
|
|
sum_post = 0
|
|
sum_expence = 0
|
|
sum_entertain = 0
|
|
sum_etc = 0
|
|
sum_all = 0
|
|
|
|
if adors.RecordCount > 0 then
|
|
%>
|
|
<table width="100%" cellpadding="3" cellspacing="0" border="0" style="border-collapse:collapse;<% if command <> "view" then %>display:none<% end if%>">
|
|
<!-- loop start -->
|
|
<%
|
|
rowindex = 0
|
|
reDim arr_hd_sum(5, 15)
|
|
|
|
for i=1 To 5
|
|
for j=1 To 15
|
|
arr_hd_sum(i, j) = 0
|
|
next
|
|
Next
|
|
|
|
for i=1 to adors.RecordCount
|
|
rowIndex = rowIndex + 1
|
|
IF rowIndex mod 2 Then
|
|
list_bgcolor="#dbe9f2"
|
|
Else
|
|
list_bgcolor="#FFFFFF"
|
|
End If %>
|
|
<tr bgcolor="<%=list_bgcolor%>">
|
|
<td width="10%" align="center" class="tahoma"><%=adors("부서")%></td>
|
|
<td width="10%" class="tahoma" align="right"><%=formatNumber(adors("식대") ,0) %></td>
|
|
<td width="10%" class="tahoma" align="right"><%=formatNumber(adors("일반교통비") ,0) %></td>
|
|
<td width="10%" class="tahoma" align="right"><%=formatNumber(adors("시외출장교통비") ,0) %></td>
|
|
<td width="10%" class="tahoma" align="right"><%=formatNumber(adors("택배비") ,0) %></td>
|
|
<td width="10%" class="tahoma" align="right"><%=formatNumber(adors("인쇄비") ,0) %></td>
|
|
<td width="10%" class="tahoma" align="right"><%=formatNumber(adors("우편발송비") ,0) %></td>
|
|
<td width="10%" class="tahoma" align="right"><%=formatNumber(adors("접대비보고서") ,0) %></td>
|
|
<td width="10%" class="tahoma" align="right"><%=formatNumber(adors("총선기타비") ,0) %></td>
|
|
<td width="10%" class="tahoma" align="right"><%=formatNumber(adors("행합계") ,0) %></td>
|
|
</tr>
|
|
<%
|
|
sum_meal = sum_meal + adors("식대")
|
|
sum_nomal_traffic = sum_nomal_traffic + adors("일반교통비")
|
|
sum_outside_traffic = sum_outside_traffic + adors("시외출장교통비")
|
|
sum_delivery = sum_delivery + adors("택배비")
|
|
sum_print = sum_print + adors("인쇄비")
|
|
sum_post = sum_post + adors("우편발송비")
|
|
sum_entertain = sum_entertain + CDbl(adors("접대비보고서"))
|
|
sum_etc = sum_etc + CDbl(adors("총선기타비"))
|
|
sum_all = sum_all + CDbl(adors("행합계"))
|
|
|
|
hd_str = split(Hd_chk(adors("depart")), "_")
|
|
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 0) = hd_str(1)
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 1) = arr_hd_sum(cint(right(hd_str(0), 1)), 1) + cDbl(adors("식대"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 2) = arr_hd_sum(cint(right(hd_str(0), 1)), 2) + cDbl(adors("일반교통비"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 3) = arr_hd_sum(cint(right(hd_str(0), 1)), 3) + cDbl(adors("시외출장교통비"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 4) = arr_hd_sum(cint(right(hd_str(0), 1)), 4) + cDbl(adors("택배비"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 5) = arr_hd_sum(cint(right(hd_str(0), 1)), 5) + cDbl(adors("인쇄비"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 6) = arr_hd_sum(cint(right(hd_str(0), 1)), 6) + cDbl(adors("우편발송비"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 7) = arr_hd_sum(cint(right(hd_str(0), 1)), 7) + cDbl(adors("접대비보고서"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 8) = arr_hd_sum(cint(right(hd_str(0), 1)), 8) + cDbl(adors("총선기타비"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 9) = arr_hd_sum(cint(right(hd_str(0), 1)), 9) + cDbl(adors("행합계"))
|
|
|
|
adors.movenext
|
|
next%>
|
|
<!-- loop end -->
|
|
<!--
|
|
<tr style="border-top:1px solid gray;height:1px;font-size:1px;">
|
|
<td colspan="10"></td>
|
|
</tr>
|
|
<%
|
|
For i=LBound(arr_hd_sum) To UBound(arr_hd_sum)
|
|
If arr_hd_sum(i, 0) <> "" Then
|
|
%>
|
|
<tr bgcolor="#FBEFFB">
|
|
<td width="7%" class="tahoma" align="center" style="font-weight:bold;"><%=arr_hd_sum(i, 0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 1),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 2),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 3),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 4),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 5),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 6),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 7),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 8),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 9),0) %></td>
|
|
</tr>
|
|
<%
|
|
End if
|
|
Next
|
|
%>
|
|
-->
|
|
<tr bgcolor="#F7F2E0" style="border-top:1px solid gray;">
|
|
<td width="10%" class="tahoma" align="center" style="font-weight:bold;">합 계</td>
|
|
<td width="10%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_meal,0) %></td>
|
|
<td width="10%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_nomal_traffic,0) %></td>
|
|
<td width="10%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_outside_traffic,0) %></td>
|
|
<td width="10%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_delivery,0) %></td>
|
|
<td width="10%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_print,0) %></td>
|
|
<td width="10%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_post,0) %></td>
|
|
<td width="10%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_entertain,0) %></td>
|
|
<td width="10%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_etc,0) %></td>
|
|
<td width="10%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_all,0) %></td>
|
|
</tr>
|
|
</table>
|
|
<%end if' if adors.RecordCount > 0 then
|
|
adors.Close
|
|
%>
|
|
|
|
</td>
|
|
</tr>
|
|
<!-------------------4. 부서 공통경비내역 종료------------------------------------------------------------------------------------------------------------------------------------------------------>
|
|
<!-------------------5. 부서별 일반비용 내역 시작------------------------------------------------------------------------------------------------------------------------------------------------------>
|
|
|
|
<tr><td style="padding:15 0 0 0"><font class="brown" size="3">5. 부서별 공통경비 내역</font></td></tr>
|
|
<tr>
|
|
<td style="padding:5 0 0 0">
|
|
|
|
<table width="100%" cellpadding="3" cellspacing="0" border="0" style="border-collapse:collapse;">
|
|
|
|
<tr>
|
|
<td width="7%" align="center" >부서</td>
|
|
<td width="7%" align="right" >식대</td>
|
|
<td width="7%" align="right" >일반교통비</td>
|
|
<td width="7%" align="right" >시외출장교통비</td>
|
|
<td width="7%" align="right" >택배비</td>
|
|
<td width="7%" align="right" >인쇄비</td>
|
|
<td width="7%" align="right" >우편발송비</td>
|
|
<td width="7%" align="right" >접대비보고서</td>
|
|
<td width="7%" align="right" >인지세/보증보험</td>
|
|
<td width="7%" align="right" >인턴/계약직</td>
|
|
<td width="7%" align="right" >기타</td>
|
|
<td width="7%" align="right" >합계</td>
|
|
</tr>
|
|
</table>
|
|
<% '5. 부서별 일반 비용 내역 쿼리문
|
|
query = " select p_sn, 부서, "
|
|
query = query & " SUM(식대) as 식대, SUM(일반교통비) as 일반교통비, SUM(시외출장교통비) as 시외출장교통비 "
|
|
query = query & " , SUM(택배비) as 택배비, SUM(인쇄비) as 인쇄비, SUM(우편발송비) as 우편발송비, SUM(접대비보고서) as 접대비보고서,SUM(인지세보증보험) as 인지세보증보험, SUM(인턴계약직) as 인턴계약직, SUM(기타) as 기타,SUM(행합계) as 행합계 "
|
|
query = query & " from ( "
|
|
query = query & " select job_date as '날짜', replace(p_sn,',','') as p_sn, "
|
|
query = query & " CASE "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999031' then 'P1' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999032' then 'P2' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999033' then 'P4' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999035' then 'M4' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999036' then 'M1' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999037' then 'M3' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999038' then 'M5' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999039' then 'M2' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999030' then 'P3' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999034' then 'KRC' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999051' then 'M6' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999021' then 'C1' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999052' then 'P5' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999053' then 'AC' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999054' then 'P6' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999055' then '비즈니스프로모터' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999061' then 'PSBU1' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999062' then 'PSBU2' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999063' then 'PSBU3' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999071' then 'MSBU1' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999072' then 'MSBU2' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999073' then 'MSBU3' "
|
|
query = query & " WHEN replace(p_sn,',','') = '9999074' then 'MSBU4' "
|
|
query = query & " END as 부서, "
|
|
query = query & " SUM(일반교통비) as 일반교통비, SUM(식대) as 식대, SUM(시외출장교통비) as 시외출장교통비, "
|
|
query = query & " SUM(택배비) as 택배비, SUM(인쇄비) as 인쇄비, SUM(우편발송비) as 우편발송비, "
|
|
query = query & " SUM(접대비보고서) as 접대비보고서, SUM(인지세보증보험) as 인지세보증보험, SUM(인턴계약직) as 인턴계약직, SUM(기타) as 기타, "
|
|
query = query & " SUM(일반교통비) + SUM(식대) + SUM(시외출장교통비) + SUM(택배비) + SUM(인쇄비) + SUM(우편발송비) + SUM(접대비보고서) + SUM(인지세보증보험) + SUM(인턴계약직) + SUM(기타) as 행합계 "
|
|
query = query & " from "
|
|
query = query & " ( "
|
|
query = query & " select a.d_code, job_date, p_sn, "
|
|
query = query & " isnull(sum(case when cost_code IN ('7','11','17','18','20','23','24') then cost_money else 0 end ),0) as '일반교통비', "
|
|
query = query & " isnull(sum(case when cost_code IN ('9','10','19','21','28','99') then cost_money else 0 end ),0) as '식대', "
|
|
query = query & " isnull(sum(case when cost_code IN ('12','13','14','15','16') then cost_money else 0 end ),0) as '시외출장교통비', "
|
|
query = query & " isnull(sum(case when cost_code = '8' then cost_money else 0 end ),0) as '택배비', "
|
|
query = query & " isnull(sum(case when cost_code = '6' then cost_money else 0 end ),0) as '인쇄비', "
|
|
query = query & " isnull(sum(case when cost_code = '5' then cost_money else 0 end ),0) as '우편발송비', "
|
|
query = query & " '0' as 접대비보고서, '0' as 인지세보증보험, '0' as 인턴계약직, '0' as 기타 "
|
|
query = query & " from ( "
|
|
query = query & " select P.p_depart as d_code, '99990' + convert(varchar, P.p_depart) as p_sn, left(job_date,7) as job_date, cost_code, sum(cost_money) as cost_money "
|
|
query = query & " from V_BUSI_COST BC left outer join V_Person P on BC.p_no = P.p_no "
|
|
query = query & " where job_date > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and job_date < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and cost_money > 0 "
|
|
query = query & " and BC.p_sn like '9999%' "
|
|
query = query & " group by P.p_depart, BC.p_sn, cost_code, left(job_date,7) "
|
|
query = query & " ) as a "
|
|
query = query & " group by job_date, a.d_code, p_sn "
|
|
query = query & " "
|
|
query = query & " union all "
|
|
query = query & " "
|
|
query = query & " select p_depart, left(convert(varchar(20),target3),7) as date, p_sn, "
|
|
query = query & " '0' as 일반교통비, '0' as 식대, '0' as 시외출장교통비, '0' as 택배비, '0' as 인쇄비, '0' as 우편발송비, "
|
|
query = query & " isnull(sum(convert(numeric(18,2), replace(convert(varchar(15), target6), ',', ''))),0) as 접대비보고서, "
|
|
query = query & " '0' as 인지세보증보험, '0' as 인턴계약직, '0' as 기타 "
|
|
query = query & " from 문서내용 as a left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " where 문서제목 in ('접대비보고서') "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and (p_sn = '99999' OR p_sn like '9999___') "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " group by 문서제목, p_depart,p_sn, left(convert(varchar(20),target3),7) "
|
|
query = query & " "
|
|
query = query & " union all "
|
|
query = query & " "
|
|
query = query & " select replace(substring(p_sn,6,2),',','') as p_depart, left(convert(varchar(20),target3),7) as date, p_sn, '0' as 일반교통비 "
|
|
query = query & " , '0' as 식대, '0' as 시외출장교통비, '0' as 택배비, '0' as 인쇄비, '0' as 우편발송비, '0' as 접대비보고서 ,'0' as 인지세보증보험, '0' as 인턴계약직 "
|
|
query = query & " , sum(convert(numeric(18,2), replace(convert(varchar(15), target5), ',', ''))) as 기타 "
|
|
query = query & " from 문서내용 as a "
|
|
query = query & " left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " where 문서제목 in ('지출결의서') "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " and 문서번호 like '%i%' "
|
|
query = query & " and ( target16 is null or not (target16 like 'research' or target16 like 'field' or target16 like 'support') ) "
|
|
query = query & " and p_sn not like '99999,' "
|
|
query = query & " and p_sn like '9999%' "
|
|
query = query & " group by 문서제목, p_depart, p_sn, left(convert(varchar(20),target3),7) "
|
|
query = query & " "
|
|
query = query & " union all "
|
|
query = query & " select replace(substring(p_sn,6,2),',','') as p_depart, "
|
|
query = query & " left(convert(varchar(20),target3),7) as date, "
|
|
query = query & " p_sn, "
|
|
query = query & " '0' as 일반교통비 , "
|
|
query = query & " '0' as 식대, "
|
|
query = query & " '0' as 시외출장교통비, "
|
|
query = query & " '0' as 택배비, "
|
|
query = query & " sum(convert(numeric(18,2), replace(convert(varchar(15), target5), ',', ''))) as 인쇄비, "
|
|
query = query & " '0' as 우편발송비, "
|
|
query = query & " '0' as 접대비보고서 , "
|
|
query = query & " '0' as 인지세보증보험, "
|
|
query = query & " '0' as 인턴계약직, "
|
|
query = query & " '0' as 기타 "
|
|
query = query & " from "
|
|
query = query & " ( "
|
|
query = query & " SELECT 문서번호, "
|
|
query = query & " target3, "
|
|
query = query & " target4, "
|
|
query = query & " target8, "
|
|
query = query & " target9, "
|
|
query = query & " target11, "
|
|
query = query & " target12, "
|
|
query = query & " gubun, "
|
|
query = query & " contents , "
|
|
query = query & " replace(substring(contents, charindex('^^', left(contents, 10))+2, charindex('^//^', contents)-4), '^', '') as p_sn , "
|
|
query = query & " replace(left(substring(contents, charindex('^//^', contents)+4, 20), charindex('^//^', substring(contents, charindex('^//^', contents)+4, 20))-1), ',', '') as target5 "
|
|
query = query & " FROM "
|
|
query = query & " ( "
|
|
query = query & " select 문서번호, "
|
|
query = query & " 문서제목, "
|
|
query = query & " target3, "
|
|
query = query & " target4, "
|
|
query = query & " target8, "
|
|
query = query & " target9, "
|
|
query = query & " target11, "
|
|
query = query & " target12, "
|
|
query = query & " convert(varchar(300), target21) as target21 , convert(varchar(300), target22) as target22 , convert(varchar(300), target23) as target23 , "
|
|
query = query & " convert(varchar(300), target24) as target24 , convert(varchar(300), target25) as target25 , convert(varchar(300), target26) as target26 , "
|
|
query = query & " convert(varchar(300), target27) as target27 , convert(varchar(300), target28) as target28 , convert(varchar(300), target29) as target29 , "
|
|
query = query & " convert(varchar(300), target30) as target30 , convert(varchar(300), target31) as target31 , convert(varchar(300), target32) as target32 , "
|
|
query = query & " convert(varchar(300), target33) as target33 , convert(varchar(300), target34) as target34 , convert(varchar(300), target35) as target35 , "
|
|
query = query & " convert(varchar(300), target36) as target36 , convert(varchar(300), target37) as target37 , convert(varchar(300), target38) as target38 , "
|
|
query = query & " convert(varchar(300), target39) as target39 , convert(varchar(300), target40) as target40 , convert(varchar(300), target41) as target41 , "
|
|
query = query & " convert(varchar(300), target42) as target42 , convert(varchar(300), target43) as target43 , convert(varchar(300), target44) as target44 , "
|
|
query = query & " convert(varchar(300), target45) as target45 , convert(varchar(300), target46) as target46 , convert(varchar(300), target47) as target47 , "
|
|
query = query & " convert(varchar(300), target48) as target48 , convert(varchar(300), target49) as target49 , convert(varchar(300), target50) as target50 "
|
|
query = query & " from 문서내용 as a "
|
|
query = query & " left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " where 문서제목 in ('지출결의서') "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " and 문서번호 like '%A%' "
|
|
query = query & " and not (target16 like 'research' or target16 like 'field' or target16 like 'support') "
|
|
query = query & " and ((convert(varchar(10),target11) = '159' and convert(varchar(10),target12) = '135') "
|
|
query = query & " or (convert(varchar(10),target11) = '162' and convert(varchar(10),target12) = '142' and target8 like '%아이프린트%')) "
|
|
query = query & " ) AS columnTable "
|
|
query = query & " UNPIVOT "
|
|
query = query & " ( "
|
|
query = query & " contents FOR gubun IN ( "
|
|
query = query & " target21, target22, target23, target24, target25, target26, target27, target28, target29, target30 , "
|
|
query = query & " target31, target32, target33, target34, target35, target36, target37, target38, target39, target40 , "
|
|
query = query & " target41, target42, target43, target44, target45, target46, target47, target48, target49, target50 "
|
|
query = query & " ) "
|
|
query = query & " ) AS rowTable "
|
|
query = query & " where contents <> '' and contents not like '%99999^//^%' "
|
|
query = query & " ) as T "
|
|
query = query & " group by replace(substring(p_sn,6,2),',',''), p_sn, left(convert(varchar(20),target3),7) "
|
|
query = query & " union all "
|
|
|
|
query = query & " select replace(substring(p_sn,6,2),',','') as p_depart, "
|
|
query = query & " left(convert(varchar(20),target3),7) as date, "
|
|
query = query & " p_sn, "
|
|
query = query & " '0' as 일반교통비 , "
|
|
query = query & " '0' as 식대, "
|
|
query = query & " '0' as 시외출장교통비, "
|
|
query = query & " '0' as 택배비, "
|
|
query = query & " '0' as 인쇄비, "
|
|
query = query & " sum(convert(numeric(18,2), replace(convert(varchar(15), target5), ',', ''))) as 우편발송비, "
|
|
query = query & " '0' as 접대비보고서 , "
|
|
query = query & " '0' as 인지세보증보험, "
|
|
query = query & " '0' as 인턴계약직, "
|
|
query = query & " '0' as 기타 "
|
|
query = query & " from "
|
|
query = query & " ( "
|
|
query = query & " SELECT 문서번호, "
|
|
query = query & " target3, "
|
|
query = query & " target4, "
|
|
query = query & " target8, "
|
|
query = query & " target9, "
|
|
query = query & " target11, "
|
|
query = query & " target12, "
|
|
query = query & " gubun, "
|
|
query = query & " contents , "
|
|
query = query & " replace(substring(contents, charindex('^^', left(contents, 10))+2, charindex('^//^', contents)-4), '^', '') as p_sn , "
|
|
query = query & " replace(left(substring(contents, charindex('^//^', contents)+4, 20), charindex('^//^', substring(contents, charindex('^//^', contents)+4, 20))-1), ',', '') as target5 "
|
|
query = query & " FROM "
|
|
query = query & " ( "
|
|
query = query & " select 문서번호, "
|
|
query = query & " 문서제목, "
|
|
query = query & " target3, "
|
|
query = query & " target4, "
|
|
query = query & " target8, "
|
|
query = query & " target9, "
|
|
query = query & " target11, "
|
|
query = query & " target12, "
|
|
query = query & " convert(varchar(300), target21) as target21 , convert(varchar(300), target22) as target22 , convert(varchar(300), target23) as target23 , "
|
|
query = query & " convert(varchar(300), target24) as target24 , convert(varchar(300), target25) as target25 , convert(varchar(300), target26) as target26 , "
|
|
query = query & " convert(varchar(300), target27) as target27 , convert(varchar(300), target28) as target28 , convert(varchar(300), target29) as target29 , "
|
|
query = query & " convert(varchar(300), target30) as target30 , convert(varchar(300), target31) as target31 , convert(varchar(300), target32) as target32 , "
|
|
query = query & " convert(varchar(300), target33) as target33 , convert(varchar(300), target34) as target34 , convert(varchar(300), target35) as target35 , "
|
|
query = query & " convert(varchar(300), target36) as target36 , convert(varchar(300), target37) as target37 , convert(varchar(300), target38) as target38 , "
|
|
query = query & " convert(varchar(300), target39) as target39 , convert(varchar(300), target40) as target40 , convert(varchar(300), target41) as target41 , "
|
|
query = query & " convert(varchar(300), target42) as target42 , convert(varchar(300), target43) as target43 , convert(varchar(300), target44) as target44 , "
|
|
query = query & " convert(varchar(300), target45) as target45 , convert(varchar(300), target46) as target46 , convert(varchar(300), target47) as target47 , "
|
|
query = query & " convert(varchar(300), target48) as target48 , convert(varchar(300), target49) as target49 , convert(varchar(300), target50) as target50 "
|
|
query = query & " from 문서내용 as a "
|
|
query = query & " left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " where 문서제목 in ('지출결의서') "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " and 문서번호 like '%A%' "
|
|
query = query & " and not (target16 like 'research' or target16 like 'field' or target16 like 'support') "
|
|
query = query & " and (convert(varchar(10),target11) = '152' and convert(varchar(10),target12) = '125') "
|
|
query = query & " "
|
|
query = query & " ) AS columnTable "
|
|
query = query & " UNPIVOT "
|
|
query = query & " ( "
|
|
query = query & " contents FOR gubun IN ( "
|
|
query = query & " target21, target22, target23, target24, target25, target26, target27, target28, target29, target30 , "
|
|
query = query & " target31, target32, target33, target34, target35, target36, target37, target38, target39, target40 , "
|
|
query = query & " target41, target42, target43, target44, target45, target46, target47, target48, target49, target50 "
|
|
query = query & " ) "
|
|
query = query & " ) AS rowTable "
|
|
query = query & " where contents <> '' and contents not like '%99999^//^%' "
|
|
query = query & " ) as T "
|
|
query = query & " group by replace(substring(p_sn,6,2),',',''), p_sn, left(convert(varchar(20),target3),7) "
|
|
|
|
query = query & " union all "
|
|
query = query & " select replace(substring(p_sn,6,2),',','') as p_depart, "
|
|
query = query & " left(convert(varchar(20),target3),7) as date, "
|
|
query = query & " p_sn, "
|
|
query = query & " sum(convert(numeric(18,2), replace(convert(varchar(15), target5), ',', ''))) as 일반교통비 , "
|
|
query = query & " '0' as 식대, "
|
|
query = query & " '0' as 시외출장교통비, "
|
|
query = query & " '0' as 택배비, "
|
|
query = query & " '0' as 인쇄비, "
|
|
query = query & " '0' as 우편발송비, "
|
|
query = query & " '0' as 접대비보고서 , "
|
|
query = query & " '0' as 인지세보증보험, "
|
|
query = query & " '0' as 인턴계약직, "
|
|
query = query & " '0' as 기타 "
|
|
query = query & " from "
|
|
query = query & " ( "
|
|
query = query & " SELECT 문서번호, "
|
|
query = query & " target3, "
|
|
query = query & " target4, "
|
|
query = query & " target8, "
|
|
query = query & " target9, "
|
|
query = query & " target11, "
|
|
query = query & " target12, "
|
|
query = query & " gubun, "
|
|
query = query & " contents , "
|
|
query = query & " replace(substring(contents, charindex('^^', left(contents, 10))+2, charindex('^//^', contents)-4), '^', '') as p_sn , "
|
|
query = query & " replace(left(substring(contents, charindex('^//^', contents)+4, 20), charindex('^//^', substring(contents, charindex('^//^', contents)+4, 20))-1), ',', '') as target5 "
|
|
query = query & " FROM "
|
|
query = query & " ( "
|
|
query = query & " select 문서번호, "
|
|
query = query & " 문서제목, "
|
|
query = query & " target3, "
|
|
query = query & " target4, "
|
|
query = query & " target8, "
|
|
query = query & " target9, "
|
|
query = query & " target11, "
|
|
query = query & " target12, "
|
|
query = query & " convert(varchar(300), target21) as target21 , convert(varchar(300), target22) as target22 , convert(varchar(300), target23) as target23 , "
|
|
query = query & " convert(varchar(300), target24) as target24 , convert(varchar(300), target25) as target25 , convert(varchar(300), target26) as target26 , "
|
|
query = query & " convert(varchar(300), target27) as target27 , convert(varchar(300), target28) as target28 , convert(varchar(300), target29) as target29 , "
|
|
query = query & " convert(varchar(300), target30) as target30 , convert(varchar(300), target31) as target31 , convert(varchar(300), target32) as target32 , "
|
|
query = query & " convert(varchar(300), target33) as target33 , convert(varchar(300), target34) as target34 , convert(varchar(300), target35) as target35 , "
|
|
query = query & " convert(varchar(300), target36) as target36 , convert(varchar(300), target37) as target37 , convert(varchar(300), target38) as target38 , "
|
|
query = query & " convert(varchar(300), target39) as target39 , convert(varchar(300), target40) as target40 , convert(varchar(300), target41) as target41 , "
|
|
query = query & " convert(varchar(300), target42) as target42 , convert(varchar(300), target43) as target43 , convert(varchar(300), target44) as target44 , "
|
|
query = query & " convert(varchar(300), target45) as target45 , convert(varchar(300), target46) as target46 , convert(varchar(300), target47) as target47 , "
|
|
query = query & " convert(varchar(300), target48) as target48 , convert(varchar(300), target49) as target49 , convert(varchar(300), target50) as target50 "
|
|
query = query & " from 문서내용 as a "
|
|
query = query & " left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " where 문서제목 in ('지출결의서') "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " and 문서번호 like '%A%' "
|
|
query = query & " and not (target16 like 'research' or target16 like 'field' or target16 like 'support') "
|
|
query = query & " and (convert(varchar(10),target11) = '151' and convert(varchar(10),target12) = '123') "
|
|
query = query & " "
|
|
query = query & " ) AS columnTable "
|
|
query = query & " UNPIVOT "
|
|
query = query & " ( "
|
|
query = query & " contents FOR gubun IN ( "
|
|
query = query & " target21, target22, target23, target24, target25, target26, target27, target28, target29, target30 , "
|
|
query = query & " target31, target32, target33, target34, target35, target36, target37, target38, target39, target40 , "
|
|
query = query & " target41, target42, target43, target44, target45, target46, target47, target48, target49, target50 "
|
|
query = query & " ) "
|
|
query = query & " ) AS rowTable "
|
|
query = query & " where contents <> '' and contents not like '%99999^//^%' "
|
|
query = query & " ) as T "
|
|
query = query & " group by replace(substring(p_sn,6,2),',',''), p_sn, left(convert(varchar(20),target3),7) "
|
|
|
|
query = query & " union all "
|
|
query = query & " select replace(substring(p_sn,6,2),',','') as p_depart, "
|
|
query = query & " left(convert(varchar(20),target3),7) as date, "
|
|
query = query & " p_sn, "
|
|
query = query & " '0' as 일반교통비 , "
|
|
query = query & " '0' as 식대, "
|
|
query = query & " '0' as 시외출장교통비, "
|
|
query = query & " sum(convert(numeric(18,2), replace(convert(varchar(15), target5), ',', ''))) as 택배비, "
|
|
query = query & " '0' as 인쇄비, "
|
|
query = query & " '0' as 우편발송비, "
|
|
query = query & " '0' as 접대비보고서 , "
|
|
query = query & " '0' as 인지세보증보험, "
|
|
query = query & " '0' as 인턴계약직, "
|
|
query = query & " '0' as 기타 "
|
|
query = query & " from "
|
|
query = query & " ( "
|
|
query = query & " SELECT 문서번호, "
|
|
query = query & " target3, "
|
|
query = query & " target4, "
|
|
query = query & " target8, "
|
|
query = query & " target9, "
|
|
query = query & " target11, "
|
|
query = query & " target12, "
|
|
query = query & " gubun, "
|
|
query = query & " contents , "
|
|
query = query & " replace(substring(contents, charindex('^^', left(contents, 10))+2, charindex('^//^', contents)-4), '^', '') as p_sn , "
|
|
query = query & " replace(left(substring(contents, charindex('^//^', contents)+4, 20), charindex('^//^', substring(contents, charindex('^//^', contents)+4, 20))-1), ',', '') as target5 "
|
|
query = query & " FROM "
|
|
query = query & " ( "
|
|
query = query & " select 문서번호, "
|
|
query = query & " 문서제목, "
|
|
query = query & " target3, "
|
|
query = query & " target4, "
|
|
query = query & " target8, "
|
|
query = query & " target9, "
|
|
query = query & " target11, "
|
|
query = query & " target12, "
|
|
query = query & " convert(varchar(300), target21) as target21 , convert(varchar(300), target22) as target22 , convert(varchar(300), target23) as target23 , "
|
|
query = query & " convert(varchar(300), target24) as target24 , convert(varchar(300), target25) as target25 , convert(varchar(300), target26) as target26 , "
|
|
query = query & " convert(varchar(300), target27) as target27 , convert(varchar(300), target28) as target28 , convert(varchar(300), target29) as target29 , "
|
|
query = query & " convert(varchar(300), target30) as target30 , convert(varchar(300), target31) as target31 , convert(varchar(300), target32) as target32 , "
|
|
query = query & " convert(varchar(300), target33) as target33 , convert(varchar(300), target34) as target34 , convert(varchar(300), target35) as target35 , "
|
|
query = query & " convert(varchar(300), target36) as target36 , convert(varchar(300), target37) as target37 , convert(varchar(300), target38) as target38 , "
|
|
query = query & " convert(varchar(300), target39) as target39 , convert(varchar(300), target40) as target40 , convert(varchar(300), target41) as target41 , "
|
|
query = query & " convert(varchar(300), target42) as target42 , convert(varchar(300), target43) as target43 , convert(varchar(300), target44) as target44 , "
|
|
query = query & " convert(varchar(300), target45) as target45 , convert(varchar(300), target46) as target46 , convert(varchar(300), target47) as target47 , "
|
|
query = query & " convert(varchar(300), target48) as target48 , convert(varchar(300), target49) as target49 , convert(varchar(300), target50) as target50 "
|
|
query = query & " from 문서내용 as a "
|
|
query = query & " left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " where 문서제목 in ('지출결의서') "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " and 문서번호 like '%A%' "
|
|
query = query & " and not (target16 like 'research' or target16 like 'field' or target16 like 'support') "
|
|
query = query & " and (convert(varchar(10),target11) = '157' and convert(varchar(10),target12) = '133') "
|
|
query = query & " "
|
|
query = query & " ) AS columnTable "
|
|
query = query & " UNPIVOT "
|
|
query = query & " ( "
|
|
query = query & " contents FOR gubun IN ( "
|
|
query = query & " target21, target22, target23, target24, target25, target26, target27, target28, target29, target30 , "
|
|
query = query & " target31, target32, target33, target34, target35, target36, target37, target38, target39, target40 , "
|
|
query = query & " target41, target42, target43, target44, target45, target46, target47, target48, target49, target50 "
|
|
query = query & " ) "
|
|
query = query & " ) AS rowTable "
|
|
query = query & " where contents <> '' and contents not like '%99999^//^%' "
|
|
query = query & " ) as T "
|
|
query = query & " group by replace(substring(p_sn,6,2),',',''), p_sn, left(convert(varchar(20),target3),7) "
|
|
query = query & " union all "
|
|
|
|
query = query & " "
|
|
query = query & " select replace(substring(p_sn,6,2),',','') as p_depart, left(convert(varchar(20),target3),7) as date, p_sn, '0' as 일반교통비 "
|
|
query = query & " , '0' as 식대, '0' as 시외출장교통비, '0' as 택배비, '0' as 인쇄비, '0' as 우편발송비, '0' as 접대비보고서 "
|
|
query = query & " , sum(convert(numeric(18,2), replace(convert(varchar(15), case when ((target11 like '154' and target12 like '129') or (target11 like '156' and target12 like '132')) then target5 else '0' end), ',', ''))) as 인지세보증보험, "
|
|
query = query & " sum(convert(numeric(18,2), replace(convert(varchar(15), case when ((target11 like '148' and target12 like '114') or (target11 like '162' and target12 like '142')) then target5 else '0' end), ',', ''))) as 인턴계약직, "
|
|
query = query & " sum(convert(numeric(18,2), replace(convert(varchar(15), case when (target11 not like '148' and target12 not like '114') and (target11 not like '162' and target12 not like '142') and (target11 not like '154' and target12 not like '129') and (target11 not like '156' and target12 not like '132') then target5 else '0' end), ',', ''))) as 기타 "
|
|
query = query & " from ( "
|
|
query = query & " SELECT 문서번호, target3, target4, target8, target9, target11, target12, gubun, contents "
|
|
query = query & " , replace(substring(contents, charindex('^^', left(contents, 10))+2, charindex('^//^', contents)-4), '^', '') as p_sn "
|
|
query = query & " , replace(left(substring(contents, charindex('^//^', contents)+4, 20), charindex('^//^', substring(contents, charindex('^//^', contents)+4, 20))-1), ',', '') as target5 "
|
|
query = query & " FROM ( "
|
|
query = query & " select 문서번호, 문서제목, target3, target4, target8, target9, target11, target12 "
|
|
query = query & " , convert(varchar(300), target21) as target21 "
|
|
query = query & " , convert(varchar(300), target22) as target22 "
|
|
query = query & " , convert(varchar(300), target23) as target23 "
|
|
query = query & " , convert(varchar(300), target24) as target24 "
|
|
query = query & " , convert(varchar(300), target25) as target25 "
|
|
query = query & " , convert(varchar(300), target26) as target26 "
|
|
query = query & " , convert(varchar(300), target27) as target27 "
|
|
query = query & " , convert(varchar(300), target28) as target28 "
|
|
query = query & " , convert(varchar(300), target29) as target29 "
|
|
query = query & " , convert(varchar(300), target30) as target30 "
|
|
query = query & " , convert(varchar(300), target31) as target31 "
|
|
query = query & " , convert(varchar(300), target32) as target32 "
|
|
query = query & " , convert(varchar(300), target33) as target33 "
|
|
query = query & " , convert(varchar(300), target34) as target34 "
|
|
query = query & " , convert(varchar(300), target35) as target35 "
|
|
query = query & " , convert(varchar(300), target36) as target36 "
|
|
query = query & " , convert(varchar(300), target37) as target37 "
|
|
query = query & " , convert(varchar(300), target38) as target38 "
|
|
query = query & " , convert(varchar(300), target39) as target39 "
|
|
query = query & " , convert(varchar(300), target40) as target40 "
|
|
query = query & " , convert(varchar(300), target41) as target41 "
|
|
query = query & " , convert(varchar(300), target42) as target42 "
|
|
query = query & " , convert(varchar(300), target43) as target43 "
|
|
query = query & " , convert(varchar(300), target44) as target44 "
|
|
query = query & " , convert(varchar(300), target45) as target45 "
|
|
query = query & " , convert(varchar(300), target46) as target46 "
|
|
query = query & " , convert(varchar(300), target47) as target47 "
|
|
query = query & " , convert(varchar(300), target48) as target48 "
|
|
query = query & " , convert(varchar(300), target49) as target49 "
|
|
query = query & " , convert(varchar(300), target50) as target50 "
|
|
query = query & " from 문서내용 as a "
|
|
query = query & " left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " where 문서제목 in ('지출결의서') "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " and 문서번호 like '%A%' "
|
|
query = query & " and not (target16 like 'research' or target16 like 'field' or target16 like 'support') "
|
|
query = query & " and not (convert(varchar(10),target11) = '152' and convert(varchar(10),target12) = '125') "
|
|
query = query & " and not (convert(varchar(10),target11) = '151' and convert(varchar(10),target12) = '123') "
|
|
query = query & " and not (convert(varchar(10),target11) = '157' and convert(varchar(10),target12) = '133') "
|
|
query = query & " and not ((convert(varchar(10),target11) = '159' and convert(varchar(10),target12) = '135') "
|
|
query = query & " or (convert(varchar(10),target11) = '162' and convert(varchar(10),target12) = '142' and target8 like '%아이프린트%')) "
|
|
query = query & " ) AS columnTable "
|
|
query = query & " UNPIVOT "
|
|
query = query & " ( "
|
|
query = query & " contents FOR gubun IN (target21, target22, target23, target24, target25, target26, target27, target28, target29, target30 "
|
|
query = query & " ,target31, target32, target33, target34, target35, target36, target37, target38, target39, target40 "
|
|
query = query & " ,target41, target42, target43, target44, target45, target46, target47, target48, target49, target50) "
|
|
query = query & " ) AS rowTable "
|
|
query = query & " where contents <> '' "
|
|
query = query & " and contents not like '%99999^//^%' "
|
|
query = query & " ) as T "
|
|
query = query & " group by replace(substring(p_sn,6,2),',',''), p_sn, left(convert(varchar(20),target3),7) "
|
|
query = query & " union all "
|
|
query = query & " select replace(substring(p_sn,6,2),',','') as p_depart, left(convert(varchar(20),target3),7) as date, p_sn, '0' as 일반교통비 "
|
|
query = query & " , '0' as 식대, '0' as 시외출장교통비, '0' as 택배비, '0' as 인쇄비, '0' as 우편발송비, '0' as 접대비보고서, '0' as 인지세보증보험, '0' as 인턴계약직, "
|
|
query = query & " sum(convert(numeric(18,2), use_cost)) as 기타 "
|
|
query = query & " from "
|
|
query = query & " ( "
|
|
query = query & " SELECT '99990' + depart_cd AS p_sn, cost_date AS target3, cost AS use_cost "
|
|
query = query & " FROM V_GROUP_COST_NEW vgcn "
|
|
query = query & " where cost_date > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and cost_date < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " ) as T "
|
|
query = query & " group by replace(substring(p_sn,6,2),',',''), p_sn, left(convert(varchar(20),target3),7) "
|
|
query = query & " ) T "
|
|
query = query & " where replace(p_sn,',','') not in ('0','9999','99999','9999003','9999004','9999005','9999012','9999017','9999018') "
|
|
query = query & " and left(job_date,4) = '"&tmp_year&"' "
|
|
query = query & " group by replace(p_sn,',',''), job_date "
|
|
query = query & " ) T "
|
|
query = query & " where 부서 <> '' "
|
|
query = query & " group by 부서, p_sn "
|
|
query = query & " order by 부서 "
|
|
|
|
|
|
|
|
'Response.Write query & "<br>"
|
|
|
|
adors.Open query, adoconn,adOpenStatic,adLockReadOnly
|
|
|
|
dim sum_common_cost
|
|
dim sum_insurance_cost
|
|
dim sum_intern_cost
|
|
|
|
sum_meal = 0
|
|
sum_nomal_traffic = 0
|
|
sum_outside_traffic = 0
|
|
sum_delivery = 0
|
|
sum_print = 0
|
|
sum_post = 0
|
|
sum_expence = 0
|
|
sum_entertain = 0
|
|
sum_common_cost = 0
|
|
sum_insurance_cost = 0
|
|
sum_intern_cost = 0
|
|
sum_all = 0
|
|
|
|
if adors.RecordCount > 0 then
|
|
%>
|
|
<table width="100%" cellpadding="3" cellspacing="0" border="0" style="border-collapse:collapse;<% if command <> "view" then %>display:none<% end if%>">
|
|
<!-- loop start -->
|
|
<%
|
|
rowIndex = 0
|
|
|
|
reDim arr_hd_sum(5, 15)
|
|
|
|
for i=1 To 5
|
|
for j=1 To 15
|
|
arr_hd_sum(i, j) = 0
|
|
next
|
|
Next
|
|
|
|
for i=1 to adors.RecordCount
|
|
rowIndex = rowIndex + 1
|
|
IF rowIndex mod 2 Then
|
|
list_bgcolor="#dbe9f2"
|
|
Else
|
|
list_bgcolor="#FFFFFF"
|
|
End If
|
|
%>
|
|
<tr bgcolor="<%=list_bgcolor%>">
|
|
<td width="7%" class="tahoma" align="center"><%=adors("부서")%></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("식대") ,0)%></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("일반교통비") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("시외출장교통비") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("택배비") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("인쇄비") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("우편발송비") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("접대비보고서") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("인지세보증보험") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("인턴계약직") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("기타") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("행합계") ,0) %></td>
|
|
</tr>
|
|
<%
|
|
sum_meal = sum_meal + cDbl(adors("식대"))
|
|
sum_nomal_traffic = sum_nomal_traffic + cDbl(adors("일반교통비"))
|
|
sum_outside_traffic = sum_outside_traffic + cDbl(adors("시외출장교통비"))
|
|
sum_delivery = sum_delivery + cDbl(adors("택배비"))
|
|
sum_print = sum_print + cDbl(adors("인쇄비"))
|
|
sum_post = sum_post + cDbl(adors("우편발송비"))
|
|
sum_entertain = sum_entertain + CDbl(adors("접대비보고서"))
|
|
sum_common_cost = sum_common_cost + CDbl(adors("기타"))
|
|
sum_insurance_cost = sum_insurance_cost + CDbl(adors("인지세보증보험"))
|
|
sum_intern_cost = sum_intern_cost + CDbl(adors("인턴계약직"))
|
|
sum_all = sum_all + CDbl(adors("행합계"))
|
|
|
|
hd_str = split(Hd_chk(adors("p_sn")), "_")
|
|
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 0) = hd_str(1)
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 1) = arr_hd_sum(cint(right(hd_str(0), 1)), 1) + cDbl(adors("식대"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 2) = arr_hd_sum(cint(right(hd_str(0), 1)), 2) + cDbl(adors("일반교통비"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 3) = arr_hd_sum(cint(right(hd_str(0), 1)), 3) + cDbl(adors("시외출장교통비"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 4) = arr_hd_sum(cint(right(hd_str(0), 1)), 4) + cDbl(adors("택배비"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 5) = arr_hd_sum(cint(right(hd_str(0), 1)), 5) + cDbl(adors("인쇄비"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 6) = arr_hd_sum(cint(right(hd_str(0), 1)), 6) + cDbl(adors("우편발송비"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 7) = arr_hd_sum(cint(right(hd_str(0), 1)), 7) + cDbl(adors("접대비보고서"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 8) = arr_hd_sum(cint(right(hd_str(0), 1)), 8) + cDbl(adors("기타"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 9) = arr_hd_sum(cint(right(hd_str(0), 1)), 9) + cDbl(adors("인지세보증보험"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 10) = arr_hd_sum(cint(right(hd_str(0), 1)), 10) + cDbl(adors("인턴계약직"))
|
|
arr_hd_sum(cint(right(hd_str(0), 1)), 11) = arr_hd_sum(cint(right(hd_str(0), 1)), 11) + cDbl(adors("행합계"))
|
|
|
|
adors.movenext
|
|
next%>
|
|
<!-- loop end -->
|
|
<!--
|
|
<tr style="border-top:1px solid gray;height:1px;font-size:1px;">
|
|
<td colspan="12"></td>
|
|
</tr>
|
|
<%
|
|
For i=LBound(arr_hd_sum) To UBound(arr_hd_sum)
|
|
If arr_hd_sum(i, 0) <> "" Then
|
|
%>
|
|
<tr bgcolor="#FBEFFB">
|
|
<td width="7%" class="tahoma" align="center" style="font-weight:bold;"><%=arr_hd_sum(i, 0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 1),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 2),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 3),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 4),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 5),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 6),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 7),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 9),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 10),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 8),0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(arr_hd_sum(i, 11),0) %></td>
|
|
</tr>
|
|
<%
|
|
End if
|
|
Next
|
|
%>
|
|
-->
|
|
<tr bgcolor="#F7F2E0" style="border-top:1px solid gray;">
|
|
<td width="7%" class="tahoma" align="center" style="font-weight:bold;">합 계</td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_meal,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_nomal_traffic,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_outside_traffic,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_delivery,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_print,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_post,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_entertain,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_insurance_cost,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_intern_cost,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_common_cost,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_all,0) %></td>
|
|
</tr>
|
|
</table>
|
|
<%end if' if adors.RecordCount > 0 then
|
|
adors.Close
|
|
%>
|
|
|
|
</td>
|
|
</tr>
|
|
<!-------------------5. 부서별 일반비용 내역 종료------------------------------------------------------------------------------------------------------------------------------------------------------>
|
|
<% If Session("Depart_code") = "0" Or Session("user_number") = "20080101" Or Session("Depart_code") = "18" Then %>
|
|
<!-------------------6. 본부별 공통경비 내역 시작------------------------------------------------------------------------------------------------------------------------------------------------------>
|
|
<!--
|
|
<tr><td style="padding:15 0 0 0"><font class="brown" size="3">6. 본부별 공통경비 내역</font></td></tr>
|
|
<tr>
|
|
<td style="padding:5 0 0 0">
|
|
|
|
<table width="100%" cellpadding="3" cellspacing="0" border="0" style="border-collapse:collapse;">
|
|
|
|
<tr>
|
|
<td width="7%" align="center" >부서</td>
|
|
<td width="7%" align="right" >식대</td>
|
|
<td width="7%" align="right" >일반교통비</td>
|
|
<td width="7%" align="right" >시외출장교통비</td>
|
|
<td width="7%" align="right" >택배비</td>
|
|
<td width="7%" align="right" >인쇄비</td>
|
|
<td width="7%" align="right" >우편발송비</td>
|
|
<td width="7%" align="right" >접대비보고서</td>
|
|
<td width="7%" align="right" >인지세/보증보험</td>
|
|
<td width="7%" align="right" >인턴/계약직</td>
|
|
<td width="7%" align="right" >기타</td>
|
|
<td width="7%" align="right" >합계</td>
|
|
</tr>
|
|
</table>
|
|
<% '6. 본부별 공통경비 내역 쿼리문
|
|
query = " select CASE WHEN p_sn = '9999003' then '1본부' WHEN p_sn = '9999004' then '2본부' WHEN p_sn = '9999005' then 'M.I.연구소(본부)' END as 부서, "
|
|
query = query & " SUM(일반교통비) as 일반교통비, SUM(식대) as 식대, SUM(시외출장교통비) as 시외출장교통비, "
|
|
query = query & " SUM(택배비) as 택배비, SUM(인쇄비) as 인쇄비, SUM(우편발송비) as 우편발송비, "
|
|
query = query & " SUM(접대비보고서) as 접대비보고서, SUM(인지세보증보험) as 인지세보증보험 , SUM(인턴계약직) as 인턴계약직 , SUM(기타) as 기타 , "
|
|
query = query & " SUM(일반교통비) + SUM(식대) + SUM(시외출장교통비) + SUM(택배비) + SUM(인쇄비) + SUM(우편발송비) + SUM(접대비보고서) + SUM(인지세보증보험) + SUM(인턴계약직) + SUM(기타) as 행합계 "
|
|
query = query & " from ( "
|
|
query = query & " select a.d_code, p_sn, "
|
|
query = query & " sum(case when cost_code IN ('7','11','17','18','20','23','24') then cost_money else 0 end ) as '일반교통비', "
|
|
query = query & " sum(case when cost_code IN ('9','10','19','21','28','99') then cost_money else 0 end ) as '식대', "
|
|
query = query & " sum(case when cost_code IN ('12','13','14','15','16') then cost_money else 0 end ) as '시외출장교통비', "
|
|
query = query & " sum(case when cost_code = '8' then cost_money else 0 end ) as '택배비', "
|
|
query = query & " sum(case when cost_code = '6' then cost_money else 0 end ) as '인쇄비', "
|
|
query = query & " sum(case when cost_code = '5' then cost_money else 0 end ) as '우편발송비', "
|
|
query = query & " 0 as 접대비보고서, '0' as 인지세보증보험, '0' as 인턴계약직, '0' as 기타 "
|
|
query = query & " from ( "
|
|
query = query & " select d.d_code, ca.user_code, p_sn, cost_code, sum(cost_money) as cost_money "
|
|
query = query & " from cost_account as ca left outer join person as p on ca.user_code = p.p_no "
|
|
query = query & " left outer join Depart as d on p.p_depart = d.d_code "
|
|
query = query & " where job_date > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and job_date < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " AND approval = 'yes' "
|
|
query = query & " and cost_money > 0 "
|
|
query = query & " and p_sn IN ('99999', '9999003','9999004','9999005') "
|
|
query = query & " and d_code = '0' "
|
|
query = query & " group by d.d_code, ca.user_code, cost_code, p_sn "
|
|
query = query & " ) as a "
|
|
query = query & " group by a.d_code, p_sn "
|
|
query = query & " "
|
|
query = query & " union all "
|
|
query = query & " "
|
|
query = query & " select p_depart, p_sn, "
|
|
query = query & " '0' as 일반교통비, '0' as 식대, '0' as 시외출장교통비, '0' as 택배비, '0' as 인쇄비, '0' as 우편발송비, "
|
|
query = query & " sum(convert(numeric(18,2), replace(convert(varchar(15), target6), ',', ''))) as 접대비보고서, '0' as 인지세보증보험, '0' as 인턴계약직, '0' as 기타 "
|
|
query = query & " from 문서내용 as a left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " where 문서제목 in ('접대비보고서') "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and p_sn IN ('99999', '9999003','9999004','9999005') "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " and p_depart = '0' "
|
|
query = query & " group by 문서제목, p_depart, p_sn "
|
|
query = query & " "
|
|
query = query & " union all "
|
|
query = query & " "
|
|
query = query & " select p_depart, replace(p_sn,',','') as p_sn, '0' as 일반교통비, '0' as 식대, '0' as 시외출장교통비, '0' as 택배비 "
|
|
query = query & " , '0' as 인쇄비, '0' as 우편발송비, '0' as 접대비보고서, '0' as 인지세보증보험, '0' as 인턴계약직 "
|
|
query = query & " , sum(convert(numeric(18,2), replace(convert(varchar(15), target5), ',', ''))) as 기타 "
|
|
query = query & " from 문서내용 as a "
|
|
query = query & " left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " where 문서제목 in ('지출결의서') "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " and 문서번호 like '%i%' "
|
|
query = query & " and ( target16 is null or not (target16 like 'research' or target16 like 'field' or target16 like 'support') ) "
|
|
query = query & " and p_sn not like '99999,' "
|
|
query = query & " and p_sn like '999900%' "
|
|
query = query & " group by 문서제목, p_depart, p_sn "
|
|
query = query & " "
|
|
query = query & " union all "
|
|
query = query & " "
|
|
query = query & " select p_depart, p_sn, sum(convert(numeric(18,2), replace(convert(varchar(15), target5), ',', ''))) as 일반교통비, '0' as 식대, '0' as 시외출장교통비, '0' as 택배비 "
|
|
query = query & " , '0' as 인쇄비, '0' as 우편발송비, '0' as 접대비보고서 "
|
|
query = query & " , '0' as 인지세보증보험, "
|
|
query = query & " '0' as 인턴계약직, "
|
|
query = query & " '0' as 기타 "
|
|
query = query & " from ( "
|
|
query = query & " SELECT 문서번호, p_depart, login_p_no, target3, target4, target8, target9, gubun, contents "
|
|
query = query & " , replace(substring(contents, charindex('^^', left(contents, 10))+2, charindex('^//^', contents)-4), '^', '') as p_sn "
|
|
query = query & " , replace(left(substring(contents, charindex('^//^', contents)+4, 20), charindex('^//^', substring(contents, charindex('^//^', contents)+4, 20))-1), ',', '') as target5 "
|
|
query = query & " FROM ( "
|
|
query = query & " select 문서번호, 문서제목, p_depart, login_p_no, target3, target4, target8, target9 "
|
|
query = query & " , convert(varchar(300), target21) as target21 "
|
|
query = query & " , convert(varchar(300), target22) as target22 "
|
|
query = query & " , convert(varchar(300), target23) as target23 "
|
|
query = query & " , convert(varchar(300), target24) as target24 "
|
|
query = query & " , convert(varchar(300), target25) as target25 "
|
|
query = query & " , convert(varchar(300), target26) as target26 "
|
|
query = query & " , convert(varchar(300), target27) as target27 "
|
|
query = query & " , convert(varchar(300), target28) as target28 "
|
|
query = query & " , convert(varchar(300), target29) as target29 "
|
|
query = query & " , convert(varchar(300), target30) as target30 "
|
|
query = query & " , convert(varchar(300), target31) as target31 "
|
|
query = query & " , convert(varchar(300), target32) as target32 "
|
|
query = query & " , convert(varchar(300), target33) as target33 "
|
|
query = query & " , convert(varchar(300), target34) as target34 "
|
|
query = query & " , convert(varchar(300), target35) as target35 "
|
|
query = query & " , convert(varchar(300), target36) as target36 "
|
|
query = query & " , convert(varchar(300), target37) as target37 "
|
|
query = query & " , convert(varchar(300), target38) as target38 "
|
|
query = query & " , convert(varchar(300), target39) as target39 "
|
|
query = query & " , convert(varchar(300), target40) as target40 "
|
|
query = query & " , convert(varchar(300), target41) as target41 "
|
|
query = query & " , convert(varchar(300), target42) as target42 "
|
|
query = query & " , convert(varchar(300), target43) as target43 "
|
|
query = query & " , convert(varchar(300), target44) as target44 "
|
|
query = query & " , convert(varchar(300), target45) as target45 "
|
|
query = query & " , convert(varchar(300), target46) as target46 "
|
|
query = query & " , convert(varchar(300), target47) as target47 "
|
|
query = query & " , convert(varchar(300), target48) as target48 "
|
|
query = query & " , convert(varchar(300), target49) as target49 "
|
|
query = query & " , convert(varchar(300), target50) as target50 "
|
|
query = query & " from 문서내용 as a "
|
|
query = query & " left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " where 문서제목 in ('지출결의서') "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " and 문서번호 like '%A%' "
|
|
query = query & " and not (target16 like 'research' or target16 like 'field' or target16 like 'support') "
|
|
query = query & " and (convert(varchar(10),target11) = '151' and convert(varchar(10),target12) = '123') "
|
|
query = query & " ) AS columnTable "
|
|
query = query & " UNPIVOT "
|
|
query = query & " ( "
|
|
query = query & " contents FOR gubun IN (target21, target22, target23, target24, target25, target26, target27, target28, target29, target30 "
|
|
query = query & " ,target31, target32, target33, target34, target35, target36, target37, target38, target39, target40 "
|
|
query = query & " ,target41, target42, target43, target44, target45, target46, target47, target48, target49, target50) "
|
|
query = query & " ) AS rowTable "
|
|
query = query & " where contents <> '' "
|
|
query = query & " and contents not like '%99999^//^%' "
|
|
query = query & " ) as T "
|
|
query = query & " group by p_depart, p_sn "
|
|
|
|
query = query & " union all "
|
|
query = query & " "
|
|
query = query & " select p_depart, p_sn, '0' as 일반교통비, '0' as 식대, '0' as 시외출장교통비, sum(convert(numeric(18,2), replace(convert(varchar(15), target5), ',', ''))) as 택배비 "
|
|
query = query & " , '0' as 인쇄비, '0' as 우편발송비, '0' as 접대비보고서 "
|
|
query = query & " , '0' as 인지세보증보험, "
|
|
query = query & " '0' as 인턴계약직, "
|
|
query = query & " '0' as 기타 "
|
|
query = query & " from ( "
|
|
query = query & " SELECT 문서번호, p_depart, login_p_no, target3, target4, target8, target9, gubun, contents "
|
|
query = query & " , replace(substring(contents, charindex('^^', left(contents, 10))+2, charindex('^//^', contents)-4), '^', '') as p_sn "
|
|
query = query & " , replace(left(substring(contents, charindex('^//^', contents)+4, 20), charindex('^//^', substring(contents, charindex('^//^', contents)+4, 20))-1), ',', '') as target5 "
|
|
query = query & " FROM ( "
|
|
query = query & " select 문서번호, 문서제목, p_depart, login_p_no, target3, target4, target8, target9 "
|
|
query = query & " , convert(varchar(300), target21) as target21 "
|
|
query = query & " , convert(varchar(300), target22) as target22 "
|
|
query = query & " , convert(varchar(300), target23) as target23 "
|
|
query = query & " , convert(varchar(300), target24) as target24 "
|
|
query = query & " , convert(varchar(300), target25) as target25 "
|
|
query = query & " , convert(varchar(300), target26) as target26 "
|
|
query = query & " , convert(varchar(300), target27) as target27 "
|
|
query = query & " , convert(varchar(300), target28) as target28 "
|
|
query = query & " , convert(varchar(300), target29) as target29 "
|
|
query = query & " , convert(varchar(300), target30) as target30 "
|
|
query = query & " , convert(varchar(300), target31) as target31 "
|
|
query = query & " , convert(varchar(300), target32) as target32 "
|
|
query = query & " , convert(varchar(300), target33) as target33 "
|
|
query = query & " , convert(varchar(300), target34) as target34 "
|
|
query = query & " , convert(varchar(300), target35) as target35 "
|
|
query = query & " , convert(varchar(300), target36) as target36 "
|
|
query = query & " , convert(varchar(300), target37) as target37 "
|
|
query = query & " , convert(varchar(300), target38) as target38 "
|
|
query = query & " , convert(varchar(300), target39) as target39 "
|
|
query = query & " , convert(varchar(300), target40) as target40 "
|
|
query = query & " , convert(varchar(300), target41) as target41 "
|
|
query = query & " , convert(varchar(300), target42) as target42 "
|
|
query = query & " , convert(varchar(300), target43) as target43 "
|
|
query = query & " , convert(varchar(300), target44) as target44 "
|
|
query = query & " , convert(varchar(300), target45) as target45 "
|
|
query = query & " , convert(varchar(300), target46) as target46 "
|
|
query = query & " , convert(varchar(300), target47) as target47 "
|
|
query = query & " , convert(varchar(300), target48) as target48 "
|
|
query = query & " , convert(varchar(300), target49) as target49 "
|
|
query = query & " , convert(varchar(300), target50) as target50 "
|
|
query = query & " from 문서내용 as a "
|
|
query = query & " left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " where 문서제목 in ('지출결의서') "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " and 문서번호 like '%A%' "
|
|
query = query & " and not (target16 like 'research' or target16 like 'field' or target16 like 'support') "
|
|
query = query & " and (convert(varchar(10),target11) = '157' and convert(varchar(10),target12) = '133') "
|
|
query = query & " ) AS columnTable "
|
|
query = query & " UNPIVOT "
|
|
query = query & " ( "
|
|
query = query & " contents FOR gubun IN (target21, target22, target23, target24, target25, target26, target27, target28, target29, target30 "
|
|
query = query & " ,target31, target32, target33, target34, target35, target36, target37, target38, target39, target40 "
|
|
query = query & " ,target41, target42, target43, target44, target45, target46, target47, target48, target49, target50) "
|
|
query = query & " ) AS rowTable "
|
|
query = query & " where contents <> '' "
|
|
query = query & " and contents not like '%99999^//^%' "
|
|
query = query & " ) as T "
|
|
query = query & " group by p_depart, p_sn "
|
|
|
|
query = query & " union all "
|
|
query = query & " "
|
|
query = query & " select p_depart, p_sn, '0' as 일반교통비, '0' as 식대, '0' as 시외출장교통비, '0' as 택배비 "
|
|
query = query & " , sum(convert(numeric(18,2), replace(convert(varchar(15), target5), ',', ''))) as 인쇄비, '0' as 우편발송비, '0' as 접대비보고서 "
|
|
query = query & " , '0' as 인지세보증보험, "
|
|
query = query & " '0' as 인턴계약직, "
|
|
query = query & " '0' as 기타 "
|
|
query = query & " from ( "
|
|
query = query & " SELECT 문서번호, p_depart, login_p_no, target3, target4, target8, target9, gubun, contents "
|
|
query = query & " , replace(substring(contents, charindex('^^', left(contents, 10))+2, charindex('^//^', contents)-4), '^', '') as p_sn "
|
|
query = query & " , replace(left(substring(contents, charindex('^//^', contents)+4, 20), charindex('^//^', substring(contents, charindex('^//^', contents)+4, 20))-1), ',', '') as target5 "
|
|
query = query & " FROM ( "
|
|
query = query & " select 문서번호, 문서제목, p_depart, login_p_no, target3, target4, target8, target9 "
|
|
query = query & " , convert(varchar(300), target21) as target21 "
|
|
query = query & " , convert(varchar(300), target22) as target22 "
|
|
query = query & " , convert(varchar(300), target23) as target23 "
|
|
query = query & " , convert(varchar(300), target24) as target24 "
|
|
query = query & " , convert(varchar(300), target25) as target25 "
|
|
query = query & " , convert(varchar(300), target26) as target26 "
|
|
query = query & " , convert(varchar(300), target27) as target27 "
|
|
query = query & " , convert(varchar(300), target28) as target28 "
|
|
query = query & " , convert(varchar(300), target29) as target29 "
|
|
query = query & " , convert(varchar(300), target30) as target30 "
|
|
query = query & " , convert(varchar(300), target31) as target31 "
|
|
query = query & " , convert(varchar(300), target32) as target32 "
|
|
query = query & " , convert(varchar(300), target33) as target33 "
|
|
query = query & " , convert(varchar(300), target34) as target34 "
|
|
query = query & " , convert(varchar(300), target35) as target35 "
|
|
query = query & " , convert(varchar(300), target36) as target36 "
|
|
query = query & " , convert(varchar(300), target37) as target37 "
|
|
query = query & " , convert(varchar(300), target38) as target38 "
|
|
query = query & " , convert(varchar(300), target39) as target39 "
|
|
query = query & " , convert(varchar(300), target40) as target40 "
|
|
query = query & " , convert(varchar(300), target41) as target41 "
|
|
query = query & " , convert(varchar(300), target42) as target42 "
|
|
query = query & " , convert(varchar(300), target43) as target43 "
|
|
query = query & " , convert(varchar(300), target44) as target44 "
|
|
query = query & " , convert(varchar(300), target45) as target45 "
|
|
query = query & " , convert(varchar(300), target46) as target46 "
|
|
query = query & " , convert(varchar(300), target47) as target47 "
|
|
query = query & " , convert(varchar(300), target48) as target48 "
|
|
query = query & " , convert(varchar(300), target49) as target49 "
|
|
query = query & " , convert(varchar(300), target50) as target50 "
|
|
query = query & " from 문서내용 as a "
|
|
query = query & " left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " where 문서제목 in ('지출결의서') "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " and 문서번호 like '%A%' "
|
|
query = query & " and not (target16 like 'research' or target16 like 'field' or target16 like 'support') "
|
|
query = query & " and ((convert(varchar(10),target11) = '159' and convert(varchar(10),target12) = '135') "
|
|
query = query & " or (convert(varchar(10),target11) = '162' and convert(varchar(10),target12) = '142' and target8 like '%아이프린트%')) "
|
|
query = query & " ) AS columnTable "
|
|
query = query & " UNPIVOT "
|
|
query = query & " ( "
|
|
query = query & " contents FOR gubun IN (target21, target22, target23, target24, target25, target26, target27, target28, target29, target30 "
|
|
query = query & " ,target31, target32, target33, target34, target35, target36, target37, target38, target39, target40 "
|
|
query = query & " ,target41, target42, target43, target44, target45, target46, target47, target48, target49, target50) "
|
|
query = query & " ) AS rowTable "
|
|
query = query & " where contents <> '' "
|
|
query = query & " and contents not like '%99999^//^%' "
|
|
query = query & " ) as T "
|
|
query = query & " group by p_depart, p_sn "
|
|
|
|
query = query & " union all "
|
|
|
|
query = query & " "
|
|
query = query & " select p_depart, p_sn, '0' as 일반교통비, '0' as 식대, '0' as 시외출장교통비, '0' as 택배비 "
|
|
query = query & " , '0' as 인쇄비, sum(convert(numeric(18,2), replace(convert(varchar(15), target5), ',', ''))) as 우편발송비, '0' as 접대비보고서 "
|
|
query = query & " , '0' as 인지세보증보험, "
|
|
query = query & " '0' as 인턴계약직, "
|
|
query = query & " '0' as 기타 "
|
|
query = query & " from ( "
|
|
query = query & " SELECT 문서번호, p_depart, login_p_no, target3, target4, target8, target9, gubun, contents "
|
|
query = query & " , replace(substring(contents, charindex('^^', left(contents, 10))+2, charindex('^//^', contents)-4), '^', '') as p_sn "
|
|
query = query & " , replace(left(substring(contents, charindex('^//^', contents)+4, 20), charindex('^//^', substring(contents, charindex('^//^', contents)+4, 20))-1), ',', '') as target5 "
|
|
query = query & " FROM ( "
|
|
query = query & " select 문서번호, 문서제목, p_depart, login_p_no, target3, target4, target8, target9 "
|
|
query = query & " , convert(varchar(300), target21) as target21 "
|
|
query = query & " , convert(varchar(300), target22) as target22 "
|
|
query = query & " , convert(varchar(300), target23) as target23 "
|
|
query = query & " , convert(varchar(300), target24) as target24 "
|
|
query = query & " , convert(varchar(300), target25) as target25 "
|
|
query = query & " , convert(varchar(300), target26) as target26 "
|
|
query = query & " , convert(varchar(300), target27) as target27 "
|
|
query = query & " , convert(varchar(300), target28) as target28 "
|
|
query = query & " , convert(varchar(300), target29) as target29 "
|
|
query = query & " , convert(varchar(300), target30) as target30 "
|
|
query = query & " , convert(varchar(300), target31) as target31 "
|
|
query = query & " , convert(varchar(300), target32) as target32 "
|
|
query = query & " , convert(varchar(300), target33) as target33 "
|
|
query = query & " , convert(varchar(300), target34) as target34 "
|
|
query = query & " , convert(varchar(300), target35) as target35 "
|
|
query = query & " , convert(varchar(300), target36) as target36 "
|
|
query = query & " , convert(varchar(300), target37) as target37 "
|
|
query = query & " , convert(varchar(300), target38) as target38 "
|
|
query = query & " , convert(varchar(300), target39) as target39 "
|
|
query = query & " , convert(varchar(300), target40) as target40 "
|
|
query = query & " , convert(varchar(300), target41) as target41 "
|
|
query = query & " , convert(varchar(300), target42) as target42 "
|
|
query = query & " , convert(varchar(300), target43) as target43 "
|
|
query = query & " , convert(varchar(300), target44) as target44 "
|
|
query = query & " , convert(varchar(300), target45) as target45 "
|
|
query = query & " , convert(varchar(300), target46) as target46 "
|
|
query = query & " , convert(varchar(300), target47) as target47 "
|
|
query = query & " , convert(varchar(300), target48) as target48 "
|
|
query = query & " , convert(varchar(300), target49) as target49 "
|
|
query = query & " , convert(varchar(300), target50) as target50 "
|
|
query = query & " from 문서내용 as a "
|
|
query = query & " left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " where 문서제목 in ('지출결의서') "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " and 문서번호 like '%A%' "
|
|
query = query & " and not (target16 like 'research' or target16 like 'field' or target16 like 'support') "
|
|
query = query & " and (convert(varchar(10),target11) = '152' and convert(varchar(10),target12) = '125') "
|
|
query = query & " ) AS columnTable "
|
|
query = query & " UNPIVOT "
|
|
query = query & " ( "
|
|
query = query & " contents FOR gubun IN (target21, target22, target23, target24, target25, target26, target27, target28, target29, target30 "
|
|
query = query & " ,target31, target32, target33, target34, target35, target36, target37, target38, target39, target40 "
|
|
query = query & " ,target41, target42, target43, target44, target45, target46, target47, target48, target49, target50) "
|
|
query = query & " ) AS rowTable "
|
|
query = query & " where contents <> '' "
|
|
query = query & " and contents not like '%99999^//^%' "
|
|
query = query & " ) as T "
|
|
query = query & " group by p_depart, p_sn "
|
|
|
|
query = query & " union all "
|
|
query = query & " "
|
|
query = query & " select p_depart, p_sn, '0' as 일반교통비, '0' as 식대, '0' as 시외출장교통비, '0' as 택배비 "
|
|
query = query & " , '0' as 인쇄비, '0' as 우편발송비, '0' as 접대비보고서 "
|
|
query = query & " , sum(convert(numeric(18,2), replace(convert(varchar(15), case when ((target11 like '154' and target12 like '129') or (target11 like '156' and target12 like '132')) then target5 else '0' end), ',', ''))) as 인지세보증보험, "
|
|
query = query & " sum(convert(numeric(18,2), replace(convert(varchar(15), case when ((target11 like '148' and target12 like '114') or (target11 like '162' and target12 like '142')) then target5 else '0' end), ',', ''))) as 인턴계약직, "
|
|
query = query & " sum(convert(numeric(18,2), replace(convert(varchar(15), case when (target11 not like '148' and target12 not like '114') and (target11 not like '162' and target12 not like '142') and (target11 not like '154' and target12 not like '129') and (target11 not like '156' and target12 not like '132') then target5 else '0' end), ',', ''))) as 기타 "
|
|
query = query & " from ( "
|
|
query = query & " SELECT 문서번호, p_depart, login_p_no, target3, target4, target8, target9, target11, target12, gubun, contents "
|
|
query = query & " , replace(substring(contents, charindex('^^', left(contents, 10))+2, charindex('^//^', contents)-4), '^', '') as p_sn "
|
|
query = query & " , replace(left(substring(contents, charindex('^//^', contents)+4, 20), charindex('^//^', substring(contents, charindex('^//^', contents)+4, 20))-1), ',', '') as target5 "
|
|
query = query & " FROM ( "
|
|
query = query & " select 문서번호, 문서제목, p_depart, login_p_no, target3, target4, target8, target9, target11, target12 "
|
|
query = query & " , convert(varchar(300), target21) as target21 "
|
|
query = query & " , convert(varchar(300), target22) as target22 "
|
|
query = query & " , convert(varchar(300), target23) as target23 "
|
|
query = query & " , convert(varchar(300), target24) as target24 "
|
|
query = query & " , convert(varchar(300), target25) as target25 "
|
|
query = query & " , convert(varchar(300), target26) as target26 "
|
|
query = query & " , convert(varchar(300), target27) as target27 "
|
|
query = query & " , convert(varchar(300), target28) as target28 "
|
|
query = query & " , convert(varchar(300), target29) as target29 "
|
|
query = query & " , convert(varchar(300), target30) as target30 "
|
|
query = query & " , convert(varchar(300), target31) as target31 "
|
|
query = query & " , convert(varchar(300), target32) as target32 "
|
|
query = query & " , convert(varchar(300), target33) as target33 "
|
|
query = query & " , convert(varchar(300), target34) as target34 "
|
|
query = query & " , convert(varchar(300), target35) as target35 "
|
|
query = query & " , convert(varchar(300), target36) as target36 "
|
|
query = query & " , convert(varchar(300), target37) as target37 "
|
|
query = query & " , convert(varchar(300), target38) as target38 "
|
|
query = query & " , convert(varchar(300), target39) as target39 "
|
|
query = query & " , convert(varchar(300), target40) as target40 "
|
|
query = query & " , convert(varchar(300), target41) as target41 "
|
|
query = query & " , convert(varchar(300), target42) as target42 "
|
|
query = query & " , convert(varchar(300), target43) as target43 "
|
|
query = query & " , convert(varchar(300), target44) as target44 "
|
|
query = query & " , convert(varchar(300), target45) as target45 "
|
|
query = query & " , convert(varchar(300), target46) as target46 "
|
|
query = query & " , convert(varchar(300), target47) as target47 "
|
|
query = query & " , convert(varchar(300), target48) as target48 "
|
|
query = query & " , convert(varchar(300), target49) as target49 "
|
|
query = query & " , convert(varchar(300), target50) as target50 "
|
|
query = query & " from 문서내용 as a "
|
|
query = query & " left outer join person as p on a.login_p_no = p.p_no "
|
|
query = query & " where 문서제목 in ('지출결의서') "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " and del_yes_no = 'no' "
|
|
query = query & " and 문서번호 like '%A%' "
|
|
query = query & " and not (target16 like 'research' or target16 like 'field' or target16 like 'support') "
|
|
query = query & " and not (convert(varchar(10),target11) = '152' and convert(varchar(10),target12) = '125') "
|
|
query = query & " and not (convert(varchar(10),target11) = '151' and convert(varchar(10),target12) = '123') "
|
|
query = query & " and not (convert(varchar(10),target11) = '157' and convert(varchar(10),target12) = '133') "
|
|
query = query & " and not ((convert(varchar(10),target11) = '159' and convert(varchar(10),target12) = '135') "
|
|
query = query & " or (convert(varchar(10),target11) = '162' and convert(varchar(10),target12) = '142' and target8 like '%아이프린트%')) "
|
|
query = query & " ) AS columnTable "
|
|
query = query & " UNPIVOT "
|
|
query = query & " ( "
|
|
query = query & " contents FOR gubun IN (target21, target22, target23, target24, target25, target26, target27, target28, target29, target30 "
|
|
query = query & " ,target31, target32, target33, target34, target35, target36, target37, target38, target39, target40 "
|
|
query = query & " ,target41, target42, target43, target44, target45, target46, target47, target48, target49, target50) "
|
|
query = query & " ) AS rowTable "
|
|
query = query & " where contents <> '' "
|
|
query = query & " and contents not like '%99999^//^%' "
|
|
query = query & " ) as T "
|
|
query = query & " group by p_depart, p_sn "
|
|
query = query & " union all "
|
|
query = query & " select replace(substring(p_sn,6,2),',','') as p_depart, p_sn "
|
|
query = query & " , '0' as 식대, '0' as 일반교통비, '0' as 시외출장교통비, '0' as 택배비, '0' as 인쇄비, '0' as 우편발송비, '0' as 접대비보고서, '0' as 인지세보증보험, '0' as 인턴계약직, "
|
|
query = query & " sum(convert(numeric(18,2), use_cost)) as 기타 "
|
|
query = query & " from "
|
|
query = query & " ( "
|
|
query = query & " SELECT p_depart as p_sn, target3, use_cost, d_name, target20 FROM "
|
|
query = query & " ( "
|
|
query = query & " SELECT D.d_no, D.d_name, '99990' + case when depart_cd = '41' then '03' when depart_cd = '42' then '04' when depart_cd = '43' then '05' else depart_cd end as p_depart, dbo.split(contents,'^^',1) as target3, convert(money, dbo.split(contents,'^^',4)) as use_cost, target20 FROM "
|
|
query = query & " ( "
|
|
query = query & " SELECT 문서번호, contents, depart_cd, target20, target97 "
|
|
query = query & " FROM "
|
|
query = query & " ( "
|
|
query = query & " select 문서번호, 문서제목, convert(varchar(300), target20) as target20, convert(varchar(2), target21) as depart_cd, convert(varchar(300), target97) as target97, "
|
|
query = query & " convert(varchar(300), target1) as target1, convert(varchar(300), target2) as target2, "
|
|
query = query & " convert(varchar(300), target3) as target3, convert(varchar(300), target4) as target4, "
|
|
query = query & " convert(varchar(300), target5) as target5, convert(varchar(300), target6) as target6, "
|
|
query = query & " convert(varchar(300), target7) as target7, convert(varchar(300), target8) as target8, "
|
|
query = query & " convert(varchar(300), target9) as target9, convert(varchar(300), target10) as target10, "
|
|
query = query & " convert(varchar(300), target11) as target11, convert(varchar(300), target12) as target12, "
|
|
query = query & " convert(varchar(300), target13) as target13, convert(varchar(300), target14) as target14 "
|
|
query = query & " from 문서내용 "
|
|
query = query & " where 문서제목 = '부서비신청서' and del_yes_no = 'no' "
|
|
query = query & " ) AS columnTable "
|
|
query = query & " UNPIVOT "
|
|
query = query & " ( "
|
|
query = query & " contents FOR gubun IN (target1, target2, target3, target4, target5, target6, target7, target8, target9, target10, target11, target12, target13, target14) "
|
|
query = query & " ) AS rowTable "
|
|
query = query & " where isnull(contents, '') <> '' "
|
|
query = query & " ) M Left outer join Document D On M.문서번호 = D.d_no "
|
|
query = query & " WHERE isnull(D.d_order_cnt, '99') <> '99' "
|
|
query = query & " ) T "
|
|
query = query & " WHERE target3 > '2015-12-31' "
|
|
query = query & " and convert(varchar(10),target3) > '" & CStr(CInt(tmp_year)-1) & "-12-31' "
|
|
query = query & " and convert(varchar(10),target3) < '" & CStr(CInt(tmp_year)+1) & "-01-01' "
|
|
query = query & " ) as T "
|
|
query = query & " group by replace(substring(p_sn,6,2),',',''), p_sn, left(convert(varchar(20),target3),7) "
|
|
query = query & " ) T "
|
|
query = query & " where (p_sn like '9999003' or p_sn like '9999004' or p_sn like '9999005') "
|
|
query = query & " group by p_sn "
|
|
|
|
'Response.Write query & "<br>"
|
|
|
|
adors.Open query, adoconn,adOpenStatic,adLockReadOnly
|
|
|
|
|
|
sum_meal = 0
|
|
sum_nomal_traffic = 0
|
|
sum_outside_traffic = 0
|
|
sum_delivery = 0
|
|
sum_print = 0
|
|
sum_post = 0
|
|
sum_expence = 0
|
|
sum_entertain = 0
|
|
sum_common_cost = 0
|
|
sum_insurance_cost = 0
|
|
sum_intern_cost = 0
|
|
sum_all = 0
|
|
|
|
if adors.RecordCount > 0 then
|
|
%>
|
|
<table width="100%" cellpadding="3" cellspacing="0" border="0" style="border-collapse:collapse;<% if command <> "view" then %>display:none<% end if%>">
|
|
<%
|
|
rowIndex = 0
|
|
for i=1 to adors.RecordCount
|
|
rowIndex = rowIndex + 1
|
|
IF rowIndex mod 2 Then
|
|
list_bgcolor="#dbe9f2"
|
|
Else
|
|
list_bgcolor="#FFFFFF"
|
|
End If
|
|
%>
|
|
<tr bgcolor="<%=list_bgcolor%>">
|
|
<td width="7%" class="tahoma" align="center"><%=adors("부서")%></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("식대") ,0)%></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("일반교통비") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("시외출장교통비") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("택배비") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("인쇄비") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("우편발송비") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("접대비보고서") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("인지세보증보험") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("인턴계약직") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("기타") ,0) %></td>
|
|
<td width="7%" class="tahoma" align="right"><%=formatNumber(adors("행합계") ,0) %></td>
|
|
</tr>
|
|
<%
|
|
sum_meal = sum_meal + cDbl(adors("식대"))
|
|
sum_nomal_traffic = sum_nomal_traffic + cDbl(adors("일반교통비"))
|
|
sum_outside_traffic = sum_outside_traffic + cDbl(adors("시외출장교통비"))
|
|
sum_delivery = sum_delivery + cDbl(adors("택배비"))
|
|
sum_print = sum_print + cDbl(adors("인쇄비"))
|
|
sum_post = sum_post + cDbl(adors("우편발송비"))
|
|
sum_entertain = sum_entertain + CDbl(adors("접대비보고서"))
|
|
sum_common_cost = sum_common_cost + CDbl(adors("기타"))
|
|
sum_insurance_cost = sum_insurance_cost + CDbl(adors("인지세보증보험"))
|
|
sum_intern_cost = sum_intern_cost + CDbl(adors("인턴계약직"))
|
|
sum_all = sum_all + CDbl(adors("행합계"))
|
|
|
|
adors.movenext
|
|
next%>
|
|
<%
|
|
rowIndex = rowIndex + 1
|
|
IF rowIndex mod 2 Then
|
|
list_bgcolor="#dbe9f2"
|
|
Else
|
|
list_bgcolor="#FFFFFF"
|
|
End If
|
|
%>
|
|
<tr bgcolor="#F7F2E0" style="border-top:1px solid gray;">
|
|
<td width="7%" class="tahoma" align="center" style="font-weight:bold;">합 계</td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_meal,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_nomal_traffic,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_outside_traffic,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_delivery,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_print,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_post,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_entertain,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_insurance_cost,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_intern_cost,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_common_cost,0) %></td>
|
|
<td width="7%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_all,0) %></td>
|
|
</tr>
|
|
</table>
|
|
-->
|
|
<%end if' if adors.RecordCount > 0 then
|
|
adors.Close
|
|
%>
|
|
|
|
</td>
|
|
</tr>
|
|
<!-------------------6. 본부별 공통경비 내역 종료------------------------------------------------------------------------------------------------------------------------------------------------------>
|
|
<% End If %>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
</td>
|
|
|
|
</form>
|
|
|
|
<%
|
|
|
|
|
|
%>
|
|
|
|
|
|
|
|
<script language="javascript" >
|
|
|
|
function goView(command) {
|
|
var tmp_year = document.team_project_count.tmp_year.value;
|
|
|
|
var url = "";
|
|
|
|
if(tmp_year == "2014"){
|
|
url = "team_project_count_CEO_2014.asp?tmp_year=" + tmp_year;
|
|
}else{
|
|
url = "team_project_count_CEO.asp?tmp_year=" + tmp_year;
|
|
}
|
|
|
|
url = url + "&command=" + command;
|
|
//eval("document.all.menuf.src = url;");
|
|
//alert(url);
|
|
document.team_project_count.action = url;
|
|
document.team_project_count.submit();
|
|
}
|
|
|
|
function detailView(depart){
|
|
var tmp_year = document.team_project_count.tmp_year.value;
|
|
var tmp_month = "0";
|
|
var p_depart = depart;
|
|
|
|
var url = "team_project_popup.asp?tmp_year=" + tmp_year + "&tmp_month=" + tmp_month + "&p_depart="+p_depart;
|
|
url = url + "&command=" + "popup";
|
|
|
|
window.open(url,"","left=50 ,top=0, menubar=no, location=no ,status=no ,toolbar=no ,width=950, height=650 ,scrollbars=yes ,resizable=yes");
|
|
}
|
|
|
|
function pageMove(command) {
|
|
var tmp_year = document.team_project_count.tmp_year.value;
|
|
//var tmp_month = document.team_project_count.tmp_month.value;
|
|
//var p_depart = document.team_project_count.p_depart.value;
|
|
|
|
var url = "team_project_count.asp?tmp_year=&tmp_month=&p_depart=";
|
|
//alert(url);
|
|
document.team_project_count.action = url;
|
|
document.team_project_count.submit();
|
|
}
|
|
</script>
|
|
|
|
<%if command <> "excel" then%>
|
|
<!-- #include file = "../include/foot.asp" -->
|
|
<%end if%>
|
|
|
|
<%
|
|
|
|
Function Hd_chk(depart_code)
|
|
query = " SELECT Convert(varchar(5), hd_cd) +'_'+ hd_name as hd_str FROM team_group WHERE RIGHT(team_cd, 2) = '" & Right(Trim(depart_code), 2) & "' "
|
|
rsc.Open query, adoconn,adOpenStatic,adLockReadOnly
|
|
tmp_hd_str = ""
|
|
if rsc.RecordCount > 0 then
|
|
tmp_hd_str = rsc("hd_str")
|
|
end if
|
|
rsc.close
|
|
Hd_chk = tmp_hd_str
|
|
End Function
|
|
%>
|
|
|
|
|
|
|