Files
sam-api/public/admin/js/custom.js
2025-07-17 10:05:47 +09:00

1591 lines
46 KiB
JavaScript

$(document).ready(function () {
// Page Preloader
$('#status').fadeOut();
$('#preloader').delay(200).fadeOut(function () {
$('body').delay(200).css({'overflow': 'visible'});
});
// 좌측메뉴 스토리지
let leftMenuType = localStorage.getItem("leftMenuType");
if(leftMenuType=='close'){
$('.menutoggle').addClass('menu-collapsed');
$('body').addClass('leftpanel-collapsed');
$('ul.children').css("display","");
}else{
$('.menutoggle').removeClass('menu-collapsed');
$('body').removeClass('leftpanel-collapsed');
$('ul.children').css("display","block");
};
// 로딩바 제거
// 상단 스케쥴 - 이동
$('.headSchedule,.headSchedule-mobile').click(function (e) {
location.href="/html/dashboard.html";
});
// Toggle Left Menu
$('.leftpanel .nav-parent > a').live('click', function () {
var parent = $(this).parent();
var sub = parent.find('> ul');
// Dropdown works only when leftpanel is not collapsed
if (!$('body').hasClass('leftpanel-collapsed')) {
if (sub.is(':visible')) {
sub.slideUp(200, function () {
parent.removeClass('nav-active');
$('.mainpanel').css({height: ''});
adjustmainpanelheight();
});
} else {
closeVisibleSubMenu();
parent.addClass('nav-active');
sub.slideDown(200, function () {
adjustmainpanelheight();
});
}
}
return false;
});
function closeVisibleSubMenu() {
$('.leftpanel .nav-parent').each(function () {
var t = $(this);
if (t.hasClass('nav-active')) {
t.find('> ul').slideUp(200, function () {
t.removeClass('nav-active');
});
}
});
}
function adjustmainpanelheight() {
// Adjust mainpanel height
var docHeight = $(document).height();
if (docHeight > $('.mainpanel').height())
$('.mainpanel').height(docHeight);
}
adjustmainpanelheight();
// Tooltip
$('.tooltips').tooltip({container: 'body'});
// Popover
$('.popovers').popover();
// Close Button in Panels
$('.panel .panel-close').click(function () {
$(this).closest('.panel').fadeOut(200);
return false;
});
// Form Toggles
$('.toggle').toggles({on: true});
$('.toggle-chat1').toggles({on: false});
// Sparkline
$('#sidebar-chart').sparkline([4, 3, 3, 1, 4, 3, 2, 2, 3, 10, 9, 6], {
type: 'bar',
height: '30px',
barColor: '#428BCA'
});
$('#sidebar-chart2').sparkline([1, 3, 4, 5, 4, 10, 8, 5, 7, 6, 9, 3], {
type: 'bar',
height: '30px',
barColor: '#D9534F'
});
$('#sidebar-chart3').sparkline([5, 9, 3, 8, 4, 10, 8, 5, 7, 6, 9, 3], {
type: 'bar',
height: '30px',
barColor: '#1CAF9A'
});
$('#sidebar-chart4').sparkline([4, 3, 3, 1, 4, 3, 2, 2, 3, 10, 9, 6], {
type: 'bar',
height: '30px',
barColor: '#428BCA'
});
$('#sidebar-chart5').sparkline([1, 3, 4, 5, 4, 10, 8, 5, 7, 6, 9, 3], {
type: 'bar',
height: '30px',
barColor: '#F0AD4E'
});
// Minimize Button in Panels
$('.minimize').click(function () {
var t = $(this);
var p = t.closest('.panel');
if (!$(this).hasClass('maximize')) {
p.find('.panel-body, .panel-footer').slideUp(200);
t.addClass('maximize');
t.html('+');
} else {
p.find('.panel-body, .panel-footer').slideDown(200);
t.removeClass('maximize');
t.html('−');
}
return false;
});
// Add class everytime a mouse pointer hover over it
$('.nav-bracket > li').hover(function () {
$(this).addClass('nav-hover');
}, function () {
$(this).removeClass('nav-hover');
});
// Menu Toggle
$('.menutoggle').click(function () {
var body = $('body');
var bodypos = body.css('position');
if (bodypos != 'relative') {
if (!body.hasClass('leftpanel-collapsed')) {
body.addClass('leftpanel-collapsed');
$('.nav-bracket ul').attr('style', '');
$(this).addClass('menu-collapsed');
localStorage.setItem("leftMenuType", 'close');
} else {
body.removeClass('leftpanel-collapsed chat-view');
$('.nav-bracket li.active ul').css({display: 'block'});
$(this).removeClass('menu-collapsed');
localStorage.removeItem("leftMenuType");
}
} else {
if (body.hasClass('leftpanel-show'))
body.removeClass('leftpanel-show');
else
body.addClass('leftpanel-show');
adjustmainpanelheight();
}
});
// Chat View
$('#chatview').click(function () {
var body = $('body');
var bodypos = body.css('position');
if (bodypos != 'relative') {
if (!body.hasClass('chat-view')) {
body.addClass('leftpanel-collapsed chat-view');
$('.nav-bracket ul').attr('style', '');
} else {
body.removeClass('chat-view');
if (!$('.menutoggle').hasClass('menu-collapsed')) {
$('body').removeClass('leftpanel-collapsed');
$('.nav-bracket li.active ul').css({display: 'block'});
} else {
}
}
} else {
if (!body.hasClass('chat-relative-view')) {
body.addClass('chat-relative-view');
body.css({left: ''});
} else {
body.removeClass('chat-relative-view');
}
}
});
reposition_topnav();
reposition_searchform();
$(window).resize(function () {
if ($('body').css('position') == 'relative') {
$('body').removeClass('leftpanel-collapsed chat-view');
} else {
$('body').removeClass('chat-relative-view');
$('body').css({left: '', marginRight: ''});
}
reposition_searchform();
reposition_topnav();
});
/* This function will reposition search form to the left panel when viewed
* in screens smaller than 767px and will return to top when viewed higher
* than 767px
*/
function reposition_searchform() {
if ($('.searchform').css('position') == 'relative') {
$('.searchform').insertBefore('.leftpanelinner .userlogged');
} else {
$('.searchform').insertBefore('.header-right');
}
}
/* This function allows top navigation menu to move to left navigation menu
* when viewed in screens lower than 1024px and will move it back when viewed
* higher than 1024px
*/
function reposition_topnav() {
if ($('.nav-horizontal').length > 0) {
// top navigation move to left nav
// .nav-horizontal will set position to relative when viewed in screen below 1024
if ($('.nav-horizontal').css('position') == 'relative') {
if ($('.leftpanel .nav-bracket').length == 2) {
$('.nav-horizontal').insertAfter('.nav-bracket:eq(1)');
} else {
// only add to bottom if .nav-horizontal is not yet in the left panel
if ($('.leftpanel .nav-horizontal').length == 0)
$('.nav-horizontal').appendTo('.leftpanelinner');
}
$('.nav-horizontal').css({display: 'block'})
.addClass('nav-pills nav-stacked nav-bracket');
$('.nav-horizontal .children').removeClass('dropdown-menu');
$('.nav-horizontal > li').each(function () {
$(this).removeClass('open');
$(this).find('a').removeAttr('class');
$(this).find('a').removeAttr('data-toggle');
});
if ($('.nav-horizontal li:last-child').has('form')) {
$('.nav-horizontal li:last-child form').addClass('searchform').appendTo('.topnav');
$('.nav-horizontal li:last-child').hide();
}
} else {
// move nav only when .nav-horizontal is currently from leftpanel
// that is viewed from screen size above 1024
if ($('.leftpanel .nav-horizontal').length > 0) {
$('.nav-horizontal').removeClass('nav-pills nav-stacked nav-bracket')
.appendTo('.topnav');
$('.nav-horizontal .children').addClass('dropdown-menu').removeAttr('style');
$('.nav-horizontal li:last-child').show();
$('.searchform').removeClass('searchform').appendTo('.nav-horizontal li:last-child .dropdown-menu');
$('.nav-horizontal > li > a').each(function () {
$(this).parent().removeClass('nav-active');
if ($(this).parent().find('.dropdown-menu').length > 0) {
$(this).attr('class', 'dropdown-toggle');
$(this).attr('data-toggle', 'dropdown');
}
});
}
}
}
}
// Sticky Header
if ($.cookie('sticky-header'))
$('body').addClass('stickyheader');
// Sticky Left Panel
if ($.cookie('sticky-leftpanel')) {
$('body').addClass('stickyheader');
$('.leftpanel').addClass('sticky-leftpanel');
}
// Left Panel Collapsed
if ($.cookie('leftpanel-collapsed')) {
$('body').addClass('leftpanel-collapsed');
$('.menutoggle').addClass('menu-collapsed');
}
// Changing Skin
var c = $.cookie('change-skin');
if (c) {
$('head').append('<link id="skinswitch" rel="stylesheet" href="css/style.' + c + '.css" />');
}
// Changing Font
var fnt = $.cookie('change-font');
if (fnt) {
$('head').append('<link id="fontswitch" rel="stylesheet" href="css/font.' + fnt + '.css" />');
}
// Check if leftpanel is collapsed
if ($('body').hasClass('leftpanel-collapsed'))
$('.nav-bracket .children').css({display: ''});
// Handles form inside of dropdown
$('.dropdown-menu').find('form').click(function (e) {
e.stopPropagation();
});
});
(function ($, window) {
$.fn.contextMenu = function (settings) {
return this.each(function () {
// Open context menu
$(this).on("contextmenu", function (e) {
// return native menu if pressing control
if (e.ctrlKey) return;
var user_no = $(this).data("id");
$("#user_no").val(user_no);
//open menu
var $menu = $(settings.menuSelector)
.data("invokedOn", $(e.target))
.show()
.css({
position: "absolute",
left: getMenuPosition(e.clientX, 'width', 'scrollLeft'),
top: getMenuPosition(e.clientY, 'height', 'scrollTop')
})
.off('click')
.on('click', 'a', function (e) {
$menu.hide();
var $invokedOn = $menu.data("invokedOn");
var $selectedMenu = $(e.target);
settings.menuSelected.call(this, $invokedOn, $selectedMenu);
});
return false;
});
//make sure menu closes on any click
$('body').click(function () {
$(settings.menuSelector).hide();
});
});
function getMenuPosition(mouse, direction, scrollDir) {
var win = $(window)[direction](),
scroll = $(window)[scrollDir](),
menu = $(settings.menuSelector)[direction](),
position = mouse + scroll;
// opening menu would pass the side of the page
if (mouse + menu > win && menu < mouse)
position -= menu;
return position;
}
};
})($, window);
$(".table td.member-id").contextMenu({
menuSelector: "#contextMenu",
menuSelected: function (invokedOn, selectedMenu) {
var msg = "You selected the menu item '" + selectedMenu.text() +
"' on the value '" + invokedOn.text() + "'";
}
});
// 회원아이디 오른쪽 클릭 메뉴 링크
function popSelMenu(menuMode) {
var user_no = $("#user_no").val();
switch (menuMode) {
case "memInfo" :
popUserInfo(user_no)
break;
case "addHistory" :
popUserHistory(user_no);
break;
case "useStore" :
popUserStore(user_no);
break;
case "smsSend" :
popUserSMS(user_no);
break;
case "mailSend" :
popUserMail(user_no);
break;
default:
break;
}
}
// 구글시트 이동
function popGoogleSheet(sheetId, sheet) {
if(sheetId && sheet) {
//window.open('https://docs.google.com/spreadsheets/d/' + spreadSheetId + '/edit#gid=' + sheetId + '&range=B' + sheet, 'GoogleSheet');
}
}
// 노션페이지 팝업
function popNotion(url) {
window.open(url, 'Notion');
event.stopImmediatePropagation();
}
// 업무 등록
function popWorkTask(task_no) {
let options = popSize(550,750);
let uri = '/html/plan/work_reg.html?task_no=' + task_no;
window.open(uri, 'WorkTask', options + ', toolbar=no, menubar=no, scrollbars=no, resizable=no');
}
// 업무 확인
function popWorkTaskView(task_no) {
let options = popSize(550,750);
let uri = '/html/plan/work_view.html?task_no=' + task_no;
window.open(uri, 'WorkTask', options + ', toolbar=no, menubar=no, scrollbars=no, resizable=no');
}
// 업무 복사 (등록)
function popWorkTaskDuplicate(task_no) {
let options = popSize(550,750);
let uri = '/html/plan/work_reg.html?duplicate_no=' + task_no;
window.open(uri, 'WorkTask_' + task_no, options + ', toolbar=no, menubar=no, scrollbars=no, resizable=no');
}
// 완료처리 팝업
function popWorkCompTask(task_no) {
let options = popSize(530,340);
let uri = '/html/plan/work_comp.html?task_no=' + task_no;
window.open(uri, 'WorkTaskComp_' + task_no, options + ', toolbar=no, menubar=no, scrollbars=no, resizable=no');
}
/* 업무 등록*/
$('#work-complete').on("click",function(){
var formData = $("#dailyTaskInput").serialize();
let breakChk = false;
$(".memberTime").each(function(){
if(!$(this).val() || $(this).val() == 0 || $(this).val()=='0.0'){
$(this).val('');
$(this).focus();
breakChk = true;
return false;
}
});
if(breakChk) {
alert("작업시간은 필수 입니다.");
return;
}
let banner = $('#banner').val() == 0 || !$('#banner').val() ? false : true;
let detail = $('#detail').val() == 0 || !$('#detail').val() ? false : true;
if($('#designYn').val() == 'Y' && !banner && !detail ){
alert("디자이너가 포함된경우 디자안(배너, 상세)값을 입력해 주세요.");
return;
}
if($('#designYn').val() == 'N' && (banner || detail) ){
if(!confirm("디자이너가 포함되지 않았는데 이미지 작업건이 있습니다. 이대로 처리 하시겠습니까?")) return;
}else{
if(!confirm('해당건을 처리 하시겠습니까?')) return;
}
$.ajax({
cache : false,
url : "/html/process.html", // 요기에
type : 'POST',
data : formData,
success : function(data) {
if(data=='Success' || data == 'Auth'){
top.opener.location.reload();
self.close();
}
else alert(data);
}, // success
error : function(xhr, status) {
alert(xhr + " : " + status);
}
}); // $.ajax */
})
/* 업무 완료 복구*/
$('.work-restore').on("click",function(e){
e.stopPropagation();
let task_idx = $(this).data('idx');
let refpage = '/plan/work_reg.html';
if(!task_idx){
alert('업무관리번호가 없습니다.');
return;
}
if(!confirm('해당건을 복구 하시겠습니까?')) return;
$.ajax({
cache : false,
url : "/html/process.html", // 요기에
type : 'POST',
data : {task_idx:task_idx,mod:'restore',refpage:refpage },
success : function(data) {
if(data=='Success' || data == 'Auth'){
location.reload();
}
else alert(data);
}, // success
error : function(xhr, status) {
alert(xhr + " : " + status);
}
});
})
// 업무일지 등록
function popPlanTask(pt_no,month) {
let options = popSize(600,550);
let uri = '/html/plan/daily_reg.html?pt_no=' + pt_no;
if(month) uri += '&month=' + month;
window.open(uri, 'PlanTask', options + ', toolbar=no, menubar=no, scrollbars=Yes, resizable=no');
}
// 회원 회원정보
function popUserInfo(user_no) {
window.open('/html/member/member_detail.html?user_no=' + user_no, '회원정보_' + user_no, 'width=800, height=700, toolbar=no, menubar=no, scrollbars=no, resizable=yes');
}
// 회원 회원등록/수정
function popUserMember(user_no) {
let options = popSize(800,510);
window.open('/html/member/member_Add.html?user_no=' + user_no, '회원등록/수정', options + ', toolbar=no, menubar=no, scrollbars=no, resizable=no');
}
// 업체정보
function popCompanyInfo(com_no) {
let options = popSize(800,510);
window.open('/html/company/company_detail.html?com_no=' + com_no, '업체정보_' + com_no, options + ', toolbar=no, menubar=no, scrollbars=no, resizable=yes');
}
$('.company-id').on("click",function() {
let com_no = $(this).data('idx');
if(com_no) popCompanyInfo(com_no);
})
// 업체등록/수정
function popCompany(user_no) {
let options = popSize(800,510);
window.open('/html/company/company_add.html?com_no=' + user_no, '회원등록/수정', options + ', toolbar=no, menubar=no, scrollbars=no, resizable=no');
}
// 화면중간에 팝업 띄우기
function popSize(width,height){
let left = (screen.width - width) / 2; // 가로 가운데 정렬을 위한 왼쪽 위치 계산
let top = (screen.height - height) / 2; // 세로 가운데 정렬을 위한 상단 위치 계산
let options = 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top;
return options;
}
$(document).ready(function () {
//최상단 체크박스 클릭
$(".checkall").click(function () {
//클릭되었으면
if ($(".checkall").prop("checked")) {
//input태그의 name이 chk인 태그들을 찾아서 checked옵션을 true로 정의
$("input[name=chk]").prop("checked", true);
//클릭이 안되있으면
} else {
//input태그의 name이 chk인 태그들을 찾아서 checked옵션을 false로 정의
$("input[name=chk]").prop("checked", false);
}
})
$('.btn-toggle').click(function () {
$(this).find('.btn').toggleClass('active');
if ($(this).find('.btn-primary').length > 0) {
$(this).find('.btn').toggleClass('btn-primary');
}
if ($(this).find('.btn-danger').length > 0) {
$(this).find('.btn').toggleClass('btn-danger');
}
if ($(this).find('.btn-success').length > 0) {
$(this).find('.btn').toggleClass('btn-success');
}
if ($(this).find('.btn-info').length > 0) {
$(this).find('.btn').toggleClass('btn-info');
}
$(this).find('.btn').toggleClass('btn-default');
});
/* 창 닫기 */
$('#btn-close').on("click",function(){
self.close();
})
/* 이전페이지로 */
$('#btn-back').on("click",function(){
history.go(-1);
})
});
/* 게시판 관리버튼 기능 [E] */
// datepicker
$(document).ready(function () {
$(function () {
$("#sdate").datepicker({dateFormat: 'yy-mm-dd', maxDate: '<?=date("Y-m-d");?>'});
$(".datepicker").datepicker({dateFormat: 'yy-mm-dd'});
});
});
// 날자 설정
function SetDate(O, S, E) {
let n = new Date();
let strF = O.charAt(0); // 첫글자
let strFP = O.slice(1) * 1; // 나머지글자
let strL = O.slice(-1); // 마지막글자
let strLP = O.slice(0,-1) * 1; // 마지막글자를 제외한
let stDate, enDate = n, last;
// 지난 월도 선택
if(strF=='B'){
stDate = new Date(n.getFullYear(), n.getMonth() - strFP, 1);
last = (new Date(stDate.getFullYear(), stDate.getMonth() + 1, 0)).getDate();
enDate = new Date(stDate.getFullYear(), stDate.getMonth() , last);
}
// 지금으로 부터 몇개월 전
else if(strL=='M'){
strLP = (strLP) ? strLP - 1 : 0;
stDate = new Date(n.getFullYear(), n.getMonth() - strLP, 1);
}
// 지난 년도
else if(strF=='Y'){
stDate = new Date(n.getFullYear() - strFP, 0, 1);
enDate = new Date(stDate.getFullYear(), 11, 31);
}
else {
switch (O) {
case 'T': stDate = n; break;
case '1': stDate = new Date(n.getFullYear(), n.getMonth(), n.getDate() - 1); enDate = stDate; break;
case '7': stDate = new Date(n.getFullYear(), n.getMonth(), n.getDate() - 7); break;
case '30': stDate = new Date(n.getFullYear(), n.getMonth(), n.getDate() - 30); break;
}
}
let sdate = getDateFormat(stDate);
let edate = getDateFormat(enDate);
$("#"+S).val(sdate);
$("#"+E).val(edate);
// option : 리포트에서 클릭시 리포트로 이동 기능
report(sdate, edate, O);
}
function getDateFormat(currentDate) {
var year = currentDate.getFullYear();
var month = ("0" + (currentDate.getMonth() + 1)).slice(-2);
var day = ("0" + currentDate.getDate()).slice(-2);
// YYYY-mm-dd 형식으로 날짜 구성
var formattedDate = year + "-" + month + "-" + day;
return formattedDate;
}
function report(sdate, edate, searDateType) {
if(sdate && edate) {
let f=document.scform;
f.searDateType.value=searDateType;
f.submit();
}
}
// 테이블 정렬
$(document).ready(function() {
// 테이블을 tablesorter로 초기화
$("#myTable").tablesorter();
});
// 엑셀다운로드
$(document).ready(function() {
$('.excelDown').on('click', function(){
let targetTable = $(this).data('target');
if(!targetTable){
return '엑셀전환 테이블이 없습니다.';
}
var datatodisplay = $("<div>").append($("#"+targetTable).clone().eq(0)).html();
$("#datatodisplay").val( $("<div>").append($("#"+targetTable).clone().eq(0)).html());
frm_excel_down.action = "/html/make_excel.php";
frm_excel_down.target = "ifr_pro";
frm_excel_down.submit();
})
$('.excelDownForm').on('click', function(){
let targetUrl = $(this).data('target');
if(!targetUrl){
return '엑셀파일이 없습니다.';
}
var datatodisplay = $("<div>").append($("#"+targetUrl).clone().eq(0)).html();
$("#datatodisplay").val( $("<div>").append($("#"+targetUrl).clone().eq(0)).html());
location.href="/html/excelFile/"+targetUrl+'.php'
/* frm_excel_down.action = "/html/excelFile/"+targetUrl+'.php';
frm_excel_down.target = "ifr_pro";
frm_excel_down.submit();*/
})
});
// cell merge
function mergeCell(tableId) {
// variable 정의
var first = true;
var prevRowspan1 = 1;
var prevCell1 = null;
var prevRowspan2 = 1;
var prevCell2 = null;
// tr 모두 추출
var rows = $("#" + tableId + " > tbody").children();
for (var i = 0; i < rows.length; i++ ) {
// first row
if (first) {
prevRow = rows[i];
prevCell1 = $(prevRow).find("td").eq(0); // 기간
prevCell2 = $(prevRow).find("td").eq(1); // 성별
// console.log("#############################################");
// console.log("## first row process");
// console.log("#############################################");
// console.log(prevCell1);
// console.log(prevCell2);
first = false;
continue;
}
var row = rows[i]; // row
var tdList = $(row).find("td"); // row > td 리스트
var firstCell = $(tdList).eq(0); // 첫 번째 행
var secondCell = $(tdList).eq(1); // 두 번째 행
var firstCellText = $(firstCell).text(); // 첫 번째 행 text 추출
var secondCellText = $(secondCell).text() // 두 번째 행 text 추출
// 두 번째 row 부터 텍스트 비교
if (prevCell1.text() == firstCellText) {
if (prevCell2.text() == secondCellText) { // 성별 값 비교
prevRowspan2++; // 중복되는 값이 있으므로 rowspan +1
$(prevCell2).attr("rowspan", prevRowspan2); // 첫 번째 row의 두 번째 cell에 rowspan 추가 (성별)
$(secondCell).remove(); // 중복 cell element 삭제
} else {
prevRowspan2 = 1;
prevCell2 = secondCell;
}
prevRowspan1++;
$(prevCell1).attr("rowspan", prevRowspan1);
$(firstCell).remove();
}
else {
prevRowspan1 = 1;
prevRowspan2 = 1;
prevCell1 = firstCell;
prevCell2 = secondCell;
}
}
}
function mergeCell3(tableId) {
// variable 정의
var first = true;
var prevRowspan1 = 1;
var prevCell1 = null;
var prevRowspan2 = 1;
var prevCell2 = null;
var prevRowspan3 = 1;
var prevCell3 = null;
// tr 모두 추출
var rows = $("#" + tableId + " > tbody").children();
for (var i = 0; i < rows.length; i++ ) {
// first row
if (first) {
prevRow = rows[i];
prevCell1 = $(prevRow).find("td").eq(0); // 1열
prevCell2 = $(prevRow).find("td").eq(1); // 2열
prevCell3 = $(prevRow).find("td").eq(2); // 3열
first = false;
continue;
}
var row = rows[i]; // row
var tdList = $(row).find("td"); // row > td 리스트
var firstCell = $(tdList).eq(0); // 첫 번째 행
var firstCellText = $(firstCell).text(); // 첫 번째 행 text 추출
var secondCell = $(tdList).eq(1); // 두 번째 행
var secondCellText = $(secondCell).text() // 두 번째 행 text 추출
var thirdCell = $(tdList).eq(2); // 두 번째 행
var thirdCellText = $(thirdCell).text() // 두 번째 행 text 추출
// 두 번째 row 부터 텍스트 비교
if (prevCell1.text() == firstCellText) { // 1열 값 비교
if (prevCell2.text() == secondCellText) { // 2열 값 비교
if (prevCell3.text() == thirdCellText) { // 3열 값 비교
prevRowspan3++; // 중복되는 값이 있으므로 rowspan +1
$(prevCell3).attr("rowspan", prevRowspan3); // 첫 번째 row의 두 번째 cell에 rowspan 추가
$(thirdCell).remove(); // 중복 cell element 삭제
} else {
prevRowspan3 = 1;
prevCell3 = thirdCell;
}
prevRowspan2++; // 중복되는 값이 있으므로 rowspan +1
$(prevCell2).attr("rowspan", prevRowspan2); // 첫 번째 row의 두 번째 cell에 rowspan 추가
$(secondCell).remove(); // 중복 cell element 삭제
} else {
prevRowspan2 = 1;
prevRowspan3 = 1;
prevCell2 = secondCell;
prevCell3 = thirdCell;
}
prevRowspan1++;
$(prevCell1).attr("rowspan", prevRowspan1);
$(firstCell).remove();
}
else {
prevRowspan1 = 1;
prevRowspan2 = 1;
prevRowspan3 = 1;
prevCell1 = firstCell;
prevCell2 = secondCell;
prevCell3 = thirdCell;
}
}
}
/* 업무 등록/수정 팝업*/
$('.work-reg').on("click",function(e){
e.stopPropagation();
let task_idx = $(this).data('idx');
popWorkTask(task_idx);
})
/* 업무 등록/수정 팝업*/
$('.work-view').on("click",function(e){
e.stopPropagation();
let task_idx = $(this).data('idx');
popWorkTaskView(task_idx);
})
/* 업무 복사 팝업*/
$('.work-duplicate').on("click",function(e){
e.stopPropagation();
let task_idx = $(this).data('idx');
popWorkTaskDuplicate(task_idx);
})
/* 업무 등록*/
$('#work-register').on("click",function(){
var formData = new FormData($('#dailyTaskInput')[0]);
let title;
$(".required").each(function(){
if(!$(this).val()){
title = $(this).parents('td').prev().text().replace(/\*/,'');
$(this).focus();
return;
}
});
if(title){
alert(title+"의 값은 필수 입니다.");
return
}
let channal = false;
$(".channal").each(function(){
if($(this).is(':checked') == true ){
channal = true;
}
});
let worker = false;
$(".worker").each(function(){
if($(this).is(':checked') == true ){
worker = true;
}
});
// 파일첨부
for (var i = 0; i < filesArr.length; i++) {
// 삭제되지 않은 파일만 폼데이터에 담기
if (!filesArr[i].is_delete) {
formData.append("attach_file[]", filesArr[i]);
}
}
// 로딩바
$('#status').fadeIn();
$('#preloader').delay(200).fadeIn();
$.ajax({
cache : false,
url : "/html/process.html", // 요기에
type : 'POST',
async: true,
data : formData,
contentType: false,
processData: false,
headers: {'cache-control': 'no-cache', 'pragma': 'no-cache'},
success : function(data) {
if(data=='Success' || data == 'Auth'){
top.opener.location.reload();
self.close();
}
else {
alert(data);
$('#status').fadeOut();
$('#preloader').delay(200).fadeOut();
}
}, // success
error : function(xhr, status) {
alert(xhr + " : " + status);
}
}); // $.ajax */
})
/* 업무 삭제*/
$('.work-delete').on("click",function(e){
e.stopPropagation();
let task_no = $(this).data('idx')
let refpage = '/plan/work_reg.html';
if(!task_no){
alert('업무관리번호가 없습니다.');
return;
}
if(!confirm('해당 업무를 삭제 하시겠습니까?')) return;
$.ajax({
cache : false,
url : "/html/process.html",
type : 'POST',
data : {task_no:task_no,mod:'del',refpage:refpage },
success : function(data) {
if(data=='Success') location.reload();
else alert(data);
}, // success
error : function(xhr, status) {
alert(xhr + " : " + status);
}
}); // $.ajax */
})
/* 업무 작업 현황 수정 - 작업자*/
$('.work-modify-worker').on("click",function(e){
e.stopPropagation();
var formData = $("#dailyTaskInput").serialize();
if(!confirm('해당 내용으로 수정 하시겠습니까?')) return;
$.ajax({
cache : false,
url : "/html/process.html",
type : 'POST',
data : formData,
success : function(data) {
if(data=='Success') location.reload();
else alert(data);
}, // success
error : function(xhr, status) {
alert(xhr + " : " + status);
}
}); // $.ajax */
})
/* 업무 등록/수정 팝업*/
$('.work-complete').on("click",function(e){
e.stopPropagation();
let task_idx = $(this).data('idx');
popWorkCompTask(task_idx);
})
/* 업무 완료처리*/
$('.set-complete').on("click",function(){
let task_idx = $(this).data('idx')
let refpage = '/plan/work_reg.html';
if(!task_idx){
alert('업무관리번호가 없습니다.');
return;
}
if(!confirm('해당업무를 완료 하시겠습니까?')) return;
$.ajax({
cache : false,
url : "/html/process.html",
type : 'POST',
data : {task_idx:task_idx,PLN_STATUS:'01',mod:'complete',refpage:refpage },
success : function(data) {
if(data=='Success') location.reload();
else alert(data);
}, // success
error : function(xhr, status) {
alert(xhr + " : " + status);
}
}); // $.ajax */
})
/**** 첨부파일 기능 [S] ****/
var fileNo = 0;
var filesArr = new Array();
/* 첨부파일 추가 */
function addFile(obj){
var maxFileCnt = 10; // 첨부파일 최대 개수
var attFileCnt = document.querySelectorAll('.filebox').length; // 기존 추가된 첨부파일 개수
var remainFileCnt = maxFileCnt - attFileCnt; // 추가로 첨부가능한 개수
var curFileCnt = obj.files.length; // 현재 선택된 첨부파일 개수
// 첨부파일 개수 확인
if (curFileCnt > remainFileCnt) {
alert("첨부파일은 최대 " + maxFileCnt + "개 까지 첨부 가능합니다.");
}
for (var i = 0; i < Math.min(curFileCnt, remainFileCnt); i++) {
const file = obj.files[i];
// 첨부파일 검증
if (validation(file)) {
// 파일 배열에 담기
var reader = new FileReader();
reader.onload = function () {
filesArr.push(file);
};
reader.readAsDataURL(file);
// 목록 추가
let htmlData = '';
htmlData += '<div id="file' + fileNo + '" class="filebox">';
htmlData += ' <p class="name">' + file.name + '</p>';
htmlData += ' <a class="delete" onclick="deleteFile(' + fileNo + ');"><i class="far fa-minus-square"></i></a>';
htmlData += '</div>';
$('.file-list').append(htmlData);
fileNo++;
} else {
continue;
}
}
// 초기화
document.querySelector("input[type=file]").value = "";
}
/* 첨부파일 검증 */
function validation(obj){
const fileTypes = [
'application/pdf', 'image/gif', 'image/jpeg', 'image/png', 'image/bmp', 'image/tif', 'application/haansofthwp', 'application/x-hwp'
, 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
];
if (obj.name.length > 100) {
alert("파일명이 100자 이상인 파일은 제외되었습니다.");
return false;
} else if (obj.size > (100 * 1024 * 1024)) {
alert("최대 파일 용량인 100MB를 초과한 파일은 제외되었습니다.");
return false;
} else if (obj.name.lastIndexOf('.') == -1) {
alert("확장자가 없는 파일은 제외되었습니다.");
return false;
}
/*else if (!fileTypes.includes(obj.type)) {
alert("첨부가 불가능한 파일은 제외되었습니다.");
return false;
}*/
else {
return true;
}
}
/* 첨부파일 삭제 */
function deleteFile(num) {
document.querySelector("#file" + num).remove();
filesArr[num].is_delete = true;
}
/* 첨부파일 삭제 및 DB */
$(document).on("click",'.file-delete',function(){
let f_id = $(this).data('idx');
let parent = $(this).parent();
let refpage = $('input[name=refpage]:eq(1)').val();
if(!f_id){
alert('파일번호가 없습니다.');
return;
}
if(!confirm('해당 파일을 삭제 하시겠습니까?')) return;
$.ajax({
cache : false,
url : "/html/process.html",
type : 'POST',
data : {f_id:f_id,mod:'file-del',refpage:refpage },
success : function(data) {
if(data=='Success') {
parent.remove();
}
else alert(data);
}, // success
error : function(xhr, status) {
alert(xhr + " : " + status);
}
}); // $.ajax */
})
/**** 첨부파일 기능 [E] ****/
/**** 대쉬보드 모달 기능 [S] ****/
// 스케듈 신규등록 화면
function openModal(date) {
if(date) $("#SET_DTTM").val(date);
$('#sidx').val('');
$('.modal-btn-del').css('display','none');
document.getElementById('myModal').style.display = 'block';
}
// 스케쥴 수정 화면
var titleORG='';
$(document).on("click",'.view-modal',function(e){
let refpage = "/html/dashboard.html";
let idx = $(this).data('idx');
$.ajax({
cache : false,
url : "/html/process.html",
type : 'POST',
dataType: 'json',
data : {sidx:idx,mod:'view',refpage:refpage },
success : function(data) {
if(data.response=='Success') {
// 일자, 구분, 제목, 내용
$('#SET_DTTM').val(data.SET_DTTM);
$('#SET_TIME').val(data.SET_TIME).prop("selected",true);
$('#SS_TYPE').val(data.SS_TYPE);
$('#TITLE').val(data.TITLE);
titleORG = data.TITLE;
$('#CONTENTS').val(data.CONTENTS);
if(idx) $('#modal-btn').text('수정');
$('.sidx').val(idx);
if(data.DEL=='Y') $('#modal-btn-del').css('display','');
$('#myModal').css('display','block');
}
else alert(data);
}, // success
error : function(xhr, status) {
alert(xhr + " : " + status);
}
}); // $.ajax */
})
function nl2br(str) {
return str.replace(/\n/g, '<br>');
}
$(document).on("click",'.view-modal2',function(e){
let refpage = "/html/dashboard.html";
let idx = $(this).data('idx');
$.ajax({
cache : false,
url : "/html/process.html",
type : 'POST',
dataType: 'json',
data : {sidx:idx,mod:'view',refpage:refpage },
success : function(data) {
if(data.response=='Success') {
console.log(data);
// 구분
let ssType = '';
switch(data.SS_TYPE){
case '01' : ssType = '공휴일'; break;
case '02' : ssType = '전체일정'; break;
case '03' : ssType = '개인일정'; break;
case '001' : ssType = '연차'; break;
case '002' : ssType = '오전반차'; break;
case '003' : ssType = '오후반차'; break;
case '004' : ssType = '기타휴가'; break;
}
// 초기 셋팅
$('#SET_TIME_AREA').css("display","none");
$('#USER_NM_AREA').css("display","none");
$('#CONTENTS_AREA').css("display","none");
$('#TITLE2').text(data.TITLE);
$('#SET_DTTM2').text(data.SET_DTTM);
$('#SS_TYPE2').text(ssType);
if(data.SET_TIME) {
$('#SET_TIME_AREA').css("display","");
$('#SET_TIME2').text(data.SET_TIME);
}
if(data.SET_TIME) {
$('#SET_TIME_AREA').css("display","");
$('#SET_TIME2').text(data.SET_TIME);
}
if(data.USER_NM && data.SS_TYPE != '01'&& data.SS_TYPE != '02') {
$('#USER_NM_AREA').css("display","");
$('#USER_NM2').text(data.USER_NM);
}
if(data.CONTENTS) {
$('#CONTENTS_AREA').css("display","");
$('#CONTENTS2').html(nl2br(data.CONTENTS));
}
$('#myModal-view').css('display','block');
}
else alert(data);
}, // success
error : function(xhr, status) {
alert(xhr + " : " + status);
}
}); // $.ajax */
})
// 스케쥴 승인취소
$(document).on("click",'.btn-agree-cancel',function(e){
e.stopPropagation();
let sidx = $(this).data('idx');
let refpage = "/html/member/member_leave.html";
let $this = $(this);
if(!confirm('승인을 취소하시겠습니까?')) return;
$.ajax({
cache : false,
url : "/html/process.html",
type : 'POST',
data : {sidx:sidx,mod:'cancel',refpage:refpage },
success : function(data) {
if(data=='Success') {
$this.removeClass('btn-danger btn-agree-cancel');
$this.addClass('btn-warning btn-agree-set');
$this.text('숭인대기');
$this.parent().parent().addClass('sch-table-bg');
}
else alert(data);
}, // success
error : function(xhr, status) {
alert(xhr + " : " + status);
}
}); // $.ajax */
})
// 스케쥴 승인
$(document).on("click",'#modal-btn-agree',function(e){
var formData = $("#leave-agree").serialize();
let $this = $(this);
$.ajax({
cache : false,
url : "/html/process.html",
type : 'POST',
data : formData,
success : function(data) {
if(data=='Success') location.reload();
else alert(data);
}, // success
error : function(xhr, status) {
alert(xhr + " : " + status);
}
}); // $.ajax */
// 모달 닫기
closeModal();
})
// 스케쥴 수정 화면
$(document).on("click",'.btn-agree-set',function(e){
e.stopPropagation();
let sidx = $(this).data('idx');
agreeModal(sidx);
})
function agreeModal(idx) {
let refpage = "/html/member/member_leave.html";
$.ajax({
cache : false,
url : "/html/process.html",
type : 'POST',
dataType: 'json',
data : {sidx:idx,mod:'view',refpage:refpage },
success : function(data) {
if(data.response=='Success') {
// 일자, 구분, 제목, 내용
$('#leave-date').text(data.SET_DTTM);
$('#leave-user').text(data.USER_NM);
$('#leave-type').text(data.TITLE);
$('#leave-count').val(data.LEAVE_COUNT);
$('#leave-contents').text(data.CONTENTS);
$('#sidx').val(idx);
if(data.DEL=='Y') $('#modal-btn-del').css('display','');
$('#myModalAgree').css('display','block');
}
else alert(data);
}, // success
error : function(xhr, status) {
alert(xhr + " : " + status);
}
}); // $.ajax */
}
// 모달창 닫기
function closeModal() {
document.getElementById("leave-register").reset();
$('.modal').css('display','none');
}
// 스케쥴 구분에 따른 설정 변경
function changeTitle() {
var typeSelect = document.getElementById('SS_TYPE');
let titleInput = document.getElementById('TITLE');
let pattern = /00/g;
// 구분값이 연차가 아닐때
if (pattern.test(typeSelect.value) === false) {
titleInput.value = titleORG;
titleInput.readOnly = false;
$('#sch-member').css('display','none');
$('#sch-time').css('display','');
}
// 구분값이 연차일때
else {
titleInput.value = typeSelect.options[typeSelect.selectedIndex].text;
titleInput.readOnly = true;
$('#sch-member').css('display','');
$('#sch-time').css('display','none');
}
}
// 스케쥴 등록
function submitSchedule() {
var formData = $("#leave-register").serialize();
let setDate = $("#SET_DTTM").val();
let setTitle = $("#TITLE").val();
if(!setDate){
alert('날짜를 입력해 주세요.');
return;
}
if(!setTitle){
alert('제목을 입력해 주세요.');
return;
}
$.ajax({
cache : false,
url : "/html/process.html",
type : 'POST',
data : formData,
success : function(data) {
if(data=='Success') location.reload();
else alert(data);
}, // success
error : function(xhr, status) {
alert(xhr + " : " + status);
}
}); // $.ajax */
// 모달 닫기
closeModal();
}
// 스케쥴 삭제
function submitFormDel() {
let refpage = "/html/dashboard.html";
let idx = $('#sidx').val();
$.ajax({
cache : false,
url : "/html/process.html",
type : 'POST',
data : {sidx:idx,mod:'del',refpage:refpage },
success : function(data) {
if(data=='Success') location.reload();
else alert(data);
}, // success
error : function(xhr, status) {
alert(xhr + " : " + status);
}
}); // $.ajax */
// 모달 닫기
closeModal();
}
/**** 대쉬보드 모달 기능 [E] ****/
/**** 회원 로그인 - 최고관리자 [S] ****/
$('.member-id').on("click",function(){
let refpage = "/getAdmin";
let midx = $(this).data('id');
if(midx) {
$.ajax({
cache: false,
url: "/html/process.html",
type: 'POST',
data: {midx: midx, refpage: refpage},
success: function (data) {
if (data == 'Success') location.href = "/";
else alert(data);
}, // success
error: function (xhr, status) {
alert(xhr + " : " + status);
}
}); // $.ajax */
}
});
/**** 회원 로그인 - 최고관리자 [E] ****/
/* ------------------------------
SCREENFULL JS
------------------------------ */
$('.screenfull-btn').on('click', function(){
if (screenfull.enabled) {
screenfull.toggle();
}
return false;
});