TableToExcel JavaScript 엑셀 다운로드
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<script type="text/javascript">
// Hack to make base64.js works in IE8, IE9.
if (!window.btoa) window.btoa = base64.encode;
if (!window.atob) window.atob = base64.decode;
</script>
<script type="text/javascript">
var tableArray = new Array();
var objDownload = null;
var refNo ="";
var title = "";
var contents = "";
var fromdate = "";
var todate = "";
var sendmailmember={};
function initLoad() {
alert("상세 통계화면은 PC 웹브라우저에 최적화 되어 있습니다.");
var targetData = null;
var surveydetailstatusinfo$ = ${surveydetailstatusinfo};
// 메일 보낼 사람들 넣어 놓는다.
var $surveyinfoarray = surveydetailstatusinfo$["surveyinfo"];
var $targetarray = surveydetailstatusinfo$["target"];
var $statusInfoarray = surveydetailstatusinfo$["statusInfo"];
var targetMemberCount = surveydetailstatusinfo$["targetMemberCount"];
refNo = surveydetailstatusinfo$["surveyinfo"][0]["REF_NO"];
title = surveydetailstatusinfo$["surveyinfo"][0]["TITLE"];
contents = surveydetailstatusinfo$["surveyinfo"][0]["CONTENTS"];
fromdate = surveydetailstatusinfo$["surveyinfo"][0]["FROM_DATE"];
todate = surveydetailstatusinfo$["surveyinfo"][0]["TO_DATE"];
var seqTemp = 0;
var categoryTemp = null;
var surveyType = null;
var question = null;
var category = new Array();
var item_data = {};
var items = new Array();
var json_columns = {width:600, align:'center'};
var temp = [[json_columns]];
var temp1 = new Array();
var questionData = null;
var seqArray = new Array();
for(var q=0; q< surveydetailstatusinfo$["surveyinfo"].length; q++){
seqArray[q] = surveydetailstatusinfo$['surveyinfo'][q]['SEQ'];
}
/* $("#subject").hide();
$("#subjectNo").hide(); */
/// 중복제거 함수
Array.prototype.unique = function(){
var a = {};
for(var i=0; i<this.length; i++){
if(typeof a[this[i]] == "undefined")
a[this[i]] = 1;
}
this.length = 0;
for( var i in a)
this[this.length] = i;
return this;
}
var seqArr = new Array();
seqArr = seqArray.unique();
var count=0;
var c = null;
makeDefaultSurveyInfo();
makeSurveyView();
function getTargetInfo(d$) {
var rst = "";
switch (d$['TARGET_TYPE']) {
case "COMPANY":
rst = "회사: " + d$["CODE_DETAIL_NAME"];
break;
case "BIZGROUP":
rst = "그룹: " + d$["CODE_DETAIL_NAME"]
break;
case "DEPT":
rst = "부서: " + d$["CODE_DETAIL_NAME"];
break;
case "MEMBER":
rst = "아이디: " + d$["TARGET_ID"];
break;
}
return rst + (d$["EXCEPT_YN"] == 'n' ? "-참여 | " : "-제외 | ");
}
function makeDefaultSurveyInfo(){
var survey_status = null;
var $targetinfo = surveydetailstatusinfo$["targetinfo"]; //타겟에 대한 정보
var targetMemberCount = surveydetailstatusinfo$["targetMemberCount"]; //대상자 총 인원수
var $memberCountOfClassify = surveydetailstatusinfo$["memberCountOfClassify"];
// 대상자 정보 가공 및 출력
var targetString = "";
$.each($targetinfo, function(idx, data) {
targetString += getTargetInfo(data);
});
var submitCount = 0 ;
var submiPpercent =0;
if($memberCountOfClassify[0] != undefined){
submitCount = $memberCountOfClassify[0]["MEMBERCOUNT"];
submiPpercent = Math.round((submitCount/targetMemberCount) *100);
}
$("#target").html(targetString + "<BR/> 참여인원: "+submitCount+"명" + " (총 인원 : " + targetMemberCount +"명" +": "+submiPpercent +"%)");
$("#survey_title").html(surveydetailstatusinfo$["surveyinfo"][0]["TITLE"]);
$("#survey_content").html(surveydetailstatusinfo$["surveyinfo"][0]["CONTENTS"]);
$("#survey_maker").html(surveydetailstatusinfo$["surveyinfo"][0]["NAME"]);
$("#survey_period").html(surveydetailstatusinfo$["surveyinfo"][0]["FROM_DATE"] + " ~ " + surveydetailstatusinfo$["surveyinfo"][0]["TO_DATE"]);
if(surveydetailstatusinfo$["surveyinfo"][0]["SURVEY_STATUS"] == "ongoing"){
survey_status = "게시중";
}else if(surveydetailstatusinfo$["surveyinfo"][0]["SURVEY_STATUS"] == "stop"){
survey_status = "보류중";
}else{
survey_status = "마감됨";
}
$("#survey_status").html(survey_status);
}
// 질문에 대한 통계의 전체적인 뷰를 만드는 함수
function makeSurveyView(){
for(var i=0; i< surveydetailstatusinfo$["surveyinfo"].length; i++){
if(seqTemp != surveydetailstatusinfo$["surveyinfo"][i]["SEQ"]){
// 각 질문에 대한 기본 내용
seqTemp = surveydetailstatusinfo$["surveyinfo"][i]["SEQ"];
surveyType = surveydetailstatusinfo$["surveyinfo"][i]["SURVEY_TYPE"];
question = surveydetailstatusinfo$["surveyinfo"][i]["QUESTION"];
// 단답형일 경우
if(surveyType == "txt"){
json_columns = {width:450, align:'center'};
$("#questionDiv").append("<table id='tt"+count+ "' class='easyui-treegrid' style='width:1212px;height200px'></table>");
makeTxtRow(count, seqTemp, surveyType, item_data);
clearQuestionData();
count++;
}
//단일형 또는 다중형일 경우
else if(surveyType == "single" || surveyType == "multiple"){
json_columns = {width:450, align:'center'};
$("#questionDiv").append("<table id='tt"+count+"' class='easyui-treegrid' style='width:1212px;height200px'></table>");
makeSingleMultipleRow(count, seqTemp, surveyType, item_data);
clearQuestionData();
count++;
}
// 참여여부형 일 경우
else{
json_columns = {width:450, align:'center'};
$("#questionDiv").append("<table id='tt"+count+"' class='easyui-treegrid' style='width:1212px;height200px'></table>");
makeParticipateRow(count, seqTemp, surveyType, item_data);
clearQuestionData();
count++;
}
}
}
}
// 대상자 목록을 불러오는 함수
function callTargetData(questionSeq, surveyType, item_data){
var dataTemp = null;
dataTemp = makerows($surveyinfoarray, $targetarray, $statusInfoarray, questionSeq, surveyType, item_data);
//alert("makerows"+$.stringify(dataTemp));
var test = KEFJ2EE.CreateMultiKeyObjectArrayFromObjectArray(dataTemp['rows'], "_parentid", "id");
//alert("test"+$.stringify(test));
//window.clipboardData.setData('Text', $.stringify(test));
targetData = null;
targetData = dataTemp;
}
// 질문 데이터 초기화 함수
function clearQuestionData(){
questionData = [];
temp1 = [];
item_data = {};
}
// 단답형 질문의 카테고리 설정 함수
function makeTxtRow(count, questionSeq, surveyType, item_data){
temp1=[];
items = [];
// 질문 설정
json_columns['title'] = question;
json_columns['field'] = 'region';
temp1.push(json_columns);
// 단답형의 기본 설정
json_columns = {}; // 한번 비워주고 다시 삽입
json_columns = {width:80, align:'center'};
json_columns['title'] = "참여도";
json_columns['field'] = "f1";
temp1.push(json_columns);
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "총 대상 인원";
json_columns['field'] = "f2";
temp1.push(json_columns);
questionData = [temp1];
treegridSetting(count, questionSeq, surveyType, item_data);
}
// 단일형, 다중형 질문의 카테고리 설정 함수
function makeSingleMultipleRow(count, questionSeq, surveyType, item_data){
temp1=[];
item_data={};
// 질문 설정
json_columns['title'] = question;
json_columns['field'] = 'region';
temp1.push(json_columns);
json_columns = {}; // 한번 비워주고 다시 삽입
json_columns = {width:80, align:'center'};
json_columns['title'] = "참여도";
json_columns['field'] = "f1";
temp1.push(json_columns);
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "총 대상 인원";
json_columns['field'] = "f2";
temp1.push(json_columns);
c=4;
// 단일형, 다중형 질문의 카테고리 설정
for(var k=0; k< surveydetailstatusinfo$["surveyinfo"].length; k++){
if(surveydetailstatusinfo$["surveyinfo"][k]['SEQ'] == seqTemp){
categoryTemp = surveydetailstatusinfo$["surveyinfo"][k]['CATEGORY'];
json_columns = {width:80, align:'center'};
json_columns["title"] = categoryTemp;
json_columns['field'] = "f"+(c);
temp1.push(json_columns);
json_columns = {};
item_data["f"+c] = categoryTemp;
//items.push(item_data);
//item_data = {};
c++;
}
}
questionData = [temp1];
treegridSetting(count, questionSeq, surveyType, item_data);
}
// 참여여부형 카테고리 설정 함수
function makeParticipateRow(count, questionSeq, surveyType, items){
temp1=[];
item_data={};
// 질문제목, 참여, 불참 등 참여여부형의 기본 카테고리 설정
json_columns['title'] = question;
json_columns['field'] = 'region';
temp1.push(json_columns);
json_columns = {}; // 한번 비워주고 다시 삽입
json_columns = {width:80, align:'center'};
json_columns['title'] = "참여도";
json_columns['field'] = "f1";
temp1.push(json_columns);
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "총 대상 인원";
json_columns['field'] = "f2";
temp1.push(json_columns);
json_columns = {}; // 한번 비워주고 다시 삽입
json_columns = {width:80, align:'center'};
json_columns['title'] = "참여";
json_columns['field'] = "f4";
item_data["f4"] = "CNT1";
temp1.push(json_columns);
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "불참";
json_columns['field'] = "f5";
item_data["f5"] = "CNT6";
temp1.push(json_columns);
json_columns = {};
c=6;
// 참여여부형의 카테고리 설정
for(var k=0; k< surveydetailstatusinfo$["surveyinfo"].length; k++){
if(surveydetailstatusinfo$["surveyinfo"][k]['SEQ'] == seqTemp){
categoryTemp = surveydetailstatusinfo$["surveyinfo"][k]['CATEGORY'];
json_columns = {width:80, align:'center'};
json_columns["title"] = categoryTemp;
json_columns['field'] = "f"+(c);
temp1.push(json_columns);
json_columns = {};
item_data["f"+c] = categoryTemp;
//items.push(item_data);
//item_data = {};
c++;
}
}
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "배우자";
json_columns['field'] = "f"+(c);
item_data["f"+c] = "CNT2";
temp1.push(json_columns);
json_columns = {};
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "기타성인"
json_columns['field'] = "f"+(c+1);
item_data["f"+(c+1)] = "CNT3";
temp1.push(json_columns);
json_columns = {};
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "초중고";
json_columns['field'] = "f"+(c+2);
item_data["f"+(c+2)] = "CNT4";
temp1.push(json_columns);
json_columns = {};
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "미취학";
json_columns['field'] = "f"+(c+3);
item_data["f"+(c+3)] = "CNT5";
temp1.push(json_columns);
json_columns = {};
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "총 참여 인원";
json_columns['field'] = "f"+(c+4);
item_data["f"+(c+4)] = "TOTAL";
temp1.push(json_columns);
json_columns = {};
questionData = [temp1];
treegridSetting(count, questionSeq, surveyType, item_data);
}
// treegrid 첫줄, 질문, 카테고리 설정 함수
function treegridSetting(count, questionSeq, surveyType, item_data){
callTargetData(questionSeq, surveyType, item_data);
$('#tt'+count).treegrid({
idField: 'id',
treeField: 'region',
rownumbers: false,
showFooter: true,
columns : questionData,
onClickRow:function(row){
getTargetMemberByCode(refNo,questionSeq,row['targetType'], row['id']);
}
});
$('#tt'+count).treegrid({
data : targetData});
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$("#list").jqGrid({
datatype: "local",
height: 250,
colNames:['회사','비즈그룹','부서','직원이름','직책', '답변', '본인','배우자','기타성인','초중고','미취학','불참사유','연락처','E-MAIL','ID'],
colModel:[
{name: 'company', index:'company', width: 100, align: 'center'},
{name: 'bizgp', index:'bizgp', width: 100, align: 'center'},
{name: 'dept', index:'dept', width: 100, align: 'center'},
{name: 'name', index:'name', width: 60, align: 'center'},
{name: 'workposition', index:'workposition', width: 60, align: 'center'},
{name: 'answer', index:'answer', width: 80, align: 'center'},
{name: 'cnt1', index:'cnt1', width: 50, align: 'center'},
{name: 'cnt2', index:'cnt2', width: 50, align: 'center'},
{name: 'cnt3', index:'cnt3', width: 50, align: 'center'},
{name: 'cnt4', index:'cnt4', width: 50, align: 'center'},
{name: 'cnt5', index:'cnt5', width: 50, align: 'center'},
{name: 'remark', index:'remark', width: 200, align: 'center'},
{name: 'phone', index:'phone', width: 80, align: 'center'},
{name: 'email', index:'email', width: 110, align: 'center'},
{name: 'id', index:'id', width: 60, align: 'center'}
],
rowNum:10,
rowList:[10,20,30],
pager: '#pager2',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption: '참여자 분류별 통계'
});
$("#list").jqGrid('navGrid','#pager2',{/* options */
add:true,edit:true,view:true,del:true,search:true,refresh:true
// add:false,edit:false,view:false,del:false,search:false,refresh:false
}
,{/* Edit options */
closeAfterAdd: true,
reloadAfterSubmit: false,
closeOnEscape:true
}
,{/* Add options */
closeAfterAdd: true,
reloadAfterSubmit: false,
closeOnEscape:true
}
,{/* Delete options */
reloadAfterSubmit: false,
closeOnEscape:true
}
,{/* Search options */
closeOnEscape:true,
onSearch:function(){
}//onSearch:function(){
}//Search Option
,{/* view parameters*/
closeOnEscape:true
} );
$("#listsubmitno").jqGrid({
datatype: "local",
height: 250,
colNames:['회사','비즈그룹','부서','직원이름','직책', '연락처','E-MAIL','ID','메일수신여부'],
colModel:[
{name: 'company', index:'company', width: 100, align: 'center'},
{name: 'bizgp', index:'bizgp', width: 100, align: 'center'},
{name: 'dept', index:'dept', width: 100, align: 'center'},
{name: 'name', index:'name', width: 60, align: 'center'},
{name: 'workposition', index:'workposition', width: 60, align: 'center'},
{name: 'phone', index:'phone', width: 80, align: 'center'},
{name: 'email', index:'email', width: 110, align: 'center'},
{name: 'id', index:'id', width: 60, align: 'center'},
{name: 'mailsend', index:'maiㅣsend', width: 80, align: 'center'}
],
rowNum:10,
rowList:[10,20,30],
pager: '#pager2',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption: '미참여자 통계'
});
$("#listsubmitno").jqGrid('navGrid','#pager2',{/* options */
add:true,edit:true,view:true,del:true,search:true,refresh:true
// add:false,edit:false,view:false,del:false,search:false,refresh:false
}
,{/* Edit options */
closeAfterAdd: true,
reloadAfterSubmit: false,
closeOnEscape:true
}
,{/* Add options */
closeAfterAdd: true,
reloadAfterSubmit: false,
closeOnEscape:true
}
,{/* Delete options */
reloadAfterSubmit: false,
closeOnEscape:true
}
,{/* Search options */
closeOnEscape:true,
onSearch:function(){
}//onSearch:function(){
}//Search Option
,{/* view parameters*/
closeOnEscape:true
} );
jQuery("#list #listsubmitno").click( function(){
var id = jQuery("#list").jqGrid('getGridParam','selrow');
if (id) {
var ret = jQuery("#list").jqGrid('getRowData',id);
} else { //alert("Please select row");
}
});
/*
jQuery("#a2").click( function(){
var su=jQuery("#list5").jqGrid('delRowData',12);
if(su) //alert("Succes. Write custom code to delete row from server"); else //alert("Allready deleted or not in list");
});
jQuery("#a3").click( function(){
var su=jQuery("#list5").jqGrid('setRowData',11,{amount:"333.00",tax:"33.00",total:"366.00",note:"<img src='images/user1.gif'/>"});
if(su) //alert("Succes. Write custom code to update row in server"); else //alert("Can not update");
});
jQuery("#a4").click( function(){
var datarow = {id:"99",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"};
var su=jQuery("#list5").jqGrid('addRowData',99,datarow);
if(su) //alert("Succes. Write custom code to add data in server"); else //alert("Can not update");
});
*/
}
////////////////////////////////////////////////////// ////////////////////////////////////////////////////// ////////////////////////////////////////////////////// //////////////////////////////////////////////////////
function getTargetMemberByCode(refNo, seq, type , code){
var request = $.ajax({
url : "SelectMembersbydeptcd.web",
type : "POST",
cache : false,
async : false,
data : { refNo : refNo, TYPE : type, CODE : code, QUESTIONSEQ: seq },
dataType : "json",
success : function(data) {
makeMemberList(data["jsonArray_TargetMembers"]); // 투효한 타겟맴버리스트 뿌리느 부분
makeSubmitNoMemberList(data["jsonArray_TargetSubmitNoMembers"],type,code); // 투효 안한 타겟맴버리스트 뿌리느 부분
},
fail : function(jqXHR, textStatus) {
return false;
}
});
};
//타겟맴버리스트 뿌리는 함수
function makeMemberList(memberlistjson){
// memberlsitjson;
$("#list").clearGridData(false); // 기존 데이터 삭제
//$('#tt').treegrid('collapseAll');
for(var i=0; i < memberlistjson.length; i++){
var member = memberlistjson[i];
// alert(member["COMPANYNM"]);
//window.clipboardData.setData('Text', $.stringify(member));
var row ={company:member["COMPANYNM"], bizgp: member["UP_DEPTNM"] ,dept:member["DEPTNM"], name:member["NAME"] , workposition:member["CODE_DETAIL_NAME"],submityn:member["SUBMIT_YN"] ,answer:member["S_ANS_CATEGORY"] ,
cnt1:member["CNT1"] ,cnt2:member["CNT2"] ,cnt3: member["CNT3"],cnt4:member["CNT4"] ,cnt5: member["CNT5"],remark:member["REMARK"], phone:member["PHONE_NO"], email:member["EMAIL"],
id: member["ID"]};
$("#list").addRowData(i,row);
}
};
function makeSubmitNoMemberList(submitnomemberlistjson,type,code){
// submitnomemberlistjson;
sendmailmember = {};
$("#listsubmitno").clearGridData(false); // 기존 데이터 삭제
for(var i=0; i < submitnomemberlistjson.length; i++){
var member = submitnomemberlistjson[i];
if(type=='COMPANY' && code== member['COMPANY']){
var row ={company:member["COMPANYNM"], bizgp: member["UP_DEPTNM"] ,dept:member["DEPTNM"], name:member["NAME"] , workposition:member["CODE_DETAIL_NAME"], submityn:member["SUBMIT_YN"] ,answer:member["S_ANS_CATEGORY"] ,
phone:member["PHONE_NO"], email:member["EMAIL"], id: member["ID"], mailsend: member["MAIL_SEND"]};
$("#listsubmitno").addRowData(i,row);
if(member['MAIL_SEND'] == 'n'){
sendmailmember[member["ID"]] = member["EMAIL"];
}
}else if(type=='BIZ_GP' && code== member['BIZ_GP']){
var row ={company:member["COMPANYNM"], bizgp: member["UP_DEPTNM"] ,dept:member["DEPTNM"], name:member["NAME"] ,workposition:member["CODE_DETAIL_NAME"], submityn:member["SUBMIT_YN"] ,answer:member["S_ANS_CATEGORY"] ,
phone:member["PHONE_NO"], email:member["EMAIL"], id: member["ID"], mailsend: member["MAIL_SEND"]};
$("#listsubmitno").addRowData(i,row);
if(member['MAIL_SEND'] == 'n'){
sendmailmember[member["ID"]] = member["EMAIL"];
}
}else if(type=='DEPT' && code== member['DEPT']){
var row ={company:member["COMPANYNM"], bizgp: member["UP_DEPTNM"] ,dept:member["DEPTNM"], name:member["NAME"] ,workposition:member["CODE_DETAIL_NAME"], submityn:member["SUBMIT_YN"] ,answer:member["S_ANS_CATEGORY"] ,
phone:member["PHONE_NO"], email:member["EMAIL"], id: member["ID"], mailsend: member["MAIL_SEND"]};
$("#listsubmitno").addRowData(i,row);
if(member['MAIL_SEND'] == 'n'){
sendmailmember[member["ID"]] = member["EMAIL"];
}
}
}
return sendmailmember;
};
////////////////////////////////////////////////////// ////////////////////////////////////////////////////// ////////////////////////////////////////////////////// //////////////////////////////////////////////////////
function makerows($surveyinfoarray, $targetarray, $statusInfoarray, questionseq, questiontype, categoryjson){
//alert("$surveyinfoarray"+$.stringify($surveyinfoarray));
var row={};
var resultjson = {};
var resultarray= new Array();
var companynm="";
var bizgpnm ="";
//var bizgpcd ="";
var totalbizmember =0;
var totalcompanymember =0;
var submitYbizmember =0;
var submitYcompanymember =0;
var deptmembercount=0;
var bizgpcount =0;
var grouping = KEFJ2EE.CreateMultiKeyObjectArrayFromObjectArray($targetarray, "COMPANY", "BIZ_GP","DEPT");
$.each(grouping, function(companykey, companydata){
totalcompanymember =0;
$.each(companydata, function(bizgpkey, bizgpdata){
//alert("bizgpdata"+$.stringify(bizgpdata));
totalbizmember=0;
submitYbizmember = 0;
$.each(bizgpdata, function(key, deptdata){
deptmembercount = count($statusInfoarray, questionseq, "DEPT", deptdata[0]['DEPT'], questiontype);
totalbizmember = totalbizmember + deptdata[0]['DEPTMEMBERCOUNT'];
submitYbizmember = submitYbizmember + deptmembercount;
companynm = deptdata[0]['COMPANYNM'];
bizgpnm = deptdata[0]['UP_DEPTNM'];
bizgpcode = deptdata[0]['BIZ_GP'];
//alert("bizgpcd"+$.stringify(bizgpcd));
if(bizgpkey != 'AZ0000'){
row['_parentId']=bizgpkey;
row['region']=deptdata[0]['DEPTNM'];
row['id']=deptdata[0]['DEPT'];
row['f1'] = deptmembercount+"명/"+Math.round((deptmembercount/deptdata[0]['DEPTMEMBERCOUNT'])*100)+"%";
row['f2']=deptdata[0]['DEPTMEMBERCOUNT'];
row['f3']= questionseq;
row['targetType'] = 'DEPT';
$.each(categoryjson, function(key, category){
//seq와 카테고리를 보내주면 인원수를 리턴해주는 함수를 만들어야한다.
var categorymrmbrtcountresult = categorymrmbrtcount($statusInfoarray,questionseq, "DEPT", category,questiontype,deptdata[0]['DEPT']);//우영
//alert("categorymrmbrtcountresult: "+$.stringify(categorymrmbrtcountresult));
$.each(categorymrmbrtcountresult['deptsOfId'], function(index, deptcd){
if(deptcd ==deptdata[0]['DEPT'] ){
//row[key] = categorymrmbrtcountresult["answermembercount"]+"명/"+Math.round((categorymrmbrtcountresult["answermembercount"]/deptdata[0]['DEPTMEMBERCOUNT']*100))+"%";
if(questiontype =='participate'){
var addparticipatejson = makeparticipatejson($statusInfoarray, questionseq,questiontype, "DEPT", deptcd );
//alert("categoryjson"+$.stringify(categoryjson)+"addparticipatejson"+$.stringify(addparticipatejson));
$.each(categoryjson, function(key, fieldname){
if(addparticipatejson[fieldname] != undefined ){
//row[key] = addparticipatejson[fieldname]+"명/"+Math.round((addparticipatejson[fieldname]/deptdata[0]['DEPTMEMBERCOUNT'])*100)+"%";
row[key] = addparticipatejson[fieldname]+"명";
}
});
}
row[key] = categorymrmbrtcountresult["answermembercount"]+"명/"+Math.round((categorymrmbrtcountresult["answermembercount"]/deptdata[0]['DEPTMEMBERCOUNT']*100))+"%";
}
});
});
resultarray.push(row);
row={};
}
});
// if(bizgpkey != 'AZ0000'){
bizgpcount = count($statusInfoarray, questionseq, "BIZGP", bizgpkey,questiontype);
totalcompanymember= totalcompanymember+ totalbizmember;
submitYcompanymember = submitYcompanymember + bizgpcount;
/* totalcompanymember 과 submitYcompanymember에 전사소속인 사람들의 수도 추가해줘야한다. */
/* 전사에 속한 사람수 구함() */
if(bizgpkey != 'AZ0000'){
row['_parentId']=companykey;
row['region']=bizgpnm;
row['id']=bizgpkey;
row['f1'] = submitYbizmember+"명/"+Math.round((submitYbizmember/totalbizmember)*100) +"%";
row['f2']= totalbizmember;
row['f3']= questionseq;
row['targetType'] = 'BIZ_GP';
}else{
/* row['_parentId']=companykey; */
row['_parentId']=companykey;
row['region']=bizgpnm;
row['id']=bizgpkey;
row['f1'] = submitYbizmember+"명/"+Math.round((submitYbizmember/totalbizmember)*100) +"%";
row['f2']= totalbizmember;
row['f3']= questionseq;
row['targetType'] = 'BIZ_GP';
}
$.each(categoryjson, function(key, category){
//seq와 카테고리를 보내주면 인원수를 리턴해주는 함수를 만들어야한다.
var categorymrmbrtcountresult = categorymrmbrtcount($statusInfoarray,questionseq, "BIZ_GP", category, questiontype,bizgpcode);
//alert("categorymrmbrtcountresult: "+$.stringify(categorymrmbrtcountresult));
$.each(categorymrmbrtcountresult['bizgpsOfId'], function(index, bizgpcd){
if(bizgpcd == bizgpkey ){
if(questiontype =='participate'){
// row[key] = categorymrmbrtcountresult["answermembercount"]+"명/"+Math.round((categorymrmbrtcountresult["answermembercount"]/totalbizmember)*100)+"%";
var addparticipatejson = makeparticipatejson($statusInfoarray, questionseq,questiontype, "BIZGP", bizgpcd );
$.each(categoryjson, function(key, fieldname){
if(addparticipatejson[fieldname] != undefined ){
row[key] = addparticipatejson[fieldname]+"명";
}
});
}
row[key] = categorymrmbrtcountresult["answermembercount"]+"명/"+Math.round((categorymrmbrtcountresult["answermembercount"]/totalbizmember)*100)+"%";
}
});
});
resultarray.push(row);
row={};
// }
});
row['region']=companynm;
row['id']=companykey;
row['f1'] = submitYcompanymember+"명/"+Math.round((submitYcompanymember/totalcompanymember)*100)+"%";
row['f2']= totalcompanymember;
row['f3']= questionseq;
row['targetType'] = 'COMPANY';
$.each(categoryjson, function(key, category){
//seq와 카테고리를 보내주면 인원수를 리턴해주는 함수를 만들어야한다.
var categorymrmbrtcountresult = categorymrmbrtcount($statusInfoarray,questionseq, "COMPANY", category,questiontype);
$.each(categorymrmbrtcountresult['companyOfId'], function(index, companycd){
if(companycd == companykey){
//row[key] = categorymrmbrtcountresult["answermembercount"]+"명/"+Math.round((categorymrmbrtcountresult["answermembercount"]/totalcompanymember)*100)+"%";
if(questiontype =='participate'){
row[key] = categorymrmbrtcountresult["answermembercount"]+"명/"+Math.round((categorymrmbrtcountresult["answermembercount"]/totalcompanymember)*100)+"%";
var addparticipatejson = makeparticipatejson($statusInfoarray, questionseq,questiontype, "COMPANY", companycd );
$.each(categoryjson, function(key, fieldname){
if(addparticipatejson[fieldname] != undefined ){
row[key] = addparticipatejson[fieldname]+"명";
}
});
}
row[key] = categorymrmbrtcountresult["answermembercount"]+"명/"+Math.round((categorymrmbrtcountresult["answermembercount"]/totalcompanymember)*100)+"%";
}
});
});
resultarray.push(row);
row={};
});
resultjson['rows'] = resultarray;
return resultjson;
};
//questiontype이 다중형일 때는 아이디체크를 해야한다.
function count($statusInfoarray, questionseq, type, code, questiontype){
var total = 0;
var tempsaveid = "";
$.each($statusInfoarray, function(index,data){ //회사 단위에서 참여 인원 수
if(type == "COMPANY"){
if(questiontype== 'multiple' && tempsaveid == data['ID'] ){
}else {
if(data['COMPANY_SEQ'] == code && questionseq == data['S_QUESTION_SEQ']){
total++;
tempsaveid= data['ID'];
}
}
}else if(type == "BIZGP"){
if(questiontype== 'multiple' && tempsaveid == data['ID'] ){
}else {
if(data['UP_DEPTCD'] == code && questionseq == data['S_QUESTION_SEQ']){
total++;
tempsaveid= data['ID'];
}
}
}else if(type == "DEPT"){
if(questiontype== 'multiple' && tempsaveid == data['ID'] ){
}else {
if(data['DEPTCD'] == code && questionseq == data['S_QUESTION_SEQ']){
total++;
tempsaveid= data['ID'];}
}
}
});
return total;
};
// 타입에따라서 변화가능하도록 만들어야한다. 참여여부형의 경우는 사람수를 다 더 해서 보여줘야한다.
function categorymrmbrtcount($statusInfoarray, questionseq ,type, category,questiontype,code){
//category 이 CNT1
//alert("categorymrmbrtcount type"+type);
// alert("$statusInfoarray"+$.stringify($statusInfoarray));
var result ={};
var membercount= 0;
var tempsaveid="";
var tempupdept ="";
var deptsOfId= new Array();
var bizgpsOfId= new Array();
var companyOfId= new Array();
var cntsum= 0;
$.each($statusInfoarray, function(index, data){
if(type=='COMPANY'){
if(data['S_ANS_CATEGORY'] == category && data['S_QUESTION_SEQ'] == questionseq && tempsaveid !=data['ID'] ){
membercount++;
companyOfId.push(data['COMPANY_SEQ']);
tempsaveid= data['ID'];
if(questiontype == 'participate' && ( category=='CNT1' ||category=='CNT2' ||category=='CNT3' ||category=='CNT4' ||category=='CNT5') ){
cntsum= cntsum + data[category];
result[category]= cntsum;
}else{
}
}
}else if(type=='BIZ_GP'){
//alert("code == data['UP_DEPTCD']"+code+"/"+data['UP_DEPTCD'])
if(data['S_ANS_CATEGORY'] == category && data['S_QUESTION_SEQ'] == questionseq && tempsaveid !=data['ID'] && code == data['UP_DEPTCD']){
// alert("tempupdept == data['UP_DEPTCD']");
membercount++;
tempupdept =data['UP_DEPTCD'];
bizgpsOfId.push(data['UP_DEPTCD']);
tempsaveid= data['ID'];
if(questiontype == 'participate' && ( category=='CNT1' ||category=='CNT2' ||category=='CNT3' ||category=='CNT4' ||category=='CNT5') ){
cntsum= cntsum + data[category];
result[category]= cntsum;
}
//이부분 수정해야함!
}
//우영
}else if(type=='DEPT'){
//alert("data"+$.stringify(data));
if(data['S_ANS_CATEGORY'] == category && data['S_QUESTION_SEQ'] == questionseq && tempsaveid !=data['ID'] && code == data['DEPTCD'] ){
membercount++;
deptsOfId.push(data['DEPTCD']);
tempsaveid= data['ID'];
if(questiontype == 'participate' && ( category=='CNT1' || category=='CNT2' ||category=='CNT3' ||category=='CNT4' ||category=='CNT5') ){
cntsum= cntsum + data[category];
result[category]= cntsum;
}else{
}
}
}
});
result['answermembercount']=membercount;
result['deptsOfId']= deptsOfId;
result['bizgpsOfId']= bizgpsOfId;
result['companyOfId']= companyOfId;
//result['category']= cntsum;
return result;
};
function makeparticipatejson($statusInfoarray, questionseq,questiontype, targettype, code ){
var tempid= "";
var result={};
var cintsum1=0;
var cintsum2=0;
var cintsum3=0;
var cintsum4=0;
var cintsum5=0;
var noparticipatecount = 0;
var addpaticipatetotal = 0;
$.each($statusInfoarray, function(statusInfoindex, statusInfodata){
if(statusInfodata['S_QUESTION_SEQ'] == questionseq && statusInfodata['SURVEY_TYPE'] == questiontype){
if(targettype=='COMPANY'){
if(statusInfodata['COMPANY_SEQ'] == code && tempid !=statusInfodata['ID'] && statusInfodata['CNT1'] == 1){
cintsum1 = cintsum1 + statusInfodata['CNT1'];
cintsum2 = cintsum2 + statusInfodata['CNT2'];
cintsum3 = cintsum3 + statusInfodata['CNT3'];
cintsum4 = cintsum4 + statusInfodata['CNT4'];
cintsum5 = cintsum5 + statusInfodata['CNT5'];
addpaticipatetotal = cintsum1+cintsum2+cintsum3+cintsum4+cintsum5;
tempid =statusInfodata['ID'];
}else if(statusInfodata['COMPANY_SEQ'] == code && tempid !=statusInfodata['ID'] && statusInfodata['CNT1'] == 0){
noparticipatecount++;
}
}else if(targettype=='BIZGP'){
if(statusInfodata['UP_DEPTCD'] == code && tempid !=statusInfodata['ID'] && statusInfodata['CNT1'] == 1){
cintsum1 = cintsum1 + statusInfodata['CNT1'];
cintsum2 = cintsum2 + statusInfodata['CNT2'];
cintsum3 = cintsum3 + statusInfodata['CNT3'];
cintsum4 = cintsum4 + statusInfodata['CNT4'];
cintsum5 = cintsum5 + statusInfodata['CNT5'];
addpaticipatetotal = cintsum1+cintsum2+cintsum3+cintsum4+cintsum5;
tempid =statusInfodata['ID'];
}else if(statusInfodata['UP_DEPTCD'] == code && tempid !=statusInfodata['ID'] && statusInfodata['CNT1'] == 0){
noparticipatecount++;
}
}else if(targettype=='DEPT'){
if(statusInfodata['DEPTCD'] == code && tempid !=statusInfodata['ID'] && statusInfodata['CNT1'] == 1){
cintsum1 = cintsum1 + statusInfodata['CNT1'];
cintsum2 = cintsum2 + statusInfodata['CNT2'];
cintsum3 = cintsum3 + statusInfodata['CNT3'];
cintsum4 = cintsum4 + statusInfodata['CNT4'];
cintsum5 = cintsum5 + statusInfodata['CNT5'];
addpaticipatetotal = cintsum1+cintsum2+cintsum3+cintsum4+cintsum5;
tempid =statusInfodata['ID'];
}else if(statusInfodata['DEPTCD'] == code && tempid !=statusInfodata['ID'] && statusInfodata['CNT1'] == 0){
noparticipatecount++;
}
}
}
});
result['CNT1'] = cintsum1;
result['CNT2'] = cintsum2;
result['CNT3'] = cintsum3;
result['CNT4'] = cintsum4;
result['CNT5'] = cintsum5;
result['CNT6'] = noparticipatecount; //불참사람수
result['TOTAL'] = addpaticipatetotal; //불참사람수
//여기서 jqgird의 컬럼이름과 맞춰서 넣으면 된댜. 컬럼이름을 NOPARTICIPATE 로 하고, categoryjson에서 받을 때도 {컬럼명:result['']에 들어갈 이름 }으로 해야한다.
return result;
};
function makeArrayForExcel(){
var browser = navigator.userAgent.toLowerCase();
var ie9_chk = navigator.appVersion.indexOf("MSIE 9") > -1 ? true : false;
var chrome_chk = browser.indexOf('chrome') != -1;
if(ie9_chk == false && chrome_chk == false){ // ie8일경우
tableArray.push('statusTable');
tableArray.push('tableForExcel');
tableArray.push("subject");
tableArray.push('list');
tableArray.push("subjectNo");
tableArray.push('listsubmitno');
exportExcelIe8('tableArray');
}else if(ie9_chk==true){ // ie9일경우
alert("인터넷 익스플로러 9 버젼에선 지원하지 않습니다. 익스플로러 8 또는 크롬에서 실행하여 주십시오.");
}
else{ // 크롬일경우
tableToExcel('excelExportChrome', '엑셀상세통계');
}
//downloadExcel('tableArray');
//saveExcel('tableArray');
}
var tableToExcel = (function() { // 크롬에서는!
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(table, name) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML};
window.location.href = uri + base64(format(template, ctx));
};
})()
function exportExcelIe8(targetId, SaveFileName){ // ie8에서
var oNewDoc = document.createDocumentFragment();
var objMeta = oNewDoc.createElement("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
var objHead = oNewDoc.createElement("<head>");
var objHtml = oNewDoc.createElement("<html>");
var objBody = oNewDoc.createElement("<body>");
for(i=0; i<6; i++){
objDownload = document.getElementById(tableArray[i]); // 테이블
var oCloneNode = objDownload.cloneNode(true);
objHead.insertBefore(objMeta);
objHtml.insertBefore(objHead);
objBody.insertBefore(oCloneNode);
objHtml.insertBefore(objBody);
}
var nLength = objDownload.rows.length;
oNewDoc.insertBefore(objHtml);
if(!SaveFileName)
{
SaveFileName='통계엑셀.xls';
}
oNewDoc.execCommand("SaveAs",true, SaveFileName);
}
function sendMail(){
//alert("sendmailmember"+$.stringify(sendmailmember)+"size"+sendmailmember.length);
if($.stringify(sendmailmember) == "{}"){
alert("메일 수신 대상자가 없습니다.");
}else{
var check = confirm("해당 회사/그룹/부서에 속해있는 미참여자에게 메일을 전송하시겠습니까?");
if(check) {
var request = $.ajax({
url : "SendMail.web",
type : "POST",
cache : false,
async : false,
data : {'sendmailmember' : $.stringify(sendmailmember) , 'refNo' : refNo, 'title':title, 'contents': contents, 'fromdate': fromdate, 'todate' :todate},
dataType : "json",
success : function(data) {
//alert($.stringify(data["result"]));
if(data["result"] == "success"){
alert("미참여자 메일을 전송 완료");
window.location.reload(); //페이지 reload
}
},
fail : function(jqXHR, textStatus) {
alert("미참여자 메일을 전송 실퍠");
return false;
}
});
}
}
}
</script>
<body>
<div id="content" class="content">
<div class="nvl h33 bg">
<span>상세통계</span>
<div class="qb w48" id="backDiv">
<a href="FrmSurveyManageList.web">목록</a>
</div>
</div>
<div class="nvl h35 bg2">
<div class="bl">
<span><%=session.getAttribute("USERBELONGINFO") %> <%=session.getAttribute("userNM")%><%=session.getAttribute("WORKPOSITION")%>님 </span>
</div>
<div class="br">
<a href="#" onclick="makeArrayForExcel();" class="btnW2 w111">통계엑셀파일다운</a>
<a class="bt" onclick="sendMail()">메일보내기</a>
<a href="/Logout.web" class="bt">로그아웃</a>
</div>
</div>
<div class="body cb ma15">
<div id='excelExportChrome'>
<div style="margin:10px 0;"></div>
<div id="surveyInfo">
<table id='statusTable' name='statusTable' class="surveyDetail" width="100%" border="1">
<colgroup>
<col width="25%">
<col width="*">
</colgroup>
<tbody id="survey_list">
<tr>
<th bgcolor="#CACACA">설문제목</th>
<td id="survey_title"></td>
</tr>
<tr>
<th bgcolor="#CACACA">대상자</th>
<td id="target"></td>
</tr>
<tr>
<th bgcolor="#CACACA">내용</th>
<td id="survey_content"></td>
</tr>
<tr>
<th bgcolor="#CACACA">작성자</th>
<td id="survey_maker"></td>
</tr>
<tr>
<th bgcolor="#CACACA">조사기간</th>
<td id="survey_period"></td>
</tr>
<tr>
<th bgcolor="#CACACA">설문상태</th>
<td id="survey_status"></td>
</tr>
</tbody>
</table>
</div>
<table id='tableForExcel'>
<div id="questionDiv" width="100%">
</div>
</table>
<table id="list">
</table>
<table id="listsubmitno">
</table>
</div>
<table id='subject' bgcolor="#CACACA" style="display:none">
<tr style="display:none">참여자 분류별 통계</tr>
<td width='100px' align='center'>회사</td> <td width='100px' align='center'>비즈그룹</td> <td width='100px' align='center'>부서</td> <td width='60px' align='center'>직원이름</td> <td width='60px' align='center'>직책</td><td width='80px' align='center'>답변</td><td width='50px' align='center'>본인</td><td width='50px' align='center'>배우자</td><td width='50px' align='center'>기타성인</td><td width='50px' align='center'>초중고</td><td width='50px' align='center'>미취학</td><td width='200px' align='center'>불참사유</td><td width='80px' align='center'>연락처</td><td width='110px' align='center'>E-MAIL</td><td width='60px' align='center'>ID</td>
</table>
<table id='subjectNo' bgcolor="#CACACA" style="display:none">
<tr style="display:none">미참여자 통계</tr>
<td width='100px' align='center'>회사</td> <td width='100px' align='center'>비즈그룹</td> <td width='100px' align='center'>부서</td> <td width='60px' align='center'>직원이름</td> <td width='60px' align='center'>직책</td> <td width='80px' align='center'>연락처</td><td width='110px' align='center'>E-MAIL</td><td width='60px' align='center'>ID</td><td width='60px' align='center'>메일발신여부</td>
</table>
</div>
</div>
</body>
pageEncoding="UTF-8"%>
<script type="text/javascript">
// Hack to make base64.js works in IE8, IE9.
if (!window.btoa) window.btoa = base64.encode;
if (!window.atob) window.atob = base64.decode;
</script>
<script type="text/javascript">
var tableArray = new Array();
var objDownload = null;
var refNo ="";
var title = "";
var contents = "";
var fromdate = "";
var todate = "";
var sendmailmember={};
function initLoad() {
alert("상세 통계화면은 PC 웹브라우저에 최적화 되어 있습니다.");
var targetData = null;
var surveydetailstatusinfo$ = ${surveydetailstatusinfo};
// 메일 보낼 사람들 넣어 놓는다.
var $surveyinfoarray = surveydetailstatusinfo$["surveyinfo"];
var $targetarray = surveydetailstatusinfo$["target"];
var $statusInfoarray = surveydetailstatusinfo$["statusInfo"];
var targetMemberCount = surveydetailstatusinfo$["targetMemberCount"];
refNo = surveydetailstatusinfo$["surveyinfo"][0]["REF_NO"];
title = surveydetailstatusinfo$["surveyinfo"][0]["TITLE"];
contents = surveydetailstatusinfo$["surveyinfo"][0]["CONTENTS"];
fromdate = surveydetailstatusinfo$["surveyinfo"][0]["FROM_DATE"];
todate = surveydetailstatusinfo$["surveyinfo"][0]["TO_DATE"];
var seqTemp = 0;
var categoryTemp = null;
var surveyType = null;
var question = null;
var category = new Array();
var item_data = {};
var items = new Array();
var json_columns = {width:600, align:'center'};
var temp = [[json_columns]];
var temp1 = new Array();
var questionData = null;
var seqArray = new Array();
for(var q=0; q< surveydetailstatusinfo$["surveyinfo"].length; q++){
seqArray[q] = surveydetailstatusinfo$['surveyinfo'][q]['SEQ'];
}
/* $("#subject").hide();
$("#subjectNo").hide(); */
/// 중복제거 함수
Array.prototype.unique = function(){
var a = {};
for(var i=0; i<this.length; i++){
if(typeof a[this[i]] == "undefined")
a[this[i]] = 1;
}
this.length = 0;
for( var i in a)
this[this.length] = i;
return this;
}
var seqArr = new Array();
seqArr = seqArray.unique();
var count=0;
var c = null;
makeDefaultSurveyInfo();
makeSurveyView();
function getTargetInfo(d$) {
var rst = "";
switch (d$['TARGET_TYPE']) {
case "COMPANY":
rst = "회사: " + d$["CODE_DETAIL_NAME"];
break;
case "BIZGROUP":
rst = "그룹: " + d$["CODE_DETAIL_NAME"]
break;
case "DEPT":
rst = "부서: " + d$["CODE_DETAIL_NAME"];
break;
case "MEMBER":
rst = "아이디: " + d$["TARGET_ID"];
break;
}
return rst + (d$["EXCEPT_YN"] == 'n' ? "-참여 | " : "-제외 | ");
}
function makeDefaultSurveyInfo(){
var survey_status = null;
var $targetinfo = surveydetailstatusinfo$["targetinfo"]; //타겟에 대한 정보
var targetMemberCount = surveydetailstatusinfo$["targetMemberCount"]; //대상자 총 인원수
var $memberCountOfClassify = surveydetailstatusinfo$["memberCountOfClassify"];
// 대상자 정보 가공 및 출력
var targetString = "";
$.each($targetinfo, function(idx, data) {
targetString += getTargetInfo(data);
});
var submitCount = 0 ;
var submiPpercent =0;
if($memberCountOfClassify[0] != undefined){
submitCount = $memberCountOfClassify[0]["MEMBERCOUNT"];
submiPpercent = Math.round((submitCount/targetMemberCount) *100);
}
$("#target").html(targetString + "<BR/> 참여인원: "+submitCount+"명" + " (총 인원 : " + targetMemberCount +"명" +": "+submiPpercent +"%)");
$("#survey_title").html(surveydetailstatusinfo$["surveyinfo"][0]["TITLE"]);
$("#survey_content").html(surveydetailstatusinfo$["surveyinfo"][0]["CONTENTS"]);
$("#survey_maker").html(surveydetailstatusinfo$["surveyinfo"][0]["NAME"]);
$("#survey_period").html(surveydetailstatusinfo$["surveyinfo"][0]["FROM_DATE"] + " ~ " + surveydetailstatusinfo$["surveyinfo"][0]["TO_DATE"]);
if(surveydetailstatusinfo$["surveyinfo"][0]["SURVEY_STATUS"] == "ongoing"){
survey_status = "게시중";
}else if(surveydetailstatusinfo$["surveyinfo"][0]["SURVEY_STATUS"] == "stop"){
survey_status = "보류중";
}else{
survey_status = "마감됨";
}
$("#survey_status").html(survey_status);
}
// 질문에 대한 통계의 전체적인 뷰를 만드는 함수
function makeSurveyView(){
for(var i=0; i< surveydetailstatusinfo$["surveyinfo"].length; i++){
if(seqTemp != surveydetailstatusinfo$["surveyinfo"][i]["SEQ"]){
// 각 질문에 대한 기본 내용
seqTemp = surveydetailstatusinfo$["surveyinfo"][i]["SEQ"];
surveyType = surveydetailstatusinfo$["surveyinfo"][i]["SURVEY_TYPE"];
question = surveydetailstatusinfo$["surveyinfo"][i]["QUESTION"];
// 단답형일 경우
if(surveyType == "txt"){
json_columns = {width:450, align:'center'};
$("#questionDiv").append("<table id='tt"+count+ "' class='easyui-treegrid' style='width:1212px;height200px'></table>");
makeTxtRow(count, seqTemp, surveyType, item_data);
clearQuestionData();
count++;
}
//단일형 또는 다중형일 경우
else if(surveyType == "single" || surveyType == "multiple"){
json_columns = {width:450, align:'center'};
$("#questionDiv").append("<table id='tt"+count+"' class='easyui-treegrid' style='width:1212px;height200px'></table>");
makeSingleMultipleRow(count, seqTemp, surveyType, item_data);
clearQuestionData();
count++;
}
// 참여여부형 일 경우
else{
json_columns = {width:450, align:'center'};
$("#questionDiv").append("<table id='tt"+count+"' class='easyui-treegrid' style='width:1212px;height200px'></table>");
makeParticipateRow(count, seqTemp, surveyType, item_data);
clearQuestionData();
count++;
}
}
}
}
// 대상자 목록을 불러오는 함수
function callTargetData(questionSeq, surveyType, item_data){
var dataTemp = null;
dataTemp = makerows($surveyinfoarray, $targetarray, $statusInfoarray, questionSeq, surveyType, item_data);
//alert("makerows"+$.stringify(dataTemp));
var test = KEFJ2EE.CreateMultiKeyObjectArrayFromObjectArray(dataTemp['rows'], "_parentid", "id");
//alert("test"+$.stringify(test));
//window.clipboardData.setData('Text', $.stringify(test));
targetData = null;
targetData = dataTemp;
}
// 질문 데이터 초기화 함수
function clearQuestionData(){
questionData = [];
temp1 = [];
item_data = {};
}
// 단답형 질문의 카테고리 설정 함수
function makeTxtRow(count, questionSeq, surveyType, item_data){
temp1=[];
items = [];
// 질문 설정
json_columns['title'] = question;
json_columns['field'] = 'region';
temp1.push(json_columns);
// 단답형의 기본 설정
json_columns = {}; // 한번 비워주고 다시 삽입
json_columns = {width:80, align:'center'};
json_columns['title'] = "참여도";
json_columns['field'] = "f1";
temp1.push(json_columns);
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "총 대상 인원";
json_columns['field'] = "f2";
temp1.push(json_columns);
questionData = [temp1];
treegridSetting(count, questionSeq, surveyType, item_data);
}
// 단일형, 다중형 질문의 카테고리 설정 함수
function makeSingleMultipleRow(count, questionSeq, surveyType, item_data){
temp1=[];
item_data={};
// 질문 설정
json_columns['title'] = question;
json_columns['field'] = 'region';
temp1.push(json_columns);
json_columns = {}; // 한번 비워주고 다시 삽입
json_columns = {width:80, align:'center'};
json_columns['title'] = "참여도";
json_columns['field'] = "f1";
temp1.push(json_columns);
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "총 대상 인원";
json_columns['field'] = "f2";
temp1.push(json_columns);
c=4;
// 단일형, 다중형 질문의 카테고리 설정
for(var k=0; k< surveydetailstatusinfo$["surveyinfo"].length; k++){
if(surveydetailstatusinfo$["surveyinfo"][k]['SEQ'] == seqTemp){
categoryTemp = surveydetailstatusinfo$["surveyinfo"][k]['CATEGORY'];
json_columns = {width:80, align:'center'};
json_columns["title"] = categoryTemp;
json_columns['field'] = "f"+(c);
temp1.push(json_columns);
json_columns = {};
item_data["f"+c] = categoryTemp;
//items.push(item_data);
//item_data = {};
c++;
}
}
questionData = [temp1];
treegridSetting(count, questionSeq, surveyType, item_data);
}
// 참여여부형 카테고리 설정 함수
function makeParticipateRow(count, questionSeq, surveyType, items){
temp1=[];
item_data={};
// 질문제목, 참여, 불참 등 참여여부형의 기본 카테고리 설정
json_columns['title'] = question;
json_columns['field'] = 'region';
temp1.push(json_columns);
json_columns = {}; // 한번 비워주고 다시 삽입
json_columns = {width:80, align:'center'};
json_columns['title'] = "참여도";
json_columns['field'] = "f1";
temp1.push(json_columns);
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "총 대상 인원";
json_columns['field'] = "f2";
temp1.push(json_columns);
json_columns = {}; // 한번 비워주고 다시 삽입
json_columns = {width:80, align:'center'};
json_columns['title'] = "참여";
json_columns['field'] = "f4";
item_data["f4"] = "CNT1";
temp1.push(json_columns);
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "불참";
json_columns['field'] = "f5";
item_data["f5"] = "CNT6";
temp1.push(json_columns);
json_columns = {};
c=6;
// 참여여부형의 카테고리 설정
for(var k=0; k< surveydetailstatusinfo$["surveyinfo"].length; k++){
if(surveydetailstatusinfo$["surveyinfo"][k]['SEQ'] == seqTemp){
categoryTemp = surveydetailstatusinfo$["surveyinfo"][k]['CATEGORY'];
json_columns = {width:80, align:'center'};
json_columns["title"] = categoryTemp;
json_columns['field'] = "f"+(c);
temp1.push(json_columns);
json_columns = {};
item_data["f"+c] = categoryTemp;
//items.push(item_data);
//item_data = {};
c++;
}
}
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "배우자";
json_columns['field'] = "f"+(c);
item_data["f"+c] = "CNT2";
temp1.push(json_columns);
json_columns = {};
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "기타성인"
json_columns['field'] = "f"+(c+1);
item_data["f"+(c+1)] = "CNT3";
temp1.push(json_columns);
json_columns = {};
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "초중고";
json_columns['field'] = "f"+(c+2);
item_data["f"+(c+2)] = "CNT4";
temp1.push(json_columns);
json_columns = {};
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "미취학";
json_columns['field'] = "f"+(c+3);
item_data["f"+(c+3)] = "CNT5";
temp1.push(json_columns);
json_columns = {};
json_columns = {};
json_columns = {width:80, align:'center'};
json_columns['title'] = "총 참여 인원";
json_columns['field'] = "f"+(c+4);
item_data["f"+(c+4)] = "TOTAL";
temp1.push(json_columns);
json_columns = {};
questionData = [temp1];
treegridSetting(count, questionSeq, surveyType, item_data);
}
// treegrid 첫줄, 질문, 카테고리 설정 함수
function treegridSetting(count, questionSeq, surveyType, item_data){
callTargetData(questionSeq, surveyType, item_data);
$('#tt'+count).treegrid({
idField: 'id',
treeField: 'region',
rownumbers: false,
showFooter: true,
columns : questionData,
onClickRow:function(row){
getTargetMemberByCode(refNo,questionSeq,row['targetType'], row['id']);
}
});
$('#tt'+count).treegrid({
data : targetData});
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$("#list").jqGrid({
datatype: "local",
height: 250,
colNames:['회사','비즈그룹','부서','직원이름','직책', '답변', '본인','배우자','기타성인','초중고','미취학','불참사유','연락처','E-MAIL','ID'],
colModel:[
{name: 'company', index:'company', width: 100, align: 'center'},
{name: 'bizgp', index:'bizgp', width: 100, align: 'center'},
{name: 'dept', index:'dept', width: 100, align: 'center'},
{name: 'name', index:'name', width: 60, align: 'center'},
{name: 'workposition', index:'workposition', width: 60, align: 'center'},
{name: 'answer', index:'answer', width: 80, align: 'center'},
{name: 'cnt1', index:'cnt1', width: 50, align: 'center'},
{name: 'cnt2', index:'cnt2', width: 50, align: 'center'},
{name: 'cnt3', index:'cnt3', width: 50, align: 'center'},
{name: 'cnt4', index:'cnt4', width: 50, align: 'center'},
{name: 'cnt5', index:'cnt5', width: 50, align: 'center'},
{name: 'remark', index:'remark', width: 200, align: 'center'},
{name: 'phone', index:'phone', width: 80, align: 'center'},
{name: 'email', index:'email', width: 110, align: 'center'},
{name: 'id', index:'id', width: 60, align: 'center'}
],
rowNum:10,
rowList:[10,20,30],
pager: '#pager2',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption: '참여자 분류별 통계'
});
$("#list").jqGrid('navGrid','#pager2',{/* options */
add:true,edit:true,view:true,del:true,search:true,refresh:true
// add:false,edit:false,view:false,del:false,search:false,refresh:false
}
,{/* Edit options */
closeAfterAdd: true,
reloadAfterSubmit: false,
closeOnEscape:true
}
,{/* Add options */
closeAfterAdd: true,
reloadAfterSubmit: false,
closeOnEscape:true
}
,{/* Delete options */
reloadAfterSubmit: false,
closeOnEscape:true
}
,{/* Search options */
closeOnEscape:true,
onSearch:function(){
}//onSearch:function(){
}//Search Option
,{/* view parameters*/
closeOnEscape:true
} );
$("#listsubmitno").jqGrid({
datatype: "local",
height: 250,
colNames:['회사','비즈그룹','부서','직원이름','직책', '연락처','E-MAIL','ID','메일수신여부'],
colModel:[
{name: 'company', index:'company', width: 100, align: 'center'},
{name: 'bizgp', index:'bizgp', width: 100, align: 'center'},
{name: 'dept', index:'dept', width: 100, align: 'center'},
{name: 'name', index:'name', width: 60, align: 'center'},
{name: 'workposition', index:'workposition', width: 60, align: 'center'},
{name: 'phone', index:'phone', width: 80, align: 'center'},
{name: 'email', index:'email', width: 110, align: 'center'},
{name: 'id', index:'id', width: 60, align: 'center'},
{name: 'mailsend', index:'maiㅣsend', width: 80, align: 'center'}
],
rowNum:10,
rowList:[10,20,30],
pager: '#pager2',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption: '미참여자 통계'
});
$("#listsubmitno").jqGrid('navGrid','#pager2',{/* options */
add:true,edit:true,view:true,del:true,search:true,refresh:true
// add:false,edit:false,view:false,del:false,search:false,refresh:false
}
,{/* Edit options */
closeAfterAdd: true,
reloadAfterSubmit: false,
closeOnEscape:true
}
,{/* Add options */
closeAfterAdd: true,
reloadAfterSubmit: false,
closeOnEscape:true
}
,{/* Delete options */
reloadAfterSubmit: false,
closeOnEscape:true
}
,{/* Search options */
closeOnEscape:true,
onSearch:function(){
}//onSearch:function(){
}//Search Option
,{/* view parameters*/
closeOnEscape:true
} );
jQuery("#list #listsubmitno").click( function(){
var id = jQuery("#list").jqGrid('getGridParam','selrow');
if (id) {
var ret = jQuery("#list").jqGrid('getRowData',id);
} else { //alert("Please select row");
}
});
/*
jQuery("#a2").click( function(){
var su=jQuery("#list5").jqGrid('delRowData',12);
if(su) //alert("Succes. Write custom code to delete row from server"); else //alert("Allready deleted or not in list");
});
jQuery("#a3").click( function(){
var su=jQuery("#list5").jqGrid('setRowData',11,{amount:"333.00",tax:"33.00",total:"366.00",note:"<img src='images/user1.gif'/>"});
if(su) //alert("Succes. Write custom code to update row in server"); else //alert("Can not update");
});
jQuery("#a4").click( function(){
var datarow = {id:"99",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"};
var su=jQuery("#list5").jqGrid('addRowData',99,datarow);
if(su) //alert("Succes. Write custom code to add data in server"); else //alert("Can not update");
});
*/
}
////////////////////////////////////////////////////// ////////////////////////////////////////////////////// ////////////////////////////////////////////////////// //////////////////////////////////////////////////////
function getTargetMemberByCode(refNo, seq, type , code){
var request = $.ajax({
url : "SelectMembersbydeptcd.web",
type : "POST",
cache : false,
async : false,
data : { refNo : refNo, TYPE : type, CODE : code, QUESTIONSEQ: seq },
dataType : "json",
success : function(data) {
makeMemberList(data["jsonArray_TargetMembers"]); // 투효한 타겟맴버리스트 뿌리느 부분
makeSubmitNoMemberList(data["jsonArray_TargetSubmitNoMembers"],type,code); // 투효 안한 타겟맴버리스트 뿌리느 부분
},
fail : function(jqXHR, textStatus) {
return false;
}
});
};
//타겟맴버리스트 뿌리는 함수
function makeMemberList(memberlistjson){
// memberlsitjson;
$("#list").clearGridData(false); // 기존 데이터 삭제
//$('#tt').treegrid('collapseAll');
for(var i=0; i < memberlistjson.length; i++){
var member = memberlistjson[i];
// alert(member["COMPANYNM"]);
//window.clipboardData.setData('Text', $.stringify(member));
var row ={company:member["COMPANYNM"], bizgp: member["UP_DEPTNM"] ,dept:member["DEPTNM"], name:member["NAME"] , workposition:member["CODE_DETAIL_NAME"],submityn:member["SUBMIT_YN"] ,answer:member["S_ANS_CATEGORY"] ,
cnt1:member["CNT1"] ,cnt2:member["CNT2"] ,cnt3: member["CNT3"],cnt4:member["CNT4"] ,cnt5: member["CNT5"],remark:member["REMARK"], phone:member["PHONE_NO"], email:member["EMAIL"],
id: member["ID"]};
$("#list").addRowData(i,row);
}
};
function makeSubmitNoMemberList(submitnomemberlistjson,type,code){
// submitnomemberlistjson;
sendmailmember = {};
$("#listsubmitno").clearGridData(false); // 기존 데이터 삭제
for(var i=0; i < submitnomemberlistjson.length; i++){
var member = submitnomemberlistjson[i];
if(type=='COMPANY' && code== member['COMPANY']){
var row ={company:member["COMPANYNM"], bizgp: member["UP_DEPTNM"] ,dept:member["DEPTNM"], name:member["NAME"] , workposition:member["CODE_DETAIL_NAME"], submityn:member["SUBMIT_YN"] ,answer:member["S_ANS_CATEGORY"] ,
phone:member["PHONE_NO"], email:member["EMAIL"], id: member["ID"], mailsend: member["MAIL_SEND"]};
$("#listsubmitno").addRowData(i,row);
if(member['MAIL_SEND'] == 'n'){
sendmailmember[member["ID"]] = member["EMAIL"];
}
}else if(type=='BIZ_GP' && code== member['BIZ_GP']){
var row ={company:member["COMPANYNM"], bizgp: member["UP_DEPTNM"] ,dept:member["DEPTNM"], name:member["NAME"] ,workposition:member["CODE_DETAIL_NAME"], submityn:member["SUBMIT_YN"] ,answer:member["S_ANS_CATEGORY"] ,
phone:member["PHONE_NO"], email:member["EMAIL"], id: member["ID"], mailsend: member["MAIL_SEND"]};
$("#listsubmitno").addRowData(i,row);
if(member['MAIL_SEND'] == 'n'){
sendmailmember[member["ID"]] = member["EMAIL"];
}
}else if(type=='DEPT' && code== member['DEPT']){
var row ={company:member["COMPANYNM"], bizgp: member["UP_DEPTNM"] ,dept:member["DEPTNM"], name:member["NAME"] ,workposition:member["CODE_DETAIL_NAME"], submityn:member["SUBMIT_YN"] ,answer:member["S_ANS_CATEGORY"] ,
phone:member["PHONE_NO"], email:member["EMAIL"], id: member["ID"], mailsend: member["MAIL_SEND"]};
$("#listsubmitno").addRowData(i,row);
if(member['MAIL_SEND'] == 'n'){
sendmailmember[member["ID"]] = member["EMAIL"];
}
}
}
return sendmailmember;
};
////////////////////////////////////////////////////// ////////////////////////////////////////////////////// ////////////////////////////////////////////////////// //////////////////////////////////////////////////////
function makerows($surveyinfoarray, $targetarray, $statusInfoarray, questionseq, questiontype, categoryjson){
//alert("$surveyinfoarray"+$.stringify($surveyinfoarray));
var row={};
var resultjson = {};
var resultarray= new Array();
var companynm="";
var bizgpnm ="";
//var bizgpcd ="";
var totalbizmember =0;
var totalcompanymember =0;
var submitYbizmember =0;
var submitYcompanymember =0;
var deptmembercount=0;
var bizgpcount =0;
var grouping = KEFJ2EE.CreateMultiKeyObjectArrayFromObjectArray($targetarray, "COMPANY", "BIZ_GP","DEPT");
$.each(grouping, function(companykey, companydata){
totalcompanymember =0;
$.each(companydata, function(bizgpkey, bizgpdata){
//alert("bizgpdata"+$.stringify(bizgpdata));
totalbizmember=0;
submitYbizmember = 0;
$.each(bizgpdata, function(key, deptdata){
deptmembercount = count($statusInfoarray, questionseq, "DEPT", deptdata[0]['DEPT'], questiontype);
totalbizmember = totalbizmember + deptdata[0]['DEPTMEMBERCOUNT'];
submitYbizmember = submitYbizmember + deptmembercount;
companynm = deptdata[0]['COMPANYNM'];
bizgpnm = deptdata[0]['UP_DEPTNM'];
bizgpcode = deptdata[0]['BIZ_GP'];
//alert("bizgpcd"+$.stringify(bizgpcd));
if(bizgpkey != 'AZ0000'){
row['_parentId']=bizgpkey;
row['region']=deptdata[0]['DEPTNM'];
row['id']=deptdata[0]['DEPT'];
row['f1'] = deptmembercount+"명/"+Math.round((deptmembercount/deptdata[0]['DEPTMEMBERCOUNT'])*100)+"%";
row['f2']=deptdata[0]['DEPTMEMBERCOUNT'];
row['f3']= questionseq;
row['targetType'] = 'DEPT';
$.each(categoryjson, function(key, category){
//seq와 카테고리를 보내주면 인원수를 리턴해주는 함수를 만들어야한다.
var categorymrmbrtcountresult = categorymrmbrtcount($statusInfoarray,questionseq, "DEPT", category,questiontype,deptdata[0]['DEPT']);//우영
//alert("categorymrmbrtcountresult: "+$.stringify(categorymrmbrtcountresult));
$.each(categorymrmbrtcountresult['deptsOfId'], function(index, deptcd){
if(deptcd ==deptdata[0]['DEPT'] ){
//row[key] = categorymrmbrtcountresult["answermembercount"]+"명/"+Math.round((categorymrmbrtcountresult["answermembercount"]/deptdata[0]['DEPTMEMBERCOUNT']*100))+"%";
if(questiontype =='participate'){
var addparticipatejson = makeparticipatejson($statusInfoarray, questionseq,questiontype, "DEPT", deptcd );
//alert("categoryjson"+$.stringify(categoryjson)+"addparticipatejson"+$.stringify(addparticipatejson));
$.each(categoryjson, function(key, fieldname){
if(addparticipatejson[fieldname] != undefined ){
//row[key] = addparticipatejson[fieldname]+"명/"+Math.round((addparticipatejson[fieldname]/deptdata[0]['DEPTMEMBERCOUNT'])*100)+"%";
row[key] = addparticipatejson[fieldname]+"명";
}
});
}
row[key] = categorymrmbrtcountresult["answermembercount"]+"명/"+Math.round((categorymrmbrtcountresult["answermembercount"]/deptdata[0]['DEPTMEMBERCOUNT']*100))+"%";
}
});
});
resultarray.push(row);
row={};
}
});
// if(bizgpkey != 'AZ0000'){
bizgpcount = count($statusInfoarray, questionseq, "BIZGP", bizgpkey,questiontype);
totalcompanymember= totalcompanymember+ totalbizmember;
submitYcompanymember = submitYcompanymember + bizgpcount;
/* totalcompanymember 과 submitYcompanymember에 전사소속인 사람들의 수도 추가해줘야한다. */
/* 전사에 속한 사람수 구함() */
if(bizgpkey != 'AZ0000'){
row['_parentId']=companykey;
row['region']=bizgpnm;
row['id']=bizgpkey;
row['f1'] = submitYbizmember+"명/"+Math.round((submitYbizmember/totalbizmember)*100) +"%";
row['f2']= totalbizmember;
row['f3']= questionseq;
row['targetType'] = 'BIZ_GP';
}else{
/* row['_parentId']=companykey; */
row['_parentId']=companykey;
row['region']=bizgpnm;
row['id']=bizgpkey;
row['f1'] = submitYbizmember+"명/"+Math.round((submitYbizmember/totalbizmember)*100) +"%";
row['f2']= totalbizmember;
row['f3']= questionseq;
row['targetType'] = 'BIZ_GP';
}
$.each(categoryjson, function(key, category){
//seq와 카테고리를 보내주면 인원수를 리턴해주는 함수를 만들어야한다.
var categorymrmbrtcountresult = categorymrmbrtcount($statusInfoarray,questionseq, "BIZ_GP", category, questiontype,bizgpcode);
//alert("categorymrmbrtcountresult: "+$.stringify(categorymrmbrtcountresult));
$.each(categorymrmbrtcountresult['bizgpsOfId'], function(index, bizgpcd){
if(bizgpcd == bizgpkey ){
if(questiontype =='participate'){
// row[key] = categorymrmbrtcountresult["answermembercount"]+"명/"+Math.round((categorymrmbrtcountresult["answermembercount"]/totalbizmember)*100)+"%";
var addparticipatejson = makeparticipatejson($statusInfoarray, questionseq,questiontype, "BIZGP", bizgpcd );
$.each(categoryjson, function(key, fieldname){
if(addparticipatejson[fieldname] != undefined ){
row[key] = addparticipatejson[fieldname]+"명";
}
});
}
row[key] = categorymrmbrtcountresult["answermembercount"]+"명/"+Math.round((categorymrmbrtcountresult["answermembercount"]/totalbizmember)*100)+"%";
}
});
});
resultarray.push(row);
row={};
// }
});
row['region']=companynm;
row['id']=companykey;
row['f1'] = submitYcompanymember+"명/"+Math.round((submitYcompanymember/totalcompanymember)*100)+"%";
row['f2']= totalcompanymember;
row['f3']= questionseq;
row['targetType'] = 'COMPANY';
$.each(categoryjson, function(key, category){
//seq와 카테고리를 보내주면 인원수를 리턴해주는 함수를 만들어야한다.
var categorymrmbrtcountresult = categorymrmbrtcount($statusInfoarray,questionseq, "COMPANY", category,questiontype);
$.each(categorymrmbrtcountresult['companyOfId'], function(index, companycd){
if(companycd == companykey){
//row[key] = categorymrmbrtcountresult["answermembercount"]+"명/"+Math.round((categorymrmbrtcountresult["answermembercount"]/totalcompanymember)*100)+"%";
if(questiontype =='participate'){
row[key] = categorymrmbrtcountresult["answermembercount"]+"명/"+Math.round((categorymrmbrtcountresult["answermembercount"]/totalcompanymember)*100)+"%";
var addparticipatejson = makeparticipatejson($statusInfoarray, questionseq,questiontype, "COMPANY", companycd );
$.each(categoryjson, function(key, fieldname){
if(addparticipatejson[fieldname] != undefined ){
row[key] = addparticipatejson[fieldname]+"명";
}
});
}
row[key] = categorymrmbrtcountresult["answermembercount"]+"명/"+Math.round((categorymrmbrtcountresult["answermembercount"]/totalcompanymember)*100)+"%";
}
});
});
resultarray.push(row);
row={};
});
resultjson['rows'] = resultarray;
return resultjson;
};
//questiontype이 다중형일 때는 아이디체크를 해야한다.
function count($statusInfoarray, questionseq, type, code, questiontype){
var total = 0;
var tempsaveid = "";
$.each($statusInfoarray, function(index,data){ //회사 단위에서 참여 인원 수
if(type == "COMPANY"){
if(questiontype== 'multiple' && tempsaveid == data['ID'] ){
}else {
if(data['COMPANY_SEQ'] == code && questionseq == data['S_QUESTION_SEQ']){
total++;
tempsaveid= data['ID'];
}
}
}else if(type == "BIZGP"){
if(questiontype== 'multiple' && tempsaveid == data['ID'] ){
}else {
if(data['UP_DEPTCD'] == code && questionseq == data['S_QUESTION_SEQ']){
total++;
tempsaveid= data['ID'];
}
}
}else if(type == "DEPT"){
if(questiontype== 'multiple' && tempsaveid == data['ID'] ){
}else {
if(data['DEPTCD'] == code && questionseq == data['S_QUESTION_SEQ']){
total++;
tempsaveid= data['ID'];}
}
}
});
return total;
};
// 타입에따라서 변화가능하도록 만들어야한다. 참여여부형의 경우는 사람수를 다 더 해서 보여줘야한다.
function categorymrmbrtcount($statusInfoarray, questionseq ,type, category,questiontype,code){
//category 이 CNT1
//alert("categorymrmbrtcount type"+type);
// alert("$statusInfoarray"+$.stringify($statusInfoarray));
var result ={};
var membercount= 0;
var tempsaveid="";
var tempupdept ="";
var deptsOfId= new Array();
var bizgpsOfId= new Array();
var companyOfId= new Array();
var cntsum= 0;
$.each($statusInfoarray, function(index, data){
if(type=='COMPANY'){
if(data['S_ANS_CATEGORY'] == category && data['S_QUESTION_SEQ'] == questionseq && tempsaveid !=data['ID'] ){
membercount++;
companyOfId.push(data['COMPANY_SEQ']);
tempsaveid= data['ID'];
if(questiontype == 'participate' && ( category=='CNT1' ||category=='CNT2' ||category=='CNT3' ||category=='CNT4' ||category=='CNT5') ){
cntsum= cntsum + data[category];
result[category]= cntsum;
}else{
}
}
}else if(type=='BIZ_GP'){
//alert("code == data['UP_DEPTCD']"+code+"/"+data['UP_DEPTCD'])
if(data['S_ANS_CATEGORY'] == category && data['S_QUESTION_SEQ'] == questionseq && tempsaveid !=data['ID'] && code == data['UP_DEPTCD']){
// alert("tempupdept == data['UP_DEPTCD']");
membercount++;
tempupdept =data['UP_DEPTCD'];
bizgpsOfId.push(data['UP_DEPTCD']);
tempsaveid= data['ID'];
if(questiontype == 'participate' && ( category=='CNT1' ||category=='CNT2' ||category=='CNT3' ||category=='CNT4' ||category=='CNT5') ){
cntsum= cntsum + data[category];
result[category]= cntsum;
}
//이부분 수정해야함!
}
//우영
}else if(type=='DEPT'){
//alert("data"+$.stringify(data));
if(data['S_ANS_CATEGORY'] == category && data['S_QUESTION_SEQ'] == questionseq && tempsaveid !=data['ID'] && code == data['DEPTCD'] ){
membercount++;
deptsOfId.push(data['DEPTCD']);
tempsaveid= data['ID'];
if(questiontype == 'participate' && ( category=='CNT1' || category=='CNT2' ||category=='CNT3' ||category=='CNT4' ||category=='CNT5') ){
cntsum= cntsum + data[category];
result[category]= cntsum;
}else{
}
}
}
});
result['answermembercount']=membercount;
result['deptsOfId']= deptsOfId;
result['bizgpsOfId']= bizgpsOfId;
result['companyOfId']= companyOfId;
//result['category']= cntsum;
return result;
};
function makeparticipatejson($statusInfoarray, questionseq,questiontype, targettype, code ){
var tempid= "";
var result={};
var cintsum1=0;
var cintsum2=0;
var cintsum3=0;
var cintsum4=0;
var cintsum5=0;
var noparticipatecount = 0;
var addpaticipatetotal = 0;
$.each($statusInfoarray, function(statusInfoindex, statusInfodata){
if(statusInfodata['S_QUESTION_SEQ'] == questionseq && statusInfodata['SURVEY_TYPE'] == questiontype){
if(targettype=='COMPANY'){
if(statusInfodata['COMPANY_SEQ'] == code && tempid !=statusInfodata['ID'] && statusInfodata['CNT1'] == 1){
cintsum1 = cintsum1 + statusInfodata['CNT1'];
cintsum2 = cintsum2 + statusInfodata['CNT2'];
cintsum3 = cintsum3 + statusInfodata['CNT3'];
cintsum4 = cintsum4 + statusInfodata['CNT4'];
cintsum5 = cintsum5 + statusInfodata['CNT5'];
addpaticipatetotal = cintsum1+cintsum2+cintsum3+cintsum4+cintsum5;
tempid =statusInfodata['ID'];
}else if(statusInfodata['COMPANY_SEQ'] == code && tempid !=statusInfodata['ID'] && statusInfodata['CNT1'] == 0){
noparticipatecount++;
}
}else if(targettype=='BIZGP'){
if(statusInfodata['UP_DEPTCD'] == code && tempid !=statusInfodata['ID'] && statusInfodata['CNT1'] == 1){
cintsum1 = cintsum1 + statusInfodata['CNT1'];
cintsum2 = cintsum2 + statusInfodata['CNT2'];
cintsum3 = cintsum3 + statusInfodata['CNT3'];
cintsum4 = cintsum4 + statusInfodata['CNT4'];
cintsum5 = cintsum5 + statusInfodata['CNT5'];
addpaticipatetotal = cintsum1+cintsum2+cintsum3+cintsum4+cintsum5;
tempid =statusInfodata['ID'];
}else if(statusInfodata['UP_DEPTCD'] == code && tempid !=statusInfodata['ID'] && statusInfodata['CNT1'] == 0){
noparticipatecount++;
}
}else if(targettype=='DEPT'){
if(statusInfodata['DEPTCD'] == code && tempid !=statusInfodata['ID'] && statusInfodata['CNT1'] == 1){
cintsum1 = cintsum1 + statusInfodata['CNT1'];
cintsum2 = cintsum2 + statusInfodata['CNT2'];
cintsum3 = cintsum3 + statusInfodata['CNT3'];
cintsum4 = cintsum4 + statusInfodata['CNT4'];
cintsum5 = cintsum5 + statusInfodata['CNT5'];
addpaticipatetotal = cintsum1+cintsum2+cintsum3+cintsum4+cintsum5;
tempid =statusInfodata['ID'];
}else if(statusInfodata['DEPTCD'] == code && tempid !=statusInfodata['ID'] && statusInfodata['CNT1'] == 0){
noparticipatecount++;
}
}
}
});
result['CNT1'] = cintsum1;
result['CNT2'] = cintsum2;
result['CNT3'] = cintsum3;
result['CNT4'] = cintsum4;
result['CNT5'] = cintsum5;
result['CNT6'] = noparticipatecount; //불참사람수
result['TOTAL'] = addpaticipatetotal; //불참사람수
//여기서 jqgird의 컬럼이름과 맞춰서 넣으면 된댜. 컬럼이름을 NOPARTICIPATE 로 하고, categoryjson에서 받을 때도 {컬럼명:result['']에 들어갈 이름 }으로 해야한다.
return result;
};
function makeArrayForExcel(){
var browser = navigator.userAgent.toLowerCase();
var ie9_chk = navigator.appVersion.indexOf("MSIE 9") > -1 ? true : false;
var chrome_chk = browser.indexOf('chrome') != -1;
if(ie9_chk == false && chrome_chk == false){ // ie8일경우
tableArray.push('statusTable');
tableArray.push('tableForExcel');
tableArray.push("subject");
tableArray.push('list');
tableArray.push("subjectNo");
tableArray.push('listsubmitno');
exportExcelIe8('tableArray');
}else if(ie9_chk==true){ // ie9일경우
alert("인터넷 익스플로러 9 버젼에선 지원하지 않습니다. 익스플로러 8 또는 크롬에서 실행하여 주십시오.");
}
else{ // 크롬일경우
tableToExcel('excelExportChrome', '엑셀상세통계');
}
//downloadExcel('tableArray');
//saveExcel('tableArray');
}
var tableToExcel = (function() { // 크롬에서는!
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(table, name) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML};
window.location.href = uri + base64(format(template, ctx));
};
})()
function exportExcelIe8(targetId, SaveFileName){ // ie8에서
var oNewDoc = document.createDocumentFragment();
var objMeta = oNewDoc.createElement("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
var objHead = oNewDoc.createElement("<head>");
var objHtml = oNewDoc.createElement("<html>");
var objBody = oNewDoc.createElement("<body>");
for(i=0; i<6; i++){
objDownload = document.getElementById(tableArray[i]); // 테이블
var oCloneNode = objDownload.cloneNode(true);
objHead.insertBefore(objMeta);
objHtml.insertBefore(objHead);
objBody.insertBefore(oCloneNode);
objHtml.insertBefore(objBody);
}
var nLength = objDownload.rows.length;
oNewDoc.insertBefore(objHtml);
if(!SaveFileName)
{
SaveFileName='통계엑셀.xls';
}
oNewDoc.execCommand("SaveAs",true, SaveFileName);
}
function sendMail(){
//alert("sendmailmember"+$.stringify(sendmailmember)+"size"+sendmailmember.length);
if($.stringify(sendmailmember) == "{}"){
alert("메일 수신 대상자가 없습니다.");
}else{
var check = confirm("해당 회사/그룹/부서에 속해있는 미참여자에게 메일을 전송하시겠습니까?");
if(check) {
var request = $.ajax({
url : "SendMail.web",
type : "POST",
cache : false,
async : false,
data : {'sendmailmember' : $.stringify(sendmailmember) , 'refNo' : refNo, 'title':title, 'contents': contents, 'fromdate': fromdate, 'todate' :todate},
dataType : "json",
success : function(data) {
//alert($.stringify(data["result"]));
if(data["result"] == "success"){
alert("미참여자 메일을 전송 완료");
window.location.reload(); //페이지 reload
}
},
fail : function(jqXHR, textStatus) {
alert("미참여자 메일을 전송 실퍠");
return false;
}
});
}
}
}
</script>
<body>
<div id="content" class="content">
<div class="nvl h33 bg">
<span>상세통계</span>
<div class="qb w48" id="backDiv">
<a href="FrmSurveyManageList.web">목록</a>
</div>
</div>
<div class="nvl h35 bg2">
<div class="bl">
<span><%=session.getAttribute("USERBELONGINFO") %> <%=session.getAttribute("userNM")%><%=session.getAttribute("WORKPOSITION")%>님 </span>
</div>
<div class="br">
<a href="#" onclick="makeArrayForExcel();" class="btnW2 w111">통계엑셀파일다운</a>
<a class="bt" onclick="sendMail()">메일보내기</a>
<a href="/Logout.web" class="bt">로그아웃</a>
</div>
</div>
<div class="body cb ma15">
<div id='excelExportChrome'>
<div style="margin:10px 0;"></div>
<div id="surveyInfo">
<table id='statusTable' name='statusTable' class="surveyDetail" width="100%" border="1">
<colgroup>
<col width="25%">
<col width="*">
</colgroup>
<tbody id="survey_list">
<tr>
<th bgcolor="#CACACA">설문제목</th>
<td id="survey_title"></td>
</tr>
<tr>
<th bgcolor="#CACACA">대상자</th>
<td id="target"></td>
</tr>
<tr>
<th bgcolor="#CACACA">내용</th>
<td id="survey_content"></td>
</tr>
<tr>
<th bgcolor="#CACACA">작성자</th>
<td id="survey_maker"></td>
</tr>
<tr>
<th bgcolor="#CACACA">조사기간</th>
<td id="survey_period"></td>
</tr>
<tr>
<th bgcolor="#CACACA">설문상태</th>
<td id="survey_status"></td>
</tr>
</tbody>
</table>
</div>
<table id='tableForExcel'>
<div id="questionDiv" width="100%">
</div>
</table>
<table id="list">
</table>
<table id="listsubmitno">
</table>
</div>
<table id='subject' bgcolor="#CACACA" style="display:none">
<tr style="display:none">참여자 분류별 통계</tr>
<td width='100px' align='center'>회사</td> <td width='100px' align='center'>비즈그룹</td> <td width='100px' align='center'>부서</td> <td width='60px' align='center'>직원이름</td> <td width='60px' align='center'>직책</td><td width='80px' align='center'>답변</td><td width='50px' align='center'>본인</td><td width='50px' align='center'>배우자</td><td width='50px' align='center'>기타성인</td><td width='50px' align='center'>초중고</td><td width='50px' align='center'>미취학</td><td width='200px' align='center'>불참사유</td><td width='80px' align='center'>연락처</td><td width='110px' align='center'>E-MAIL</td><td width='60px' align='center'>ID</td>
</table>
<table id='subjectNo' bgcolor="#CACACA" style="display:none">
<tr style="display:none">미참여자 통계</tr>
<td width='100px' align='center'>회사</td> <td width='100px' align='center'>비즈그룹</td> <td width='100px' align='center'>부서</td> <td width='60px' align='center'>직원이름</td> <td width='60px' align='center'>직책</td> <td width='80px' align='center'>연락처</td><td width='110px' align='center'>E-MAIL</td><td width='60px' align='center'>ID</td><td width='60px' align='center'>메일발신여부</td>
</table>
</div>
</div>
</body>
'IT노트 > javaScript' 카테고리의 다른 글
자바스크립트 배열로 JSON 만들기 (0) | 2015.05.04 |
---|---|
자바 스크립트 문자열 처리 함수 모음 (0) | 2015.04.13 |
Node.js란? (0) | 2015.03.21 |
ArrayList를 javascript에서 var로 받는 방법!!!! (0) | 2015.03.19 |
tableToExcel('excelExportChrome', '엑셀상세통계'); (0) | 2015.03.17 |