Files
KIN/management/vac_month.asp
2025-09-29 17:55:08 +09:00

174 lines
6.6 KiB
Plaintext

<!-- #include virtual = "include/header.asp" -->
<!-- #include virtual = "include/left.asp" -->
<%
dim cyear
cyear = LEFT(cstr(date), 4)
if request("cyear") <> "" then
cyear = request("cyear")
end if
%>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<style>
#searchDiv{
padding: 5px 15px;
}
#contents{
overflow-y: scroll;
height: 660px;
}
#vacMonthTb{
width: 100%;
border-collapse: collapse;
margin-top: 15px;
margin-bottom: 10px;
}
#vacMonthTb th, #vacMonthTb td{
text-align:center;
border:1px solid #eaeaea;
}
#vacMonthTb th{
padding: 5px;
background-color: #cccccc;
}
</style>
<!-- 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 row-0">
<div class="col-12">
<div id='searchDiv'>
기준년 :
<select id='cyear'>
<% dim iyear %>
<% for iyear = year(now) - 1 To year(now) %>
<option value='<%=iyear%>' <%= iif(cint(cyear)=iyear, "selected", "") %>><%=iyear%>년</option>
<% Next %>
</select>
</div>
<div id='contents'>
<table id='vacMonthTb' class="table table-sm table-sm2 table-bordered table-head tr-colors mb-0">
<thead>
<th>입사일자</th>
<th>성명</th>
<th>소속</th>
<% dim imonth %>
<% for imonth = 1 To 12 %>
<th><%=imonth%>월</th>
<% Next %>
<th>합계</th>
</thead>
<tbody>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /.content -->
<%
query = ""
query = query & " SELECT P.krc_in_date, J.p_no, P.p_name, ISNULL(P.p_team_name, '') as p_team_name, CONVERT(integer, SUBSTRING(j_date, 6, 2)) AS u_month, ISNULL(sum(CASE WHEN j_contents=8 THEN 1 "
query = query & " WHEN j_contents IN (10, 11) THEN 0.5 END), 0) AS u_cnt "
query = query & " FROM project2.dbo.V_Job_List J LEFT JOIN V_PERSON P "
query = query & " ON J.p_no = P.p_no "
query = query & " WHERE j_contents IN (8,10,11) "
query = query & " AND j_date LIKE '" & cyear & "%' "
query = query & " GROUP BY P.krc_in_date, J.p_no, CONVERT(integer, SUBSTRING(j_date, 6, 2)), P.p_name, P.p_team_name "
%>
<!-- REQUIRED SCRIPTS -->
<script>
function uniq(arr, item){
var retArr = [];
if(Array.isArray(item) == true){
retArr = $.unique($.map(arr, function(obj){
var tmpArr = [];
for(var i=0; i<item.length; i++){
tmpArr.push(obj[item[i]]);
}
return tmpArr.join("|");
}).sort());
retArr = $.map(retArr, function(obj){
var tmpObj = {};
var tmpVal = obj.split("|");
for(var i=0; i<item.length; i++){
tmpObj[item[i]] = tmpVal[i];
}
return tmpObj;
});
return retArr;
}else{
retArr = $.unique($.map(arr, function(obj){ return obj[item]; }).sort());
}
return retArr;
}
function groupBySum(jsonArr, groupArr, sumArr_opt){
var sumArr = sumArr_opt || [];
var newJsonArr = uniq(jsonArr, groupArr);
$.each(newJsonArr, function(i, obj){
$.each(sumArr, function(idx, sumCol){
obj[sumCol] = 0;
});
obj["groupByCount"] = 0;
});
$.each(newJsonArr, function(idx, obj){
$.each($.grep(jsonArr, function(o, i){
var nStr = "";
var pStr = "";
$.each(groupArr, function(ix, groupCol){
nStr += obj[groupCol] + "|";
pStr += o[groupCol] + "|";
});
return nStr == pStr;
}), function(i, o){
$.each(sumArr, function(ix, sumCol){
obj[sumCol] += +o[sumCol];
});
obj["groupByCount"]++;
});
});
return newJsonArr;
}
var vacMonthJsonArr = <%=queryToJson(query)%>;
var userJsonArr = groupBySum(vacMonthJsonArr, ["krc_in_date", "p_name", "p_no", "p_team_name"]);
$(function(){
cutmenu();
$("#cyear").on("change", function(){
location.href='./vac_month.asp?cyear=' + $(this).children("option:selected").val();
});
$.each(userJsonArr, function(idx, obj){
var userVacMonth = $.grep(vacMonthJsonArr, function(o, ix){ return o.p_no == obj.p_no });
var tmpHTML = "";
tmpHTML += "<tr>";
tmpHTML += "<td>" + obj.krc_in_date + "</td>";
tmpHTML += "<td>" + obj.p_name + "</td>";
tmpHTML += "<td>" + obj.p_team_name + "</td>";
for(var i=1; i<=12; i++){
var tmpUserVacMonth = $.grep(userVacMonth, function(o, ix){ return +o.u_month == i });
tmpHTML += tmpUserVacMonth.length > 0 ? "<td>" + tmpUserVacMonth[0].u_cnt + "</td>" : "<td>0</td>";
}
tmpHTML += "<td>" + groupBySum(userVacMonth, ["p_no"], ["u_cnt"])[0].u_cnt + "</td>";
tmpHTML += "</tr>";
$("#vacMonthTb > tbody").append(tmpHTML);
});
});
</script>
</div>
<!-- /.content-wrapper -->
<!-- #include virtual = "include/footer.asp" -->