260424_02_ENH: 관리 사이트 엑셀 파일 업로드로 지원자 추가/수정, 투표소 배정/해제 추가
This commit is contained in:
@@ -12,41 +12,71 @@ select case gubun
|
||||
|
||||
case "List"
|
||||
|
||||
DBConnect()
|
||||
DBConnect()
|
||||
|
||||
SQL = ""
|
||||
SQL = SQL&" select a.*, case isnull(b.Status,'') when '1' then '진행중' when '11' then '수정가능' when '10' then '완료' else '미진행' end as status from [No.6].krc_survey.dbo.Dat_2002020_B_exit a "&VbCrlf
|
||||
SQL = SQL&" left join [No.6].krc_survey.dbo.Dat_2002020_B b on a.id=case when CHARINDEX('_', b.IDKey)<>0 then LEFT(b.IDKey, CHARINDEX('_', b.IDKey)-1) end where a.flag='1' "&VbCrlf
|
||||
'response.write SQL
|
||||
Objdb.Open SQL,DBConn,3,1,1
|
||||
If not objdb.eof Then
|
||||
while not objdb.eof
|
||||
response.write "<tr>"&VbCrlf
|
||||
response.write " <td>"&objdb("Q1")&"</td>"&VbCrlf
|
||||
response.write " <td>"&objdb("cluster_nm")&"</td>"&VbCrlf
|
||||
response.write " <td>"&objdb("Q4")&"<input type='hidden' name='E_No' value='"&objdb("ID")&"'/></td>"&VbCrlf
|
||||
response.write " <td>"&objdb("Q3")&"</td>"&VbCrlf
|
||||
response.write " <td>"&objdb("Q10")&"</td>"&VbCrlf
|
||||
response.write " <td>"&objdb("pre_name")&"</td>"&VbCrlf
|
||||
response.write " <td>"&objdb("pre_phone")&"</td>"&VbCrlf
|
||||
response.write " <td>"&objdb("status")&"</td>"&VbCrlf
|
||||
response.write "</tr>"&VbCrlf
|
||||
objdb.movenext
|
||||
wend
|
||||
End If
|
||||
SQL = ""
|
||||
SQL = SQL&" select a.*, case isnull(b.Status,'') when '1' then '진행중' when '11' then '수정가능' when '10' then '완료' else '미진행' end as status from [No.6].krc_survey.dbo.Dat_2002020_B_exit a "&VbCrlf
|
||||
SQL = SQL&" left join [No.6].krc_survey.dbo.Dat_2002020_B b on a.id=case when CHARINDEX('_', b.IDKey)<>0 then LEFT(b.IDKey, CHARINDEX('_', b.IDKey)-1) end where a.flag='1' "&VbCrlf
|
||||
'response.write SQL
|
||||
Objdb.Open SQL,DBConn,3,1,1
|
||||
If not objdb.eof Then
|
||||
while not objdb.eof
|
||||
response.write "<tr>"&VbCrlf
|
||||
response.write " <td>"&objdb("Q1")&"</td>"&VbCrlf
|
||||
response.write " <td>"&objdb("cluster_nm")&"</td>"&VbCrlf
|
||||
response.write " <td>"&objdb("Q4")&"<input type='hidden' name='E_No' value='"&objdb("ID")&"'/></td>"&VbCrlf
|
||||
response.write " <td>"&objdb("Q3")&"</td>"&VbCrlf
|
||||
response.write " <td>"&objdb("Q10")&"</td>"&VbCrlf
|
||||
response.write " <td>"&objdb("pre_name")&"</td>"&VbCrlf
|
||||
response.write " <td>"&objdb("pre_phone")&"</td>"&VbCrlf
|
||||
response.write " <td>"&objdb("status")&"</td>"&VbCrlf
|
||||
response.write "</tr>"&VbCrlf
|
||||
objdb.movenext
|
||||
wend
|
||||
End If
|
||||
|
||||
DBClose()
|
||||
DBClose()
|
||||
|
||||
case "json_list"
|
||||
DBConnect()
|
||||
|
||||
SQL = ""
|
||||
SQL = SQL & " SELECT e_subarea_cd " & VbCrlf
|
||||
SQL = SQL & " ,e_subarea_nm " & VbCrlf
|
||||
SQL = SQL & " ,e_exit_cd " & VbCrlf
|
||||
SQL = SQL & " ,e_full_it " & VbCrlf
|
||||
SQL = SQL & " ,e_it " & VbCrlf
|
||||
SQL = SQL & " ,ex_cd " & VbCrlf
|
||||
SQL = SQL & " ,cluster " & VbCrlf
|
||||
SQL = SQL & " ,e_exit_nm " & VbCrlf
|
||||
SQL = SQL & " ,e_full_nm " & VbCrlf
|
||||
SQL = SQL & " ,e_full_ad " & VbCrlf
|
||||
SQL = SQL & " FROM exitpoll.dbo.R_Exit " & VbCrlf
|
||||
SQL = SQL & " WHERE Flag = 1 " & VbCrlf
|
||||
SQL = SQL & " FOR JSON PATH " & VbCrlf
|
||||
|
||||
Objdb.Open SQL,DBConn
|
||||
If Not Objdb.EOF Then
|
||||
Do While Not Objdb.EOF
|
||||
Response.Write Objdb(0)
|
||||
Objdb.MoveNext
|
||||
Loop
|
||||
Else
|
||||
Response.Write "[]"
|
||||
End If
|
||||
|
||||
DBClose()
|
||||
|
||||
case "confirm"
|
||||
|
||||
If IDKey <> "" Then
|
||||
SQL = "Update krc_survey.dbo.dat_2002020_B set status='10' where Idkey= '"&IDKEY&"'"
|
||||
flag = ExecuteSQL1(SQL)
|
||||
Else
|
||||
flag = false
|
||||
End If
|
||||
If IDKey <> "" Then
|
||||
SQL = "Update krc_survey.dbo.dat_2002020_B set status='10' where Idkey= '"&IDKEY&"'"
|
||||
flag = ExecuteSQL1(SQL)
|
||||
Else
|
||||
flag = false
|
||||
End If
|
||||
|
||||
response.write flag
|
||||
response.write flag
|
||||
|
||||
End Select
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ Dim SQL, Objdb
|
||||
Dim sel_gubun : sel_gubun = Request("sel_gubun")
|
||||
set Objdb = Server.CreateObject("ADODB.Recordset")
|
||||
Dim sel_code : sel_code = Request("sel_code")
|
||||
Dim r_phone : r_phone = Request("r_phone")
|
||||
|
||||
if sel_code = "edu" Then
|
||||
sel_gubun = "edu"
|
||||
@@ -29,7 +30,36 @@ case "code"
|
||||
End If
|
||||
|
||||
DBClose()
|
||||
case "upload_use_code"
|
||||
DBConnect()
|
||||
SQL = ""
|
||||
SQL = SQL & " SELECT gubun, r_cd, r_nm " & vbCrLf
|
||||
SQL = SQL & " FROM [exitpoll].[dbo].[R_code] " & vbCrLf
|
||||
SQL = SQL & " WHERE Flag = 1 AND gubun in ('area','district','position') " & vbCrLf
|
||||
SQL = SQL & " ORDER BY gubun, r_cd " & vbCrLf
|
||||
SQL = SQL & " FOR JSON PATH "
|
||||
|
||||
Objdb.Open SQL,DBConn
|
||||
If Not Objdb.EOF Then
|
||||
Do While Not Objdb.EOF
|
||||
Response.Write Objdb(0)
|
||||
Objdb.MoveNext
|
||||
Loop
|
||||
Else
|
||||
Response.Write "[]"
|
||||
End If
|
||||
|
||||
DBClose()
|
||||
case "phone_exist"
|
||||
DBConnect()
|
||||
SQL = " SELECT 1 FROM exitpoll.dbo.R_info WHERE r_phone = dbo.base64_encode('" & r_phone & "') And flag = 1"
|
||||
Objdb.Open SQL,DBConn,3,1,1
|
||||
if not Objdb.eof Then
|
||||
response.write "EXIST"
|
||||
ELSE
|
||||
response.write "NOT EXIST"
|
||||
End If
|
||||
DBClose()
|
||||
case "edu"
|
||||
Response.Write "<option value=''>선택</option>"
|
||||
DBConnect()
|
||||
|
||||
38
AdminPoll/Ajax/DeployEdit.asp
Normal file
38
AdminPoll/Ajax/DeployEdit.asp
Normal file
@@ -0,0 +1,38 @@
|
||||
<!--#include Virtual="/Lib/config.asp" -->
|
||||
<%
|
||||
Dim SQL, Objdb
|
||||
Dim gubun : gubun = Request("gubun")
|
||||
set Objdb = Server.CreateObject("ADODB.Recordset")
|
||||
Dim r_phone : r_phone = Request("r_phone")
|
||||
Dim exit_cd : exit_cd = Trim(Request("exit_cd"))
|
||||
|
||||
|
||||
Dim flag
|
||||
|
||||
if gubun = "insert" then
|
||||
SQL = ""
|
||||
SQL = SQL & " Delete " & VbcRlf
|
||||
SQL = SQL & " FROM exitpoll.dbo.R_Deploy " & VbcRlf
|
||||
SQL = SQL & " where dbo.base64_decode(r_phone) = '" & r_phone & "' And exit_cd = '" & exit_cd & "'" & VbcRlf
|
||||
ExecuteSQL(SQL)
|
||||
|
||||
SQL = ""
|
||||
SQL = SQL &" insert into exitpoll.dbo.R_Deploy ( r_phone, exit_cd) " & VbcRlf
|
||||
SQL = SQL &" values ( " & VbcRlf
|
||||
SQL = SQL &" dbo.base64_encode('" & r_phone & "'), " & VbcRlf
|
||||
SQL = SQL &" '" & exit_cd & "' " & VbcRlf
|
||||
SQL = SQL &" ) " & VbcRlf
|
||||
flag = ExecuteSQL(SQL)
|
||||
End If
|
||||
|
||||
If gubun = "delete" Then
|
||||
SQL = ""
|
||||
SQL = SQL & " Delete from R_Deploy where dbo.base64_decode(r_phone) = '" & r_phone & "' And exit_cd = '" & exit_cd & "'" & VbcRlf
|
||||
flag = ExecuteSQL(SQL)
|
||||
End If
|
||||
|
||||
|
||||
if flag = True Then
|
||||
response.write "1"
|
||||
End If
|
||||
%>
|
||||
@@ -4,6 +4,7 @@ Dim SQL, Objdb
|
||||
Dim gubun : gubun = Request("gubun")
|
||||
set Objdb = Server.CreateObject("ADODB.Recordset")
|
||||
Dim r_phone : r_phone = Request("r_phone")
|
||||
Dim r_name : r_name = Trim(Request("r_name"))
|
||||
Dim r_position : r_position = Trim(Request("r_position"))
|
||||
Dim r_area : r_area = Request("r_area")
|
||||
Dim r_district : r_district = Request("r_district")
|
||||
@@ -11,15 +12,41 @@ Dim r_edu : r_edu = Trim(Request("r_edu"))
|
||||
|
||||
Dim flag
|
||||
|
||||
if gubun = "insert" then
|
||||
SQL = ""
|
||||
SQL = SQL &" insert into exitpoll.dbo.R_Info (r_name, r_phone, r_pass, r_area, r_district, r_position, r_job, chk) " & VbcRlf
|
||||
SQL = SQL &" values ( " & VbcRlf
|
||||
SQL = SQL &" '" & r_name & "', " & VbcRlf
|
||||
SQL = SQL &" dbo.base64_encode('" & r_phone & "'), " & VbcRlf
|
||||
SQL = SQL &" dbo.base64_encode('" & r_phone & "'), " & VbcRlf
|
||||
SQL = SQL &" '" & r_area & "', " & VbcRlf
|
||||
SQL = SQL &" '" & r_district & "', " & VbcRlf
|
||||
SQL = SQL &" '" & r_position & "', " & VbcRlf
|
||||
SQL = SQL &" '1', " & VbcRlf
|
||||
SQL = SQL &" '0' " & VbcRlf
|
||||
SQL = SQL &" ) " & VbcRlf
|
||||
|
||||
flag = ExecuteSQL(SQL)
|
||||
End If
|
||||
|
||||
if gubun = "update" Then
|
||||
SQL = ""
|
||||
SQL = SQL &" Update exitpoll.dbo.R_Info set "&VbcRlf
|
||||
SQL = SQL &" r_position = '"&r_position&"', "&VbcRlf
|
||||
SQL = SQL &" r_area = '"&r_area&"', "&VbcRlf
|
||||
If r_district <> "" Then
|
||||
If r_name <> "NULL" Then
|
||||
SQL = SQL &" r_name = '"&r_name&"', "&VbcRlf
|
||||
End If
|
||||
If r_position <> "NULL" Then
|
||||
SQL = SQL &" r_position = '"&r_position&"', "&VbcRlf
|
||||
End If
|
||||
If r_area <> "NULL" Then
|
||||
SQL = SQL &" r_area = '"&r_area&"', "&VbcRlf
|
||||
End If
|
||||
If r_district <> "" OR r_district <> "NULL" Then
|
||||
SQL = SQL &" r_district = '"&r_district&"', "&VbcRlf
|
||||
End If
|
||||
SQL = SQL &" r_edu = '"&r_edu&"', "&VbcRlf
|
||||
If r_edu <> "NULL" Then
|
||||
SQL = SQL &" r_edu = '"&r_edu&"', "&VbcRlf
|
||||
End If
|
||||
SQL = SQL &" Udate = getDate() "&VbcRlf
|
||||
SQL = SQL &" where dbo.base64_decode(r_phone) = '"&r_phone&"'; "&VbcRlf
|
||||
flag = ExecuteSQL(SQL)
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
<div class="col-xs-12 col-sm-10">
|
||||
<input type='file' id='excelUploadInput' accept='.xlsx,.xls' style='display:none;' />
|
||||
<br/>
|
||||
<div class="row">
|
||||
<div class="panel">
|
||||
@@ -133,6 +134,7 @@
|
||||
<script src="https://cdn.datatables.net/buttons/1.6.1/js/buttons.html5.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.6.1/js/buttons.print.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/1.6.1/js/buttons.colVis.min.js"></script>
|
||||
<script src="https://cdn.sheetjs.com/xlsx-0.20.3/package/dist/xlsx.full.min.js"></script>
|
||||
<script>
|
||||
function getFlag(){
|
||||
var tmpFlag = $("#delListLoadChk").length == 0 ? "1" : ($("#delListLoadChk").prop("checked") ? "2" : "1");
|
||||
@@ -181,7 +183,20 @@
|
||||
dom:'lBfrtip',
|
||||
lengthCange:false,
|
||||
paging:false,
|
||||
buttons: ['copy', 'excel', 'pdf', 'colvis'],
|
||||
buttons: [
|
||||
'copy',
|
||||
'excel',
|
||||
'pdf',
|
||||
'colvis',
|
||||
{
|
||||
text: 'File Upload',
|
||||
className: 'btn btn-primary',
|
||||
action: function(){
|
||||
$("#excelUploadInput").val("");
|
||||
$("#excelUploadInput").trigger("click");
|
||||
}
|
||||
}
|
||||
],
|
||||
"scrollX": true,
|
||||
"scrollY": "700px",
|
||||
scrollCollapse: true,
|
||||
@@ -190,6 +205,12 @@
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$("#excelUploadInput").on("change", function(){
|
||||
var file = this.files && this.files.length > 0 ? this.files[0] : null;
|
||||
handleExcelUpload(file);
|
||||
});
|
||||
|
||||
$("#r_list_wrapper").prepend("<div id='delListDiv'><label for='delListLoadChk' style='font-weight:bold;'>삭제 목록 보기 <input type='checkbox' value='2' id='delListLoadChk' /></label></div>");
|
||||
|
||||
table.on('preXhr.dt', function(e, settings, data){
|
||||
@@ -325,6 +346,364 @@
|
||||
});
|
||||
}
|
||||
|
||||
function handleExcelUpload(file){
|
||||
if(!file) return;
|
||||
|
||||
var fileName = (file.name || "").toLowerCase();
|
||||
if(!/\.xlsx?$/.test(fileName)){
|
||||
alert("엑셀 파일만 가능합니다. (xlsx, xls)");
|
||||
return;
|
||||
}
|
||||
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(e){
|
||||
try{
|
||||
var workbook = XLSX.read(e.target.result, { type: "array" });
|
||||
var firstSheetName = workbook.SheetNames[0];
|
||||
var secondSheetName = workbook.SheetNames[1];
|
||||
var firstSheet = workbook.Sheets[firstSheetName];
|
||||
var secondSheet = workbook.Sheets[secondSheetName];
|
||||
var upsertUserRows = XLSX.utils.sheet_to_json(firstSheet, { defval: "" });
|
||||
var updateDeployRows = secondSheet ? XLSX.utils.sheet_to_json(secondSheet, { defval: "" }) : [];
|
||||
|
||||
runUploadedExcelTask(upsertUserRows, updateDeployRows);
|
||||
}catch(err){
|
||||
console.error(err);
|
||||
alert("파일을 읽는데 실패했습니다.");
|
||||
}
|
||||
};
|
||||
reader.onerror = function(){
|
||||
alert("파일을 읽을수 없습니다.");
|
||||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
}
|
||||
|
||||
function runUploadedExcelTask(upsertUserRows, updateDeployRows){
|
||||
var upsertUsers = validateUserRow(upsertUserRows);
|
||||
const insertPhones = upsertUsers == undefined? [] : upsertUsers
|
||||
.filter(user => user.gubun === "insert")
|
||||
.map(user => user.r_phone);
|
||||
|
||||
var updateDeploys = validateDeployRow(updateDeployRows, insertPhones);
|
||||
|
||||
if(upsertUsers != undefined && updateDeploys != undefined){
|
||||
var userResult = AjaxExcelUserUpdate(upsertUsers);
|
||||
var deployResult = AjaxExcelDeployUpdate(updateDeploys);
|
||||
|
||||
var completeMessage = "업로드 완료\n";
|
||||
completeMessage += `지원자: 추가(${userResult.insert}), 수정(${userResult.update}), 실패(${userResult.fail})\n`;
|
||||
completeMessage += `투표소: 배정(${deployResult.insert}), 해제(${deployResult.delete}), 실패(${deployResult.fail})`;
|
||||
alert(completeMessage);
|
||||
|
||||
var dt = $("#r_list").DataTable();
|
||||
dt.ajax.reload(null, false);
|
||||
}
|
||||
}
|
||||
|
||||
function returnError(sheetName, rowNum, message){
|
||||
alert(`[${sheetName}] ${(rowNum + 2)}행 ${message}`);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function normalizeCode(v, len) {
|
||||
var s = String(v == null ? "" : v).trim();
|
||||
if (s === "") return "NULL";
|
||||
return len ? s.padStart(len, "0") : s;
|
||||
}
|
||||
|
||||
function validateUserRow(upsertUserRows){
|
||||
var upsertUsers = [];
|
||||
var codeTable = AjaxGetCode();
|
||||
|
||||
var codeMap = {
|
||||
position: {},
|
||||
area: {},
|
||||
district: {}
|
||||
};
|
||||
|
||||
for (var c = 0; c < codeTable.length; c++) {
|
||||
var code = codeTable[c];
|
||||
if (code && code.gubun && codeMap[code.gubun]) {
|
||||
if(code.gubun == "position"){
|
||||
codeMap[code.gubun][String(code.r_nm).trim()] = String(code.r_cd).trim();
|
||||
}
|
||||
else{
|
||||
codeMap[code.gubun][String(code.r_cd).trim()] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < upsertUserRows.length; i++) {
|
||||
var row = upsertUserRows[i];
|
||||
|
||||
var gubun = String(row["구분"]).trim() == "신규" ? "insert" : "update";
|
||||
var r_name = normalizeCode(row["이름"]);
|
||||
var r_phone = normalizeCode(row["연락처"]);
|
||||
var r_position = normalizeCode(row["직책"]);
|
||||
var r_area = normalizeCode(row["지역"], 2);
|
||||
var r_district = normalizeCode(row["권역"], 4);
|
||||
|
||||
if (r_phone == "NULL") {
|
||||
return returnError("지원자 정보", i, "연락처는 필수 입니다.");
|
||||
}
|
||||
|
||||
if (r_phone.charAt(0) !== "0") {
|
||||
r_phone = "0" + r_phone;
|
||||
}
|
||||
|
||||
if (r_district != "NULL" && r_area == "NULL") {
|
||||
return returnError("지원자 정보", i, "권역값이 있으면 지역은 필수입니다.");
|
||||
}
|
||||
|
||||
if (r_position != "NULL" && !codeMap.position[r_position]) {
|
||||
return returnError("지원자 정보", i, "직책이 올바르지 않습니다.");
|
||||
}
|
||||
|
||||
if (r_area != "NULL" && !codeMap.area[r_area]) {
|
||||
return returnError("지원자 정보", i, "지역이 올바르지 않습니다.");
|
||||
}
|
||||
|
||||
if (r_district != "NULL") {
|
||||
if(r_district.substring(0, 2) != r_area) {
|
||||
return returnError("지원자 정보", i, "지역과 권역이 맞지 않습니다.");
|
||||
}
|
||||
if(!codeMap.district[r_district]){
|
||||
return returnError("지원자 정보", i, "권역이 올바르지 않습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
if (gubun == "insert") {
|
||||
if (r_name == "NULL" || r_position == "NULL" || r_area == "NULL" || r_district == "NULL") {
|
||||
return returnError("지원자 정보", i, "신규지원자는 모든 정보가 필수 입니다.");
|
||||
}
|
||||
if (AjaxCheckExistPhone(r_phone)) {
|
||||
return returnError("지원자 정보", i, "신규지원자(연락처)는 이미 존재하여 추가할 수 없습니다.");
|
||||
}
|
||||
} else {
|
||||
if (!AjaxCheckExistPhone(r_phone)) {
|
||||
return returnError("지원자 정보", i, "없는 사용자(연락처) 입니다.");
|
||||
}
|
||||
}
|
||||
|
||||
upsertUsers.push({
|
||||
gubun: gubun,
|
||||
r_name: r_name,
|
||||
r_phone: r_phone,
|
||||
r_position: r_position,
|
||||
r_area: r_area,
|
||||
r_district: r_district
|
||||
});
|
||||
}
|
||||
|
||||
return upsertUsers;
|
||||
}
|
||||
|
||||
function validateDeployRow(updateDeployRows, insertPhones){
|
||||
var updateDeploys = [];
|
||||
var exitTable = AjaxGetExit();
|
||||
var exitCodeMap = {};
|
||||
var normalizeName = function(v){
|
||||
return String(v == null ? "" : v).trim().replace(/\s+/g, " ");
|
||||
};
|
||||
|
||||
for (var e = 0; e < exitTable.length; e++) {
|
||||
var exitRow = exitTable[e];
|
||||
if (exitRow && exitRow.e_full_it != null) {
|
||||
var exitCd = String(exitRow.e_full_it).trim();
|
||||
var exitNm = normalizeName(exitRow.e_exit_nm);
|
||||
|
||||
if (exitNm !== "" && !exitCodeMap[exitNm]) {
|
||||
exitCodeMap[exitNm] = exitCd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < updateDeployRows.length; i++) {
|
||||
var row = updateDeployRows[i];
|
||||
|
||||
var gubunRaw = String(row["구분"] == null ? "" : row["구분"]).trim();
|
||||
var gubun = gubunRaw == "해제" ? "delete" : "insert";
|
||||
var r_phone = normalizeCode(row["연락처"]);
|
||||
if (r_phone != "NULL" && r_phone.charAt(0) !== "0") {
|
||||
r_phone = "0" + r_phone;
|
||||
}
|
||||
var rawExitName = row["투표소 이름"] || row["투표소명"] || row["투표소 명"] || row["e_full_nm"] || row["e_exit_nm"] || row["투표구 명"] || row["투표구명"];
|
||||
var exit_nm = normalizeName(rawExitName);
|
||||
var exit_cd = exitCodeMap[exit_nm] || "NULL";
|
||||
|
||||
if (r_phone == "NULL") {
|
||||
return returnError("투표소 배정 및 해제", i, "연락처는 필수 입니다.");
|
||||
}
|
||||
if (!AjaxCheckExistPhone(r_phone) && !insertPhones.includes(r_phone)) {
|
||||
return returnError("투표소 배정 및 해제", i, "없는 사용자(연락처) 입니다.");
|
||||
}
|
||||
if (exit_nm == "") {
|
||||
return returnError("투표소 배정 및 해제", i, "투표소 이름은 필수 입니다.");
|
||||
}
|
||||
if (exit_cd == "NULL") {
|
||||
return returnError("투표소 배정 및 해제", i, "투표소(" + exit_nm + ")가 존재하지 않습니다.");
|
||||
}
|
||||
|
||||
updateDeploys.push({
|
||||
gubun: gubun,
|
||||
r_phone: r_phone,
|
||||
exit_cd: exit_cd
|
||||
});
|
||||
}
|
||||
|
||||
return updateDeploys;
|
||||
}
|
||||
|
||||
function AjaxGetCode(){
|
||||
var result = [];
|
||||
|
||||
$.ajax({
|
||||
url:"../Ajax/AjaxSelect.asp",
|
||||
method:"POST",
|
||||
async:false,
|
||||
data:{"sel_gubun" : "upload_use_code"},
|
||||
success:function(res){
|
||||
if(res){
|
||||
result = JSON.parse(res);
|
||||
}
|
||||
},
|
||||
error:function(err){
|
||||
alert("System Error\n관리자 문의");
|
||||
console.error(err);
|
||||
result = [];
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function AjaxGetExit(){
|
||||
var result = [];
|
||||
|
||||
$.ajax({
|
||||
url:"../Ajax/AjaxExit.asp",
|
||||
method:"POST",
|
||||
async:false,
|
||||
data:{"gubun" : "json_list"},
|
||||
success:function(res){
|
||||
if(res){
|
||||
result = JSON.parse(res);
|
||||
}
|
||||
},
|
||||
error:function(err){
|
||||
alert("System Error\n관리자 문의");
|
||||
console.error(err);
|
||||
result = [];
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function AjaxCheckExistPhone(r_phone){
|
||||
var exists = false;
|
||||
|
||||
$.ajax({
|
||||
url:"/Ajax/AjaxSelect.asp",
|
||||
method:"POST",
|
||||
async:false,
|
||||
data:{
|
||||
"sel_gubun" : "phone_exist",
|
||||
"r_phone" : r_phone,
|
||||
},
|
||||
success:function(res){
|
||||
exists = (res == "EXIST");
|
||||
},
|
||||
error:function(res){
|
||||
exists = true;
|
||||
}
|
||||
});
|
||||
|
||||
return exists;
|
||||
}
|
||||
|
||||
function AjaxExcelUserUpdate(upsertRows){
|
||||
if(upsertRows == undefined) return {"insert": 0, "update": 0, "fail": 0};
|
||||
|
||||
var insertCnt = 0;
|
||||
var updateCnt = 0;
|
||||
var failCnt = 0;
|
||||
|
||||
upsertRows.forEach((upsertRow) => {
|
||||
$.ajax({
|
||||
url:"/Ajax/Redit.asp",
|
||||
method:"POST",
|
||||
async:false,
|
||||
data:{
|
||||
"gubun" : upsertRow.gubun,
|
||||
"r_name" : upsertRow.r_name,
|
||||
"r_phone" : upsertRow.r_phone,
|
||||
"r_position" : upsertRow.r_position,
|
||||
"r_area" : upsertRow.r_area,
|
||||
"r_district" : upsertRow.r_district,
|
||||
"r_edu" : "NULL"
|
||||
},
|
||||
success:function(res){
|
||||
if(res == "1"){
|
||||
if(upsertRow.gubun == "insert") {
|
||||
insertCnt++;
|
||||
}
|
||||
else{
|
||||
updateCnt++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
failCnt++;
|
||||
}
|
||||
},
|
||||
error:function(res){
|
||||
return failCnt++;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return {"insert": insertCnt, "update": updateCnt, "fail": failCnt};
|
||||
}
|
||||
|
||||
function AjaxExcelDeployUpdate(updateRows){
|
||||
if(updateRows == undefined) return {"insert": 0, "delete": 0, "fail": 0};
|
||||
|
||||
var insertCnt = 0;
|
||||
var deleteCnt = 0;
|
||||
var failCnt = 0;
|
||||
|
||||
updateRows.forEach((updateRow) => {
|
||||
$.ajax({
|
||||
url:"/Ajax/DeployEdit.asp",
|
||||
method:"POST",
|
||||
async:false,
|
||||
data:{
|
||||
"gubun" : updateRow.gubun,
|
||||
"r_phone" : updateRow.r_phone,
|
||||
"exit_cd" : updateRow.exit_cd,
|
||||
},
|
||||
success:function(res){
|
||||
if(res == "1"){
|
||||
if(updateRow.gubun == "insert") {
|
||||
insertCnt++;
|
||||
}
|
||||
else{
|
||||
deleteCnt++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
failCnt++;
|
||||
}
|
||||
},
|
||||
error:function(res){
|
||||
return failCnt++;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return {"insert": insertCnt, "delete": deleteCnt, "fail": failCnt};
|
||||
}
|
||||
|
||||
function AjaxUpdate(gubun, phone, position, area, district, edu){
|
||||
$.ajax({
|
||||
url:"/Ajax/Redit.asp",
|
||||
@@ -332,6 +711,7 @@
|
||||
async:false,
|
||||
data:{
|
||||
"gubun" : gubun,
|
||||
"r_name" : "NULL",
|
||||
"r_phone" : phone,
|
||||
"r_position" : position,
|
||||
"r_area" : area,
|
||||
@@ -361,4 +741,4 @@
|
||||
}
|
||||
|
||||
</script>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user