1341 lines
51 KiB
Plaintext
1341 lines
51 KiB
Plaintext
<!--#include file="./include/Header.asp" -->
|
|
<%
|
|
Call Login()
|
|
Dim Code : Code = request("code")
|
|
Dim setType : setType = request("SetType")
|
|
|
|
%>
|
|
<style>
|
|
.col_row_sel{
|
|
outline:none;
|
|
box-shadow:none;
|
|
-webkit-box-shadow:none;
|
|
}
|
|
#menubutton{
|
|
display:none;
|
|
}
|
|
|
|
#content{
|
|
width:1400px;
|
|
margin:0 0 0 30px;
|
|
}
|
|
.data-table {
|
|
font-family: 'NanumBarunGothic', sans-serif;
|
|
color:#646464;
|
|
margin-top:20px;
|
|
margin-bottom:20px;
|
|
font-size:11px;
|
|
}
|
|
|
|
.data-table th{
|
|
font-weight:600;
|
|
vertical-align:middle;
|
|
width:50px;
|
|
padding:1px !important;
|
|
|
|
}
|
|
.data-table td{
|
|
vertical-align:middle;
|
|
width:50px;
|
|
padding:1px !important;
|
|
}
|
|
|
|
.var-list{
|
|
background-color: #42484f;
|
|
color:white;
|
|
border:1px solid #42484f;
|
|
text-align:center;
|
|
}
|
|
|
|
.tabMenu {
|
|
width: 390px;
|
|
height: 80px;
|
|
margin: 0 auto;
|
|
list-style: none;
|
|
overflow: hidden;
|
|
padding: 0;
|
|
}
|
|
.tabMenu li{
|
|
padding:0;
|
|
}
|
|
|
|
.tabMenu li a {
|
|
background-color: #343a40;
|
|
text-align:center;
|
|
width:25%;
|
|
height:55px;
|
|
float:left;
|
|
position: relative;
|
|
display: block;
|
|
margin-top: 35px;
|
|
padding: 10px 0 0 0;
|
|
font-family: 'Open Sans', sans-serif;
|
|
font-size: 15px;
|
|
text-align: center;
|
|
text-decoration: none;
|
|
color: #ffffff;
|
|
|
|
-webkit-box-shadow: 8px 12px 25px 2px rgba(0,0,0,0.4);
|
|
-moz-box-shadow: 8px 12px 25px 2px rgba(0,0,0,0.4);
|
|
box-shadow: 8px 12px 25px 2px rgba(0,0,0,0.4);
|
|
border: 0px solid #000000;
|
|
-webkit-transition: padding 0.2s ease, margin 0.2s ease;
|
|
-moz-transition: padding 0.2s ease, margin 0.2s ease;
|
|
-o-transition: padding 0.2s ease, margin 0.2s ease;
|
|
-ms-transition: padding 0.2s ease, margin 0.2s ease;
|
|
transition: padding 0.2s ease, margin 0.2s ease;
|
|
}
|
|
.tabMenu li:first-child a {
|
|
z-index: 3;
|
|
-webkit-border-top-left-radius: 8px;
|
|
-moz-border-radius-topleft: 8px;
|
|
border-top-left-radius: 8px;
|
|
}
|
|
.tabMenu li:nth-child(2) a {
|
|
z-index: 2;
|
|
}
|
|
.tabMenu li:last-child a {
|
|
z-index: 1;
|
|
-webkit-box-shadow: 2px 8px 25px -2px rgba(0,0,0,0.3);
|
|
-moz-box-shadow: 2px 8px 25px -2px rgba(0,0,0,0.3);
|
|
box-shadow: 2px 8px 25px -2px rgba(0,0,0,0.3);
|
|
-webkit-border-top-right-radius: 8px;
|
|
-moz-border-radius-topright: 8px;
|
|
border-top-right-radius: 8px;
|
|
}
|
|
.tabMenu li a:hover {
|
|
margin: 30px 0 0 0;
|
|
padding: 10px 0 10px 0;
|
|
color:#ffffff;
|
|
}
|
|
.tabMenu li a.active {
|
|
margin: 25px 0 0 0;
|
|
padding: 10px 0 10px 0;
|
|
background: #0350a3;
|
|
color: #ffffff;
|
|
z-index: 4;
|
|
outline: none;
|
|
}
|
|
|
|
::-webkit-scrollbar {
|
|
width: 10px;
|
|
}
|
|
::-webkit-scrollbar-track {
|
|
background-color: grey;
|
|
box-shadow: inset 0px 0px 5px white;
|
|
}
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
background-color: #343a40;
|
|
border-radius: 5px;
|
|
background-clip: padding-box;
|
|
border: 1px solid transparent;
|
|
}
|
|
::-webkit-scrollbar-button:start:decrement,
|
|
::-webkit-scrollbar-button:end:increment {
|
|
width:16px;
|
|
height:16px;
|
|
border-radius: 2px;
|
|
background:#343a40;
|
|
}
|
|
.data-table{
|
|
-webkit-user-select: none;
|
|
-moz-user-select: none;
|
|
-ms-user-select: none;
|
|
user-select: none;
|
|
}
|
|
|
|
</style>
|
|
<body>
|
|
<div class="container-fluid h-100" style="text-align: center;">
|
|
<div style="width:0px;height:0px;"><input type="text" id="hiddenPaste" text="" /></div>
|
|
<div class="row sticky-top p-3 bg-dark shadow-sm">
|
|
<div class="col-xl-12 align-self-center text-left text-white text-bold ">
|
|
<strong><%=CODE%></strong>
|
|
<span class="p-2 m-1 rounded" id="menubutton">
|
|
<i class="fa fa-bars" aria-hidden="true"></i>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div class="row h-100">
|
|
<div class="col-xl-12">
|
|
<div class="container-fluid" id="mframe">
|
|
<div class="row">
|
|
<div class="col-xl-12" id="mtop">
|
|
</div>
|
|
</div>
|
|
<div class="row" id="mcontent">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row fixed-bottom p-3 bg-dark shadow-sm">
|
|
<div class="col-xl-12 align-self-center">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="Progress_Loading">
|
|
<img src="./img/96x96.gif" style="position:absolute;top:calc(50% - (96px / 2));left:calc(50% - (96px / 2));z-index:100;"/>
|
|
</div>
|
|
<div id="fixedContent"></div>
|
|
<div id="content"></div>
|
|
|
|
<!-- Modal -->
|
|
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h4 class="modal-title" id="myModalLabel" style="color:#343a40;">저장 위치를 선택하세요.</h4>
|
|
</div>
|
|
<div class="modal-body">
|
|
<select class="form-control" id="sel_quotaOrder">
|
|
<option value="1">Quota 1</option>
|
|
<option value="2">Quota 2</option>
|
|
<option value="3">Quota 3</option>
|
|
</select>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-primary" onclick="fnVarSave();">Save</button>
|
|
<button type="button" class="btn btn-danger" data-dismiss="modal" >Close</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Modal -->
|
|
<div class="modal fade bd-example-modal-xl" id="guideModal" tabindex="-1" role="dialog" aria-labelledby="myExtraLargeModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-xl">
|
|
<div class="modal-content">
|
|
<!-- 가이드 바꿀 것 -->
|
|
<img src="./img/quotaset_guide.png" style="width:100%;">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
<link type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" />
|
|
<link href="https://fonts.googleapis.com/css?family=Nanum+Gothic&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
|
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
|
|
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
|
|
|
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
|
<script src="./module/toExcel_QuotaSet.js"></script>
|
|
<script src="./module/ToastrCustom.js?ver=1"></script>
|
|
|
|
<script type="text/javascript">
|
|
var Code = "<%=Code%>"
|
|
|
|
// k1 엑셀 테이블 선언.
|
|
var k1 = kon.exceltable;
|
|
k1.makeContext("k1");
|
|
|
|
var ctrlDown = false,
|
|
ctrlKey = 17,
|
|
cmdKey = 91,
|
|
vKey = 86,
|
|
cKey = 67,
|
|
sKey = 83;
|
|
|
|
|
|
$(document).keydown(function(e) {
|
|
if (e.keyCode == ctrlKey || e.keyCode == cmdKey) ctrlDown = true;
|
|
}).keyup(function(e) {
|
|
if (e.keyCode == ctrlKey || e.keyCode == cmdKey) ctrlDown = false;
|
|
});
|
|
|
|
// Document Ctrl + C/V/S
|
|
$(document).keydown(function(e) {
|
|
if (ctrlDown && (e.keyCode == cKey)){
|
|
k1.selectedCopy();
|
|
}
|
|
if (ctrlDown && (e.keyCode == vKey)){
|
|
$('#hiddenPaste').focus();
|
|
return true;
|
|
}
|
|
if (ctrlDown && (e.keyCode == sKey)){
|
|
$("button[name=btn_quota_save]").click();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
$('#hiddenPaste').on('paste', function (e){
|
|
k1.selectPaste(e);
|
|
setTableSum($("table"))
|
|
});
|
|
|
|
$(function(){
|
|
$('#Progress_Loading').hide();
|
|
|
|
var fixedContent = document.getElementById("fixedContent")
|
|
var content = document.getElementById("content");
|
|
$(content).css("width","1600px");
|
|
|
|
var tab_li_1 = createnode("li", [ createnode("a","Create Quota", { "class" : "active" , "id" : "li_1", "style" : "cursor:pointer;" }) ], {"style" : "padding:0;" , "href" : "#/qbox"});
|
|
var tab_li_2 = createnode("li", [ createnode("a","Quota 1", { "id" : "li_2", "style" : "cursor:pointer;" }) ], {"style" : "padding:0;" , "href" : "#/first" , "data-toggle" : "tooltip", "data-placement" : "left"});
|
|
var tab_li_3 = createnode("li", [ createnode("a","Quota 2", { "id" : "li_3", "style" : "cursor:pointer;" }) ], {"style" : "padding:0;" , "href" : "#/second", "data-toggle" : "tooltip", "data-placement" : "left"});
|
|
var tab_li_4 = createnode("li", [ createnode("a","Quota 3", { "id" : "li_4", "style" : "cursor:pointer;" }) ], {"style" : "padding:0;" , "href" : "#/third" , "data-toggle" : "tooltip", "data-placement" : "left"});
|
|
var tab_ul = createnode("ul", [tab_li_1, tab_li_2, tab_li_3, tab_li_4] , {"class" : "tabMenu" , "style" : "width:100%;margin:0 auto;margin-top:10px;"}, "");
|
|
content.appendChild(tab_ul);
|
|
|
|
var setData = $.map(make_set_info(), function(o){
|
|
return { "QSORDER" : o.QSORDER , "COL" : strReplace(o.COL), "ROW" : strReplace(o.ROW) }
|
|
})
|
|
|
|
var setArr = []
|
|
for(var i = 0 ; i < 3 ; i ++){
|
|
setArr[i] = document.getElementById("li_" + ( i + 2 ) )
|
|
}
|
|
|
|
setArr.forEach(function(v, i){
|
|
$.each($.grep(setData, function(obj, idx){ return obj.QSORDER == (i + 1); }), function(idx, obj){
|
|
v.innerText = "Quota " + (i + 1) + " (설정완료)"
|
|
var setLabel = "";
|
|
if(obj.COL != ""){
|
|
setLabel += "Column : [ " + obj.COL + " ]";
|
|
}
|
|
if(obj.ROW != ""){
|
|
if(setLabel != ""){
|
|
setLabel += " / ";
|
|
}
|
|
setLabel += "Row : [ " + obj.ROW + " ]";
|
|
}
|
|
if( setLabel.charAt(setLabel.length-1) === "," ) setLabel = setLabel.slice(-1)
|
|
v.title += setLabel + "\n"
|
|
})
|
|
})
|
|
$('[data-toggle="tooltip"]').tooltip()
|
|
|
|
var select_qid_div = createnode("DIV", "", {"class" : "", "id" : "select_qid_div", "style" : "width:100%;display:inline-block;float:left;padding:10px;"})
|
|
var show_qid_div = createnode("DIV", "", {"class" : "", "id" : "show_qid_div", "style" : "width:100%;height:900px;display:inline-block;padding:10px;overflow-y:scroll;" } )
|
|
|
|
var qbox = createnode("DIV", [select_qid_div], { "id" : "qbox", "style" : "width:100%;height:900px;padding:10px;border:1px solid #dadada;overflow:hidden;" });
|
|
var first = createnode("DIV", "" , { "class" : "table-container table-responsive", "id" : "first", "style" : "width:100%;height:900px;padding:10px;overflow:auto;border:1px solid #dadada;display:none;" });
|
|
var second = createnode("DIV", "" , { "class" : "table-container table-responsive", "id" : "second", "style" : "width:100%;height:900px;padding:10px;overflow:auto;border:1px solid #dadada;display:none;" });
|
|
var third = createnode("DIV", "" , { "class" : "table-container table-responsive", "id" : "third", "style" : "width:100%;height:900px;padding:10px;overflow:auto;border:1px solid #dadada;display:none;" });
|
|
|
|
var guideTopLine = createnode("DIV", "Variable Drag & Drop" , { "style" : "background-color:#343a40;border-bottom:1px solid #aaa;border-radius:3px 3px 0 0;height:45px;text-align:center;color:#ffffff;line-height:40px;" } );
|
|
var guideFrame = createnode("DIV", [guideTopLine, show_qid_div] , { "id" : "DND" , "class" : "ui-widget-content", "style" : "width:200px;position:fixed;top:100px;right:50px;border-radius:5px;z-index:5;border:1px solid rgb(218, 218, 218);overflow:hidden;" })
|
|
|
|
// 2022-11-30 서성완 quota Create Quota만 guideFrame제시 나머지는 미제시 후 최대 크기로 변경
|
|
$("a[id^=li]").on("click", function(){
|
|
var realId = $(this).attr("id").split("_")[1]
|
|
if(realId != "1"){
|
|
$("#DND").hide();
|
|
$(content).css("width","100%");
|
|
}else{
|
|
$("#DND").show();
|
|
$(content).css("width","1600px");
|
|
}
|
|
})
|
|
fixedContent.appendChild(guideFrame)
|
|
|
|
appendChild_m( content , [qbox, first, second, third] );
|
|
make_btn_QID();
|
|
|
|
$(".col_row_sel").on("click", function(){
|
|
if( $("input[name=col_row_sel]:checked").val() == "col" ){
|
|
$("#radio_col").parent("label").addClass("active");
|
|
$("#radio_row").parent("label").removeClass("active");
|
|
}else{
|
|
$("#radio_row").parent("label").addClass("active");
|
|
$("#radio_col").parent("label").removeClass("active");
|
|
}
|
|
});
|
|
|
|
var tabs = $(".tabMenu li a");
|
|
tabs.click(function() {
|
|
var content = this.hash.replace('/','');
|
|
var setType = "<%=setType%>";
|
|
|
|
tabs.removeClass("active");
|
|
$(this).addClass("active");
|
|
|
|
switch ($(this).attr("id")) {
|
|
case "li_1":
|
|
$("#content").children('div').hide();
|
|
$("#qbox").show();
|
|
break;
|
|
case "li_2":
|
|
$("#content").children('div').hide();
|
|
$("#first").show();
|
|
$('#Progress_Loading').show(function(){
|
|
showQuotaTable(1,"first");
|
|
});
|
|
break;
|
|
case "li_3":
|
|
$("#content").children('div').hide();
|
|
$("#second").show();
|
|
$('#Progress_Loading').show(function(){
|
|
showQuotaTable(2,"second");
|
|
});
|
|
break;
|
|
case "li_4":
|
|
$("#content").children('div').hide();
|
|
$("#third").show();
|
|
$('#Progress_Loading').show(function(){
|
|
showQuotaTable(3,"third");
|
|
});
|
|
break;
|
|
}
|
|
});
|
|
|
|
$(document).on("mouseenter", ".data-table", function(e){
|
|
k1.setTable(document.getElementById($(e.target).closest('table').attr("id")))
|
|
});
|
|
|
|
/*
|
|
setType 파라미터로 추가할시, 자동 뷰 보여줌.
|
|
2021-02-19 추가
|
|
|
|
*/
|
|
if("<%=setType%>" != ""){
|
|
|
|
switch("<%=setType%>"){
|
|
case "1":
|
|
$("#li_2").click();
|
|
$('#Progress_Loading').show(function(){
|
|
showQuotaTable(1,"first");
|
|
});
|
|
break;
|
|
case "2":
|
|
$("#li_3").click();
|
|
$('#Progress_Loading').show(function(){
|
|
showQuotaTable(2,"second");
|
|
});
|
|
break;
|
|
case "3":
|
|
$("#li_4").click();
|
|
$('#Progress_Loading').show(function(){
|
|
showQuotaTable(3,"third");
|
|
});
|
|
break;
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
function strReplace(str){
|
|
str = str.replace(/\[/gi, "");
|
|
str = str.replace(/\]/gi, "");
|
|
str = str.replace(/\˝/gi, "");
|
|
return str
|
|
}
|
|
|
|
/* 쿼터뷰에 이용할 단수문항 가져오기 */
|
|
function make_btn_QID(){
|
|
var param = {
|
|
"COMMAND" : "GET_QUESTION",
|
|
"pkey" : Code
|
|
};
|
|
|
|
$.ajax({
|
|
url: "./QuotaSet_ajax.asp",
|
|
data: param,
|
|
method: "POST",
|
|
datatype: "json",
|
|
async: false,
|
|
success: function(json) {
|
|
typeof(json) === "string" ? json = JSON.parse(json) : json = json
|
|
fnMakeDiv(json);
|
|
},
|
|
error: function(xhr, option, error) {
|
|
console.log(xhr);
|
|
}
|
|
});
|
|
}
|
|
|
|
function make_set_info(){
|
|
var data = []
|
|
var param = {
|
|
"COMMAND" : "GET_QUOTASET",
|
|
"pkey" : Code
|
|
};
|
|
|
|
$.ajax({
|
|
url: "./QuotaSet_ajax.asp",
|
|
data: param,
|
|
method: "POST",
|
|
datatype: "json",
|
|
async: false,
|
|
success: function(json) {
|
|
typeof(json) === "string" ? json = JSON.parse(json) : json = json
|
|
data = json
|
|
},
|
|
error: function(xhr, option, error) {
|
|
console.log(xhr);
|
|
}
|
|
});
|
|
return data;
|
|
}
|
|
|
|
function make_PREVIEW_JSON(qid, flag){
|
|
var data = []
|
|
var param = {
|
|
"COMMAND" : "PREVIEW_JSON",
|
|
"QIDS" : qid,
|
|
"pkey" : Code,
|
|
"flag" : flag
|
|
};
|
|
|
|
$.ajax({
|
|
url: "./QuotaSet_ajax.asp",
|
|
data: param,
|
|
method: "POST",
|
|
datatype: "json",
|
|
async: false,
|
|
success: function(json) {
|
|
data = json
|
|
$.each(data, function(i, o){
|
|
typeof(o.json) === "string" ? o.json = JSON.parse(o.json) : o.json = o.json
|
|
});
|
|
},
|
|
error: function(xhr, option, error) {
|
|
console.log(xhr.responseText);
|
|
}
|
|
|
|
});
|
|
return data;
|
|
}
|
|
|
|
function make_TABLE_SQL(jsonData){
|
|
var data = [];
|
|
sql = "";
|
|
$.each(jsonData, function(i, o){
|
|
data = o.json
|
|
sql = sql + " ( "
|
|
$.each(data, function(idx, obj){
|
|
sql = sql + "select ";
|
|
sql = sql + " '" + obj.value + "' as " + String.fromCharCode(65 + parseInt(i)) + " union all ";
|
|
});
|
|
sql = sql.substr(0, sql.length - 10); //union all 문자열 제외
|
|
sql = sql + " ) " + String.fromCharCode(65 + parseInt(i)) + String.fromCharCode(65 + parseInt(i));
|
|
if(i != 0) sql = sql + " on 1 = 1 ";
|
|
sql = sql + " left join ";
|
|
});
|
|
sql = sql.substr(0, sql.length - 10); //left join 문자열 제외
|
|
return sql;
|
|
}
|
|
|
|
function make_TABLE_DATA(jsonData, columnList, rowList){
|
|
var tableData = [];
|
|
|
|
$.each(jsonData, function(i, o){
|
|
if(o.flag == "col"){
|
|
$.each(o.json, function(idx, obj){
|
|
$.each(columnList , function(index, object){
|
|
if(o.QID == object){
|
|
tableData.push({ "idx" : i, "QID" : o.QID ,"label" : obj.label, "value" : obj.value, "gubun" : "col", "length" : index, "variable" : o.variable });
|
|
}
|
|
})
|
|
});
|
|
}else{
|
|
$.each(o.json, function(idx, obj){
|
|
$.each(rowList , function(index, object){
|
|
if(o.QID == object){
|
|
tableData.push({ "idx" : i, "QID" : o.QID ,"label" : obj.label, "value" : obj.value, "gubun" : "row", "length" : index, "variable" : o.variable });
|
|
}
|
|
});
|
|
});
|
|
}
|
|
});
|
|
return tableData;
|
|
}
|
|
|
|
function drag(ev) {
|
|
$(".quota-list").css("border", "2px dashed #17a2b8")
|
|
.css("background-image", "url(/img/plus.png)")
|
|
.css("background-repeat","no-repeat")
|
|
.css("background-position", "center")
|
|
.css("background-color", "#f6f6f6")
|
|
ev.dataTransfer.setData("text", ev.target.id);
|
|
}
|
|
|
|
function drop(ev) {
|
|
ev.preventDefault();
|
|
$(".quota-list").css("border", "1px solid #ced4da")
|
|
.css("background-image", "none")
|
|
.css("background-color", "#fff")
|
|
var idx = 0;
|
|
var overIdx = 0;
|
|
var data = ev.dataTransfer.getData("text");
|
|
var e = document.getElementById(data)
|
|
var attr = {};
|
|
|
|
attr["title"] = e.getAttribute("title")
|
|
attr["tabindex"] = e.getAttribute("tabindex")
|
|
attr["data-placement"] = e.getAttribute("data-placement")
|
|
attr["data-value"] = e.getAttribute("data-value")
|
|
attr["ondragend"] = e.getAttribute("ondragend")
|
|
attr["class"] = "btn btn-light";
|
|
attr["onclick"] = "fnVarDel(this)";
|
|
if(ev.target.id != "sel_row_0"){
|
|
attr["style"] = "width:100px;height:65px;margin:5px;background-color:#fff;border:1px solid #ddd;outline:none;color:#343a40;";
|
|
}else{
|
|
attr["style"] = "width:120px;height:65px;margin:5px;background-color:#fff;border:1px solid #ddd;outline:none;color:#343a40;";
|
|
}
|
|
|
|
var newNode = createnode(e.tagName, e.innerText, attr)
|
|
ev.target.childNodes.forEach(function(o, i){
|
|
if( o.dataset["value"] == newNode.dataset["value"] ) idx = idx + 1;
|
|
})
|
|
|
|
var setCount = 1;
|
|
if(ev.target.id == "sel_row_0"){
|
|
document.getElementById("sel_col_0").childNodes.forEach(function(v, i){
|
|
if(newNode.dataset["value"] == v.dataset["value"]) overIdx = overIdx + 1;
|
|
});
|
|
}else{
|
|
setCount = 3;
|
|
document.getElementById("sel_row_0").childNodes.forEach(function(v, i){
|
|
if(newNode.dataset["value"] == v.dataset["value"]) overIdx = overIdx + 1;
|
|
|
|
})
|
|
}
|
|
|
|
if(ev.target.childNodes.length >= setCount){
|
|
tAlert("최대 "+setCount+"문항까지 설정가능합니다.")
|
|
return false;
|
|
}
|
|
|
|
if(idx == 0 && overIdx == 0) ev.target.appendChild(newNode)
|
|
else if(idx > 0) tAlert("이미 선택된 문항입니다.")
|
|
else if(overIdx > 0) tAlert("행과 열에 같은 변수를 설정할 수 없습니다.")
|
|
|
|
}
|
|
|
|
function notdrag(ev){
|
|
$(".quota-list").css("border", "1px solid #ced4da")
|
|
.css("background-image", "none")
|
|
.css("background-color", "#fff")
|
|
}
|
|
|
|
function allowDrop(ev) {
|
|
ev.preventDefault();
|
|
}
|
|
|
|
/* 쿼터뷰 레이아웃 구성 */
|
|
function fnMakeDiv(json){
|
|
var show_qid_div = document.getElementById("show_qid_div");
|
|
var select_qid_div = document.getElementById("select_qid_div");
|
|
var hr = createnode("hr" , "" , {"style" : "border-top:1px solid #dadada"});
|
|
|
|
$.each(json, function(i, o){
|
|
show_qid_div.appendChild(createnode("SPAN" , "" , {"id" : "qidNum_" + i , "style" : "display:none;" } ))
|
|
document.getElementById("qidNum_" + i).innerHTML = o.title
|
|
show_qid_div.appendChild(
|
|
createnode("P" , [{"element" : "BUTTON", "text" : o.QID + " [" + o.variable + "]", "attr" : {
|
|
"class" : "btn btn-outline-info",
|
|
"id" : "qidBtn_" + i,
|
|
"style" : "width:80%;height:60px;margin-right:5px;",
|
|
"title" : document.getElementById("qidNum_" + i).innerText,
|
|
"tabindex" : "0",
|
|
"data-toggle" : "tooltip",
|
|
"data-placement" : "left",
|
|
"data-value" : o.QID,
|
|
"draggable" : "true" ,
|
|
"ondragstart" : "drag(event)",
|
|
"ondragend" : "notdrag(event)"
|
|
} , "thisText" : "" }], {"style" : "text-align:center;"} )
|
|
);
|
|
});
|
|
|
|
var btSelFormat = createnode("BUTTON" , "Reset" , { "class" : "btn btn-danger", "onclick" : "fnSelFormat()", "style" : "width:77px;margin:3px auto;margin-right:6px;display:inline-block;"});
|
|
var btSelSave = createnode("BUTTON" , "Save" , { "class" : "btn btn-success", "onclick" : "" , "data-toggle" : "modal" , "data-target" : "#myModal", "style" : "width:77px;margin:3px auto;display:inline-block;"});
|
|
var btSelGuide = createnode("BUTTON" , "Guide" , { "class" : "btn btn-warning", "onclick" : "" , "data-toggle" : "modal" , "data-target" : "#guideModal", "style" : "width:77px;margin:3px auto;margin-right:6px;display:inline-block;"});
|
|
var btSelEnd = createnode("BUTTON" , "Preview" , { "class" : "btn btn-success", "onclick" : "fnSelPreview()", "style" : "width:77px;margin:3px auto;display:inline-block;"});
|
|
|
|
divSelEnd = createnode("DIV" , [btSelFormat, btSelSave, btSelGuide, btSelEnd] , { "class" : "" , "style" : "width:160px;height:80px;margin:5px;text-align:center;float:left;" });
|
|
select_qid_div.appendChild(divSelEnd);
|
|
|
|
var variable_list = [];
|
|
variable_list[0] = createnode("div", "" , { "class" : "form-control quota-list", "id" : "sel_col_0", "ondrop" : "drop(event)", "ondragover" : "allowDrop(event)", "style" : "width:1250px;height:100px;margin:5px;display:inline-block;float:left;line-height:45px;"}, "");
|
|
variable_list[1] = createnode("div", "" , { "class" : "form-control quota-list", "id" : "sel_row_0", "ondrop" : "drop(event)", "ondragover" : "allowDrop(event)", "style" : "width:160px;height:650px;margin:5px;display:inline-block;float:left;line-height:45px;"}, "");
|
|
|
|
var variable_label = [];
|
|
variable_label[0] = createnode("div", "Column" , { "class" : "form-control btn-secondary", "title" : "우측 영역에 열 변수를 설정하세요." , "style" : "cursor:help;width:75px;height:100px;margin:5px;display:inline-block;float:left;line-height:70px;"}, "");
|
|
variable_label[1] = createnode("div", "Row" , { "class" : "form-control btn-secondary", "title" : "하단 영역에 행 변수를 설정하세요." , "style" : "cursor:help;width:160px;height:40px;margin:5px;margin-top:10px;display:inline-block;float:left;text-align:center;"}, "");
|
|
|
|
|
|
|
|
var variable_div = [];
|
|
variable_div[0] = createnode("div", [variable_label[0], variable_list[0] ] , {"style" : "width:1350px;height:100px;display:inline-block;float:left;line-height:30px;"} )
|
|
variable_div[1] = createnode("div", [variable_label[1], variable_list[1] ] , {"style" : "width:160px;height:750px;display:inline-block;float:left;line-height:45px;"} )
|
|
|
|
appendChild_m(select_qid_div, variable_div);
|
|
}
|
|
|
|
/* 선택 문항 클릭 삭제 */
|
|
function fnVarDel(e){
|
|
$(e).remove();
|
|
}
|
|
|
|
/* 선택 문항 전체 삭제 */
|
|
function fnSelFormat(){
|
|
$(".quota-list").children("button").remove()
|
|
var data_table = document.getElementById("quotaTableDiv");
|
|
$(data_table).remove()
|
|
$("#first")[0].innerHTML = ""
|
|
$("#second")[0].innerHTML = ""
|
|
$("#third")[0].innerHTML = ""
|
|
}
|
|
|
|
// 함수 정의
|
|
function fnSelPreview(){
|
|
$("#quotaTableDiv").remove()
|
|
$('#Progress_Loading').show(function(){
|
|
fnSelEnd();
|
|
});
|
|
}
|
|
|
|
function fnVarSave(){
|
|
var sel_quotaOrder = $("#sel_quotaOrder option:selected").val();
|
|
|
|
var variable_c = document.getElementById("sel_col_0")
|
|
var variable_r = document.getElementById("sel_row_0")
|
|
|
|
var array_c = []
|
|
var array_r = []
|
|
|
|
$(variable_c).children("button").each( function(i, o){
|
|
array_c.push(o.dataset["value"]);
|
|
});
|
|
$(variable_r).children("button").each( function(i, o){
|
|
array_r.push(o.dataset["value"]);
|
|
});
|
|
|
|
if (array_c.length == 0 && array_r.length == 0 ) {
|
|
$("#myModal button[data-dismiss=modal]").click()
|
|
tAlert("설정된 문항이 없습니다.", "error")
|
|
|
|
return false;
|
|
}
|
|
/*
|
|
else if (array_c.length > 1 && array_r.length == 0 ) {
|
|
$("#myModal button[data-dismiss=modal]").click()
|
|
tAlert("Column이 2개 이상일 때는 Row는 필수 입니다.", "error")
|
|
|
|
return false;
|
|
}
|
|
*/
|
|
var qsJson = "{\"COL\":[";
|
|
$(array_c).each(function(i, o){
|
|
if(i!=0) qsJson = qsJson + ","
|
|
qsJson = qsJson + "\"" + o + "\"";
|
|
});
|
|
qsJson = qsJson + "],\"ROW\":[";
|
|
$(array_r).each(function(i, o){
|
|
if(i!=0) qsJson = qsJson + ","
|
|
qsJson = qsJson + "\"" + o + "\"";
|
|
});
|
|
qsJson = qsJson + "]}";
|
|
|
|
var param = { "COMMAND" : "INSERT_QUOTASET",
|
|
"QSJSON" : qsJson,
|
|
"pkey" : Code,
|
|
"QSORDER" : sel_quotaOrder
|
|
};
|
|
$.ajax({
|
|
url: "./QuotaSet_ajax.asp",
|
|
data: param,
|
|
method: "POST",
|
|
datatype: "json",
|
|
async: false,
|
|
success: function(response) {
|
|
var colQid = ""
|
|
var rowQid = ""
|
|
|
|
array_c.forEach(function(o, i){
|
|
colQid = colQid + o + ",";
|
|
});
|
|
|
|
array_r.forEach(function(o, i){
|
|
rowQid = rowQid + o + ",";
|
|
});
|
|
|
|
colQid = colQid.substring(0, colQid.length - 1);
|
|
rowQid = rowQid.substring(0, rowQid.length - 1);
|
|
|
|
var colJsonData = []
|
|
var rowJsonData = []
|
|
|
|
if(colQid.length > 0) colJsonData = make_PREVIEW_JSON(colQid, "col")
|
|
if(rowQid.length > 0) rowJsonData = make_PREVIEW_JSON(rowQid, "row")
|
|
saveQuotaCellZero(colJsonData, rowJsonData, sel_quotaOrder)
|
|
|
|
tAlert(response, "info");
|
|
$("#myModal button[data-dismiss=modal]").click();
|
|
},
|
|
error: function(xhr, option, error) {
|
|
console.log(xhr);
|
|
}
|
|
});
|
|
}
|
|
|
|
function saveQuotaCellZero(colJsonData, rowJsonData, qsOrder){
|
|
var rowCount = 1;
|
|
var colCountArr = [1,1,1];
|
|
var rowQID = "";
|
|
var colQIDArr = ["","",""];
|
|
if(rowJsonData.length > 0){
|
|
rowCount = Object.keys(rowJsonData[0].json).length;
|
|
rowQID = rowJsonData[0].QID;
|
|
}
|
|
|
|
if(colJsonData.length > 0){
|
|
$.each(colJsonData, function(i,e){
|
|
colCountArr[i] = Object.keys(colJsonData[i].json).length;
|
|
colQIDArr[i] = colJsonData[i].QID;
|
|
})
|
|
}
|
|
|
|
var quotaJson = {};
|
|
for(var r = 0; r < rowCount; r++){
|
|
if(rowQID != ""){
|
|
quotaJson[rowQID] = Object.values(rowJsonData[0].json)[r].value;
|
|
}
|
|
for(var c1 = 0; c1 < colCountArr[0]; c1++){
|
|
if(colQIDArr[0] != ""){
|
|
quotaJson[colQIDArr[0]] = Object.values(colJsonData[0].json)[c1].value;
|
|
}
|
|
for(var c2 = 0; c2 < colCountArr[1]; c2++){
|
|
if(colQIDArr[1] != ""){
|
|
quotaJson[colQIDArr[1]] = Object.values(colJsonData[1].json)[c2].value;
|
|
}
|
|
for(var c3 = 0; c3 < colCountArr[2]; c3++){
|
|
if(colQIDArr[2] != ""){
|
|
quotaJson[colQIDArr[2]] = Object.values(colJsonData[2].json)[c3].value;
|
|
}
|
|
|
|
var param = { "COMMAND" : "INSERT_QUOTACELL",
|
|
"QUOTAJSON" : JSON.stringify(quotaJson),
|
|
"pkey" : Code,
|
|
"QSORDER" : qsOrder
|
|
};
|
|
$.ajax({
|
|
url: "./QuotaSet_ajax.asp",
|
|
data: param,
|
|
method: "POST",
|
|
datatype: "json",
|
|
async: false,
|
|
success: function(response) {
|
|
},
|
|
error: function(xhr, option, error) {
|
|
console.log(xhr);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function saveQuotaCell(qsOrder){
|
|
var onlyCnt = $("#chk_onlyCnt").is(":checked")?"1":"0";
|
|
var quotaJson = [];
|
|
$(".quota-cnt").each(function(i,e){
|
|
if($(e).data("quotaid") != undefined){
|
|
var quotaCnt = $(e).val().trim();
|
|
if(quotaCnt == ""){
|
|
quotaCnt= "0"
|
|
}
|
|
quotaJson.push({"cnt":quotaCnt, "quotaid":$(e).data("quotaid")});
|
|
|
|
if(onlyCnt == "0"){
|
|
$(".quota-cnt[data-quotaori="+$(e).data("quotaid")+"]").text(quotaCnt);
|
|
}
|
|
}
|
|
});
|
|
|
|
var param = {
|
|
"COMMAND" : "UPDATE_QUOTA_CELL",
|
|
"QUOTAJSON":JSON.stringify(quotaJson),
|
|
"QSORDER" : qsOrder,
|
|
"pkey" : Code,
|
|
"ONLYCNT":onlyCnt
|
|
};
|
|
$.ajax({
|
|
url: "./QuotaSet_ajax.asp",
|
|
data: param,
|
|
method: "POST",
|
|
datatype: "json",
|
|
async: false,
|
|
success: function(response) {
|
|
tAlert(response, "info");
|
|
},
|
|
error: function(xhr, option, error) {
|
|
console.log(xhr);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 미리보기
|
|
function fnSelEnd(){
|
|
var data_table = document.getElementById("quotaTableDiv");
|
|
$(data_table).remove()
|
|
$("#first")[0].innerHTML = ""
|
|
$("#second")[0].innerHTML = ""
|
|
$("#third")[0].innerHTML = ""
|
|
|
|
// 열변수 1그룹 , 행변수 1그룹 까지만 가능
|
|
var variable_c = document.getElementById("sel_col_0")
|
|
var variable_r = document.getElementById("sel_row_0")
|
|
|
|
var Array_c = []
|
|
var Array_r = []
|
|
$(variable_c).children("button").each( function(i, o){
|
|
Array_c.push(o.dataset["value"]);
|
|
});
|
|
$(variable_r).children("button").each( function(i, o){
|
|
Array_r.push(o.dataset["value"]);
|
|
});
|
|
|
|
if (Array_c.length == 0 && Array_r.length == 0 ) {
|
|
tAlert("설정 된 문항이 없습니다.", "error")
|
|
$('#Progress_Loading').hide();
|
|
return false;
|
|
};
|
|
|
|
var tableDiv = createnode("DIV", "" , {"class" : "table-responsive" , "id" : "quotaTableDiv", "style" : "width:86%;height:700px;float:right;margin:15px;overflow:auto;padding:20px;"});
|
|
var select_qid_div = document.getElementById("select_qid_div");
|
|
select_qid_div.appendChild(tableDiv);
|
|
|
|
if(Array_c.length > 0 || Array_r.length > 0){
|
|
var colQid = ""
|
|
var rowQid = ""
|
|
|
|
Array_c.forEach(function(o, i){
|
|
colQid = colQid + o + ",";
|
|
});
|
|
|
|
Array_r.forEach(function(o, i){
|
|
rowQid = rowQid + o + ",";
|
|
});
|
|
|
|
colQid = colQid.substring(0, colQid.length - 1);
|
|
rowQid = rowQid.substring(0, rowQid.length - 1);
|
|
|
|
var colJsonData = []
|
|
var rowJsonData = []
|
|
|
|
if(colQid.length > 0) colJsonData = make_PREVIEW_JSON(colQid, "col")
|
|
if(rowQid.length > 0) rowJsonData = make_PREVIEW_JSON(rowQid, "row")
|
|
|
|
fnNewDrawTable(colJsonData, rowJsonData, colQid, rowQid, "quotaTableDiv");
|
|
}
|
|
$('#Progress_Loading').hide();
|
|
}
|
|
|
|
function fnNewDrawTable(colJsonData, rowJsonData, colQid, rowQid, divId){
|
|
var returnValue;
|
|
|
|
var tableDiv = document.getElementById(divId)
|
|
var table = createnode("table", "", { "class": "table shadow-sm table-bordered data-table text-center", "name" : "data-table", "id" : "data-table-0"});
|
|
tableDiv.appendChild(table);
|
|
var dataTable = document.getElementById("data-table-0");
|
|
|
|
var caption = "체크 쿼터(쿼터 체크시 사용되는 수량) - Column Variable : [ " + colQid + " ] / Row Variable : [ " + rowQid + " ]"
|
|
table.appendChild(createnode("caption" , caption, {"class" : "table" ,"style" : "caption-side:top;text-align:left;font-size:15px;font-weight:bold;background-color:#455e89;border:1px solid #455e89;margin-bottom:0;color:#ffffff;padding-left:15px;"} ))
|
|
|
|
var oriTable = createnode("table", "", { "class": "table shadow-sm table-bordered data-table text-center", "name" : "data-table", "id" : "ori-table-0"});
|
|
tableDiv.appendChild(oriTable);
|
|
oriTable.appendChild(createnode("caption" , "원 쿼터(Report에 노출 되는 수량)", {"class" : "table" ,"style" : "caption-side:top;text-align:left;font-size:15px;font-weight:bold;background-color:#455e89;border:1px solid #455e89;margin-bottom:0;color:#ffffff;padding-left:15px;"} ))
|
|
|
|
var quotaCnt;
|
|
if(divId != "quotaTableDiv"){
|
|
var tableNum = divId == "first" ? 1 : divId == "second" ? 2 : 3;
|
|
quotaCnt = getQuotaCnt(tableNum);
|
|
}
|
|
|
|
var rowSpan = 1;
|
|
var rowCount = 1;
|
|
var colCountArr = [1,1,1];
|
|
var rowQID = "";
|
|
var colQIDArr = ["","",""];
|
|
if(rowJsonData.length > 0){
|
|
rowCount = Object.keys(rowJsonData[0].json).length;
|
|
rowQID = rowJsonData[0].QID;
|
|
}
|
|
|
|
if(colJsonData.length > 0){
|
|
rowSpan = colJsonData.length;
|
|
$.each(colJsonData, function(i,e){
|
|
colCountArr[i] = Object.keys(colJsonData[i].json).length;
|
|
colQIDArr[i] = colJsonData[i].QID;
|
|
})
|
|
}
|
|
|
|
var tr;
|
|
var oriTr;
|
|
//header
|
|
if(colJsonData.length > 0){
|
|
$.each(colJsonData, function(i1,e1){
|
|
var loopCnt = 1;
|
|
var colSpan = 1;
|
|
|
|
tr = createnode("TR", "")
|
|
if(i1 == 0){
|
|
if(rowJsonData.length > 0){
|
|
tr.appendChild(createnode("TH" , "구분" , {"rowspan" : rowSpan})); //구분
|
|
}
|
|
}
|
|
else{
|
|
for(var c = i1 - 1; c >= 0; c--){
|
|
loopCnt = loopCnt * colCountArr[c];
|
|
}
|
|
}
|
|
|
|
if((i1+1) < colJsonData.length){
|
|
for(var c = i1 + 1; c < colJsonData.length; c++){
|
|
colSpan = colSpan * colCountArr[c];
|
|
}
|
|
}
|
|
|
|
for(var l = 0; l < loopCnt; l++){
|
|
$.each(Object.values(e1.json), function(i2, e2){
|
|
tr.appendChild(createnode("TH" , e2.label , {"colspan" : colSpan}));
|
|
});
|
|
}
|
|
|
|
if(i1 == 0){
|
|
tr.appendChild(createnode("TH" , "합계" , {"class" : "table-active" , "rowspan" : rowSpan} ));
|
|
}
|
|
|
|
var clonedTr = tr.cloneNode(true);
|
|
table.appendChild(tr);
|
|
oriTable.appendChild(clonedTr);
|
|
});
|
|
}
|
|
else{
|
|
tr = createnode("TR", "")
|
|
tr.appendChild(createnode("TH" , "구분" , {})); //구분
|
|
tr.appendChild(createnode("TH" , "쿼터" , {})); //구분
|
|
tr.appendChild(createnode("TH" , "합계" , {"class" : "table-active"} ));
|
|
table.appendChild(tr);
|
|
|
|
var clonedTr = tr.cloneNode(true);
|
|
oriTable.appendChild(clonedTr);
|
|
}
|
|
//header end
|
|
//body
|
|
var quotaJson = {};
|
|
for(var r = 0; r < rowCount; r++){
|
|
var rowData;
|
|
tr = createnode("TR", "")
|
|
oriTr = createnode("TR", "");
|
|
|
|
if(rowQID != ""){
|
|
tr.appendChild(createnode("TH" , Object.values(rowJsonData[0].json)[r].label , {}));
|
|
oriTr.appendChild(createnode("TH" , Object.values(rowJsonData[0].json)[r].label , {}));
|
|
|
|
quotaJson[rowQID] = Object.values(rowJsonData[0].json)[r].value;
|
|
if(divId != "quotaTableDiv"){
|
|
rowData = $.grep(quotaCnt, function(o, i){ return o.QUOTAJSON[rowQID] == Object.values(rowJsonData[0].json)[r].value; });
|
|
}
|
|
}
|
|
else{
|
|
rowData = quotaCnt;
|
|
}
|
|
|
|
for(var c1 = 0; c1 < colCountArr[0]; c1++){
|
|
var col1Data;
|
|
if(colQIDArr[0] != ""){
|
|
quotaJson[colQIDArr[0]] = Object.values(colJsonData[0].json)[c1].value;
|
|
if(divId != "quotaTableDiv"){
|
|
col1Data = $.grep(rowData, function(o, i){ return o.QUOTAJSON[colQIDArr[0]] == Object.values(colJsonData[0].json)[c1].value; });
|
|
}
|
|
}
|
|
else{
|
|
col1Data = rowData;
|
|
}
|
|
for(var c2 = 0; c2 < colCountArr[1]; c2++){
|
|
var col2Data;
|
|
if(colQIDArr[1] != ""){
|
|
quotaJson[colQIDArr[1]] = Object.values(colJsonData[1].json)[c2].value;
|
|
if(divId != "quotaTableDiv"){
|
|
col2Data = $.grep(col1Data, function(o, i){ return o.QUOTAJSON[colQIDArr[1]] == Object.values(colJsonData[1].json)[c2].value; });
|
|
}
|
|
}
|
|
else{
|
|
col2Data = col1Data;
|
|
}
|
|
for(var c3 = 0; c3 < colCountArr[2]; c3++){
|
|
var col3Data;
|
|
if(colQIDArr[2] != ""){
|
|
quotaJson[colQIDArr[2]] = Object.values(colJsonData[2].json)[c3].value;
|
|
if(divId != "quotaTableDiv"){
|
|
col3Data = $.grep(col2Data, function(o, i){ return o.QUOTAJSON[colQIDArr[2]] == Object.values(colJsonData[2].json)[c3].value; });
|
|
}
|
|
}
|
|
else{
|
|
col3Data = col2Data;
|
|
}
|
|
|
|
var td;
|
|
var oriTd;
|
|
if(divId != "quotaTableDiv"){
|
|
var oriValue = "";
|
|
td = createnode("TD" , "");
|
|
|
|
if(col3Data.length == 1){
|
|
var quotaValue = col3Data[0].cnt;
|
|
oriValue = col3Data[0].ori_cnt;
|
|
var quotaID = col3Data[0].id;
|
|
var inputText = createnode("input", "", {"type":"text", "value":quotaValue, "data-quotaid":quotaID, "data-quota":JSON.stringify(quotaJson), "class":"form-control form-control-sm quota-cnt", "style":"text-align: center;width:90%;margin:0px auto;"});
|
|
td.appendChild(inputText);
|
|
}
|
|
oriTd = createnode("TD" , oriValue,{"class":"quota-cnt","data-quotaori":quotaID});
|
|
}
|
|
else{
|
|
td = createnode("TD" , "0");
|
|
oriTd = createnode("TD" , "0");
|
|
}
|
|
tr.appendChild(td);//여기
|
|
oriTr.appendChild(oriTd);
|
|
}
|
|
}
|
|
}
|
|
tr.appendChild(createnode("TD", "0", {"class" : "table-active"} ));
|
|
oriTr.appendChild(createnode("TD", "0", {"class" : "table-active"} ));
|
|
table.appendChild(tr);
|
|
oriTable.appendChild(oriTr);
|
|
}
|
|
|
|
tr = createnode("TR", "")
|
|
oriTr = createnode("TR", "")
|
|
if(rowJsonData.length > 0){
|
|
tr.appendChild(createnode("TH" , "합계" , {"class" : "table-active"} ));
|
|
oriTr.appendChild(createnode("TH" , "합계" , {"class" : "table-active"} ));
|
|
}
|
|
$(table).find("tr:last td").each(function(){
|
|
tr.appendChild(createnode("TD", "0", {"class" : "table-active"} ));
|
|
});
|
|
|
|
$(oriTable).find("tr:last td").each(function(){
|
|
oriTr.appendChild(createnode("TD", "0", {"class" : "table-active"} ));
|
|
});
|
|
|
|
table.appendChild(tr);
|
|
oriTable.appendChild(oriTr);
|
|
//body end
|
|
|
|
if(divId != "quotaTableDiv"){
|
|
setTableSum(table);
|
|
setTableSum(oriTable);
|
|
}
|
|
|
|
return returnValue
|
|
}
|
|
|
|
$(document).on("keyup", ".quota-cnt", function(){
|
|
$(this).val($(this).val().replace(/[^0-9]/g, ''));;
|
|
setTableSum($(this).closest("table"))
|
|
});
|
|
|
|
function setTableSum(dataTable){
|
|
var sumArr;
|
|
var tr = $(dataTable).find("tr:not(last)");
|
|
|
|
$(tr).each(function(i1,e1){
|
|
if($(e1).find(".quota-cnt").length > 0){
|
|
if(sumArr == undefined){
|
|
sumArr = new Array($(e1).find(".quota-cnt").length);
|
|
}
|
|
var sumVal = 0;// 합계
|
|
$(e1).find(".quota-cnt").each(function(i2,e2){
|
|
var eleVal = 0;
|
|
if($(e2).prop('tagName') == "TD"){
|
|
eleVal = Number($(e2).text());
|
|
}
|
|
else{
|
|
eleVal = Number($(e2).val());
|
|
}
|
|
|
|
if(sumArr[i2] == undefined){
|
|
sumArr[i2] = eleVal;
|
|
}
|
|
else{
|
|
sumArr[i2] += eleVal;
|
|
}
|
|
sumVal += eleVal;
|
|
});
|
|
$(e1).find("td:last").html(sumVal);
|
|
}
|
|
});
|
|
|
|
var totalSum = 0;
|
|
$(dataTable).find("tr:last td").each(function(i,e){
|
|
if(i < sumArr.length){
|
|
totalSum += sumArr[i];
|
|
$(e).html(sumArr[i]);
|
|
}
|
|
else{
|
|
$(e).html(totalSum);
|
|
}
|
|
});
|
|
}
|
|
|
|
function getQuotaCnt(qsOrder){
|
|
var jsonData = [];
|
|
var param = {
|
|
"COMMAND" : "GET_QUOTA_CNT",
|
|
"QSORDER" : qsOrder,
|
|
"pkey" : Code
|
|
};
|
|
|
|
$.ajax({
|
|
url: "./QuotaSet_ajax.asp",
|
|
data: param,
|
|
method: "POST",
|
|
datatype: "json",
|
|
async: false,
|
|
success: function(json) {
|
|
$.each(json, function(i,e){
|
|
e.QUOTAJSON = JSON.parse(e.QUOTAJSON.replace(/˝/g,"\""))
|
|
})
|
|
jsonData = json
|
|
},
|
|
error: function(xhr, option, error) {
|
|
console.log(xhr);
|
|
}
|
|
});
|
|
return jsonData
|
|
}
|
|
|
|
function selQuotaTable(qidx){
|
|
var jsonData = [];
|
|
var param = {
|
|
"COMMAND" : "SEL_QUOTATABLE",
|
|
"QSORDER" : qidx,
|
|
"pkey" : Code
|
|
};
|
|
|
|
$.ajax({
|
|
url: "./QuotaSet_ajax.asp",
|
|
data: param,
|
|
method: "POST",
|
|
datatype: "json",
|
|
async: false,
|
|
success: function(json) {
|
|
jsonData = json
|
|
},
|
|
error: function(xhr, option, error) {
|
|
console.log(xhr);
|
|
}
|
|
});
|
|
return jsonData
|
|
}
|
|
|
|
function showQuotaTable(qidx, tableId){
|
|
fnSelFormat()
|
|
var jsonData = selQuotaTable(qidx)
|
|
|
|
if(jsonData.length == 0){
|
|
$('#Progress_Loading').hide();
|
|
tAlert("등록되지 않았습니다");
|
|
return false;
|
|
}
|
|
var buttonHeader = createnode("DIV", [createnode("button" , "쿼터 저장" , { "class" : "btn btn-info mr-4" , "name" : "btn_quota_save", "style" : "width:160px; margin-left: 15px;", "title" : "쿼터 저장", "onclick" : "saveQuotaCell("+qidx+");"})] , {"class" : "d-inline-block", "style":" vertical-align: top;"})
|
|
$("#"+ tableId).append(buttonHeader)
|
|
$(buttonHeader).append("<label for='chk_onlyCnt' class='m-0'><input type='checkbox' class='m-1' id='chk_onlyCnt'/>체크 쿼터만 변경</label>")
|
|
|
|
var Array_c = [];
|
|
var Array_r = [];
|
|
|
|
$.each( $.grep(jsonData, function(o, i){ return o.gubun == "col" && o.TYPE == "1" }), function(i, o){
|
|
Array_c.push(o.value)
|
|
});
|
|
|
|
$.each( $.grep(jsonData, function(o, i){ return o.gubun == "row" && o.TYPE == "1" }), function(i, o){
|
|
Array_r.push(o.value)
|
|
});
|
|
|
|
if(Array_c.length > 0 || Array_r.length > 0){
|
|
var colQid = ""
|
|
var rowQid = ""
|
|
|
|
Array_c.forEach(function(o, i){
|
|
colQid = colQid + o + ",";
|
|
});
|
|
|
|
Array_r.forEach(function(o, i){
|
|
rowQid = rowQid + o + ",";
|
|
});
|
|
|
|
colQid = colQid.substring(0, colQid.length - 1);
|
|
rowQid = rowQid.substring(0, rowQid.length - 1);
|
|
|
|
var colJsonData = []
|
|
var rowJsonData = []
|
|
|
|
if(colQid.length > 0) colJsonData = make_PREVIEW_JSON(colQid, "col")
|
|
if(rowQid.length > 0) rowJsonData = make_PREVIEW_JSON(rowQid, "row")
|
|
|
|
fnNewDrawTable(colJsonData, rowJsonData, colQid, rowQid, tableId);
|
|
}
|
|
$('#Progress_Loading').hide();
|
|
}
|
|
|
|
|
|
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("|");
|
|
}));
|
|
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;
|
|
}
|
|
|
|
</script>
|
|
</html>
|
|
|
|
<br><br><br>
|
|
|
|
<!-- #include Virtual="/include/footer.asp" -->
|
|
|
|
<script>
|
|
clklog("wi11u215oh","KON_MAIN","<%=Session("name") %>","<%=Session("team") %>","<%=request.servervariables("HTTP_HOST") & request.servervariables("HTTP_url") %>","KON_MAIN")
|
|
</script> |