270 lines
17 KiB
Plaintext
270 lines
17 KiB
Plaintext
<!-- #include virtual = "include/header.asp" -->
|
|
<%
|
|
dim command
|
|
command = Request("command")
|
|
if command <> "excel" then
|
|
%>
|
|
<!-- #include virtual = "include/left.asp" -->
|
|
<!-- Content Wrapper. Contains page content -->
|
|
<div class="content-wrapper">
|
|
<!-- Content Header (Page header) -->
|
|
<div class="content-header">
|
|
<h1>업무일지 비용집계</h1>
|
|
</div>
|
|
<!-- /.content-header -->
|
|
<!-- Main content -->
|
|
<div class="content-body">
|
|
<div class="content">
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<%
|
|
end if
|
|
|
|
job_month = Request("job_month")
|
|
search_kind = Request("search_kind")
|
|
|
|
if command = "excel" Then
|
|
Response.CacheControl = "public"
|
|
Response.ContentType = "application/vnd.ms-excel"
|
|
Response.AddHeader "Content-Disposition","attachment;filename=업무일지비용정산_" & job_month & "_" & search_kind & ".xls"
|
|
end if
|
|
%>
|
|
<script>
|
|
function search(command) {
|
|
var url = "";
|
|
var job_month = document.job_cost_total.job_month.value;
|
|
var search_kind = "";
|
|
if (document.job_cost_total.search_kind[0].checked == true) {
|
|
search_kind = "project";
|
|
} else {
|
|
search_kind = "personal";
|
|
}
|
|
if (job_month == "") {
|
|
alert("날짜를 선택하세요.");
|
|
} else {
|
|
url = "job_cost_total.asp?command=" + command + "&job_month=" + job_month + "&search_kind=" + search_kind;
|
|
document.job_cost_total.action = url;
|
|
document.job_cost_total.submit();
|
|
}
|
|
}
|
|
|
|
window.onload = function () {
|
|
if ("<%= search_kind%>" != "personal") {
|
|
document.getElementById("i_project").checked = true;
|
|
} else {
|
|
document.getElementById("i_personal").checked = true;
|
|
}
|
|
}
|
|
</script>
|
|
<form name="job_cost_total" method="post" >
|
|
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
|
<%if command <> "excel" then%>
|
|
<tr>
|
|
<td style="padding:10 0 0 0;">
|
|
<table style='width:1000px' class="table table-sm table-sm2 table-bordered table-head tr-colors" >
|
|
<tr>
|
|
<td align="center" >일 자</td>
|
|
<td align="left" >
|
|
<select name="job_month" style="width:100px;">
|
|
<option value=""> 선 택 </option>
|
|
<%
|
|
For i=0 To 24
|
|
%>
|
|
<option value="<%=LEFT(DateAdd("m", i*(-1), date), 7) %>" <%if job_month = LEFT(DateAdd("m", i*(-1), date), 7) then %> selected <% end if %>><%=LEFT(DateAdd("m", i*(-1), date), 7) %></option>
|
|
<%
|
|
Next
|
|
%>
|
|
</select>
|
|
</td>
|
|
<td align="center" >집계방법</td>
|
|
<td align="center" >
|
|
<input type="radio" name="search_kind" id="i_project" value="project"/> <label for="i_project" class='mb-0 mr-2'>프로젝트별</label>
|
|
<input type="radio" name="search_kind" id="i_personal" value="personal" /> <label for="i_personal" class='mb-0'>개인별</label>
|
|
</td>
|
|
<td align="right">
|
|
<button type="button" class='btn btn-sm btn-primary' onclick='search("view");'>조회</button>
|
|
<button type="button" class='btn btn-sm btn-success' onclick='search("excel");'>Excel</button>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
<% end if %>
|
|
<% if command <> "" then %>
|
|
<tr>
|
|
<td style="padding:10 0 0 0;">
|
|
<table style='width:1000px' class="table table-sm table-sm2 table-bordered table-head tr-colors">
|
|
<%
|
|
If search_kind = "project" Then
|
|
query = ""
|
|
query = query & " SELECT job_date, p_sn, p_subject, cost_name, sum(cost_money) AS cost_money "
|
|
query = query & " FROM "
|
|
query = query & " ( "
|
|
query = query & " SELECT P.p_team_name, P.p_name, T.p_no, LEFT(job_date, 7) AS job_date, "
|
|
query = query & " ISNULL(VPM.p_subject, ( "
|
|
query = query & " CASE P.p_depart_now "
|
|
query = query & " WHEN 'E' THEN p_name + ' 공통경비' "
|
|
query = query & " WHEN 'R' THEN P.p_team_name + ' 공통경비' "
|
|
query = query & " WHEN 'F' THEN P.p_team_name + ' 공통경비' "
|
|
query = query & " ELSE '일반/행정' END)) AS p_subject, "
|
|
query = query & " CASE T.p_sn "
|
|
query = query & " WHEN '99999' THEN "
|
|
query = query & " CASE P.p_depart_now "
|
|
query = query & " WHEN 'R' THEN '99990' + CONVERT(varchar, P.p_depart) "
|
|
query = query & " WHEN 'F' THEN '99990' + CONVERT(varchar, P.p_depart) "
|
|
query = query & " WHEN 'E' THEN p_name "
|
|
query = query & " ELSE '99999' END "
|
|
query = query & " ELSE T.p_sn END AS p_sn, "
|
|
query = query & " T.cost_code, CC.cost_name, cost_money "
|
|
query = query & " FROM V_BUSI_COST T LEFT JOIN V_PROJECT_METHOD VPM ON T.p_sn = VPM.p_child_sn "
|
|
query = query & " LEFT JOIN cost_category CC ON T.cost_code = CC.cost_code "
|
|
query = query & " LEFT JOIN ( "
|
|
query = query & " SELECT P.p_no, P.p_name, P.p_depart_now, before_info AS p_depart, D.T_Name AS p_team_name, "
|
|
query = query & " ISNULL((SELECT TOP 1 change_date FROM Person_Log WHERE p_no = P.p_no AND info_name = 'depart' AND change_date < PL.change_date ORDER BY change_date DESC), krc_in_date) AS log_st, CONVERT(varchar(10), DATEADD(DAY, -1, change_date), 120) AS log_en "
|
|
query = query & " FROM v_Person P "
|
|
query = query & " LEFT JOIN Person_Log PL ON P.p_no = PL.p_no AND PL.info_name = 'depart' AND PL.after_info <> '' "
|
|
query = query & " LEFT JOIN v_Department D ON PL.before_info = D.before_t_cd1 "
|
|
query = query & " WHERE before_info IS NOT NULL "
|
|
query = query & " UNION ALL "
|
|
query = query & " SELECT p_no, p_name, p_depart_now, p_depart, p_team_name, "
|
|
query = query & " ISNULL((SELECT TOP 1 change_date FROM Person_Log WHERE p_no = P.p_no AND info_name = 'depart' ORDER BY change_date DESC), krc_in_date) AS log_st, '2099-12-31' AS log_en "
|
|
query = query & " FROM v_Person P "
|
|
query = query & " ) P ON T.p_no = P.p_no AND T.job_date BETWEEN P.log_st AND P.log_en "
|
|
query = query & " WHERE job_date LIKE '" & job_month & "%' "
|
|
query = query & " ) T "
|
|
query = query & " GROUP BY job_date, p_sn, p_subject, cost_name "
|
|
'Response.write query
|
|
Adors.open query, adoconn, adopenstatic, adlockreadonly
|
|
|
|
if Adors.RecordCount > 0 Then
|
|
sum_money = 0
|
|
%>
|
|
<tr height=30>
|
|
<td align="center" style="width:7%;">년월</td>
|
|
<td align="center" style="width:13%;">프로젝트코드</td>
|
|
<td align="center" style="width:50%;">프로젝트명</td>
|
|
<td align="center" style="width:23%">비용항목</td>
|
|
<td align="center" style="width:7%">금액</td>
|
|
</tr>
|
|
<%
|
|
For i=1 to Adors.recordcount
|
|
%>
|
|
<tr height=30>
|
|
<td align="center" ><%=Adors("job_date") %></td>
|
|
<td align="center" ><%=Adors("p_sn") %></td>
|
|
<td align="center" ><%=Adors("p_subject")%></td>
|
|
<td align="center" ><%=Adors("cost_name") %></td>
|
|
<td align="center" ><%=Formatnumber(Adors("cost_money"), 0) %></td>
|
|
</tr>
|
|
<%
|
|
sum_money = sum_money + CDbl(Adors("cost_money"))
|
|
adors.movenext
|
|
next
|
|
AdoRs.close
|
|
%>
|
|
<tr height=30>
|
|
<td align="center" colspan="4"> 합 계 </td>
|
|
<td align="center" ><%= Formatnumber(sum_money, 0) %></td>
|
|
</tr>
|
|
<%
|
|
End if
|
|
End if
|
|
|
|
If search_kind = "personal" Then
|
|
query = ""
|
|
query = query & " SELECT job_date, p_team_name, p_no, p_name, sum(cost_money) AS cost_money "
|
|
query = query & " FROM "
|
|
query = query & " ( "
|
|
query = query & " SELECT P.p_team_name, P.p_name, T.p_no, LEFT(job_date, 7) AS job_date, "
|
|
query = query & " ISNULL(VPM.p_subject, ( "
|
|
query = query & " CASE P.p_depart_now "
|
|
query = query & " WHEN 'E' THEN p_name + ' 공통경비' "
|
|
query = query & " WHEN 'R' THEN P.p_team_name + ' 공통경비' "
|
|
query = query & " WHEN 'F' THEN P.p_team_name + ' 공통경비' "
|
|
query = query & " ELSE '일반/행정' END)) AS p_subject, "
|
|
query = query & " CASE T.p_sn "
|
|
query = query & " WHEN '99999' THEN "
|
|
query = query & " CASE P.p_depart_now "
|
|
query = query & " WHEN 'R' THEN '99990' + CONVERT(varchar, P.p_depart) "
|
|
query = query & " WHEN 'F' THEN '99990' + CONVERT(varchar, P.p_depart) "
|
|
query = query & " ELSE '99999' END "
|
|
query = query & " ELSE T.p_sn END AS p_sn, "
|
|
query = query & " T.cost_code, CC.cost_name, cost_money "
|
|
query = query & " FROM V_BUSI_COST T LEFT JOIN V_PROJECT_METHOD VPM ON T.p_sn = VPM.p_child_sn "
|
|
query = query & " LEFT JOIN cost_category CC ON T.cost_code = CC.cost_code "
|
|
query = query & " LEFT JOIN ( "
|
|
query = query & " SELECT P.p_no, P.p_name, P.p_depart_now, before_info AS p_depart, D.T_Name AS p_team_name, "
|
|
query = query & " ISNULL((SELECT TOP 1 change_date FROM Person_Log WHERE p_no = P.p_no AND info_name = 'depart' AND change_date < PL.change_date ORDER BY change_date DESC), krc_in_date) AS log_st, CONVERT(varchar(10), DATEADD(DAY, -1, change_date), 120) AS log_en "
|
|
query = query & " FROM v_Person P "
|
|
query = query & " LEFT JOIN Person_Log PL ON P.p_no = PL.p_no AND PL.info_name = 'depart' AND PL.after_info <> '' "
|
|
query = query & " LEFT JOIN v_Department D ON PL.before_info = D.before_t_cd1 "
|
|
query = query & " WHERE before_info IS NOT NULL "
|
|
query = query & " UNION ALL "
|
|
query = query & " SELECT p_no, p_name, p_depart_now, p_depart, p_team_name, "
|
|
query = query & " ISNULL((SELECT TOP 1 change_date FROM Person_Log WHERE p_no = P.p_no AND info_name = 'depart' ORDER BY change_date DESC), krc_in_date) AS log_st, '2099-12-31' AS log_en "
|
|
query = query & " FROM v_Person P "
|
|
query = query & " ) P ON T.p_no = P.p_no AND T.job_date BETWEEN P.log_st AND P.log_en "
|
|
query = query & " WHERE job_date LIKE '" & job_month & "%' "
|
|
query = query & " ) T "
|
|
query = query & " GROUP BY job_date, p_team_name, p_no, p_name "
|
|
'Response.write query
|
|
Adors.open query, adoconn, adopenstatic, adlockreadonly
|
|
|
|
if Adors.RecordCount > 0 Then
|
|
sum_money = 0
|
|
%>
|
|
<tr height=30>
|
|
<td align="center" style="width:15%;">년월</td>
|
|
<td align="center" style="width:25%;">부서명</td>
|
|
<td align="center" style="width:20%;">사원번호</td>
|
|
<td align="center" style="width:20%;">사원명</td>
|
|
<td align="center" style="width:20%;">금액</td>
|
|
</tr>
|
|
<%
|
|
For i=1 to Adors.recordcount
|
|
%>
|
|
<tr height=30 >
|
|
<td align="center" ><%=Adors("job_date") %></td>
|
|
<td align="center" ><%=Adors("p_team_name") %></td>
|
|
<td align="center" ><%=Adors("p_no") %></td>
|
|
<td align="center" ><%=Adors("p_name") %></td>
|
|
<td align="center" ><%=Formatnumber(Adors("cost_money"), 0) %></td>
|
|
</tr>
|
|
<%
|
|
sum_money = sum_money + CDbl(Adors("cost_money"))
|
|
adors.movenext
|
|
next
|
|
AdoRs.close
|
|
%>
|
|
<tr height=30>
|
|
<td align="center" colspan="4"> 합 계 </td>
|
|
<td align="center" ><%= Formatnumber(sum_money, 0) %></td>
|
|
</tr>
|
|
<%
|
|
End if
|
|
End if
|
|
%>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
<% end if %>
|
|
</table>
|
|
</form>
|
|
<% if command <> "excel" then%>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- /.content -->
|
|
<!-- REQUIRED SCRIPTS -->
|
|
<script>
|
|
|
|
</script>
|
|
</div>
|
|
<!-- /.content-wrapper -->
|
|
<!-- #include virtual = "include/footer.asp" -->
|
|
<% end if %>
|
|
|