Files
KIN/approval/doc_myun_pay_detail.asp
2025-09-29 17:55:08 +09:00

462 lines
24 KiB
Plaintext

<!-- #include virtual = "lib/config.asp" -->
<%
Response.CharSet = "EUC-KR" '한글
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "cache-control", "no-staff"
Response.Expires = -1
dim tmpstr
dim Query
dim i
dim user_name(4) '현재 사용자,0:사원코드, 1:이름,2:직급,3:전화번호, 4:부서코드(명)
dim Max_Width
dim title
dim target_name '발급대상자 이름
dim Curr_date '오늘날짜
dim Company(6)
dim Gap(10) '1:프로젝트 코드, 2:지출(입금)목적, 3:지출(입금)일자, 4:지출(입금)방법, 5:공급가액, 6:부가세액, 7:총액, 8:거래처, 9:프로젝트 코드, 10:품의서 문서번호
dim krc_no
dim db_table_name
dim approval_chk
dim title_type
db_table_name = "문서내용"
approval_chk = "true"
p_child_sn = request("p_child_sn")
pay_type = request("pay_type")
cost_type = request("cost_type")
work_month = request("work_month")
sv = request("sv")
krc_no = request("krc_no")
work_kind = unescape(request("work_kind"))
If pay_type = 1 Then
title="내근직 세부내용 및 예상누계"
title2 = "내근직별 세부지출결의비용"
Else
title="면접원 세부내용 및 예상누계"
End if
d_no = request("d_no")
query = "SELECT * "
query = query & " FROM 문서내용 as a "
query = query & " INNER JOIN Document as b on a.문서번호 = b.d_no "
query = query & " WHERE a.문서번호='" & d_no & "' "
query = query & " AND b.d_delok = 'N' "
rsc.Open query, adoConn, 1
if rsc.RecordCount > 0 Then
If rsc("문서제목") = "내근직수당지출결의서" Then
pay_type = "1"
Else
pay_type = "2"
End If
startDT = rsc("target10")
endDT = rsc("target11")
overMoney_reason = rsc("target17")
End if
title_type = mid(replace(title," ",""), 1, 7)
Max_Width =750
Curr_date = year(date) & "년 " & zeroformat(month(date),2) & "월 " & zeroformat(day(date),2) & "일"
set rsm = server.CreateObject("ADODB.RECORDSET")
''//===============
''회사 회사명, 사업자등록번호, 대표자명, 주소 가져오기
Query = "select * from company"
adoRs.open Query, adoconn,adopenstatic, adlockreadonly
Company(1) = adors("com_name")
Company(2) = adors("사업자등록번호")
Company(3) = adors("대표자명")
Company(4) = adors("주소")
Company(5) = adors("법인등록번호")
Company(6) = adors("회사대표전화번호")
adoRs.close
''///===============
''로그인 사용자 정보
'user_name(0) = Session("User_Number")
user_name(0) = Session("User_Number")
Query = "SELECT p_name, p_team_name, p_rank_name, p_tel3 FROM project2.dbo.V_Person WHERE p_no = '" & user_name(0) & "'"
adoRs.open Query, adoconn,adopenstatic, adlockreadonly
user_name(1) = adoRs("p_name") '이름
user_name(2) = adoRs("p_rank_name") '직위 코드
user_name(3) = adoRs("p_tel3") '직통 전화
user_name(4) = adoRs("p_team_name") '부서코드
adoRs.close
''////////========================
''값가져오기
gap(1) = request("txt_prj_name")
gap(2) = request("txt_pay_target")
gap(3) = request("txt_date")
gap(4) = request("sel_pay_type")
gap(5) = request("txt_pay")
gap(6) = request("txt_pay_vat")
gap(7) = request("txt_pay_tot")
gap(8) = request("txt_client")
gap(9) = request("txt_p_sn")
gap(10) = request("txt_d_no")
%>
<script language="javascript">
function win_close()
{
window.close();
}
function menuChange(menuNum) {
if (menuNum == "1") {
document.getElementById("menu1").style.color = "#0000FF";
document.getElementById("menu1").style.backgroundColor = "#F7D172";
document.getElementById("table1").style.display = "";
document.getElementById("menu2").style.color = "#3030FF";
document.getElementById("menu2").style.backgroundColor = "#EEEEEE";
document.getElementById("table2").style.display = "none";
} else {
document.getElementById("menu1").style.color = "#3030FF";
document.getElementById("menu1").style.backgroundColor = "#EEEEEE";
document.getElementById("table1").style.display = "none";
document.getElementById("menu2").style.color = "#0000FF";
document.getElementById("menu2").style.backgroundColor = "#F7D172";
document.getElementById("table2").style.display = "";
}
}
function super_detail(index, n_name, n_jumin, s_gubun) {
var krc_no = "<%=krc_no %>"
var work_month = "<%=work_month %>"
var p_child_sn = "<%=p_child_sn %>"
var sv = "<%=sv %>"
var param = {
krc_no : "<%=krc_no %>",
work_month: "<%=work_month %>",
p_child_sn : "<%=p_child_sn %>",
sv : "<%=sv %>",
n_name : n_name,
n_jumin : n_jumin,
s_gubun: s_gubun
};
if ($("#superdetail_" + index).html() == "") {
ajaxCallJson("../approval/doc_myun_pay_detail_ajax.asp", param, null, "post", "detail_view('" + index + "')");
} else {
$("#arrow_under_" + index).css("display", "");
$("#arrow_up_" + index).css("display", "none");
$("#superdetail_" + index).html("");
}
}
function detail_view(index){
$("#superdetail_" + index).append(ajaxResponse);
$("#arrow_under_" + index).css("display", "none");
$("#arrow_up_" + index).css("display", "");
}
</script>
<body topmargin="10" leftmargin="10">
<form method='post' name='frm_money'>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><img src="/images/approval/docbg_top.jpg"></td>
</tr>
<tr>
<td width="720" align="center" style="padding:10;border-left:1px solid #dedede;border-right:1px solid #dedede;">
<table width="98%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td colspan="2" style="padding:0 0 10 0">
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;">
<tr>
<td width="50%" align="left">
<div id="menu1" align="center" onclick="menuChange('1')" style="background-color:#F7D172;width:100%;height:30px;vertical-align:middle;line-height:30px;cursor:pointer;color:#0000FF;font-size:15px;"><b><%=title%> 내역</b></div>
</td>
<td width="50%" align="right">
<div id="menu2" align="center" onclick="menuChange('2')" style="background-color:#EEEEEE;width:100%;height:30px;vertical-align:middle;line-height:30px;cursor:pointer;color:#3030FF;font-size:15px;"><b><%=title2%> 내역</b></div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" bgcolor="#d8d8d8" height="1"></td>
</tr>
<tr>
<td colspan="2" bgcolor="#d8d8d8" height="2"></td>
</tr>
<%
Dim pay_apply_username
pay_apply_username = ""
set adors2 = server.CreateObject("ADODB.RECORDSET")
query = "select p_name from person where p_no = '" & sv & "' "
adors2.open query, adoconn, adopenstatic, adlockreadonly
If adors2.recordCount > 0 Then
pay_apply_username = adors2("p_name")
End If
adors2.close
%>
<tr>
<td colspan="2" align="center" style="padding:10 0 0 0">
<table width="100%" cellpadding="5" cellspacing="0" border="0" style="border-collapse:collapse;">
<tr>
<td width="17%" class="tit2" align="center">수당 결재 기간</td>
<td width="24%" class="tit7" align="center"><font class="tahoma"><%
if work_month = "2022-04" Then
Response.Write work_month & "-01 ~ " & work_month & "-25"
elseif work_month > "2022-04" Then
Response.Write DATEADD("m",-1,cdate(work_month & "-26")) & " ~ " & work_month & "-25"
else
Response.Write work_month
end if
%></font></td>
<td width="17%" class="tit2" align="center">수당 담당자</td>
<td width="42%" class="tit7" align="center"><font class="tahoma"><%=pay_apply_username%></font></td>
</tr>
<tr>
<td width="17%" class="tit2" align="center">프로젝트코드</td>
<td width="24%" class="tit7" align="center"><font class="tahoma"><%=p_child_sn%></font></td>
<td width="17%" class="tit2" align="center">프로젝트 명</td>
<%
Query = " select p_sn, p_child_sn, p_subject from v_project_method "
Query = Query & " where p_child_sn = '" & p_child_sn & "' "
'Response.Write query & "<BR>"
adoRs.open Query, adoconn,adopenstatic, adlockreadonly
Dim tmp_p_subject
tmp_p_subject = ""
if adoRs.recordcount > 0 Then
tmp_p_subject = adoRs("p_subject")
End If
adoRs.close
%>
<td width="42%" class="tit7" align="center"><font class="tahoma"><%=tmp_p_subject%></font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" align="center" style="padding:10 0 0 0">
<table width="100%" id="table1" cellpadding="5" cellspacing="0" border="0" style="border-collapse:collapse;">
<tr>
<td width="20%" class="tit2" align="center">비용세부항목</td>
<td width="20%" class="tit2" align="center">세부지출결의비용</td>
<td width="20%" class="tit2" align="center">예상직접비</td>
<td width="20%" class="tit2" align="center">누적비용(결재중 포함)</td>
<td width="20%" class="tit2" align="center">예상잔액</td>
</tr>
<%
Query = " select p_child_sn, sebu, sum(est_money) as est_money, sum(accumulate_pay) as accumulate_pay, sum(pay) as pay, sum(food_pay) as food_pay "
Query = Query & " from ( "
Query = Query & " select p_child_sn, sebu, convert(numeric(18,0), est_money) as est_money, 0 as accumulate_pay, 0 as pay, 0 as food_pay "
Query = Query & " from ( "
Query = Query & " select * from direct_cost where left(p_sn, 2) >= '14' and hangmok = '49' and del_yes_no = 'no' and sebu != '해독원' "
Query = Query & " union all "
Query = Query & " select * from direct_cost where left(p_sn, 2) >= '14' and hangmok in ('감청','검증','에디팅','컨택','코더','펀칭','AS비용') and del_yes_no='no' "
Query = Query & " ) as T1 "
Query = Query & " where p_child_sn = '" & p_child_sn & "' "
Query = Query & " union all "
Query = Query & " select p_sn as p_child_sn, case when left(s_gubun, 2) = '추가' then "
Query = Query & " (select top 1 s_gubun from t_neakeun_pay where attribute01 = a.attribute01 and left(s_gubun, 2) <> '추가') +'_'+ s_gubun "
Query = Query & " else s_gubun end as sebu, 0 as est_money, isnull(s_sum, 0) as accumulate_pay, 0 as pay, "
Query = Query & " case when left(s_gubun, 2) <> '추가' then "
Query = Query & " ISNULL((select sum(s_sum) from t_neakeun_pay where attribute01 = a.attribute01 and left(s_gubun, 2) = '추가'),0) "
Query = Query & " else 0 end as food_pay "
Query = Query & " from t_neakeun_pay a "
Query = Query & " where pay_type = 1 and isnull(attribute05,'') <> '' and p_sn = '" & p_child_sn & "' "
Query = Query & " union all "
Query = Query & " select a.p_sn as p_child_sn, case when left(s_gubun, 2) = '추가' then "
Query = Query & " (select top 1 s_gubun from t_neakeun_pay where attribute01 = a.attribute01 and left(s_gubun, 2) <> '추가') +'_'+ s_gubun "
Query = Query & " else s_gubun end as sebu, 0 as est_money, 0 as accumulate_pay, isnull(a.s_sum, 0) as pay, 0 as food_pay "
Query = Query & " from t_neakeun_pay a left outer join neakeun_work nw on a.attribute01 = nw.id "
Query = Query & " where attribute01 in ( "
Query = Query & " select attribute01 from t_neakeun_pay np left join neakeun_work w on np.attribute01 = w.id "
Query = Query & " where pay_type = 1 and isnull(a.attribute05,'') = '" & krc_no & "' "
if work_month = "2022-04" Then
Query = Query & " and ((work_dt between '" & work_month & "-01' and '" & work_month & "-25' AND W.in_time + W.out_time + W.p_sebu_code <> '000000004') OR "
Query = Query & " (work_dt between '" & work_month & "-16' and cast(DATEADD(m,1,cast('" & work_month & "-05' as date)) as varchar) "
elseif work_month > "2022-04" Then
Query = Query & " and ((work_dt between cast(DATEADD(m,-1,cast('" & work_month & "-26' as date))as varchar) and '" & work_month & "-25' AND W.in_time + W.out_time + W.p_sebu_code <> '000000004') OR "
Query = Query & " (work_dt between '" & work_month & "-06' and cast(DATEADD(m,1,cast('" & work_month & "-05' as date)) as varchar) "
else
Query = Query & " and ((LEFT(work_dt, 7) = '" & work_month & "' AND W.in_time + W.out_time + W.p_sebu_code <> '000000004') OR "
Query = Query & " (work_dt between '" & work_month & "-16' and cast(DATEADD(m,1,cast('" & work_month & "-15' as date)) as varchar) "
end if
Query = Query & " AND W.in_time + W.out_time + W.p_sebu_code = '000000004')) "
Query = Query & " and a.p_sn = '" & p_child_sn & "' and nw.p_sv_no = '" & sv & "' and s_gubun = '" & work_kind & "') "
Query = Query & " ) as T2 "
Query = Query & " group by p_child_sn, sebu "
Query = Query & " order by sebu "
'Response.Write query & "<BR>"
adoRs.open Query, adoconn,adopenstatic, adlockreadonly
Dim total_estimate_money, total_currentMoney, total_Pay, total_chaPay
total_estimate_money = 0
total_currentMoney = 0
total_Pay = 0
total_chaPay = 0
Dim minus_money_flag, dataCount
dataCount = 0
if adoRs.recordcount > 0 Then
dataCount = adoRs.recordcount
do while not adoRs.eof
%>
<tr>
<td align="center" class="tit7"><font class="tahoma"><%=adoRs("sebu")%></font></td>
<td align="right" class="tit7"><font class="tahoma"><%=FormatNumber(CDbl(adoRs("pay")), 0)%></font></td>
<td align="right" class="tit7"><font class="tahoma"><%if instr(1,adoRs("sebu"),"_") = false then %><%=FormatNumber(CDbl(adoRs("est_money")), 0)%><%end if %></font></td>
<td align="right" class="tit7"><font class="tahoma"><%=FormatNumber(CDbl(adoRs("accumulate_pay")), 0)%></font></td>
<td align="right" class="tit7">
<% chaPay = CDbl(adoRs("est_money")) - CDbl(adoRs("accumulate_pay")) - CDbl(adoRs("food_pay")) %>
<font class="tahoma" <% if CDbl(chaPay) < 0 then %> color="red" <% end if %>><%if instr(1,adoRs("sebu"),"_") = false then %><%=FormatNumber(CDbl(chaPay), 0)%><%end if %></font></td>
<%
total_estimate_money = total_estimate_money + CDbl(adoRs("est_money"))
total_currentMoney = total_currentMoney + CDbl(adoRs("accumulate_pay"))
total_Pay = total_Pay + CDbl(adoRs("pay"))
if instr(1,adoRs("sebu"),"_") = false then
total_chaPay = total_chaPay + CDbl(chaPay)
end if
%>
</tr>
<%
adoRs.movenext
loop
end if
adoRs.close
%>
<tr>
<td align="center" class="tit2"><font class="tahoma">합계</font></td>
<td align="right" class="tit2"><font class="tahoma"><%=FormatNumber(total_Pay, 0)%></font></td>
<td align="right" class="tit2"><font class="tahoma"><%=FormatNumber(total_estimate_money, 0)%></font></td>
<td align="right" class="tit2"><font class="tahoma"><%=FormatNumber(total_currentMoney, 0)%></font></td>
<td align="right" class="tit2"><font class="tahoma"><%=FormatNumber(total_chaPay, 0)%></font></td>
</tr>
<tr>
<td align="right" colspan="5"><font class="tahoma" color="red">결재 상신 전에는 예상 잔액이 다르게 보일 수 있습니다.</font></td>
</tr>
</table>
<table width="100%" id="table2" cellpadding="5" cellspacing="0" border="0" style="border-collapse:collapse;display:none;">
<tr>
<td width="15%" class="tit2" align="center">내근직성명</td>
<td width="15%" class="tit2" align="center">생년월일</td>
<td width="14%" class="tit2" align="center">업무</td>
<td width="14%" class="tit2" align="center">수당</td>
<td width="14%" class="tit2" align="center">추가수당1</td>
<td width="14%" class="tit2" align="center">추가수당2</td>
<td width="14%" class="tit2" align="center">합계</td>
</tr>
<%
Query = ""
Query = Query & " SELECT m_name, m_jumin, s_gubun, SUM(s_sum) as s_sum, SUM(add_1) as add_1, SUM(add_2) as add_2 FROM "&VbCrlf
Query = Query & " ( "&VbCrlf
Query = Query & " select a.m_name, a.m_jumin, s_gubun, s_sum, "&VbCrlf
Query = Query & " isnull((select s_sum from t_neakeun_pay where attribute01 = a.attribute01 and s_gubun = '추가수당1'), 0) as add_1, "&VbCrlf
Query = Query & " isnull((select s_sum from t_neakeun_pay where attribute01 = a.attribute01 and s_gubun = '추가수당2'), 0) as add_2 "&VbCrlf
Query = Query & " from t_neakeun_pay a "&VbCrlf
Query = Query & " left outer join neakeun_work nw on a.attribute01 = nw.id "&VbCrlf
Query = Query & " where pay_type = 1 and isnull(a.attribute05,'') = '" & krc_no & "' "
if work_month = "2022-04" Then
Query = Query & " and ((work_dt between '" & work_month & "-01' and '" & work_month & "-25' AND NW.in_time + NW.out_time + NW.p_sebu_code <> '000000004') OR "
Query = Query & " (work_dt between '" & work_month & "-16' and cast(DATEADD(m,1,cast('" & work_month & "-05' as date)) as varchar) "
elseif work_month > "2022-04" Then
Query = Query & " and ((work_dt between cast(DATEADD(m,-1,cast('" & work_month & "-26' as date))as varchar) and '" & work_month & "-25' AND NW.in_time + NW.out_time + NW.p_sebu_code <> '000000004') OR "
Query = Query & " (work_dt between '" & work_month & "-06' and cast(DATEADD(m,1,cast('" & work_month & "-05' as date)) as varchar) "
else
Query = Query & " and ((LEFT(work_dt, 7) = '" & work_month & "' AND NW.in_time + NW.out_time + NW.p_sebu_code <> '000000004') OR "
Query = Query & " (work_dt between '" & work_month & "-16' and cast(DATEADD(m,1,cast('" & work_month & "-15' as date)) as varchar) "
end if
Query = Query & " AND NW.in_time + NW.out_time + NW.p_sebu_code = '000000004')) "
Query = Query & " and a.p_sn = '" & p_child_sn & "' and p_sv_no = '" & sv & "' "&VbCrlf
Query = Query & " and left(s_gubun, 2) <> '추가' and s_gubun = '" & work_kind & "' "&VbCrlf
Query = Query & " ) T "&VbCrlf
Query = Query & " group by m_name, m_jumin, s_gubun "&VbCrlf
Query = Query & " Order by m_name "&VbCrlf
'Response.Write query & "<BR>"
adoRs.open Query, adoconn,adopenstatic, adlockreadonly
Dim s_sum_sum, add_1_sum, add_2_sum
if adoRs.recordcount > 0 Then
do while not adoRs.eof
%>
<tr>
<td align="center" class="tit7"><font class="tahoma">
<a href="javascript:super_detail('<%=adoRs.AbsolutePosition %>', '<%=escape(adoRs("m_name"))%>', '<%=left(adoRs("m_jumin"), 6)%>', '<%=escape(adoRs("s_gubun"))%>');">
<span id="arrow_under_<%=adoRs.AbsolutePosition %>">▼</span><span id="arrow_up_<%=adoRs.AbsolutePosition %>" style="display:none;">▲</span><%=adoRs("m_name")%></a></font></td>
<td align="center" class="tit7"><font class="tahoma"><%=left(adoRs("m_jumin"), 6)%></font></td>
<td align="center" class="tit7"><font class="tahoma"><%=adoRs("s_gubun")%></font></td>
<td align="right" class="tit7"><font class="tahoma"><%=FormatNumber(CDbl(adoRs("s_sum")), 0)%></font></td>
<td align="right" class="tit7"><font class="tahoma"><%=FormatNumber(CDbl(adoRs("add_1")), 0)%></font></td>
<td align="right" class="tit7"><font class="tahoma"><%=FormatNumber(CDbl(adoRs("add_2")), 0)%></font></td>
<td align="right" class="tit7"><font class="tahoma"><%=FormatNumber(CDbl(adoRs("s_sum")) + CDbl(adoRs("add_1")) + CDbl(adoRs("add_2")), 0)%></font></td>
<%
s_sum_sum = s_sum_sum + CDbl(adoRs("s_sum"))
add_1_sum = add_1_sum + CDbl(adoRs("add_1"))
add_2_sum = add_2_sum + CDbl(adoRs("add_2"))
%>
</tr>
<tr>
<td colspan="7" style="margin: 0 0 0 0; padding: 0 0 0 0;"><div id="superdetail_<%=adoRs.AbsolutePosition %>" style="margin: 0 0 0 0; padding: 0 0 0 0;"></div></td>
</tr>
<%
adoRs.movenext
loop
end if
adoRs.close
%>
<tr>
<td align="center" class="tit2" colspan="3"><font class="tahoma">합계</font></td>
<td align="right" class="tit2"><font class="tahoma"><%=FormatNumber(s_sum_sum, 0)%></font></td>
<td align="right" class="tit2"><font class="tahoma"><%=FormatNumber(add_1_sum, 0)%></font></td>
<td align="right" class="tit2"><font class="tahoma"><%=FormatNumber(add_2_sum, 0)%></font></td>
<td align="right" class="tit2"><font class="tahoma"><%=FormatNumber(s_sum_sum + add_1_sum + add_2_sum, 0)%></font></td>
</tr>
<tr>
<td align="right" colspan="7"><font class="tahoma" color="red">결재 상신 전에는 예상 잔액이 다르게 보일 수 있습니다.</font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" align="center" style="padding:15 0 5 0"><!-- #include virtual= "approval/inc_logo.asp" --></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><img src="/images/approval/docbg_btm.jpg"></td>
</tr>
</table>
</form>
</body>