1283 lines
88 KiB
Plaintext
1283 lines
88 KiB
Plaintext
<%
|
|
command = request("command")
|
|
tmp_year = request("tmp_year")
|
|
tmp_month = request("tmp_month")
|
|
p_depart = request("p_depart")
|
|
|
|
Dim teamPlace, team_depart
|
|
teamPlace = session("teamplace")
|
|
team_depart = session("depart_code")
|
|
|
|
if tmp_year = "" then
|
|
tmp_year = "0000"
|
|
end if
|
|
|
|
if tmp_month = "" then
|
|
tmp_month = 0
|
|
end if
|
|
if p_depart = "" then
|
|
p_depart = session("depart_Code")
|
|
end If
|
|
|
|
sql = ""
|
|
sql = sql & " SELECT DISTINCT before_t_cd1 as d_code, LEFT(T_Name, 8) as d_name "
|
|
sql = sql & " FROM project2.dbo.v_Department "
|
|
sql = sql & " WHERE (before_t_cd1 in (12, 17, 90) or before_t_cd1 between 20 and 90) " '//-- 2020-10-15 11:47:44
|
|
sql = sql & " order by LEFT(T_Name, 8)"
|
|
|
|
'response.write sql
|
|
|
|
Rs.open sql, adoconn,adopenstatic, adlockreadonly
|
|
krc_team_cnt = Rs.recordcount
|
|
redim krc_team(krc_team_cnt,2)
|
|
krc_team_cnt = 0
|
|
do while not Rs.eof
|
|
krc_team_cnt = krc_team_cnt + 1
|
|
krc_team(krc_team_cnt,1) = rs("d_code")
|
|
krc_team(krc_team_cnt,2) = rs("d_name")
|
|
Rs.movenext
|
|
loop
|
|
Rs.close
|
|
%>
|
|
<!-- < !-- #include virtual = "statistics/inc_team_project.asp" -- > -->
|
|
|
|
<!-- #include virtual = "statistics/inc_team_project_next.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" and command <> "popup" 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">
|
|
<select name=tmp_year>
|
|
<%
|
|
Dim temp_minus_yyyy
|
|
temp_minus_yyyy = 0
|
|
%>
|
|
<%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>
|
|
|
|
조사시작월
|
|
<select name=tmp_month>
|
|
<OPTION value='0'>전체</OPTION>
|
|
<% for i=1 to 12%>
|
|
<OPTION value='<%=zeroFormat(i,2)%>' <%if cint(i) = cint(tmp_month) then%> selected <%end if%>><%=i%>월</OPTION>
|
|
<%next%>
|
|
</select>
|
|
|
|
팀
|
|
<%
|
|
query = ""
|
|
query = query & " SELECT DISTINCT before_t_cd1 as d_code, LEFT(T_Name, 8) as d_name "
|
|
query = query & " FROM project2.dbo.v_Department "
|
|
query = query & " WHERE (before_t_cd1 in (12, 17, 90) or before_t_cd1 between 20 and 90) " '//-- 2020-10-15 11:48:33
|
|
query = query & " order by LEFT(T_Name, 8)"
|
|
adors.Open query, adoconn,adOpenStatic,adLockReadOnly
|
|
%>
|
|
<select name=p_depart>
|
|
<%if session("Depart_Code") = "18" or session("Depart_Code") = "0" then %>
|
|
<!--<OPTION value='0'>전체</OPTION>-->
|
|
<%end if%>
|
|
<%for i=1 to adors.recordcount %>
|
|
<%if cint(p_depart) = cint(adors("d_code")) or session("Depart_Code") = "18" or session("Depart_Code") = "0" then%>
|
|
<OPTION value='<%=adors("d_code")%>' <% if cint(p_depart) = cint(adors("d_code")) then %> selected <% End if %>><%=adors("d_name")%></OPTION>
|
|
<%end if%>
|
|
<%
|
|
adors.movenext
|
|
next%>
|
|
</select>
|
|
<% adors.close %>
|
|
<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;'>
|
|
|
|
<% If teamPlace > 4 or session("Depart_Code") = "18" Then %>
|
|
<input type="button" name="" value="전체실적 페이지 이동" onclick="javascript:pageMove('view');"/>
|
|
<% End If %>
|
|
</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" <% If teamPlace < 4 And team_depart >= 20 Then %> style="display:none;" <% End If %>>부서</td>
|
|
<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 & " CASE WHEN substring(p_decide_date, 3,2) = '" & cstr(cint(RIGHT(tmp_year, 2)) - 1) & "' THEN '"& cstr(cint(tmp_year) - 1) &"년 이월' ELSE '20' + substring(p_decide_date, 3,2) + '-' + substring(p_decide_date, 6,2) END as p_date, "&VbCrlf
|
|
'''query = query & " CASE WHEN LEFT(p_sn, 2) = '" & cstr(cint(RIGHT(tmp_year, 2)) - 1) & "' THEN '"& cstr(cint(tmp_year) - 1) &"년 이월' ELSE '20' + SUBSTRING(p_sn, 1,2) + '-' + SUBSTRING(p_sn, 3,2) END as p_date, "&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
|
|
query = query & " case when LEFT(p_sn, 2) = '" &RIGHT(tmp_year, 2)-1& "' Then case when p_total_cost='0' Then SUM(p_cont_cost) else p_total_cost end else p_total_cost end as p_total_cost "&VbCrlf '##### 이월 프로젝트의 수주실적 총 합계 -> 0원이면 수주실적 = 수행실적 (2018-10-24)
|
|
'query = query & " p_total_cost, "&VbCrlf
|
|
query = query & " , p_decide_date "&VbCrlf
|
|
query = query & " , weeknum "&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 #statistics_next "&VbCrlf
|
|
'query = query & " WHERE p_statistics = '" & tmp_year & "' "
|
|
query = query & " WHERE 1=1 "&VbCrlf
|
|
|
|
if tmp_month <> "0" then
|
|
if tmp_month = "01" then
|
|
query = query & " AND substring(p_decide_date, 1,4) <= '" & tmp_year &"-"& tmp_month & "' "&VbCrlf
|
|
else
|
|
query = query & " AND substring(p_decide_date, 1,4) = '" & tmp_year &"-"& tmp_month & "' "&VbCrlf
|
|
end if
|
|
else
|
|
query = query & " AND ( substring(p_decide_date, 1,4) = '" & tmp_year & "' OR ( substring(p_decide_date, 1,4) = '" & tmp_year - 1 & "' AND p_statistics = '" & tmp_year & "')) "&VbCrlf
|
|
end if
|
|
|
|
'if tmp_month <> "0" then
|
|
' if tmp_month = "01" then
|
|
' query = query & " AND substring(p_sn, 1,4) <= '" & right(tmp_year, 2) & tmp_month & "' "&VbCrlf
|
|
' else
|
|
' query = query & " AND substring(p_sn, 1,4) = '" & right(tmp_year, 2) & tmp_month & "' "&VbCrlf
|
|
' end if
|
|
'else
|
|
' query = query & " AND (substring(p_sn, 1,2) = '" & right(tmp_year, 2) & "' OR (substring(p_sn, 1,2) = '" & right(tmp_year, 2) - 1 & "' AND p_statistics = '" & tmp_year & "')) "&VbCrlf
|
|
'end if
|
|
|
|
|
|
if p_depart <> "0" then
|
|
query = query & " AND (hd_cd = '"& p_depart &"' or team_cd = '"& p_depart &"') "&VbCrlf
|
|
end if
|
|
query = query & " GROUP BY team_name, team_cd, p_sn, p_total_cost, p_decide_date, weeknum "&VbCrlf
|
|
query = query & " ) T "&VbCrlf
|
|
query = query & " GROUP BY team_name, team_cd "&VbCrlf
|
|
query = query & " , CASE WHEN substring(p_decide_date, 3,2) = '" & cstr(cint(RIGHT(tmp_year, 2)) - 1) & "' THEN '"& cstr(cint(tmp_year) - 1) &"년 이월' ELSE '20' + substring(p_decide_date, 3,2) + '-' + substring(p_decide_date, 6,2) END "&VbCrlf
|
|
''query = query & " , CASE WHEN LEFT(p_sn, 2) = '" & cstr(cint(RIGHT(tmp_year, 2)) - 1) & "' THEN '"& cstr(cint(tmp_year) - 1) &"년 이월' ELSE '20' + SUBSTRING(p_sn, 1,2) + '-' + SUBSTRING(p_sn, 3,2) END "&VbCrlf
|
|
query = query & " ORDER BY team_name "&VbCrlf
|
|
query = query & " , CASE WHEN substring(p_decide_date, 3,2) = '" & cstr(cint(RIGHT(tmp_year, 2)) - 1) & "' THEN '"& cstr(cint(tmp_year) - 1) &"년 이월' ELSE '20' + substring(p_decide_date, 3,2) + '-' + substring(p_decide_date, 6,2) END "&VbCrlf
|
|
''query = query & " , CASE WHEN LEFT(p_sn, 2) = '" & cstr(cint(RIGHT(tmp_year, 2)) - 1) & "' THEN '"& cstr(cint(tmp_year) - 1) &"년 이월' ELSE '20' + SUBSTRING(p_sn, 1,2) + '-' + SUBSTRING(p_sn, 3,2) END "&VbCrlf
|
|
|
|
'Response.Write query & "<br>"
|
|
adminView("<br>1. 계약실적 쿼리문<br>")
|
|
adminView(query)
|
|
|
|
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;">
|
|
<%
|
|
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" <% If teamPlace < 4 And team_depart >= 20 Then %> style="display:none;" <% End If %>><%=adors("team_name")%></td>
|
|
<td width="13%" class="tahoma" align="center"><a href="javascript:detailView('<%=adors("p_date")%>', '<%=adors("team_cd")%>', 1, '<%=tmp_year%>')"><%=adors("p_date") %></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
|
|
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" colspan="<% If teamPlace < 4 And team_depart >= 20 Then %> 1 <% Else %> 2 <% End If %>" 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
|
|
End if
|
|
%>
|
|
|
|
</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" <% If teamPlace < 4 And team_depart >= 20 Then %> style="display:none;" <% End If %>>부서</td>
|
|
<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 & " CASE WHEN LEFT(p_sn, 2) = '" & cstr(cint(RIGHT(tmp_year, 2)) - 1) & "' THEN '"& cstr(cint(tmp_year) - 1) &"년 이월' ELSE '20' + SUBSTRING(p_sn, 1,2) + '-' + SUBSTRING(p_sn, 3,2) END as p_date, "
|
|
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_next "
|
|
'query = query & " WHERE p_statistics = '" & tmp_year & "' "
|
|
query = query & " WHERE 1=1 "
|
|
if tmp_month <> "0" then
|
|
if tmp_month = "01" then
|
|
query = query & " AND substring(p_sn, 1,4) <= '" & right(tmp_year, 2) & tmp_month & "' "
|
|
else
|
|
query = query & " AND substring(p_sn, 1,4) = '" & right(tmp_year, 2) & tmp_month & "' "
|
|
end if
|
|
else
|
|
query = query & " AND (substring(p_sn, 1,2) = '" & right(tmp_year, 2) & "' OR (substring(p_sn, 1,2) = '" & right(tmp_year, 2) - 1 & "' AND p_statistics = '" & tmp_year & "')) "
|
|
end if
|
|
if p_depart <> "0" then
|
|
query = query & " AND (hd_cd = '"& p_depart &"' or team_cd = '"& p_depart &"') "
|
|
end if
|
|
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 진행 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
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 & " GROUP BY team_name, team_cd, "
|
|
query = query & " CASE WHEN LEFT(p_sn, 2) = '" & cstr(cint(RIGHT(tmp_year, 2)) - 1) & "' THEN '"& cstr(cint(tmp_year) - 1) &"년 이월' ELSE '20' + SUBSTRING(p_sn, 1,2) + '-' + SUBSTRING(p_sn, 3,2) END "
|
|
query = query & " ORDER BY team_name, CASE WHEN LEFT(p_sn, 2) = '" & cstr(cint(RIGHT(tmp_year, 2)) - 1) & "' THEN '"& cstr(cint(tmp_year) - 1) &"년 이월' ELSE '20' + SUBSTRING(p_sn, 1,2) + '-' + SUBSTRING(p_sn, 3,2) END "
|
|
|
|
'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" <% If teamPlace < 4 And team_depart >= 20 Then %> style="display:none;" <% End If %>><%=adors("team_name")%></td>
|
|
<td width="13%" class="tahoma" align="center"><a href="javascript:detailView('<%=adors("p_date")%>', '<%=p_depart%>', 2, '<%=tmp_year%>')"><%=adors("p_date") %></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
|
|
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" colspan="<% If teamPlace < 4 And team_depart >= 20 Then %> 1 <% Else %> 2 <% End If %>" 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" <% If teamPlace < 4 And team_depart >= 20 Then %> style="display:none;" <% End If %>>부서</td>
|
|
<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 & " CASE WHEN LEFT(p_con_date_end, 4) = '" & cstr(cint(tmp_year) - 1) & "' THEN '"& cstr(cint(tmp_year) - 1) &"년 이월' ELSE p_con_date_end END as p_date, "
|
|
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_next "
|
|
query = query & " WHERE p_statistics = '" & tmp_year & "' "
|
|
if tmp_month <> "0" then
|
|
if tmp_month = "01" then
|
|
query = query & " AND LEFT(p_con_date_end, 7) <= '" & tmp_year & "-" & tmp_month & "' "
|
|
else
|
|
query = query & " AND LEFT(p_con_date_end, 7) = '" & tmp_year & "-" & tmp_month & "' "
|
|
end if
|
|
end if
|
|
if p_depart <> "0" then
|
|
query = query & " AND (hd_cd = '"& p_depart &"' or team_cd = '"& p_depart &"') "
|
|
end if
|
|
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 종료 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
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 & " GROUP BY team_name, team_cd, "
|
|
query = query & " CASE WHEN LEFT(p_con_date_end, 4) = '" & cstr(cint(tmp_year) - 1) & "' THEN '"& cstr(cint(tmp_year) - 1) &"년 이월' ELSE p_con_date_end END "
|
|
query = query & " ORDER BY team_name, CASE WHEN LEFT(p_con_date_end, 4) = '" & cstr(cint(tmp_year) - 1) & "' THEN '"& cstr(cint(tmp_year) - 1) &"년 이월' ELSE p_con_date_end END "
|
|
'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" <% If teamPlace < 4 And team_depart >= 20 Then %> style="display:none;" <% End If %>><%=adors("team_name")%></td>
|
|
<td width="13%" class="tahoma" align="center"><a href="javascript:detailView('<%=adors("p_date")%>', '<%=p_depart%>', 3, '<%=tmp_year%>')"><%=adors("p_date") %></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
|
|
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" colspan="<% If teamPlace < 4 And team_depart >= 20 Then %> 1 <% Else %> 2 <% End If %>" 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="9%" align="center" <% If teamPlace < 4 And team_depart >= 20 Then %> style="display:none;" <% End If %>>부서</td>
|
|
<td width="9%" align="center" >날짜</td>
|
|
<td width="9%" align="right" >식대</td>
|
|
<td width="9%" align="right" >일반교통비</td>
|
|
<td width="9%" align="right" >시외출장교통비</td>
|
|
<td width="9%" align="right" >택배비</td>
|
|
<td width="9%" align="right" >인쇄비</td>
|
|
<td width="9%" align="right" >우편발송비</td>
|
|
<td width="9%" align="right" >접대비보고서</td>
|
|
<%if tmp_year = "2016" and p_depart = "90" then ' 20대 총선 비용%>
|
|
<td width="9%" align="right" >총선기타비</td>
|
|
<%end if%>
|
|
<td width="9%" align="right" >합계</td>
|
|
</tr>
|
|
</table>
|
|
<% '4. 부서 공통경비내역 쿼리문
|
|
query = " select (select Top 1 T_name from V_Department as d where TT.depart = d.before_t_cd1) 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 & " isnull(SUM(일반교통비),0) as 일반교통비, isnull(SUM(식대),0) as 식대, isnull(SUM(시외출장교통비),0) as 시외출장교통비, "
|
|
query = query & " isnull(SUM(택배비),0) as 택배비, isnull(SUM(인쇄비),0) as 인쇄비, isnull(SUM(우편발송비),0) as 우편발송비, "
|
|
query = query & " isnull(SUM(총선기타비),0) as 총선기타비, isnull(SUM(접대비보고서),0) as 접대비보고서, "
|
|
query = query & " isnull(SUM(일반교통비)+SUM(식대)+SUM(시외출장교통비)+SUM(택배비)+SUM(인쇄비)+SUM(우편발송비)+SUM(총선기타비)+SUM(접대비보고서),0) 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 document d on a.문서번호 = d.d_no "
|
|
query = query & " left outer join V_PROJECT as vp on left(a.p_sn,7) = vp.p_sn "
|
|
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') "
|
|
if p_depart <> "0" then
|
|
query = query & " and isnull(vp.p_depart_dep, d_code) = '"&p_depart&"' "
|
|
end if
|
|
if tmp_month <> "0" then
|
|
if tmp_month = "01" then
|
|
query = query & " AND '20'+left(T.p_sn,2)+'-'+SUBSTRING(T.p_sn,3,2) <= '" & tmp_year & "-" & tmp_month & "' "
|
|
else
|
|
query = query & " AND '20'+left(T.p_sn,2)+'-'+SUBSTRING(T.p_sn,3,2) = '" & tmp_year & "-" & tmp_month & "' "
|
|
end if
|
|
end if
|
|
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 & " 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_all = 0
|
|
sum_etc = 0
|
|
|
|
if adors.RecordCount > 0 then
|
|
%>
|
|
<table width="100%" cellpadding="3" cellspacing="0" border="0" style="border-collapse:collapse;<% if command = "" then%> display:none; <% end if%> ">
|
|
<!-- loop start -->
|
|
<%
|
|
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="9%" class="tahoma" align="center" <% If teamPlace < 4 And team_depart >= 20 Then %> style="display:none;" <% End If %>><%=adors("부서")%></td>
|
|
<td width="9%" class="tahoma" align="center"><%=adors("날짜")%></td>
|
|
<td width="9%" class="tahoma" align="right"><%=formatNumber(adors("식대") ,0) %></td>
|
|
<td width="9%" class="tahoma" align="right"><%=formatNumber(adors("일반교통비") ,0) %></td>
|
|
<td width="9%" class="tahoma" align="right"><%=formatNumber(adors("시외출장교통비") ,0) %></td>
|
|
<td width="9%" class="tahoma" align="right"><%=formatNumber(adors("택배비") ,0) %></td>
|
|
<td width="9%" class="tahoma" align="right"><%=formatNumber(adors("인쇄비") ,0) %></td>
|
|
<td width="9%" class="tahoma" align="right"><%=formatNumber(adors("우편발송비") ,0) %></td>
|
|
<td width="9%" class="tahoma" align="right"><%=formatNumber(adors("접대비보고서") ,0) %></td>
|
|
<%if tmp_year = "2016" and p_depart = "90" then ' 20대 총선 비용%>
|
|
<td width="9%" class="tahoma" align="right"><%=formatNumber(adors("총선기타비") ,0) %></td>
|
|
<%end if %>
|
|
<td width="9%" 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_all = sum_all + CDbl(adors("행합계"))
|
|
sum_etc = sum_etc + CDbl(adors("총선기타비"))
|
|
adors.movenext
|
|
next%>
|
|
<!-- loop end -->
|
|
<%
|
|
rowIndex = rowIndex + 1
|
|
IF rowIndex mod 2 Then
|
|
list_bgcolor="#dbe9f2"
|
|
Else
|
|
list_bgcolor="#FFFFFF"
|
|
End If
|
|
%>
|
|
<tr bgcolor="<%=list_bgcolor%>">
|
|
<td width="9%" class="tahoma" align="center" colspan="<% If teamPlace < 4 And team_depart >= 20 Then %> 1 <% Else %> 2 <% End If %>" style="font-weight:bold;">합 계</td>
|
|
<td width="9%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_meal,0) %></td>
|
|
<td width="9%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_nomal_traffic,0) %></td>
|
|
<td width="9%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_outside_traffic,0) %></td>
|
|
<td width="9%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_delivery,0) %></td>
|
|
<td width="9%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_print,0) %></td>
|
|
<td width="9%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_post,0) %></td>
|
|
<td width="9%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_entertain,0) %></td>
|
|
<%if tmp_year = "2016" and p_depart = "90" then ' 20대 총선 비용%>
|
|
<td width="9%" class="tahoma" align="right" style="font-weight:bold;"><%=formatNumber(sum_etc,0) %></td>
|
|
<%end if %>
|
|
<td width="9%" 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" <% If teamPlace < 4 And team_depart >= 20 Then %> style="display:none;" <% End If %>>부서</td>
|
|
<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 job_date as '날짜', right(replace(rtrim(p_sn),',',''),2) as p_sn, "
|
|
query = query & " CASE "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '31' then 'P1' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '32' then 'P2' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '33' then 'P4' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '35' then 'M4' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '36' then 'M1' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '37' then 'M3' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '38' then 'M5' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '39' then 'M2' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '30' then 'P3' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '34' then 'KRC' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '51' then 'M6' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '21' then 'C1' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '52' then 'P5' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '53' then 'AC' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '54' then 'P6' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '55' then '비즈니스프로모터' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '61' then 'PSBU1' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '62' then 'PSBU2' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '63' then 'PSBU3' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '71' then 'MSBU1' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '72' then 'MSBU2' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '73' then 'MSBU3' "
|
|
query = query & " WHEN right(replace(rtrim(p_sn),',',''), 2) = '74' 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 ('9','10','19','21','28','99') then cost_money else 0 end ),0) as '식대', "
|
|
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 ('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 CASE WHEN right(p_sn,2) >= 20 and right(p_sn,2) < 40 then right(p_sn,2) else p_depart end as 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 문서제목, CASE WHEN right(p_sn,2) >= 20 and right(p_sn,2) < 40 then right(p_sn,2) else p_depart end, 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, "
|
|
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), 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 & " '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 & " '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 & " select replace(substring(p_sn,6,2),',','') as 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 우편발송비, '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 "
|
|
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, target20, depart_cd, 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 replace(p_sn,',','') not in ('0','9999','99999','9999003','9999004','9999005','9999012','9999017','9999018') "
|
|
query = query & " and left(job_date,4) = '"&tmp_year&"' "
|
|
if tmp_month <> "0" then
|
|
query = query & " and RIGHT(job_date,2) = '"&tmp_month&"' "
|
|
end if
|
|
if p_depart <> "0" then
|
|
query = query & " and right(replace(rtrim(p_sn),',',''),2) = '"&p_depart&"' "
|
|
End if
|
|
query = query & " group by right(replace(rtrim(p_sn),',',''),2), job_date "
|
|
query = query & " order by p_sn "
|
|
|
|
'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;">
|
|
<!-- loop start -->
|
|
<%
|
|
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" <% If teamPlace < 4 And team_depart >= 20 Then %> style="display:none;" <% End If %>><%=adors("부서")%></td>
|
|
<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%>
|
|
<!-- loop end -->
|
|
<%
|
|
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" colspan="<% If teamPlace < 4 And team_depart >= 20 Then %> 1 <% Else %> 2 <% End If %>" 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. 부서별 일반비용 내역 종료------------------------------------------------------------------------------------------------------------------------------------------------------>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
|
|
|
|
</form>
|
|
<%
|
|
|
|
%> |